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

feat: remove send zero checks #43

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions src/legacy/transfers/RONTransferHelperExtended.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ library RONTransferHelperExtended {
*/
function safeUnwrapTokenAndTransfer(IWRON wron, address token, address payable to, uint256 amount) internal {
if (token == address(wron)) {
// Check whether the recipient receives RON
if (RONTransferHelper.send(to, 0)) {
wron.withdraw(amount);
RONTransferHelper.safeTransfer(to, amount);
return;
}
wron.withdraw(amount);
RONTransferHelper.safeTransfer(to, amount);
return;
}

TransferHelper.safeTransfer(token, to, amount);
Expand All @@ -48,12 +45,9 @@ library RONTransferHelperExtended {
uint256 amount
) internal {
if (token == address(wron)) {
// Check whether the recipient receives RON
if (RONTransferHelper.send(to, 0)) {
wron.approve(address(wronHelper), amount);
wronHelper.withdrawTo(to, amount);
return;
}
wron.approve(address(wronHelper), amount);
wronHelper.withdrawTo(to, amount);
return;
}

TransferHelper.safeTransfer(token, to, amount);
Expand All @@ -74,13 +68,10 @@ library RONTransferHelperExtended {
internal
{
if (token == address(wron)) {
// Check whether the recipient receives RON
if (RONTransferHelper.send(to, 0)) {
TransferFromHelper.safeTransferFrom(token, from, address(this), amount);
IWRON(wron).withdraw(amount);
RONTransferHelper.safeTransfer(to, amount);
return;
}
TransferFromHelper.safeTransferFrom(token, from, address(this), amount);
IWRON(wron).withdraw(amount);
RONTransferHelper.safeTransfer(to, amount);
return;
}

TransferFromHelper.safeTransferFrom(token, from, to, amount);
Expand All @@ -104,13 +95,10 @@ library RONTransferHelperExtended {
uint256 amount
) internal {
if (token == address(wron)) {
// Check whether the recipient receives RON
if (RONTransferHelper.send(to, 0)) {
TransferFromHelper.safeTransferFrom(token, from, address(this), amount);
wron.approve(address(wronHelper), amount);
wronHelper.withdrawTo(to, amount);
return;
}
TransferFromHelper.safeTransferFrom(token, from, address(this), amount);
wron.approve(address(wronHelper), amount);
wronHelper.withdrawTo(to, amount);
return;
}

TransferFromHelper.safeTransferFrom(token, from, to, amount);
Expand Down
Loading