The current implementation of getPremiumDiscountFactor
allow traders to withdraw more assets (a premium) when Vault is in debt and less assets(a discount) when the vault is credit. It should be the other way around.
Traders can exit the protocol and swap their usdToken
for a Vault's asset at any time. The amount of assetsOut for the given usdToken
amount is calculated by getAmountOfAssetOut.
A premium
or discount
is applied depending if Vault is in credit respectively debt.
For example if usdAmountIn is 2000 usd, price is 2000 and the factor is 1.1 the trader will get back 2000 / 2000 * 1.1 = 1.1 asset
amount.
Instead, if the factor is 0.8, the trader will receive only 2000/ 2000 * 0.8 = 0.8 amount of asset
.
A value of vaultDebtUsdX18
smaller than 0
means that the vault is in credit, while a value bigger than 0
means that the vault is in debt.
The problem is that when Vault is in credit the pdCurveYX18
is subtracted from 1 (UD60x18_UNIT
), and summed to 1 when Vault is in debt.
Traders will be penalized when vault is in credit and they will withdraw more funds than they should. This will destabilize the vault more.
The getPremiumDiscountFactor
acts as a destabilizing factor, allowing traders to withdraw more funds than they are allowed to and in this way the vault will accumulate even more debt. Vault can get drained.
Reverse the logic from getPremiumDiscountFactor
:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.