Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

contracts/core/tokens/WrappedSDToken.sol

Your Solidity contract WrappedSDToken appears to be well-structured, but here are a few potential vulnerabilities and considerations that you might want to address:

1. Reentrancy Attacks

The contract interacts with external contracts (sdToken) and performs state changes after calling an external function (e.g., sdToken.transfer). To prevent reentrancy attacks, consider using the Checks-Effects-Interactions pattern or implementing a Reentrancy Guard.

2. Invalid State Assumptions

The functions that transfer tokens rely on the assumption that the calls to sdToken (like transferFrom and transfer) will succeed. If these calls fail for any reason (e.g., not enough allowance), it could leave the contract in an unexpected state. You may want to use require statements to handle these failures explicitly.

3. Gas Limit Issues

If sdToken.getStakeByShares or sdToken.getSharesByStake are complex computations, they may run into gas limit issues if they consume too much gas. Be cautious of how these functions are implemented in IStakingRewardsPool.

4. Token Transfer Failures

The unwrap function uses sdToken.transfer(msg.sender, unwrappedAmount); without checking if the transfer was successful. It’s a good practice to wrap this call in a require statement:

bool success = sdToken.transfer(msg.sender, unwrappedAmount);
require(success, "Transfer failed");

5. Potential for Arithmetic Overflow/Underflow

Although Solidity 0.8.x has built-in overflow/underflow checks, be aware of any indirect arithmetic operations in external calls. Ensure that any arithmetic on token amounts (e.g., _amount, wrappedAmount, etc.) is correctly handled.

6. Access Control

Ensure that the functions are adequately protected against unauthorized access. Since the functions are marked external, anyone can call them. If certain functions should only be callable by specific roles, implement role-based access control.

7. Denial of Service (DoS)

If sdToken goes offline or changes its implementation and the contract relies on it, it could lead to a denial of service. You may want to consider implementing a fallback mechanism or upgradeability pattern.

8. Unused Input Parameter in onTokenTransfer

The onTokenTransfer function has an unused bytes calldata parameter. If it’s not needed, consider removing it to save gas.

9. Potential Token Mismatch

Ensure that the contract correctly interacts with sdToken as intended, especially with rebase tokens, as they may change balances in unexpected ways. This could lead to mismatches in the expected versus actual token balances.

Recommendations

  • Test Extensively: Implement unit tests and integration tests to ensure that the contract behaves as expected.

  • Audit: Consider getting an external audit, especially if the contract will handle significant value.

  • Documentation: Ensure that the purpose and expected behavior of each function are well documented for future reference.

Overall, while the code has a solid foundation, addressing these points will help to enhance security and robustness.

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.