Execution Venues
How to integrate Tycho in different execution venues.
Cow Protocol
To solve orders on CoW Protocol, you'll need to prepare your solution following specific formatting requirements.
First, initialize the encoder:
let encoder = TychoRouterEncoderBuilder::new()
.chain(Chain::Ethereum)
.build()
.expect("Failed to build encoder");
Since you are not passing the swapper_pk
, the TychoRouter
will use a transferFrom
to transfer the token in as opposed to using permit2.
When solving for CoW Protocol, you need to return a Solution object that contains a list of interactions to be executed in sequence.
To solve with the Tycho Router you only need one custom interaction where:
callData
is the full encoded method calldata using the encoded solution returned fromencoder.encode_solutions(...)
allowances
is a list with one entry where the allowance for the token in and amount in is set for spender to be the Tycho Router. This is necessary for thetransferFrom
to work.
Uniswap X
To help you fill Uniswap X orders using Tycho, we provide an example UniswapXFiller
contract. This contract is a starting point—you should adapt it to fit your use case.
The example contract:
Inherits from
IReactorCallback
and implementsexecute
andreactorCallback
Calls the
TychoRouter
fromreactorCallback
to execute swapsUses standard token approvals to allow
TychoRouter
to pull funds; you can replace this with Permit2 easily (you need to change the encoding accordingly though).Approves the UniswapX Reactor contract to transfer tokens out after execution
Only supports solving one order at a time; you can extend it to support batching by implementing
executeBatch
and updatingreactorCallback
Can safely hold tokens. The Uniswap X Reactor only transfers out the required amount. If your solution is more efficient, any surplus stays in the filler contract
Is not audited—use at your own risk
See how to encode the callbackData
for TychoRouter
here.
For more on filling Uniswap X orders, see their docs and examples.
Other competition venues
For other venues, like 1inch Fusion, please contact us.
Last updated