@sodax/sdk 2.2.0-rc.8 → 2.3.0-rc.1
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 +6 -6
- package/dist/index.cjs +1973 -320
- package/dist/index.d.cts +433 -34
- package/dist/index.d.ts +433 -34
- package/dist/index.mjs +1962 -321
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -123,8 +123,8 @@ function serializeCause(cause, depth) {
|
|
|
123
123
|
}
|
|
124
124
|
function sanitizeContext(value, depth) {
|
|
125
125
|
const out = {};
|
|
126
|
-
for (const [key,
|
|
127
|
-
out[key] = sanitizeValue(
|
|
126
|
+
for (const [key, v11] of Object.entries(value)) {
|
|
127
|
+
out[key] = sanitizeValue(v11, depth + 1);
|
|
128
128
|
}
|
|
129
129
|
return out;
|
|
130
130
|
}
|
|
@@ -135,13 +135,13 @@ function sanitizeValue(value, depth) {
|
|
|
135
135
|
if (t === "bigint") return value.toString();
|
|
136
136
|
if (t === "string" || t === "number" || t === "boolean") return value;
|
|
137
137
|
if (t === "function" || t === "symbol") return safeString(value);
|
|
138
|
-
if (Array.isArray(value)) return value.map((
|
|
138
|
+
if (Array.isArray(value)) return value.map((v11) => sanitizeValue(v11, depth + 1));
|
|
139
139
|
if (value instanceof Date) return value.toISOString();
|
|
140
140
|
if (value instanceof Map) {
|
|
141
|
-
return Array.from(value.entries()).map(([k,
|
|
141
|
+
return Array.from(value.entries()).map(([k, v11]) => [sanitizeValue(k, depth + 1), sanitizeValue(v11, depth + 1)]);
|
|
142
142
|
}
|
|
143
143
|
if (value instanceof Set) {
|
|
144
|
-
return Array.from(value.values()).map((
|
|
144
|
+
return Array.from(value.values()).map((v11) => sanitizeValue(v11, depth + 1));
|
|
145
145
|
}
|
|
146
146
|
if (value instanceof Error) return { name: value.name, message: value.message };
|
|
147
147
|
if (t === "object") {
|
|
@@ -153,9 +153,9 @@ function sanitizeValue(value, depth) {
|
|
|
153
153
|
}
|
|
154
154
|
return safeString(value);
|
|
155
155
|
}
|
|
156
|
-
function safeString(
|
|
156
|
+
function safeString(v11) {
|
|
157
157
|
try {
|
|
158
|
-
return String(
|
|
158
|
+
return String(v11);
|
|
159
159
|
} catch {
|
|
160
160
|
return "[unserializable]";
|
|
161
161
|
}
|
|
@@ -317,7 +317,7 @@ var CHAIN_KEYS = Object.values(ChainKeys);
|
|
|
317
317
|
var spokeChainKeysSet = new Set(CHAIN_KEYS);
|
|
318
318
|
|
|
319
319
|
// ../types/dist/chains/tokens.js
|
|
320
|
-
var TOKEN_LOGO_BASE_URL = "https://raw.githubusercontent.com/
|
|
320
|
+
var TOKEN_LOGO_BASE_URL = "https://raw.githubusercontent.com/gosodax/sodax-sdks/main/packages/assets/token";
|
|
321
321
|
var tokenLogoSlug = (symbol) => symbol.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
322
322
|
var tokenLogo = (symbol) => `${TOKEN_LOGO_BASE_URL}/${tokenLogoSlug(symbol)}.png`;
|
|
323
323
|
var StatATokenAddresses = {
|
|
@@ -378,7 +378,9 @@ var HubVaultSymbols = [
|
|
|
378
378
|
"TSM",
|
|
379
379
|
"AMD",
|
|
380
380
|
"INTC",
|
|
381
|
-
"BABA"
|
|
381
|
+
"BABA",
|
|
382
|
+
"sodaADA",
|
|
383
|
+
"sodaZEC"
|
|
382
384
|
];
|
|
383
385
|
var SodaTokens = {
|
|
384
386
|
sodaBNB: {
|
|
@@ -881,6 +883,24 @@ var SodaTokens = {
|
|
|
881
883
|
chainKey: ChainKeys.SONIC_MAINNET,
|
|
882
884
|
hubAsset: "0x1BeD0547D76F6424e9A3465b36F6dcDCF798A5cf",
|
|
883
885
|
vault: "0x1BeD0547D76F6424e9A3465b36F6dcDCF798A5cf"
|
|
886
|
+
},
|
|
887
|
+
sodaADA: {
|
|
888
|
+
symbol: "sodaADA",
|
|
889
|
+
name: "SODA ADA",
|
|
890
|
+
decimals: 18,
|
|
891
|
+
address: "0xa3e161c014b6285f06425f9fd78aa83b60c1ab9e",
|
|
892
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
893
|
+
hubAsset: "0xa3e161c014b6285f06425f9fd78aa83b60c1ab9e",
|
|
894
|
+
vault: "0xa3e161c014b6285f06425f9fd78aa83b60c1ab9e"
|
|
895
|
+
},
|
|
896
|
+
sodaZEC: {
|
|
897
|
+
symbol: "sodaZEC",
|
|
898
|
+
name: "SODA ZEC",
|
|
899
|
+
decimals: 18,
|
|
900
|
+
address: "0xf4af0aa80f079d5bff230c5b12109fa19b24f558",
|
|
901
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
902
|
+
hubAsset: "0xf4af0aa80f079d5bff230c5b12109fa19b24f558",
|
|
903
|
+
vault: "0xf4af0aa80f079d5bff230c5b12109fa19b24f558"
|
|
884
904
|
}
|
|
885
905
|
};
|
|
886
906
|
var LsodaSymbols = ["lsodaWEETH", "lsodaWSTETH", "lsodaJITOSOL", "lsodaSUSDS"];
|
|
@@ -1422,6 +1442,216 @@ var solanaSupportedTokens = {
|
|
|
1422
1442
|
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1423
1443
|
hubAsset: "0x0a3a93b7303a582b2ab84cfb3493fdb9d160a3ef",
|
|
1424
1444
|
vault: "0x0a3a93b7303a582b2ab84cfb3493fdb9d160a3ef"
|
|
1445
|
+
},
|
|
1446
|
+
"2Z": {
|
|
1447
|
+
symbol: "2Z",
|
|
1448
|
+
name: "DoubleZero",
|
|
1449
|
+
decimals: 8,
|
|
1450
|
+
address: "J6pQQ3FAcJQeWPPGppWRb4nM8jU3wLyYbRrLh7feMfvd",
|
|
1451
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1452
|
+
hubAsset: "0xe27f9c0e27a71743a1e43f585b9f17c6a9c2493f",
|
|
1453
|
+
vault: "0xe27f9c0e27a71743a1e43f585b9f17c6a9c2493f"
|
|
1454
|
+
},
|
|
1455
|
+
ANSEM: {
|
|
1456
|
+
symbol: "ANSEM",
|
|
1457
|
+
name: "The Black Bull",
|
|
1458
|
+
decimals: 6,
|
|
1459
|
+
address: "9cRCn9rGT8V2imeM2BaKs13yhMEais3ruM3rPvTGpump",
|
|
1460
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1461
|
+
hubAsset: "0x0392de493dc89cf5dac2f06ce4a60c590008e537",
|
|
1462
|
+
vault: "0x0392de493dc89cf5dac2f06ce4a60c590008e537"
|
|
1463
|
+
},
|
|
1464
|
+
BP: {
|
|
1465
|
+
symbol: "BP",
|
|
1466
|
+
name: "Backpack",
|
|
1467
|
+
decimals: 9,
|
|
1468
|
+
address: "BPxxfRCXkUVhig4HS1Lh7kZqV6SPJhzfEk4x6fVBjPCy",
|
|
1469
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1470
|
+
hubAsset: "0x9a1e90e1f591ac516781c5dc0523d998015dca74",
|
|
1471
|
+
vault: "0x9a1e90e1f591ac516781c5dc0523d998015dca74"
|
|
1472
|
+
},
|
|
1473
|
+
CARDS: {
|
|
1474
|
+
symbol: "CARDS",
|
|
1475
|
+
name: "Collector Crypt",
|
|
1476
|
+
decimals: 6,
|
|
1477
|
+
address: "CARDSccUMFKoPRZxt5vt3ksUbxEFEcnZ3H2pd3dKxYjp",
|
|
1478
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1479
|
+
hubAsset: "0xe639567bc448c8fe4c34b3c074fffea2047c77d2",
|
|
1480
|
+
vault: "0xe639567bc448c8fe4c34b3c074fffea2047c77d2"
|
|
1481
|
+
},
|
|
1482
|
+
CASH: {
|
|
1483
|
+
symbol: "CASH",
|
|
1484
|
+
name: "CASH",
|
|
1485
|
+
decimals: 6,
|
|
1486
|
+
address: "CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH",
|
|
1487
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1488
|
+
hubAsset: "0x28e5589c8030d0f53961db173e9bf1e0f59e716a",
|
|
1489
|
+
vault: "0x28e5589c8030d0f53961db173e9bf1e0f59e716a"
|
|
1490
|
+
},
|
|
1491
|
+
Fartcoin: {
|
|
1492
|
+
symbol: "Fartcoin",
|
|
1493
|
+
name: "Fartcoin",
|
|
1494
|
+
decimals: 6,
|
|
1495
|
+
address: "9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump",
|
|
1496
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1497
|
+
hubAsset: "0x7127c0a5cab393a6b0b311684130c985a00eb06a",
|
|
1498
|
+
vault: "0x7127c0a5cab393a6b0b311684130c985a00eb06a"
|
|
1499
|
+
},
|
|
1500
|
+
GLDx: {
|
|
1501
|
+
symbol: "GLDx",
|
|
1502
|
+
isRwa: true,
|
|
1503
|
+
name: "Gold xStock",
|
|
1504
|
+
decimals: 8,
|
|
1505
|
+
address: "Xsv9hRk1z5ystj9MhnA7Lq4vjSsLwzL2nxrwmwtD3re",
|
|
1506
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1507
|
+
hubAsset: "0x236d062ba08cea4e28e006ab8d14c5b407bcfa0d",
|
|
1508
|
+
vault: "0x236d062ba08cea4e28e006ab8d14c5b407bcfa0d"
|
|
1509
|
+
},
|
|
1510
|
+
HOODx: {
|
|
1511
|
+
symbol: "HOODx",
|
|
1512
|
+
isRwa: true,
|
|
1513
|
+
name: "Robinhood xStock",
|
|
1514
|
+
decimals: 8,
|
|
1515
|
+
address: "XsvNBAYkrDRNhA7wPHQfX3ZUXZyZLdnCQDfHZ56bzpg",
|
|
1516
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1517
|
+
hubAsset: "0xd9c608fc37d1c7714ea1d1019197473d2b94e46e",
|
|
1518
|
+
vault: "0xd9c608fc37d1c7714ea1d1019197473d2b94e46e"
|
|
1519
|
+
},
|
|
1520
|
+
HYPE: {
|
|
1521
|
+
symbol: "HYPE",
|
|
1522
|
+
name: "Wormhole Bridged HYPE",
|
|
1523
|
+
decimals: 9,
|
|
1524
|
+
address: "98sMhvDwXj1RQi5c5Mndm3vPe9cBqPrbLaufMXFNMh5g",
|
|
1525
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1526
|
+
hubAsset: "0xe16bde1138dde975d84b43e99998fb6baee4bd8f",
|
|
1527
|
+
vault: SodaTokens.sodaHYPE.address
|
|
1528
|
+
},
|
|
1529
|
+
hyUSD: {
|
|
1530
|
+
symbol: "hyUSD",
|
|
1531
|
+
name: "Hylo USD",
|
|
1532
|
+
decimals: 6,
|
|
1533
|
+
address: "5YMkXAYccHSGnHn9nob9xEvv6Pvka9DZWH7nTbotTu9E",
|
|
1534
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1535
|
+
hubAsset: "0x5e2d86db5d93354de1ff2f70591509cf47cd878c",
|
|
1536
|
+
vault: "0x5e2d86db5d93354de1ff2f70591509cf47cd878c"
|
|
1537
|
+
},
|
|
1538
|
+
KMNO: {
|
|
1539
|
+
symbol: "KMNO",
|
|
1540
|
+
name: "Kamino",
|
|
1541
|
+
decimals: 6,
|
|
1542
|
+
address: "KMNo3nJsBXfcpJTVhZcXLW7RmTwTt4GVFE7suUBo9sS",
|
|
1543
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1544
|
+
hubAsset: "0x96e788fc83ef83c3201e4763fabe8e2dedf6eca7",
|
|
1545
|
+
vault: "0x96e788fc83ef83c3201e4763fabe8e2dedf6eca7"
|
|
1546
|
+
},
|
|
1547
|
+
LBTC: {
|
|
1548
|
+
symbol: "LBTC",
|
|
1549
|
+
name: "Lombard BTC",
|
|
1550
|
+
decimals: 8,
|
|
1551
|
+
address: "LBTCgU4b3wsFKsPwBn1rRZDx5DoFutM6RPiEt1TPDsY",
|
|
1552
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1553
|
+
hubAsset: "0x0abcce0b778587f9d6c83064d857027797220507",
|
|
1554
|
+
vault: SodaTokens.sodaBTC.address
|
|
1555
|
+
},
|
|
1556
|
+
MET: {
|
|
1557
|
+
symbol: "MET",
|
|
1558
|
+
name: "Meteora",
|
|
1559
|
+
decimals: 6,
|
|
1560
|
+
address: "METvsvVRapdj9cFLzq4Tr43xK4tAjQfwX76z3n6mWQL",
|
|
1561
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1562
|
+
hubAsset: "0xf6c71a67a7def6f87b0867113e366fcbba71b55f",
|
|
1563
|
+
vault: "0xf6c71a67a7def6f87b0867113e366fcbba71b55f"
|
|
1564
|
+
},
|
|
1565
|
+
ONYC: {
|
|
1566
|
+
symbol: "ONYC",
|
|
1567
|
+
name: "OnRe Tokenized Reinsurance",
|
|
1568
|
+
decimals: 9,
|
|
1569
|
+
address: "5Y8NV33Vv7WbnLfq3zBcKSdYPrk7g2KoiQoe7M2tcxp5",
|
|
1570
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1571
|
+
hubAsset: "0xacc1adb3095706e0fd7b70b2cab2b331bc95d32a",
|
|
1572
|
+
vault: "0xacc1adb3095706e0fd7b70b2cab2b331bc95d32a"
|
|
1573
|
+
},
|
|
1574
|
+
PENGU: {
|
|
1575
|
+
symbol: "PENGU",
|
|
1576
|
+
name: "Pudgy Penguins",
|
|
1577
|
+
decimals: 6,
|
|
1578
|
+
address: "2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv",
|
|
1579
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1580
|
+
hubAsset: "0x0cea0541b3790e8b54eef79fe243b9d1ba909add",
|
|
1581
|
+
vault: "0x0cea0541b3790e8b54eef79fe243b9d1ba909add"
|
|
1582
|
+
},
|
|
1583
|
+
PRIME: {
|
|
1584
|
+
symbol: "PRIME",
|
|
1585
|
+
name: "Hastra PRIME",
|
|
1586
|
+
decimals: 6,
|
|
1587
|
+
address: "3b8X44fLF9ooXaUm3hhSgjpmVs6rZZ3pPoGnGahc3Uu7",
|
|
1588
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1589
|
+
hubAsset: "0xc848404d5c99c10a554094a53e71d0305fbac518",
|
|
1590
|
+
vault: "0xc848404d5c99c10a554094a53e71d0305fbac518"
|
|
1591
|
+
},
|
|
1592
|
+
SPCXx: {
|
|
1593
|
+
symbol: "SPCXx",
|
|
1594
|
+
isRwa: true,
|
|
1595
|
+
name: "SpaceX xStock",
|
|
1596
|
+
decimals: 8,
|
|
1597
|
+
address: "Xs3oZwbHvqis4NYcf4YKWmEia2eC84wSiVrcYcTqpH8",
|
|
1598
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1599
|
+
hubAsset: "0x760bc9d7dede486a235e58992815ff54bc1b3269",
|
|
1600
|
+
vault: "0x760bc9d7dede486a235e58992815ff54bc1b3269"
|
|
1601
|
+
},
|
|
1602
|
+
STONK: {
|
|
1603
|
+
symbol: "STONK",
|
|
1604
|
+
name: "STONK",
|
|
1605
|
+
decimals: 9,
|
|
1606
|
+
address: "6GmAFSYs4gk3FDao5FzzySQpPZaWsa4rUJHacpMpUNgx",
|
|
1607
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1608
|
+
hubAsset: "0x02a88631e2fe0dd2169b6e9452e65e98b2c6f27e",
|
|
1609
|
+
vault: "0x02a88631e2fe0dd2169b6e9452e65e98b2c6f27e"
|
|
1610
|
+
},
|
|
1611
|
+
syrupUSDC: {
|
|
1612
|
+
symbol: "syrupUSDC",
|
|
1613
|
+
name: "syrupUSDC",
|
|
1614
|
+
decimals: 6,
|
|
1615
|
+
address: "AvZZF1YaZDziPY2RCK4oJrRVrbN3mTD9NL24hPeaZeUj",
|
|
1616
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1617
|
+
hubAsset: "0x2941198088fdac45d983798d1246f073fc36330f",
|
|
1618
|
+
vault: "0x2941198088fdac45d983798d1246f073fc36330f"
|
|
1619
|
+
},
|
|
1620
|
+
TRUMP: {
|
|
1621
|
+
symbol: "TRUMP",
|
|
1622
|
+
name: "Official Trump",
|
|
1623
|
+
decimals: 6,
|
|
1624
|
+
address: "6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
|
|
1625
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1626
|
+
hubAsset: "0xf5291267892347830b1a7b92a4061e8c28cc06fb",
|
|
1627
|
+
vault: "0xf5291267892347830b1a7b92a4061e8c28cc06fb"
|
|
1628
|
+
},
|
|
1629
|
+
USX: {
|
|
1630
|
+
symbol: "USX",
|
|
1631
|
+
name: "USX",
|
|
1632
|
+
decimals: 6,
|
|
1633
|
+
address: "6FrrzDk5mQARGc1TDYoyVnSyRdds1t4PbtohCD6p3tgG",
|
|
1634
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1635
|
+
hubAsset: "0x4f8b6611700fbf8aabfbcd595e0b33d23de89dd5",
|
|
1636
|
+
vault: "0x4f8b6611700fbf8aabfbcd595e0b33d23de89dd5"
|
|
1637
|
+
},
|
|
1638
|
+
xBTC: {
|
|
1639
|
+
symbol: "xBTC",
|
|
1640
|
+
name: "OKX Wrapped BTC",
|
|
1641
|
+
decimals: 8,
|
|
1642
|
+
address: "CtzPWv73Sn1dMGVU3ZtLv9yWSyUAanBni19YWDaznnkn",
|
|
1643
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1644
|
+
hubAsset: "0x4a47a698603c31e59d4c464d86dc6d54c60106df",
|
|
1645
|
+
vault: SodaTokens.sodaBTC.address
|
|
1646
|
+
},
|
|
1647
|
+
ZEC: {
|
|
1648
|
+
symbol: "ZEC",
|
|
1649
|
+
name: "OmniBridge Bridged Zcash (Solana)",
|
|
1650
|
+
decimals: 8,
|
|
1651
|
+
address: "A7bdiYdS5GjqGFtxf17ppRHtDKPkkRqbKtR27dxvQXaS",
|
|
1652
|
+
chainKey: ChainKeys.SOLANA_MAINNET,
|
|
1653
|
+
hubAsset: "0xdfce285d5bb2da89fab4212d06683a4699e90560",
|
|
1654
|
+
vault: SodaTokens.sodaZEC.address
|
|
1425
1655
|
}
|
|
1426
1656
|
};
|
|
1427
1657
|
var avalancheSupportedTokens = {
|
|
@@ -1689,6 +1919,24 @@ var arbitrumSupportedTokens = {
|
|
|
1689
1919
|
chainKey: ChainKeys.ARBITRUM_MAINNET,
|
|
1690
1920
|
hubAsset: "0x68ff591a66f6b6c77bdf6463d88e8cb5578c8a53",
|
|
1691
1921
|
vault: "0x68ff591a66f6b6c77bdf6463d88e8cb5578c8a53"
|
|
1922
|
+
},
|
|
1923
|
+
CHIP: {
|
|
1924
|
+
symbol: "CHIP",
|
|
1925
|
+
name: "USD.AI",
|
|
1926
|
+
decimals: 18,
|
|
1927
|
+
address: "0x0c1c1c109fe34733fca54b82d7b46b75cfb71f6e",
|
|
1928
|
+
chainKey: ChainKeys.ARBITRUM_MAINNET,
|
|
1929
|
+
hubAsset: "0x87a879e35027f55655a3b4540cf71e27c28e8116",
|
|
1930
|
+
vault: "0x87a879e35027f55655a3b4540cf71e27c28e8116"
|
|
1931
|
+
},
|
|
1932
|
+
RAIN: {
|
|
1933
|
+
symbol: "RAIN",
|
|
1934
|
+
name: "Rain",
|
|
1935
|
+
decimals: 18,
|
|
1936
|
+
address: "0x25118290e6a5f4139381d072181157035864099d",
|
|
1937
|
+
chainKey: ChainKeys.ARBITRUM_MAINNET,
|
|
1938
|
+
hubAsset: "0x1ec7afdbd09dcd9e7bc9ec651a0826aa6bfd3ede",
|
|
1939
|
+
vault: "0x1ec7afdbd09dcd9e7bc9ec651a0826aa6bfd3ede"
|
|
1692
1940
|
}
|
|
1693
1941
|
};
|
|
1694
1942
|
var baseSupportedTokens = {
|
|
@@ -1827,6 +2075,51 @@ var baseSupportedTokens = {
|
|
|
1827
2075
|
chainKey: ChainKeys.BASE_MAINNET,
|
|
1828
2076
|
hubAsset: "0x7e1af5084ac6f15afa97a5525b2e35a804e80b01",
|
|
1829
2077
|
vault: "0x7e1af5084ac6f15afa97a5525b2e35a804e80b01"
|
|
2078
|
+
},
|
|
2079
|
+
AAVE: {
|
|
2080
|
+
symbol: "AAVE",
|
|
2081
|
+
name: "Aave",
|
|
2082
|
+
decimals: 18,
|
|
2083
|
+
address: "0x63706e401c06ac8513145b7687a14804d17f814b",
|
|
2084
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
2085
|
+
hubAsset: "0x4e525b4b09092ef4b8e142daf13eb20e0b2191c3",
|
|
2086
|
+
vault: "0x4e525b4b09092ef4b8e142daf13eb20e0b2191c3"
|
|
2087
|
+
},
|
|
2088
|
+
JitoSOL: {
|
|
2089
|
+
symbol: "JitoSOL",
|
|
2090
|
+
name: "Jito Staked SOL",
|
|
2091
|
+
decimals: 9,
|
|
2092
|
+
address: "0x97be14dd8f994a5364573bc035d85309e7cb34de",
|
|
2093
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
2094
|
+
hubAsset: "0x16153346be11f0a3bfd586d4bd087199a94dae3c",
|
|
2095
|
+
vault: SodaTokens.sodaJITOSOL.address
|
|
2096
|
+
},
|
|
2097
|
+
SOL: {
|
|
2098
|
+
symbol: "SOL",
|
|
2099
|
+
name: "Base Bridged SOL (Base)",
|
|
2100
|
+
decimals: 9,
|
|
2101
|
+
address: "0x311935cd80b76769bf2ecc9d8ab7635b2139cf82",
|
|
2102
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
2103
|
+
hubAsset: "0x53b6274b1d0d655084dda1c0a9f2330256374b84",
|
|
2104
|
+
vault: SodaTokens.sodaSOL.address
|
|
2105
|
+
},
|
|
2106
|
+
VVV: {
|
|
2107
|
+
symbol: "VVV",
|
|
2108
|
+
name: "Venice Token",
|
|
2109
|
+
decimals: 18,
|
|
2110
|
+
address: "0xacfe6019ed1a7dc6f7b508c02d1b04ec88cc21bf",
|
|
2111
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
2112
|
+
hubAsset: "0x8451569f3b251670df4fef74721517bcbd4af00e",
|
|
2113
|
+
vault: "0x8451569f3b251670df4fef74721517bcbd4af00e"
|
|
2114
|
+
},
|
|
2115
|
+
ZEN: {
|
|
2116
|
+
symbol: "ZEN",
|
|
2117
|
+
name: "Horizen",
|
|
2118
|
+
decimals: 18,
|
|
2119
|
+
address: "0xf43eb8de897fbc7f2502483b2bef7bb9ea179229",
|
|
2120
|
+
chainKey: ChainKeys.BASE_MAINNET,
|
|
2121
|
+
hubAsset: "0x61d95d519907daa3cf505420b0d3c8607cd9f921",
|
|
2122
|
+
vault: "0x61d95d519907daa3cf505420b0d3c8607cd9f921"
|
|
1830
2123
|
}
|
|
1831
2124
|
};
|
|
1832
2125
|
var optimismSupportedTokens = {
|
|
@@ -2092,6 +2385,51 @@ var bscSupportedTokens = {
|
|
|
2092
2385
|
chainKey: ChainKeys.BSC_MAINNET,
|
|
2093
2386
|
hubAsset: "0xdab003b59749fe08fad6e0e7685f31bbcf4cbd6e",
|
|
2094
2387
|
vault: "0xdab003b59749fe08fad6e0e7685f31bbcf4cbd6e"
|
|
2388
|
+
},
|
|
2389
|
+
FF: {
|
|
2390
|
+
symbol: "FF",
|
|
2391
|
+
name: "Falcon Finance",
|
|
2392
|
+
decimals: 18,
|
|
2393
|
+
address: "0xac23b90a79504865d52b49b327328411a23d4db2",
|
|
2394
|
+
chainKey: ChainKeys.BSC_MAINNET,
|
|
2395
|
+
hubAsset: "0x2a3c409f26b0ac54889172f20441c25941b3c745",
|
|
2396
|
+
vault: "0x2a3c409f26b0ac54889172f20441c25941b3c745"
|
|
2397
|
+
},
|
|
2398
|
+
PENDLE: {
|
|
2399
|
+
symbol: "PENDLE",
|
|
2400
|
+
name: "Pendle",
|
|
2401
|
+
decimals: 18,
|
|
2402
|
+
address: "0xb3ed0a426155b79b898849803e3b36552f7ed507",
|
|
2403
|
+
chainKey: ChainKeys.BSC_MAINNET,
|
|
2404
|
+
hubAsset: "0xc059a10554d4e9a1dc4792db40ddf5137973b473",
|
|
2405
|
+
vault: "0xc059a10554d4e9a1dc4792db40ddf5137973b473"
|
|
2406
|
+
},
|
|
2407
|
+
STABLE: {
|
|
2408
|
+
symbol: "STABLE",
|
|
2409
|
+
name: "Stable",
|
|
2410
|
+
decimals: 18,
|
|
2411
|
+
address: "0x011ebe7d75e2c9d1e0bd0be0bef5c36f0a90075f",
|
|
2412
|
+
chainKey: ChainKeys.BSC_MAINNET,
|
|
2413
|
+
hubAsset: "0x4b7f7a7fcb3b45d41ab6c6727b0c1aeedc62aea7",
|
|
2414
|
+
vault: "0x4b7f7a7fcb3b45d41ab6c6727b0c1aeedc62aea7"
|
|
2415
|
+
},
|
|
2416
|
+
TUSD: {
|
|
2417
|
+
symbol: "TUSD",
|
|
2418
|
+
name: "TrueUSD",
|
|
2419
|
+
decimals: 18,
|
|
2420
|
+
address: "0x40af3827f39d0eacbf4a168f8d4ee67c121d11c9",
|
|
2421
|
+
chainKey: ChainKeys.BSC_MAINNET,
|
|
2422
|
+
hubAsset: "0x0ab0d545288137382d388ec679641de9f231f7fa",
|
|
2423
|
+
vault: "0x0ab0d545288137382d388ec679641de9f231f7fa"
|
|
2424
|
+
},
|
|
2425
|
+
U: {
|
|
2426
|
+
symbol: "U",
|
|
2427
|
+
name: "United Stables",
|
|
2428
|
+
decimals: 18,
|
|
2429
|
+
address: "0xce24439f2d9c6a2289f741120fe202248b666666",
|
|
2430
|
+
chainKey: ChainKeys.BSC_MAINNET,
|
|
2431
|
+
hubAsset: "0xd0c38d58d592ef223c5331673a189795e0f5510c",
|
|
2432
|
+
vault: "0xd0c38d58d592ef223c5331673a189795e0f5510c"
|
|
2095
2433
|
}
|
|
2096
2434
|
};
|
|
2097
2435
|
var polygonSupportedTokens = {
|
|
@@ -3075,6 +3413,15 @@ var suiSupportedTokens = {
|
|
|
3075
3413
|
chainKey: ChainKeys.SUI_MAINNET,
|
|
3076
3414
|
hubAsset: "0x2037d840f01e903e09e33b146f2dd3fa4a4d2c21",
|
|
3077
3415
|
vault: "0x2037d840f01e903e09e33b146f2dd3fa4a4d2c21"
|
|
3416
|
+
},
|
|
3417
|
+
USDY: {
|
|
3418
|
+
symbol: "USDY",
|
|
3419
|
+
name: "Ondo US Dollar Yield",
|
|
3420
|
+
decimals: 6,
|
|
3421
|
+
address: "0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY",
|
|
3422
|
+
chainKey: ChainKeys.SUI_MAINNET,
|
|
3423
|
+
hubAsset: "0x04dc969dc822f1b45d354b8fc296b23f5b924176",
|
|
3424
|
+
vault: "0x04dc969dc822f1b45d354b8fc296b23f5b924176"
|
|
3078
3425
|
}
|
|
3079
3426
|
};
|
|
3080
3427
|
var iconSupportedTokens = {
|
|
@@ -3473,6 +3820,123 @@ var ethereumSupportedTokens = {
|
|
|
3473
3820
|
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3474
3821
|
hubAsset: "0x081e274ec570bdb023f1b41c54df0f3f73da8924",
|
|
3475
3822
|
vault: "0x081e274ec570bdb023f1b41c54df0f3f73da8924"
|
|
3823
|
+
},
|
|
3824
|
+
AUSD: {
|
|
3825
|
+
symbol: "AUSD",
|
|
3826
|
+
name: "AUSD",
|
|
3827
|
+
decimals: 6,
|
|
3828
|
+
address: "0x00000000efe302beaa2b3e6e1b18d08d69a9012a",
|
|
3829
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3830
|
+
hubAsset: "0xa5c8482ba138872dc844dd4b15aaa21490d064ec",
|
|
3831
|
+
vault: "0xa5c8482ba138872dc844dd4b15aaa21490d064ec"
|
|
3832
|
+
},
|
|
3833
|
+
cirBTC: {
|
|
3834
|
+
symbol: "cirBTC",
|
|
3835
|
+
name: "Circle Wrapped BTC",
|
|
3836
|
+
decimals: 8,
|
|
3837
|
+
address: "0x72dfb2e44f59c5ad2bafe84314e5b99a7cd5075e",
|
|
3838
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3839
|
+
hubAsset: "0x1316179f1c6b6f2658f96bfe0bab59d0b03c7fd3",
|
|
3840
|
+
vault: SodaTokens.sodaBTC.address
|
|
3841
|
+
},
|
|
3842
|
+
CRV: {
|
|
3843
|
+
symbol: "CRV",
|
|
3844
|
+
name: "Curve DAO",
|
|
3845
|
+
decimals: 18,
|
|
3846
|
+
address: "0xd533a949740bb3306d119cc777fa900ba034cd52",
|
|
3847
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3848
|
+
hubAsset: "0x0f39fe572ff21675ba88dab6a60f824eae12a897",
|
|
3849
|
+
vault: "0x0f39fe572ff21675ba88dab6a60f824eae12a897"
|
|
3850
|
+
},
|
|
3851
|
+
EURC: {
|
|
3852
|
+
symbol: "EURC",
|
|
3853
|
+
name: "EURC",
|
|
3854
|
+
decimals: 6,
|
|
3855
|
+
address: "0x1abaea1f7c830bd89acc67ec4af516284b1bc33c",
|
|
3856
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3857
|
+
hubAsset: "0x0e5bf34dfd21c45934c342c3bc6bc76bf467b365",
|
|
3858
|
+
vault: "0x0e5bf34dfd21c45934c342c3bc6bc76bf467b365"
|
|
3859
|
+
},
|
|
3860
|
+
ICP: {
|
|
3861
|
+
symbol: "ICP",
|
|
3862
|
+
name: "Internet Computer",
|
|
3863
|
+
decimals: 8,
|
|
3864
|
+
address: "0x00f3c42833c3170159af4e92dbb451fb3f708917",
|
|
3865
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3866
|
+
hubAsset: "0x33ffb6bbe55f7e1081efe5ce95c2767937154b52",
|
|
3867
|
+
vault: "0x33ffb6bbe55f7e1081efe5ce95c2767937154b52"
|
|
3868
|
+
},
|
|
3869
|
+
kBTC: {
|
|
3870
|
+
symbol: "kBTC",
|
|
3871
|
+
name: "Kraken Wrapped BTC",
|
|
3872
|
+
decimals: 8,
|
|
3873
|
+
address: "0x73e0c0d45e048d25fc26fa3159b0aa04bfa4db98",
|
|
3874
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3875
|
+
hubAsset: "0xa42f8bae7a463f492ca81df8ab319a1177df586c",
|
|
3876
|
+
vault: SodaTokens.sodaBTC.address
|
|
3877
|
+
},
|
|
3878
|
+
NEAR: {
|
|
3879
|
+
symbol: "NEAR",
|
|
3880
|
+
name: "Rainbow Bridged Near (Ethereum)",
|
|
3881
|
+
decimals: 24,
|
|
3882
|
+
address: "0x85f17cf997934a597031b2e18a9ab6ebd4b9f6a4",
|
|
3883
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3884
|
+
hubAsset: "0x9295415078420d6d736aafa303430e24e89b0740",
|
|
3885
|
+
vault: SodaTokens.sodaNEAR.address
|
|
3886
|
+
},
|
|
3887
|
+
ONDO: {
|
|
3888
|
+
symbol: "ONDO",
|
|
3889
|
+
name: "Ondo",
|
|
3890
|
+
decimals: 18,
|
|
3891
|
+
address: "0xfaba6f8e4a5e8ab82f62fe7c39859fa577269be3",
|
|
3892
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3893
|
+
hubAsset: "0xe1fc12564dfb98c5aca98354ae4810d608600fa4",
|
|
3894
|
+
vault: "0xe1fc12564dfb98c5aca98354ae4810d608600fa4"
|
|
3895
|
+
},
|
|
3896
|
+
QNT: {
|
|
3897
|
+
symbol: "QNT",
|
|
3898
|
+
name: "Quant",
|
|
3899
|
+
decimals: 18,
|
|
3900
|
+
address: "0x4a220e6096b25eadb88358cb44068a3248254675",
|
|
3901
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3902
|
+
hubAsset: "0x65094257d27a71ffe4d7e9fef63c5243c885a7d1",
|
|
3903
|
+
vault: "0x65094257d27a71ffe4d7e9fef63c5243c885a7d1"
|
|
3904
|
+
},
|
|
3905
|
+
SOL: {
|
|
3906
|
+
symbol: "SOL",
|
|
3907
|
+
name: "Wormhole Bridged WSOL",
|
|
3908
|
+
decimals: 9,
|
|
3909
|
+
address: "0xd31a59c85ae9d8edefec411d448f90841571b89c",
|
|
3910
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3911
|
+
hubAsset: "0x3bb9c57dc70f33aa67fc33d7f88b9a2c5b1b392f",
|
|
3912
|
+
vault: SodaTokens.sodaSOL.address
|
|
3913
|
+
},
|
|
3914
|
+
tBTC: {
|
|
3915
|
+
symbol: "tBTC",
|
|
3916
|
+
name: "tBTC",
|
|
3917
|
+
decimals: 18,
|
|
3918
|
+
address: "0x18084fba666a33d37592fa2633fd49a74dd93a88",
|
|
3919
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3920
|
+
hubAsset: "0x79ce2f30c941308286f09ef5d815a14ad5830be3",
|
|
3921
|
+
vault: SodaTokens.sodaBTC.address
|
|
3922
|
+
},
|
|
3923
|
+
wM: {
|
|
3924
|
+
symbol: "wM",
|
|
3925
|
+
name: "WrappedM by M0",
|
|
3926
|
+
decimals: 6,
|
|
3927
|
+
address: "0x437cc33344a0b27a429f795ff6b469c72698b291",
|
|
3928
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3929
|
+
hubAsset: "0x512188ae67298355088c659c29bb2f78650c066a",
|
|
3930
|
+
vault: "0x512188ae67298355088c659c29bb2f78650c066a"
|
|
3931
|
+
},
|
|
3932
|
+
wTAO: {
|
|
3933
|
+
symbol: "wTAO",
|
|
3934
|
+
name: "Wrapped TAO",
|
|
3935
|
+
decimals: 9,
|
|
3936
|
+
address: "0x77e06c9eccf2e797fd462a92b6d7642ef85b0a44",
|
|
3937
|
+
chainKey: ChainKeys.ETHEREUM_MAINNET,
|
|
3938
|
+
hubAsset: "0xf0db27b881f28794b3a18bee0be18570ca60b966",
|
|
3939
|
+
vault: "0xf0db27b881f28794b3a18bee0be18570ca60b966"
|
|
3476
3940
|
}
|
|
3477
3941
|
};
|
|
3478
3942
|
var kaiaSupportedTokens = {
|
|
@@ -4189,6 +4653,33 @@ var robinhoodSupportedTokens = {
|
|
|
4189
4653
|
chainKey: ChainKeys.ROBINHOOD_MAINNET,
|
|
4190
4654
|
hubAsset: "0x9cf6640c73dd4c278cfa08a8b8773e7b22420582",
|
|
4191
4655
|
vault: "0x9cf6640c73dd4c278cfa08a8b8773e7b22420582"
|
|
4656
|
+
},
|
|
4657
|
+
AI: {
|
|
4658
|
+
symbol: "AI",
|
|
4659
|
+
name: "Artificial Inu",
|
|
4660
|
+
decimals: 18,
|
|
4661
|
+
address: "0x2e8c31162b855a2ffa90f6f8634643ad6f111e18",
|
|
4662
|
+
chainKey: ChainKeys.ROBINHOOD_MAINNET,
|
|
4663
|
+
hubAsset: "0x1c56aaf3fc5a4517132d8bdc636a798f31ccf4b0",
|
|
4664
|
+
vault: "0x1c56aaf3fc5a4517132d8bdc636a798f31ccf4b0"
|
|
4665
|
+
},
|
|
4666
|
+
CASHCAT: {
|
|
4667
|
+
symbol: "CASHCAT",
|
|
4668
|
+
name: "Cash Cat",
|
|
4669
|
+
decimals: 18,
|
|
4670
|
+
address: "0x020bfc650a365f8bb26819deaabf3e21291018b4",
|
|
4671
|
+
chainKey: ChainKeys.ROBINHOOD_MAINNET,
|
|
4672
|
+
hubAsset: "0x79150886ae702f6de9d36eb8748fcb9fcb483c2b",
|
|
4673
|
+
vault: "0x79150886ae702f6de9d36eb8748fcb9fcb483c2b"
|
|
4674
|
+
},
|
|
4675
|
+
TAO: {
|
|
4676
|
+
symbol: "TAO",
|
|
4677
|
+
name: "ForeverMoney Wrapped TAO",
|
|
4678
|
+
decimals: 18,
|
|
4679
|
+
address: "0xf3081494b87e8d5fb7960f066e931d1d0e6e3d67",
|
|
4680
|
+
chainKey: ChainKeys.ROBINHOOD_MAINNET,
|
|
4681
|
+
hubAsset: "0x4318e2fb5192256106e624565a64b6bb1c41e807",
|
|
4682
|
+
vault: "0x4318e2fb5192256106e624565a64b6bb1c41e807"
|
|
4192
4683
|
}
|
|
4193
4684
|
};
|
|
4194
4685
|
var stacksSupportedTokens = {
|
|
@@ -4300,7 +4791,7 @@ var RelayChainIdMap = {
|
|
|
4300
4791
|
};
|
|
4301
4792
|
var INTENT_CHAIN_IDS = Object.values(RelayChainIdMap);
|
|
4302
4793
|
var IntentRelayChainIdToChainKey = new Map(Object.entries(RelayChainIdMap).map(([chainKey, chainId]) => [chainId, chainKey]));
|
|
4303
|
-
var CHAIN_LOGO_BASE_URL = "https://raw.githubusercontent.com/
|
|
4794
|
+
var CHAIN_LOGO_BASE_URL = "https://raw.githubusercontent.com/gosodax/sodax-sdks/main/packages/assets/chain";
|
|
4304
4795
|
var chainLogo = (key) => `${CHAIN_LOGO_BASE_URL}/${key}.png`;
|
|
4305
4796
|
var baseChainInfo = {
|
|
4306
4797
|
[ChainKeys.SONIC_MAINNET]: {
|
|
@@ -6173,41 +6664,98 @@ var swapSupportedTokens = {
|
|
|
6173
6664
|
]
|
|
6174
6665
|
};
|
|
6175
6666
|
var stagingSwapSupportedTokens = {
|
|
6176
|
-
[ChainKeys.SONIC_MAINNET]: [],
|
|
6667
|
+
[ChainKeys.SONIC_MAINNET]: [SodaTokens.sodaADA],
|
|
6177
6668
|
[ChainKeys.AVALANCHE_MAINNET]: [],
|
|
6178
|
-
[ChainKeys.ARBITRUM_MAINNET]: [
|
|
6669
|
+
[ChainKeys.ARBITRUM_MAINNET]: [
|
|
6670
|
+
spokeChainConfig[ChainKeys.ARBITRUM_MAINNET].supportedTokens.CHIP,
|
|
6671
|
+
spokeChainConfig[ChainKeys.ARBITRUM_MAINNET].supportedTokens.RAIN
|
|
6672
|
+
],
|
|
6179
6673
|
[ChainKeys.BASE_MAINNET]: [
|
|
6180
6674
|
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.bnUSD,
|
|
6181
|
-
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.AERO
|
|
6675
|
+
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.AERO,
|
|
6676
|
+
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.AAVE,
|
|
6677
|
+
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.JitoSOL,
|
|
6678
|
+
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.SOL,
|
|
6679
|
+
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.VVV,
|
|
6680
|
+
spokeChainConfig[ChainKeys.BASE_MAINNET].supportedTokens.ZEN
|
|
6182
6681
|
],
|
|
6183
6682
|
[ChainKeys.OPTIMISM_MAINNET]: [],
|
|
6184
6683
|
[ChainKeys.POLYGON_MAINNET]: [
|
|
6185
6684
|
spokeChainConfig[ChainKeys.POLYGON_MAINNET].supportedTokens.USDT,
|
|
6186
6685
|
spokeChainConfig[ChainKeys.POLYGON_MAINNET].supportedTokens.wstETH
|
|
6187
6686
|
],
|
|
6188
|
-
[ChainKeys.BSC_MAINNET]: [
|
|
6687
|
+
[ChainKeys.BSC_MAINNET]: [
|
|
6688
|
+
spokeChainConfig[ChainKeys.BSC_MAINNET].supportedTokens.FF,
|
|
6689
|
+
spokeChainConfig[ChainKeys.BSC_MAINNET].supportedTokens.PENDLE,
|
|
6690
|
+
spokeChainConfig[ChainKeys.BSC_MAINNET].supportedTokens.STABLE,
|
|
6691
|
+
spokeChainConfig[ChainKeys.BSC_MAINNET].supportedTokens.TUSD,
|
|
6692
|
+
spokeChainConfig[ChainKeys.BSC_MAINNET].supportedTokens.U
|
|
6693
|
+
],
|
|
6189
6694
|
[ChainKeys.HYPEREVM_MAINNET]: [],
|
|
6190
6695
|
[ChainKeys.LIGHTLINK_MAINNET]: [
|
|
6191
6696
|
spokeChainConfig[ChainKeys.LIGHTLINK_MAINNET].supportedTokens["HYPE.LL"]
|
|
6192
6697
|
],
|
|
6193
|
-
[ChainKeys.SOLANA_MAINNET]: [
|
|
6698
|
+
[ChainKeys.SOLANA_MAINNET]: [
|
|
6699
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens["2Z"],
|
|
6700
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.ANSEM,
|
|
6701
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.BP,
|
|
6702
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.CARDS,
|
|
6703
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.CASH,
|
|
6704
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.Fartcoin,
|
|
6705
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.GLDx,
|
|
6706
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.HOODx,
|
|
6707
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.HYPE,
|
|
6708
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.hyUSD,
|
|
6709
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.KMNO,
|
|
6710
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.LBTC,
|
|
6711
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.MET,
|
|
6712
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.ONYC,
|
|
6713
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.PENGU,
|
|
6714
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.PRIME,
|
|
6715
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.SPCXx,
|
|
6716
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.STONK,
|
|
6717
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.syrupUSDC,
|
|
6718
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.TRUMP,
|
|
6719
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.USX,
|
|
6720
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.xBTC,
|
|
6721
|
+
spokeChainConfig[ChainKeys.SOLANA_MAINNET].supportedTokens.ZEC
|
|
6722
|
+
],
|
|
6194
6723
|
[ChainKeys.ICON_MAINNET]: [],
|
|
6195
6724
|
[ChainKeys.STELLAR_MAINNET]: [],
|
|
6196
|
-
[ChainKeys.SUI_MAINNET]: [
|
|
6725
|
+
[ChainKeys.SUI_MAINNET]: [
|
|
6726
|
+
spokeChainConfig[ChainKeys.SUI_MAINNET].supportedTokens.USDT,
|
|
6727
|
+
spokeChainConfig[ChainKeys.SUI_MAINNET].supportedTokens.USDY
|
|
6728
|
+
],
|
|
6197
6729
|
[ChainKeys.INJECTIVE_MAINNET]: [],
|
|
6198
6730
|
[ChainKeys.NEAR_MAINNET]: [],
|
|
6199
6731
|
[ChainKeys.BITCOIN_MAINNET]: [],
|
|
6200
6732
|
[ChainKeys.ETHEREUM_MAINNET]: [
|
|
6201
6733
|
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.wstETH,
|
|
6202
|
-
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.weETH
|
|
6734
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.weETH,
|
|
6735
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.AUSD,
|
|
6736
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.cirBTC,
|
|
6737
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.CRV,
|
|
6738
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.EURC,
|
|
6739
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.ICP,
|
|
6740
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.kBTC,
|
|
6741
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.NEAR,
|
|
6742
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.ONDO,
|
|
6743
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.QNT,
|
|
6744
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.SOL,
|
|
6745
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.tBTC,
|
|
6746
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.wM,
|
|
6747
|
+
spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.wTAO
|
|
6203
6748
|
],
|
|
6204
6749
|
[ChainKeys.REDBELLY_MAINNET]: [],
|
|
6205
6750
|
[ChainKeys.KAIA_MAINNET]: [],
|
|
6206
6751
|
[ChainKeys.STACKS_MAINNET]: [],
|
|
6207
6752
|
// Hedera promoted to production — see swapSupportedTokens
|
|
6208
6753
|
[ChainKeys.HEDERA_MAINNET]: [],
|
|
6209
|
-
|
|
6210
|
-
|
|
6754
|
+
[ChainKeys.ROBINHOOD_MAINNET]: [
|
|
6755
|
+
spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.AI,
|
|
6756
|
+
spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.CASHCAT,
|
|
6757
|
+
spokeChainConfig[ChainKeys.ROBINHOOD_MAINNET].supportedTokens.TAO
|
|
6758
|
+
]
|
|
6211
6759
|
};
|
|
6212
6760
|
var swapsConfig = {
|
|
6213
6761
|
supportedTokens: swapSupportedTokens
|
|
@@ -6514,7 +7062,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
6514
7062
|
}
|
|
6515
7063
|
|
|
6516
7064
|
// ../types/dist/index.js
|
|
6517
|
-
var CONFIG_VERSION =
|
|
7065
|
+
var CONFIG_VERSION = 2030001;
|
|
6518
7066
|
var RC_STABLE = 99;
|
|
6519
7067
|
var MIN_CONFIG_VERSION = 1e6;
|
|
6520
7068
|
var MAX_CONFIG_VERSION = 99999999;
|
|
@@ -6767,12 +7315,12 @@ function canonicalizeBitcoinAddress(address) {
|
|
|
6767
7315
|
}
|
|
6768
7316
|
}
|
|
6769
7317
|
function normalizePsbtToBase64(signedPsbt) {
|
|
6770
|
-
const
|
|
6771
|
-
return
|
|
7318
|
+
const isHex4 = /^[0-9a-fA-F]+$/.test(signedPsbt);
|
|
7319
|
+
return isHex4 ? Buffer.from(signedPsbt, "hex").toString("base64") : signedPsbt;
|
|
6772
7320
|
}
|
|
6773
7321
|
function normalizeSignatureToBase64(signature) {
|
|
6774
|
-
const
|
|
6775
|
-
return
|
|
7322
|
+
const isHex4 = /^[0-9a-fA-F]+$/.test(signature);
|
|
7323
|
+
return isHex4 ? Buffer.from(signature, "hex").toString("base64") : signature;
|
|
6776
7324
|
}
|
|
6777
7325
|
function isNativeBitcoinTransfer(config, chainKey, token) {
|
|
6778
7326
|
return isBitcoinChainKeyType(chainKey) && !!token && isNativeBitcoinToken(config.getChainConfig(chainKey), token.address);
|
|
@@ -7177,7 +7725,8 @@ function mapRelayFailure(error, ctx) {
|
|
|
7177
7725
|
const baseCtx = {
|
|
7178
7726
|
action: ctx.action,
|
|
7179
7727
|
srcChainKey: ctx.srcChainKey,
|
|
7180
|
-
dstChainKey: ctx.dstChainKey
|
|
7728
|
+
dstChainKey: ctx.dstChainKey,
|
|
7729
|
+
...ctx.srcTxHash !== void 0 && { srcTxHash: ctx.srcTxHash }
|
|
7181
7730
|
};
|
|
7182
7731
|
if (message === RELAY_ERROR_CODES.RELAY_TIMEOUT) {
|
|
7183
7732
|
return new SodaxError("RELAY_TIMEOUT", "Relay packet did not arrive within timeout", {
|
|
@@ -7262,9 +7811,11 @@ function isWalletRejection(error) {
|
|
|
7262
7811
|
if (typeof error !== "object") return false;
|
|
7263
7812
|
const o = error;
|
|
7264
7813
|
if (o.name === "UserRejectedRequestError") return true;
|
|
7814
|
+
if (o.name === "AtomicReadyWalletRejectedUpgradeError") return true;
|
|
7265
7815
|
if (o.name === "WalletSignTransactionError" && matchRejectionText(o.message)) return true;
|
|
7266
7816
|
if (o.name === "WalletConnectionError" && matchRejectionText(o.message)) return true;
|
|
7267
7817
|
if (o.code === 4001) return true;
|
|
7818
|
+
if (o.code === 5750) return true;
|
|
7268
7819
|
if (o.code === "ACTION_REJECTED") return true;
|
|
7269
7820
|
if (o.code === "CANCEL_SIGNING") return true;
|
|
7270
7821
|
if (o.code === "CANCEL_JSON-RPC") return true;
|
|
@@ -7326,6 +7877,13 @@ function allowanceCheckFailed(feature, cause, context) {
|
|
|
7326
7877
|
context: { phase: "allowanceCheck", ...context }
|
|
7327
7878
|
});
|
|
7328
7879
|
}
|
|
7880
|
+
function withErrorContext(error, context) {
|
|
7881
|
+
return new SodaxError(error.code, error.message, {
|
|
7882
|
+
feature: error.feature,
|
|
7883
|
+
cause: error.cause,
|
|
7884
|
+
context: { ...error.context, ...context }
|
|
7885
|
+
});
|
|
7886
|
+
}
|
|
7329
7887
|
function gasEstimationFailed(feature, cause, context) {
|
|
7330
7888
|
return new SodaxError("GAS_ESTIMATION_FAILED", messageOf(cause, "Gas estimation failed"), {
|
|
7331
7889
|
feature,
|
|
@@ -16646,7 +17204,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
16646
17204
|
}
|
|
16647
17205
|
function encodeContractCalls(calls) {
|
|
16648
17206
|
return viem.encodeAbiParameters(viem.parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
16649
|
-
calls.map((
|
|
17207
|
+
calls.map((v11) => [v11.address, v11.value, v11.data])
|
|
16650
17208
|
]);
|
|
16651
17209
|
}
|
|
16652
17210
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -16759,6 +17317,172 @@ function getEvmViemChain(key) {
|
|
|
16759
17317
|
}
|
|
16760
17318
|
}
|
|
16761
17319
|
}
|
|
17320
|
+
|
|
17321
|
+
// src/shared/utils/evmAtomicBatch.ts
|
|
17322
|
+
function canSendAtomicBatch(walletProvider) {
|
|
17323
|
+
return typeof walletProvider.getAtomicBatchSupport === "function" && typeof walletProvider.sendAtomicBatch === "function" && typeof walletProvider.waitForBatch === "function";
|
|
17324
|
+
}
|
|
17325
|
+
async function readAtomicBatchSupport(walletProvider, chainId) {
|
|
17326
|
+
try {
|
|
17327
|
+
return await walletProvider.getAtomicBatchSupport(chainId);
|
|
17328
|
+
} catch {
|
|
17329
|
+
return "unsupported";
|
|
17330
|
+
}
|
|
17331
|
+
}
|
|
17332
|
+
var BATCH_REFUSED_CODES = /* @__PURE__ */ new Set([4200, -32601, 5700, 5710, 5740, 5760]);
|
|
17333
|
+
var MAX_CAUSE_DEPTH2 = 5;
|
|
17334
|
+
var UPGRADE_DECLINED_CODE = 5750;
|
|
17335
|
+
function isAtomicBatchRefused(error) {
|
|
17336
|
+
return hasErrorCode(error, (code) => BATCH_REFUSED_CODES.has(code));
|
|
17337
|
+
}
|
|
17338
|
+
function isAccountUpgradeDeclined(error) {
|
|
17339
|
+
return hasErrorCode(error, (code) => code === UPGRADE_DECLINED_CODE);
|
|
17340
|
+
}
|
|
17341
|
+
function hasErrorCode(error, matches) {
|
|
17342
|
+
let current = error;
|
|
17343
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH2 && typeof current === "object" && current !== null; depth++) {
|
|
17344
|
+
const code = "code" in current ? current.code : void 0;
|
|
17345
|
+
if (typeof code === "number" && matches(code)) return true;
|
|
17346
|
+
current = "cause" in current ? current.cause : void 0;
|
|
17347
|
+
}
|
|
17348
|
+
return false;
|
|
17349
|
+
}
|
|
17350
|
+
|
|
17351
|
+
// src/shared/utils/approvalBatch.ts
|
|
17352
|
+
function approvalBatchWaitMs(timeout) {
|
|
17353
|
+
return Math.max(resolveTimeoutMs(timeout, DEFAULT_RELAY_TX_TIMEOUT), DEFAULT_RELAY_TX_TIMEOUT);
|
|
17354
|
+
}
|
|
17355
|
+
var ATOMIC_BATCH_REFUSED = "atomic-batch-refused";
|
|
17356
|
+
var ATOMIC_BATCH_UNCONFIRMED = "atomic-batch-unconfirmed";
|
|
17357
|
+
var ACCOUNT_UPGRADE_DECLINED = "account-upgrade-declined";
|
|
17358
|
+
var BATCH_NOTHING_LANDED_CODES = /* @__PURE__ */ new Set([400, 500]);
|
|
17359
|
+
async function resolveApprovalStrategy({
|
|
17360
|
+
srcChainKey,
|
|
17361
|
+
walletProvider,
|
|
17362
|
+
allowAccountUpgrade = true
|
|
17363
|
+
}) {
|
|
17364
|
+
if (isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider) && canSendAtomicBatch(walletProvider)) {
|
|
17365
|
+
const support = await readAtomicBatchSupport(walletProvider, getEvmViemChain(srcChainKey).id);
|
|
17366
|
+
if (support === "supported" || support === "ready" && allowAccountUpgrade) return "atomic-batch";
|
|
17367
|
+
}
|
|
17368
|
+
return "sequential";
|
|
17369
|
+
}
|
|
17370
|
+
async function sendApprovalBatch({
|
|
17371
|
+
walletProvider,
|
|
17372
|
+
srcChainKey,
|
|
17373
|
+
txs,
|
|
17374
|
+
timeoutMs,
|
|
17375
|
+
feature,
|
|
17376
|
+
context,
|
|
17377
|
+
onBatchSent
|
|
17378
|
+
}) {
|
|
17379
|
+
if (!canSendAtomicBatch(walletProvider)) {
|
|
17380
|
+
return {
|
|
17381
|
+
ok: false,
|
|
17382
|
+
error: new SodaxError("INTENT_CREATION_FAILED", "Wallet provider does not implement EIP-5792 batches", {
|
|
17383
|
+
feature,
|
|
17384
|
+
context: { ...context, phase: "intentCreation", reason: ATOMIC_BATCH_REFUSED }
|
|
17385
|
+
})
|
|
17386
|
+
};
|
|
17387
|
+
}
|
|
17388
|
+
let batchId;
|
|
17389
|
+
try {
|
|
17390
|
+
batchId = await walletProvider.sendAtomicBatch(txs, { expectedChainId: getEvmViemChain(srcChainKey).id });
|
|
17391
|
+
} catch (error) {
|
|
17392
|
+
const reason = isAtomicBatchRefused(error) ? ATOMIC_BATCH_REFUSED : isAccountUpgradeDeclined(error) ? ACCOUNT_UPGRADE_DECLINED : void 0;
|
|
17393
|
+
return { ok: false, error: intentCreationFailed(feature, error, { ...context, ...reason && { reason } }) };
|
|
17394
|
+
}
|
|
17395
|
+
try {
|
|
17396
|
+
onBatchSent?.(batchId);
|
|
17397
|
+
} catch {
|
|
17398
|
+
}
|
|
17399
|
+
return confirmApprovalBatch({ walletProvider, batchId, callCount: txs.length, timeoutMs, feature, context });
|
|
17400
|
+
}
|
|
17401
|
+
async function confirmApprovalBatch({
|
|
17402
|
+
walletProvider,
|
|
17403
|
+
batchId,
|
|
17404
|
+
callCount,
|
|
17405
|
+
timeoutMs,
|
|
17406
|
+
feature,
|
|
17407
|
+
context
|
|
17408
|
+
}) {
|
|
17409
|
+
const unconfirmed = (cause) => ({
|
|
17410
|
+
ok: false,
|
|
17411
|
+
error: new SodaxError("TX_VERIFICATION_FAILED", "Atomic approval batch was sent but not confirmed", {
|
|
17412
|
+
feature,
|
|
17413
|
+
cause,
|
|
17414
|
+
context: {
|
|
17415
|
+
...context,
|
|
17416
|
+
phase: "verify",
|
|
17417
|
+
reason: ATOMIC_BATCH_UNCONFIRMED,
|
|
17418
|
+
batchId,
|
|
17419
|
+
...callCount !== void 0 && { callCount }
|
|
17420
|
+
}
|
|
17421
|
+
})
|
|
17422
|
+
});
|
|
17423
|
+
if (!canSendAtomicBatch(walletProvider)) return unconfirmed();
|
|
17424
|
+
try {
|
|
17425
|
+
const batch = await walletProvider.waitForBatch(batchId, { timeout: Math.max(1, timeoutMs) });
|
|
17426
|
+
if (batch.status !== "success" && !BATCH_NOTHING_LANDED_CODES.has(batch.statusCode)) return unconfirmed();
|
|
17427
|
+
if (batch.status !== "success") {
|
|
17428
|
+
return {
|
|
17429
|
+
ok: false,
|
|
17430
|
+
error: new SodaxError("INTENT_CREATION_FAILED", "Atomic approval batch did not succeed", {
|
|
17431
|
+
feature,
|
|
17432
|
+
context: {
|
|
17433
|
+
...context,
|
|
17434
|
+
phase: "intentCreation",
|
|
17435
|
+
reason: "atomic-batch-failed",
|
|
17436
|
+
batchId,
|
|
17437
|
+
statusCode: batch.statusCode
|
|
17438
|
+
}
|
|
17439
|
+
})
|
|
17440
|
+
};
|
|
17441
|
+
}
|
|
17442
|
+
const { receipts } = batch;
|
|
17443
|
+
const oneTx = new Set(receipts.map((receipt) => receipt.transactionHash)).size === 1;
|
|
17444
|
+
const depositReceipt = oneTx || receipts.length === callCount ? receipts.at(-1) : void 0;
|
|
17445
|
+
if (depositReceipt?.status !== "success") return unconfirmed();
|
|
17446
|
+
return { ok: true, value: { txHash: depositReceipt.transactionHash, batchId } };
|
|
17447
|
+
} catch (error) {
|
|
17448
|
+
return unconfirmed(error);
|
|
17449
|
+
}
|
|
17450
|
+
}
|
|
17451
|
+
async function confirmApproval({
|
|
17452
|
+
waitForTxReceipt,
|
|
17453
|
+
txHash,
|
|
17454
|
+
chainKey,
|
|
17455
|
+
feature,
|
|
17456
|
+
context
|
|
17457
|
+
}) {
|
|
17458
|
+
const receipt = await waitForTxReceipt({ txHash, chainKey });
|
|
17459
|
+
if (receipt.ok && receipt.value.status === "success") return { ok: true, value: void 0 };
|
|
17460
|
+
return {
|
|
17461
|
+
ok: false,
|
|
17462
|
+
error: new SodaxError("APPROVE_FAILED", `Approval transaction ${txHash} did not confirm`, {
|
|
17463
|
+
feature,
|
|
17464
|
+
cause: receipt.ok ? receipt.value : receipt.error,
|
|
17465
|
+
context: { ...context, phase: "approve", reason: "approve-not-confirmed", approveTxHash: txHash }
|
|
17466
|
+
})
|
|
17467
|
+
};
|
|
17468
|
+
}
|
|
17469
|
+
function isAtomicBatchRefusal(error) {
|
|
17470
|
+
return isSodaxError(error) && error.code === "INTENT_CREATION_FAILED" && error.context?.reason === ATOMIC_BATCH_REFUSED;
|
|
17471
|
+
}
|
|
17472
|
+
async function runWithApproval({
|
|
17473
|
+
strategy,
|
|
17474
|
+
notRequired,
|
|
17475
|
+
atomicBatch,
|
|
17476
|
+
sequential,
|
|
17477
|
+
onBatchRefused
|
|
17478
|
+
}) {
|
|
17479
|
+
if (strategy === "not-required") return { result: await notRequired(), approvalStrategy: strategy };
|
|
17480
|
+
if (strategy === "sequential") return { result: await sequential(false), approvalStrategy: strategy };
|
|
17481
|
+
const batched = await atomicBatch();
|
|
17482
|
+
if (batched.ok || !isAtomicBatchRefusal(batched.error)) return { result: batched, approvalStrategy: "atomic-batch" };
|
|
17483
|
+
onBatchRefused?.(batched.error);
|
|
17484
|
+
return { result: await sequential(true), approvalStrategy: "sequential" };
|
|
17485
|
+
}
|
|
16762
17486
|
var EvmVaultTokenService = class {
|
|
16763
17487
|
constructor() {
|
|
16764
17488
|
}
|
|
@@ -17744,7 +18468,11 @@ var StacksSpokeService = class {
|
|
|
17744
18468
|
async getWalletBalances(params) {
|
|
17745
18469
|
const { srcChainKey, srcAddress, tokens } = params;
|
|
17746
18470
|
const collector = createBalanceCollector({ logger: this.config.logger, chainKey: srcChainKey });
|
|
17747
|
-
await settleWalletBalances(
|
|
18471
|
+
await settleWalletBalances(
|
|
18472
|
+
collector,
|
|
18473
|
+
tokens,
|
|
18474
|
+
(token) => this.getWalletBalance({ srcChainKey, srcAddress, token })
|
|
18475
|
+
);
|
|
17748
18476
|
return collector.finish();
|
|
17749
18477
|
}
|
|
17750
18478
|
/**
|
|
@@ -19549,22 +20277,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
19549
20277
|
const byte0 = Uint8Array.of(0);
|
|
19550
20278
|
const byte1 = Uint8Array.of(1);
|
|
19551
20279
|
const _maxDrbgIters = 1e3;
|
|
19552
|
-
let
|
|
20280
|
+
let v11 = u8n(hashLen);
|
|
19553
20281
|
let k = u8n(hashLen);
|
|
19554
20282
|
let i = 0;
|
|
19555
20283
|
const reset = () => {
|
|
19556
|
-
|
|
20284
|
+
v11.fill(1);
|
|
19557
20285
|
k.fill(0);
|
|
19558
20286
|
i = 0;
|
|
19559
20287
|
};
|
|
19560
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
20288
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v11, ...msgs));
|
|
19561
20289
|
const reseed = (seed = NULL) => {
|
|
19562
20290
|
k = h(byte0, seed);
|
|
19563
|
-
|
|
20291
|
+
v11 = h();
|
|
19564
20292
|
if (seed.length === 0)
|
|
19565
20293
|
return;
|
|
19566
20294
|
k = h(byte1, seed);
|
|
19567
|
-
|
|
20295
|
+
v11 = h();
|
|
19568
20296
|
};
|
|
19569
20297
|
const gen = () => {
|
|
19570
20298
|
if (i++ >= _maxDrbgIters)
|
|
@@ -19572,10 +20300,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
19572
20300
|
let len = 0;
|
|
19573
20301
|
const out = [];
|
|
19574
20302
|
while (len < qByteLen) {
|
|
19575
|
-
|
|
19576
|
-
const sl =
|
|
20303
|
+
v11 = h();
|
|
20304
|
+
const sl = v11.slice();
|
|
19577
20305
|
out.push(sl);
|
|
19578
|
-
len +=
|
|
20306
|
+
len += v11.length;
|
|
19579
20307
|
}
|
|
19580
20308
|
return concatBytes(...out);
|
|
19581
20309
|
};
|
|
@@ -19601,7 +20329,7 @@ function validateObject(object4, fields = {}, optFields = {}) {
|
|
|
19601
20329
|
if (current !== expectedType || val === null)
|
|
19602
20330
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
19603
20331
|
}
|
|
19604
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
20332
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v11]) => checkField(k, v11, isOpt));
|
|
19605
20333
|
iter(fields, false);
|
|
19606
20334
|
iter(optFields, true);
|
|
19607
20335
|
}
|
|
@@ -19672,9 +20400,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
19672
20400
|
function sqrt5mod8(Fp, n) {
|
|
19673
20401
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
19674
20402
|
const n2 = Fp.mul(n, _2n);
|
|
19675
|
-
const
|
|
19676
|
-
const nv = Fp.mul(n,
|
|
19677
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
20403
|
+
const v11 = Fp.pow(n2, p5div8);
|
|
20404
|
+
const nv = Fp.mul(n, v11);
|
|
20405
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v11);
|
|
19678
20406
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
19679
20407
|
assertIsSquare(Fp, root, n);
|
|
19680
20408
|
return root;
|
|
@@ -20256,9 +20984,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
20256
20984
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
20257
20985
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
20258
20986
|
const modP = (n) => Fp.create(n);
|
|
20259
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
20987
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v11) => {
|
|
20260
20988
|
try {
|
|
20261
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
20989
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v11)) };
|
|
20262
20990
|
} catch (e) {
|
|
20263
20991
|
return { isValid: false, value: _0n4 };
|
|
20264
20992
|
}
|
|
@@ -20354,8 +21082,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
20354
21082
|
aInRange("point.y", y, _0n4, max);
|
|
20355
21083
|
const y2 = modP(y * y);
|
|
20356
21084
|
const u = modP(y2 - _1n4);
|
|
20357
|
-
const
|
|
20358
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
21085
|
+
const v11 = modP(d * y2 - a);
|
|
21086
|
+
let { isValid, value: x } = uvRatio2(u, v11);
|
|
20359
21087
|
if (!isValid)
|
|
20360
21088
|
throw new Error("bad point: invalid y coordinate");
|
|
20361
21089
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -20695,13 +21423,13 @@ function adjustScalarBytes(bytes) {
|
|
|
20695
21423
|
return bytes;
|
|
20696
21424
|
}
|
|
20697
21425
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
20698
|
-
function uvRatio(u,
|
|
21426
|
+
function uvRatio(u, v11) {
|
|
20699
21427
|
const P = ed25519_CURVE_p;
|
|
20700
|
-
const v32 = mod(
|
|
20701
|
-
const v72 = mod(v32 * v32 *
|
|
21428
|
+
const v32 = mod(v11 * v11 * v11, P);
|
|
21429
|
+
const v72 = mod(v32 * v32 * v11, P);
|
|
20702
21430
|
const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
|
|
20703
21431
|
let x = mod(u * v32 * pow, P);
|
|
20704
|
-
const vx2 = mod(
|
|
21432
|
+
const vx2 = mod(v11 * x * x, P);
|
|
20705
21433
|
const root1 = x;
|
|
20706
21434
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
20707
21435
|
const useRoot1 = vx2 === u;
|
|
@@ -21032,7 +21760,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
21032
21760
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
21033
21761
|
}
|
|
21034
21762
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
21035
|
-
const stakes = validators.map((
|
|
21763
|
+
const stakes = validators.map((v11) => BigInt(v11.stake)).sort(sortBigIntAsc);
|
|
21036
21764
|
const num = BigInt(numSeats);
|
|
21037
21765
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
21038
21766
|
if (stakesSum < num) {
|
|
@@ -21061,7 +21789,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
21061
21789
|
if (minimumStakeRatio.length != 2) {
|
|
21062
21790
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
21063
21791
|
}
|
|
21064
|
-
const stakes = validators.map((
|
|
21792
|
+
const stakes = validators.map((v11) => BigInt(v11.stake)).sort(sortBigIntAsc);
|
|
21065
21793
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
21066
21794
|
if (validators.length < maxNumberOfSeats) {
|
|
21067
21795
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -21233,10 +21961,10 @@ var DER = {
|
|
|
21233
21961
|
if (length < 128)
|
|
21234
21962
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
21235
21963
|
}
|
|
21236
|
-
const
|
|
21237
|
-
if (
|
|
21964
|
+
const v11 = data.subarray(pos, pos + length);
|
|
21965
|
+
if (v11.length !== length)
|
|
21238
21966
|
throw new E("tlv.decode: wrong value length");
|
|
21239
|
-
return { v:
|
|
21967
|
+
return { v: v11, l: data.subarray(pos + length) };
|
|
21240
21968
|
}
|
|
21241
21969
|
},
|
|
21242
21970
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -21983,14 +22711,14 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
21983
22711
|
return false;
|
|
21984
22712
|
const { r, s } = sig;
|
|
21985
22713
|
const h = bits2int_modN(message);
|
|
21986
|
-
const
|
|
21987
|
-
const u1 = Fn.create(h *
|
|
21988
|
-
const u2 = Fn.create(r *
|
|
22714
|
+
const is4 = Fn.inv(s);
|
|
22715
|
+
const u1 = Fn.create(h * is4);
|
|
22716
|
+
const u2 = Fn.create(r * is4);
|
|
21989
22717
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
21990
22718
|
if (R.is0())
|
|
21991
22719
|
return false;
|
|
21992
|
-
const
|
|
21993
|
-
return
|
|
22720
|
+
const v11 = Fn.create(R.x);
|
|
22721
|
+
return v11 === r;
|
|
21994
22722
|
} catch (e) {
|
|
21995
22723
|
return false;
|
|
21996
22724
|
}
|
|
@@ -24885,7 +25613,11 @@ var NearSpokeService = class {
|
|
|
24885
25613
|
async getWalletBalances(params) {
|
|
24886
25614
|
const { srcChainKey, srcAddress, tokens } = params;
|
|
24887
25615
|
const collector = createBalanceCollector({ logger: this.config.logger, chainKey: srcChainKey });
|
|
24888
|
-
await settleWalletBalances(
|
|
25616
|
+
await settleWalletBalances(
|
|
25617
|
+
collector,
|
|
25618
|
+
tokens,
|
|
25619
|
+
(token) => this.getWalletBalance({ srcChainKey, srcAddress, token })
|
|
25620
|
+
);
|
|
24889
25621
|
return collector.finish();
|
|
24890
25622
|
}
|
|
24891
25623
|
/**
|
|
@@ -27168,7 +27900,11 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
27168
27900
|
async getWalletBalances(params) {
|
|
27169
27901
|
const { srcChainKey, srcAddress, tokens } = params;
|
|
27170
27902
|
const collector = createBalanceCollector({ logger: this.config.logger, chainKey: srcChainKey });
|
|
27171
|
-
await settleWalletBalances(
|
|
27903
|
+
await settleWalletBalances(
|
|
27904
|
+
collector,
|
|
27905
|
+
tokens,
|
|
27906
|
+
(token) => this.getWalletBalance({ srcChainKey, srcAddress, token })
|
|
27907
|
+
);
|
|
27172
27908
|
return collector.finish();
|
|
27173
27909
|
}
|
|
27174
27910
|
/**
|
|
@@ -28024,9 +28760,9 @@ var SpokeService = class _SpokeService {
|
|
|
28024
28760
|
* Sign and broadcast the approval plan for an ERC-20 on the hub or an EVM spoke.
|
|
28025
28761
|
*
|
|
28026
28762
|
* A token of the TetherToken lineage rejects an allowance change from one non-zero value to
|
|
28027
|
-
* another, so a wallet holding a stale allowance needs `approve(0)` first.
|
|
28028
|
-
*
|
|
28029
|
-
*
|
|
28763
|
+
* another, so a wallet holding a stale allowance needs `approve(0)` first. Sent as separate
|
|
28764
|
+
* transactions, each is only valid once its predecessor has been mined, so this waits between them
|
|
28765
|
+
* (an EIP-5792 atomic batch can carry both, in order). The hash of the last is returned.
|
|
28030
28766
|
*/
|
|
28031
28767
|
async executeErc20ApprovalPlan(params) {
|
|
28032
28768
|
const { walletProvider } = params;
|
|
@@ -29899,12 +30635,195 @@ var EvmHubProvider = class {
|
|
|
29899
30635
|
});
|
|
29900
30636
|
}
|
|
29901
30637
|
};
|
|
30638
|
+
var ChainKeySchema = v__namespace.custom((input) => typeof input === "string");
|
|
30639
|
+
var SpokeChainKeySchema = v__namespace.custom((input) => typeof input === "string");
|
|
30640
|
+
var AddressSchema = v__namespace.custom((input) => typeof input === "string");
|
|
30641
|
+
var XTokenSchema = v__namespace.object({
|
|
30642
|
+
symbol: v__namespace.string(),
|
|
30643
|
+
name: v__namespace.string(),
|
|
30644
|
+
decimals: v__namespace.number(),
|
|
30645
|
+
address: v__namespace.string(),
|
|
30646
|
+
chainKey: ChainKeySchema,
|
|
30647
|
+
hubAsset: AddressSchema,
|
|
30648
|
+
vault: AddressSchema,
|
|
30649
|
+
access: v__namespace.optional(v__namespace.picklist(["withdrawOnly", "depositOnly"]))
|
|
30650
|
+
});
|
|
30651
|
+
var IntentStructSchema = v__namespace.object({
|
|
30652
|
+
intentId: v__namespace.string(),
|
|
30653
|
+
creator: v__namespace.string(),
|
|
30654
|
+
inputToken: v__namespace.string(),
|
|
30655
|
+
outputToken: v__namespace.string(),
|
|
30656
|
+
inputAmount: v__namespace.string(),
|
|
30657
|
+
minOutputAmount: v__namespace.string(),
|
|
30658
|
+
deadline: v__namespace.string(),
|
|
30659
|
+
allowPartialFill: v__namespace.boolean(),
|
|
30660
|
+
srcChain: v__namespace.number(),
|
|
30661
|
+
dstChain: v__namespace.number(),
|
|
30662
|
+
srcAddress: v__namespace.string(),
|
|
30663
|
+
dstAddress: v__namespace.string(),
|
|
30664
|
+
solver: v__namespace.string(),
|
|
30665
|
+
data: v__namespace.string()
|
|
30666
|
+
});
|
|
30667
|
+
var FillEventSchema = v__namespace.object({
|
|
30668
|
+
eventType: v__namespace.literal("intent-filled"),
|
|
30669
|
+
// The hub-chain fill tx; an empty one is no use as `fill_tx_hash`.
|
|
30670
|
+
txHash: v__namespace.pipe(v__namespace.string(), v__namespace.nonEmpty()),
|
|
30671
|
+
// Terminality. An intent created with `allowPartialFill` emits a fill event per fill, so the
|
|
30672
|
+
// event alone does not mean the intent is done — only `remainingInput === '0'` does. Required:
|
|
30673
|
+
// without it there is no proof of completion, and claiming SOLVED on a partial fill would report
|
|
30674
|
+
// an unfinished swap as complete.
|
|
30675
|
+
intentState: v__namespace.object({
|
|
30676
|
+
remainingInput: v__namespace.string()
|
|
30677
|
+
})
|
|
30678
|
+
});
|
|
30679
|
+
var IntentEventTypeSchema = v__namespace.object({ eventType: v__namespace.string() });
|
|
30680
|
+
var IntentResponseSchema = v__namespace.object({
|
|
30681
|
+
intentHash: v__namespace.string(),
|
|
30682
|
+
txHash: v__namespace.string(),
|
|
30683
|
+
logIndex: v__namespace.number(),
|
|
30684
|
+
chainId: v__namespace.number(),
|
|
30685
|
+
blockNumber: v__namespace.number(),
|
|
30686
|
+
open: v__namespace.boolean(),
|
|
30687
|
+
intent: IntentStructSchema,
|
|
30688
|
+
events: v__namespace.array(v__namespace.unknown())
|
|
30689
|
+
});
|
|
30690
|
+
var UserIntentsResponseSchema = v__namespace.object({
|
|
30691
|
+
total: v__namespace.number(),
|
|
30692
|
+
offset: v__namespace.number(),
|
|
30693
|
+
limit: v__namespace.number(),
|
|
30694
|
+
items: v__namespace.array(IntentResponseSchema)
|
|
30695
|
+
});
|
|
30696
|
+
var OrderbookResponseSchema = v__namespace.object({
|
|
30697
|
+
total: v__namespace.number(),
|
|
30698
|
+
data: v__namespace.array(
|
|
30699
|
+
v__namespace.object({
|
|
30700
|
+
intentState: v__namespace.object({
|
|
30701
|
+
exists: v__namespace.boolean(),
|
|
30702
|
+
remainingInput: v__namespace.string(),
|
|
30703
|
+
receivedOutput: v__namespace.string(),
|
|
30704
|
+
pendingPayment: v__namespace.boolean()
|
|
30705
|
+
}),
|
|
30706
|
+
intentData: v__namespace.object({
|
|
30707
|
+
intentId: v__namespace.string(),
|
|
30708
|
+
creator: v__namespace.string(),
|
|
30709
|
+
inputToken: v__namespace.string(),
|
|
30710
|
+
outputToken: v__namespace.string(),
|
|
30711
|
+
inputAmount: v__namespace.string(),
|
|
30712
|
+
minOutputAmount: v__namespace.string(),
|
|
30713
|
+
deadline: v__namespace.string(),
|
|
30714
|
+
allowPartialFill: v__namespace.boolean(),
|
|
30715
|
+
srcChain: v__namespace.number(),
|
|
30716
|
+
dstChain: v__namespace.number(),
|
|
30717
|
+
srcAddress: v__namespace.string(),
|
|
30718
|
+
dstAddress: v__namespace.string(),
|
|
30719
|
+
solver: v__namespace.string(),
|
|
30720
|
+
data: v__namespace.string(),
|
|
30721
|
+
intentHash: v__namespace.string(),
|
|
30722
|
+
txHash: v__namespace.string(),
|
|
30723
|
+
blockNumber: v__namespace.number()
|
|
30724
|
+
})
|
|
30725
|
+
})
|
|
30726
|
+
)
|
|
30727
|
+
});
|
|
30728
|
+
var MoneyMarketPositionSchema = v__namespace.object({
|
|
30729
|
+
userAddress: v__namespace.string(),
|
|
30730
|
+
positions: v__namespace.array(
|
|
30731
|
+
v__namespace.object({
|
|
30732
|
+
reserveAddress: v__namespace.string(),
|
|
30733
|
+
aTokenAddress: v__namespace.string(),
|
|
30734
|
+
variableDebtTokenAddress: v__namespace.string(),
|
|
30735
|
+
aTokenBalance: v__namespace.string(),
|
|
30736
|
+
variableDebtTokenBalance: v__namespace.string(),
|
|
30737
|
+
blockNumber: v__namespace.number()
|
|
30738
|
+
})
|
|
30739
|
+
)
|
|
30740
|
+
});
|
|
30741
|
+
var MoneyMarketAssetSchema = v__namespace.object({
|
|
30742
|
+
reserveAddress: v__namespace.string(),
|
|
30743
|
+
aTokenAddress: v__namespace.string(),
|
|
30744
|
+
totalATokenBalance: v__namespace.string(),
|
|
30745
|
+
variableDebtTokenAddress: v__namespace.string(),
|
|
30746
|
+
totalVariableDebtTokenBalance: v__namespace.string(),
|
|
30747
|
+
liquidityRate: v__namespace.string(),
|
|
30748
|
+
symbol: v__namespace.string(),
|
|
30749
|
+
totalSuppliers: v__namespace.number(),
|
|
30750
|
+
totalBorrowers: v__namespace.number(),
|
|
30751
|
+
variableBorrowRate: v__namespace.string(),
|
|
30752
|
+
stableBorrowRate: v__namespace.string(),
|
|
30753
|
+
liquidityIndex: v__namespace.string(),
|
|
30754
|
+
variableBorrowIndex: v__namespace.string(),
|
|
30755
|
+
blockNumber: v__namespace.number()
|
|
30756
|
+
});
|
|
30757
|
+
var MoneyMarketAssetsSchema = v__namespace.array(MoneyMarketAssetSchema);
|
|
30758
|
+
var MoneyMarketAssetBorrowersSchema = v__namespace.object({
|
|
30759
|
+
borrowers: v__namespace.array(v__namespace.string()),
|
|
30760
|
+
total: v__namespace.number(),
|
|
30761
|
+
offset: v__namespace.number(),
|
|
30762
|
+
limit: v__namespace.number()
|
|
30763
|
+
});
|
|
30764
|
+
var MoneyMarketAssetSuppliersSchema = v__namespace.object({
|
|
30765
|
+
suppliers: v__namespace.array(v__namespace.string()),
|
|
30766
|
+
total: v__namespace.number(),
|
|
30767
|
+
offset: v__namespace.number(),
|
|
30768
|
+
limit: v__namespace.number()
|
|
30769
|
+
});
|
|
30770
|
+
var MoneyMarketBorrowersSchema = v__namespace.object({
|
|
30771
|
+
borrowers: v__namespace.array(v__namespace.string()),
|
|
30772
|
+
total: v__namespace.number(),
|
|
30773
|
+
offset: v__namespace.number(),
|
|
30774
|
+
limit: v__namespace.number()
|
|
30775
|
+
});
|
|
30776
|
+
var GetChainsResponseSchema = v__namespace.array(SpokeChainKeySchema);
|
|
30777
|
+
var TokensByChainMapSchema = v__namespace.custom(
|
|
30778
|
+
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v__namespace.is(XTokenSchema, t)))
|
|
30779
|
+
);
|
|
30780
|
+
var TokensListSchema = v__namespace.array(XTokenSchema);
|
|
30781
|
+
var ReserveAssetsSchema = v__namespace.array(AddressSchema);
|
|
30782
|
+
var ORACLE_CANDLE_INTERVALS = ["1m", "5m", "1h", "1d"];
|
|
30783
|
+
var OracleCandleIntervalSchema = v__namespace.picklist(ORACLE_CANDLE_INTERVALS);
|
|
30784
|
+
var OracleMarketsResponseSchema = v__namespace.object({
|
|
30785
|
+
quote: v__namespace.string(),
|
|
30786
|
+
intervals: v__namespace.array(
|
|
30787
|
+
v__namespace.object({
|
|
30788
|
+
key: v__namespace.string(),
|
|
30789
|
+
label: v__namespace.string(),
|
|
30790
|
+
seconds: v__namespace.number()
|
|
30791
|
+
})
|
|
30792
|
+
),
|
|
30793
|
+
symbols: v__namespace.array(v__namespace.string())
|
|
30794
|
+
});
|
|
30795
|
+
var OracleCandlesResponseSchema = v__namespace.object({
|
|
30796
|
+
symbol: v__namespace.string(),
|
|
30797
|
+
quote: v__namespace.string(),
|
|
30798
|
+
interval: OracleCandleIntervalSchema,
|
|
30799
|
+
candles: v__namespace.array(
|
|
30800
|
+
v__namespace.object({
|
|
30801
|
+
timestamp: v__namespace.number(),
|
|
30802
|
+
open: v__namespace.string(),
|
|
30803
|
+
high: v__namespace.string(),
|
|
30804
|
+
low: v__namespace.string(),
|
|
30805
|
+
close: v__namespace.string(),
|
|
30806
|
+
final: v__namespace.optional(v__namespace.boolean())
|
|
30807
|
+
})
|
|
30808
|
+
)
|
|
30809
|
+
});
|
|
30810
|
+
var isFillEvent = (value) => v__namespace.is(FillEventSchema, value);
|
|
30811
|
+
var isOracleCandleInterval = (value) => v__namespace.is(OracleCandleIntervalSchema, value);
|
|
29902
30812
|
|
|
29903
30813
|
// src/backendApi/detailedStatusRouting.ts
|
|
29904
30814
|
var DETAILED_STATUS_NOT_DELIVERED = "relay_not_delivered";
|
|
29905
30815
|
function isBackendSubmitTxAbandoned(data) {
|
|
29906
30816
|
return data.status === "failed" || Boolean(data.abandonedAt);
|
|
29907
30817
|
}
|
|
30818
|
+
function readIntentJournalOutcome(intent) {
|
|
30819
|
+
const settled = intent.events.filter(isFillEvent).find((fill) => fill.intentState.remainingInput === "0");
|
|
30820
|
+
if (settled) return { kind: "solved", fillTxHash: settled.txHash };
|
|
30821
|
+
const eventTypes = intent.events.flatMap((event) => v__namespace.is(IntentEventTypeSchema, event) ? [event.eventType] : []);
|
|
30822
|
+
if (!intent.open && eventTypes.includes("intent-cancelled") && !eventTypes.includes("intent-filled")) {
|
|
30823
|
+
return { kind: "cancelled" };
|
|
30824
|
+
}
|
|
30825
|
+
return void 0;
|
|
30826
|
+
}
|
|
29908
30827
|
async function resolveDeliveredPacket(params) {
|
|
29909
30828
|
const { srcChainKey, srcTxHash, relayerApiEndpoint, backendAnswered } = params;
|
|
29910
30829
|
const relayChainId = getIntentRelayChainId(srcChainKey);
|
|
@@ -30335,181 +31254,6 @@ async function runBackendSubmitTx({
|
|
|
30335
31254
|
});
|
|
30336
31255
|
return polled.ok ? { ok: true, value: polled.value } : { ok: false, cause: polled.cause };
|
|
30337
31256
|
}
|
|
30338
|
-
var ChainKeySchema = v__namespace.custom((input) => typeof input === "string");
|
|
30339
|
-
var SpokeChainKeySchema = v__namespace.custom((input) => typeof input === "string");
|
|
30340
|
-
var AddressSchema = v__namespace.custom((input) => typeof input === "string");
|
|
30341
|
-
var XTokenSchema = v__namespace.object({
|
|
30342
|
-
symbol: v__namespace.string(),
|
|
30343
|
-
name: v__namespace.string(),
|
|
30344
|
-
decimals: v__namespace.number(),
|
|
30345
|
-
address: v__namespace.string(),
|
|
30346
|
-
chainKey: ChainKeySchema,
|
|
30347
|
-
hubAsset: AddressSchema,
|
|
30348
|
-
vault: AddressSchema,
|
|
30349
|
-
access: v__namespace.optional(v__namespace.picklist(["withdrawOnly", "depositOnly"]))
|
|
30350
|
-
});
|
|
30351
|
-
var IntentStructSchema = v__namespace.object({
|
|
30352
|
-
intentId: v__namespace.string(),
|
|
30353
|
-
creator: v__namespace.string(),
|
|
30354
|
-
inputToken: v__namespace.string(),
|
|
30355
|
-
outputToken: v__namespace.string(),
|
|
30356
|
-
inputAmount: v__namespace.string(),
|
|
30357
|
-
minOutputAmount: v__namespace.string(),
|
|
30358
|
-
deadline: v__namespace.string(),
|
|
30359
|
-
allowPartialFill: v__namespace.boolean(),
|
|
30360
|
-
srcChain: v__namespace.number(),
|
|
30361
|
-
dstChain: v__namespace.number(),
|
|
30362
|
-
srcAddress: v__namespace.string(),
|
|
30363
|
-
dstAddress: v__namespace.string(),
|
|
30364
|
-
solver: v__namespace.string(),
|
|
30365
|
-
data: v__namespace.string()
|
|
30366
|
-
});
|
|
30367
|
-
var FillEventSchema = v__namespace.object({
|
|
30368
|
-
eventType: v__namespace.literal("intent-filled"),
|
|
30369
|
-
// The hub-chain fill tx; an empty one is no use as `fill_tx_hash`.
|
|
30370
|
-
txHash: v__namespace.pipe(v__namespace.string(), v__namespace.nonEmpty()),
|
|
30371
|
-
// Terminality. An intent created with `allowPartialFill` emits a fill event per fill, so the
|
|
30372
|
-
// event alone does not mean the intent is done — only `remainingInput === '0'` does. Required:
|
|
30373
|
-
// without it there is no proof of completion, and claiming SOLVED on a partial fill would report
|
|
30374
|
-
// an unfinished swap as complete.
|
|
30375
|
-
intentState: v__namespace.object({
|
|
30376
|
-
remainingInput: v__namespace.string()
|
|
30377
|
-
})
|
|
30378
|
-
});
|
|
30379
|
-
var IntentResponseSchema = v__namespace.object({
|
|
30380
|
-
intentHash: v__namespace.string(),
|
|
30381
|
-
txHash: v__namespace.string(),
|
|
30382
|
-
logIndex: v__namespace.number(),
|
|
30383
|
-
chainId: v__namespace.number(),
|
|
30384
|
-
blockNumber: v__namespace.number(),
|
|
30385
|
-
open: v__namespace.boolean(),
|
|
30386
|
-
intent: IntentStructSchema,
|
|
30387
|
-
events: v__namespace.array(v__namespace.unknown())
|
|
30388
|
-
});
|
|
30389
|
-
var UserIntentsResponseSchema = v__namespace.object({
|
|
30390
|
-
total: v__namespace.number(),
|
|
30391
|
-
offset: v__namespace.number(),
|
|
30392
|
-
limit: v__namespace.number(),
|
|
30393
|
-
items: v__namespace.array(IntentResponseSchema)
|
|
30394
|
-
});
|
|
30395
|
-
var OrderbookResponseSchema = v__namespace.object({
|
|
30396
|
-
total: v__namespace.number(),
|
|
30397
|
-
data: v__namespace.array(
|
|
30398
|
-
v__namespace.object({
|
|
30399
|
-
intentState: v__namespace.object({
|
|
30400
|
-
exists: v__namespace.boolean(),
|
|
30401
|
-
remainingInput: v__namespace.string(),
|
|
30402
|
-
receivedOutput: v__namespace.string(),
|
|
30403
|
-
pendingPayment: v__namespace.boolean()
|
|
30404
|
-
}),
|
|
30405
|
-
intentData: v__namespace.object({
|
|
30406
|
-
intentId: v__namespace.string(),
|
|
30407
|
-
creator: v__namespace.string(),
|
|
30408
|
-
inputToken: v__namespace.string(),
|
|
30409
|
-
outputToken: v__namespace.string(),
|
|
30410
|
-
inputAmount: v__namespace.string(),
|
|
30411
|
-
minOutputAmount: v__namespace.string(),
|
|
30412
|
-
deadline: v__namespace.string(),
|
|
30413
|
-
allowPartialFill: v__namespace.boolean(),
|
|
30414
|
-
srcChain: v__namespace.number(),
|
|
30415
|
-
dstChain: v__namespace.number(),
|
|
30416
|
-
srcAddress: v__namespace.string(),
|
|
30417
|
-
dstAddress: v__namespace.string(),
|
|
30418
|
-
solver: v__namespace.string(),
|
|
30419
|
-
data: v__namespace.string(),
|
|
30420
|
-
intentHash: v__namespace.string(),
|
|
30421
|
-
txHash: v__namespace.string(),
|
|
30422
|
-
blockNumber: v__namespace.number()
|
|
30423
|
-
})
|
|
30424
|
-
})
|
|
30425
|
-
)
|
|
30426
|
-
});
|
|
30427
|
-
var MoneyMarketPositionSchema = v__namespace.object({
|
|
30428
|
-
userAddress: v__namespace.string(),
|
|
30429
|
-
positions: v__namespace.array(
|
|
30430
|
-
v__namespace.object({
|
|
30431
|
-
reserveAddress: v__namespace.string(),
|
|
30432
|
-
aTokenAddress: v__namespace.string(),
|
|
30433
|
-
variableDebtTokenAddress: v__namespace.string(),
|
|
30434
|
-
aTokenBalance: v__namespace.string(),
|
|
30435
|
-
variableDebtTokenBalance: v__namespace.string(),
|
|
30436
|
-
blockNumber: v__namespace.number()
|
|
30437
|
-
})
|
|
30438
|
-
)
|
|
30439
|
-
});
|
|
30440
|
-
var MoneyMarketAssetSchema = v__namespace.object({
|
|
30441
|
-
reserveAddress: v__namespace.string(),
|
|
30442
|
-
aTokenAddress: v__namespace.string(),
|
|
30443
|
-
totalATokenBalance: v__namespace.string(),
|
|
30444
|
-
variableDebtTokenAddress: v__namespace.string(),
|
|
30445
|
-
totalVariableDebtTokenBalance: v__namespace.string(),
|
|
30446
|
-
liquidityRate: v__namespace.string(),
|
|
30447
|
-
symbol: v__namespace.string(),
|
|
30448
|
-
totalSuppliers: v__namespace.number(),
|
|
30449
|
-
totalBorrowers: v__namespace.number(),
|
|
30450
|
-
variableBorrowRate: v__namespace.string(),
|
|
30451
|
-
stableBorrowRate: v__namespace.string(),
|
|
30452
|
-
liquidityIndex: v__namespace.string(),
|
|
30453
|
-
variableBorrowIndex: v__namespace.string(),
|
|
30454
|
-
blockNumber: v__namespace.number()
|
|
30455
|
-
});
|
|
30456
|
-
var MoneyMarketAssetsSchema = v__namespace.array(MoneyMarketAssetSchema);
|
|
30457
|
-
var MoneyMarketAssetBorrowersSchema = v__namespace.object({
|
|
30458
|
-
borrowers: v__namespace.array(v__namespace.string()),
|
|
30459
|
-
total: v__namespace.number(),
|
|
30460
|
-
offset: v__namespace.number(),
|
|
30461
|
-
limit: v__namespace.number()
|
|
30462
|
-
});
|
|
30463
|
-
var MoneyMarketAssetSuppliersSchema = v__namespace.object({
|
|
30464
|
-
suppliers: v__namespace.array(v__namespace.string()),
|
|
30465
|
-
total: v__namespace.number(),
|
|
30466
|
-
offset: v__namespace.number(),
|
|
30467
|
-
limit: v__namespace.number()
|
|
30468
|
-
});
|
|
30469
|
-
var MoneyMarketBorrowersSchema = v__namespace.object({
|
|
30470
|
-
borrowers: v__namespace.array(v__namespace.string()),
|
|
30471
|
-
total: v__namespace.number(),
|
|
30472
|
-
offset: v__namespace.number(),
|
|
30473
|
-
limit: v__namespace.number()
|
|
30474
|
-
});
|
|
30475
|
-
var GetChainsResponseSchema = v__namespace.array(SpokeChainKeySchema);
|
|
30476
|
-
var TokensByChainMapSchema = v__namespace.custom(
|
|
30477
|
-
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v__namespace.is(XTokenSchema, t)))
|
|
30478
|
-
);
|
|
30479
|
-
var TokensListSchema = v__namespace.array(XTokenSchema);
|
|
30480
|
-
var ReserveAssetsSchema = v__namespace.array(AddressSchema);
|
|
30481
|
-
var ORACLE_CANDLE_INTERVALS = ["1m", "5m", "1h", "1d"];
|
|
30482
|
-
var OracleCandleIntervalSchema = v__namespace.picklist(ORACLE_CANDLE_INTERVALS);
|
|
30483
|
-
var OracleMarketsResponseSchema = v__namespace.object({
|
|
30484
|
-
quote: v__namespace.string(),
|
|
30485
|
-
intervals: v__namespace.array(
|
|
30486
|
-
v__namespace.object({
|
|
30487
|
-
key: v__namespace.string(),
|
|
30488
|
-
label: v__namespace.string(),
|
|
30489
|
-
seconds: v__namespace.number()
|
|
30490
|
-
})
|
|
30491
|
-
),
|
|
30492
|
-
symbols: v__namespace.array(v__namespace.string())
|
|
30493
|
-
});
|
|
30494
|
-
var OracleCandlesResponseSchema = v__namespace.object({
|
|
30495
|
-
symbol: v__namespace.string(),
|
|
30496
|
-
quote: v__namespace.string(),
|
|
30497
|
-
interval: OracleCandleIntervalSchema,
|
|
30498
|
-
candles: v__namespace.array(
|
|
30499
|
-
v__namespace.object({
|
|
30500
|
-
timestamp: v__namespace.number(),
|
|
30501
|
-
open: v__namespace.string(),
|
|
30502
|
-
high: v__namespace.string(),
|
|
30503
|
-
low: v__namespace.string(),
|
|
30504
|
-
close: v__namespace.string(),
|
|
30505
|
-
final: v__namespace.optional(v__namespace.boolean())
|
|
30506
|
-
})
|
|
30507
|
-
)
|
|
30508
|
-
});
|
|
30509
|
-
|
|
30510
|
-
// src/backendApi/guards.ts
|
|
30511
|
-
var isFillEvent = (value) => v__namespace.is(FillEventSchema, value);
|
|
30512
|
-
var isOracleCandleInterval = (value) => v__namespace.is(OracleCandleIntervalSchema, value);
|
|
30513
31257
|
function decodePacketIntentTarget(payload) {
|
|
30514
31258
|
try {
|
|
30515
31259
|
const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
|
|
@@ -30529,6 +31273,11 @@ function selectSolvedIntentPacket(packets, intentsContract) {
|
|
|
30529
31273
|
return packets.reduce((highest, packet) => packet.conn_sn > highest.conn_sn ? packet : highest);
|
|
30530
31274
|
}
|
|
30531
31275
|
|
|
31276
|
+
// src/swap/intentDepositSpender.ts
|
|
31277
|
+
function intentDepositSpender(config, srcChainKey) {
|
|
31278
|
+
return isHubChainKeyType(srcChainKey) ? config.solver.intentsContract : config.getChainConfig(srcChainKey).addresses.assetManager;
|
|
31279
|
+
}
|
|
31280
|
+
|
|
30532
31281
|
// src/swap/speed-tier.ts
|
|
30533
31282
|
var SPEED_TIER_SECONDS = {
|
|
30534
31283
|
/** Either token's vault is a money-market-reserve (sodaAsset). */
|
|
@@ -30556,6 +31305,25 @@ function estimateSwapSpeedTier({ srcToken, dstToken }, isSodaAssetRelated) {
|
|
|
30556
31305
|
}
|
|
30557
31306
|
return { tier: secondsToTier(estimatedSeconds), estimatedSeconds };
|
|
30558
31307
|
}
|
|
31308
|
+
function summarizeSwapStatus(status) {
|
|
31309
|
+
if (status.source === "backend") {
|
|
31310
|
+
const { status: backendStatus, result } = status.data;
|
|
31311
|
+
return {
|
|
31312
|
+
state: backendStatus === "solved" || backendStatus === "failed" ? backendStatus : "pending",
|
|
31313
|
+
hubTxHash: asHex(result?.dstIntentTxHash),
|
|
31314
|
+
fillTxHash: asHex(result?.fillTxHash)
|
|
31315
|
+
};
|
|
31316
|
+
}
|
|
31317
|
+
const { status: solverStatus, fill_tx_hash } = status.data;
|
|
31318
|
+
return {
|
|
31319
|
+
state: solverStatus === exports.SolverIntentStatusCode.SOLVED ? "solved" : solverStatus === exports.SolverIntentStatusCode.FAILED ? "failed" : "pending",
|
|
31320
|
+
hubTxHash: status.dstTxHash,
|
|
31321
|
+
fillTxHash: asHex(fill_tx_hash)
|
|
31322
|
+
};
|
|
31323
|
+
}
|
|
31324
|
+
function asHex(value) {
|
|
31325
|
+
return value && viem.isHex(value) ? value : void 0;
|
|
31326
|
+
}
|
|
30559
31327
|
|
|
30560
31328
|
// src/swap/errors.ts
|
|
30561
31329
|
var swapInvariant = createInvariant("swap");
|
|
@@ -30579,6 +31347,9 @@ var SWAP_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
30579
31347
|
var isSwapCreateIntentError = isCodeMember(CREATE_INTENT_CODES);
|
|
30580
31348
|
var isPostExecutionError = isCodeMember(POST_EXECUTION_ERROR_CODES);
|
|
30581
31349
|
var isSwapError = isCodeMember(SWAP_ERROR_CODES);
|
|
31350
|
+
var isSwapWithApprovalError = isCodeMember(
|
|
31351
|
+
/* @__PURE__ */ new Set([...SWAP_ERROR_CODES, "APPROVE_FAILED", "ALLOWANCE_CHECK_FAILED"])
|
|
31352
|
+
);
|
|
30582
31353
|
|
|
30583
31354
|
// src/swap/SwapService.ts
|
|
30584
31355
|
var RECONCILE_TIMEOUT_MS = 5e3;
|
|
@@ -30593,13 +31364,14 @@ var SwapService = class {
|
|
|
30593
31364
|
relayerApiEndpoint;
|
|
30594
31365
|
// backend swaps-API client
|
|
30595
31366
|
backendApi;
|
|
31367
|
+
useBackendSubmitTxOverride;
|
|
30596
31368
|
/**
|
|
30597
31369
|
* Effective 2-step submit-tx flow (`swaps.useBackendSubmitTx`, default on). Read live off
|
|
30598
31370
|
* `ConfigService`, like {@link SwapService.partnerFee}, so the config object and the behavior can
|
|
30599
|
-
* never disagree.
|
|
31371
|
+
* never disagree — unless a direct constructor caller passed the deprecated override.
|
|
30600
31372
|
*/
|
|
30601
31373
|
get useBackendSubmitTx() {
|
|
30602
|
-
return this.config.swapUseBackendSubmitTx;
|
|
31374
|
+
return this.useBackendSubmitTxOverride ?? this.config.swapUseBackendSubmitTx;
|
|
30603
31375
|
}
|
|
30604
31376
|
/**
|
|
30605
31377
|
* Effective swap partner fee (`swaps.partnerFee`, else the global `fee`). Read live off
|
|
@@ -30610,13 +31382,14 @@ var SwapService = class {
|
|
|
30610
31382
|
get partnerFee() {
|
|
30611
31383
|
return this.config.swapPartnerFee;
|
|
30612
31384
|
}
|
|
30613
|
-
constructor({ config, hubProvider, spoke, backendApi }) {
|
|
31385
|
+
constructor({ config, hubProvider, spoke, backendApi, useBackendSubmitTx }) {
|
|
30614
31386
|
this.solver = config.solver;
|
|
30615
31387
|
this.relayerApiEndpoint = config.relay.relayerApiEndpoint;
|
|
30616
31388
|
this.config = config;
|
|
30617
31389
|
this.hubProvider = hubProvider;
|
|
30618
31390
|
this.spoke = spoke;
|
|
30619
31391
|
this.backendApi = backendApi;
|
|
31392
|
+
this.useBackendSubmitTxOverride = useBackendSubmitTx;
|
|
30620
31393
|
}
|
|
30621
31394
|
/**
|
|
30622
31395
|
* Estimates the gas cost for a raw (unsigned) transaction on a spoke chain.
|
|
@@ -30703,10 +31476,14 @@ var SwapService = class {
|
|
|
30703
31476
|
* polled and passes {@link DETAILED_STATUS_SOLVER_TIMEOUT_MS}. Both go through here so the
|
|
30704
31477
|
* durable-intent reconcile below is written once.
|
|
30705
31478
|
*
|
|
30706
|
-
* `timeoutMs` bounds the solver request alone. The reconcile that a
|
|
30707
|
-
*
|
|
31479
|
+
* `timeoutMs` bounds the solver request alone. The reconcile that a non-final solver read falls
|
|
31480
|
+
* through to carries its own {@link RECONCILE_TIMEOUT_MS}, so a bounded call can cost both.
|
|
31481
|
+
*
|
|
31482
|
+
* `reconcileNonFinal` is for `getDetailedStatus` alone: it reconciles an in-flight answer as well as
|
|
31483
|
+
* a `NOT_FOUND`, and reads a journal cancel as `FAILED`. The solver can keep reporting a cancelled
|
|
31484
|
+
* intent in flight, and nothing else ends that poll. `getStatus` leaves it off and keeps its answers.
|
|
30708
31485
|
*/
|
|
30709
|
-
async resolveSolverStatus(request, timeoutMs) {
|
|
31486
|
+
async resolveSolverStatus(request, { timeoutMs, reconcileNonFinal = false } = {}) {
|
|
30710
31487
|
const solverResult = await SolverApiService.getStatus(
|
|
30711
31488
|
request,
|
|
30712
31489
|
this.solver,
|
|
@@ -30714,12 +31491,20 @@ var SwapService = class {
|
|
|
30714
31491
|
timeoutMs,
|
|
30715
31492
|
this.config.apiKey
|
|
30716
31493
|
);
|
|
30717
|
-
const
|
|
30718
|
-
if (
|
|
31494
|
+
const status = solverResult.ok ? solverResult.value.status : void 0;
|
|
31495
|
+
if (status === exports.SolverIntentStatusCode.SOLVED || status === exports.SolverIntentStatusCode.FAILED) return solverResult;
|
|
31496
|
+
const forgotten = !solverResult.ok || status === exports.SolverIntentStatusCode.NOT_FOUND;
|
|
31497
|
+
if (!forgotten && !reconcileNonFinal) return solverResult;
|
|
30719
31498
|
const timeout = Math.min(RECONCILE_TIMEOUT_MS, this.backendApi.requestTimeoutMs);
|
|
30720
31499
|
const intent = await this.backendApi.getIntentByTxHash(request.intent_tx_hash, { timeout });
|
|
30721
|
-
const
|
|
30722
|
-
if (
|
|
31500
|
+
const outcome = intent.ok ? readIntentJournalOutcome(intent.value) : void 0;
|
|
31501
|
+
if (outcome?.kind === "solved") {
|
|
31502
|
+
return { ok: true, value: { status: exports.SolverIntentStatusCode.SOLVED, fill_tx_hash: outcome.fillTxHash } };
|
|
31503
|
+
}
|
|
31504
|
+
if (outcome?.kind === "cancelled" && reconcileNonFinal) {
|
|
31505
|
+
return { ok: true, value: { status: exports.SolverIntentStatusCode.FAILED } };
|
|
31506
|
+
}
|
|
31507
|
+
if (!forgotten) return solverResult;
|
|
30723
31508
|
const backendAnswered = intent.ok || isSodaxError(intent.error) && intent.error.context?.status === 404;
|
|
30724
31509
|
if (solverResult.ok && !backendAnswered) {
|
|
30725
31510
|
return {
|
|
@@ -30737,9 +31522,14 @@ var SwapService = class {
|
|
|
30737
31522
|
/**
|
|
30738
31523
|
* Reads a swap's status from its source-chain transaction — the identifier a caller always holds.
|
|
30739
31524
|
*
|
|
30740
|
-
* **Routes;
|
|
30741
|
-
* otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result
|
|
30742
|
-
* tagged with `source` (discriminate on it)
|
|
31525
|
+
* **Routes; defines no status of its own.** Returns the backend submit-tx record while it is in
|
|
31526
|
+
* play, otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result
|
|
31527
|
+
* is tagged with `source` (discriminate on it).
|
|
31528
|
+
*
|
|
31529
|
+
* The solver arm is reconciled against the backend's durable intent record: a settling fill reads
|
|
31530
|
+
* `SOLVED`, and a cancel with nothing filled reads `FAILED` even while the solver still reports the
|
|
31531
|
+
* intent in flight. A cancelled intent is already refunded, so do not offer to cancel it again.
|
|
31532
|
+
* Otherwise it carries the solver's answer unmodified, and the backend arm its record unmodified.
|
|
30743
31533
|
*
|
|
30744
31534
|
* **Any** unusable backend response routes to the solver — a 404, a transport or server error, or
|
|
30745
31535
|
* a record the backend gave up on. See `docs/SWAPS.md` § Get Detailed Status for why.
|
|
@@ -30773,7 +31563,7 @@ var SwapService = class {
|
|
|
30773
31563
|
if (!dstTxHash.ok) return dstTxHash;
|
|
30774
31564
|
const solver = await this.resolveSolverStatus(
|
|
30775
31565
|
{ intent_tx_hash: dstTxHash.value },
|
|
30776
|
-
DETAILED_STATUS_SOLVER_TIMEOUT_MS
|
|
31566
|
+
{ timeoutMs: DETAILED_STATUS_SOLVER_TIMEOUT_MS, reconcileNonFinal: true }
|
|
30777
31567
|
);
|
|
30778
31568
|
if (!solver.ok) {
|
|
30779
31569
|
return { ok: false, error: this.detailedStatusLookupFailed(solver.error, params.srcChainKey) };
|
|
@@ -30943,19 +31733,7 @@ var SwapService = class {
|
|
|
30943
31733
|
if (!createIntentResult.ok) {
|
|
30944
31734
|
return { ok: false, error: createIntentResult.error };
|
|
30945
31735
|
}
|
|
30946
|
-
|
|
30947
|
-
const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
|
|
30948
|
-
if (this.useBackendSubmitTx) {
|
|
30949
|
-
const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
|
|
30950
|
-
if (submitted.ok) return submitted;
|
|
30951
|
-
this.config.logger.warn(
|
|
30952
|
-
"[swap] backend submit-tx did not complete; falling back to the client-side relay",
|
|
30953
|
-
{
|
|
30954
|
-
error: submitted.error
|
|
30955
|
-
}
|
|
30956
|
-
);
|
|
30957
|
-
}
|
|
30958
|
-
return this.fallbackSwapSteps(_params, created, timeoutMs);
|
|
31736
|
+
return await this.completeSwap(_params, createIntentResult.value);
|
|
30959
31737
|
} catch (error) {
|
|
30960
31738
|
if (isSwapError(error)) return { ok: false, error };
|
|
30961
31739
|
return {
|
|
@@ -30981,6 +31759,262 @@ var SwapService = class {
|
|
|
30981
31759
|
}
|
|
30982
31760
|
);
|
|
30983
31761
|
}
|
|
31762
|
+
/**
|
|
31763
|
+
* Which approval path {@link swapWithApproval} would take for these params, so a UI can say up front
|
|
31764
|
+
* whether the swap costs one signature or two. Read-only; sends nothing.
|
|
31765
|
+
*
|
|
31766
|
+
* `'atomic-batch'` needs an EVM spoke source and a wallet that reports EIP-5792 atomic support for
|
|
31767
|
+
* that chain — `'supported'`, or `'ready'` (the wallet asks the user to upgrade the account on the
|
|
31768
|
+
* first batch; pass `allowAccountUpgrade: false` to treat such a wallet as unable to batch). The Sonic
|
|
31769
|
+
* hub, a Stellar source that needs a trustline, and wallets without batch support get `'sequential'`;
|
|
31770
|
+
* other non-EVM sources have no allowance and get `'not-required'`.
|
|
31771
|
+
*
|
|
31772
|
+
* @returns `ALLOWANCE_CHECK_FAILED` when the allowance read fails; otherwise the strategy.
|
|
31773
|
+
*/
|
|
31774
|
+
async getApprovalStrategy(_params) {
|
|
31775
|
+
const { params, walletProvider, allowAccountUpgrade = true } = _params;
|
|
31776
|
+
const srcChainKey = params.srcChainKey;
|
|
31777
|
+
const allowance = await this.isAllowanceValid(_params);
|
|
31778
|
+
if (!allowance.ok) {
|
|
31779
|
+
return {
|
|
31780
|
+
ok: false,
|
|
31781
|
+
error: allowanceCheckFailed("swap", allowance.error, {
|
|
31782
|
+
srcChainKey,
|
|
31783
|
+
dstChainKey: params.dstChainKey,
|
|
31784
|
+
action: "swapWithApproval"
|
|
31785
|
+
})
|
|
31786
|
+
};
|
|
31787
|
+
}
|
|
31788
|
+
if (allowance.value) return { ok: true, value: "not-required" };
|
|
31789
|
+
return { ok: true, value: await resolveApprovalStrategy({ srcChainKey, walletProvider, allowAccountUpgrade }) };
|
|
31790
|
+
}
|
|
31791
|
+
/**
|
|
31792
|
+
* {@link swap} with the source-token approval folded in. Picks a path with
|
|
31793
|
+
* {@link getApprovalStrategy}: no approval when the allowance already suffices; on an EIP-5792
|
|
31794
|
+
* wallet, approve and the swap transaction as **one atomic batch — one signature**; otherwise
|
|
31795
|
+
* approve, wait for it to confirm, then the swap transaction. Completion (backend submit-tx with
|
|
31796
|
+
* the client-side relay fallback) is exactly `swap()`'s.
|
|
31797
|
+
*
|
|
31798
|
+
* A wallet that refuses the batch before signing anything (e.g. EIP-5792 5760, atomicity not
|
|
31799
|
+
* supported) falls back to the two-step path. A batch the user saw is never retried as separate
|
|
31800
|
+
* transactions:
|
|
31801
|
+
* - rejected → `USER_REJECTED`; a declined account upgrade (5750) adds `context.reason:`
|
|
31802
|
+
* {@link ACCOUNT_UPGRADE_DECLINED}, after which `allowAccountUpgrade: false` swaps without one;
|
|
31803
|
+
* - never included or fully reverted (EIP-5792 400 / 500) → `INTENT_CREATION_FAILED` with
|
|
31804
|
+
* `context.reason: 'atomic-batch-failed'`;
|
|
31805
|
+
* - anything else short of a confirmed deposit receipt (not confirmed within `timeout`, a partial
|
|
31806
|
+
* revert, receipts that do not identify the deposit) → `TX_VERIFICATION_FAILED` with
|
|
31807
|
+
* `context.reason:` {@link ATOMIC_BATCH_UNCONFIRMED}, `context.batchId` and `context.callCount`. It may
|
|
31808
|
+
* have landed — do not send it again; call again with `resumeBatchId` and `resumeBatchCallCount` to
|
|
31809
|
+
* finish it once it does.
|
|
31810
|
+
*
|
|
31811
|
+
* @returns A `Result<SwapWithApprovalResponse, SwapWithApprovalError>` — `swap()`'s response plus the
|
|
31812
|
+
* `approvalStrategy` that ran. Errors are `swap()`'s codes plus `APPROVE_FAILED` and
|
|
31813
|
+
* `ALLOWANCE_CHECK_FAILED`.
|
|
31814
|
+
*/
|
|
31815
|
+
async swapWithApproval(_params) {
|
|
31816
|
+
const { params } = _params;
|
|
31817
|
+
const srcChainKey = params.srcChainKey;
|
|
31818
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "swapWithApproval" };
|
|
31819
|
+
return this.config.analytics.trackResult(
|
|
31820
|
+
"swap",
|
|
31821
|
+
"swapWithApproval",
|
|
31822
|
+
async () => {
|
|
31823
|
+
try {
|
|
31824
|
+
if (_params.resumeBatchId !== void 0) return await this.resumeAtomicBatch(_params, _params.resumeBatchId);
|
|
31825
|
+
const strategy = await this.getApprovalStrategy(_params);
|
|
31826
|
+
if (!strategy.ok) return strategy;
|
|
31827
|
+
const { result: created, approvalStrategy } = await runWithApproval({
|
|
31828
|
+
strategy: strategy.value,
|
|
31829
|
+
notRequired: () => this.createIntent(_params),
|
|
31830
|
+
atomicBatch: () => this.createIntentInAtomicBatch(_params),
|
|
31831
|
+
sequential: (afterRefusedBatch) => this.approveThenCreateIntent(_params, afterRefusedBatch),
|
|
31832
|
+
onBatchRefused: (error) => this.config.logger.warn("[swapWithApproval] wallet refused the atomic batch; approving separately", {
|
|
31833
|
+
error
|
|
31834
|
+
})
|
|
31835
|
+
});
|
|
31836
|
+
if (!created.ok) return created;
|
|
31837
|
+
const completed = await this.completeSwap(_params, created.value);
|
|
31838
|
+
if (!completed.ok) return completed;
|
|
31839
|
+
return { ok: true, value: { ...completed.value, approvalStrategy } };
|
|
31840
|
+
} catch (error) {
|
|
31841
|
+
if (isSwapWithApprovalError(error)) return { ok: false, error };
|
|
31842
|
+
return { ok: false, error: unknownFailed("swap", error, baseCtx) };
|
|
31843
|
+
}
|
|
31844
|
+
},
|
|
31845
|
+
{
|
|
31846
|
+
start: () => ({
|
|
31847
|
+
srcChainKey,
|
|
31848
|
+
dstChainKey: params.dstChainKey,
|
|
31849
|
+
srcAddress: params.srcAddress,
|
|
31850
|
+
dstAddress: params.dstAddress
|
|
31851
|
+
}),
|
|
31852
|
+
success: (value) => ({
|
|
31853
|
+
srcChainKey,
|
|
31854
|
+
dstChainKey: params.dstChainKey,
|
|
31855
|
+
srcTxHash: value.intentDeliveryInfo.srcTxHash,
|
|
31856
|
+
dstTxHash: value.intentDeliveryInfo.dstTxHash,
|
|
31857
|
+
approvalStrategy: value.approvalStrategy
|
|
31858
|
+
}),
|
|
31859
|
+
failure: (error) => ({ code: error.code })
|
|
31860
|
+
}
|
|
31861
|
+
);
|
|
31862
|
+
}
|
|
31863
|
+
/**
|
|
31864
|
+
* Approve + deposit as one EIP-5792 atomic batch, in broadcast order (`[reset?, approve, deposit]`),
|
|
31865
|
+
* then hand back the batch's transaction hash as the intent tx, for {@link completeSwap}.
|
|
31866
|
+
*/
|
|
31867
|
+
async createIntentInAtomicBatch(_params) {
|
|
31868
|
+
const { params, walletProvider, extras, skipSimulation } = _params;
|
|
31869
|
+
const srcChainKey = params.srcChainKey;
|
|
31870
|
+
swapInvariant(
|
|
31871
|
+
isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider),
|
|
31872
|
+
"Atomic batches need an EVM spoke source and an EVM wallet provider"
|
|
31873
|
+
);
|
|
31874
|
+
swapInvariant(canSendAtomicBatch(walletProvider), "Wallet provider does not implement EIP-5792 batches");
|
|
31875
|
+
const ctx = {
|
|
31876
|
+
srcChainKey,
|
|
31877
|
+
dstChainKey: params.dstChainKey,
|
|
31878
|
+
action: "swapWithApproval",
|
|
31879
|
+
approvalStrategy: "atomic-batch"
|
|
31880
|
+
};
|
|
31881
|
+
const [approval, created] = await Promise.all([
|
|
31882
|
+
this.buildApproveTxs({ params, raw: true }),
|
|
31883
|
+
this.createIntent({ params, extras, skipSimulation, raw: true })
|
|
31884
|
+
]);
|
|
31885
|
+
if (!approval.ok) {
|
|
31886
|
+
return {
|
|
31887
|
+
ok: false,
|
|
31888
|
+
error: isSwapWithApprovalError(approval.error) ? withErrorContext(approval.error, ctx) : approveFailed("swap", approval.error, ctx)
|
|
31889
|
+
};
|
|
31890
|
+
}
|
|
31891
|
+
if (!created.ok) return created;
|
|
31892
|
+
const { resetTx, approveTx } = approval.value;
|
|
31893
|
+
const depositTx = created.value.tx;
|
|
31894
|
+
const txs = resetTx ? [resetTx, approveTx, depositTx] : [approveTx, depositTx];
|
|
31895
|
+
const sent = await sendApprovalBatch({
|
|
31896
|
+
walletProvider,
|
|
31897
|
+
srcChainKey,
|
|
31898
|
+
txs,
|
|
31899
|
+
timeoutMs: approvalBatchWaitMs(_params.timeout),
|
|
31900
|
+
feature: "swap",
|
|
31901
|
+
context: ctx
|
|
31902
|
+
});
|
|
31903
|
+
if (!sent.ok) return sent;
|
|
31904
|
+
return {
|
|
31905
|
+
ok: true,
|
|
31906
|
+
value: {
|
|
31907
|
+
tx: sent.value.txHash,
|
|
31908
|
+
intent: created.value.intent,
|
|
31909
|
+
relayData: created.value.relayData
|
|
31910
|
+
}
|
|
31911
|
+
};
|
|
31912
|
+
}
|
|
31913
|
+
/**
|
|
31914
|
+
* Finishes a batch an earlier call left {@link ATOMIC_BATCH_UNCONFIRMED}, without sending anything to
|
|
31915
|
+
* the wallet: waits for it again, relays its deposit client-side and notifies the solver. The
|
|
31916
|
+
* original intent went with that call, so it is read back from the hub tx the relay delivers.
|
|
31917
|
+
*/
|
|
31918
|
+
async resumeAtomicBatch(_params, batchId) {
|
|
31919
|
+
const { params, walletProvider } = _params;
|
|
31920
|
+
const srcChainKey = params.srcChainKey;
|
|
31921
|
+
swapInvariant(
|
|
31922
|
+
isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider) && canSendAtomicBatch(walletProvider),
|
|
31923
|
+
"Resuming an atomic batch needs an EVM spoke source and an EIP-5792 wallet provider"
|
|
31924
|
+
);
|
|
31925
|
+
const ctx = {
|
|
31926
|
+
srcChainKey,
|
|
31927
|
+
dstChainKey: params.dstChainKey,
|
|
31928
|
+
action: "swapWithApproval",
|
|
31929
|
+
approvalStrategy: "atomic-batch"
|
|
31930
|
+
};
|
|
31931
|
+
const timeoutMs = approvalBatchWaitMs(_params.timeout);
|
|
31932
|
+
const deposit = await confirmApprovalBatch({
|
|
31933
|
+
walletProvider,
|
|
31934
|
+
batchId,
|
|
31935
|
+
callCount: _params.resumeBatchCallCount,
|
|
31936
|
+
timeoutMs,
|
|
31937
|
+
feature: "swap",
|
|
31938
|
+
context: ctx
|
|
31939
|
+
});
|
|
31940
|
+
if (!deposit.ok) return deposit;
|
|
31941
|
+
const srcTxHash = deposit.value.txHash;
|
|
31942
|
+
const txCtx = { ...ctx, srcTxHash };
|
|
31943
|
+
const packet = await relayTxAndWaitPacket({
|
|
31944
|
+
srcTxHash,
|
|
31945
|
+
chainKey: srcChainKey,
|
|
31946
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
31947
|
+
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
31948
|
+
});
|
|
31949
|
+
if (!packet.ok) return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap", ...txCtx }) };
|
|
31950
|
+
const dstTxHash = packet.value.dst_tx_hash;
|
|
31951
|
+
const intent = await this.getIntent(dstTxHash);
|
|
31952
|
+
if (!intent.ok) return { ok: false, error: unknownFailed("swap", intent.error, txCtx) };
|
|
31953
|
+
const solved = await this.postExecution({ intent_tx_hash: dstTxHash });
|
|
31954
|
+
if (!solved.ok) return { ok: false, error: withErrorContext(solved.error, { srcChainKey, srcTxHash, dstTxHash }) };
|
|
31955
|
+
return {
|
|
31956
|
+
ok: true,
|
|
31957
|
+
value: {
|
|
31958
|
+
solverExecutionResponse: solved.value,
|
|
31959
|
+
intent: intent.value,
|
|
31960
|
+
intentDeliveryInfo: {
|
|
31961
|
+
srcChainKey,
|
|
31962
|
+
srcTxHash,
|
|
31963
|
+
srcAddress: params.srcAddress,
|
|
31964
|
+
dstChainKey: params.dstChainKey,
|
|
31965
|
+
dstTxHash,
|
|
31966
|
+
dstAddress: params.dstAddress
|
|
31967
|
+
},
|
|
31968
|
+
approvalStrategy: "atomic-batch"
|
|
31969
|
+
}
|
|
31970
|
+
};
|
|
31971
|
+
}
|
|
31972
|
+
/** Approve, wait for the approval to confirm, then create the intent — two or more signatures. */
|
|
31973
|
+
async approveThenCreateIntent(_params, validated = false) {
|
|
31974
|
+
const { params, extras, skipSimulation } = _params;
|
|
31975
|
+
const ctx = {
|
|
31976
|
+
srcChainKey: params.srcChainKey,
|
|
31977
|
+
dstChainKey: params.dstChainKey,
|
|
31978
|
+
action: "swapWithApproval",
|
|
31979
|
+
approvalStrategy: "sequential"
|
|
31980
|
+
};
|
|
31981
|
+
if (!validated) {
|
|
31982
|
+
const preflight = await this.createIntent({ params, extras, skipSimulation, raw: true });
|
|
31983
|
+
if (!preflight.ok) return preflight;
|
|
31984
|
+
}
|
|
31985
|
+
const approved = await this.approve(_params);
|
|
31986
|
+
if (!approved.ok) {
|
|
31987
|
+
return {
|
|
31988
|
+
ok: false,
|
|
31989
|
+
error: isSwapWithApprovalError(approved.error) ? withErrorContext(approved.error, ctx) : approveFailed("swap", approved.error, ctx)
|
|
31990
|
+
};
|
|
31991
|
+
}
|
|
31992
|
+
const confirmed = await confirmApproval({
|
|
31993
|
+
waitForTxReceipt: (receiptParams) => this.spoke.waitForTxReceipt(receiptParams),
|
|
31994
|
+
txHash: approved.value,
|
|
31995
|
+
chainKey: params.srcChainKey,
|
|
31996
|
+
feature: "swap",
|
|
31997
|
+
context: ctx
|
|
31998
|
+
});
|
|
31999
|
+
if (!confirmed.ok) return confirmed;
|
|
32000
|
+
return this.createIntent(_params);
|
|
32001
|
+
}
|
|
32002
|
+
/**
|
|
32003
|
+
* Completes a swap whose intent tx is already broadcast: the backend 2-step attempt when
|
|
32004
|
+
* `useBackendSubmitTx` is on, falling back to {@link fallbackSwapSteps} on any non-success.
|
|
32005
|
+
* Shared by `swap()` and `swapWithApproval()`, which differ only in how the intent tx is created.
|
|
32006
|
+
*/
|
|
32007
|
+
async completeSwap(_params, created) {
|
|
32008
|
+
const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
|
|
32009
|
+
if (this.useBackendSubmitTx) {
|
|
32010
|
+
const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
|
|
32011
|
+
if (submitted.ok) return submitted;
|
|
32012
|
+
this.config.logger.warn("[swap] backend submit-tx did not complete; falling back to the client-side relay", {
|
|
32013
|
+
error: submitted.error
|
|
32014
|
+
});
|
|
32015
|
+
}
|
|
32016
|
+
return this.fallbackSwapSteps(_params, created, timeoutMs);
|
|
32017
|
+
}
|
|
30984
32018
|
/**
|
|
30985
32019
|
* Client-side swap completion (opt-out via `swaps.useBackendSubmitTx: false`): verify the broadcast intent
|
|
30986
32020
|
* tx landed, then relay it to the hub — or use it directly when the source IS the hub — then notify the
|
|
@@ -30994,14 +32028,14 @@ var SwapService = class {
|
|
|
30994
32028
|
async fallbackSwapSteps(_params, created, timeoutMs) {
|
|
30995
32029
|
const { params } = _params;
|
|
30996
32030
|
const srcChainKey = params.srcChainKey;
|
|
30997
|
-
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
|
|
30998
32031
|
const { tx: spokeTxHash, intent, relayData } = created;
|
|
32032
|
+
const txCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "swap", srcTxHash: spokeTxHash };
|
|
30999
32033
|
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
31000
32034
|
txHash: created.tx,
|
|
31001
32035
|
chainKey: srcChainKey
|
|
31002
32036
|
});
|
|
31003
32037
|
if (!verifyTxHashResult.ok) {
|
|
31004
|
-
return { ok: false, error: verifyFailed("swap", verifyTxHashResult.error,
|
|
32038
|
+
return { ok: false, error: verifyFailed("swap", verifyTxHashResult.error, txCtx) };
|
|
31005
32039
|
}
|
|
31006
32040
|
let dstIntentTxHash;
|
|
31007
32041
|
if (isHubChainKeyType(srcChainKey)) {
|
|
@@ -31020,7 +32054,7 @@ var SwapService = class {
|
|
|
31020
32054
|
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
31021
32055
|
});
|
|
31022
32056
|
if (!packet.ok) {
|
|
31023
|
-
return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap",
|
|
32057
|
+
return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap", ...txCtx }) };
|
|
31024
32058
|
}
|
|
31025
32059
|
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
31026
32060
|
}
|
|
@@ -31028,7 +32062,14 @@ var SwapService = class {
|
|
|
31028
32062
|
intent_tx_hash: dstIntentTxHash
|
|
31029
32063
|
});
|
|
31030
32064
|
if (!postExecResult.ok) {
|
|
31031
|
-
return {
|
|
32065
|
+
return {
|
|
32066
|
+
ok: false,
|
|
32067
|
+
error: withErrorContext(postExecResult.error, {
|
|
32068
|
+
srcChainKey,
|
|
32069
|
+
srcTxHash: spokeTxHash,
|
|
32070
|
+
dstTxHash: dstIntentTxHash
|
|
32071
|
+
})
|
|
32072
|
+
};
|
|
31032
32073
|
}
|
|
31033
32074
|
return {
|
|
31034
32075
|
ok: true,
|
|
@@ -31134,7 +32175,7 @@ var SwapService = class {
|
|
|
31134
32175
|
token: params.inputToken,
|
|
31135
32176
|
amount: params.inputAmount,
|
|
31136
32177
|
owner: params.srcAddress,
|
|
31137
|
-
spender: this.
|
|
32178
|
+
spender: intentDepositSpender(this.config, srcChainKey)
|
|
31138
32179
|
});
|
|
31139
32180
|
}
|
|
31140
32181
|
if (isEvmSpokeOnlyChainKeyType(srcChainKey)) {
|
|
@@ -31143,7 +32184,7 @@ var SwapService = class {
|
|
|
31143
32184
|
token: params.inputToken,
|
|
31144
32185
|
amount: params.inputAmount,
|
|
31145
32186
|
owner: params.srcAddress,
|
|
31146
|
-
spender: this.config
|
|
32187
|
+
spender: intentDepositSpender(this.config, srcChainKey)
|
|
31147
32188
|
});
|
|
31148
32189
|
}
|
|
31149
32190
|
if (isStellarChainKeyType(srcChainKey)) {
|
|
@@ -31187,7 +32228,7 @@ var SwapService = class {
|
|
|
31187
32228
|
isOptionalEvmWalletProviderType(_params.walletProvider),
|
|
31188
32229
|
"Invalid wallet provider. Expected Evm wallet provider."
|
|
31189
32230
|
);
|
|
31190
|
-
const spender =
|
|
32231
|
+
const spender = intentDepositSpender(this.config, params.srcChainKey);
|
|
31191
32232
|
const coreParams = {
|
|
31192
32233
|
srcChainKey: params.srcChainKey,
|
|
31193
32234
|
owner: params.srcAddress,
|
|
@@ -31258,7 +32299,7 @@ var SwapService = class {
|
|
|
31258
32299
|
const wrapApproveFailure = (cause) => approveFailed("swap", cause);
|
|
31259
32300
|
try {
|
|
31260
32301
|
if (isHubChainKeyType(params.srcChainKey) || isEvmSpokeOnlyChainKeyType(params.srcChainKey)) {
|
|
31261
|
-
const spender =
|
|
32302
|
+
const spender = intentDepositSpender(this.config, params.srcChainKey);
|
|
31262
32303
|
const result = await this.spoke.buildApproveTxs({
|
|
31263
32304
|
srcChainKey: params.srcChainKey,
|
|
31264
32305
|
owner: params.srcAddress,
|
|
@@ -34977,7 +36018,7 @@ var LeverageYieldApiService = class _LeverageYieldApiService {
|
|
|
34977
36018
|
/**
|
|
34978
36019
|
* Build an unsigned token-approval transaction for the deposit input token.
|
|
34979
36020
|
*
|
|
34980
|
-
* @returns `Result<ApproveResponseV2>` — `{ tx }` (chain-specific unsigned
|
|
36021
|
+
* @returns `Result<ApproveResponseV2>` — `{ tx, resetTx? }` (chain-specific unsigned txs); mine `resetTx` first when present.
|
|
34981
36022
|
*/
|
|
34982
36023
|
async approve(body, config) {
|
|
34983
36024
|
const txSchema = swapsApi.rawTxSchemaForChainKey(body.srcChainKey);
|
|
@@ -35751,6 +36792,9 @@ var BRIDGE_CODES = /* @__PURE__ */ new Set([
|
|
|
35751
36792
|
"UNKNOWN"
|
|
35752
36793
|
]);
|
|
35753
36794
|
var isBridgeOrchestrationError = isCodeMember(ORCHESTRATION_CODES);
|
|
36795
|
+
var isBridgeWithApprovalError = isCodeMember(
|
|
36796
|
+
/* @__PURE__ */ new Set([...ORCHESTRATION_CODES, "APPROVE_FAILED", "ALLOWANCE_CHECK_FAILED"])
|
|
36797
|
+
);
|
|
35754
36798
|
var isBridgeCreateIntentError = isCodeMember(CREATE_INTENT_CODES);
|
|
35755
36799
|
var isBridgeApproveError = isCodeMember(APPROVE_CODES);
|
|
35756
36800
|
var isBridgeAllowanceCheckError = isCodeMember(ALLOWANCE_CHECK_CODES);
|
|
@@ -36055,16 +37099,7 @@ var BridgeService = class {
|
|
|
36055
37099
|
try {
|
|
36056
37100
|
const created = await this.createBridgeIntent(_params);
|
|
36057
37101
|
if (!created.ok) return { ok: false, error: created.error };
|
|
36058
|
-
|
|
36059
|
-
if (this.useBackendSubmitTx) {
|
|
36060
|
-
const submitted = await this.submitTx(_params, created.value, createSubmitTxAttempt(timeoutMs));
|
|
36061
|
-
if (submitted.ok) return submitted;
|
|
36062
|
-
this.config.logger.warn(
|
|
36063
|
-
"[bridge] backend submit-tx did not complete; falling back to the client-side relay",
|
|
36064
|
-
{ error: submitted.error }
|
|
36065
|
-
);
|
|
36066
|
-
}
|
|
36067
|
-
return this.fallbackBridgeSteps(_params, created.value, timeoutMs);
|
|
37102
|
+
return await this.completeBridge(_params, created.value);
|
|
36068
37103
|
} catch (error) {
|
|
36069
37104
|
if (isBridgeOrchestrationError(error)) return { ok: false, error };
|
|
36070
37105
|
return {
|
|
@@ -36091,6 +37126,229 @@ var BridgeService = class {
|
|
|
36091
37126
|
}
|
|
36092
37127
|
);
|
|
36093
37128
|
}
|
|
37129
|
+
/**
|
|
37130
|
+
* Which approval path {@link bridgeWithApproval} would take for these params, so a UI can say up
|
|
37131
|
+
* front whether the bridge costs one signature or two. Read-only; sends nothing.
|
|
37132
|
+
*
|
|
37133
|
+
* `'atomic-batch'` needs an EVM spoke source and a wallet that reports EIP-5792 atomic support for
|
|
37134
|
+
* that chain (`'supported'`, or `'ready'` unless `allowAccountUpgrade: false`). The Sonic hub,
|
|
37135
|
+
* Stellar and wallets without batch support get `'sequential'`; other non-EVM sources have no
|
|
37136
|
+
* allowance and get `'not-required'`.
|
|
37137
|
+
*
|
|
37138
|
+
* @returns `isAllowanceValid`'s error — `VALIDATION_FAILED` for invalid params, `ALLOWANCE_CHECK_FAILED`
|
|
37139
|
+
* when the read fails — or the strategy.
|
|
37140
|
+
*/
|
|
37141
|
+
async getApprovalStrategy(_params) {
|
|
37142
|
+
const { params, walletProvider, allowAccountUpgrade = true } = _params;
|
|
37143
|
+
const allowance = await this.isAllowanceValid(_params);
|
|
37144
|
+
if (!allowance.ok) {
|
|
37145
|
+
return {
|
|
37146
|
+
ok: false,
|
|
37147
|
+
error: withErrorContext(allowance.error, {
|
|
37148
|
+
srcChainKey: params.srcChainKey,
|
|
37149
|
+
dstChainKey: params.dstChainKey,
|
|
37150
|
+
action: "bridgeWithApproval"
|
|
37151
|
+
})
|
|
37152
|
+
};
|
|
37153
|
+
}
|
|
37154
|
+
if (allowance.value) return { ok: true, value: "not-required" };
|
|
37155
|
+
return {
|
|
37156
|
+
ok: true,
|
|
37157
|
+
value: await resolveApprovalStrategy({ srcChainKey: params.srcChainKey, walletProvider, allowAccountUpgrade })
|
|
37158
|
+
};
|
|
37159
|
+
}
|
|
37160
|
+
/**
|
|
37161
|
+
* {@link bridge} with the source-token approval folded in. Picks a path with
|
|
37162
|
+
* {@link getApprovalStrategy}: no approval when the allowance already suffices; on an EIP-5792
|
|
37163
|
+
* wallet, approve and the deposit as **one atomic batch — one signature**; otherwise approve, wait
|
|
37164
|
+
* for it to confirm, then the deposit. Completion is exactly `bridge()`'s.
|
|
37165
|
+
*
|
|
37166
|
+
* A wallet that refuses the batch before signing anything falls back to the two-step path. A batch
|
|
37167
|
+
* the user saw is never retried as separate transactions:
|
|
37168
|
+
* - rejected → `USER_REJECTED`; a declined account upgrade (5750) adds `context.reason:
|
|
37169
|
+
* 'account-upgrade-declined'`, after which `allowAccountUpgrade: false` bridges without one;
|
|
37170
|
+
* - never included or fully reverted (EIP-5792 400 / 500) → `INTENT_CREATION_FAILED` with
|
|
37171
|
+
* `context.reason: 'atomic-batch-failed'`;
|
|
37172
|
+
* - anything else short of a confirmed deposit receipt → `TX_VERIFICATION_FAILED` with
|
|
37173
|
+
* `context.reason:` {@link ATOMIC_BATCH_UNCONFIRMED}, `context.batchId` and `context.callCount`. It may
|
|
37174
|
+
* have landed — do not send it again; call again with `resumeBatchId` and `resumeBatchCallCount` to
|
|
37175
|
+
* finish it once it does.
|
|
37176
|
+
*
|
|
37177
|
+
* @returns `bridge()`'s `TxHashPair` plus the `approvalStrategy` that ran. Errors are `bridge()`'s
|
|
37178
|
+
* codes plus `APPROVE_FAILED` and `ALLOWANCE_CHECK_FAILED`.
|
|
37179
|
+
*/
|
|
37180
|
+
async bridgeWithApproval(_params) {
|
|
37181
|
+
const { params } = _params;
|
|
37182
|
+
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey, action: "bridgeWithApproval" };
|
|
37183
|
+
return this.config.analytics.trackResult(
|
|
37184
|
+
"bridge",
|
|
37185
|
+
"bridgeWithApproval",
|
|
37186
|
+
async () => {
|
|
37187
|
+
try {
|
|
37188
|
+
if (_params.resumeBatchId !== void 0) return await this.resumeAtomicBatch(_params, _params.resumeBatchId);
|
|
37189
|
+
const strategy = await this.getApprovalStrategy(_params);
|
|
37190
|
+
if (!strategy.ok) return strategy;
|
|
37191
|
+
const { result: created, approvalStrategy } = await runWithApproval({
|
|
37192
|
+
strategy: strategy.value,
|
|
37193
|
+
notRequired: () => this.createBridgeIntent(_params),
|
|
37194
|
+
atomicBatch: () => this.createBridgeIntentInAtomicBatch(_params),
|
|
37195
|
+
sequential: (afterRefusedBatch) => this.approveThenCreateBridgeIntent(_params, afterRefusedBatch),
|
|
37196
|
+
onBatchRefused: (error) => this.config.logger.warn("[bridgeWithApproval] wallet refused the atomic batch; approving separately", {
|
|
37197
|
+
error
|
|
37198
|
+
})
|
|
37199
|
+
});
|
|
37200
|
+
if (!created.ok) return created;
|
|
37201
|
+
const completed = await this.completeBridge(_params, created.value);
|
|
37202
|
+
if (!completed.ok) return completed;
|
|
37203
|
+
return { ok: true, value: { ...completed.value, approvalStrategy } };
|
|
37204
|
+
} catch (error) {
|
|
37205
|
+
if (isBridgeWithApprovalError(error)) return { ok: false, error };
|
|
37206
|
+
return { ok: false, error: executionFailed("bridge", error, baseCtx) };
|
|
37207
|
+
}
|
|
37208
|
+
},
|
|
37209
|
+
{
|
|
37210
|
+
start: () => ({
|
|
37211
|
+
srcChainKey: params.srcChainKey,
|
|
37212
|
+
dstChainKey: params.dstChainKey,
|
|
37213
|
+
srcToken: params.srcToken,
|
|
37214
|
+
dstToken: params.dstToken,
|
|
37215
|
+
amount: params.amount,
|
|
37216
|
+
srcAddress: params.srcAddress,
|
|
37217
|
+
recipient: params.recipient
|
|
37218
|
+
}),
|
|
37219
|
+
success: (value) => ({
|
|
37220
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
37221
|
+
dstChainTxHash: value.dstChainTxHash,
|
|
37222
|
+
approvalStrategy: value.approvalStrategy
|
|
37223
|
+
}),
|
|
37224
|
+
failure: (error) => ({ code: error.code })
|
|
37225
|
+
}
|
|
37226
|
+
);
|
|
37227
|
+
}
|
|
37228
|
+
/**
|
|
37229
|
+
* Approve + deposit as one EIP-5792 atomic batch, in broadcast order (`[reset?, approve, deposit]`),
|
|
37230
|
+
* then hand back the batch's transaction hash as the deposit tx, for {@link completeBridge}.
|
|
37231
|
+
*/
|
|
37232
|
+
async createBridgeIntentInAtomicBatch(_params) {
|
|
37233
|
+
const { params, walletProvider, extras, skipSimulation } = _params;
|
|
37234
|
+
const srcChainKey = params.srcChainKey;
|
|
37235
|
+
bridgeInvariant(
|
|
37236
|
+
isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider),
|
|
37237
|
+
"Atomic batches need an EVM spoke source and an EVM wallet provider"
|
|
37238
|
+
);
|
|
37239
|
+
const ctx = {
|
|
37240
|
+
srcChainKey,
|
|
37241
|
+
dstChainKey: params.dstChainKey,
|
|
37242
|
+
action: "bridgeWithApproval",
|
|
37243
|
+
approvalStrategy: "atomic-batch"
|
|
37244
|
+
};
|
|
37245
|
+
const [approval, created] = await Promise.all([
|
|
37246
|
+
this.buildApproveTxs({ params, raw: true }),
|
|
37247
|
+
this.createBridgeIntent({ params, extras, skipSimulation, raw: true })
|
|
37248
|
+
]);
|
|
37249
|
+
if (!approval.ok) return { ok: false, error: withErrorContext(approval.error, ctx) };
|
|
37250
|
+
if (!created.ok) return { ok: false, error: withErrorContext(created.error, ctx) };
|
|
37251
|
+
const { resetTx, approveTx } = approval.value;
|
|
37252
|
+
const depositTx = created.value.tx;
|
|
37253
|
+
const sent = await sendApprovalBatch({
|
|
37254
|
+
walletProvider,
|
|
37255
|
+
srcChainKey,
|
|
37256
|
+
txs: resetTx ? [resetTx, approveTx, depositTx] : [approveTx, depositTx],
|
|
37257
|
+
timeoutMs: approvalBatchWaitMs(_params.timeout),
|
|
37258
|
+
feature: "bridge",
|
|
37259
|
+
context: ctx
|
|
37260
|
+
});
|
|
37261
|
+
if (!sent.ok) return sent;
|
|
37262
|
+
return {
|
|
37263
|
+
ok: true,
|
|
37264
|
+
value: {
|
|
37265
|
+
tx: sent.value.txHash,
|
|
37266
|
+
relayData: created.value.relayData
|
|
37267
|
+
}
|
|
37268
|
+
};
|
|
37269
|
+
}
|
|
37270
|
+
/**
|
|
37271
|
+
* Finishes a batch an earlier call left {@link ATOMIC_BATCH_UNCONFIRMED}, without sending anything to
|
|
37272
|
+
* the wallet: waits for it again, then relays its deposit client-side and waits for the settlement packet.
|
|
37273
|
+
*/
|
|
37274
|
+
async resumeAtomicBatch(_params, batchId) {
|
|
37275
|
+
const { params, walletProvider } = _params;
|
|
37276
|
+
const srcChainKey = params.srcChainKey;
|
|
37277
|
+
bridgeInvariant(
|
|
37278
|
+
isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider) && canSendAtomicBatch(walletProvider),
|
|
37279
|
+
"Resuming an atomic batch needs an EVM spoke source and an EIP-5792 wallet provider"
|
|
37280
|
+
);
|
|
37281
|
+
const ctx = {
|
|
37282
|
+
srcChainKey,
|
|
37283
|
+
dstChainKey: params.dstChainKey,
|
|
37284
|
+
action: "bridgeWithApproval",
|
|
37285
|
+
approvalStrategy: "atomic-batch"
|
|
37286
|
+
};
|
|
37287
|
+
const timeoutMs = approvalBatchWaitMs(_params.timeout);
|
|
37288
|
+
const deposit = await confirmApprovalBatch({
|
|
37289
|
+
walletProvider,
|
|
37290
|
+
batchId,
|
|
37291
|
+
callCount: _params.resumeBatchCallCount,
|
|
37292
|
+
timeoutMs,
|
|
37293
|
+
feature: "bridge",
|
|
37294
|
+
context: ctx
|
|
37295
|
+
});
|
|
37296
|
+
if (!deposit.ok) return deposit;
|
|
37297
|
+
const srcTxHash = deposit.value.txHash;
|
|
37298
|
+
const txCtx = { ...ctx, srcTxHash };
|
|
37299
|
+
const packet = await relayTxAndWaitPacket({
|
|
37300
|
+
srcTxHash,
|
|
37301
|
+
chainKey: srcChainKey,
|
|
37302
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
37303
|
+
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
37304
|
+
});
|
|
37305
|
+
if (!packet.ok) return { ok: false, error: mapRelayFailure(packet.error, { feature: "bridge", ...txCtx }) };
|
|
37306
|
+
return {
|
|
37307
|
+
ok: true,
|
|
37308
|
+
value: { srcChainTxHash: srcTxHash, dstChainTxHash: packet.value.dst_tx_hash, approvalStrategy: "atomic-batch" }
|
|
37309
|
+
};
|
|
37310
|
+
}
|
|
37311
|
+
/** Approve, wait for the approval to confirm, then send the deposit — two or more signatures. */
|
|
37312
|
+
async approveThenCreateBridgeIntent(_params, validated = false) {
|
|
37313
|
+
const { params, extras, skipSimulation } = _params;
|
|
37314
|
+
const ctx = {
|
|
37315
|
+
srcChainKey: params.srcChainKey,
|
|
37316
|
+
dstChainKey: params.dstChainKey,
|
|
37317
|
+
action: "bridgeWithApproval",
|
|
37318
|
+
approvalStrategy: "sequential"
|
|
37319
|
+
};
|
|
37320
|
+
if (!validated) {
|
|
37321
|
+
const preflight = await this.createBridgeIntent({ params, extras, skipSimulation, raw: true });
|
|
37322
|
+
if (!preflight.ok) return { ok: false, error: withErrorContext(preflight.error, ctx) };
|
|
37323
|
+
}
|
|
37324
|
+
const approved = await this.approve(_params);
|
|
37325
|
+
if (!approved.ok) return { ok: false, error: withErrorContext(approved.error, ctx) };
|
|
37326
|
+
const confirmed = await confirmApproval({
|
|
37327
|
+
waitForTxReceipt: (receiptParams) => this.spoke.waitForTxReceipt(receiptParams),
|
|
37328
|
+
txHash: approved.value,
|
|
37329
|
+
chainKey: params.srcChainKey,
|
|
37330
|
+
feature: "bridge",
|
|
37331
|
+
context: ctx
|
|
37332
|
+
});
|
|
37333
|
+
if (!confirmed.ok) return confirmed;
|
|
37334
|
+
return this.createBridgeIntent(_params);
|
|
37335
|
+
}
|
|
37336
|
+
/**
|
|
37337
|
+
* Completes a bridge whose deposit tx is already broadcast: the backend submit-tx attempt when
|
|
37338
|
+
* `useBackendSubmitTx` is on, falling back to {@link fallbackBridgeSteps} on any non-success.
|
|
37339
|
+
* Shared by `bridge()` and `bridgeWithApproval()`, which differ only in how the deposit is sent.
|
|
37340
|
+
*/
|
|
37341
|
+
async completeBridge(_params, created) {
|
|
37342
|
+
const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
|
|
37343
|
+
if (this.useBackendSubmitTx) {
|
|
37344
|
+
const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
|
|
37345
|
+
if (submitted.ok) return submitted;
|
|
37346
|
+
this.config.logger.warn("[bridge] backend submit-tx did not complete; falling back to the client-side relay", {
|
|
37347
|
+
error: submitted.error
|
|
37348
|
+
});
|
|
37349
|
+
}
|
|
37350
|
+
return this.fallbackBridgeSteps(_params, created, timeoutMs);
|
|
37351
|
+
}
|
|
36094
37352
|
/**
|
|
36095
37353
|
* Client-side bridge completion (opt-out via `bridge.useBackendSubmitTx: false`): verify the broadcast
|
|
36096
37354
|
* spoke-deposit tx, then relay it to the hub and wait for the settlement packet. Extracted verbatim from
|
|
@@ -36103,13 +37361,18 @@ var BridgeService = class {
|
|
|
36103
37361
|
*/
|
|
36104
37362
|
async fallbackBridgeSteps(_params, created, timeoutMs) {
|
|
36105
37363
|
const { params } = _params;
|
|
36106
|
-
const
|
|
37364
|
+
const txCtx = {
|
|
37365
|
+
srcChainKey: params.srcChainKey,
|
|
37366
|
+
dstChainKey: params.dstChainKey,
|
|
37367
|
+
action: "bridge",
|
|
37368
|
+
srcTxHash: created.tx
|
|
37369
|
+
};
|
|
36107
37370
|
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
36108
37371
|
txHash: created.tx,
|
|
36109
37372
|
chainKey: params.srcChainKey
|
|
36110
37373
|
});
|
|
36111
37374
|
if (!verifyTxHashResult.ok) {
|
|
36112
|
-
return { ok: false, error: verifyFailed("bridge", verifyTxHashResult.error,
|
|
37375
|
+
return { ok: false, error: verifyFailed("bridge", verifyTxHashResult.error, txCtx) };
|
|
36113
37376
|
}
|
|
36114
37377
|
const packetResult = await relayTxAndWaitPacket({
|
|
36115
37378
|
srcTxHash: created.tx,
|
|
@@ -36125,15 +37388,7 @@ var BridgeService = class {
|
|
|
36125
37388
|
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
36126
37389
|
});
|
|
36127
37390
|
if (!packetResult.ok) {
|
|
36128
|
-
return {
|
|
36129
|
-
ok: false,
|
|
36130
|
-
error: mapRelayFailure(packetResult.error, {
|
|
36131
|
-
feature: "bridge",
|
|
36132
|
-
action: "bridge",
|
|
36133
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
36134
|
-
dstChainKey: baseCtx.dstChainKey
|
|
36135
|
-
})
|
|
36136
|
-
};
|
|
37391
|
+
return { ok: false, error: mapRelayFailure(packetResult.error, { feature: "bridge", ...txCtx }) };
|
|
36137
37392
|
}
|
|
36138
37393
|
return {
|
|
36139
37394
|
ok: true,
|
|
@@ -44680,6 +45935,9 @@ var isLeverageYieldPostExecutionError = isCodeMember(
|
|
|
44680
45935
|
LEVERAGE_YIELD_POST_EXECUTION_CODES
|
|
44681
45936
|
);
|
|
44682
45937
|
var isLeverageYieldSwapError = isCodeMember(LEVERAGE_YIELD_SWAP_CODES);
|
|
45938
|
+
var isVaultSwapWithApprovalError = isCodeMember(
|
|
45939
|
+
/* @__PURE__ */ new Set([...LEVERAGE_YIELD_SWAP_CODES, "APPROVE_FAILED", "ALLOWANCE_CHECK_FAILED"])
|
|
45940
|
+
);
|
|
44683
45941
|
var isLeverageYieldError = isCodeMember(LEVERAGE_YIELD_CODES);
|
|
44684
45942
|
|
|
44685
45943
|
// src/leverageYield/positionFunding.ts
|
|
@@ -44792,7 +46050,7 @@ var LeverageYieldService = class {
|
|
|
44792
46050
|
}
|
|
44793
46051
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
44794
46052
|
getVault(name) {
|
|
44795
|
-
return this.listVaults().find((
|
|
46053
|
+
return this.listVaults().find((v11) => v11.name === name);
|
|
44796
46054
|
}
|
|
44797
46055
|
/**
|
|
44798
46056
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -44800,7 +46058,7 @@ var LeverageYieldService = class {
|
|
|
44800
46058
|
*/
|
|
44801
46059
|
getVaultByAddress(address) {
|
|
44802
46060
|
const normalized = address.toLowerCase();
|
|
44803
|
-
return this.listVaults().find((
|
|
46061
|
+
return this.listVaults().find((v11) => v11.vault.toLowerCase() === normalized);
|
|
44804
46062
|
}
|
|
44805
46063
|
/**
|
|
44806
46064
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -45227,17 +46485,7 @@ var LeverageYieldService = class {
|
|
|
45227
46485
|
if (!createIntentResult.ok) {
|
|
45228
46486
|
return { ok: false, error: createIntentResult.error };
|
|
45229
46487
|
}
|
|
45230
|
-
|
|
45231
|
-
const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
|
|
45232
|
-
if (this.useBackendSubmitTx) {
|
|
45233
|
-
const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
|
|
45234
|
-
if (submitted.ok) return submitted;
|
|
45235
|
-
this.config.logger.warn(
|
|
45236
|
-
"[leverageYield] backend submit-tx did not complete; falling back to the client-side relay",
|
|
45237
|
-
{ error: submitted.error }
|
|
45238
|
-
);
|
|
45239
|
-
}
|
|
45240
|
-
return this.fallbackVaultSwapSteps(_params, created, timeoutMs);
|
|
46488
|
+
return await this.completeVaultSwap(_params, createIntentResult.value);
|
|
45241
46489
|
} catch (error) {
|
|
45242
46490
|
if (isLeverageYieldSwapError(error)) return { ok: false, error };
|
|
45243
46491
|
return {
|
|
@@ -45265,6 +46513,374 @@ var LeverageYieldService = class {
|
|
|
45265
46513
|
}
|
|
45266
46514
|
);
|
|
45267
46515
|
}
|
|
46516
|
+
/**
|
|
46517
|
+
* Which approval path {@link vaultSwapWithApproval} would take for a vault swap's source token, so a
|
|
46518
|
+
* UI can say up front whether a deposit costs one signature or two. Read-only; sends nothing. Not
|
|
46519
|
+
* the hub-side {@link approve} / {@link isAllowanceValid}, which cover depositing into a vault directly.
|
|
46520
|
+
*
|
|
46521
|
+
* A withdraw (`hubWalletSwap`) spends from the hub wallet and is always `'not-required'`. A deposit
|
|
46522
|
+
* approves the same spender a swap does. `'atomic-batch'` needs an EVM spoke source and a wallet
|
|
46523
|
+
* that reports EIP-5792 atomic support for that chain (`'supported'`, or `'ready'` unless
|
|
46524
|
+
* `allowAccountUpgrade: false`); the Sonic hub, Stellar and wallets without batch support get
|
|
46525
|
+
* `'sequential'`.
|
|
46526
|
+
*
|
|
46527
|
+
* @returns `ALLOWANCE_CHECK_FAILED` when the allowance read fails; otherwise the strategy.
|
|
46528
|
+
*/
|
|
46529
|
+
async getApprovalStrategy(_params) {
|
|
46530
|
+
const { params, walletProvider, hubWalletSwap, allowAccountUpgrade = true } = _params;
|
|
46531
|
+
if (hubWalletSwap) return { ok: true, value: "not-required" };
|
|
46532
|
+
const allowance = await this.isDepositAllowanceValid(params);
|
|
46533
|
+
if (!allowance.ok) {
|
|
46534
|
+
return {
|
|
46535
|
+
ok: false,
|
|
46536
|
+
error: allowanceCheckFailed("leverageYield", allowance.error, {
|
|
46537
|
+
srcChainKey: params.srcChainKey,
|
|
46538
|
+
dstChainKey: params.dstChainKey,
|
|
46539
|
+
action: "vaultSwapWithApproval"
|
|
46540
|
+
})
|
|
46541
|
+
};
|
|
46542
|
+
}
|
|
46543
|
+
if (allowance.value) return { ok: true, value: "not-required" };
|
|
46544
|
+
return {
|
|
46545
|
+
ok: true,
|
|
46546
|
+
value: await resolveApprovalStrategy({ srcChainKey: params.srcChainKey, walletProvider, allowAccountUpgrade })
|
|
46547
|
+
};
|
|
46548
|
+
}
|
|
46549
|
+
/**
|
|
46550
|
+
* {@link vaultSwap} with a deposit's source-token approval folded in. Picks a path with
|
|
46551
|
+
* {@link getApprovalStrategy}: none when the allowance already suffices (and never for a withdraw);
|
|
46552
|
+
* on an EIP-5792 wallet, approve and the deposit as **one atomic batch — one signature**; otherwise
|
|
46553
|
+
* approve, wait for it to confirm, then the deposit. Intent creation, the leverage-yield partner fee
|
|
46554
|
+
* and completion (backend submit-tx with its `operation`, then the client-side fallback) are exactly
|
|
46555
|
+
* `vaultSwap()`'s.
|
|
46556
|
+
*
|
|
46557
|
+
* A wallet that refuses the batch before signing anything falls back to the two-step path. A batch
|
|
46558
|
+
* the user saw is never retried as separate transactions:
|
|
46559
|
+
* - rejected → `USER_REJECTED`; a declined account upgrade (5750) adds `context.reason:
|
|
46560
|
+
* 'account-upgrade-declined'`, after which `allowAccountUpgrade: false` deposits without one;
|
|
46561
|
+
* - never included or fully reverted (EIP-5792 400 / 500) → `INTENT_CREATION_FAILED` with
|
|
46562
|
+
* `context.reason: 'atomic-batch-failed'`;
|
|
46563
|
+
* - anything else short of a confirmed deposit receipt → `TX_VERIFICATION_FAILED` with
|
|
46564
|
+
* `context.reason:` {@link ATOMIC_BATCH_UNCONFIRMED}, `context.batchId` and `context.callCount`. It may
|
|
46565
|
+
* have landed — do not send it again; call again with `resumeBatchId` and `resumeBatchCallCount` to
|
|
46566
|
+
* finish it once it does.
|
|
46567
|
+
*
|
|
46568
|
+
* @returns `vaultSwap()`'s response plus the `approvalStrategy` that ran. Errors are `vaultSwap()`'s
|
|
46569
|
+
* codes plus `APPROVE_FAILED` and `ALLOWANCE_CHECK_FAILED`.
|
|
46570
|
+
*/
|
|
46571
|
+
async vaultSwapWithApproval(_params) {
|
|
46572
|
+
const { params } = _params;
|
|
46573
|
+
const baseCtx = {
|
|
46574
|
+
srcChainKey: params.srcChainKey,
|
|
46575
|
+
dstChainKey: params.dstChainKey,
|
|
46576
|
+
action: "vaultSwapWithApproval"
|
|
46577
|
+
};
|
|
46578
|
+
return this.config.analytics.trackResult(
|
|
46579
|
+
"leverageYield",
|
|
46580
|
+
"vaultSwapWithApproval",
|
|
46581
|
+
async () => {
|
|
46582
|
+
try {
|
|
46583
|
+
if (_params.resumeBatchId !== void 0) return await this.resumeAtomicBatch(_params, _params.resumeBatchId);
|
|
46584
|
+
const strategy = await this.getApprovalStrategy(_params);
|
|
46585
|
+
if (!strategy.ok) return strategy;
|
|
46586
|
+
const { result: created, approvalStrategy } = await runWithApproval({
|
|
46587
|
+
strategy: strategy.value,
|
|
46588
|
+
notRequired: () => this.createVaultIntent(_params),
|
|
46589
|
+
atomicBatch: () => this.createVaultIntentInAtomicBatch(_params),
|
|
46590
|
+
sequential: (afterRefusedBatch) => this.approveThenCreateVaultIntent(_params, afterRefusedBatch),
|
|
46591
|
+
onBatchRefused: (error) => this.config.logger.warn("[vaultSwapWithApproval] wallet refused the atomic batch; approving separately", {
|
|
46592
|
+
error
|
|
46593
|
+
})
|
|
46594
|
+
});
|
|
46595
|
+
if (!created.ok) return created;
|
|
46596
|
+
const completed = await this.completeVaultSwap(_params, created.value);
|
|
46597
|
+
if (!completed.ok) return completed;
|
|
46598
|
+
return { ok: true, value: { ...completed.value, approvalStrategy } };
|
|
46599
|
+
} catch (error) {
|
|
46600
|
+
if (isVaultSwapWithApprovalError(error)) return { ok: false, error };
|
|
46601
|
+
return { ok: false, error: unknownFailed("leverageYield", error, baseCtx) };
|
|
46602
|
+
}
|
|
46603
|
+
},
|
|
46604
|
+
{
|
|
46605
|
+
start: () => ({
|
|
46606
|
+
srcChainKey: params.srcChainKey,
|
|
46607
|
+
dstChainKey: params.dstChainKey,
|
|
46608
|
+
srcAddress: params.srcAddress,
|
|
46609
|
+
dstAddress: params.dstAddress,
|
|
46610
|
+
inputToken: params.inputToken,
|
|
46611
|
+
outputToken: params.outputToken,
|
|
46612
|
+
inputAmount: params.inputAmount
|
|
46613
|
+
}),
|
|
46614
|
+
success: (value) => ({
|
|
46615
|
+
intentId: value.intent.intentId,
|
|
46616
|
+
srcTxHash: value.intentDeliveryInfo.srcTxHash,
|
|
46617
|
+
dstTxHash: value.intentDeliveryInfo.dstTxHash,
|
|
46618
|
+
approvalStrategy: value.approvalStrategy
|
|
46619
|
+
}),
|
|
46620
|
+
failure: (error) => ({ code: error.code })
|
|
46621
|
+
}
|
|
46622
|
+
);
|
|
46623
|
+
}
|
|
46624
|
+
/**
|
|
46625
|
+
* Approve + deposit as one EIP-5792 atomic batch, in broadcast order (`[reset?, approve, deposit]`),
|
|
46626
|
+
* then hand back the batch's transaction hash as the intent tx, for {@link completeVaultSwap}.
|
|
46627
|
+
*/
|
|
46628
|
+
async createVaultIntentInAtomicBatch(_params) {
|
|
46629
|
+
const { params, walletProvider, extras, skipSimulation, partnerFee } = _params;
|
|
46630
|
+
const srcChainKey = params.srcChainKey;
|
|
46631
|
+
leverageYieldInvariant(
|
|
46632
|
+
isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider),
|
|
46633
|
+
"Atomic batches need an EVM spoke source and an EVM wallet provider"
|
|
46634
|
+
);
|
|
46635
|
+
const ctx = {
|
|
46636
|
+
srcChainKey,
|
|
46637
|
+
dstChainKey: params.dstChainKey,
|
|
46638
|
+
action: "vaultSwapWithApproval",
|
|
46639
|
+
approvalStrategy: "atomic-batch"
|
|
46640
|
+
};
|
|
46641
|
+
const [approval, created] = await Promise.all([
|
|
46642
|
+
this.buildDepositApproveTxs(params, srcChainKey),
|
|
46643
|
+
this.createVaultIntent({ params, extras, skipSimulation, partnerFee, raw: true })
|
|
46644
|
+
]);
|
|
46645
|
+
if (!approval.ok) return { ok: false, error: approveFailed("leverageYield", approval.error, ctx) };
|
|
46646
|
+
if (!created.ok) return { ok: false, error: withErrorContext(created.error, ctx) };
|
|
46647
|
+
const { resetTx, approveTx } = approval.value;
|
|
46648
|
+
const depositTx = created.value.tx;
|
|
46649
|
+
const sent = await sendApprovalBatch({
|
|
46650
|
+
walletProvider,
|
|
46651
|
+
srcChainKey,
|
|
46652
|
+
txs: resetTx ? [resetTx, approveTx, depositTx] : [approveTx, depositTx],
|
|
46653
|
+
timeoutMs: approvalBatchWaitMs(_params.timeout),
|
|
46654
|
+
feature: "leverageYield",
|
|
46655
|
+
context: ctx
|
|
46656
|
+
});
|
|
46657
|
+
if (!sent.ok) return sent;
|
|
46658
|
+
return {
|
|
46659
|
+
ok: true,
|
|
46660
|
+
value: {
|
|
46661
|
+
tx: sent.value.txHash,
|
|
46662
|
+
intent: created.value.intent,
|
|
46663
|
+
relayData: created.value.relayData
|
|
46664
|
+
}
|
|
46665
|
+
};
|
|
46666
|
+
}
|
|
46667
|
+
/**
|
|
46668
|
+
* Finishes a batch an earlier call left {@link ATOMIC_BATCH_UNCONFIRMED}, without sending anything to
|
|
46669
|
+
* the wallet: waits for it again, relays its deposit client-side and notifies the solver. The
|
|
46670
|
+
* original intent went with that call, so it is read back from the hub tx the relay delivers.
|
|
46671
|
+
*/
|
|
46672
|
+
async resumeAtomicBatch(_params, batchId) {
|
|
46673
|
+
const { params, walletProvider } = _params;
|
|
46674
|
+
const srcChainKey = params.srcChainKey;
|
|
46675
|
+
leverageYieldInvariant(
|
|
46676
|
+
isEvmSpokeOnlyChainKeyType(srcChainKey) && isEvmWalletProviderType(walletProvider) && canSendAtomicBatch(walletProvider),
|
|
46677
|
+
"Resuming an atomic batch needs an EVM spoke source and an EIP-5792 wallet provider"
|
|
46678
|
+
);
|
|
46679
|
+
const ctx = {
|
|
46680
|
+
srcChainKey,
|
|
46681
|
+
dstChainKey: params.dstChainKey,
|
|
46682
|
+
action: "vaultSwapWithApproval",
|
|
46683
|
+
approvalStrategy: "atomic-batch"
|
|
46684
|
+
};
|
|
46685
|
+
const timeoutMs = approvalBatchWaitMs(_params.timeout);
|
|
46686
|
+
const deposit = await confirmApprovalBatch({
|
|
46687
|
+
walletProvider,
|
|
46688
|
+
batchId,
|
|
46689
|
+
callCount: _params.resumeBatchCallCount,
|
|
46690
|
+
timeoutMs,
|
|
46691
|
+
feature: "leverageYield",
|
|
46692
|
+
context: ctx
|
|
46693
|
+
});
|
|
46694
|
+
if (!deposit.ok) return deposit;
|
|
46695
|
+
const srcTxHash = deposit.value.txHash;
|
|
46696
|
+
const txCtx = { ...ctx, srcTxHash };
|
|
46697
|
+
const packet = await relayTxAndWaitPacket({
|
|
46698
|
+
srcTxHash,
|
|
46699
|
+
chainKey: srcChainKey,
|
|
46700
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
46701
|
+
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
46702
|
+
});
|
|
46703
|
+
if (!packet.ok) return { ok: false, error: mapRelayFailure(packet.error, { feature: "leverageYield", ...txCtx }) };
|
|
46704
|
+
const dstTxHash = packet.value.dst_tx_hash;
|
|
46705
|
+
let intent;
|
|
46706
|
+
try {
|
|
46707
|
+
intent = await EvmSolverService.getIntent(dstTxHash, this.config, this.hubProvider.publicClient);
|
|
46708
|
+
} catch (error) {
|
|
46709
|
+
return { ok: false, error: unknownFailed("leverageYield", error, { ...txCtx, dstTxHash }) };
|
|
46710
|
+
}
|
|
46711
|
+
const solved = await this.notifySolver({ intent_tx_hash: dstTxHash });
|
|
46712
|
+
if (!solved.ok) return { ok: false, error: withErrorContext(solved.error, { srcChainKey, srcTxHash, dstTxHash }) };
|
|
46713
|
+
return {
|
|
46714
|
+
ok: true,
|
|
46715
|
+
value: {
|
|
46716
|
+
solverExecutionResponse: solved.value,
|
|
46717
|
+
intent,
|
|
46718
|
+
intentDeliveryInfo: {
|
|
46719
|
+
srcChainKey,
|
|
46720
|
+
srcTxHash,
|
|
46721
|
+
srcAddress: params.srcAddress,
|
|
46722
|
+
dstChainKey: params.dstChainKey,
|
|
46723
|
+
dstTxHash,
|
|
46724
|
+
dstAddress: params.dstAddress
|
|
46725
|
+
},
|
|
46726
|
+
approvalStrategy: "atomic-batch"
|
|
46727
|
+
}
|
|
46728
|
+
};
|
|
46729
|
+
}
|
|
46730
|
+
/** Approve, wait for the approval to confirm, then send the deposit — two or more signatures. */
|
|
46731
|
+
async approveThenCreateVaultIntent(_params, validated = false) {
|
|
46732
|
+
const { params, extras, skipSimulation, partnerFee } = _params;
|
|
46733
|
+
const ctx = {
|
|
46734
|
+
srcChainKey: params.srcChainKey,
|
|
46735
|
+
dstChainKey: params.dstChainKey,
|
|
46736
|
+
action: "vaultSwapWithApproval",
|
|
46737
|
+
approvalStrategy: "sequential"
|
|
46738
|
+
};
|
|
46739
|
+
if (!validated) {
|
|
46740
|
+
const preflight = await this.createVaultIntent({
|
|
46741
|
+
params,
|
|
46742
|
+
extras,
|
|
46743
|
+
skipSimulation,
|
|
46744
|
+
partnerFee,
|
|
46745
|
+
raw: true
|
|
46746
|
+
});
|
|
46747
|
+
if (!preflight.ok) return { ok: false, error: withErrorContext(preflight.error, ctx) };
|
|
46748
|
+
}
|
|
46749
|
+
const approved = await this.approveDeposit(_params);
|
|
46750
|
+
if (!approved.ok) {
|
|
46751
|
+
return {
|
|
46752
|
+
ok: false,
|
|
46753
|
+
error: isLeverageYieldApproveError(approved.error) ? withErrorContext(approved.error, ctx) : approveFailed("leverageYield", approved.error, ctx)
|
|
46754
|
+
};
|
|
46755
|
+
}
|
|
46756
|
+
const confirmed = await confirmApproval({
|
|
46757
|
+
waitForTxReceipt: (receiptParams) => this.spoke.waitForTxReceipt(receiptParams),
|
|
46758
|
+
txHash: approved.value,
|
|
46759
|
+
chainKey: params.srcChainKey,
|
|
46760
|
+
feature: "leverageYield",
|
|
46761
|
+
context: ctx
|
|
46762
|
+
});
|
|
46763
|
+
if (!confirmed.ok) return confirmed;
|
|
46764
|
+
return this.createVaultIntent(_params);
|
|
46765
|
+
}
|
|
46766
|
+
/** Whether the deposit's source-token allowance already covers `inputAmount`. */
|
|
46767
|
+
async isDepositAllowanceValid(params) {
|
|
46768
|
+
try {
|
|
46769
|
+
const { srcChainKey } = params;
|
|
46770
|
+
if (isHubChainKeyType(srcChainKey)) {
|
|
46771
|
+
return await this.spoke.isAllowanceValid({
|
|
46772
|
+
srcChainKey,
|
|
46773
|
+
token: params.inputToken,
|
|
46774
|
+
amount: params.inputAmount,
|
|
46775
|
+
owner: params.srcAddress,
|
|
46776
|
+
spender: intentDepositSpender(this.config, srcChainKey)
|
|
46777
|
+
});
|
|
46778
|
+
}
|
|
46779
|
+
if (isEvmSpokeOnlyChainKeyType(srcChainKey)) {
|
|
46780
|
+
return await this.spoke.isAllowanceValid({
|
|
46781
|
+
srcChainKey,
|
|
46782
|
+
token: params.inputToken,
|
|
46783
|
+
amount: params.inputAmount,
|
|
46784
|
+
owner: params.srcAddress,
|
|
46785
|
+
spender: intentDepositSpender(this.config, srcChainKey)
|
|
46786
|
+
});
|
|
46787
|
+
}
|
|
46788
|
+
if (isStellarChainKeyType(srcChainKey)) {
|
|
46789
|
+
return await this.spoke.isAllowanceValid({
|
|
46790
|
+
srcChainKey,
|
|
46791
|
+
token: params.inputToken,
|
|
46792
|
+
amount: params.inputAmount,
|
|
46793
|
+
owner: params.srcAddress
|
|
46794
|
+
});
|
|
46795
|
+
}
|
|
46796
|
+
return { ok: true, value: true };
|
|
46797
|
+
} catch (error) {
|
|
46798
|
+
return { ok: false, error };
|
|
46799
|
+
}
|
|
46800
|
+
}
|
|
46801
|
+
/** The deposit's unsigned approval leg(s) on an EVM spoke, for the atomic batch. */
|
|
46802
|
+
async buildDepositApproveTxs(params, srcChainKey) {
|
|
46803
|
+
try {
|
|
46804
|
+
return await this.spoke.buildApproveTxs({
|
|
46805
|
+
srcChainKey,
|
|
46806
|
+
owner: params.srcAddress,
|
|
46807
|
+
token: params.inputToken,
|
|
46808
|
+
amount: params.inputAmount,
|
|
46809
|
+
spender: intentDepositSpender(this.config, srcChainKey),
|
|
46810
|
+
raw: true
|
|
46811
|
+
});
|
|
46812
|
+
} catch (error) {
|
|
46813
|
+
return { ok: false, error };
|
|
46814
|
+
}
|
|
46815
|
+
}
|
|
46816
|
+
/** Signs and sends the deposit's approval (hub, EVM spoke or Stellar); resolves at broadcast. */
|
|
46817
|
+
async approveDeposit(_params) {
|
|
46818
|
+
const { params, walletProvider } = _params;
|
|
46819
|
+
try {
|
|
46820
|
+
if (isHubChainKeyType(params.srcChainKey) || isEvmSpokeOnlyChainKeyType(params.srcChainKey)) {
|
|
46821
|
+
leverageYieldInvariant(
|
|
46822
|
+
isOptionalEvmWalletProviderType(walletProvider),
|
|
46823
|
+
"Invalid wallet provider. Expected Evm wallet provider."
|
|
46824
|
+
);
|
|
46825
|
+
const result = await this.spoke.approve({
|
|
46826
|
+
srcChainKey: params.srcChainKey,
|
|
46827
|
+
owner: params.srcAddress,
|
|
46828
|
+
token: params.inputToken,
|
|
46829
|
+
amount: params.inputAmount,
|
|
46830
|
+
spender: intentDepositSpender(this.config, params.srcChainKey),
|
|
46831
|
+
raw: false,
|
|
46832
|
+
walletProvider
|
|
46833
|
+
});
|
|
46834
|
+
if (!result.ok) return result;
|
|
46835
|
+
return {
|
|
46836
|
+
ok: true,
|
|
46837
|
+
value: result.value
|
|
46838
|
+
};
|
|
46839
|
+
}
|
|
46840
|
+
if (isStellarChainKeyType(params.srcChainKey)) {
|
|
46841
|
+
leverageYieldInvariant(
|
|
46842
|
+
isOptionalStellarWalletProviderType(walletProvider),
|
|
46843
|
+
"Invalid wallet provider. Expected Stellar wallet provider."
|
|
46844
|
+
);
|
|
46845
|
+
const result = await this.spoke.approve({
|
|
46846
|
+
srcChainKey: params.srcChainKey,
|
|
46847
|
+
token: params.inputToken,
|
|
46848
|
+
amount: params.inputAmount,
|
|
46849
|
+
owner: params.srcAddress,
|
|
46850
|
+
raw: false,
|
|
46851
|
+
walletProvider
|
|
46852
|
+
});
|
|
46853
|
+
if (!result.ok) return result;
|
|
46854
|
+
return {
|
|
46855
|
+
ok: true,
|
|
46856
|
+
value: result.value
|
|
46857
|
+
};
|
|
46858
|
+
}
|
|
46859
|
+
leverageYieldInvariant(false, "Approve only supported for hub (Sonic), EVM spokes, and Stellar", {
|
|
46860
|
+
srcChainKey: params.srcChainKey,
|
|
46861
|
+
field: "srcChainKey"
|
|
46862
|
+
});
|
|
46863
|
+
} catch (error) {
|
|
46864
|
+
return { ok: false, error };
|
|
46865
|
+
}
|
|
46866
|
+
}
|
|
46867
|
+
/**
|
|
46868
|
+
* Completes a vault swap whose intent tx is already broadcast: the backend submit-tx attempt when
|
|
46869
|
+
* `useBackendSubmitTx` is on, falling back to {@link fallbackVaultSwapSteps} on any non-success.
|
|
46870
|
+
* Shared by `vaultSwap()` and `vaultSwapWithApproval()`, which differ only in how the intent tx is sent.
|
|
46871
|
+
*/
|
|
46872
|
+
async completeVaultSwap(_params, created) {
|
|
46873
|
+
const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
|
|
46874
|
+
if (this.useBackendSubmitTx) {
|
|
46875
|
+
const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
|
|
46876
|
+
if (submitted.ok) return submitted;
|
|
46877
|
+
this.config.logger.warn(
|
|
46878
|
+
"[leverageYield] backend submit-tx did not complete; falling back to the client-side relay",
|
|
46879
|
+
{ error: submitted.error }
|
|
46880
|
+
);
|
|
46881
|
+
}
|
|
46882
|
+
return this.fallbackVaultSwapSteps(_params, created, timeoutMs);
|
|
46883
|
+
}
|
|
45268
46884
|
/**
|
|
45269
46885
|
* Client-side vault-swap completion (the opt-out path, and the fallback): verify the broadcast
|
|
45270
46886
|
* intent tx landed,
|
|
@@ -45276,14 +46892,19 @@ var LeverageYieldService = class {
|
|
|
45276
46892
|
async fallbackVaultSwapSteps(_params, created, timeoutMs) {
|
|
45277
46893
|
const { params } = _params;
|
|
45278
46894
|
const srcChainKey = params.srcChainKey;
|
|
45279
|
-
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "vaultSwap" };
|
|
45280
46895
|
const { tx: spokeTxHash, intent, relayData } = created;
|
|
46896
|
+
const txCtx = {
|
|
46897
|
+
srcChainKey,
|
|
46898
|
+
dstChainKey: params.dstChainKey,
|
|
46899
|
+
action: "vaultSwap",
|
|
46900
|
+
srcTxHash: spokeTxHash
|
|
46901
|
+
};
|
|
45281
46902
|
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
45282
46903
|
txHash: spokeTxHash,
|
|
45283
46904
|
chainKey: srcChainKey
|
|
45284
46905
|
});
|
|
45285
46906
|
if (!verifyTxHashResult.ok) {
|
|
45286
|
-
return { ok: false, error: verifyFailed("leverageYield", verifyTxHashResult.error,
|
|
46907
|
+
return { ok: false, error: verifyFailed("leverageYield", verifyTxHashResult.error, txCtx) };
|
|
45287
46908
|
}
|
|
45288
46909
|
let dstIntentTxHash;
|
|
45289
46910
|
if (isHubChainKeyType(srcChainKey)) {
|
|
@@ -45301,7 +46922,7 @@ var LeverageYieldService = class {
|
|
|
45301
46922
|
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
45302
46923
|
});
|
|
45303
46924
|
if (!packet.ok) {
|
|
45304
|
-
return { ok: false, error: mapRelayFailure(packet.error, { feature: "leverageYield", ...
|
|
46925
|
+
return { ok: false, error: mapRelayFailure(packet.error, { feature: "leverageYield", ...txCtx }) };
|
|
45305
46926
|
}
|
|
45306
46927
|
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
45307
46928
|
}
|
|
@@ -45309,7 +46930,14 @@ var LeverageYieldService = class {
|
|
|
45309
46930
|
intent_tx_hash: dstIntentTxHash
|
|
45310
46931
|
});
|
|
45311
46932
|
if (!postExecResult.ok) {
|
|
45312
|
-
return {
|
|
46933
|
+
return {
|
|
46934
|
+
ok: false,
|
|
46935
|
+
error: withErrorContext(postExecResult.error, {
|
|
46936
|
+
srcChainKey,
|
|
46937
|
+
srcTxHash: spokeTxHash,
|
|
46938
|
+
dstTxHash: dstIntentTxHash
|
|
46939
|
+
})
|
|
46940
|
+
};
|
|
45313
46941
|
}
|
|
45314
46942
|
return {
|
|
45315
46943
|
ok: true,
|
|
@@ -45510,17 +47138,25 @@ var LeverageYieldService = class {
|
|
|
45510
47138
|
* unreadable backend into an error, which is right for a polled read that would otherwise spend a
|
|
45511
47139
|
* budget on an unverified miss, and wrong to impose on a surface that already ships without it.
|
|
45512
47140
|
*
|
|
47141
|
+
* Every non-final answer is reconciled, an in-flight one included, and a journal cancel reads
|
|
47142
|
+
* `FAILED`: the solver can keep reporting a cancelled intent in flight, and nothing else ends that poll.
|
|
47143
|
+
*
|
|
45513
47144
|
* `timeoutMs` bounds the solver request alone. The reconcile carries its own
|
|
45514
47145
|
* {@link RECONCILE_TIMEOUT_MS}, so a bounded call can cost both.
|
|
45515
47146
|
*/
|
|
45516
47147
|
async resolveSolverStatus(request, timeoutMs, apiKey) {
|
|
45517
47148
|
const solverResult = await this.solverStatus(request, timeoutMs, apiKey);
|
|
45518
|
-
const
|
|
45519
|
-
if (
|
|
47149
|
+
const status = solverResult.ok ? solverResult.value.status : void 0;
|
|
47150
|
+
if (status === exports.SolverIntentStatusCode.SOLVED || status === exports.SolverIntentStatusCode.FAILED) return solverResult;
|
|
47151
|
+
const forgotten = !solverResult.ok || status === exports.SolverIntentStatusCode.NOT_FOUND;
|
|
45520
47152
|
const timeout = Math.min(RECONCILE_TIMEOUT_MS2, this.backendApi.requestTimeoutMs);
|
|
45521
47153
|
const intent = await this.backendApi.getIntentByTxHash(request.intent_tx_hash, { timeout, apiKey });
|
|
45522
|
-
const
|
|
45523
|
-
if (
|
|
47154
|
+
const outcome = intent.ok ? readIntentJournalOutcome(intent.value) : void 0;
|
|
47155
|
+
if (outcome?.kind === "solved") {
|
|
47156
|
+
return { ok: true, value: { status: exports.SolverIntentStatusCode.SOLVED, fill_tx_hash: outcome.fillTxHash } };
|
|
47157
|
+
}
|
|
47158
|
+
if (outcome?.kind === "cancelled") return { ok: true, value: { status: exports.SolverIntentStatusCode.FAILED } };
|
|
47159
|
+
if (!forgotten) return solverResult;
|
|
45524
47160
|
const backendAnswered = intent.ok || isSodaxError(intent.error) && intent.error.context?.status === 404;
|
|
45525
47161
|
if (solverResult.ok && !backendAnswered) {
|
|
45526
47162
|
return {
|
|
@@ -45539,9 +47175,14 @@ var LeverageYieldService = class {
|
|
|
45539
47175
|
* Reads a vault swap's status from its source-chain transaction — the identifier a caller always
|
|
45540
47176
|
* holds after `vaultSwap()`.
|
|
45541
47177
|
*
|
|
45542
|
-
* **Routes;
|
|
45543
|
-
* otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result
|
|
45544
|
-
* tagged with `source` (discriminate on it)
|
|
47178
|
+
* **Routes; defines no status of its own.** Returns the backend submit-tx record while it is in
|
|
47179
|
+
* play, otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result
|
|
47180
|
+
* is tagged with `source` (discriminate on it).
|
|
47181
|
+
*
|
|
47182
|
+
* The solver arm is reconciled against the backend's durable intent record: a settling fill reads
|
|
47183
|
+
* `SOLVED`, and a cancel with nothing filled reads `FAILED` even while the solver still reports the
|
|
47184
|
+
* intent in flight. Otherwise it carries the solver's answer unmodified, and the backend arm its
|
|
47185
|
+
* record unmodified.
|
|
45545
47186
|
*
|
|
45546
47187
|
* `sodax.api.leverageYield.getSubmitTxStatus` cannot answer for every vault swap. Sometimes there
|
|
45547
47188
|
* is no record — `useBackendSubmitTx: false`, or the submit was rejected. More often the record
|
|
@@ -45561,8 +47202,8 @@ var LeverageYieldService = class {
|
|
|
45561
47202
|
*
|
|
45562
47203
|
* @param params - `srcChainKey` and `srcTxHash` of the source-chain vault-swap transaction.
|
|
45563
47204
|
* @param config - Optional per-request override. Its `apiKey` reaches every keyed leg — the
|
|
45564
|
-
* submit-tx record read, the solver read, and the durable-intent read a solver
|
|
45565
|
-
* back to — so one override keys the whole call. The relay leg is unauthenticated and takes none.
|
|
47205
|
+
* submit-tx record read, the solver read, and the durable-intent read a non-final solver answer
|
|
47206
|
+
* falls back to — so one override keys the whole call. The relay leg is unauthenticated and takes none.
|
|
45566
47207
|
* @returns A `Result` containing a {@link DetailedLeverageYieldStatus}. Fails with `LOOKUP_FAILED`
|
|
45567
47208
|
* when no source can answer yet. Branch on `error.context.reason`:
|
|
45568
47209
|
* `DETAILED_STATUS_NOT_DELIVERED` is the ambiguous miss a caller should bound with a retry
|
|
@@ -47991,8 +49632,11 @@ Object.defineProperty(exports, "BridgeApiError", {
|
|
|
47991
49632
|
enumerable: true,
|
|
47992
49633
|
get: function () { return bridgeApi.BridgeApiError; }
|
|
47993
49634
|
});
|
|
49635
|
+
exports.ACCOUNT_UPGRADE_DECLINED = ACCOUNT_UPGRADE_DECLINED;
|
|
47994
49636
|
exports.ALLOWANCE_CHECK_CODES = ALLOWANCE_CHECK_CODES;
|
|
47995
49637
|
exports.APPROVE_CODES = APPROVE_CODES;
|
|
49638
|
+
exports.ATOMIC_BATCH_REFUSED = ATOMIC_BATCH_REFUSED;
|
|
49639
|
+
exports.ATOMIC_BATCH_UNCONFIRMED = ATOMIC_BATCH_UNCONFIRMED;
|
|
47996
49640
|
exports.AssetService = AssetService;
|
|
47997
49641
|
exports.BACKEND_API_BASE_PATH = BACKEND_API_BASE_PATH;
|
|
47998
49642
|
exports.BITCOIN_CHAIN_KEYS = BITCOIN_CHAIN_KEYS;
|
|
@@ -48189,6 +49833,7 @@ exports.clTickLensAbi = clTickLensAbi;
|
|
|
48189
49833
|
exports.classifySponsorError = classifySponsorError;
|
|
48190
49834
|
exports.concentratedLiquidityConfig = concentratedLiquidityConfig;
|
|
48191
49835
|
exports.configVersionFor = configVersionFor;
|
|
49836
|
+
exports.confirmApprovalBatch = confirmApprovalBatch;
|
|
48192
49837
|
exports.connectionAbi = connectionAbi;
|
|
48193
49838
|
exports.consoleLogger = consoleLogger;
|
|
48194
49839
|
exports.convertTransactionInstructionToRaw = convertTransactionInstructionToRaw;
|
|
@@ -48261,6 +49906,7 @@ exports.iconSupportedTokens = iconSupportedTokens;
|
|
|
48261
49906
|
exports.injectiveSupportedTokens = injectiveSupportedTokens;
|
|
48262
49907
|
exports.intentCreationFailed = intentCreationFailed;
|
|
48263
49908
|
exports.isApprovalSupportedChainKeyType = isApprovalSupportedChainKeyType;
|
|
49909
|
+
exports.isAtomicBatchRefusal = isAtomicBatchRefusal;
|
|
48264
49910
|
exports.isAuthFailure = isAuthFailure;
|
|
48265
49911
|
exports.isAuthStatus = isAuthStatus;
|
|
48266
49912
|
exports.isBackendHttpError = isBackendHttpError;
|
|
@@ -48274,6 +49920,7 @@ exports.isBridgeCreateIntentError = isBridgeCreateIntentError;
|
|
|
48274
49920
|
exports.isBridgeError = isBridgeError;
|
|
48275
49921
|
exports.isBridgeLookupError = isBridgeLookupError;
|
|
48276
49922
|
exports.isBridgeOrchestrationError = isBridgeOrchestrationError;
|
|
49923
|
+
exports.isBridgeWithApprovalError = isBridgeWithApprovalError;
|
|
48277
49924
|
exports.isCodeMember = isCodeMember;
|
|
48278
49925
|
exports.isDexApproveError = isDexApproveError;
|
|
48279
49926
|
exports.isDexCreateIntentError = isDexCreateIntentError;
|
|
@@ -48374,12 +50021,14 @@ exports.isSupportedBitcoinAddressType = isSupportedBitcoinAddressType;
|
|
|
48374
50021
|
exports.isSwapCreateIntentError = isSwapCreateIntentError;
|
|
48375
50022
|
exports.isSwapError = isSwapError;
|
|
48376
50023
|
exports.isSwapSupportedToken = isSwapSupportedToken;
|
|
50024
|
+
exports.isSwapWithApprovalError = isSwapWithApprovalError;
|
|
48377
50025
|
exports.isUndefinedOrValidWalletProviderForChainKey = isUndefinedOrValidWalletProviderForChainKey;
|
|
48378
50026
|
exports.isUnifiedBnUSDMigrateParams = isUnifiedBnUSDMigrateParams;
|
|
48379
50027
|
exports.isValidBitcoinAddress = isValidBitcoinAddress;
|
|
48380
50028
|
exports.isValidInjectiveAddress = isValidInjectiveAddress;
|
|
48381
50029
|
exports.isValidNearAccountId = isValidNearAccountId;
|
|
48382
50030
|
exports.isValidWalletProviderForChainKey = isValidWalletProviderForChainKey;
|
|
50031
|
+
exports.isVaultSwapWithApprovalError = isVaultSwapWithApprovalError;
|
|
48383
50032
|
exports.kaiaSupportedTokens = kaiaSupportedTokens;
|
|
48384
50033
|
exports.leverageYieldConfig = leverageYieldConfig;
|
|
48385
50034
|
exports.leverageYieldInvariant = leverageYieldInvariant;
|
|
@@ -48433,12 +50082,14 @@ exports.requestAddress = requestAddress;
|
|
|
48433
50082
|
exports.requestJsonRpc = requestJsonRpc;
|
|
48434
50083
|
exports.requestSigning = requestSigning;
|
|
48435
50084
|
exports.resolveAnalytics = resolveAnalytics;
|
|
50085
|
+
exports.resolveApprovalStrategy = resolveApprovalStrategy;
|
|
48436
50086
|
exports.resolveLogger = resolveLogger;
|
|
48437
50087
|
exports.resolvePositionFundingAddress = resolvePositionFundingAddress;
|
|
48438
50088
|
exports.retry = retry;
|
|
48439
50089
|
exports.reverseEncodeAddress = reverseEncodeAddress;
|
|
48440
50090
|
exports.robinhoodChain = robinhoodChain;
|
|
48441
50091
|
exports.robinhoodSupportedTokens = robinhoodSupportedTokens;
|
|
50092
|
+
exports.sendApprovalBatch = sendApprovalBatch;
|
|
48442
50093
|
exports.serializeAddressData = serializeAddressData;
|
|
48443
50094
|
exports.settleWalletBalances = settleWalletBalances;
|
|
48444
50095
|
exports.silentLogger = silentLogger;
|
|
@@ -48464,6 +50115,7 @@ exports.stataTokenFactoryAbi = stataTokenFactoryAbi;
|
|
|
48464
50115
|
exports.stellarSupportedTokens = stellarSupportedTokens;
|
|
48465
50116
|
exports.submitTransaction = submitTransaction;
|
|
48466
50117
|
exports.suiSupportedTokens = suiSupportedTokens;
|
|
50118
|
+
exports.summarizeSwapStatus = summarizeSwapStatus;
|
|
48467
50119
|
exports.supportedSpokeChains = supportedSpokeChains;
|
|
48468
50120
|
exports.supportedTokensByChain = supportedTokensByChain;
|
|
48469
50121
|
exports.swapExactInSingleParamsAbi = swapExactInSingleParamsAbi;
|
|
@@ -48491,4 +50143,5 @@ exports.waitForStacksTransaction = waitForStacksTransaction;
|
|
|
48491
50143
|
exports.waitForTransactionReceipt = waitForTransactionReceipt;
|
|
48492
50144
|
exports.waitUntilIntentExecuted = waitUntilIntentExecuted;
|
|
48493
50145
|
exports.walletFactoryAbi = walletFactoryAbi;
|
|
50146
|
+
exports.withErrorContext = withErrorContext;
|
|
48494
50147
|
exports.wrappedSonicAbi = wrappedSonicAbi;
|