Protocol Integration
Tycho Protocol SDK is a library to integrate liquidity layer protocols (DEXs, Staking, Lending etc.) into Tycho.
Integration Process
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
Indexing
Provide a substreams package that emits a specified set of messages. If your protocol already has a substreams package, 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.
Simulation
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 (read more here). 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.
Execution
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.
Integration Criteria
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.
Last updated