Dyson Finance Contract Docs
  • Overview
  • Guides
    • Set Up Your Local Environment
    • Interact with Dyson Finance contracts on Sepolia testnet
    • Integration of Swap
      • Trial Calculation of Swap
      • Perform a Swap
      • Deep Understanding of Swap
    • Integration of Dual Investment
      • Trial Calculation before deposit
      • Perfrom a Dual Investment Deposit
      • Perform a Dual Investment Withdrawal
    • Stake your $DYSN for $sDYSN
    • Boost the Pool by depositing your $sDYSN
    • Sponsorship Reward
  • Technical Reference
    • Overview
    • Core
      • AddressBook
      • DYSON
      • Pair
      • Router
      • PairFactory
      • Membership
        • Agency
        • AgentNFT
      • Fee & Reward distribution
        • FeeDistributor
        • Bribe
      • Staking & Yield Boosting
        • sDYSON
        • Farm
        • Gauge
      • Events
    • Libraries
      • TransferHelper
      • SqrtMath
      • ABDKMath64x64
    • Unit Definition
  • Contract Addresses & Info
    • Blast
    • Polygon zkEVM
    • Linea
    • X Layer
    • Testnet (Sepolia)
    • Testnet (Blast Sepolia)
Powered by GitBook
On this page
  • safeApprove
  • safeTransfer
  • safeTransferFrom
  • safeTransferETH
  1. Technical Reference
  2. Libraries

TransferHelper

The TransferHelper library provides functions for safely interacting with ERC-20 tokens and Ether transfers.

safeApprove

Safely approves spending of a specified amount of tokens by a target address.

function safeApprove(
    address token, 
    address to, 
    uint value) internal

Parameters:

Name
Type
Description

token

address

Address of the ERC-20 token.

to

address

Address that will be approved to spend the tokens.

value

uint

Amount of tokens to approve.

safeTransfer

Safely transfers a specified amount of tokens to a target address.

function safeTransfer(
    address token, 
    address to, 
    uint value) internal

Parameters:

Name
Type
Description

token

address

Address of the ERC-20 token.

to

address

Address to which the tokens will be transferred.

value

uint

Amount of tokens to transfer.

safeTransferFrom

Safely transfers a specified amount of tokens from one address to another.

function safeTransferFrom(
    address token, 
    address from, 
    address to, 
    uint value) internal

Parameters:

Name
Type
Description

token

address

Address of the ERC-20 token.

from

address

Address from which the tokens will be transferred.

to

address

Address to which the tokens will be transferred.

value

uint

Amount of tokens to transfer.

safeTransferETH

Safely transfers a specified amount of Ether to a target address.

function safeTransferETH(
    address to, 
    uint value) internal

Parameters:

Name
Type
Description

to

address

Address to which the Ether will be transferred.

value

uint

Amount of Ether to transfer.

PreviousLibrariesNextSqrtMath

Last updated 1 year ago