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 variable debt position, returning the amount actually repaid. Set the amount to max 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

    Declares repay_amount as a caller-supplied parameter, the quantity to be repaid at execution.

  2. 2·Take

    Adds borrow_token as a caller-supplied parameter, naming the asset being repaid.

  3. 3·Take

    Names aave_market as a caller-supplied parameter identifying the market used throughout this transaction.

  4. 4·Take

    Introduces withdraw_amount as a caller-supplied parameter, the quantity to withdraw.

  5. 5·Take

    Rounds out the inputs with supply_token as a caller-supplied parameter, naming the collateral asset to withdraw.

  6. 6·Flash loan

    Takes a flash loan of [repay_amount] in [borrow_token] from [aave_market], to be repaid within this same transaction.

  7. 7·Set

    Saves the flash loan repayment obligation from slot 5.5 into unwind_loan_owed for a later check.

  8. 8·Repay

    Repays [repay_amount] of [borrow_token] to [aave_market] from the socket's balance, clearing the outstanding debt.

  9. 9·Withdraw

    Withdraws [withdraw_amount] of [supply_token] from [aave_market] back to the socket now that the debt is cleared.

  10. 10·Get address

    Loads the solver address into a named value for use as a transfer destination.

  11. 11·Get token balance

    Reads the [borrow_token] balance held by 0x4844...3a88 before routing.

  12. 12·Transfer tokens

    Sends [withdraw_amount] of [supply_token] to [the solver] to be routed.

  13. 13·Get solution

    Hands the transferred tokens to the solver for routing, then verifies the outcome.

  14. 14·Get token balance

    Reads the [borrow_token] balance held by 0x4844...3a88 again after routing.

  15. 15·Calculate

    Subtracts the pre-routing balance in slot 10.1 from the post-routing balance to measure how much [borrow_token] came back from routing.

  16. 16·Compare two values

    Checks whether that gain is greater than or equal to unwind_loan_owed.

  17. 17·Predicate

    Requires that comparison to hold true, aborting the transaction if the gain does not cover the loan owed.

  18. 18·End block

    Closes the innermost open block.

  19. 19·End block

    Closes the remaining open block.

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
  • Loop WETH/USDC at Target HF

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

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

    database
    boolean
    aave
  • Borrow + Term Repayment Schedule

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

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

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

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

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

    aave
    boolean
    evm

On other protocols · 4