-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix: tf remove #42
fix: tf remove #42
Conversation
Schlagonia
commented
Mar 28, 2024
- set correct array to storage
- Allow setTradeFactory to take in address(0)
lgtm |
if (i != _rewardTokensLocal.length - 1) { | ||
// if it isn't the last token, swap with the last one/ | ||
rewardTokens_[i] = rewardTokens_[rewardTokens_.length - 1]; | ||
_rewardTokensLocal[i] = _rewardTokensLocal[ | ||
_rewardTokensLocal.length - 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 don't think you need this if check at all. You can use directy:
_rewardTokensLocal[i] = _rewardTokensLocal[
_rewardTokensLocal.length - 1
];
If the length is 3, and the "i" is 2 it will just do an unnecessary set to array[2] = array[2]
Is it more gas friendly that way?
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.
an if check is more gas efficient than setting variables in a memory array.
Would expect the majority of uses would also only have 1 reward token so the will likely stop alot of unnecessary memory work
src/swappers/TradeFactorySwapper.sol
Outdated
ERC20(_tokenFrom).safeApprove(_tf, 0); | ||
ITradeFactory(_tf).disable(_tokenFrom, _tokenTo); |
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.
To fix this issue we need to add:
if (_tf != address(0)) ITradeFactory(_tf).disable(_tokenFrom, _tokenTo);;
or even
if (_tf != address(0)) {
ERC20(_tokenFrom).safeApprove(_tf, 0);
ITradeFactory(_tf).disable(_tokenFrom, _tokenTo);
}
Would that be a problem for the other actions that the trade factory will be used for?
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.
added
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.
LGTM