Skip to main content

Overview

The Master Pool Rebalancer is an autonomous protocol module that manages AREAL DAO’s own liquidity in the master concentrated pools (RWT/USDY, RWT/USDC) on the native DEX. This module is separate from the DEX contract — it operates as an independent program that interacts with the DEX via CPI. It ensures that protocol-owned liquidity is always concentrated around the current NAV Book Value, providing deep liquidity exactly where trading occurs.
Only protocol-owned liquidity is managed by this module. User LP positions on the native DEX are never touched, modified, or rebalanced. Users manage their own positions independently.

On-Chain Accounts

ProtocolLiquidity

Main PDA for each master pool’s protocol-owned position. Stores the LP position reference, deposited amounts, last rebalance price, rebalance threshold (default 1%), and the target bin count (default 50). Seeds: ["protocol_liquidity", pool].

RebalancerConfig

Global configuration for the rebalancer module: rebalance threshold (basis points), target bin count, commit interval, and reference to the RWT Vault for NAV Book Value reads. Modifiable by Engine Authority. Seeds: ["rebalancer_config"].

Core Instructions

deposit_protocol_liquidity

Deposits AREAL DAO capital into a master pool as protocol-owned liquidity via the ProtocolLiquidity PDA. The concentrated range is centered on the current NAV Book Value within the configured bin count (default 50 bins).Authority: Engine Authority (DAO governance)
Accounts:
  - engine_authority:    Signer
  - protocol_liquidity:  PDA (init or mut)
  - rebalancer_config:   PDA
  - pool_state:          DEX pool PDA (mut, CPI)
  - bin_array:           DEX bin array PDA (mut, CPI)
  - dao_token_a_ata:     DAO's RWT account (mut)
  - dao_token_b_ata:     DAO's USDY/USDC account (mut)
  - rwt_vault:           RWT Vault PDA (NAV Book Value source)
  - dex_program
  - token_program

Args:
  - amount_a: u64        RWT amount
  - amount_b: u64        USDY/USDC amount
Auto-rebalances the protocol-owned liquidity when NAV Book Value deviates from the last rebalance price by more than the threshold. Withdraws the ProtocolLiquidity position from the DEX via CPI, re-centers the concentrated range on the new NAV, and redeposits.User LP positions are never touched — only the DAO’s own capital is rebalanced.Authority: Permissionless (crank), guarded by deviation check
Accounts:
  - crank:               Signer
  - protocol_liquidity:  PDA (mut)
  - rebalancer_config:   PDA
  - pool_state:          DEX pool PDA (mut, CPI)
  - bin_array:           DEX bin array PDA (mut, CPI)
  - rwt_vault:           RWT Vault PDA (NAV Book Value source)
  - pool_token_a_vault:  DEX pool token A vault (mut, CPI)
  - pool_token_b_vault:  DEX pool token B vault (mut, CPI)
  - dex_program
  - token_program
Withdraws protocol-owned liquidity from a master pool back to the DAO wallet. Used when the DAO decides to reallocate capital or reduce protocol liquidity in a specific pool.Authority: Engine Authority (DAO governance)
Accounts:
  - engine_authority:    Signer
  - protocol_liquidity:  PDA (mut)
  - pool_state:          DEX pool PDA (mut, CPI)
  - bin_array:           DEX bin array PDA (mut, CPI)
  - dao_token_a_ata:     DAO's RWT account (mut)
  - dao_token_b_ata:     DAO's USDY/USDC account (mut)
  - pool_token_a_vault:  DEX pool token A vault (mut, CPI)
  - pool_token_b_vault:  DEX pool token B vault (mut, CPI)
  - dex_program
  - token_program

Args:
  - amount: u64          Liquidity to withdraw (0 = full position)
Updates the rebalancer module configuration — rebalance threshold, target bin count, or other parameters. Requires Engine Authority.Authority: Engine Authority (DAO governance)
Accounts:
  - engine_authority:    Signer
  - rebalancer_config:   PDA (mut)

Args:
  - threshold_bps: Option<u16>    Rebalance threshold (default 100 = 1%)
  - target_bins: Option<u16>      Number of bins for concentrated range (default 50)

Rebalancing Flow

NAV deviation detected

The crank checks if the current NAV Book Value (from the RWT Vault) differs from protocol_liquidity.last_rebalance_price by more than the configured threshold (default 1%).

Protocol liquidity withdrawn

The module calls remove_liquidity on the native DEX via CPI, withdrawing the DAO’s ProtocolLiquidity position. User positions remain untouched.

Range re-centered

The concentrated bin range is recalculated: center = new NAV Book Value, spread = configured bin count (default 50 bins).

Protocol liquidity redeposited

The module calls add_liquidity on the native DEX via CPI, depositing DAO capital in the new range. protocol_liquidity.last_rebalance_price is updated.

Protocol vs User Liquidity

The Master Pool Rebalancer only manages ProtocolLiquidity — it has no access to user LP positions.
Protocol LiquidityUser Liquidity
Managed byProtocolLiquidity PDA (this module)Individual LpPosition PDA (DEX contract)
Auto-rebalancedYes — via rebalance_protocol_liquidityNo — users manage their own range
Deposit/withdrawEngine Authority (DAO)LP owner (permissionless)
PurposeEnsure deep liquidity around NAV Book ValueUsers earn fees and yield on their capital
Bin rangeAlways centered on NAV, auto-adjustedSet by user at deposit time, never changed

Interaction with Native DEX

This module interacts with the Native DEX exclusively via CPI calls — it does not modify DEX state directly. The module calls the DEX’s standard add_liquidity and remove_liquidity instructions, using the ProtocolLiquidity PDA as the LP owner.
Because the rebalancer uses standard DEX instructions via CPI, it benefits from all DEX security guarantees — slippage protection, pool immutability, and account ownership checks.

Security Considerations

User isolation

The module has zero access to user LP positions. It can only manage ProtocolLiquidity PDAs — which are owned by this program, not the DEX.

Deviation guard

rebalance_protocol_liquidity is permissionless but guarded by the threshold check. Cannot be triggered arbitrarily — only when NAV actually deviates beyond the configured limit.

CPI-only interaction

All DEX interactions go through standard CPI calls. The module cannot bypass DEX security checks or access DEX accounts directly.

Configurable parameters

Threshold, bin count, and other parameters are stored in RebalancerConfig and modifiable only by Engine Authority (DAO governance).
The Master Pool Rebalancer module is currently in development. This documentation describes the target architecture. Module code has not yet been audited.