Skip to main content
Version: 2.0.2

DEX protocol

DEX protocols need to follow a standardized interface and have to implement these functions. The main goal for this is to make it easy to swap in and out different protocols for agents or environments without having to change code.

To create a dex protocol, make a dex.py file in the directory of your protocol and create a class that implements the DexInterface. From there you only need to implement the required function using the standardized format.

Functions

__init__(self, contracts: List[ContractInterface], tokens: List[TokenInterface], settings: dict, metric_helper: MetricHelperInterface)
initialize(self, agent_addresses: List[str])

swap(self,
from_address: str,
token0: str,
token1: str,
amount: int
)

swap_output(self,
from_address: str,
token0: str,
token1: str,
amount: int
)

quote_input(self,
token0: str,
)

open_position(self,
from_address: str,
pool: str,
amount: int
)

add_liquidity(self,
from_address: str,
pool: str,
amount: int
)

remove_liquidity(self,
from_address: str,
pool: str,
amount: int
)