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