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 { val: u32 sign: bool }
The i32 type is used for storing unshifted limits.
i128
i128 { val: u128 sign: bool }
The i128 type is used for storing liquidity deltas.
i256
The i256 type is used for storing token amount deltas.
For simplicity and efficiency, limits are stored in shifted form by mapping unshifted i32 limits to shifted u32 limits.
u32
Specifically, an offset equal to the largest possible multiple of the market width is applied for shifting and unshifting.
offset
width
Last updated 1 year ago
i256 { val: u256 sign: bool }