Skip to main content

How to specify an order with flash loan

The flash loan is encoded into the appData's metadata as an optional object. This information serves as a hint for the solver, but the solver ultimately can decide for a different approach in order to make the operation more optimal.

It is important to ensure that the flash loan gas overhead is added to the slippage tolerance when creating the order.

{
"flashloan": {
"lender": "0x1111111111111111111111111111111111111111",
"borrower": "0x2222222222222222222222222222222222222222",
"token": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"amount": "1000000"
}
}
  • lender (optional): the contract that could be used to borrow the funds from. For example 0x60744434d6339a6B27d73d9Eda62b6F66a0a04FA for Maker DAO, or 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 for AAVE. If the value is not provided the solver will choose a sensible default.
  • borrower (optional): who should receive the borrowed tokens. If no value is provided, the order owner's address will be used as the borrower.
  • token: the token that needs to get borrowed.
  • amount: how many atoms of the token need to get borrowed (e.g., 1 WETH would be 10ยนโธ).

How a lender protocol can be compatible with CoW Protocol

If the lender protocol rely on direct repayment from the borrower through transferFrom, then the lender protocol could implement the borrower functions as in Aave Borrower or in ERC-3156 wrapper.

If the lender supports ERC-3156 then there is no extra smart-contract work needed.