{"skill":{"slug":"rerange-skill","displayName":"Skills","summary":"Build, preview, monitor, rerange, close, and risk-check non-custodial Rerange liquid orders using @rerange/wagmi.","description":"---\nname: rerange\ndescription: Build, preview, monitor, rerange, close, and risk-check non-custodial Rerange liquid orders using @rerange/wagmi.\nhomepage: https://rerange.xyz\nmetadata: {\"openclaw\":{\"homepage\":\"https://rerange.xyz\",\"requires\":{\"bins\":[\"node\"]}}}\n---\n\n# Rerange Skill\n\nUse this skill when a user or agent needs to discover Rerange deployments,\nconstruct liquid orders, monitor order state, run permissionless reranges,\nmanage user vault delegation, compose bounded strategies, or perform safety\npreflight checks.\n\nRerange is a non-custodial liquidity execution protocol:\n\n```text\nintent -> directional concentrated-liquidity order -> monitored execution\n```\n\nUse `@rerange/wagmi` as the SDK boundary for ABIs, generated contract actions,\nand canonical deployment metadata. Do not reconstruct hub or vault addresses\nmanually when the SDK can provide them.\n\n## SDK Execution\n\nThis skill includes a Node helper at `{baseDir}/index.js`.\n\nRun it with:\n\n```bash\nnode {baseDir}/index.js <command> [args]\n```\n\nThe helper imports `@rerange/wagmi`; in this repository it can also fall back to\nthe local built SDK at `../sdk/dist/index.js` for development.\n\nCommands:\n\n- `deployments [chainId]`: print all supported deployments or one deployment.\n- `abi hub|vault`: print the selected ABI from `@rerange/wagmi`.\n- `encode hub|vault <functionName> <jsonArgs>`: encode calldata without signing.\n- `read <chainId> hub|vault <address> <functionName> <jsonArgs> [rpcUrl]`: perform a read-only contract call.\n\nExamples:\n\n```bash\nnode {baseDir}/index.js deployments\nnode {baseDir}/index.js deployments 8453\nnode {baseDir}/index.js abi hub\nnode {baseDir}/index.js encode hub getOrderState '[\"0x...orderKey\"]'\nnode {baseDir}/index.js read 8453 hub 0x888956E46d2af8F6B2890a39E55542219F4bd192 hubConfig '[]' https://mainnet.base.org\n```\n\nThe helper never signs transactions and never asks for private keys. For writes,\nreturn unsigned transaction intent, wagmi action name, target contract, calldata,\nvalue, and safety status so a wallet-connected runtime can simulate and submit.\n\n## Shared Rules\n\n- Use `getOrderState(orderKey)` as the canonical order state read.\n- Use `previewOpen`, `previewRerange`, and `previewClose` before submitting\n  transactions.\n- Treat target price as fixed user intent. Reranging moves the live liquidity\n  window, not the execution objective.\n- Keep token prices in user units until the integration boundary, then convert\n  to ticks.\n- Use canonical pool token order for `token0` and `token1`; `isSell` identifies\n  which token is being sold.\n- Respect `hubConfig.paused`, `hubConfig.rerangeCooldown`, adapter safety\n  checks, and gas economics.\n- Never grant an agent withdrawal authority. `setAgent` is for scoped order\n  management, not custody.\n- Never request, store, or handle private keys or seed phrases.\n\n## Recommended Agent Flow\n\n1. Run protocol discovery to resolve deployment metadata, token metadata,\n   adapter allowlist status, pool data, and vault or order identity.\n2. Run safety and risk checks before any state-changing action.\n3. For a new user intent, build order parameters, then submit `open` or `open2`\n   only after fresh preview, funding, and simulation checks.\n4. Persist the returned or emitted `orderKey`, then monitor with live\n   `getOrderState`.\n5. Use resolver rerange only for maintenance actions that pass preview,\n   cooldown, adapter safety, and gas policy.\n6. Use vault management only for owner-authorized vault, delegation, close, and\n   direct withdrawal workflows.\n\n## Protocol Discovery\n\nUse discovery before any other Rerange action. It resolves the chain,\ndeployment, adapters, tokens, pools, vaults, order keys, and live hub config.\n\nRequired inputs:\n\n```json\n{\n  \"chain_id\": \"<chain-id-from-deployments>\",\n  \"owner\": \"<owner-address>\",\n  \"from_token\": \"WETH\",\n  \"to_token\": \"USDC\",\n  \"order_key\": \"<order-key>\",\n  \"vault\": \"<vault-address>\",\n  \"order_index\": 0\n}\n```\n\nOnly `chain_id` is always required. Interpret optional identifiers in this\npriority order: `order_key`, `(vault, order_index)`, `vault`, `owner`.\n\nRequired reads:\n\n- Deployment metadata from `@rerange/wagmi`.\n- `RerangeHub.hubConfig()`\n- `RerangeHub.adapters(adapter)`\n- `RerangeHub.vaults(owner)` as the next vault index upper bound.\n- `RerangeHub.predictVault(owner, vaultIndex)`\n- `RerangeHub.vaultOrderCount(vault)`\n- `RerangeHub.getOrderKey(vault, orderIndex)`\n- `RerangeHub.getOrder(orderKey)` when reconstructing existing order metadata.\n- `RerangeHub.getOrderState(orderKey)`\n\nPool selection must prefer pools where token order is canonical, adapter is\nallowed, usable liquidity exists near current tick, fee tier fits the execution\nhorizon, and tokens are supported. Rank valid pools by live liquidity, then\nhistorical volume, then fee tier suitability. For large orders, require live or\nindexed liquidity data.\n\nFor a new order with no explicit vault, read `vaults(owner)`, call\n`predictVault(owner, vaultIndex)`, use that predicted address in `previewOpen`,\nthen let `open` create the vault or create it explicitly with `createVault`.\n\nReturn a blocking error when the chain is unsupported, the hub is paused,\nadapter is not allowed, token is unsupported or ambiguous, no valid pool exists,\nan order key cannot be resolved, or required reads fail through healthy RPC.\n\n## Intent Order Builder\n\nUse this for `sell_high`, `buy_low`, `passive_exit`, and `rebalance_step`\nintents. DCA and grid strategies are composed by the strategy composer.\n\nRequired inputs:\n\n```json\n{\n  \"chain_id\": \"<chain-id-from-deployments>\",\n  \"owner\": \"<owner-address>\",\n  \"intent\": \"sell_high\",\n  \"from_token\": \"WETH\",\n  \"to_token\": \"USDC\",\n  \"amount\": \"1.0\",\n  \"target_price\": 3500,\n  \"trigger_bps\": 500,\n  \"pool\": \"<pool-address>\",\n  \"risk_profile\": \"moderate\",\n  \"referrer\": \"ZERO_ADDRESS\",\n  \"keep_balances_in_vault\": false,\n  \"unwrap_out\": false\n}\n```\n\nConstruction rules:\n\n1. Resolve deployment, tokens, adapters, and candidate pools.\n2. Convert `amount` into raw token units using source token decimals.\n3. Canonically sort the pool pair into `token0` and `token1`.\n4. Set `isSell = true` when source token is `token0`; otherwise `false`.\n5. Convert `target_price` into `targetTick` using canonical pool token order.\n6. Convert `trigger_bps` into `triggerTicks`, or default to the tick distance\n   between current price and target.\n7. Resolve `risk_profile` into concrete adapter policy values.\n8. Encode adapter config with pool, fee tier, TWAP, tick drift, and slippage.\n9. Call `previewOpen(owner, params)`.\n10. Return unsigned transaction parameters only after preview succeeds.\n\nRisk profile defaults:\n\n```json\n{\n  \"conservative\": {\"max_slippage_bps\": 50, \"max_twap_deviation_ticks\": 50, \"max_tick_deviation\": 50},\n  \"moderate\": {\"max_slippage_bps\": 100, \"max_twap_deviation_ticks\": 100, \"max_tick_deviation\": 100},\n  \"aggressive\": {\"max_slippage_bps\": 150, \"max_twap_deviation_ticks\": 150, \"max_tick_deviation\": 150}\n}\n```\n\nIf no mapping is configured, ignore `risk_profile` and require concrete adapter\npolicy fields.\n\nCreate order parameter shape:\n\n```json\n{\n  \"vault\": \"ZERO_ADDRESS\",\n  \"adapter\": \"<adapter-address-from-deployments>\",\n  \"token0\": \"<canonical-token0-address>\",\n  \"token1\": \"<canonical-token1-address>\",\n  \"capital\": \"1000000000000000000\",\n  \"isSell\": true,\n  \"targetTick\": -195000,\n  \"triggerTicks\": 300,\n  \"adapterConfig\": \"<encoded-adapter-config>\",\n  \"referrer\": \"ZERO_ADDRESS\",\n  \"keepBalancesInVault\": false,\n  \"unwrapOut\": false\n}\n```\n\nUse `open(params)` after approval or vault prefunding. Use\n`open2(params, permit, signature)` only when the owner provides Permit2. Always\nrefresh `previewOpen(owner, params)` before submission.\n\nBlock order construction when target direction is wrong, capital is zero, hub is\npaused, adapter is not allowed, preview reverts, immediate flow has no activation\nplan, current tick drifted materially, funding cannot be proven, or the user\nasks to bypass slippage, TWAP, or liquidity checks.\n\n## Order Monitor\n\nUse monitoring for open Rerange orders because they are persistent liquidity\npositions, not one-time swaps.\n\nAt least one of `order_key`, `(vault, order_index)`, or `owner` is required.\n\nRequired reads:\n\n- `getOrderState(orderKey)`\n- `isOrderClosed(orderKey)`\n- `previewRerange(orderKey)` for actionability\n- `hubConfig()` for pause and cooldown state\n- `previewClose(orderKey)` before user-requested close\n- Events: `OrderOpened`, `OrderReranged`, `OrderClosed`, `VaultCreated`,\n  `OrderExecuted`\n\nMap live protocol state into agent states: `OPEN`, `ACTIVE`, `IN_RANGE`,\n`OUT_OF_RANGE`, `RERANGEABLE`, `COMPLETED`, `CLOSED`, and `ACTION_BLOCKED`.\nNever persist stale lifecycle state as truth; refresh from `getOrderState`.\n\nPersist minimal memory: chain id, order key, owner, vault, order index, intent,\ntokens, target tick, trigger ticks, creation time, last seen status, last rerange\ntime, and last progress bps. Reconstruct tokens from `token0`, `token1`, and\n`isSell`; do not invent symbols when metadata is missing.\n\nMonitor active user-facing orders every 5 to 15 minutes, resolver candidates\nfrom every block to every 5 minutes, passive portfolio reports every 30 to 60\nminutes, and event logs after restart or missed RPC intervals.\n\nDo not infer final status from event logs alone. Do not trigger rerange purely\nbecause a range was exited; always preview and check cooldown.\n\n## Resolver Rerange\n\nUse this for permissionless resolvers that advance or close orders by calling\n`rerange` or `batchRerange`. Resolvers do not need vault ownership. Resolver\nrewards are paid only from target-asset fees.\n\nBuild candidates from `OrderOpened` logs, local indexed open orders, watchlists,\nand `OrderReranged` events. Drop candidates when `isOrderClosed(orderKey)` is\ntrue.\n\nRequired reads per candidate:\n\n1. `getOrderState(orderKey)`\n2. `hubConfig()`\n3. `previewRerange(orderKey)`\n4. Current gas estimate and target-token value for expected reward.\n\nFor permissionless `rerange(orderKey)`, enforce\n`block.timestamp >= order.lastRerangeAt + hubConfig.rerangeCooldown`.\n\nA candidate is executable only when preview succeeds and will close, will\nactivate, is economically justified while in range, price is inside the trigger\nband around target, or price crossed the target and the action will close.\n\nSubmit only when:\n\n```text\nexpected_target_asset_reward_value >= gas_cost * required_margin\n```\n\nUse `1.2` for private routing and `1.5` for public mempool unless policy says\notherwise. Include L1 data fee on L2 networks. Ignore non-target-asset fees for\nresolver reward estimation. For sell orders target token is `token1`; for buy\norders target token is `token0`.\n\nUse `rerange(orderKey)` for a single candidate, manager overloads only with\nexplicit authority, and `batchRerange(orderKeys)` for permissionless scanning.\nDo not submit during hub pause, without a fresh preview, inside cooldown, or\nwhen gas exceeds expected reward.\n\n## Vault Manager\n\nUse this for owner-authorized vault workflows: create vaults, assign\ntime-limited agents, choose balance policy, close orders, and report balances.\n\nOwner actions:\n\n- `RerangeHub.createVault()`\n- `RerangeVault.setAgent(agent, accessExpiresAt)`\n- `RerangeHub.close(orderKey)` when owner-authorized\n- `RerangeVault.withdraw(token, to, amount)`\n- `RerangeVault.call(target, value, data)` for exact owner-approved calls\n- `RerangeVault.multicall(targets, values, data)` for exact owner-approved\n  batches\n\nA configured vault agent can manage supported orders but must not receive\nwithdrawal authority. Use `setAgent(agent, accessExpiresAt)` for scoped,\nsession-key-like delegation.\n\nBalance policy:\n\n- `keepBalancesInVault = false`: close returns attributable balances to owner.\n- `keepBalancesInVault = true`: final balances remain in vault.\n- `unwrapOut = true`: unwrap WETH output to native ETH where supported.\n\nBefore closing, read `getOrderState`, call `previewClose`, explain expected\nreturned tokens, fees, and reward settlement, submit `close(orderKey)` only from\nowner or authorized agent context, then confirm via event and final balances.\n\nDo not ask users to delegate unlimited wallet authority. Do not call arbitrary\nvault `call` unless the owner explicitly requested target, value, calldata,\npurpose, and risk.\n\n## Strategy Composer\n\nUse this to turn portfolio or treasury objectives into bounded Rerange orders.\nSupported modules: `productive_limit_order`, `passive_exit`,\n`buy_low_accumulation`, `dca`, `grid`, `rebalance`, and `treasury_runway`.\n\nDo not present leverage, liquidation protection, derivatives, or cross-chain\nexecution as Rerange v1 features.\n\nPlanning rules:\n\n1. Check portfolio balances and existing open Rerange orders.\n2. Enforce user exposure, concentration, and order-count limits.\n3. Split capital only when multiple orders materially improve execution control.\n4. Use the intent order builder for each proposed order.\n5. Use safety and risk checks for each order and aggregate strategy.\n6. Return explicit order parameters and monitoring policy.\n\nFor DCA, create one order for the current step and wait for completion, close,\nor timeout before the next step, unless simultaneous deployment is approved. For\ngrid, place buys below current price and sells above current price, cap per-band\ncapital, cap active orders, and monitor aggregate exposure after every fill.\n\nDo not reinvest proceeds, replace completed bands, or hide the difference\nbetween an order target and a guaranteed execution price without explicit user\npolicy.\n\n## Safety And Risk\n\nUse this as mandatory preflight for all Rerange actions.\n\nGlobal checks:\n\n- supported chain,\n- correct hub address,\n- `hubConfig.paused == false` for opens and reranges,\n- adapter is allowed,\n- token addresses and decimals are known,\n- pool token order is canonical,\n- user amount is nonzero,\n- target direction matches user intent,\n- preview succeeds,\n- simulation succeeds where wallet tooling supports it,\n- gas cost is acceptable.\n\nClose is the pause exception: `close(orderKey)` is an owner or manager recovery\npath and may be used while paused after preview and authorization checks.\n\nOpen checks require successful `previewOpen`, non-empty activation when the flow\nexpects immediate activation, bounded tick drift since preview, correct target\ndirection, sufficient allowance, Permit2, vault prefunding, or native wrap,\nsufficient pool liquidity, and enabled slippage and TWAP policy.\n\nRerange checks require open order, elapsed cooldown, successful\n`previewRerange`, close or activation signal, adapter safety, profitable gas for\npermissionless execution, and fresh submission.\n\nClose checks require owner or authorized agent caller, successful\n`previewClose`, and clear explanation of balance destination, fees, and rewards.\n\nRecommended autonomous limits:\n\n```json\n{\n  \"max_single_order_portfolio_pct\": 20,\n  \"max_asset_exposure_pct\": 40,\n  \"max_active_orders_per_pair\": 8,\n  \"min_rerange_interval_sec\": 300,\n  \"max_slippage_bps\": 100,\n  \"max_twap_deviation_ticks\": 100,\n  \"min_profit_to_gas_ratio\": 1.2\n}\n```\n\nFee settlement is asset-aware: resolver reward is paid only from target-asset\nfees; referrer share is paid only from non-target-asset fees; treasury receives\nremaining non-target-asset fees; target-asset fees are not routed to referrer or\ntreasury; non-target-asset fees are not routed to resolver.\n\nStop opening new orders and switch to read-only monitoring when hub is paused,\nRPC responses disagree, pool tick diverges from TWAP, indexed liquidity is\nstale, gas spikes above policy, token metadata is inconsistent, or preview and\nsimulation disagree.\n\nNever bypass preview, promise exact fill price, execute with unknown token\nmetadata, treat fee APR as guaranteed yield, or use owner withdrawal functions\nfrom an autonomous resolver.\n","tags":{"latest":"1.0.2"},"stats":{"comments":0,"downloads":406,"installsAllTime":15,"installsCurrent":1,"stars":1,"versions":3},"createdAt":1778264449937,"updatedAt":1778507508642},"latestVersion":{"version":"1.0.2","createdAt":1778505687780,"changelog":"Update @rerange/wagmi sdk","license":"MIT-0"},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"rerange","userId":"s176f3y7q6g3yj0wzzc8hte3a186bqzn","displayName":"RΞRANGE","image":"https://rerange.xyz/icon.png"},"moderation":null}