The protocol's price adjustment mechanism for USD-to-asset swaps contains a critical flaw in its market-making logic. When vaults hold excess collateral, users face higher prices (premiums) for asset withdrawals, while debt-laden vaults offer discounted prices - exactly opposite to sound market-making principles. This inverted pricing model creates a feedback loop where struggling vaults become more unstable through increased withdrawals, while healthy vaults accumulate unnecessary collateral.
The fulfillSwap function in the protocol uses getAmountOfAssetOut to calculate swap outputs, which applies a premium/discount factor based on the vault's debt/TVL ratio. The current implementation in UsdTokenSwapConfig.getPremiumDiscountFactor() has inverted logic:
In the current implementation, vaults with outstanding debt (debt > 0) have a factor calculated as UD60x18_UNIT + pdCurveYX18, which results in a value greater than 1. This means users receive more assets for their USD, creating an incentive to withdraw additional assets from already indebted vaults.
Conversely, when a vault has excess collateral (debt < 0), the factor is determined as UD60x18_UNIT - pdCurveYX18, resulting in a value less than 1. As a result, users receive fewer assets for their USD, discouraging the withdrawal of surplus collateral from overcollateralized vaults.
However, the intended behavior should be the opposite: when a vault is in debt (premium scenario), users should receive fewer assets per USD, effectively paying more USD per asset. In contrast, when a vault holds excess collateral (discount scenario), users should receive more assets per USD, allowing them to pay less USD per asset.
HIGH. The inverted premium and discount logic creates systemic risks:
Indebted vaults become more indebted due to increased asset withdrawals
Overcollateralized vaults accumulate excessive collateral
Manual Review
Reverse the premium and discount logic in 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.