Skip to content

w1r2p1/flashloan-bzx

 
 

Repository files navigation


bZx v2.0 Smart Contracts

Dependencies

Documentation and Support

Install all necessary packages with

yarn install

Function signature for bZx flash loan

    function flashBorrow(
        uint256 borrowAmount,
        address borrower,
        address target,
        string calldata signature,
        bytes calldata data
    ) external payable returns (bytes memory);
  • borrowAmount - amount you want to flash borrow
  • borrower - receiver of the flash borrow call
  • target - target address for flash borrow callback
  • signature - function signature to be encoded with abi.encodePacked(bytes4(keccak256(bytes(signature))), data), if not provided data will be used as callData instead
  • data - target address function arguments.
  • returns signature funciton operation results.

To take a flash loan in USDC you need to call flashBorrow on the iUSDC contract. List of iToken contracts can be found here

BZxFlashLoaner is an example contract that takes opportunity of the bZx flash loans. it does so in several steps:

  1. Transaction entry point doStuffWithFlashLoan
  2. Loan initialization initiateFlashLoanBzx
  3. operation with loaned money executeOperation
  4. return loaned money before executeOperation end repayFlashLoan
  5. final checks doStuffWithFlashLoan . you can actually revert a transaction at this time if you consider your transaction not profitable for example

Flash Loans are uncolaterized loans that are required to be returned in the same transaction. There is no real world analogy. the closes you can compare is with overnight market or Repurchase Agreement but without collateral.

Please note currently bZx flash loans are FREE. you pay ZERO fees for taking a flash loan.

There are a couple of use cases where someone might use flash loans:

  • Arbitrage
  • Liquidations
  • re-finance exiting loans
  • other

Support

For any dev related questions and support please join our discord #dev channel. We have very supportive community.

Testing

To run the tests, first install the developer dependencies:

pip install -r requirements.txt

Make sure you have environemtn variables setup for ETHERSCAN and INFIRA

export ETHERSCAN_TOKEN= ...
export WEB3_INFURA_PROJECT_ID= ...

Run the all tests with:

brownie test --network mainnet-fork

License

This project is licensed under the Apache License, Version 2.0.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 63.1%
  • Python 36.9%