@sodax/sdk 0.0.1-rc.30 → 0.0.1-rc.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -16,7 +16,7 @@ var rlp = require('rlp');
16
16
  var splToken = require('@solana/spl-token');
17
17
  var anchor = require('@coral-xyz/anchor');
18
18
  var BN = require('bn.js');
19
- var invariant11 = require('tiny-invariant');
19
+ var invariant12 = require('tiny-invariant');
20
20
  var BigNumber4 = require('bignumber.js');
21
21
 
22
22
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -43,7 +43,7 @@ var IconSdkRaw__namespace = /*#__PURE__*/_interopNamespace(IconSdkRaw);
43
43
  var rlp__namespace = /*#__PURE__*/_interopNamespace(rlp);
44
44
  var anchor__namespace = /*#__PURE__*/_interopNamespace(anchor);
45
45
  var BN__default = /*#__PURE__*/_interopDefault(BN);
46
- var invariant11__default = /*#__PURE__*/_interopDefault(invariant11);
46
+ var invariant12__default = /*#__PURE__*/_interopDefault(invariant12);
47
47
  var BigNumber4__default = /*#__PURE__*/_interopDefault(BigNumber4);
48
48
 
49
49
  // src/abis/asset-manager.abi.ts
@@ -6133,7 +6133,7 @@ async function waitForTransactionReceipt(hash, provider) {
6133
6133
  return provider.waitForTransactionReceipt(hash);
6134
6134
  }
6135
6135
  var DEFAULT_MAX_RETRY = 3;
6136
- var DEFAULT_RELAY_TX_TIMEOUT = 6e4;
6136
+ var DEFAULT_RELAY_TX_TIMEOUT = 12e4;
6137
6137
  var DEFAULT_RETRY_DELAY_MS = 2e3;
6138
6138
  var ICON_TX_RESULT_WAIT_MAX_RETRY = 10;
6139
6139
  var MAX_UINT256 = (1n << 256n) - 1n;
@@ -6215,6 +6215,155 @@ function getEvmViemChain(id) {
6215
6215
  throw new Error(`Unsupported EVM chain ID: ${id}`);
6216
6216
  }
6217
6217
  }
6218
+ var HubVaultSymbols = [
6219
+ "sodaAVAX",
6220
+ "sodaBNB",
6221
+ "sodaETH",
6222
+ "sodaBTC",
6223
+ "sodaSUI",
6224
+ "sodaINJ",
6225
+ "sodaXLM",
6226
+ "sodaSOL",
6227
+ "sodaSODA",
6228
+ "sodaUSDT",
6229
+ "sodaUSDC",
6230
+ "bnUSD",
6231
+ "sodaPOL",
6232
+ "sodaNIBI",
6233
+ "sodaS",
6234
+ "IbnUSD"
6235
+ ];
6236
+ var SodaTokens = {
6237
+ sodaBNB: {
6238
+ symbol: "sodaBNB",
6239
+ name: "Soda BNB",
6240
+ decimals: 18,
6241
+ address: "0x40Cd41b35DB9e5109ae7E54b44De8625dB320E6b",
6242
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6243
+ },
6244
+ sodaAVAX: {
6245
+ symbol: "sodaAVAX",
6246
+ name: "Soda AVAX",
6247
+ decimals: 18,
6248
+ address: "0x14238D267557E9d799016ad635B53CD15935d290",
6249
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6250
+ },
6251
+ sodaETH: {
6252
+ symbol: "sodaETH",
6253
+ name: "Soda ETH",
6254
+ decimals: 18,
6255
+ address: "0x4effB5813271699683C25c734F4daBc45B363709",
6256
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6257
+ },
6258
+ sodaBTC: {
6259
+ symbol: "sodaBTC",
6260
+ name: "Soda BTC",
6261
+ decimals: 18,
6262
+ address: "0x7A1A5555842Ad2D0eD274d09b5c4406a95799D5d",
6263
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6264
+ },
6265
+ sodaSOL: {
6266
+ symbol: "sodaSOL",
6267
+ name: "Soda SOL",
6268
+ decimals: 18,
6269
+ address: "0xdEa692287E2cE8Cb08FA52917Be0F16b1DACDC87",
6270
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6271
+ },
6272
+ sodaXLM: {
6273
+ symbol: "sodaXLM",
6274
+ name: "Soda XLM",
6275
+ decimals: 18,
6276
+ address: "0x6BC8C37cba91F76E68C9e6d689A9C21E4d32079B",
6277
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6278
+ },
6279
+ sodaINJ: {
6280
+ symbol: "sodaINJ",
6281
+ name: "Soda INJ",
6282
+ decimals: 18,
6283
+ address: "0x1f22279C89B213944b7Ea41daCB0a868DdCDFd13",
6284
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6285
+ },
6286
+ sodaNIBI: {
6287
+ symbol: "sodaNIBI",
6288
+ name: "Soda NIBI",
6289
+ decimals: 18,
6290
+ address: "0xc6c85287a8b173A509C2F198bB719A8a5a2d0C68",
6291
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6292
+ },
6293
+ sodaSUI: {
6294
+ symbol: "sodaSUI",
6295
+ name: "Soda SUI",
6296
+ decimals: 18,
6297
+ address: "0xdc5B4b00F98347E95b9F94911213DAB4C687e1e3",
6298
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6299
+ },
6300
+ bnUSD: {
6301
+ symbol: "bnUSD",
6302
+ name: "Balanced Dollar",
6303
+ decimals: 18,
6304
+ address: "0xE801CA34E19aBCbFeA12025378D19c4FBE250131",
6305
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6306
+ },
6307
+ sodaUSDC: {
6308
+ symbol: "sodaUSDC",
6309
+ name: "Soda USDC",
6310
+ decimals: 18,
6311
+ address: "0xAbbb91c0617090F0028BDC27597Cd0D038F3A833",
6312
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6313
+ },
6314
+ sodaUSDT: {
6315
+ symbol: "sodaUSDT",
6316
+ name: "Soda USDT",
6317
+ decimals: 18,
6318
+ address: "0xbDf1F453FCB61424011BBDDCB96cFDB30f3Fe876",
6319
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6320
+ },
6321
+ IbnUSD: {
6322
+ symbol: "IbnUSD",
6323
+ name: "ICON bnUSD (Migration)",
6324
+ decimals: 18,
6325
+ address: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51",
6326
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6327
+ },
6328
+ sodaS: {
6329
+ symbol: "sodaS",
6330
+ name: "Soda S",
6331
+ decimals: 18,
6332
+ address: "0x62ecc3Eeb80a162c57624B3fF80313FE69f5203e",
6333
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6334
+ },
6335
+ sodaPOL: {
6336
+ symbol: "sodaPOL",
6337
+ name: "Soda POL",
6338
+ decimals: 18,
6339
+ address: "0x208ED38f4783328aA9eBFeC360D32e7520A9B779",
6340
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6341
+ },
6342
+ sodaSODA: {
6343
+ symbol: "sodaSODA",
6344
+ name: "Soda SODA",
6345
+ decimals: 18,
6346
+ address: "0x21685E341DE7844135329914Be6Bd8D16982d834",
6347
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6348
+ }
6349
+ };
6350
+ var SodaTokensAsHubAssets = Object.values(SodaTokens).reduce(
6351
+ (acc, token) => {
6352
+ acc[token.address] = {
6353
+ asset: token.address,
6354
+ decimal: token.decimals,
6355
+ symbol: token.symbol,
6356
+ name: token.name,
6357
+ vault: token.address
6358
+ };
6359
+ return acc;
6360
+ },
6361
+ {}
6362
+ );
6363
+ var SodaVaultTokensSet = new Set(Object.values(SodaTokens).map((token) => token.address.toLowerCase()));
6364
+ var isSodaVaultToken = (address) => {
6365
+ return SodaVaultTokensSet.has(address.toLowerCase());
6366
+ };
6218
6367
  var hubChainConfig = {
6219
6368
  [types.SONIC_MAINNET_CHAIN_ID]: {
6220
6369
  chain: {
@@ -6254,44 +6403,45 @@ var spokeChainConfig = {
6254
6403
  symbol: "S",
6255
6404
  name: "Sonic",
6256
6405
  decimals: 18,
6257
- address: "0x0000000000000000000000000000000000000000"
6258
- },
6259
- bnUSD: {
6260
- symbol: "bnUSD",
6261
- name: "bnUSD",
6262
- decimals: 18,
6263
- address: "0xE801CA34E19aBCbFeA12025378D19c4FBE250131"
6406
+ address: "0x0000000000000000000000000000000000000000",
6407
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6264
6408
  },
6265
6409
  WETH: {
6266
6410
  symbol: "WETH",
6267
6411
  name: "Wrapped Ether",
6268
6412
  decimals: 18,
6269
- address: "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b"
6413
+ address: "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b",
6414
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6270
6415
  },
6271
6416
  USDC: {
6272
6417
  symbol: "USDC",
6273
6418
  name: "USD Coin",
6274
6419
  decimals: 6,
6275
- address: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894"
6420
+ address: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
6421
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6276
6422
  },
6277
6423
  USDT: {
6278
6424
  symbol: "USDT",
6279
6425
  name: "Tether USD",
6280
6426
  decimals: 6,
6281
- address: "0x6047828dc181963ba44974801FF68e538dA5eaF9"
6427
+ address: "0x6047828dc181963ba44974801FF68e538dA5eaF9",
6428
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6282
6429
  },
6283
6430
  wS: {
6284
6431
  symbol: "wS",
6285
6432
  name: "Wrapped Sonic",
6286
6433
  decimals: 18,
6287
- address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
6434
+ address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
6435
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6288
6436
  },
6289
6437
  SODA: {
6290
6438
  symbol: "SODA",
6291
6439
  name: "SODAX",
6292
6440
  decimals: 18,
6293
- address: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963"
6294
- }
6441
+ address: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
6442
+ xChainId: types.SONIC_MAINNET_CHAIN_ID
6443
+ },
6444
+ ...SodaTokens
6295
6445
  }
6296
6446
  },
6297
6447
  [types.SOLANA_MAINNET_CHAIN_ID]: {
@@ -6310,19 +6460,22 @@ var spokeChainConfig = {
6310
6460
  symbol: "SOL",
6311
6461
  name: "Solana",
6312
6462
  decimals: 9,
6313
- address: "11111111111111111111111111111111"
6463
+ address: "11111111111111111111111111111111",
6464
+ xChainId: types.SOLANA_MAINNET_CHAIN_ID
6314
6465
  },
6315
6466
  bnUSD: {
6316
6467
  symbol: "bnUSD",
6317
6468
  name: "bnUSD",
6318
6469
  decimals: 9,
6319
- address: "3rSPCLNEF7Quw4wX8S1NyKivELoyij8eYA2gJwBgt4V5"
6470
+ address: "3rSPCLNEF7Quw4wX8S1NyKivELoyij8eYA2gJwBgt4V5",
6471
+ xChainId: types.SOLANA_MAINNET_CHAIN_ID
6320
6472
  },
6321
6473
  USDC: {
6322
6474
  symbol: "USDC",
6323
6475
  name: "USD Coin",
6324
6476
  decimals: 6,
6325
- address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
6477
+ address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
6478
+ xChainId: types.SOLANA_MAINNET_CHAIN_ID
6326
6479
  }
6327
6480
  },
6328
6481
  gasPrice: "500000",
@@ -6346,25 +6499,29 @@ var spokeChainConfig = {
6346
6499
  symbol: "AVAX",
6347
6500
  name: "Avalanche",
6348
6501
  decimals: 18,
6349
- address: "0x0000000000000000000000000000000000000000"
6502
+ address: "0x0000000000000000000000000000000000000000",
6503
+ xChainId: types.AVALANCHE_MAINNET_CHAIN_ID
6350
6504
  },
6351
6505
  bnUSD: {
6352
6506
  symbol: "bnUSD",
6353
6507
  name: "bnUSD",
6354
6508
  decimals: 18,
6355
- address: "0x6958a4CBFe11406E2a1c1d3a71A1971aD8B3b92F"
6509
+ address: "0x6958a4CBFe11406E2a1c1d3a71A1971aD8B3b92F",
6510
+ xChainId: types.AVALANCHE_MAINNET_CHAIN_ID
6356
6511
  },
6357
6512
  USDT: {
6358
6513
  symbol: "USDT",
6359
6514
  name: "Tether USD",
6360
6515
  decimals: 6,
6361
- address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"
6516
+ address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
6517
+ xChainId: types.AVALANCHE_MAINNET_CHAIN_ID
6362
6518
  },
6363
6519
  USDC: {
6364
6520
  symbol: "USDC",
6365
6521
  name: "USD Coin",
6366
6522
  decimals: 6,
6367
- address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"
6523
+ address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
6524
+ xChainId: types.AVALANCHE_MAINNET_CHAIN_ID
6368
6525
  }
6369
6526
  }
6370
6527
  },
@@ -6385,13 +6542,15 @@ var spokeChainConfig = {
6385
6542
  symbol: "NIBI",
6386
6543
  name: "Nibiru",
6387
6544
  decimals: 6,
6388
- address: "0x0000000000000000000000000000000000000000"
6545
+ address: "0x0000000000000000000000000000000000000000",
6546
+ xChainId: types.NIBIRU_MAINNET_CHAIN_ID
6389
6547
  },
6390
6548
  bnUSD: {
6391
6549
  symbol: "bnUSD",
6392
6550
  name: "bnUSD",
6393
6551
  decimals: 18,
6394
- address: "0x043fb7e23350Dd5b77dE5E228B528763DEcb9131"
6552
+ address: "0x043fb7e23350Dd5b77dE5E228B528763DEcb9131",
6553
+ xChainId: types.NIBIRU_MAINNET_CHAIN_ID
6395
6554
  }
6396
6555
  }
6397
6556
  },
@@ -6412,49 +6571,57 @@ var spokeChainConfig = {
6412
6571
  symbol: "ETH",
6413
6572
  name: "Ethereum",
6414
6573
  decimals: 18,
6415
- address: "0x0000000000000000000000000000000000000000"
6574
+ address: "0x0000000000000000000000000000000000000000",
6575
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6416
6576
  },
6417
6577
  bnUSD: {
6418
6578
  symbol: "bnUSD",
6419
6579
  name: "bnUSD",
6420
6580
  decimals: 18,
6421
- address: "0xA256dd181C3f6E5eC68C6869f5D50a712d47212e"
6581
+ address: "0xA256dd181C3f6E5eC68C6869f5D50a712d47212e",
6582
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6422
6583
  },
6423
6584
  wstETH: {
6424
6585
  symbol: "wstETH",
6425
6586
  name: "Wrapped stETH",
6426
6587
  decimals: 18,
6427
- address: "0x5979D7b546E38E414F7E9822514be443A4800529"
6588
+ address: "0x5979D7b546E38E414F7E9822514be443A4800529",
6589
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6428
6590
  },
6429
6591
  weETH: {
6430
6592
  symbol: "weETH",
6431
6593
  name: "Wrapped eETH",
6432
6594
  decimals: 18,
6433
- address: "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe"
6595
+ address: "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe",
6596
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6434
6597
  },
6435
6598
  tBTC: {
6436
6599
  symbol: "tBTC",
6437
6600
  name: "Arbitrum tBTC v2",
6438
6601
  decimals: 18,
6439
- address: "0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40"
6602
+ address: "0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40",
6603
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6440
6604
  },
6441
6605
  WBTC: {
6442
6606
  symbol: "WBTC",
6443
6607
  name: "Wrapped BTC",
6444
6608
  decimals: 8,
6445
- address: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f"
6609
+ address: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
6610
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6446
6611
  },
6447
6612
  USDC: {
6448
6613
  symbol: "USDC",
6449
6614
  name: "USD Coin (USDC)",
6450
6615
  decimals: 6,
6451
- address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
6616
+ address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
6617
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6452
6618
  },
6453
6619
  USDT: {
6454
6620
  symbol: "USDT",
6455
6621
  name: "TetherToken",
6456
6622
  decimals: 6,
6457
- address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
6623
+ address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
6624
+ xChainId: types.ARBITRUM_MAINNET_CHAIN_ID
6458
6625
  }
6459
6626
  }
6460
6627
  },
@@ -6475,37 +6642,43 @@ var spokeChainConfig = {
6475
6642
  symbol: "ETH",
6476
6643
  name: "Ethereum",
6477
6644
  decimals: 18,
6478
- address: "0x0000000000000000000000000000000000000000"
6645
+ address: "0x0000000000000000000000000000000000000000",
6646
+ xChainId: types.BASE_MAINNET_CHAIN_ID
6479
6647
  },
6480
6648
  bnUSD: {
6481
6649
  symbol: "bnUSD",
6482
6650
  name: "bnUSD",
6483
6651
  decimals: 18,
6484
- address: "0xAcfab3F31C0a18559D78556BBf297EC29c6cf8aa"
6652
+ address: "0xAcfab3F31C0a18559D78556BBf297EC29c6cf8aa",
6653
+ xChainId: types.BASE_MAINNET_CHAIN_ID
6485
6654
  },
6486
6655
  weETH: {
6487
6656
  symbol: "weETH",
6488
6657
  name: "Wrapped eETH",
6489
6658
  decimals: 18,
6490
- address: "0x04c0599ae5a44757c0af6f9ec3b93da8976c150a"
6659
+ address: "0x04c0599ae5a44757c0af6f9ec3b93da8976c150a",
6660
+ xChainId: types.BASE_MAINNET_CHAIN_ID
6491
6661
  },
6492
6662
  USDC: {
6493
6663
  symbol: "USDC",
6494
6664
  name: "USD Coin",
6495
6665
  decimals: 6,
6496
- address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
6666
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
6667
+ xChainId: types.BASE_MAINNET_CHAIN_ID
6497
6668
  },
6498
6669
  wstETH: {
6499
6670
  symbol: "wstETH",
6500
6671
  name: "Wrapped stETH",
6501
6672
  decimals: 18,
6502
- address: "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452"
6673
+ address: "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452",
6674
+ xChainId: types.BASE_MAINNET_CHAIN_ID
6503
6675
  },
6504
6676
  cbBTC: {
6505
6677
  symbol: "cbBTC",
6506
6678
  name: "Coinbase Wrapped BTC",
6507
6679
  decimals: 8,
6508
- address: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf"
6680
+ address: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
6681
+ xChainId: types.BASE_MAINNET_CHAIN_ID
6509
6682
  }
6510
6683
  }
6511
6684
  },
@@ -6526,37 +6699,43 @@ var spokeChainConfig = {
6526
6699
  symbol: "ETH",
6527
6700
  name: "Ethereum",
6528
6701
  decimals: 18,
6529
- address: "0x0000000000000000000000000000000000000000"
6702
+ address: "0x0000000000000000000000000000000000000000",
6703
+ xChainId: types.OPTIMISM_MAINNET_CHAIN_ID
6530
6704
  },
6531
6705
  bnUSD: {
6532
6706
  symbol: "bnUSD",
6533
6707
  name: "bnUSD",
6534
6708
  decimals: 18,
6535
- address: "0xF4f7dC27c17470a26d0de9039Cf0EA5045F100E8"
6709
+ address: "0xF4f7dC27c17470a26d0de9039Cf0EA5045F100E8",
6710
+ xChainId: types.OPTIMISM_MAINNET_CHAIN_ID
6536
6711
  },
6537
6712
  USDC: {
6538
6713
  symbol: "USDC",
6539
6714
  name: "USD Coin",
6540
6715
  decimals: 6,
6541
- address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"
6716
+ address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
6717
+ xChainId: types.OPTIMISM_MAINNET_CHAIN_ID
6542
6718
  },
6543
6719
  wstETH: {
6544
6720
  symbol: "wstETH",
6545
6721
  name: "Wrapped stETH",
6546
6722
  decimals: 18,
6547
- address: "0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb"
6723
+ address: "0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb",
6724
+ xChainId: types.OPTIMISM_MAINNET_CHAIN_ID
6548
6725
  },
6549
6726
  weETH: {
6550
6727
  symbol: "weETH",
6551
6728
  name: "Wrapped eETH",
6552
6729
  decimals: 18,
6553
- address: "0x5A7fACB970D094B6C7FF1df0eA68D99E6e73CBFF"
6730
+ address: "0x5A7fACB970D094B6C7FF1df0eA68D99E6e73CBFF",
6731
+ xChainId: types.OPTIMISM_MAINNET_CHAIN_ID
6554
6732
  },
6555
6733
  USDT: {
6556
6734
  symbol: "USDT",
6557
6735
  name: "Tether USD",
6558
6736
  decimals: 6,
6559
- address: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"
6737
+ address: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",
6738
+ xChainId: types.OPTIMISM_MAINNET_CHAIN_ID
6560
6739
  }
6561
6740
  }
6562
6741
  },
@@ -6577,31 +6756,36 @@ var spokeChainConfig = {
6577
6756
  symbol: "BNB",
6578
6757
  name: "BNB",
6579
6758
  decimals: 18,
6580
- address: "0x0000000000000000000000000000000000000000"
6759
+ address: "0x0000000000000000000000000000000000000000",
6760
+ xChainId: types.BSC_MAINNET_CHAIN_ID
6581
6761
  },
6582
6762
  bnUSD: {
6583
6763
  symbol: "bnUSD",
6584
6764
  name: "bnUSD",
6585
6765
  decimals: 18,
6586
- address: "0x8428FedC020737a5A2291F46cB1B80613eD71638"
6766
+ address: "0x8428FedC020737a5A2291F46cB1B80613eD71638",
6767
+ xChainId: types.BSC_MAINNET_CHAIN_ID
6587
6768
  },
6588
6769
  ETHB: {
6589
6770
  symbol: "ETHB",
6590
6771
  name: "Ethereum BSC",
6591
6772
  decimals: 18,
6592
- address: "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
6773
+ address: "0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
6774
+ xChainId: types.BSC_MAINNET_CHAIN_ID
6593
6775
  },
6594
6776
  BTCB: {
6595
6777
  symbol: "BTCB",
6596
6778
  name: "Bitcoin BSC",
6597
6779
  decimals: 18,
6598
- address: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"
6780
+ address: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",
6781
+ xChainId: types.BSC_MAINNET_CHAIN_ID
6599
6782
  },
6600
6783
  USDC: {
6601
6784
  symbol: "USDC",
6602
6785
  name: "USD Coin",
6603
6786
  decimals: 18,
6604
- address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"
6787
+ address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
6788
+ xChainId: types.BSC_MAINNET_CHAIN_ID
6605
6789
  }
6606
6790
  }
6607
6791
  },
@@ -6622,19 +6806,22 @@ var spokeChainConfig = {
6622
6806
  symbol: "POL",
6623
6807
  name: "Polygon",
6624
6808
  decimals: 18,
6625
- address: "0x0000000000000000000000000000000000000000"
6809
+ address: "0x0000000000000000000000000000000000000000",
6810
+ xChainId: types.POLYGON_MAINNET_CHAIN_ID
6626
6811
  },
6627
6812
  bnUSD: {
6628
6813
  symbol: "bnUSD",
6629
6814
  name: "bnUSD",
6630
6815
  decimals: 18,
6631
- address: "0x39E77f86C1B1f3fbAb362A82b49D2E86C09659B4"
6816
+ address: "0x39E77f86C1B1f3fbAb362A82b49D2E86C09659B4",
6817
+ xChainId: types.POLYGON_MAINNET_CHAIN_ID
6632
6818
  },
6633
6819
  USDC: {
6634
6820
  symbol: "USDC",
6635
6821
  name: "USD Coin",
6636
6822
  decimals: 6,
6637
- address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
6823
+ address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
6824
+ xChainId: types.POLYGON_MAINNET_CHAIN_ID
6638
6825
  }
