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
34actions
  1. 1·Take

    Declares supply_amount as a caller-supplied parameter whose value is provided at execution time.

  2. 2·Take

    Adds supply_token as a caller-supplied parameter naming the asset to supply.

  3. 3·Take

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

  4. 4·Take

    Introduces borrow_amount as a caller-supplied parameter, the quantity to borrow.

  5. 5·Take

    Declares borrow_token as a caller-supplied parameter naming the asset to borrow.

  6. 6·Take

    Rounds out the inputs with is_winding, a caller-supplied flag that selects between the wind and unwind paths.

  7. 7·Predicate

    An if opens on the is_winding flag being equal to 1, entering the wind path when the caller set it true.

  8. 8·Flash loan

    Takes a flash loan of the supply_amount in the supply_token from the aave_market, to be repaid within this same transaction.

  9. 9·Set

    Saves the flash loan repayment obligation into wind_loan_owed for a later check.

  10. 10·Supply

    Supplies the supply_amount of the supply_token into the aave_market, minting aTokens to the socket as collateral.

  11. 11·Borrow

    Borrows the borrow_amount of the borrow_token from the aave_market against the collateral just supplied.

  12. 12·Get address

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

  13. 13·Get token balance

    Reads the supply_token balance held by 0x4844...3a88 before routing.

  14. 14·Transfer tokens

    Sends the borrow_amount of the borrow_token to the solver to be routed.

  15. 15·Get solution

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

  16. 16·Get token balance

    Reads the supply_token balance held by 0x4844...3a88 again after routing.

  17. 17·Calculate

    Subtracts the pre-routing balance from the post-routing balance to measure how much supply_token was gained.

  18. 18·Compare two values

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

  19. 19·Predicate

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

  20. 20·End block

    Closes the wind branch opened above.

  21. 21·Else branch

    Opens the else branch for the case where is_winding is not true, the unwind path.

  22. 22·Flash loan

    Takes a flash loan of the borrow_amount in the borrow_token from the aave_market, to be repaid within this same transaction.

  23. 23·Set

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

  24. 24·Withdraw

    Withdraws the supply_amount of the supply_token from the aave_market back to the socket now that the borrow is covered by the flash loan.

  25. 25·Get address

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

  26. 26·Get token balance

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

  27. 27·Transfer tokens

    Sends the supply_amount of the supply_token to the solver to be routed.

  28. 28·Get solution

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

  29. 29·Get token balance

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

  30. 30·Calculate

    Subtracts the pre-routing balance from the post-routing balance to measure how much borrow_token came back from routing.

  31. 31·Compare two values

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

  32. 32·Predicate

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

  33. 33·End block

    Closes the unwind branch.

  34. 34·End block

    Closes the remaining open conditional block.

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
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
  • Card: Buy $50 WBTC With USDC Once a Week

    time
    values
    math
  • Card: Buy an 18 Dec Token With X% of USDC

    plug
    evm
    math
  • Card: Sell X% of an 18 Dec Token for USDC

    plug
    evm
    math
  • Card: Sell 18 Dec Token for USDC

    plug
    chainlink
    math
  • Card: Sell 8 Dec Token for USDC

    plug
    chainlink
    math
  • Card: Buy 8 Dec Token With USDC

    plug
    chainlink
    values
  • Card: Buy 18 Dec Token With USDC

    plug
    chainlink
    values
  • Card: Sell 10% of ETH for USDC

    evm
    math
    chainlink
  • Card: Buy ETH With 10% of USDC

    evm
    math
    chainlink
  • Card: Sell $25 ETH for USDC

    values
    math
    chainlink
  • Card: Buy $25 ETH With USDC

    values
    math
    chainlink
  • 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
  • Exit Morpho at Epoch End

    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
  • Wind or Unwind to Maintain Target HF

    plug
    aave
    math
  • Supply if a Token Balance Is 0

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

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