Flash loan
Flash loan

Aave · Acts onchain

Borrows an asset from an Aave market with no collateral, repaid inside this transaction. The action opens a block: the steps inside it spend the borrowed funds, and before the block ends the socket must hold the principal plus Aave's flash premium, surfaced as the owed output, or the whole transaction reverts. Approval for the repayment is handled here. Reach for it to refinance debt between markets without capital, to unwind a leveraged position by repaying before withdrawing collateral, or to fund an arbitrage across venues. Coil owed into a comparison so a predicate requires the balance covers it before the block closes.

Wind

plug
aave
evm
19actions
  1. 1·Take

    Takes supply_amount as a caller parameter, sizing the collateral leg flash-borrowed and supplied on this wind path.

  2. 2·Take

    Next, supply_token is declared as a caller parameter, naming the collateral asset flash-borrowed and supplied here.

  3. 3·Take

    The market address aave_market enters as a caller parameter, resolving every Aave action in this plug.

  4. 4·Take

    Also taken is borrow_amount, a caller parameter setting how much debt to draw against the supplied collateral.

  5. 5·Take

    Rounding out the inputs, borrow_token is declared as a caller parameter, naming the debt asset borrowed.

  6. 6·Flash loan

    A flash loan pulls supply_amount of supply_token from aave_market, to be repaid within this same transaction.

  7. 7·Set

    The repayment obligation returned by that flash loan is saved into wind_loan_owed for the later coverage check.

  8. 8·Supply

    Supplying supply_amount of supply_token to aave_market mints aTokens to the socket as collateral.

  9. 9·Borrow

    Against that collateral, borrow_amount of borrow_token is borrowed from aave_market.

  10. 10·Get address

    Loading the solver address into a named value sets the destination for the transfer that follows.

  11. 11·Get token balance

    Reading the supply_token balance held by 0x4844...3a88 captures the holding before routing begins.

  12. 12·Transfer tokens

    Sending borrow_amount of borrow_token to the solver hands the borrowed funds over to be routed.

  13. 13·Get solution

    The solver takes the transferred tokens for routing, then the outcome is verified.

  14. 14·Get token balance

    After routing, the supply_token balance held by 0x4844...3a88 is read again.

  15. 15·Calculate

    Subtracting the pre-routing balance from the post-routing balance measures how much supply_token routing produced.

  16. 16·Compare two values

    Comparing that gain against wind_loan_owed tests whether it is greater than or equal to the loan owed.

  17. 17·Predicate

    A require enforces that comparison be true, aborting the transaction if the gain does not cover wind_loan_owed.

  18. 18·End block

    Closing the innermost open block ends the coverage check.

  19. 19·End block

    Closing the remaining open block completes the composed wind transaction.

Take
Take
Take
Take
Take
Flash loan from
Set to
Supply to
Borrow from
Get
Get balance of held by
Transfer to
Get solution
Get balance of held by
Calculate
Is
End block
End block
  • Aave: Wind or Unwind Position

    plug
    boolean
    aave
  • Wind

    plug
    aave
    evm
  • Unwind

    plug
    aave
    evm

On other protocols · 2