When adding liquidity to Curve AMM, fees are calculated by the following code

_fee: uint256 = self.fee * N_COINS / (4 * (N_COINS - 1))


I am guessing that division by 4 means 25% of self.fee. But why is self.fee multiplied by N_COINS / (N_COINS - 1)?

Thanks in advance.

2 Answers 2


Posting answer from Twitter

Simple derivation for the multiplier. We want 2 things:

  • Zero fee when all assets are added/removed in proportion to their balances (maintain same price)
  • Adding/removing liquidity in imbalance should be equivalent to adding/removing liquidity in balance and then swapping

enter image description here

https://twitter.com/0xa9a/status/1511392050805350402 https://demo.hedgedoc.org/_Lk3HV8WSzqVGEGSep6W9g?both


Disclaimer: I am not affiliated with Curve, so this answer is conjectural

As the number of coins in the pool increase, the larger will be the transaction cost because of the loop of L286. So I think the factor N_COINS / (4 * (N_COINS - 1)) is used to compensate for the extra gas cost in the fee.

Adjusted fee per number of coins

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.