@inversealtruism/cairnx-core 0.1.42 → 0.1.44
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/CONVENTION.md +11 -0
- package/MAKERS.md +399 -117
- package/README.md +5 -3
- package/dist/index.cjs +72 -22
- package/dist/index.d.cts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +50 -3
- package/dist/mm/index.cjs +364 -0
- package/dist/mm/index.d.cts +193 -0
- package/dist/mm/index.d.ts +193 -0
- package/dist/mm/index.js +323 -0
- package/package.json +13 -3
- package/test/vectors/replay-corpus.json +1 -1
- package/test/vectors/replay-hashes.json +4 -3
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ the operator's resolver does, and disagreement is detectable.
|
|
|
38
38
|
┌───────────────┴───────────────────────────────────────────────┴──────────────┐
|
|
39
39
|
│ cairnX OVERLAY = resolve(events, tip) → state (THIS PACKAGE) │
|
|
40
40
|
│ every replayer runs the SAME pure function and gets the SAME bytes: │
|
|
41
|
-
│ wallet (SPV, in-browser) ·
|
|
41
|
+
│ wallet (SPV, in-browser) · reference resolver · clarvis · cli │
|
|
42
42
|
└───────────────▲────────────────────────────────────────────────────────────────┘
|
|
43
43
|
│ events (Propose/Attest) + block headers
|
|
44
44
|
┌───────────────┴────────────────────────────────────────────────────────────────┐
|
|
@@ -61,7 +61,7 @@ flowchart TD
|
|
|
61
61
|
end
|
|
62
62
|
CORE["cairnx-core<br/><b>resolve(events, tip) → state</b><br/>pure · deterministic · this package"]
|
|
63
63
|
W["Cairn Wallet<br/>in-browser SPV replayer"]
|
|
64
|
-
G["
|
|
64
|
+
G["reference resolver svc :8794"]
|
|
65
65
|
CL["clarvis · 2nd source"]
|
|
66
66
|
CLI["cairn-cli"]
|
|
67
67
|
UIN["CNS UI /names"]
|
|
@@ -264,7 +264,9 @@ v2.4–v2.7 were re-pinned 2026-07-03 from their originally published heights (4
|
|
|
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` /
|
|
267
|
-
`primaryRankBefore`, the one primary-name selection every host must agree on) · `
|
|
267
|
+
`primaryRankBefore`, the one primary-name selection every host must agree on) · `src/mm/` (the
|
|
268
|
+
`@inversealtruism/cairnx-core/mm` subpath: the market maker's bid sizer, fill notional, Sunrise spot curve and
|
|
269
|
+
order pricing, and the RFQ all-in sum; not consensus and not part of the root export) · `CONVENTION.md`
|
|
268
270
|
(normative spec, §1–§30) · `test/vectors/` (portable conformance corpus).
|
|
269
271
|
|
|
270
272
|
### Use it
|
package/dist/index.cjs
CHANGED
|
@@ -115,13 +115,14 @@ __export(index_exports, {
|
|
|
115
115
|
blockReward: () => import_csd_codec5.blockReward,
|
|
116
116
|
buildFeeHeight: () => buildFeeHeight,
|
|
117
117
|
buildRecord: () => buildRecord,
|
|
118
|
+
burnedPayment: () => burnedPayment,
|
|
118
119
|
canonicalJson: () => import_csd_codec5.canonicalJson,
|
|
119
120
|
canonicalState: () => canonicalState,
|
|
120
121
|
claimGraceOf: () => claimGraceOf,
|
|
121
122
|
claimWindowAt: () => claimWindowAt,
|
|
122
123
|
claimWindowOf: () => claimWindowOf,
|
|
123
124
|
deploy: () => deploy,
|
|
124
|
-
epochOf: () => epochOf,
|
|
125
|
+
epochOf: () => import_csd_codec.epochOf,
|
|
125
126
|
expiredClaimFee: () => expiredClaimFee,
|
|
126
127
|
fclaim: () => fclaim,
|
|
127
128
|
fclaimEpochFor: () => fclaimEpochFor,
|
|
@@ -139,6 +140,7 @@ __export(index_exports, {
|
|
|
139
140
|
isTokenWant: () => isTokenWant,
|
|
140
141
|
makerRebate: () => makerRebate,
|
|
141
142
|
mint: () => mint,
|
|
143
|
+
myProvenFillClosedOffer: () => myProvenFillClosedOffer,
|
|
142
144
|
nameClaim: () => nameClaim,
|
|
143
145
|
nameCommit: () => nameCommit,
|
|
144
146
|
nameCommitRecord: () => nameCommitRecord,
|
|
@@ -159,6 +161,7 @@ __export(index_exports, {
|
|
|
159
161
|
previewFill: () => previewFill,
|
|
160
162
|
primaryRankBefore: () => primaryRankBefore,
|
|
161
163
|
provenOfferTerms: () => provenOfferTerms,
|
|
164
|
+
ptAmt: () => ptAmt,
|
|
162
165
|
replayLiveHold: () => replayLiveHold,
|
|
163
166
|
requiredClaimDepth: () => requiredClaimDepth,
|
|
164
167
|
requiredFillOutputs: () => requiredFillOutputs,
|
|
@@ -193,7 +196,7 @@ function expiredClaimFee(name, epochsPastGraceEnd, height) {
|
|
|
193
196
|
const mult = 1n + (NAME_PREMIUM_START - 1n) * left / BigInt(NAME_PREMIUM_DECAY_EPOCHS);
|
|
194
197
|
return base * mult;
|
|
195
198
|
}
|
|
196
|
-
var MAX_RECORD_BYTES =
|
|
199
|
+
var MAX_RECORD_BYTES = import_csd_codec.MAX_URI_BYTES;
|
|
197
200
|
var MAX_AMOUNT = (1n << 96n) - 1n;
|
|
198
201
|
var SCORE_FILL = 100;
|
|
199
202
|
var SCORE_CANCEL = 0;
|
|
@@ -265,7 +268,6 @@ var V26_HEIGHT = 46480;
|
|
|
265
268
|
var V27_HEIGHT = 46520;
|
|
266
269
|
var V28_HEIGHT = 6e4;
|
|
267
270
|
var V29_HEIGHT = 88e3;
|
|
268
|
-
var epochOf = (height) => Math.floor(height / import_csd_codec.EPOCH_LEN);
|
|
269
271
|
var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
270
272
|
var FCLAIM_WINDOW_MIN = CLAIM_WINDOW_BLOCKS_V20 + CLAIM_FILL_GRACE_BLOCKS + 1;
|
|
271
273
|
var claimWindowOf = (claimUntilHeight, claimTxid) => {
|
|
@@ -273,12 +275,12 @@ var claimWindowOf = (claimUntilHeight, claimTxid) => {
|
|
|
273
275
|
return claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
274
276
|
};
|
|
275
277
|
var claimGraceOf = (claimUntilHeight, claimTxid) => claimTxid !== void 0 ? 0 : claimUntilHeight - CLAIM_WINDOW_BLOCKS_V20 >= V20_HEIGHT ? CLAIM_FILL_GRACE_BLOCKS : 0;
|
|
276
|
-
var fclaimEpochFor = (tipHeight, offerExpiresEpoch) => Math.min(epochOf(tipHeight + CLAIM_WINDOW_BLOCKS_V20 + CLAIM_FILL_GRACE_BLOCKS), offerExpiresEpoch);
|
|
278
|
+
var fclaimEpochFor = (tipHeight, offerExpiresEpoch) => Math.min((0, import_csd_codec.epochOf)(tipHeight + CLAIM_WINDOW_BLOCKS_V20 + CLAIM_FILL_GRACE_BLOCKS), offerExpiresEpoch);
|
|
277
279
|
var fclaimHoldEnd = (expiresEpoch) => (expiresEpoch + 1) * import_csd_codec.EPOCH_LEN - 1;
|
|
278
280
|
var offerExpiryHeightOf = (expiresEpoch, anchorHeight) => {
|
|
279
281
|
const raw = (Number(expiresEpoch ?? 0) + 1) * import_csd_codec.EPOCH_LEN;
|
|
280
282
|
if (anchorHeight >= V22_HEIGHT) return raw;
|
|
281
|
-
const capped = (epochOf(anchorHeight) + MAX_OFFER_EPOCHS + 1) * import_csd_codec.EPOCH_LEN;
|
|
283
|
+
const capped = ((0, import_csd_codec.epochOf)(anchorHeight) + MAX_OFFER_EPOCHS + 1) * import_csd_codec.EPOCH_LEN;
|
|
282
284
|
return Math.min(raw, Math.max(V21_HEIGHT, capped));
|
|
283
285
|
};
|
|
284
286
|
var isNameGive = (g) => typeof g.name === "string";
|
|
@@ -604,9 +606,9 @@ function resolve(events, tipHeight) {
|
|
|
604
606
|
b.available += amt;
|
|
605
607
|
}
|
|
606
608
|
};
|
|
607
|
-
const effExpiry = (e, height) => e.height >= V22_HEIGHT ? e.expiresEpoch : height >= V21_HEIGHT ? Math.min(e.expiresEpoch, epochOf(e.height) + MAX_OFFER_EPOCHS) : e.expiresEpoch;
|
|
609
|
+
const effExpiry = (e, height) => e.height >= V22_HEIGHT ? e.expiresEpoch : height >= V21_HEIGHT ? Math.min(e.expiresEpoch, (0, import_csd_codec.epochOf)(e.height) + MAX_OFFER_EPOCHS) : e.expiresEpoch;
|
|
608
610
|
const sweepExpired = (height) => {
|
|
609
|
-
const ep = epochOf(height);
|
|
611
|
+
const ep = (0, import_csd_codec.epochOf)(height);
|
|
610
612
|
for (const id of [...openOffers]) {
|
|
611
613
|
const o = offers.get(id);
|
|
612
614
|
if (!o || o.status !== "open") {
|
|
@@ -642,7 +644,7 @@ function resolve(events, tipHeight) {
|
|
|
642
644
|
if (height > r.finalizeBy) recaptures.delete(nm);
|
|
643
645
|
}
|
|
644
646
|
};
|
|
645
|
-
const V15_EPOCH = epochOf(V15_HEIGHT);
|
|
647
|
+
const V15_EPOCH = (0, import_csd_codec.epochOf)(V15_HEIGHT);
|
|
646
648
|
const paidThrough = (n) => n.paidThroughEpoch ?? V15_EPOCH + NAME_TERM_EPOCHS;
|
|
647
649
|
const lapsed = (n, ep) => ep > paidThrough(n) + NAME_GRACE_EPOCHS;
|
|
648
650
|
const inGrace = (n, ep) => ep > paidThrough(n) && !lapsed(n, ep);
|
|
@@ -799,7 +801,7 @@ function resolve(events, tipHeight) {
|
|
|
799
801
|
effHeight = cH;
|
|
800
802
|
}
|
|
801
803
|
const cur = names.get(rec.name);
|
|
802
|
-
const epClaim = epochOf(ev.height);
|
|
804
|
+
const epClaim = (0, import_csd_codec.epochOf)(ev.height);
|
|
803
805
|
const curActive = cur && cur.pending && cur.finalizeBy !== void 0 && ev.height > cur.finalizeBy ? void 0 : cur;
|
|
804
806
|
if (curActive && !curActive.pending && v15 && lapsed(curActive, epClaim)) {
|
|
805
807
|
if (v26) {
|
|
@@ -909,7 +911,7 @@ function resolve(events, tipHeight) {
|
|
|
909
911
|
delete n.pending;
|
|
910
912
|
delete n.finalizeBy;
|
|
911
913
|
pendingNames.delete(rec.name);
|
|
912
|
-
n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
|
|
914
|
+
n.paidThroughEpoch = (0, import_csd_codec.epochOf)(ev.height) + NAME_TERM_EPOCHS;
|
|
913
915
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
914
916
|
note(ev, ev.id, "nfinalize", true);
|
|
915
917
|
continue;
|
|
@@ -930,7 +932,7 @@ function resolve(events, tipHeight) {
|
|
|
930
932
|
continue;
|
|
931
933
|
}
|
|
932
934
|
const cur = names.get(rec.name);
|
|
933
|
-
const ep = epochOf(ev.height);
|
|
935
|
+
const ep = (0, import_csd_codec.epochOf)(ev.height);
|
|
934
936
|
if (!cur || cur.pending || !lapsed(cur, ep)) {
|
|
935
937
|
recaptures.delete(rec.name);
|
|
936
938
|
note(ev, ev.id, "nfinalize", false, "name is no longer lapsed");
|
|
@@ -959,7 +961,7 @@ function resolve(events, tipHeight) {
|
|
|
959
961
|
note(ev, ev.id, "nxfer", false, "name reservation not yet finalized");
|
|
960
962
|
continue;
|
|
961
963
|
}
|
|
962
|
-
if (v15 && lapsed(n, epochOf(ev.height))) {
|
|
964
|
+
if (v15 && lapsed(n, (0, import_csd_codec.epochOf)(ev.height))) {
|
|
963
965
|
note(ev, ev.id, "nxfer", false, "lease lapsed \u2014 claim it instead");
|
|
964
966
|
continue;
|
|
965
967
|
}
|
|
@@ -981,7 +983,7 @@ function resolve(events, tipHeight) {
|
|
|
981
983
|
note(ev, ev.id, "nset", false, "name reservation not yet finalized");
|
|
982
984
|
continue;
|
|
983
985
|
}
|
|
984
|
-
if (v15 && lapsed(n, epochOf(ev.height))) {
|
|
986
|
+
if (v15 && lapsed(n, (0, import_csd_codec.epochOf)(ev.height))) {
|
|
985
987
|
note(ev, ev.id, "nset", false, "lease lapsed \u2014 claim it instead");
|
|
986
988
|
continue;
|
|
987
989
|
}
|
|
@@ -1002,7 +1004,7 @@ function resolve(events, tipHeight) {
|
|
|
1002
1004
|
note(ev, ev.id, "nprofile", false, "name reservation not yet finalized");
|
|
1003
1005
|
continue;
|
|
1004
1006
|
}
|
|
1005
|
-
if (v15 && lapsed(n, epochOf(ev.height))) {
|
|
1007
|
+
if (v15 && lapsed(n, (0, import_csd_codec.epochOf)(ev.height))) {
|
|
1006
1008
|
note(ev, ev.id, "nprofile", false, "lease lapsed \u2014 claim it instead");
|
|
1007
1009
|
continue;
|
|
1008
1010
|
}
|
|
@@ -1027,11 +1029,11 @@ function resolve(events, tipHeight) {
|
|
|
1027
1029
|
note(ev, ev.id, "offer", false, "expiresEpoch out of safe-integer range");
|
|
1028
1030
|
continue;
|
|
1029
1031
|
}
|
|
1030
|
-
if (epochOf(ev.height) > ev.expiresEpoch) {
|
|
1032
|
+
if ((0, import_csd_codec.epochOf)(ev.height) > ev.expiresEpoch) {
|
|
1031
1033
|
note(ev, ev.id, "offer", false, "already expired at anchor");
|
|
1032
1034
|
continue;
|
|
1033
1035
|
}
|
|
1034
|
-
if (ev.height >= V21_HEIGHT && ev.height < V22_HEIGHT && ev.expiresEpoch - epochOf(ev.height) > MAX_OFFER_EPOCHS) {
|
|
1036
|
+
if (ev.height >= V21_HEIGHT && ev.height < V22_HEIGHT && ev.expiresEpoch - (0, import_csd_codec.epochOf)(ev.height) > MAX_OFFER_EPOCHS) {
|
|
1035
1037
|
note(ev, ev.id, "offer", false, "v2.1: offer duration exceeds the max");
|
|
1036
1038
|
continue;
|
|
1037
1039
|
}
|
|
@@ -1106,11 +1108,11 @@ function resolve(events, tipHeight) {
|
|
|
1106
1108
|
note(ev, ev.id, "bid", false, "expiresEpoch out of safe-integer range");
|
|
1107
1109
|
continue;
|
|
1108
1110
|
}
|
|
1109
|
-
if (epochOf(ev.height) > ev.expiresEpoch) {
|
|
1111
|
+
if ((0, import_csd_codec.epochOf)(ev.height) > ev.expiresEpoch) {
|
|
1110
1112
|
note(ev, ev.id, "bid", false, "already expired at anchor");
|
|
1111
1113
|
continue;
|
|
1112
1114
|
}
|
|
1113
|
-
if (ev.height >= V21_HEIGHT && ev.height < V22_HEIGHT && ev.expiresEpoch - epochOf(ev.height) > MAX_OFFER_EPOCHS) {
|
|
1115
|
+
if (ev.height >= V21_HEIGHT && ev.height < V22_HEIGHT && ev.expiresEpoch - (0, import_csd_codec.epochOf)(ev.height) > MAX_OFFER_EPOCHS) {
|
|
1114
1116
|
note(ev, ev.id, "bid", false, "v2.1: bid duration exceeds the max");
|
|
1115
1117
|
continue;
|
|
1116
1118
|
}
|
|
@@ -1165,7 +1167,7 @@ function resolve(events, tipHeight) {
|
|
|
1165
1167
|
continue;
|
|
1166
1168
|
}
|
|
1167
1169
|
const n = names.get(rec.name);
|
|
1168
|
-
const ep = epochOf(ev.height);
|
|
1170
|
+
const ep = (0, import_csd_codec.epochOf)(ev.height);
|
|
1169
1171
|
if (n && n.pending) {
|
|
1170
1172
|
note(ev, ev.id, "nrenew", false, "name reservation not yet finalized");
|
|
1171
1173
|
continue;
|
|
@@ -1236,11 +1238,11 @@ function resolve(events, tipHeight) {
|
|
|
1236
1238
|
deny("hold would outlive the offer expiry");
|
|
1237
1239
|
continue;
|
|
1238
1240
|
}
|
|
1239
|
-
if (E > epochOf(ev.height) + FCLAIM_MAX_EPOCH_AHEAD) {
|
|
1241
|
+
if (E > (0, import_csd_codec.epochOf)(ev.height) + FCLAIM_MAX_EPOCH_AHEAD) {
|
|
1240
1242
|
deny("hold too far ahead (anti-squat)");
|
|
1241
1243
|
continue;
|
|
1242
1244
|
}
|
|
1243
|
-
if (epochOf(ev.height) > E) {
|
|
1245
|
+
if ((0, import_csd_codec.epochOf)(ev.height) > E) {
|
|
1244
1246
|
deny("expiry already in the past");
|
|
1245
1247
|
continue;
|
|
1246
1248
|
}
|
|
@@ -1535,7 +1537,7 @@ function resolve(events, tipHeight) {
|
|
|
1535
1537
|
const tipV15 = tipHeight >= V15_HEIGHT;
|
|
1536
1538
|
const tipV19 = tipHeight >= V19_HEIGHT;
|
|
1537
1539
|
const tipV25 = tipHeight >= V25_HEIGHT;
|
|
1538
|
-
const tipEpoch = epochOf(tipHeight);
|
|
1540
|
+
const tipEpoch = (0, import_csd_codec.epochOf)(tipHeight);
|
|
1539
1541
|
for (const [nm, n] of [...names.entries()].sort(([a], [b]) => ord(a, b))) {
|
|
1540
1542
|
if (tipV25 && n.pending) {
|
|
1541
1543
|
namesOut[nm] = { name: nm, owner: n.owner, claimId: n.id, height: n.height, effectiveHeight: n.effHeight, locked: n.locked, pending: true, finalizeBy: n.finalizeBy };
|
|
@@ -1911,6 +1913,51 @@ function paidToFromOutputs(outputs) {
|
|
|
1911
1913
|
}
|
|
1912
1914
|
return m;
|
|
1913
1915
|
}
|
|
1916
|
+
function burnedPayment(paidTo, payer, offer2) {
|
|
1917
|
+
const read = (addr) => addr === payer ? 0n : ptAmt(paidTo?.[addr]);
|
|
1918
|
+
let counterparty = 0n;
|
|
1919
|
+
if (offer2) {
|
|
1920
|
+
for (const addr of /* @__PURE__ */ new Set([offer2.seller, offer2.want.payto])) if (addr !== TREASURY_ADDR) counterparty += read(addr);
|
|
1921
|
+
}
|
|
1922
|
+
return { treasury: read(TREASURY_ADDR), counterparty };
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
// src/fillclosed.ts
|
|
1926
|
+
var lc = (v) => String(v).toLowerCase();
|
|
1927
|
+
function myProvenFillClosedOffer(fill, fclaim2, offerEv, me, grantHeight) {
|
|
1928
|
+
if (!(grantHeight >= V29_HEIGHT)) return false;
|
|
1929
|
+
if (!fill || fill.kind !== "attest" || fill.score !== SCORE_FILL) return false;
|
|
1930
|
+
if (lc(fill.attester) !== lc(me) || lc(fill.proposalId) !== lc(fclaim2.id)) return false;
|
|
1931
|
+
if (!(fill.height > fclaim2.height && fill.height < grantHeight)) return false;
|
|
1932
|
+
if (!offerEv || offerEv.kind !== "propose" || lc(offerEv.id) !== lc(fclaim2.offer)) return false;
|
|
1933
|
+
const bound = bindProvenOffer(offerEv);
|
|
1934
|
+
const value = bound?.terms.value;
|
|
1935
|
+
if (!bound || value === void 0) return false;
|
|
1936
|
+
const t = bound.terms;
|
|
1937
|
+
const state = {
|
|
1938
|
+
id: lc(offerEv.id),
|
|
1939
|
+
seller: bound.seller,
|
|
1940
|
+
give: t.giveName !== void 0 ? { name: t.giveName } : { ticker: String(t.giveTicker ?? ""), amount: String(t.giveAmount ?? "") },
|
|
1941
|
+
want: { value, payto: bound.payto },
|
|
1942
|
+
status: "open",
|
|
1943
|
+
expiresEpoch: offerEv.expiresEpoch,
|
|
1944
|
+
height: t.height,
|
|
1945
|
+
feeBps: t.feeBps,
|
|
1946
|
+
taker: t.taker,
|
|
1947
|
+
bid: t.bid,
|
|
1948
|
+
min: t.min,
|
|
1949
|
+
paid: "0",
|
|
1950
|
+
delivered: "0"
|
|
1951
|
+
};
|
|
1952
|
+
let need;
|
|
1953
|
+
try {
|
|
1954
|
+
need = requiredFillOutputs(state, BigInt(value));
|
|
1955
|
+
} catch {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1958
|
+
if (!need) return false;
|
|
1959
|
+
return need.every((leg) => ptAmt(fill.paidTo?.[lc(leg.to)]) >= leg.value);
|
|
1960
|
+
}
|
|
1914
1961
|
|
|
1915
1962
|
// src/index.ts
|
|
1916
1963
|
var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
@@ -2011,6 +2058,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
2011
2058
|
blockReward,
|
|
2012
2059
|
buildFeeHeight,
|
|
2013
2060
|
buildRecord,
|
|
2061
|
+
burnedPayment,
|
|
2014
2062
|
canonicalJson,
|
|
2015
2063
|
canonicalState,
|
|
2016
2064
|
claimGraceOf,
|
|
@@ -2035,6 +2083,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
2035
2083
|
isTokenWant,
|
|
2036
2084
|
makerRebate,
|
|
2037
2085
|
mint,
|
|
2086
|
+
myProvenFillClosedOffer,
|
|
2038
2087
|
nameClaim,
|
|
2039
2088
|
nameCommit,
|
|
2040
2089
|
nameCommitRecord,
|
|
@@ -2055,6 +2104,7 @@ var import_csd_codec5 = require("@inversealtruism/csd-codec");
|
|
|
2055
2104
|
previewFill,
|
|
2056
2105
|
primaryRankBefore,
|
|
2057
2106
|
provenOfferTerms,
|
|
2107
|
+
ptAmt,
|
|
2058
2108
|
replayLiveHold,
|
|
2059
2109
|
requiredClaimDepth,
|
|
2060
2110
|
requiredFillOutputs,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EPOCH_LEN, HALVING_INTERVAL, INITIAL_REWARD, MIN_FEE_ATTEST, MIN_FEE_PROPOSE, blockReward, canonicalJson, payloadHash } from '@inversealtruism/csd-codec';
|
|
1
|
+
export { EPOCH_LEN, HALVING_INTERVAL, INITIAL_REWARD, MIN_FEE_ATTEST, MIN_FEE_PROPOSE, blockReward, canonicalJson, epochOf, payloadHash } from '@inversealtruism/csd-codec';
|
|
2
2
|
|
|
3
3
|
declare const DOMAIN = "cairnx:v1";
|
|
4
4
|
declare const ACTIVATION_HEIGHT = 29860;
|
|
@@ -74,7 +74,6 @@ declare const V26_HEIGHT = 46480;
|
|
|
74
74
|
declare const V27_HEIGHT = 46520;
|
|
75
75
|
declare const V28_HEIGHT = 60000;
|
|
76
76
|
declare const V29_HEIGHT = 88000;
|
|
77
|
-
declare const epochOf: (height: number) => number;
|
|
78
77
|
declare const claimWindowAt: (height: number) => number;
|
|
79
78
|
declare const FCLAIM_WINDOW_MIN: number;
|
|
80
79
|
declare const claimWindowOf: (claimUntilHeight: number, claimTxid?: string) => number;
|
|
@@ -427,6 +426,7 @@ declare const tokenMeta: (r: Omit<TokenMetaRecord, "v" | "t">) => BuiltRecord;
|
|
|
427
426
|
declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecord;
|
|
428
427
|
declare const fclaim: (r: Omit<FclaimRecord, "v" | "t">) => BuiltRecord;
|
|
429
428
|
|
|
429
|
+
declare function ptAmt(v: unknown): bigint;
|
|
430
430
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
431
431
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
432
432
|
* The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
|
|
@@ -688,6 +688,8 @@ interface FillVerdict {
|
|
|
688
688
|
* across offers, so without this the surface would false-accept a cap-denied fclaim. `opts.pay` overrides the
|
|
689
689
|
* payment (base units to want.payto) for a PARTIAL tail-fill; defaults to the offer's full want.value.
|
|
690
690
|
*
|
|
691
|
+
* `opts.sums` is caller data (the per-address outputs the caller is about to build), so it cannot default on:
|
|
692
|
+
* without it there is nothing to bind. A caller that omits it keeps the overpay exposure described next.
|
|
691
693
|
* `opts.sums` (OPT-IN, B6a / REBIND W3; default OFF = byte-identical verdicts for existing callers) binds the
|
|
692
694
|
* caller's PLANNED per-address CSD payment sums to the PROVEN offer state: requiredFillOutputs is re-run over
|
|
693
695
|
* the merkle-proven, replayed offer (so `paid`/`delivered` are the chain's, not a served lie) and the caller's
|
|
@@ -767,5 +769,27 @@ declare function paidToFromOutputs(outputs: readonly {
|
|
|
767
769
|
addr: string;
|
|
768
770
|
value: number;
|
|
769
771
|
}[]): Record<string, string>;
|
|
772
|
+
/** What a record resolve() refused paid to the parties the protocol pays, read with the resolver's ptAmt:
|
|
773
|
+
* `treasury` is the output to TREASURY_ADDR, `counterparty` the outputs to the target offer's seller and
|
|
774
|
+
* want.payto (pass `offer` for a fill, omit it otherwise). Each address counts once and the payer's own
|
|
775
|
+
* outputs never count, so a payer paying itself burns nothing. */
|
|
776
|
+
declare function burnedPayment(paidTo: Readonly<Record<string, unknown>> | undefined, payer: string, offer?: Pick<OfferState, "seller" | "want"> | null): {
|
|
777
|
+
treasury: bigint;
|
|
778
|
+
counterparty: bigint;
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* True only when `fill` proves `me`'s own fill CLOSED the offer behind `fclaim` before `grantHeight`, so a
|
|
783
|
+
* resolver at a grant height >= V29_HEIGHT no longer counts that hold. `fill` and `offerEv` must be
|
|
784
|
+
* merkle-proven and prevout-bound by the caller. The fill must be a SCORE_FILL by `me` on exactly this fclaim,
|
|
785
|
+
* mined strictly after the fclaim and strictly before the grant, and carry every output of a FULL fill of the
|
|
786
|
+
* proven offer (want.value to payto, the fee, the maker rebate), read as the resolver reads them (ptAmt).
|
|
787
|
+
* A partial-lane offer closed by a remainder fill stays counted: the remainder depends on the served `paid`.
|
|
788
|
+
*/
|
|
789
|
+
declare function myProvenFillClosedOffer(fill: ProvenEvent | null, fclaim: {
|
|
790
|
+
id: string;
|
|
791
|
+
height: number;
|
|
792
|
+
offer: string;
|
|
793
|
+
}, offerEv: ProvenEvent | null, me: string, grantHeight: number): boolean;
|
|
770
794
|
|
|
771
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy,
|
|
795
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EPOCH_LEN, HALVING_INTERVAL, INITIAL_REWARD, MIN_FEE_ATTEST, MIN_FEE_PROPOSE, blockReward, canonicalJson, payloadHash } from '@inversealtruism/csd-codec';
|
|
1
|
+
export { EPOCH_LEN, HALVING_INTERVAL, INITIAL_REWARD, MIN_FEE_ATTEST, MIN_FEE_PROPOSE, blockReward, canonicalJson, epochOf, payloadHash } from '@inversealtruism/csd-codec';
|
|
2
2
|
|
|
3
3
|
declare const DOMAIN = "cairnx:v1";
|
|
4
4
|
declare const ACTIVATION_HEIGHT = 29860;
|
|
@@ -74,7 +74,6 @@ declare const V26_HEIGHT = 46480;
|
|
|
74
74
|
declare const V27_HEIGHT = 46520;
|
|
75
75
|
declare const V28_HEIGHT = 60000;
|
|
76
76
|
declare const V29_HEIGHT = 88000;
|
|
77
|
-
declare const epochOf: (height: number) => number;
|
|
78
77
|
declare const claimWindowAt: (height: number) => number;
|
|
79
78
|
declare const FCLAIM_WINDOW_MIN: number;
|
|
80
79
|
declare const claimWindowOf: (claimUntilHeight: number, claimTxid?: string) => number;
|
|
@@ -427,6 +426,7 @@ declare const tokenMeta: (r: Omit<TokenMetaRecord, "v" | "t">) => BuiltRecord;
|
|
|
427
426
|
declare const nameProfile: (r: Omit<NameProfileRecord, "v" | "t">) => BuiltRecord;
|
|
428
427
|
declare const fclaim: (r: Omit<FclaimRecord, "v" | "t">) => BuiltRecord;
|
|
429
428
|
|
|
429
|
+
declare function ptAmt(v: unknown): bigint;
|
|
430
430
|
declare function resolve(events: ChainEvent[], tipHeight: number): CairnXState;
|
|
431
431
|
/** Canonical serialization of state (FORMAT 2) — byte-identical across honest resolvers.
|
|
432
432
|
* The canonical surface is the DATA ONLY: {tipHeight, tokens, balances, names, offers, bids,
|
|
@@ -688,6 +688,8 @@ interface FillVerdict {
|
|
|
688
688
|
* across offers, so without this the surface would false-accept a cap-denied fclaim. `opts.pay` overrides the
|
|
689
689
|
* payment (base units to want.payto) for a PARTIAL tail-fill; defaults to the offer's full want.value.
|
|
690
690
|
*
|
|
691
|
+
* `opts.sums` is caller data (the per-address outputs the caller is about to build), so it cannot default on:
|
|
692
|
+
* without it there is nothing to bind. A caller that omits it keeps the overpay exposure described next.
|
|
691
693
|
* `opts.sums` (OPT-IN, B6a / REBIND W3; default OFF = byte-identical verdicts for existing callers) binds the
|
|
692
694
|
* caller's PLANNED per-address CSD payment sums to the PROVEN offer state: requiredFillOutputs is re-run over
|
|
693
695
|
* the merkle-proven, replayed offer (so `paid`/`delivered` are the chain's, not a served lie) and the caller's
|
|
@@ -767,5 +769,27 @@ declare function paidToFromOutputs(outputs: readonly {
|
|
|
767
769
|
addr: string;
|
|
768
770
|
value: number;
|
|
769
771
|
}[]): Record<string, string>;
|
|
772
|
+
/** What a record resolve() refused paid to the parties the protocol pays, read with the resolver's ptAmt:
|
|
773
|
+
* `treasury` is the output to TREASURY_ADDR, `counterparty` the outputs to the target offer's seller and
|
|
774
|
+
* want.payto (pass `offer` for a fill, omit it otherwise). Each address counts once and the payer's own
|
|
775
|
+
* outputs never count, so a payer paying itself burns nothing. */
|
|
776
|
+
declare function burnedPayment(paidTo: Readonly<Record<string, unknown>> | undefined, payer: string, offer?: Pick<OfferState, "seller" | "want"> | null): {
|
|
777
|
+
treasury: bigint;
|
|
778
|
+
counterparty: bigint;
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* True only when `fill` proves `me`'s own fill CLOSED the offer behind `fclaim` before `grantHeight`, so a
|
|
783
|
+
* resolver at a grant height >= V29_HEIGHT no longer counts that hold. `fill` and `offerEv` must be
|
|
784
|
+
* merkle-proven and prevout-bound by the caller. The fill must be a SCORE_FILL by `me` on exactly this fclaim,
|
|
785
|
+
* mined strictly after the fclaim and strictly before the grant, and carry every output of a FULL fill of the
|
|
786
|
+
* proven offer (want.value to payto, the fee, the maker rebate), read as the resolver reads them (ptAmt).
|
|
787
|
+
* A partial-lane offer closed by a remainder fill stays counted: the remainder depends on the served `paid`.
|
|
788
|
+
*/
|
|
789
|
+
declare function myProvenFillClosedOffer(fill: ProvenEvent | null, fclaim: {
|
|
790
|
+
id: string;
|
|
791
|
+
height: number;
|
|
792
|
+
offer: string;
|
|
793
|
+
}, offerEv: ProvenEvent | null, me: string, grantHeight: number): boolean;
|
|
770
794
|
|
|
771
|
-
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy,
|
|
795
|
+
export { ACTIVATION_HEIGHT, ADDR_RE, AMOUNT_RE, type AppliedEvent, type AttestEvent, BID_KEYS, type BalanceState, type BidRecord, type BidState, type BidStatus, type BindTermsOpts, type BuiltRecord, CLAIM_ATTACKER_Q, CLAIM_COOLDOWN_BLOCKS, CLAIM_FILL_GRACE_BLOCKS, CLAIM_MIN_DEPTH, CLAIM_WINDOW_BLOCKS, CLAIM_WINDOW_BLOCKS_V20, COMMIT_MAX_BLOCKS, COMMIT_REVEAL_MIN_DEPTH, CONF_TOKEN_FILL, type CairnXRecord, type CairnXState, type ChainEvent, DEPLOY_FEE, DEPLOY_KEYS, DOMAIN, type DeployRecord, FCLAIM_KEYS, FCLAIM_MAX_EPOCH_AHEAD, FCLAIM_WINDOW_MIN, FEE_BPS, FEE_BPS_V16, FEE_GATE_MARGIN_BLOCKS, FILL_TIP_MARGIN, FINALIZE_TIP_MARGIN, type FclaimRecord, type FillEndorsement, type FillEntry, type FillOutputPlan, type FillPreview, type FillSafety, type FillSpvIo, type FillVerdict, GAP_NEEDED, type Give, HASH_RE, type HoldReplay, MAX_ACTIVE_CLAIMS, MAX_AMOUNT, MAX_OFFER_EPOCHS, MAX_PENDING_REG, MAX_RECORD_BYTES, MAX_SCAN, MINT_KEYS, type MintRecord, type MintedProvenOfferTerms, NAME_FEE_LEN3_V24, NAME_FEE_LEN4_V24, NAME_FEE_LONG_V24, NAME_FEE_MID_V24, NAME_FEE_SHORT_V18, NAME_FEE_V18, NAME_GRACE_EPOCHS, NAME_KEYS, NAME_PREMIUM_DECAY_EPOCHS, NAME_PREMIUM_START, NAME_RE, NAME_TERM_EPOCHS, NFINALIZE_KEYS, NPROFILE_KEYS, type NameCommitRecord, type NameFinalizeRecord, type NameProfileRecord, type NameRecord, type NameRenewRecord, type NameSetRecord, type NameState, type NameXferRecord, OFFER_KEYS, type OfferCancelAllRecord, type OfferRecord, type OfferState, type OfferStatus, PKEY, PROFILE_MAX_KEYS, PROFILE_MAX_VALUE_BYTES, type ProposeEvent, type ProvenAttest, type ProvenEvent, type ProvenOfferTerms, type ProvenPropose, REBATE_BPS, REBATE_FLAT, REG_COMMIT_MAX_BLOCKS, REG_FINALIZE_GRACE_BLOCKS, RESERVED_NAMES, SALT_RE, SCAN_MARGIN, SCORE_CANCEL, SCORE_CLAIM, SCORE_FILL, TICKER_RE, TRANSFER_KEYS, TREASURY_ADDR, type TokenMetaRecord, type TokenState, type TransferRecord, V11_HEIGHT, V12_HEIGHT, V13_HEIGHT, V14_HEIGHT, V15_HEIGHT, V16_HEIGHT, V17_HEIGHT, V18_HEIGHT, V19_HEIGHT, V20_HEIGHT, V21_HEIGHT, V22_HEIGHT, V23_HEIGHT, V24_HEIGHT, V25_HEIGHT, V26_HEIGHT, V27_HEIGHT, V28_HEIGHT, V29_HEIGHT, type Want, ZERO_ADDR, bid, bindOfferTerms, bindProvenOffer, buildFeeHeight, buildRecord, burnedPayment, canonicalState, claimGraceOf, claimWindowAt, claimWindowOf, deploy, expiredClaimFee, fclaim, fclaimEpochFor, fclaimHoldEnd, feeBpsAt, fillEndorsement, fillIsSafe, fillOutputPlan, fillTargetId, finalizeWinnerCheck, hasLiveClaim, isName, isNameGive, isOpenClaimLane, isTokenWant, makerRebate, mint, myProvenFillClosedOffer, nameClaim, nameCommit, nameCommitRecord, nameFinalize, nameProfile, nameRegFee, nameRenew, nameSet, nameXfer, offer, offerCancelAll, offerExpiryHeightOf, paidToFromOutputs, parseAmount, parseRecord, pickPrimaryName, previewFill, primaryRankBefore, provenOfferTerms, ptAmt, replayLiveHold, requiredClaimDepth, requiredFillOutputs, resolve, tokenMeta, tradeFee, transfer, unsafeMintProvenOfferTerms, verifyFillSpv };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
-
import { EPOCH_LEN } from "@inversealtruism/csd-codec";
|
|
2
|
+
import { EPOCH_LEN, MAX_URI_BYTES, epochOf } from "@inversealtruism/csd-codec";
|
|
3
3
|
var DOMAIN = "cairnx:v1";
|
|
4
4
|
var ACTIVATION_HEIGHT = 29860;
|
|
5
5
|
var V11_HEIGHT = 29960;
|
|
@@ -20,7 +20,7 @@ function expiredClaimFee(name, epochsPastGraceEnd, height) {
|
|
|
20
20
|
const mult = 1n + (NAME_PREMIUM_START - 1n) * left / BigInt(NAME_PREMIUM_DECAY_EPOCHS);
|
|
21
21
|
return base * mult;
|
|
22
22
|
}
|
|
23
|
-
var MAX_RECORD_BYTES =
|
|
23
|
+
var MAX_RECORD_BYTES = MAX_URI_BYTES;
|
|
24
24
|
var MAX_AMOUNT = (1n << 96n) - 1n;
|
|
25
25
|
var SCORE_FILL = 100;
|
|
26
26
|
var SCORE_CANCEL = 0;
|
|
@@ -92,7 +92,6 @@ var V26_HEIGHT = 46480;
|
|
|
92
92
|
var V27_HEIGHT = 46520;
|
|
93
93
|
var V28_HEIGHT = 6e4;
|
|
94
94
|
var V29_HEIGHT = 88e3;
|
|
95
|
-
var epochOf = (height) => Math.floor(height / EPOCH_LEN);
|
|
96
95
|
var claimWindowAt = (height) => height >= V20_HEIGHT ? CLAIM_WINDOW_BLOCKS_V20 : CLAIM_WINDOW_BLOCKS;
|
|
97
96
|
var FCLAIM_WINDOW_MIN = CLAIM_WINDOW_BLOCKS_V20 + CLAIM_FILL_GRACE_BLOCKS + 1;
|
|
98
97
|
var claimWindowOf = (claimUntilHeight, claimTxid) => {
|
|
@@ -1738,6 +1737,51 @@ function paidToFromOutputs(outputs) {
|
|
|
1738
1737
|
}
|
|
1739
1738
|
return m;
|
|
1740
1739
|
}
|
|
1740
|
+
function burnedPayment(paidTo, payer, offer2) {
|
|
1741
|
+
const read = (addr) => addr === payer ? 0n : ptAmt(paidTo?.[addr]);
|
|
1742
|
+
let counterparty = 0n;
|
|
1743
|
+
if (offer2) {
|
|
1744
|
+
for (const addr of /* @__PURE__ */ new Set([offer2.seller, offer2.want.payto])) if (addr !== TREASURY_ADDR) counterparty += read(addr);
|
|
1745
|
+
}
|
|
1746
|
+
return { treasury: read(TREASURY_ADDR), counterparty };
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
// src/fillclosed.ts
|
|
1750
|
+
var lc = (v) => String(v).toLowerCase();
|
|
1751
|
+
function myProvenFillClosedOffer(fill, fclaim2, offerEv, me, grantHeight) {
|
|
1752
|
+
if (!(grantHeight >= V29_HEIGHT)) return false;
|
|
1753
|
+
if (!fill || fill.kind !== "attest" || fill.score !== SCORE_FILL) return false;
|
|
1754
|
+
if (lc(fill.attester) !== lc(me) || lc(fill.proposalId) !== lc(fclaim2.id)) return false;
|
|
1755
|
+
if (!(fill.height > fclaim2.height && fill.height < grantHeight)) return false;
|
|
1756
|
+
if (!offerEv || offerEv.kind !== "propose" || lc(offerEv.id) !== lc(fclaim2.offer)) return false;
|
|
1757
|
+
const bound = bindProvenOffer(offerEv);
|
|
1758
|
+
const value = bound?.terms.value;
|
|
1759
|
+
if (!bound || value === void 0) return false;
|
|
1760
|
+
const t = bound.terms;
|
|
1761
|
+
const state = {
|
|
1762
|
+
id: lc(offerEv.id),
|
|
1763
|
+
seller: bound.seller,
|
|
1764
|
+
give: t.giveName !== void 0 ? { name: t.giveName } : { ticker: String(t.giveTicker ?? ""), amount: String(t.giveAmount ?? "") },
|
|
1765
|
+
want: { value, payto: bound.payto },
|
|
1766
|
+
status: "open",
|
|
1767
|
+
expiresEpoch: offerEv.expiresEpoch,
|
|
1768
|
+
height: t.height,
|
|
1769
|
+
feeBps: t.feeBps,
|
|
1770
|
+
taker: t.taker,
|
|
1771
|
+
bid: t.bid,
|
|
1772
|
+
min: t.min,
|
|
1773
|
+
paid: "0",
|
|
1774
|
+
delivered: "0"
|
|
1775
|
+
};
|
|
1776
|
+
let need;
|
|
1777
|
+
try {
|
|
1778
|
+
need = requiredFillOutputs(state, BigInt(value));
|
|
1779
|
+
} catch {
|
|
1780
|
+
return false;
|
|
1781
|
+
}
|
|
1782
|
+
if (!need) return false;
|
|
1783
|
+
return need.every((leg) => ptAmt(fill.paidTo?.[lc(leg.to)]) >= leg.value);
|
|
1784
|
+
}
|
|
1741
1785
|
|
|
1742
1786
|
// src/index.ts
|
|
1743
1787
|
import {
|
|
@@ -1846,6 +1890,7 @@ export {
|
|
|
1846
1890
|
blockReward2 as blockReward,
|
|
1847
1891
|
buildFeeHeight,
|
|
1848
1892
|
buildRecord,
|
|
1893
|
+
burnedPayment,
|
|
1849
1894
|
canonicalJson2 as canonicalJson,
|
|
1850
1895
|
canonicalState,
|
|
1851
1896
|
claimGraceOf,
|
|
@@ -1870,6 +1915,7 @@ export {
|
|
|
1870
1915
|
isTokenWant,
|
|
1871
1916
|
makerRebate,
|
|
1872
1917
|
mint,
|
|
1918
|
+
myProvenFillClosedOffer,
|
|
1873
1919
|
nameClaim,
|
|
1874
1920
|
nameCommit,
|
|
1875
1921
|
nameCommitRecord,
|
|
@@ -1890,6 +1936,7 @@ export {
|
|
|
1890
1936
|
previewFill,
|
|
1891
1937
|
primaryRankBefore,
|
|
1892
1938
|
provenOfferTerms,
|
|
1939
|
+
ptAmt,
|
|
1893
1940
|
replayLiveHold,
|
|
1894
1941
|
requiredClaimDepth,
|
|
1895
1942
|
requiredFillOutputs,
|