DODO Docs
Searchโ€ฆ
โšก
Flash Loan

What is a Flash Loan?

In short, it means you can make payments on DODO with credit. When you buy tokens, you can get them first and then pay for them.
Flash Loan Mechanism
The above diagram illustrates the four steps of the DODO V2 flash swap.
1. Invoke the flashLoan function in the pool contract .
2.The pool sends the base and quote token to the applicant (where baseAmount or quoteAmount can be lent to 0) .
3.If the flashLoan function is called with data data that is not empty, the contract calls the DVMFlashLoanCall or DPPFlashLoanCall method (corresponding to public and private pools) passed by the applicant into the assetTo contract address.
4. After the DVMFlashLoanCall or DPPFlashLoanCall is executed, the tokens will be returned and the contract will calculate if the pool is losing money, and if it is losing money, it will be traded out directly.
1
function flashLoan(
2
uint256 baseAmount,
3
uint256 quoteAmount,
4
address assetTo,
5
bytes calldata data
6
) external;
Copied!
PS: DODO V2 flashLoan will preview a transaction that equalize the base and quote token to the initial state. using the preview transaction fee as the flashloan fee. No more fee will be charged in other situations.
Requires users implement the IDODOCallee interface.
1
interface IDODOCallee {
2
function DVMFlashLoanCall(
3
address sender,
4
uint256 baseAmount,
5
uint256 quoteAmount,
6
bytes calldata data
7
) external;
8
โ€‹
9
function DPPFlashLoanCall(
10
address sender,
11
uint256 baseAmount,
12
uint256 quoteAmount,
13
bytes calldata data
14
) external;
15
โ€‹
16
function DSPFlashLoanCall(
17
address sender,
18
uint256 baseAmount,
19
uint256 quoteAmount,
20
bytes calldata data
21
) external;
22
}
Copied!

How to use

Sample code:DODOFlashloan.solโ€‹
Some thoughts
Once you dive into Flash Loan Exchange, you'll understand the advantages of the DeFi world over the centralized world. By combining smart contracts, we can increase the utilization of funds in DeFi to unprecedented levels. the cost of trust in the DeFi world is extremely low. The DODO team hopes to get DeFi practitioners started in the DeFi world by introducing them to Flash Loan exchange.
Note:Flash Loan was inspired by dYdX and Uniswap. and the DODO team pays tribute to these pioneers of the DeFi world. ๐Ÿ‘
โ€‹