Fees
The fees are made of two parts. The regular 2% fee (base fee) and a dynamic fee.
Last updated
The fees are made of two parts. The regular 2% fee (base fee) and a dynamic fee.
Last updated
The AMM contract charges a 2% base fee (baseFee) on every trade that happens in the pool. Additionally, an exponential fee (dynamicFee) is added to the base fee to deter economic attacks.
The calculation for the dynamic fee is dependent on the size of the trade relative to the pool amount A:
Where parameter .
Disclaimer: with the current UI, users can only provide or remove liquidity equally on both sides
Since the pool is single-sided, the division of fees happens evenly among the two pools: 50% of the fees go to liquidity providers of token A and 50% of the fees go to liquidity providers of token B.
Fees are always calculated as a relation to token B amount.
The contract keeps track of the fee amount in a feePoolA and feePoolB.
The fair distribution of fees is tracked by the number of shares of each feePool a liquidity provider has.
The contract will always charge fees in token B. That means that fees will be charged slightly differently depending on the trade direction and exact input or output.
Example 1
A user wants to buy 3 options out of a pool of 30 options ( we will be usingexactOutputA
).
The contract will calculate the new option price using BS per unit.
Then it will calculate the total price given to transaction amount (50 USDC).
Then it will add to the total amount to the base 2% fee and dynamic fee:
Then the total fees get split in half (2/2) and sent to feePoolA and feePoolB in equal proportions.
Example 2
A user has 50 USDC and wants to buy all of it in options (will use exactInputB
)
The contract will calculate the new option price using BS per unit.
Before calculating the total price based on the transaction amount, the contract will calculate the total fees in the total amount of token B the user is using (50*0.04=2) and use the discounted amount (50-2=48) to calculate the total price.
The total fee gets cut in half (2/2) and sent to feePoolA and feePoolB in equal amounts.
When adding liquidity, a user is also "buying" shares offeePool
it added liquidity for. The new shares emission formula is as follows for each token pool:
base fee =
dynamic fee =
Total fees being