@sodax/sdk 1.2.4-beta → 1.2.6-beta

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
@@ -10443,13 +10443,12 @@ var MoneyMarketDataService = class {
10443
10443
  }
10444
10444
  /**
10445
10445
  * Get the user reserves data
10446
- * @param spokeProvider - The spoke provider
10446
+ * @param spokeChainId - The spoke chain ID
10447
+ * @param userAddress - The user's wallet address on the spoke chain
10447
10448
  * @returns {Promise<readonly [readonly UserReserveData[], number]>} - The user reserves data
10448
10449
  */
10449
- async getUserReservesData(spokeProvider) {
10450
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
10451
- const spokeChainId = spokeProvider.chainConfig.chain.id;
10452
- const hubWalletAddress = await HubService.getUserHubWalletAddress(walletAddress, spokeChainId, this.hubProvider);
10450
+ async getUserReservesData(spokeChainId, userAddress) {
10451
+ const hubWalletAddress = await HubService.getUserHubWalletAddress(userAddress, spokeChainId, this.hubProvider);
10453
10452
  return this.uiPoolDataProviderService.getUserReservesData(hubWalletAddress);
10454
10453
  }
10455
10454
  /**
@@ -10475,13 +10474,12 @@ var MoneyMarketDataService = class {
10475
10474
  }
10476
10475
  /**
10477
10476
  * Get the user reserves humanized
10478
- * @param spokeProvider - The spoke provider
10477
+ * @param spokeChainId - The spoke chain ID
10478
+ * @param userAddress - The user's wallet address on the spoke chain
10479
10479
  * @returns {Promise<{userReserves: UserReserveDataHumanized[], userEmodeCategoryId: number}>} - The user reserves humanized
10480
10480
  */
10481
- async getUserReservesHumanized(spokeProvider) {
10482
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
10483
- const spokeChainId = spokeProvider.chainConfig.chain.id;
10484
- const hubWalletAddress = await HubService.getUserHubWalletAddress(walletAddress, spokeChainId, this.hubProvider);
10481
+ async getUserReservesHumanized(spokeChainId, userAddress) {
10482
+ const hubWalletAddress = await HubService.getUserHubWalletAddress(userAddress, spokeChainId, this.hubProvider);
10485
10483
  return this.uiPoolDataProviderService.getUserReservesHumanized(hubWalletAddress);
10486
10484
  }
10487
10485
  /**
@@ -15521,6 +15519,11 @@ var PartnerFeeClaimService = class {
15521
15519
  invariant6__default.default(isSonicSpokeProviderType(spokeProvider), "PartnerFeeClaimService only supports Sonic spoke provider");
15522
15520
  invariant6__default.default(this.config.protocolIntentsContract, "protocolIntentsContract is not configured in solver config");
15523
15521
  const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
15522
+ const outputToken = params.dstChain !== this.hubProvider.chainConfig.chain.id ? this.hubProvider.configService.getHubAssetInfo(params.dstChain, params.outputToken)?.asset : params.outputToken;
15523
+ invariant6__default.default(
15524
+ outputToken,
15525
+ `hub asset not found for spoke chain token (params.outputToken): ${params.outputToken} with chain id: ${params.dstChain}`
15526
+ );
15524
15527
  const rawTx = {
15525
15528
  from: walletAddress,
15526
15529
  to: this.config.protocolIntentsContract,
@@ -15529,7 +15532,7 @@ var PartnerFeeClaimService = class {
15529
15532
  abi: ProtocolIntentsAbi,
15530
15533
  functionName: "setAutoSwapPreferences",
15531
15534
  args: [
15532
- params.outputToken,
15535
+ outputToken,
15533
15536
  BigInt(types.getIntentRelayChainId(params.dstChain)),
15534
15537
  encodeAddress(params.dstChain, params.dstAddress)
15535
15538
  ]
@@ -16465,6 +16468,18 @@ function isSonicRawSpokeProvider(value) {
16465
16468
  function isAddressString(value) {
16466
16469
  return typeof value === "string";
16467
16470
  }
16471
+ function isEvmRawSpokeProviderConfig(value) {
16472
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "EVM";
16473
+ }
16474
+ function isSonicRawSpokeProviderConfig(value) {
16475
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "EVM" && value.chainConfig.chain.id === types.SONIC_MAINNET_CHAIN_ID;
16476
+ }
16477
+ function isStellarRawSpokeProviderConfig(value) {
16478
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "STELLAR";
16479
+ }
16480
+ function isSolanaRawSpokeProviderConfig(value) {
16481
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && "connection" in value && value.chainConfig.chain.type === "SOLANA";
16482
+ }
16468
16483
  async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
16469
16484
  do {
16470
16485
  try {
@@ -16576,6 +16591,51 @@ function sleep(ms) {
16576
16591
  function isHubSpokeProvider(spokeProvider, hubProvider) {
16577
16592
  return spokeProvider.chainConfig.chain.id === hubProvider.chainConfig.chain.id;
16578
16593
  }
16594
+ function constructRawSpokeProvider(config) {
16595
+ const chainType = config.chainConfig?.chain?.type;
16596
+ switch (chainType) {
16597
+ case "EVM": {
16598
+ if (config.chainConfig.chain.id === types.SONIC_MAINNET_CHAIN_ID) {
16599
+ invariant6__default.default(isSonicRawSpokeProviderConfig(config), "Invalid Sonic raw spoke provider config");
16600
+ return new SonicRawSpokeProvider(config.walletAddress, config.chainConfig, config.rpcUrl);
16601
+ }
16602
+ invariant6__default.default(isEvmRawSpokeProviderConfig(config), "Invalid Evm raw spoke provider config");
16603
+ return new EvmRawSpokeProvider(config.walletAddress, config.chainConfig, config.rpcUrl);
16604
+ }
16605
+ case "STELLAR":
16606
+ invariant6__default.default(isStellarRawSpokeProviderConfig(config), "Invalid Stellar raw spoke provider config");
16607
+ return new StellarRawSpokeProvider(config.walletAddress, config.chainConfig, config.rpcConfig);
16608
+ case "SOLANA": {
16609
+ invariant6__default.default(isSolanaRawSpokeProviderConfig(config), "Invalid Solana raw spoke provider config");
16610
+ return new SolanaRawSpokeProvider({
16611
+ connection: config.connection,
16612
+ walletAddress: config.walletAddress,
16613
+ chainConfig: config.chainConfig
16614
+ });
16615
+ }
16616
+ case "ICON": {
16617
+ return new IconRawSpokeProvider(
16618
+ config.chainConfig,
16619
+ config.walletAddress
16620
+ );
16621
+ }
16622
+ case "INJECTIVE": {
16623
+ return new InjectiveRawSpokeProvider(
16624
+ config.chainConfig,
16625
+ config.walletAddress
16626
+ );
16627
+ }
16628
+ case "SUI": {
16629
+ return new SuiRawSpokeProvider(
16630
+ config.chainConfig,
16631
+ config.walletAddress
16632
+ );
16633
+ }
16634
+ default: {
16635
+ throw new Error(`Unsupported chain type: ${chainType}`);
16636
+ }
16637
+ }
16638
+ }
16579
16639
 
16580
16640
  // src/shared/types.ts
16581
16641
  var SolverIntentStatusCode = /* @__PURE__ */ ((SolverIntentStatusCode2) => {
@@ -20822,6 +20882,7 @@ exports.calculateHealthFactorFromBalancesBigUnits = calculateHealthFactorFromBal
20822
20882
  exports.calculateLinearInterest = calculateLinearInterest;
20823
20883
  exports.calculatePercentageFeeAmount = calculatePercentageFeeAmount;
20824
20884
  exports.connectionAbi = connectionAbi;
20885
+ exports.constructRawSpokeProvider = constructRawSpokeProvider;
20825
20886
  exports.convertTransactionInstructionToRaw = convertTransactionInstructionToRaw;
20826
20887
  exports.deriveUserWalletAddress = deriveUserWalletAddress;
20827
20888
  exports.encodeAddress = encodeAddress;
@@ -20862,6 +20923,7 @@ exports.isCreateIntentAutoSwapError = isCreateIntentAutoSwapError;
20862
20923
  exports.isEvmHubChainConfig = isEvmHubChainConfig;
20863
20924
  exports.isEvmInitializedConfig = isEvmInitializedConfig;
20864
20925
  exports.isEvmRawSpokeProvider = isEvmRawSpokeProvider;
20926
+ exports.isEvmRawSpokeProviderConfig = isEvmRawSpokeProviderConfig;
20865
20927
  exports.isEvmSpokeChainConfig = isEvmSpokeChainConfig;
20866
20928
  exports.isEvmSpokeProvider = isEvmSpokeProvider;
20867
20929
  exports.isEvmSpokeProviderType = isEvmSpokeProviderType;
@@ -20906,13 +20968,16 @@ exports.isResponseSigningType = isResponseSigningType;
20906
20968
  exports.isSetSwapPreferenceError = isSetSwapPreferenceError;
20907
20969
  exports.isSolanaNativeToken = isSolanaNativeToken;
20908
20970
  exports.isSolanaRawSpokeProvider = isSolanaRawSpokeProvider;
20971
+ exports.isSolanaRawSpokeProviderConfig = isSolanaRawSpokeProviderConfig;
20909
20972
  exports.isSolanaSpokeProvider = isSolanaSpokeProvider;
20910
20973
  exports.isSolanaSpokeProviderType = isSolanaSpokeProviderType;
20911
20974
  exports.isSolverErrorResponse = isSolverErrorResponse;
20912
20975
  exports.isSonicRawSpokeProvider = isSonicRawSpokeProvider;
20976
+ exports.isSonicRawSpokeProviderConfig = isSonicRawSpokeProviderConfig;
20913
20977
  exports.isSonicSpokeProvider = isSonicSpokeProvider;
20914
20978
  exports.isSonicSpokeProviderType = isSonicSpokeProviderType;
20915
20979
  exports.isStellarRawSpokeProvider = isStellarRawSpokeProvider;
20980
+ exports.isStellarRawSpokeProviderConfig = isStellarRawSpokeProviderConfig;
20916
20981
  exports.isStellarSpokeProvider = isStellarSpokeProvider;
20917
20982
  exports.isStellarSpokeProviderType = isStellarSpokeProviderType;
20918
20983
  exports.isSuiRawSpokeProvider = isSuiRawSpokeProvider;