-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Pool support pool burn and collect (#116)
- Loading branch information
1 parent
357fad3
commit a172b5a
Showing
3 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
demo-contract/contracts/wtfswap/libraries/TransferHelper.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.6.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
/// @title TransferHelper | ||
/// @notice Contains helper methods for interacting with ERC20 tokens that do not consistently return true/false | ||
library TransferHelper { | ||
/// @notice Transfers tokens from msg.sender to a recipient | ||
/// @dev Calls transfer on token contract, errors with TF if transfer fails | ||
/// @param token The contract address of the token which will be transferred | ||
/// @param to The recipient of the transfer | ||
/// @param value The value of the transfer | ||
function safeTransfer(address token, address to, uint256 value) internal { | ||
(bool success, bytes memory data) = token.call( | ||
abi.encodeWithSelector(IERC20.transfer.selector, to, value) | ||
); | ||
require( | ||
success && (data.length == 0 || abi.decode(data, (bool))), | ||
"TF" | ||
); | ||
} | ||
} |