VM Integration
This page describes the interface required to implement your protocol logical component.
To create a VM integration, provide a manifest file and an implementation of the corresponding adapter interface.
Example Implementations
The following exchanges are integrated with the VM approach:
Balancer V2 (see
/evm/src/balancer-v2
)
Step-by-step Guide
Install prerequisites
Install Foundry, start by downloading and installing the Foundry installer:
then start a new terminal session and run
Clone the Tycho Protocol SDK:
Install dependencies:
Understanding the ISwapAdapter
Read the documentation of the Ethereum Solidity interface. It describes the functions that need to be implemented and the manifest file.
Additionally, read through the docstring of the ISwapAdapter.sol interface and the ISwapAdapterTypes.sol interface, which defines the data types and errors the adapter interface uses. You can also generate the documentation locally and look at the generated documentation in the ./docs
folder:
Implementing the ISwapAdapter interface
Your integration should be in a separate directory in the evm/src
folder. Start by cloning the template directory:
Implement the ISwapAdapter
interface in the ./evm/src/<your-adapter-name>.sol
file. See Balancer V2 implementation for reference.
Testing your implementation
Set up test files:
Copy
evm/test/TemplateSwapAdapter.t.sol
Rename to
<your-adapter-name>.t.sol
Write comprehensive tests:
Test all implemented functions.
Use fuzz testing (see Foundry test guide, especially the chapter for Fuzz testing)
Reference existing test files:
BalancerV2SwapAdapter.t.sol
Configure fork testing (run a local mainnet fork against actual contracts and data):
Set
ETH_RPC_URL
environment variableUse your own Ethereum node or services like Infura
Run the tests with
Last updated