pods-finance / contracts

The easiest way to hedge crypto.
https://app.pods.finance
Other
54 stars 12 forks source link

QSP-34 mAB Could Be A Zero Multiplier #121

Closed ggviana closed 3 years ago

ggviana commented 3 years ago

Severity: Undetermined

File(s) affected: contracts/amm/AMM.sol

Description: When users remove liquidity, their returns are adjusted by a multiplier. Specifically, the mAB multiplier defines how much B tokens can a user remove for each A token initially deposited by the same user. In _getMultipliers, if mAA is set as in L596 (say mAA > 1 => there is more A tokens that what the pool owes), mBB is set to:

totalTokenBWithPrecision.div(deamortizedTokenBBalance

in L602, and say mBB > 1. All indicators are healthy, as there are more tokens than debt. Still, in 607, mAB will be zero (this can be verified if one expand the whole equation).

Recommendation: Verify whether the described behavior is indeed intended, and if so, document if properly in the code. If not, adjust the mathematical model and its implementation.

Robsonsjre commented 3 years ago

This is expected behavior.