Predicate
Predicate

Boolean · 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.

Aave: Wind or Unwind Position

plug
boolean
aave
36actions
  1. 1·Take

    Opens by declaring supply_amount, a caller parameter set at execution time to size the collateral leg.

  2. 2·Take

    Declaring supply_token next, a caller parameter, names the collateral asset the flow moves.

  3. 3·Take

    Taking aave_market as a caller parameter resolves every Aave action in this plug to one market.

  4. 4·Take

    Following that, borrow_amount is declared, the caller-supplied figure sizing the debt leg.

  5. 5·Take

    A parameter borrow_token is taken from the caller, naming the debt asset.

  6. 6·Take

    Rounding out the inputs, is_winding is declared, the caller flag selecting the wind or unwind path.

  7. 7·Predicate

    An if opens on the is_winding flag equalling 1, entering the wind path only when that holds.

  8. 8·Flash loan

    On the wind path, a flash loan pulls the supply_amount of supply_token from the market, repaid within this transaction.

  9. 9·Set

    The repayment obligation from that flash loan is saved into wind_loan_owed for the coverage check below.

  10. 10·Supply

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

  11. 11·Borrow

    Against that collateral, the borrow_amount of borrow_token is borrowed from the market.

  12. 12·Get address

    The Solver is held here as a named value, standing as the destination for the transfer that follows.

  13. 13·Get token balance

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

  14. 14·Transfer tokens

    Sending the borrow_amount of borrow_token to the solver hands the borrowed funds over for routing.

  15. 15·Get solution

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

  16. 16·Get token balance

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

  17. 17·Calculate

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

  18. 18·Compare two values

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

  19. 19·Predicate

    A require enforces that comparison equal true, aborting if the gain fails to cover wind_loan_owed.

  20. 20·End block

    Closing the innermost open block ends the wind coverage check.

  21. 21·End block

    Closing the next open block closes the wind branch.

  22. 22·Else branch

    An else opens for the unwind path, when the is_winding flag was not 1.

  23. 23·Flash loan

    On this path, a flash loan pulls the borrow_amount of borrow_token from the market, repaid within this transaction.

  24. 24·Set

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

  25. 25·Withdraw

    Withdrawing the supply_amount of supply_token from the market pulls the collateral back to the socket.

  26. 26·Get address

    The Solver is held here again as a named value, the destination for the transfer that follows.

  27. 27·Get token balance

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

  28. 28·Transfer tokens

    Sending the supply_amount of supply_token to the solver hands the withdrawn collateral over for routing.

  29. 29·Get solution

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

  30. 30·Get token balance

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

  31. 31·Calculate

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

  32. 32·Compare two values

    Testing that gain against unwind_loan_owed returns whether it is greater than or equal to the loan owed.

  33. 33·Predicate

    A require enforces that comparison equal true, aborting if the gain fails to cover unwind_loan_owed.

  34. 34·End block

    Closing the innermost open block ends the unwind coverage check.

  35. 35·End block

    Closing the next open block closes the unwind branch.

  36. 36·End block

    Closing the remaining open block completes the composed transaction.

Take
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
Else
Flash loan from
Set to
Withdraw from
Get
Get balance of held by
Transfer to
Get solution
Get balance of held by
Calculate
Is
End block
End block
End block
  • Unstake From Lido, Claim It When It Clears, Restake It

    plug
    database
    boolean
  • Pendle Leveraged PT Auto Rollover

    plug
    pendle
    time
  • Dust Guard

    plug
    boolean
  • Raw Weights to Percents

    plug
    evm
    boolean
  • Get Simple Moving Average

    plug
    time
    chainlink
  • Rebalance Holdings to Target

    plug
    values
    evm
  • Get Total Holdings Value

    plug
    evm
    boolean
  • Swap at Floor

    plug
    evm
    values
  • Morpho: Auto Leverage Trigger

    plug
    morpho
    math
  • Swap

    plug
    values
    evm
  • Morpho: Refinance to Cheaper Borrow Market

    morpho
    plug
    boolean
  • Morpho Pendle Expiry Deleveraging

    pendle
    time
    boolean
  • Find Value Delta

    plug
    boolean
    evm
  • Morpho: Get Health Factor

    plug
    boolean
    evm
  • Aave: Wind or Unwind Position

    plug
    boolean
    aave
  • Target Debt to Debt Delta

    plug
    aave
    boolean
  • Wind

    plug
    aave
    evm
  • Unwind

    plug
    aave
    evm
  • Dust Guard

    plug
    boolean
    evm
  • Strategy: Loop WETH/USDC at Target HF + Stop Loss

    boolean
    aave
    evm
  • Wind or Unwind to Maintain Target HF

    plug
    aave
    math
  • Supply if a Token Balance Is 0

    plug
    aave
    evm
  • Supply Idle Balance Weekly

    time
    evm
    boolean
  • Borrow + Weekly Repayments

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

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

    boolean
    aave
    evm
  • Loop WETH/USDC at Target HF

    aave
    evm
    boolean
  • Borrow + Term Repayment Schedule

    time
    database
    boolean
  • Trailing Stop Loss (WETH/USDC Loop)

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

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

    aave
    boolean
    evm
  • 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