# PackingUtils

_External library used to pack and unpack values_

## pack

```solidity
function pack(uint256[] _values, uint256[] _bitLengths) external pure returns (uint256 packed)
```

_Packs values array into a single uint256_

### Parameters

| Name         | Type       | Description                              |
| ------------ | ---------- | ---------------------------------------- |
| \_values     | uint256\[] | values to pack                           |
| \_bitLengths | uint256\[] | corresponding bit lengths for each value |

## unpack

```solidity
function unpack(uint256 _packed, uint256[] _bitLengths) external pure returns (uint256[] values)
```

_Unpacks a single uint256 into an array of values_

### Parameters

| Name         | Type       | Description                              |
| ------------ | ---------- | ---------------------------------------- |
| \_packed     | uint256    | packed value                             |
| \_bitLengths | uint256\[] | corresponding bit lengths for each value |

## unpack256To64

```solidity
function unpack256To64(uint256 _packed) external pure returns (uint64 a, uint64 b, uint64 c, uint64 d)
```

_Unpacks a single uint256 into 4 uint64 values_

### Parameters

| Name     | Type    | Description  |
| -------- | ------- | ------------ |
| \_packed | uint256 | packed value |

### Return Values

| Name | Type   | Description      |
| ---- | ------ | ---------------- |
| a    | uint64 | returned value 1 |
| b    | uint64 | returned value 2 |
| c    | uint64 | returned value 3 |
| d    | uint64 | returned value 4 |

## unpackTriggerOrder

```solidity
function unpackTriggerOrder(uint256 _packed) external pure returns (uint8 orderType, address trader, uint32 index)
```

_Unpacks trigger order calldata into 3 values_

### Parameters

| Name     | Type    | Description  |
| -------- | ------- | ------------ |
| \_packed | uint256 | packed value |

### Return Values

| Name      | Type    | Description    |
| --------- | ------- | -------------- |
| orderType | uint8   | order type     |
| trader    | address | trader address |
| index     | uint32  | trade index    |
