@sodax/sdk 0.0.1-rc.16 → 0.0.1-rc.18

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getAbiItem, fromHex, createPublicClient, http, toHex, encodeAbiParameters, parseAbiParameters, erc20Abi as erc20Abi$1, encodeFunctionData, isAddress, decodeAbiParameters, encodePacked, parseEventLogs, keccak256 } from 'viem';
2
2
  import { nibiru, polygon, bsc, optimism, base, arbitrum, avalanche, sonic } from 'viem/chains';
3
- import { ICON_MAINNET_CHAIN_ID, SUI_MAINNET_CHAIN_ID, STELLAR_MAINNET_CHAIN_ID, INJECTIVE_MAINNET_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, NIBIRU_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID, SPOKE_CHAIN_IDS } from '@sodax/types';
3
+ import { SPOKE_CHAIN_IDS, ICON_MAINNET_CHAIN_ID, SUI_MAINNET_CHAIN_ID, STELLAR_MAINNET_CHAIN_ID, INJECTIVE_MAINNET_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, OPTIMISM_MAINNET_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ARBITRUM_MAINNET_CHAIN_ID, NIBIRU_MAINNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, SOLANA_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID } from '@sodax/types';
4
4
  export * from '@sodax/types';
5
5
  import { ChainGrpcWasmApi, TxGrpcApi, toBase64 } from '@injectivelabs/sdk-ts';
6
6
  import { getNetworkEndpoints, Network } from '@injectivelabs/networks';
@@ -6212,14 +6212,20 @@ var spokeChainConfig = {
6212
6212
  wrappedSonic: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
6213
6213
  },
6214
6214
  nativeToken: "0x0000000000000000000000000000000000000000",
