@shippedcalls/sdk 0.3.1 → 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/src/types.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import type { Address, Hash, Hex } from "viem";
2
+ import type { Asset, AssetSymbol } from "./assets.js";
2
3
  import type { Side } from "./odds.js";
3
4
 
4
- // The API's answers as served: amounts are wei as decimal strings, times unix seconds. Compare addresses without
5
- // case: some routes checksum them and some lowercase them. GET /v1/openapi.json is the full description.
5
+ // The API's answers as served: amounts are base units of the Call's asset as decimal strings (wei on an ETH Call,
6
+ // millionths on a USDG Call), times unix seconds. Compare addresses without case: some routes checksum them and some
7
+ // lowercase them. GET /v1/openapi.json is the full description.
6
8
 
7
9
  export type CallStatus = "open" | "settled" | "disputed" | "final" | "voided";
8
10
  export type CallType = "posted" | "onchain" | "price" | "deed";
9
11
  export type Wei = string;
12
+ /** Base units of the Call's own asset, as a decimal string: wei for ETH, millionths for USDG. */
13
+ export type Units = string;
10
14
 
11
15
  export interface Post {
12
16
  id: string | null;
@@ -36,9 +40,14 @@ export interface CallSummary {
36
40
  closeAt: number;
37
41
  deadline: number;
38
42
  openedAt: number;
39
- bond: Wei;
43
+ /** What the Call is staked in. Every amount on it is in base units of this asset. */
44
+ asset: Asset;
45
+ bond: Units;
46
+ /** The bonus pot sponsors added, shared by the winners on top of the losing pool. Always "0" on an ETH Call. */
47
+ bonus: Units;
40
48
  deedId: string | null;
41
- pools: { holds: Wei; breaks: Wei; total: Wei; eth: number };
49
+ /** `eth` is the pot in ETH, null on a USDG Call; `amount` is the pot in whole units of the Call's asset. */
50
+ pools: { holds: Units; breaks: Units; total: Units; eth: number | null; amount: number };
42
51
  odds: { holdsBps: number; breaksBps: number; holdsMultiple: number | null; breaksMultiple: number | null; lopsided: number };
43
52
  betCount: number;
44
53
  outcome: Side | null;
@@ -54,7 +63,7 @@ export interface CallSummary {
54
63
  export interface CallRow extends CallSummary {
55
64
  spark: number[];
56
65
  change1h: number;
57
- recentStake: Wei;
66
+ recentStake: Units;
58
67
  recentBets15: number;
59
68
  }
60
69
 
@@ -63,9 +72,9 @@ export interface Bet {
63
72
  logIndex: number;
64
73
  bettor: Address;
65
74
  side: Side;
66
- amount: Wei;
67
- holdsPool: Wei;
68
- breaksPool: Wei;
75
+ amount: Units;
76
+ holdsPool: Units;
77
+ breaksPool: Units;
69
78
  block: number;
70
79
  at: number;
71
80
  tag: Tag;
@@ -79,20 +88,22 @@ export interface CallDetail extends CallSummary {
79
88
  evidence: { hash: Hash; url: string; matchesChain: boolean | null } | null;
80
89
  settledBy: Address | null;
81
90
  disputer: Address | null;
82
- disputeBond: Wei | null;
91
+ disputeBond: Units | null;
83
92
  disputedAt: number | null;
84
93
  resolvedAt: number | null;
85
- winnersPool: Wei | null;
86
- losersPool: Wei | null;
87
- rake: Wei | null;
88
- openerPaid: Wei | null;
89
- treasuryPaid: Wei | null;
94
+ winnersPool: Units | null;
95
+ losersPool: Units | null;
96
+ rake: Units | null;
97
+ openerPaid: Units | null;
98
+ treasuryPaid: Units | null;
90
99
  openerAtFault: boolean | null;
91
100
  reasonHash: Hash | null;
92
101
  openedBlock: number;
93
102
  openedTx: Hash;
94
103
  unresolvable: { reason: string; refundsAt: number } | null;
95
104
  bets: Bet[];
105
+ /** Every addition to the bonus pot, newest first. Empty on an ETH Call. */
106
+ bonuses: { txHash: Hash; logIndex: number; sponsor: Address; amount: Units; bonus: Units; block: number; at: number }[];
96
107
  records: { tokenId: number; account: Address; collection: Address | null; txHash: Hash; block: number; at: number }[] | null;
97
108
  }
98
109
 
@@ -102,11 +113,13 @@ export interface RecentBet {
102
113
  callAddress: Address;
103
114
  bettor: Address;
104
115
  side: Side;
105
- amount: Wei;
116
+ amount: Units;
117
+ /** What the Call is staked in, and so what `amount` and `pools` are in. */
118
+ asset: AssetSymbol;
106
119
  block: number;
107
120
  at: number;
108
121
  callTextHash: Hash;
109
- pools: { holds: Wei; breaks: Wei };
122
+ pools: { holds: Units; breaks: Units };
110
123
  tag: Tag;
111
124
  }
112
125
 
@@ -203,18 +216,22 @@ export interface Proof {
203
216
  export interface Quote {
204
217
  call: Address;
205
218
  side: Side;
206
- amount: Wei;
219
+ amount: Units;
220
+ /** What the Call is staked in. Every amount in the quote is in base units of it. */
221
+ asset: Asset;
222
+ /** The bonus pot counted in `payout`. "0" on an ETH Call. */
223
+ bonus: Units;
207
224
  status: CallStatus;
208
225
  bettingOpen: boolean;
209
226
  closeAt: number;
210
- minBet: Wei;
211
- pools: { holds: Wei; breaks: Wei };
212
- poolsAfter: { holds: Wei; breaks: Wei };
227
+ minBet: Units;
228
+ pools: { holds: Units; breaks: Units };
229
+ poolsAfter: { holds: Units; breaks: Units };
213
230
  impliedBps: number | null;
214
231
  impliedBpsAfter: number;
215
- /** If this side wins, with the pools as the bet leaves them. Later bets move it until betting closes. */
216
- payout: Wei;
217
- profit: Wei;
232
+ /** If this side wins, with the pools as the bet leaves them and its share of any bonus. Later bets move it until betting closes. */
233
+ payout: Units;
234
+ profit: Units;
218
235
  multiple: number;
219
236
  /** The other side is empty. If it stays empty every stake comes back and nobody wins. */
220
237
  refund: boolean;
@@ -297,15 +314,49 @@ export interface Settlement {
297
314
 
298
315
  export interface Positions {
299
316
  address: Address;
300
- /** The wallet's ETH on the chain, or null when no endpoint answered. */
301
- balance: Wei | null;
317
+ /** The asset these positions are staked in. ETH unless asked for another; no figure adds one asset to another. */
318
+ asset: Asset;
319
+ /** The wallet's balance of `asset` on the chain, or null when no endpoint answered. */
320
+ balance: Units | null;
321
+ /** The wallet's ETH, which pays the gas whatever the stake is in. On an ETH read it is `balance`. */
322
+ gas: Wei | null;
302
323
  positions: Player["positions"];
303
324
  /** Newest 50 Final and Voided Calls, each with what `claim()` pays now (`owed`, null when no endpoint answered). */
304
- settled: (Player["shelf"][number] & { owed: Wei | null })[];
325
+ settled: (Player["shelf"][number] & { owed: Units | null })[];
305
326
  week: Player["week"];
306
327
  all: Player["all"];
307
328
  }
308
329
 
330
+ /** What a USDG write needs from the wallet before it goes, read from the chain. */
331
+ export interface Approval {
332
+ token: Address;
333
+ /** The contract the wallet lets take its USDG: the USDG factory for a bet or a bonus, the Call for a dispute. */
334
+ spender: Address;
335
+ owner: Address;
336
+ balance: Units;
337
+ allowance: Units;
338
+ amount: Units;
339
+ /** The allowance to set first, exactly `amount`, or null when the allowance already covers it. A separate transaction. */
340
+ approve: Units | null;
341
+ /** How much USDG the wallet lacks. "0" when it holds enough. */
342
+ short: Units;
343
+ }
344
+
345
+ /** What adding to a USDG Call's bonus pot does, with the pot as it stands. */
346
+ export interface BonusQuote {
347
+ call: Address;
348
+ asset: Asset;
349
+ amount: Units;
350
+ status: CallStatus;
351
+ bettingOpen: boolean;
352
+ closeAt: number;
353
+ pools: { holds: Units; breaks: Units };
354
+ bonus: Units;
355
+ bonusAfter: Units;
356
+ /** What this wallet has put in the pot so far, or null without a wallet. */
357
+ sponsored: Units | null;
358
+ }
359
+
309
360
  export type RoundOutcome = "up" | "down" | "refunded";
310
361
  export type RoundSide = "up" | "down";
311
362