@absol-labs/agent 0.12.0-rc.1 → 0.12.0-rc.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/README.md +1 -1
- package/dist/cli/commands/claim.d.ts +41 -0
- package/dist/cli/commands/claim.d.ts.map +1 -1
- package/dist/cli/commands/claim.js +127 -28
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/pay.d.ts +15 -0
- package/dist/cli/commands/pay.d.ts.map +1 -1
- package/dist/cli/commands/pay.js +131 -7
- package/dist/cli/commands/pay.js.map +1 -1
- package/dist/cli/commands/reclaim.d.ts.map +1 -1
- package/dist/cli/commands/reclaim.js +20 -4
- package/dist/cli/commands/reclaim.js.map +1 -1
- package/dist/cli/commands/refund.d.ts +21 -1
- package/dist/cli/commands/refund.d.ts.map +1 -1
- package/dist/cli/commands/refund.js +323 -32
- package/dist/cli/commands/refund.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +11 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +2 -0
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/context.d.ts +19 -0
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/deps.d.ts +20 -0
- package/dist/cli/deps.d.ts.map +1 -1
- package/dist/cli/deps.js +14 -0
- package/dist/cli/deps.js.map +1 -1
- package/dist/cli/progress.d.ts +13 -1
- package/dist/cli/progress.d.ts.map +1 -1
- package/dist/cli/progress.js +7 -1
- package/dist/cli/progress.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +26 -14
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/status.d.ts +109 -0
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +335 -47
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/wallet.d.ts +1 -1
- package/dist/cli/wallet.d.ts.map +1 -1
- package/dist/cli/wallet.js +28 -4
- package/dist/cli/wallet.js.map +1 -1
- package/dist/gateway/http-server.d.ts +17 -0
- package/dist/gateway/http-server.d.ts.map +1 -1
- package/dist/gateway/http-server.js +76 -9
- package/dist/gateway/http-server.js.map +1 -1
- package/dist/gateway/x402-opener-mode.d.ts +39 -2
- package/dist/gateway/x402-opener-mode.d.ts.map +1 -1
- package/dist/gateway/x402-opener-mode.js +273 -43
- package/dist/gateway/x402-opener-mode.js.map +1 -1
- package/dist/mcp/server.d.ts +12 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +28 -9
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/x402-tools.d.ts +8 -3
- package/dist/mcp/x402-tools.d.ts.map +1 -1
- package/dist/mcp/x402-tools.js +126 -6
- package/dist/mcp/x402-tools.js.map +1 -1
- package/dist/sdk/client.d.ts +13 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/client.js +15 -0
- package/dist/sdk/client.js.map +1 -1
- package/dist/x402-buyer/pay.d.ts +22 -0
- package/dist/x402-buyer/pay.d.ts.map +1 -1
- package/dist/x402-buyer/pay.js +33 -3
- package/dist/x402-buyer/pay.js.map +1 -1
- package/dist/x402-opener/block-floors.d.ts +35 -0
- package/dist/x402-opener/block-floors.d.ts.map +1 -0
- package/dist/x402-opener/block-floors.js +72 -0
- package/dist/x402-opener/block-floors.js.map +1 -0
- package/dist/x402-opener/facilitator-entry.js +4 -1
- package/dist/x402-opener/facilitator-entry.js.map +1 -1
- package/dist/x402-opener/facilitator-server.d.ts +29 -0
- package/dist/x402-opener/facilitator-server.d.ts.map +1 -1
- package/dist/x402-opener/facilitator-server.js +74 -1
- package/dist/x402-opener/facilitator-server.js.map +1 -1
- package/dist/x402-opener/index.d.ts +1 -0
- package/dist/x402-opener/index.d.ts.map +1 -1
- package/dist/x402-opener/index.js +1 -0
- package/dist/x402-opener/index.js.map +1 -1
- package/dist/x402-opener/refund-relay.d.ts +92 -5
- package/dist/x402-opener/refund-relay.d.ts.map +1 -1
- package/dist/x402-opener/refund-relay.js +482 -202
- package/dist/x402-opener/refund-relay.js.map +1 -1
- package/dist/x402-opener/scheme.d.ts +87 -0
- package/dist/x402-opener/scheme.d.ts.map +1 -1
- package/dist/x402-opener/scheme.js +340 -40
- package/dist/x402-opener/scheme.js.map +1 -1
- package/dist/x402-opener/terms.d.ts +61 -1
- package/dist/x402-opener/terms.d.ts.map +1 -1
- package/dist/x402-opener/terms.js +94 -2
- package/dist/x402-opener/terms.js.map +1 -1
- package/docs/cli.md +110 -11
- package/docs/mcp-reference.md +18 -2
- package/docs/quickstart.md +3 -3
- package/docs/x402.md +233 -36
- package/package.json +3 -3
- package/src/cli/commands/claim.ts +184 -33
- package/src/cli/commands/pay.ts +150 -8
- package/src/cli/commands/reclaim.ts +25 -5
- package/src/cli/commands/refund.ts +377 -38
- package/src/cli/commands/status.ts +11 -1
- package/src/cli/commands/watch.ts +4 -0
- package/src/cli/context.ts +16 -0
- package/src/cli/deps.ts +37 -0
- package/src/cli/progress.ts +21 -2
- package/src/cli/run.ts +26 -13
- package/src/cli/status.ts +468 -50
- package/src/cli/wallet.ts +44 -7
- package/src/gateway/http-server.ts +96 -8
- package/src/gateway/x402-opener-mode.ts +365 -43
- package/src/mcp/server.ts +43 -11
- package/src/mcp/x402-tools.ts +171 -7
- package/src/sdk/client.ts +25 -0
- package/src/x402-buyer/pay.ts +41 -3
- package/src/x402-opener/block-floors.ts +78 -0
- package/src/x402-opener/facilitator-entry.ts +4 -1
- package/src/x402-opener/facilitator-server.ts +108 -1
- package/src/x402-opener/index.ts +1 -0
- package/src/x402-opener/refund-relay.ts +609 -210
- package/src/x402-opener/scheme.ts +497 -41
- package/src/x402-opener/terms.ts +155 -2
package/dist/cli/status.d.ts
CHANGED
|
@@ -38,6 +38,87 @@ export interface SettlementCoverage {
|
|
|
38
38
|
* is to withhold a number we cannot stand behind, never to print one we cannot.
|
|
39
39
|
*/
|
|
40
40
|
export declare function settlementCoverage(stream: Pick<StreamV2, "closedAt" | "expiresAt">, latestCheckpointCheckedAt: number | null, nowSeconds: number): SettlementCoverage;
|
|
41
|
+
/**
|
|
42
|
+
* How much of the operator's verified, unclaimed accrual the buyer's no-proof
|
|
43
|
+
* escape hatch (`reclaimUnverified`) could take. All amounts are GROSS
|
|
44
|
+
* cumulative USDC base units (before the protocol fee), the unit the escrow
|
|
45
|
+
* settles in; the operator receives a claimed amount net of the fee.
|
|
46
|
+
*
|
|
47
|
+
* The rule depends on the escrow's generation:
|
|
48
|
+
*
|
|
49
|
+
* - **V2**: the hatch settles the operator at `claimedCumulative`, so every
|
|
50
|
+
* verified-but-unclaimed unit is exposed.
|
|
51
|
+
* - **V3**: the hatch settles the operator at
|
|
52
|
+
* `max(claimedCumulative, provenCumulative)` — the on-chain proven high-water
|
|
53
|
+
* the oracle's `recordProven` keeper (or any claim / reclaim with a proof)
|
|
54
|
+
* writes, and which the operator can redeem with `claimProven`. Only verified
|
|
55
|
+
* value NOBODY has proven on-chain is exposed.
|
|
56
|
+
*/
|
|
57
|
+
export interface OperatorHatchExposure {
|
|
58
|
+
/** Verified cumulative from the oracle proof, capped at the deposit (gross). */
|
|
59
|
+
readonly verifiedCumulative: bigint;
|
|
60
|
+
/** What the hatch would still settle to the operator (gross). */
|
|
61
|
+
readonly protectedCumulative: bigint;
|
|
62
|
+
/** `max(0, verifiedCumulative − protectedCumulative)` (gross). */
|
|
63
|
+
readonly atRiskCumulative: bigint;
|
|
64
|
+
/**
|
|
65
|
+
* V3 only: whether `provenCumulative` was read. `false` means it was assumed
|
|
66
|
+
* to be zero (worst case for the operator), never assumed to be protective.
|
|
67
|
+
* Always `true` on V2, which has no such view.
|
|
68
|
+
*/
|
|
69
|
+
readonly provenCumulativeKnown: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The exposure for a stream that has NOT been reclaimed and has a verified
|
|
73
|
+
* proof. Pure, so the per-generation rule is testable without an RPC. Returns
|
|
74
|
+
* `null` when there is nothing to reason about (no proof, or already reclaimed:
|
|
75
|
+
* a reclaimed stream has no hatch left to open).
|
|
76
|
+
*/
|
|
77
|
+
export declare function operatorHatchExposure(stream: Pick<StreamV2, "deposit" | "claimedCumulative" | "reclaimed">, verifiedCumulative: bigint | null, generation: string, provenCumulative: bigint | null): OperatorHatchExposure | null;
|
|
78
|
+
/**
|
|
79
|
+
* A stream whose buyer side is over, read from chain state. All amounts gross.
|
|
80
|
+
*
|
|
81
|
+
* Two ways to get here:
|
|
82
|
+
*
|
|
83
|
+
* - `reclaimed`: the buyer reclaimed. Read from the stream tuple, which reclaim
|
|
84
|
+
* WRITES, unlike during the stream's active life. The buyer's refund is
|
|
85
|
+
* deliberately absent: reclaim overwrites `deposit` with the operator's
|
|
86
|
+
* entitlement, so `deposit − settled` is NOT the refund, and the true figure
|
|
87
|
+
* lives only in the reclaim's `BuyerReclaimed` event, which this screen does
|
|
88
|
+
* not scan for (the reclaim block is unknown, so the lookup is not bounded).
|
|
89
|
+
* - `deposit-exhausted`: the stream has stopped (closed, or past expiry) and the
|
|
90
|
+
* operator's floor already covers the whole deposit, so there is nothing to
|
|
91
|
+
* reclaim and the buyer never will. Both buyer exits settle the operator at no
|
|
92
|
+
* less than `max(claimedCumulative, provenCumulative)` (V2:
|
|
93
|
+
* `claimedCumulative`) and revert `NothingToReclaim` when `deposit − floor` is
|
|
94
|
+
* zero, so `reclaimed` stays `false` forever on such a stream.
|
|
95
|
+
*/
|
|
96
|
+
export interface FinalSettlement {
|
|
97
|
+
readonly finishedBy: "reclaimed" | "deposit-exhausted";
|
|
98
|
+
/**
|
|
99
|
+
* The operator's entitlement: `settledCumulative` (fixed at reclaim), or the
|
|
100
|
+
* whole `deposit` when it was exhausted.
|
|
101
|
+
*/
|
|
102
|
+
readonly settledToOperator: bigint;
|
|
103
|
+
/** `claimedCumulative`: what the operator has redeemed so far. */
|
|
104
|
+
readonly operatorClaimed: bigint;
|
|
105
|
+
/** `settledToOperator − operatorClaimed`, still escrowed for the operator. */
|
|
106
|
+
readonly operatorUnclaimed: bigint;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Whether the buyer side of a stream is finished, and what the operator holds.
|
|
110
|
+
* Pure, so the rule is testable without an RPC.
|
|
111
|
+
*
|
|
112
|
+
* `stopped` is the escrow's own reclaim gate (closed, or `now >= expiresAt`).
|
|
113
|
+
* `provenCumulative` counts only on V3, and only when it was READ: an
|
|
114
|
+
* unreadable high-water is treated as zero, so it can never make a stream look
|
|
115
|
+
* finished that is not.
|
|
116
|
+
*/
|
|
117
|
+
export declare function finalSettlement(stream: Pick<StreamV2, "reclaimed" | "settledCumulative" | "claimedCumulative" | "deposit">, exhaustion?: {
|
|
118
|
+
readonly stopped: boolean;
|
|
119
|
+
readonly generation: string;
|
|
120
|
+
readonly provenCumulative: bigint | null;
|
|
121
|
+
}): FinalSettlement | null;
|
|
41
122
|
/**
|
|
42
123
|
* A stream as the CLI reports it.
|
|
43
124
|
*
|
|
@@ -55,6 +136,12 @@ export interface StreamReport {
|
|
|
55
136
|
/** Why there is no proof yet, when applicable. */
|
|
56
137
|
readonly proofUnavailable: string | null;
|
|
57
138
|
readonly claimable: bigint | null;
|
|
139
|
+
/**
|
|
140
|
+
* What {@link claimable} was computed against: the oracle's current proof,
|
|
141
|
+
* or — V3, when the latest checkpoint no longer contains the stream — the
|
|
142
|
+
* on-chain proven high-water, which `claimProven` redeems without a proof.
|
|
143
|
+
*/
|
|
144
|
+
readonly claimableSource: "checkpoint-proof" | "proven-on-chain" | null;
|
|
58
145
|
readonly reclaimable: bigint | null;
|
|
59
146
|
readonly protocolFeeBps: number | null;
|
|
60
147
|
/**
|
|
@@ -83,10 +170,32 @@ export interface StreamReport {
|
|
|
83
170
|
* "no overlap".
|
|
84
171
|
*/
|
|
85
172
|
readonly attesters: AttesterSet;
|
|
173
|
+
/** The escrow generation this report was read against (`v2` / `v3`). */
|
|
174
|
+
readonly escrowGeneration: string;
|
|
175
|
+
/**
|
|
176
|
+
* V3 only: the on-chain proven high-water (`provenCumulativeOf`). `null` on
|
|
177
|
+
* V2, or when the read failed — see {@link provenUnavailable}.
|
|
178
|
+
*/
|
|
179
|
+
readonly provenCumulative: bigint | null;
|
|
180
|
+
/** Why a V3 proven high-water could not be read, when applicable. */
|
|
181
|
+
readonly provenUnavailable: string | null;
|
|
182
|
+
/** See {@link operatorHatchExposure}. `null` when not applicable. */
|
|
183
|
+
readonly operatorExposure: OperatorHatchExposure | null;
|
|
184
|
+
/**
|
|
185
|
+
* See {@link finalSettlement}. Non-null exactly when the buyer side is over:
|
|
186
|
+
* reclaimed, or stopped with the whole deposit already the operator's.
|
|
187
|
+
*/
|
|
188
|
+
readonly finalSettlement: FinalSettlement | null;
|
|
86
189
|
}
|
|
87
190
|
export declare function readStreamReport(read: CliReadClient, streamId: `0x${string}`, nowSeconds: number,
|
|
88
191
|
/** The escrow's generation (decides the escape-hatch rule). Default `v2`. */
|
|
89
192
|
escrowGeneration?: string): Promise<StreamReport>;
|
|
90
193
|
export declare function streamReportJson(report: StreamReport): unknown;
|
|
91
194
|
export declare function streamReportRows(report: StreamReport): (readonly [string, string])[];
|
|
195
|
+
/**
|
|
196
|
+
* The expiry row. A stream that was closed before its expiry never reaches
|
|
197
|
+
* it, so it never reads as a countdown ("in 57m") — that looked like a stream
|
|
198
|
+
* still running. Exported for tests.
|
|
199
|
+
*/
|
|
200
|
+
export declare function describeDeadline(stream: Pick<StreamV2, "expiresAt" | "closedAt">, nowSeconds: number): readonly [string, string];
|
|
92
201
|
//# sourceMappingURL=status.d.ts.map
|
package/dist/cli/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/cli/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAIL,KAAK,WAAW,EACjB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BAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,GACnB,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAmF/B;AA6JD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,UAAU,CAAC,EAChD,UAAU,EAAE,MAAM,GACjB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAoB3B"}
|
package/dist/cli/status.js
CHANGED
|
@@ -24,6 +24,71 @@ export function settlementCoverage(stream, latestCheckpointCheckedAt, nowSeconds
|
|
|
24
24
|
pending: stopAt !== null && (coveredUpTo === null || coveredUpTo < stopAt),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The exposure for a stream that has NOT been reclaimed and has a verified
|
|
29
|
+
* proof. Pure, so the per-generation rule is testable without an RPC. Returns
|
|
30
|
+
* `null` when there is nothing to reason about (no proof, or already reclaimed:
|
|
31
|
+
* a reclaimed stream has no hatch left to open).
|
|
32
|
+
*/
|
|
33
|
+
export function operatorHatchExposure(stream, verifiedCumulative, generation, provenCumulative) {
|
|
34
|
+
if (stream.reclaimed || verifiedCumulative === null)
|
|
35
|
+
return null;
|
|
36
|
+
const verified = verifiedCumulative > stream.deposit ? stream.deposit : verifiedCumulative;
|
|
37
|
+
let protectedCumulative = stream.claimedCumulative;
|
|
38
|
+
let provenCumulativeKnown = true;
|
|
39
|
+
if (generation === "v3") {
|
|
40
|
+
if (provenCumulative === null) {
|
|
41
|
+
provenCumulativeKnown = false;
|
|
42
|
+
}
|
|
43
|
+
else if (provenCumulative > protectedCumulative) {
|
|
44
|
+
protectedCumulative = provenCumulative;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const atRiskCumulative = verified > protectedCumulative ? verified - protectedCumulative : 0n;
|
|
48
|
+
return {
|
|
49
|
+
verifiedCumulative: verified,
|
|
50
|
+
protectedCumulative,
|
|
51
|
+
atRiskCumulative,
|
|
52
|
+
provenCumulativeKnown,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether the buyer side of a stream is finished, and what the operator holds.
|
|
57
|
+
* Pure, so the rule is testable without an RPC.
|
|
58
|
+
*
|
|
59
|
+
* `stopped` is the escrow's own reclaim gate (closed, or `now >= expiresAt`).
|
|
60
|
+
* `provenCumulative` counts only on V3, and only when it was READ: an
|
|
61
|
+
* unreadable high-water is treated as zero, so it can never make a stream look
|
|
62
|
+
* finished that is not.
|
|
63
|
+
*/
|
|
64
|
+
export function finalSettlement(stream, exhaustion) {
|
|
65
|
+
if (stream.reclaimed) {
|
|
66
|
+
return settled("reclaimed", stream.settledCumulative, stream);
|
|
67
|
+
}
|
|
68
|
+
if (exhaustion === undefined || !exhaustion.stopped)
|
|
69
|
+
return null;
|
|
70
|
+
if (stream.deposit <= 0n)
|
|
71
|
+
return null;
|
|
72
|
+
let operatorFloor = stream.claimedCumulative;
|
|
73
|
+
if (exhaustion.generation === "v3" &&
|
|
74
|
+
exhaustion.provenCumulative !== null &&
|
|
75
|
+
exhaustion.provenCumulative > operatorFloor) {
|
|
76
|
+
operatorFloor = exhaustion.provenCumulative;
|
|
77
|
+
}
|
|
78
|
+
if (operatorFloor < stream.deposit)
|
|
79
|
+
return null;
|
|
80
|
+
return settled("deposit-exhausted", stream.deposit, stream);
|
|
81
|
+
}
|
|
82
|
+
function settled(finishedBy, settledToOperator, stream) {
|
|
83
|
+
return {
|
|
84
|
+
finishedBy,
|
|
85
|
+
settledToOperator,
|
|
86
|
+
operatorClaimed: stream.claimedCumulative,
|
|
87
|
+
operatorUnclaimed: settledToOperator > stream.claimedCumulative
|
|
88
|
+
? settledToOperator - stream.claimedCumulative
|
|
89
|
+
: 0n,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
27
92
|
export async function readStreamReport(read, streamId, nowSeconds,
|
|
28
93
|
/** The escrow's generation (decides the escape-hatch rule). Default `v2`. */
|
|
29
94
|
escrowGeneration = "v2") {
|
|
@@ -40,13 +105,38 @@ escrowGeneration = "v2") {
|
|
|
40
105
|
catch (error) {
|
|
41
106
|
proofUnavailable = describeError(error);
|
|
42
107
|
}
|
|
108
|
+
let provenCumulative = null;
|
|
109
|
+
let provenUnavailable = null;
|
|
110
|
+
if (escrowGeneration === "v3") {
|
|
111
|
+
if (read.provenCumulativeOf === undefined) {
|
|
112
|
+
provenUnavailable = "this read client cannot read provenCumulativeOf";
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
try {
|
|
116
|
+
provenCumulative = await read.provenCumulativeOf(streamId);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
provenUnavailable = describeError(error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
43
123
|
let claimable = null;
|
|
124
|
+
let claimableSource = null;
|
|
44
125
|
let reclaimable = null;
|
|
45
126
|
if (proof !== null) {
|
|
46
127
|
[claimable, reclaimable] = await Promise.all([
|
|
47
128
|
read.claimableForV2(streamId, proof.cumulativeAmount),
|
|
48
129
|
read.reclaimableForV2(streamId, proof.cumulativeAmount),
|
|
49
130
|
]);
|
|
131
|
+
claimableSource = "checkpoint-proof";
|
|
132
|
+
}
|
|
133
|
+
else if (provenCumulative !== null &&
|
|
134
|
+
provenCumulative > stream.claimedCumulative) {
|
|
135
|
+
// The latest checkpoint no longer lists the stream, but a value proven
|
|
136
|
+
// against a signed root is recorded on-chain. `claimableFor` at that value
|
|
137
|
+
// is exactly what `claimProven` pays (same `_payableCumulative` and fee).
|
|
138
|
+
claimable = await read.claimableForV2(streamId, provenCumulative);
|
|
139
|
+
claimableSource = "proven-on-chain";
|
|
50
140
|
}
|
|
51
141
|
let protocolFeeBps = null;
|
|
52
142
|
try {
|
|
@@ -69,7 +159,14 @@ escrowGeneration = "v2") {
|
|
|
69
159
|
catch {
|
|
70
160
|
latestCheckpointCheckedAt = null;
|
|
71
161
|
}
|
|
72
|
-
const
|
|
162
|
+
const coverage = settlementCoverage(stream, latestCheckpointCheckedAt, now.seconds);
|
|
163
|
+
const final = finalSettlement(stream, {
|
|
164
|
+
stopped: coverage.stopAt !== null,
|
|
165
|
+
generation: escrowGeneration,
|
|
166
|
+
provenCumulative,
|
|
167
|
+
});
|
|
168
|
+
// A finished stream is settled: there is no checkpoint left to wait for.
|
|
169
|
+
const settlement = final !== null ? { ...coverage, pending: false } : coverage;
|
|
73
170
|
const attesters = await readAttesterSet(read);
|
|
74
171
|
return {
|
|
75
172
|
streamId,
|
|
@@ -77,6 +174,7 @@ escrowGeneration = "v2") {
|
|
|
77
174
|
proof,
|
|
78
175
|
proofUnavailable,
|
|
79
176
|
claimable,
|
|
177
|
+
claimableSource,
|
|
80
178
|
reclaimable,
|
|
81
179
|
protocolFeeBps,
|
|
82
180
|
escapeHatch,
|
|
@@ -85,6 +183,14 @@ escrowGeneration = "v2") {
|
|
|
85
183
|
clockSource: now.source,
|
|
86
184
|
settlement,
|
|
87
185
|
attesters,
|
|
186
|
+
escrowGeneration,
|
|
187
|
+
provenCumulative,
|
|
188
|
+
provenUnavailable,
|
|
189
|
+
// A finished stream has no hatch left that could take anything.
|
|
190
|
+
operatorExposure: final !== null
|
|
191
|
+
? null
|
|
192
|
+
: operatorHatchExposure(stream, proof === null ? null : proof.cumulativeAmount, escrowGeneration, provenCumulative),
|
|
193
|
+
finalSettlement: final,
|
|
88
194
|
};
|
|
89
195
|
}
|
|
90
196
|
export function streamReportJson(report) {
|
|
@@ -125,8 +231,19 @@ export function streamReportJson(report) {
|
|
|
125
231
|
// settled-looking number derived from a checkpoint that predates the
|
|
126
232
|
// stream's stop time. The superseded figure is still available, explicitly
|
|
127
233
|
// labelled, under `settlement.provisionalReclaimable`.
|
|
128
|
-
|
|
129
|
-
|
|
234
|
+
// A finished stream with nothing left for the operator has nothing
|
|
235
|
+
// claimable, even when no proof was fetched.
|
|
236
|
+
claimable: report.claimable ??
|
|
237
|
+
(report.finalSettlement?.operatorUnclaimed === 0n ? 0n : null),
|
|
238
|
+
// `checkpoint-proof`, `proven-on-chain` (V3: what `claimProven` pays), or
|
|
239
|
+
// `null` when `claimable` is.
|
|
240
|
+
claimableSource: report.claimableSource,
|
|
241
|
+
// Nothing is reclaimable from a stream whose buyer side is finished.
|
|
242
|
+
reclaimable: report.finalSettlement !== null
|
|
243
|
+
? 0n
|
|
244
|
+
: report.settlement.pending
|
|
245
|
+
? null
|
|
246
|
+
: report.reclaimable,
|
|
130
247
|
settlement: {
|
|
131
248
|
pending: report.settlement.pending,
|
|
132
249
|
stopAt: report.settlement.stopAt,
|
|
@@ -150,15 +267,42 @@ export function streamReportJson(report) {
|
|
|
150
267
|
ready: report.escapeHatch.ready,
|
|
151
268
|
secondsUntilReady: report.escapeHatch.secondsRemaining,
|
|
152
269
|
},
|
|
270
|
+
escrowGeneration: report.escrowGeneration,
|
|
271
|
+
// V3 only; `null` on V2 or when unreadable (`provenCumulativeUnavailable`).
|
|
272
|
+
provenCumulative: report.provenCumulative,
|
|
273
|
+
provenCumulativeUnavailable: report.provenUnavailable,
|
|
274
|
+
// True once nothing more is owed to, or can be reclaimed by, the buyer —
|
|
275
|
+
// reclaimed, or stopped with the whole deposit already the operator's —
|
|
276
|
+
// and the escape hatch no longer applies.
|
|
277
|
+
buyerSideFinished: report.finalSettlement !== null,
|
|
278
|
+
// Non-null exactly when `buyerSideFinished`. Gross base units. The buyer's
|
|
279
|
+
// refund is not included: see `FinalSettlement`.
|
|
280
|
+
finalSettlement: report.finalSettlement === null
|
|
281
|
+
? null
|
|
282
|
+
: {
|
|
283
|
+
finishedBy: report.finalSettlement.finishedBy,
|
|
284
|
+
settledToOperator: report.finalSettlement.settledToOperator,
|
|
285
|
+
operatorClaimed: report.finalSettlement.operatorClaimed,
|
|
286
|
+
operatorUnclaimed: report.finalSettlement.operatorUnclaimed,
|
|
287
|
+
},
|
|
288
|
+
// What the buyer's no-proof escape hatch could take from the operator.
|
|
289
|
+
// `null` once reclaimed or before any proof. Gross base units.
|
|
290
|
+
operatorHatchExposure: report.operatorExposure === null
|
|
291
|
+
? null
|
|
292
|
+
: {
|
|
293
|
+
units: "gross",
|
|
294
|
+
verifiedCumulative: report.operatorExposure.verifiedCumulative,
|
|
295
|
+
protectedCumulative: report.operatorExposure.protectedCumulative,
|
|
296
|
+
atRiskCumulative: report.operatorExposure.atRiskCumulative,
|
|
297
|
+
protectedOnChain: report.operatorExposure.atRiskCumulative === 0n,
|
|
298
|
+
provenCumulativeKnown: report.operatorExposure.provenCumulativeKnown,
|
|
299
|
+
},
|
|
153
300
|
};
|
|
154
301
|
}
|
|
155
302
|
export function streamReportRows(report) {
|
|
156
303
|
const { stream, proof } = report;
|
|
157
304
|
const rows = [
|
|
158
|
-
[
|
|
159
|
-
"status",
|
|
160
|
-
stream.reclaimed ? `${stream.status} (reclaimed)` : stream.status,
|
|
161
|
-
],
|
|
305
|
+
["status", describeStatus(report)],
|
|
162
306
|
...(stream.opener === null || stream.opener === undefined
|
|
163
307
|
? [["buyer", stream.buyer]]
|
|
164
308
|
: [
|
|
@@ -167,20 +311,28 @@ export function streamReportRows(report) {
|
|
|
167
311
|
]),
|
|
168
312
|
["operator", stream.operator],
|
|
169
313
|
["serviceRef", stream.serviceRef],
|
|
170
|
-
|
|
314
|
+
// Reclaim OVERWRITES `deposit` with the operator's entitlement, so after a
|
|
315
|
+
// reclaim the field is what is still escrowed for the operator — not what
|
|
316
|
+
// the buyer put in. Printing it bare would read as "the buyer deposited 0".
|
|
317
|
+
[
|
|
318
|
+
"deposit",
|
|
319
|
+
stream.reclaimed
|
|
320
|
+
? `${formatUsdc(stream.deposit)} still escrowed for the operator (reclaim replaces the original deposit with the operator's entitlement)`
|
|
321
|
+
: formatUsdc(stream.deposit),
|
|
322
|
+
],
|
|
171
323
|
["rate", `${formatUsdc(stream.ratePerSecond)} / second`],
|
|
172
324
|
["opened", formatTimestamp(stream.openedAt)],
|
|
173
|
-
|
|
325
|
+
describeDeadline(stream, report.nowSeconds),
|
|
174
326
|
];
|
|
175
327
|
if (stream.closedAt > 0) {
|
|
176
328
|
rows.push(["closed", formatTimestamp(stream.closedAt)]);
|
|
177
329
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
]);
|
|
330
|
+
if (report.finalSettlement !== null) {
|
|
331
|
+
rows.push(...finalSettlementRows(report, report.finalSettlement));
|
|
332
|
+
pushTrailingRows(rows, report);
|
|
333
|
+
return rows;
|
|
334
|
+
}
|
|
335
|
+
rows.push(["verified accrual", describeVerifiedAccrual(report)]);
|
|
184
336
|
// `claim` accepts ANY retained root, so the operator's balance is obtainable
|
|
185
337
|
// now — it is merely not FINAL until the covering checkpoint lands, and it
|
|
186
338
|
// can only grow. `reclaim` requires the LATEST root to reach the stop time,
|
|
@@ -190,9 +342,11 @@ export function streamReportRows(report) {
|
|
|
190
342
|
"operator claimable",
|
|
191
343
|
report.claimable === null
|
|
192
344
|
? "-"
|
|
193
|
-
: report.
|
|
194
|
-
? `${formatUsdc(report.claimable)}
|
|
195
|
-
:
|
|
345
|
+
: report.claimableSource === "proven-on-chain"
|
|
346
|
+
? `${formatUsdc(report.claimable)} (net of the protocol fee) — from the on-chain proven high-water; \`metrik claim\` redeems it with claimProven, no fresh proof needed`
|
|
347
|
+
: report.settlement.pending
|
|
348
|
+
? `${formatUsdc(report.claimable)} so far (net of the protocol fee) — not final until the checkpoint covering the stop time lands`
|
|
349
|
+
: `${formatUsdc(report.claimable)} (net of the protocol fee)`,
|
|
196
350
|
]);
|
|
197
351
|
rows.push([
|
|
198
352
|
"buyer reclaimable",
|
|
@@ -202,46 +356,161 @@ export function streamReportRows(report) {
|
|
|
202
356
|
? "-"
|
|
203
357
|
: formatUsdc(report.reclaimable),
|
|
204
358
|
]);
|
|
359
|
+
if (report.escrowGeneration === "v3") {
|
|
360
|
+
rows.push([
|
|
361
|
+
"proven on-chain",
|
|
362
|
+
report.provenCumulative === null
|
|
363
|
+
? `unknown (${report.provenUnavailable ?? "not read"})`
|
|
364
|
+
: `${formatUsdc(report.provenCumulative)} gross (the escrow's proven high-water; the escape hatch cannot take it)`,
|
|
365
|
+
]);
|
|
366
|
+
}
|
|
205
367
|
rows.push(["fees paid", formatUsdc(stream.feesPaid)]);
|
|
206
|
-
rows.push(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
? "-"
|
|
210
|
-
: report.latestCheckpointCheckedAt <= 0
|
|
211
|
-
? "none posted yet"
|
|
212
|
-
: `latest covers up to ${formatTimestamp(report.latestCheckpointCheckedAt)}`,
|
|
213
|
-
]);
|
|
214
|
-
// The no-proof path. Printed for every stream, not only blocked ones: a buyer
|
|
215
|
-
// should learn that this exists before they need it.
|
|
368
|
+
rows.push(oracleCheckpointRow(report));
|
|
369
|
+
// The no-proof path. Printed for every live stream, not only blocked ones: a
|
|
370
|
+
// buyer should learn that this exists before they need it.
|
|
216
371
|
rows.push([
|
|
217
372
|
"escape hatch",
|
|
218
373
|
report.escapeHatch === null
|
|
219
374
|
? "-"
|
|
220
|
-
: `${describeEscapeHatch(report.escapeHatch)} —
|
|
375
|
+
: `${describeEscapeHatch(report.escapeHatch)} — ${report.escrowGeneration === "v3"
|
|
376
|
+
? "no-proof reclaim, refunds only value not proven on-chain; the operator keeps max(claimed, proven high-water)"
|
|
377
|
+
: "no-proof reclaim, forfeits the operator's unclaimed earnings"}`,
|
|
221
378
|
]);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
379
|
+
const operatorRow = operatorExposureRow(report);
|
|
380
|
+
if (operatorRow !== null)
|
|
381
|
+
rows.push(operatorRow);
|
|
382
|
+
pushTrailingRows(rows, report);
|
|
383
|
+
return rows;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* The same escape-hatch row, read from the seller's side.
|
|
387
|
+
*
|
|
388
|
+
* V2: `reclaimUnverified` settles the operator at `claimedCumulative`, so an
|
|
389
|
+
* operator who has earned but not claimed loses all of it the moment the
|
|
390
|
+
* window opens. The window is fixed and the grace immutable, so the only thing
|
|
391
|
+
* an operator can do about it is claim in time — which they cannot do if
|
|
392
|
+
* nothing tells them the deadline exists.
|
|
393
|
+
*
|
|
394
|
+
* V3: the hatch settles the operator at `max(claimed, provenCumulative)`, so
|
|
395
|
+
* only verified value nobody proved on-chain is exposed. Warning about the
|
|
396
|
+
* WHOLE unclaimed balance there would be false — and would push an operator to
|
|
397
|
+
* spend gas racing a deadline that cannot hurt them.
|
|
398
|
+
*/
|
|
399
|
+
function operatorExposureRow(report) {
|
|
400
|
+
const hatch = report.escapeHatch;
|
|
401
|
+
if (hatch === null || report.claimable === null || report.claimable <= 0n) {
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
if (report.escrowGeneration !== "v3") {
|
|
405
|
+
return [
|
|
232
406
|
"operator deadline",
|
|
233
|
-
|
|
407
|
+
hatch.ready
|
|
234
408
|
? `${formatUsdc(report.claimable)} is unclaimed and the buyer's no-proof reclaim is ALREADY open — it would take this amount from the operator`
|
|
235
|
-
: `${formatUsdc(report.claimable)} is unclaimed; \`metrik claim\` it before ${formatTimestamp(
|
|
409
|
+
: `${formatUsdc(report.claimable)} is unclaimed; \`metrik claim\` it before ${formatTimestamp(hatch.readyAt)}, after which a buyer's no-proof reclaim can take it`,
|
|
410
|
+
];
|
|
411
|
+
}
|
|
412
|
+
const exposure = report.operatorExposure;
|
|
413
|
+
if (exposure === null)
|
|
414
|
+
return null;
|
|
415
|
+
const units = `(gross: before the protocol fee; \`metrik claim\` pays the operator net of it — ${formatUsdc(report.claimable)} net unclaimed)`;
|
|
416
|
+
if (exposure.atRiskCumulative === 0n) {
|
|
417
|
+
return [
|
|
418
|
+
"operator earnings",
|
|
419
|
+
`${formatUsdc(exposure.verifiedCumulative)} gross verified, all protected on-chain by the proven high-water — a buyer's no-proof reclaim cannot take it, so it can be claimed at any time with \`metrik claim\` ${units}`,
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
const protectedPart = exposure.provenCumulativeKnown
|
|
423
|
+
? `${formatUsdc(exposure.protectedCumulative)} gross is protected on-chain (claimed or proven high-water)`
|
|
424
|
+
: "the on-chain proven high-water could not be read, so this assumes none of the unclaimed balance is protected";
|
|
425
|
+
return [
|
|
426
|
+
"operator deadline",
|
|
427
|
+
hatch.ready
|
|
428
|
+
? `${formatUsdc(exposure.atRiskCumulative)} gross of verified accrual is not proven on-chain and the buyer's no-proof reclaim is ALREADY open — it would refund that part to the buyer. ${protectedPart}. ${units}`
|
|
429
|
+
: `${formatUsdc(exposure.atRiskCumulative)} gross of verified accrual is not proven on-chain; \`metrik claim\` it before ${formatTimestamp(hatch.readyAt)}, after which a buyer's no-proof reclaim refunds that part to the buyer. ${protectedPart}. ${units}`,
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A reclaimed stream, from the state reclaim WROTE. The buyer side is over:
|
|
434
|
+
* no checkpoint to wait for, nothing reclaimable, and no escape hatch left to
|
|
435
|
+
* open (`reclaimUnverified` reverts `AlreadyReclaimed`). So none of those are
|
|
436
|
+
* printed as live items — only what the operator is still owed.
|
|
437
|
+
*/
|
|
438
|
+
function finalSettlementRows(report, settlement) {
|
|
439
|
+
const refundTo = report.stream.payer ?? report.stream.buyer;
|
|
440
|
+
const exhausted = settlement.finishedBy === "deposit-exhausted";
|
|
441
|
+
const rows = [
|
|
442
|
+
[
|
|
443
|
+
"buyer side",
|
|
444
|
+
exhausted
|
|
445
|
+
? `finished — the operator's claimed${report.escrowGeneration === "v3" ? " or proven" : ""} amount already covers the whole deposit, so there is nothing to reclaim (the escrow would revert NothingToReclaim) and the buyer never reclaimed. Nothing more is owed to, or reclaimable by, the buyer.`
|
|
446
|
+
: `finished — the buyer has reclaimed, and the refund was paid to ${refundTo}. Nothing more is owed to, or reclaimable by, the buyer.`,
|
|
447
|
+
],
|
|
448
|
+
[
|
|
449
|
+
"settled to operator",
|
|
450
|
+
`${formatUsdc(settlement.settledToOperator)} gross (${exhausted ? "the whole deposit" : "fixed at reclaim"})`,
|
|
451
|
+
],
|
|
452
|
+
["operator claimed", `${formatUsdc(settlement.operatorClaimed)} gross`],
|
|
453
|
+
[
|
|
454
|
+
"operator unclaimed",
|
|
455
|
+
settlement.operatorUnclaimed === 0n
|
|
456
|
+
? "none — fully settled"
|
|
457
|
+
: `${formatUsdc(settlement.operatorUnclaimed)} gross, reserved for the operator — the buyer side is finished, so nothing can take it; \`metrik claim\` it at any time (paid net of the protocol fee)`,
|
|
458
|
+
],
|
|
459
|
+
];
|
|
460
|
+
if (exhausted && report.provenCumulative !== null) {
|
|
461
|
+
rows.push([
|
|
462
|
+
"proven on-chain",
|
|
463
|
+
`${formatUsdc(report.provenCumulative)} gross (the escrow's proven high-water)`,
|
|
236
464
|
]);
|
|
237
465
|
}
|
|
466
|
+
rows.push(["fees paid", formatUsdc(report.stream.feesPaid)]);
|
|
467
|
+
return rows;
|
|
468
|
+
}
|
|
469
|
+
function describeStatus(report) {
|
|
470
|
+
const { stream } = report;
|
|
471
|
+
const final = report.finalSettlement;
|
|
472
|
+
if (final === null)
|
|
473
|
+
return stream.status;
|
|
474
|
+
if (final.finishedBy === "reclaimed")
|
|
475
|
+
return `${stream.status} (reclaimed)`;
|
|
476
|
+
const stop = stream.closedAt > 0 ? "closed" : "expired";
|
|
477
|
+
return final.operatorUnclaimed === 0n
|
|
478
|
+
? `${stream.status} (${stop}, fully settled)`
|
|
479
|
+
: `${stream.status} (${stop}, buyer side finished)`;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* The verified-accrual row. With no current proof on V3, a non-zero proven
|
|
483
|
+
* high-water IS verified accrual — proven against a signed checkpoint root and
|
|
484
|
+
* recorded on-chain — so it is stated rather than "not checkpointed yet", which
|
|
485
|
+
* reads as "nothing verified".
|
|
486
|
+
*/
|
|
487
|
+
function describeVerifiedAccrual(report) {
|
|
488
|
+
const { proof } = report;
|
|
489
|
+
if (proof !== null) {
|
|
490
|
+
return `${formatUsdc(proof.cumulativeAmount)} gross @ checkpoint ${proof.checkpointId} (${formatTimestamp(Number(proof.checkedAt))})`;
|
|
491
|
+
}
|
|
492
|
+
if (report.provenCumulative !== null && report.provenCumulative > 0n) {
|
|
493
|
+
return `${formatUsdc(report.provenCumulative)} gross proven on-chain (provenCumulativeOf) — the latest checkpoint does not contain this stream (${report.proofUnavailable ?? "no proof"}), so this is read from the escrow`;
|
|
494
|
+
}
|
|
495
|
+
return `not checkpointed yet (${report.proofUnavailable ?? "no proof"})`;
|
|
496
|
+
}
|
|
497
|
+
function oracleCheckpointRow(report) {
|
|
498
|
+
return [
|
|
499
|
+
"oracle checkpoint",
|
|
500
|
+
report.latestCheckpointCheckedAt === null
|
|
501
|
+
? "-"
|
|
502
|
+
: report.latestCheckpointCheckedAt <= 0
|
|
503
|
+
? "none posted yet"
|
|
504
|
+
: `latest covers up to ${formatTimestamp(report.latestCheckpointCheckedAt)}`,
|
|
505
|
+
];
|
|
506
|
+
}
|
|
507
|
+
function pushTrailingRows(rows, report) {
|
|
238
508
|
if (report.protocolFeeBps !== null) {
|
|
239
509
|
rows.push([
|
|
240
510
|
"protocol fee",
|
|
241
511
|
`${report.protocolFeeBps} bps (read from the escrow)`,
|
|
242
512
|
]);
|
|
243
513
|
}
|
|
244
|
-
return rows;
|
|
245
514
|
}
|
|
246
515
|
/**
|
|
247
516
|
* What is being waited for, in the place a number used to be. Names the two
|
|
@@ -254,11 +523,30 @@ function describePendingSettlement(settlement) {
|
|
|
254
523
|
: formatTimestamp(settlement.coveredUpTo);
|
|
255
524
|
return `pending final checkpoint — the stream stopped at ${stopAt}, the oracle has published only to ${covered}. Reclaim reverts until a checkpoint reaches the stop time (~15-22s apart).`;
|
|
256
525
|
}
|
|
257
|
-
|
|
526
|
+
/**
|
|
527
|
+
* The expiry row. A stream that was closed before its expiry never reaches
|
|
528
|
+
* it, so it never reads as a countdown ("in 57m") — that looked like a stream
|
|
529
|
+
* still running. Exported for tests.
|
|
530
|
+
*/
|
|
531
|
+
export function describeDeadline(stream, nowSeconds) {
|
|
532
|
+
const { expiresAt } = stream;
|
|
533
|
+
const closedEarly = stream.closedAt > 0 && stream.closedAt < expiresAt;
|
|
534
|
+
if (closedEarly) {
|
|
535
|
+
return [
|
|
536
|
+
"would have expired",
|
|
537
|
+
`${formatTimestamp(expiresAt)} — not reached: closed early at ${formatTimestamp(stream.closedAt)}, so it accrues nothing more`,
|
|
538
|
+
];
|
|
539
|
+
}
|
|
258
540
|
const remaining = expiresAt - nowSeconds;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
541
|
+
if (remaining > 0) {
|
|
542
|
+
return [
|
|
543
|
+
"expires",
|
|
544
|
+
`${formatTimestamp(expiresAt)} — in ${formatDuration(remaining)}`,
|
|
545
|
+
];
|
|
546
|
+
}
|
|
547
|
+
return [
|
|
548
|
+
"expired",
|
|
549
|
+
`${formatTimestamp(expiresAt)} — ${formatDuration(-remaining)} ago`,
|
|
550
|
+
];
|
|
263
551
|
}
|
|
264
552
|
//# sourceMappingURL=status.js.map
|