| Crates.io | openoc |
| lib.rs | openoc |
| version | 0.1.1 |
| created_at | 2026-01-17 09:20:36.027713+00 |
| updated_at | 2026-01-22 21:40:49.166728+00 |
| description | Unofficial Rust client for the OpenOcean DEX aggregator API |
| homepage | |
| repository | https://github.com/yldfi/yldfi-rs/tree/main/crates/openoc |
| max_upload_size | |
| id | 2050182 |
| size | 71,850 |
Unofficial Rust client for the OpenOcean DEX Aggregator API
[dependencies]
openoc = "0.1"
tokio = { version = "1", features = ["full"] }
use openoc::{Client, Chain, QuoteRequest};
#[tokio::main]
async fn main() -> Result<(), openoc::Error> {
let client = Client::new()?;
// Get a quote for swapping 1 ETH to USDC
let request = QuoteRequest::new(
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // Native ETH
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
"1", // 1 ETH (human readable)
).with_gas_price("30000000000");
let quote = client.get_quote(Chain::Eth, &request).await?;
println!("Output: {} USDC", quote.out_amount);
Ok(())
}
use openoc::{Client, Chain, SwapRequest};
#[tokio::main]
async fn main() -> Result<(), openoc::Error> {
let client = Client::new()?;
let request = SwapRequest::new(
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"1", // Human readable amount
"0xYourWalletAddress",
).with_slippage(1.0);
let swap = client.get_swap_quote(Chain::Eth, &request).await?;
// Ready to sign and send
println!("To: {}", swap.to);
println!("Data: {}", swap.data);
println!("Value: {}", swap.value);
Ok(())
}
Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche, Fantom, Gnosis, zkSync Era, Linea, Scroll, Mantle, Blast, Solana, Sui
MIT