Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Solver inventory rebalance

Template: solver-inventory-rebalance ยท category: intents ยท risk: money_moving

Keeps a solver's fill wallet stocked. It polls the solver wallet's ERC20 inventory and, when the balance drifts below a floor, parks a top-up transfer from a separate funding wallet behind a human approval โ€” refilling the solver back to a target balance. The pairing for erc7683-solver: the fill workflow burns output-token inventory, this keeps it topped up.

When to use it

  • your solver runs out of a token mid-day and starts skipping fills
  • you want a human in the loop before reserve capital moves to the hot wallet
  • you keep funding capital in a separate wallet from the fill wallet

Generate it

rflow new --template solver-inventory-rebalance
 
# or add the workflow to an existing project
rflow add workflow solver-inventory-rebalance

Non-interactive (CI/agents):

rflow new --template solver-inventory-rebalance --yes --output ./rebalance \
  --answer token_address=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
  --answer min_inventory=50000 --answer refill_to=100000

Inputs

keytypedefault
project_namestringsolver-inventory-rebalance
network / chain_id / rpc_env / rpc_urlnetwork / chain_id / env_var / stringethereum / 1 / ETH_RPC / a public RPC
confirmationsint3
token_name / token_address / token_decimalscontract / address / intToken / USDC mainnet / 6
solver_walletaddresszero placeholder (replace!)
min_inventory / refill_totoken_amount50000 / 100000
poll_everyduration1m
approval_timeoutduration30m
gas_max_pricestring50 gwei

Required env vars

DATABASE_URL, the RPC env var (default ETH_RPC), and RAW_DANGEROUS_MNEMONIC โ€” rflow new writes a fresh DEV-ONLY mnemonic; swap in a production signer before real funds ride on it.

Safety notes

Money-moving, so every rail is on: pre-flight simulation with assert_sim: ["${{ sim.ok }}"], a gas.max_price ceiling, a concurrency group (skip) so a parked top-up never stacks, wait_for: confirmed, and on_failure: dead_letter. The top-up is parked behind approval โ€” rflow approve <id> โ€” and the approval re-simulates immediately before broadcast, so a wallet refilled during the wait sends nothing. Attach a budget to cap cumulative top-up spend.

Run it locally

docker compose up -d     # postgres on localhost:5448
# fill .env (RPC + a real signer), set solver_wallet
rflow validate
rflow start

Common modifications

  • refill from an external treasury by pointing funding at that wallet
  • watch several tokens by adding a workflow per token
  • raise poll_every on quiet chains to cut RPC load