odos-sdk-0.22.0 has been yanked.
Odos Rust SDK
One-to-one Swap Example
use NamedChain;
use ;
use Erc20;
use ;
/// Token address of the token to swap
const TOKEN: &str = "0x4200000000000000000000000000000000000006";
/// Top holder of the token at time of writing according to https://etherscan.io/token/0x4200000000000000000000000000000000000006#balances
const HOLDER: &str = "0xb2cc224c1c9feE385f8ad6a55b4d94E92359DC59";
/// Odos v2 router address on Base
const ROUTER: &str = "0x19cEeAd7105607Cd444F5ad10dd51356436095a1";
/// Recipient of the swap
const RECIPIENT: &str = "0x83384D138420436f4b0DaE97b02002dd5011a7D9";
const USDC: &str = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
let chain = Base;
let token_address = TOKEN..unwrap;
let token_contract = new;
let balance = token_contract.balance_of.await?;
let quote_request = builder
.chain_id
.input_tokens
.output_tokens
.slippage_limit_percent
.user_addr
.compact
.simple
.referral_code
.disable_rfqs
.build;
let sor_client = new;
let quote = sor_client.get_swap_quote.await.unwrap;
let token_contract = new;
// Approve the router to spend the token on behalf of the signer
let pending_tx = token_contract
.approve
.await
.unwrap;
let receipt = pending_tx.get_receipt.await.unwrap;
// Assert the transaction was successful
assert!;
let swap_params = builder
.chain
.router_address
.signer_address
.output_recipient
.token_address
.token_amount
.path_id
.build;
let tx_request = sor_client
.build_base_transaction
.await
.unwrap;
// User can apply custom gas parameters to the transaction as they see fit
let pending_tx = signer_provider.send_transaction.await.unwrap;
let receipt = pending_tx.get_receipt.await.unwrap;
// Assert the transaction was successful
assert!;