Files
uniswap-v2/contracts/token/SafeTransfer.sol
Noah Zinsmeister da6ba92d92 clean up names and implementation of oracle stuff
update UQ104.104 copy

make safetransfer much clearer
2019-11-26 13:42:55 -05:00

15 lines
520 B
Solidity

pragma solidity 0.5.12;
contract SafeTransfer {
function safeTransfer(address token, address to, uint256 value) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSignature("transfer(address,uint256)", to, value));
require(success, "SafeTransfer: SWAP_FAILED");
if (data.length == 32) {
require(abi.decode(data, (bool)), "SafeTransfer: SWAP_FAILED");
} else if (data.length > 32) {
revert("SafeTransfer: SWAP_FAILED");
}
}
}