@hyperbridge/sdk 2.8.8 → 2.8.11
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/dist/browser/index.d.ts +610 -83
- package/dist/browser/index.js +999 -155
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +1004 -151
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +8 -5
- package/dist/node/index.d.ts +8 -5
- package/dist/node/index.js +999 -155
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-BCsIHRts.d.cts → intents-helpers-BRegx4yZ.d.cts} +1368 -451
- package/dist/node/{intents-helpers-BCsIHRts.d.ts → intents-helpers-BRegx4yZ.d.ts} +1368 -451
- package/dist/node/intents-helpers.cjs +378 -118
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +2 -1
- package/dist/node/intents-helpers.d.ts +2 -1
- package/dist/node/intents-helpers.js +374 -120
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var viem = require('viem');
|
|
4
4
|
require('@polkadot/api');
|
|
5
5
|
var util = require('@polkadot/util');
|
|
6
|
-
require('@polkadot/util-crypto');
|
|
6
|
+
var utilCrypto = require('@polkadot/util-crypto');
|
|
7
7
|
var scaleTs = require('scale-ts');
|
|
8
8
|
require('p-queue');
|
|
9
9
|
var accounts = require('viem/accounts');
|
|
@@ -73,7 +73,7 @@ var ABI2 = [
|
|
|
73
73
|
type: "constructor",
|
|
74
74
|
inputs: [
|
|
75
75
|
{
|
|
76
|
-
name: "
|
|
76
|
+
name: "owner",
|
|
77
77
|
type: "address",
|
|
78
78
|
internalType: "address"
|
|
79
79
|
}
|
|
@@ -148,25 +148,6 @@ var ABI2 = [
|
|
|
148
148
|
],
|
|
149
149
|
stateMutability: "view"
|
|
150
150
|
},
|
|
151
|
-
{
|
|
152
|
-
type: "function",
|
|
153
|
-
name: "_instances",
|
|
154
|
-
inputs: [
|
|
155
|
-
{
|
|
156
|
-
name: "",
|
|
157
|
-
type: "bytes32",
|
|
158
|
-
internalType: "bytes32"
|
|
159
|
-
}
|
|
160
|
-
],
|
|
161
|
-
outputs: [
|
|
162
|
-
{
|
|
163
|
-
name: "",
|
|
164
|
-
type: "address",
|
|
165
|
-
internalType: "address"
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
stateMutability: "view"
|
|
169
|
-
},
|
|
170
151
|
{
|
|
171
152
|
type: "function",
|
|
172
153
|
name: "_nonce",
|
|
@@ -204,6 +185,19 @@ var ABI2 = [
|
|
|
204
185
|
],
|
|
205
186
|
stateMutability: "view"
|
|
206
187
|
},
|
|
188
|
+
{
|
|
189
|
+
type: "function",
|
|
190
|
+
name: "_owner",
|
|
191
|
+
inputs: [],
|
|
192
|
+
outputs: [
|
|
193
|
+
{
|
|
194
|
+
name: "",
|
|
195
|
+
type: "address",
|
|
196
|
+
internalType: "address"
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
stateMutability: "view"
|
|
200
|
+
},
|
|
207
201
|
{
|
|
208
202
|
type: "function",
|
|
209
203
|
name: "_partialFills",
|
|
@@ -578,6 +572,11 @@ var ABI2 = [
|
|
|
578
572
|
type: "uint256",
|
|
579
573
|
internalType: "uint256"
|
|
580
574
|
},
|
|
575
|
+
{
|
|
576
|
+
name: "validUntil",
|
|
577
|
+
type: "uint256",
|
|
578
|
+
internalType: "uint256"
|
|
579
|
+
},
|
|
581
580
|
{
|
|
582
581
|
name: "outputs",
|
|
583
582
|
type: "tuple[]",
|
|
@@ -614,6 +613,61 @@ var ABI2 = [
|
|
|
614
613
|
],
|
|
615
614
|
stateMutability: "view"
|
|
616
615
|
},
|
|
616
|
+
{
|
|
617
|
+
type: "function",
|
|
618
|
+
name: "initialize",
|
|
619
|
+
inputs: [
|
|
620
|
+
{
|
|
621
|
+
name: "p",
|
|
622
|
+
type: "tuple",
|
|
623
|
+
internalType: "struct Params",
|
|
624
|
+
components: [
|
|
625
|
+
{
|
|
626
|
+
name: "host",
|
|
627
|
+
type: "address",
|
|
628
|
+
internalType: "address"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
name: "dispatcher",
|
|
632
|
+
type: "address",
|
|
633
|
+
internalType: "address"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
name: "solverSelection",
|
|
637
|
+
type: "bool",
|
|
638
|
+
internalType: "bool"
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "surplusShareBps",
|
|
642
|
+
type: "uint256",
|
|
643
|
+
internalType: "uint256"
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "protocolFeeBps",
|
|
647
|
+
type: "uint256",
|
|
648
|
+
internalType: "uint256"
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "priceOracle",
|
|
652
|
+
type: "address",
|
|
653
|
+
internalType: "address"
|
|
654
|
+
}
|
|
655
|
+
]
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
name: "peerChains",
|
|
659
|
+
type: "bytes[]",
|
|
660
|
+
internalType: "bytes[]"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
name: "relayer",
|
|
664
|
+
type: "address",
|
|
665
|
+
internalType: "address"
|
|
666
|
+
}
|
|
667
|
+
],
|
|
668
|
+
outputs: [],
|
|
669
|
+
stateMutability: "nonpayable"
|
|
670
|
+
},
|
|
617
671
|
{
|
|
618
672
|
type: "function",
|
|
619
673
|
name: "instance",
|
|
@@ -633,6 +687,19 @@ var ABI2 = [
|
|
|
633
687
|
],
|
|
634
688
|
stateMutability: "view"
|
|
635
689
|
},
|
|
690
|
+
{
|
|
691
|
+
type: "function",
|
|
692
|
+
name: "migrate",
|
|
693
|
+
inputs: [
|
|
694
|
+
{
|
|
695
|
+
name: "relayer",
|
|
696
|
+
type: "address",
|
|
697
|
+
internalType: "address"
|
|
698
|
+
}
|
|
699
|
+
],
|
|
700
|
+
outputs: [],
|
|
701
|
+
stateMutability: "nonpayable"
|
|
702
|
+
},
|
|
636
703
|
{
|
|
637
704
|
type: "function",
|
|
638
705
|
name: "onAccept",
|
|
@@ -1144,7 +1211,7 @@ var ABI2 = [
|
|
|
1144
1211
|
internalType: "uint256"
|
|
1145
1212
|
}
|
|
1146
1213
|
],
|
|
1147
|
-
stateMutability: "
|
|
1214
|
+
stateMutability: "nonpayable"
|
|
1148
1215
|
},
|
|
1149
1216
|
{
|
|
1150
1217
|
type: "function",
|
|
@@ -1200,6 +1267,19 @@ var ABI2 = [
|
|
|
1200
1267
|
internalType: "uint256"
|
|
1201
1268
|
}
|
|
1202
1269
|
],
|
|
1270
|
+
stateMutability: "nonpayable"
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
type: "function",
|
|
1274
|
+
name: "relayer",
|
|
1275
|
+
inputs: [],
|
|
1276
|
+
outputs: [
|
|
1277
|
+
{
|
|
1278
|
+
name: "",
|
|
1279
|
+
type: "address",
|
|
1280
|
+
internalType: "address"
|
|
1281
|
+
}
|
|
1282
|
+
],
|
|
1203
1283
|
stateMutability: "view"
|
|
1204
1284
|
},
|
|
1205
1285
|
{
|
|
@@ -1240,66 +1320,67 @@ var ABI2 = [
|
|
|
1240
1320
|
},
|
|
1241
1321
|
{
|
|
1242
1322
|
type: "function",
|
|
1243
|
-
name: "
|
|
1323
|
+
name: "setRelayer",
|
|
1244
1324
|
inputs: [
|
|
1245
1325
|
{
|
|
1246
|
-
name: "
|
|
1247
|
-
type: "
|
|
1248
|
-
internalType: "
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
type: "bool",
|
|
1263
|
-
internalType: "bool"
|
|
1264
|
-
},
|
|
1265
|
-
{
|
|
1266
|
-
name: "surplusShareBps",
|
|
1267
|
-
type: "uint256",
|
|
1268
|
-
internalType: "uint256"
|
|
1269
|
-
},
|
|
1270
|
-
{
|
|
1271
|
-
name: "protocolFeeBps",
|
|
1272
|
-
type: "uint256",
|
|
1273
|
-
internalType: "uint256"
|
|
1274
|
-
},
|
|
1275
|
-
{
|
|
1276
|
-
name: "priceOracle",
|
|
1277
|
-
type: "address",
|
|
1278
|
-
internalType: "address"
|
|
1279
|
-
}
|
|
1280
|
-
]
|
|
1326
|
+
name: "relayer",
|
|
1327
|
+
type: "address",
|
|
1328
|
+
internalType: "address"
|
|
1329
|
+
}
|
|
1330
|
+
],
|
|
1331
|
+
outputs: [],
|
|
1332
|
+
stateMutability: "nonpayable"
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
type: "function",
|
|
1336
|
+
name: "upgradeToAndCall",
|
|
1337
|
+
inputs: [
|
|
1338
|
+
{
|
|
1339
|
+
name: "newImplementation",
|
|
1340
|
+
type: "address",
|
|
1341
|
+
internalType: "address"
|
|
1281
1342
|
},
|
|
1282
1343
|
{
|
|
1283
|
-
name: "
|
|
1284
|
-
type: "
|
|
1285
|
-
internalType: "
|
|
1286
|
-
components: [
|
|
1287
|
-
{
|
|
1288
|
-
name: "chain",
|
|
1289
|
-
type: "bytes",
|
|
1290
|
-
internalType: "bytes"
|
|
1291
|
-
},
|
|
1292
|
-
{
|
|
1293
|
-
name: "gateway",
|
|
1294
|
-
type: "address",
|
|
1295
|
-
internalType: "address"
|
|
1296
|
-
}
|
|
1297
|
-
]
|
|
1344
|
+
name: "data",
|
|
1345
|
+
type: "bytes",
|
|
1346
|
+
internalType: "bytes"
|
|
1298
1347
|
}
|
|
1299
1348
|
],
|
|
1300
1349
|
outputs: [],
|
|
1301
1350
|
stateMutability: "nonpayable"
|
|
1302
1351
|
},
|
|
1352
|
+
{
|
|
1353
|
+
type: "function",
|
|
1354
|
+
name: "version",
|
|
1355
|
+
inputs: [],
|
|
1356
|
+
outputs: [
|
|
1357
|
+
{
|
|
1358
|
+
name: "",
|
|
1359
|
+
type: "uint64",
|
|
1360
|
+
internalType: "uint64"
|
|
1361
|
+
}
|
|
1362
|
+
],
|
|
1363
|
+
stateMutability: "view"
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
type: "event",
|
|
1367
|
+
name: "DeploymentAdded",
|
|
1368
|
+
inputs: [
|
|
1369
|
+
{
|
|
1370
|
+
name: "chain",
|
|
1371
|
+
type: "string",
|
|
1372
|
+
indexed: false,
|
|
1373
|
+
internalType: "string"
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
name: "gateway",
|
|
1377
|
+
type: "address",
|
|
1378
|
+
indexed: false,
|
|
1379
|
+
internalType: "address"
|
|
1380
|
+
}
|
|
1381
|
+
],
|
|
1382
|
+
anonymous: false
|
|
1383
|
+
},
|
|
1303
1384
|
{
|
|
1304
1385
|
type: "event",
|
|
1305
1386
|
name: "DestinationProtocolFeeUpdated",
|
|
@@ -1433,16 +1514,29 @@ var ABI2 = [
|
|
|
1433
1514
|
},
|
|
1434
1515
|
{
|
|
1435
1516
|
type: "event",
|
|
1436
|
-
name: "
|
|
1517
|
+
name: "Initialized",
|
|
1437
1518
|
inputs: [
|
|
1438
1519
|
{
|
|
1439
|
-
name: "
|
|
1440
|
-
type: "
|
|
1520
|
+
name: "version",
|
|
1521
|
+
type: "uint64",
|
|
1441
1522
|
indexed: false,
|
|
1442
|
-
internalType: "
|
|
1523
|
+
internalType: "uint64"
|
|
1524
|
+
}
|
|
1525
|
+
],
|
|
1526
|
+
anonymous: false
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
type: "event",
|
|
1530
|
+
name: "OrderCancelled",
|
|
1531
|
+
inputs: [
|
|
1532
|
+
{
|
|
1533
|
+
name: "commitment",
|
|
1534
|
+
type: "bytes32",
|
|
1535
|
+
indexed: true,
|
|
1536
|
+
internalType: "bytes32"
|
|
1443
1537
|
},
|
|
1444
1538
|
{
|
|
1445
|
-
name: "
|
|
1539
|
+
name: "canceller",
|
|
1446
1540
|
type: "address",
|
|
1447
1541
|
indexed: false,
|
|
1448
1542
|
internalType: "address"
|
|
@@ -1770,14 +1864,52 @@ var ABI2 = [
|
|
|
1770
1864
|
],
|
|
1771
1865
|
anonymous: false
|
|
1772
1866
|
},
|
|
1867
|
+
{
|
|
1868
|
+
type: "event",
|
|
1869
|
+
name: "RelayerUpdated",
|
|
1870
|
+
inputs: [
|
|
1871
|
+
{
|
|
1872
|
+
name: "previous",
|
|
1873
|
+
type: "address",
|
|
1874
|
+
indexed: false,
|
|
1875
|
+
internalType: "address"
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
name: "current",
|
|
1879
|
+
type: "address",
|
|
1880
|
+
indexed: false,
|
|
1881
|
+
internalType: "address"
|
|
1882
|
+
}
|
|
1883
|
+
],
|
|
1884
|
+
anonymous: false
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
type: "event",
|
|
1888
|
+
name: "Upgraded",
|
|
1889
|
+
inputs: [
|
|
1890
|
+
{
|
|
1891
|
+
name: "implementation",
|
|
1892
|
+
type: "address",
|
|
1893
|
+
indexed: true,
|
|
1894
|
+
internalType: "address"
|
|
1895
|
+
}
|
|
1896
|
+
],
|
|
1897
|
+
anonymous: false
|
|
1898
|
+
},
|
|
1773
1899
|
{
|
|
1774
1900
|
type: "error",
|
|
1775
|
-
name: "
|
|
1776
|
-
inputs: [
|
|
1901
|
+
name: "AddressEmptyCode",
|
|
1902
|
+
inputs: [
|
|
1903
|
+
{
|
|
1904
|
+
name: "target",
|
|
1905
|
+
type: "address",
|
|
1906
|
+
internalType: "address"
|
|
1907
|
+
}
|
|
1908
|
+
]
|
|
1777
1909
|
},
|
|
1778
1910
|
{
|
|
1779
1911
|
type: "error",
|
|
1780
|
-
name: "
|
|
1912
|
+
name: "Cancelled",
|
|
1781
1913
|
inputs: []
|
|
1782
1914
|
},
|
|
1783
1915
|
{
|
|
@@ -1807,11 +1939,37 @@ var ABI2 = [
|
|
|
1807
1939
|
}
|
|
1808
1940
|
]
|
|
1809
1941
|
},
|
|
1942
|
+
{
|
|
1943
|
+
type: "error",
|
|
1944
|
+
name: "ERC1967InvalidImplementation",
|
|
1945
|
+
inputs: [
|
|
1946
|
+
{
|
|
1947
|
+
name: "implementation",
|
|
1948
|
+
type: "address",
|
|
1949
|
+
internalType: "address"
|
|
1950
|
+
}
|
|
1951
|
+
]
|
|
1952
|
+
},
|
|
1953
|
+
{
|
|
1954
|
+
type: "error",
|
|
1955
|
+
name: "ERC1967NonPayable",
|
|
1956
|
+
inputs: []
|
|
1957
|
+
},
|
|
1810
1958
|
{
|
|
1811
1959
|
type: "error",
|
|
1812
1960
|
name: "Expired",
|
|
1813
1961
|
inputs: []
|
|
1814
1962
|
},
|
|
1963
|
+
{
|
|
1964
|
+
type: "error",
|
|
1965
|
+
name: "FailedCall",
|
|
1966
|
+
inputs: []
|
|
1967
|
+
},
|
|
1968
|
+
{
|
|
1969
|
+
type: "error",
|
|
1970
|
+
name: "FillExpired",
|
|
1971
|
+
inputs: []
|
|
1972
|
+
},
|
|
1815
1973
|
{
|
|
1816
1974
|
type: "error",
|
|
1817
1975
|
name: "Filled",
|
|
@@ -1822,6 +1980,11 @@ var ABI2 = [
|
|
|
1822
1980
|
name: "InsufficientNativeToken",
|
|
1823
1981
|
inputs: []
|
|
1824
1982
|
},
|
|
1983
|
+
{
|
|
1984
|
+
type: "error",
|
|
1985
|
+
name: "InvalidInitialization",
|
|
1986
|
+
inputs: []
|
|
1987
|
+
},
|
|
1825
1988
|
{
|
|
1826
1989
|
type: "error",
|
|
1827
1990
|
name: "InvalidInput",
|
|
@@ -1837,6 +2000,21 @@ var ABI2 = [
|
|
|
1837
2000
|
name: "NotExpired",
|
|
1838
2001
|
inputs: []
|
|
1839
2002
|
},
|
|
2003
|
+
{
|
|
2004
|
+
type: "error",
|
|
2005
|
+
name: "NotInitializing",
|
|
2006
|
+
inputs: []
|
|
2007
|
+
},
|
|
2008
|
+
{
|
|
2009
|
+
type: "error",
|
|
2010
|
+
name: "PartialFillNotAllowed",
|
|
2011
|
+
inputs: []
|
|
2012
|
+
},
|
|
2013
|
+
{
|
|
2014
|
+
type: "error",
|
|
2015
|
+
name: "ReentrancyGuardReentrantCall",
|
|
2016
|
+
inputs: []
|
|
2017
|
+
},
|
|
1840
2018
|
{
|
|
1841
2019
|
type: "error",
|
|
1842
2020
|
name: "SafeERC20FailedOperation",
|
|
@@ -1874,6 +2052,11 @@ var ABI2 = [
|
|
|
1874
2052
|
name: "UnexpectedCall",
|
|
1875
2053
|
inputs: []
|
|
1876
2054
|
},
|
|
2055
|
+
{
|
|
2056
|
+
type: "error",
|
|
2057
|
+
name: "UnknownInstance",
|
|
2058
|
+
inputs: []
|
|
2059
|
+
},
|
|
1877
2060
|
{
|
|
1878
2061
|
type: "error",
|
|
1879
2062
|
name: "UnknownOrder",
|
|
@@ -1888,6 +2071,7 @@ var ABI2 = [
|
|
|
1888
2071
|
var IntentGatewayV2_default = { ABI: ABI2 };
|
|
1889
2072
|
|
|
1890
2073
|
// src/chains/intentsCoprocessor.ts
|
|
2074
|
+
util.u8aToHex(util.u8aConcat(utilCrypto.xxhashAsU8a("System", 128), utilCrypto.xxhashAsU8a("Events", 128)));
|
|
1891
2075
|
new TextEncoder().encode("intents::bid::");
|
|
1892
2076
|
new TextEncoder().encode("intents::phantom::order::");
|
|
1893
2077
|
scaleTs.Struct({ filler: scaleTs.Bytes(32), user_op: scaleTs.Vector(scaleTs.u8) });
|
|
@@ -1947,6 +2131,53 @@ function sortPoolSymbols(symbolA, symbolB) {
|
|
|
1947
2131
|
function poolSlug(symbolA, symbolB) {
|
|
1948
2132
|
return sortPoolSymbols(symbolA, symbolB).join("-");
|
|
1949
2133
|
}
|
|
2134
|
+
var FILL_ORDER_V1_ABI = [
|
|
2135
|
+
{
|
|
2136
|
+
type: "function",
|
|
2137
|
+
name: "fillOrder",
|
|
2138
|
+
stateMutability: "payable",
|
|
2139
|
+
outputs: [],
|
|
2140
|
+
inputs: [
|
|
2141
|
+
ABI2.find((e) => e.type === "function" && e.name === "fillOrder").inputs[0],
|
|
2142
|
+
{
|
|
2143
|
+
name: "options",
|
|
2144
|
+
type: "tuple",
|
|
2145
|
+
internalType: "struct FillOptions",
|
|
2146
|
+
components: [
|
|
2147
|
+
{ name: "relayerFee", type: "uint256", internalType: "uint256" },
|
|
2148
|
+
{ name: "nativeDispatchFee", type: "uint256", internalType: "uint256" },
|
|
2149
|
+
{
|
|
2150
|
+
name: "outputs",
|
|
2151
|
+
type: "tuple[]",
|
|
2152
|
+
internalType: "struct TokenInfo[]",
|
|
2153
|
+
components: [
|
|
2154
|
+
{ name: "token", type: "bytes32", internalType: "bytes32" },
|
|
2155
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
2156
|
+
]
|
|
2157
|
+
}
|
|
2158
|
+
]
|
|
2159
|
+
}
|
|
2160
|
+
]
|
|
2161
|
+
}
|
|
2162
|
+
];
|
|
2163
|
+
function decodeFillOrder(data) {
|
|
2164
|
+
try {
|
|
2165
|
+
const decoded = viem.decodeFunctionData({ abi: ABI2, data });
|
|
2166
|
+
if (decoded.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
|
|
2167
|
+
return { order: decoded.args[0], options: decoded.args[1] };
|
|
2168
|
+
}
|
|
2169
|
+
} catch {
|
|
2170
|
+
}
|
|
2171
|
+
try {
|
|
2172
|
+
const decoded = viem.decodeFunctionData({ abi: FILL_ORDER_V1_ABI, data });
|
|
2173
|
+
if (decoded.functionName === "fillOrder" && decoded.args && decoded.args.length >= 2) {
|
|
2174
|
+
const legacy = decoded.args[1];
|
|
2175
|
+
return { order: decoded.args[0], options: { ...legacy, validUntil: 0n } };
|
|
2176
|
+
}
|
|
2177
|
+
} catch {
|
|
2178
|
+
}
|
|
2179
|
+
return null;
|
|
2180
|
+
}
|
|
1950
2181
|
var SELECT_SOLVER_TYPEHASH = viem.keccak256(viem.toHex("SelectSolver(bytes32 commitment,address solver)"));
|
|
1951
2182
|
var PACKED_USEROP_TYPEHASH = viem.keccak256(
|
|
1952
2183
|
viem.toHex(
|
|
@@ -2593,9 +2824,16 @@ function zipFillLegs(assets, outputs) {
|
|
|
2593
2824
|
};
|
|
2594
2825
|
});
|
|
2595
2826
|
}
|
|
2596
|
-
var UNISWAP_QUOTE_HAIRCUT_BPS =
|
|
2827
|
+
var UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
|
|
2828
|
+
var PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
|
|
2829
|
+
function haircut(amount, bps) {
|
|
2830
|
+
return amount * (10000n - bps) / 10000n;
|
|
2831
|
+
}
|
|
2597
2832
|
function applyUniswapQuoteHaircut(amount) {
|
|
2598
|
-
return amount
|
|
2833
|
+
return haircut(amount, UNISWAP_QUOTE_HAIRCUT_BPS);
|
|
2834
|
+
}
|
|
2835
|
+
function applyPhantomQuoteHaircut(amount) {
|
|
2836
|
+
return haircut(amount, PHANTOM_QUOTE_HAIRCUT_BPS);
|
|
2599
2837
|
}
|
|
2600
2838
|
function weightedMedian(entries) {
|
|
2601
2839
|
const sorted = [...entries].sort((a, b) => a.price < b.price ? -1 : a.price > b.price ? 1 : 0);
|
|
@@ -2618,10 +2856,10 @@ function extractFillData(callData, gatewayAddress) {
|
|
|
2618
2856
|
for (const call of calls) {
|
|
2619
2857
|
if (call.target.toLowerCase() !== normalized) continue;
|
|
2620
2858
|
try {
|
|
2621
|
-
const decoded =
|
|
2622
|
-
if (
|
|
2623
|
-
const order = decoded.
|
|
2624
|
-
const options = decoded.
|
|
2859
|
+
const decoded = decodeFillOrder(call.data);
|
|
2860
|
+
if (!decoded) continue;
|
|
2861
|
+
const order = decoded.order;
|
|
2862
|
+
const options = decoded.options;
|
|
2625
2863
|
const assets = order?.output?.assets;
|
|
2626
2864
|
const outputs = options?.outputs;
|
|
2627
2865
|
if (!assets?.length || !outputs?.length) continue;
|
|
@@ -2664,7 +2902,7 @@ var recoverBidSignerViem = async (userOp, entryPoint, chainId, solverSignature)
|
|
|
2664
2902
|
}
|
|
2665
2903
|
};
|
|
2666
2904
|
var DELEGATION_INDICATOR_PREFIX = "0xef0100";
|
|
2667
|
-
async function isDelegatedToSolverAccount(evmRpcUrl, account,
|
|
2905
|
+
async function isDelegatedToSolverAccount(evmRpcUrl, account, solverAccounts) {
|
|
2668
2906
|
const response = await rpcCall(evmRpcUrl, {
|
|
2669
2907
|
id: 1,
|
|
2670
2908
|
jsonrpc: "2.0",
|
|
@@ -2676,15 +2914,17 @@ async function isDelegatedToSolverAccount(evmRpcUrl, account, solverAccount) {
|
|
|
2676
2914
|
}
|
|
2677
2915
|
const code = response.result.toLowerCase();
|
|
2678
2916
|
if (!code.startsWith(DELEGATION_INDICATOR_PREFIX)) return false;
|
|
2679
|
-
|
|
2917
|
+
const delegate = `0x${code.slice(DELEGATION_INDICATOR_PREFIX.length)}`;
|
|
2918
|
+
return solverAccounts.some((solverAccount) => solverAccount.toLowerCase() === delegate);
|
|
2680
2919
|
}
|
|
2681
2920
|
function memoizedDelegationCheck() {
|
|
2682
2921
|
const cache = /* @__PURE__ */ new Map();
|
|
2683
|
-
return (evmRpcUrl, account,
|
|
2684
|
-
const
|
|
2922
|
+
return (evmRpcUrl, account, solverAccounts) => {
|
|
2923
|
+
const targets = solverAccounts.map((a) => a.toLowerCase()).sort().join(",");
|
|
2924
|
+
const key = `${evmRpcUrl}|${account.toLowerCase()}|${targets}`;
|
|
2685
2925
|
let pending = cache.get(key);
|
|
2686
2926
|
if (!pending) {
|
|
2687
|
-
pending = isDelegatedToSolverAccount(evmRpcUrl, account,
|
|
2927
|
+
pending = isDelegatedToSolverAccount(evmRpcUrl, account, solverAccounts).catch((err) => {
|
|
2688
2928
|
cache.delete(key);
|
|
2689
2929
|
throw err;
|
|
2690
2930
|
});
|
|
@@ -2704,7 +2944,7 @@ async function isVerifiedSolverBid(params) {
|
|
|
2704
2944
|
commitment,
|
|
2705
2945
|
sessionKey,
|
|
2706
2946
|
chainId,
|
|
2707
|
-
|
|
2947
|
+
solverAccounts,
|
|
2708
2948
|
evmRpcUrl,
|
|
2709
2949
|
recoverSigner,
|
|
2710
2950
|
bidNonceKey,
|
|
@@ -2733,8 +2973,8 @@ async function isVerifiedSolverBid(params) {
|
|
|
2733
2973
|
logger?.warn({ solver, commitment, signer }, "Rejecting phantom bid: signature does not recover to the sender");
|
|
2734
2974
|
return false;
|
|
2735
2975
|
}
|
|
2736
|
-
if (!await isDelegated(evmRpcUrl, solver,
|
|
2737
|
-
logger?.warn({ solver, commitment,
|
|
2976
|
+
if (!await isDelegated(evmRpcUrl, solver, solverAccounts)) {
|
|
2977
|
+
logger?.warn({ solver, commitment, solverAccounts }, "Rejecting phantom bid: sender is not a delegated solver");
|
|
2738
2978
|
return false;
|
|
2739
2979
|
}
|
|
2740
2980
|
return true;
|
|
@@ -2748,12 +2988,12 @@ async function fetchBidsForOrder(nodeUrl, commitment) {
|
|
|
2748
2988
|
});
|
|
2749
2989
|
return Array.isArray(data.result) ? data.result : [];
|
|
2750
2990
|
}
|
|
2751
|
-
async function ethCallUint(evmRpcUrl, to, data) {
|
|
2991
|
+
async function ethCallUint(evmRpcUrl, to, data, blockTag = "latest") {
|
|
2752
2992
|
const result = await rpcCall(evmRpcUrl, {
|
|
2753
2993
|
id: 1,
|
|
2754
2994
|
jsonrpc: "2.0",
|
|
2755
2995
|
method: "eth_call",
|
|
2756
|
-
params: [{ to, data },
|
|
2996
|
+
params: [{ to, data }, blockTag]
|
|
2757
2997
|
});
|
|
2758
2998
|
if (result.result === "0x") return 0n;
|
|
2759
2999
|
if (typeof result.result !== "string") {
|
|
@@ -2761,12 +3001,12 @@ async function ethCallUint(evmRpcUrl, to, data) {
|
|
|
2761
3001
|
}
|
|
2762
3002
|
return BigInt(result.result);
|
|
2763
3003
|
}
|
|
2764
|
-
async function getTotalSolverBalance(evmRpcUrl, chain, token, solver, yieldVaults) {
|
|
3004
|
+
async function getTotalSolverBalance(evmRpcUrl, chain, token, solver, yieldVaults, blockTag = "latest") {
|
|
2765
3005
|
const padded = solver.replace("0x", "").padStart(64, "0");
|
|
2766
|
-
const raw = await ethCallUint(evmRpcUrl, token, `0x70a08231${padded}
|
|
3006
|
+
const raw = await ethCallUint(evmRpcUrl, token, `0x70a08231${padded}`, blockTag);
|
|
2767
3007
|
const vaults = yieldVaults[chain]?.[token.toLowerCase()] ?? [];
|
|
2768
3008
|
const vaultBalances = await Promise.all(
|
|
2769
|
-
vaults.map((v) => ethCallUint(evmRpcUrl, v, `0xce96cb77${padded}
|
|
3009
|
+
vaults.map((v) => ethCallUint(evmRpcUrl, v, `0xce96cb77${padded}`, blockTag))
|
|
2770
3010
|
// maxWithdraw(address)
|
|
2771
3011
|
);
|
|
2772
3012
|
return vaultBalances.reduce((acc, b) => acc + b, raw);
|
|
@@ -2776,13 +3016,14 @@ var SELECTOR_POSITION_LIQUIDITY = "0x1efeed33";
|
|
|
2776
3016
|
var SELECTOR_POOL_AND_POSITION_INFO = "0x7ba03aad";
|
|
2777
3017
|
var SELECTOR_GET_SLOT0 = "0xc815641c";
|
|
2778
3018
|
var uint256Arg = (value) => value.toString(16).padStart(64, "0");
|
|
2779
|
-
async function readV4Position(
|
|
3019
|
+
async function readV4Position(params) {
|
|
3020
|
+
const { evmRpcUrl, contracts, tokenId, keccak, blockTag = "latest", logger } = params;
|
|
2780
3021
|
const call = async (to, data) => {
|
|
2781
3022
|
const result = await rpcCall(evmRpcUrl, {
|
|
2782
3023
|
id: 1,
|
|
2783
3024
|
jsonrpc: "2.0",
|
|
2784
3025
|
method: "eth_call",
|
|
2785
|
-
params: [{ to, data },
|
|
3026
|
+
params: [{ to, data }, blockTag]
|
|
2786
3027
|
});
|
|
2787
3028
|
if (result.result === "0x") return null;
|
|
2788
3029
|
if (typeof result.result !== "string") {
|
|
@@ -2826,7 +3067,7 @@ function memoizedV4Position(keccak, logger) {
|
|
|
2826
3067
|
const key = `${chain}|${tokenId}`;
|
|
2827
3068
|
let pending = cache.get(key);
|
|
2828
3069
|
if (!pending) {
|
|
2829
|
-
pending = readV4Position(evmRpcUrl, contracts, tokenId, keccak, logger).catch((err) => {
|
|
3070
|
+
pending = readV4Position({ evmRpcUrl, contracts, tokenId, keccak, logger }).catch((err) => {
|
|
2830
3071
|
cache.delete(key);
|
|
2831
3072
|
throw err;
|
|
2832
3073
|
});
|
|
@@ -2835,13 +3076,13 @@ function memoizedV4Position(keccak, logger) {
|
|
|
2835
3076
|
return pending;
|
|
2836
3077
|
};
|
|
2837
3078
|
}
|
|
2838
|
-
function memoizedSolverBalance(yieldVaults) {
|
|
3079
|
+
function memoizedSolverBalance(yieldVaults, blockTags = {}) {
|
|
2839
3080
|
const cache = /* @__PURE__ */ new Map();
|
|
2840
3081
|
return (evmRpcUrl, chain, token, solver) => {
|
|
2841
3082
|
const key = `${chain}|${token.toLowerCase()}|${solver.toLowerCase()}`;
|
|
2842
3083
|
let pending = cache.get(key);
|
|
2843
3084
|
if (!pending) {
|
|
2844
|
-
pending = getTotalSolverBalance(evmRpcUrl, chain, token, solver, yieldVaults).catch((err) => {
|
|
3085
|
+
pending = getTotalSolverBalance(evmRpcUrl, chain, token, solver, yieldVaults, blockTags[chain]).catch((err) => {
|
|
2845
3086
|
cache.delete(key);
|
|
2846
3087
|
throw err;
|
|
2847
3088
|
});
|
|
@@ -2897,7 +3138,10 @@ async function aggregatePhantomBids(params) {
|
|
|
2897
3138
|
}
|
|
2898
3139
|
var AGGREGATION_ATTEMPTS = 5;
|
|
2899
3140
|
async function runAggregation(params, isDelegated) {
|
|
2900
|
-
const { nodeUrl, evmRpcUrls, chain, gatewayAddress, commitment, yieldVaults,
|
|
3141
|
+
const { nodeUrl, evmRpcUrls, chain, gatewayAddress, commitment, yieldVaults, logger } = params;
|
|
3142
|
+
const solverAccounts = (Array.isArray(params.solverAccount) ? params.solverAccount : [params.solverAccount]).filter(
|
|
3143
|
+
(a) => typeof a === "string" && a.length > 0
|
|
3144
|
+
);
|
|
2901
3145
|
const extractFill = params.extractFill ?? extractFillData;
|
|
2902
3146
|
const recoverSigner = params.recoverSigner ?? recoverBidSignerViem;
|
|
2903
3147
|
const bidNonceKey = params.bidNonceKey ?? CryptoUtils.bidNonceKey;
|
|
@@ -2905,7 +3149,7 @@ async function runAggregation(params, isDelegated) {
|
|
|
2905
3149
|
const destUrl = evmRpcUrls[chain];
|
|
2906
3150
|
if (!destUrl) return null;
|
|
2907
3151
|
const chainId = evmChainId(chain);
|
|
2908
|
-
if (
|
|
3152
|
+
if (solverAccounts.length === 0 || chainId === null) {
|
|
2909
3153
|
logger?.warn({ chain, commitment }, "Cannot verify phantom bids: no SolverAccount or chain id for chain");
|
|
2910
3154
|
return null;
|
|
2911
3155
|
}
|
|
@@ -2916,6 +3160,7 @@ async function runAggregation(params, isDelegated) {
|
|
|
2916
3160
|
const getBalance = params.getBalance ?? memoizedSolverBalance(yieldVaults);
|
|
2917
3161
|
const quotesByLeg = /* @__PURE__ */ new Map();
|
|
2918
3162
|
const lpBalances = [];
|
|
3163
|
+
const verifiedPositions = [];
|
|
2919
3164
|
const countedSolvers = /* @__PURE__ */ new Set();
|
|
2920
3165
|
for (const bid of bids) {
|
|
2921
3166
|
if (!bid.user_op) continue;
|
|
@@ -2939,7 +3184,7 @@ async function runAggregation(params, isDelegated) {
|
|
|
2939
3184
|
commitment,
|
|
2940
3185
|
sessionKey,
|
|
2941
3186
|
chainId,
|
|
2942
|
-
|
|
3187
|
+
solverAccounts,
|
|
2943
3188
|
evmRpcUrl: destUrl,
|
|
2944
3189
|
recoverSigner,
|
|
2945
3190
|
bidNonceKey,
|
|
@@ -2956,23 +3201,32 @@ async function runAggregation(params, isDelegated) {
|
|
|
2956
3201
|
const declaration = decodePhantomBidDeclaration(decoded.paymasterAndData);
|
|
2957
3202
|
const acceptedSources = declaration.acceptedSources;
|
|
2958
3203
|
const poolPriced = declaration.uniswapV4Positions.length > 0;
|
|
2959
|
-
const
|
|
2960
|
-
|
|
2961
|
-
|
|
3204
|
+
const applyHaircut = poolPriced ? applyUniswapQuoteHaircut : applyPhantomQuoteHaircut;
|
|
3205
|
+
const quotedLegs = [...fillData.legs.entries()].map(([legIndex, leg]) => [
|
|
3206
|
+
legIndex,
|
|
3207
|
+
{ ...leg, solverAmount: applyHaircut(leg.solverAmount) }
|
|
3208
|
+
]).filter(([, leg]) => leg.solverAmount !== 0n);
|
|
2962
3209
|
const declaredPositions = v4Contracts ? declaration.uniswapV4Positions : [];
|
|
2963
|
-
const
|
|
2964
|
-
declaredPositions.map((tokenId) =>
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
3210
|
+
const ownedPositions = (await Promise.all(
|
|
3211
|
+
declaredPositions.map(async (tokenId) => ({
|
|
3212
|
+
tokenId,
|
|
3213
|
+
state: await readPosition(destUrl, chain, v4Contracts, tokenId)
|
|
3214
|
+
}))
|
|
3215
|
+
)).filter((entry) => {
|
|
3216
|
+
if (!entry.state) return false;
|
|
3217
|
+
if (entry.state.owner !== normalizedSolver) {
|
|
2968
3218
|
logger?.warn(
|
|
2969
|
-
{ solver, commitment, tokenId:
|
|
3219
|
+
{ solver, commitment, tokenId: entry.tokenId.toString(), owner: entry.state.owner },
|
|
2970
3220
|
"Ignoring declared Uniswap V4 position: not owned by the bidding solver"
|
|
2971
3221
|
);
|
|
2972
3222
|
return false;
|
|
2973
3223
|
}
|
|
2974
3224
|
return true;
|
|
2975
3225
|
});
|
|
3226
|
+
const positions = ownedPositions.map((entry) => entry.state);
|
|
3227
|
+
for (const entry of ownedPositions) {
|
|
3228
|
+
verifiedPositions.push({ solver: normalizedSolver, chain, tokenId: entry.tokenId });
|
|
3229
|
+
}
|
|
2976
3230
|
const weights = await Promise.all(
|
|
2977
3231
|
// Price influence: the solver's liquidity in THIS leg's output token on the destination
|
|
2978
3232
|
// chain, so a leg is weighted by the inventory that actually backs it.
|
|
@@ -3032,14 +3286,17 @@ async function runAggregation(params, isDelegated) {
|
|
|
3032
3286
|
}
|
|
3033
3287
|
];
|
|
3034
3288
|
});
|
|
3035
|
-
return { legs, lpBalances };
|
|
3289
|
+
return { legs, lpBalances, positions: verifiedPositions, solvers: [...countedSolvers] };
|
|
3036
3290
|
}
|
|
3037
3291
|
|
|
3038
3292
|
exports.ENTRY_POINT_V08_ADDRESS = ENTRY_POINT_V08_ADDRESS;
|
|
3039
3293
|
exports.FILL_ORDER_ABI = FILL_ORDER_ABI;
|
|
3294
|
+
exports.FILL_ORDER_V1_ABI = FILL_ORDER_V1_ABI;
|
|
3040
3295
|
exports.IntentGatewayV2 = IntentGatewayV2_default;
|
|
3296
|
+
exports.PHANTOM_QUOTE_HAIRCUT_BPS = PHANTOM_QUOTE_HAIRCUT_BPS;
|
|
3041
3297
|
exports.UNISWAP_QUOTE_HAIRCUT_BPS = UNISWAP_QUOTE_HAIRCUT_BPS;
|
|
3042
3298
|
exports.aggregatePhantomBids = aggregatePhantomBids;
|
|
3299
|
+
exports.applyPhantomQuoteHaircut = applyPhantomQuoteHaircut;
|
|
3043
3300
|
exports.applyUniswapQuoteHaircut = applyUniswapQuoteHaircut;
|
|
3044
3301
|
exports.decodeAcceptedSourceChains = decodeAcceptedSourceChains;
|
|
3045
3302
|
exports.decodeERC7821ExecuteBatch = decodeERC7821ExecuteBatch;
|
|
@@ -3051,9 +3308,12 @@ exports.encodePhantomBidDeclaration = encodePhantomBidDeclaration;
|
|
|
3051
3308
|
exports.encodeUserOpScale = encodeUserOpScale;
|
|
3052
3309
|
exports.extractFillData = extractFillData;
|
|
3053
3310
|
exports.fetchBidsForOrder = fetchBidsForOrder;
|
|
3311
|
+
exports.getTotalSolverBalance = getTotalSolverBalance;
|
|
3054
3312
|
exports.memoizedSolverBalance = memoizedSolverBalance;
|
|
3055
3313
|
exports.orderCommitmentFromDecoded = orderCommitmentFromDecoded;
|
|
3056
3314
|
exports.poolSlug = poolSlug;
|
|
3315
|
+
exports.positionAmountOfToken = positionAmountOfToken;
|
|
3316
|
+
exports.readV4Position = readV4Position;
|
|
3057
3317
|
exports.recoverBidSignerViem = recoverBidSignerViem;
|
|
3058
3318
|
exports.setAggregationFetch = setAggregationFetch;
|
|
3059
3319
|
exports.sortPoolSymbols = sortPoolSymbols;
|