Small improvements to the docs
This commit is contained in:
@@ -4,12 +4,12 @@ description: Provide protocol logic using the ethereum virtual machine
|
||||
|
||||
# Ethereum: Solidity
|
||||
|
||||
### Swap
|
||||
## Swap/exchange protocol
|
||||
|
||||
To integrate an EVM exchange protocol the [ISwapAdapter.sol ](https://github.com/propeller-heads/propeller-protocol-lib/blob/main/evm/interfaces/ISwapAdapter.sol)should be implemented. Additionally a manifest file is required that summarises some metadata about the protocol.
|
||||
|
||||
{% hint style="info" %}
|
||||
Although the interface is specified for Solidity, you are not limited to writing the adapater contract in solidity. We can use any compiled evm bytecode. So if you prefer e.g. Vyper you are welcome to implement the interface using vyper. Unfortunately we do not provide all the tooling for vyper contracts yet, but you can certainly submit compiled vyper byte code.
|
||||
Although the interface is specified for Solidity, you are not limited to writing the adapater contract in Solidity. We can use any compiled evm bytecode. So if you prefer e.g. Vyper, you are welcome to implement the interface using Vyper. Unfortunately we do not provide all the tooling for Vyper contracts yet, but you can certainly submit compiled Vyper byte code.
|
||||
{% endhint %}
|
||||
|
||||
The manifest file contains information about the author, as well as additional static information about the protocol and how to test the current implementation. The file below lists all valid keys.
|
||||
@@ -22,9 +22,10 @@ author:
|
||||
|
||||
# Protocol Constants
|
||||
constants:
|
||||
# The minimum gas usage of the protocol, excluding any token transfers
|
||||
# The minimum gas usage of a swap using the protocol, excluding any token transfers
|
||||
protocol_gas: 30000
|
||||
# Minimum capabilities we can expect, individual pools may extend these
|
||||
# Minimum capabilities we can expect, individual pools may extend these.
|
||||
# To learn about Capabilities, see ISwapAdapter.sol
|
||||
capabilities:
|
||||
- SellSide
|
||||
- BuySide
|
||||
@@ -32,17 +33,18 @@ constants:
|
||||
|
||||
# The files containing the adapter contract (byte)code
|
||||
contract:
|
||||
# The contract bytecode (required if no source is provided)
|
||||
# The contract runtime (i.e. deployed) bytecode (required if no source is provided)
|
||||
runtime: UniswapV2SwapAdapter.bin
|
||||
# If you submit the source our CI can generate the bytecode
|
||||
source: UniswapV2SwapAdapter.sol
|
||||
|
||||
# Deployment instances used to generate chain specific bytecode.
|
||||
# Deployment instances used to generate chain-specific bytecode.
|
||||
# Used by the runtime bytecode build script.
|
||||
instances:
|
||||
- chain:
|
||||
name: mainnet
|
||||
id: 0
|
||||
# Arguments passed to the constructor when building the contract
|
||||
arguments:
|
||||
- "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"
|
||||
|
||||
@@ -63,9 +65,11 @@ tests:
|
||||
|
||||
Calculates pool prices for specified amounts (optional).
|
||||
|
||||
The returned prices should include all protocol fees, in case the fee is dynamic, the returned price is expected to include the minimum fee. 
|
||||
The returned prices should be in `buyToken/sellToken` units.
|
||||
|
||||
Ideally this method should be implemented, although it is optional as the price function can be numerically estimated from the swap function. In case it is not available it should be flagged accordingly via capabilities and calling it should revert using the NotImplemented error. 
|
||||
The returned prices should include all protocol fees. In case the fee is dynamic, the returned price is expected to include the minimum fee.
|
||||
|
||||
Ideally this method should be implemented, although it is optional as the price function can be numerically estimated from the swap function. In case it is not available, it should be flagged accordingly via capabilities, and calling it should revert using the NotImplemented error.
|
||||
|
||||
The method needs to be implemented as view as this is usually more efficient and can be run in parallel.
|
||||
|
||||
@@ -82,11 +86,11 @@ function price(
|
||||
|
||||
Simulates swapping tokens on a given pool.
|
||||
|
||||
This function should be state modifying meaning it should actually execute the swap and change the state of the vm accordingly.
|
||||
This function should be state modifying, meaning it should actually execute the swap and change the state of the VM accordingly.
|
||||
|
||||
Please include a gas usage estimate for each amount. This can be achieved e.g. by using the gasleft() function.
|
||||
Please include a gas usage estimate for each amount. This can be achieved e.g. by using the `gasleft()` function.
|
||||
|
||||
The return type Trade, has a price attribute which should contain the value of price(specifiedAmount). As previously mentioned, the price function support is optional, it is valid to return a zero value for this price in that case it will be estimated numerically. To return zero please use Fraction(0, 1).
|
||||
The return type `Trade` has a price attribute which should contain the value of `price(specifiedAmount)`. As previously mentioned, the price function support is optional, it is valid to return a zero value for this price (in that case it will be estimated numerically). To return zero please use `Fraction(0, 1)`.
|
||||
|
||||
```solidity
|
||||
function swap(
|
||||
@@ -102,7 +106,7 @@ function swap(
|
||||
|
||||
Retrieves the limits for each token.
|
||||
|
||||
This method returns the maximum limits of a token that can be traded. The limit is reached when the change in the received amounts is zero or close to zero. If in doubt over estimate the limit. The swap function should not error with LimitExceeded if called with any amounts below the limit.
|
||||
This method returns the maximum amount of a token that can be traded. The limit is reached when the change in the received amounts is zero or close to zero. If in doubt, overestimate the limit. The swap function should not error with LimitExceeded if called with any amounts below the limit.
|
||||
|
||||
```solidity
|
||||
function getLimits(bytes32 poolId, OrderSide side)
|
||||
@@ -136,7 +140,7 @@ function getTokens(bytes32 poolId)
|
||||
|
||||
Retrieves a range of pool IDs.
|
||||
|
||||
_Mainly used for testing it is alright to not return all available pools here. Nevertheless this is useful to test against the substreams implementation. If implemented it safes time writing custom tests._
|
||||
_Mainly used for testing. It is alright to not return all available pools here. Nevertheless, this is useful to test against the substreams implementation. If implemented, it saves time writing custom tests._
|
||||
|
||||
```solidity
|
||||
function getPoolIds(uint256 offset, uint256 limit)
|
||||
|
||||
Reference in New Issue
Block a user