@shippedcalls/sdk 0.5.0 → 0.6.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/README.md +32 -2
- package/dist/client.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +54 -7
- package/dist/jobs.js +110 -24
- package/dist/jobs.js.map +1 -1
- package/package.json +1 -1
- package/skill/references/jobs.md +1 -1
- package/skill/scripts/calls.sh +1 -1
- package/src/index.ts +1 -1
- package/src/jobs.ts +109 -22
package/README.md
CHANGED
|
@@ -135,9 +135,39 @@ await worker.jobs.evidence(id, "https://example.com/report");
|
|
|
135
135
|
await worker.jobs.collect();
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
The worker writes every term, so `fund` compares the job with what the client agreed and sends nothing if they differ. It refuses a reviewer the client didn't name, a job that pays the worker on silence, one an on-chain check can release, and a refund to anyone but the client. `check` runs the same comparison and spends nothing.
|
|
138
|
+
The worker writes every term, so `fund` compares the job with what the client agreed and sends nothing if they differ. It refuses a reviewer the client didn't name, a job that pays the worker on silence beyond what the client agreed to, one an on-chain check can release, and a refund to anyone but the client. `check` runs the same comparison and spends nothing.
|
|
139
139
|
|
|
140
|
-
The worker can lock its own money with `workerBond
|
|
140
|
+
The worker can lock its own money with `workerBond`. It comes back on acceptance and goes to the client on a rejection or if the worker gives up. By default the bond is locked when the job opens, the client funds the amount once it sees the bond in, and a reviewer who stays silent returns everything to the client.
|
|
141
|
+
|
|
142
|
+
Two options change that. The worker sets them when it opens the job, and the client accepts each by setting the same flag in its agreement:
|
|
143
|
+
|
|
144
|
+
- `bondAfterFunding`: the job opens with nothing locked. The client funds the amount alone, and the job reads `awaiting_bond` until the worker posts its bond with `postBond(id)`. The client's agreement names the bond in `minWorkerBond`, and the job has to name exactly that bond: `check` and `fund` refuse it otherwise (`bond_not_agreed`).
|
|
145
|
+
- `silenceReturnsBond`: a reviewer who stays silent past the window returns the amount to the client and the bond to the worker, less Shipped's fee on the bond. The registry rounds the worker's share down, so with the bond in, the client gets its whole amount back. `silenceSplit(amount, bond)` gives the split the job carries.
|
|
146
|
+
|
|
147
|
+
On a job whose bond follows the funding, the split applies from the moment the client funds: until the worker posts its bond, a job that settles at the default split pays the worker `silenceSplit(amount, bond)` basis points of the client's amount. The client is covered by the worker posting its bond or giving the job up, and by naming a reviewer who rules.
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const { id } = await worker.jobs.open({
|
|
151
|
+
title: "Weekly gas report",
|
|
152
|
+
brief: "A one-page report on median gas for the week, at a public link.",
|
|
153
|
+
client: "0xClient…",
|
|
154
|
+
amount: usdgToUnits("25"),
|
|
155
|
+
deadline: Math.floor(Date.now() / 1000) + 7 * 86_400,
|
|
156
|
+
reviewer: "council",
|
|
157
|
+
workerBond: usdgToUnits("2.5"),
|
|
158
|
+
bondAfterFunding: true,
|
|
159
|
+
silenceReturnsBond: true,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const agreement = { amount: usdgToUnits("25"), reviewers: ["council"], worker: worker.address, minWorkerBond: usdgToUnits("2.5"), bondAfterFunding: true, silenceReturnsBond: true };
|
|
163
|
+
await client.jobs.fund(id, agreement); // locks the 25 USDG alone
|
|
164
|
+
|
|
165
|
+
await worker.jobs.postBond(id); // locks the 2.5 USDG bond; the job is now in progress
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`postBond` sends nothing for a job the wallet did not open, one that is no longer open or names no bond, one the client has not funded yet, or one that already holds the bond, nor while it is already posting that bond or the wallet has a transaction pending (`bond_pending`). After a lost receipt, read the job with `get` before posting again. If a funding fails after its approval, `fund` and `postBond` set the approval back to zero. The registry's ABI ships as `deedsAbi`, so a worker can follow a job's `Funded` events.
|
|
169
|
+
|
|
170
|
+
A reviewer's fee comes out of the job, up to a tenth of it. The AI council charges at least 0.25 USDG, so a job it reviews holds at least 2.50 USDG. Shipped's fee is 1% of what the worker receives, and nothing on a refund. One call locks at most 25 USDG unless `maxJobFund` raises it.
|
|
141
171
|
|
|
142
172
|
## What a write does before it sends
|
|
143
173
|
|
package/dist/client.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
57
57
|
}) => Promise<import("./jobs.js").JobTx & {
|
|
58
58
|
amount: string;
|
|
59
59
|
}>;
|
|
60
|
+
postBond: (jobId: unknown, { maxFund: limit }?: {
|
|
61
|
+
maxFund?: bigint;
|
|
62
|
+
}) => Promise<import("./jobs.js").JobTx & {
|
|
63
|
+
amount: string;
|
|
64
|
+
}>;
|
|
60
65
|
evidence: (jobId: unknown, uri: string, contentHash?: Hash) => Promise<import("./jobs.js").JobTx>;
|
|
61
66
|
accept: (jobId: unknown, reason?: string) => Promise<import("./jobs.js").JobTx>;
|
|
62
67
|
reject: (jobId: unknown, reason: string) => Promise<import("./jobs.js").JobTx>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { CallsError, RECEIPT_UNKNOWN } from "./errors.js";
|
|
|
7
7
|
export { callTextHash, canonicalPostUrl, normalizeHandle, parsePostUrl, postRefHash, specHash, subjectHash, ZERO_HASH } from "./hashes.js";
|
|
8
8
|
export { DISPUTE_WINDOW, MIN_BET, MIN_OPENER_BOND, PRICE_DISPUTE_WINDOW, RAKE_BPS, ethToWei, multipleOf, odds, payout, quoteOf, roundInPlay, roundPayout, type Pools, type Side } from "./odds.js";
|
|
9
9
|
export type * from "./types.js";
|
|
10
|
-
export { bondNumberOf, checkJob, COUNCIL_MIN_FEE, DEFAULT_MAX_JOB_FUND, DEFAULT_REVIEW_WINDOW, jobMilestone, jobStateOf, jobTerms, readJobTag, usdgToUnits, type ChainDeed, type Job, type JobAgreement, type JobProblem, type JobsClient, type JobState, type JobTerms, type JobTx, type OpenJobInput } from "./jobs.js";
|
|
10
|
+
export { bondNumberOf, checkJob, COUNCIL_MIN_FEE, deedsAbi, DEFAULT_MAX_JOB_FUND, DEFAULT_REVIEW_WINDOW, jobMilestone, jobStateOf, jobTerms, readJobTag, silenceSplit, usdgToUnits, type ChainDeed, type Job, type JobAgreement, type JobProblem, type JobsClient, type JobState, type JobTerms, type JobTx, type OpenJobInput } from "./jobs.js";
|
package/dist/index.js
CHANGED
|
@@ -6,5 +6,5 @@ export { canonical, hashJson } from "./canonical.js";
|
|
|
6
6
|
export { CallsError, RECEIPT_UNKNOWN } from "./errors.js";
|
|
7
7
|
export { callTextHash, canonicalPostUrl, normalizeHandle, parsePostUrl, postRefHash, specHash, subjectHash, ZERO_HASH } from "./hashes.js";
|
|
8
8
|
export { DISPUTE_WINDOW, MIN_BET, MIN_OPENER_BOND, PRICE_DISPUTE_WINDOW, RAKE_BPS, ethToWei, multipleOf, odds, payout, quoteOf, roundInPlay, roundPayout } from "./odds.js";
|
|
9
|
-
export { bondNumberOf, checkJob, COUNCIL_MIN_FEE, DEFAULT_MAX_JOB_FUND, DEFAULT_REVIEW_WINDOW, jobMilestone, jobStateOf, jobTerms, readJobTag, usdgToUnits } from "./jobs.js";
|
|
9
|
+
export { bondNumberOf, checkJob, COUNCIL_MIN_FEE, deedsAbi, DEFAULT_MAX_JOB_FUND, DEFAULT_REVIEW_WINDOW, jobMilestone, jobStateOf, jobTerms, readJobTag, silenceSplit, usdgToUnits } from "./jobs.js";
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAClL,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,Q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only type: "event";
|
|
346
|
+
readonly inputs: readonly [{
|
|
347
|
+
readonly type: "uint256";
|
|
348
|
+
readonly name: "deedId";
|
|
349
|
+
readonly indexed: true;
|
|
350
|
+
}, {
|
|
351
|
+
readonly type: "address";
|
|
352
|
+
readonly name: "from";
|
|
353
|
+
readonly indexed: true;
|
|
354
|
+
}, {
|
|
355
|
+
readonly type: "uint256";
|
|
356
|
+
readonly name: "amount";
|
|
357
|
+
}, {
|
|
358
|
+
readonly type: "uint256";
|
|
359
|
+
readonly name: "balance";
|
|
360
|
+
}];
|
|
343
361
|
}, {
|
|
344
362
|
readonly name: "AssetNotAllowed";
|
|
345
363
|
readonly type: "error";
|
|
@@ -466,8 +484,12 @@ export interface OpenJobInput {
|
|
|
466
484
|
reviewWindow?: number;
|
|
467
485
|
/** Paid to the reviewer from the job when its ruling stands, USDG units. 0.25 USDG at least for the council. */
|
|
468
486
|
reviewerFee?: bigint;
|
|
469
|
-
/** What the worker locks on its own side. It is lost to the client if the job
|
|
487
|
+
/** What the worker locks on its own side. It is lost to the client if the job is rejected or the worker gives up. */
|
|
470
488
|
workerBond?: bigint;
|
|
489
|
+
/** Opens with nothing locked; the worker posts `workerBond` with `postBond` once the client has funded the amount. */
|
|
490
|
+
bondAfterFunding?: boolean;
|
|
491
|
+
/** A silent reviewer returns the amount to the client and the bond to the worker, less Shipped's fee on the bond. */
|
|
492
|
+
silenceReturnsBond?: boolean;
|
|
471
493
|
}
|
|
472
494
|
/** What the client agreed to, for `check` and `fund` to compare against what the worker actually opened. */
|
|
473
495
|
export interface JobAgreement {
|
|
@@ -481,14 +503,23 @@ export interface JobAgreement {
|
|
|
481
503
|
notAfter?: number;
|
|
482
504
|
/** The largest reviewer fee the client accepts, USDG units. A tenth of the amount by default. */
|
|
483
505
|
maxReviewerFee?: bigint;
|
|
484
|
-
/** The least the worker must have locked, USDG units. */
|
|
506
|
+
/** The least the worker must have locked, USDG units. With `bondAfterFunding`, exactly the bond the job must name. */
|
|
485
507
|
minWorkerBond?: bigint;
|
|
508
|
+
/**
|
|
509
|
+
* You fund the amount alone, and the worker's bond follows it. Name the bond in `minWorkerBond` as well: without it
|
|
510
|
+
* `check` and `fund` refuse the job (`bond_not_agreed`), since the job's own bond would set what silence leaves the
|
|
511
|
+
* worker. The type does not require it, so that code written for 0.5.0 against this interface still compiles.
|
|
512
|
+
*/
|
|
513
|
+
bondAfterFunding?: boolean;
|
|
514
|
+
/** A silent reviewer may return the worker's bond to it: the job may pay the worker the bond's share of the escrow. */
|
|
515
|
+
silenceReturnsBond?: boolean;
|
|
486
516
|
}
|
|
487
517
|
export interface JobProblem {
|
|
488
518
|
code: string;
|
|
489
519
|
message: string;
|
|
490
520
|
}
|
|
491
|
-
|
|
521
|
+
/** `awaiting_bond`: the job holds the client's amount and not yet the worker's bond. */
|
|
522
|
+
export type JobState = "awaiting_funds" | "awaiting_bond" | "in_progress" | "in_review" | "refundable" | "ruled" | "paid" | "partly_paid" | "refunded";
|
|
492
523
|
export interface Job {
|
|
493
524
|
id: string;
|
|
494
525
|
number: number;
|
|
@@ -505,7 +536,7 @@ export interface Job {
|
|
|
505
536
|
escrow: string;
|
|
506
537
|
funded: boolean;
|
|
507
538
|
deadline: number;
|
|
508
|
-
/** When anyone can
|
|
539
|
+
/** When anyone can settle the job at its default split if the reviewer has stayed silent. */
|
|
509
540
|
refundableAt: number;
|
|
510
541
|
state: JobState;
|
|
511
542
|
}
|
|
@@ -522,6 +553,13 @@ export declare function readJobTag(milestone: string): {
|
|
|
522
553
|
amount: bigint;
|
|
523
554
|
bond: bigint;
|
|
524
555
|
} | null;
|
|
556
|
+
/**
|
|
557
|
+
* The default split, in basis points of the escrow, under which a silent reviewer returns the amount to the client and
|
|
558
|
+
* the bond to the worker. The registry rounds the worker's share down, so this is the largest split whose share is at
|
|
559
|
+
* most the bond: the client always gets its whole amount back, and the worker its bond less at most 0.01% of the
|
|
560
|
+
* escrow, which goes to the client.
|
|
561
|
+
*/
|
|
562
|
+
export declare function silenceSplit(amount: bigint, bond: bigint): number;
|
|
525
563
|
/** The registry's bond number on Shipped's site. */
|
|
526
564
|
export declare const bondNumberOf: (id: bigint | number, chainId?: number) => number;
|
|
527
565
|
/** The terms a job opens with. Refuses anything the registry would, before anything is sent. */
|
|
@@ -553,7 +591,7 @@ export interface JobsDeps {
|
|
|
553
591
|
export declare function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFund, registry }: JobsDeps): {
|
|
554
592
|
/** One job as the chain has it. */
|
|
555
593
|
get: (jobId: unknown) => Promise<Job>;
|
|
556
|
-
/** Worker: opens the job
|
|
594
|
+
/** Worker: opens the job, locking its bond now unless `bondAfterFunding`. Hand the id to the client to fund. */
|
|
557
595
|
open: (input: OpenJobInput, { maxFund: limit }?: {
|
|
558
596
|
maxFund?: bigint;
|
|
559
597
|
}) => Promise<JobTx>;
|
|
@@ -562,12 +600,18 @@ export declare function createJobs({ reads, chainId, send, guarded, wallet, toTx
|
|
|
562
600
|
ok: boolean;
|
|
563
601
|
problems: JobProblem[];
|
|
564
602
|
}>;
|
|
565
|
-
/** Client: locks the agreed amount, and only if the job passes `check`. */
|
|
603
|
+
/** Client: locks the agreed amount, and only if the job passes `check`. With `bondAfterFunding`, the amount alone. */
|
|
566
604
|
fund: (jobId: unknown, agreement: JobAgreement, { maxFund: limit }?: {
|
|
567
605
|
maxFund?: bigint;
|
|
568
606
|
}) => Promise<JobTx & {
|
|
569
607
|
amount: string;
|
|
570
608
|
}>;
|
|
609
|
+
/** Worker: locks the bond the job names, once the job holds the client's amount and not yet the bond. */
|
|
610
|
+
postBond: (jobId: unknown, { maxFund: limit }?: {
|
|
611
|
+
maxFund?: bigint;
|
|
612
|
+
}) => Promise<JobTx & {
|
|
613
|
+
amount: string;
|
|
614
|
+
}>;
|
|
571
615
|
/** Worker or reviewer: points at what was delivered. */
|
|
572
616
|
evidence: (jobId: unknown, uri: string, contentHash?: Hash) => Promise<JobTx>;
|
|
573
617
|
/** Reviewer: the work was delivered. Pays the worker at once. */
|
|
@@ -576,7 +620,10 @@ export declare function createJobs({ reads, chainId, send, guarded, wallet, toTx
|
|
|
576
620
|
reject: (jobId: unknown, reason: string) => Promise<JobTx>;
|
|
577
621
|
/** Worker: gives up. The client gets everything the job holds, at once. */
|
|
578
622
|
concede: (jobId: unknown, reason: string) => Promise<JobTx>;
|
|
579
|
-
/**
|
|
623
|
+
/**
|
|
624
|
+
* Anyone: the reviewer stayed silent past its window, so the job settles at its default split. The client gets
|
|
625
|
+
* everything, or with `silenceReturnsBond` the amount while the worker gets its bond back.
|
|
626
|
+
*/
|
|
580
627
|
refund: (jobId: unknown) => Promise<JobTx>;
|
|
581
628
|
/** What a wallet can collect in USDG across settled jobs and bonds. */
|
|
582
629
|
owed: (address?: string) => Promise<string>;
|
package/dist/jobs.js
CHANGED
|
@@ -4,7 +4,8 @@ import { CallsError, RECEIPT_UNKNOWN } from "./errors.js";
|
|
|
4
4
|
// A job is a Shipped bond the worker opens and the client funds. The bond's paid side belongs to whoever opens it, so
|
|
5
5
|
// the worker has to; the milestone carries a tag with the agreed amount, so anyone can tell a job from a bond and see
|
|
6
6
|
// what it is meant to hold. The worker writes every term, which is why `check` exists and `fund` refuses to pay into
|
|
7
|
-
// anything it fails.
|
|
7
|
+
// anything it fails. A worker's bond is locked when the job opens, or with `bondAfterFunding` after the client has
|
|
8
|
+
// funded the amount, through `postBond`.
|
|
8
9
|
export const USDG_DECIMALS = 6;
|
|
9
10
|
export const MAX_TITLE = 96;
|
|
10
11
|
export const MAX_MILESTONE = 2_048;
|
|
@@ -20,6 +21,7 @@ export const MAX_REVIEWER_SHARE_DIVISOR = 10n;
|
|
|
20
21
|
export const DEFAULT_MAX_JOB_FUND = 25000000n;
|
|
21
22
|
const LEAD_SLACK = 60;
|
|
22
23
|
const BPS = 10_000;
|
|
24
|
+
const BPS_UNITS = 10000n;
|
|
23
25
|
const STATUS_OPEN = 1;
|
|
24
26
|
const STATUS_SETTLED = 4;
|
|
25
27
|
const ERC721_TRANSFER = toEventSelector("Transfer(address,address,uint256)");
|
|
@@ -37,6 +39,7 @@ export const deedsAbi = parseAbi([
|
|
|
37
39
|
"function getDeed(uint256 deedId) view returns (Deed)",
|
|
38
40
|
"function owed(address account, address asset) view returns (uint256)",
|
|
39
41
|
"function timeline(uint256 deedId) view returns (uint64 deadline, uint64 verifierEnd, uint64 backupEnd, uint64 defaultAt, uint64 appealEnd, uint64 panelEnd)",
|
|
42
|
+
"event Funded(uint256 indexed deedId, address indexed from, uint256 amount, uint256 balance)",
|
|
40
43
|
"error AssetNotAllowed()",
|
|
41
44
|
"error CreationIsPaused()",
|
|
42
45
|
"error InvalidDeadline()",
|
|
@@ -86,6 +89,18 @@ export function readJobTag(milestone) {
|
|
|
86
89
|
return null;
|
|
87
90
|
return { brief: milestone.slice(0, match.index), amount: BigInt(match[1]), bond: BigInt(match[2]) };
|
|
88
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The default split, in basis points of the escrow, under which a silent reviewer returns the amount to the client and
|
|
94
|
+
* the bond to the worker. The registry rounds the worker's share down, so this is the largest split whose share is at
|
|
95
|
+
* most the bond: the client always gets its whole amount back, and the worker its bond less at most 0.01% of the
|
|
96
|
+
* escrow, which goes to the client.
|
|
97
|
+
*/
|
|
98
|
+
export function silenceSplit(amount, bond) {
|
|
99
|
+
if (bond <= 0n || amount < 0n)
|
|
100
|
+
return 0;
|
|
101
|
+
const bps = (BPS_UNITS * (bond + 1n) - 1n) / (amount + bond);
|
|
102
|
+
return Number(bps < BPS_UNITS ? bps : BPS_UNITS);
|
|
103
|
+
}
|
|
89
104
|
/** The registry's bond number on Shipped's site. */
|
|
90
105
|
export const bondNumberOf = (id, chainId = CHAIN_ID) => Number(id) - (chainId === CHAIN_ID ? 1 : 0);
|
|
91
106
|
/** The terms a job opens with. Refuses anything the registry would, before anything is sent. */
|
|
@@ -137,7 +152,7 @@ export function jobTerms(input, { worker, now }) {
|
|
|
137
152
|
check: zeroAddress,
|
|
138
153
|
checkData: "0x",
|
|
139
154
|
refundTo: client,
|
|
140
|
-
defaultRemainderBps: 0,
|
|
155
|
+
defaultRemainderBps: input.silenceReturnsBond ? silenceSplit(input.amount, bond) : 0,
|
|
141
156
|
refundCapBps: 0,
|
|
142
157
|
allowPartial: false,
|
|
143
158
|
verifierGrace: reviewWindow,
|
|
@@ -173,8 +188,10 @@ export function checkJob(deed, agreement, { client, now }) {
|
|
|
173
188
|
add("refund_elsewhere", `A failed job pays ${t.refundTo}, not you.`);
|
|
174
189
|
if (agreement.worker && !same(deed.creator, addressOf(agreement.worker, "worker")))
|
|
175
190
|
add("wrong_worker", `The job was opened by ${deed.creator}, not the worker you agreed with.`);
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
// The split is a share of whatever the job holds, so it is bounded by the bond the client agreed to, not the tag's.
|
|
192
|
+
const silence = agreement.silenceReturnsBond ? silenceSplit(tag.amount, agreement.minWorkerBond ?? tag.bond) : 0;
|
|
193
|
+
if (t.defaultRemainderBps > silence)
|
|
194
|
+
add("pays_on_silence", agreement.silenceReturnsBond ? "The job pays the worker more than its bond if the reviewer stays silent." : "The job pays the worker if the reviewer stays silent. It has to refund you.");
|
|
178
195
|
if (t.check !== zeroAddress)
|
|
179
196
|
add("has_check", "The job can be released by an on-chain check instead of the reviewer.");
|
|
180
197
|
if (t.allowPartial)
|
|
@@ -184,12 +201,22 @@ export function checkJob(deed, agreement, { client, now }) {
|
|
|
184
201
|
if (tag.amount !== agreement.amount)
|
|
185
202
|
add("wrong_amount", `The job asks for ${usdg(tag.amount)}, not the ${usdg(agreement.amount)} you agreed.`);
|
|
186
203
|
const minBond = agreement.minWorkerBond ?? 0n;
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
204
|
+
if (agreement.bondAfterFunding) {
|
|
205
|
+
// Nothing is locked until the client funds, so the job names exactly the agreed bond: a bigger one would raise the
|
|
206
|
+
// share of the amount a silent reviewer leaves the worker should the bond never come. The agreement has to name it.
|
|
207
|
+
if (agreement.minWorkerBond === undefined)
|
|
208
|
+
add("bond_not_agreed", "Name the bond you agreed in minWorkerBond: with the bond to follow, the job's own bond would set what silence leaves the worker.");
|
|
209
|
+
else if (tag.bond !== agreement.minWorkerBond)
|
|
210
|
+
add("bond_not_agreed", `The job names a bond of ${usdg(tag.bond)}, not the ${usdg(agreement.minWorkerBond)} agreed.`);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
if (tag.bond < minBond)
|
|
214
|
+
add("bond_too_small", `The worker's bond is ${usdg(tag.bond)}, under the ${usdg(minBond)} you asked for.`);
|
|
215
|
+
if (deed.balance < tag.bond)
|
|
216
|
+
add("bond_missing", "The worker has not locked the bond the job names.");
|
|
217
|
+
if (deed.balance >= tag.amount + tag.bond)
|
|
218
|
+
add("already_funded", "This job already holds its full amount.");
|
|
219
|
+
}
|
|
193
220
|
const maxFee = agreement.maxReviewerFee ?? agreement.amount / MAX_REVIEWER_SHARE_DIVISOR;
|
|
194
221
|
if (t.verifierFee > maxFee)
|
|
195
222
|
add("fee_too_high", `The reviewer's fee is ${usdg(t.verifierFee)}, over the ${usdg(maxFee)} you accept.`);
|
|
@@ -198,6 +225,9 @@ export function checkJob(deed, agreement, { client, now }) {
|
|
|
198
225
|
add("deadline_too_soon", "The deadline is too close for the work to be done.");
|
|
199
226
|
if (agreement.notAfter != null && deadline > agreement.notAfter)
|
|
200
227
|
add("deadline_too_late", "The deadline is later than you agreed.");
|
|
228
|
+
// Last, so a job that both holds its amount and differs from the agreement is reported for the difference first.
|
|
229
|
+
if (agreement.bondAfterFunding && deed.balance >= tag.amount)
|
|
230
|
+
add("already_funded", "This job already holds its amount.");
|
|
201
231
|
return problems;
|
|
202
232
|
}
|
|
203
233
|
export function jobStateOf(deed, refundableAt, now) {
|
|
@@ -209,7 +239,7 @@ export function jobStateOf(deed, refundableAt, now) {
|
|
|
209
239
|
if (now > refundableAt)
|
|
210
240
|
return "refundable";
|
|
211
241
|
if (tag && deed.balance < tag.amount + tag.bond)
|
|
212
|
-
return "awaiting_funds";
|
|
242
|
+
return deed.balance >= tag.amount ? "awaiting_bond" : "awaiting_funds";
|
|
213
243
|
return now <= Number(deed.terms.deadline) ? "in_progress" : "in_review";
|
|
214
244
|
}
|
|
215
245
|
const idOf = (value) => {
|
|
@@ -236,13 +266,19 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
236
266
|
]);
|
|
237
267
|
if (balance < amount)
|
|
238
268
|
throw new CallsError(`This wallet holds ${usdg(balance)}, and this needs ${usdg(amount)}.`, "insufficient_usdg");
|
|
239
|
-
if (allowance
|
|
240
|
-
|
|
269
|
+
if (allowance >= amount)
|
|
270
|
+
return false;
|
|
271
|
+
await send({ address: USDG, abi: erc20Abi, functionName: "approve", args: [registry, amount] });
|
|
272
|
+
return true;
|
|
241
273
|
}
|
|
242
274
|
const cap = (amount, limit) => {
|
|
243
275
|
if (amount > limit)
|
|
244
276
|
throw new CallsError(`This would lock ${usdg(amount)}, over the ${usdg(limit)} limit. Raise maxFund only on your operator's word.`, "over_cap");
|
|
245
277
|
};
|
|
278
|
+
/** The allowance a write gave is not left standing for money that did not go in. */
|
|
279
|
+
const unapprove = () => send({ address: USDG, abi: erc20Abi, functionName: "approve", args: [registry, 0n] }).catch(() => { });
|
|
280
|
+
/** Jobs whose bond this client is posting now. */
|
|
281
|
+
const posting = new Set();
|
|
246
282
|
return {
|
|
247
283
|
/** One job as the chain has it. */
|
|
248
284
|
get: (jobId) => guarded(async () => {
|
|
@@ -274,15 +310,15 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
274
310
|
state: jobStateOf(deed, refundableAt, now),
|
|
275
311
|
};
|
|
276
312
|
}),
|
|
277
|
-
/** Worker: opens the job
|
|
313
|
+
/** Worker: opens the job, locking its bond now unless `bondAfterFunding`. Hand the id to the client to fund. */
|
|
278
314
|
open: (input, { maxFund: limit = maxFund } = {}) => guarded(async () => {
|
|
279
315
|
const worker = wallet().address;
|
|
280
316
|
const terms = jobTerms(input, { worker, now: await timeOnChain() });
|
|
281
|
-
const
|
|
282
|
-
cap(
|
|
283
|
-
if (
|
|
284
|
-
await approveUpTo(
|
|
285
|
-
const receipt = await write("create", [terms,
|
|
317
|
+
const deposit = input.bondAfterFunding ? 0n : (input.workerBond ?? 0n);
|
|
318
|
+
cap(deposit, limit);
|
|
319
|
+
if (deposit > 0n)
|
|
320
|
+
await approveUpTo(deposit);
|
|
321
|
+
const receipt = await write("create", [terms, deposit]);
|
|
286
322
|
// The registry mints the paid side as token id * 2, from the zero address, in the same transaction.
|
|
287
323
|
const minted = receipt.logs.find((log) => same(log.address, registry) && log.topics[0] === ERC721_TRANSFER && BigInt(log.topics[1] ?? 1) === 0n);
|
|
288
324
|
if (!minted?.topics[3])
|
|
@@ -296,7 +332,7 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
296
332
|
const problems = checkJob(deed, agreement, { client, now });
|
|
297
333
|
return { ok: problems.length === 0, problems };
|
|
298
334
|
}),
|
|
299
|
-
/** Client: locks the agreed amount, and only if the job passes `check`. */
|
|
335
|
+
/** Client: locks the agreed amount, and only if the job passes `check`. With `bondAfterFunding`, the amount alone. */
|
|
300
336
|
fund: (jobId, agreement, { maxFund: limit = maxFund } = {}) => guarded(async () => {
|
|
301
337
|
const id = idOf(jobId);
|
|
302
338
|
const client = wallet().address;
|
|
@@ -304,10 +340,57 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
304
340
|
const problems = checkJob(deed, { ...agreement, client }, { client, now });
|
|
305
341
|
if (problems.length > 0)
|
|
306
342
|
throw new CallsError(`Not funded. ${problems.map((p) => p.message).join(" ")}`, problems[0].code);
|
|
307
|
-
const amount = tag.amount + tag.bond - deed.balance;
|
|
343
|
+
const amount = agreement.bondAfterFunding ? tag.amount : tag.amount + tag.bond - deed.balance;
|
|
308
344
|
cap(amount, limit);
|
|
309
|
-
await approveUpTo(amount);
|
|
310
|
-
|
|
345
|
+
const approved = await approveUpTo(amount);
|
|
346
|
+
try {
|
|
347
|
+
return { id: id.toString(), amount: amount.toString(), tx: toTx(await write("fund", [id, amount])) };
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
if (approved)
|
|
351
|
+
await unapprove();
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
}),
|
|
355
|
+
/** Worker: locks the bond the job names, once the job holds the client's amount and not yet the bond. */
|
|
356
|
+
postBond: (jobId, { maxFund: limit = maxFund } = {}) => guarded(async () => {
|
|
357
|
+
const id = idOf(jobId);
|
|
358
|
+
const key = id.toString();
|
|
359
|
+
// One post per job: a second while the first is under way, or while a transaction of this wallet is still
|
|
360
|
+
// pending, could lock the bond twice.
|
|
361
|
+
if (posting.has(key))
|
|
362
|
+
throw new CallsError("This wallet is already posting this job's bond. Read the job before posting it again.", "bond_pending");
|
|
363
|
+
posting.add(key);
|
|
364
|
+
try {
|
|
365
|
+
const { deed, tag } = await jobAt(id);
|
|
366
|
+
const owner = wallet().address;
|
|
367
|
+
if (!same(deed.creator, owner))
|
|
368
|
+
throw new CallsError("Only the worker who opened the job posts its bond.", "not_worker");
|
|
369
|
+
if (deed.status !== STATUS_OPEN)
|
|
370
|
+
throw new CallsError("This job is no longer open.", "not_open");
|
|
371
|
+
if (tag.bond === 0n)
|
|
372
|
+
throw new CallsError("This job names no bond.", "no_bond");
|
|
373
|
+
if (deed.balance < tag.amount)
|
|
374
|
+
throw new CallsError("The client has not funded the job's amount yet. Post the bond once it has.", "not_funded");
|
|
375
|
+
if (deed.balance >= tag.amount + tag.bond)
|
|
376
|
+
throw new CallsError("This job already holds its amount and the bond.", "already_funded");
|
|
377
|
+
const [mined, pending] = await Promise.all([reads.getTransactionCount({ address: owner, blockTag: "latest" }), reads.getTransactionCount({ address: owner, blockTag: "pending" })]);
|
|
378
|
+
if (pending > mined)
|
|
379
|
+
throw new CallsError("This wallet has a transaction still pending. Once it lands, read the job before posting the bond again.", "bond_pending");
|
|
380
|
+
cap(tag.bond, limit);
|
|
381
|
+
const approved = await approveUpTo(tag.bond);
|
|
382
|
+
try {
|
|
383
|
+
return { id: key, amount: tag.bond.toString(), tx: toTx(await write("fund", [id, tag.bond])) };
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
if (approved)
|
|
387
|
+
await unapprove();
|
|
388
|
+
throw error;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
finally {
|
|
392
|
+
posting.delete(key);
|
|
393
|
+
}
|
|
311
394
|
}),
|
|
312
395
|
/** Worker or reviewer: points at what was delivered. */
|
|
313
396
|
evidence: (jobId, uri, contentHash = zeroHash) => guarded(async () => {
|
|
@@ -329,7 +412,10 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
329
412
|
const id = idOf(jobId);
|
|
330
413
|
return { id: id.toString(), tx: toTx(await write("concede", [id, reason])) };
|
|
331
414
|
}),
|
|
332
|
-
/**
|
|
415
|
+
/**
|
|
416
|
+
* Anyone: the reviewer stayed silent past its window, so the job settles at its default split. The client gets
|
|
417
|
+
* everything, or with `silenceReturnsBond` the amount while the worker gets its bond back.
|
|
418
|
+
*/
|
|
333
419
|
refund: (jobId) => guarded(async () => {
|
|
334
420
|
const id = idOf(jobId);
|
|
335
421
|
return { id: id.toString(), tx: toTx(await write("settleDefault", [id])) };
|
package/dist/jobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAyG,MAAM,MAAM,CAAC;AACtM,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,M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AAC,MAAM,EAAE,CAAC,OAAO,CAAC;YACtE,MAAM,MAAM,GAAG,CAAC,MAAM,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAe,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAW,CAAC,CAAW,CAAC;YACnJ,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC,CAAC;QAEJ,6CAA6C;QAC7C,OAAO,EAAE,GAAwB,EAAE,CACjC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC5F,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shippedcalls/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Read and bet on Shipped Calls from code or the command line: markets in ETH or USDG on whether a public claim holds, on Robinhood Chain.",
|
|
5
5
|
"keywords": ["shipped-calls", "prediction-market", "parimutuel", "robinhood-chain", "agents", "cli"],
|
|
6
6
|
"homepage": "https://calls.shipped.bond/agents",
|
package/skill/references/jobs.md
CHANGED
|
@@ -6,7 +6,7 @@ A job holds payment until the work is accepted. The worker opens it, the client
|
|
|
6
6
|
|
|
7
7
|
1. Agree the amount, the deadline and the reviewer with the client.
|
|
8
8
|
2. `open_job`, and give the client the id it returns.
|
|
9
|
-
3. Read `get_job` until `funded` is true. Do not start before it is.
|
|
9
|
+
3. Read `get_job` until `funded` is true. Do not start before it is. On a job opened with `bondAfterFunding`, `funded` turns true once you post your bond: when `state` reads `awaiting_bond`, the client's amount is in, and you post the bond with `client.jobs.postBond(id)` from the SDK.
|
|
10
10
|
4. Do the work and `post_job_evidence` with a link to it.
|
|
11
11
|
5. Once `state` is `paid`, `collect_job_money`.
|
|
12
12
|
|
package/skill/scripts/calls.sh
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { CallsError, RECEIPT_UNKNOWN } from "./errors.js";
|
|
|
7
7
|
export { callTextHash, canonicalPostUrl, normalizeHandle, parsePostUrl, postRefHash, specHash, subjectHash, ZERO_HASH } from "./hashes.js";
|
|
8
8
|
export { DISPUTE_WINDOW, MIN_BET, MIN_OPENER_BOND, PRICE_DISPUTE_WINDOW, RAKE_BPS, ethToWei, multipleOf, odds, payout, quoteOf, roundInPlay, roundPayout, type Pools, type Side } from "./odds.js";
|
|
9
9
|
export type * from "./types.js";
|
|
10
|
-
export { bondNumberOf, checkJob, COUNCIL_MIN_FEE, DEFAULT_MAX_JOB_FUND, DEFAULT_REVIEW_WINDOW, jobMilestone, jobStateOf, jobTerms, readJobTag, usdgToUnits, type ChainDeed, type Job, type JobAgreement, type JobProblem, type JobsClient, type JobState, type JobTerms, type JobTx, type OpenJobInput } from "./jobs.js";
|
|
10
|
+
export { bondNumberOf, checkJob, COUNCIL_MIN_FEE, deedsAbi, DEFAULT_MAX_JOB_FUND, DEFAULT_REVIEW_WINDOW, jobMilestone, jobStateOf, jobTerms, readJobTag, silenceSplit, usdgToUnits, type ChainDeed, type Job, type JobAgreement, type JobProblem, type JobsClient, type JobState, type JobTerms, type JobTx, type OpenJobInput } from "./jobs.js";
|
package/src/jobs.ts
CHANGED
|
@@ -6,7 +6,8 @@ import type { Tx } from "./types.js";
|
|
|
6
6
|
// A job is a Shipped bond the worker opens and the client funds. The bond's paid side belongs to whoever opens it, so
|
|
7
7
|
// the worker has to; the milestone carries a tag with the agreed amount, so anyone can tell a job from a bond and see
|
|
8
8
|
// what it is meant to hold. The worker writes every term, which is why `check` exists and `fund` refuses to pay into
|
|
9
|
-
// anything it fails.
|
|
9
|
+
// anything it fails. A worker's bond is locked when the job opens, or with `bondAfterFunding` after the client has
|
|
10
|
+
// funded the amount, through `postBond`.
|
|
10
11
|
|
|
11
12
|
export const USDG_DECIMALS = 6;
|
|
12
13
|
export const MAX_TITLE = 96;
|
|
@@ -24,6 +25,7 @@ export const DEFAULT_MAX_JOB_FUND = 25_000_000n;
|
|
|
24
25
|
|
|
25
26
|
const LEAD_SLACK = 60;
|
|
26
27
|
const BPS = 10_000;
|
|
28
|
+
const BPS_UNITS = 10_000n;
|
|
27
29
|
const STATUS_OPEN = 1;
|
|
28
30
|
const STATUS_SETTLED = 4;
|
|
29
31
|
const ERC721_TRANSFER = toEventSelector("Transfer(address,address,uint256)");
|
|
@@ -42,6 +44,7 @@ export const deedsAbi = parseAbi([
|
|
|
42
44
|
"function getDeed(uint256 deedId) view returns (Deed)",
|
|
43
45
|
"function owed(address account, address asset) view returns (uint256)",
|
|
44
46
|
"function timeline(uint256 deedId) view returns (uint64 deadline, uint64 verifierEnd, uint64 backupEnd, uint64 defaultAt, uint64 appealEnd, uint64 panelEnd)",
|
|
47
|
+
"event Funded(uint256 indexed deedId, address indexed from, uint256 amount, uint256 balance)",
|
|
45
48
|
"error AssetNotAllowed()",
|
|
46
49
|
"error CreationIsPaused()",
|
|
47
50
|
"error InvalidDeadline()",
|
|
@@ -120,8 +123,12 @@ export interface OpenJobInput {
|
|
|
120
123
|
reviewWindow?: number;
|
|
121
124
|
/** Paid to the reviewer from the job when its ruling stands, USDG units. 0.25 USDG at least for the council. */
|
|
122
125
|
reviewerFee?: bigint;
|
|
123
|
-
/** What the worker locks on its own side. It is lost to the client if the job
|
|
126
|
+
/** What the worker locks on its own side. It is lost to the client if the job is rejected or the worker gives up. */
|
|
124
127
|
workerBond?: bigint;
|
|
128
|
+
/** Opens with nothing locked; the worker posts `workerBond` with `postBond` once the client has funded the amount. */
|
|
129
|
+
bondAfterFunding?: boolean;
|
|
130
|
+
/** A silent reviewer returns the amount to the client and the bond to the worker, less Shipped's fee on the bond. */
|
|
131
|
+
silenceReturnsBond?: boolean;
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
/** What the client agreed to, for `check` and `fund` to compare against what the worker actually opened. */
|
|
@@ -136,8 +143,16 @@ export interface JobAgreement {
|
|
|
136
143
|
notAfter?: number;
|
|
137
144
|
/** The largest reviewer fee the client accepts, USDG units. A tenth of the amount by default. */
|
|
138
145
|
maxReviewerFee?: bigint;
|
|
139
|
-
/** The least the worker must have locked, USDG units. */
|
|
146
|
+
/** The least the worker must have locked, USDG units. With `bondAfterFunding`, exactly the bond the job must name. */
|
|
140
147
|
minWorkerBond?: bigint;
|
|
148
|
+
/**
|
|
149
|
+
* You fund the amount alone, and the worker's bond follows it. Name the bond in `minWorkerBond` as well: without it
|
|
150
|
+
* `check` and `fund` refuse the job (`bond_not_agreed`), since the job's own bond would set what silence leaves the
|
|
151
|
+
* worker. The type does not require it, so that code written for 0.5.0 against this interface still compiles.
|
|
152
|
+
*/
|
|
153
|
+
bondAfterFunding?: boolean;
|
|
154
|
+
/** A silent reviewer may return the worker's bond to it: the job may pay the worker the bond's share of the escrow. */
|
|
155
|
+
silenceReturnsBond?: boolean;
|
|
141
156
|
}
|
|
142
157
|
|
|
143
158
|
export interface JobProblem {
|
|
@@ -145,7 +160,8 @@ export interface JobProblem {
|
|
|
145
160
|
message: string;
|
|
146
161
|
}
|
|
147
162
|
|
|
148
|
-
|
|
163
|
+
/** `awaiting_bond`: the job holds the client's amount and not yet the worker's bond. */
|
|
164
|
+
export type JobState = "awaiting_funds" | "awaiting_bond" | "in_progress" | "in_review" | "refundable" | "ruled" | "paid" | "partly_paid" | "refunded";
|
|
149
165
|
|
|
150
166
|
export interface Job {
|
|
151
167
|
id: string;
|
|
@@ -163,7 +179,7 @@ export interface Job {
|
|
|
163
179
|
escrow: string;
|
|
164
180
|
funded: boolean;
|
|
165
181
|
deadline: number;
|
|
166
|
-
/** When anyone can
|
|
182
|
+
/** When anyone can settle the job at its default split if the reviewer has stayed silent. */
|
|
167
183
|
refundableAt: number;
|
|
168
184
|
state: JobState;
|
|
169
185
|
}
|
|
@@ -199,6 +215,18 @@ export function readJobTag(milestone: string): { brief: string; amount: bigint;
|
|
|
199
215
|
return { brief: milestone.slice(0, match.index), amount: BigInt(match[1]!), bond: BigInt(match[2]!) };
|
|
200
216
|
}
|
|
201
217
|
|
|
218
|
+
/**
|
|
219
|
+
* The default split, in basis points of the escrow, under which a silent reviewer returns the amount to the client and
|
|
220
|
+
* the bond to the worker. The registry rounds the worker's share down, so this is the largest split whose share is at
|
|
221
|
+
* most the bond: the client always gets its whole amount back, and the worker its bond less at most 0.01% of the
|
|
222
|
+
* escrow, which goes to the client.
|
|
223
|
+
*/
|
|
224
|
+
export function silenceSplit(amount: bigint, bond: bigint): number {
|
|
225
|
+
if (bond <= 0n || amount < 0n) return 0;
|
|
226
|
+
const bps = (BPS_UNITS * (bond + 1n) - 1n) / (amount + bond);
|
|
227
|
+
return Number(bps < BPS_UNITS ? bps : BPS_UNITS);
|
|
228
|
+
}
|
|
229
|
+
|
|
202
230
|
/** The registry's bond number on Shipped's site. */
|
|
203
231
|
export const bondNumberOf = (id: bigint | number, chainId = CHAIN_ID) => Number(id) - (chainId === CHAIN_ID ? 1 : 0);
|
|
204
232
|
|
|
@@ -242,7 +270,7 @@ export function jobTerms(input: OpenJobInput, { worker, now }: { worker: string;
|
|
|
242
270
|
check: zeroAddress,
|
|
243
271
|
checkData: "0x",
|
|
244
272
|
refundTo: client,
|
|
245
|
-
defaultRemainderBps: 0,
|
|
273
|
+
defaultRemainderBps: input.silenceReturnsBond ? silenceSplit(input.amount, bond) : 0,
|
|
246
274
|
refundCapBps: 0,
|
|
247
275
|
allowPartial: false,
|
|
248
276
|
verifierGrace: reviewWindow,
|
|
@@ -273,16 +301,25 @@ export function checkJob(deed: ChainDeed, agreement: JobAgreement, { client, now
|
|
|
273
301
|
|
|
274
302
|
if (!same(t.refundTo, client)) add("refund_elsewhere", `A failed job pays ${t.refundTo}, not you.`);
|
|
275
303
|
if (agreement.worker && !same(deed.creator, addressOf(agreement.worker, "worker"))) add("wrong_worker", `The job was opened by ${deed.creator}, not the worker you agreed with.`);
|
|
276
|
-
|
|
304
|
+
// The split is a share of whatever the job holds, so it is bounded by the bond the client agreed to, not the tag's.
|
|
305
|
+
const silence = agreement.silenceReturnsBond ? silenceSplit(tag.amount, agreement.minWorkerBond ?? tag.bond) : 0;
|
|
306
|
+
if (t.defaultRemainderBps > silence) add("pays_on_silence", agreement.silenceReturnsBond ? "The job pays the worker more than its bond if the reviewer stays silent." : "The job pays the worker if the reviewer stays silent. It has to refund you.");
|
|
277
307
|
if (t.check !== zeroAddress) add("has_check", "The job can be released by an on-chain check instead of the reviewer.");
|
|
278
308
|
if (t.allowPartial) add("allows_partial", "The reviewer can split this job between you and the worker.");
|
|
279
309
|
if (!same(t.asset, USDG)) add("wrong_asset", "The job is not held in USDG.");
|
|
280
310
|
|
|
281
311
|
if (tag.amount !== agreement.amount) add("wrong_amount", `The job asks for ${usdg(tag.amount)}, not the ${usdg(agreement.amount)} you agreed.`);
|
|
282
312
|
const minBond = agreement.minWorkerBond ?? 0n;
|
|
283
|
-
if (
|
|
284
|
-
|
|
285
|
-
|
|
313
|
+
if (agreement.bondAfterFunding) {
|
|
314
|
+
// Nothing is locked until the client funds, so the job names exactly the agreed bond: a bigger one would raise the
|
|
315
|
+
// share of the amount a silent reviewer leaves the worker should the bond never come. The agreement has to name it.
|
|
316
|
+
if (agreement.minWorkerBond === undefined) add("bond_not_agreed", "Name the bond you agreed in minWorkerBond: with the bond to follow, the job's own bond would set what silence leaves the worker.");
|
|
317
|
+
else if (tag.bond !== agreement.minWorkerBond) add("bond_not_agreed", `The job names a bond of ${usdg(tag.bond)}, not the ${usdg(agreement.minWorkerBond)} agreed.`);
|
|
318
|
+
} else {
|
|
319
|
+
if (tag.bond < minBond) add("bond_too_small", `The worker's bond is ${usdg(tag.bond)}, under the ${usdg(minBond)} you asked for.`);
|
|
320
|
+
if (deed.balance < tag.bond) add("bond_missing", "The worker has not locked the bond the job names.");
|
|
321
|
+
if (deed.balance >= tag.amount + tag.bond) add("already_funded", "This job already holds its full amount.");
|
|
322
|
+
}
|
|
286
323
|
|
|
287
324
|
const maxFee = agreement.maxReviewerFee ?? agreement.amount / MAX_REVIEWER_SHARE_DIVISOR;
|
|
288
325
|
if (t.verifierFee > maxFee) add("fee_too_high", `The reviewer's fee is ${usdg(t.verifierFee)}, over the ${usdg(maxFee)} you accept.`);
|
|
@@ -290,6 +327,8 @@ export function checkJob(deed: ChainDeed, agreement: JobAgreement, { client, now
|
|
|
290
327
|
const deadline = Number(t.deadline);
|
|
291
328
|
if (deadline <= now + MIN_LEAD) add("deadline_too_soon", "The deadline is too close for the work to be done.");
|
|
292
329
|
if (agreement.notAfter != null && deadline > agreement.notAfter) add("deadline_too_late", "The deadline is later than you agreed.");
|
|
330
|
+
// Last, so a job that both holds its amount and differs from the agreement is reported for the difference first.
|
|
331
|
+
if (agreement.bondAfterFunding && deed.balance >= tag.amount) add("already_funded", "This job already holds its amount.");
|
|
293
332
|
return problems;
|
|
294
333
|
}
|
|
295
334
|
|
|
@@ -298,7 +337,7 @@ export function jobStateOf(deed: ChainDeed, refundableAt: number, now: number):
|
|
|
298
337
|
if (deed.status !== STATUS_OPEN) return "ruled";
|
|
299
338
|
const tag = readJobTag(deed.terms.milestone);
|
|
300
339
|
if (now > refundableAt) return "refundable";
|
|
301
|
-
if (tag && deed.balance < tag.amount + tag.bond) return "awaiting_funds";
|
|
340
|
+
if (tag && deed.balance < tag.amount + tag.bond) return deed.balance >= tag.amount ? "awaiting_bond" : "awaiting_funds";
|
|
302
341
|
return now <= Number(deed.terms.deadline) ? "in_progress" : "in_review";
|
|
303
342
|
}
|
|
304
343
|
|
|
@@ -337,13 +376,21 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
337
376
|
reads.readContract({ address: USDG, abi: erc20Abi as Abi, functionName: "allowance", args: [owner, registry] } as never) as Promise<bigint>,
|
|
338
377
|
]);
|
|
339
378
|
if (balance < amount) throw new CallsError(`This wallet holds ${usdg(balance)}, and this needs ${usdg(amount)}.`, "insufficient_usdg");
|
|
340
|
-
if (allowance
|
|
379
|
+
if (allowance >= amount) return false;
|
|
380
|
+
await send({ address: USDG, abi: erc20Abi as Abi, functionName: "approve", args: [registry, amount] });
|
|
381
|
+
return true;
|
|
341
382
|
}
|
|
342
383
|
|
|
343
384
|
const cap = (amount: bigint, limit: bigint) => {
|
|
344
385
|
if (amount > limit) throw new CallsError(`This would lock ${usdg(amount)}, over the ${usdg(limit)} limit. Raise maxFund only on your operator's word.`, "over_cap");
|
|
345
386
|
};
|
|
346
387
|
|
|
388
|
+
/** The allowance a write gave is not left standing for money that did not go in. */
|
|
389
|
+
const unapprove = () => send({ address: USDG, abi: erc20Abi as Abi, functionName: "approve", args: [registry, 0n] }).catch(() => {});
|
|
390
|
+
|
|
391
|
+
/** Jobs whose bond this client is posting now. */
|
|
392
|
+
const posting = new Set<string>();
|
|
393
|
+
|
|
347
394
|
return {
|
|
348
395
|
/** One job as the chain has it. */
|
|
349
396
|
get: (jobId: unknown): Promise<Job> =>
|
|
@@ -377,15 +424,15 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
377
424
|
};
|
|
378
425
|
}),
|
|
379
426
|
|
|
380
|
-
/** Worker: opens the job
|
|
427
|
+
/** Worker: opens the job, locking its bond now unless `bondAfterFunding`. Hand the id to the client to fund. */
|
|
381
428
|
open: (input: OpenJobInput, { maxFund: limit = maxFund }: { maxFund?: bigint } = {}): Promise<JobTx> =>
|
|
382
429
|
guarded(async () => {
|
|
383
430
|
const worker = wallet().address;
|
|
384
431
|
const terms = jobTerms(input, { worker, now: await timeOnChain() });
|
|
385
|
-
const
|
|
386
|
-
cap(
|
|
387
|
-
if (
|
|
388
|
-
const receipt = await write("create", [terms,
|
|
432
|
+
const deposit = input.bondAfterFunding ? 0n : (input.workerBond ?? 0n);
|
|
433
|
+
cap(deposit, limit);
|
|
434
|
+
if (deposit > 0n) await approveUpTo(deposit);
|
|
435
|
+
const receipt = await write("create", [terms, deposit]);
|
|
389
436
|
// The registry mints the paid side as token id * 2, from the zero address, in the same transaction.
|
|
390
437
|
const minted = receipt.logs.find((log) => same(log.address, registry) && log.topics[0] === ERC721_TRANSFER && BigInt(log.topics[1] ?? 1) === 0n);
|
|
391
438
|
if (!minted?.topics[3]) throw new CallsError(`Transaction ${receipt.transactionHash} landed but its job id could not be read.`, RECEIPT_UNKNOWN);
|
|
@@ -401,7 +448,7 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
401
448
|
return { ok: problems.length === 0, problems };
|
|
402
449
|
}),
|
|
403
450
|
|
|
404
|
-
/** Client: locks the agreed amount, and only if the job passes `check`. */
|
|
451
|
+
/** Client: locks the agreed amount, and only if the job passes `check`. With `bondAfterFunding`, the amount alone. */
|
|
405
452
|
fund: (jobId: unknown, agreement: JobAgreement, { maxFund: limit = maxFund }: { maxFund?: bigint } = {}): Promise<JobTx & { amount: string }> =>
|
|
406
453
|
guarded(async () => {
|
|
407
454
|
const id = idOf(jobId);
|
|
@@ -409,10 +456,47 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
409
456
|
const [{ deed, tag }, now] = await Promise.all([jobAt(id), timeOnChain()]);
|
|
410
457
|
const problems = checkJob(deed, { ...agreement, client }, { client, now });
|
|
411
458
|
if (problems.length > 0) throw new CallsError(`Not funded. ${problems.map((p) => p.message).join(" ")}`, problems[0]!.code);
|
|
412
|
-
const amount = tag.amount + tag.bond - deed.balance;
|
|
459
|
+
const amount = agreement.bondAfterFunding ? tag.amount : tag.amount + tag.bond - deed.balance;
|
|
413
460
|
cap(amount, limit);
|
|
414
|
-
await approveUpTo(amount);
|
|
415
|
-
|
|
461
|
+
const approved = await approveUpTo(amount);
|
|
462
|
+
try {
|
|
463
|
+
return { id: id.toString(), amount: amount.toString(), tx: toTx(await write("fund", [id, amount])) };
|
|
464
|
+
} catch (error) {
|
|
465
|
+
if (approved) await unapprove();
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
}),
|
|
469
|
+
|
|
470
|
+
/** Worker: locks the bond the job names, once the job holds the client's amount and not yet the bond. */
|
|
471
|
+
postBond: (jobId: unknown, { maxFund: limit = maxFund }: { maxFund?: bigint } = {}): Promise<JobTx & { amount: string }> =>
|
|
472
|
+
guarded(async () => {
|
|
473
|
+
const id = idOf(jobId);
|
|
474
|
+
const key = id.toString();
|
|
475
|
+
// One post per job: a second while the first is under way, or while a transaction of this wallet is still
|
|
476
|
+
// pending, could lock the bond twice.
|
|
477
|
+
if (posting.has(key)) throw new CallsError("This wallet is already posting this job's bond. Read the job before posting it again.", "bond_pending");
|
|
478
|
+
posting.add(key);
|
|
479
|
+
try {
|
|
480
|
+
const { deed, tag } = await jobAt(id);
|
|
481
|
+
const owner = wallet().address;
|
|
482
|
+
if (!same(deed.creator, owner)) throw new CallsError("Only the worker who opened the job posts its bond.", "not_worker");
|
|
483
|
+
if (deed.status !== STATUS_OPEN) throw new CallsError("This job is no longer open.", "not_open");
|
|
484
|
+
if (tag.bond === 0n) throw new CallsError("This job names no bond.", "no_bond");
|
|
485
|
+
if (deed.balance < tag.amount) throw new CallsError("The client has not funded the job's amount yet. Post the bond once it has.", "not_funded");
|
|
486
|
+
if (deed.balance >= tag.amount + tag.bond) throw new CallsError("This job already holds its amount and the bond.", "already_funded");
|
|
487
|
+
const [mined, pending] = await Promise.all([reads.getTransactionCount({ address: owner, blockTag: "latest" }), reads.getTransactionCount({ address: owner, blockTag: "pending" })]);
|
|
488
|
+
if (pending > mined) throw new CallsError("This wallet has a transaction still pending. Once it lands, read the job before posting the bond again.", "bond_pending");
|
|
489
|
+
cap(tag.bond, limit);
|
|
490
|
+
const approved = await approveUpTo(tag.bond);
|
|
491
|
+
try {
|
|
492
|
+
return { id: key, amount: tag.bond.toString(), tx: toTx(await write("fund", [id, tag.bond])) };
|
|
493
|
+
} catch (error) {
|
|
494
|
+
if (approved) await unapprove();
|
|
495
|
+
throw error;
|
|
496
|
+
}
|
|
497
|
+
} finally {
|
|
498
|
+
posting.delete(key);
|
|
499
|
+
}
|
|
416
500
|
}),
|
|
417
501
|
|
|
418
502
|
/** Worker or reviewer: points at what was delivered. */
|
|
@@ -443,7 +527,10 @@ export function createJobs({ reads, chainId, send, guarded, wallet, toTx, maxFun
|
|
|
443
527
|
return { id: id.toString(), tx: toTx(await write("concede", [id, reason])) };
|
|
444
528
|
}),
|
|
445
529
|
|
|
446
|
-
/**
|
|
530
|
+
/**
|
|
531
|
+
* Anyone: the reviewer stayed silent past its window, so the job settles at its default split. The client gets
|
|
532
|
+
* everything, or with `silenceReturnsBond` the amount while the worker gets its bond back.
|
|
533
|
+
*/
|
|
447
534
|
refund: (jobId: unknown): Promise<JobTx> =>
|
|
448
535
|
guarded(async () => {
|
|
449
536
|
const id = idOf(jobId);
|