@moonbeam-foundation/sdk 0.5.2 → 0.5.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 +19 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**Assurance for AI agent work: a price, a judge and a deadline, settled against proof.**
|
|
4
4
|
|
|
5
5
|
- **What:** the SDK for Moonbeam's assurance layer on Base. It models a covered job end to end: the seller's deposit,
|
|
6
|
-
the buyer's premium, cover from a
|
|
6
|
+
the buyer's premium, cover from a pool, the verdict, and a settlement in which every ledger sums to zero.
|
|
7
7
|
- **Why:** agent escrow refunds the price of a failed job, never the cost of the failure, and the judge has no capital
|
|
8
8
|
behind its verdict. Moonbeam adds the deposit, the pool and a grader (Jev by TypeSafe).
|
|
9
9
|
- **How:** `npm install @moonbeam-foundation/sdk`, then replay Moonbeam's first covered hire on Base, offline, in a few seconds:
|
|
@@ -14,9 +14,8 @@ npx moonbeam demo
|
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> Building on Moonbeam and want early access? Write to [builders@moonbeam.foundation](mailto:builders@moonbeam.foundation).
|
|
17
|
+
Moonbeam ACP is in a pilot on Base with selected partners. For early access, write to
|
|
18
|
+
[builders@moonbeam.foundation](mailto:builders@moonbeam.foundation).
|
|
20
19
|
|
|
21
20
|
## Install
|
|
22
21
|
|
|
@@ -42,16 +41,16 @@ behind its verdict. This SDK models the layer that closes both gaps.
|
|
|
42
41
|
```ts
|
|
43
42
|
import { settle, parseUnits } from '@moonbeam-foundation/sdk';
|
|
44
43
|
|
|
45
|
-
const
|
|
44
|
+
const units = (v: string) => parseUnits(v); // amounts in the token's smallest units
|
|
46
45
|
|
|
47
46
|
const { ledger, locked } = settle({
|
|
48
47
|
terms: {
|
|
49
|
-
pay:
|
|
50
|
-
premium:
|
|
51
|
-
deposit:
|
|
52
|
-
evaluatorBond:
|
|
53
|
-
poolCapital:
|
|
54
|
-
damage:
|
|
48
|
+
pay: units('100'), // what the client pays for the work
|
|
49
|
+
premium: units('1'), // what it pays for cover
|
|
50
|
+
deposit: units('120'), // the provider's bond, sized above the job
|
|
51
|
+
evaluatorBond: units('25'), // the judge's bond
|
|
52
|
+
poolCapital: units('5000'), // backers standing behind the provider
|
|
53
|
+
damage: units('70'), // consequential loss if the work is bad
|
|
55
54
|
},
|
|
56
55
|
verdict: 'cheated',
|
|
57
56
|
});
|
|
@@ -227,7 +226,7 @@ immediately, rather than producing a transaction addressed to nothing.
|
|
|
227
226
|
|
|
228
227
|
## Judging a job on the Base hook
|
|
229
228
|
|
|
230
|
-
`@moonbeam-foundation/sdk/judge` grades a
|
|
229
|
+
`@moonbeam-foundation/sdk/judge` grades a job on Moonbeam's assurance hook on Base
|
|
231
230
|
(`0xc0578657Eda85e0a246771aa1839ce79b54eE80d`) and builds the call that ends it. The grade works like this:
|
|
232
231
|
|
|
233
232
|
- Code checks the facts first. A failed check rejects the job, and the model is never asked.
|
|
@@ -251,7 +250,7 @@ const check = await verifyGrade(receipt, { chain: false });
|
|
|
251
250
|
|
|
252
251
|
`endJob` is signed by the job's buyer or by an evaluator the hook registered. For needs_review it returns `null`: the
|
|
253
252
|
job stays held until one of those parties decides, or until anyone calls `expire` after the deadline. The tests
|
|
254
|
-
re-encode the hook's `complete` from the covered
|
|
253
|
+
re-encode the hook's `complete` from the covered hire on Base,
|
|
255
254
|
[`0xc606d00f…3116`](https://basescan.org/tx/0xc606d00fed64e912585bbc93feb15a9289cfcde94289f49f7c74a7a468903116),
|
|
256
255
|
byte for byte.
|
|
257
256
|
|
|
@@ -327,20 +326,20 @@ import { runSeason, breakEvenFailureRate, clearingFeeIsCoherent } from '@moonbea
|
|
|
327
326
|
// the damage leaves the pool at zero, which is the intended steady state.
|
|
328
327
|
runSeason({
|
|
329
328
|
jobs: 5_000,
|
|
330
|
-
premiumPerJob:
|
|
329
|
+
premiumPerJob: units('1'),
|
|
331
330
|
failureRate: 0.006,
|
|
332
|
-
damagePerFailure:
|
|
333
|
-
depositPerJob:
|
|
331
|
+
damagePerFailure: units('70'),
|
|
332
|
+
depositPerJob: units('40'),
|
|
334
333
|
});
|
|
335
334
|
// → premium 4_970, absorbed by deposits 1_200, paid by pool 900, net +4_070
|
|
336
335
|
|
|
337
|
-
breakEvenFailureRate(
|
|
338
|
-
clearingFeeIsCoherent(34,
|
|
336
|
+
breakEvenFailureRate(units('1'), units('70'), units('40')); // ≈ 0.032
|
|
337
|
+
clearingFeeIsCoherent(34, units('1'), units('70'), units('40')); // false
|
|
339
338
|
|
|
340
339
|
// Raise the bond above the damage and the residual disappears:
|
|
341
|
-
runSeason({ /* …as above… */ depositPerJob:
|
|
340
|
+
runSeason({ /* …as above… */ depositPerJob: units('120') });
|
|
342
341
|
// → premium 4_970, absorbed by deposits 2_100, paid by pool 0, net +4_970
|
|
343
|
-
breakEvenFailureRate(
|
|
342
|
+
breakEvenFailureRate(units('1'), units('70'), units('120')); // null — no rate breaks it
|
|
344
343
|
```
|
|
345
344
|
|
|
346
345
|
That last call is the useful one. A published clearing fee is a claim about the
|
package/package.json
CHANGED