Contracts

InstaFlashAggregator

flashloan()

Sends the requested amounts of assets to the contract which called it, passing the included params, using the passed route. If the flash loaned amounts + fee is not returned by the end of the transaction, then the transaction will revert.

function flashLoan( 
        address[] memory tokens,    
        uint256[] memory amounts,
        uint256 route,
        bytes calldata data,
        bytes calldata instaData
    );
paramstypeDescription
tokensaddress[]The addresses of the tokens for which user needs flashloan.
amountsuint256[]The amounts of the respective tokens for flashloan. This needs to contain the same number of elements as tokens.
routeuint256Route through which user wants flashloan.
databytesbytes-encoded parameters to be used by the receiver contract.
instaDatabytesbytes-encoded parameters. Kept for future use by instadapp. Currently used nowhere.

getRoutes()

Returns an integer list of available routes.

function getRoutes() public pure returns (uint16[] memory routes);

InstaFlashResolver

This contract can be used to get data from the flashloan aggregator which can be helpful in deciding the route through which user wants to take flashloan. The flashResolver has the following functions:-

getRoutesInfo()

This function returns a list of available routes and a list of respective fee in BPS (1 BPS = 0.01%).

function getRoutesInfo() public view returns (uint16[] memory, uint256[] memory)

getBestRoutes()

This function returns the best routes(can be more than 1) and a the best fee in BPS (1 BPS = 0.01%). The best routes are found considering the tokens availability, amounts of tokens for flashloan, and the fee.

function getBestRoutes(address[] memory tokens, uint256[] memory amounts) public view returns (uint16[] memory, uint256)
paramstypeDescription
tokensaddress[]The addresses of the tokens for which user needs flashloan.
amountsuint256[]The amounts of the respective tokens for flashloan. This needs to contain the same number of elements as tokens.

Receiver Contract Interface

The receiver contract must follow the below interface to use the flashloan aggregator.

interface InstaFlashReceiverInterface {
    function executeOperation(
        address[] calldata assets,
        uint256[] calldata amounts,
        uint256[] calldata premiums,
        address initiator,
        bytes calldata data
    ) external returns (bool);
}
paramstypeDescription
assetsaddress[]The addresses of the tokens for which user needs flashloan.
amountsuint256[]The amounts of the respective tokens for flashloan. This needs to contain the same number of elements as tokens.
premiumsuint256[]The fee for the respective tokens based on the amounts borrowed. At the end user need to return the amount + premium for all the tokens.
initiatoraddressThe address which initiated the flashloan transaction.
databytesbytes-encoded parameters to be used by the receiver contract.

If you still can't find something you're looking for or have any questions, ask them at our developers community on Discord or simply send an Email.

Our team is excited about assisting you to build an application using Instadapp Developer Platform. Your questions and feedback help us make a better development environment for future developers.