Skip to content
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

Merged
merged 6 commits into from
Mar 28, 2024
Merged

fix: tf remove #42

merged 6 commits into from
Mar 28, 2024

Conversation

Schlagonia
Copy link
Collaborator

  • set correct array to storage
  • Allow setTradeFactory to take in address(0)

@mil0xeth
Copy link
Contributor

lgtm

Comment on lines +77 to 82
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
];
}
Copy link

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?

Copy link
Collaborator Author

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

Comment on lines 83 to 84
ERC20(_tokenFrom).safeApprove(_tf, 0);
ITradeFactory(_tf).disable(_tokenFrom, _tokenTo);
Copy link

@tapired tapired Mar 28, 2024

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

tapired

This comment was marked as duplicate.

Copy link

@tapired tapired left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Schlagonia Schlagonia merged commit abdec36 into master Mar 28, 2024
2 of 3 checks passed
@Schlagonia Schlagonia deleted the tf_fixes branch March 28, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants