/erc20-helper

Primary LanguageSolidityGNU Affero General Public License v3.0AGPL-3.0

ERC20Helper

CircleCI License: AGPL v3

DISCLAIMER: Please do not use in production without taking the appropriate steps to ensure maximum security.

WARNING: Unlike other similar libraries, this library does NOT REVERT ON FAILURES. Any contracts that inherit this code that expect the reversion to occur in this contract can have UNINTENDED AND POTENTIALLY CATASTROPHIC CONSEQUENCES.

Overview

ERC20Helper is a basic library designed to be used as a middleware between general smart contracts and diverse ERC-20 tokens. It standardizes the behaviours of all commonly used implementations.

The decision to intentionally not revert was so that this library can be more flexible for contracts that:

  • Want to choose their own revert strings, or none at all (i.e. require(ERC20Helper.transfer(asset, msg.sender, amount), "FOO:FAILED_TRANSFER");).
  • Want to use the returns as booleans (i.e. require(ERC20Helper.transfer(asset1, msg.sender, amount) || ERC20Helper.transfer(asset2, msg.sender, amount));).
  • Do not care about the result of a transfer.

Setup

This project was built using dapptools.

git clone git@github.com:maple-labs/erc20-helper.git
cd erc20-helper
dapp update

Running Tests

  • To run all tests: make test (runs ./test.sh)
  • To run a specific test function: ./test.sh -t <test_name> (e.g., ./test.sh -t test_fundLoan)

Audit Reports

Auditor Report link
Trail of Bits ToB - Dec 28, 2021
Code 4rena C4 - Jan 5, 2022
Trail of Bits ToB Report - April 12, 2022
Code 4rena C4 Report - April 20, 2022

Bug Bounty

For all information related to the ongoing bug bounty for these contracts run by Immunefi, please visit this site.

Acknowledgements

These contracts were inspired by and/or directly modified from the following sources: