


Acts onchain
Steers control flow by comparing two values: branch, loop, or require the condition holds. The verb decides the shape. if, if not, and else if open a branch; for and until open a loop that re-evaluates the comparison every iteration; require reverts the whole transaction when the condition is false. Operators cover equal, not equal, greater, greater or equal, less, less or equal, and, and or. Reach for it to guard a write behind a read, such as requiring a health factor stays above a floor, to branch between two strategies on a price, or to repeat a step until a balance target is met. Use the comparison action when you need the boolean as a value.
Plug lets you combine onchain actions like this one into a single transaction, without writing a smart contract. Use in App opens a new plug with this action already in it.
Aave: Wind or Unwind Position



1·Take
Take opens by declaring supply_amount as a caller parameter, sizing the collateral leg fed into the wind flash loan and supply below.
2·Take
Next, supply_token is declared as a caller parameter, naming the collateral asset used across the Aave actions on the wind side.
3·Take
The market address aave_market is taken as a caller parameter, binding every Aave action here to one market.
4·Take
Also taken is borrow_amount, a caller parameter sizing the debt leg drawn against the collateral.
5·Take
Rounding out the asset inputs, borrow_token is declared as a caller parameter, naming the debt asset.
6·Take
Finally is_winding is declared as a caller parameter, the flag that selects between the wind and unwind paths.
7·Predicate
Comparing is_winding against 1, this predicate opens the wind branch that runs only when the flag reads true.
8·Flash loan
On the wind side, a flash loan pulls supply_amount of supply_token from aave_market, repaid within this same transaction.
9·Set
The repayment obligation returned by that flash loan is saved into wind_loan_owed for the coverage check below.
10·Supply
Supplying supply_amount of supply_token to aave_market mints aTokens to the wallet as collateral.
11·Borrow
Against that collateral, borrow_amount of borrow_token is borrowed from aave_market.
12·Get address
Loading the solver address into a named value sets the destination for the transfer that follows.
13·Get token balance
Reading the supply_token balance held by your wallet captures the holding before routing begins.
14·Transfer tokens
Sending borrow_amount of borrow_token to the solver hands the borrowed funds over for routing.
15·Get solution
The solver takes the transferred tokens for routing, then the outcome is verified.
16·Get token balance
After routing, the supply_token balance held by your wallet is read again.
17·Calculate
Subtracting the pre-routing balance from the post-routing balance measures how much supply_token routing produced.
18·Compare two values
Comparing that gain against wind_loan_owed tests whether it is greater than or equal to the loan owed.
19·Predicate
A require enforces that comparison be true, aborting if the gain does not cover wind_loan_owed.
20·End block
Closing the innermost open block ends the wind coverage check.
21·End block
Closing the next open block ends the wind branch.
22·Else branch
Opening the else branch, this defines the unwind path taken when is_winding is not true.
23·Flash loan
On the unwind side, a flash loan pulls borrow_amount of borrow_token from aave_market, repaid within this same transaction.
24·Set
The repayment obligation returned by that flash loan is saved into unwind_loan_owed for the coverage check below.
25·Withdraw
Withdrawing supply_amount of supply_token from aave_market pulls the supplied collateral back to the socket.
26·Get address
Loading the solver address into a named value sets the destination for the unwind transfer.
27·Get token balance
Reading the borrow_token balance held by your wallet captures the holding before routing begins.
28·Transfer tokens
Sending supply_amount of supply_token to the solver hands the freed collateral over for routing.
29·Get solution
The solver takes the transferred tokens for routing, then the outcome is verified.
30·Get token balance
After routing, the borrow_token balance held by your wallet is read again.
31·Calculate
Subtracting the pre-routing balance from the post-routing balance measures how much borrow_token routing produced.
32·Compare two values
Comparing that gain against unwind_loan_owed tests whether it is greater than or equal to the loan owed.
33·Predicate
A require enforces that comparison be true, aborting if the gain does not cover unwind_loan_owed.
34·End block
Closing the innermost open block ends the unwind coverage check.
35·End block
Closing the next open block ends the unwind branch.
36·End block
Closing the remaining open block completes the composed wind-or-unwind transaction.
Dollar-cost average on Base · 4 plugs
Posts · 18
More on Boolean · 4