pub trait OdosChain {
// Required methods
fn lo_router_address(&self) -> OdosChainResult<Address>;
fn v2_router_address(&self) -> OdosChainResult<Address>;
fn v3_router_address(&self) -> OdosChainResult<Address>;
fn supports_odos(&self) -> bool;
fn supports_lo(&self) -> bool;
fn supports_v2(&self) -> bool;
fn supports_v3(&self) -> bool;
// Provided methods
fn router_availability(&self) -> RouterAvailability { ... }
fn try_lo_router_address(&self) -> Option<Address> { ... }
fn try_v2_router_address(&self) -> Option<Address> { ... }
fn try_v3_router_address(&self) -> Option<Address> { ... }
}Expand description
Trait for chains that support Odos protocol
This trait provides a type-safe way to access Odos router addresses for supported blockchain networks, integrating seamlessly with the Alloy ecosystem.
§Examples
use odos_sdk::OdosChain;
use alloy_chains::NamedChain;
// Get router addresses
let lo_router = NamedChain::Mainnet.lo_router_address()?;
let v2_router = NamedChain::Mainnet.v2_router_address()?;
let v3_router = NamedChain::Mainnet.v3_router_address()?;
// Check router support
assert!(NamedChain::Mainnet.supports_odos());
assert!(NamedChain::Mainnet.supports_lo());
assert!(NamedChain::Mainnet.supports_v2());
assert!(NamedChain::Mainnet.supports_v3());
// Get router availability
let availability = NamedChain::Mainnet.router_availability();
assert!(availability.limit_order && availability.v2 && availability.v3);Required Methods§
Sourcefn lo_router_address(&self) -> OdosChainResult<Address>
fn lo_router_address(&self) -> OdosChainResult<Address>
Get the Limit Order V2 router address for this chain
§Returns
Ok(Address)- The LO router contract addressErr(OdosChainError)- If the chain doesn’t support LO or address is invalid
§Example
use odos_sdk::OdosChain;
use alloy_chains::NamedChain;
let address = NamedChain::Mainnet.lo_router_address()?;Sourcefn v2_router_address(&self) -> OdosChainResult<Address>
fn v2_router_address(&self) -> OdosChainResult<Address>
Sourcefn v3_router_address(&self) -> OdosChainResult<Address>
fn v3_router_address(&self) -> OdosChainResult<Address>
Get the V3 router address for this chain
V3 uses the same address across all supported chains, following CREATE2 deterministic deployment.
§Returns
Ok(Address)- The V3 router contract addressErr(OdosChainError)- If the chain is not supported or address is invalid
§Example
use odos_sdk::OdosChain;
use alloy_chains::NamedChain;
let address = NamedChain::Mainnet.v3_router_address()?;Sourcefn supports_odos(&self) -> bool
fn supports_odos(&self) -> bool
Check if this chain supports Odos protocol
§Returns
true if any router (LO, V2, or V3) is supported on this chain
Sourcefn supports_lo(&self) -> bool
fn supports_lo(&self) -> bool
Sourcefn supports_v2(&self) -> bool
fn supports_v2(&self) -> bool
Sourcefn supports_v3(&self) -> bool
fn supports_v3(&self) -> bool
Provided Methods§
Sourcefn router_availability(&self) -> RouterAvailability
fn router_availability(&self) -> RouterAvailability
Get router availability for this chain
§Returns
A RouterAvailability struct indicating which routers are available
§Example
use odos_sdk::OdosChain;
use alloy_chains::NamedChain;
let availability = NamedChain::Mainnet.router_availability();
assert!(availability.limit_order);
assert!(availability.v2);
assert!(availability.v3);Sourcefn try_lo_router_address(&self) -> Option<Address>
fn try_lo_router_address(&self) -> Option<Address>
Try to get the LO router address without errors
§Returns
Some(address) if supported, None if not supported
Sourcefn try_v2_router_address(&self) -> Option<Address>
fn try_v2_router_address(&self) -> Option<Address>
Try to get the V2 router address without errors
§Returns
Some(address) if supported, None if not supported
Sourcefn try_v3_router_address(&self) -> Option<Address>
fn try_v3_router_address(&self) -> Option<Address>
Try to get the V3 router address without errors
§Returns
Some(address) if supported, None if not supported