Usage
1. Adding the Dependency
git clone https://github.com/0xMerso/tycho-orderbook-sdk sdk[dependencies]
tycho-orderbook = { path = "../sdk" } 2. Instantiate the provider and build an orderbook
let network = networks.clone().into_iter().find(|x| x.name == name).expect("Network not found");
let mut psb = ProtocolStreamBuilder::new(&network.tycho, chain)
.exchange::<UniswapV2State>(TychoSupportedProtocol::UniswapV2.to_string().as_str(), filter.clone(), None)
.exchange::<UniswapV3State>(TychoSupportedProtocol::UniswapV3.to_string().as_str(), filter.clone(), None)
.exchange::<UniswapV4State>(TychoSupportedProtocol::UniswapV4.to_string().as_str(), filter.clone(), Some(u4))
.auth_key(Some(key.clone()))
.skip_state_decode_failures(true)
.set_tokens(tokens.clone())
.await;
let builder = OrderbookBuilder::new(network.clone(), psb, key.clone(), tokens.clone());
match builder.build(xstate).await {
Ok(provider: OrderbookProvider) => {
[..]
}
}
3. Execution
Last updated
Was this helpful?