stake.link

stake.link
DeFiHardhatBridge
27,500 USDC
View results
Submission Details
Severity: low
Invalid

The withdrawal amount should be greater than 0

Summary

Because the user can input an amount equal to 0, lock owners can potentially spam the withdraw() function to keep updateNeeded always equal to 1. This can result in unnecessary gas consumption for the system when calling CCIP to update the system.

Test

it('Possible to withdraw 0 tokens', async () => {
await mintLock(false)
await expect(sdlPool.withdraw(1, 0)).to.be.emit(sdlPool, "QueueWithdraw")
assert.equal(await sdlPool.shouldUpdate(), true)
})

Recommendations

  • Consider adding a requirement for the withdrawal amount to always be greater than 0:

function withdraw(uint256 _lockId, uint256 _amount)
external
onlyLockOwner(_lockId, msg.sender)
updateRewards(msg.sender)
{
if (_amount == 0) revert InvalidValue(); // <- @AUDIT - add here
...
emit QueueWithdraw(msg.sender, _lockId, _amount);
}
  • Similarly to the withdraw function in the SDLPoolPrimary contract, it would be clearer to check if the entered amount is different from 0.

Updates

Lead Judging Commences

0kage Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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