Ethereum: Solidity
Provide protocol logic using the ethereum virtual machine
Last updated
Provide protocol logic using the ethereum virtual machine
Last updated
To integrate an EVM exchange protocol:
Implement the interface.
Create a manifest file summarizing the protocol's metadata.
While we specify the interface for Solidity, you can use any compiled EVM bytecode. If you prefer Vyper, feel free to implement the interface using it. You can submit compiled Vyper bytecode, although we don't yet provide all the tooling for Vyper contracts.
The manifest file contains author information and additional static details about the protocol and its testing. Here's a list of all valid keys:
Calculates pool prices for specified amounts.
Return prices in buyToken/sellToken units.
Include all protocol fees (use minimum fee for dynamic fees).
Implement this method as view
for efficiency and parallel execution.
If you don't implement this function, flag it accordingly in capabilities and make it revert using the NotImplemented
error.
While optional, we highly recommend implementing this function. If unavailable, we'll numerically estimate the price function from the swap function.
Simulates token swapping on a given pool.
Execute the swap and change the VM state accordingly.
Include a gas usage estimate for each amount (use gasleft()
function).
Return a Trade
struct with a price
attribute containing price(specifiedAmount)
.
If the price function isn't supported, return Fraction(0, 1)
for the price (we'll estimate it numerically).
Retrieves token trading limits.
Return the maximum tradeable amount for each token.
The limit is reached when the change in received amounts is zero or close to zero.
Overestimate the limit if in doubt.
Ensure the swap function doesn't error with LimitExceeded
for amounts below the limit.
Retrieves pool capabilities.
Retrieves tokens for a given pool.
We mainly use this for testing, as it's redundant with the required substreams implementation.
Retrieves a range of pool IDs.
We mainly use this for testing. It's okay not to return all available pools here.
This function helps us test against the substreams implementation.
If you implement it, it saves us time writing custom tests.