The zcs1 off-chain standard
The zcs1 profile for SigmaFi clients and batchers, covering script disclosure, token metadata, share count, the maturity grid, cover at the fill, batching rules and defaults.
The contracts fix what must be true for a box to move. Everything else is decided off chain: what a client writes into the boxes it creates, how a batcher finds and serves work, and how a wallet shows bonds and shares. That off-chain part is the profile zcs1. The Lithos client follows all of it. Any client that follows it works with every other.
How the rules are graded#
The profile sorts its rules into three grades:
| Grade | Meaning |
|---|---|
| Required | A batcher cannot work without it. Batchers skip boxes that break one. The owner can still act on such a box with their own client |
| Recommended | Keeps the market uniform. Clients always write it, and readers flag boxes that break one, but batchers still serve them |
| Default | What a client writes when the user chooses nothing else. A departure is never flagged |
Off-chain rules serve user experience and batching. They never decide a price or a risk. Principal, repayment, collateral, maturity, liquidation ratio, yields, an offer's curve and floor, an ask's price, and the prices of an auction or a lot are always the user's own input. No client defaults them.
Script disclosure (required)#
The contracts name the scripts they pay by hash only, but a batcher must build outputs under the script itself: an expiry refund, a fill's delivery, a payout, a share mint. The indexed node cannot look a script up by its hash, so every box must lead to its scripts in one lookup.
The following boxes name a script:
| Box | Register | Script |
|---|---|---|
| Order, PricedOrder | R6 | Borrower |
| Bond | R5 | Borrower, copied from the order |
| LendOffer | R4 | Owner |
| SaleOrder, PricedAsk, LotAuction | R4 | Seller |
| Fractional or Dutch mint request | R7 | Owner |
| Wrap mint request | R4 | Owner |
Writers. A transaction that creates any of these boxes, a continuation or a delivered request
included, puts context variable 64 on INPUTS(0): a Coll[Coll[Byte]] holding the ErgoTree bytes
of each named script the transaction does not otherwise show. The bytes are the whole ErgoTree, the bytes
the hash is taken over. A P2PK ErgoTree is 36 bytes, so a disclosure adds about 40 bytes to the
transaction and nothing to any box. Signatures cover the extension, so a disclosure cannot change after
signing.
The Lithos client counts a script as shown only when an output carries it. The node lists a pending transaction's inputs without their scripts, so an input does not show the script while the transaction waits in the mempool.
Readers resolve a hash in the following order:
- A local cache of hash to ErgoTree. A hash never changes meaning, so entries never expire.
- The box's creating transaction:
/blockchain/transaction/byId/{txId}on the indexed node, or/transactions/unconfirmed/byTransactionId/{txId}while it is pending. Match against variable 64 in the inputs'spendingProof.extension, then against every output'sergoTree. - Nothing else. A box whose script is not found this way breaks the rule, and batchers skip it.
Context variables 64 to 127 are reserved for off-chain data. No standard contract reads them.
Token metadata (recommended)#
Three kinds of token are issued: bond units (three per fill), shares (2N + 1 per mint) and wrap receipts (three per wrap). Names and descriptions are built only from chain data, so any two clients write the same bytes for the same token and readers can flag a mismatch.
Names are short and say what a token is:
| Token | Name |
|---|---|
| Bond unit | ZCS-Bond-Unit- and the first six lowercase hex characters of its token id |
| Shares of a known bond, plain, Selective or Dutch | ZCS-Bond-Shares- and the bond's six characters |
| Shares delivered through a lend offer | ZCS-Bond-Shares |
| Wrap receipt | ZCS-Wrap- and the wrapped token's six characters |
A share token's own id cannot be its suffix: it is the mint request's box id, which hashes over the request's registers, the name among them.
Each description is one compact JSON object, with no whitespace, keys in the fixed order below, and keys that do not apply left out:
| Key | Value | In |
|---|---|---|
zcs | 1 | Every description |
type | "bond unit", "shares", "selective shares", "auction shares" or "wrap receipt" | Every description |
shares | 100, the share supply in display units | Shares |
bond | The bond token's six characters | Shares whose bond is known |
market | "ERG" or "SigUSD" | Bond units and shares |
via | "lend offer" | Shares whose bond is not known |
principal, repayment | Amounts in the market's unit | Bond units, shares whose bond is known |
start, maturity | Heights | The same |
rule | "maturity", "oracle" or "other" | The same |
ratio | The oracle rule's ratio in percent | With "rule":"oracle" |
ruleHash | The rule hash's first 8 hex characters | With "rule":"other" |
auction | {"from":opening,"to":floor,"blocks":length,"expiry":expiry}, with "threshold":units last for Selective shares | Selective and auction shares |
note | "Verify on chain." | Every description |
Two examples follow. A bond unit with the oracle rule:
{"zcs":1,"type":"bond unit","market":"SigUSD","principal":100,"repayment":105.5,"start":1712000,"maturity":1749600,"rule":"oracle","ratio":150,"note":"Verify on chain."}Selective shares whose bond is known, the longest form at 279 bytes:
{"zcs":1,"type":"selective shares","shares":100,"bond":"3fa2c1","market":"SigUSD","principal":100,"repayment":105.5,"start":1712000,"maturity":1749600,"rule":"oracle","ratio":150,"auction":{"from":100,"to":90,"blocks":720,"expiry":2160,"threshold":100},"note":"Verify on chain."}Write ASCII only, encoded as EIP-4 Coll[Byte]. Amounts are JSON numbers in the market's unit, ERG with 9
decimals and SigUSD with 2, with trailing zeros and a trailing point removed, no exponent and no thousands
separators. Percentages are basis points over 100, formatted the same way. Decimals are 0 for a bond
unit, which the order enforces, and 6 for shares.
Metadata is display only. A mismatch never changes what verification says about a token. To show a token, resolve it from the chain first, as Verifying a bond token describes, and fall back to EIP-4 only when you cannot.
Share count (recommended)#
Every share token has N = 100,000,000 raw shares with 6 decimals, so a wallet shows 100.000000 for the
whole bond and 1.000000 for 1% of it. The rule covers fractionalizing, an offer's delivery and a Dutch
mint alike. Share prices are quoted as a percentage of face: a price p for u raw shares of a bond
repaying R is p × N / (u × R).
A claim of u raw shares takes floor(balance × u / N) of each asset. Clients sell and claim in lots of at
least ceil(N / R) raw shares, so the repayment asset never rounds to zero, and warn when a claim would
round a collateral token to zero. Every contract product involving N is computed in BigInt, so N
cannot overflow anywhere the contracts allow it.
The count stays off chain because it protects no value: vaults pay pro rata for any N, and the offer's yield test is exact for any N. Readers learn N from the chain and flag anything other than 100,000,000.
Maturity grid (default)#
A client snaps a fixed maturity at least 21,600 blocks away, about 30 days, to the nearest multiple of 21,600. A tie goes to the later height. A nearer maturity keeps its exact height, and the user can always keep an exact height. The client shows the snapped height before signing. Term (on-close) orders mature at the fill plus a duration, so they stay off the grid.
No batcher, offer or reader refuses, ranks down or flags an off-grid maturity. The grid exists so that bonds of one market mature at the same heights, which a later series layer can pool into one fungible token.
Cover at the fill#
Without a guard, nothing stops a fill from starting a bond that can be liquidated at once, and an order left open while the price moves becomes a free option for lenders. A client and batcher following zcs1:
- Give every oracle order the on-chain fill guard by default, at the order's own ratio.
- Never fill an order, by hand or from an offer, whose bond would start under its own oracle ratio at the confirmed oracle price. Never buy a claim on such a bond from any ask: liquidate it instead.
- Never post an unguarded oracle order already under its own ratio, and show the ERG price at which a fill would start a liquidatable bond, or at which the guard stops fills.
- Check a guard before building, so a fill the guard would refuse is never sent.
- Give a fixed-maturity order an expiry within half its term by default, and at most a week.
The user may override the off-chain refusals for their own transaction. Nothing overrides a guard.
Batching#
A batcher following zcs1 does the following:
- Packs independent work into one transaction. Expiry refunds of orders, offers and asks, and
liquidations, share one transaction, one miner fee and one change box, at most 20 boxes. Share mints and
new-bond fills cannot pack, since each mints the id of
INPUTS(0). Independent existing-bond matches can share a transaction. - Counts fees per transaction. Work is worth running when its fees together exceed the miner fee. A pack that fails is retried piece by piece.
- Chains through continuations. An offer that can take three orders needs three transactions, each spending the last one's continuation. Reading the mempool lets all three land in one block. A batcher never builds on a box it already spent, and pays fees from confirmed wallet boxes first.
- Reads the oracle from the chain. Oracles race to refresh the USD pool, and the losing refresh's box never exists. The Lithos client also treats a single uncontested pending refresh as the oracle, and sends a dependent transaction only when the node will order it after the refresh.
- Checks heights where the signer runs scripts. The node signs at height h and the transaction lands at h + 1 or later. A path open only before X needs h + 1 < X. A path open from X on needs h ≥ X.
- Uses one matching order. Offers go by the largest remaining batcher reward. Each takes the order
or ask giving it the highest yield,
(R / P - 1) × 262,800 / D. Ties go to the lower box id. - Prices ahead. A yield ask or priced order is paid at the most it asks from now to 3 blocks ahead. A Dutch lot or a lot auction is bought at the current price, which only falls.
- Picks a window order's maturity by one rule. The candidates are the ends of the heights both sides accept, both curves' breakpoints and the grid heights between. Of those the offer accepts: a grid height first, then the widest gap between the yield the offer earns and the yield it requires, then the shorter maturity.
- Refreshes old boxes. Bonds, vaults and wrap vaults over 525,600 blocks old pay up to 0.01 ERG to whoever refreshes them. A bond due for liquidation is liquidated instead, and none is refreshed in the 720 blocks before its maturity. A bond's successor is stamped 60 blocks back and discloses its borrower.
- Skips boxes that break script disclosure, and boxes naming an expression it has no bytes for.
Defaults#
These values coordinate clients and batchers. An order and an offer meet only when the order's oracle age is at least the offer's:
| Value | Default | Floor in the contracts |
|---|---|---|
| Miner fee | 0.001 ERG | |
| Order expiry | 5,040 blocks, or half a fixed maturity's term if less | |
| Order expiry fee | 0.005 ERG | 0.002 ERG |
| Oracle age written into an order's rule | 60 blocks | 1 to 100,000 |
| Oracle age on an offer | 30 blocks | At most the bond's |
| Offer maturity window | 1 to 262,800 blocks | |
| Offer and ask expiry | 5,040 blocks | |
| ERG offer batcher fee; token offer refund fee | 0.005 ERG | 0.002 ERG |
| Token offer least fill | 1% of original capital | 1% |
| Token offer reward budget | 0.2 ERG | Each fill's reward at least 0.002 ERG |
| ERG carried by a SigUSD offer for fees | 0.5 ERG | |
| Liquidation fee reserve | 0.05 ERG | 0 |
| Share mint fee, pull fee | 0.005 ERG each | 0.002 ERG |
| Ask refund fee | 0.002 ERG | None |
| Ask least fill, offer least price | 1 raw unit | |
| Fill guard on an oracle order | On, at the order's own ratio | At least that ratio |
| Sale guard | Off; oracle age 30 blocks when set | 1 to 100,000 blocks |
| Share count, decimals | 100,000,000, 6 | 1 to 1,000,000,000 |
| Share vault | Selective, threshold 100 | Threshold at least 100 |
| Auction length, expiry | 720 and 2,160 blocks | Length 1 to 1,000,000 |
| Offer's longest auction expiry bought | 0, which buys no shares | |
| Yield end point | The order's or ask's expiry | After the start |
| Lot fall, hold | 720 and 2,160 blocks | Fall at least 1 block |
| Lot refund fee | 0.002 ERG | None |
| Wrap mint fee; wrap refresh reserve | 0.005 ERG; 0.03 ERG | 0.002 ERG; none |
| Refresh age, bounty, stamp | 525,600 blocks; 0.01 ERG; a bond 60 blocks back, a vault now | Bond 60 to 999 back, others up to 999 |
Display#
A client shows SigmaFi data under the following rules:
- Amounts in the market's unit: ERG with 9 decimals, SigUSD with 2.
- Yields as a simple return per 262,800 blocks, never a calendar rate or a compounded APY, with the block normalization shown wherever a yield is.
- Heights with an approximate date at 2 minutes per block.
- Share prices as a percentage of face.
- A flag on anything the reader could not verify: an unproven origin, an unknown expression, nonstandard metadata, or a share count other than 100,000,000.
Next steps#
- ZC Standard contracts: the registers and paths these rules write into.
- Pricing: the formulas behind yields, curves and the matching order.
- Building on the Lithos API: a client that already follows every rule here.