Submitted by carrotsmuggler, also found by peanuts, pontifex, adam-idarrha, d3e4, Al-Qa-qa, amaron (1, 2), 0xblack_bird, foxb868, Infect3d, windhustler, 0xSecuri, jesjupyter, forgebyola, Ryonen, AM, KupiaSec, wangxx2026, SpicyMeatball, nnez, itsabinashb, cu5t0mpeo, zhuying, T1MOH, VAD37, darksnow (1, 2), Dudex_2004, Jorgect, 0xnev, AlexCzm, 0xAlix2, GalloDaSballo, and Egis_Security
The value of kerosene tokens is calculated according to the following formula:
Note: Please see scenario in wardens original submission.
The price of kerosene changes based on user actions. If a user has a large amount of tokens in their vault, that adds to the TVL. Now if a user mints a bunch of dyad tokens with their deposit as collateral, or if a removes a bunch of their unused collateral, the price of kerosene tokens will drop instantaneously.
When calculating the collateralization ratio of a users position, the price of kerosene is essential. This is used in the getKeroseneValue function.
As seen above, thetotalUsdValue depends on the getKeroseneValue function, which calls getUsdValue on the kerosene vaults. So instantaneously dropping the price of kerosene tokens will also instantaneously drop the totalUSDValue of the users position, decreasing their collateralization ratio. This can be used to force users into liquidation, if their final ratio drops below the liquidation threshold.
Since this allows any user to affect the collateralization ratio of other users positions, this is a high severity issue.
Assume Alice has 1 million USDC tokens in her vault, and 0 minted dyad tokens. TVL is 10 million USD of exo collateral, dyad supply is 5.5 million. Assume total supply of kerosene is 100,000.
So the price of kerosene is:
kerosenePrice = {10,000,000 - 5,500,000}/{100,000} = 45 USD
Now assume Bob has an account with 1000 USDC tokens, and 20 kerosene tokens. They minted 1150 dyad tokens. These values were already included in the calculation above, so the minted amounts wont change. Their current collateralization ratio is:
CR = {1000 + 45 * 20}/{1150} = 1.65
Now, Alice decides to attack BOBs position. She withdraws her 1 million USDC tokens from her vault. This drops the TVL to 9 million USD. Now the price of kerosene is:
kerosenePrice = {9,000,000 - 5,500,000}/{100,000} = 35 USD
Now the collateralization ratio of Bobs position is:
CR = {1000 + 35 * 20}\{1150} = 1.48
Thus, Bobs position is liquidatable.
Whales can set up traps by putting in large amounts of capital as TVL into the vault, propping up the price of kerosene. Then whenever a user opens a position which is moderately close to the liquidation threshold, the whale can immediately take out their liquidity, effectively doing a rug pull, and liquidate the users.
Since this gives high net worth users an easy way to manipulate the protocol at no loss, this is a high severity issue.
Add a TWAP mechanism to calculate the price of kerosene. The price of kerosene being manipulatable instantaneously is a huge risk. By using a TWAP mechanism, the price of kerosene will be more stable, and users will have more time to react to changes in the price of kerosene.
Oracle
0xMax1 (DYAD) commented:
shafu0x (DYAD) acknowledged
Koolex (judge) decreased severity to Medium and commented:
For this audit, 12 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by Bauchibred received the top score from the judge.
The following wardens also submitted reports: Al-Qa-qa, albahaca, niloy, sxima, SBSecurity, oakcobalt, Sathish9098, clara, VAD37, K42, and ZanyBonzy.
