The program performs integer arithmetic. This page shows the same formulas in product terms, with the important units and rounding behavior called out.
Units
Total Shares
The vault adds all recipient shares together. Each recipient’s expected proportion is: Example:
The total share is 100, so the shares map directly to percentages. The same split could also be represented as 5, 3, and 2 shares.
Manual Funding Amount
Manual funding takesmax_amount, but the program never transfers more than the source token account currently holds:
If Transfer Amount = 0, the instruction fails.
For standard SPL Token mints, the funded amount is the transfer amount:
For supported Token 2022 transfer-fee mints, the program calculates the transfer fee for the current epoch and accounts for the amount excluding that fee:
This prevents funding accounting from crediting more tokens than the token vault receives.
Claim-By-Integration Funding
When a PDA vault funds itself throughfund_by_claiming_fee, the program measures the token vault balance before and after the whitelisted CPI.
If Claimed Amount > 0, the vault adds that amount to fee accounting:
If the balance does not increase, the program does not update fee accounting or emit a fund event.
Fee Per Share
Each time new fees enter the vault, the vault increases the cumulative fee-per-share value. Conceptually: In the program: Then it updates the cumulative value: The vault also increasestotal_funded_fee:
Claimable Fee
Each recipient stores a checkpoint: the fee-per-share value they had already claimed up to. When the recipient claims, the vault calculates the difference between the current fee-per-share and that recipient’s checkpoint. Then the vault multiplies that delta by the recipient’s share: After the claim, the recipient’s checkpoint and total claimed amount are updated: This is how the vault prevents double-claiming while still allowing recipients to claim independently.Worked Example
Assume a vault has three recipients:
Total share:
A funder adds 1,000 USDC into the vault.
The expected distribution is:
If the creator claims first, the creator receives 500 USDC and the creator’s checkpoint updates. The partner and treasury can claim later; their balances remain claimable because their checkpoints have not moved.
Multiple Funding Events
Dynamic Fee Sharing supports repeated funding. Example:
Total funded fee:
A 30% recipient would be entitled to:
If that recipient already claimed 300 USDC after the first funding event, the next claim would be around 225 USDC, subject to integer rounding.
Remaining Vault Balance
For standard SPL Token mints, the token vault balance usually represents funded fees that have not yet been claimed, plus small rounding dust. Simplified formula: Because token amounts are integers andfee_per_share increments are floored, small dust can remain when funded amounts do not divide evenly across shares.
Transfer-Fee Token Claims
For supported Token 2022 transfer-fee mints, manual funding credits the net amount received by the token vault. Claims are different: the program calculates a grossClaimable Fee and transfers that amount from the token vault to the recipient token account. If the mint charges a transfer fee on that outgoing transfer, the recipient token account may receive less than the gross claimed amount.
The program’s fee_claimed field tracks the gross claimed amount.
Rounding and Precision
The program uses high-precision fee-per-share accounting by scaling calculations with2^64. This helps preserve precision for small funding amounts and large total-share values. The program includes a property test that checks small funded amounts still produce a non-zero fee_per_share even when total_share is u32::MAX.
Even with high precision, final claim amounts are integer token amounts. If a funded amount cannot be split perfectly between recipients, dust can remain in the vault.
For product planning, choose share weights that are easy to communicate. Percent-style totals such as 100, 1,000, or 10,000 are usually easier for teams and recipients to reason about.

