everyblock-mcp 0.2.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 +4 -0
- package/dist/abi.js +504 -0
- package/dist/chain.js +7 -2
- package/dist/server.js +123 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,10 @@ With neither `RPC_URL` nor `EVERYBLOCK` set it talks to the live Monad testnet d
|
|
|
26
26
|
| `split` / `merge` | yes | Mints complete sets (1 UP + 1 DOWN for $1.00), or burns them back into collateral. |
|
|
27
27
|
| `faucet` | yes | Mints TestUSD collateral (testnet and local only). |
|
|
28
28
|
| `open_market` | yes | Opens the current (or next) market for a feed when no keeper has; returns the existing id if it is open. |
|
|
29
|
+
| `post_quote` | yes | Posts a resting maker quote that joins every batch until filled, cancelled or expired (`ttlSeconds`, default 60). |
|
|
30
|
+
| `cancel_quote` | yes | Takes a quote off (not during the window it sits in) and credits what it holds. |
|
|
31
|
+
| `withdraw_quote_cash` | yes | Collects the cash a market's quotes earned. |
|
|
32
|
+
| `register_agent` | signs | Signs "I am an agent called X" with the wallet and registers it with the app, so the leaderboard shows the name with an Agent badge. No transaction. |
|
|
29
33
|
| `settle` | yes | Proves a market's price to beat and/or its result with signed Pyth prices from the app's `/api/proof` (no Pyth key needed), paying Pyth's update fee. |
|
|
30
34
|
|
|
31
35
|
Every write returns the transaction hash and the decoded result (events and amounts). Writes run one at a time.
|
package/dist/abi.js
CHANGED
|
@@ -22,10 +22,28 @@ export const everyblockAbi = [
|
|
|
22
22
|
"name": "owner_",
|
|
23
23
|
"type": "address",
|
|
24
24
|
"internalType": "address"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "batchSeconds_",
|
|
28
|
+
"type": "uint256",
|
|
29
|
+
"internalType": "uint256"
|
|
25
30
|
}
|
|
26
31
|
],
|
|
27
32
|
"stateMutability": "nonpayable"
|
|
28
33
|
},
|
|
34
|
+
{
|
|
35
|
+
"type": "function",
|
|
36
|
+
"name": "BATCH_SECONDS",
|
|
37
|
+
"inputs": [],
|
|
38
|
+
"outputs": [
|
|
39
|
+
{
|
|
40
|
+
"name": "",
|
|
41
|
+
"type": "uint256",
|
|
42
|
+
"internalType": "uint256"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"stateMutability": "view"
|
|
46
|
+
},
|
|
29
47
|
{
|
|
30
48
|
"type": "function",
|
|
31
49
|
"name": "CENT",
|
|
@@ -65,6 +83,32 @@ export const everyblockAbi = [
|
|
|
65
83
|
],
|
|
66
84
|
"stateMutability": "view"
|
|
67
85
|
},
|
|
86
|
+
{
|
|
87
|
+
"type": "function",
|
|
88
|
+
"name": "MAX_QUOTES",
|
|
89
|
+
"inputs": [],
|
|
90
|
+
"outputs": [
|
|
91
|
+
{
|
|
92
|
+
"name": "",
|
|
93
|
+
"type": "uint256",
|
|
94
|
+
"internalType": "uint256"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"stateMutability": "view"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"type": "function",
|
|
101
|
+
"name": "MAX_QUOTES_PER_MAKER",
|
|
102
|
+
"inputs": [],
|
|
103
|
+
"outputs": [
|
|
104
|
+
{
|
|
105
|
+
"name": "",
|
|
106
|
+
"type": "uint256",
|
|
107
|
+
"internalType": "uint256"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"stateMutability": "view"
|
|
111
|
+
},
|
|
68
112
|
{
|
|
69
113
|
"type": "function",
|
|
70
114
|
"name": "MAX_SAMPLE_DELAY",
|
|
@@ -78,6 +122,19 @@ export const everyblockAbi = [
|
|
|
78
122
|
],
|
|
79
123
|
"stateMutability": "view"
|
|
80
124
|
},
|
|
125
|
+
{
|
|
126
|
+
"type": "function",
|
|
127
|
+
"name": "MIN_QUOTE_SIZE",
|
|
128
|
+
"inputs": [],
|
|
129
|
+
"outputs": [
|
|
130
|
+
{
|
|
131
|
+
"name": "",
|
|
132
|
+
"type": "uint64",
|
|
133
|
+
"internalType": "uint64"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"stateMutability": "view"
|
|
137
|
+
},
|
|
81
138
|
{
|
|
82
139
|
"type": "function",
|
|
83
140
|
"name": "SAMPLES",
|
|
@@ -130,6 +187,48 @@ export const everyblockAbi = [
|
|
|
130
187
|
],
|
|
131
188
|
"stateMutability": "view"
|
|
132
189
|
},
|
|
190
|
+
{
|
|
191
|
+
"type": "function",
|
|
192
|
+
"name": "batchWindow",
|
|
193
|
+
"inputs": [
|
|
194
|
+
{
|
|
195
|
+
"name": "batchId",
|
|
196
|
+
"type": "uint256",
|
|
197
|
+
"internalType": "uint256"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"outputs": [
|
|
201
|
+
{
|
|
202
|
+
"name": "start",
|
|
203
|
+
"type": "uint256",
|
|
204
|
+
"internalType": "uint256"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "end",
|
|
208
|
+
"type": "uint256",
|
|
209
|
+
"internalType": "uint256"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"stateMutability": "view"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"type": "function",
|
|
216
|
+
"name": "cancelQuote",
|
|
217
|
+
"inputs": [
|
|
218
|
+
{
|
|
219
|
+
"name": "marketId",
|
|
220
|
+
"type": "uint256",
|
|
221
|
+
"internalType": "uint256"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "slot",
|
|
225
|
+
"type": "uint8",
|
|
226
|
+
"internalType": "uint8"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"outputs": [],
|
|
230
|
+
"stateMutability": "nonpayable"
|
|
231
|
+
},
|
|
133
232
|
{
|
|
134
233
|
"type": "function",
|
|
135
234
|
"name": "claim",
|
|
@@ -238,6 +337,19 @@ export const everyblockAbi = [
|
|
|
238
337
|
],
|
|
239
338
|
"stateMutability": "nonpayable"
|
|
240
339
|
},
|
|
340
|
+
{
|
|
341
|
+
"type": "function",
|
|
342
|
+
"name": "currentBatch",
|
|
343
|
+
"inputs": [],
|
|
344
|
+
"outputs": [
|
|
345
|
+
{
|
|
346
|
+
"name": "",
|
|
347
|
+
"type": "uint256",
|
|
348
|
+
"internalType": "uint256"
|
|
349
|
+
}
|
|
350
|
+
],
|
|
351
|
+
"stateMutability": "view"
|
|
352
|
+
},
|
|
241
353
|
{
|
|
242
354
|
"type": "function",
|
|
243
355
|
"name": "downBalance",
|
|
@@ -512,6 +624,72 @@ export const everyblockAbi = [
|
|
|
512
624
|
],
|
|
513
625
|
"stateMutability": "view"
|
|
514
626
|
},
|
|
627
|
+
{
|
|
628
|
+
"type": "function",
|
|
629
|
+
"name": "getQuotes",
|
|
630
|
+
"inputs": [
|
|
631
|
+
{
|
|
632
|
+
"name": "marketId",
|
|
633
|
+
"type": "uint256",
|
|
634
|
+
"internalType": "uint256"
|
|
635
|
+
}
|
|
636
|
+
],
|
|
637
|
+
"outputs": [
|
|
638
|
+
{
|
|
639
|
+
"name": "",
|
|
640
|
+
"type": "tuple[4]",
|
|
641
|
+
"internalType": "struct Everyblock.Quote[4]",
|
|
642
|
+
"components": [
|
|
643
|
+
{
|
|
644
|
+
"name": "maker",
|
|
645
|
+
"type": "address",
|
|
646
|
+
"internalType": "address"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
"name": "kind",
|
|
650
|
+
"type": "uint8",
|
|
651
|
+
"internalType": "enum Everyblock.Kind"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"name": "tick",
|
|
655
|
+
"type": "uint8",
|
|
656
|
+
"internalType": "uint8"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"name": "price",
|
|
660
|
+
"type": "uint8",
|
|
661
|
+
"internalType": "uint8"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"name": "expiresAt",
|
|
665
|
+
"type": "uint40",
|
|
666
|
+
"internalType": "uint40"
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
"name": "batchId",
|
|
670
|
+
"type": "uint40",
|
|
671
|
+
"internalType": "uint40"
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
"name": "size",
|
|
675
|
+
"type": "uint64",
|
|
676
|
+
"internalType": "uint64"
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
"name": "offset",
|
|
680
|
+
"type": "uint96",
|
|
681
|
+
"internalType": "uint96"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"name": "escrow",
|
|
685
|
+
"type": "uint128",
|
|
686
|
+
"internalType": "uint128"
|
|
687
|
+
}
|
|
688
|
+
]
|
|
689
|
+
}
|
|
690
|
+
],
|
|
691
|
+
"stateMutability": "view"
|
|
692
|
+
},
|
|
515
693
|
{
|
|
516
694
|
"type": "function",
|
|
517
695
|
"name": "isCleared",
|
|
@@ -771,6 +949,45 @@ export const everyblockAbi = [
|
|
|
771
949
|
],
|
|
772
950
|
"stateMutability": "nonpayable"
|
|
773
951
|
},
|
|
952
|
+
{
|
|
953
|
+
"type": "function",
|
|
954
|
+
"name": "postQuote",
|
|
955
|
+
"inputs": [
|
|
956
|
+
{
|
|
957
|
+
"name": "marketId",
|
|
958
|
+
"type": "uint256",
|
|
959
|
+
"internalType": "uint256"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"name": "kind",
|
|
963
|
+
"type": "uint8",
|
|
964
|
+
"internalType": "enum Everyblock.Kind"
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
"name": "price",
|
|
968
|
+
"type": "uint8",
|
|
969
|
+
"internalType": "uint8"
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"name": "size",
|
|
973
|
+
"type": "uint64",
|
|
974
|
+
"internalType": "uint64"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
"name": "expiresAt",
|
|
978
|
+
"type": "uint40",
|
|
979
|
+
"internalType": "uint40"
|
|
980
|
+
}
|
|
981
|
+
],
|
|
982
|
+
"outputs": [
|
|
983
|
+
{
|
|
984
|
+
"name": "slot",
|
|
985
|
+
"type": "uint8",
|
|
986
|
+
"internalType": "uint8"
|
|
987
|
+
}
|
|
988
|
+
],
|
|
989
|
+
"stateMutability": "nonpayable"
|
|
990
|
+
},
|
|
774
991
|
{
|
|
775
992
|
"type": "function",
|
|
776
993
|
"name": "previewClaim",
|
|
@@ -823,6 +1040,30 @@ export const everyblockAbi = [
|
|
|
823
1040
|
],
|
|
824
1041
|
"stateMutability": "view"
|
|
825
1042
|
},
|
|
1043
|
+
{
|
|
1044
|
+
"type": "function",
|
|
1045
|
+
"name": "quoteCash",
|
|
1046
|
+
"inputs": [
|
|
1047
|
+
{
|
|
1048
|
+
"name": "",
|
|
1049
|
+
"type": "uint256",
|
|
1050
|
+
"internalType": "uint256"
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
"name": "",
|
|
1054
|
+
"type": "address",
|
|
1055
|
+
"internalType": "address"
|
|
1056
|
+
}
|
|
1057
|
+
],
|
|
1058
|
+
"outputs": [
|
|
1059
|
+
{
|
|
1060
|
+
"name": "",
|
|
1061
|
+
"type": "uint256",
|
|
1062
|
+
"internalType": "uint256"
|
|
1063
|
+
}
|
|
1064
|
+
],
|
|
1065
|
+
"stateMutability": "view"
|
|
1066
|
+
},
|
|
826
1067
|
{
|
|
827
1068
|
"type": "function",
|
|
828
1069
|
"name": "redeem",
|
|
@@ -938,6 +1179,25 @@ export const everyblockAbi = [
|
|
|
938
1179
|
],
|
|
939
1180
|
"stateMutability": "view"
|
|
940
1181
|
},
|
|
1182
|
+
{
|
|
1183
|
+
"type": "function",
|
|
1184
|
+
"name": "withdrawQuoteCash",
|
|
1185
|
+
"inputs": [
|
|
1186
|
+
{
|
|
1187
|
+
"name": "marketId",
|
|
1188
|
+
"type": "uint256",
|
|
1189
|
+
"internalType": "uint256"
|
|
1190
|
+
}
|
|
1191
|
+
],
|
|
1192
|
+
"outputs": [
|
|
1193
|
+
{
|
|
1194
|
+
"name": "amount",
|
|
1195
|
+
"type": "uint256",
|
|
1196
|
+
"internalType": "uint256"
|
|
1197
|
+
}
|
|
1198
|
+
],
|
|
1199
|
+
"stateMutability": "nonpayable"
|
|
1200
|
+
},
|
|
941
1201
|
{
|
|
942
1202
|
"type": "event",
|
|
943
1203
|
"name": "BatchCleared",
|
|
@@ -1235,6 +1495,215 @@ export const everyblockAbi = [
|
|
|
1235
1495
|
],
|
|
1236
1496
|
"anonymous": false
|
|
1237
1497
|
},
|
|
1498
|
+
{
|
|
1499
|
+
"type": "event",
|
|
1500
|
+
"name": "QuoteCancelled",
|
|
1501
|
+
"inputs": [
|
|
1502
|
+
{
|
|
1503
|
+
"name": "marketId",
|
|
1504
|
+
"type": "uint256",
|
|
1505
|
+
"indexed": true,
|
|
1506
|
+
"internalType": "uint256"
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
"name": "slot",
|
|
1510
|
+
"type": "uint8",
|
|
1511
|
+
"indexed": false,
|
|
1512
|
+
"internalType": "uint8"
|
|
1513
|
+
},
|
|
1514
|
+
{
|
|
1515
|
+
"name": "maker",
|
|
1516
|
+
"type": "address",
|
|
1517
|
+
"indexed": true,
|
|
1518
|
+
"internalType": "address"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
"name": "cash",
|
|
1522
|
+
"type": "uint256",
|
|
1523
|
+
"indexed": false,
|
|
1524
|
+
"internalType": "uint256"
|
|
1525
|
+
},
|
|
1526
|
+
{
|
|
1527
|
+
"name": "tokens",
|
|
1528
|
+
"type": "uint256",
|
|
1529
|
+
"indexed": false,
|
|
1530
|
+
"internalType": "uint256"
|
|
1531
|
+
}
|
|
1532
|
+
],
|
|
1533
|
+
"anonymous": false
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
"type": "event",
|
|
1537
|
+
"name": "QuoteCashWithdrawn",
|
|
1538
|
+
"inputs": [
|
|
1539
|
+
{
|
|
1540
|
+
"name": "marketId",
|
|
1541
|
+
"type": "uint256",
|
|
1542
|
+
"indexed": true,
|
|
1543
|
+
"internalType": "uint256"
|
|
1544
|
+
},
|
|
1545
|
+
{
|
|
1546
|
+
"name": "maker",
|
|
1547
|
+
"type": "address",
|
|
1548
|
+
"indexed": true,
|
|
1549
|
+
"internalType": "address"
|
|
1550
|
+
},
|
|
1551
|
+
{
|
|
1552
|
+
"name": "amount",
|
|
1553
|
+
"type": "uint256",
|
|
1554
|
+
"indexed": false,
|
|
1555
|
+
"internalType": "uint256"
|
|
1556
|
+
}
|
|
1557
|
+
],
|
|
1558
|
+
"anonymous": false
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
"type": "event",
|
|
1562
|
+
"name": "QuoteFilled",
|
|
1563
|
+
"inputs": [
|
|
1564
|
+
{
|
|
1565
|
+
"name": "marketId",
|
|
1566
|
+
"type": "uint256",
|
|
1567
|
+
"indexed": true,
|
|
1568
|
+
"internalType": "uint256"
|
|
1569
|
+
},
|
|
1570
|
+
{
|
|
1571
|
+
"name": "batchId",
|
|
1572
|
+
"type": "uint256",
|
|
1573
|
+
"indexed": true,
|
|
1574
|
+
"internalType": "uint256"
|
|
1575
|
+
},
|
|
1576
|
+
{
|
|
1577
|
+
"name": "slot",
|
|
1578
|
+
"type": "uint8",
|
|
1579
|
+
"indexed": false,
|
|
1580
|
+
"internalType": "uint8"
|
|
1581
|
+
},
|
|
1582
|
+
{
|
|
1583
|
+
"name": "maker",
|
|
1584
|
+
"type": "address",
|
|
1585
|
+
"indexed": true,
|
|
1586
|
+
"internalType": "address"
|
|
1587
|
+
},
|
|
1588
|
+
{
|
|
1589
|
+
"name": "filled",
|
|
1590
|
+
"type": "uint256",
|
|
1591
|
+
"indexed": false,
|
|
1592
|
+
"internalType": "uint256"
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
"name": "cash",
|
|
1596
|
+
"type": "uint256",
|
|
1597
|
+
"indexed": false,
|
|
1598
|
+
"internalType": "uint256"
|
|
1599
|
+
}
|
|
1600
|
+
],
|
|
1601
|
+
"anonymous": false
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
"type": "event",
|
|
1605
|
+
"name": "QuoteJoined",
|
|
1606
|
+
"inputs": [
|
|
1607
|
+
{
|
|
1608
|
+
"name": "marketId",
|
|
1609
|
+
"type": "uint256",
|
|
1610
|
+
"indexed": true,
|
|
1611
|
+
"internalType": "uint256"
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
"name": "batchId",
|
|
1615
|
+
"type": "uint256",
|
|
1616
|
+
"indexed": true,
|
|
1617
|
+
"internalType": "uint256"
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
"name": "slot",
|
|
1621
|
+
"type": "uint8",
|
|
1622
|
+
"indexed": false,
|
|
1623
|
+
"internalType": "uint8"
|
|
1624
|
+
},
|
|
1625
|
+
{
|
|
1626
|
+
"name": "maker",
|
|
1627
|
+
"type": "address",
|
|
1628
|
+
"indexed": true,
|
|
1629
|
+
"internalType": "address"
|
|
1630
|
+
},
|
|
1631
|
+
{
|
|
1632
|
+
"name": "kind",
|
|
1633
|
+
"type": "uint8",
|
|
1634
|
+
"indexed": false,
|
|
1635
|
+
"internalType": "enum Everyblock.Kind"
|
|
1636
|
+
},
|
|
1637
|
+
{
|
|
1638
|
+
"name": "tick",
|
|
1639
|
+
"type": "uint8",
|
|
1640
|
+
"indexed": false,
|
|
1641
|
+
"internalType": "uint8"
|
|
1642
|
+
},
|
|
1643
|
+
{
|
|
1644
|
+
"name": "size",
|
|
1645
|
+
"type": "uint64",
|
|
1646
|
+
"indexed": false,
|
|
1647
|
+
"internalType": "uint64"
|
|
1648
|
+
},
|
|
1649
|
+
{
|
|
1650
|
+
"name": "offset",
|
|
1651
|
+
"type": "uint96",
|
|
1652
|
+
"indexed": false,
|
|
1653
|
+
"internalType": "uint96"
|
|
1654
|
+
}
|
|
1655
|
+
],
|
|
1656
|
+
"anonymous": false
|
|
1657
|
+
},
|
|
1658
|
+
{
|
|
1659
|
+
"type": "event",
|
|
1660
|
+
"name": "QuotePosted",
|
|
1661
|
+
"inputs": [
|
|
1662
|
+
{
|
|
1663
|
+
"name": "marketId",
|
|
1664
|
+
"type": "uint256",
|
|
1665
|
+
"indexed": true,
|
|
1666
|
+
"internalType": "uint256"
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1669
|
+
"name": "slot",
|
|
1670
|
+
"type": "uint8",
|
|
1671
|
+
"indexed": false,
|
|
1672
|
+
"internalType": "uint8"
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
"name": "maker",
|
|
1676
|
+
"type": "address",
|
|
1677
|
+
"indexed": true,
|
|
1678
|
+
"internalType": "address"
|
|
1679
|
+
},
|
|
1680
|
+
{
|
|
1681
|
+
"name": "kind",
|
|
1682
|
+
"type": "uint8",
|
|
1683
|
+
"indexed": false,
|
|
1684
|
+
"internalType": "enum Everyblock.Kind"
|
|
1685
|
+
},
|
|
1686
|
+
{
|
|
1687
|
+
"name": "price",
|
|
1688
|
+
"type": "uint8",
|
|
1689
|
+
"indexed": false,
|
|
1690
|
+
"internalType": "uint8"
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
"name": "size",
|
|
1694
|
+
"type": "uint64",
|
|
1695
|
+
"indexed": false,
|
|
1696
|
+
"internalType": "uint64"
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
"name": "expiresAt",
|
|
1700
|
+
"type": "uint40",
|
|
1701
|
+
"indexed": false,
|
|
1702
|
+
"internalType": "uint40"
|
|
1703
|
+
}
|
|
1704
|
+
],
|
|
1705
|
+
"anonymous": false
|
|
1706
|
+
},
|
|
1238
1707
|
{
|
|
1239
1708
|
"type": "event",
|
|
1240
1709
|
"name": "Redeemed",
|
|
@@ -1358,6 +1827,11 @@ export const everyblockAbi = [
|
|
|
1358
1827
|
"name": "AlreadyResolved",
|
|
1359
1828
|
"inputs": []
|
|
1360
1829
|
},
|
|
1830
|
+
{
|
|
1831
|
+
"type": "error",
|
|
1832
|
+
"name": "BadBatchSeconds",
|
|
1833
|
+
"inputs": []
|
|
1834
|
+
},
|
|
1361
1835
|
{
|
|
1362
1836
|
"type": "error",
|
|
1363
1837
|
"name": "BadPrice",
|
|
@@ -1418,11 +1892,21 @@ export const everyblockAbi = [
|
|
|
1418
1892
|
"name": "NoFeeRecipient",
|
|
1419
1893
|
"inputs": []
|
|
1420
1894
|
},
|
|
1895
|
+
{
|
|
1896
|
+
"type": "error",
|
|
1897
|
+
"name": "NoQuoteSlot",
|
|
1898
|
+
"inputs": []
|
|
1899
|
+
},
|
|
1421
1900
|
{
|
|
1422
1901
|
"type": "error",
|
|
1423
1902
|
"name": "NotOwner",
|
|
1424
1903
|
"inputs": []
|
|
1425
1904
|
},
|
|
1905
|
+
{
|
|
1906
|
+
"type": "error",
|
|
1907
|
+
"name": "NotQuoteMaker",
|
|
1908
|
+
"inputs": []
|
|
1909
|
+
},
|
|
1426
1910
|
{
|
|
1427
1911
|
"type": "error",
|
|
1428
1912
|
"name": "NotSettled",
|
|
@@ -1433,6 +1917,21 @@ export const everyblockAbi = [
|
|
|
1433
1917
|
"name": "NothingToRedeem",
|
|
1434
1918
|
"inputs": []
|
|
1435
1919
|
},
|
|
1920
|
+
{
|
|
1921
|
+
"type": "error",
|
|
1922
|
+
"name": "QuoteBusy",
|
|
1923
|
+
"inputs": []
|
|
1924
|
+
},
|
|
1925
|
+
{
|
|
1926
|
+
"type": "error",
|
|
1927
|
+
"name": "QuoteExpired",
|
|
1928
|
+
"inputs": []
|
|
1929
|
+
},
|
|
1930
|
+
{
|
|
1931
|
+
"type": "error",
|
|
1932
|
+
"name": "QuoteTooSmall",
|
|
1933
|
+
"inputs": []
|
|
1934
|
+
},
|
|
1436
1935
|
{
|
|
1437
1936
|
"type": "error",
|
|
1438
1937
|
"name": "Reentrancy",
|
|
@@ -1453,6 +1952,11 @@ export const everyblockAbi = [
|
|
|
1453
1952
|
"name": "StrikeNotSet",
|
|
1454
1953
|
"inputs": []
|
|
1455
1954
|
},
|
|
1955
|
+
{
|
|
1956
|
+
"type": "error",
|
|
1957
|
+
"name": "TooManyQuotes",
|
|
1958
|
+
"inputs": []
|
|
1959
|
+
},
|
|
1456
1960
|
{
|
|
1457
1961
|
"type": "error",
|
|
1458
1962
|
"name": "TransferFailed",
|
package/dist/chain.js
CHANGED
|
@@ -14,7 +14,7 @@ export const MONAD_MAINNET = 143;
|
|
|
14
14
|
export const MONAD_TESTNET = 10143;
|
|
15
15
|
/** The live Monad testnet deployment (docs/SUBMISSION.md, "Deployed contracts"). */
|
|
16
16
|
export const TESTNET_RPC = "https://testnet-rpc.monad.xyz";
|
|
17
|
-
export const TESTNET_EVERYBLOCK = "
|
|
17
|
+
export const TESTNET_EVERYBLOCK = "0x885F6CD4E75F432E8DE60A0fbA97fC0D24c415ad";
|
|
18
18
|
/** The hosted web app's proof endpoint for the testnet deployment. */
|
|
19
19
|
export const TESTNET_PROOF_URL = "https://everyblock-gray.vercel.app/api/proof";
|
|
20
20
|
export const ANVIL = 31337;
|
|
@@ -87,9 +87,11 @@ export async function connect(cfg) {
|
|
|
87
87
|
account = cfg.unlockedAccount;
|
|
88
88
|
}
|
|
89
89
|
const wallet = account ? createWalletClient({ transport: http(cfg.rpcUrl) }) : null;
|
|
90
|
-
const [collateral, cent] = await Promise.all([
|
|
90
|
+
const [collateral, cent, batchSeconds] = await Promise.all([
|
|
91
91
|
pub.readContract({ address: cfg.everyblock, abi: everyblockAbi, functionName: "collateral" }),
|
|
92
92
|
pub.readContract({ address: cfg.everyblock, abi: everyblockAbi, functionName: "CENT" }),
|
|
93
|
+
// Deployments from before batch windows have no BATCH_SECONDS: there a batch is one block.
|
|
94
|
+
pub.readContract({ address: cfg.everyblock, abi: everyblockAbi, functionName: "BATCH_SECONDS" }).catch(() => 0n),
|
|
93
95
|
]);
|
|
94
96
|
const share = 100n * cent;
|
|
95
97
|
const digits = String(share).length - 1;
|
|
@@ -112,6 +114,7 @@ export async function connect(cfg) {
|
|
|
112
114
|
maxSpend,
|
|
113
115
|
logRange: cfg.logRange,
|
|
114
116
|
logLookback: cfg.logLookback,
|
|
117
|
+
batchSeconds: Number(batchSeconds),
|
|
115
118
|
proofUrl: cfg.proofUrl === undefined ? (chainId === MONAD_TESTNET ? TESTNET_PROOF_URL : undefined) : cfg.proofUrl || undefined,
|
|
116
119
|
queue: Promise.resolve(),
|
|
117
120
|
};
|
|
@@ -200,3 +203,5 @@ export function reason(e) {
|
|
|
200
203
|
}
|
|
201
204
|
return e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
202
205
|
}
|
|
206
|
+
/** The batch an order sent now joins: the time window, or the block on per-block deployments. */
|
|
207
|
+
export const batchAt = (ctx, t) => ctx.batchSeconds ? t.timestamp / BigInt(ctx.batchSeconds) : t.number;
|
package/dist/server.js
CHANGED
|
@@ -3,15 +3,15 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { isAddress } from "viem";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { everyblockAbi } from "./abi.js";
|
|
6
|
-
import { FEED_NAMES, feeBps, MONAD_MAINNET, now, read, readToken, reason, send, serialize, writeBlocker, } from "./chain.js";
|
|
6
|
+
import { FEED_NAMES, feeBps, MONAD_MAINNET, now, read, readToken, reason, send, serialize, writeBlocker, batchAt, } from "./chain.js";
|
|
7
7
|
import { centsToUsd, clearBatch, describeKind, escrowOf, feeOn, GRACE, isBid, kindOf, KINDS, marketStatus, meanPrice, OUTCOMES, ownPriceAt, priceOf, scenarios, tickOf, usd, WINDOW, } from "./orders.js";
|
|
8
8
|
export const INSTRUCTIONS = `Everyblock runs short crypto UP/DOWN markets (e.g. "is BTC/USD higher at the close than at the open?") on Monad.
|
|
9
9
|
|
|
10
10
|
How it works:
|
|
11
11
|
- Each market has an open and a close time (5 minutes on the live schedule). The strike is the mean of 12 Pyth prices over the 60 s before the open; the closing price is the mean of 12 Pyth prices over the 60 s from the close. UP wins if the closing mean is above the strike, DOWN if below; a tie, or no proof within an hour, voids the market and every share redeems for $0.50.
|
|
12
12
|
- A winning share pays $1.00. Prices are in cents (1-99): buying UP at 60 means paying at most $0.60 per share.
|
|
13
|
-
- There is no continuous order book. All orders sent in the same block form one batch that clears at ONE uniform price after the
|
|
14
|
-
- Orders live for one
|
|
13
|
+
- There is no continuous order book. All orders sent in the same batch window (a few seconds: the contract's BATCH_SECONDS; one block on older deployments) form one batch that clears at ONE uniform price after the window ends, so being first or fast inside it gives no advantage. Orders better than the clearing price fill fully, orders at it may fill pro rata, worse ones do not fill. Buyers never pay more than their limit and get back any price improvement.
|
|
14
|
+
- Orders live for one batch. After its window ends, call claim with the order's nonce to collect the fill, the refund of anything unfilled and the price improvement. Claiming is required even if the order did not fill (that returns the escrow).
|
|
15
15
|
- After a market resolves, call redeem to turn winning shares into collateral. Claim open orders first.
|
|
16
16
|
- split turns $1 of collateral into 1 UP + 1 DOWN (needed before you can sell shares you do not own); merge does the reverse.
|
|
17
17
|
|
|
@@ -87,8 +87,25 @@ async function marketView(ctx, marketId, t, latestBlock) {
|
|
|
87
87
|
pendingBatch: m.pendingBatch === 0n ? null : m.pendingBatch,
|
|
88
88
|
fee: { bps: fee.bps, source: fee.source },
|
|
89
89
|
lastClearing: latestBlock === null ? undefined : await lastClearing(ctx, marketId, latestBlock),
|
|
90
|
+
restingQuotes: await restingQuotes(ctx, marketId, t),
|
|
90
91
|
};
|
|
91
92
|
}
|
|
93
|
+
/** A market's resting quotes: makers' orders that join every batch until filled, cancelled or expired. */
|
|
94
|
+
async function restingQuotes(ctx, marketId, t) {
|
|
95
|
+
const qs = (await read(ctx, "getQuotes", [marketId]).catch(() => []));
|
|
96
|
+
return qs
|
|
97
|
+
.map((q, slot) => ({ q, slot }))
|
|
98
|
+
.filter(({ q }) => q.maker !== "0x0000000000000000000000000000000000000000")
|
|
99
|
+
.map(({ q, slot }) => ({
|
|
100
|
+
slot,
|
|
101
|
+
maker: q.maker,
|
|
102
|
+
...describeKind(q.kind),
|
|
103
|
+
limitCents: q.price,
|
|
104
|
+
sharesLeft: q.size,
|
|
105
|
+
expires: iso(BigInt(q.expiresAt)),
|
|
106
|
+
live: BigInt(q.expiresAt) > t,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
92
109
|
async function batchView(ctx, marketId, batchId) {
|
|
93
110
|
const [b, cleared] = await Promise.all([
|
|
94
111
|
read(ctx, "getBatch", [marketId, batchId]),
|
|
@@ -231,7 +248,7 @@ async function quote(ctx, a) {
|
|
|
231
248
|
wallet,
|
|
232
249
|
ok: problems.length === 0,
|
|
233
250
|
problems,
|
|
234
|
-
note: "The order joins the current
|
|
251
|
+
note: "The order joins the current batch and clears at one price for everyone once the batch's window ends; you never pay more than your limit. Claim it with its nonce afterwards.",
|
|
235
252
|
},
|
|
236
253
|
};
|
|
237
254
|
}
|
|
@@ -298,8 +315,8 @@ export function createServer(ctx) {
|
|
|
298
315
|
}));
|
|
299
316
|
server.registerTool("get_batch", {
|
|
300
317
|
title: "Get batch",
|
|
301
|
-
description: "The order book of one batch (a market's orders from one
|
|
302
|
-
inputSchema: { marketId: id.describe("Market id."), batchId: id.describe("
|
|
318
|
+
description: "The order book of one batch (a market's orders from one batch window: batchId = floor(time / BATCH_SECONDS), or the block number on older deployments): size resting at each tick on each side, and the clearing result (price, volume, fills at the clearing tick). A batch not cleared yet shows the indicative clearing price.",
|
|
319
|
+
inputSchema: { marketId: id.describe("Market id."), batchId: id.describe("The batch id (from place_order or get_positions).") },
|
|
303
320
|
annotations: readOnly,
|
|
304
321
|
}, guarded(async ({ marketId, batchId }) => ok(await batchView(ctx, BigInt(marketId), BigInt(batchId)))));
|
|
305
322
|
server.registerTool("get_positions", {
|
|
@@ -354,7 +371,7 @@ export function createServer(ctx) {
|
|
|
354
371
|
kind: KINDS[kind],
|
|
355
372
|
limitCents: priceOf(kind, o.tick),
|
|
356
373
|
size: o.size,
|
|
357
|
-
status: cleared ? "cleared: claim it" : batchId === number ? "in the current
|
|
374
|
+
status: cleared ? "cleared: claim it" : BigInt(batchId) === batchAt(ctx, { timestamp, number }) ? "in the current batch" : "waiting to clear (claiming clears it)",
|
|
358
375
|
claim,
|
|
359
376
|
});
|
|
360
377
|
}
|
|
@@ -400,7 +417,7 @@ export function createServer(ctx) {
|
|
|
400
417
|
}, guarded(async (a) => ok((await quote(ctx, a)).view)));
|
|
401
418
|
server.registerTool("place_order", {
|
|
402
419
|
title: "Place order",
|
|
403
|
-
description: "Sends a limit order into the current
|
|
420
|
+
description: "Sends a limit order into the current batch (one transaction; plus a collateral approval first if needed, capped at this server's per-call spend limit). Returns the tx hash, the order's nonce and batchId. The order lives one batch: once its window ends, call claim with its nonce to collect fills and refunds. Refused if over the server's size or spend limits, on a chain not allowed for writes, or if the market is not trading.",
|
|
404
421
|
inputSchema: orderShape,
|
|
405
422
|
annotations: writes,
|
|
406
423
|
}, guarded(async (a) => {
|
|
@@ -423,13 +440,13 @@ export function createServer(ctx) {
|
|
|
423
440
|
approval,
|
|
424
441
|
order: { ...q.view.order, nonce: ev?.nonce, batchId: ev?.batchId, upBookTick: ev?.tick },
|
|
425
442
|
escrow: q.view.escrow,
|
|
426
|
-
next: `Batch ${ev?.batchId} clears once its
|
|
443
|
+
next: `Batch ${ev?.batchId} clears once its window has passed${ctx.batchSeconds ? ` (${ctx.batchSeconds} s batches)` : ""}. Then call claim with nonces [${ev?.nonce}] (get_batch shows the clearing price).`,
|
|
427
444
|
});
|
|
428
445
|
});
|
|
429
446
|
}));
|
|
430
447
|
server.registerTool("claim", {
|
|
431
448
|
title: "Claim orders",
|
|
432
|
-
description: "Settles your orders whose batch has
|
|
449
|
+
description: "Settles your orders whose batch window has ended (clearing the batch first if nobody has): credits the UP/DOWN shares bought, pays the cash from sales, refunds anything unfilled plus price improvement. One transaction per nonce; returns each tx hash and what it paid. Order nonces come from place_order or get_positions.",
|
|
433
450
|
inputSchema: { nonces: z.array(z.number().int().min(0)).min(1).max(20).describe("Order nonces to claim.") },
|
|
434
451
|
annotations: writes,
|
|
435
452
|
}, guarded(async ({ nonces }) => {
|
|
@@ -613,8 +630,104 @@ export function createServer(ctx) {
|
|
|
613
630
|
});
|
|
614
631
|
});
|
|
615
632
|
}));
|
|
633
|
+
server.registerTool("post_quote", {
|
|
634
|
+
title: "Post a resting quote",
|
|
635
|
+
description: "Posts a maker quote that rests on the market and joins EVERY batch until it is filled, cancelled, expires or the market closes, so takers arriving at any time can trade against it (an ordinary order lives one batch only). Escrowed once like an order (collateral plus fee for buys, shares for sells). At least 10 shares; at most 4 quotes per market and 2 per maker. Fills go straight to your UP/DOWN balance; cash (sale proceeds, price improvement) accrues until withdraw_quote_cash. Every fill is at the batch's single clearing price, never worse than your limit. Keep quotes short-lived (ttlSeconds) and re-post when the price moves: a resting quote can be hit after the market moves.",
|
|
636
|
+
inputSchema: {
|
|
637
|
+
...orderShape,
|
|
638
|
+
ttlSeconds: z.number().int().min(5).max(3600).optional().describe("How long it rests, in seconds (default 60)."),
|
|
639
|
+
},
|
|
640
|
+
annotations: writes,
|
|
641
|
+
}, guarded(async (a) => {
|
|
642
|
+
const blocked = writeBlocker(ctx);
|
|
643
|
+
if (blocked)
|
|
644
|
+
return fail(blocked);
|
|
645
|
+
if (a.size < 10)
|
|
646
|
+
return fail("a quote needs at least 10 shares");
|
|
647
|
+
return serialize(ctx, async () => {
|
|
648
|
+
const q = await quote(ctx, a);
|
|
649
|
+
if (q.problems.length)
|
|
650
|
+
return fail(`quote refused: ${q.problems.join("; ")}`);
|
|
651
|
+
let approval;
|
|
652
|
+
if (q.escrowCollateral > 0n)
|
|
653
|
+
approval = await ensureAllowance(ctx, q.escrowCollateral);
|
|
654
|
+
const { timestamp } = await now(ctx);
|
|
655
|
+
const expiresAt = timestamp + BigInt(a.ttlSeconds ?? 60);
|
|
656
|
+
const sent = await send(ctx, "everyblock", "postQuote", [q.marketId, q.kind, a.price, q.size, expiresAt]);
|
|
657
|
+
const ev = eventArgs(sent, "QuotePosted");
|
|
658
|
+
return ok({
|
|
659
|
+
posted: true,
|
|
660
|
+
...tx(sent),
|
|
661
|
+
approval,
|
|
662
|
+
quote: { ...q.view.order, slot: ev?.slot, expires: iso(expiresAt) },
|
|
663
|
+
escrow: q.view.escrow,
|
|
664
|
+
next: `It joins every batch until ${iso(expiresAt)}. cancel_quote with slot ${ev?.slot} takes it off (not during the window it is sitting in); withdraw_quote_cash collects what it earned.`,
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
}));
|
|
668
|
+
server.registerTool("cancel_quote", {
|
|
669
|
+
title: "Cancel a resting quote",
|
|
670
|
+
description: "Takes your quote off the market: settles the last batch it joined, then credits what it still holds (collateral to your quote cash, shares back to your balance). Refused while the quote sits in the batch window that is still open; try again a few seconds later.",
|
|
671
|
+
inputSchema: { marketId: id.describe("Market id."), slot: z.number().int().min(0).max(3).describe("The quote's slot (from post_quote or get_market).") },
|
|
672
|
+
annotations: writes,
|
|
673
|
+
}, guarded(async ({ marketId, slot }) => {
|
|
674
|
+
const blocked = writeBlocker(ctx);
|
|
675
|
+
if (blocked)
|
|
676
|
+
return fail(blocked);
|
|
677
|
+
return serialize(ctx, async () => {
|
|
678
|
+
const sent = await send(ctx, "everyblock", "cancelQuote", [BigInt(marketId), slot]);
|
|
679
|
+
const ev = eventArgs(sent, "QuoteCancelled");
|
|
680
|
+
return ok({ cancelled: true, ...tx(sent), marketId, slot, cashCreditedUsd: ev ? usd(ev.cash, ctx.cent) : undefined, sharesReturned: ev?.tokens });
|
|
681
|
+
});
|
|
682
|
+
}));
|
|
683
|
+
server.registerTool("withdraw_quote_cash", {
|
|
684
|
+
title: "Withdraw quote cash",
|
|
685
|
+
description: "Sends you the cash your resting quotes earned in a market (sale proceeds, price improvement, refunds of cancelled quotes).",
|
|
686
|
+
inputSchema: { marketId: id.describe("Market id.") },
|
|
687
|
+
annotations: writes,
|
|
688
|
+
}, guarded(async ({ marketId }) => {
|
|
689
|
+
const blocked = writeBlocker(ctx);
|
|
690
|
+
if (blocked)
|
|
691
|
+
return fail(blocked);
|
|
692
|
+
return serialize(ctx, async () => {
|
|
693
|
+
const owed = (await read(ctx, "quoteCash", [BigInt(marketId), ctx.address]));
|
|
694
|
+
if (owed === 0n)
|
|
695
|
+
return ok({ withdrawn: false, reason: "nothing to withdraw", marketId });
|
|
696
|
+
const sent = await send(ctx, "everyblock", "withdrawQuoteCash", [BigInt(marketId)]);
|
|
697
|
+
return ok({ withdrawn: true, ...tx(sent), marketId, amountUsd: usd(owed, ctx.cent) });
|
|
698
|
+
});
|
|
699
|
+
}));
|
|
700
|
+
server.registerTool("register_agent", {
|
|
701
|
+
title: "Register as an agent",
|
|
702
|
+
description: "Signs a message with this server's wallet saying it is an AI agent with the given name, and registers it with the Everyblock app, so the leaderboard shows the name with an Agent badge and in the Agents tab. Costs nothing (a signature, not a transaction). Run it again to change the name.",
|
|
703
|
+
inputSchema: { name: z.string().describe("2-32 characters: letters, digits, spaces, _ . or -. Shown on the leaderboard.") },
|
|
704
|
+
annotations: { ...writes, idempotentHint: true },
|
|
705
|
+
}, guarded(async ({ name }) => {
|
|
706
|
+
if (!ctx.wallet || !ctx.account || !ctx.address)
|
|
707
|
+
return fail("this server is read-only: set MCP_PRIVATE_KEY to register a wallet");
|
|
708
|
+
if (!ctx.proofUrl)
|
|
709
|
+
return fail("no app endpoint configured (set EVERYBLOCK_PROOF_URL to the app's /api/proof)");
|
|
710
|
+
const clean = name.trim();
|
|
711
|
+
if (!AGENT_NAME_RE.test(clean))
|
|
712
|
+
return fail("name must be 2-32 letters, digits, spaces, _ . or -");
|
|
713
|
+
const message = `Register on Everyblock as an AI agent\nName: ${clean}\nAddress: ${ctx.address.toLowerCase()}`;
|
|
714
|
+
const signature = await ctx.wallet.signMessage({ account: ctx.account, message });
|
|
715
|
+
const url = new URL("/api/agents", ctx.proofUrl).toString();
|
|
716
|
+
const res = await fetch(url, {
|
|
717
|
+
method: "POST",
|
|
718
|
+
headers: { "content-type": "application/json" },
|
|
719
|
+
body: JSON.stringify({ address: ctx.address, name: clean, signature }),
|
|
720
|
+
signal: AbortSignal.timeout(20_000),
|
|
721
|
+
});
|
|
722
|
+
const body = (await res.json().catch(() => ({})));
|
|
723
|
+
if (!res.ok)
|
|
724
|
+
return fail(`registry: ${body.error ?? `HTTP ${res.status}`}`);
|
|
725
|
+
return ok({ registered: true, agent: body.agent, leaderboard: new URL("/leaderboard", ctx.proofUrl).toString() });
|
|
726
|
+
}));
|
|
616
727
|
return server;
|
|
617
728
|
}
|
|
729
|
+
/** Mirrors web/lib/agents.ts NAME_RE; the app checks again. The signed message must match agentMessage() there. */
|
|
730
|
+
const AGENT_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9 _.\-]{1,31}$/;
|
|
618
731
|
const PYTH_FEE_ABI = [
|
|
619
732
|
{
|
|
620
733
|
type: "function",
|