Your Solidity contract WrappedSDToken appears to be well-structured, but here are a few potential vulnerabilities and considerations that you might want to address:
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.
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.
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.
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:
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.
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.
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.
onTokenTransferThe onTokenTransfer function has an unused bytes calldata parameter. If it’s not needed, consider removing it to save gas.
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.
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.