TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: high
Invalid

TempleGoldStaking::withdrawAll reverts due to insufficient TempleGold balance

Summary

Users stake in TempleGoldStaking contract but gets no reward when they want to withdraw their stake and reward.

Vulnerability Details

Proof of Code

Due to the size of my test suite, I couldn't host it on GitHub, but it can be download here: https://docs.google.com/document/d/165MB-BQw24urgMUCmzJ5YQBI1C83ikK8jLboWfm9__Y/edit?usp=sharing
The file suite is in zip format. Once downloaded you can run the PoCs with ease. No additional dowloads or cloning.

The following property breaks with the sequence of calls below. Note that this is part of a stateful fuzz test suite.

// Stakes should always receive staking reward

Call sequence:

// forge test --match-test test_templeGoldStaking_withdrawAll_0 -vv
function test_templeGoldStaking_withdrawAll_0() public {
vm.roll(36898);
vm.warp(168958);
vm.prank(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69);
templeGoldStaking_stake(57797116559274667104792965608664960324359384909072175397041482114744647446113);
vm.roll(36899);
vm.warp(355243);
vm.prank(0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF);
templeGoldStaking_distributeRewards();
vm.roll(65981);
vm.warp(437946);
vm.prank(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69);
templeGoldStaking_getReward(165, 22116177955790739426180104203601567471689472697726939180361363326254627369265);
vm.roll(106340);
vm.warp(487157);
vm.prank();
templeGoldStaking_stake(278600598730963629050112);
vm.roll(106348);
vm.warp(733042);
vm.prank(0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69);
templeGoldStaking_withdrawAll(8192, hex"true");
}

Revert message:

[revert (error: ERC20InsufficientBalance(0xc58275005697abce7bb4bca2ebe779296286496b, 3379394977168949771689497, 8134938133067142873145779))]

Impact

Loss of reward for users

Tools Used

Medusa and Foundry

Recommendations

Ensure the contract has sufficient balance before starting the reward epochs.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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