Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

0xrice.cooker - Wrong intergation with Stargate's LPStakingTime contract leads to all users earn less interest than expected and rewards got stuck in StakedStargateAM contract #9

Closed
sherlock-admin2 opened this issue Feb 16, 2024 · 1 comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin2
Copy link

sherlock-admin2 commented Feb 16, 2024

0xrice.cooker

high

Wrong intergation with Stargate's LPStakingTime contract leads to all users earn less interest than expected and rewards got stuck in StakedStargateAM contract

Summary

Wrong intergation with Stargate's LPStakingTime contract leads to all users earn less interest than expected and rewards got stuck in StakedStargateAM contract

Vulnerability Detail

Stagate's LPStakingTime have no method to specialise to only withdrawing reward out. Due to that, LPStakingTime.deposit() and LPStakingTime.withdraw() beside depositing/withdraw funds, it will also send the accumulated reward to the caller.

In StakedStargateAM, we don't have any logic to store the value of received reward during a call deposit() and withdraw(), hence the protocol is not even know that the reward is already distribute

Impact

This will lead to user who owns StakedStargateAM NFT will lose majority of reward. And the StakedStargateAM contract have the no method to take the un distribute reward out

Code Snippet

https://github.com/sherlock-audit/2023-12-arcadia/blob/de7289bebb3729505a2462aa044b3960d8926d78/accounts-v2/src/asset-modules/Stargate-Finance/StakedStargateAM.sol#L82C1-L97C6

https://basescan.org/address/0x06Eb48763f117c7Be887296CDcdfad2E4092739C#code#F1#L159

https://basescan.org/address/0x06Eb48763f117c7Be887296CDcdfad2E4092739C#code#F1#174

Tool used

Manual Review

Recommendation

+   uint256 cache;
    
    function _stake(address asset, uint256 amount) internal override {
+	cache += LP_STAKING_TIME.pendingEmissionToken(assetToPid[asset], address(this));
        ERC20(asset).approve(address(LP_STAKING_TIME), amount);

        LP_STAKING_TIME.deposit(assetToPid[asset], amount);
    }

    function _withdraw(address asset, uint256 amount) internal override {
+	cache += LP_STAKING_TIME.pendingEmissionToken(assetToPid[asset], address(this));
        LP_STAKING_TIME.withdraw(assetToPid[asset], amount);
    }

    function _claimReward(address asset) internal override {
+	cache = 0;
        LP_STAKING_TIME.withdraw(assetToPid[asset], 0);
    }

    function _getCurrentReward(address asset) internal view override returns (uint256 currentReward) {
-       currentReward = LP_STAKING_TIME.pendingEmissionToken(assetToPid[asset], address(this));
+       currentReward = LP_STAKING_TIME.pendingEmissionToken(assetToPid[asset], address(this)) + cache;
    }

Duplicate of #38

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Feb 21, 2024
@sherlock-admin2
Copy link
Author

1 comment(s) were left on this issue during the judging contest.

takarez commented:

valid: some portion of the reward will be stucked in the contract; medium(1)

@nevillehuang nevillehuang added High A valid High severity issue Medium A valid Medium severity issue and removed Medium A valid Medium severity issue High A valid High severity issue labels Feb 26, 2024
@sherlock-admin sherlock-admin changed the title Deep Menthol Meerkat - Wrong intergation with Stargate's LPStakingTime contract leads to all users earn less interest than expected and rewards got stuck in StakedStargateAM contract 0xrice.cooker - Wrong intergation with Stargate's LPStakingTime contract leads to all users earn less interest than expected and rewards got stuck in StakedStargateAM contract Feb 28, 2024
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

3 participants