Raxol.Payments.RebalanceMonitor (Raxol Payments v0.2.0)

Copy Markdown View Source

Periodically runs Raxol.Payments.RebalanceAdvisor against the solver's live balances and the SettlementLedger drain, emitting recommendations (via the advisor's telemetry + logs). Recommend-only: raxol cannot move the solver wallet; the Riddler auto-rebalancer executes.

A GenServer scheduled with Process.send_after/3 (the codebase's periodic-task idiom). The gather+advise step is exposed as advise_once/1 so the on-demand mix task shares the exact code path.

Phase 1 covers native gas-refuel recommendations (native balances only). USDC and other-asset inventory rebalancing arrive with the multi-asset ChainReader ERC-20 read.

Options

  • :ledger -- the SettlementLedger server. Required.
  • :reader -- a ChainReader.reader. Required.
  • :solver_address -- the solver wallet to read balances for. Required.
  • :policy -- a RebalancePolicy (default RebalancePolicy.default/0).
  • :chains -- chains to sweep (default the six supported EVM chains).
  • :interval_ms -- sweep period (default 5 min).
  • :initial_delay_ms -- delay before the first sweep (default :interval_ms).
  • :price_fn -- native_symbol -> Decimal | nil for sizing conversions.

Summary

Functions

Run one gather+advise cycle without a running process -- the shared core used by the periodic sweep and the on-demand mix task. Takes the same keys as start_link/1 (:ledger, :reader, :solver_address, :policy, :chains, :price_fn).

Returns a specification to start this module under a supervisor.

Trigger a sweep immediately and return the recommendation list.

Functions

advise_once(opts)

Run one gather+advise cycle without a running process -- the shared core used by the periodic sweep and the on-demand mix task. Takes the same keys as start_link/1 (:ledger, :reader, :solver_address, :policy, :chains, :price_fn).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

sweep_now(server \\ __MODULE__)

Trigger a sweep immediately and return the recommendation list.