@inversealtruism/cairnx-core 0.1.41 → 0.1.43
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/README.md +3 -1
- package/dist/index.cjs +59 -21
- package/dist/index.js +59 -21
- package/dist/mm/index.cjs +364 -0
- package/dist/mm/index.d.cts +192 -0
- package/dist/mm/index.d.ts +192 -0
- package/dist/mm/index.js +323 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -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
|
@@ -552,6 +552,24 @@ function resolve(events, tipHeight) {
|
|
|
552
552
|
const offers = /* @__PURE__ */ new Map();
|
|
553
553
|
const offerLock = /* @__PURE__ */ new Map();
|
|
554
554
|
const bids = /* @__PURE__ */ new Map();
|
|
555
|
+
const openOffers = /* @__PURE__ */ new Set();
|
|
556
|
+
const openBids = /* @__PURE__ */ new Set();
|
|
557
|
+
const pendingNames = /* @__PURE__ */ new Set();
|
|
558
|
+
const setOfferStatus = (o, status) => {
|
|
559
|
+
o.status = status;
|
|
560
|
+
if (status === "open") openOffers.add(o.id);
|
|
561
|
+
else openOffers.delete(o.id);
|
|
562
|
+
};
|
|
563
|
+
const setBidStatus = (b, status) => {
|
|
564
|
+
b.status = status;
|
|
565
|
+
if (status === "open") openBids.add(b.id);
|
|
566
|
+
else openBids.delete(b.id);
|
|
567
|
+
};
|
|
568
|
+
const putName = (nm, n) => {
|
|
569
|
+
names.set(nm, n);
|
|
570
|
+
if (n.pending) pendingNames.add(nm);
|
|
571
|
+
else pendingNames.delete(nm);
|
|
572
|
+
};
|
|
555
573
|
const fclaims = /* @__PURE__ */ new Map();
|
|
556
574
|
const log = [];
|
|
557
575
|
let feesPaid = 0n;
|
|
@@ -589,18 +607,35 @@ function resolve(events, tipHeight) {
|
|
|
589
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;
|
|
590
608
|
const sweepExpired = (height) => {
|
|
591
609
|
const ep = epochOf(height);
|
|
592
|
-
for (const
|
|
593
|
-
|
|
610
|
+
for (const id of [...openOffers]) {
|
|
611
|
+
const o = offers.get(id);
|
|
612
|
+
if (!o || o.status !== "open") {
|
|
613
|
+
openOffers.delete(id);
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
if (ep > effExpiry(o, height)) {
|
|
594
617
|
releaseGive(o);
|
|
595
|
-
o
|
|
618
|
+
setOfferStatus(o, "expired");
|
|
596
619
|
}
|
|
597
620
|
}
|
|
598
|
-
for (const
|
|
599
|
-
|
|
621
|
+
for (const id of [...openBids]) {
|
|
622
|
+
const b = bids.get(id);
|
|
623
|
+
if (!b || b.status !== "open") {
|
|
624
|
+
openBids.delete(id);
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
if (ep > effExpiry(b, height)) setBidStatus(b, "expired");
|
|
600
628
|
}
|
|
601
|
-
for (const nm of [...
|
|
629
|
+
for (const nm of [...pendingNames]) {
|
|
602
630
|
const n = names.get(nm);
|
|
603
|
-
if (n
|
|
631
|
+
if (!n || !n.pending) {
|
|
632
|
+
pendingNames.delete(nm);
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
if (n.finalizeBy !== void 0 && height > n.finalizeBy) {
|
|
636
|
+
names.delete(nm);
|
|
637
|
+
pendingNames.delete(nm);
|
|
638
|
+
}
|
|
604
639
|
}
|
|
605
640
|
for (const nm of [...recaptures.keys()]) {
|
|
606
641
|
const r = recaptures.get(nm);
|
|
@@ -614,13 +649,13 @@ function resolve(events, tipHeight) {
|
|
|
614
649
|
const markBidDone = (o, buyer) => {
|
|
615
650
|
if (!o.bid) return;
|
|
616
651
|
const b = bids.get(o.bid);
|
|
617
|
-
if (b && b.status === "open" && b.bidder === buyer) b
|
|
652
|
+
if (b && b.status === "open" && b.bidder === buyer) setBidStatus(b, "done");
|
|
618
653
|
};
|
|
619
654
|
const voidOpenNameOffers = (name, height) => {
|
|
620
655
|
for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === name) {
|
|
621
656
|
if (height >= V28_HEIGHT && o.claimTxid !== void 0 && claimHeld(o, height)) continue;
|
|
622
657
|
releaseGive(o);
|
|
623
|
-
o
|
|
658
|
+
setOfferStatus(o, "cancelled");
|
|
624
659
|
}
|
|
625
660
|
};
|
|
626
661
|
const earlierAnchor = (effHeight, pos, id, inc) => effHeight < inc.effHeight || effHeight === inc.effHeight && (pos < inc.pos || pos === inc.pos && id < inc.id);
|
|
@@ -795,7 +830,7 @@ function resolve(events, tipHeight) {
|
|
|
795
830
|
continue;
|
|
796
831
|
}
|
|
797
832
|
voidOpenNameOffers(rec.name, ev.height);
|
|
798
|
-
|
|
833
|
+
putName(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, viaFill: true, paidThroughEpoch: epClaim + NAME_TERM_EPOCHS });
|
|
799
834
|
feesPaid += fee;
|
|
800
835
|
note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
|
|
801
836
|
continue;
|
|
@@ -819,7 +854,7 @@ function resolve(events, tipHeight) {
|
|
|
819
854
|
if (curActive) {
|
|
820
855
|
voidOpenNameOffers(rec.name, ev.height);
|
|
821
856
|
}
|
|
822
|
-
|
|
857
|
+
putName(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, pending: true, finalizeBy: effHeight + REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS });
|
|
823
858
|
note(ev, ev.id, "name", true, curActive ? "reserved (displaced prior reservation)" : "reserved (pending finalize)");
|
|
824
859
|
continue;
|
|
825
860
|
}
|
|
@@ -844,7 +879,7 @@ function resolve(events, tipHeight) {
|
|
|
844
879
|
if (curActive) {
|
|
845
880
|
voidOpenNameOffers(rec.name, ev.height);
|
|
846
881
|
}
|
|
847
|
-
|
|
882
|
+
putName(rec.name, cand);
|
|
848
883
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
849
884
|
note(ev, ev.id, "name", true, curActive ? "displaced prior holder" : void 0);
|
|
850
885
|
} else if (rec.t === "nfinalize") {
|
|
@@ -873,6 +908,7 @@ function resolve(events, tipHeight) {
|
|
|
873
908
|
}
|
|
874
909
|
delete n.pending;
|
|
875
910
|
delete n.finalizeBy;
|
|
911
|
+
pendingNames.delete(rec.name);
|
|
876
912
|
n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
|
|
877
913
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
878
914
|
note(ev, ev.id, "nfinalize", true);
|
|
@@ -906,7 +942,7 @@ function resolve(events, tipHeight) {
|
|
|
906
942
|
continue;
|
|
907
943
|
}
|
|
908
944
|
voidOpenNameOffers(rec.name, ev.height);
|
|
909
|
-
|
|
945
|
+
putName(rec.name, { owner: who, effHeight: r.effHeight, pos: r.pos, id: r.id, height: r.height, locked: false, paidThroughEpoch: ep + NAME_TERM_EPOCHS });
|
|
910
946
|
recaptures.delete(rec.name);
|
|
911
947
|
feesPaid += fee;
|
|
912
948
|
note(ev, ev.id, "nfinalize", true, "recapture finalized (premium)");
|
|
@@ -1057,6 +1093,7 @@ function resolve(events, tipHeight) {
|
|
|
1057
1093
|
feeBps: v11 ? v16 ? FEE_BPS_V16 : FEE_BPS : 0
|
|
1058
1094
|
};
|
|
1059
1095
|
offers.set(ev.id, o);
|
|
1096
|
+
openOffers.add(ev.id);
|
|
1060
1097
|
const linked = rec.bid !== void 0 ? bids.get(rec.bid) : void 0;
|
|
1061
1098
|
if (linked) linked.offers.push(ev.id);
|
|
1062
1099
|
note(ev, ev.id, "offer", true);
|
|
@@ -1087,6 +1124,7 @@ function resolve(events, tipHeight) {
|
|
|
1087
1124
|
height: ev.height,
|
|
1088
1125
|
offers: []
|
|
1089
1126
|
});
|
|
1127
|
+
openBids.add(ev.id);
|
|
1090
1128
|
note(ev, ev.id, "bid", true);
|
|
1091
1129
|
} else if (rec.t === "ocancel") {
|
|
1092
1130
|
if (!v12) {
|
|
@@ -1108,7 +1146,7 @@ function resolve(events, tipHeight) {
|
|
|
1108
1146
|
if (ev.height >= V28_HEIGHT && o.claimTxid !== void 0 && claimHeld(o, ev.height)) continue;
|
|
1109
1147
|
if (o.status === "open") {
|
|
1110
1148
|
releaseGive(o);
|
|
1111
|
-
o
|
|
1149
|
+
setOfferStatus(o, "cancelled");
|
|
1112
1150
|
n++;
|
|
1113
1151
|
}
|
|
1114
1152
|
}
|
|
@@ -1117,7 +1155,7 @@ function resolve(events, tipHeight) {
|
|
|
1117
1155
|
} else {
|
|
1118
1156
|
for (const o of targets) {
|
|
1119
1157
|
releaseGive(o);
|
|
1120
|
-
o
|
|
1158
|
+
setOfferStatus(o, "cancelled");
|
|
1121
1159
|
}
|
|
1122
1160
|
note(ev, ev.id, "ocancel", true, `${targets.length} cancelled`);
|
|
1123
1161
|
}
|
|
@@ -1251,7 +1289,7 @@ function resolve(events, tipHeight) {
|
|
|
1251
1289
|
note(ev, ev.txid, "bidcancel", false, `bid ${b.status}`);
|
|
1252
1290
|
continue;
|
|
1253
1291
|
}
|
|
1254
|
-
b
|
|
1292
|
+
setBidStatus(b, "cancelled");
|
|
1255
1293
|
note(ev, ev.txid, "bidcancel", true);
|
|
1256
1294
|
}
|
|
1257
1295
|
continue;
|
|
@@ -1277,13 +1315,13 @@ function resolve(events, tipHeight) {
|
|
|
1277
1315
|
}
|
|
1278
1316
|
if (o.status === "open") {
|
|
1279
1317
|
releaseGive(o);
|
|
1280
|
-
o
|
|
1318
|
+
setOfferStatus(o, "cancelled");
|
|
1281
1319
|
note(ev, ev.txid, "cancel", true);
|
|
1282
1320
|
} else note(ev, ev.txid, "cancel", false, "superseded by same-block fill (v1.4)");
|
|
1283
1321
|
});
|
|
1284
1322
|
} else {
|
|
1285
1323
|
releaseGive(o);
|
|
1286
|
-
o
|
|
1324
|
+
setOfferStatus(o, "cancelled");
|
|
1287
1325
|
note(ev, ev.txid, "cancel", true);
|
|
1288
1326
|
}
|
|
1289
1327
|
} else if (ev.score === SCORE_FILL && isTokenWant(o.want)) {
|
|
@@ -1325,7 +1363,7 @@ function resolve(events, tipHeight) {
|
|
|
1325
1363
|
if (fee > 0n) bal(o.want.ticker, TREASURY_ADDR).available += fee;
|
|
1326
1364
|
if (isNameGive(o.give)) deliverNameToBuyer(giveName, who, ev);
|
|
1327
1365
|
else releaseGiveLock(o, who, giveLock);
|
|
1328
|
-
o
|
|
1366
|
+
setOfferStatus(o, "filled");
|
|
1329
1367
|
o.fill = { buyer: who, txid: ev.txid, height: ev.height, paid: amt.toString(), fee: fee.toString() };
|
|
1330
1368
|
markBidDone(o, who);
|
|
1331
1369
|
note(ev, ev.txid, "fill", true);
|
|
@@ -1383,7 +1421,7 @@ function resolve(events, tipHeight) {
|
|
|
1383
1421
|
(o.fills ??= []).push(entry);
|
|
1384
1422
|
feesPaid += fee;
|
|
1385
1423
|
if (newPaid === want) {
|
|
1386
|
-
o
|
|
1424
|
+
setOfferStatus(o, "filled");
|
|
1387
1425
|
o.fill = entry;
|
|
1388
1426
|
offerLock.delete(o.id);
|
|
1389
1427
|
markBidDone(o, who);
|
|
@@ -1439,7 +1477,7 @@ function resolve(events, tipHeight) {
|
|
|
1439
1477
|
releaseGiveLock(o, who, amt);
|
|
1440
1478
|
}
|
|
1441
1479
|
feesPaid += fee;
|
|
1442
|
-
o
|
|
1480
|
+
setOfferStatus(o, "filled");
|
|
1443
1481
|
o.fill = { buyer: who, txid: ev.txid, height: ev.height, paid: paid.toString(), fee: fee.toString() };
|
|
1444
1482
|
markBidDone(o, who);
|
|
1445
1483
|
note(ev, ev.txid, "fill", true);
|
package/dist/index.js
CHANGED
|
@@ -379,6 +379,24 @@ function resolve(events, tipHeight) {
|
|
|
379
379
|
const offers = /* @__PURE__ */ new Map();
|
|
380
380
|
const offerLock = /* @__PURE__ */ new Map();
|
|
381
381
|
const bids = /* @__PURE__ */ new Map();
|
|
382
|
+
const openOffers = /* @__PURE__ */ new Set();
|
|
383
|
+
const openBids = /* @__PURE__ */ new Set();
|
|
384
|
+
const pendingNames = /* @__PURE__ */ new Set();
|
|
385
|
+
const setOfferStatus = (o, status) => {
|
|
386
|
+
o.status = status;
|
|
387
|
+
if (status === "open") openOffers.add(o.id);
|
|
388
|
+
else openOffers.delete(o.id);
|
|
389
|
+
};
|
|
390
|
+
const setBidStatus = (b, status) => {
|
|
391
|
+
b.status = status;
|
|
392
|
+
if (status === "open") openBids.add(b.id);
|
|
393
|
+
else openBids.delete(b.id);
|
|
394
|
+
};
|
|
395
|
+
const putName = (nm, n) => {
|
|
396
|
+
names.set(nm, n);
|
|
397
|
+
if (n.pending) pendingNames.add(nm);
|
|
398
|
+
else pendingNames.delete(nm);
|
|
399
|
+
};
|
|
382
400
|
const fclaims = /* @__PURE__ */ new Map();
|
|
383
401
|
const log = [];
|
|
384
402
|
let feesPaid = 0n;
|
|
@@ -416,18 +434,35 @@ function resolve(events, tipHeight) {
|
|
|
416
434
|
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;
|
|
417
435
|
const sweepExpired = (height) => {
|
|
418
436
|
const ep = epochOf(height);
|
|
419
|
-
for (const
|
|
420
|
-
|
|
437
|
+
for (const id of [...openOffers]) {
|
|
438
|
+
const o = offers.get(id);
|
|
439
|
+
if (!o || o.status !== "open") {
|
|
440
|
+
openOffers.delete(id);
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (ep > effExpiry(o, height)) {
|
|
421
444
|
releaseGive(o);
|
|
422
|
-
o
|
|
445
|
+
setOfferStatus(o, "expired");
|
|
423
446
|
}
|
|
424
447
|
}
|
|
425
|
-
for (const
|
|
426
|
-
|
|
448
|
+
for (const id of [...openBids]) {
|
|
449
|
+
const b = bids.get(id);
|
|
450
|
+
if (!b || b.status !== "open") {
|
|
451
|
+
openBids.delete(id);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (ep > effExpiry(b, height)) setBidStatus(b, "expired");
|
|
427
455
|
}
|
|
428
|
-
for (const nm of [...
|
|
456
|
+
for (const nm of [...pendingNames]) {
|
|
429
457
|
const n = names.get(nm);
|
|
430
|
-
if (n
|
|
458
|
+
if (!n || !n.pending) {
|
|
459
|
+
pendingNames.delete(nm);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
if (n.finalizeBy !== void 0 && height > n.finalizeBy) {
|
|
463
|
+
names.delete(nm);
|
|
464
|
+
pendingNames.delete(nm);
|
|
465
|
+
}
|
|
431
466
|
}
|
|
432
467
|
for (const nm of [...recaptures.keys()]) {
|
|
433
468
|
const r = recaptures.get(nm);
|
|
@@ -441,13 +476,13 @@ function resolve(events, tipHeight) {
|
|
|
441
476
|
const markBidDone = (o, buyer) => {
|
|
442
477
|
if (!o.bid) return;
|
|
443
478
|
const b = bids.get(o.bid);
|
|
444
|
-
if (b && b.status === "open" && b.bidder === buyer) b
|
|
479
|
+
if (b && b.status === "open" && b.bidder === buyer) setBidStatus(b, "done");
|
|
445
480
|
};
|
|
446
481
|
const voidOpenNameOffers = (name, height) => {
|
|
447
482
|
for (const o of offers.values()) if (o.status === "open" && isNameGive(o.give) && o.give.name === name) {
|
|
448
483
|
if (height >= V28_HEIGHT && o.claimTxid !== void 0 && claimHeld(o, height)) continue;
|
|
449
484
|
releaseGive(o);
|
|
450
|
-
o
|
|
485
|
+
setOfferStatus(o, "cancelled");
|
|
451
486
|
}
|
|
452
487
|
};
|
|
453
488
|
const earlierAnchor = (effHeight, pos, id, inc) => effHeight < inc.effHeight || effHeight === inc.effHeight && (pos < inc.pos || pos === inc.pos && id < inc.id);
|
|
@@ -622,7 +657,7 @@ function resolve(events, tipHeight) {
|
|
|
622
657
|
continue;
|
|
623
658
|
}
|
|
624
659
|
voidOpenNameOffers(rec.name, ev.height);
|
|
625
|
-
|
|
660
|
+
putName(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, viaFill: true, paidThroughEpoch: epClaim + NAME_TERM_EPOCHS });
|
|
626
661
|
feesPaid += fee;
|
|
627
662
|
note(ev, ev.id, "name", true, "lapsed lease re-claimed (premium)");
|
|
628
663
|
continue;
|
|
@@ -646,7 +681,7 @@ function resolve(events, tipHeight) {
|
|
|
646
681
|
if (curActive) {
|
|
647
682
|
voidOpenNameOffers(rec.name, ev.height);
|
|
648
683
|
}
|
|
649
|
-
|
|
684
|
+
putName(rec.name, { owner: who, effHeight, pos: ev.pos, id: ev.id, height: ev.height, locked: false, pending: true, finalizeBy: effHeight + REG_COMMIT_MAX_BLOCKS + REG_FINALIZE_GRACE_BLOCKS });
|
|
650
685
|
note(ev, ev.id, "name", true, curActive ? "reserved (displaced prior reservation)" : "reserved (pending finalize)");
|
|
651
686
|
continue;
|
|
652
687
|
}
|
|
@@ -671,7 +706,7 @@ function resolve(events, tipHeight) {
|
|
|
671
706
|
if (curActive) {
|
|
672
707
|
voidOpenNameOffers(rec.name, ev.height);
|
|
673
708
|
}
|
|
674
|
-
|
|
709
|
+
putName(rec.name, cand);
|
|
675
710
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
676
711
|
note(ev, ev.id, "name", true, curActive ? "displaced prior holder" : void 0);
|
|
677
712
|
} else if (rec.t === "nfinalize") {
|
|
@@ -700,6 +735,7 @@ function resolve(events, tipHeight) {
|
|
|
700
735
|
}
|
|
701
736
|
delete n.pending;
|
|
702
737
|
delete n.finalizeBy;
|
|
738
|
+
pendingNames.delete(rec.name);
|
|
703
739
|
n.paidThroughEpoch = epochOf(ev.height) + NAME_TERM_EPOCHS;
|
|
704
740
|
feesPaid += nameRegFee(rec.name, ev.height);
|
|
705
741
|
note(ev, ev.id, "nfinalize", true);
|
|
@@ -733,7 +769,7 @@ function resolve(events, tipHeight) {
|
|
|
733
769
|
continue;
|
|
734
770
|
}
|
|
735
771
|
voidOpenNameOffers(rec.name, ev.height);
|
|
736
|
-
|
|
772
|
+
putName(rec.name, { owner: who, effHeight: r.effHeight, pos: r.pos, id: r.id, height: r.height, locked: false, paidThroughEpoch: ep + NAME_TERM_EPOCHS });
|
|
737
773
|
recaptures.delete(rec.name);
|
|
738
774
|
feesPaid += fee;
|
|
739
775
|
note(ev, ev.id, "nfinalize", true, "recapture finalized (premium)");
|
|
@@ -884,6 +920,7 @@ function resolve(events, tipHeight) {
|
|
|
884
920
|
feeBps: v11 ? v16 ? FEE_BPS_V16 : FEE_BPS : 0
|
|
885
921
|
};
|
|
886
922
|
offers.set(ev.id, o);
|
|
923
|
+
openOffers.add(ev.id);
|
|
887
924
|
const linked = rec.bid !== void 0 ? bids.get(rec.bid) : void 0;
|
|
888
925
|
if (linked) linked.offers.push(ev.id);
|
|
889
926
|
note(ev, ev.id, "offer", true);
|
|
@@ -914,6 +951,7 @@ function resolve(events, tipHeight) {
|
|
|
914
951
|
height: ev.height,
|
|
915
952
|
offers: []
|
|
916
953
|
});
|
|
954
|
+
openBids.add(ev.id);
|
|
917
955
|
note(ev, ev.id, "bid", true);
|
|
918
956
|
} else if (rec.t === "ocancel") {
|
|
919
957
|
if (!v12) {
|
|
@@ -935,7 +973,7 @@ function resolve(events, tipHeight) {
|
|
|
935
973
|
if (ev.height >= V28_HEIGHT && o.claimTxid !== void 0 && claimHeld(o, ev.height)) continue;
|
|
936
974
|
if (o.status === "open") {
|
|
937
975
|
releaseGive(o);
|
|
938
|
-
o
|
|
976
|
+
setOfferStatus(o, "cancelled");
|
|
939
977
|
n++;
|
|
940
978
|
}
|
|
941
979
|
}
|
|
@@ -944,7 +982,7 @@ function resolve(events, tipHeight) {
|
|
|
944
982
|
} else {
|
|
945
983
|
for (const o of targets) {
|
|
946
984
|
releaseGive(o);
|
|
947
|
-
o
|
|
985
|
+
setOfferStatus(o, "cancelled");
|
|
948
986
|
}
|
|
949
987
|
note(ev, ev.id, "ocancel", true, `${targets.length} cancelled`);
|
|
950
988
|
}
|
|
@@ -1078,7 +1116,7 @@ function resolve(events, tipHeight) {
|
|
|
1078
1116
|
note(ev, ev.txid, "bidcancel", false, `bid ${b.status}`);
|
|
1079
1117
|
continue;
|
|
1080
1118
|
}
|
|
1081
|
-
b
|
|
1119
|
+
setBidStatus(b, "cancelled");
|
|
1082
1120
|
note(ev, ev.txid, "bidcancel", true);
|
|
1083
1121
|
}
|
|
1084
1122
|
continue;
|
|
@@ -1104,13 +1142,13 @@ function resolve(events, tipHeight) {
|
|
|
1104
1142
|
}
|
|
1105
1143
|
if (o.status === "open") {
|
|
1106
1144
|
releaseGive(o);
|
|
1107
|
-
o
|
|
1145
|
+
setOfferStatus(o, "cancelled");
|
|
1108
1146
|
note(ev, ev.txid, "cancel", true);
|
|
1109
1147
|
} else note(ev, ev.txid, "cancel", false, "superseded by same-block fill (v1.4)");
|
|
1110
1148
|
});
|
|
1111
1149
|
} else {
|
|
1112
1150
|
releaseGive(o);
|
|
1113
|
-
o
|
|
1151
|
+
setOfferStatus(o, "cancelled");
|
|
1114
1152
|
note(ev, ev.txid, "cancel", true);
|
|
1115
1153
|
}
|
|
1116
1154
|
} else if (ev.score === SCORE_FILL && isTokenWant(o.want)) {
|
|
@@ -1152,7 +1190,7 @@ function resolve(events, tipHeight) {
|
|
|
1152
1190
|
if (fee > 0n) bal(o.want.ticker, TREASURY_ADDR).available += fee;
|
|
1153
1191
|
if (isNameGive(o.give)) deliverNameToBuyer(giveName, who, ev);
|
|
1154
1192
|
else releaseGiveLock(o, who, giveLock);
|
|
1155
|
-
o
|
|
1193
|
+
setOfferStatus(o, "filled");
|
|
1156
1194
|
o.fill = { buyer: who, txid: ev.txid, height: ev.height, paid: amt.toString(), fee: fee.toString() };
|
|
1157
1195
|
markBidDone(o, who);
|
|
1158
1196
|
note(ev, ev.txid, "fill", true);
|
|
@@ -1210,7 +1248,7 @@ function resolve(events, tipHeight) {
|
|
|
1210
1248
|
(o.fills ??= []).push(entry);
|
|
1211
1249
|
feesPaid += fee;
|
|
1212
1250
|
if (newPaid === want) {
|
|
1213
|
-
o
|
|
1251
|
+
setOfferStatus(o, "filled");
|
|
1214
1252
|
o.fill = entry;
|
|
1215
1253
|
offerLock.delete(o.id);
|
|
1216
1254
|
markBidDone(o, who);
|
|
@@ -1266,7 +1304,7 @@ function resolve(events, tipHeight) {
|
|
|
1266
1304
|
releaseGiveLock(o, who, amt);
|
|
1267
1305
|
}
|
|
1268
1306
|
feesPaid += fee;
|
|
1269
|
-
o
|
|
1307
|
+
setOfferStatus(o, "filled");
|
|
1270
1308
|
o.fill = { buyer: who, txid: ev.txid, height: ev.height, paid: paid.toString(), fee: fee.toString() };
|
|
1271
1309
|
markBidDone(o, who);
|
|
1272
1310
|
note(ev, ev.txid, "fill", true);
|