FluidFlashLender
Inherits:Structs, IFluidFlashLender, IProtocol, Helpers
contract that provides Flashloans via Fluid. ERC-3156 compatible.
In addition also implements a flashLoanMultiple()
method which can be used to flash loan multiple tokens at once.
Fee is a constant 0. This contract is not upgradeable.
Functions
constructor
constructor(IFluidLiquidity liquidity_) Helpers(liquidity_);
maxFlashLoan
The amount of currency available to be lent.
function maxFlashLoan(address token_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token_ | address | The loan currency. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of token that can be borrowed. |
flashFee
The fee to be charged for a given loan.
function flashFee(address token_, uint256 amount_) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token_ | address | loan currency. |
amount_ | uint256 | The amount of tokens lent. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of token to be charged for the loan, on top of the returned principal. |
flashLoan
Initiate a flash loan.
receiver_ must approve amount_
of token_
for payback. For native token, it must be send as msg.value.
function flashLoan(IERC3156FlashBorrower receiver_, address token_, uint256 amount_, bytes calldata data_)
external
validAddress(address(receiver_))
validAddress(token_)
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
receiver_ | IERC3156FlashBorrower | The receiver of the tokens in the loan, and the receiver of the callback. |
token_ | address | The loan currency. |
amount_ | uint256 | The amount of tokens lent. |
data_ | bytes | Arbitrary data structure, intended to contain user-defined parameters. |
flashLoanMultiple
Initiate a flash loan with multiple tokens.
receiver_ must approve amount_
of each token for payback. For native token, it must be send as msg.value.
function flashLoanMultiple(IFlashBorrower receiver_, AddressUint256[] calldata tokensWithAmounts_, bytes calldata data_)
external
validAddress(address(receiver_))
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
receiver_ | IFlashBorrower | The receiver of the tokens in the loan, and the receiver of the callback. |
tokensWithAmounts_ | AddressUint256[] | An array of token addresses and loan amounts. |
data_ | bytes | Arbitrary data structure, intended to contain user-defined parameters. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | 'true' if the flash loans are successful |
liquidityCallback
flashLender liquidity callback
function liquidityCallback(address token_, uint256 amount_, bytes calldata data_) external;
Parameters
Name | Type | Description |
---|---|---|
token_ | address | The token being transferred |
amount_ | uint256 | The amount being transferred |
data_ | bytes |
receive
@Fallback function to receive Ether
receive() external payable;
rescueFunds
sends any potentially stuck funds to Liquidity contract. Only callable by Liquidity auths.
function rescueFunds(address token_) external;
repayAtLiquidity
repays repayAmount_
for token_
at Liquidity.
Can be used to balance out any leftover rounding differences at Liquidity if ever needed.
function repayAtLiquidity(address token_, uint256 repayAmount_) external payable;
Events
LogRescueFunds
emitted whenever funds for a certain token
are rescued to Liquidity
event LogRescueFunds(address indexed token);
LogFlashLoan
emitted when a flashloan has been taken and repaid
event LogFlashLoan(address indexed token, uint256 indexed amount, address indexed receiver);