Skip to content

Latest commit

 

History

History
151 lines (128 loc) · 4.08 KB

NTransferUtilV2.md

File metadata and controls

151 lines (128 loc) · 4.08 KB

NTransferUtilV2.sol

View Source: contracts/libraries/NTransferUtilV2.sol

NTransferUtilV2

Functions

ensureTransfer

function ensureTransfer(IERC20 malicious, address recipient, uint256 amount) external nonpayable

Arguments

Name Type Description
malicious IERC20
recipient address
amount uint256
Source Code
function ensureTransfer(
    IERC20 malicious,
    address recipient,
    uint256 amount
  ) external {
    require(recipient != address(0), "Invalid recipient");
    require(amount > 0, "Invalid transfer amount");

    uint256 pre = malicious.balanceOf(recipient);
    malicious.safeTransfer(recipient, amount);

    uint256 post = malicious.balanceOf(recipient);

    // slither-disable-next-line incorrect-equality
    require(post.sub(pre) == amount, "Invalid transfer");
  }

ensureTransferFrom

function ensureTransferFrom(IERC20 malicious, address sender, address recipient, uint256 amount) external nonpayable

Arguments

Name Type Description
malicious IERC20
sender address
recipient address
amount uint256
Source Code
function ensureTransferFrom(
    IERC20 malicious,
    address sender,
    address recipient,
    uint256 amount
  ) external {
    require(recipient != address(0), "Invalid recipient");
    require(amount > 0, "Invalid transfer amount");

    uint256 pre = malicious.balanceOf(recipient);
    malicious.safeTransferFrom(sender, recipient, amount);
    uint256 post = malicious.balanceOf(recipient);

    // slither-disable-next-line incorrect-equality
    require(post.sub(pre) == amount, "Invalid transfer");
  }

Contracts