Alkemi Earn Contracts
Earn AppEarn API
  • Alkemi Earn Contracts
  • docs
    • EIP20NonStandardInterface (EIP20NonStandardInterface.sol)
    • EIP20Interface.sol
    • RewardControlStorage.sol
    • TestTokens.sol
    • Careful Math (CarefulMath.sol)
    • RewardControlInterface.sol
    • AggregatorV3Interface.sol
    • PriceOracleProxy.sol
    • RewardControl.sol
    • Migrations.sol
    • SafeToken.sol
    • AlkemiWETH.sol
    • Exponential module for storing fixed-precision decimals (ExponentialNoError.sol)
    • AlkemiEarnPublic.sol
    • ErrorReporter.sol
    • AlkemiEarnVerified.sol
    • Earn Interest Rate Model (AlkemiRateModel.sol)
    • PriceOracle.sol
    • ExchangeRateModel.sol
    • Exponential.sol
    • LiquidationChecker.sol
    • InterestRateModel Interface (InterestRateModel.sol)
    • SafeMath.sol
    • ChainLink.sol
    • PriceOracleInterface.sol
    • Liquidator.sol
  • .solidoc
    • templates
      • table-header
      • function
      • modifier
      • contract
  • scripts
    • DEPLOYMENT
Powered by GitBook
On this page

Was this helpful?

  1. docs

SafeToken.sol

PreviousMigrations.solNextAlkemiWETH.sol

Last updated 3 years ago

Was this helpful?

View Source:

↗ Extends: ↘ Derived Contracts: , ,

Functions

  • checkTransferIn(address asset, address from, uint256 amount)

  • doTransferIn(address asset, address from, uint256 amount)

  • getCash(address asset)

  • getBalanceOf(address asset, address from)

  • doTransferOut(address asset, address to, uint256 amount)

  • doApprove(address asset, address to, uint256 amount)

checkTransferIn

Checks whether or not there is sufficient allowance for this contract to move amount from from and whether or not from has a balance of at least amount. Does NOT do a transfer.

function checkTransferIn(address asset, address from, uint256 amount) internal view
returns(enum ErrorReporter.Error)

Arguments

Name

Type

Description

asset

address

from

address

amount

uint256

doTransferIn

Similar to EIP20 transfer, except it handles a False result from transferFrom and returns an explanatory error code rather than reverting. If caller has not called checkTransferIn, this may revert due to insufficient balance or insufficient allowance. If caller has called checkTransferIn prior to this call, and it returned Error.NO_ERROR, this should not revert in normal conditions.

  • Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.

function doTransferIn(address asset, address from, uint256 amount) internal nonpayable
returns(enum ErrorReporter.Error)

Arguments

Name

Type

Description

asset

address

from

address

amount

uint256

getCash

Checks balance of this contract in asset

function getCash(address asset) internal view
returns(uint256)

Arguments

Name

Type

Description

asset

address

getBalanceOf

Checks balance of from in asset

function getBalanceOf(address asset, address from) internal view
returns(uint256)

Arguments

Name

Type

Description

asset

address

from

address

doTransferOut

Similar to EIP20 transfer, except it handles a False result from transfer and returns an explanatory error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified it is >= amount, this should not revert in normal conditions.

  • Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.

function doTransferOut(address asset, address to, uint256 amount) internal nonpayable
returns(enum ErrorReporter.Error)

Arguments

Name

Type

Description

asset

address

to

address

amount

uint256

doApprove

function doApprove(address asset, address to, uint256 amount) internal nonpayable
returns(enum ErrorReporter.Error)

Arguments

Name

Type

Description

asset

address

to

address

amount

uint256

See here:

See here:

contracts/SafeToken.sol
ErrorReporter
AlkemiEarnPublic
AlkemiEarnVerified
Liquidator
https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca