Data Encoding
Custom data types
Sphinx uses several custom data types on top of the primitive types offered by Cairo.
We do not rely on the native signed integer type as we rely on math operations that are not currently implemented by the Cairo core lib.
i32
i32
The i32
type is used for storing unshifted limits.
i128
i128
The i128
type is used for storing liquidity deltas.
i256
i256
The i256
type is used for storing token amount deltas.
Limit shifting
For simplicity and efficiency, limits are stored in shifted form by mapping unshifted i32
limits to shifted u32
limits.
Specifically, an offset
equal to the largest possible multiple of the market width
is applied for shifting and unshifting.
Last updated