Skip to main content
Technical Article

Automatic Income Allocation.

The technical mechanism behind how Rheofi captures, tracks, and distributes protocol income — without bots, without governance multisigs, without off-chain coordination.

SourcesSpread & liquidationsBorrow-supply rate spread accumulates per market; liquidation bonuses share with the protocol.
HubProtocolShareReserveSingle accounting and distribution contract for all protocol income.
DestinationsTreasury · Risk Fund · AllocationsTwo-step transfer: tokens move, then receiver state updates.
Income sources

Interest rate spread

The difference between the borrow rate paid by borrowers and the supply rate earned by suppliers. Accumulates as protocol reserves inside each market.

Liquidation incentives

A liquidation bonus is applied; a portion of that bonus is allocated to the protocol and treated as income.

Streaming distribution model

Rheofi distributes accumulated reserves in near-real-time using user-triggered transactions. No off-chain scripts, no manual governance — distribution logic is embedded directly into protocol contracts and naturally fires as users interact. The ProtocolShareReserve contract is the central accounting hub for all protocol income.

Isolated Pools — spread income

For Isolated Pools, spread income accumulation triggers periodic distribution after threshold conditions are met. The mechanism is socialized and optimized for gas efficiency.

Isolated Pools — liquidation income

In Isolated Pools, liquidations are handled directly by the rToken contracts. The protocol's share of seized collateral is transferred immediately to the ProtocolShareReserve. No redemption-retry logic is required — liquidation accounting stays simple within isolated environments.

ProtocolShareReserve

All collected protocol income is managed by the ProtocolShareReserve contract.

Tracks income per pool

Each pool's income is tracked separately for accurate destination accounting.

Categorizes by origin

Spread vs liquidation income is tracked separately, enabling distinct distribution schemas.

Routes to destinations

Manages distribution to final destinations — Treasury, Risk Fund, governance allocations.

On XRPL Sidechain, native asset wrapping (where required) must occur before funds are transferred into the reserve contract.

updateAssetsState function

updateAssetsState registers newly received income.

Parameters

  • address comptroller — The Comptroller associated with the pool generating income.
  • address asset — The asset being transferred into the reserve.
  • IncomeOrigin origin — Whether income came from spread or liquidation.

Internal logic

When called, the function:

  1. Calculates the net transferred amount (current balance minus previous balance).
  2. Assigns the amount to the appropriate pool, asset, and income category.
  3. Updates the global accounting state for future distribution.

This design keeps income tracking accurate and auditable.

releaseFunds function

Distributes accumulated protocol income to designated destinations.

Permissionless

Can be called by anyone — keeper, bot, or any user. Gas paid by the caller, not the protocol.

Step 1 — transfer funds

Tokens move from ProtocolShareReserve to configured destinations: Treasury, Risk Fund, governance allocation.

Step 2 — update receiver state

After transfer, the receiving contract's updateAssetsState is invoked. Accounting records are updated atomically.

Design goals

Minimize manual governance intervention. Reduce operational overhead. Enable near-real-time income routing. Maintain full on-chain transparency. Support Isolated Pools. Operate efficiently within the XRPL Sidechain environment.