Read global flag
Read global flag

Boolean · Acts onchain

Reads a boolean flag from the socket's global storage by key. The flag lives in socket-scoped storage that persists across transactions and is shared by every plug the socket runs. The read returns the committed value, so a set earlier in the same transaction is not reflected until it lands. Reach for it to coordinate plugs: read a flag another plug set, then branch on it with a predicate, so one run can mark a milestone and later runs react to it.

Strategy: Loop WETH/USDC at Target HF + Stop Loss

boolean
aave
evm
8actions
  1. 1·Read global flag

    Reads the boolean flag exited_weth/usdc_swarm from the socket's global storage so the run can tell whether this loop is already closed.

  2. 2·Predicate

    Requiring that flag to equal false, this halts the whole plug if the loop was already exited so nothing runs against a closed position.

  3. 3·Get asset data

    Fetching Aave reserve data for WETH at 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 in the Ethereum market at 0x2f39d218133afab8f2b819b1066c7e434ad94e9e, this pulls live rates and token addresses.

  4. 4·Get token balance

    Looking up the token balance for the token named in slot 2.1.8 held by 0x484428507A212cA56D71baa27Ca6089a6dB63a88, this reads the position held at that address.

  5. 5·Get asset data

    Also pulling Aave reserve data for USDC at 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, with the market wired from slot 2.1 so it matches the WETH reserve's market.

  6. 6·Use

    Composes the plug Supply if aToken Balance is 0, which opens the position by supplying when no aToken is yet held.

  7. 7·Use

    Running the plug Wind or Unwind to Maintain Target HF, this adjusts borrow and collateral to hold the loop at its target health factor.

  8. 8·Use

    Composes the plug Stop Loss, which unwinds and closes the loop when its stop loss condition is met.

Read global flag
Get asset data of in
Get balance of held by
Get asset data of in
Use where
supply_tokenis
aave_marketis
holder_walletis
supply_amountis
Use where
aave_marketis
supply_tokenis
target_health_factoris
borrow_tokenis
Use where
supply_tokenis
aave_marketis
holder_walletis
stop_loss_priceis
global_flag_keyis
borrow_tokenis
  • Strategy: Loop WETH/USDC at Target HF + Stop Loss

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

    boolean
    aave
    evm
  • Swarm: Loop WETH/USDC at Target HF

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

On other protocols · 1