@shippedcalls/sdk 0.3.0 → 0.4.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 CHANGED
@@ -21,6 +21,13 @@ calls bet <address> <holds|breaks> <eth> [--quote] [--yes] [--max-stake <eth>]
21
21
  calls claim <address> [--opener]
22
22
  calls open --text <sentence> --spec <json|@file> [--handle <x handle>] [--post-url <url>] [--bond <eth>] [--yes]
23
23
  calls open --text <sentence> --bond-number <n> [--yes]
24
+
25
+ calls rounds [<market>]
26
+ calls rounds history [<wallet>]
27
+ calls rounds bet <market> <up|down> <eth> [--quote] [--yes] [--max-stake <eth>]
28
+ calls rounds claim [<market>]
29
+ calls rounds plain-wins <on|off>
30
+ calls rounds limit <eth>
24
31
  ```
25
32
 
26
33
  `--json` works on every command. A failure is `{"error": "...", "code": "..."}` with a non-zero exit.
@@ -40,6 +47,8 @@ npx @shippedcalls/sdk bet <address> holds 0.001 --yes
40
47
  | `CALLS_RPC_URL` | RPC endpoints, comma-separated, tried in order. A public list by default. |
41
48
  | `CALLS_API_URL` | https://calls.shipped.bond by default. |
42
49
 
50
+ The CLI and the MCP server read these. The library takes them as options: `createClient({ privateKey, api, rpc })`.
51
+
43
52
  ## The library
44
53
 
45
54
  ```ts
@@ -60,9 +69,9 @@ Bring a private key or any viem account as `account`; reads need neither.
60
69
  | From the chain | `quote()` `pool()` `status()` `disputeWindow()` `odds()` `payoutOf()` `stake()` `balance()` `isCall()` |
61
70
  | Both | `positions()` `verifySettlement()` |
62
71
  | Writes | `bet()` `claim()` `claimOpener()` `finalize()` `dispute()` `open()` |
63
- | Rounds | `rounds.markets()` `rounds.state()` `rounds.history()` `rounds.bet()` `rounds.claim()` |
72
+ | Rounds | `rounds.markets()` `rounds.state()` `rounds.quote()` `rounds.history()` `rounds.bet()` `rounds.claim()` `rounds.setPlainWins()` `rounds.setLimit()` |
64
73
 
65
- Rounds are five-minute markets on whether ETH, BTC or SOL goes up or down: `calls.rounds.bet("ETH", "up", ethToWei("0.001"))` stakes on the round taking bets now, and `calls.rounds.claim()` collects everything the wallet is owed. A bet is refused while `rounds.markets()` answers `open: false`, because nothing is pricing rounds and the stake would wait an hour to come back.
74
+ Rounds are five-minute markets on whether ETH, BTC or SOL goes up or down: `calls.rounds.bet("ETH", "up", ethToWei("0.001"))` stakes on the round taking bets now, and `calls.rounds.claim()` collects everything the wallet is owed. Only matched stake plays: a fully matched win pays 1.94 times the stake, after a 3% fee on what played, and whatever isn't matched comes back win or lose. A stake alone in a round comes back, except that close to the lock a Shipped agent may match up to 0.005 ETH of it. A win that earns a card pays 10% of its profit as $SHIPPED; `calls.rounds.setPlainWins(true)` or `calls rounds plain-wins on` takes every win in ETH instead. A bet is refused while `rounds.markets()` answers `open: false`, because rounds aren't being priced and the stake would wait an hour to come back.
66
75
 
67
76
  A Call's result stays open to dispute for `disputeWindow` seconds after it settles: 1 hour on a Price Call, 24 hours on a Post or contract-read Call and on every Call opened on an earlier factory, none on a bond Call. `isCall()` and every write accept Calls of the earlier factories too.
68
77
 
@@ -72,6 +81,37 @@ Amounts going in are wei as `bigint`. Amounts coming back from the API, and from
72
81
 
73
82
  Failures throw `CallsError`, with one sentence as `message` and a `code` to branch on: a revert's error name, such as `BettingClosed`, or `over_max_stake`, `not_a_call`, `no_wallet`.
74
83
 
