-
Notifications
You must be signed in to change notification settings - Fork 2
Test: Initial Strategy & Service #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ) external onlyStrategyOwner(strategyId) { | ||
| if (obligationPercentage > MAX_PERCENTAGE) revert ICore.InvalidPercentage(); | ||
| if (obligationPercentage <= obligations[strategyId][bApp][token]) revert ICore.InvalidPercentage(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check new condition when going from 0% to >0%
if (obligations[strategyId][bApp][token] == 0 && obligationPercentage > 0) {
usedTokens[strategyId][token] += 1;
}
or add a check if the obligation does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find Marco!
| obligations[strategyId][bApp][token] = obligationPercentage; | ||
| } | ||
|
|
||
| obligationsCounter[strategyId][bApp] += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think obligationsCounter should be incremented only if obligationPercentage != 0, as it represents the total obligations created in a strategy, right?
maybe also don't emit the next event. So:
if (obligationPercentage != 0) {
usedTokens[strategyId][token] += 1;
obligations[strategyId][bApp][token] = obligationPercentage;
}
obligationsCounter[strategyId][bApp] += 1;
emit ObligationCreated(strategyId, bApp, token, obligationPercentage);
| /// @notice Withdraw ETH from the strategy | ||
| /// @param strategyId The ID of the strategy | ||
| /// @param amount The amount to withdraw | ||
| function fastWithdrawETH(uint256 strategyId, uint256 amount) external { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential candidate to use nonReentrant modifier.
We need to add a test to simulate a reentrancy attack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was planning to have timebox task to try and break the contract, testing reentrancy and more.
| * If the counter is 0, the token is unused and we can allow fast withdrawal. | ||
| */ | ||
| mapping(uint256 strategyId => mapping(address token => uint32 servicesCounter)) public usedTokens; | ||
| mapping(uint256 strategyId => mapping(address token => uint32 bAppsCounter)) public usedTokens; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double check each action that sets an obligation from >0 to 0 or 0 to >0 also updates usedTokens
No description provided.