pub struct V3Router<N: Network = Ethereum, P: Provider<N> = RootProvider<N>> { /* private fields */ }Expand description
The V3 SOR Router contract.
This router is generic over the network type, allowing it to work with both standard Ethereum networks and OP-stack networks (Optimism, Base, Fraxtal).
§Type Parameters
N: The network type (defaults toEthereum). Useop_alloy_network::Optimismfor OP-stack chains.P: The provider type.
§Example
ⓘ
use odos_sdk::V3Router;
use alloy_network::Ethereum;
use alloy_provider::ProviderBuilder;
// Standard Ethereum usage
let provider = ProviderBuilder::new().connect_http("https://eth.llamarpc.com".parse()?);
let router: V3Router<Ethereum, _> = V3Router::new(address, provider);
// OP-stack usage (requires op-stack feature)
#[cfg(feature = "op-stack")]
{
use odos_sdk::op_stack::Optimism;
let op_provider = ProviderBuilder::new()
.network::<Optimism>()
.connect_http("https://mainnet.base.org".parse()?);
let op_router: V3Router<Optimism, _> = V3Router::new(address, op_provider);
}Implementations§
Source§impl<N: Network, P: Provider<N>> V3Router<N, P>
impl<N: Network, P: Provider<N>> V3Router<N, P>
Sourcepub async fn liquidator_address(&self) -> Result<Address, Error>
pub async fn liquidator_address(&self) -> Result<Address, Error>
Returns the liquidator address.
Sourcepub fn build_swap_router_funds_call(
&self,
input_token_info: inputTokenInfo,
output_token_info: outputTokenInfo,
inputs: &SwapInputs,
from: Address,
) -> CallBuilder<&P, PhantomData<swapRouterFundsCall>, N>
pub fn build_swap_router_funds_call( &self, input_token_info: inputTokenInfo, output_token_info: outputTokenInfo, inputs: &SwapInputs, from: Address, ) -> CallBuilder<&P, PhantomData<swapRouterFundsCall>, N>
Builds a swap call using router funds.
Sourcepub fn transfer_router_funds(
&self,
from: Address,
token: Address,
amount: U256,
output_recipient: Address,
) -> CallBuilder<&P, PhantomData<transferRouterFundsCall>, N>
pub fn transfer_router_funds( &self, from: Address, token: Address, amount: U256, output_recipient: Address, ) -> CallBuilder<&P, PhantomData<transferRouterFundsCall>, N>
Transfers router funds to a recipient.
Trait Implementations§
Auto Trait Implementations§
impl<N, P> Freeze for V3Router<N, P>where
P: Freeze,
impl<N, P> RefUnwindSafe for V3Router<N, P>where
P: RefUnwindSafe,
N: RefUnwindSafe,
impl<N, P> Send for V3Router<N, P>
impl<N, P> Sync for V3Router<N, P>
impl<N, P> Unpin for V3Router<N, P>
impl<N, P> UnwindSafe for V3Router<N, P>where
P: UnwindSafe,
N: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more