DODO V2 designs
DODOV2Proxy, which encapsulating the bottom pools, realizing multi hops transaction routing. If a trader needs to direct use the underlying pool for trading, we have also unified definitions for different types of pools, exposing two functions for use:
sellBase to sell base token and get quote token. This function requires the trader to construct a transaction that contains two actions. The first action is to transfer the base token to the pool contract, and the second action is to use a receiving address as a parameter to trigger sellBase. Before the end, traders are advised to check the value of
receiveQuoteAmount to ensure the safe execution of the transaction.
sellQuote to sell quote token and get base token. This function also requires the trader to construct a transaction that contains two actions. The first action is to transfer the quote token to the pool contract, and the second action is to use a receiving address as a parameter to trigger sellQuote. Before the end, traders are advised to check the value of
receiveBaseAmount to ensure the safe execution of the transaction.
DODO V2 also provides a view version of these two functions. View functions can be executed without sending transactions and they help users estimate prices before spending gas. ps: the incoming parameters is the address of the trader
How to integrate DODOProxy and use your own contract to trade with DODOV1 and DODOV2 pool: DODOProxyIntegrate.sol
How to off-chain calculate the trading results of DODOV1 or DODOV2 pool using PMM algorithm: pmmOffchainCalc.ts
DODO V2 designs two types of pools, including DODO vending machine and DODO private pools.
DODOV2Proxy encapsulates the liquidity management functions. And also people can directly interact with the underly pools.
Anyone can participate in DODO vending machine, and due to the flexible design, the same trading pair can have more than one pools with different parameter settings. When user chooses the pool to participate, base and quote token will be injected according to the current ration. and user get
shares assets minted by the pool.
represents the lp's share of the asset pool. It is an erc20 token and can be traded freely. Each DODO vending machine corresponds to a kind ofshares
buyShares to inject liquidity into the pool. User needs to construct a transaction consisting of two actions. The first action is to deposit tokens in the pool according to the current base and quote ratio. The second action is to use a receiving address as the parameter to trigger
buyShares. Before the end, it is recommended checking the amount of the two actual deposited values of
quoteInput to ensure the safe execution of the transaction.
sellShares to remove liquidity from the pool. User can directly call the corresponding function of the pool to execute the transaction. The reqeust parameters include the amount of shares removed, the receiving address, baseMinAmount used for slippage protection (the minimum received base amount), quoteMinAmount (the minimum received quote amount), data is generally set to empty, if it's not, the external contract call will be executed at the end to achieve additional functions such as the conversion from WETH to ETH, and deadline is the effective time after the transaction is sent, it will automatically fail when overtime aiming to protect the safe execution of the transaction.
DODO Private Pool is controlled by a single LP (market-making agency or project party, etc.), They has the authority to modify the pool's parameters dynamically and control the access of assets freely, which provides sufficient flexibility for the on-chain market-making strategy. The private pool has an owner, and the owner can set operator to realize the permission control.
The operator of the private pool can trigger the reset function in
DODOV2Proxy to realize market making directly.
Described as follows:
- dppAddress：the address of the private pool
- paramList：Array includes newLpFeeRate, newI (base amount/quote amount,decimals = 18 - base token decimal + quote token decimal), newK (0 equals to sell tokens in a constant price and 1 equals to bonding curve like uniswap)
- flag: mark of wrapping ETH or unwrapping WETH. (0 presents no conversion, 1 presents injecting base token wrapping to WETH, 2 presents injecting quote token wrapping to WETH, 3 presents removing base token unwrapping to ETH, 4 presents removing quote token unwrapping to ETH)
- minBaseReserve && minQuoteReserve: When the owener modifies the pool's parameters, sometimes may cause the pool's price changing. At this time, robot may preempt the arbitrage. Therefore, after these two parameters are set well, the transaction will fail if the amount of existing base and quote is smaller than the passed value, which is a protective mechanism. We recommend pool's owner to set with each transaction.
The platform also provides a method for the owner to trigger the reset function at the bottom level, which is achieved by triggering the private pool's admin contract (the admin contract corresponds to the address of the owner parameter of the private pool)
If the owner trigger directly, operator can be empty. Other parameters descriptions are the same as above.
Developers can fetch metadata from
DODO Private Pool Factory &&
DODO Vending Machine Factory &&
DODO Stable Pool Factory.
getDODOPool, user need to distinguish base and quote as parameters in order, while for
getDODOPoolBidirection, no need to distinguish base or quote token. And function will return two pool lists, which correspond to the token0 as base, the other is token1 as base. For
getDODOPoolByUser will return the pool list under the user.
At the same time, we provide real-time monitoring of DODO platform's creation and removal events, which makes it easier to maintain the latest pool lists under the platform in real time
RemoveDVM are events from
DODO Vending Machine Factory,
RemoveDPP are events from
DODO Private Pool Factory, and
RemoveDSP are events from
DODO Stable Pool Factory,