OdosChain

Trait OdosChain 

Source
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§

Source

fn lo_router_address(&self) -> OdosChainResult<Address>

Get the Limit Order V2 router address for this chain

§Returns
  • Ok(Address) - The LO router contract address
  • Err(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()?;
Source

fn v2_router_address(&self) -> OdosChainResult<Address>

Get the V2 router address for this chain

§Returns
  • Ok(Address) - The V2 router contract address
  • Err(OdosChainError) - If the chain is not supported or address is invalid
§Example
use odos_sdk::OdosChain;
use alloy_chains::NamedChain;

let address = NamedChain::Mainnet.v2_router_address()?;
Source

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 address
  • Err(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()?;
Source

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

Source

fn supports_lo(&self) -> bool

Check if this chain supports Odos Limit Order

§Returns

true if LO is supported on this chain

Source

fn supports_v2(&self) -> bool

Check if this chain supports Odos V2

§Returns

true if V2 is supported on this chain

Source

fn supports_v3(&self) -> bool

Check if this chain supports Odos V3

§Returns

true if V3 is supported on this chain

Provided Methods§

Source

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);
Source

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

Source

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

Source

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

Implementations on Foreign Types§

Source§

impl OdosChain for NamedChain

Implementors§