@avow-finance/spec 0.0.0-stage → 0.1.0
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/LICENSE +201 -0
- package/README.md +119 -2
- package/dist/agent-connect.d.ts +82 -0
- package/dist/agent-connect.d.ts.map +1 -0
- package/dist/agent-connect.js +91 -0
- package/dist/agent-connect.js.map +1 -0
- package/dist/agent-session.d.ts +791 -0
- package/dist/agent-session.d.ts.map +1 -0
- package/dist/agent-session.js +176 -0
- package/dist/agent-session.js.map +1 -0
- package/dist/ap2.d.ts +79 -0
- package/dist/ap2.d.ts.map +1 -0
- package/dist/ap2.js +151 -0
- package/dist/ap2.js.map +1 -0
- package/dist/api-request.d.ts +144 -0
- package/dist/api-request.d.ts.map +1 -0
- package/dist/api-request.js +246 -0
- package/dist/api-request.js.map +1 -0
- package/dist/api.d.ts +288 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +332 -0
- package/dist/api.js.map +1 -0
- package/dist/canonical.d.ts +22 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +66 -0
- package/dist/canonical.js.map +1 -0
- package/dist/commitment-card.d.ts +78 -0
- package/dist/commitment-card.d.ts.map +1 -0
- package/dist/commitment-card.js +224 -0
- package/dist/commitment-card.js.map +1 -0
- package/dist/commitment.d.ts +185 -0
- package/dist/commitment.d.ts.map +1 -0
- package/dist/commitment.js +148 -0
- package/dist/commitment.js.map +1 -0
- package/dist/compute-offers.d.ts +128 -0
- package/dist/compute-offers.d.ts.map +1 -0
- package/dist/compute-offers.js +111 -0
- package/dist/compute-offers.js.map +1 -0
- package/dist/contest.d.ts +88 -0
- package/dist/contest.d.ts.map +1 -0
- package/dist/contest.js +131 -0
- package/dist/contest.js.map +1 -0
- package/dist/demo.d.ts +69 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/demo.js +152 -0
- package/dist/demo.js.map +1 -0
- package/dist/dependencies.d.ts +308 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +133 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/eip712.d.ts +1569 -0
- package/dist/eip712.d.ts.map +1 -0
- package/dist/eip712.js +550 -0
- package/dist/eip712.js.map +1 -0
- package/dist/elided-terms.d.ts +37 -0
- package/dist/elided-terms.d.ts.map +1 -0
- package/dist/elided-terms.js +48 -0
- package/dist/elided-terms.js.map +1 -0
- package/dist/erc8183.d.ts +78 -0
- package/dist/erc8183.d.ts.map +1 -0
- package/dist/erc8183.js +88 -0
- package/dist/erc8183.js.map +1 -0
- package/dist/facts.d.ts +70 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +33 -0
- package/dist/facts.js.map +1 -0
- package/dist/gpu-reservation.d.ts +79 -0
- package/dist/gpu-reservation.d.ts.map +1 -0
- package/dist/gpu-reservation.js +135 -0
- package/dist/gpu-reservation.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/job-session.d.ts +981 -0
- package/dist/job-session.d.ts.map +1 -0
- package/dist/job-session.js +170 -0
- package/dist/job-session.js.map +1 -0
- package/dist/job-verification.d.ts +244 -0
- package/dist/job-verification.d.ts.map +1 -0
- package/dist/job-verification.js +89 -0
- package/dist/job-verification.js.map +1 -0
- package/dist/job-wording.d.ts +48 -0
- package/dist/job-wording.d.ts.map +1 -0
- package/dist/job-wording.js +134 -0
- package/dist/job-wording.js.map +1 -0
- package/dist/job.d.ts +117 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +166 -0
- package/dist/job.js.map +1 -0
- package/dist/json-fields.d.ts +13 -0
- package/dist/json-fields.d.ts.map +1 -0
- package/dist/json-fields.js +30 -0
- package/dist/json-fields.js.map +1 -0
- package/dist/keychain.d.ts +51 -0
- package/dist/keychain.d.ts.map +1 -0
- package/dist/keychain.js +133 -0
- package/dist/keychain.js.map +1 -0
- package/dist/mailbox.d.ts +1650 -0
- package/dist/mailbox.d.ts.map +1 -0
- package/dist/mailbox.js +87 -0
- package/dist/mailbox.js.map +1 -0
- package/dist/mandate.d.ts +53 -0
- package/dist/mandate.d.ts.map +1 -0
- package/dist/mandate.js +97 -0
- package/dist/mandate.js.map +1 -0
- package/dist/networks.d.ts +18 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +24 -0
- package/dist/networks.js.map +1 -0
- package/dist/profiles.d.ts +31 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +33 -0
- package/dist/profiles.js.map +1 -0
- package/dist/rail.d.ts +48 -0
- package/dist/rail.d.ts.map +1 -0
- package/dist/rail.js +28 -0
- package/dist/rail.js.map +1 -0
- package/dist/reasons.d.ts +173 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +174 -0
- package/dist/reasons.js.map +1 -0
- package/dist/reference-link.d.ts +23 -0
- package/dist/reference-link.d.ts.map +1 -0
- package/dist/reference-link.js +56 -0
- package/dist/reference-link.js.map +1 -0
- package/dist/references.d.ts +125 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +108 -0
- package/dist/references.js.map +1 -0
- package/dist/replay.d.ts +30 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +27 -0
- package/dist/replay.js.map +1 -0
- package/dist/sandbox-registration.d.ts +200 -0
- package/dist/sandbox-registration.d.ts.map +1 -0
- package/dist/sandbox-registration.js +172 -0
- package/dist/sandbox-registration.js.map +1 -0
- package/dist/sandbox.d.ts +3478 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +316 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/session-fields.d.ts +203 -0
- package/dist/session-fields.d.ts.map +1 -0
- package/dist/session-fields.js +43 -0
- package/dist/session-fields.js.map +1 -0
- package/dist/supplier-adapter.d.ts +65 -0
- package/dist/supplier-adapter.d.ts.map +1 -0
- package/dist/supplier-adapter.js +91 -0
- package/dist/supplier-adapter.js.map +1 -0
- package/dist/terms-v1.d.ts +74 -0
- package/dist/terms-v1.d.ts.map +1 -0
- package/dist/terms-v1.js +156 -0
- package/dist/terms-v1.js.map +1 -0
- package/dist/terms.d.ts +341 -0
- package/dist/terms.d.ts.map +1 -0
- package/dist/terms.js +715 -0
- package/dist/terms.js.map +1 -0
- package/dist/test-customer.d.ts +1525 -0
- package/dist/test-customer.d.ts.map +1 -0
- package/dist/test-customer.js +260 -0
- package/dist/test-customer.js.map +1 -0
- package/dist/types.d.ts +272 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +51 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +66 -0
- package/dist/version.js.map +1 -0
- package/dist/wire.d.ts +2698 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +678 -0
- package/dist/wire.js.map +1 -0
- package/package.json +37 -3
- package/vectors/api-request-v1.json +53 -0
- package/vectors/contest-statement-v1.json +42 -0
- package/vectors/terms-v2.json +398 -0
- package/vectors/terms-v3.json +2103 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import { type ElidedSection, type TermsSection } from './terms.js';
|
|
3
|
+
import type { ChainedTerms } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Version 3 terms as the buyer is shown them when Avow checks the bookings they rely on. Every
|
|
6
|
+
* section is in clear with its own salt, except dependencies, which travels as its digest under
|
|
7
|
+
* its label. The buyer still works out the whole terms hash from this, so it can check that the
|
|
8
|
+
* approval Avow signs names these exact terms, hidden section included. Only terms whose header
|
|
9
|
+
* says Avow checks can be shown this way, since a buyer that checks the bookings itself needs every
|
|
10
|
+
* entry, and a reader that needs the entries refuses this view with `dependency.elided`.
|
|
11
|
+
*/
|
|
12
|
+
export type ElidedTerms = Omit<ChainedTerms, 'dependencyCheck' | 'dependencies'> & {
|
|
13
|
+
dependencyCheck: 'avow';
|
|
14
|
+
/** The dependencies section's hash under `DEPENDENCIES_LABEL`. Its salt never reaches the buyer. */
|
|
15
|
+
dependencies: ElidedSection;
|
|
16
|
+
/**
|
|
17
|
+
* The own salt of each section shown in clear. The terms' salt, which every section salt comes
|
|
18
|
+
* from, never reaches the buyer.
|
|
19
|
+
*/
|
|
20
|
+
salts: Readonly<Record<TermsSection, Hex>>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The buyer's view of version 3 terms Avow checks: the terms with their dependencies section
|
|
24
|
+
* replaced by its digest under its label, and each other section's own salt. Throws on terms the
|
|
25
|
+
* buyer checks, since it needs those in full, and on terms that can't be hashed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function elideDependencies(terms: ChainedTerms, salt: Hex): ElidedTerms;
|
|
28
|
+
/**
|
|
29
|
+
* The terms hash a buyer's view gives, the one the terms in full give. The view is read exactly as
|
|
30
|
+
* `parseElidedTerms` reads it, so this throws on any view that refuses, such as one whose header
|
|
31
|
+
* says the buyer checks, one hiding another section, or one holding a field the hash would leave
|
|
32
|
+
* out. Each section in clear is hashed with its own salt and the digest stands in for the
|
|
33
|
+
* dependencies section, so the hash binds the hidden entries too, and an approval naming it binds
|
|
34
|
+
* them.
|
|
35
|
+
*/
|
|
36
|
+
export declare function elidedTermsHash(view: ElidedTerms): Hex;
|
|
37
|
+
//# sourceMappingURL=elided-terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elided-terms.d.ts","sourceRoot":"","sources":["../src/elided-terms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,EAKL,KAAK,aAAa,EAIlB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAG9C;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,iBAAiB,GAAG,cAAc,CAAC,GAAG;IACjF,eAAe,EAAE,MAAM,CAAA;IACvB,oGAAoG;IACpG,YAAY,EAAE,aAAa,CAAA;IAC3B;;;OAGG;IACH,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAA;CAC3C,CAAA;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,GAAG,WAAW,CAqB7E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,GAAG,CAUtD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { chainedTermsHashFromSections, chainedTermsShapeProblem, DEPENDENCIES_LABEL, dependencyCheckProblem, sectionHash, sectionSalt, TERMS_SECTIONS, termsHeader, } from './terms.js';
|
|
2
|
+
import { parseElidedTerms, toWire } from './wire.js';
|
|
3
|
+
/**
|
|
4
|
+
* The buyer's view of version 3 terms Avow checks: the terms with their dependencies section
|
|
5
|
+
* replaced by its digest under its label, and each other section's own salt. Throws on terms the
|
|
6
|
+
* buyer checks, since it needs those in full, and on terms that can't be hashed.
|
|
7
|
+
*/
|
|
8
|
+
export function elideDependencies(terms, salt) {
|
|
9
|
+
const problem = chainedTermsShapeProblem(terms);
|
|
10
|
+
if (problem)
|
|
11
|
+
throw new TypeError(`These terms can't be hashed (${problem})`);
|
|
12
|
+
const { dependencies, dependencyCheck, ...shown } = terms;
|
|
13
|
+
if (dependencyCheck !== 'avow') {
|
|
14
|
+
throw new TypeError('The buyer checks the bookings these terms rely on, so it sees them in full');
|
|
15
|
+
}
|
|
16
|
+
if (dependencyCheckProblem(terms)) {
|
|
17
|
+
throw new TypeError("These terms' template has the buyer check the bookings they rely on");
|
|
18
|
+
}
|
|
19
|
+
const digest = sectionHash('dependencies', dependencies, sectionSalt(salt, 'dependencies'));
|
|
20
|
+
const salts = {};
|
|
21
|
+
for (const s of TERMS_SECTIONS)
|
|
22
|
+
salts[s] = sectionSalt(salt, s);
|
|
23
|
+
return {
|
|
24
|
+
...shown,
|
|
25
|
+
dependencyCheck,
|
|
26
|
+
dependencies: { label: DEPENDENCIES_LABEL, digest },
|
|
27
|
+
salts,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The terms hash a buyer's view gives, the one the terms in full give. The view is read exactly as
|
|
32
|
+
* `parseElidedTerms` reads it, so this throws on any view that refuses, such as one whose header
|
|
33
|
+
* says the buyer checks, one hiding another section, or one holding a field the hash would leave
|
|
34
|
+
* out. Each section in clear is hashed with its own salt and the digest stands in for the
|
|
35
|
+
* dependencies section, so the hash binds the hidden entries too, and an approval naming it binds
|
|
36
|
+
* them.
|
|
37
|
+
*/
|
|
38
|
+
export function elidedTermsHash(view) {
|
|
39
|
+
const read = parseElidedTerms(toWire(view));
|
|
40
|
+
if (!read.ok)
|
|
41
|
+
throw new TypeError(`This view of the terms can't be hashed (${read.reason})`);
|
|
42
|
+
const v = read.value;
|
|
43
|
+
const hashes = { dependencies: v.dependencies.digest };
|
|
44
|
+
for (const s of TERMS_SECTIONS)
|
|
45
|
+
hashes[s] = sectionHash(s, v[s], v.salts[s]);
|
|
46
|
+
return chainedTermsHashFromSections(termsHeader(v), hashes);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=elided-terms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elided-terms.js","sourceRoot":"","sources":["../src/elided-terms.ts"],"names":[],"mappings":"AACA,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EAEtB,WAAW,EACX,WAAW,EACX,cAAc,EAEd,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAqBpD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB,EAAE,IAAS;IAC9D,MAA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Ac;QAAE,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5E,OAAO,4BAA4B,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAC7D,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import { type Commitment, type CommitmentState, type Ending } from './commitment.js';
|
|
3
|
+
/**
|
|
4
|
+
* ERC-8183's job states, as its draft of 25 February 2026 names them. Completed, Rejected and
|
|
5
|
+
* Expired are endings.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ERC8183_STATUSES: readonly ['Open', 'Funded', 'Submitted', 'Completed', 'Rejected', 'Expired'];
|
|
8
|
+
export type Erc8183Status = (typeof ERC8183_STATUSES)[number];
|
|
9
|
+
/** The moves ERC-8183's state table allows. No job moves out of an ending. */
|
|
10
|
+
export declare const ERC8183_TRANSITIONS: {
|
|
11
|
+
readonly [S in Erc8183Status]: readonly Erc8183Status[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Where each state before an ending sits in a job. A commitment is open until money reaches the
|
|
15
|
+
* lock, funded while the supplier is bound to it, and submitted from the supplier's report of a
|
|
16
|
+
* charge until the charge is paid or ruled on.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ERC8183_STATUS_OF: {
|
|
19
|
+
readonly [S in Exclude<CommitmentState, Ending>]: Erc8183Status;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Where a commitment sits in a job, decided by its state. A charge completes the job, and so does
|
|
23
|
+
* a ruling or the day-90 default that paid the supplier anything. ERC-8183 lets a job expire only
|
|
24
|
+
* once `expiredAt` has passed, so a reserve that went back at its release date expires the job.
|
|
25
|
+
* Every other ending gave the whole reserve back, often before the release date, or never held
|
|
26
|
+
* one, as a rejected job does.
|
|
27
|
+
*/
|
|
28
|
+
export declare function erc8183Status(c: Commitment): Erc8183Status;
|
|
29
|
+
/**
|
|
30
|
+
* A commitment as an ERC-8183 job, for an adapter that shows Avow's commitments to systems that
|
|
31
|
+
* read ERC-8183. Amounts are the token's base units.
|
|
32
|
+
*/
|
|
33
|
+
export interface Erc8183Job {
|
|
34
|
+
status: Erc8183Status;
|
|
35
|
+
/** The business account whose lock holds the reserve. */
|
|
36
|
+
client: Address;
|
|
37
|
+
/**
|
|
38
|
+
* The supplier's payee that the reserve's backing names, which a charge pays. Null in a state
|
|
39
|
+
* where no money has reached the lock, even when the record already holds the backing.
|
|
40
|
+
*/
|
|
41
|
+
provider: Address | null;
|
|
42
|
+
/**
|
|
43
|
+
* The lock that the reserve's backing names, which decides every charge. It pays one once the
|
|
44
|
+
* contest window closes, applies Avow's ruling or the arbiter's, and applies the day-90 default.
|
|
45
|
+
* Null in a state where no money has reached the lock, even when the record already holds the
|
|
46
|
+
* backing.
|
|
47
|
+
*/
|
|
48
|
+
evaluator: Address | null;
|
|
49
|
+
/** The reserve, which is the most the supplier can charge. Usage is paid apart from it. */
|
|
50
|
+
budget: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* The release date. From then on anyone can return a reserve the supplier accepted with no
|
|
53
|
+
* report, and a reported charge stays held until it ends, so a submitted job can outlast it.
|
|
54
|
+
*/
|
|
55
|
+
expiredAt: bigint;
|
|
56
|
+
/** The salted terms hash both sides signed, which stands in for the job's description. */
|
|
57
|
+
description: Hex;
|
|
58
|
+
/**
|
|
59
|
+
* What the supplier was paid and the business got back, once the commitment has ended. The two
|
|
60
|
+
* add up to the budget, or to zero when nothing reached the lock.
|
|
61
|
+
*/
|
|
62
|
+
settled: {
|
|
63
|
+
paid: bigint;
|
|
64
|
+
refunded: bigint;
|
|
65
|
+
} | null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The job view of a commitment, from its record, the business account the record leaves to the
|
|
69
|
+
* chain, and the decimals of the reserve's token. The lock and the payee come from the reserve's
|
|
70
|
+
* backing once the state says money reached the lock. The record has to fit its state, as
|
|
71
|
+
* `parseCommitment` checks. Throws when an amount can't be paid exactly in a token with these
|
|
72
|
+
* decimals.
|
|
73
|
+
*/
|
|
74
|
+
export declare function toErc8183Job(c: Commitment, chain: {
|
|
75
|
+
account: Address;
|
|
76
|
+
decimals: number;
|
|
77
|
+
}): Erc8183Job;
|
|
78
|
+
//# sourceMappingURL=erc8183.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc8183.d.ts","sourceRoot":"","sources":["../src/erc8183.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,MAAM,EAAc,MAAM,iBAAiB,CAAA;AAIhG;;;GAGG;AACH,eAAO,MAAM,gBAAgB,YAC3B,MAAM,EACN,QAAQ,EACR,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,CACD,CAAA;AACV,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7D,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,EAAE;IAAE,QAAQ,EAAE,CAAC,IAAI,aAAa,GAAG,SAAS,aAAa,EAAE;CAO1F,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE;IAC9B,QAAQ,EAAE,CAAC,IAAI,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG,aAAa;CAShE,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG,aAAa,CAa1D;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,aAAa,CAAA;IACrB,yDAAyD;IACzD,MAAM,EAAE,OAAO,CAAA;IACf;;;OAGG;IACH,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,SAAS,EAAE,OAAO,GAAG,IAAI,CAAA;IACzB,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,0FAA0F;IAC1F,WAAW,EAAE,GAAG,CAAA;IAChB;;;OAGG;IACH,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CACnD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EAAE,UAAU,EACb,KAAK,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C,UAAU,CAqBZ"}
|
package/dist/erc8183.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isOffChain } from './commitment.js';
|
|
2
|
+
import { toTokenUnits } from './rail.js';
|
|
3
|
+
import { lockTerms } from './terms.js';
|
|
4
|
+
/**
|
|
5
|
+
* ERC-8183's job states, as its draft of 25 February 2026 names them. Completed, Rejected and
|
|
6
|
+
* Expired are endings.
|
|
7
|
+
*/
|
|
8
|
+
export const ERC8183_STATUSES = [
|
|
9
|
+
'Open',
|
|
10
|
+
'Funded',
|
|
11
|
+
'Submitted',
|
|
12
|
+
'Completed',
|
|
13
|
+
'Rejected',
|
|
14
|
+
'Expired',
|
|
15
|
+
];
|
|
16
|
+
/** The moves ERC-8183's state table allows. No job moves out of an ending. */
|
|
17
|
+
export const ERC8183_TRANSITIONS = {
|
|
18
|
+
Open: ['Funded', 'Rejected'],
|
|
19
|
+
Funded: ['Submitted', 'Rejected', 'Expired'],
|
|
20
|
+
Submitted: ['Completed', 'Rejected', 'Expired'],
|
|
21
|
+
Completed: [],
|
|
22
|
+
Rejected: [],
|
|
23
|
+
Expired: [],
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Where each state before an ending sits in a job. A commitment is open until money reaches the
|
|
27
|
+
* lock, funded while the supplier is bound to it, and submitted from the supplier's report of a
|
|
28
|
+
* charge until the charge is paid or ruled on.
|
|
29
|
+
*/
|
|
30
|
+
export const ERC8183_STATUS_OF = {
|
|
31
|
+
draft: 'Open',
|
|
32
|
+
agreed: 'Open',
|
|
33
|
+
awaiting_approval: 'Open',
|
|
34
|
+
reserved: 'Funded',
|
|
35
|
+
accepted: 'Funded',
|
|
36
|
+
charge_pending: 'Submitted',
|
|
37
|
+
paused: 'Submitted',
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Where a commitment sits in a job, decided by its state. A charge completes the job, and so does
|
|
41
|
+
* a ruling or the day-90 default that paid the supplier anything. ERC-8183 lets a job expire only
|
|
42
|
+
* once `expiredAt` has passed, so a reserve that went back at its release date expires the job.
|
|
43
|
+
* Every other ending gave the whole reserve back, often before the release date, or never held
|
|
44
|
+
* one, as a rejected job does.
|
|
45
|
+
*/
|
|
46
|
+
export function erc8183Status(c) {
|
|
47
|
+
switch (c.state) {
|
|
48
|
+
case 'charged':
|
|
49
|
+
return 'Completed';
|
|
50
|
+
case 'resolved':
|
|
51
|
+
return c.outcome.charged > 0n ? 'Completed' : 'Rejected';
|
|
52
|
+
case 'released':
|
|
53
|
+
return c.outcome.kind === 'reached_release_date' ? 'Expired' : 'Rejected';
|
|
54
|
+
case 'expired':
|
|
55
|
+
return 'Rejected';
|
|
56
|
+
default:
|
|
57
|
+
return ERC8183_STATUS_OF[c.state];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The job view of a commitment, from its record, the business account the record leaves to the
|
|
62
|
+
* chain, and the decimals of the reserve's token. The lock and the payee come from the reserve's
|
|
63
|
+
* backing once the state says money reached the lock. The record has to fit its state, as
|
|
64
|
+
* `parseCommitment` checks. Throws when an amount can't be paid exactly in a token with these
|
|
65
|
+
* decimals.
|
|
66
|
+
*/
|
|
67
|
+
export function toErc8183Job(c, chain) {
|
|
68
|
+
const terms = lockTerms(c.terms, chain.decimals);
|
|
69
|
+
const backing = isOffChain(c.state)
|
|
70
|
+
? null
|
|
71
|
+
: (c.backing.find((b) => b.side === terms.side)?.ref ?? null);
|
|
72
|
+
return {
|
|
73
|
+
status: erc8183Status(c),
|
|
74
|
+
client: chain.account,
|
|
75
|
+
provider: backing?.payee ?? null,
|
|
76
|
+
evaluator: backing?.lock ?? null,
|
|
77
|
+
budget: terms.amount,
|
|
78
|
+
expiredAt: terms.releaseDate,
|
|
79
|
+
description: c.termsHash,
|
|
80
|
+
settled: c.outcome === null
|
|
81
|
+
? null
|
|
82
|
+
: {
|
|
83
|
+
paid: toTokenUnits(c.outcome.charged, chain.decimals),
|
|
84
|
+
refunded: toTokenUnits(c.outcome.released, chain.decimals),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=erc8183.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc8183.js","sourceRoot":"","sources":["../src/erc8183.ts"],"names":[],"mappings":"AACA,OAAO,EAAsD,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;IACN,QAAQ;IACR,WAAW;IACX,WAAW;IACX,UAAU;IACV,SAAS;CACD,CAAA;AAGV,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAgE;IAC9F,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC5B,MAAM,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC;IAC5C,SAAS,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC;IAC/C,SAAS,EAAE,EAAE;IACb,QAAQ,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AO;QACL,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;QACxB,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;QAChC,SAAS,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI;QAChC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,WAAW;QAC5B,WAAW,EAAE,CAAC,CAAC,SAAS;QACxB,OAAO,EACL,CAAC,CAAC,OAAO,KAAK,IAAI;YAChB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC;gBACE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC;gBACrD,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;aAC3D;KACR,CAAA;AACH,CAAC"}
|
package/dist/facts.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type PinnedBlock } from './dependencies.js';
|
|
4
|
+
import { type CommitmentReference } from './references.js';
|
|
5
|
+
/**
|
|
6
|
+
* A fact is a statement a check made about the chain, with what it rests on. Whoever states it,
|
|
7
|
+
* the developer's session or the customer, it names who verified it, the commitment it's about and
|
|
8
|
+
* the block it was read at, so a reader can check it from the chain itself and never takes it on
|
|
9
|
+
* the word of whoever posted it. A signature on an event that carries a fact says who posted it,
|
|
10
|
+
* never that the fact is true.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Who verified a fact or a receipt: the developer's `service.ts` on the developer's machine, the
|
|
14
|
+
* customer's verifier, or Avow's API.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VERIFIERS: readonly ['service', 'customer', 'avow'];
|
|
17
|
+
export type VerifiedBy = (typeof VERIFIERS)[number];
|
|
18
|
+
/**
|
|
19
|
+
* Which check a fact comes from: the check of a booking relied on, of a commitment's terms and
|
|
20
|
+
* approval, of a reserve on its lock, or of a payment transfer.
|
|
21
|
+
*/
|
|
22
|
+
export declare const FACT_CHECKS: readonly ['dependency', 'commitment', 'reserve', 'payment'];
|
|
23
|
+
export type FactCheck = (typeof FACT_CHECKS)[number];
|
|
24
|
+
/** The longest a fact's text may be. */
|
|
25
|
+
export declare const FACT_TEXT_MAX = 500;
|
|
26
|
+
/** What a fact says and what it rests on. */
|
|
27
|
+
export interface FactBody {
|
|
28
|
+
text: string;
|
|
29
|
+
check: FactCheck;
|
|
30
|
+
verifiedBy: VerifiedBy;
|
|
31
|
+
/** The commitment the fact is about: chain, lock, commitment id and side, with its terms hash. */
|
|
32
|
+
reference: CommitmentReference;
|
|
33
|
+
/** The block the check read. The fact says nothing about the chain after it. */
|
|
34
|
+
block: PinnedBlock;
|
|
35
|
+
/** The transaction the fact rests on, such as the one that funded a reserve, when there is one. */
|
|
36
|
+
transactionHash: Hex | null;
|
|
37
|
+
}
|
|
38
|
+
/** A fact's fields as JSON, which an event or an order's state carries. */
|
|
39
|
+
export declare const factBodyShape: {
|
|
40
|
+
text: z.ZodString;
|
|
41
|
+
check: z.ZodEnum<{
|
|
42
|
+
commitment: "commitment";
|
|
43
|
+
dependency: "dependency";
|
|
44
|
+
payment: "payment";
|
|
45
|
+
reserve: "reserve";
|
|
46
|
+
}>;
|
|
47
|
+
verifiedBy: z.ZodEnum<{
|
|
48
|
+
avow: "avow";
|
|
49
|
+
customer: "customer";
|
|
50
|
+
service: "service";
|
|
51
|
+
}>;
|
|
52
|
+
reference: z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<"commitment">;
|
|
54
|
+
chainId: z.ZodNumber;
|
|
55
|
+
lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
56
|
+
commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
57
|
+
side: z.ZodEnum<{
|
|
58
|
+
buyer: "buyer";
|
|
59
|
+
supplier: "supplier";
|
|
60
|
+
}>;
|
|
61
|
+
termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
block: z.ZodObject<{
|
|
64
|
+
number: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
65
|
+
hash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
66
|
+
timestamp: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
transactionHash: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,mBAAmB,CAAA;AAErE,OAAO,EAAE,KAAK,mBAAmB,EAA2B,MAAM,iBAAiB,CAAA;AAEnF;;;;;;GAMG;AAEH;;;GAGG;AACH,eAAO,MAAM,SAAS,YAAI,SAAS,EAAE,UAAU,EAAE,MAAM,CAAU,CAAA;AACjE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnD;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAI,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAU,CAAA;AACtF,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpD,wCAAwC;AACxC,eAAO,MAAM,aAAa,MAAM,CAAA;AAEhC,6CAA6C;AAC7C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;IACtB,kGAAkG;IAClG,SAAS,EAAE,mBAAmB,CAAA;IAC9B,gFAAgF;IAChF,KAAK,EAAE,WAAW,CAAA;IAClB,mGAAmG;IACnG,eAAe,EAAE,GAAG,GAAG,IAAI,CAAA;CAC5B;AAED,2EAA2E;AAC3E,eAAO,MAAM,aAAa;IACxB,IAAI;IACJ,KAAK;;;;;;IACL,UAAU;;;;;IACV,SAAS;;;;;;;;;;;IACT,KAAK;;;;;IACL,eAAe;CAChB,CAAA"}
|
package/dist/facts.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { pinnedBlockJson } from './dependencies.js';
|
|
3
|
+
import { bytes32 } from './json-fields.js';
|
|
4
|
+
import { commitmentReferenceJson } from './references.js';
|
|
5
|
+
/**
|
|
6
|
+
* A fact is a statement a check made about the chain, with what it rests on. Whoever states it,
|
|
7
|
+
* the developer's session or the customer, it names who verified it, the commitment it's about and
|
|
8
|
+
* the block it was read at, so a reader can check it from the chain itself and never takes it on
|
|
9
|
+
* the word of whoever posted it. A signature on an event that carries a fact says who posted it,
|
|
10
|
+
* never that the fact is true.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Who verified a fact or a receipt: the developer's `service.ts` on the developer's machine, the
|
|
14
|
+
* customer's verifier, or Avow's API.
|
|
15
|
+
*/
|
|
16
|
+
export const VERIFIERS = ['service', 'customer', 'avow'];
|
|
17
|
+
/**
|
|
18
|
+
* Which check a fact comes from: the check of a booking relied on, of a commitment's terms and
|
|
19
|
+
* approval, of a reserve on its lock, or of a payment transfer.
|
|
20
|
+
*/
|
|
21
|
+
export const FACT_CHECKS = ['dependency', 'commitment', 'reserve', 'payment'];
|
|
22
|
+
/** The longest a fact's text may be. */
|
|
23
|
+
export const FACT_TEXT_MAX = 500;
|
|
24
|
+
/** A fact's fields as JSON, which an event or an order's state carries. */
|
|
25
|
+
export const factBodyShape = {
|
|
26
|
+
text: z.string().min(1).max(FACT_TEXT_MAX),
|
|
27
|
+
check: z.enum(FACT_CHECKS),
|
|
28
|
+
verifiedBy: z.enum(VERIFIERS),
|
|
29
|
+
reference: commitmentReferenceJson,
|
|
30
|
+
block: pinnedBlockJson,
|
|
31
|
+
transactionHash: bytes32.nullable(),
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=facts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.js","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAA4B,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAEnF;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAU,CAAA;AAGjE;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAU,CAAA;AAGtF,wCAAwC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;AAehC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC7B,SAAS,EAAE,uBAAuB;IAClC,KAAK,EAAE,eAAe;IACtB,eAAe,EAAE,OAAO,CAAC,QAAQ,EAAE;CACpC,CAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Address } from 'viem';
|
|
2
|
+
import type { ReasonCode } from './reasons.js';
|
|
3
|
+
import { type ChainedTermsOf, type Currency, type TermsOf } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The first template, a reservation of GPU capacity for a window of time. It's the only part of
|
|
6
|
+
* the terms that knows what a GPU is. Its meaning is fixed, and a change of meaning would be
|
|
7
|
+
* `gpu-reservation/2`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GPU_RESERVATION: 'gpu-reservation/1';
|
|
10
|
+
/** The unit a GPU reservation's rate is charged per. */
|
|
11
|
+
export declare const GPU_HOUR = "gpu-hour";
|
|
12
|
+
/** What a GPU reservation promises: the capacity and the window it's held for. */
|
|
13
|
+
export interface GpuSubject {
|
|
14
|
+
resource: {
|
|
15
|
+
gpu: string;
|
|
16
|
+
count: number;
|
|
17
|
+
region: string;
|
|
18
|
+
sku: string;
|
|
19
|
+
};
|
|
20
|
+
windowStart: bigint;
|
|
21
|
+
windowDuration: bigint;
|
|
22
|
+
}
|
|
23
|
+
/** GPU reservation terms. Usage is charged per GPU-hour and paid like any other purchase. */
|
|
24
|
+
export type GpuReservationTerms = TermsOf<GpuSubject, typeof GPU_RESERVATION>;
|
|
25
|
+
/** Version 3 GPU reservation terms, for a reservation that relies on other bookings. */
|
|
26
|
+
export type ChainedGpuReservationTerms = ChainedTermsOf<GpuSubject, typeof GPU_RESERVATION>;
|
|
27
|
+
/** What a booking states, in micros and unix seconds, before the template builds its terms. */
|
|
28
|
+
export interface GpuReservationInput {
|
|
29
|
+
resource: GpuSubject['resource'];
|
|
30
|
+
currency: Currency;
|
|
31
|
+
windowStart: bigint;
|
|
32
|
+
windowDuration: bigint;
|
|
33
|
+
/** The last moment the supplier can accept, the window's start when left out. */
|
|
34
|
+
acceptBy?: bigint;
|
|
35
|
+
pricePerGpuHour: bigint;
|
|
36
|
+
freeCancelBy: bigint;
|
|
37
|
+
lateCancellation: bigint;
|
|
38
|
+
noShow: bigint;
|
|
39
|
+
/** How long after the window starts the buyer can still start before it's a no-show. */
|
|
40
|
+
gracePeriod: bigint;
|
|
41
|
+
chargeDeadline: bigint;
|
|
42
|
+
contestWindow: bigint;
|
|
43
|
+
releaseDate: bigint;
|
|
44
|
+
arbiter: Address;
|
|
45
|
+
day90SupplierShareBps: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Builds GPU reservation terms. A late cancellation can be charged from the free-cancellation
|
|
49
|
+
* deadline and a no-show once the grace period after the window's start has passed. A charge set
|
|
50
|
+
* to zero is left out, and the reserve is the largest charge.
|
|
51
|
+
*/
|
|
52
|
+
export declare function gpuReservationTerms(input: GpuReservationInput): GpuReservationTerms;
|
|
53
|
+
/**
|
|
54
|
+
* The template's own rules, which a reader checks after the core's. The resource names a GPU,
|
|
55
|
+
* a positive count, a region and a SKU, the rate is per GPU-hour and the window has a length.
|
|
56
|
+
* Free cancellation and acceptance end by the window's start, and the window ends by the charge
|
|
57
|
+
* deadline. A late cancellation is chargeable from the free-cancellation deadline, and a no-show
|
|
58
|
+
* from the window's start or later.
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateGpuReservation(t: Pick<GpuReservationTerms, 'subject' | 'consideration' | 'remedies'>): ReasonCode | null;
|
|
61
|
+
/**
|
|
62
|
+
* What's wrong with a GPU reservation's subject on its own, or null when nothing is. The resource
|
|
63
|
+
* names a GPU, a positive count, a region and a SKU, and the window's start and length are whole
|
|
64
|
+
* numbers (`terms.template_invalid`), and the window has a length (`terms.deadlines_out_of_order`).
|
|
65
|
+
* A subject of any other shape is refused here, so nothing that reads it after this throws.
|
|
66
|
+
*/
|
|
67
|
+
export declare function gpuSubjectProblem(s: GpuSubject): ReasonCode | null;
|
|
68
|
+
/**
|
|
69
|
+
* Whether a reservation fits inside a reservation it relies on. It asks for no more GPUs, of the
|
|
70
|
+
* same GPU and in the same region, and its window starts no earlier and ends no later. The SKU
|
|
71
|
+
* isn't compared, since a reseller can sell part of what it booked under its own SKU. Each pair is
|
|
72
|
+
* judged on its own, so two reservations that each fit inside the same one both pass. A subject
|
|
73
|
+
* `gpuSubjectProblem` refuses fits nowhere and holds nothing, so asking for no GPUs or for a window
|
|
74
|
+
* with no length never fits.
|
|
75
|
+
*/
|
|
76
|
+
export declare function gpuSubjectFits(inner: GpuSubject, outer: GpuSubject): boolean;
|
|
77
|
+
/** How long after the window starts a no-show becomes chargeable, or null with no such charge. */
|
|
78
|
+
export declare function gpuGracePeriod(t: GpuReservationTerms): bigint | null;
|
|
79
|
+
//# sourceMappingURL=gpu-reservation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-reservation.d.ts","sourceRoot":"","sources":["../src/gpu-reservation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,QAAQ,EAGb,KAAK,OAAO,EACb,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAG,mBAA4B,CAAA;AAE3D,wDAAwD;AACxD,eAAO,MAAM,QAAQ,aAAa,CAAA;AAElC,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACrE,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,6FAA6F;AAC7F,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,UAAU,EAAE,OAA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|
|
|
1
|
+
import { AMOUNT_DECIMALS, TERMS_VERSION, } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The first template, a reservation of GPU capacity for a window of time. It's the only part of
|
|
4
|
+
* the terms that knows what a GPU is. Its meaning is fixed, and a change of meaning would be
|
|
5
|
+
* `gpu-reservation/2`.
|
|
6
|
+
*/
|
|
7
|
+
export const GPU_RESERVATION = 'gpu-reservation/1';
|
|
8
|
+
/** The unit a GPU reservation's rate is charged per. */
|
|
9
|
+
export const GPU_HOUR = 'gpu-hour';
|
|
10
|
+
/**
|
|
11
|
+
* Builds GPU reservation terms. A late cancellation can be charged from the free-cancellation
|
|
12
|
+
* deadline and a no-show once the grace period after the window's start has passed. A charge set
|
|
13
|
+
* to zero is left out, and the reserve is the largest charge.
|
|
14
|
+
*/
|
|
15
|
+
export function gpuReservationTerms(input) {
|
|
16
|
+
const charges = [];
|
|
17
|
+
if (input.lateCancellation > 0n) {
|
|
18
|
+
charges.push({
|
|
19
|
+
kind: 'lateCancellation',
|
|
20
|
+
amount: input.lateCancellation,
|
|
21
|
+
earliest: input.freeCancelBy,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (input.noShow > 0n) {
|
|
25
|
+
charges.push({
|
|
26
|
+
kind: 'noShow',
|
|
27
|
+
amount: input.noShow,
|
|
28
|
+
earliest: input.windowStart + input.gracePeriod,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const reserve = input.lateCancellation > input.noShow ? input.lateCancellation : input.noShow;
|
|
32
|
+
return {
|
|
33
|
+
version: TERMS_VERSION,
|
|
34
|
+
template: GPU_RESERVATION,
|
|
35
|
+
currency: input.currency,
|
|
36
|
+
amountDecimals: AMOUNT_DECIMALS,
|
|
37
|
+
subject: {
|
|
38
|
+
resource: { ...input.resource },
|
|
39
|
+
windowStart: input.windowStart,
|
|
40
|
+
windowDuration: input.windowDuration,
|
|
41
|
+
},
|
|
42
|
+
consideration: { kind: 'rate', amount: input.pricePerGpuHour, unit: GPU_HOUR },
|
|
43
|
+
remedies: {
|
|
44
|
+
acceptBy: input.acceptBy ?? input.windowStart,
|
|
45
|
+
freeCancelBy: input.freeCancelBy,
|
|
46
|
+
charges,
|
|
47
|
+
chargeDeadline: input.chargeDeadline,
|
|
48
|
+
},
|
|
49
|
+
resolution: {
|
|
50
|
+
contestWindow: input.contestWindow,
|
|
51
|
+
arbiter: input.arbiter,
|
|
52
|
+
day90SupplierShareBps: input.day90SupplierShareBps,
|
|
53
|
+
},
|
|
54
|
+
backing: { kind: 'reserve', side: 'buyer', amount: reserve, releaseDate: input.releaseDate },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The template's own rules, which a reader checks after the core's. The resource names a GPU,
|
|
59
|
+
* a positive count, a region and a SKU, the rate is per GPU-hour and the window has a length.
|
|
60
|
+
* Free cancellation and acceptance end by the window's start, and the window ends by the charge
|
|
61
|
+
* deadline. A late cancellation is chargeable from the free-cancellation deadline, and a no-show
|
|
62
|
+
* from the window's start or later.
|
|
63
|
+
*/
|
|
64
|
+
export function validateGpuReservation(t) {
|
|
65
|
+
const { subject: s, remedies: r, consideration: c } = t;
|
|
66
|
+
const subject = gpuSubjectProblem(s);
|
|
67
|
+
// A wrong resource or consideration is reported before a window with no length.
|
|
68
|
+
if (subject === 'terms.template_invalid')
|
|
69
|
+
return subject;
|
|
70
|
+
if (c.kind !== 'rate' || c.unit !== GPU_HOUR)
|
|
71
|
+
return 'terms.template_invalid';
|
|
72
|
+
if (subject)
|
|
73
|
+
return subject;
|
|
74
|
+
const windowEnd = s.windowStart + s.windowDuration;
|
|
75
|
+
if (r.freeCancelBy > s.windowStart || r.acceptBy > s.windowStart) {
|
|
76
|
+
return 'terms.deadlines_out_of_order';
|
|
77
|
+
}
|
|
78
|
+
if (windowEnd > r.chargeDeadline)
|
|
79
|
+
return 'terms.deadlines_out_of_order';
|
|
80
|
+
for (const charge of r.charges) {
|
|
81
|
+
if (charge.kind === 'lateCancellation' && charge.earliest !== r.freeCancelBy) {
|
|
82
|
+
return 'terms.template_invalid';
|
|
83
|
+
}
|
|
84
|
+
if (charge.kind === 'noShow' && charge.earliest < s.windowStart) {
|
|
85
|
+
return 'terms.deadlines_out_of_order';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const isText = (v) => typeof v === 'string' && v.length > 0;
|
|
91
|
+
/**
|
|
92
|
+
* What's wrong with a GPU reservation's subject on its own, or null when nothing is. The resource
|
|
93
|
+
* names a GPU, a positive count, a region and a SKU, and the window's start and length are whole
|
|
94
|
+
* numbers (`terms.template_invalid`), and the window has a length (`terms.deadlines_out_of_order`).
|
|
95
|
+
* A subject of any other shape is refused here, so nothing that reads it after this throws.
|
|
96
|
+
*/
|
|
97
|
+
export function gpuSubjectProblem(s) {
|
|
98
|
+
const r = s?.resource;
|
|
99
|
+
if (typeof r !== 'object' || r === null)
|
|
100
|
+
return 'terms.template_invalid';
|
|
101
|
+
const { gpu, count, region, sku } = r;
|
|
102
|
+
if (!isText(gpu) || !isText(region) || !isText(sku))
|
|
103
|
+
return 'terms.template_invalid';
|
|
104
|
+
if (!Number.isSafeInteger(count) || count <= 0)
|
|
105
|
+
return 'terms.template_invalid';
|
|
106
|
+
if (typeof s.windowStart !== 'bigint' || typeof s.windowDuration !== 'bigint') {
|
|
107
|
+
return 'terms.template_invalid';
|
|
108
|
+
}
|
|
109
|
+
return s.windowDuration > 0n ? null : 'terms.deadlines_out_of_order';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether a reservation fits inside a reservation it relies on. It asks for no more GPUs, of the
|
|
113
|
+
* same GPU and in the same region, and its window starts no earlier and ends no later. The SKU
|
|
114
|
+
* isn't compared, since a reseller can sell part of what it booked under its own SKU. Each pair is
|
|
115
|
+
* judged on its own, so two reservations that each fit inside the same one both pass. A subject
|
|
116
|
+
* `gpuSubjectProblem` refuses fits nowhere and holds nothing, so asking for no GPUs or for a window
|
|
117
|
+
* with no length never fits.
|
|
118
|
+
*/
|
|
119
|
+
export function gpuSubjectFits(inner, outer) {
|
|
120
|
+
if (gpuSubjectProblem(inner) || gpuSubjectProblem(outer))
|
|
121
|
+
return false;
|
|
122
|
+
const a = inner.resource;
|
|
123
|
+
const b = outer.resource;
|
|
124
|
+
return (a.gpu === b.gpu &&
|
|
125
|
+
a.region === b.region &&
|
|
126
|
+
a.count <= b.count &&
|
|
127
|
+
inner.windowStart >= outer.windowStart &&
|
|
128
|
+
inner.windowStart + inner.windowDuration <= outer.windowStart + outer.windowDuration);
|
|
129
|
+
}
|
|
130
|
+
/** How long after the window starts a no-show becomes chargeable, or null with no such charge. */
|
|
131
|
+
export function gpuGracePeriod(t) {
|
|
132
|
+
const noShow = t.remedies.charges.find((c) => c.kind === 'noShow');
|
|
133
|
+
return noShow ? noShow.earliest - t.subject.windowStart : null;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=gpu-reservation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-reservation.js","sourceRoot":"","sources":["../src/gpu-reservation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAIf,aAAa,GAEd,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,mBAA4B,CAAA;AAE3D,wDAAwD;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAA;AAoClC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA0B;IAC5D,MAAM,OAAO,GAAmB,EAAE,CAAA;IAClC,IAAI,KAAK,CAAC,gBAAgB,GAAG,EAAE,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,KAAK,CAAC,gBAAgB;YAC9B,QAAQ,EAAE,KAAK,CAAC,YAAY;SAC7B,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,KA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