Swap Mechanism
1. The Trading Invariant (The "k" Constant)

Once liquidity is established in the BT/ITL pool, the protocol enables decentralized trades using the Constant Product Formula. This formula ensures that the pool remains solvent at any price level by maintaining a specific mathematical relationship between the two assets.
Every swap must satisfy the "Trading Invariant," where the product of the reserves () remains constant (excluding fees). When a trader adds one token, they must receive an amount of the other such that:
Variables defined:
: The current reserves of BT and ITL in the pool.
: The amount of BT sent to the pool by the trader.
: The amount of ITL received by the trader.
: The invariant that must remain unchanged by the trade.
2. Calculating Swap Output
Determining the exact amount of tokens a user receives depends on which asset they are selling. The formula rearranges the invariant to solve for the "out" amount based on the "in" amount.
Selling BT for ITL
Selling ITL for BT
As the input amount ( or ) increases, the output amount follows a curved trajectory, ensuring the pool is never fully depleted.
3. Trading Fees & LP Incentives
To reward Liquidity Providers (LPs) for their capital, the protocol levies a fixed fee of 0.3% () on every trade. This fee is deducted from the input amount before the swap occurs, which effectively causes the constant to grow over time as fees accumulate in the pool.
Fee Processing Steps:
Fee Calculation:
Effective Input:
Final Output Formula:
The accumulated fees remain in the pool, increasing the value of all LP tokens and providing a "yield" for those who provide liquidity.
4. Price Impact & Slippage
Every trade shifts the ratio of reserves, which directly changes the price. Price Impact is the difference between the current mid-market price and the actual execution price of the trade.
Execution Price (): Calculated as .
Slippage: As the input amount increases relative to the total reserves (), the execution price deviates further from the spot price.
Liquidity Depth: Larger reserves () are essential to minimize slippage, especially for high-volume traders.
5. Native ITL Swaps (Technical Flow)
When swapping the native ITL asset for BT, the protocol follows an atomic sequence to ensure compatibility with the smart contract pair:
Wrapping: Native ITL is wrapped into WITL (Wrapped ITL) via the Router to make it compatible with the standard token interface.
Pathing: The Router identifies the most efficient path, specifically looking for the BT/WITL Pair contract.
Execution: The swap function is called on the Pair contract, transferring the WITL in and sending the resulting BT directly to the trader’s wallet.
6. Liquidity Withdrawal (Burning LP Tokens)
Liquidity Providers can exit the pool at any time by "burning" their LP tokens to reclaim their pro-rata share of the current reserves. Because trading fees are never removed, the amount withdrawn typically exceeds the original deposit value (accrued value).
Redemption Formulas:
BT Claimed:
ITL Claimed:
This ensures that LPs receive their original principal plus their share of all accumulated trading fees generated since their initial deposit.
Last updated
