Skip to content

Commit

Permalink
remove if
Browse files Browse the repository at this point in the history
  • Loading branch information
WalidOfNow committed Jun 13, 2024
1 parent c8c1f26 commit 51a07b2
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions mainnet-contracts/src/based-contracts/PufToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ contract PufToken is ERC20, ERC20Permit {
revert DepositAmountMustBeGreaterThanZero();
}

if (!IERC20(originalToken).transferFrom(user, address(this), amount)) {
revert TransferFailed();
}
IERC20(originalToken).transferFrom(user, address(this), amount);

_mint(user, amount);
}
Expand All @@ -50,9 +48,7 @@ contract PufToken is ERC20, ERC20Permit {

_burn(user, amount);

if (!IERC20(originalToken).transfer(user, amount)) {
revert TransferFailed();
}
IERC20(originalToken).transfer(user, amount);
}

function migrateFor(address user, address migrator, address destination, uint256 amount) external onlyDepositor {
Expand All @@ -62,9 +58,7 @@ contract PufToken is ERC20, ERC20Permit {

_burn(user, amount);

if (!IERC20(originalToken).approve(migrator, amount)) {
revert ApprovalFailed();
}
IERC20(originalToken).approve(migrator, amount);

IMigrator(migrator).migrate(user, originalToken, destination, amount);
}
Expand All @@ -74,9 +68,7 @@ contract PufToken is ERC20, ERC20Permit {
revert DepositAmountMustBeGreaterThanZero();
}

if (!IERC20(originalToken).transferFrom(msg.sender, address(this), amount)) {
revert TransferFailed();
}
IERC20(originalToken).transferFrom(msg.sender, address(this), amount);

_mint(msg.sender, amount);
}
Expand All @@ -88,9 +80,7 @@ contract PufToken is ERC20, ERC20Permit {

_burn(msg.sender, amount);

if (!IERC20(originalToken).transfer(msg.sender, amount)) {
revert TransferFailed();
}
IERC20(originalToken).transfer(msg.sender, amount);
}
}

Expand Down

0 comments on commit 51a07b2

Please sign in to comment.