6215
- bnUSD: "0x6958a4CBFe11406E2a1c1d3a71A1971aD8B3b92F",
6215
+ bnUSD: "0xE801CA34E19aBCbFeA12025378D19c4FBE250131",
6216
6216
  supportedTokens: {
6217
- Sonic: {
6218
- symbol: "Sonic",
6217
+ S: {
6218
+ symbol: "S",
6219
6219
  name: "Sonic",
6220
6220
  decimals: 18,
6221
6221
  address: "0x0000000000000000000000000000000000000000"
6222
6222
  },
6223
+ bnUSD: {
6224
+ symbol: "bnUSD",
6225
+ name: "bnUSD",
6226
+ decimals: 18,
6227
+ address: "0xE801CA34E19aBCbFeA12025378D19c4FBE250131"
6228
+ },
6223
6229
  WETH: {
6224
6230
  symbol: "WETH",
6225
6231
  name: "Wrapped Ether",
@@ -6238,8 +6244,8 @@ var spokeChainConfig = {
6238
6244
  decimals: 6,
6239
6245
  address: "0x6047828dc181963ba44974801FF68e538dA5eaF9"
6240
6246
  },
6241
- wSonic: {
6242
- symbol: "wSonic",
6247
+ wS: {
6248
+ symbol: "wS",
6243
6249
  name: "Wrapped Sonic",
6244
6250
  decimals: 18,
6245
6251
  address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
@@ -6788,6 +6794,14 @@ var spokeChainConfig = {
6788
6794
  address: "cx3975b43d260fb8ec802cef6e60c2f4d07486f11d"
6789
6795
  },
6790
6796
  bnUSD: {
6797
+ // same as legacy
6798
+ symbol: "bnUSD",
6799
+ name: "bnUSD",
6800
+ decimals: 18,
6801
+ address: "cx88fd7df7ddff82f7cc735c871dc519838cb235bb"
6802
+ },
6803
+ legacybnUSD: {
6804
+ // duplicate of bnUSD purely for consistency with other legacy tokens chains (sui, stellar)
6791
6805
  symbol: "bnUSD",
6792
6806
  name: "bnUSD",
6793
6807
  decimals: 18,
@@ -6825,6 +6839,7 @@ var HubVaultSymbols = [
6825
6839
  ];
6826
6840
  var hubVaults = {
6827
6841
  IbnUSD: {
6842
+ // ICON bnUSD (Migration) vault on Sonic contains legacy bnUSD tokens (stellar, sui, icon)
6828
6843
  address: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51",
6829
6844
  reserves: [
6830
6845
  // hub asset addresses contained in the vault
@@ -6855,6 +6870,7 @@ var hubVaults = {
6855
6870
  ]
6856
6871
  },
6857
6872
  bnUSD: {
6873
+ // new bnUSD vault on Sonic (also contains IbnUSD vault token as part of it)
6858
6874
  address: "0xe801ca34e19abcbfea12025378d19c4fbe250131",
6859
6875
  reserves: [
6860
6876
  // hub asset addresses contained in the vault
@@ -7000,45 +7016,81 @@ var hubVaults = {
7000
7016
  ]
7001
7017
  }
7002
7018
  };
7019
+ var bnUSDLegacySpokeChainIds = [
7020
+ ICON_MAINNET_CHAIN_ID,
7021
+ SUI_MAINNET_CHAIN_ID,
7022
+ STELLAR_MAINNET_CHAIN_ID
7023
+ ];
7024
+ var newbnUSDSpokeChainIds = SPOKE_CHAIN_IDS.filter((chainId) => chainId !== ICON_MAINNET_CHAIN_ID);
7025
+ var bnUSDLegacyTokens = [
7026
+ spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7027
+ spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.legacybnUSD,
7028
+ spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.legacybnUSD
7029
+ ];
7030
+ var bnUSDNewTokens = newbnUSDSpokeChainIds.map((chainId) => spokeChainConfig[chainId].supportedTokens.bnUSD);
7031
+ var isLegacybnUSDChainId = (chainId) => {
7032
+ return bnUSDLegacySpokeChainIds.includes(chainId);
7033
+ };
7034
+ var isNewbnUSDChainId = (chainId) => {
7035
+ return newbnUSDSpokeChainIds.includes(chainId);
7036
+ };
7037
+ var isLegacybnUSDToken = (token) => {
7038
+ if (typeof token === "string") {
7039
+ return bnUSDLegacyTokens.some((t) => t.address.toLowerCase() === token.toLowerCase());
7040
+ }
7041
+ return bnUSDLegacyTokens.some((t) => t.address.toLowerCase() === token.address.toLowerCase());
7042
+ };
7043
+ var isNewbnUSDToken = (token) => {
7044
+ if (typeof token === "string") {
7045
+ return newbnUSDSpokeChainIds.map((chainId) => spokeChainConfig[chainId].supportedTokens.bnUSD).some((t) => t.address.toLowerCase() === token.toLowerCase());
7046
+ }
7047
+ return newbnUSDSpokeChainIds.map((chainId) => spokeChainConfig[chainId].supportedTokens.bnUSD).some((t) => t.address.toLowerCase() === token.address.toLowerCase());
7048
+ };
7049
+ var getAllLegacybnUSDTokens = () => {
7050
+ return bnUSDLegacySpokeChainIds.map((chainId) => ({
7051
+ token: spokeChainConfig[chainId].supportedTokens.legacybnUSD,
7052
+ chainId
7053
+ }));
7054
+ };
7003
7055
  var hubAssets = {
7004
7056
  [SONIC_MAINNET_CHAIN_ID]: {
7005
7057
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].nativeToken]: {
7006
- asset: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
7058
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address,
7007
7059
  decimal: 18,
7008
7060
  symbol: "S",
7009
7061
  name: "Sonic",
7010
7062
  vault: hubVaults.sodaS.address
7011
7063
  },
7012
- [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic.address]: {
7013
- asset: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
7064
+ [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address]: {
7065
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address,
7014
7066
  decimal: 18,
7015
- symbol: "wSonic",
7067
+ symbol: "wS",
7016
7068
  name: "Sonic",
7017
7069
  vault: hubVaults.sodaS.address
7018
7070
  },
7019
7071
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH.address]: {
7020
- asset: "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b",
7072
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH.address,
7021
7073
  decimal: 18,
7022
7074
  symbol: "WETH",
7023
7075
  name: "Wrapped Ethereum",
7024
7076
  vault: hubVaults.sodaETH.address
7025
7077
  },
7026
7078
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
7027
- asset: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
7079
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC.address,
7028
7080
  decimal: 6,
7029
7081
  symbol: "USDC ",
7030
7082
  name: "USD Coin",
7031
7083
  vault: hubVaults.sodaUSDC.address
7032
7084
  },
7033
7085
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
7034
- asset: "0x6047828dc181963ba44974801ff68e538da5eaf9",
7086
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT.address,
7035
7087
  decimal: 6,
7036
7088
  symbol: "USDT",
7037
7089
  name: "Tether USD",
7038
7090
  vault: hubVaults.sodaUSDT.address
7039
7091
  },
7040
7092
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.SODA.address]: {
7041
- asset: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
7093
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.SODA.address,
7042
7094
  decimal: 18,
7043
7095
  symbol: "SODA",
7044
7096
  name: "SODA",
@@ -7353,7 +7405,7 @@ var hubAssets = {
7353
7405
  decimal: 18,
7354
7406
  symbol: "legacybnUSD",
7355
7407
  name: "legacybnUSD",
7356
- vault: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51"
7408
+ vault: hubVaults.IbnUSD.address
7357
7409
  }
7358
7410
  },
7359
7411
  [SUI_MAINNET_CHAIN_ID]: {
@@ -7431,7 +7483,7 @@ var hubAssets = {
7431
7483
  decimal: 9,
7432
7484
  symbol: "bnUSD",
7433
7485
  name: "legacybnUSD",
7434
- vault: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51"
7486
+ vault: hubVaults.IbnUSD.address
7435
7487
  }
7436
7488
  },
7437
7489
  [SOLANA_MAINNET_CHAIN_ID]: {
@@ -7478,7 +7530,7 @@ var hubAssets = {
7478
7530
  decimal: 18,
7479
7531
  symbol: "bnUSD",
7480
7532
  name: "bnUSD",
7481
- vault: hubVaults.bnUSD.address
7533
+ vault: hubVaults.IbnUSD.address
7482
7534
  },
7483
7535
  [spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.BALN.address]: {
7484
7536
  asset: "0xde8e19a099fedf9d617599f62c5f7f020d92b572",
@@ -7500,10 +7552,11 @@ var solverConfig = {
7500
7552
  var getSolverConfig = (chainId) => solverConfig[chainId];
7501
7553
  var solverSupportedTokens = {
7502
7554
  [SONIC_MAINNET_CHAIN_ID]: [
7503
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH, // NOTE: Planned for next release (1 - 2 weeks)
7504
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC, // NOTE: Planned for next release (1 - 2 weeks)
7505
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT, // NOTE: Planned for next release (1 - 2 weeks)
7506
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic, // NOTE: Planned for next release (1 - 2 weeks)
7555
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.S,
7556
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH,
7557
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC,
7558
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT,
7559
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS
7507
7560
  ],
7508
7561
  [AVALANCHE_MAINNET_CHAIN_ID]: [
7509
7562
  spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.AVAX,
@@ -7670,35 +7723,13 @@ var moneyMarketSupportedTokens = {
7670
7723
  ],
7671
7724
  [NIBIRU_MAINNET_CHAIN_ID]: [],
7672
7725
  [SONIC_MAINNET_CHAIN_ID]: [
7673
- spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.Sonic,
7726
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.S,
7674
7727
  spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH,
7675
7728
  spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC,
7676
7729
  spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT,
7677
- spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic
7730
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS
7678
7731
  ]
7679
7732
  };
7680
- var migrationConfig = {
7681
- bnUSD: {
7682
- [ICON_MAINNET_CHAIN_ID]: {
7683
- legacybnUSD: spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
7684
- newbnUSD: hubVaults.bnUSD.address
7685
- },
7686
- [SUI_MAINNET_CHAIN_ID]: {
7687
- legacybnUSD: spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.legacybnUSD,
7688
- newbnUSD: hubVaults.bnUSD.address
7689
- },
7690
- [STELLAR_MAINNET_CHAIN_ID]: {
7691
- legacybnUSD: spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.legacybnUSD,
7692
- newbnUSD: hubVaults.bnUSD.address
7693
- }
7694
- },
7695
- ICX: {
7696
- [ICON_MAINNET_CHAIN_ID]: {
7697
- icx: spokeChainConfig[ICON_MAINNET_CHAIN_ID]["nativeToken"],
7698
- wICX: spokeChainConfig[ICON_MAINNET_CHAIN_ID]["addresses"]["wICX"]
7699
- }
7700
- }
7701
- };
7702
7733
  var isMoneyMarketSupportedToken = (chainId, token) => moneyMarketSupportedTokens[chainId].some((t) => t.address.toLowerCase() === token.toLowerCase());
7703
7734
  var getSupportedMoneyMarketTokens = (chainId) => moneyMarketSupportedTokens[chainId];
7704
7735
  var hubVaultsAddressSet = new Set(
@@ -9025,16 +9056,28 @@ var EvmWalletAbstraction = class {
9025
9056
  var WalletAbstractionService = class {
9026
9057
  constructor() {
9027
9058
  }
9028
- static async getUserHubWalletAddress(chainId, address, hubProvider, spokeProvider) {
9029
- if (chainId === hubProvider.chainConfig.chain.id) {
9059
+ /**
9060
+ * Gets the hub wallet address for a user based on their spoke chain address.
9061
+ * @param address - The user's address on the spoke chain
9062
+ * @param spokeProvider - The provider for interacting with the spoke chain
9063
+ * @param hubProvider - The provider for interacting with the hub chain
9064
+ * @returns The user's hub wallet address
9065
+ */
9066
+ static async getUserHubWalletAddress(address, spokeProvider, hubProvider) {
9067
+ const encodedAddress = encodeAddress(spokeProvider.chainConfig.chain.id, address);
9068
+ if (spokeProvider.chainConfig.chain.id === hubProvider.chainConfig.chain.id) {
9030
9069
  if (spokeProvider instanceof SonicSpokeProvider) {
9031
- return SonicSpokeService.getUserRouter(address, spokeProvider);
9070
+ return SonicSpokeService.getUserRouter(encodedAddress, spokeProvider);
9032
9071
  }
9033
9072
  throw new Error(
9034
9073
  "[WalletAbstractionService.getUserHubWalletAddress] Invalid spoke provider. Sonic spoke provider is required."
9035
9074
  );
9036
9075
  }
9037
- return EvmWalletAbstraction.getUserHubWalletAddress(chainId, address, hubProvider);
9076
+ return EvmWalletAbstraction.getUserHubWalletAddress(
9077
+ spokeProvider.chainConfig.chain.id,
9078
+ encodedAddress,
9079
+ hubProvider
9080
+ );
9038
9081
  }
9039
9082
  };
9040
9083
  async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
@@ -9412,26 +9455,32 @@ var MoneyMarketService = class _MoneyMarketService {
9412
9455
  if (!txResult.ok) {
9413
9456
  return txResult;
9414
9457
  }
9415
- const packetResult = await relayTxAndWaitPacket(
9416
- txResult.value,
9417
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9418
- spokeProvider,
9419
- this.config.relayerApiEndpoint,
9420
- timeout
9421
- );
9422
- if (!packetResult.ok) {
9423
- return {
9424
- ok: false,
9425
- error: {
9426
- code: packetResult.error.code,
9427
- data: {
9428
- error: packetResult.error,
9429
- payload: txResult.value
9458
+ let intentTxHash = null;
9459
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9460
+ const packetResult = await relayTxAndWaitPacket(
9461
+ txResult.value,
9462
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9463
+ spokeProvider,
9464
+ this.config.relayerApiEndpoint,
9465
+ timeout
9466
+ );
9467
+ if (!packetResult.ok) {
9468
+ return {
9469
+ ok: false,
9470
+ error: {
9471
+ code: packetResult.error.code,
9472
+ data: {
9473
+ error: packetResult.error,
9474
+ payload: txResult.value
9475
+ }
9430
9476
  }
9431
- }
9432
- };
9477
+ };
9478
+ }
9479
+ intentTxHash = packetResult.value.dst_tx_hash;
9480
+ } else {
9481
+ intentTxHash = txResult.value;
9433
9482
  }
9434
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9483
+ return { ok: true, value: [txResult.value, intentTxHash] };
9435
9484
  } catch (error) {
9436
9485
  return {
9437
9486
  ok: false,
@@ -9486,12 +9535,11 @@ var MoneyMarketService = class _MoneyMarketService {
9486
9535
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9487
9536
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9488
9537
  );
9489
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9538
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9490
9539
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9491
- spokeProvider.chainConfig.chain.id,
9492
- walletAddressBytes,
9493
- this.hubProvider,
9494
- spokeProvider
9540
+ walletAddress,
9541
+ spokeProvider,
9542
+ this.hubProvider
9495
9543
  );
9496
9544
  const data = this.buildSupplyData(
9497
9545
  params.token,
@@ -9499,7 +9547,6 @@ var MoneyMarketService = class _MoneyMarketService {
9499
9547
  params.amount,
9500
9548
  spokeProvider.chainConfig.chain.id
9501
9549
  );
9502
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9503
9550
  const txResult = await SpokeService.deposit(
9504
9551
  {
9505
9552
  from: walletAddress,
@@ -9566,26 +9613,32 @@ var MoneyMarketService = class _MoneyMarketService {
9566
9613
  if (!txResult.ok) {
9567
9614
  return txResult;
9568
9615
  }
9569
- const packetResult = await relayTxAndWaitPacket(
9570
- txResult.value,
9571
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9572
- spokeProvider,
9573
- this.config.relayerApiEndpoint,
9574
- timeout
9575
- );
9576
- if (!packetResult.ok) {
9577
- return {
9578
- ok: false,
9579
- error: {
9580
- code: packetResult.error.code,
9581
- data: {
9582
- error: packetResult.error,
9583
- payload: txResult.value
9616
+ let intentTxHash = null;
9617
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9618
+ const packetResult = await relayTxAndWaitPacket(
9619
+ txResult.value,
9620
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9621
+ spokeProvider,
9622
+ this.config.relayerApiEndpoint,
9623
+ timeout
9624
+ );
9625
+ if (!packetResult.ok) {
9626
+ return {
9627
+ ok: false,
9628
+ error: {
9629
+ code: packetResult.error.code,
9630
+ data: {
9631
+ error: packetResult.error,
9632
+ payload: txResult.value
9633
+ }
9584
9634
  }
9585
- }
9586
- };
9635
+ };
9636
+ }
9637
+ intentTxHash = packetResult.value.dst_tx_hash;
9638
+ } else {
9639
+ intentTxHash = txResult.value;
9587
9640
  }
9588
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9641
+ return { ok: true, value: [txResult.value, intentTxHash] };
9589
9642
  } catch (error) {
9590
9643
  return {
9591
9644
  ok: false,
@@ -9637,16 +9690,16 @@ var MoneyMarketService = class _MoneyMarketService {
9637
9690
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9638
9691
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9639
9692
  );
9640
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9693
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9694
+ const encodedAddress = encodeAddress(spokeProvider.chainConfig.chain.id, walletAddress);
9641
9695
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9642
- spokeProvider.chainConfig.chain.id,
9643
- walletAddressBytes,
9644
- this.hubProvider,
9645
- spokeProvider
9696
+ walletAddress,
9697
+ spokeProvider,
9698
+ this.hubProvider
9646
9699
  );
9647
9700
  const data = this.buildBorrowData(
9648
9701
  hubWallet,
9649
- walletAddressBytes,
9702
+ encodedAddress,
9650
9703
  params.token,
9651
9704
  params.amount,
9652
9705
  spokeProvider.chainConfig.chain.id
@@ -9695,26 +9748,32 @@ var MoneyMarketService = class _MoneyMarketService {
9695
9748
  if (!txResult.ok) {
9696
9749
  return txResult;
9697
9750
  }
9698
- const packetResult = await relayTxAndWaitPacket(
9699
- txResult.value,
9700
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9701
- spokeProvider,
9702
- this.config.relayerApiEndpoint,
9703
- timeout
9704
- );
9705
- if (!packetResult.ok) {
9706
- return {
9707
- ok: false,
9708
- error: {
9709
- code: packetResult.error.code,
9710
- data: {
9711
- error: packetResult.error,
9712
- payload: txResult.value
9751
+ let intentTxHash = null;
9752
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9753
+ const packetResult = await relayTxAndWaitPacket(
9754
+ txResult.value,
9755
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9756
+ spokeProvider,
9757
+ this.config.relayerApiEndpoint,
9758
+ timeout
9759
+ );
9760
+ if (!packetResult.ok) {
9761
+ return {
9762
+ ok: false,
9763
+ error: {
9764
+ code: packetResult.error.code,
9765
+ data: {
9766
+ error: packetResult.error,
9767
+ payload: txResult.value
9768
+ }
9713
9769
  }
9714
- }
9715
- };
9770
+ };
9771
+ }
9772
+ intentTxHash = packetResult.value.dst_tx_hash;
9773
+ } else {
9774
+ intentTxHash = txResult.value;
9716
9775
  }
9717
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9776
+ return { ok: true, value: [txResult.value, intentTxHash] };
9718
9777
  } catch (error) {
9719
9778
  return {
9720
9779
  ok: false,
@@ -9766,16 +9825,16 @@ var MoneyMarketService = class _MoneyMarketService {
9766
9825
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9767
9826
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9768
9827
  );
9769
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9828
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9829
+ const encodedAddress = encodeAddress(spokeProvider.chainConfig.chain.id, walletAddress);
9770
9830
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9771
- spokeProvider.chainConfig.chain.id,
9772
- walletAddressBytes,
9773
- this.hubProvider,
9774
- spokeProvider
9831
+ walletAddress,
9832
+ spokeProvider,
9833
+ this.hubProvider
9775
9834
  );
9776
9835
  const data = this.buildWithdrawData(
9777
9836
  hubWallet,
9778
- walletAddressBytes,
9837
+ encodedAddress,
9779
9838
  params.token,
9780
9839
  params.amount,
9781
9840
  spokeProvider.chainConfig.chain.id
@@ -9824,26 +9883,32 @@ var MoneyMarketService = class _MoneyMarketService {
9824
9883
  if (!txResult.ok) {
9825
9884
  return txResult;
9826
9885
  }
9827
- const packetResult = await relayTxAndWaitPacket(
9828
- txResult.value,
9829
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9830
- spokeProvider,
9831
- this.config.relayerApiEndpoint,
9832
- timeout
9833
- );
9834
- if (!packetResult.ok) {
9835
- return {
9836
- ok: false,
9837
- error: {
9838
- code: packetResult.error.code,
9839
- data: {
9840
- error: packetResult.error,
9841
- payload: txResult.value
9886
+ let intentTxHash = null;
9887
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9888
+ const packetResult = await relayTxAndWaitPacket(
9889
+ txResult.value,
9890
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9891
+ spokeProvider,
9892
+ this.config.relayerApiEndpoint,
9893
+ timeout
9894
+ );
9895
+ if (!packetResult.ok) {
9896
+ return {
9897
+ ok: false,
9898
+ error: {
9899
+ code: packetResult.error.code,
9900
+ data: {
9901
+ error: packetResult.error,
9902
+ payload: txResult.value
9903
+ }
9842
9904
  }
9843
- }
9844
- };
9905
+ };
9906
+ }
9907
+ intentTxHash = packetResult.value.dst_tx_hash;
9908
+ } else {
9909
+ intentTxHash = txResult.value;
9845
9910
  }
9846
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9911
+ return { ok: true, value: [txResult.value, intentTxHash] };
9847
9912
  } catch (error) {
9848
9913
  return {
9849
9914
  ok: false,
@@ -9897,15 +9962,13 @@ var MoneyMarketService = class _MoneyMarketService {
9897
9962
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9898
9963
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9899
9964
  );
9900
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9965
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9901
9966
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9902
- spokeProvider.chainConfig.chain.id,
9903
- walletAddressBytes,
9904
- this.hubProvider,
9905
- spokeProvider
9967
+ walletAddress,
9968
+ spokeProvider,
9969
+ this.hubProvider
9906
9970
  );
9907
9971
  const data = this.buildRepayData(params.token, hubWallet, params.amount, spokeProvider.chainConfig.chain.id);
9908
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9909
9972
  const txResult = await SpokeService.deposit(
9910
9973
  {
9911
9974
  from: walletAddress,
@@ -11614,6 +11677,18 @@ function isMoneyMarketWithdrawUnknownError(error) {
11614
11677
  function isMoneyMarketRepayUnknownError(error) {
11615
11678
  return typeof error === "object" && error !== null && "code" in error && error.code === "REPAY_UNKNOWN_ERROR";
11616
11679
  }
11680
+ function isIcxMigrateParams(value) {
11681
+ return typeof value === "object" && value !== null && "address" in value && "amount" in value && "to" in value;
11682
+ }
11683
+ function isUnifiedBnUSDMigrateParams(value) {
11684
+ return typeof value === "object" && value !== null && "srcChainId" in value && "srcbnUSD" in value && "dstChainId" in value && "dstbnUSD" in value && "amount" in value && "to" in value;
11685
+ }
11686
+ function isBalnMigrateParams(value) {
11687
+ return typeof value === "object" && value !== null && "amount" in value && "lockupPeriod" in value && "to" in value && "stake" in value;
11688
+ }
11689
+ function isIcxCreateRevertMigrationParams(value) {
11690
+ return typeof value === "object" && value !== null && "amount" in value && "to" in value;
11691
+ }
11617
11692
 
11618
11693
  // src/services/spoke/SpokeService.ts
11619
11694
  var SpokeService = class {
@@ -12496,15 +12571,15 @@ var SolverService = class {
12496
12571
  * // handle error
12497
12572
  * }
12498
12573
  */
12499
- async swap(payload, spokeProvider, fee, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
12500
- return this.createAndSubmitIntent(payload, spokeProvider, fee, timeout);
12574
+ async swap(payload, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
12575
+ return this.createAndSubmitIntent(payload, spokeProvider, this.config.partnerFee, timeout);
12501
12576
  }
12502
12577
  /**
12503
12578
  * Creates an intent and submits it to the Solver API and Relayer API
12504
12579
  * @param {CreateIntentParams} payload - The intent to create
12505
12580
  * @param {ISpokeProvider} spokeProvider - The spoke provider
12506
12581
  * @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
12507
- * @returns {Promise<Result<[SolverExecutionResponse, Intent, PacketData], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
12582
+ * @returns {Promise<Result<[SolverExecutionResponse, Intent, Hex], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
12508
12583
  *
12509
12584
  * @example
12510
12585
  * const payload = {
@@ -12533,49 +12608,55 @@ var SolverService = class {
12533
12608
  * // handle error
12534
12609
  * }
12535
12610
  */
12536
- async createAndSubmitIntent(payload, spokeProvider, fee, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
12611
+ async createAndSubmitIntent(payload, spokeProvider, fee = this.config.partnerFee, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
12537
12612
  try {
12538
12613
  const createIntentResult = await this.createIntent(payload, spokeProvider, fee, false);
12539
12614
  if (!createIntentResult.ok) {
12540
12615
  return createIntentResult;
12541
12616
  }
12542
12617
  const [spokeTxHash, intent, data] = createIntentResult.value;
12543
- const intentRelayChainId = getIntentRelayChainId(payload.srcChain).toString();
12544
- const submitPayload = payload.srcChain === SOLANA_MAINNET_CHAIN_ID && data ? {
12545
- action: "submit",
12546
- params: {
12547
- chain_id: intentRelayChainId,
12548
- tx_hash: spokeTxHash,
12549
- data: {
12550
- address: intent.creator,
12551
- payload: data
12618
+ let intentTxHash = null;
12619
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
12620
+ const intentRelayChainId = getIntentRelayChainId(payload.srcChain).toString();
12621
+ const submitPayload = payload.srcChain === SOLANA_MAINNET_CHAIN_ID && data ? {
12622
+ action: "submit",
12623
+ params: {
12624
+ chain_id: intentRelayChainId,
12625
+ tx_hash: spokeTxHash,
12626
+ data: {
12627
+ address: intent.creator,
12628
+ payload: data
12629
+ }
12630
+ }
12631
+ } : {
12632
+ action: "submit",
12633
+ params: {
12634
+ chain_id: intentRelayChainId,
12635
+ tx_hash: spokeTxHash
12552
12636
  }
12637
+ };
12638
+ const submitResult = await this.submitIntent(submitPayload);
12639
+ if (!submitResult.ok) {
12640
+ return submitResult;
12553
12641
  }
12554
- } : {
12555
- action: "submit",
12556
- params: {
12557
- chain_id: intentRelayChainId,
12558
- tx_hash: spokeTxHash
12642
+ const packet = await waitUntilIntentExecuted({
12643
+ intentRelayChainId,
12644
+ spokeTxHash,
12645
+ timeout,
12646
+ apiUrl: this.config.relayerApiEndpoint
12647
+ });
12648
+ if (!packet.ok) {
12649
+ return {
12650
+ ok: false,
12651
+ error: packet.error
12652
+ };
12559
12653
  }
12560
- };
12561
- const submitResult = await this.submitIntent(submitPayload);
12562
- if (!submitResult.ok) {
12563
- return submitResult;
12564
- }
12565
- const packet = await waitUntilIntentExecuted({
12566
- intentRelayChainId,
12567
- spokeTxHash,
12568
- timeout,
12569
- apiUrl: this.config.relayerApiEndpoint
12570
- });
12571
- if (!packet.ok) {
12572
- return {
12573
- ok: false,
12574
- error: packet.error
12575
- };
12654
+ intentTxHash = packet.value.dst_tx_hash;
12655
+ } else {
12656
+ intentTxHash = spokeTxHash;
12576
12657
  }
12577
12658
  const result = await this.postExecution({
12578
- intent_tx_hash: packet.value.dst_tx_hash
12659
+ intent_tx_hash: intentTxHash
12579
12660
  });
12580
12661
  if (!result.ok) {
12581
12662
  return {
@@ -12588,7 +12669,7 @@ var SolverService = class {
12588
12669
  }
12589
12670
  return {
12590
12671
  ok: true,
12591
- value: [result.value, intent, packet.value]
12672
+ value: [result.value, intent, intentTxHash]
12592
12673
  };
12593
12674
  } catch (error) {
12594
12675
  return {
@@ -12758,12 +12839,7 @@ var SolverService = class {
12758
12839
  "srcAddress must be the same as wallet address"
12759
12840
  );
12760
12841
  const walletAddressBytes = encodeAddress(params.srcChain, walletAddress);
12761
- const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
12762
- params.srcChain,
12763
- walletAddressBytes,
12764
- this.hubProvider,
12765
- spokeProvider
12766
- );
12842
+ const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(walletAddress, spokeProvider, this.hubProvider);
12767
12843
  const [data, intent, feeAmount] = EvmSolverService.constructCreateIntentData(
12768
12844
  {
12769
12845
  ...params,
@@ -12813,13 +12889,9 @@ var SolverService = class {
12813
12889
  try {
12814
12890
  invariant2(isValidIntentRelayChainId(intent.srcChain), `Invalid intent.srcChain: ${intent.srcChain}`);
12815
12891
  invariant2(isValidIntentRelayChainId(intent.dstChain), `Invalid intent.dstChain: ${intent.dstChain}`);
12816
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
12817
- const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
12818
- spokeProvider.chainConfig.chain.id,
12819
- walletAddressBytes,
12820
- this.hubProvider,
12821
- spokeProvider
12822
- );
12892
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
12893
+ const walletAddressBytes = encodeAddress(spokeProvider.chainConfig.chain.id, walletAddress);
12894
+ const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(walletAddress, spokeProvider, this.hubProvider);
12823
12895
  const calls = [];
12824
12896
  const intentsContract = this.config.intentsContract;
12825
12897
  calls.push(EvmSolverService.encodeCancelIntent(intent, intentsContract));
@@ -13444,9 +13516,25 @@ var MigrationService = class {
13444
13516
  invariant2(params.amount > 0n, "Amount must be greater than 0");
13445
13517
  invariant2(isAddress(params.to) || isIconAddress(params.to), "To address is required");
13446
13518
  invariant2(
13447
- spokeProvider instanceof IconSpokeProvider || spokeProvider instanceof SuiSpokeProvider || spokeProvider instanceof StellarSpokeProvider,
13448
- "Spoke provider must be an instance of IconSpokeProvider, SuiSpokeProvider, or StellarSpokeProvider"
13519
+ isIcxMigrateParams(params) || isBalnMigrateParams(params) || isUnifiedBnUSDMigrateParams(params),
13520
+ "Invalid params"
13449
13521
  );
13522
+ if (spokeProvider instanceof IconSpokeProvider && (isIcxMigrateParams(params) || isBalnMigrateParams(params))) {
13523
+ return {
13524
+ ok: true,
13525
+ value: true
13526
+ };
13527
+ }
13528
+ if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
13529
+ const evmSpokeProvider = spokeProvider;
13530
+ return await Erc20Service.isAllowanceValid(
13531
+ params.srcbnUSD,
13532
+ params.amount,
13533
+ await evmSpokeProvider.walletProvider.getWalletAddress(),
13534
+ evmSpokeProvider instanceof EvmSpokeProvider ? evmSpokeProvider.chainConfig.addresses.assetManager : evmSpokeProvider.chainConfig.bnUSD,
13535
+ evmSpokeProvider
13536
+ );
13537
+ }
13450
13538
  return {
13451
13539
  ok: true,
13452
13540
  value: true
@@ -13455,19 +13543,28 @@ var MigrationService = class {
13455
13543
  if (action === "revert") {
13456
13544
  invariant2(params.amount > 0n, "Amount must be greater than 0");
13457
13545
  invariant2(params.to.length > 0, "To address is required");
13458
- invariant2(
13459
- spokeProvider instanceof SonicSpokeProvider,
13460
- "Spoke provider must be an instance of SonicSpokeProvider"
13461
- );
13462
- const wallet = await spokeProvider.walletProvider.getWalletAddress();
13463
- const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
13464
- return await Erc20Service.isAllowanceValid(
13465
- this.hubProvider.chainConfig.addresses.sodaToken,
13466
- params.amount,
13467
- wallet,
13468
- userRouter,
13469
- spokeProvider
13470
- );
13546
+ invariant2(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
13547
+ if (spokeProvider instanceof SonicSpokeProvider && isIcxCreateRevertMigrationParams(params)) {
13548
+ const wallet = await spokeProvider.walletProvider.getWalletAddress();
13549
+ const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
13550
+ return await Erc20Service.isAllowanceValid(
13551
+ this.hubProvider.chainConfig.addresses.sodaToken,
13552
+ params.amount,
13553
+ wallet,
13554
+ userRouter,
13555
+ spokeProvider
13556
+ );
13557
+ }
13558
+ if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
13559
+ const evmSpokeProvider = spokeProvider;
13560
+ return await Erc20Service.isAllowanceValid(
13561
+ params.srcbnUSD,
13562
+ params.amount,
13563
+ await evmSpokeProvider.walletProvider.getWalletAddress(),
13564
+ evmSpokeProvider instanceof EvmSpokeProvider ? evmSpokeProvider.chainConfig.addresses.assetManager : evmSpokeProvider.chainConfig.bnUSD,
13565
+ evmSpokeProvider
13566
+ );
13567
+ }
13471
13568
  }
13472
13569
  return {
13473
13570
  ok: false,
@@ -13501,25 +13598,65 @@ var MigrationService = class {
13501
13598
  */
13502
13599
  async approve(params, action, spokeProvider, raw) {
13503
13600
  try {
13601
+ if (action === "migrate") {
13602
+ invariant2(params.amount > 0n, "Amount must be greater than 0");
13603
+ invariant2(params.to.length > 0, "To address is required");
13604
+ invariant2(isUnifiedBnUSDMigrateParams(params), "Invalid params");
13605
+ if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
13606
+ const evmSpokeProvider = spokeProvider;
13607
+ const result = await Erc20Service.approve(
13608
+ params.srcbnUSD,
13609
+ params.amount,
13610
+ evmSpokeProvider instanceof EvmSpokeProvider ? evmSpokeProvider.chainConfig.addresses.assetManager : evmSpokeProvider.chainConfig.bnUSD,
13611
+ evmSpokeProvider,
13612
+ raw
13613
+ );
13614
+ return {
13615
+ ok: true,
13616
+ value: result
13617
+ };
13618
+ }
13619
+ return {
13620
+ ok: false,
13621
+ error: new Error("Invalid params for migrate action")
13622
+ };
13623
+ }
13504
13624
  if (action === "revert") {
13505
13625
  invariant2(params.amount > 0n, "Amount must be greater than 0");
13506
13626
  invariant2(params.to.length > 0, "To address is required");
13507
- invariant2(
13508
- spokeProvider instanceof SonicSpokeProvider,
13509
- "Spoke provider must be an instance of SonicSpokeProvider"
13510
- );
13511
- const wallet = await spokeProvider.walletProvider.getWalletAddress();
13512
- const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
13513
- const result = await Erc20Service.approve(
13514
- this.hubProvider.chainConfig.addresses.sodaToken,
13515
- params.amount,
13516
- userRouter,
13517
- spokeProvider,
13518
- raw
13519
- );
13627
+ invariant2(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
13628
+ if (spokeProvider instanceof SonicSpokeProvider && isIcxCreateRevertMigrationParams(params)) {
13629
+ const wallet = await spokeProvider.walletProvider.getWalletAddress();
13630
+ const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
13631
+ const result = await Erc20Service.approve(
13632
+ this.hubProvider.chainConfig.addresses.sodaToken,
13633
+ params.amount,
13634
+ userRouter,
13635
+ spokeProvider,
13636
+ raw
13637
+ );
13638
+ return {
13639
+ ok: true,
13640
+ value: result
13641
+ };
13642
+ }
13643
+ if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
13644
+ const evmSpokeProvider = spokeProvider;
13645
+ const result = await Erc20Service.approve(
13646
+ params.srcbnUSD,
13647
+ params.amount,
13648
+ evmSpokeProvider instanceof EvmSpokeProvider ? evmSpokeProvider.chainConfig.addresses.assetManager : evmSpokeProvider.chainConfig.bnUSD,
13649
+ evmSpokeProvider,
13650
+ raw
13651
+ );
13652
+ return {
13653
+ ok: true,
13654
+ value: result
13655
+ };
13656
+ }
13520
13657
  return {
13521
- ok: true,
13522
- value: result
13658
+ ok: false,
13659
+ error: new Error("Invalid params or chain type for revert action")
13523
13660
  };
13524
13661
  }
13525
13662
  return {
@@ -13534,27 +13671,37 @@ var MigrationService = class {
13534
13671
  }
13535
13672
  }
13536
13673
  /**
13537
- * Migrates legacy bnUSD tokens to new bnUSD tokens on the hub chain (sonic).
13538
- * This function handles the migration of legacy bnUSD tokens to new bnUSD tokens.
13674
+ * Migrates bnUSD tokens between legacy and new formats across supported spoke chains via the hub chain (sonic).
13675
+ * Handles both legacy-to-new and new-to-legacy bnUSD migrations, enforcing validation and relaying the transaction.
13539
13676
  *
13540
- * @param params - The parameters for the migration transaction.
13541
- * @param spokeProvider - The spoke provider.
13542
- * @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
13677
+ * @param params - Migration parameters, including source/destination chain IDs, token addresses, amount, and recipient.
13678
+ * @param spokeProvider - The SpokeProvider instance for the source chain.
13679
+ * @param timeout - Optional timeout in milliseconds for the relay operation (default: 60 seconds).
13680
+ * @param unchecked - Optional flag to skip validation checks (default: false).
13543
13681
  * @returns {Promise<Result<[string, Hex], MigrationError<'MIGRATION_FAILED'> | MigrationError<'CREATE_MIGRATION_INTENT_FAILED'> | RelayError>>}
13544
- * Returns a Result containing a tuple of [spokeTxHash, hubTxHash] if successful,
13545
- * or an error describing why the migration or relay failed.
13546
- *
13682
+ * Result containing a tuple: [spokeTxHash, hubTxHash] if successful, or an error describing the failure.
13547
13683
  *
13548
13684
  * @example
13549
- * // Example: Migrate legacy bnUSD tokens to new bnUSD tokens on the hub chain (sonic)
13685
+ * // Migrate legacy bnUSD to new bnUSD
13550
13686
  * const result = await sodax.migration.migratebnUSD({
13551
- * address: 'cx88fd7df7ddff82f7cc735c871dc519838cb235bb', // mock legacy bnUSD address
13552
- * srcChainID: '0x1.icon', // source chain ID (e.g., ICON_MAINNET_CHAIN_ID)
13553
- * amount: 1000000000000000000n,
13554
- * to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', // recipient address
13555
- * dstChainID: 'sonic', // destination hub chain ID (e.g., SONIC_MAINNET_CHAIN_ID)
13687
+ * srcChainId: '0x1.icon', // Source chain ID (legacy)
13688
+ * dstChainId: 'sonic', // Destination chain ID (new)
13689
+ * srcbnUSD: 'cx...', // Legacy bnUSD token address
13690
+ * dstbnUSD: '0x...', // New bnUSD token address
13691
+ * amount: 1000n, // Amount to migrate
13692
+ * to: '0x...', // Recipient address on destination chain
13556
13693
  * }, iconSpokeProvider);
13557
13694
  *
13695
+ * // Reverse migration: new bnUSD to legacy bnUSD
13696
+ * const result = await sodax.migration.migratebnUSD({
13697
+ * srcChainId: 'sonic', // Source chain ID (new)
13698
+ * dstChainId: '0x1.icon', // Destination chain ID (legacy)
13699
+ * srcbnUSD: '0x...', // New bnUSD token address
13700
+ * dstbnUSD: 'cx...', // Legacy bnUSD token address
13701
+ * amount: 1000n, // Amount to migrate
13702
+ * to: 'hx...', // Recipient address on destination chain
13703
+ * }, sonicSpokeProvider);
13704
+ *
13558
13705
  * if (result.ok) {
13559
13706
  * // result.value is a tuple: [spokeTxHash, hubTxHash]
13560
13707
  * const [spokeTxHash, hubTxHash] = result.value;
@@ -13565,9 +13712,9 @@ var MigrationService = class {
13565
13712
  * console.error('[migrateBnUSD] error', result.error);
13566
13713
  * }
13567
13714
  */
13568
- async migratebnUSD(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
13715
+ async migratebnUSD(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT, unchecked = false) {
13569
13716
  try {
13570
- const txResult = await this.createMigratebnUSDIntent(params, spokeProvider);
13717
+ const txResult = await this.createMigratebnUSDIntent(params, spokeProvider, unchecked);
13571
13718
  if (!txResult.ok) {
13572
13719
  return {
13573
13720
  ok: false,
@@ -13598,70 +13745,6 @@ var MigrationService = class {
13598
13745
  };
13599
13746
  }
13600
13747
  }
13601
- /**
13602
- * Reverses the migration of legacy bnUSD tokens to new bnUSD tokens on the hub chain (sonic).
13603
- * This function handles the reversal of the migration of legacy bnUSD tokens to new bnUSD tokens.
13604
- *
13605
- * @param params - The parameters for the migration transaction.
13606
- * @param spokeProvider - The spoke provider.
13607
- * @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
13608
- * @returns {Promise<Result<[string, Hex], MigrationError<'REVERT_MIGRATION_FAILED'> | MigrationError<'CREATE_REVERT_MIGRATION_INTENT_FAILED'> | RelayError>>}
13609
- * Returns a Result containing a tuple of [spokeTxHash, hubTxHash] if successful,
13610
- * or an error describing why the revert migration or relay failed.
13611
- *
13612
- *
13613
- * @example
13614
- * // Example: Reverse the migration of legacy bnUSD tokens to new bnUSD tokens on the hub chain (sonic)
13615
- * const result = await sodax.migration.reverseMigratebnUSD({
13616
- * srcChainID: 'sonic', // source chain ID (e.g., SONIC_MAINNET_CHAIN_ID)
13617
- * amount: 1000000000000000000n,
13618
- * to: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', // The spoke chain address that will receive the migrated legacy bnUSD tokens
13619
- * dstChainID: '0x1.icon', // destination chain ID of type bnUSDLegacySpokeChainId (e.g., ICON_MAINNET_CHAIN_ID)
13620
- * }, iconSpokeProvider);
13621
- *
13622
- * if (result.ok) {
13623
- * // result.value is a tuple: [spokeTxHash, hubTxHash]
13624
- * const [spokeTxHash, hubTxHash] = result.value;
13625
- * console.log('[reverseMigrateBnUSD] hubTxHash', hubTxHash);
13626
- * console.log('[reverseMigrateBnUSD] spokeTxHash', spokeTxHash);
13627
- * } else {
13628
- * // Handle revert migration error
13629
- * console.error('[reverseMigrateBnUSD] error', result.error);
13630
- * }
13631
- */
13632
- async reverseMigratebnUSD(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
13633
- try {
13634
- const txResult = await this.createRevertMigratebnUSDIntent(params, spokeProvider);
13635
- if (!txResult.ok) {
13636
- return {
13637
- ok: false,
13638
- error: txResult.error
13639
- };
13640
- }
13641
- const packetResult = await relayTxAndWaitPacket(
13642
- txResult.value,
13643
- void 0,
13644
- spokeProvider,
13645
- this.config.relayerApiEndpoint,
13646
- timeout
13647
- );
13648
- if (!packetResult.ok) {
13649
- return packetResult;
13650
- }
13651
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
13652
- } catch (error) {
13653
- return {
13654
- ok: false,
13655
- error: {
13656
- code: "REVERT_MIGRATION_FAILED",
13657
- data: {
13658
- payload: params,
13659
- error
13660
- }
13661
- }
13662
- };
13663
- }
13664
- }
13665
13748
  /**
13666
13749
  * Migrates ICX tokens to SODA tokens on the hub chain (sonic).
13667
13750
  * This function handles the migration of ICX tokens to SODA tokens.
@@ -13854,62 +13937,6 @@ var MigrationService = class {
13854
13937
  };
13855
13938
  }
13856
13939
  }
13857
- /**
13858
- * Creates a revert migration intent and submits (relays) it to the spoke chain.
13859
- * @param params - The parameters for the revert migration transaction.
13860
- * @param spokeProvider - The spoke provider.
13861
- * @param raw - Whether to return the raw transaction hash instead of the transaction receipt
13862
- * @returns {Promise<Result<TxReturnType<bnUSDLegacyMigrationProviders, R>>>} - Returns the raw transaction payload or transaction hash
13863
- *
13864
- * @example
13865
- * const result = await migrationService.createRevertMigratebnUSDIntent(
13866
- * {
13867
- * srcChainID: 'sonic', // The source chain ID where the new bnUSD token exists (hub chain)
13868
- * amount: 1000n, // The amount of new bnUSD tokens to migrate back
13869
- * to: '0x...', // The spoke chain address that will receive the migrated legacy bnUSD tokens
13870
- * dstChainID: '0x1.icon', // The destination chain ID for the migration (spoke chain)
13871
- * },
13872
- * spokeProvider, // IconSpokeProvider instance
13873
- * true // Optional raw flag to return the raw transaction hash instead of the transaction receipt
13874
- * );
13875
- *
13876
- */
13877
- async createRevertMigratebnUSDIntent(params, spokeProvider, raw) {
13878
- try {
13879
- const { legacybnUSD, newbnUSD } = migrationConfig.bnUSD[params.dstChainID];
13880
- const migrationData = this.bnUSDMigrationService.revertMigrationData({
13881
- ...params,
13882
- legacybnUSD: legacybnUSD.address,
13883
- newbnUSD
13884
- });
13885
- const txResult = await SpokeService.deposit(
13886
- {
13887
- from: await spokeProvider.walletProvider.getWalletAddressBytes(),
13888
- token: newbnUSD,
13889
- amount: params.amount,
13890
- data: migrationData
13891
- },
13892
- spokeProvider,
13893
- this.hubProvider,
13894
- raw
13895
- );
13896
- return {
13897
- ok: true,
13898
- value: txResult
13899
- };
13900
- } catch (error) {
13901
- return {
13902
- ok: false,
13903
- error: {
13904
- code: "CREATE_REVERT_MIGRATION_INTENT_FAILED",
13905
- data: {
13906
- payload: params,
13907
- error
13908
- }
13909
- }
13910
- };
13911
- }
13912
- }
13913
13940
  /**
13914
13941
  * Creates a BALN migration intent on spoke chain (icon).
13915
13942
  *
@@ -13964,39 +13991,112 @@ var MigrationService = class {
13964
13991
  }
13965
13992
  }
13966
13993
  /**
13967
- * Creates a bnUSD migration intent on spoke chain (icon).
13994
+ * Creates a bnUSD migration or reverse migration (legacy bnUSD to new bnUSD or vice versa) intent on a spoke chain.
13968
13995
  *
13969
- * @param params - The parameters for the bnUSD migration transaction.
13970
- * @param spokeProvider - The spoke provider.
13971
- * @param raw - Whether to return the raw transaction hash instead of the transaction receipt
13972
- * @returns {Promise<Result<TxReturnType<bnUSDLegacyMigrationProviders, R>>>} - Returns the raw transaction payload or transaction hash
13996
+ * This function prepares the transaction data for migrating legacy bnUSD to new bnUSD,
13997
+ * or for reverting (migrating new bnUSD back to legacy bnUSD), depending on the provided parameters.
13998
+ * It performs validation on chain IDs and token addresses unless `unchecked` is set to true.
13999
+ *
14000
+ * @param params - The parameters for the bnUSD migration or reverse migration transaction.
14001
+ * @param spokeProvider - The spoke provider instance for the source chain.
14002
+ * @param unchecked - If true, skips input validation (use with caution).
14003
+ * @param raw - If true, returns the raw transaction hash instead of the transaction receipt.
14004
+ * @returns {Promise<Result<TxReturnType<S, R>, MigrationError<'CREATE_MIGRATION_INTENT_FAILED'>>>}
14005
+ * Returns a Result containing the transaction payload or hash, or an error if creation failed.
13973
14006
  *
13974
14007
  * @example
14008
+ * // Migrate legacy bnUSD to new bnUSD
13975
14009
  * const result = await migrationService.createMigratebnUSDIntent(
13976
14010
  * {
13977
- * srcChainID: 'sonic', // The source chain ID where the legacy bnUSD token exists (spoke chain)
13978
- * amount: 1000n, // The amount of legacy bnUSD tokens to migrate
13979
- * to: '0x...', // The hub (sonic) chain address that will receive the migrated new bnUSD tokens
13980
- * dstChainID: '0x1.icon', // The destination chain ID for the migration (hub chain)
13981
- * },
13982
- * spokeProvider, // IconSpokeProvider instance
13983
- * true // Optional raw flag to return the raw transaction hash instead of the transaction receipt
14011
+ * srcChainId: '0x1.icon', // Source chain ID (legacy bnUSD chain)
14012
+ * dstChainId: 'sonic', // Destination chain ID (new bnUSD chain)
14013
+ * srcbnUSD: 'cx...', // Legacy bnUSD token address
14014
+ * dstbnUSD: '0x...', // New bnUSD token address
14015
+ * amount: 1000n, // Amount to migrate
14016
+ * to: '0x...', // Recipient address on destination chain
14017
+ * } satisfies UnifiedBnUSDMigrateParams,
14018
+ * spokeProvider, // SpokeProvider instance
14019
+ * false, // Optional unchecked flag (validation is skipped)
14020
+ * true // Optional raw flag
13984
14021
  * );
13985
14022
  *
14023
+ * // Reverse migration: new bnUSD to legacy bnUSD
14024
+ * const result = await migrationService.createMigratebnUSDIntent(
14025
+ * {
14026
+ * srcChainId: 'sonic', // Source chain ID (new bnUSD chain)
14027
+ * dstChainId: '0x1.icon', // Destination chain ID (legacy bnUSD chain)
14028
+ * srcbnUSD: '0x...', // New bnUSD token address
14029
+ * dstbnUSD: 'cx...', // Legacy bnUSD token address
14030
+ * amount: 1000n, // Amount to migrate
14031
+ * to: 'hx...', // Recipient address on destination chain
14032
+ * } satisfies UnifiedBnUSDMigrateParams,
14033
+ * spokeProvider
14034
+ * );
13986
14035
  */
13987
- async createMigratebnUSDIntent(params, spokeProvider, raw) {
14036
+ async createMigratebnUSDIntent(params, spokeProvider, unchecked = false, raw) {
13988
14037
  try {
13989
- const { legacybnUSD, newbnUSD } = migrationConfig.bnUSD[params.srcChainID];
13990
- const migrationData = this.bnUSDMigrationService.migrateData({
13991
- ...params,
13992
- to: encodeAddress(this.hubProvider.chainConfig.chain.id, params.to),
13993
- legacybnUSD: legacybnUSD.address,
13994
- newbnUSD
13995
- });
14038
+ if (!unchecked) {
14039
+ invariant2(isValidSpokeChainId(params.srcChainId), "Invalid spoke source chain ID");
14040
+ invariant2(isValidSpokeChainId(params.dstChainId), "Invalid spoke destination chain ID");
14041
+ invariant2(params.srcbnUSD.length > 0, "Legacy bnUSD token address is required");
14042
+ invariant2(params.dstbnUSD.length > 0, "New bnUSD token address is required");
14043
+ invariant2(params.amount > 0, "Amount must be greater than 0");
14044
+ invariant2(params.to.length > 0, "Recipient address is required");
14045
+ invariant2(
14046
+ !(isLegacybnUSDToken(params.srcbnUSD) && isLegacybnUSDToken(params.dstbnUSD)),
14047
+ "srcbnUSD and dstbnUSD cannot both be legacy bnUSD tokens"
14048
+ );
14049
+ }
14050
+ let migrationData;
14051
+ if (isLegacybnUSDToken(params.srcbnUSD)) {
14052
+ if (!unchecked) {
14053
+ invariant2(
14054
+ isLegacybnUSDChainId(params.srcChainId),
14055
+ "srcChainId must be a legacy bnUSD chain (icon, sui, stellar) if srcbnUSD is a legacy bnUSD token"
14056
+ );
14057
+ invariant2(
14058
+ isNewbnUSDChainId(params.dstChainId),
14059
+ "dstChainId must be a new bnUSD chain (all spoke chains besides Icon) if dstbnUSD is a legacy bnUSD token"
14060
+ );
14061
+ }
14062
+ migrationData = this.bnUSDMigrationService.migrateData({
14063
+ srcChainId: params.srcChainId,
14064
+ legacybnUSD: params.srcbnUSD,
14065
+ newbnUSD: params.dstbnUSD,
14066
+ dstChainId: params.dstChainId,
14067
+ amount: params.amount,
14068
+ to: encodeAddress(params.dstChainId, params.to)
14069
+ });
14070
+ } else if (isLegacybnUSDToken(params.dstbnUSD)) {
14071
+ if (!unchecked) {
14072
+ invariant2(
14073
+ isLegacybnUSDChainId(params.dstChainId),
14074
+ "dstChainId must be a legacy bnUSD chain (sui, stellar, icon) if dstbnUSD is a legacy bnUSD token"
14075
+ );
14076
+ invariant2(
14077
+ isNewbnUSDToken(params.srcbnUSD),
14078
+ "srcbnUSD must be a new bnUSD token if dstbnUSD is a legacy bnUSD token"
14079
+ );
14080
+ invariant2(
14081
+ isNewbnUSDChainId(params.srcChainId),
14082
+ "srcChainId must be a new bnUSD chain (all spoke chains besides Icon) if srcbnUSD is a new bnUSD token"
14083
+ );
14084
+ }
14085
+ migrationData = this.bnUSDMigrationService.revertMigrationData({
14086
+ srcChainId: params.srcChainId,
14087
+ legacybnUSD: params.dstbnUSD,
14088
+ newbnUSD: params.srcbnUSD,
14089
+ dstChainId: params.dstChainId,
14090
+ amount: params.amount,
14091
+ to: encodeAddress(params.dstChainId, params.to)
14092
+ });
14093
+ } else {
14094
+ throw new Error("srcbnUSD or dstbnUSD must be a legacy bnUSD token");
14095
+ }
13996
14096
  const txResult = await SpokeService.deposit(
13997
14097
  {
13998
14098
  from: await spokeProvider.walletProvider.getWalletAddress(),
13999
- token: legacybnUSD.address,
14099
+ token: params.srcbnUSD,
14000
14100
  amount: params.amount,
14001
14101
  data: migrationData
14002
14102
  },
@@ -14167,7 +14267,7 @@ var BnUSDMigrationService = class {
14167
14267
  */
14168
14268
  migrateData(params) {
14169
14269
  const calls = [];
14170
- const assetConfig = getHubAssetInfo(params.srcChainID, params.legacybnUSD);
14270
+ const assetConfig = getHubAssetInfo(params.srcChainId, params.legacybnUSD);
14171
14271
  invariant2(assetConfig, `hub asset not found for legacy bnUSD token: ${params.legacybnUSD}`);
14172
14272
  const bnUSDVault = getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID).bnUSDVault;
14173
14273
  calls.push(Erc20Service.encodeApprove(assetConfig.asset, assetConfig.vault, params.amount));
@@ -14179,7 +14279,7 @@ var BnUSDMigrationService = class {
14179
14279
  calls.push(Erc20Service.encodeTransfer(bnUSDVault, params.to, translatedAmount));
14180
14280
  return encodeContractCalls(calls);
14181
14281
  }
14182
- const dstAssetConfig = getHubAssetInfo(this.hubProvider.chainConfig.chain.id, params.newbnUSD);
14282
+ const dstAssetConfig = getHubAssetInfo(params.dstChainId, params.newbnUSD);
14183
14283
  invariant2(dstAssetConfig, `hub asset not found for new bnUSD token: ${params.newbnUSD}`);
14184
14284
  calls.push(EvmVaultTokenService.encodeWithdraw(bnUSDVault, dstAssetConfig.asset, translatedAmount));
14185
14285
  const translatedAmountOut = EvmVaultTokenService.translateOutgoingDecimals(
@@ -14210,19 +14310,17 @@ var BnUSDMigrationService = class {
14210
14310
  revertMigrationData(params) {
14211
14311
  const calls = [];
14212
14312
  const bnUSDVault = getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID).bnUSDVault;
14213
- console.log("params.newbnUSD", params.newbnUSD);
14214
- console.log("bnUSDVault", bnUSDVault);
14215
14313
  let decimals = 18;
14216
14314
  if (params.newbnUSD.toLowerCase() !== bnUSDVault.toLowerCase()) {
14217
- const assetConfig = getHubAssetInfo(params.srcChainID, params.newbnUSD);
14315
+ const assetConfig = getHubAssetInfo(params.srcChainId, params.newbnUSD);
14218
14316
  invariant2(assetConfig, `hub asset not found for new bnUSD token: ${params.newbnUSD}`);
14219
14317
  decimals = assetConfig.decimal;
14220
14318
  calls.push(Erc20Service.encodeApprove(assetConfig.asset, bnUSDVault, params.amount));
14221
14319
  calls.push(EvmVaultTokenService.encodeDeposit(bnUSDVault, assetConfig.asset, params.amount));
14222
14320
  }
14223
14321
  const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(decimals, params.amount);
14224
- const dstAssetConfig = getHubAssetInfo(params.dstChainID, params.legacybnUSD);
14225
- invariant2(dstAssetConfig, `hub asset not found for legacy bnUSD token: ${params.legacybnUSD}`);
14322
+ const dstAssetConfig = getHubAssetInfo(params.dstChainId, params.legacybnUSD);
14323
+ invariant2(dstAssetConfig, `hub asset not found for new bnUSD token: ${params.legacybnUSD}`);
14226
14324
  calls.push(EvmVaultTokenService.encodeWithdraw(bnUSDVault, dstAssetConfig.vault, translatedAmount));
14227
14325
  calls.push(EvmVaultTokenService.encodeWithdraw(dstAssetConfig.vault, dstAssetConfig.asset, translatedAmount));
14228
14326
  const translatedAmountOut = EvmVaultTokenService.translateOutgoingDecimals(
@@ -14538,6 +14636,6 @@ var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
14538
14636
  return SolverIntentErrorCode2;
14539
14637
  })(SolverIntentErrorCode || {});
14540
14638
 
14541
- export { BalnSwapService, BigIntToHex, BnUSDMigrationService, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, EVM_CHAIN_IDS, EVM_SPOKE_CHAIN_IDS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, SupportedMigrationTokens, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, balnSwapAbi, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isInjectiveSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, migrationConfig, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, originalAssetTohubAssetMap, poolAbi, randomUint256, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, variableDebtTokenAbi, vaultTokenAbi, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
14639
+ export { BalnSwapService, BigIntToHex, BnUSDMigrationService, ChainIdToIntentRelayChainId, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, EVM_CHAIN_IDS, EVM_SPOKE_CHAIN_IDS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, SupportedMigrationTokens, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, balnSwapAbi, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getAllLegacybnUSDTokens, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isBalnMigrateParams, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isNewbnUSDChainId, isNewbnUSDToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isUnifiedBnUSDMigrateParams, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, newbnUSDSpokeChainIds, originalAssetTohubAssetMap, poolAbi, randomUint256, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, variableDebtTokenAbi, vaultTokenAbi, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
14542
14640
  //# sourceMappingURL=index.mjs.map
14543
14641
  //# sourceMappingURL=index.mjs.map