@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 +42 -2
- package/dist/abi.d.ts +264 -0
- package/dist/abi.js +342 -0
- package/dist/abi.js.map +1 -1
- package/dist/chain.d.ts +2 -0
- package/dist/chain.js +2 -0
- package/dist/chain.js.map +1 -1
- package/dist/cli.js +87 -4
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +57 -3
- package/dist/client.js +86 -9
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +22 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +588 -0
- package/dist/jobs.js +347 -0
- package/dist/jobs.js.map +1 -0
- package/dist/odds.d.ts +4 -0
- package/dist/odds.js +13 -0
- package/dist/odds.js.map +1 -1
- package/dist/types.d.ts +31 -8
- package/package.json +1 -1
- package/skill/SKILL.md +9 -2
- package/skill/references/api.md +6 -1
- package/skill/references/jobs.md +30 -0
- package/skill/references/rounds.md +16 -7
- package/skill/references/write-path.md +4 -0
- package/skill/scripts/calls.sh +1 -1
- package/src/abi.ts +342 -0
- package/src/chain.ts +2 -0
- package/src/cli.ts +76 -4
- package/src/client.ts +88 -9
- package/src/errors.ts +24 -1
- package/src/index.ts +4 -3
- package/src/jobs.ts +467 -0
- package/src/odds.ts +14 -0
- package/src/types.ts +14 -6
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# Rounds
|
|
2
2
|
|
|
3
|
-
Five minutes, up or down, on ETH, BTC and SOL, around the clock. You stake ETH on Up or Down before a round locks. Five minutes after the lock, the price decides and
|
|
3
|
+
Five minutes, up or down, on ETH, BTC and SOL, around the clock. You stake ETH on Up or Down before a round locks. Five minutes after the lock, the price decides. Only matched stake plays, and a win pays it back 1.94 times.
|
|
4
4
|
|
|
5
5
|
## How a round runs
|
|
6
6
|
|
|
7
7
|
- Epoch `e = floor(unix seconds / 300)` takes bets until ten seconds before `(e + 1) * 300`, locks there, and closes at `(e + 2) * 300`.
|
|
8
8
|
- Close above lock, Up wins. Close below lock, Down wins.
|
|
9
9
|
- A tie, or a round with money on one side only, refunds everyone with no fee.
|
|
10
|
-
- The
|
|
10
|
+
- Only matched stake plays. The smaller side's total plays against the same amount from the larger side, and the larger side's excess comes back to its wallets pro rata, win or lose.
|
|
11
|
+
- The fee is 3% of what plays, so a fully matched win pays 1.94 times the stake and a holder's pays 1.97 times.
|
|
11
12
|
- A wallet stakes 0.001 to 0.5 ETH in a round, on one side, and may add to it.
|
|
12
|
-
-
|
|
13
|
-
-
|
|
13
|
+
- The lock and close prices are Pyth's first signed price at or after each moment. Pyth's contract checks every one onchain and anyone can post them, so Shipped can't choose a result. If a round goes an hour without its prices, anyone can void it, which refunds every stake.
|
|
14
|
+
- Close to the lock, a Shipped agent may match up to 0.005 ETH of a stake that's alone in a round, and the rest comes back.
|
|
15
|
+
- Three or more wins in a row, across markets with refunds ignored, earns a card: an NFT minted to the winner when they collect. 10% of that win's profit buys $SHIPPED for them in the same transaction, up to 0.05 ETH on one Collect. If the buy fails, they get it in ETH.
|
|
16
|
+
- A wallet holding 1,000,000 $SHIPPED at its first bet in a round and again when it collects pays 1.5% on its share of that round instead of 3%. `terms.holdMin` in `GET /v1/rounds` is the current amount.
|
|
14
17
|
|
|
15
18
|
## Reading
|
|
16
19
|
|
|
@@ -23,7 +26,9 @@ GET /v1/rounds/{market}/{epoch}/card/{address}.png a wallet's result as a shar
|
|
|
23
26
|
GET /v1/accounts/{address}/rounds streak, today's stake and profit, what it can collect, its limit
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
While `open` is false
|
|
29
|
+
While `open` is false rounds aren't being priced, so don't bet: the stake would wait out the hour and refund. In the last ten seconds before a lock, `betting` still names the round that has stopped taking bets: its `cutoffAt` is in the past, and the next round opens at the lock.
|
|
30
|
+
|
|
31
|
+
`unclaimed` in the account route lists the oldest 40 rounds, which is what one claim takes. `unclaimedRounds` counts all of them.
|
|
27
32
|
|
|
28
33
|
## Writing
|
|
29
34
|
|
|
@@ -31,17 +36,21 @@ The contract's address is `contract` in `GET /v1/rounds`.
|
|
|
31
36
|
|
|
32
37
|
- `bet(bytes32 market, bool up)` with the stake as the value. `market` is the symbol as left-aligned bytes32.
|
|
33
38
|
- `claim(bytes32[] markets, uint256[] epochs)` collects winnings and refunds. `unclaimed` in the account route lists what to pass.
|
|
39
|
+
- `setPlainWins(bool plain)` takes every win in ETH, with no card and no buy.
|
|
34
40
|
- `setLimit(uint256 cap)` sets the wallet's own daily stake limit. Lowering it applies at once; raising or removing it takes 24 hours.
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
`claim` also hands a losing wallet its unmatched stake.
|
|
43
|
+
|
|
44
|
+
From the CLI: `calls rounds bet ETH up 0.001 --yes`, `calls rounds claim`, `calls rounds plain-wins on` and `calls rounds limit 0.01`. From the SDK: `rounds.quote("ETH", "up", amount)`, `rounds.bet("ETH", "up", amount)`, `rounds.claim()`, `rounds.setPlainWins(true)` and `rounds.setLimit(cap)`. From MCP: `rounds_bet`, `rounds_claim` and `rounds_plain_wins`.
|
|
37
45
|
|
|
38
46
|
## Errors
|
|
39
47
|
|
|
40
48
|
| Error | Meaning |
|
|
41
49
|
| - | - |
|
|
42
|
-
| `TooLate` | The round has stopped taking bets. The next one
|
|
50
|
+
| `TooLate` | The round has stopped taking bets. The next one opens at the lock, within ten seconds. |
|
|
43
51
|
| `BelowMinimum` | The minimum is 0.001 ETH. |
|
|
44
52
|
| `OverStakeCap` | One wallet can stake up to 0.5 ETH in a round. |
|
|
45
53
|
| `OverDailyLimit` | This would pass the daily limit the wallet set for itself. |
|
|
46
54
|
| `OtherSide` | The wallet is already on the other side of this round. |
|
|
47
55
|
| `MarketPaused` | This market isn't taking bets right now. |
|
|
56
|
+
| `GasTooLow` | A win's card and buy need more gas. Send at least the estimate. |
|
|
@@ -66,3 +66,7 @@ calls open --text "Shipped bond #1 is accepted by its deadline." --bond-number 1
|
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
`calls open` does both steps, checks the API's hashes against its own before it spends anything, and reads a bond Call's deadline from Shipped's registry.
|
|
69
|
+
|
|
70
|
+
## Rounds
|
|
71
|
+
|
|
72
|
+
Rounds has its own contract and its own write path: see `references/rounds.md`.
|
package/skill/scripts/calls.sh
CHANGED
package/src/abi.ts
CHANGED
|
@@ -2159,6 +2159,21 @@ export const roundsAbi = [
|
|
|
2159
2159
|
"name": "sources_",
|
|
2160
2160
|
"type": "address[]",
|
|
2161
2161
|
"internalType": "contract IPriceSource[]"
|
|
2162
|
+
},
|
|
2163
|
+
{
|
|
2164
|
+
"name": "holdToken",
|
|
2165
|
+
"type": "address",
|
|
2166
|
+
"internalType": "address"
|
|
2167
|
+
},
|
|
2168
|
+
{
|
|
2169
|
+
"name": "holdMin_",
|
|
2170
|
+
"type": "uint256",
|
|
2171
|
+
"internalType": "uint256"
|
|
2172
|
+
},
|
|
2173
|
+
{
|
|
2174
|
+
"name": "cards_",
|
|
2175
|
+
"type": "address",
|
|
2176
|
+
"internalType": "contract IRoundCards"
|
|
2162
2177
|
}
|
|
2163
2178
|
],
|
|
2164
2179
|
"stateMutability": "nonpayable"
|
|
@@ -2176,6 +2191,58 @@ export const roundsAbi = [
|
|
|
2176
2191
|
],
|
|
2177
2192
|
"stateMutability": "view"
|
|
2178
2193
|
},
|
|
2194
|
+
{
|
|
2195
|
+
"type": "function",
|
|
2196
|
+
"name": "CARD_CUT_BPS",
|
|
2197
|
+
"inputs": [],
|
|
2198
|
+
"outputs": [
|
|
2199
|
+
{
|
|
2200
|
+
"name": "",
|
|
2201
|
+
"type": "uint256",
|
|
2202
|
+
"internalType": "uint256"
|
|
2203
|
+
}
|
|
2204
|
+
],
|
|
2205
|
+
"stateMutability": "view"
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
"type": "function",
|
|
2209
|
+
"name": "CARD_STREAK",
|
|
2210
|
+
"inputs": [],
|
|
2211
|
+
"outputs": [
|
|
2212
|
+
{
|
|
2213
|
+
"name": "",
|
|
2214
|
+
"type": "uint256",
|
|
2215
|
+
"internalType": "uint256"
|
|
2216
|
+
}
|
|
2217
|
+
],
|
|
2218
|
+
"stateMutability": "view"
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
"type": "function",
|
|
2222
|
+
"name": "HOLDER_RAKE_BPS",
|
|
2223
|
+
"inputs": [],
|
|
2224
|
+
"outputs": [
|
|
2225
|
+
{
|
|
2226
|
+
"name": "",
|
|
2227
|
+
"type": "uint256",
|
|
2228
|
+
"internalType": "uint256"
|
|
2229
|
+
}
|
|
2230
|
+
],
|
|
2231
|
+
"stateMutability": "view"
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
"type": "function",
|
|
2235
|
+
"name": "HOLD_TOKEN",
|
|
2236
|
+
"inputs": [],
|
|
2237
|
+
"outputs": [
|
|
2238
|
+
{
|
|
2239
|
+
"name": "",
|
|
2240
|
+
"type": "address",
|
|
2241
|
+
"internalType": "address"
|
|
2242
|
+
}
|
|
2243
|
+
],
|
|
2244
|
+
"stateMutability": "view"
|
|
2245
|
+
},
|
|
2179
2246
|
{
|
|
2180
2247
|
"type": "function",
|
|
2181
2248
|
"name": "INTERVAL",
|
|
@@ -2202,6 +2269,19 @@ export const roundsAbi = [
|
|
|
2202
2269
|
],
|
|
2203
2270
|
"stateMutability": "view"
|
|
2204
2271
|
},
|
|
2272
|
+
{
|
|
2273
|
+
"type": "function",
|
|
2274
|
+
"name": "MAX_CARD_CUT",
|
|
2275
|
+
"inputs": [],
|
|
2276
|
+
"outputs": [
|
|
2277
|
+
{
|
|
2278
|
+
"name": "",
|
|
2279
|
+
"type": "uint256",
|
|
2280
|
+
"internalType": "uint256"
|
|
2281
|
+
}
|
|
2282
|
+
],
|
|
2283
|
+
"stateMutability": "view"
|
|
2284
|
+
},
|
|
2205
2285
|
{
|
|
2206
2286
|
"type": "function",
|
|
2207
2287
|
"name": "MAX_STAKE",
|
|
@@ -2320,6 +2400,19 @@ export const roundsAbi = [
|
|
|
2320
2400
|
"outputs": [],
|
|
2321
2401
|
"stateMutability": "payable"
|
|
2322
2402
|
},
|
|
2403
|
+
{
|
|
2404
|
+
"type": "function",
|
|
2405
|
+
"name": "cards",
|
|
2406
|
+
"inputs": [],
|
|
2407
|
+
"outputs": [
|
|
2408
|
+
{
|
|
2409
|
+
"name": "",
|
|
2410
|
+
"type": "address",
|
|
2411
|
+
"internalType": "contract IRoundCards"
|
|
2412
|
+
}
|
|
2413
|
+
],
|
|
2414
|
+
"stateMutability": "view"
|
|
2415
|
+
},
|
|
2323
2416
|
{
|
|
2324
2417
|
"type": "function",
|
|
2325
2418
|
"name": "claim",
|
|
@@ -2419,6 +2512,38 @@ export const roundsAbi = [
|
|
|
2419
2512
|
],
|
|
2420
2513
|
"stateMutability": "view"
|
|
2421
2514
|
},
|
|
2515
|
+
{
|
|
2516
|
+
"type": "function",
|
|
2517
|
+
"name": "holdMin",
|
|
2518
|
+
"inputs": [],
|
|
2519
|
+
"outputs": [
|
|
2520
|
+
{
|
|
2521
|
+
"name": "",
|
|
2522
|
+
"type": "uint256",
|
|
2523
|
+
"internalType": "uint256"
|
|
2524
|
+
}
|
|
2525
|
+
],
|
|
2526
|
+
"stateMutability": "view"
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
"type": "function",
|
|
2530
|
+
"name": "holds",
|
|
2531
|
+
"inputs": [
|
|
2532
|
+
{
|
|
2533
|
+
"name": "wallet",
|
|
2534
|
+
"type": "address",
|
|
2535
|
+
"internalType": "address"
|
|
2536
|
+
}
|
|
2537
|
+
],
|
|
2538
|
+
"outputs": [
|
|
2539
|
+
{
|
|
2540
|
+
"name": "",
|
|
2541
|
+
"type": "bool",
|
|
2542
|
+
"internalType": "bool"
|
|
2543
|
+
}
|
|
2544
|
+
],
|
|
2545
|
+
"stateMutability": "view"
|
|
2546
|
+
},
|
|
2422
2547
|
{
|
|
2423
2548
|
"type": "function",
|
|
2424
2549
|
"name": "limitOf",
|
|
@@ -2543,6 +2668,25 @@ export const roundsAbi = [
|
|
|
2543
2668
|
],
|
|
2544
2669
|
"stateMutability": "view"
|
|
2545
2670
|
},
|
|
2671
|
+
{
|
|
2672
|
+
"type": "function",
|
|
2673
|
+
"name": "plainWins",
|
|
2674
|
+
"inputs": [
|
|
2675
|
+
{
|
|
2676
|
+
"name": "wallet",
|
|
2677
|
+
"type": "address",
|
|
2678
|
+
"internalType": "address"
|
|
2679
|
+
}
|
|
2680
|
+
],
|
|
2681
|
+
"outputs": [
|
|
2682
|
+
{
|
|
2683
|
+
"name": "",
|
|
2684
|
+
"type": "bool",
|
|
2685
|
+
"internalType": "bool"
|
|
2686
|
+
}
|
|
2687
|
+
],
|
|
2688
|
+
"stateMutability": "view"
|
|
2689
|
+
},
|
|
2546
2690
|
{
|
|
2547
2691
|
"type": "function",
|
|
2548
2692
|
"name": "positionOf",
|
|
@@ -2582,6 +2726,50 @@ export const roundsAbi = [
|
|
|
2582
2726
|
],
|
|
2583
2727
|
"stateMutability": "view"
|
|
2584
2728
|
},
|
|
2729
|
+
{
|
|
2730
|
+
"type": "function",
|
|
2731
|
+
"name": "preview",
|
|
2732
|
+
"inputs": [
|
|
2733
|
+
{
|
|
2734
|
+
"name": "market",
|
|
2735
|
+
"type": "bytes32",
|
|
2736
|
+
"internalType": "bytes32"
|
|
2737
|
+
},
|
|
2738
|
+
{
|
|
2739
|
+
"name": "epoch",
|
|
2740
|
+
"type": "uint256",
|
|
2741
|
+
"internalType": "uint256"
|
|
2742
|
+
},
|
|
2743
|
+
{
|
|
2744
|
+
"name": "wallet",
|
|
2745
|
+
"type": "address",
|
|
2746
|
+
"internalType": "address"
|
|
2747
|
+
}
|
|
2748
|
+
],
|
|
2749
|
+
"outputs": [
|
|
2750
|
+
{
|
|
2751
|
+
"name": "amount",
|
|
2752
|
+
"type": "uint256",
|
|
2753
|
+
"internalType": "uint256"
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
"name": "cut",
|
|
2757
|
+
"type": "uint256",
|
|
2758
|
+
"internalType": "uint256"
|
|
2759
|
+
},
|
|
2760
|
+
{
|
|
2761
|
+
"name": "streak",
|
|
2762
|
+
"type": "uint256",
|
|
2763
|
+
"internalType": "uint256"
|
|
2764
|
+
},
|
|
2765
|
+
{
|
|
2766
|
+
"name": "card",
|
|
2767
|
+
"type": "bool",
|
|
2768
|
+
"internalType": "bool"
|
|
2769
|
+
}
|
|
2770
|
+
],
|
|
2771
|
+
"stateMutability": "view"
|
|
2772
|
+
},
|
|
2585
2773
|
{
|
|
2586
2774
|
"type": "function",
|
|
2587
2775
|
"name": "prices",
|
|
@@ -2668,6 +2856,32 @@ export const roundsAbi = [
|
|
|
2668
2856
|
],
|
|
2669
2857
|
"stateMutability": "view"
|
|
2670
2858
|
},
|
|
2859
|
+
{
|
|
2860
|
+
"type": "function",
|
|
2861
|
+
"name": "setCards",
|
|
2862
|
+
"inputs": [
|
|
2863
|
+
{
|
|
2864
|
+
"name": "cards_",
|
|
2865
|
+
"type": "address",
|
|
2866
|
+
"internalType": "contract IRoundCards"
|
|
2867
|
+
}
|
|
2868
|
+
],
|
|
2869
|
+
"outputs": [],
|
|
2870
|
+
"stateMutability": "nonpayable"
|
|
2871
|
+
},
|
|
2872
|
+
{
|
|
2873
|
+
"type": "function",
|
|
2874
|
+
"name": "setHoldMin",
|
|
2875
|
+
"inputs": [
|
|
2876
|
+
{
|
|
2877
|
+
"name": "holdMin_",
|
|
2878
|
+
"type": "uint256",
|
|
2879
|
+
"internalType": "uint256"
|
|
2880
|
+
}
|
|
2881
|
+
],
|
|
2882
|
+
"outputs": [],
|
|
2883
|
+
"stateMutability": "nonpayable"
|
|
2884
|
+
},
|
|
2671
2885
|
{
|
|
2672
2886
|
"type": "function",
|
|
2673
2887
|
"name": "setLimit",
|
|
@@ -2699,6 +2913,19 @@ export const roundsAbi = [
|
|
|
2699
2913
|
"outputs": [],
|
|
2700
2914
|
"stateMutability": "nonpayable"
|
|
2701
2915
|
},
|
|
2916
|
+
{
|
|
2917
|
+
"type": "function",
|
|
2918
|
+
"name": "setPlainWins",
|
|
2919
|
+
"inputs": [
|
|
2920
|
+
{
|
|
2921
|
+
"name": "plain",
|
|
2922
|
+
"type": "bool",
|
|
2923
|
+
"internalType": "bool"
|
|
2924
|
+
}
|
|
2925
|
+
],
|
|
2926
|
+
"outputs": [],
|
|
2927
|
+
"stateMutability": "nonpayable"
|
|
2928
|
+
},
|
|
2702
2929
|
{
|
|
2703
2930
|
"type": "function",
|
|
2704
2931
|
"name": "setTreasury",
|
|
@@ -2712,6 +2939,35 @@ export const roundsAbi = [
|
|
|
2712
2939
|
"outputs": [],
|
|
2713
2940
|
"stateMutability": "nonpayable"
|
|
2714
2941
|
},
|
|
2942
|
+
{
|
|
2943
|
+
"type": "function",
|
|
2944
|
+
"name": "streakOf",
|
|
2945
|
+
"inputs": [
|
|
2946
|
+
{
|
|
2947
|
+
"name": "market",
|
|
2948
|
+
"type": "bytes32",
|
|
2949
|
+
"internalType": "bytes32"
|
|
2950
|
+
},
|
|
2951
|
+
{
|
|
2952
|
+
"name": "epoch",
|
|
2953
|
+
"type": "uint256",
|
|
2954
|
+
"internalType": "uint256"
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
"name": "wallet",
|
|
2958
|
+
"type": "address",
|
|
2959
|
+
"internalType": "address"
|
|
2960
|
+
}
|
|
2961
|
+
],
|
|
2962
|
+
"outputs": [
|
|
2963
|
+
{
|
|
2964
|
+
"name": "",
|
|
2965
|
+
"type": "uint256",
|
|
2966
|
+
"internalType": "uint256"
|
|
2967
|
+
}
|
|
2968
|
+
],
|
|
2969
|
+
"stateMutability": "view"
|
|
2970
|
+
},
|
|
2715
2971
|
{
|
|
2716
2972
|
"type": "function",
|
|
2717
2973
|
"name": "treasury",
|
|
@@ -2805,6 +3061,50 @@ export const roundsAbi = [
|
|
|
2805
3061
|
],
|
|
2806
3062
|
"anonymous": false
|
|
2807
3063
|
},
|
|
3064
|
+
{
|
|
3065
|
+
"type": "event",
|
|
3066
|
+
"name": "CardCut",
|
|
3067
|
+
"inputs": [
|
|
3068
|
+
{
|
|
3069
|
+
"name": "wallet",
|
|
3070
|
+
"type": "address",
|
|
3071
|
+
"indexed": true,
|
|
3072
|
+
"internalType": "address"
|
|
3073
|
+
},
|
|
3074
|
+
{
|
|
3075
|
+
"name": "cards",
|
|
3076
|
+
"type": "uint256",
|
|
3077
|
+
"indexed": false,
|
|
3078
|
+
"internalType": "uint256"
|
|
3079
|
+
},
|
|
3080
|
+
{
|
|
3081
|
+
"name": "cut",
|
|
3082
|
+
"type": "uint256",
|
|
3083
|
+
"indexed": false,
|
|
3084
|
+
"internalType": "uint256"
|
|
3085
|
+
},
|
|
3086
|
+
{
|
|
3087
|
+
"name": "paid",
|
|
3088
|
+
"type": "bool",
|
|
3089
|
+
"indexed": false,
|
|
3090
|
+
"internalType": "bool"
|
|
3091
|
+
}
|
|
3092
|
+
],
|
|
3093
|
+
"anonymous": false
|
|
3094
|
+
},
|
|
3095
|
+
{
|
|
3096
|
+
"type": "event",
|
|
3097
|
+
"name": "CardsSet",
|
|
3098
|
+
"inputs": [
|
|
3099
|
+
{
|
|
3100
|
+
"name": "cards",
|
|
3101
|
+
"type": "address",
|
|
3102
|
+
"indexed": true,
|
|
3103
|
+
"internalType": "address"
|
|
3104
|
+
}
|
|
3105
|
+
],
|
|
3106
|
+
"anonymous": false
|
|
3107
|
+
},
|
|
2808
3108
|
{
|
|
2809
3109
|
"type": "event",
|
|
2810
3110
|
"name": "Claimed",
|
|
@@ -2911,6 +3211,19 @@ export const roundsAbi = [
|
|
|
2911
3211
|
],
|
|
2912
3212
|
"anonymous": false
|
|
2913
3213
|
},
|
|
3214
|
+
{
|
|
3215
|
+
"type": "event",
|
|
3216
|
+
"name": "HoldMinSet",
|
|
3217
|
+
"inputs": [
|
|
3218
|
+
{
|
|
3219
|
+
"name": "holdMin",
|
|
3220
|
+
"type": "uint256",
|
|
3221
|
+
"indexed": false,
|
|
3222
|
+
"internalType": "uint256"
|
|
3223
|
+
}
|
|
3224
|
+
],
|
|
3225
|
+
"anonymous": false
|
|
3226
|
+
},
|
|
2914
3227
|
{
|
|
2915
3228
|
"type": "event",
|
|
2916
3229
|
"name": "LimitSet",
|
|
@@ -2974,6 +3287,25 @@ export const roundsAbi = [
|
|
|
2974
3287
|
],
|
|
2975
3288
|
"anonymous": false
|
|
2976
3289
|
},
|
|
3290
|
+
{
|
|
3291
|
+
"type": "event",
|
|
3292
|
+
"name": "PlainWinsSet",
|
|
3293
|
+
"inputs": [
|
|
3294
|
+
{
|
|
3295
|
+
"name": "wallet",
|
|
3296
|
+
"type": "address",
|
|
3297
|
+
"indexed": true,
|
|
3298
|
+
"internalType": "address"
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
"name": "plain",
|
|
3302
|
+
"type": "bool",
|
|
3303
|
+
"indexed": false,
|
|
3304
|
+
"internalType": "bool"
|
|
3305
|
+
}
|
|
3306
|
+
],
|
|
3307
|
+
"anonymous": false
|
|
3308
|
+
},
|
|
2977
3309
|
{
|
|
2978
3310
|
"type": "event",
|
|
2979
3311
|
"name": "Priced",
|
|
@@ -3086,6 +3418,11 @@ export const roundsAbi = [
|
|
|
3086
3418
|
"name": "BelowMinimum",
|
|
3087
3419
|
"inputs": []
|
|
3088
3420
|
},
|
|
3421
|
+
{
|
|
3422
|
+
"type": "error",
|
|
3423
|
+
"name": "GasTooLow",
|
|
3424
|
+
"inputs": []
|
|
3425
|
+
},
|
|
3089
3426
|
{
|
|
3090
3427
|
"type": "error",
|
|
3091
3428
|
"name": "MarketExists",
|
|
@@ -3111,6 +3448,11 @@ export const roundsAbi = [
|
|
|
3111
3448
|
"name": "NothingToClaim",
|
|
3112
3449
|
"inputs": []
|
|
3113
3450
|
},
|
|
3451
|
+
{
|
|
3452
|
+
"type": "error",
|
|
3453
|
+
"name": "NothingToVoid",
|
|
3454
|
+
"inputs": []
|
|
3455
|
+
},
|
|
3114
3456
|
{
|
|
3115
3457
|
"type": "error",
|
|
3116
3458
|
"name": "OtherSide",
|
package/src/chain.ts
CHANGED
|
@@ -8,6 +8,8 @@ export const CALLED_IT = "0x500855cA9F281A1383482399ADDd1651269BB866" as const;
|
|
|
8
8
|
/** Earlier factories whose Calls are still running, newest first. They stay Calls: bets, claims and disputes go on. */
|
|
9
9
|
export const PREVIOUS_FACTORIES: readonly `0x${string}`[] = ["0xf1F8E31D084B516b62E5646C684F7e955E8dA378"];
|
|
10
10
|
export const DEEDS = "0xD5Da523ee49CB7Fe855B0C6fa38707190A9D531F" as const;
|
|
11
|
+
export const USDG = "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168" as const;
|
|
12
|
+
export const COUNCIL = "0x71b3F054cfc653d1BA6433b8EF6a5627fA5692db" as const;
|
|
11
13
|
|
|
12
14
|
// The order Shipped's own services run: the official endpoint, then POKT, which also serves old state, then dRPC.
|
|
13
15
|
export const RPC_URLS = ["https://rpc.mainnet.chain.robinhood.com", "https://robinhood.api.pocket.network", "https://robinhood.drpc.org"] as const;
|
package/src/cli.ts
CHANGED
|
@@ -8,6 +8,13 @@ import { CallsError } from "./errors.js";
|
|
|
8
8
|
import { ethToWei } from "./odds.js";
|
|
9
9
|
import type { CallDetail, CallRow, Quote } from "./types.js";
|
|
10
10
|
|
|
11
|
+
const NOT_A_QUOTE = "--quote only works with bet and open. This command would send a transaction.";
|
|
12
|
+
/** The ETH the next claim brings, and what of it goes on $SHIPPED. */
|
|
13
|
+
const collecting = (a: { unclaimedTotal: string; cutTotal: string }) => {
|
|
14
|
+
const cut = BigInt(a.cutTotal);
|
|
15
|
+
return cut > 0n ? `${eth(BigInt(a.unclaimedTotal) - cut)} in ETH and ${eth(cut)} to $SHIPPED` : eth(a.unclaimedTotal);
|
|
16
|
+
};
|
|
17
|
+
|
|
11
18
|
const HELP = `calls: read and bet on Shipped Calls, ETH markets on whether a public claim holds, on Robinhood Chain.
|
|
12
19
|
|
|
13
20
|
Read, no wallet needed:
|
|
@@ -16,15 +23,21 @@ Read, no wallet needed:
|
|
|
16
23
|
calls quote <address> <holds|breaks> <eth>
|
|
17
24
|
calls positions [<wallet>]
|
|
18
25
|
calls proof
|
|
26
|
+
calls rounds [<market>]
|
|
27
|
+
calls rounds history [<wallet>]
|
|
19
28
|
|
|
20
29
|
Write, with CALLS_PRIVATE_KEY set:
|
|
21
30
|
calls bet <address> <holds|breaks> <eth> [--quote] [--yes] [--max-stake <eth>]
|
|
22
31
|
calls claim <address> [--opener]
|
|
32
|
+
calls rounds bet <market> <up|down> <eth> [--quote] [--yes] [--max-stake <eth>]
|
|
33
|
+
calls rounds claim [<market>]
|
|
34
|
+
calls rounds plain-wins <on|off>
|
|
35
|
+
calls rounds limit <eth>
|
|
23
36
|
calls open --text <sentence> --spec <json|@file> [--handle <x handle>] [--post-url <url>] [--post-text <text>]
|
|
24
37
|
[--deadline <unix>] [--close-at <unix>] [--bond <eth>] [--max-bond <eth>] [--quote] [--yes]
|
|
25
38
|
calls open --text <sentence> --bond-number <n> [--deadline <unix>] [--close-at <unix>] [--bond <eth>] [--quote] [--yes]
|
|
26
39
|
|
|
27
|
-
--quote
|
|
40
|
+
--quote With bet or open: show what would be sent and send nothing.
|
|
28
41
|
--yes Skip the confirmation. Without a terminal to confirm in, a bet or an open needs it.
|
|
29
42
|
--max-stake The most one bet may stake. 0.01 ETH unless set here or in CALLS_MAX_STAKE.
|
|
30
43
|
--max-bond The largest bond open may post. 0.02 ETH unless set.
|
|
@@ -73,6 +86,7 @@ const clean = (s: string | null | undefined) => String(s ?? "").replace(CONTROL,
|
|
|
73
86
|
|
|
74
87
|
const eth = (wei: string | bigint) => `${formatEther(BigInt(wei))} ETH`;
|
|
75
88
|
const when = (unix: number) => `${new Date(unix * 1000).toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
89
|
+
const second = (unix: number) => `${new Date(unix * 1000).toISOString().slice(0, 19).replace("T", " ")} UTC`;
|
|
76
90
|
const named = (side: string) => (side === "holds" ? "Holds" : "Breaks");
|
|
77
91
|
|
|
78
92
|
function unixOf(value: string | undefined, what: string): number | undefined {
|
|
@@ -198,6 +212,7 @@ async function run(command: string | undefined, args: string[], values: Values,
|
|
|
198
212
|
return { json: { quote, tx }, lines: [`Bet placed: ${eth(amount)} on ${named(side)}. ${tx.explorerUrl ?? tx.hash}`] };
|
|
199
213
|
}
|
|
200
214
|
case "claim": {
|
|
215
|
+
if (values.quote) throw new CallsError(NOT_A_QUOTE, "usage");
|
|
201
216
|
const address = needs(args[0], "calls claim <address> [--opener]");
|
|
202
217
|
if (values.opener) {
|
|
203
218
|
const tx = await client.claimOpener(address);
|
|
@@ -231,13 +246,69 @@ async function run(command: string | undefined, args: string[], values: Values,
|
|
|
231
246
|
return { json: opened, lines: [`Opened ${opened.address}. Betting closes ${when(opened.closeAt)}. ${opened.explorerUrl ?? opened.hash}`] };
|
|
232
247
|
}
|
|
233
248
|
case "positions": {
|
|
234
|
-
const positions = await client.positions(args[0]);
|
|
249
|
+
const [positions, rounds] = await Promise.all([client.positions(args[0]), client.rounds.history(args[0]).catch(() => null)]);
|
|
235
250
|
const lines = [`${positions.address}${positions.balance == null ? "" : ` ${eth(positions.balance)}`}`];
|
|
236
251
|
lines.push(...positions.positions.map((p) => ` ${p.call} Holds ${eth(p.holds)}, Breaks ${eth(p.breaks)}, pays ${eth(p.paysNow)} if its side wins`));
|
|
237
252
|
const owed = positions.settled.filter((s) => s.owed && s.owed !== "0");
|
|
238
253
|
lines.push(...owed.map((s) => ` ${s.call} ${eth(s.owed!)} to claim`));
|
|
239
|
-
|
|
240
|
-
|
|
254
|
+
const running = rounds?.rounds.filter((r) => r.outcome === null) ?? [];
|
|
255
|
+
const inRounds = running.reduce((sum, r) => sum + BigInt(r.stake), 0n);
|
|
256
|
+
if (running.length) lines.push(` Rounds: ${eth(inRounds)} in ${running.length} still running`);
|
|
257
|
+
if (rounds?.unclaimedRounds) lines.push(` Rounds: ${rounds.unclaimedRounds} to collect, ${collecting(rounds)} in the next claim. Run calls rounds claim.`);
|
|
258
|
+
if (!positions.positions.length && !owed.length && !running.length && !rounds?.unclaimedRounds) lines.push(" No open positions and nothing to claim.");
|
|
259
|
+
return { json: { ...positions, rounds: rounds && { running, unclaimedRounds: rounds.unclaimedRounds, unclaimedTotal: rounds.unclaimedTotal } }, lines };
|
|
260
|
+
}
|
|
261
|
+
case "rounds": {
|
|
262
|
+
if (args[0] === "history") {
|
|
263
|
+
const history = await client.rounds.history(args[1]);
|
|
264
|
+
const lines = [`${history.wallet}: ${history.wins}-${history.losses}, streak ${history.streak.current}, best ${history.streak.best}. ${history.unclaimedRounds} to collect, ${collecting(history)} in the next claim.`];
|
|
265
|
+
const result = (r: (typeof history.rounds)[number]) => (r.outcome === null ? "not decided yet" : r.outcome === "refunded" ? "refunded" : r.won ? `won, paid ${eth(r.payout!)}` : `lost, ${eth(r.payout ?? "0")} back`);
|
|
266
|
+
lines.push(...history.rounds.slice(0, 10).map((r) => ` ${r.market} ${r.epoch} ${r.up ? "Up" : "Down"} ${eth(r.stake)}: ${result(r)}`));
|
|
267
|
+
return { json: history, lines };
|
|
268
|
+
}
|
|
269
|
+
if (args[0] === "bet") {
|
|
270
|
+
const usage = "calls rounds bet <market> <up|down> <eth> [--quote] [--yes] [--max-stake <eth>]";
|
|
271
|
+
const [market, side] = [needs(args[1], usage), needs(args[2], usage)];
|
|
272
|
+
const amount = ethToWei(needs(args[3], usage), "The stake");
|
|
273
|
+
if (!values.quote && !client.address) throw new CallsError("Set CALLS_PRIVATE_KEY to bet. --quote shows what a bet pays without a wallet.", "no_wallet");
|
|
274
|
+
const quote = await client.rounds.quote(market, side, amount);
|
|
275
|
+
const lines = [
|
|
276
|
+
`${quote.market} ${quote.side} in round ${quote.epoch}: ${eth(quote.inPlay)} of your ${eth(amount)} is matched with the pools as they stand. A win pays ${eth(quote.payout)}, and whatever isn't matched comes back either way. Bets stop ${second(quote.cutoffAt)}.`,
|
|
277
|
+
...(quote.refund ? ["Nobody is on the other side yet. Close to the lock a Shipped agent may match up to 0.005 ETH of it. If nobody takes it, the stake comes back."] : []),
|
|
278
|
+
...(quote.refused ? [`This bet would be refused: ${quote.refused.message}`] : []),
|
|
279
|
+
];
|
|
280
|
+
if (values.quote) return { json: { quote }, lines };
|
|
281
|
+
if (!values.json) console.error(lines.join("\n"));
|
|
282
|
+
await confirm(`Stake ${eth(amount)} on ${quote.side}?`, values, "place this bet", { quote });
|
|
283
|
+
const tx = await client.rounds.bet(market, side, amount);
|
|
284
|
+
return { json: { quote, tx }, lines: [`Bet placed: ${eth(amount)} on ${quote.market} ${quote.side}, round ${tx.epoch}. ${tx.explorerUrl ?? tx.hash}`] };
|
|
285
|
+
}
|
|
286
|
+
if (args[0] === "claim") {
|
|
287
|
+
if (values.quote) throw new CallsError(NOT_A_QUOTE, "usage");
|
|
288
|
+
const tx = await client.rounds.claim(args[1]);
|
|
289
|
+
return { json: tx, lines: [`Collected ${eth(tx.amount)} from ${tx.rounds} ${tx.rounds === 1 ? "round" : "rounds"}, ${tx.left} left.${tx.cut === "0" ? "" : ` ${eth(tx.cut)} bought $SHIPPED.`} ${tx.explorerUrl ?? tx.hash}`] };
|
|
290
|
+
}
|
|
291
|
+
if (args[0] === "plain-wins") {
|
|
292
|
+
if (values.quote) throw new CallsError(NOT_A_QUOTE, "usage");
|
|
293
|
+
const setting = needs(args[1], "calls rounds plain-wins <on|off>");
|
|
294
|
+
if (setting !== "on" && setting !== "off") throw new CallsError("Usage: calls rounds plain-wins <on|off>", "usage");
|
|
295
|
+
const tx = await client.rounds.setPlainWins(setting === "on");
|
|
296
|
+
return { json: tx, lines: [`${setting === "on" ? "Every win now pays in ETH, with no card and no $SHIPPED buy." : "A win that earns a card now mints it, and 10% of its profit buys $SHIPPED."} ${tx.explorerUrl ?? tx.hash}`] };
|
|
297
|
+
}
|
|
298
|
+
if (args[0] === "limit") {
|
|
299
|
+
if (values.quote) throw new CallsError(NOT_A_QUOTE, "usage");
|
|
300
|
+
const cap = ethToWei(needs(args[1], "calls rounds limit <eth>"), "The limit");
|
|
301
|
+
const tx = await client.rounds.setLimit(cap);
|
|
302
|
+
return { json: tx, lines: [`Asked for a daily limit of ${cap === 0n ? "none" : eth(cap)}. Lowering it applies at once; raising or removing it takes 24 hours. ${tx.explorerUrl ?? tx.hash}`] };
|
|
303
|
+
}
|
|
304
|
+
if (args[0]) {
|
|
305
|
+
const market = await client.rounds.state(args[0]);
|
|
306
|
+
return { json: market, lines: [`${market.market} round ${market.betting.epoch}: Up ${eth(market.betting.up)}, Down ${eth(market.betting.down)}. Bets stop ${second(market.betting.cutoffAt)}.${market.open ? "" : " Rounds isn't taking bets right now."}`] };
|
|
307
|
+
}
|
|
308
|
+
const floor = await client.rounds.markets();
|
|
309
|
+
const lines = floor.markets.map((m) => `${m.market} round ${m.betting.epoch}: Up ${eth(m.betting.up)}, Down ${eth(m.betting.down)}. Bets stop ${second(m.betting.cutoffAt)}.`);
|
|
310
|
+
if (!floor.open) lines.push("Rounds isn't taking bets right now.");
|
|
311
|
+
return { json: floor, lines };
|
|
241
312
|
}
|
|
242
313
|
case "proof": {
|
|
243
314
|
const proof = await client.proof();
|
|
@@ -245,6 +316,7 @@ async function run(command: string | undefined, args: string[], values: Values,
|
|
|
245
316
|
lines.push(...proof.contracts.map((c) => ` ${c.name}: ${c.address}${c.sourcify === "exact_match" ? ", source published, exact match" : ""}`));
|
|
246
317
|
if (proof.rules.minBet) lines.push(`Minimum bet ${eth(proof.rules.minBet)}. Fee ${(proof.rules.rakeBps ?? 0) / 100}% of the losing pool. Dispute window ${windowLine(proof.rules)}.`);
|
|
247
318
|
if (proof.activity) lines.push(`${proof.activity.opened} Calls opened, ${eth(proof.activity.staked)} staked, ${eth(proof.activity.paidOut)} paid out.`);
|
|
319
|
+
if (proof.rounds) lines.push(`Rounds: prices checked by Pyth at ${proof.rounds.oracle}, guarded by ${proof.rounds.guardian.address}.`);
|
|
248
320
|
if (proof.agents.length) lines.push(`Shipped agents: ${proof.agents.map((a) => a.name).join(", ")}.`);
|
|
249
321
|
return { json: proof, lines };
|
|
250
322
|
}
|