Titandocs

Byte layouts

The exact encodings of the payload, the state leaf and the manifest.

All three are fixed binary layouts. Integers are big-endian. Text is a 2-byte length followed by UTF-8.

Payload

The bytes in payload.hex. Its leaf hash is your entry in the users tree.

FieldEncoding
encoding version1 byte (0x01)
operatortext
usertext
batchNumint64
prevUserBatchHash32 bytes
userSeqNumint64
eventRoot32 bytes
stateRoot32 bytes
versionint64

The tail is fixed-size, so the two roots can be read from the end: stateRoot is bytes [len - 40, len - 8) and eventRoot is bytes [len - 72, len - 40).

State leaf

The bytes in state.hex. Its leaf hash is the payload's stateRoot.

FieldEncoding
encoding version, tag2 bytes (0x01 0x80)
usertext
balanceamount
position countuint16
each positionid (text), market (text), size (amount), cost basis (cost), margin (amount), leverage (int64), margin mode (1 byte), funding entry (cost), funding tick (uint64)
cost dustcost
withdrawal counterint64
userSeqNumint64
funding clearinguint16 count, then market (text) and amount per entry. Always empty except on the exchange's own account
unclaimed referral creditamount, present only when non-zero

An amount is a 16-byte two's-complement integer scaled by 10¹⁰. A cost is the same, scaled by 10²⁰. Margin mode is 0x01 for isolated and 0x02 for cross.

Manifest

The pre-image of prevManifestHash, which is a plain SHA-256 of these bytes.

FieldEncoding
encoding version1 byte (0x01)
operatortext
batchNumint64
timestampint64, Unix nanoseconds (microsecond precision)
prevManifestHash32 bytes
usersRoot32 bytes
versionint64
public observer partytext
auditor0x00 if none, else 0x01 then text

On this page