@inversealtruism/cairnx-core 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/MAKERS.md CHANGED
@@ -234,7 +234,7 @@ Amounts named "base" are base units (CSD has 8 decimals). Defaults are those of
234
234
  | `MM_LEVELS` | `[[0,50],[2500,100],[6000,200]]` | `[spreadBps, size]` RFQ indicative tiers. In Sunrise only the sizes are read. |
235
235
  | `MM_LEVELS_FRAC` | `[[0,100],[2500,1000],[6000,2000]]` | Inventory-fraction ask tiers in bps of remaining inventory (1%, 10%, 20%), so a large seed is not a toy book. `[]` falls back to `MM_LEVELS`. |
236
236
  | `MM_LADDER_LEVELS` | `[]` (off) | The resting ask ladder. |
237
- | `MM_LADDER_EXPIRY`, `MM_LADDER_MAX_OPEN` | `8`, `4` | Rung expiry in epochs (must exceed the hold) and cap on standing rungs. |
237
+ | `MM_LADDER_EXPIRY`, `MM_LADDER_MAX_OPEN` | `8`, `4` | Rung expiry in epochs (must exceed the hold; a value below 4 is raised to 4) and cap on standing rungs. |
238
238
  | `MM_MIN_FILL` | `5000000` | Partial-fill floor in base CSD (pre-v1.3 ladder offers). |
239
239
  | `MM_EXPIRY`, `MM_ANSWER_EXPIRY` | `48`, `2` | Pre-v1.3 ladder and bid-answer expiry, in epochs. |
240
240
  | `MM_POLL_MS` | `30000` | Pass interval; a bid should be answered in about 30 seconds. At least 1000. |
@@ -242,7 +242,7 @@ Amounts named "base" are base units (CSD has 8 decimals). Defaults are those of
242
242
  | `MM_MIN_REF_BUYERS`, `MM_MAX_BUYER_SHARE_BPS` | `3`, `5000` | Distinct buyers required before an upward move; per-buyer weight cap. |
243
243
  | `MM_REF_CLAMP_BPS`, `MM_REF_CLAMP_BLOCKS` | `2000`, `30` | One clamp step per admitted print, at most once per this many blocks. |
244
244
  | `MM_BAND_LO`, `MM_BAND_HI` | unset | Absolute price band in base CSD per display unit. Set both. |
245
- | `MM_DRIFT_BPS`, `MM_DRIFT_PASSES` | `1500`, `2` | Ladder-refresh drift threshold and debounce. |
245
+ | `MM_DRIFT_BPS`, `MM_DRIFT_PASSES` | `1500`, `2` | Drift threshold and debounce. The ask ladder refreshes after the reference stays moved by more than `MM_DRIFT_BPS` for `MM_DRIFT_PASSES` consecutive passes; an own bid is cancelled after its price stays off target by more than `MM_DRIFT_BPS` for `MM_DRIFT_PASSES` blocks. |
246
246
  | `MM_FEE_BUDGET` | `1000000000` | Base CSD per UTC day of fees that bought nothing back. Live and filled answers are not counted; answers that expired unfilled are. Past half of it, addresses with no prior fill on CairnX are answered only for bids of at least `MM_FRESH_MIN_CSD` (reason `budget-fresh-min`); past all of it the bot posts nothing of its own and answers returning buyers only (`budget-returning-only`). Answers to returning buyers are bounded by `MM_MAX_BID_ANSWERS` and `MM_MIN_FLOAT_HARD`, not by this budget. |
247
247
  | `MM_FRESH_MIN_CSD`, `MM_FRESH_SLOTS` | `2000000000`, `16` | A bid below the minimum from an address with no prior fill is "fresh small" (in Sunrise the answer price is compared, not the bid). Such answers hold at most `MM_FRESH_SLOTS` of the `MM_MAX_BID_ANSWERS` slots (reason `fresh-slots`). |
248
248
  | `MM_BID_MIN`, `MM_BID_MARGIN_BPS`, `MM_MAX_BID_ANSWERS` | `200000000`, `200`, `24` | Bid dust floor (2 CSD), accept margin over the reference, and outstanding-answer cap. |