84
+ ## Jobs
85
+
86
+ Hold payment until the work is accepted. The worker opens a job, the client locks USDG, and a named reviewer releases it. Accepted, the worker is paid. Rejected, or left unreviewed past the reviewer's window, the client gets the money back.
87
+
88
+ ```js
89
+ import { createClient, usdgToUnits } from "@shippedcalls/sdk";
90
+
91
+ const worker = createClient({ privateKey: process.env.WORKER_KEY });
92
+ const { id } = await worker.jobs.open({
93
+ title: "Weekly gas report",
94
+ brief: "A one-page report on median gas for the week, at a public link.",
95
+ client: "0xClient…",
96
+ amount: usdgToUnits("25"),
97
+ deadline: Math.floor(Date.now() / 1000) + 7 * 86_400,
98
+ reviewer: "council", // or an address
99
+ });
100
+
101
+ const client = createClient({ privateKey: process.env.CLIENT_KEY });
102
+ const agreement = { amount: usdgToUnits("25"), reviewers: ["council"], worker: worker.address };
103
+ await client.jobs.check(id, agreement); // { ok, problems }
104
+ await client.jobs.fund(id, agreement);
105
+
106
+ await worker.jobs.evidence(id, "https://example.com/report");
107
+ // the reviewer calls accept(id, reason), or reject(id, reason) after the deadline
108
+ await worker.jobs.collect();
109
+ ```
110
+
111
+ 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.
112
+
113
+ The worker can lock its own money with `workerBond`; it comes back on acceptance and goes to the client if the job fails. 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.
114
+
75
115
  ## What a write does before it sends
76
116
 
77
117
  - `bet()` refuses an amount over `maxStake` (0.01 ETH unless you set it) and any address that is not one of the factory's Calls.
package/dist/abi.d.ts CHANGED
@@ -1669,6 +1669,18 @@ export declare const roundsAbi: readonly [{
1669
1669
  readonly name: "sources_";
1670
1670
  readonly type: "address[]";
1671
1671
  readonly internalType: "contract IPriceSource[]";
1672
+ }, {
1673
+ readonly name: "holdToken";
1674
+ readonly type: "address";
1675
+ readonly internalType: "address";
1676
+ }, {
1677
+ readonly name: "holdMin_";
1678
+ readonly type: "uint256";
1679
+ readonly internalType: "uint256";
1680
+ }, {
1681
+ readonly name: "cards_";
1682
+ readonly type: "address";
1683
+ readonly internalType: "contract IRoundCards";
1672
1684
  }];
1673
1685
  readonly stateMutability: "nonpayable";
