# Data Encoding

## Custom data types

Sphinx uses several custom data types on top of the primitive types offered by Cairo.&#x20;

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`

```rust
i32 {
    val: u32
    sign: bool
}
```

The `i32` type is used for storing unshifted limits.&#x20;

### `i128`

```rust
i128 {
    val: u128
    sign: bool
}
```

The `i128` type is used for storing liquidity deltas.&#x20;

### `i256`

```rust
i256 {
    val: u256
    sign: bool
}
```

The `i256` type is used for storing token amount deltas.&#x20;

## 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.
