
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



1·Take
Declares repay_amount as a caller-supplied parameter, the quantity to be repaid at execution.
2·Take
Adds borrow_token as a caller-supplied parameter, naming the asset being repaid.
3·Take
Names aave_market as a caller-supplied parameter identifying the market used throughout this transaction.
4·Take
Introduces withdraw_amount as a caller-supplied parameter, the quantity to withdraw.
5·Take
Rounds out the inputs with supply_token as a caller-supplied parameter, naming the collateral asset to withdraw.
6·Flash loan
Takes a flash loan of [repay_amount] in [borrow_token] from [aave_market], to be repaid within this same transaction.
7·Set
Saves the flash loan repayment obligation from slot 5.5 into unwind_loan_owed for a later check.
8·Repay
Repays [repay_amount] of [borrow_token] to [aave_market] from the socket's balance, clearing the outstanding debt.
9·Withdraw
Withdraws [withdraw_amount] of [supply_token] from [aave_market] back to the socket now that the debt is cleared.
10·Get address
Loads the solver address into a named value for use as a transfer destination.
11·Get token balance
Reads the [borrow_token] balance held by 0x4844...3a88 before routing.
12·Transfer tokens
Sends [withdraw_amount] of [supply_token] to [the solver] to be routed.
13·Get solution
Hands the transferred tokens to the solver for routing, then verifies the outcome.
14·Get token balance
Reads the [borrow_token] balance held by 0x4844...3a88 again after routing.
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·Compare two values
Checks whether that gain is greater than or equal to unwind_loan_owed.
17·Predicate
Requires that comparison to hold true, aborting the transaction if the gain does not cover the loan owed.
18·End block
Closes the innermost open block.
19·End block
Closes the remaining open block.
On other protocols · 4