


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.
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.
Strategy: Loop WETH/USDC at Target HF + Stop Loss



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 looped position was already closed.
2·Predicate
Requiring that flag to equal false, this halts the whole plug when the loop has already exited, so nothing runs against a closed position.
3·Get asset data
Fetches Aave reserve data for WETH at 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 in the Ethereum market at 0x2f39d218133afab8f2b819b1066c7e434ad94e9e, pulling live rates and token addresses.
4·Get token balance
Looking up the token balance for the token named in slot 2.1.8 held by 0x484428507A212cA56D71baa27Ca6089a6dB63a88, this reads the current supply position.
5·Get asset data
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·Use
Composes the plug Supply if aToken Balance is 0, which opens the collateral position when none exists yet.
7·Use
Running the plug Wind or Unwind to Maintain Target HF, this adjusts the loop toward its target health factor.
8·Use
Composes the plug Stop Loss last, which unwinds the position when the stop loss condition is met.
Dollar-cost average on Base · 4 plugs
Posts · 1
More on Boolean · 4





On other protocols · 1