End block
End block

Logic · Acts onchain

Closes the innermost open block, whether a conditional branch or a loop. Every if, if not, else if, else, for, until, and while needs a matching End; for loops, reaching End returns to the loop start for the next condition check. Reach for it to mark where a branch or loop body stops and unconditional execution resumes, so the steps after it run on every path.

Takes nothing — it reads the caller's own position.

Card: Buy $50 WBTC With USDC Once a Week

time
values
math
20actions
  1. 1·Repeat

    This plug is rate limited to run at most once every two weeks, so it can fire only a single time per fortnight.

  2. 2·Get constant

    A named constant WAD equal to 1e18 is loaded for later math involving 18 decimal scaling.

  3. 3·Calculate

    Fifty is multiplied by the WAD constant, scaling the number fifty up to 18 decimals.

  4. 4·Get constant

    The basis-point denominator of 10,000 is loaded as a named constant.

  5. 5·Calculate

    From the scaled fifty in slot 3.0, fifty is subtracted, producing that scaled value minus a plain fifty.

  6. 6·Calculate proportional value

    A proportion is taken: 10,000 basis points of the WAD value, which is the whole of it since 10,000 basis points equals one hundred percent.

  7. 7·Get price

    The latest Chainlink price of BTC in USD is read, normalized to 18 decimals.

  8. 8·Calculate

    Ten is raised to the power of eight, giving the factor for eight decimals.

  9. 9·Multiply then divide

    Multiplying the value from slot 5.0 by the BTC price and dividing by the value in slot 6.7, rounding down, computes a scaled expected amount.

  10. 10·Get token balance

    The socket's own WBTC balance is read before any swap happens.

  11. 11·Get address

    The solver address is held as a named value for use as the transfer destination.

  12. 12·Calculate

    Ten is raised to the power of six, giving the factor for six decimals matching USDC.

  13. 13·Calculate

    Fifty is multiplied by the six-decimal factor, producing fifty USDC in base units.

  14. 14·Transfer tokens

    That fifty USDC is transferred to the balance-holder address referenced from slot 10.0.

  15. 15·Get solution

    The solver takes the transferred tokens, routes them, and the outcome is verified.

  16. 16·Get token balance

    After routing, the socket's WBTC balance is read again.

  17. 17·Calculate

    Subtracting the pre-swap WBTC balance from the post-swap balance yields the WBTC actually received.

  18. 18·Predicate

    A requirement enforces that the WBTC received is greater than or equal to the expected amount from slot 8.0, reverting otherwise.

  19. 19·End block

    The open block is closed here.

  20. 20·Bubble

    The WBTC received amount is surfaced as the output of this plug.

Repeat up to x every
Get constant
Calculate
Get constant
Calculate
Calculate of
Get price of in
Calculate
Calculate times divided by rounded
Get balance of held by
Get
Calculate
Calculate
Transfer to
Get solution
Get balance of held by
Calculate
End block
Bubble
  • 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
  • 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
  • Aave: Wind or Unwind Position

    plug
    boolean
    aave
  • Target Debt to Debt Delta

    plug
    aave
    boolean
  • Wind

    plug
    aave
    evm
  • Unwind

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