Skip to main content

Module math

Module math 

Source
Expand description

Pure math functions for the PerpCity protocol.

These operate directly on Alloy primitives (U256, I256) and f64 โ€” no structs, no state, just math. Each submodule corresponds to a domain:

ModulePurpose
tickTick โ†” price conversions, tick alignment, getSqrtRatioAtTick
liquidityLiquidity estimation for maker positions
positionEntry price, size, value, leverage, liquidation price

Modulesยง

liquidity
Liquidity estimation for PerpCity maker positions.
position
Position-level math: entry price, size, value, leverage, liquidation price.
tick
Tick โ†” price conversions and the Uniswap V4 getSqrtRatioAtTick algorithm.