@@ -264,10 +264,8 @@ Amounts named "base" are base units (CSD has 8 decimals). Defaults are those of
264
264
  | `MM_BUY_PAUSE_PARTIES`, `MM_BUY_PAUSE_MIN_CSD` | `3`, `2000000000` | The prints below the pause line must come from this many distinct addresses and sum to this much CSD. |
265
265
  | `MM_VERIFY_INCLUSION` | `0` | 1 checks each indexer transaction against the maker's own node. Records younger than 12 blocks are deferred to a later pass, so the maker sees new records about 12 blocks late; `MM_INFLIGHT_TTL` grows by 12 blocks so a held-back post is not signed again, an answer holds its quota and capacity until its last epoch is final (one that expired unfilled frees it 12 blocks after expiry), and a buyer's bid is answered only once it is final with 2 epochs left; a record the node cannot prove fails the pass. It binds each record's outputs, position, height and own fields (proposer, uri, payload hash, expiry and domain; attester, score, confidence and target proposal) to the node's raw transaction, and an indexer row that disagrees fails the pass. The proposer or attester is the key whose signature in the first input verifies over the transaction's sighash, and a body without one fails the pass; this costs about 2.2 ms per record, cached until a reorg clears the cache (cold scan of 2,000 records on the test harness). The node supplies the headers, the tip and the bodies, and the maker checks no PoW and holds no UTXO set, so it cannot check that the signing key owns input 0's coin (a lying node could re-sign input 0 with its own key); the indexer can still withhold or delay records. A record with an expiry past 2^53 is parsed exactly and rejected per record, as with the flag off. Before turning it on in production, run one read-only flag-on scan against the live indexer and node and expect 0 field mismatches. |
266
266
  | `MM_INV_LO` | `4000000000000` | Skip new sells when inventory is below this, in base units. Set it to 20% of `MM_SEED_INVENTORY` in base units (display units times 1e8 for an 8-decimal token): a 1M seed gives 200k, a 21M seed gives 4.2M. |
267
- | `MM_BOOTSTRAP_BID` | off | Post a floor-bootstrap bid when the tape is empty. |
268
267
  | `MM_STALE_BLOCKS`, `MM_INFLIGHT_TTL` | `2`, `24` | Indexer-lag skip threshold; blocks an unconfirmed post stays "covering". |
269
268
  | `MM_SKEW_WINDOW`, `MM_SKEW_K_BPS`, `MM_SKEW_MAX_BPS`, `MM_SKEW_MAX_DN_BPS` | `720`, `200`, `10000`, `2000` | Flow skew of the ask: net tokens sold over the window (blocks) scaled by `k` against inventory, capped upward and, more tightly, downward so buying inventory back cannot sag the ask. |
270
- | `MM_BUSY_PATTERNS` | unset (off) | Comma-separated `pgrep -f` patterns; while one matches, the bot skips its pass. For an operator sharing one key between the bot and manual scripts; leave off with a dedicated key. |
271
269
  | `MM_DRY` | off | `1` builds everything, submits nothing, writes nothing, logs what would post. |
272
270
  | `MM_MODE` | `reservoir` | `reservoir` or `sunrise`. |
273
271
  | `MM_SEED_INVENTORY`, `MM_SEED_CSD`, `MM_REFILL_BELOW_BPS` | `197000`, `13700000000`, `2500` | Reservoir well denominator (display units); informational CSD buffer (base); raise `refillDue` when remaining inventory is below this many bps of seed. Refill coin, never CSD. |
@@ -409,9 +407,8 @@ maker self-publishes, the chain advertises where, aggregators merge.
409
407
  `sig` recovers to `maker` (the same csd-crypto scheme as anchors), so quotes are self-certifying and the hosting URL is
410
408
  not trusted. Quotes are indicative only; the binding act is the on-chain taker-bound answer, so a lying quote file costs
411
409
  its maker reputation, never a counterparty's funds.
