Steadefi

Steadefi
DeFiHardhatFoundryOracle
35,000 USDC
View results
Submission Details
Severity: high
Valid

Users withdraw more assets than should when `mintFee` was called long ago

Summary

The amount of LP-tokens to withdraw is calculated at the GMXWithdraw.withdraw before the mintFee function is called. The mintFee function increases the totalSupply amount. This way users receive more tokens than should be at the current timestamp. The longer the period since the last mintFee was called the more excess tokens the user receives.

Vulnerability Details

The protocol mints vault token shares as management fees to protocol treasury with the mintFee function. This increases the totalSupply of the shares. The amount of minted fees depends on the time since the last mintFee call.

function mintFee() public {
_mint(_store.treasury, GMXReader.pendingFee(_store));
_store.lastFeeCollected = block.timestamp;
}

While withdrawal amount of LP-token can be calculated with outdated totalSupply:

67 _wc.shareRatio = wp.shareAmt
68 * SAFE_MULTIPLIER
69 / IERC20(address(self.vault)).totalSupply();
70 _wc.lpAmt = _wc.shareRatio
71 * GMXReader.lpAmt(self)
72 / SAFE_MULTIPLIER;
101 self.vault.mintFee();

The mintFee is called only after this calculation.

Impact

Users can receive excess amounts of tokens during withdrawal. Other users and the protocol management lose value of their shares.

Tools used

Manual Review

Recommendations

Consider calling the mintFee before the _wc.shareRatio calculation.

Updates

Lead Judging Commences

hans Auditor
almost 2 years ago
hans Auditor
almost 2 years ago
hans Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

Fee not accounted during withdrawal

Impact: High Likelihood: High User share amount is calculated before minting fee and the remaining users will need to more fee than reasonable.

nmirchev8 Auditor
almost 2 years ago
hans Auditor
almost 2 years ago
pontifex Submitter
almost 2 years ago
hans Auditor
almost 2 years ago
hans Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

Withdraw share amount does not take the fee into account

Support

FAQs

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