CLIVEBREMNER
local
RECEIVED
TREASURY

the book

TS/B
OPEN POSITIONS · COLLATERAL · FLOAT
TS/B/1

how the book is kept

read directly from the cluster

The book is the set of all accounts owned by the system program. It is not a database. It is the on-chain state, read directly from the cluster, and it is read once, when this page is opened. There are four kinds of accounts in the book. The float account holds pooled value that has not been assigned to any position. A position account records one obligation between the float and a counterparty. A collateral account records value a counterparty has locked against one or more positions. The config account holds the rate sheet and the operator key.1 Every account is a program-derived address.2 The seeds are listed on the instruments page so that anyone can derive and verify them.

TS/B/2

reading a position

field definitions, fixed by the program
FIELDTYPEMEANING
counterpartyPubkeyThe account that entered into the position.
instrumentu8 enumWhich instrument opened it. See the instruments page.
amountu64Base units of the float's mint. Display divided by the mint's decimals, read from the mint account.
collateralPubkeyThe collateral account backing this position.
opened_ati64Unix timestamp from the opening transaction's clock sysvar.
batch_windowu32The overnight batch number in which this position is eligible to settle.
settledboolWhether the settle instrument has been applied. Settled positions are closed and rent is returned, so a settled position should not normally appear here.
bumpu8PDA bump seed.
TS/B/3

worked example, without figures

PROCEDURE

A counterparty locks collateral with the lock instrument. The program creates a collateral account keyed to the counterparty and the mint. The counterparty calls open with an amount and a nonce. The program reads the collateral ratio from config, checks the collateral account covers the amount at that ratio, creates a position account, and moves the amount from the float vault to the counterparty's token account. The position carries the batch number it will be eligible to settle in. When that batch runs, settle moves the amount plus the fee back to the float vault and closes the position. When no positions remain against the collateral, release returns it. At no point does anyone at this desk touch value by hand.

TS/B/4

what the book is not

CLARIFICATION

It is not a market. Nothing on it is priced by anyone. It is not a fund. Nothing on it is managed. It is not an offer. Opening a position is a counterparty's decision made against a published rate sheet and a program that will refuse them if the collateral is short.1 The book records what was done. It does not invite anything.

TS/B/5

the float

pooled value, uncommitted

The float is pooled value that is not yet committed. It is the only account the open instrument draws from and the only account the settle instrument returns to. It cannot be withdrawn from except by the operator key, and the operator key cannot withdraw it while any position is open.3 That constraint is enforced by the program, not by this desk.

TS/B/6

the four account kinds, side by side

COMPARISON
KINDOWNERCREATED BYCLOSED BYHOW MANY EXIST
floatthe programinitializeneverexactly one per mint
configthe programinitializeneverexactly one
positionthe programopensettleone per open obligation
collateralthe programlockrelease, when it backs nothing and its amount is zeroone per counterparty per mint
namethe programnameneverat most one per counterparty
TS/B/7

why positions are closed, not flagged

DESIGN

A settled position is closed and its rent returned rather than kept with a flag set to true. Two reasons. First, the book should be the list of what is open, and a list that contains closed things is not that list. Second, an account that exists can be passed to an instrument by mistake, and an account that does not exist cannot. The settled flag in the struct exists only so that a position in the middle of being closed, in the same transaction, cannot be settled twice. If you ever see a position with settled set to true, the transaction that set it was not completed and that is an incident.

TS/B/8

the nonce

DETAIL

Each position's address is derived from the counterparty and a nonce the counterparty supplies. The program does not check that nonces are sequential. It checks only that the derived address does not already exist.2 A counterparty that reuses a nonce gets a named error and nothing else happens. A counterparty that wants to know its own open positions can derive addresses for any nonces it has used and read them. The desk keeps no separate index. The chain is the index.

TS/B/9

decimals

DISPLAY

Amounts are stored as base units. This site divides by the decimals field read from the mint account before display and shows the full fractional part with no rounding. If the mint account cannot be read, the site shows base units and says so beside the figure. The program never sees decimals. It moves base units.

TS/B/10

things you will not find in the book

ABSENCES

Prices. Interest. Yield. Ratings. Names of people. Reasons. The book holds amounts, keys, timestamps, and a batch number. Everything a person might want to know about why a position was opened lives in the head of the counterparty who opened it, and this desk does not ask.

  1. 1. The rate sheet is the set of rate parameters held in the config account and printed, unaltered, on the rate sheet page.
  2. 2. A program derived address is an account address computed from fixed seeds, so anyone can derive it and check the desk's work.
  3. 3. The operator key is the single key this desk signs with, and what it may do is fixed by the program, not by the desk.
END OF THE BOOK