> For the complete documentation index, see [llms.txt](https://betfin.gitbook.io/betfin-public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://betfin.gitbook.io/betfin-public/staking-manual/staking-explanation/liquidity-pool-cumulative-accounting.md).

# Liquidity Pool Cumulative Accounting

The protocol ensures fair distribution of gains and losses across all participants.

The Liquidity Pool (LP) utilizes a high-performance O(1) gas-efficient cumulative accounting model. This ensures that transaction costs remain low and constant regardless of how many providers join the pool:

* **Global Accumulators**: Instead of calculating rewards for each user individually every block, the pool maintains two global counters: accumulatedProfitPerShare and accumulatedDebtPerShare. These counters only move forward (monotonically non-decreasing), recording the entire history of the pool's performance.

* **Fair Entry Snapshots**: When you deposit, your Position NFT snapshots the current state of these accumulators. This "Fair Entry" mechanism ensures you never inherit debt from player wins that happened before you joined, and you only earn from game activity that occurs during your participation.

* **4-Week Sync Epochs:** Every 4th Thursday between 12:00 and 24:00 UTC, the system synchronizes the "Actual Balance" (tokens currently in the contract) with the "Expected Principal" (the baseline of all deposits minus withdrawals). The difference—whether profit or loss—is then added to the global accumulators and distributed to all providers simultaneously.
