Repay
Repay

Aave · Acts onchain

Repays borrowed assets to an Aave market from the socket's balance. The socket approves the pool and calls repay on the wallet's variable debt position, returning the amount actually repaid. Pick Repay all to clear the full debt, interest included; the approval is reset afterward. Any excess over the outstanding debt is not pulled. Reach for it to close or reduce a borrow before withdrawing collateral, to bring the health factor back above a floor when a predicate finds it has slipped, or to settle the debt leg after a swap has produced the repayment asset earlier in the transaction.

Unwind

plug
aave
evm
19actions
  1. 1·Take

    Take opens by declaring repay_amount as a caller parameter, sizing the debt repaid to Aave later in this flow.

  2. 2·Take

    Next, borrow_token is declared as a caller parameter, naming the debt asset flash-borrowed and repaid.

  3. 3·Take

    The market address aave_market is taken as a caller parameter, resolving every Aave action here to one market.

  4. 4·Take

    Also taken is withdraw_amount, a caller parameter sizing the collateral pulled out of the market.

  5. 5·Take

    Rounding out the inputs, supply_token is declared as a caller parameter, naming the collateral asset withdrawn.

  6. 6·Flash loan

    A flash loan pulls repay_amount of borrow_token from aave_market, repaid within this same transaction.

  7. 7·Set

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

  8. 8·Repay

    Repaying repay_amount of borrow_token to aave_market clears the outstanding debt using the flash-loaned funds.

  9. 9·Withdraw

    With the debt cleared, withdraw_amount of supply_token is withdrawn from aave_market back to the socket.

  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 borrow_token balance held by 0x4844...3a88 captures the holding before routing begins.

  12. 12·Transfer tokens

    Sending withdraw_amount of supply_token to the solver hands the freed collateral over for routing.

  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 borrow_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 borrow_token routing produced.

  16. 16·Compare two values

    Comparing that gain against unwind_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 unwind_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 unwind transaction.

Take
Take
Take
Take
Take
Flash loan from
Set to
Repay to
Withdraw from
Get
Get balance of held by
Transfer to
Get solution
Get balance of held by
Calculate
Is
End block
End block
  • Unwind

    plug
    aave
    evm
  • Wind or Unwind to Maintain Target HF

    plug
    aave
    math
  • Borrow + Weekly Repayments

    time
    aave
    evm
  • Borrow Rate Exit Guard (WETH/USDC Loop)

    boolean
    aave
    evm
  • Trailing Stop Loss (WETH/USDC Loop)

    boolean
    aave
    evm
  • Take Profit (WETH/USDC Loop)

    boolean
    aave
    evm
  • Loop at Target HF + Borrow Rate Entry & Exit Guard

    aave
    boolean
    evm
  • Loop WETH/USDC at Target HF

    aave
    evm
    boolean
  • Borrow + Term Repayment Schedule

    time
    database
    boolean
  • Loop at Target HF + Borrow Rate Exit Guard

    database
    boolean
    aave
  • Loop at Target HF + Trailing Stop Loss

    database
    boolean
    aave
  • Swarm: Loop WETH/USDC at Target HF

    boolean
    aave
    evm
  • Stop Loss (WETH/USDC Loop)

    boolean
    aave
    evm

On other protocols · 5