🔹Mechanism
Last updated
Last updated
They consist of pairs of tokens locked into smart contracts, enabling users to trade one token for another without relying on an order book or centralized intermediaries.
Each pool contains reserves of two tokens, maintaining a specific ratio determined at the time of creation. For instance, in an INJ/USDT pool, both Injective (INJ) and Tether (USDT) are deposited in a predefined ratio, and the pool's smart contract calculates the exchange rate between these tokens.
Users contribute to these pools by depositing an equal value of both tokens, receiving liquidity provider (LP) tokens in return. These LP tokens represent their share of the pool and entitle holders to a portion of the trading fees generated on the platform.
The pool's automated market maker (AMM) mechanism adjusts token prices based on the ratio of assets in the pool. When someone swaps tokens, the trade directly impacts the pool's balance, leading to a change in the token prices according to the constant product formula
where x and y are the quantities of the tokens in the pool, and k is a constant value that remains unchanged.
In order to preserve the constant product invariant, Dojoswap will make prices that ensure the product of resultant balances of the pool is as close as possible to product calculated prior to the trade. With X being the current balance of the pool’s source asset and and Y being that of the target asset:
To determine the proper value of Bout given the trader’s offered asset Ain :
Dojoswap is able to execute trades with only the current balances of the pool and the number of incoming tokens. The market price is calculated by dividing the number of pool’s target token into the source asset (also called the pool ratio). The spread between the executed and the expected trade is:
When a pool has large balances of tokens on both sides from liquidity providers, the spread becomes smaller and helps the pool execute closer to its reported price of Y/X .