Protocol Integration
Last updated
Last updated
is a library to integrate liquidity layer protocols (DEXs, Staking, Lending etc.) into Tycho.
Integrating with Tycho requires three components:
Indexing: Provide the protocol state/data needed for simulation and execution
Simulation: Implement the protocol's logic for simulations
Execution: Define how to encode and execute swaps against your protocol
Provide a package that emits a specified set of messages. If your protocol already has a , you can adjust it to emit the required messages.
Important: Simulation happens entirely off-chain. This means everything needed during simulation must be explicitly indexed.
Tycho offers two integration modes:
VM Integration: Implement an adapter interface in a language that compiles to VM bytecode. This SDK provides a Solidity interface (). Simulations run in an empty VM loaded only with the indexed contracts, storage and token balances.
Native Rust Integration: Implement a Rust trait that defines the protocol logic. Values used in this logic must be indexed as state attributes.
To enable swap execution, implement:
SwapEncoder: A Rust struct that formats input/output tokens, pool addresses, and other parameters correctly for the Executor
contract.
Executor: A Solidity contract that handles the execution of swaps over your protocol's liquidity pools.
Tycho supports many protocol designs, however certain architectures present indexing challenges.
Before integrating, consider these limitations:
Soon to be supported:
Protocols that interface with external contracts during operations Tycho should support (i.e swap, price and limit calculations etc.). External contracts are those not deployed by the protocol's factories. ERC20 token contracts are exempt from this restriction.
Not supported:
Protocols where any operation that Tycho should support requires off-chain data, such as signed prices.