Skip to main content

Module auto_funding

Module auto_funding 

Source
Expand description

§Auto Funding Strategy

This strategy listens for channel state change events to check whether a channel has dropped below min_stake_threshold HOPR. If this happens, the strategy issues a fund channel transaction to re-stake the channel with funding_amount HOPR.

Additionally, the strategy periodically scans all outgoing open channels on each tick and funds any that have fallen below the threshold. This catches channels opened with low balance and channels that were underfunded when the node started.

§In-flight tracking

To prevent duplicate funding when multiple balance-decrease events arrive in quick succession, the strategy maintains a set of channel IDs currently being funded. A channel is added to the set when a funding tx is successfully enqueued, and removed when:

  • The spawned confirmation task observes a transaction failure,
  • A balance increase event is observed for that channel (indicating the funding confirmed), or
  • An on_tick scan finds the channel’s balance has risen above the threshold.

§Metrics

  • hopr_strategy_auto_funding_funding_count — incremented when a funding tx is successfully enqueued
  • hopr_strategy_auto_funding_failure_count — incremented when a funding tx fails to enqueue or confirm

For details on default parameters see AutoFundingStrategyConfig.

Structs§

AutoFundingStrategy
The AutoFundingStrategy automatically funds a channel that dropped its staked balance below the configured threshold.
AutoFundingStrategyConfig
Configuration for AutoFundingStrategy
METRIC_COUNT_AUTO_FUNDINGS 🔒
METRIC_COUNT_AUTO_FUNDING_FAILURES 🔒

Functions§

validate_funding_amount 🔒
Validates that AutoFundingStrategyConfig::funding_amount is non-zero.