6639
6826
  }
6640
6827
  },
@@ -6659,19 +6846,22 @@ var spokeChainConfig = {
6659
6846
  symbol: "INJ",
6660
6847
  name: "Injective",
6661
6848
  decimals: 18,
6662
- address: "inj"
6849
+ address: "inj",
6850
+ xChainId: types.INJECTIVE_MAINNET_CHAIN_ID
6663
6851
  },
6664
6852
  bnUSD: {
6665
6853
  symbol: "bnUSD",
6666
6854
  name: "bnUSD",
6667
6855
  decimals: 18,
6668
- address: "factory/inj1d036ftaatxpkqsu9hja8r24rv3v33chz3appxp/bnUSD"
6856
+ address: "factory/inj1d036ftaatxpkqsu9hja8r24rv3v33chz3appxp/bnUSD",
6857
+ xChainId: types.INJECTIVE_MAINNET_CHAIN_ID
6669
6858
  },
6670
6859
  USDC: {
6671
6860
  symbol: "USDC",
6672
6861
  name: "USD Coin",
6673
6862
  decimals: 6,
6674
- address: "ibc/2CBC2EA121AE42563B08028466F37B600F2D7D4282342DE938283CC3FB2BC00E"
6863
+ address: "ibc/2CBC2EA121AE42563B08028466F37B600F2D7D4282342DE938283CC3FB2BC00E",
6864
+ xChainId: types.INJECTIVE_MAINNET_CHAIN_ID
6675
6865
  }
6676
6866
  },
6677
6867
  gasPrice: "500000000inj",
@@ -6694,25 +6884,29 @@ var spokeChainConfig = {
6694
6884
  symbol: "bnUSD",
6695
6885
  name: "bnUSD",
6696
6886
  decimals: 7,
6697
- address: "CD6YBFFWMU2UJHX2NGRJ7RN76IJVTCC7MRA46DUBXNB7E6W7H7JRJ2CX"
6887
+ address: "CD6YBFFWMU2UJHX2NGRJ7RN76IJVTCC7MRA46DUBXNB7E6W7H7JRJ2CX",
6888
+ xChainId: types.STELLAR_MAINNET_CHAIN_ID
6698
6889
  },
6699
6890
  XLM: {
6700
6891
  symbol: "XLM",
6701
6892
  name: "Stellar Lumens",
6702
6893
  decimals: 7,
6703
- address: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA"
6894
+ address: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
6895
+ xChainId: types.STELLAR_MAINNET_CHAIN_ID
6704
6896
  },
6705
6897
  USDC: {
6706
6898
  symbol: "USDC",
6707
6899
  name: "USD Coin",
6708
6900
  decimals: 7,
6709
- address: "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75"
6901
+ address: "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
6902
+ xChainId: types.STELLAR_MAINNET_CHAIN_ID
6710
6903
  },
6711
6904
  legacybnUSD: {
6712
- symbol: "bnUSD",
6905
+ symbol: "bnUSD (legacy)",
6713
6906
  name: "legacybnUSD",
6714
6907
  decimals: 18,
6715
- address: "CCT4ZYIYZ3TUO2AWQFEOFGBZ6HQP3GW5TA37CK7CRZVFRDXYTHTYX7KP"
6908
+ address: "CCT4ZYIYZ3TUO2AWQFEOFGBZ6HQP3GW5TA37CK7CRZVFRDXYTHTYX7KP",
6909
+ xChainId: types.STELLAR_MAINNET_CHAIN_ID
6716
6910
  }
6717
6911
  },
6718
6912
  nativeToken: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
