PackingUtils

External library used to pack and unpack values

pack

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

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

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

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