Skip to content

Commit

Permalink
Merge pull request #43 from axieinfinity/feature/remove-send-zero-checks
Browse files Browse the repository at this point in the history
feat: remove send zero checks
  • Loading branch information
TuDo1403 authored Mar 19, 2024
2 parents e5fdb79 + b7f66ed commit ef0f90d
Showing 1 changed file with 14 additions and 26 deletions.
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

0 comments on commit ef0f90d

Please sign in to comment.