412
- 2. The URL is advertised on chain, either through the L3 registry (a `cairnx:makers` list in the csd-registry convention
413
- with entries `{ addr, url, ticker? }`; resolvers exist in `@inversealtruism/csd-registry`) or through a new cairnx record
414
- `{"v":1,"t":"maker","url":"https://..."}`, which would need a convention revision.
410
+ 2. The URL is advertised on chain through a new cairnx record `{"v":1,"t":"maker","url":"https://..."}`, which would
411
+ need a convention revision.
415
412
  3. Aggregators fetch every advertised URL, verify `sig` against the advertised maker, drop stale quotes (older than about
416
413
  three poll intervals) and halted makers, keep the latest per maker, and merge the book by best `pricePerUnit` per size
417
414
  tier with attribution.
package/README.md CHANGED
@@ -256,11 +256,11 @@ is bounded in the light client, not the chain.
256
256
  | v2.3 | 52 000 | `nset` to the zero address CLEARS the pointer (*still pending as of 2026-07-06, tip ~48 300*) |
257
257
 
258
258
  v2.4–v2.7 were re-pinned 2026-07-03 from their originally published heights (49 200 / 51 000 / 51 200 /
259
- 52 500) — see the re-pin history note in `CONVENTION.md` and `CONSENSUS_CHANGES.md` 0.1.33.
259
+ 52 500); see the re-pin history note in `CONVENTION.md` and `CONSENSUS_CHANGES.md` 0.1.33.
260
260
 
261
261
  ### Package layout
262
262
 
263
- `src/resolve.ts` (the ledger) · `src/records.ts` (the parse/validate gate) · `src/types.ts` (constants +
263
+ `src/resolve.ts` + `src/resolve/` (the ledger: the replay loop and its per-record handlers) · `src/records.ts` (the parse/validate gate) · `src/types.ts` (constants +
264
264
  height-gated client selectors) · `src/client.ts` (reorg-safety helpers a payer applies) · `src/preflight.ts`
265
265
  (build-side helpers every host must compute identically: `requiredFillOutputs`, `previewFill`/`fillIsSafe`,
266
266
  `buildFeeHeight` + `NAME_FEE_GATES`, `finalizeWinnerCheck`) · `src/primary.ts` (`pickPrimaryName` /
@@ -290,8 +290,8 @@ console.log(state.names, state.tokens.CAIRN, state.balances.CAIRN);
290
290
 
291
291
  ### Write a conformant resolver in another language
292
292
 
293
- 1. Implement `CONVENTION.md` §1–§30 (apply order, every record type, the `V*_HEIGHT` activations — using
294
- the re-pinned v2.4–v2.7 heights — the canonical-state format, ordinal key ordering, data surface only).
293
+ 1. Implement `CONVENTION.md` §1–§30 (apply order, every record type, the `V*_HEIGHT` activations (using
294
+ the re-pinned v2.4–v2.7 heights), the canonical-state format, ordinal key ordering, data surface only).
295
295
  2. Replay `test/vectors/cases.json`: your canonical state must equal `expectedState` **byte-for-byte**.
296
296
  3. Replay the live chain and compare `sha256(canonicalState)` against `test/vectors/replay-hashes.json`.
297
297
 
@@ -314,8 +314,9 @@ is a silent chain fork, the exact bug class the shared-core de-dup (`cairn/docs/
314
314
  | **the Python oracle** `conformance/cairnx_ref.py` | INDEPENDENT re-implementation (the differential, **KEEP**) | `test:crosslang` (JS⇄Python) |
315
315
 
316
316
  **To make a consensus change:** edit `src/` here **and** `conformance/cairnx_ref.py`; add a height-gated
317
- `V*_HEIGHT` (never reinterpret history) + a vector; `pnpm build && pnpm test && pnpm test:crosslang &&
318
- node scripts/check-lockstep.mjs` (all green); **bump the version**; `pnpm publish`; **rebuild + recommit
317
+ `V*_HEIGHT` (never reinterpret history) + a vector; `pnpm build && pnpm test && pnpm test:crosslang`
318
+ (all green); **bump the version** (`node scripts/check-lockstep.mjs` fails until you do: it compares the
319
+ published tarball of the current version with this build); `pnpm publish`; **rebuild + recommit
319
320
  the two vendored bundles**; re-pin every consumer and deploy them **between** activation heights, not
320
321
  across one (below the gate the output is byte-identical, so the rollout is fork-free).
321
322