Skip to content

bridge-monitor: tier-aware gas auto-topup - #1557

Open
Flotapponnier wants to merge 2 commits into
devfrom
feat/gas-topup-tier-guard
Open

bridge-monitor: tier-aware gas auto-topup#1557
Flotapponnier wants to merge 2 commits into
devfrom
feat/gas-topup-tier-guard

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

What

Reworks the native-gas auto-top-up system so it is safe and autonomous:

  • Enabled by default (GAS_TOPUP_ENABLED=true). The tier guard — not an env flag — is the safety mechanism.
  • Tier-aware canDivert: before swapping stablecoins into SOL/ETH, computes canDivert = stableUSD - tier × 1.20. If below $5 minimum, sends a Slack alert and leaves the chain gas-blocked.
  • Runs at every downgrade-ladder rung (not just i==0). At $300 tier, Sol USDC $248 can't safely divert; at $50 tier, $248 - $60 = $188 is free — the swap happens automatically.
  • Arb USDC → USDT fallback: Arb USDC = $0 on current wallet; adds FallbackStable=arbUSDTAddr so Arb ETH shortage still has a funding source.
  • topUpChain now returns bool; CheckAndTopUp returns bool (false = at least one chain gas-blocked).
  • Per-chain spentToday cap (UTC day reset), independent of the triangle rebalancer budget.

Wallet context

Sol SOL = $0.75 (below $15 floor). Sol USDC = $248.82. At $50 ladder rung: canDivert = $248.82 - $60 = $188 → swap $25 USDC→SOL via LiFi/Jupiter same-chain swap. System handles this automatically.

Deploy

Bridge-monitor runs on VPS ocb-par-main, not Railway. After merge to main: rsync harness source + docker build --no-cache ocb-bridge-monitor on the VPS.

- GAS_TOPUP_ENABLED defaults true (tier guard is the safety, not env flag)
- CheckAndTopUp now takes tier param; canDivert = stableUSD - tier*1.20
- Gas check runs at every downgrade ladder rung (not just i==0)
- Arb USDC->USDT fallback when primary has no balance
- topUpChain returns bool; any failure propagates to allOK
- spentToday per-chain daily cap, UTC day reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant