Skip to main content

FeeReserve

Admin-controlled reserve for subsidizing fees during the bootstrapping phase.

Source

packages/contracts/FeeReserve.compact

Ledgers

LedgerTypeDescription
reserve_balanceCounterCurrent reserve balance
total_depositedCounterLifetime deposits
total_withdrawnCounterLifetime withdrawals
configMap<Bytes, Counter>Configuration (key 0x02 = warning threshold)
adminMap<Bytes, Bytes>Admin identity (key 0x01)

Circuits

initialize(admin_id: Bytes, warning_threshold: Counter)

Sets the admin identity and the balance warning threshold. Only the admin can deposit and withdraw.

deposit(caller: Bytes, amount: Counter)

Adds funds to the reserve. Fails if caller is not the admin.

withdraw(caller: Bytes, amount: Counter)

Withdraws funds from the reserve. Fails if:

  • caller is not the admin
  • amount exceeds reserve_balance

getReserveBalance(): Counter

Returns the current reserve balance.

getWarningThreshold(): Counter

Returns the configured warning threshold. When the balance drops below this value, the admin should be notified (off-chain monitoring).

getTotalDeposited(): Counter

Returns the lifetime total of deposits.

getTotalWithdrawn(): Counter

Returns the lifetime total of withdrawals.

Purpose

The FeeReserve funds the FeePool during bootstrapping when user deposits may not cover the normalization gap. As the user base grows and the pool becomes self-sustaining, the reserve can be drawn down.

Admin deposits → FeeReserve → subsidizes → FeePool

User deposits