Brokex Docs
Docs/PROTOCOL MECHANICS/Vault Accounting and NAV

Vault Accounting and NAV

O(1) provision-free Net Asset Value formula in BrokexVault.sol.

O(1) totalAssets() Formula

idle = max(0, USDC.balanceOf(Vault) - totalUnclaimedUsdc)
totalAssets = idle + aaveSuppliedAssets() + Math.mulDiv(totalLongDebtShares, previewLongDebtIndex(), RAY, Floor)

Because totalLongDebtShares is tracked globally and previewLongDebtIndex() is a single RAY (1e27) scalar, totalAssets() executes in O(1) gas regardless of the number of open positions.