DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: medium
Invalid

Secondary exit short doesn't repay collateral on partial repay

Summary

According to docs there are 2 ways of exit short:

  1. Primary: user submits market bid to buy ercDebt for collateral and therefore repay. User receives collateral on partial exit

  2. Secondary: user provides ercDebt for collateral. Issue is that user doesn't receive collateral on partial exit

Vulnerability Details

User's ethEsrowed increases only when buyBackAmount == ercDebt, otherwise he doesn't receive repayed collateral

function exitShortWallet(address asset, uint8 id, uint88 buyBackAmount)
external
isNotFrozen(asset)
nonReentrant
onlyValidShortRecord(asset, msg.sender, id)
{
...
if (buyBackAmount == ercDebt) {
uint256 vault = s.asset[asset].vault;
uint88 collateral = short.collateral;
s.vaultUser[vault][msg.sender].ethEscrowed += collateral;
LibShortRecord.disburseCollateral(
asset, msg.sender, collateral, short.zethYieldRate, short.updatedAt
);
LibShortRecord.deleteShortRecord(asset, msg.sender, id);
} else {
short.ercDebt -= buyBackAmount;
short.maybeResetFlag(asset);
}
...
}

Impact

User expects to receive collateral on partial exit like it happens in Secondary Exit Short. This non-obvious behaviour leads to poor UX and isn't documented.

Tools Used

Manual Review

Recommendations

if (buyBackAmount == ercDebt) {
uint256 vault = s.asset[asset].vault;
uint88 collateral = short.collateral;
s.vaultUser[vault][msg.sender].ethEscrowed += collateral;
LibShortRecord.disburseCollateral(
asset, msg.sender, collateral, short.zethYieldRate, short.updatedAt
);
LibShortRecord.deleteShortRecord(asset, msg.sender, id);
} else {
short.ercDebt -= buyBackAmount;
+ s.vaultUser[vault][msg.sender].ethEscrowed += buyBackAmount.mul(LibOracle.getPrice(asset));
short.maybeResetFlag(asset);
}
Updates

Lead Judging Commences

0xnevi Lead Judge
about 2 years ago
0xnevi Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.