Use Case & Applications
Verifies that the sum of all individual positions exactly matches the total supply reported by the protocol, preventing supply manipulation, double counting, and accounting discrepancies. Critical for lending protocols, liquidity pools, staking mechanisms, synthetic asset protocols, and fractionalized NFT protocols where accurate position accounting is fundamental to security. Any discrepancy between individual positions and total supply could lead to incorrect calculations, withdrawal failures, or protocol insolvency.Explanation
Since direct iteration over all positions isn’t currently supported, this assertion uses a workaround that tracks position changes through function calls:- Capture the pre-state total supply before the transaction
- Monitor all function calls that modify positions (deposit, withdraw)
- Calculate the sum of changes to these positions
- Verify that the new total supply equals the pre-state total supply plus the sum of position changes
ph.forkPreState()/ph.forkPostState(): Capture total supply before and after transactionph.getCallInputs(): Track function calls that modify positionsregisterCallTrigger(): Trigger on position-modifying functions
Code Example
Full examples with tests available in the Phylax Assertion Examples Repository.
Related Assertions
- Lending Health Factor: Ensures user balances are consistent across different views
- Liquidation Health Factor: Verifies that the total supply doesn’t exceed protocol limits