1674
1686
  }, {
@@ -1681,6 +1693,46 @@ export declare const roundsAbi: readonly [{
1681
1693
  readonly internalType: "uint256";
1682
1694
  }];
1683
1695
  readonly stateMutability: "view";
1696
+ }, {
1697
+ readonly type: "function";
1698
+ readonly name: "CARD_CUT_BPS";
1699
+ readonly inputs: readonly [];
1700
+ readonly outputs: readonly [{
1701
+ readonly name: "";
1702
+ readonly type: "uint256";
1703
+ readonly internalType: "uint256";
1704
+ }];
1705
+ readonly stateMutability: "view";
1706
+ }, {
1707
+ readonly type: "function";
1708
+ readonly name: "CARD_STREAK";
1709
+ readonly inputs: readonly [];
1710
+ readonly outputs: readonly [{
1711
+ readonly name: "";
1712
+ readonly type: "uint256";
1713
+ readonly internalType: "uint256";
1714
+ }];
1715
+ readonly stateMutability: "view";
1716
+ }, {
1717
+ readonly type: "function";
1718
+ readonly name: "HOLDER_RAKE_BPS";
1719
+ readonly inputs: readonly [];
1720
+ readonly outputs: readonly [{
1721
+ readonly name: "";
1722
+ readonly type: "uint256";
1723
+ readonly internalType: "uint256";
1724
+ }];
1725
+ readonly stateMutability: "view";
1726
+ }, {
1727
+ readonly type: "function";
1728
+ readonly name: "HOLD_TOKEN";
1729
+ readonly inputs: readonly [];
1730
+ readonly outputs: readonly [{
1731
+ readonly name: "";
1732
+ readonly type: "address";
1733
+ readonly internalType: "address";
1734
+ }];
1735
+ readonly stateMutability: "view";
1684
1736
  }, {
1685
1737
  readonly type: "function";
1686
1738
  readonly name: "INTERVAL";
@@ -1701,6 +1753,16 @@ export declare const roundsAbi: readonly [{
1701
1753
  readonly internalType: "uint256";
1702
1754
  }];
1703
1755
  readonly stateMutability: "view";
1756
+ }, {
1757
+ readonly type: "function";
1758
+ readonly name: "MAX_CARD_CUT";
1759
+ readonly inputs: readonly [];
1760
+ readonly outputs: readonly [{
1761
+ readonly name: "";
1762
+ readonly type: "uint256";
1763
+ readonly internalType: "uint256";
1764
+ }];
1765
+ readonly stateMutability: "view";
1704
1766
  }, {
1705
1767
  readonly type: "function";
1706
1768
  readonly name: "MAX_STAKE";
@@ -1793,6 +1855,16 @@ export declare const roundsAbi: readonly [{
1793
1855
  }];
1794
1856
  readonly outputs: readonly [];
1795
1857
  readonly stateMutability: "payable";
1858
+ }, {
1859
+ readonly type: "function";
1860
+ readonly name: "cards";
1861
+ readonly inputs: readonly [];
1862
+ readonly outputs: readonly [{
1863
+ readonly name: "";
1864
+ readonly type: "address";
1865
+ readonly internalType: "contract IRoundCards";
1866
+ }];
1867
+ readonly stateMutability: "view";
1796
1868
  }, {
1797
1869
  readonly type: "function";
1798
1870
  readonly name: "claim";
@@ -1869,6 +1941,30 @@ export declare const roundsAbi: readonly [{
1869
1941
  readonly internalType: "address";
1870
1942
  }];
1871
1943
  readonly stateMutability: "view";
1944
+ }, {
1945
+ readonly type: "function";
1946
+ readonly name: "holdMin";
1947
+ readonly inputs: readonly [];
1948
+ readonly outputs: readonly [{
1949
+ readonly name: "";
1950
+ readonly type: "uint256";
1951
+ readonly internalType: "uint256";
1952
+ }];
1953
+ readonly stateMutability: "view";
1954
+ }, {
1955
+ readonly type: "function";
1956
+ readonly name: "holds";
1957
+ readonly inputs: readonly [{
1958
+ readonly name: "wallet";
1959
+ readonly type: "address";
1960
+ readonly internalType: "address";
1961
+ }];
1962
+ readonly outputs: readonly [{
1963
+ readonly name: "";
1964
+ readonly type: "bool";
1965
+ readonly internalType: "bool";
1966
+ }];
1967
+ readonly stateMutability: "view";
1872
1968
  }, {
1873
1969
  readonly type: "function";
1874
1970
  readonly name: "limitOf";
@@ -1963,6 +2059,20 @@ export declare const roundsAbi: readonly [{
1963
2059
  readonly internalType: "address";
1964
2060
  }];
1965
2061
  readonly stateMutability: "view";
2062
+ }, {
2063
+ readonly type: "function";
2064
+ readonly name: "plainWins";
2065
+ readonly inputs: readonly [{
2066
+ readonly name: "wallet";
2067
+ readonly type: "address";
2068
+ readonly internalType: "address";
2069
+ }];
2070
+ readonly outputs: readonly [{
2071
+ readonly name: "";
2072
+ readonly type: "bool";
2073
+ readonly internalType: "bool";
2074
+ }];
2075
+ readonly stateMutability: "view";
1966
2076
  }, {
1967
2077
  readonly type: "function";
1968
2078
  readonly name: "positionOf";
@@ -1993,6 +2103,40 @@ export declare const roundsAbi: readonly [{
1993
2103
  readonly internalType: "bool";
1994
2104
  }];
1995
2105
  readonly stateMutability: "view";
2106
+ }, {
2107
+ readonly type: "function";
2108
+ readonly name: "preview";
2109
+ readonly inputs: readonly [{
2110
+ readonly name: "market";
2111
+ readonly type: "bytes32";
2112
+ readonly internalType: "bytes32";
2113
+ }, {
2114
+ readonly name: "epoch";
2115
+ readonly type: "uint256";
2116
+ readonly internalType: "uint256";
2117
+ }, {
2118
+ readonly name: "wallet";
2119
+ readonly type: "address";
2120
+ readonly internalType: "address";
2121
+ }];
2122
+ readonly outputs: readonly [{
2123
+ readonly name: "amount";
2124
+ readonly type: "uint256";
2125
+ readonly internalType: "uint256";
2126
+ }, {
2127
+ readonly name: "cut";
2128
+ readonly type: "uint256";
2129
+ readonly internalType: "uint256";
2130
+ }, {
2131
+ readonly name: "streak";
2132
+ readonly type: "uint256";
2133
+ readonly internalType: "uint256";
2134
+ }, {
2135
+ readonly name: "card";
2136
+ readonly type: "bool";
2137
+ readonly internalType: "bool";
2138
+ }];
2139
+ readonly stateMutability: "view";
1996
2140
  }, {
1997
2141
  readonly type: "function";
1998
2142
  readonly name: "prices";
@@ -2059,6 +2203,26 @@ export declare const roundsAbi: readonly [{
2059
2203
  readonly internalType: "uint64";
2060
2204
  }];
2061
2205
  readonly stateMutability: "view";
2206
+ }, {
2207
+ readonly type: "function";
2208
+ readonly name: "setCards";
2209
+ readonly inputs: readonly [{
2210
+ readonly name: "cards_";
2211
+ readonly type: "address";
2212
+ readonly internalType: "contract IRoundCards";
2213
+ }];
2214
+ readonly outputs: readonly [];
2215
+ readonly stateMutability: "nonpayable";
2216
+ }, {
2217
+ readonly type: "function";
2218
+ readonly name: "setHoldMin";
2219
+ readonly inputs: readonly [{
2220
+ readonly name: "holdMin_";
2221
+ readonly type: "uint256";
2222
+ readonly internalType: "uint256";
2223
+ }];
2224
+ readonly outputs: readonly [];
2225
+ readonly stateMutability: "nonpayable";
2062
2226
  }, {
2063
2227
  readonly type: "function";
2064
2228
  readonly name: "setLimit";
@@ -2083,6 +2247,16 @@ export declare const roundsAbi: readonly [{
2083
2247
  }];
2084
2248
  readonly outputs: readonly [];
2085
2249
  readonly stateMutability: "nonpayable";
2250
+ }, {
2251
+ readonly type: "function";
2252
+ readonly name: "setPlainWins";
2253
+ readonly inputs: readonly [{
2254
+ readonly name: "plain";
2255
+ readonly type: "bool";
2256
+ readonly internalType: "bool";
2257
+ }];
2258
+ readonly outputs: readonly [];
2259
+ readonly stateMutability: "nonpayable";
2086
2260
  }, {
2087
2261
  readonly type: "function";
2088
2262
  readonly name: "setTreasury";
@@ -2093,6 +2267,28 @@ export declare const roundsAbi: readonly [{
2093
2267
  }];
2094
2268
  readonly outputs: readonly [];
2095
2269
  readonly stateMutability: "nonpayable";
2270
+ }, {
2271
+ readonly type: "function";
2272
+ readonly name: "streakOf";
2273
+ readonly inputs: readonly [{
2274
+ readonly name: "market";
2275
+ readonly type: "bytes32";
2276
+ readonly internalType: "bytes32";
2277
+ }, {
2278
+ readonly name: "epoch";
2279
+ readonly type: "uint256";
2280
+ readonly internalType: "uint256";
2281
+ }, {
2282
+ readonly name: "wallet";
2283
+ readonly type: "address";
2284
+ readonly internalType: "address";
2285
+ }];
2286
+ readonly outputs: readonly [{
2287
+ readonly name: "";
2288
+ readonly type: "uint256";
2289
+ readonly internalType: "uint256";
2290
+ }];
2291
+ readonly stateMutability: "view";
2096
2292
  }, {
2097
2293
  readonly type: "function";
2098
2294
  readonly name: "treasury";
@@ -2167,6 +2363,41 @@ export declare const roundsAbi: readonly [{
2167
2363
  readonly internalType: "uint256";
2168
2364
  }];
2169
2365
  readonly anonymous: false;
2366
+ }, {
2367
+ readonly type: "event";
2368
+ readonly name: "CardCut";
2369
+ readonly inputs: readonly [{
2370
+ readonly name: "wallet";
2371
+ readonly type: "address";
2372
+ readonly indexed: true;
2373
+ readonly internalType: "address";
2374
+ }, {
2375
+ readonly name: "cards";
2376
+ readonly type: "uint256";
2377
+ readonly indexed: false;
2378
+ readonly internalType: "uint256";
2379
+ }, {
2380
+ readonly name: "cut";
2381
+ readonly type: "uint256";
2382
+ readonly indexed: false;
2383
+ readonly internalType: "uint256";
2384
+ }, {
2385
+ readonly name: "paid";
2386
+ readonly type: "bool";
2387
+ readonly indexed: false;
2388
+ readonly internalType: "bool";
2389
+ }];
2390
+ readonly anonymous: false;
2391
+ }, {
2392
+ readonly type: "event";
2393
+ readonly name: "CardsSet";
2394
+ readonly inputs: readonly [{
2395
+ readonly name: "cards";
2396
+ readonly type: "address";
2397
+ readonly indexed: true;
2398
+ readonly internalType: "address";
2399
+ }];
2400
+ readonly anonymous: false;
2170
2401
  }, {
2171
2402
  readonly type: "event";
2172
2403
  readonly name: "Claimed";
@@ -2252,6 +2483,16 @@ export declare const roundsAbi: readonly [{
2252
2483
  readonly internalType: "address";
2253
2484
  }];
2254
2485
  readonly anonymous: false;
2486
+ }, {
2487
+ readonly type: "event";
2488
+ readonly name: "HoldMinSet";
2489
+ readonly inputs: readonly [{
2490
+ readonly name: "holdMin";
2491
+ readonly type: "uint256";
2492
+ readonly indexed: false;
2493
+ readonly internalType: "uint256";
2494
+ }];
2495
+ readonly anonymous: false;
2255
2496
  }, {
2256
2497
  readonly type: "event";
2257
2498
  readonly name: "LimitSet";
@@ -2302,6 +2543,21 @@ export declare const roundsAbi: readonly [{
2302
2543
  readonly internalType: "bool";
2303
2544
  }];
2304
2545
  readonly anonymous: false;
2546
+ }, {
2547
+ readonly type: "event";
2548
+ readonly name: "PlainWinsSet";
2549
+ readonly inputs: readonly [{
2550
+ readonly name: "wallet";
2551
+ readonly type: "address";
2552
+ readonly indexed: true;
2553
+ readonly internalType: "address";
2554
+ }, {
2555
+ readonly name: "plain";
2556
+ readonly type: "bool";
2557
+ readonly indexed: false;
2558
+ readonly internalType: "bool";
2559
+ }];
2560
+ readonly anonymous: false;
2305
2561
  }, {
2306
2562
  readonly type: "event";
2307
2563
  readonly name: "Priced";
@@ -2391,6 +2647,10 @@ export declare const roundsAbi: readonly [{
2391
2647
  readonly type: "error";
2392
2648
  readonly name: "BelowMinimum";
2393
2649
  readonly inputs: readonly [];
2650
+ }, {
2651
+ readonly type: "error";
2652
+ readonly name: "GasTooLow";
2653
+ readonly inputs: readonly [];
2394
2654
  }, {
2395
2655
  readonly type: "error";
2396
2656
  readonly name: "MarketExists";
@@ -2411,6 +2671,10 @@ export declare const roundsAbi: readonly [{
2411
2671
  readonly type: "error";
2412
2672
  readonly name: "NothingToClaim";
2413
2673
  readonly inputs: readonly [];
2674
+ }, {
2675
+ readonly type: "error";
2676
+ readonly name: "NothingToVoid";
2677
+ readonly inputs: readonly [];
2414
2678
  }, {
2415
2679
  readonly type: "error";
2416
2680
  readonly name: "OtherSide";