@shippedcalls/sdk 0.4.0 → 0.5.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 +41 -13
- package/dist/abi.d.ts +1328 -0
- package/dist/abi.js +1703 -0
- package/dist/abi.js.map +1 -1
- package/dist/assets.d.ts +34 -0
- package/dist/assets.js +48 -0
- package/dist/assets.js.map +1 -0
- package/dist/chain.d.ts +2 -0
- package/dist/chain.js +2 -0
- package/dist/chain.js.map +1 -1
- package/dist/cli.js +121 -38
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +85 -17
- package/dist/client.js +276 -69
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +16 -3
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/jobs.js +2 -2
- package/dist/jobs.js.map +1 -1
- package/dist/odds.d.ts +7 -6
- package/dist/odds.js +13 -12
- package/dist/odds.js.map +1 -1
- package/dist/types.d.ts +90 -30
- package/package.json +3 -3
- package/skill/SKILL.md +24 -14
- package/skill/references/api.md +30 -12
- package/skill/references/funding.md +4 -2
- package/skill/references/settlement.md +5 -2
- package/skill/references/write-path.md +30 -2
- package/skill/scripts/calls.sh +1 -1
- package/src/abi.ts +1705 -0
- package/src/assets.ts +65 -0
- package/src/chain.ts +2 -0
- package/src/cli.ts +118 -39
- package/src/client.ts +291 -71
- package/src/errors.ts +18 -3
- package/src/index.ts +3 -2
- package/src/jobs.ts +2 -2
- package/src/odds.ts +13 -12
- package/src/types.ts +77 -26
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Account, type Address, type Hash, type Transport } from "viem";
|
|
2
|
+
import { type Asset, type AssetSymbol } from "./assets.js";
|
|
2
3
|
import { type Side } from "./odds.js";
|
|
3
|
-
import type { CallDetail, CallRow, CallStatus, CallType, Leaderboard, Opened, OpenInput, Player, Positions, Prepared, Proof, Quote, RecentBet, RoundsAccount, RoundsFloor, RoundSide, RoundsMarket, Settlement, ShippedAgent, TapeItem, Tx } from "./types.js";
|
|
4
|
+
import type { Approval, BonusQuote, CallDetail, CallRow, CallStatus, CallType, Leaderboard, Opened, OpenInput, Player, Positions, Prepared, Proof, Quote, RecentBet, RoundsAccount, RoundsFloor, RoundSide, RoundsMarket, Settlement, ShippedAgent, TapeItem, Tx } from "./types.js";
|
|
4
5
|
export interface ClientOptions {
|
|
5
6
|
/** The API's origin. https://calls.shipped.bond by default. */
|
|
6
7
|
api?: string;
|
|
@@ -9,14 +10,18 @@ export interface ClientOptions {
|
|
|
9
10
|
/** A private key, or `account` for any viem account. Reads need neither. */
|
|
10
11
|
privateKey?: string;
|
|
11
12
|
account?: Account;
|
|
12
|
-
/** The most one bet may stake, wei. 0.01 ETH by default. */
|
|
13
|
+
/** The most one bet may stake on an ETH Call, wei. 0.01 ETH by default. */
|
|
13
14
|
maxStake?: bigint;
|
|
15
|
+
/** The most one bet or bonus may put into a USDG Call, USDG units. 10 USDG by default. */
|
|
16
|
+
maxStakeUsdg?: bigint;
|
|
14
17
|
/** The most one job call may lock, USDG units. 25 USDG by default. */
|
|
15
18
|
maxJobFund?: bigint;
|
|
16
19
|
chainId?: number;
|
|
17
20
|
factory?: Address;
|
|
18
21
|
/** Earlier factories whose Calls this client still treats as Calls. The published ones unless `factory` is set. */
|
|
19
22
|
previousFactories?: readonly Address[];
|
|
23
|
+
/** The factory USDG Calls open on. The published one unless `factory` is set; null leaves USDG Calls out. */
|
|
24
|
+
usdgFactory?: Address | null;
|
|
20
25
|
fetch?: typeof fetch;
|
|
21
26
|
/** A viem transport in place of `rpc`. */
|
|
22
27
|
transport?: Transport;
|
|
@@ -35,6 +40,8 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
35
40
|
address: `0x${string}` | null;
|
|
36
41
|
chainId: number;
|
|
37
42
|
factory: `0x${string}`;
|
|
43
|
+
/** The factory USDG Calls open on, or null when this client knows none. */
|
|
44
|
+
usdgFactory: `0x${string}` | null;
|
|
38
45
|
/** Hold payment until the work is accepted: the worker opens a job, the client funds it, a named reviewer releases it. */
|
|
39
46
|
jobs: {
|
|
40
47
|
get: (jobId: unknown) => Promise<import("./jobs.js").Job>;
|
|
@@ -60,10 +67,12 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
60
67
|
tx: Tx;
|
|
61
68
|
}>;
|
|
62
69
|
};
|
|
70
|
+
/** Every asset by default; `asset` keeps to Calls staked in one. */
|
|
63
71
|
calls(filters?: {
|
|
64
72
|
status?: CallStatus;
|
|
65
73
|
type?: CallType;
|
|
66
74
|
subject?: string;
|
|
75
|
+
asset?: AssetSymbol;
|
|
67
76
|
sort?: "closing" | "lopsided" | "pot" | "newest";
|
|
68
77
|
limit?: number;
|
|
69
78
|
offset?: number;
|
|
@@ -74,31 +83,45 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
74
83
|
call?: string;
|
|
75
84
|
limit?: number;
|
|
76
85
|
}): Promise<RecentBet[] | CallDetail["bets"]>;
|
|
77
|
-
tape({ limit }?: {
|
|
86
|
+
tape({ limit, asset }?: {
|
|
78
87
|
limit?: number;
|
|
88
|
+
asset?: AssetSymbol;
|
|
79
89
|
}): Promise<TapeItem[]>;
|
|
80
90
|
leaderboard: (filters?: {
|
|
81
91
|
window?: "week" | "all";
|
|
82
92
|
board?: "profit" | "best" | "streak" | "openers";
|
|
83
93
|
limit?: number;
|
|
84
94
|
me?: string;
|
|
95
|
+
asset?: AssetSymbol;
|
|
85
96
|
}) => Promise<Leaderboard>;
|
|
86
|
-
player: (address?: string
|
|
97
|
+
player: (address?: string, { asset }?: {
|
|
98
|
+
asset?: AssetSymbol;
|
|
99
|
+
}) => Promise<Player>;
|
|
87
100
|
/** Shipped agents: name, rule and wallet. */
|
|
88
101
|
agents(): Promise<ShippedAgent[]>;
|
|
89
102
|
proof: () => Promise<Proof>;
|
|
90
103
|
/**
|
|
91
|
-
* What `amount`
|
|
92
|
-
* no endpoint answers. Later bets move the
|
|
104
|
+
* What `amount` on `side` pays with the pools as they stand, in base units of the Call's asset, its share of any
|
|
105
|
+
* bonus included. Reads the pools from the chain, and from the API if no endpoint answers. Later bets move the
|
|
106
|
+
* payout until betting closes.
|
|
93
107
|
*/
|
|
94
108
|
quote(address: string, side: Side | string, amount: bigint): Promise<Quote>;
|
|
95
|
-
/**
|
|
96
|
-
|
|
109
|
+
/** What a Call is staked in, from the chain, or from the API if no endpoint answers. */
|
|
110
|
+
assetOf(address: string): Promise<Asset>;
|
|
111
|
+
/**
|
|
112
|
+
* One wallet's open positions and settled Calls in one asset, ETH unless `asset` asks for USDG, from the API, with
|
|
113
|
+
* its balance and what it can claim from the chain. `gas` is its ETH, which pays the gas either way.
|
|
114
|
+
*/
|
|
115
|
+
positions(address?: string, { asset }?: {
|
|
116
|
+
asset?: AssetSymbol;
|
|
117
|
+
}): Promise<Positions>;
|
|
97
118
|
isCall: (address: string) => Promise<boolean>;
|
|
98
119
|
pool: (address: string, side: Side | string) => Promise<bigint>;
|
|
99
120
|
status: (address: string) => Promise<CallStatus>;
|
|
100
121
|
/** Seconds this Call's result stays open to dispute after it settles. A Call of an earlier factory has no such read, and ran 24 hours. */
|
|
101
122
|
disputeWindow: (address: string) => Promise<number>;
|
|
123
|
+
/** The bonus pot sponsors added to a USDG Call, USDG units. 0 on an ETH Call, which has none. */
|
|
124
|
+
bonus: (address: string) => Promise<bigint>;
|
|
102
125
|
odds(address: string): Promise<{
|
|
103
126
|
holdsBps: number;
|
|
104
127
|
breaksBps: number;
|
|
@@ -108,20 +131,27 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
108
131
|
holds: bigint;
|
|
109
132
|
breaks: bigint;
|
|
110
133
|
};
|
|
134
|
+
bonus: bigint;
|
|
111
135
|
}>;
|
|
112
136
|
payoutOf: (address: string, who?: string) => Promise<bigint>;
|
|
113
137
|
stake: (address: string, side: Side | string, who?: string) => Promise<bigint>;
|
|
114
138
|
balance: (who?: string) => Promise<bigint>;
|
|
115
139
|
/**
|
|
116
|
-
* Stakes `amount`
|
|
117
|
-
*
|
|
140
|
+
* Stakes `amount` on `side`, in base units of the Call's asset. Refuses an address that is not a Call of one of the
|
|
141
|
+
* factories, and an amount over the cap for its asset (`maxStake` in wei on an ETH Call, `maxStakeUsdg` in USDG
|
|
142
|
+
* units on a USDG Call), before anything goes out. A USDG bet goes through the USDG factory, and when the factory's
|
|
143
|
+
* allowance is short it first approves exactly `amount` in a transaction of its own, reported as `approval`. Every
|
|
144
|
+
* transaction simulates first, so one the contract would refuse costs nothing.
|
|
118
145
|
*/
|
|
119
|
-
bet(address: string, side: Side | string, amount: bigint, { maxStake: cap }?: {
|
|
146
|
+
bet(address: string, side: Side | string, amount: bigint, { maxStake: cap, maxStakeUsdg: usdgCap }?: {
|
|
120
147
|
maxStake?: bigint;
|
|
148
|
+
maxStakeUsdg?: bigint;
|
|
121
149
|
}): Promise<{
|
|
122
150
|
call: `0x${string}`;
|
|
123
151
|
side: Side;
|
|
124
152
|
amount: string;
|
|
153
|
+
asset: Asset;
|
|
154
|
+
approval: Tx | null;
|
|
125
155
|
pools: {
|
|
126
156
|
holds: string;
|
|
127
157
|
breaks: string;
|
|
@@ -132,6 +162,33 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
132
162
|
fee: import("./types.js").Wei;
|
|
133
163
|
explorerUrl: string | null;
|
|
134
164
|
}>;
|
|
165
|
+
/**
|
|
166
|
+
* What adding `amount` USDG units to a USDG Call's bonus pot does, with the pot as it stands. Winners share the pot
|
|
167
|
+
* by stake on top of the losing pool, with no fee on it; if the Call is voided or one side is empty, each sponsor
|
|
168
|
+
* takes back what they put in. Sends nothing.
|
|
169
|
+
*/
|
|
170
|
+
bonusQuote: (address: string, amount: bigint) => Promise<BonusQuote>;
|
|
171
|
+
/**
|
|
172
|
+
* Adds `amount` USDG units to a USDG Call's bonus pot while betting is open, through the USDG factory, approving
|
|
173
|
+
* exactly `amount` first when the allowance is short. Counts against the same cap as a USDG bet. Adding to the pot
|
|
174
|
+
* buys no stake: to share in it, bet.
|
|
175
|
+
*/
|
|
176
|
+
addBonus(address: string, amount: bigint, { maxStakeUsdg: usdgCap }?: {
|
|
177
|
+
maxStakeUsdg?: bigint;
|
|
178
|
+
}): Promise<{
|
|
179
|
+
call: `0x${string}`;
|
|
180
|
+
amount: string;
|
|
181
|
+
asset: Asset;
|
|
182
|
+
approval: Tx | null;
|
|
183
|
+
bonus: string | null;
|
|
184
|
+
hash: Hash;
|
|
185
|
+
block: number;
|
|
186
|
+
gasUsed: string;
|
|
187
|
+
fee: import("./types.js").Wei;
|
|
188
|
+
explorerUrl: string | null;
|
|
189
|
+
}>;
|
|
190
|
+
/** The wallet's USDG, what it has allowed the USDG factory, and the approval a bet or bonus of `amount` would send first. */
|
|
191
|
+
usdgApproval: (amount: bigint, who?: string) => Promise<Approval>;
|
|
135
192
|
/** Five minutes, up or down. The contract's address comes from the API, so a new deployment needs no new client. */
|
|
136
193
|
rounds: {
|
|
137
194
|
/** Every market's round taking bets, the round running and its latest results, in one read. */
|
|
@@ -198,9 +255,13 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
198
255
|
explorerUrl: string | null;
|
|
199
256
|
}>;
|
|
200
257
|
};
|
|
201
|
-
/**
|
|
202
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Collects winnings or a refund once the Call is Final or Voided, in the Call's asset, a sponsor's bonus coming back
|
|
260
|
+
* with it when the bonus refunds. The money only ever goes to the wallet that sends this.
|
|
261
|
+
*/
|
|
262
|
+
claim(address: string): Promise<{
|
|
203
263
|
call: `0x${string}`;
|
|
264
|
+
asset: Asset;
|
|
204
265
|
amount: string | null;
|
|
205
266
|
hash: Hash;
|
|
206
267
|
block: number;
|
|
@@ -209,8 +270,9 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
209
270
|
explorerUrl: string | null;
|
|
210
271
|
}>;
|
|
211
272
|
/** Pays the opener's bond and fee share. Anyone can send it; the money only ever goes to the opener. */
|
|
212
|
-
claimOpener
|
|
273
|
+
claimOpener(address: string): Promise<{
|
|
213
274
|
call: `0x${string}`;
|
|
275
|
+
asset: Asset;
|
|
214
276
|
opener: `0x${string}` | null;
|
|
215
277
|
amount: string | null;
|
|
216
278
|
hash: Hash;
|
|
@@ -220,7 +282,7 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
220
282
|
explorerUrl: string | null;
|
|
221
283
|
}>;
|
|
222
284
|
/** Makes a Settled Call Final once its dispute window has passed. Anyone can send it. */
|
|
223
|
-
finalize
|
|
285
|
+
finalize(address: string): Promise<{
|
|
224
286
|
call: `0x${string}`;
|
|
225
287
|
hash: Hash;
|
|
226
288
|
block: number;
|
|
@@ -228,10 +290,16 @@ export declare function createClient(options?: ClientOptions): {
|
|
|
228
290
|
fee: import("./types.js").Wei;
|
|
229
291
|
explorerUrl: string | null;
|
|
230
292
|
}>;
|
|
231
|
-
/**
|
|
232
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Disputes a settled result inside its window, posting the dispute bond: 0.02 ETH on an ETH Call, 20 USDG on a USDG
|
|
295
|
+
* Call, which pulls it after an approval of exactly the bond to the Call. The court rules; the bond comes back if it
|
|
296
|
+
* flips the result.
|
|
297
|
+
*/
|
|
298
|
+
dispute(address: string): Promise<{
|
|
233
299
|
call: `0x${string}`;
|
|
300
|
+
asset: Asset;
|
|
234
301
|
bond: string;
|
|
302
|
+
approval: Tx | null;
|
|
235
303
|
hash: Hash;
|
|
236
304
|
block: number;
|
|
237
305
|
gasUsed: string;
|