@zkp2p/cash 0.1.2 → 0.1.3
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/AGENTS.md +3 -2
- package/README.md +3 -1
- package/dist/index.cjs +18 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/skills/peer-cash-integration/SKILL.md +3 -2
package/AGENTS.md
CHANGED
|
@@ -77,8 +77,9 @@ if (order.nextActions.includes('withdraw') && shouldUnwind) {
|
|
|
77
77
|
binding rate resolves at the oracle when a buyer fills. Do not display or
|
|
78
78
|
log it as a locked price.
|
|
79
79
|
- **Do not invent an ETA.** Use `estimate().eta`: `{ seconds, label }` backed
|
|
80
|
-
by rolling
|
|
81
|
-
|
|
80
|
+
by rolling 30-day indexer data from zero-spread (`spreadBps: 0`) market-rate
|
|
81
|
+
deposits in the same payout corridor, measured from deposit creation to first
|
|
82
|
+
fill. Use `order.explain()` for live order state.
|
|
82
83
|
- **Do not hardcode Relay source assets.** Use Relay SDK-backed EVM
|
|
83
84
|
`capabilities({ includeRelaySources: true })` and `cashout({ source, ... })`.
|
|
84
85
|
Destination is always Base USDC. Non-Base source chains require `sourceSigner`.
|
package/README.md
CHANGED
|
@@ -105,7 +105,9 @@ awaiting-buyer ──────────► matched ───────
|
|
|
105
105
|
fills. `estimate()` says "approximately"; nothing in this API pretends to
|
|
106
106
|
lock a price.
|
|
107
107
|
- **ETA is historical.** `estimate().eta` is just `{ seconds, label }`, backed
|
|
108
|
-
by rolling
|
|
108
|
+
by rolling 30-day indexer data from zero-spread (`spreadBps: 0`) market-rate
|
|
109
|
+
deposits in the same payout corridor, measured from deposit creation to first
|
|
110
|
+
fulfilled fill.
|
|
109
111
|
- **Everything is resumable.** An order is reconstructed from the chain by
|
|
110
112
|
`depositId` alone. Close the tab, switch devices, crash the process - then
|
|
111
113
|
call `order(depositId)`.
|
package/dist/index.cjs
CHANGED
|
@@ -615,9 +615,10 @@ function mapChainError(verb, err) {
|
|
|
615
615
|
}
|
|
616
616
|
return errors.chainCallFailed(verb, err);
|
|
617
617
|
}
|
|
618
|
-
var ETA_WINDOW_DAYS =
|
|
618
|
+
var ETA_WINDOW_DAYS = 30;
|
|
619
619
|
var ETA_WINDOW_SECONDS = ETA_WINDOW_DAYS * 24 * 60 * 60;
|
|
620
|
-
var
|
|
620
|
+
var ETA_PAGE_LIMIT = 250;
|
|
621
|
+
var ETA_MAX_DEPOSIT_SCAN = 2e3;
|
|
621
622
|
var FULFILLED = /* @__PURE__ */ new Set(["FULFILLED", "MANUALLY_RELEASED"]);
|
|
622
623
|
function toUnixSeconds2(value) {
|
|
623
624
|
if (value === null || value === void 0 || value === "") return void 0;
|
|
@@ -652,19 +653,27 @@ function matchesPayout(deposit, environment, platform, currency) {
|
|
|
652
653
|
deposit.currencies ?? [],
|
|
653
654
|
sdk.getPaymentMethodsCatalog(BASE_CHAIN_ID, environment)
|
|
654
655
|
);
|
|
655
|
-
if (payouts.length === 0) return true;
|
|
656
656
|
return payouts.some(
|
|
657
|
-
(payout) => (platform === void 0 || payout.platform === platform) && (currency === void 0 || payout.currency === currency)
|
|
657
|
+
(payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0 && (platform === void 0 || payout.platform === platform) && (currency === void 0 || payout.currency === currency)
|
|
658
658
|
);
|
|
659
659
|
}
|
|
660
660
|
async function readFillEta(client, input) {
|
|
661
661
|
const now = Math.floor(Date.now() / 1e3);
|
|
662
662
|
const windowStart = now - ETA_WINDOW_SECONDS;
|
|
663
|
-
const deposits =
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
663
|
+
const deposits = [];
|
|
664
|
+
for (let offset = 0; offset < ETA_MAX_DEPOSIT_SCAN; offset += ETA_PAGE_LIMIT) {
|
|
665
|
+
const page = await client.indexer.getDepositsWithRelations(
|
|
666
|
+
{ chainId: BASE_CHAIN_ID },
|
|
667
|
+
{ limit: ETA_PAGE_LIMIT, offset, orderBy: "timestamp", orderDirection: "desc" },
|
|
668
|
+
{ includeIntents: true, intentStatuses: ["FULFILLED", "MANUALLY_RELEASED"] }
|
|
669
|
+
);
|
|
670
|
+
deposits.push(...page);
|
|
671
|
+
if (page.length < ETA_PAGE_LIMIT) break;
|
|
672
|
+
const oldestCreatedAt = Math.min(
|
|
673
|
+
...page.map((deposit) => toUnixSeconds2(deposit.createdAt ?? deposit.timestamp) ?? Infinity)
|
|
674
|
+
);
|
|
675
|
+
if (oldestCreatedAt < windowStart) break;
|
|
676
|
+
}
|
|
668
677
|
const firstFillLatencies = [];
|
|
669
678
|
for (const deposit of deposits) {
|
|
670
679
|
const createdAt = toUnixSeconds2(deposit.createdAt ?? deposit.timestamp);
|