@@ -6728,8 +6922,8 @@ var spokeChainConfig = {
6728
6922
  [types.SUI_MAINNET_CHAIN_ID]: {
6729
6923
  addresses: {
6730
6924
  connection: "0xf3b1e696a66d02cb776dc15aae73c68bc8f03adcb6ba0ec7f6332d9d90a6a3d2::connectionv3::0x3ee76d13909ac58ae13baab4c9be5a5142818d9a387aed641825e5d4356969bf",
6731
- assetManagerId: "0x71535403c625ebf004135f52c8691cb0b740f801f19beb43791cb2cecc6f37ae::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6732
- assetManager: "0x897f911a4b7691870a1a2513af7e85fdee8de275615c77068fd8b90b8e78c678::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6925
+ assetManagerConfigId: "0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6926
+ originalAssetManager: "0xa17a409164d1676db71b411ab50813ba2c7dd547d2df538c699049566f1ff922::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6733
6927
  xTokenManager: "",
6734
6928
  rateLimit: "",
6735
6929
  testToken: ""
@@ -6739,61 +6933,71 @@ var spokeChainConfig = {
6739
6933
  symbol: "SUI",
6740
6934
  name: "SUI",
6741
6935
  decimals: 9,
6742
- address: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
6936
+ address: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
6937
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6743
6938
  },
6744
6939
  bnUSD: {
6745
6940
  symbol: "bnUSD",
6746
6941
  name: "bnUSD",
6747
6942
  decimals: 9,
6748
- address: "0xff4de2b2b57dd7611d2812d231a467d007b702a101fd5c7ad3b278257cddb507::bnusd::BNUSD"
6943
+ address: "0xff4de2b2b57dd7611d2812d231a467d007b702a101fd5c7ad3b278257cddb507::bnusd::BNUSD",
6944
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6749
6945
  },
6750
6946
  USDC: {
6751
6947
  symbol: "USDC",
6752
6948
  name: "USD Coin",
6753
6949
  decimals: 6,
6754
- address: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
6950
+ address: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
6951
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6755
6952
  },
6756
6953
  legacybnUSD: {
6757
- symbol: "bnUSD",
6954
+ symbol: "bnUSD (legacy)",
6758
6955
  name: "legacybnUSD",
6759
6956
  decimals: 9,
6760
- address: "0x03917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR"
6957
+ address: "0x03917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR",
6958
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6761
6959
  },
6762
6960
  afSUI: {
6763
6961
  symbol: "afSUI",
6764
6962
  name: "Aftermath Staked Sui",
6765
6963
  decimals: 9,
6766
- address: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
6964
+ address: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI",
6965
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6767
6966
  },
6768
6967
  mSUI: {
6769
6968
  symbol: "mSUI",
6770
6969
  name: "Mirai Staked SUI",
6771
6970
  decimals: 9,
6772
- address: "0x922d15d7f55c13fd790f6e54397470ec592caa2b508df292a2e8553f3d3b274f::msui::MSUI"
6971
+ address: "0x922d15d7f55c13fd790f6e54397470ec592caa2b508df292a2e8553f3d3b274f::msui::MSUI",
6972
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6773
6973
  },
6774
6974
  haSUI: {
6775
6975
  symbol: "haSUI",
6776
6976
  name: "haSUI",
6777
6977
  decimals: 9,
6778
- address: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
6978
+ address: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI",
6979
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6779
6980
  },
6780
6981
  vSUI: {
6781
6982
  symbol: "vSUI",
6782
6983
  name: "Volo Staked SUI",
6783
6984
  decimals: 9,
6784
- address: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
6985
+ address: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT",
6986
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6785
6987
  },
6786
6988
  yapSUI: {
6787
6989
  symbol: "yapSUI",
6788
6990
  name: "Yap Staked SUI",
6789
6991
  decimals: 9,
6790
- address: "0x83f1bb8c91ecd1fd313344058b0eed94d63c54e41d8d1ae5bff1353443517d65::yap_sui::YAP_SUI"
6992
+ address: "0x83f1bb8c91ecd1fd313344058b0eed94d63c54e41d8d1ae5bff1353443517d65::yap_sui::YAP_SUI",
6993
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6791
6994
  },
6792
6995
  trevinSUI: {
6793
6996
  symbol: "trevinSUI",
6794
6997
  name: "Trevin Staked SUI",
6795
6998
  decimals: 9,
6796
- address: "0x502867b177303bf1bf226245fcdd3403c177e78d175a55a56c0602c7ff51c7fa::trevin_sui::TREVIN_SUI"
6999
+ address: "0x502867b177303bf1bf226245fcdd3403c177e78d175a55a56c0602c7ff51c7fa::trevin_sui::TREVIN_SUI",
7000
+ xChainId: types.SUI_MAINNET_CHAIN_ID
6797
7001
  }
6798
7002
  },
6799
7003
  nativeToken: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
@@ -6814,7 +7018,7 @@ var spokeChainConfig = {
6814
7018
  },
6815
7019
  chain: {
6816
7020
  id: types.ICON_MAINNET_CHAIN_ID,
6817
- name: "ICON Mainnet",
7021
+ name: "ICON",
6818
7022
  type: "ICON"
6819
7023
  },
6820
7024
  supportedTokens: {
@@ -6822,33 +7026,38 @@ var spokeChainConfig = {
6822
7026
  symbol: "ICX",
6823
7027
  name: "ICON",
6824
7028
  decimals: 18,
6825
- address: "cx0000000000000000000000000000000000000000"
7029
+ address: "cx0000000000000000000000000000000000000000",
7030
+ xChainId: types.ICON_MAINNET_CHAIN_ID
6826
7031
  },
6827
7032
  wICX: {
6828
7033
  symbol: "wICX",
6829
7034
  name: "Wrapped ICX",
6830
7035
  decimals: 18,
6831
- address: "cx3975b43d260fb8ec802cef6e60c2f4d07486f11d"
7036
+ address: "cx3975b43d260fb8ec802cef6e60c2f4d07486f11d",
7037
+ xChainId: types.ICON_MAINNET_CHAIN_ID
6832
7038
  },
6833
7039
  bnUSD: {
6834
7040
  // same as legacy
6835
- symbol: "bnUSD",
7041
+ symbol: "bnUSD (legacy)",
6836
7042
  name: "bnUSD",
6837
7043
  decimals: 18,
6838
- address: "cx88fd7df7ddff82f7cc735c871dc519838cb235bb"
7044
+ address: "cx88fd7df7ddff82f7cc735c871dc519838cb235bb",
7045
+ xChainId: types.ICON_MAINNET_CHAIN_ID
6839
7046
  },
6840
7047
  legacybnUSD: {
6841
7048
  // duplicate of bnUSD purely for consistency with other legacy tokens chains (sui, stellar)
6842
- symbol: "bnUSD",
7049
+ symbol: "bnUSD (legacy)",
6843
7050
  name: "bnUSD",
6844
7051
  decimals: 18,
6845
- address: "cx88fd7df7ddff82f7cc735c871dc519838cb235bb"
7052
+ address: "cx88fd7df7ddff82f7cc735c871dc519838cb235bb",
7053
+ xChainId: types.ICON_MAINNET_CHAIN_ID
6846
7054
  },
6847
7055
  BALN: {
6848
7056
  symbol: "BALN",
6849
7057
  name: "BALN",
6850
7058
  decimals: 18,
6851
- address: "cxf61cd5a45dc9f91c15aa65831a30a90d59a09619"
7059
+ address: "cxf61cd5a45dc9f91c15aa65831a30a90d59a09619",
7060
+ xChainId: types.ICON_MAINNET_CHAIN_ID
6852
7061
  }
6853
7062
  },
6854
7063
  nativeToken: "cx0000000000000000000000000000000000000000",
@@ -6856,26 +7065,8 @@ var spokeChainConfig = {
6856
7065
  nid: "0x1"
6857
7066
  }
6858
7067
  };
6859
- var HubVaultSymbols = [
6860
- "sodaAVAX",
6861
- "sodaBNB",
6862
- "sodaETH",
6863
- "sodaBTC",
6864
- "sodaSUI",
6865
- "sodaINJ",
6866
- "sodaXLM",
6867
- "sodaSOL",
6868
- "sodaSODA",
6869
- "sodaUSDT",
6870
- "sodaUSDC",
6871
- "bnUSD",
6872
- "sodaPOL",
6873
- "sodaNIBI",
6874
- "sodaS",
6875
- "IbnUSD"
6876
- ];
6877
7068
  var hubVaults = {
6878
- IbnUSD: {
7069
+ [SodaTokens.IbnUSD.symbol]: {
6879
7070
  // ICON bnUSD (Migration) vault on Sonic contains legacy bnUSD tokens (stellar, sui, icon)
6880
7071
  address: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51",
6881
7072
  reserves: [
@@ -6885,28 +7076,28 @@ var hubVaults = {
6885
7076
  "0x1559B52d2e165da1505a542EA37C543c9137f52a"
6886
7077
  ]
6887
7078
  },
6888
- sodaS: {
7079
+ [SodaTokens.sodaS.symbol]: {
6889
7080
  address: "0x62ecc3eeb80a162c57624b3ff80313fe69f5203e",
6890
7081
  reserves: [
6891
7082
  // hub asset addresses contained in the vault
6892
7083
  "0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38"
6893
7084
  ]
6894
7085
  },
6895
- sodaNIBI: {
7086
+ [SodaTokens.sodaNIBI.symbol]: {
6896
7087
  address: "0xc6c85287a8b173a509c2f198bb719a8a5a2d0c68",
6897
7088
  reserves: [
6898
7089
  // hub asset addresses contained in the vault
6899
7090
  "0xe0064414c2c1a636a9424c7a17d86fbf7fd3f190"
6900
7091
  ]
6901
7092
  },
6902
- sodaPOL: {
7093
+ [SodaTokens.sodaPOL.symbol]: {
6903
7094
  address: "0x208ed38f4783328aa9ebfec360d32e7520a9b779",
6904
7095
  reserves: [
6905
7096
  // hub asset addresses contained in the vault
6906
7097
  "0x9ee17486571917837210824b0d4cadfe3b324d12"
6907
7098
  ]
6908
7099
  },
6909
- bnUSD: {
7100
+ [SodaTokens.bnUSD.symbol]: {
6910
7101
  // new bnUSD vault on Sonic (also contains IbnUSD vault token as part of it)
6911
7102
  address: "0xe801ca34e19abcbfea12025378d19c4fbe250131",
6912
7103
  reserves: [
@@ -6925,19 +7116,33 @@ var hubVaults = {
6925
7116
  "0xdf23097b9aeb917bf8fb70e99b6c528fffa35364",
6926
7117
  "0x11b93c162aabffd026539bb3b9f9ec22c8b7ef8a",
6927
7118
  "0x69425ffb14704124a58d6f69d510f74a59d9a5bc",
6928
- "0x9d4b663eb075d2a1c7b8eaefb9eccc0510388b51"
7119
+ "0x9d4b663eb075d2a1c7b8eaefb9eccc0510388b51",
7120
+ "0xD1d14BF3324C901855A1f7d0d5CA4c8458D2a780"
6929
7121
  ]
6930
7122
  },
6931
- sodaSODA: {
7123
+ [SodaTokens.sodaSODA.symbol]: {
6932
7124
  // SODA SODA vault
6933
7125
  address: "0x21685e341de7844135329914be6bd8d16982d834",
6934
7126
  reserves: [
6935
7127
  // hub asset addresses contained in the vault
6936
- "0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963"
7128
+ "0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963",
6937
7129
  // SODA SODA hub asset
7130
+ "0xf51d7082375cdca8C19C74e1A0c77dA482aFDa4e",
7131
+ "0x93a367E5B37a1B9E8D04ef25a6Af40d181a3DfFF",
7132
+ "0x17fF8Ad5EBe6CA8B15751067cD0c89f0E580CD17",
7133
+ "0x4d12c72A8633588097D10e57b559ed642588e4C6",
7134
+ "0x26cd76cB5622Dc8638670A16E0Da5a51394A8DB1",
7135
+ "0x0eD0d274dC77ef460DC96b9fBaFF3EDB074e0471",
7136
+ "0x8D78A620E009Ba751Eb40d77A5e9Db48A3F2016b",
7137
+ "0x4Cf5Ce9594AEDdc5D3efe9d4Cdf0b944b4e73A53",
7138
+ "0xD749B5FfFED7cEDaa3239abDd16D677179C29AEc",
7139
+ "0x07Db7b1a96ebE474B20F52fF487cEE415adee79e",
7140
+ "0x20Ce75CdcEe44B1308365447b91B9c26e2b71Ffd",
7141
+ "0x5Db9CEc919f40C50809D9490DC3BbA4F05b0a1D7",
7142
+ "0x655730024B673B3378CD6031B1Cd01eaE9afb138"
6938
7143
  ]
6939
7144
  },
6940
- sodaAVAX: {
7145
+ [SodaTokens.sodaAVAX.symbol]: {
6941
7146
  // SODA AVAX vault
6942
7147
  address: "0x14238d267557e9d799016ad635b53cd15935d290",
6943
7148
  reserves: [
@@ -6946,7 +7151,7 @@ var hubVaults = {
6946
7151
  // AvalancheAVAX hub asset
6947
7152
  ]
6948
7153
  },
6949
- sodaBNB: {
7154
+ [SodaTokens.sodaBNB.symbol]: {
6950
7155
  // SODA BNB vault
6951
7156
  address: "0x40cd41b35db9e5109ae7e54b44de8625db320e6b",
6952
7157
  reserves: [
@@ -6955,7 +7160,7 @@ var hubVaults = {
6955
7160
  // BSC BNB hub asset
6956
7161
  ]
6957
7162
  },
6958
- sodaETH: {
7163
+ [SodaTokens.sodaETH.symbol]: {
6959
7164
  // SODA ETH vault
6960
7165
  address: "0x4effb5813271699683c25c734f4dabc45b363709",
6961
7166
  reserves: [
@@ -6972,7 +7177,7 @@ var hubVaults = {
6972
7177
  // Sonic WETH hub asset
6973
7178
  ]
6974
7179
  },
6975
- sodaBTC: {
7180
+ [SodaTokens.sodaBTC.symbol]: {
6976
7181
  // SODA BTC vault
6977
7182
  address: "0x7a1a5555842ad2d0ed274d09b5c4406a95799d5d",
6978
7183
  reserves: [
@@ -6983,11 +7188,12 @@ var hubVaults = {
6983
7188
  // Arbitrum wBTC hub asset
6984
7189
  "0x96fc8540736f1598b7e235e6de8814062b3b5d3b",
6985
7190
  // Arbitrum tBTC hub asset,
6986
- "0xd8a24c71fea5bb81c66c01e532de7d9b11e13905"
7191
+ "0xd8a24c71fea5bb81c66c01e532de7d9b11e13905",
6987
7192
  // BSC BTCB hub asset
7193
+ "0x03E99853C6376b13a4c6e4d0A115F1639c9FA14e"
6988
7194
  ]
6989
7195
  },
6990
- sodaSUI: {
7196
+ [SodaTokens.sodaSUI.symbol]: {
6991
7197
  // SODA SUI vault
6992
7198
  address: "0xdc5b4b00f98347e95b9f94911213dab4c687e1e3",
6993
7199
  reserves: [
@@ -6996,7 +7202,7 @@ var hubVaults = {
6996
7202
  // SUI SUI hub asset
6997
7203
  ]
6998
7204
  },
6999
- sodaINJ: {
7205
+ [SodaTokens.sodaINJ.symbol]: {
7000
7206
  // SODA INJ vault
7001
7207
  address: "0x1f22279c89b213944b7ea41dacb0a868ddcdfd13",
7002
7208
  reserves: [
@@ -7005,7 +7211,7 @@ var hubVaults = {
7005
7211
  // Injective INJ hub asset
7006
7212
  ]
7007
7213
  },
7008
- sodaXLM: {
7214
+ [SodaTokens.sodaXLM.symbol]: {
7009
7215
  // SODA XLM vault
7010
7216
  address: "0x6bc8c37cba91f76e68c9e6d689a9c21e4d32079b",
7011
7217
  reserves: [
@@ -7014,7 +7220,7 @@ var hubVaults = {
7014
7220
  // Stellar XLM hub asset
7015
7221
  ]
7016
7222
  },
7017
- sodaSOL: {
7223
+ [SodaTokens.sodaSOL.symbol]: {
7018
7224
  // SODA SOL vault
7019
7225
  address: "0xdea692287e2ce8cb08fa52917be0f16b1dacdc87",
7020
7226
  reserves: [
@@ -7023,7 +7229,7 @@ var hubVaults = {
7023
7229
  // Solana SOL hub asset
7024
7230
  ]
7025
7231
  },
7026
- sodaUSDT: {
7232
+ [SodaTokens.sodaUSDT.symbol]: {
7027
7233
  // SODA USDT vault
7028
7234
  address: "0xbdf1f453fcb61424011bbddcb96cfdb30f3fe876",
7029
7235
  reserves: [
@@ -7035,7 +7241,7 @@ var hubVaults = {
7035
7241
  // Sonic USDT
7036
7242
  ]
7037
7243
  },
7038
- sodaUSDC: {
7244
+ [SodaTokens.sodaUSDC.symbol]: {
7039
7245
  address: "0xabbb91c0617090f0028bdc27597cd0d038f3a833",
7040
7246
  reserves: [
7041
7247
  "0x41abf4b1559ff709ef8150079bcb26db1fffd117",
@@ -7049,10 +7255,25 @@ var hubVaults = {
7049
7255
  "0x4bc1211faa06fb50ff61a70331f56167ae511057",
7050
7256
  "0x348007b53f25a9a857ab8ea81ec9e3ccbcf440f2",
7051
7257
  "0xc3f020057510ffe10ceb882e1b48238b43d78a5e",
7052
- "0x9d58508ad10d34048a11640735ca5075bba07b35"
7258
+ "0x9d58508ad10d34048a11640735ca5075bba07b35",
7259
+ "0xC1df02fb7b1b06bE886592C89F6955387998B2f7"
7053
7260
  ]
7054
7261
  }
7055
7262
  };
7263
+ var hubVaultTokensMap = new Map(
7264
+ Object.entries(hubVaults).map(([symbol, vault]) => [
7265
+ vault.address.toLowerCase(),
7266
+ {
7267
+ address: vault.address.toLowerCase(),
7268
+ symbol,
7269
+ name: symbol,
7270
+ decimals: 18
7271
+ }
7272
+ ])
7273
+ );
7274
+ var getHubVaultTokenByAddress = (address) => {
7275
+ return hubVaultTokensMap.get(address.toLowerCase());
7276
+ };
7056
7277
  var bnUSDLegacySpokeChainIds = [
7057
7278
  types.ICON_MAINNET_CHAIN_ID,
7058
7279
  types.SUI_MAINNET_CHAIN_ID,
@@ -7098,6 +7319,13 @@ var hubAssets = {
7098
7319
  name: "Sonic",
7099
7320
  vault: hubVaults.sodaS.address
7100
7321
  },
7322
+ [spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].bnUSD]: {
7323
+ asset: "0x289cDa1043b4Ce26BDCa3c12E534f56b24308A5B",
7324
+ decimal: 18,
7325
+ symbol: "bnUSD",
7326
+ name: "bnUSD",
7327
+ vault: hubVaults.bnUSD.address
7328
+ },
7101
7329
  [spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address]: {
7102
7330
  asset: spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address,
7103
7331
  decimal: 18,
@@ -7132,7 +7360,8 @@ var hubAssets = {
7132
7360
  symbol: "SODA",
7133
7361
  name: "SODA",
7134
7362
  vault: hubVaults.sodaSODA.address
7135
- }
7363
+ },
7364
+ ...SodaTokensAsHubAssets
7136
7365
  },
7137
7366
  [types.AVALANCHE_MAINNET_CHAIN_ID]: {
7138
7367
  [spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].nativeToken]: {
@@ -7593,17 +7822,18 @@ var solverSupportedTokens = {
7593
7822
  spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH,
7594
7823
  spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC,
7595
7824
  spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT,
7596
- spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.wS
7825
+ spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.wS,
7826
+ spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.bnUSD
7597
7827
  ],
7598
7828
  [types.AVALANCHE_MAINNET_CHAIN_ID]: [
7599
7829
  spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.AVAX,
7600
7830
  spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDT,
7601
- spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDC
7602
- // spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7831
+ spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDC,
7832
+ spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.bnUSD
7603
7833
  ],
7604
7834
  [types.ARBITRUM_MAINNET_CHAIN_ID]: [
7605
7835
  spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.ETH,
7606
- // spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7836
+ spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7607
7837
  spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC,
7608
7838
  spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH,
7609
7839
  spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
@@ -7613,7 +7843,7 @@ var solverSupportedTokens = {
7613
7843
  ],
7614
7844
  [types.BASE_MAINNET_CHAIN_ID]: [
7615
7845
  spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.ETH,
7616
- // spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7846
+ spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7617
7847
  spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.weETH,
7618
7848
  spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.USDC,
7619
7849
  spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH,
@@ -7621,7 +7851,7 @@ var solverSupportedTokens = {
7621
7851
  ],
7622
7852
  [types.OPTIMISM_MAINNET_CHAIN_ID]: [
7623
7853
  spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.ETH,
7624
- // spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7854
+ spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7625
7855
  spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC,
7626
7856
  spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
7627
7857
  // spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH, // NOTE: Not Implemented
@@ -7629,19 +7859,20 @@ var solverSupportedTokens = {
7629
7859
  ],
7630
7860
  [types.POLYGON_MAINNET_CHAIN_ID]: [
7631
7861
  spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].supportedTokens.POL,
7632
- // spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7862
+ spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7633
7863
  spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].supportedTokens.USDC
7634
7864
  ],
7635
7865
  [types.BSC_MAINNET_CHAIN_ID]: [
7636
7866
  spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.BNB,
7637
7867
  spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.ETHB,
7638
7868
  spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.BTCB,
7639
- // spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7869
+ spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7640
7870
  spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.USDC
7641
7871
  ],
7642
7872
  [types.SOLANA_MAINNET_CHAIN_ID]: [
7643
7873
  spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL,
7644
- // spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7874
+ spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7875
+ // NOTE: Not Implemented
7645
7876
  spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC
7646
7877
  ],
7647
7878
  [types.ICON_MAINNET_CHAIN_ID]: [
@@ -7653,12 +7884,14 @@ var solverSupportedTokens = {
7653
7884
  ],
7654
7885
  [types.STELLAR_MAINNET_CHAIN_ID]: [
7655
7886
  spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.XLM,
7656
- // spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7887
+ spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7888
+ // NOTE: Not Implemented
7657
7889
  spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.USDC
7658
7890
  ],
7659
7891
  [types.SUI_MAINNET_CHAIN_ID]: [
7660
7892
  spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.SUI,
7661
- // spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7893
+ spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7894
+ // NOTE: Not Implemented
7662
7895
  spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.USDC,
7663
7896
  spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.afSUI,
7664
7897
  spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.mSUI,
@@ -7668,9 +7901,9 @@ var solverSupportedTokens = {
7668
7901
  spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.trevinSUI
7669
7902
  ],
7670
7903
  [types.INJECTIVE_MAINNET_CHAIN_ID]: [
7671
- spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
7904
+ // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
7672
7905
  // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
7673
- spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC
7906
+ // spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC,
7674
7907
  ],
7675
7908
  [types.NIBIRU_MAINNET_CHAIN_ID]: [
7676
7909
  // spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.NIBI, // NOTE: Not Implemented
@@ -7802,11 +8035,30 @@ var chainIdToHubAssetsMap = new Map(
7802
8035
  var supportedHubAssets = new Set(
7803
8036
  Object.values(hubAssets).flatMap((assets) => Object.values(assets).map((info) => info.asset.toLowerCase()))
7804
8037
  );
8038
+ var supportedSodaAssets = new Set(
8039
+ Object.values(hubAssets).flatMap((assets) => Object.values(assets).map((info) => info.vault.toLowerCase()))
8040
+ );
7805
8041
  var spokeChainIdsSet = new Set(types.SPOKE_CHAIN_IDS);
8042
+ var getOriginalAssetInfoFromVault = (chainId, vault) => {
8043
+ const assets = hubAssets[chainId];
8044
+ if (!assets) {
8045
+ return [];
8046
+ }
8047
+ const vaultAddress = vault.toLowerCase();
8048
+ const result = [];
8049
+ for (const [spokeToken, info] of Object.entries(assets)) {
8050
+ if (info.vault.toLowerCase() === vaultAddress) {
8051
+ result.push(spokeToken);
8052
+ }
8053
+ }
8054
+ return result;
8055
+ };
7806
8056
  var getHubAssetInfo = (chainId, asset) => originalAssetTohubAssetMap.get(chainId)?.get(asset.toLowerCase());
7807
8057
  var isValidOriginalAssetAddress = (chainId, asset) => originalAssetTohubAssetMap.get(chainId)?.has(asset.toLowerCase()) ?? false;
7808
8058
  var getOriginalAssetAddress = (chainId, hubAsset) => hubAssetToOriginalAssetMap.get(chainId)?.get(hubAsset.toLowerCase());
8059
+ var getOriginalTokenFromOriginalAssetAddress = (chainId, asset) => Object.values(spokeChainConfig[chainId].supportedTokens).find((t) => t.address.toLowerCase() === asset.toLowerCase()) ?? void 0;
7809
8060
  var isValidHubAsset = (hubAsset) => supportedHubAssets.has(hubAsset.toLowerCase());
8061
+ var isValidVault = (vault) => supportedSodaAssets.has(vault.toLowerCase());
7810
8062
  var isValidChainHubAsset = (chainId, hubAsset) => chainIdToHubAssetsMap.get(chainId)?.has(hubAsset.toLowerCase()) ?? false;
7811
8063
  var isValidSpokeChainId = (chainId) => spokeChainIdsSet.has(chainId);
7812
8064
  var isValidIntentRelayChainId = (chainId) => Object.values(INTENT_RELAY_CHAIN_IDS).some((id) => id === chainId);
@@ -7859,12 +8111,13 @@ var InjectiveSpokeProvider = class {
7859
8111
  );
7860
8112
  }
7861
8113
  async getBalance(token) {
7862
- return this.chainGrpcWasmApi.fetchSmartContractState(
8114
+ const response = await this.chainGrpcWasmApi.fetchSmartContractState(
7863
8115
  this.chainConfig.addresses.assetManager,
7864
8116
  sdkTs.toBase64({
7865
8117
  get_balance: { denom: token }
7866
8118
  })
7867
8119
  );
8120
+ return sdkTs.fromBase64(response.data);
7868
8121
  }
7869
8122
  // Execute Methods (requires SigningCosmWasmClient)
7870
8123
  /**
@@ -8402,341 +8655,66 @@ var StellarSpokeProvider = class {
8402
8655
  return viem.toHex(Buffer.from(stellaraddress, "hex"));
8403
8656
  }
8404
8657
  };
8405
- var SuiSpokeProvider = class _SuiSpokeProvider {
8406
- walletProvider;
8407
- chainConfig;
8408
- publicClient;
8409
- constructor(config, wallet_provider) {
8410
- this.chainConfig = config;
8411
- this.walletProvider = wallet_provider;
8412
- this.publicClient = new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
8413
- }
8414
- async getBalance(token) {
8415
- const assetmanager = this.splitAddress(this.chainConfig.addresses.assetManager);
8416
- const tx = new transactions.Transaction();
8417
- const result = await this.walletProvider.viewContract(
8418
- tx,
8419
- assetmanager.packageId,
8420
- assetmanager.moduleId,
8421
- "get_token_balance",
8422
- [tx.object(assetmanager.stateId)],
8423
- [token]
8424
- );
8425
- if (!Array.isArray(result?.returnValues) || !Array.isArray(result.returnValues[0]) || result.returnValues[0][0] === void 0) {
8426
- throw new Error("Failed to get Balance");
8427
- }
8428
- const val = result.returnValues[0][0];
8429
- const str_u64 = bcs.bcs.U64.parse(Uint8Array.from(val));
8430
- return BigInt(str_u64);
8658
+ var Erc20Service = class {
8659
+ constructor() {
8431
8660
  }
8432
- async transfer(token, amount, to, data, raw) {
8433
- const isNative2 = token.toLowerCase() === this.chainConfig.nativeToken.toLowerCase();
8434
- const tx = new transactions.Transaction();
8435
- const walletAddress = await this.walletProvider.getWalletAddressBytes();
8436
- const coin = isNative2 ? await this.getNativeCoin(tx, amount) : await this.getCoin(tx, token, amount, walletAddress);
8437
- const connection = this.splitAddress(this.chainConfig.addresses.connection);
8438
- const assetManager = this.splitAddress(this.chainConfig.addresses.assetManager);
8439
- tx.moveCall({
8440
- target: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
8441
- typeArguments: [token],
8442
- arguments: [
8443
- tx.object(assetManager.stateId),
8444
- tx.object(connection.stateId),
8445
- // Connection state object
8446
- coin,
8447
- tx.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(to)),
8448
- tx.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(data))
8449
- ]
8450
- });
8451
- if (raw) {
8452
- tx.setSender(walletAddress);
8453
- const transactionRaw = await tx.build({
8454
- client: this.publicClient,
8455
- onlyTransactionKind: true
8661
+ /**
8662
+ * Check if spender has enough ERC20 allowance for given amount
8663
+ * @param token - ERC20 token address
8664
+ * @param amount - Amount to check allowance for
8665
+ * @param owner - User wallet address
8666
+ * @param spender - Spender address
8667
+ * @param spokeProvider - EVM Spoke provider
8668
+ * @return - True if spender is allowed to spend amount on behalf of owner
8669
+ */
8670
+ static async isAllowanceValid(token, amount, owner, spender, spokeProvider) {
8671
+ try {
8672
+ if (token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
8673
+ return {
8674
+ ok: true,
8675
+ value: true
8676
+ };
8677
+ }
8678
+ const allowedAmount = await spokeProvider.publicClient.readContract({
8679
+ address: token,
8680
+ abi: viem.erc20Abi,
8681
+ functionName: "allowance",
8682
+ args: [owner, spender]
8456
8683
  });
8457
- const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
8458
8684
  return {
8459
- from: walletAddress,
8460
- to: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
8461
- value: amount,
8462
- data: transactionRawBase64String
8685
+ ok: true,
8686
+ value: allowedAmount >= amount
8687
+ };
8688
+ } catch (e) {
8689
+ return {
8690
+ ok: false,
8691
+ error: e
8463
8692
  };
8464
8693
  }
8465
- return this.walletProvider.signAndExecuteTxn(tx);
8466
8694
  }
8467
- async getNativeCoin(tx, amount) {
8468
- const coin = tx.splitCoins(tx.gas, [tx.pure.u64(amount)])[0];
8469
- if (coin === void 0) {
8470
- return Promise.reject(Error("[SuiIntentService.getNativeCoin] coin undefined"));
8695
+ /**
8696
+ * Approve ERC20 amount spending
8697
+ * @param token - ERC20 token address
8698
+ * @param amount - Amount to approve
8699
+ * @param spender - Spender address
8700
+ * @param provider - EVM Provider
8701
+ */
8702
+ static async approve(token, amount, spender, spokeProvider, raw) {
8703
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
8704
+ const rawTx = {
8705
+ from: walletAddress,
8706
+ to: token,
8707
+ value: 0n,
8708
+ data: viem.encodeFunctionData({
8709
+ abi: viem.erc20Abi,
8710
+ functionName: "approve",
8711
+ args: [spender, amount]
8712
+ })
8713
+ };
8714
+ if (raw) {
8715
+ return rawTx;
8471
8716
  }
8472
- return coin;
8473
- }
8474
- async getCoin(tx, coin, amount, address) {
8475
- const coins = await this.walletProvider.getCoins(address, coin);
8476
- const objects = [];
8477
- let totalAmount = BigInt(0);
8478
- for (const coin2 of coins.data) {
8479
- totalAmount += BigInt(coin2.balance);
8480
- objects.push(coin2.coinObjectId);
8481
- if (totalAmount >= amount) {
8482
- break;
8483
- }
8484
- }
8485
- const firstObject = objects[0];
8486
- if (!firstObject) {
8487
- throw new Error(`[SuiIntentService.getCoin] Coin=${coin} not found for address=${address} and amount=${amount}`);
8488
- }
8489
- if (objects.length > 1) {
8490
- tx.mergeCoins(firstObject, objects.slice(1));
8491
- }
8492
- if (totalAmount === amount) {
8493
- return tx.object(firstObject);
8494
- }
8495
- return tx.splitCoins(firstObject, [amount]);
8496
- }
8497
- splitAddress(address) {
8498
- const parts = address.split("::");
8499
- if (parts.length === 3) {
8500
- if (parts[0] && parts[1] && parts[2]) {
8501
- return { packageId: parts[0], moduleId: parts[1], stateId: parts[2] };
8502
- }
8503
- throw new Error("Invalid package address");
8504
- }
8505
- throw new Error("Invalid package address");
8506
- }
8507
- async sendMessage(dst_chain_id, dst_address, data, raw) {
8508
- const txb = new transactions.Transaction();
8509
- const connection = this.splitAddress(this.chainConfig.addresses.connection);
8510
- txb.moveCall({
8511
- target: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
8512
- arguments: [
8513
- txb.object(connection.stateId),
8514
- txb.pure.u256(dst_chain_id),
8515
- txb.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(dst_address)),
8516
- txb.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(data))
8517
- ]
8518
- });
8519
- const walletAddress = await this.walletProvider.getWalletAddress();
8520
- if (raw) {
8521
- txb.setSender(walletAddress);
8522
- const transactionRaw = await txb.build({
8523
- client: this.publicClient,
8524
- onlyTransactionKind: true
8525
- });
8526
- const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
8527
- return {
8528
- from: walletAddress,
8529
- to: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
8530
- value: 0n,
8531
- data: transactionRawBase64String
8532
- };
8533
- }
8534
- return this.walletProvider.signAndExecuteTxn(txb);
8535
- }
8536
- async configureAssetManagerHub(hubNetworkId, hubAssetManager) {
8537
- const tx = new transactions.Transaction();
8538
- const assetmanager = this.splitAddress(this.chainConfig.addresses.assetManager);
8539
- tx.moveCall({
8540
- target: `${assetmanager.packageId}::${assetmanager.moduleId}::set_hub_details`,
8541
- arguments: [tx.object(assetmanager.stateId), tx.pure.u64(hubNetworkId), tx.pure.vector("u8", hubAssetManager)]
8542
- });
8543
- const result = await this.walletProvider.signAndExecuteTxn(tx);
8544
- return result;
8545
- }
8546
- async getWalletAddress() {
8547
- return this.walletProvider.getWalletAddress();
8548
- }
8549
- async getWalletAddressBytes() {
8550
- const address = await this.getWalletAddress();
8551
- return _SuiSpokeProvider.getAddressBCSBytes(address);
8552
- }
8553
- static getAddressBCSBytes(suiaddress) {
8554
- return viem.toHex(bcs.bcs.Address.serialize(suiaddress).toBytes());
8555
- }
8556
- };
8557
-
8558
- // src/entities/solana/SolanaSpokeProvider.ts
8559
- var SolanaSpokeProvider = class {
8560
- walletProvider;
8561
- chainConfig;
8562
- constructor(walletProvider, chainConfig) {
8563
- this.walletProvider = walletProvider;
8564
- this.chainConfig = chainConfig;
8565
- }
8566
- };
8567
- var solanaSpokeChainConfig = spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID];
8568
- function getSolanaAddressBytes(address) {
8569
- return `0x${Buffer.from(address.toBytes()).toString("hex")}`;
8570
- }
8571
- function isNative(address) {
8572
- if (address.equals(new web3_js.PublicKey(solanaSpokeChainConfig.nativeToken))) {
8573
- return true;
8574
- }
8575
- return false;
8576
- }
8577
- function convertTransactionInstructionToRaw(instruction) {
8578
- return {
8579
- keys: instruction.keys.map((key) => ({
8580
- pubkey: key.pubkey.toBase58(),
8581
- isSigner: key.isSigner,
8582
- isWritable: key.isWritable
8583
- })),
8584
- programId: instruction.programId.toBase58(),
8585
- data: instruction.data
8586
- };
8587
- }
8588
-
8589
- // src/entities/icon/HanaWalletConnector.ts
8590
- function requestAddress() {
8591
- return new Promise((resolve) => {
8592
- const eventHandler = (event) => {
8593
- const customEvent = event;
8594
- const response = customEvent.detail;
8595
- if (isResponseAddressType(response)) {
8596
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8597
- resolve({
8598
- ok: true,
8599
- value: response.payload
8600
- });
8601
- }
8602
- };
8603
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8604
- window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8605
- window.dispatchEvent(
8606
- new CustomEvent("ICONEX_RELAY_REQUEST", {
8607
- detail: {
8608
- type: "REQUEST_ADDRESS"
8609
- }
8610
- })
8611
- );
8612
- });
8613
- }
8614
- function requestSigning(from, hash) {
8615
- return new Promise((resolve, reject) => {
8616
- const signRequest = new CustomEvent("ICONEX_RELAY_REQUEST", {
8617
- detail: {
8618
- type: "REQUEST_SIGNING",
8619
- payload: {
8620
- from,
8621
- hash
8622
- }
8623
- }
8624
- });
8625
- const eventHandler = (event) => {
8626
- const customEvent = event;
8627
- const response = customEvent.detail;
8628
- if (isResponseSigningType(response)) {
8629
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8630
- resolve({
8631
- ok: true,
8632
- value: response.payload
8633
- });
8634
- } else if (response.type === "CANCEL_SIGNING") {
8635
- reject(new Error("CANCEL_SIGNING"));
8636
- }
8637
- };
8638
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8639
- window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8640
- window.dispatchEvent(signRequest);
8641
- });
8642
- }
8643
- function requestJsonRpc(rawTransaction, id = 99999) {
8644
- return new Promise((resolve, reject) => {
8645
- const eventHandler = (event) => {
8646
- const customEvent = event;
8647
- const { type, payload } = customEvent.detail;
8648
- if (type === "RESPONSE_JSON-RPC") {
8649
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8650
- if (isJsonRpcPayloadResponse(payload)) {
8651
- resolve({
8652
- ok: true,
8653
- value: payload
8654
- });
8655
- } else {
8656
- reject(new Error("Invalid payload response type (expected JsonRpcPayloadResponse)"));
8657
- }
8658
- } else if (type === "CANCEL_JSON-RPC") {
8659
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8660
- reject(new Error("CANCEL_JSON-RPC"));
8661
- }
8662
- };
8663
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8664
- window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8665
- window.dispatchEvent(
8666
- new CustomEvent("ICONEX_RELAY_REQUEST", {
8667
- detail: {
8668
- type: "REQUEST_JSON-RPC",
8669
- payload: {
8670
- jsonrpc: "2.0",
8671
- method: "icx_sendTransaction",
8672
- params: rawTransaction,
8673
- id
8674
- }
8675
- }
8676
- })
8677
- );
8678
- });
8679
- }
8680
- var Erc20Service = class {
8681
- constructor() {
8682
- }
8683
- /**
8684
- * Check if spender has enough ERC20 allowance for given amount
8685
- * @param token - ERC20 token address
8686
- * @param amount - Amount to check allowance for
8687
- * @param owner - User wallet address
8688
- * @param spender - Spender address
8689
- * @param spokeProvider - EVM Spoke provider
8690
- * @return - True if spender is allowed to spend amount on behalf of owner
8691
- */
8692
- static async isAllowanceValid(token, amount, owner, spender, spokeProvider) {
8693
- try {
8694
- if (token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
8695
- return {
8696
- ok: true,
8697
- value: true
8698
- };
8699
- }
8700
- const allowedAmount = await spokeProvider.publicClient.readContract({
8701
- address: token,
8702
- abi: viem.erc20Abi,
8703
- functionName: "allowance",
8704
- args: [owner, spender]
8705
- });
8706
- return {
8707
- ok: true,
8708
- value: allowedAmount >= amount
8709
- };
8710
- } catch (e) {
8711
- return {
8712
- ok: false,
8713
- error: e
8714
- };
8715
- }
8716
- }
8717
- /**
8718
- * Approve ERC20 amount spending
8719
- * @param token - ERC20 token address
8720
- * @param amount - Amount to approve
8721
- * @param spender - Spender address
8722
- * @param provider - EVM Provider
8723
- */
8724
- static async approve(token, amount, spender, spokeProvider, raw) {
8725
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
8726
- const rawTx = {
8727
- from: walletAddress,
8728
- to: token,
8729
- value: 0n,
8730
- data: viem.encodeFunctionData({
8731
- abi: viem.erc20Abi,
8732
- functionName: "approve",
8733
- args: [spender, amount]
8734
- })
8735
- };
8736
- if (raw) {
8737
- return rawTx;
8738
- }
8739
- return spokeProvider.walletProvider.sendTransaction(rawTx);
8717
+ return spokeProvider.walletProvider.sendTransaction(rawTx);
8740
8718
  }
8741
8719
  /**
8742
8720
  * Encodes a transfer transaction for a token.
@@ -9080,57 +9058,41 @@ var EvmWalletAbstraction = class {
9080
9058
  });
9081
9059
  }
9082
9060
  };
9083
- var EvmSpokeService = class _EvmSpokeService {
9061
+ var SuiSpokeService = class _SuiSpokeService {
9084
9062
  constructor() {
9085
9063
  }
9086
9064
  /**
9087
- * Estimates the gas necessary to complete a transaction without submitting it to the network.
9088
- *
9089
- * - Docs: https://viem.sh/docs/actions/public/estimateGas
9090
- * - JSON-RPC Methods: [`eth_estimateGas`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)
9091
- *
9092
- * @param {EvmRawTransaction} rawTx - The raw transaction to estimate the gas for.
9093
- * @param {EvmSpokeProvider} spokeProvider - The EVM spoke provider.
9094
- * @returns {Promise<bigint>} Estimated gas for the transaction.
9095
- *
9096
- * @example
9097
- *
9098
- * const rawTx: EvmRawTransaction = {
9099
- * from: '0x1234...abcd', // sender address
9100
- * to: '0xabcd...1234', // recipient address
9101
- * value: 1000000000000000000n, // 1 ETH in wei
9102
- * data: '0x', // no calldata
9103
- * };
9104
- *
9105
- * // Assume spokeProvider is an initialized EvmSpokeProvider
9106
- * const estimatedGas = await EvmSpokeService.estimateGas(rawTx, spokeProvider);
9107
- * console.log(`Estimated gas: ${estimatedGas}`);
9065
+ * Estimate the gas for a transaction.
9066
+ * @param {SuiRawTransaction} rawTx - The raw transaction to estimate the gas for.
9067
+ * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
9068
+ * @returns {Promise<bigint>} The estimated computation cost.
9108
9069
  */
9109
9070
  static async estimateGas(rawTx, spokeProvider) {
9110
- return spokeProvider.publicClient.estimateGas({
9111
- account: rawTx.from,
9112
- to: rawTx.to,
9113
- value: rawTx.value,
9114
- data: rawTx.data
9071
+ const txb = transactions.Transaction.fromKind(rawTx.data);
9072
+ const result = await spokeProvider.publicClient.devInspectTransactionBlock({
9073
+ sender: rawTx.from,
9074
+ transactionBlock: txb
9115
9075
  });
9076
+ return result.effects.gasUsed;
9116
9077
  }
9117
9078
  /**
9118
9079
  * Deposit tokens to the spoke chain.
9119
- * @param {EvmSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9120
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9080
+ * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9081
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9121
9082
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9122
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9083
+ * @param {boolean} raw - The return type raw or just transaction hash
9084
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9123
9085
  */
9124
9086
  static async deposit(params, spokeProvider, hubProvider, raw) {
9125
- const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9087
+ const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9126
9088
  spokeProvider.chainConfig.chain.id,
9127
9089
  params.from,
9128
9090
  hubProvider
9129
9091
  );
9130
- return _EvmSpokeService.transfer(
9092
+ return _SuiSpokeService.transfer(
9131
9093
  {
9132
9094
  token: params.token,
9133
- recipient: to,
9095
+ recipient: userWallet,
9134
9096
  amount: params.amount,
9135
9097
  data: params.data
9136
9098
  },
@@ -9141,21 +9103,16 @@ var EvmSpokeService = class _EvmSpokeService {
9141
9103
  /**
9142
9104
  * Get the balance of the token in the spoke chain.
9143
9105
  * @param {Address} token - The address of the token to get the balance of.
9144
- * @param {EvmSpokeProvider} spokeProvider - The spoke provider.
9106
+ * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
9145
9107
  * @returns {Promise<bigint>} The balance of the token.
9146
9108
  */
9147
9109
  static async getDeposit(token, spokeProvider) {
9148
- return spokeProvider.publicClient.readContract({
9149
- address: token,
9150
- abi: erc20Abi,
9151
- functionName: "balanceOf",
9152
- args: [token]
9153
- });
9110
+ return spokeProvider.getBalance(token);
9154
9111
  }
9155
9112
  /**
9156
- * Generate simulation parameters for deposit from EvmSpokeDepositParams.
9157
- * @param {EvmSpokeDepositParams} params - The deposit parameters.
9158
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9113
+ * Generate simulation parameters for deposit from SuiSpokeDepositParams.
9114
+ * @param {SuiSpokeDepositParams} params - The deposit parameters.
9115
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9159
9116
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9160
9117
  * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9161
9118
  */
@@ -9165,219 +9122,681 @@ var EvmSpokeService = class _EvmSpokeService {
9165
9122
  params.from,
9166
9123
  hubProvider
9167
9124
  );
9125
+ const encoder = new TextEncoder();
9168
9126
  return {
9169
9127
  spokeChainID: spokeProvider.chainConfig.chain.id,
9170
- token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9128
+ token: viem.toHex(encoder.encode(params.token)),
9171
9129
  from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9172
9130
  to,
9173
9131
  amount: params.amount,
9174
9132
  data: params.data,
9175
- srcAddress: encodeAddress(
9176
- spokeProvider.chainConfig.chain.id,
9177
- spokeProvider.chainConfig.addresses.assetManager
9178
- )
9133
+ srcAddress: viem.toHex(encoder.encode(spokeProvider.chainConfig.addresses.originalAssetManager))
9179
9134
  };
9180
9135
  }
9181
9136
  /**
9182
9137
  * Calls a contract on the spoke chain using the user's wallet.
9183
- * @param {HubAddress} from - The address of the user on the hub chain.
9138
+ * @param {HubAddress} from - The address of the user on the spoke chain.
9184
9139
  * @param {Hex} payload - The payload to send to the contract.
9185
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9140
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9186
9141
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9187
9142
  * @param {boolean} raw - The return type raw or just transaction hash
9188
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9143
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9189
9144
  */
9190
9145
  static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
9191
9146
  const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9192
- const result = await _EvmSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9193
- return result;
9194
- }
9195
- /**
9196
- * Transfers tokens to the hub chain.
9197
- * @param {EvmTransferToHubParams} params - The parameters for the transfer, including:
9198
- * - {Address} token: The address of the token to transfer (use address(0) for native token).
9199
- * - {Address} recipient: The recipient address on the hub chain.
9200
- * - {bigint} amount: The amount to transfer.
9201
- * - {Hex} [data="0x"]: Additional data for the transfer.
9202
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9203
- * @param {boolean} raw - The return type raw or just transaction hash
9204
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9205
- */
9206
- static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
9207
- const txPayload = {
9208
- address: spokeProvider.chainConfig.addresses.assetManager,
9209
- value: token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase() ? amount : void 0
9210
- };
9211
- const from = await spokeProvider.walletProvider.getWalletAddress();
9212
- const rawTx = {
9213
- from,
9214
- to: txPayload.address,
9215
- value: txPayload.value ?? 0n,
9216
- data: viem.encodeFunctionData({
9217
- abi: spokeAssetManagerAbi,
9218
- functionName: "transfer",
9219
- args: [token, recipient, amount, data]
9220
- })
9221
- };
9222
- if (raw) {
9223
- return rawTx;
9224
- }
9225
- return spokeProvider.walletProvider.sendTransaction(rawTx);
9147
+ return _SuiSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9226
9148
  }
9227
9149
  /**
9228
- * Sends a message to the hub chain.
9229
- * @param {bigint} dstChainId - The chain ID of the hub chain.
9230
- * @param {Address} dstAddress - The address on the hub chain.
9231
- * @param {Hex} payload - The payload to send.
9232
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9233
- * @param {boolean} raw - The return type raw or just transaction hash
9234
- * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9150
+ * Fetch the asset manager config from the spoke chain.
9151
+ * @param {SuiSpokeProvider} suiSpokeProvider - The spoke provider.
9152
+ * @returns {Promise<string>} The asset manager config.
9235
9153
  */
9236
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
9237
- const txPayload = {
9238
- address: spokeProvider.chainConfig.addresses.connection};
9239
- const from = await spokeProvider.walletProvider.getWalletAddress();
9240
- const rawTx = {
9241
- from,
9242
- to: txPayload.address,
9243
- value: 0n,
9244
- data: viem.encodeFunctionData({
9245
- abi: connectionAbi,
9246
- functionName: "sendMessage",
9247
- args: [dstChainId, dstAddress, payload]
9248
- })
9249
- };
9250
- if (raw) {
9251
- return rawTx;
9252
- }
9253
- return spokeProvider.walletProvider.sendTransaction(rawTx);
9254
- }
9255
- };
9256
- var InjectiveSpokeService = class _InjectiveSpokeService {
9257
- constructor() {
9154
+ static async fetchAssetManagerAddress(suiSpokeProvider) {
9155
+ const latestPackageId = await _SuiSpokeService.fetchLatestAssetManagerPackageId(suiSpokeProvider);
9156
+ return `${latestPackageId}::asset_manager::${suiSpokeProvider.chainConfig.addresses.assetManagerConfigId}`;
9258
9157
  }
9259
9158
  /**
9260
- * Estimate the gas for a transaction.
9261
- * @param {InjectiveRawTransaction} rawTx - The raw transaction to estimate the gas for.
9262
- * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9263
- * @returns {Promise<InjectiveGasEstimate>} The estimated gas for the transaction.
9159
+ * Fetch the latest asset manager package id from the spoke chain.
9160
+ * @param {SuiSpokeProvider} suiSpokeProvider - The spoke provider.
9161
+ * @returns {Promise<string>} The latest asset manager package id.
9264
9162
  */
9265
- static async estimateGas(rawTx, spokeProvider) {
9266
- const txRaw = coreProtoTs.CosmosTxV1Beta1Tx.TxRaw.fromPartial({
9267
- bodyBytes: rawTx.signedDoc.bodyBytes,
9268
- authInfoBytes: rawTx.signedDoc.authInfoBytes,
9269
- signatures: []
9270
- // not required for simulation
9163
+ static async fetchLatestAssetManagerPackageId(suiSpokeProvider) {
9164
+ const configData = await suiSpokeProvider.publicClient.getObject({
9165
+ id: suiSpokeProvider.chainConfig.addresses.assetManagerConfigId,
9166
+ options: {
9167
+ showContent: true
9168
+ }
9271
9169
  });
9272
- const { gasInfo } = await spokeProvider.txClient.simulate(txRaw);
9273
- return {
9274
- gasWanted: gasInfo.gasWanted,
9275
- gasUsed: gasInfo.gasUsed
9276
- };
9277
- }
9278
- /**
9279
- * Deposit tokens to the spoke chain.
9280
- * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9281
- * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9282
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9283
- * @param {boolean} raw - The return type raw or just transaction hash
9284
- * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9285
- */
9286
- static async deposit(params, spokeProvider, hubProvider, raw) {
9287
- const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9288
- spokeProvider.chainConfig.chain.id,
9289
- viem.toHex(Buffer.from(params.from, "utf-8")),
9290
- hubProvider
9291
- );
9292
- return _InjectiveSpokeService.transfer(
9293
- {
9294
- token: params.token,
9295
- recipient: userWallet,
9296
- amount: params.amount.toString(),
9297
- data: params.data
9298
- },
9299
- spokeProvider,
9300
- raw
9301
- );
9302
- }
9303
- /**
9304
- * Generate simulation parameters for deposit from InjectiveSpokeDepositParams.
9305
- * @param {InjectiveSpokeDepositParams} params - The deposit parameters.
9306
- * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9307
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9308
- * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9309
- */
9310
- static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9311
- const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9312
- spokeProvider.chainConfig.chain.id,
9313
- viem.toHex(Buffer.from(params.from, "utf-8")),
9314
- hubProvider
9315
- );
9316
- return {
9317
- spokeChainID: spokeProvider.chainConfig.chain.id,
9318
- token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9319
- from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9320
- to,
9321
- amount: params.amount,
9322
- data: params.data,
9323
- srcAddress: encodeAddress(
9324
- spokeProvider.chainConfig.chain.id,
9325
- spokeProvider.chainConfig.addresses.assetManager
9326
- )
9327
- };
9328
- }
9329
- /**
9330
- * Get the balance of the token that deposited in the spoke chain Asset Manager.
9331
- * @param {Address} token - The address of the token to get the balance of.
9332
- * @param {InjectiveSpokeProvider} spokeProvider - The spoke provider.
9333
- * @returns {Promise<bigint>} The balance of the token.
9334
- */
9335
- static async getDeposit(token, spokeProvider) {
9336
- const bal = await spokeProvider.getBalance(token);
9337
- return BigInt(bal);
9338
- }
9339
- /**
9340
- * Calls a contract on the spoke chain using the user's wallet.
9341
- * @param {HubAddress} from - The address of the user on the hub chain.
9342
- * @param {Hex} payload - The payload to send to the contract.
9343
- * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9344
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9345
- * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9346
- */
9347
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
9348
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9349
- return _InjectiveSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9170
+ if (configData.error) {
9171
+ throw new Error(`Failed to fetch asset manager id. Details: ${JSON.stringify(configData.error)}`);
9172
+ }
9173
+ if (!configData.data) {
9174
+ throw new Error("Asset manager id not found (no data)");
9175
+ }
9176
+ if (configData.data.content?.dataType !== "moveObject") {
9177
+ throw new Error("Asset manager id not found (not a move object)");
9178
+ }
9179
+ if (!("latest_package_id" in configData.data.content.fields)) {
9180
+ throw new Error("Asset manager id not found (no latest package id)");
9181
+ }
9182
+ const latestPackageId = configData.data.content.fields["latest_package_id"];
9183
+ if (typeof latestPackageId !== "string") {
9184
+ throw new Error("Asset manager id invalid (latest package id is not a string)");
9185
+ }
9186
+ if (!latestPackageId) {
9187
+ throw new Error("Asset manager id not found (no latest package id)");
9188
+ }
9189
+ return latestPackageId.toString();
9350
9190
  }
9351
9191
  /**
9352
9192
  * Transfers tokens to the hub chain.
9353
- * @param {InjectiveTransferToHubParams} params - The parameters for the transfer, including:
9193
+ * @param {SuiTransferToHubParams} params - The parameters for the transfer, including:
9354
9194
  * - {string} token: The address of the token to transfer (use address(0) for native token).
9355
9195
  * - {Uint8Array} recipient: The recipient address on the hub chain.
9356
9196
  * - {string} amount: The amount to transfer.
9357
9197
  * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
9358
- * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9198
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9359
9199
  * @param {boolean} raw - The return type raw or just transaction hash
9360
- * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9200
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9361
9201
  */
9362
9202
  static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
9363
- const sender = await spokeProvider.walletProvider.getWalletAddress();
9364
- return InjectiveSpokeProvider.deposit(sender, token, recipient, amount, data, spokeProvider, raw);
9203
+ return spokeProvider.transfer(token, amount, viem.fromHex(recipient, "bytes"), viem.fromHex(data, "bytes"), raw);
9365
9204
  }
9366
9205
  /**
9367
9206
  * Sends a message to the hub chain.
9368
9207
  * @param {bigint} dstChainId - The chain ID of the hub chain.
9369
- * @param {Address} dstAddress - The address on the hub chain.
9208
+ * @param {HubAddress} dstAddress - The address on the hub chain.
9370
9209
  * @param {Hex} payload - The payload to send.
9371
- * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9372
- * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9210
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9211
+ * @param {boolean} raw - The return type raw or just transaction hash
9212
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9373
9213
  */
9374
9214
  static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
9375
- const sender = await spokeProvider.walletProvider.getWalletAddress();
9376
- return spokeProvider.send_message(sender, dstChainId.toString(), dstAddress, payload, raw);
9215
+ return spokeProvider.sendMessage(dstChainId, viem.fromHex(dstAddress, "bytes"), viem.fromHex(payload, "bytes"), raw);
9377
9216
  }
9378
9217
  };
9379
9218
 
9380
- // src/utils/icon-utils.ts
9219
+ // src/entities/sui/SuiSpokeProvider.ts
9220
+ var SuiSpokeProvider = class _SuiSpokeProvider {
9221
+ walletProvider;
9222
+ chainConfig;
9223
+ publicClient;
9224
+ assetManagerAddress;
9225
+ constructor(config, wallet_provider) {
9226
+ this.chainConfig = config;
9227
+ this.walletProvider = wallet_provider;
9228
+ this.publicClient = new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
9229
+ }
9230
+ async getBalance(token) {
9231
+ const assetmanager = this.splitAddress(await this.getAssetManagerAddress());
9232
+ const tx = new transactions.Transaction();
9233
+ const result = await this.walletProvider.viewContract(
9234
+ tx,
9235
+ assetmanager.packageId,
9236
+ assetmanager.moduleId,
9237
+ "get_token_balance",
9238
+ [tx.object(assetmanager.stateId)],
9239
+ [token]
9240
+ );
9241
+ if (!Array.isArray(result?.returnValues) || !Array.isArray(result.returnValues[0]) || result.returnValues[0][0] === void 0) {
9242
+ throw new Error("Failed to get Balance");
9243
+ }
9244
+ const val = result.returnValues[0][0];
9245
+ const str_u64 = bcs.bcs.U64.parse(Uint8Array.from(val));
9246
+ return BigInt(str_u64);
9247
+ }
9248
+ async transfer(token, amount, to, data, raw) {
9249
+ const isNative2 = token.toLowerCase() === this.chainConfig.nativeToken.toLowerCase();
9250
+ const tx = new transactions.Transaction();
9251
+ const walletAddress = await this.walletProvider.getWalletAddressBytes();
9252
+ const coin = isNative2 ? await this.getNativeCoin(tx, amount) : await this.getCoin(tx, token, amount, walletAddress);
9253
+ const connection = this.splitAddress(this.chainConfig.addresses.connection);
9254
+ const assetManager = this.splitAddress(await this.getAssetManagerAddress());
9255
+ tx.moveCall({
9256
+ target: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
9257
+ typeArguments: [token],
9258
+ arguments: [
9259
+ tx.object(assetManager.stateId),
9260
+ tx.object(connection.stateId),
9261
+ // Connection state object
9262
+ coin,
9263
+ tx.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(to)),
9264
+ tx.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(data))
9265
+ ]
9266
+ });
9267
+ if (raw) {
9268
+ tx.setSender(walletAddress);
9269
+ const transactionRaw = await tx.build({
9270
+ client: this.publicClient,
9271
+ onlyTransactionKind: true
9272
+ });
9273
+ const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
9274
+ return {
9275
+ from: walletAddress,
9276
+ to: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
9277
+ value: amount,
9278
+ data: transactionRawBase64String
9279
+ };
9280
+ }
9281
+ return this.walletProvider.signAndExecuteTxn(tx);
9282
+ }
9283
+ async getNativeCoin(tx, amount) {
9284
+ const coin = tx.splitCoins(tx.gas, [tx.pure.u64(amount)])[0];
9285
+ if (coin === void 0) {
9286
+ return Promise.reject(Error("[SuiIntentService.getNativeCoin] coin undefined"));
9287
+ }
9288
+ return coin;
9289
+ }
9290
+ async getCoin(tx, coin, amount, address) {
9291
+ const coins = await this.walletProvider.getCoins(address, coin);
9292
+ const objects = [];
9293
+ let totalAmount = BigInt(0);
9294
+ for (const coin2 of coins.data) {
9295
+ totalAmount += BigInt(coin2.balance);
9296
+ objects.push(coin2.coinObjectId);
9297
+ if (totalAmount >= amount) {
9298
+ break;
9299
+ }
9300
+ }
9301
+ const firstObject = objects[0];
9302
+ if (!firstObject) {
9303
+ throw new Error(`[SuiIntentService.getCoin] Coin=${coin} not found for address=${address} and amount=${amount}`);
9304
+ }
9305
+ if (objects.length > 1) {
9306
+ tx.mergeCoins(firstObject, objects.slice(1));
9307
+ }
9308
+ if (totalAmount === amount) {
9309
+ return tx.object(firstObject);
9310
+ }
9311
+ return tx.splitCoins(firstObject, [amount]);
9312
+ }
9313
+ splitAddress(address) {
9314
+ const parts = address.split("::");
9315
+ if (parts.length === 3) {
9316
+ if (parts[0] && parts[1] && parts[2]) {
9317
+ return { packageId: parts[0], moduleId: parts[1], stateId: parts[2] };
9318
+ }
9319
+ throw new Error("Invalid package address");
9320
+ }
9321
+ throw new Error("Invalid package address");
9322
+ }
9323
+ async sendMessage(dst_chain_id, dst_address, data, raw) {
9324
+ const txb = new transactions.Transaction();
9325
+ const connection = this.splitAddress(this.chainConfig.addresses.connection);
9326
+ txb.moveCall({
9327
+ target: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
9328
+ arguments: [
9329
+ txb.object(connection.stateId),
9330
+ txb.pure.u256(dst_chain_id),
9331
+ txb.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(dst_address)),
9332
+ txb.pure(bcs.bcs.vector(bcs.bcs.u8()).serialize(data))
9333
+ ]
9334
+ });
9335
+ const walletAddress = await this.walletProvider.getWalletAddress();
9336
+ if (raw) {
9337
+ txb.setSender(walletAddress);
9338
+ const transactionRaw = await txb.build({
9339
+ client: this.publicClient,
9340
+ onlyTransactionKind: true
9341
+ });
9342
+ const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
9343
+ return {
9344
+ from: walletAddress,
9345
+ to: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
9346
+ value: 0n,
9347
+ data: transactionRawBase64String
9348
+ };
9349
+ }
9350
+ return this.walletProvider.signAndExecuteTxn(txb);
9351
+ }
9352
+ async configureAssetManagerHub(hubNetworkId, hubAssetManager) {
9353
+ const tx = new transactions.Transaction();
9354
+ const assetmanager = this.splitAddress(await this.getAssetManagerAddress());
9355
+ tx.moveCall({
9356
+ target: `${assetmanager.packageId}::${assetmanager.moduleId}::set_hub_details`,
9357
+ arguments: [tx.object(assetmanager.stateId), tx.pure.u64(hubNetworkId), tx.pure.vector("u8", hubAssetManager)]
9358
+ });
9359
+ const result = await this.walletProvider.signAndExecuteTxn(tx);
9360
+ return result;
9361
+ }
9362
+ async getWalletAddress() {
9363
+ return this.walletProvider.getWalletAddress();
9364
+ }
9365
+ async getWalletAddressBytes() {
9366
+ const address = await this.getWalletAddress();
9367
+ return _SuiSpokeProvider.getAddressBCSBytes(address);
9368
+ }
9369
+ static getAddressBCSBytes(suiaddress) {
9370
+ return viem.toHex(bcs.bcs.Address.serialize(suiaddress).toBytes());
9371
+ }
9372
+ async getAssetManagerAddress() {
9373
+ if (!this.assetManagerAddress) {
9374
+ this.assetManagerAddress = await SuiSpokeService.fetchAssetManagerAddress(this);
9375
+ }
9376
+ return this.assetManagerAddress.toString();
9377
+ }
9378
+ };
9379
+
9380
+ // src/entities/solana/SolanaSpokeProvider.ts
9381
+ var SolanaSpokeProvider = class {
9382
+ walletProvider;
9383
+ chainConfig;
9384
+ constructor(walletProvider, chainConfig) {
9385
+ this.walletProvider = walletProvider;
9386
+ this.chainConfig = chainConfig;
9387
+ }
9388
+ };
9389
+ var solanaSpokeChainConfig = spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID];
9390
+ function getSolanaAddressBytes(address) {
9391
+ return `0x${Buffer.from(address.toBytes()).toString("hex")}`;
9392
+ }
9393
+ function isNative(address) {
9394
+ if (address.equals(new web3_js.PublicKey(solanaSpokeChainConfig.nativeToken))) {
9395
+ return true;
9396
+ }
9397
+ return false;
9398
+ }
9399
+ function convertTransactionInstructionToRaw(instruction) {
9400
+ return {
9401
+ keys: instruction.keys.map((key) => ({
9402
+ pubkey: key.pubkey.toBase58(),
9403
+ isSigner: key.isSigner,
9404
+ isWritable: key.isWritable
9405
+ })),
9406
+ programId: instruction.programId.toBase58(),
9407
+ data: instruction.data
9408
+ };
9409
+ }
9410
+
9411
+ // src/entities/icon/HanaWalletConnector.ts
9412
+ function requestAddress() {
9413
+ return new Promise((resolve) => {
9414
+ const eventHandler = (event) => {
9415
+ const customEvent = event;
9416
+ const response = customEvent.detail;
9417
+ if (isResponseAddressType(response)) {
9418
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9419
+ resolve({
9420
+ ok: true,
9421
+ value: response.payload
9422
+ });
9423
+ }
9424
+ };
9425
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9426
+ window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9427
+ window.dispatchEvent(
9428
+ new CustomEvent("ICONEX_RELAY_REQUEST", {
9429
+ detail: {
9430
+ type: "REQUEST_ADDRESS"
9431
+ }
9432
+ })
9433
+ );
9434
+ });
9435
+ }
9436
+ function requestSigning(from, hash) {
9437
+ return new Promise((resolve, reject) => {
9438
+ const signRequest = new CustomEvent("ICONEX_RELAY_REQUEST", {
9439
+ detail: {
9440
+ type: "REQUEST_SIGNING",
9441
+ payload: {
9442
+ from,
9443
+ hash
9444
+ }
9445
+ }
9446
+ });
9447
+ const eventHandler = (event) => {
9448
+ const customEvent = event;
9449
+ const response = customEvent.detail;
9450
+ if (isResponseSigningType(response)) {
9451
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9452
+ resolve({
9453
+ ok: true,
9454
+ value: response.payload
9455
+ });
9456
+ } else if (response.type === "CANCEL_SIGNING") {
9457
+ reject(new Error("CANCEL_SIGNING"));
9458
+ }
9459
+ };
9460
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9461
+ window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9462
+ window.dispatchEvent(signRequest);
9463
+ });
9464
+ }
9465
+ function requestJsonRpc(rawTransaction, id = 99999) {
9466
+ return new Promise((resolve, reject) => {
9467
+ const eventHandler = (event) => {
9468
+ const customEvent = event;
9469
+ const { type, payload } = customEvent.detail;
9470
+ if (type === "RESPONSE_JSON-RPC") {
9471
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9472
+ if (isJsonRpcPayloadResponse(payload)) {
9473
+ resolve({
9474
+ ok: true,
9475
+ value: payload
9476
+ });
9477
+ } else {
9478
+ reject(new Error("Invalid payload response type (expected JsonRpcPayloadResponse)"));
9479
+ }
9480
+ } else if (type === "CANCEL_JSON-RPC") {
9481
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9482
+ reject(new Error("CANCEL_JSON-RPC"));
9483
+ }
9484
+ };
9485
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9486
+ window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9487
+ window.dispatchEvent(
9488
+ new CustomEvent("ICONEX_RELAY_REQUEST", {
9489
+ detail: {
9490
+ type: "REQUEST_JSON-RPC",
9491
+ payload: {
9492
+ jsonrpc: "2.0",
9493
+ method: "icx_sendTransaction",
9494
+ params: rawTransaction,
9495
+ id
9496
+ }
9497
+ }
9498
+ })
9499
+ );
9500
+ });
9501
+ }
9502
+ var EvmSpokeService = class _EvmSpokeService {
9503
+ constructor() {
9504
+ }
9505
+ /**
9506
+ * Estimates the gas necessary to complete a transaction without submitting it to the network.
9507
+ *
9508
+ * - Docs: https://viem.sh/docs/actions/public/estimateGas
9509
+ * - JSON-RPC Methods: [`eth_estimateGas`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)
9510
+ *
9511
+ * @param {EvmRawTransaction} rawTx - The raw transaction to estimate the gas for.
9512
+ * @param {EvmSpokeProvider} spokeProvider - The EVM spoke provider.
9513
+ * @returns {Promise<bigint>} Estimated gas for the transaction.
9514
+ *
9515
+ * @example
9516
+ *
9517
+ * const rawTx: EvmRawTransaction = {
9518
+ * from: '0x1234...abcd', // sender address
9519
+ * to: '0xabcd...1234', // recipient address
9520
+ * value: 1000000000000000000n, // 1 ETH in wei
9521
+ * data: '0x', // no calldata
9522
+ * };
9523
+ *
9524
+ * // Assume spokeProvider is an initialized EvmSpokeProvider
9525
+ * const estimatedGas = await EvmSpokeService.estimateGas(rawTx, spokeProvider);
9526
+ * console.log(`Estimated gas: ${estimatedGas}`);
9527
+ */
9528
+ static async estimateGas(rawTx, spokeProvider) {
9529
+ return spokeProvider.publicClient.estimateGas({
9530
+ account: rawTx.from,
9531
+ to: rawTx.to,
9532
+ value: rawTx.value,
9533
+ data: rawTx.data
9534
+ });
9535
+ }
9536
+ /**
9537
+ * Deposit tokens to the spoke chain.
9538
+ * @param {EvmSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9539
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9540
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9541
+ * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9542
+ */
9543
+ static async deposit(params, spokeProvider, hubProvider, raw) {
9544
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9545
+ spokeProvider.chainConfig.chain.id,
9546
+ params.from,
9547
+ hubProvider
9548
+ );
9549
+ return _EvmSpokeService.transfer(
9550
+ {
9551
+ token: params.token,
9552
+ recipient: to,
9553
+ amount: params.amount,
9554
+ data: params.data
9555
+ },
9556
+ spokeProvider,
9557
+ raw
9558
+ );
9559
+ }
9560
+ /**
9561
+ * Get the balance of the token in the spoke chain.
9562
+ * @param {Address} token - The address of the token to get the balance of.
9563
+ * @param {EvmSpokeProvider} spokeProvider - The spoke provider.
9564
+ * @returns {Promise<bigint>} The balance of the token.
9565
+ */
9566
+ static async getDeposit(token, spokeProvider) {
9567
+ return spokeProvider.publicClient.readContract({
9568
+ address: token,
9569
+ abi: erc20Abi,
9570
+ functionName: "balanceOf",
9571
+ args: [spokeProvider.chainConfig.addresses.assetManager]
9572
+ });
9573
+ }
9574
+ /**
9575
+ * Generate simulation parameters for deposit from EvmSpokeDepositParams.
9576
+ * @param {EvmSpokeDepositParams} params - The deposit parameters.
9577
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9578
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9579
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9580
+ */
9581
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9582
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9583
+ spokeProvider.chainConfig.chain.id,
9584
+ params.from,
9585
+ hubProvider
9586
+ );
9587
+ return {
9588
+ spokeChainID: spokeProvider.chainConfig.chain.id,
9589
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9590
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9591
+ to,
9592
+ amount: params.amount,
9593
+ data: params.data,
9594
+ srcAddress: encodeAddress(
9595
+ spokeProvider.chainConfig.chain.id,
9596
+ spokeProvider.chainConfig.addresses.assetManager
9597
+ )
9598
+ };
9599
+ }
9600
+ /**
9601
+ * Calls a contract on the spoke chain using the user's wallet.
9602
+ * @param {HubAddress} from - The address of the user on the hub chain.
9603
+ * @param {Hex} payload - The payload to send to the contract.
9604
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9605
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9606
+ * @param {boolean} raw - The return type raw or just transaction hash
9607
+ * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9608
+ */
9609
+ static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
9610
+ const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9611
+ const result = await _EvmSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9612
+ return result;
9613
+ }
9614
+ /**
9615
+ * Transfers tokens to the hub chain.
9616
+ * @param {EvmTransferToHubParams} params - The parameters for the transfer, including:
9617
+ * - {Address} token: The address of the token to transfer (use address(0) for native token).
9618
+ * - {Address} recipient: The recipient address on the hub chain.
9619
+ * - {bigint} amount: The amount to transfer.
9620
+ * - {Hex} [data="0x"]: Additional data for the transfer.
9621
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9622
+ * @param {boolean} raw - The return type raw or just transaction hash
9623
+ * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9624
+ */
9625
+ static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
9626
+ const txPayload = {
9627
+ address: spokeProvider.chainConfig.addresses.assetManager,
9628
+ value: token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase() ? amount : void 0
9629
+ };
9630
+ const from = await spokeProvider.walletProvider.getWalletAddress();
9631
+ const rawTx = {
9632
+ from,
9633
+ to: txPayload.address,
9634
+ value: txPayload.value ?? 0n,
9635
+ data: viem.encodeFunctionData({
9636
+ abi: spokeAssetManagerAbi,
9637
+ functionName: "transfer",
9638
+ args: [token, recipient, amount, data]
9639
+ })
9640
+ };
9641
+ if (raw) {
9642
+ return rawTx;
9643
+ }
9644
+ return spokeProvider.walletProvider.sendTransaction(rawTx);
9645
+ }
9646
+ /**
9647
+ * Sends a message to the hub chain.
9648
+ * @param {bigint} dstChainId - The chain ID of the hub chain.
9649
+ * @param {Address} dstAddress - The address on the hub chain.
9650
+ * @param {Hex} payload - The payload to send.
9651
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9652
+ * @param {boolean} raw - The return type raw or just transaction hash
9653
+ * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash.
9654
+ */
9655
+ static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
9656
+ const txPayload = {
9657
+ address: spokeProvider.chainConfig.addresses.connection};
9658
+ const from = await spokeProvider.walletProvider.getWalletAddress();
9659
+ const rawTx = {
9660
+ from,
9661
+ to: txPayload.address,
9662
+ value: 0n,
9663
+ data: viem.encodeFunctionData({
9664
+ abi: connectionAbi,
9665
+ functionName: "sendMessage",
9666
+ args: [dstChainId, dstAddress, payload]
9667
+ })
9668
+ };
9669
+ if (raw) {
9670
+ return rawTx;
9671
+ }
9672
+ return spokeProvider.walletProvider.sendTransaction(rawTx);
9673
+ }
9674
+ };
9675
+ var InjectiveSpokeService = class _InjectiveSpokeService {
9676
+ constructor() {
9677
+ }
9678
+ /**
9679
+ * Estimate the gas for a transaction.
9680
+ * @param {InjectiveRawTransaction} rawTx - The raw transaction to estimate the gas for.
9681
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9682
+ * @returns {Promise<InjectiveGasEstimate>} The estimated gas for the transaction.
9683
+ */
9684
+ static async estimateGas(rawTx, spokeProvider) {
9685
+ const txRaw = coreProtoTs.CosmosTxV1Beta1Tx.TxRaw.fromPartial({
9686
+ bodyBytes: rawTx.signedDoc.bodyBytes,
9687
+ authInfoBytes: rawTx.signedDoc.authInfoBytes,
9688
+ signatures: []
9689
+ // not required for simulation
9690
+ });
9691
+ const { gasInfo } = await spokeProvider.txClient.simulate(txRaw);
9692
+ return {
9693
+ gasWanted: gasInfo.gasWanted,
9694
+ gasUsed: gasInfo.gasUsed
9695
+ };
9696
+ }
9697
+ /**
9698
+ * Deposit tokens to the spoke chain.
9699
+ * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9700
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9701
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9702
+ * @param {boolean} raw - The return type raw or just transaction hash
9703
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9704
+ */
9705
+ static async deposit(params, spokeProvider, hubProvider, raw) {
9706
+ const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9707
+ spokeProvider.chainConfig.chain.id,
9708
+ viem.toHex(Buffer.from(params.from, "utf-8")),
9709
+ hubProvider
9710
+ );
9711
+ return _InjectiveSpokeService.transfer(
9712
+ {
9713
+ token: params.token,
9714
+ recipient: userWallet,
9715
+ amount: params.amount.toString(),
9716
+ data: params.data
9717
+ },
9718
+ spokeProvider,
9719
+ raw
9720
+ );
9721
+ }
9722
+ /**
9723
+ * Generate simulation parameters for deposit from InjectiveSpokeDepositParams.
9724
+ * @param {InjectiveSpokeDepositParams} params - The deposit parameters.
9725
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9726
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9727
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9728
+ */
9729
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9730
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9731
+ spokeProvider.chainConfig.chain.id,
9732
+ viem.toHex(Buffer.from(params.from, "utf-8")),
9733
+ hubProvider
9734
+ );
9735
+ return {
9736
+ spokeChainID: spokeProvider.chainConfig.chain.id,
9737
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9738
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9739
+ to,
9740
+ amount: params.amount,
9741
+ data: params.data,
9742
+ srcAddress: encodeAddress(
9743
+ spokeProvider.chainConfig.chain.id,
9744
+ spokeProvider.chainConfig.addresses.assetManager
9745
+ )
9746
+ };
9747
+ }
9748
+ /**
9749
+ * Get the balance of the token that deposited in the spoke chain Asset Manager.
9750
+ * @param {Address} token - The address of the token to get the balance of.
9751
+ * @param {InjectiveSpokeProvider} spokeProvider - The spoke provider.
9752
+ * @returns {Promise<bigint>} The balance of the token.
9753
+ */
9754
+ static async getDeposit(token, spokeProvider) {
9755
+ const bal = await spokeProvider.getBalance(token);
9756
+ return BigInt(bal);
9757
+ }
9758
+ /**
9759
+ * Calls a contract on the spoke chain using the user's wallet.
9760
+ * @param {HubAddress} from - The address of the user on the hub chain.
9761
+ * @param {Hex} payload - The payload to send to the contract.
9762
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9763
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9764
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9765
+ */
9766
+ static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
9767
+ const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9768
+ return _InjectiveSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9769
+ }
9770
+ /**
9771
+ * Transfers tokens to the hub chain.
9772
+ * @param {InjectiveTransferToHubParams} params - The parameters for the transfer, including:
9773
+ * - {string} token: The address of the token to transfer (use address(0) for native token).
9774
+ * - {Uint8Array} recipient: The recipient address on the hub chain.
9775
+ * - {string} amount: The amount to transfer.
9776
+ * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
9777
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9778
+ * @param {boolean} raw - The return type raw or just transaction hash
9779
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9780
+ */
9781
+ static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
9782
+ const sender = await spokeProvider.walletProvider.getWalletAddress();
9783
+ return InjectiveSpokeProvider.deposit(sender, token, recipient, amount, data, spokeProvider, raw);
9784
+ }
9785
+ /**
9786
+ * Sends a message to the hub chain.
9787
+ * @param {bigint} dstChainId - The chain ID of the hub chain.
9788
+ * @param {Address} dstAddress - The address on the hub chain.
9789
+ * @param {Hex} payload - The payload to send.
9790
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9791
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9792
+ */
9793
+ static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
9794
+ const sender = await spokeProvider.walletProvider.getWalletAddress();
9795
+ return spokeProvider.send_message(sender, dstChainId.toString(), dstAddress, payload, raw);
9796
+ }
9797
+ };
9798
+
9799
+ // src/utils/icon-utils.ts
9381
9800
  async function estimateStepCost(rawTx, debugRpcUrl) {
9382
9801
  try {
9383
9802
  const tmpRawTx = { ...rawTx };
@@ -9662,18 +10081,14 @@ var SolanaSpokeService = class _SolanaSpokeService {
9662
10081
  );
9663
10082
  }
9664
10083
  static async getDeposit(token, spokeProvider) {
9665
- const assetManagerProgram = await getAssetManagerProgram(
9666
- spokeProvider.walletProvider.getWalletBase58PublicKey(),
9667
- spokeProvider.chainConfig.rpcUrl,
9668
- spokeProvider.chainConfig.addresses.assetManager
9669
- );
9670
- const solToken = new web3_js.PublicKey(Buffer.from(token, "hex"));
10084
+ const assetManagerProgramId = new web3_js.PublicKey(spokeProvider.chainConfig.addresses.assetManager);
10085
+ const solToken = new web3_js.PublicKey(token);
9671
10086
  if (isNative(new web3_js.PublicKey(solToken))) {
9672
- const vaultNative = AssetManagerPDA.vault_native(assetManagerProgram.programId);
10087
+ const vaultNative = AssetManagerPDA.vault_native(assetManagerProgramId);
9673
10088
  const balance = await spokeProvider.walletProvider.getBalance(vaultNative.pda.toBase58());
9674
10089
  return BigInt(balance);
9675
10090
  }
9676
- const vaultToken = AssetManagerPDA.vault_token(assetManagerProgram.programId, new web3_js.PublicKey(solToken));
10091
+ const vaultToken = AssetManagerPDA.vault_token(assetManagerProgramId, new web3_js.PublicKey(solToken));
9677
10092
  const tokenAccount = await spokeProvider.walletProvider.getTokenAccountBalance(vaultToken.pda.toBase58());
9678
10093
  return BigInt(tokenAccount.value.amount);
9679
10094
  }
@@ -9881,6 +10296,12 @@ var StellarSpokeService = class _StellarSpokeService {
9881
10296
  raw
9882
10297
  );
9883
10298
  }
10299
+ /**
10300
+ * Get the balance of the token in the spoke chain asset manager.
10301
+ * @param token - The address of the token to get the balance of.
10302
+ * @param spokeProvider - The spoke provider.
10303
+ * @returns The balance of the token.
10304
+ */
9884
10305
  static async getDeposit(token, spokeProvider) {
9885
10306
  return BigInt(await spokeProvider.getBalance(token));
9886
10307
  }
@@ -9929,131 +10350,16 @@ var StellarSpokeService = class _StellarSpokeService {
9929
10350
  amount.toString(),
9930
10351
  viem.fromHex(recipient, "bytes"),
9931
10352
  viem.fromHex(data, "bytes"),
9932
- raw
9933
- );
9934
- }
9935
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
9936
- return await spokeProvider.sendMessage(
9937
- dstChainId.toString(),
9938
- viem.fromHex(dstAddress, "bytes"),
9939
- viem.fromHex(payload, "bytes"),
9940
- raw
9941
- );
9942
- }
9943
- };
9944
- var SuiSpokeService = class _SuiSpokeService {
9945
- constructor() {
9946
- }
9947
- /**
9948
- * Estimate the gas for a transaction.
9949
- * @param {SuiRawTransaction} rawTx - The raw transaction to estimate the gas for.
9950
- * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
9951
- * @returns {Promise<bigint>} The estimated computation cost.
9952
- */
9953
- static async estimateGas(rawTx, spokeProvider) {
9954
- const txb = transactions.Transaction.fromKind(rawTx.data);
9955
- const result = await spokeProvider.publicClient.devInspectTransactionBlock({
9956
- sender: rawTx.from,
9957
- transactionBlock: txb
9958
- });
9959
- return result.effects.gasUsed;
9960
- }
9961
- /**
9962
- * Deposit tokens to the spoke chain.
9963
- * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9964
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9965
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9966
- * @param {boolean} raw - The return type raw or just transaction hash
9967
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9968
- */
9969
- static async deposit(params, spokeProvider, hubProvider, raw) {
9970
- const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9971
- spokeProvider.chainConfig.chain.id,
9972
- params.from,
9973
- hubProvider
9974
- );
9975
- return _SuiSpokeService.transfer(
9976
- {
9977
- token: params.token,
9978
- recipient: userWallet,
9979
- amount: params.amount,
9980
- data: params.data
9981
- },
9982
- spokeProvider,
9983
- raw
9984
- );
9985
- }
9986
- /**
9987
- * Get the balance of the token in the spoke chain.
9988
- * @param {Address} token - The address of the token to get the balance of.
9989
- * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
9990
- * @returns {Promise<bigint>} The balance of the token.
9991
- */
9992
- static async getDeposit(token, spokeProvider) {
9993
- return spokeProvider.getBalance(token);
9994
- }
9995
- /**
9996
- * Generate simulation parameters for deposit from SuiSpokeDepositParams.
9997
- * @param {SuiSpokeDepositParams} params - The deposit parameters.
9998
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9999
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
10000
- * @returns {Promise<DepositSimulationParams>} The simulation parameters.
10001
- */
10002
- static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
10003
- const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
10004
- spokeProvider.chainConfig.chain.id,
10005
- params.from,
10006
- hubProvider
10007
- );
10008
- const encoder = new TextEncoder();
10009
- return {
10010
- spokeChainID: spokeProvider.chainConfig.chain.id,
10011
- token: viem.toHex(encoder.encode(params.token)),
10012
- from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
10013
- to,
10014
- amount: params.amount,
10015
- data: params.data,
10016
- srcAddress: viem.toHex(encoder.encode(spokeProvider.chainConfig.addresses.assetManagerId))
10017
- };
10018
- }
10019
- /**
10020
- * Calls a contract on the spoke chain using the user's wallet.
10021
- * @param {HubAddress} from - The address of the user on the spoke chain.
10022
- * @param {Hex} payload - The payload to send to the contract.
10023
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
10024
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
10025
- * @param {boolean} raw - The return type raw or just transaction hash
10026
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
10027
- */
10028
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
10029
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
10030
- return _SuiSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
10031
- }
10032
- /**
10033
- * Transfers tokens to the hub chain.
10034
- * @param {SuiTransferToHubParams} params - The parameters for the transfer, including:
10035
- * - {string} token: The address of the token to transfer (use address(0) for native token).
10036
- * - {Uint8Array} recipient: The recipient address on the hub chain.
10037
- * - {string} amount: The amount to transfer.
10038
- * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
10039
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
10040
- * @param {boolean} raw - The return type raw or just transaction hash
10041
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
10042
- */
10043
- static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
10044
- return spokeProvider.transfer(token, amount, viem.fromHex(recipient, "bytes"), viem.fromHex(data, "bytes"), raw);
10045
- }
10046
- /**
10047
- * Sends a message to the hub chain.
10048
- * @param {bigint} dstChainId - The chain ID of the hub chain.
10049
- * @param {HubAddress} dstAddress - The address on the hub chain.
10050
- * @param {Hex} payload - The payload to send.
10051
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
10052
- * @param {boolean} raw - The return type raw or just transaction hash
10053
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
10054
- */
10353
+ raw
10354
+ );
10355
+ }
10055
10356
  static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
10056
- return spokeProvider.sendMessage(dstChainId, viem.fromHex(dstAddress, "bytes"), viem.fromHex(payload, "bytes"), raw);
10357
+ return await spokeProvider.sendMessage(
10358
+ dstChainId.toString(),
10359
+ viem.fromHex(dstAddress, "bytes"),
10360
+ viem.fromHex(payload, "bytes"),
10361
+ raw
10362
+ );
10057
10363
  }
10058
10364
  };
10059
10365
  var SonicSpokeService = class _SonicSpokeService {
@@ -10112,7 +10418,7 @@ var SonicSpokeService = class _SonicSpokeService {
10112
10418
  * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash
10113
10419
  */
10114
10420
  static async deposit(params, spokeProvider, raw) {
10115
- invariant11__default.default(spokeProvider instanceof SonicSpokeProvider, "[SonicSpokeService] invalid spoke provider");
10421
+ invariant12__default.default(spokeProvider instanceof SonicSpokeProvider, "[SonicSpokeService] invalid spoke provider");
10116
10422
  const userHubAddress = params.to ?? await _SonicSpokeService.getUserRouter(params.from, spokeProvider);
10117
10423
  const calls = Array.from(
10118
10424
  viem.decodeAbiParameters(
@@ -10177,11 +10483,11 @@ var SonicSpokeService = class _SonicSpokeService {
10177
10483
  inputToken = hubProvider.chainConfig.nativeToken;
10178
10484
  }
10179
10485
  const outputToken = getHubAssetInfo(createIntentParams.dstChain, createIntentParams.outputToken)?.asset;
10180
- invariant11__default.default(
10486
+ invariant12__default.default(
10181
10487
  inputToken,
10182
10488
  `hub asset not found for spoke chain token (intent.inputToken): ${createIntentParams.inputToken}`
10183
10489
  );
10184
- invariant11__default.default(
10490
+ invariant12__default.default(
10185
10491
  outputToken,
10186
10492
  `hub asset not found for spoke chain token (intent.outputToken): ${createIntentParams.outputToken}`
10187
10493
  );
@@ -10244,7 +10550,7 @@ var SonicSpokeService = class _SonicSpokeService {
10244
10550
  * @returns {PromiseEvmTxReturnType<R>} A promise that resolves to the transaction hash
10245
10551
  */
10246
10552
  static async callWallet(payload, spokeProvider, raw) {
10247
- invariant11__default.default(spokeProvider instanceof SonicSpokeProvider, "[SonicSpokeService] invalid spoke provider");
10553
+ invariant12__default.default(spokeProvider instanceof SonicSpokeProvider, "[SonicSpokeService] invalid spoke provider");
10248
10554
  const calls = viem.decodeAbiParameters(
10249
10555
  [
10250
10556
  {
@@ -10733,11 +11039,8 @@ var SpokeService = class _SpokeService {
10733
11039
  */
10734
11040
  static async deposit(params, spokeProvider, hubProvider, raw, skipSimulation = false) {
10735
11041
  if (spokeProvider instanceof SonicSpokeProvider) {
10736
- return SonicSpokeService.deposit(
10737
- params,
10738
- spokeProvider,
10739
- raw
10740
- );
11042
+ const _params = params;
11043
+ return SonicSpokeService.deposit(_params, spokeProvider, raw);
10741
11044
  }
10742
11045
  if (spokeProvider instanceof EvmSpokeProvider) {
10743
11046
  await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
@@ -10762,7 +11065,6 @@ var SpokeService = class _SpokeService {
10762
11065
  );
10763
11066
  }
10764
11067
  if (spokeProvider instanceof SuiSpokeProvider) {
10765
- await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10766
11068
  return SuiSpokeService.deposit(
10767
11069
  params,
10768
11070
  spokeProvider,
@@ -10890,6 +11192,20 @@ var SpokeService = class _SpokeService {
10890
11192
  raw
10891
11193
  );
10892
11194
  }
11195
+ if (!skipSimulation) {
11196
+ const result = await _SpokeService.simulateRecvMessage(
11197
+ {
11198
+ target: from,
11199
+ srcChainId: getIntentRelayChainId(spokeProvider.chainConfig.chain.id),
11200
+ srcAddress: await spokeProvider.walletProvider.getWalletAddressBytes(),
11201
+ payload
11202
+ },
11203
+ hubProvider
11204
+ );
11205
+ if (!result.success) {
11206
+ throw new Error("Simulation failed", { cause: result });
11207
+ }
11208
+ }
10893
11209
  if (isEvmSpokeProvider(spokeProvider)) {
10894
11210
  await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10895
11211
  return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
@@ -10958,19 +11274,19 @@ async function postRequest(payload, apiUrl) {
10958
11274
  return response.json();
10959
11275
  }
10960
11276
  async function submitTransaction(payload, apiUrl) {
10961
- invariant11__default.default(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
10962
- invariant11__default.default(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
11277
+ invariant12__default.default(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
11278
+ invariant12__default.default(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
10963
11279
  return postRequest(payload, apiUrl);
10964
11280
  }
10965
11281
  async function getTransactionPackets(payload, apiUrl) {
10966
- invariant11__default.default(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
10967
- invariant11__default.default(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
11282
+ invariant12__default.default(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
11283
+ invariant12__default.default(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
10968
11284
  return postRequest(payload, apiUrl);
10969
11285
  }
10970
11286
  async function getPacket(payload, apiUrl) {
10971
- invariant11__default.default(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
10972
- invariant11__default.default(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
10973
- invariant11__default.default(payload.params.conn_sn.length > 0, "Invalid input parameters. conn_sn empty");
11287
+ invariant12__default.default(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
11288
+ invariant12__default.default(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
11289
+ invariant12__default.default(payload.params.conn_sn.length > 0, "Invalid input parameters. conn_sn empty");
10974
11290
  return postRequest(payload, apiUrl);
10975
11291
  }
10976
11292
  async function waitUntilIntentExecuted(payload) {
@@ -11101,11 +11417,11 @@ var EvmSolverService = class _EvmSolverService {
11101
11417
  inputToken = hubProvider.chainConfig.wrappedNativeToken;
11102
11418
  }
11103
11419
  const outputToken = getHubAssetInfo(createIntentParams.dstChain, createIntentParams.outputToken)?.asset;
11104
- invariant11__default.default(
11420
+ invariant12__default.default(
11105
11421
  inputToken,
11106
11422
  `hub asset not found for spoke chain token (intent.inputToken): ${createIntentParams.inputToken}`
11107
11423
  );
11108
- invariant11__default.default(
11424
+ invariant12__default.default(
11109
11425
  outputToken,
11110
11426
  `hub asset not found for spoke chain token (intent.outputToken): ${createIntentParams.outputToken}`
11111
11427
  );
@@ -11137,7 +11453,7 @@ var EvmSolverService = class _EvmSolverService {
11137
11453
  * @returns A tuple containing [encoded fee data, fee amount]. Fee amount will be 0n if no fee.
11138
11454
  */
11139
11455
  static createIntentFeeData(fee, inputAmount) {
11140
- invariant11__default.default(inputAmount > 0n, "Input amount must be greater than 0");
11456
+ invariant12__default.default(inputAmount > 0n, "Input amount must be greater than 0");
11141
11457
  if (!fee) {
11142
11458
  return ["0x", 0n];
11143
11459
  }
@@ -11145,7 +11461,7 @@ var EvmSolverService = class _EvmSolverService {
11145
11461
  if (isPartnerFeeAmount(fee)) {
11146
11462
  feeAmount = fee.amount;
11147
11463
  } else if (isPartnerFeePercentage(fee)) {
11148
- invariant11__default.default(
11464
+ invariant12__default.default(
11149
11465
  fee.percentage >= 0 && fee.percentage <= FEE_PERCENTAGE_SCALE,
11150
11466
  `Fee percentage must be between 0 and ${FEE_PERCENTAGE_SCALE}}`
11151
11467
  );
@@ -11272,23 +11588,23 @@ var SolverApiService = class {
11272
11588
  * }
11273
11589
  */
11274
11590
  static async getQuote(payload, config) {
11275
- invariant11__default.default(payload.token_src.length > 0, "Empty token_src");
11276
- invariant11__default.default(payload.token_src_blockchain_id.length > 0, "Empty token_src_blockchain_id");
11277
- invariant11__default.default(payload.token_dst.length > 0, "Empty token_dst");
11278
- invariant11__default.default(payload.token_dst_blockchain_id.length > 0, "Empty token_dst_blockchain_id");
11279
- invariant11__default.default(payload.amount > 0n, "amount must be greater than 0");
11280
- invariant11__default.default(
11591
+ invariant12__default.default(payload.token_src.length > 0, "Empty token_src");
11592
+ invariant12__default.default(payload.token_src_blockchain_id.length > 0, "Empty token_src_blockchain_id");
11593
+ invariant12__default.default(payload.token_dst.length > 0, "Empty token_dst");
11594
+ invariant12__default.default(payload.token_dst_blockchain_id.length > 0, "Empty token_dst_blockchain_id");
11595
+ invariant12__default.default(payload.amount > 0n, "amount must be greater than 0");
11596
+ invariant12__default.default(
11281
11597
  isValidOriginalAssetAddress(payload.token_src_blockchain_id, payload.token_src),
11282
11598
  "unsupported token_src for src chain"
11283
11599
  );
11284
- invariant11__default.default(
11600
+ invariant12__default.default(
11285
11601
  isValidOriginalAssetAddress(payload.token_dst_blockchain_id, payload.token_dst),
11286
11602
  "unsupported token_dst for dst chain"
11287
11603
  );
11288
11604
  const tokenSrc = getHubAssetInfo(payload.token_src_blockchain_id, payload.token_src)?.asset;
11289
11605
  const tokenDst = getHubAssetInfo(payload.token_dst_blockchain_id, payload.token_dst)?.asset;
11290
- invariant11__default.default(tokenSrc, "hub asset not found for token_src");
11291
- invariant11__default.default(tokenDst, "hub asset not found for token_dst");
11606
+ invariant12__default.default(tokenSrc, "hub asset not found for token_src");
11607
+ invariant12__default.default(tokenDst, "hub asset not found for token_dst");
11292
11608
  try {
11293
11609
  const response = await fetch(`${config.solverApiEndpoint}/quote`, {
11294
11610
  method: "POST",
@@ -11383,7 +11699,7 @@ var SolverApiService = class {
11383
11699
  }
11384
11700
  }
11385
11701
  static async getStatus(request, config) {
11386
- invariant11__default.default(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
11702
+ invariant12__default.default(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
11387
11703
  try {
11388
11704
  const response = await fetch(`${config.solverApiEndpoint}/status`, {
11389
11705
  method: "POST",
@@ -12015,19 +12331,19 @@ var SolverService = class {
12015
12331
  fee = this.config.partnerFee,
12016
12332
  raw
12017
12333
  }) {
12018
- invariant11__default.default(
12334
+ invariant12__default.default(
12019
12335
  isValidOriginalAssetAddress(params.srcChain, params.inputToken),
12020
12336
  `Unsupported spoke chain token (params.srcChain): ${params.srcChain}, params.inputToken): ${params.inputToken}`
12021
12337
  );
12022
- invariant11__default.default(
12338
+ invariant12__default.default(
12023
12339
  isValidOriginalAssetAddress(params.dstChain, params.outputToken),
12024
12340
  `Unsupported spoke chain token (params.dstChain): ${params.dstChain}, params.outputToken): ${params.outputToken}`
12025
12341
  );
12026
- invariant11__default.default(isValidSpokeChainId(params.srcChain), `Invalid spoke chain (params.srcChain): ${params.srcChain}`);
12027
- invariant11__default.default(isValidSpokeChainId(params.dstChain), `Invalid spoke chain (params.dstChain): ${params.dstChain}`);
12342
+ invariant12__default.default(isValidSpokeChainId(params.srcChain), `Invalid spoke chain (params.srcChain): ${params.srcChain}`);
12343
+ invariant12__default.default(isValidSpokeChainId(params.dstChain), `Invalid spoke chain (params.dstChain): ${params.dstChain}`);
12028
12344
  try {
12029
12345
  const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
12030
- invariant11__default.default(
12346
+ invariant12__default.default(
12031
12347
  params.srcAddress.toLowerCase() === walletAddress.toLowerCase(),
12032
12348
  "srcAddress must be the same as wallet address"
12033
12349
  );
@@ -12101,8 +12417,8 @@ var SolverService = class {
12101
12417
  */
12102
12418
  async cancelIntent(intent, spokeProvider, raw) {
12103
12419
  try {
12104
- invariant11__default.default(isValidIntentRelayChainId(intent.srcChain), `Invalid intent.srcChain: ${intent.srcChain}`);
12105
- invariant11__default.default(isValidIntentRelayChainId(intent.dstChain), `Invalid intent.dstChain: ${intent.dstChain}`);
12420
+ invariant12__default.default(isValidIntentRelayChainId(intent.srcChain), `Invalid intent.srcChain: ${intent.srcChain}`);
12421
+ invariant12__default.default(isValidIntentRelayChainId(intent.dstChain), `Invalid intent.dstChain: ${intent.dstChain}`);
12106
12422
  const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
12107
12423
  const creatorHubWalletAddress = await deriveUserWalletAddress(spokeProvider, this.hubProvider, walletAddress);
12108
12424
  const calls = [];
@@ -12149,7 +12465,7 @@ var SolverService = class {
12149
12465
  * @returns {bigint} The deadline for the swap as a sum of hub chain block timestamp and deadline offset
12150
12466
  */
12151
12467
  async getSwapDeadline(deadline = DEFAULT_DEADLINE_OFFSET) {
12152
- invariant11__default.default(deadline > 0n, "Deadline must be greater than 0");
12468
+ invariant12__default.default(deadline > 0n, "Deadline must be greater than 0");
12153
12469
  const block = await this.hubProvider.publicClient.getBlock({
12154
12470
  includeTransactions: false,
12155
12471
  blockTag: "latest"
@@ -12627,7 +12943,7 @@ var IcxMigrationService = class {
12627
12943
  migrateData(params) {
12628
12944
  const calls = [];
12629
12945
  const assetConfig = getHubAssetInfo(types.ICON_MAINNET_CHAIN_ID, params.address);
12630
- invariant11__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${params.address}`);
12946
+ invariant12__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${params.address}`);
12631
12947
  calls.push(
12632
12948
  Erc20Service.encodeApprove(assetConfig.asset, this.hubProvider.chainConfig.addresses.icxMigration, params.amount)
12633
12949
  );
@@ -12643,7 +12959,7 @@ var IcxMigrationService = class {
12643
12959
  revertMigration(params) {
12644
12960
  const calls = [];
12645
12961
  const assetConfig = getHubAssetInfo(types.ICON_MAINNET_CHAIN_ID, params.wICX);
12646
- invariant11__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${params.wICX}`);
12962
+ invariant12__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${params.wICX}`);
12647
12963
  calls.push(
12648
12964
  Erc20Service.encodeApprove(
12649
12965
  this.hubProvider.chainConfig.addresses.sodaToken,
@@ -12739,9 +13055,9 @@ var MigrationService = class {
12739
13055
  async isAllowanceValid(params, action, spokeProvider) {
12740
13056
  try {
12741
13057
  if (action === "migrate") {
12742
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
12743
- invariant11__default.default(viem.isAddress(params.to) || isIconAddress(params.to), "To address is required");
12744
- invariant11__default.default(
13058
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
13059
+ invariant12__default.default(viem.isAddress(params.to) || isIconAddress(params.to), "To address is required");
13060
+ invariant12__default.default(
12745
13061
  isIcxMigrateParams(params) || isBalnMigrateParams(params) || isUnifiedBnUSDMigrateParams(params),
12746
13062
  "Invalid params"
12747
13063
  );
@@ -12767,9 +13083,9 @@ var MigrationService = class {
12767
13083
  };
12768
13084
  }
12769
13085
  if (action === "revert") {
12770
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
12771
- invariant11__default.default(params.to.length > 0, "To address is required");
12772
- invariant11__default.default(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
13086
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
13087
+ invariant12__default.default(params.to.length > 0, "To address is required");
13088
+ invariant12__default.default(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
12773
13089
  if (spokeProvider instanceof SonicSpokeProvider && isIcxCreateRevertMigrationParams(params)) {
12774
13090
  const wallet = await spokeProvider.walletProvider.getWalletAddress();
12775
13091
  const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
@@ -12825,9 +13141,9 @@ var MigrationService = class {
12825
13141
  async approve(params, action, spokeProvider, raw) {
12826
13142
  try {
12827
13143
  if (action === "migrate") {
12828
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
12829
- invariant11__default.default(params.to.length > 0, "To address is required");
12830
- invariant11__default.default(isUnifiedBnUSDMigrateParams(params), "Invalid params");
13144
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
13145
+ invariant12__default.default(params.to.length > 0, "To address is required");
13146
+ invariant12__default.default(isUnifiedBnUSDMigrateParams(params), "Invalid params");
12831
13147
  if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
12832
13148
  const evmSpokeProvider = spokeProvider;
12833
13149
  const result = await Erc20Service.approve(
@@ -12848,9 +13164,9 @@ var MigrationService = class {
12848
13164
  };
12849
13165
  }
12850
13166
  if (action === "revert") {
12851
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
12852
- invariant11__default.default(params.to.length > 0, "To address is required");
12853
- invariant11__default.default(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
13167
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
13168
+ invariant12__default.default(params.to.length > 0, "To address is required");
13169
+ invariant12__default.default(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
12854
13170
  if (spokeProvider instanceof SonicSpokeProvider && isIcxCreateRevertMigrationParams(params)) {
12855
13171
  const wallet = await spokeProvider.walletProvider.getWalletAddress();
12856
13172
  const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
@@ -13262,13 +13578,13 @@ var MigrationService = class {
13262
13578
  async createMigratebnUSDIntent(params, spokeProvider, unchecked = false, raw) {
13263
13579
  try {
13264
13580
  if (!unchecked) {
13265
- invariant11__default.default(isValidSpokeChainId(params.srcChainId), "Invalid spoke source chain ID");
13266
- invariant11__default.default(isValidSpokeChainId(params.dstChainId), "Invalid spoke destination chain ID");
13267
- invariant11__default.default(params.srcbnUSD.length > 0, "Legacy bnUSD token address is required");
13268
- invariant11__default.default(params.dstbnUSD.length > 0, "New bnUSD token address is required");
13269
- invariant11__default.default(params.amount > 0, "Amount must be greater than 0");
13270
- invariant11__default.default(params.to.length > 0, "Recipient address is required");
13271
- invariant11__default.default(
13581
+ invariant12__default.default(isValidSpokeChainId(params.srcChainId), "Invalid spoke source chain ID");
13582
+ invariant12__default.default(isValidSpokeChainId(params.dstChainId), "Invalid spoke destination chain ID");
13583
+ invariant12__default.default(params.srcbnUSD.length > 0, "Legacy bnUSD token address is required");
13584
+ invariant12__default.default(params.dstbnUSD.length > 0, "New bnUSD token address is required");
13585
+ invariant12__default.default(params.amount > 0, "Amount must be greater than 0");
13586
+ invariant12__default.default(params.to.length > 0, "Recipient address is required");
13587
+ invariant12__default.default(
13272
13588
  !(isLegacybnUSDToken(params.srcbnUSD) && isLegacybnUSDToken(params.dstbnUSD)),
13273
13589
  "srcbnUSD and dstbnUSD cannot both be legacy bnUSD tokens"
13274
13590
  );
@@ -13276,11 +13592,11 @@ var MigrationService = class {
13276
13592
  let migrationData;
13277
13593
  if (isLegacybnUSDToken(params.srcbnUSD)) {
13278
13594
  if (!unchecked) {
13279
- invariant11__default.default(
13595
+ invariant12__default.default(
13280
13596
  isLegacybnUSDChainId(params.srcChainId),
13281
13597
  "srcChainId must be a legacy bnUSD chain (icon, sui, stellar) if srcbnUSD is a legacy bnUSD token"
13282
13598
  );
13283
- invariant11__default.default(
13599
+ invariant12__default.default(
13284
13600
  isNewbnUSDChainId(params.dstChainId),
13285
13601
  "dstChainId must be a new bnUSD chain (all spoke chains besides Icon) if dstbnUSD is a legacy bnUSD token"
13286
13602
  );
@@ -13295,15 +13611,15 @@ var MigrationService = class {
13295
13611
  });
13296
13612
  } else if (isLegacybnUSDToken(params.dstbnUSD)) {
13297
13613
  if (!unchecked) {
13298
- invariant11__default.default(
13614
+ invariant12__default.default(
13299
13615
  isLegacybnUSDChainId(params.dstChainId),
13300
13616
  "dstChainId must be a legacy bnUSD chain (sui, stellar, icon) if dstbnUSD is a legacy bnUSD token"
13301
13617
  );
13302
- invariant11__default.default(
13618
+ invariant12__default.default(
13303
13619
  isNewbnUSDToken(params.srcbnUSD),
13304
13620
  "srcbnUSD must be a new bnUSD token if dstbnUSD is a legacy bnUSD token"
13305
13621
  );
13306
- invariant11__default.default(
13622
+ invariant12__default.default(
13307
13623
  isNewbnUSDChainId(params.srcChainId),
13308
13624
  "srcChainId must be a new bnUSD chain (all spoke chains besides Icon) if srcbnUSD is a new bnUSD token"
13309
13625
  );
@@ -13376,13 +13692,13 @@ var MigrationService = class {
13376
13692
  */
13377
13693
  async createMigrateIcxToSodaIntent(params, spokeProvider, raw) {
13378
13694
  try {
13379
- invariant11__default.default(params.amount > 0, "Amount must be greater than 0");
13380
- invariant11__default.default(viem.isAddress(params.to), "Recipient address is required");
13381
- invariant11__default.default(
13695
+ invariant12__default.default(params.amount > 0, "Amount must be greater than 0");
13696
+ invariant12__default.default(viem.isAddress(params.to), "Recipient address is required");
13697
+ invariant12__default.default(
13382
13698
  params.address.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.address.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
13383
13699
  "Token must be wICX or native ICX token"
13384
13700
  );
13385
- invariant11__default.default(spokeProvider instanceof IconSpokeProvider, "Spoke provider must be an instance of IconSpokeProvider");
13701
+ invariant12__default.default(spokeProvider instanceof IconSpokeProvider, "Spoke provider must be an instance of IconSpokeProvider");
13386
13702
  const availableAmount = await this.icxMigration.getAvailableAmount();
13387
13703
  if (availableAmount < params.amount) {
13388
13704
  throw new Error(
@@ -13494,7 +13810,7 @@ var BnUSDMigrationService = class {
13494
13810
  migrateData(params) {
13495
13811
  const calls = [];
13496
13812
  const assetConfig = getHubAssetInfo(params.srcChainId, params.legacybnUSD);
13497
- invariant11__default.default(assetConfig, `hub asset not found for legacy bnUSD token: ${params.legacybnUSD}`);
13813
+ invariant12__default.default(assetConfig, `hub asset not found for legacy bnUSD token: ${params.legacybnUSD}`);
13498
13814
  const bnUSDVault = getMoneyMarketConfig(types.SONIC_MAINNET_CHAIN_ID).bnUSDVault;
13499
13815
  calls.push(Erc20Service.encodeApprove(assetConfig.asset, assetConfig.vault, params.amount));
13500
13816
  calls.push(EvmVaultTokenService.encodeDeposit(assetConfig.vault, assetConfig.asset, params.amount));
@@ -13506,7 +13822,7 @@ var BnUSDMigrationService = class {
13506
13822
  return encodeContractCalls(calls);
13507
13823
  }
13508
13824
  const dstAssetConfig = getHubAssetInfo(params.dstChainId, params.newbnUSD);
13509
- invariant11__default.default(dstAssetConfig, `hub asset not found for new bnUSD token: ${params.newbnUSD}`);
13825
+ invariant12__default.default(dstAssetConfig, `hub asset not found for new bnUSD token: ${params.newbnUSD}`);
13510
13826
  calls.push(EvmVaultTokenService.encodeWithdraw(bnUSDVault, dstAssetConfig.asset, translatedAmount));
13511
13827
  const translatedAmountOut = EvmVaultTokenService.translateOutgoingDecimals(
13512
13828
  dstAssetConfig.decimal,
@@ -13539,14 +13855,14 @@ var BnUSDMigrationService = class {
13539
13855
  let decimals = 18;
13540
13856
  if (params.newbnUSD.toLowerCase() !== bnUSDVault.toLowerCase()) {
13541
13857
  const assetConfig = getHubAssetInfo(params.srcChainId, params.newbnUSD);
13542
- invariant11__default.default(assetConfig, `hub asset not found for new bnUSD token: ${params.newbnUSD}`);
13858
+ invariant12__default.default(assetConfig, `hub asset not found for new bnUSD token: ${params.newbnUSD}`);
13543
13859
  decimals = assetConfig.decimal;
13544
13860
  calls.push(Erc20Service.encodeApprove(assetConfig.asset, bnUSDVault, params.amount));
13545
13861
  calls.push(EvmVaultTokenService.encodeDeposit(bnUSDVault, assetConfig.asset, params.amount));
13546
13862
  }
13547
13863
  const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(decimals, params.amount);
13548
13864
  const dstAssetConfig = getHubAssetInfo(params.dstChainId, params.legacybnUSD);
13549
- invariant11__default.default(dstAssetConfig, `hub asset not found for new bnUSD token: ${params.legacybnUSD}`);
13865
+ invariant12__default.default(dstAssetConfig, `hub asset not found for new bnUSD token: ${params.legacybnUSD}`);
13550
13866
  calls.push(EvmVaultTokenService.encodeWithdraw(bnUSDVault, dstAssetConfig.vault, translatedAmount));
13551
13867
  calls.push(EvmVaultTokenService.encodeWithdraw(dstAssetConfig.vault, dstAssetConfig.asset, translatedAmount));
13552
13868
  const translatedAmountOut = EvmVaultTokenService.translateOutgoingDecimals(
@@ -13629,7 +13945,7 @@ var BalnSwapService = class {
13629
13945
  */
13630
13946
  async swapData(balnToken, params) {
13631
13947
  const assetConfig = getHubAssetInfo(types.ICON_MAINNET_CHAIN_ID, balnToken);
13632
- invariant11__default.default(assetConfig, `hub asset not found for baln token: ${balnToken}`);
13948
+ invariant12__default.default(assetConfig, `hub asset not found for baln token: ${balnToken}`);
13633
13949
  const calls = [];
13634
13950
  calls.push(
13635
13951
  Erc20Service.encodeApprove(assetConfig.asset, this.hubProvider.chainConfig.addresses.balnSwap, params.amount)
@@ -13682,129 +13998,620 @@ var BalnSwapService = class {
13682
13998
  return await this.call(spokeProvider, unstakeTx, raw);
13683
13999
  }
13684
14000
  /**
13685
- * Gets detailed locks for a specific user including unstake requests and staked amounts.
14001
+ * Gets detailed locks for a specific user including unstake requests and staked amounts.
14002
+ *
14003
+ * @param publicClient - The public client for reading contract state
14004
+ * @param user - The user address
14005
+ * @returns Array of detailed lock information for the user
14006
+ */
14007
+ async getDetailedUserLocks(publicClient, user) {
14008
+ return await publicClient.readContract({
14009
+ address: this.hubProvider.chainConfig.addresses.balnSwap,
14010
+ abi: balnSwapAbi,
14011
+ functionName: "getDetailedUserLocks",
14012
+ args: [user]
14013
+ });
14014
+ }
14015
+ // ===== ENCODING METHODS =====
14016
+ /**
14017
+ * Encodes a swap transaction for the BALN swap contract.
14018
+ *
14019
+ * @param amount - The amount of BALN tokens to swap
14020
+ * @param lockupPeriod - The lockup period for the swap
14021
+ * @param to - The address that will receive the swapped SODA tokens
14022
+ * @param stake - Whether to stake the SODA tokens
14023
+ * @returns The encoded contract call for the swap operation
14024
+ */
14025
+ encodeSwap(amount, lockupPeriod, to, stake) {
14026
+ return {
14027
+ address: this.hubProvider.chainConfig.addresses.balnSwap,
14028
+ value: 0n,
14029
+ data: viem.encodeFunctionData({
14030
+ abi: balnSwapAbi,
14031
+ functionName: "swap",
14032
+ args: [amount, BigInt(lockupPeriod), to, stake]
14033
+ })
14034
+ };
14035
+ }
14036
+ /**
14037
+ * Encodes a claim transaction for the BALN swap contract.
14038
+ *
14039
+ * @param lockId - The lock ID to claim from
14040
+ * @returns The encoded contract call for the claim operation
14041
+ */
14042
+ encodeClaim(lockId) {
14043
+ return {
14044
+ address: this.hubProvider.chainConfig.addresses.balnSwap,
14045
+ value: 0n,
14046
+ data: viem.encodeFunctionData({
14047
+ abi: balnSwapAbi,
14048
+ functionName: "claim",
14049
+ args: [lockId]
14050
+ })
14051
+ };
14052
+ }
14053
+ /**
14054
+ * Encodes a claim unstaked transaction for the BALN swap contract.
14055
+ *
14056
+ * @param lockId - The lock ID to claim unstaked tokens from
14057
+ * @returns The encoded contract call for the claim unstaked operation
14058
+ */
14059
+ encodeClaimUnstaked(lockId) {
14060
+ return {
14061
+ address: this.hubProvider.chainConfig.addresses.balnSwap,
14062
+ value: 0n,
14063
+ data: viem.encodeFunctionData({
14064
+ abi: balnSwapAbi,
14065
+ functionName: "claimUnstaked",
14066
+ args: [lockId]
14067
+ })
14068
+ };
14069
+ }
14070
+ /**
14071
+ * Encodes a stake transaction for the BALN swap contract.
14072
+ *
14073
+ * @param lockId - The lock ID to stake
14074
+ * @returns The encoded contract call for the stake operation
14075
+ */
14076
+ encodeStake(lockId) {
14077
+ return {
14078
+ address: this.hubProvider.chainConfig.addresses.balnSwap,
14079
+ value: 0n,
14080
+ data: viem.encodeFunctionData({
14081
+ abi: balnSwapAbi,
14082
+ functionName: "stake",
14083
+ args: [lockId]
14084
+ })
14085
+ };
14086
+ }
14087
+ /**
14088
+ * Encodes an unstake transaction for the BALN swap contract.
14089
+ *
14090
+ * @param lockId - The lock ID to unstake
14091
+ * @returns The encoded contract call for the unstake operation
14092
+ */
14093
+ encodeUnstake(lockId) {
14094
+ return {
14095
+ address: this.hubProvider.chainConfig.addresses.balnSwap,
14096
+ value: 0n,
14097
+ data: viem.encodeFunctionData({
14098
+ abi: balnSwapAbi,
14099
+ functionName: "unstake",
14100
+ args: [lockId]
14101
+ })
14102
+ };
14103
+ }
14104
+ // ===== PRIVATE HELPER METHODS =====
14105
+ /**
14106
+ * Executes a contract call through the Sonic wallet provider.
14107
+ * @param spokeProvider - The Sonic spoke provider
14108
+ * @param rawTx - The raw contract call to execute
14109
+ * @param raw - Whether to return raw transaction data
14110
+ * @returns The transaction hash or raw transaction data
14111
+ */
14112
+ async call(spokeProvider, rawTx, raw) {
14113
+ const from = await spokeProvider.walletProvider.getWalletAddress();
14114
+ const tx = {
14115
+ from,
14116
+ to: rawTx.address,
14117
+ value: rawTx.value,
14118
+ data: rawTx.data
14119
+ };
14120
+ if (raw) {
14121
+ return tx;
14122
+ }
14123
+ return spokeProvider.walletProvider.sendTransaction(tx);
14124
+ }
14125
+ };
14126
+ var BridgeService = class {
14127
+ hubProvider;
14128
+ relayerApiEndpoint;
14129
+ config;
14130
+ constructor(hubProvider, relayerApiEndpoint, config = void 0) {
14131
+ this.config = config ? config : { partnerFee: void 0 };
14132
+ this.hubProvider = hubProvider;
14133
+ this.relayerApiEndpoint = relayerApiEndpoint;
14134
+ }
14135
+ /**
14136
+ * Get the fee for a given input amount
14137
+ * @param {bigint} inputAmount - The amount of input tokens
14138
+ * @returns {Promise<bigint>} The fee amount (denominated in input tokens)
14139
+ *
14140
+ * @example
14141
+ * const fee: bigint = await sodax.bridge.getFee(1000000000000000n);
14142
+ * console.log('Fee:', fee);
14143
+ */
14144
+ getFee(inputAmount) {
14145
+ if (!this.config.partnerFee) {
14146
+ return 0n;
14147
+ }
14148
+ return calculateFeeAmount(inputAmount, this.config.partnerFee);
14149
+ }
14150
+ /**
14151
+ * Check if allowance is valid for the bridge transaction
14152
+ * @param params - The bridge parameters
14153
+ * @param spokeProvider - The spoke provider
14154
+ * @returns {Promise<Result<boolean, BridgeError<'ALLOWANCE_CHECK_FAILED'>>>}
14155
+ */
14156
+ async isAllowanceValid({
14157
+ params,
14158
+ spokeProvider
14159
+ }) {
14160
+ try {
14161
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
14162
+ invariant12__default.default(params.srcAsset.length > 0, "Source asset is required");
14163
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
14164
+ if (spokeProvider instanceof EvmSpokeProvider) {
14165
+ invariant12__default.default(viem.isAddress(params.srcAsset), "Invalid source asset address for EVM chain");
14166
+ const allowanceResult = await Erc20Service.isAllowanceValid(
14167
+ params.srcAsset,
14168
+ params.amount,
14169
+ walletAddress,
14170
+ spokeProvider.chainConfig.addresses.assetManager,
14171
+ spokeProvider
14172
+ );
14173
+ if (!allowanceResult.ok) {
14174
+ return {
14175
+ ok: false,
14176
+ error: {
14177
+ code: "ALLOWANCE_CHECK_FAILED",
14178
+ error: allowanceResult.error
14179
+ }
14180
+ };
14181
+ }
14182
+ return {
14183
+ ok: true,
14184
+ value: allowanceResult.value
14185
+ };
14186
+ }
14187
+ if (spokeProvider instanceof SonicSpokeProvider) {
14188
+ invariant12__default.default(viem.isAddress(params.srcAsset), "Invalid source asset address for Sonic chain");
14189
+ const userRouter = await SonicSpokeService.getUserRouter(walletAddress, spokeProvider);
14190
+ const allowanceResult = await Erc20Service.isAllowanceValid(
14191
+ params.srcAsset,
14192
+ params.amount,
14193
+ walletAddress,
14194
+ userRouter,
14195
+ spokeProvider
14196
+ );
14197
+ if (!allowanceResult.ok) {
14198
+ return {
14199
+ ok: false,
14200
+ error: {
14201
+ code: "ALLOWANCE_CHECK_FAILED",
14202
+ error: allowanceResult.error
14203
+ }
14204
+ };
14205
+ }
14206
+ return {
14207
+ ok: true,
14208
+ value: allowanceResult.value
14209
+ };
14210
+ }
14211
+ return {
14212
+ ok: true,
14213
+ value: true
14214
+ };
14215
+ } catch (error) {
14216
+ return {
14217
+ ok: false,
14218
+ error: {
14219
+ code: "ALLOWANCE_CHECK_FAILED",
14220
+ error
14221
+ }
14222
+ };
14223
+ }
14224
+ }
14225
+ /**
14226
+ * Approve token spending for the bridge transaction
14227
+ * @param params - The bridge parameters
14228
+ * @param spokeProvider - The spoke provider
14229
+ * @param raw - Whether to return raw transaction data
14230
+ * @returns Promise<Result<TxReturnType<S, R>, BridgeError<'APPROVAL_FAILED'>>>
14231
+ */
14232
+ async approve({
14233
+ params,
14234
+ spokeProvider,
14235
+ raw
14236
+ }) {
14237
+ try {
14238
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
14239
+ invariant12__default.default(params.srcAsset.length > 0, "Source asset is required");
14240
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
14241
+ if (spokeProvider instanceof EvmSpokeProvider) {
14242
+ invariant12__default.default(viem.isAddress(params.srcAsset), "Invalid source asset address for EVM chain");
14243
+ const result = await Erc20Service.approve(
14244
+ params.srcAsset,
14245
+ params.amount,
14246
+ spokeProvider.chainConfig.addresses.assetManager,
14247
+ spokeProvider,
14248
+ raw
14249
+ );
14250
+ return {
14251
+ ok: true,
14252
+ value: result
14253
+ };
14254
+ }
14255
+ if (spokeProvider instanceof SonicSpokeProvider) {
14256
+ invariant12__default.default(viem.isAddress(params.srcAsset), "Invalid source asset address for Sonic chain");
14257
+ const userRouter = await SonicSpokeService.getUserRouter(
14258
+ walletAddress,
14259
+ spokeProvider
14260
+ );
14261
+ const result = await Erc20Service.approve(params.srcAsset, params.amount, userRouter, spokeProvider, raw);
14262
+ return {
14263
+ ok: true,
14264
+ value: result
14265
+ };
14266
+ }
14267
+ return {
14268
+ ok: false,
14269
+ error: {
14270
+ code: "APPROVAL_FAILED",
14271
+ error: new Error("Approval only supported for EVM spoke chains")
14272
+ }
14273
+ };
14274
+ } catch (error) {
14275
+ console.error(error);
14276
+ return {
14277
+ ok: false,
14278
+ error: {
14279
+ code: "APPROVAL_FAILED",
14280
+ error
14281
+ }
14282
+ };
14283
+ }
14284
+ }
14285
+ /**
14286
+ * Execute a bridge transaction to transfer tokens from one chain to another
14287
+ * @param params - The bridge parameters including source/destination chains, assets, and recipient
14288
+ * @param spokeProvider - The spoke provider for the source chain
14289
+ * @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
14290
+ * @returns {Promise<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>>} - Returns the transaction hashes for both spoke and hub chains or error
13686
14291
  *
13687
- * @param publicClient - The public client for reading contract state
13688
- * @param user - The user address
13689
- * @returns Array of detailed lock information for the user
13690
- */
13691
- async getDetailedUserLocks(publicClient, user) {
13692
- return await publicClient.readContract({
13693
- address: this.hubProvider.chainConfig.addresses.balnSwap,
13694
- abi: balnSwapAbi,
13695
- functionName: "getDetailedUserLocks",
13696
- args: [user]
13697
- });
13698
- }
13699
- // ===== ENCODING METHODS =====
13700
- /**
13701
- * Encodes a swap transaction for the BALN swap contract.
14292
+ * @example
14293
+ * const result = await sodax.bridge.bridge(
14294
+ * {
14295
+ * srcChainId: '0x2105.base',
14296
+ * srcAsset: '0x...', // Address of the source token
14297
+ * amount: 1000n, // Amount to bridge (in token decimals)
14298
+ * dstChainId: '0x89.polygon',
14299
+ * dstAsset: '0x...', // Address of the destination token
14300
+ * recipient: '0x...', // Recipient address on destination chain
14301
+ * partnerFee: { address: '0x...', percentage: 0.1 } // Optional partner fee. Partner fees and denominated in vault token decimals (18)
14302
+ * },
14303
+ * spokeProvider,
14304
+ * 30000 // Optional timeout in milliseconds (default: 60000, i.e. 60 seconds)
14305
+ * );
13702
14306
  *
13703
- * @param amount - The amount of BALN tokens to swap
13704
- * @param lockupPeriod - The lockup period for the swap
13705
- * @param to - The address that will receive the swapped SODA tokens
13706
- * @param stake - Whether to stake the SODA tokens
13707
- * @returns The encoded contract call for the swap operation
14307
+ * if (!result.ok) {
14308
+ * // Handle error
14309
+ * }
14310
+ *
14311
+ * const [
14312
+ * spokeTxHash, // transaction hash on the source chain
14313
+ * hubTxHash, // transaction hash on the hub chain
14314
+ * ] = result.value;
14315
+ * console.log('Bridge transaction hashes:', { spokeTxHash, hubTxHash });
13708
14316
  */
13709
- encodeSwap(amount, lockupPeriod, to, stake) {
13710
- return {
13711
- address: this.hubProvider.chainConfig.addresses.balnSwap,
13712
- value: 0n,
13713
- data: viem.encodeFunctionData({
13714
- abi: balnSwapAbi,
13715
- functionName: "swap",
13716
- args: [amount, BigInt(lockupPeriod), to, stake]
13717
- })
13718
- };
14317
+ async bridge({
14318
+ params,
14319
+ spokeProvider,
14320
+ fee = this.config.partnerFee,
14321
+ timeout = DEFAULT_RELAY_TX_TIMEOUT
14322
+ }) {
14323
+ try {
14324
+ const txResult = await this.createBridgeIntent({ params, spokeProvider, fee, raw: false });
14325
+ if (!txResult.ok) {
14326
+ return txResult;
14327
+ }
14328
+ const packetResult = await relayTxAndWaitPacket(
14329
+ txResult.value,
14330
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
14331
+ spokeProvider,
14332
+ this.relayerApiEndpoint,
14333
+ timeout
14334
+ );
14335
+ if (!packetResult.ok) {
14336
+ return {
14337
+ ok: false,
14338
+ error: {
14339
+ code: packetResult.error.code,
14340
+ error: packetResult.error
14341
+ }
14342
+ };
14343
+ }
14344
+ return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
14345
+ } catch (error) {
14346
+ return {
14347
+ ok: false,
14348
+ error: {
14349
+ code: "BRIDGE_FAILED",
14350
+ error
14351
+ }
14352
+ };
14353
+ }
13719
14354
  }
13720
14355
  /**
13721
- * Encodes a claim transaction for the BALN swap contract.
14356
+ * Create bridge intent only (without relaying to hub)
14357
+ * NOTE: This method only executes the transaction on the spoke chain and creates the bridge intent
14358
+ * In order to successfully bridge tokens, you need to:
14359
+ * 1. Check if the allowance is sufficient using isAllowanceValid
14360
+ * 2. Approve the appropriate contract to spend the tokens using approve
14361
+ * 3. Create the bridge intent using this method
14362
+ * 4. Relay the transaction to the hub and await completion using the bridge method
13722
14363
  *
13723
- * @param lockId - The lock ID to claim from
13724
- * @returns The encoded contract call for the claim operation
14364
+ * @param params - The bridge parameters including source/destination chains, assets, and recipient
14365
+ * @param spokeProvider - The spoke provider for the source chain
14366
+ * @param raw - Whether to return the raw transaction data
14367
+ * @returns {Promise<Result<TxReturnType<S, R>, BridgeError<BridgeErrorCode>>>} - Returns the transaction result
14368
+ *
14369
+ * @example
14370
+ * const bridgeService = new BridgeService(hubProvider, relayerApiEndpoint);
14371
+ * const result = await sodax.bridge.createBridgeIntent(
14372
+ * {
14373
+ * srcChainId: 'ethereum',
14374
+ * srcAsset: "0x123...", // source token address
14375
+ * amount: 1000000000000000000n, // 1 token in wei
14376
+ * dstChainId: 'polygon',
14377
+ * dstAsset: "0x456...", // destination token address
14378
+ * recipient: "0x789..." // recipient address
14379
+ * },
14380
+ * spokeProvider,
14381
+ * raw // Optional: true = return the raw transaction data, false = execute and return the transaction hash (default: false)
14382
+ * );
14383
+ *
14384
+ * if (result.ok) {
14385
+ * const txHash = result.value;
14386
+ * console.log('Bridge intent transaction hash:', txHash);
14387
+ * } else {
14388
+ * console.error('Bridge intent creation failed:', result.error);
14389
+ * }
13725
14390
  */
13726
- encodeClaim(lockId) {
13727
- return {
13728
- address: this.hubProvider.chainConfig.addresses.balnSwap,
13729
- value: 0n,
13730
- data: viem.encodeFunctionData({
13731
- abi: balnSwapAbi,
13732
- functionName: "claim",
13733
- args: [lockId]
13734
- })
13735
- };
14391
+ async createBridgeIntent({
14392
+ params,
14393
+ spokeProvider,
14394
+ fee = this.config.partnerFee,
14395
+ raw
14396
+ }) {
14397
+ try {
14398
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
14399
+ const srcAssetInfo = getHubAssetInfo(params.srcChainId, params.srcAsset);
14400
+ const dstAssetInfo = getHubAssetInfo(params.dstChainId, params.dstAsset);
14401
+ invariant12__default.default(srcAssetInfo, `Unsupported spoke chain (${params.srcChainId}) token: ${params.srcAsset}`);
14402
+ invariant12__default.default(dstAssetInfo, `Unsupported spoke chain (${params.dstChainId}) token: ${params.dstAsset}`);
14403
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
14404
+ const hubWallet = await WalletAbstractionService.getUserAbstractedWalletAddress(
14405
+ walletAddress,
14406
+ spokeProvider,
14407
+ this.hubProvider
14408
+ );
14409
+ const data = this.buildBridgeData(params, srcAssetInfo, dstAssetInfo, fee);
14410
+ const txResult = await SpokeService.deposit(
14411
+ {
14412
+ from: walletAddress,
14413
+ to: hubWallet,
14414
+ token: params.srcAsset,
14415
+ amount: params.amount,
14416
+ data
14417
+ },
14418
+ spokeProvider,
14419
+ this.hubProvider,
14420
+ raw
14421
+ );
14422
+ return {
14423
+ ok: true,
14424
+ value: txResult,
14425
+ data: {
14426
+ address: hubWallet,
14427
+ payload: data
14428
+ }
14429
+ };
14430
+ } catch (error) {
14431
+ console.error(error);
14432
+ return {
14433
+ ok: false,
14434
+ error: {
14435
+ code: "CREATE_BRIDGE_INTENT_FAILED",
14436
+ error
14437
+ }
14438
+ };
14439
+ }
13736
14440
  }
13737
14441
  /**
13738
- * Encodes a claim unstaked transaction for the BALN swap contract.
13739
- *
13740
- * @param lockId - The lock ID to claim unstaked tokens from
13741
- * @returns The encoded contract call for the claim unstaked operation
14442
+ * Build the bridge transaction data for executing the bridge operation on the hub
14443
+ * @param params - The create bridge intent parameters
14444
+ * @param srcAssetInfo - The source asset information
14445
+ * @param dstAssetInfo - The destination asset information
14446
+ * @returns Hex - The encoded contract calls for the bridge operation
13742
14447
  */
13743
- encodeClaimUnstaked(lockId) {
13744
- return {
13745
- address: this.hubProvider.chainConfig.addresses.balnSwap,
13746
- value: 0n,
13747
- data: viem.encodeFunctionData({
13748
- abi: balnSwapAbi,
13749
- functionName: "claimUnstaked",
13750
- args: [lockId]
13751
- })
13752
- };
14448
+ buildBridgeData(params, srcAssetInfo, dstAssetInfo, partnerFee) {
14449
+ const calls = [];
14450
+ let translatedAmount = params.amount;
14451
+ let srcVault = params.srcAsset;
14452
+ if (!isValidVault(srcAssetInfo.asset)) {
14453
+ calls.push(Erc20Service.encodeApprove(srcAssetInfo.asset, srcAssetInfo.vault, params.amount));
14454
+ calls.push(EvmVaultTokenService.encodeDeposit(srcAssetInfo.vault, srcAssetInfo.asset, params.amount));
14455
+ translatedAmount = EvmVaultTokenService.translateIncomingDecimals(srcAssetInfo.decimal, params.amount);
14456
+ srcVault = srcAssetInfo.vault;
14457
+ }
14458
+ const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
14459
+ if (partnerFee && feeAmount > 0n) {
14460
+ calls.push(Erc20Service.encodeTransfer(srcVault, partnerFee.address, feeAmount));
14461
+ }
14462
+ const withdrawAmount = translatedAmount - feeAmount;
14463
+ let translatedWithdrawAmount = withdrawAmount;
14464
+ if (!isValidVault(dstAssetInfo.asset)) {
14465
+ calls.push(EvmVaultTokenService.encodeWithdraw(dstAssetInfo.vault, dstAssetInfo.asset, withdrawAmount));
14466
+ translatedWithdrawAmount = EvmVaultTokenService.translateOutgoingDecimals(dstAssetInfo.decimal, withdrawAmount);
14467
+ }
14468
+ const encodedRecipientAddress = encodeAddress(params.dstChainId, params.recipient);
14469
+ if (params.dstChainId === this.hubProvider.chainConfig.chain.id) {
14470
+ calls.push(Erc20Service.encodeTransfer(dstAssetInfo.asset, encodedRecipientAddress, translatedWithdrawAmount));
14471
+ } else {
14472
+ invariant12__default.default(dstAssetInfo, `Unsupported hub chain (${params.dstChainId}) token: ${params.dstAsset}`);
14473
+ calls.push(
14474
+ EvmAssetManagerService.encodeTransfer(
14475
+ dstAssetInfo.asset,
14476
+ encodedRecipientAddress,
14477
+ translatedWithdrawAmount,
14478
+ this.hubProvider.chainConfig.addresses.assetManager
14479
+ )
14480
+ );
14481
+ }
14482
+ return encodeContractCalls(calls);
13753
14483
  }
13754
14484
  /**
13755
- * Encodes a stake transaction for the BALN swap contract.
14485
+ * Retrieves the deposited token balance held by the asset manager on a spoke chain.
14486
+ * This balance represents the available liquidity for bridging operations and is used to verify
14487
+ * that the target chain has sufficient funds to complete a bridge transaction.
13756
14488
  *
13757
- * @param lockId - The lock ID to stake
13758
- * @returns The encoded contract call for the stake operation
14489
+ * @param spokeProvider - The spoke provider instance
14490
+ * @param token - The token address to query the balance for
14491
+ * @returns {Promise<bigint>} - The token balance as a bigint value
13759
14492
  */
13760
- encodeStake(lockId) {
13761
- return {
13762
- address: this.hubProvider.chainConfig.addresses.balnSwap,
13763
- value: 0n,
13764
- data: viem.encodeFunctionData({
13765
- abi: balnSwapAbi,
13766
- functionName: "stake",
13767
- args: [lockId]
13768
- })
13769
- };
14493
+ async getBridgeableAmount(from, to) {
14494
+ try {
14495
+ const fromHubAsset = getHubAssetInfo(from.xChainId, from.address);
14496
+ const toHubAsset = getHubAssetInfo(to.xChainId, to.address);
14497
+ invariant12__default.default(fromHubAsset, `Hub asset not found for token ${from.address} on chain ${from.xChainId}`);
14498
+ invariant12__default.default(toHubAsset, `Hub asset not found for token ${to.address} on chain ${to.xChainId}`);
14499
+ const [depositTokenInfo, reserves] = await Promise.all([
14500
+ EvmVaultTokenService.getTokenInfo(fromHubAsset.vault, fromHubAsset.asset, this.hubProvider.publicClient),
14501
+ EvmVaultTokenService.getVaultReserves(toHubAsset.vault, this.hubProvider.publicClient)
14502
+ ]);
14503
+ if (!isValidVault(fromHubAsset.asset) && isValidVault(toHubAsset.asset)) {
14504
+ const fromTokenIndex2 = reserves.tokens.findIndex((t) => t.toLowerCase() === fromHubAsset.asset.toLowerCase());
14505
+ invariant12__default.default(
14506
+ fromTokenIndex2 !== -1,
14507
+ `Token ${fromHubAsset.asset} not found in the vault reserves for chain ${from.xChainId}`
14508
+ );
14509
+ const fromTokenDepositedAmount2 = reserves.balances[fromTokenIndex2] ?? 0n;
14510
+ const availableDeposit2 = depositTokenInfo.maxDeposit - fromTokenDepositedAmount2;
14511
+ return {
14512
+ ok: true,
14513
+ value: availableDeposit2
14514
+ };
14515
+ }
14516
+ if (isValidVault(fromHubAsset.asset)) {
14517
+ const tokenIndex2 = reserves.tokens.findIndex((t) => t.toLowerCase() === toHubAsset.asset.toLowerCase());
14518
+ invariant12__default.default(
14519
+ tokenIndex2 !== -1,
14520
+ `Token ${toHubAsset.asset} not found in the vault reserves for chain ${to.xChainId}`
14521
+ );
14522
+ const assetManagerBalance2 = reserves.balances[tokenIndex2] ?? 0n;
14523
+ return {
14524
+ ok: true,
14525
+ value: assetManagerBalance2
14526
+ };
14527
+ }
14528
+ const fromTokenIndex = reserves.tokens.findIndex((t) => t.toLowerCase() === fromHubAsset.asset.toLowerCase());
14529
+ invariant12__default.default(
14530
+ fromTokenIndex !== -1,
14531
+ `Token ${fromHubAsset.asset} not found in the vault reserves for chain ${from.xChainId}`
14532
+ );
14533
+ const fromTokenDepositedAmount = reserves.balances[fromTokenIndex] ?? 0n;
14534
+ const availableDeposit = depositTokenInfo.maxDeposit - fromTokenDepositedAmount;
14535
+ const tokenIndex = reserves.tokens.findIndex((t) => t.toLowerCase() === toHubAsset.asset.toLowerCase());
14536
+ invariant12__default.default(
14537
+ tokenIndex !== -1,
14538
+ `Token ${toHubAsset.asset} not found in the vault reserves for chain ${to.xChainId}`
14539
+ );
14540
+ const assetManagerBalance = reserves.balances[tokenIndex] ?? 0n;
14541
+ return {
14542
+ ok: true,
14543
+ value: availableDeposit < assetManagerBalance ? availableDeposit : assetManagerBalance
14544
+ };
14545
+ } catch (error) {
14546
+ console.error(error);
14547
+ return {
14548
+ ok: false,
14549
+ error
14550
+ };
14551
+ }
13770
14552
  }
13771
14553
  /**
13772
- * Encodes an unstake transaction for the BALN swap contract.
13773
- *
13774
- * @param lockId - The lock ID to unstake
13775
- * @returns The encoded contract call for the unstake operation
14554
+ * Check if two assets on different chains are bridgeable
14555
+ * Two assets are bridgeable if they share the same vault on the hub chain
14556
+ * @param from - The source X token
14557
+ * @param to - The destination X token
14558
+ * @param unchecked - Whether to skip the chain ID validation
14559
+ * @returns boolean - true if assets are bridgeable, false otherwise
13776
14560
  */
13777
- encodeUnstake(lockId) {
13778
- return {
13779
- address: this.hubProvider.chainConfig.addresses.balnSwap,
13780
- value: 0n,
13781
- data: viem.encodeFunctionData({
13782
- abi: balnSwapAbi,
13783
- functionName: "unstake",
13784
- args: [lockId]
13785
- })
13786
- };
14561
+ isBridgeable({
14562
+ from,
14563
+ to,
14564
+ unchecked = false
14565
+ }) {
14566
+ try {
14567
+ if (!unchecked) {
14568
+ invariant12__default.default(isValidSpokeChainId(from.xChainId), `Invalid spoke chain (${from.xChainId})`);
14569
+ invariant12__default.default(isValidSpokeChainId(to.xChainId), `Invalid spoke chain (${to.xChainId})`);
14570
+ }
14571
+ const srcAssetInfo = getHubAssetInfo(from.xChainId, from.address);
14572
+ const dstAssetInfo = getHubAssetInfo(to.xChainId, to.address);
14573
+ invariant12__default.default(srcAssetInfo, `Hub asset not found for token ${from.address} on chain ${from.xChainId}`);
14574
+ invariant12__default.default(dstAssetInfo, `Hub asset not found for token ${to.address} on chain ${to.xChainId}`);
14575
+ return srcAssetInfo.vault.toLowerCase() === dstAssetInfo.vault.toLowerCase();
14576
+ } catch (error) {
14577
+ console.error(error);
14578
+ return false;
14579
+ }
13787
14580
  }
13788
- // ===== PRIVATE HELPER METHODS =====
13789
14581
  /**
13790
- * Executes a contract call through the Sonic wallet provider.
13791
- * @param spokeProvider - The Sonic spoke provider
13792
- * @param rawTx - The raw contract call to execute
13793
- * @param raw - Whether to return raw transaction data
13794
- * @returns The transaction hash or raw transaction data
14582
+ * Get all bridgeable tokens from a source token to a destination chain
14583
+ * @param from - The source chain ID
14584
+ * @param to - The destination chain ID
14585
+ * @param token - The source token address
14586
+ * @returns XToken[] - Array of bridgeable tokens on the destination chain
13795
14587
  */
13796
- async call(spokeProvider, rawTx, raw) {
13797
- const from = await spokeProvider.walletProvider.getWalletAddress();
13798
- const tx = {
13799
- from,
13800
- to: rawTx.address,
13801
- value: rawTx.value,
13802
- data: rawTx.data
13803
- };
13804
- if (raw) {
13805
- return tx;
14588
+ getBridgeableTokens(from, to, token) {
14589
+ try {
14590
+ const srcAssetInfo = getHubAssetInfo(from, token);
14591
+ invariant12__default.default(srcAssetInfo, `Hub asset not found for token ${token} on chain ${from}`);
14592
+ return {
14593
+ ok: true,
14594
+ value: this.filterTokensWithSameVault(spokeChainConfig[to].supportedTokens, to, srcAssetInfo)
14595
+ };
14596
+ } catch (error) {
14597
+ return {
14598
+ ok: false,
14599
+ error
14600
+ };
13806
14601
  }
13807
- return spokeProvider.walletProvider.sendTransaction(tx);
14602
+ }
14603
+ filterTokensWithSameVault(tokens, to, srcAssetInfo) {
14604
+ const bridgeableTokens = [];
14605
+ for (const token of Object.values(tokens)) {
14606
+ const dstAssetInfo = getHubAssetInfo(to, token.address);
14607
+ if (dstAssetInfo && srcAssetInfo && dstAssetInfo.vault.toLowerCase() === srcAssetInfo.vault.toLowerCase()) {
14608
+ bridgeableTokens.push({
14609
+ ...token,
14610
+ xChainId: to
14611
+ });
14612
+ }
14613
+ }
14614
+ return bridgeableTokens;
13808
14615
  }
13809
14616
  };
13810
14617
 
@@ -13817,6 +14624,8 @@ var Sodax = class {
13817
14624
  // Money Market service enabling cross-chain lending and borrowing
13818
14625
  migration;
13819
14626
  // ICX migration service enabling ICX migration to SODA
14627
+ bridge;
14628
+ // Bridge service enabling cross-chain transfers
13820
14629
  hubProvider;
13821
14630
  // hub provider for the hub chain (e.g. Sonic mainnet)
13822
14631
  relayerApiEndpoint;
@@ -13828,6 +14637,7 @@ var Sodax = class {
13828
14637
  this.solver = config && config.solver ? new SolverService(config.solver, this.hubProvider, this.relayerApiEndpoint) : new SolverService(void 0, this.hubProvider, this.relayerApiEndpoint);
13829
14638
  this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService(void 0, this.hubProvider, this.relayerApiEndpoint);
13830
14639
  this.migration = config && config.migration ? new MigrationService(this.hubProvider, config.migration) : new MigrationService(this.hubProvider);
14640
+ this.bridge = config && config.bridge ? new BridgeService(this.hubProvider, this.relayerApiEndpoint, config.bridge) : new BridgeService(this.hubProvider, this.relayerApiEndpoint);
13831
14641
  }
13832
14642
  };
13833
14643
 
@@ -13894,16 +14704,16 @@ function calculateFeeAmount(inputAmount, fee) {
13894
14704
  if (!fee) {
13895
14705
  return 0n;
13896
14706
  }
13897
- invariant11__default.default(inputAmount > 0n, "Input amount must be greater than 0");
14707
+ invariant12__default.default(inputAmount > 0n, "Input amount must be greater than 0");
13898
14708
  let feeAmount = 0n;
13899
14709
  if (isPartnerFeeAmount(fee)) {
13900
- invariant11__default.default(
14710
+ invariant12__default.default(
13901
14711
  fee.amount >= 0 && fee.amount <= inputAmount,
13902
14712
  `Fee amount must be greater than 0 and less than or equal to the input amount: ${fee.amount}`
13903
14713
  );
13904
14714
  feeAmount = fee.amount;
13905
14715
  } else if (isPartnerFeePercentage(fee)) {
13906
- invariant11__default.default(
14716
+ invariant12__default.default(
13907
14717
  fee.percentage >= 0 && fee.percentage <= FEE_PERCENTAGE_SCALE,
13908
14718
  `Fee percentage must be between 0 and ${FEE_PERCENTAGE_SCALE}}`
13909
14719
  );
@@ -13912,8 +14722,8 @@ function calculateFeeAmount(inputAmount, fee) {
13912
14722
  return feeAmount;
13913
14723
  }
13914
14724
  function adjustAmountByFee(amount, fee, quoteType) {
13915
- invariant11__default.default(amount > 0n, "Amount must be greater than 0");
13916
- invariant11__default.default(quoteType === "exact_input" || quoteType === "exact_output", "Invalid quote type");
14725
+ invariant12__default.default(amount > 0n, "Amount must be greater than 0");
14726
+ invariant12__default.default(quoteType === "exact_input" || quoteType === "exact_output", "Invalid quote type");
13917
14727
  if (quoteType === "exact_input") {
13918
14728
  return amount - calculateFeeAmount(amount, fee);
13919
14729
  }
@@ -15488,9 +16298,9 @@ var MoneyMarketService = class _MoneyMarketService {
15488
16298
  */
15489
16299
  async isAllowanceValid(params, spokeProvider) {
15490
16300
  try {
15491
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
15492
- invariant11__default.default(params.token.length > 0, "Token is required");
15493
- invariant11__default.default(
16301
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
16302
+ invariant12__default.default(params.token.length > 0, "Token is required");
16303
+ invariant12__default.default(
15494
16304
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
15495
16305
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
15496
16306
  );
@@ -15585,19 +16395,19 @@ var MoneyMarketService = class _MoneyMarketService {
15585
16395
  */
15586
16396
  async approve(params, spokeProvider, raw) {
15587
16397
  try {
15588
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
15589
- invariant11__default.default(params.token.length > 0, "Token is required");
15590
- invariant11__default.default(
16398
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
16399
+ invariant12__default.default(params.token.length > 0, "Token is required");
16400
+ invariant12__default.default(
15591
16401
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
15592
16402
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
15593
16403
  );
15594
16404
  const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
15595
16405
  if (spokeProvider instanceof EvmSpokeProvider) {
15596
- invariant11__default.default(
16406
+ invariant12__default.default(
15597
16407
  params.action === "supply" || params.action === "repay",
15598
16408
  "Invalid action (only supply and repay are supported on evm)"
15599
16409
  );
15600
- invariant11__default.default(viem.isAddress(params.token), "Invalid token address");
16410
+ invariant12__default.default(viem.isAddress(params.token), "Invalid token address");
15601
16411
  const result = await Erc20Service.approve(
15602
16412
  params.token,
15603
16413
  params.amount,
@@ -15611,11 +16421,11 @@ var MoneyMarketService = class _MoneyMarketService {
15611
16421
  };
15612
16422
  }
15613
16423
  if (spokeProvider instanceof SonicSpokeProvider && spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
15614
- invariant11__default.default(
16424
+ invariant12__default.default(
15615
16425
  params.action === "withdraw" || params.action === "borrow" || params.action === "supply" || params.action === "repay",
15616
16426
  "Invalid action (only withdraw, borrow, supply and repay are supported on sonic)"
15617
16427
  );
15618
- invariant11__default.default(viem.isAddress(params.token), "Invalid token address");
16428
+ invariant12__default.default(viem.isAddress(params.token), "Invalid token address");
15619
16429
  if (params.action === "withdraw") {
15620
16430
  const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
15621
16431
  params.token,
@@ -15787,10 +16597,10 @@ var MoneyMarketService = class _MoneyMarketService {
15787
16597
  */
15788
16598
  async createSupplyIntent(params, spokeProvider, raw) {
15789
16599
  try {
15790
- invariant11__default.default(params.action === "supply", "Invalid action");
15791
- invariant11__default.default(params.token.length > 0, "Token is required");
15792
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
15793
- invariant11__default.default(
16600
+ invariant12__default.default(params.action === "supply", "Invalid action");
16601
+ invariant12__default.default(params.token.length > 0, "Token is required");
16602
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
16603
+ invariant12__default.default(
15794
16604
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
15795
16605
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
15796
16606
  );
@@ -15952,10 +16762,10 @@ var MoneyMarketService = class _MoneyMarketService {
15952
16762
  * }
15953
16763
  */
15954
16764
  async createBorrowIntent(params, spokeProvider, raw) {
15955
- invariant11__default.default(params.action === "borrow", "Invalid action");
15956
- invariant11__default.default(params.token.length > 0, "Token is required");
15957
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
15958
- invariant11__default.default(
16765
+ invariant12__default.default(params.action === "borrow", "Invalid action");
16766
+ invariant12__default.default(params.token.length > 0, "Token is required");
16767
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
16768
+ invariant12__default.default(
15959
16769
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
15960
16770
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
15961
16771
  );
@@ -16088,10 +16898,10 @@ var MoneyMarketService = class _MoneyMarketService {
16088
16898
  * }
16089
16899
  */
16090
16900
  async createWithdrawIntent(params, spokeProvider, raw) {
16091
- invariant11__default.default(params.action === "withdraw", "Invalid action");
16092
- invariant11__default.default(params.token.length > 0, "Token is required");
16093
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
16094
- invariant11__default.default(
16901
+ invariant12__default.default(params.action === "withdraw", "Invalid action");
16902
+ invariant12__default.default(params.token.length > 0, "Token is required");
16903
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
16904
+ invariant12__default.default(
16095
16905
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
16096
16906
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
16097
16907
  );
@@ -16239,10 +17049,10 @@ var MoneyMarketService = class _MoneyMarketService {
16239
17049
  * }
16240
17050
  */
16241
17051
  async createRepayIntent(params, spokeProvider, raw) {
16242
- invariant11__default.default(params.action === "repay", "Invalid action");
16243
- invariant11__default.default(params.token.length > 0, "Token is required");
16244
- invariant11__default.default(params.amount > 0n, "Amount must be greater than 0");
16245
- invariant11__default.default(
17052
+ invariant12__default.default(params.action === "repay", "Invalid action");
17053
+ invariant12__default.default(params.token.length > 0, "Token is required");
17054
+ invariant12__default.default(params.amount > 0n, "Amount must be greater than 0");
17055
+ invariant12__default.default(
16246
17056
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
16247
17057
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
16248
17058
  );
@@ -16295,7 +17105,7 @@ var MoneyMarketService = class _MoneyMarketService {
16295
17105
  buildSupplyData(token, to, amount, spokeChainId) {
16296
17106
  const calls = [];
16297
17107
  const assetConfig = getHubAssetInfo(spokeChainId, token);
16298
- invariant11__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
17108
+ invariant12__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
16299
17109
  let assetAddress = assetConfig.asset;
16300
17110
  const vaultAddress = assetConfig.vault;
16301
17111
  const lendingPool = this.config.lendingPool;
@@ -16326,13 +17136,13 @@ var MoneyMarketService = class _MoneyMarketService {
16326
17136
  * @returns {Hex} The transaction data.
16327
17137
  */
16328
17138
  buildBorrowData(from, to, token, amount, spokeChainId) {
16329
- invariant11__default.default(isValidSpokeChainId(spokeChainId), `Invalid spokeChainId: ${spokeChainId}`);
16330
- invariant11__default.default(
17139
+ invariant12__default.default(isValidSpokeChainId(spokeChainId), `Invalid spokeChainId: ${spokeChainId}`);
17140
+ invariant12__default.default(
16331
17141
  isValidOriginalAssetAddress(spokeChainId, token),
16332
17142
  `Unsupported spoke chain (${spokeChainId}) token: ${token}`
16333
17143
  );
16334
17144
  const assetConfig = getHubAssetInfo(spokeChainId, token);
16335
- invariant11__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
17145
+ invariant12__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
16336
17146
  let assetAddress = assetConfig.asset;
16337
17147
  const vaultAddress = assetConfig.vault;
16338
17148
  const bnUSDVault = this.config.bnUSDVault;
@@ -16660,6 +17470,7 @@ exports.BalnSwapService = BalnSwapService;
16660
17470
  exports.BigIntToHex = BigIntToHex;
16661
17471
  exports.BigNumberZeroDecimal = BigNumberZeroDecimal;
16662
17472
  exports.BnUSDMigrationService = BnUSDMigrationService;
17473
+ exports.BridgeService = BridgeService;
16663
17474
  exports.ChainIdToIntentRelayChainId = ChainIdToIntentRelayChainId;
16664
17475
  exports.DEFAULT_DEADLINE_OFFSET = DEFAULT_DEADLINE_OFFSET;
16665
17476
  exports.DEFAULT_MAX_RETRY = DEFAULT_MAX_RETRY;
@@ -16701,6 +17512,9 @@ exports.RAY_DECIMALS = RAY_DECIMALS;
16701
17512
  exports.SECONDS_PER_YEAR = SECONDS_PER_YEAR;
16702
17513
  exports.STELLAR_DEFAULT_TX_TIMEOUT_SECONDS = STELLAR_DEFAULT_TX_TIMEOUT_SECONDS;
16703
17514
  exports.STELLAR_PRIORITY_FEE = STELLAR_PRIORITY_FEE;
17515
+ exports.SodaTokens = SodaTokens;
17516
+ exports.SodaTokensAsHubAssets = SodaTokensAsHubAssets;
17517
+ exports.SodaVaultTokensSet = SodaVaultTokensSet;
16704
17518
  exports.Sodax = Sodax;
16705
17519
  exports.SolanaSpokeProvider = SolanaSpokeProvider;
16706
17520
  exports.SolverIntentErrorCode = SolverIntentErrorCode;
@@ -16711,6 +17525,7 @@ exports.SonicSpokeService = SonicSpokeService;
16711
17525
  exports.SpokeService = SpokeService;
16712
17526
  exports.StellarSpokeProvider = StellarSpokeProvider;
16713
17527
  exports.SuiSpokeProvider = SuiSpokeProvider;
17528
+ exports.SuiSpokeService = SuiSpokeService;
16714
17529
  exports.SupportedMigrationTokens = SupportedMigrationTokens;
16715
17530
  exports.USD_DECIMALS = USD_DECIMALS;
16716
17531
  exports.UiPoolDataProviderService = UiPoolDataProviderService;
@@ -16758,12 +17573,15 @@ exports.getCompoundedBalance = getCompoundedBalance;
16758
17573
  exports.getEvmViemChain = getEvmViemChain;
16759
17574
  exports.getHubAssetInfo = getHubAssetInfo;
16760
17575
  exports.getHubChainConfig = getHubChainConfig;
17576
+ exports.getHubVaultTokenByAddress = getHubVaultTokenByAddress;
16761
17577
  exports.getIconAddressBytes = getIconAddressBytes;
16762
17578
  exports.getIntentRelayChainId = getIntentRelayChainId;
16763
17579
  exports.getLinearBalance = getLinearBalance;
16764
17580
  exports.getMarketReferenceCurrencyAndUsdBalance = getMarketReferenceCurrencyAndUsdBalance;
16765
17581
  exports.getMoneyMarketConfig = getMoneyMarketConfig;
16766
17582
  exports.getOriginalAssetAddress = getOriginalAssetAddress;
17583
+ exports.getOriginalAssetInfoFromVault = getOriginalAssetInfoFromVault;
17584
+ exports.getOriginalTokenFromOriginalAssetAddress = getOriginalTokenFromOriginalAssetAddress;
16767
17585
  exports.getPacket = getPacket;
16768
17586
  exports.getRandomBytes = getRandomBytes;
16769
17587
  exports.getReserveNormalizedIncome = getReserveNormalizedIncome;
@@ -16777,6 +17595,7 @@ exports.getTransactionPackets = getTransactionPackets;
16777
17595
  exports.hexToBigInt = hexToBigInt;
16778
17596
  exports.hubAssetToOriginalAssetMap = hubAssetToOriginalAssetMap;
16779
17597
  exports.hubAssets = hubAssets;
17598
+ exports.hubVaultTokensMap = hubVaultTokensMap;
16780
17599
  exports.hubVaults = hubVaults;
16781
17600
  exports.hubVaultsAddressSet = hubVaultsAddressSet;
16782
17601
  exports.intentRelayChainIdToSpokeChainIdMap = intentRelayChainIdToSpokeChainIdMap;
@@ -16823,6 +17642,7 @@ exports.isPartnerFeeAmount = isPartnerFeeAmount;
16823
17642
  exports.isPartnerFeePercentage = isPartnerFeePercentage;
16824
17643
  exports.isResponseAddressType = isResponseAddressType;
16825
17644
  exports.isResponseSigningType = isResponseSigningType;
17645
+ exports.isSodaVaultToken = isSodaVaultToken;
16826
17646
  exports.isSolanaSpokeProvider = isSolanaSpokeProvider;
16827
17647
  exports.isSolverSupportedToken = isSolverSupportedToken;
16828
17648
  exports.isSonicSpokeProvider = isSonicSpokeProvider;
@@ -16834,6 +17654,7 @@ exports.isValidHubAsset = isValidHubAsset;
16834
17654
  exports.isValidIntentRelayChainId = isValidIntentRelayChainId;
16835
17655
  exports.isValidOriginalAssetAddress = isValidOriginalAssetAddress;
16836
17656
  exports.isValidSpokeChainId = isValidSpokeChainId;
17657
+ exports.isValidVault = isValidVault;
16837
17658
  exports.isWaitUntilIntentExecutedFailed = isWaitUntilIntentExecutedFailed;
16838
17659
  exports.moneyMarketReserveAssets = moneyMarketReserveAssets;
16839
17660
  exports.moneyMarketReserveHubAssetsSet = moneyMarketReserveHubAssetsSet;
@@ -16862,6 +17683,7 @@ exports.spokeChainIdsSet = spokeChainIdsSet;
16862
17683
  exports.submitTransaction = submitTransaction;
16863
17684
  exports.supportedHubAssets = supportedHubAssets;
16864
17685
  exports.supportedHubChains = supportedHubChains;
17686
+ exports.supportedSodaAssets = supportedSodaAssets;
16865
17687
  exports.supportedSpokeChains = supportedSpokeChains;
16866
17688
  exports.supportedTokensPerChain = supportedTokensPerChain;
16867
17689
  exports.uiPoolDataAbi = uiPoolDataAbi;