Skip to content
All docs

Accounting

One canonical model, implemented three times and cross-checked:

ImplementationPathRole
Soliditycontracts/src/libraries/SettlementMath.solauthoritative (moves money)
TypeScriptpackages/core/src/accounting.tsUI previews (web and mobile)
Python (independent, exact rationals)proof/reference_model/imprest_model.pyscores the contract

Rules: position-use fee only while exposed, capped at 25% of stake; flat-only claims of realized profit above the high-water mark, fees netted first, split trader/pool/protocol; settlement waterfall principal -> keeper (once) -> fees -> trader. Agreement: 26/26 cases from real executions (proof/reference_model/results.json); waterfall and split conservation fuzzed (contracts/test/accounting/SettlementMath.t.sol).