Auriswap’s liquidity pools operate on the core principles of decentralized automated market making, ensuring that token swaps are executed efficiently without the need for traditional order books. Liquidity providers (LPs) contribute two assets to a pool, allowing traders to swap between these tokens at market-driven prices. The protocol uses a constant product formula to maintain the balance of assets within each pool, ensuring that the product of the reserves always remains constant after each trade.
Each pair follows the constant product formula:
x * y = k
where:
x
: Reserve of token A
y
: Reserve of token B
k
: A constant that maintains the pool's balance
The invariant k
ensures that any swap or liquidity change in the pool maintains the product of reserves, thereby establishing a predictable price curve. Any deviation from this invariant indicates that a trade has occurred, shifting the relative price of the tokens.
Each trade on Auriswap incurs a 0.30% fee, which is distributed to liquidity providers proportional to their share in the pool. Unlike traditional exchanges where fees are collected centrally, Auriswap’s fee mechanism automatically integrates fee earnings into the pool, increasing the overall liquidity and value of the LP tokens.
Fee Adjustment Formula:
Where:
This formula guarantees that the swap always maintains the invariant by correctly adjusting the reserves to account for the trading fee.
This formula guarantees that the swap always maintains the invariant by correctly adjusting the reserves to account for the trading fee.
When a new liquidity pool is created, the initial share of liquidity tokens must be carefully computed. In Auriswap, the supply of liquidity tokens is directly proportional to the value of the reserves deposited. Each liquidity provider is issued LP tokens representing their proportional share in the pool.
For Existing Pools: When a new liquidity provider deposits tokens into an existing pool, the number of liquidity tokens minted is based on the current pool share:
Where:
For New Pools (First-Time Depositors): If the pool is new and has no existing liquidity, the formula for minting liquidity tokens is modified to account for the initial ratio of deposits:
This ensures that the initial supply of liquidity tokens is the geometric mean of the deposited amounts. For example, if a liquidity provider deposits 100 units of Token A and 10,000 units of Token B, the initial liquidity tokens issued would be:
The price for a swap on Auriswap is determined by the ratio of reserves:
where xxx and yyy are the current reserves of Token A and Token B. Since trades impact the reserve balances, the spot price changes dynamically based on the demand and supply in the pool.
Time-Weighted Average Price (TWAP):
To prevent price manipulation and provide accurate pricing information, Auriswap integrates a time-weighted average price (TWAP) oracle, inspired by Uniswap V2. The TWAP formula is computed as:
Where
This TWAP oracle makes it difficult for attackers to manipulate prices within a single block, ensuring robust pricing data for external contracts.
Every liquidity provider receives LP tokens that represent their share in the pool. The value of these tokens grows over time as fees accumulate and trading occurs. LPs can redeem these tokens at any time to withdraw their proportional share of the reserves, including any accrued fees.
Example Calculation:
If a liquidity provider holds 20% of the pool’s LP tokens and the pool has 1,000 Token A and 10,000 Token B:
Their share of the reserves would be:
Token A: 0.20 × 1,000 = 200
Token B: 0.20 × 10,000 = 2,000
When removing liquidity, the provider will receive their proportional share minus a small amount burned as part of the platform’s withdrawal fee.
= Initial reserve of Token A.
= Initial reserve of Token B.
= New reserve of Token A after the trade.
= New reserve of Token B after the trade.
= Amount of Token A added during the swap.
= Amount of Token B added during the swap.
= Number of liquidity tokens minted.
= Amount of Token A added by the new liquidity provider.
= Initial amount of Token A in the pool.
= Total supply of liquidity tokens before the deposit.
Burning Initial Shares: To prevent manipulation and ensure fair distribution, Auriswap follows Uniswap’s model of burning the first liquidity tokens minted. This mechanism minimizes the impact of small deposits and protects against potential attacks.
Example: If the initial minting results in 1,000 liquidity tokens, the first tokens will be burned, ensuring a negligible impact on the total supply.
= Cumulative prices at time .
= Cumulative prices at time .
= Time interval over which the average is measured.