@sodax/sdk 0.0.1-rc.44 → 0.0.1-rc.45

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.d.cts CHANGED
@@ -6650,7 +6650,7 @@ declare class SonicSpokeService {
6650
6650
  */
6651
6651
  static isBorrowApproved(from: Address, borrowInfo: BorrowInfo, spokeProvider: SonicSpokeProvider, spender?: HubAddress): Promise<Result<boolean>>;
6652
6652
  static approveBorrow<R extends boolean = false>(from: Address, borrowInfo: BorrowInfo, spokeProvider: SonicSpokeProvider, raw?: R): PromiseEvmTxReturnType<R>;
6653
- static buildWithdrawData(from: Address, withdrawInfo: WithdrawInfo, amount: bigint, spokeProvider: SonicSpokeProvider, moneyMarketService: MoneyMarketService, userRouterAddress?: HubAddress): Promise<Hex$1>;
6653
+ static buildWithdrawData(from: Address, withdrawInfo: WithdrawInfo, amount: bigint, spokeProvider: SonicSpokeProvider, moneyMarketService: MoneyMarketService): Promise<Hex$1>;
6654
6654
  }
6655
6655
 
6656
6656
  declare class CustomSorobanServer extends SorobanRpc.Server {
package/dist/index.d.ts CHANGED
@@ -6650,7 +6650,7 @@ declare class SonicSpokeService {
6650
6650
  */
6651
6651
  static isBorrowApproved(from: Address, borrowInfo: BorrowInfo, spokeProvider: SonicSpokeProvider, spender?: HubAddress): Promise<Result<boolean>>;
6652
6652
  static approveBorrow<R extends boolean = false>(from: Address, borrowInfo: BorrowInfo, spokeProvider: SonicSpokeProvider, raw?: R): PromiseEvmTxReturnType<R>;
6653
- static buildWithdrawData(from: Address, withdrawInfo: WithdrawInfo, amount: bigint, spokeProvider: SonicSpokeProvider, moneyMarketService: MoneyMarketService, userRouterAddress?: HubAddress): Promise<Hex$1>;
6653
+ static buildWithdrawData(from: Address, withdrawInfo: WithdrawInfo, amount: bigint, spokeProvider: SonicSpokeProvider, moneyMarketService: MoneyMarketService): Promise<Hex$1>;
6654
6654
  }
6655
6655
 
6656
6656
  declare class CustomSorobanServer extends SorobanRpc.Server {
package/dist/index.mjs CHANGED
@@ -11809,15 +11809,10 @@ var SonicSpokeService = class _SonicSpokeService {
11809
11809
  throw new Error("[SonicSpokeService.getWithdrawInfo] Hub asset not found");
11810
11810
  }
11811
11811
  const vaultAddress = assetConfig.vault;
11812
- const [normalizedIncome, reserveData] = await Promise.all([
11813
- dataService.getReserveNormalizedIncome(vaultAddress),
11814
- dataService.getReserveData(vaultAddress)
11815
- ]);
11816
- const aTokenAddress = reserveData.aTokenAddress;
11817
- const aTokenAmount = MoneyMarketService.calculateATokenAmount(amount, normalizedIncome);
11812
+ const aTokenAddress = (await dataService.getReserveData(vaultAddress)).aTokenAddress;
11818
11813
  return {
11819
11814
  aTokenAddress,
11820
- aTokenAmount,
11815
+ aTokenAmount: amount,
11821
11816
  token
11822
11817
  };
11823
11818
  }
@@ -11855,7 +11850,7 @@ var SonicSpokeService = class _SonicSpokeService {
11855
11850
  try {
11856
11851
  const spenderAddress = spender ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
11857
11852
  return Erc20Service.isAllowanceValid(
11858
- withdrawInfo.token,
11853
+ withdrawInfo.aTokenAddress,
11859
11854
  withdrawInfo.aTokenAmount,
11860
11855
  from,
11861
11856
  spenderAddress,
@@ -11946,16 +11941,12 @@ var SonicSpokeService = class _SonicSpokeService {
11946
11941
  }
11947
11942
  return spokeProvider.walletProvider.sendTransaction(rawTx);
11948
11943
  }
11949
- static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService, userRouterAddress) {
11950
- const userRouter = userRouterAddress ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
11951
- let token = withdrawInfo.token;
11952
- if (withdrawInfo.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
11953
- token = spokeProvider.chainConfig.addresses.wrappedSonic;
11954
- }
11944
+ static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
11945
+ const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
11955
11946
  const withdrawCall = moneyMarketService.buildWithdrawData(
11956
11947
  userRouter,
11957
11948
  from,
11958
- token,
11949
+ withdrawInfo.token,
11959
11950
  amount,
11960
11951
  spokeProvider.chainConfig.chain.id
11961
11952
  );
@@ -11973,6 +11964,18 @@ var SonicSpokeService = class _SonicSpokeService {
11973
11964
  ],
11974
11965
  withdrawCall
11975
11966
  )[0];
11967
+ const transferFromCall = Erc20Service.encodeTransferFrom(
11968
+ withdrawInfo.aTokenAddress,
11969
+ from,
11970
+ userRouter,
11971
+ withdrawInfo.aTokenAmount
11972
+ );
11973
+ calls.unshift({
11974
+ address: transferFromCall.address,
11975
+ value: transferFromCall.value,
11976
+ data: transferFromCall.data
11977
+ });
11978
+ console.log("calls", calls);
11976
11979
  return encodeContractCalls(calls);
11977
11980
  }
11978
11981
  };
@@ -17802,7 +17805,7 @@ var Sodax = class {
17802
17805
  this.relayerApiEndpoint = config?.relayerApiEndpoint ?? DEFAULT_RELAYER_API_ENDPOINT;
17803
17806
  this.hubProvider = new EvmHubProvider(config?.hubProviderConfig);
17804
17807
  this.solver = config && config.solver ? new SolverService(config.solver, this.hubProvider, this.relayerApiEndpoint) : new SolverService(void 0, this.hubProvider, this.relayerApiEndpoint);
17805
- this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService(void 0, this.hubProvider, this.relayerApiEndpoint);
17808
+ this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService2(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService2(void 0, this.hubProvider, this.relayerApiEndpoint);
17806
17809
  this.migration = config && config.migration ? new MigrationService(this.hubProvider, config.migration) : new MigrationService(this.hubProvider);
17807
17810
  this.bridge = config && config.bridge ? new BridgeService(this.hubProvider, this.relayerApiEndpoint, config.bridge) : new BridgeService(this.hubProvider, this.relayerApiEndpoint);
17808
17811
  this.backendApiService = new BackendApiService(config?.backendApiConfig);
@@ -19412,7 +19415,7 @@ function formatBasisPoints(value) {
19412
19415
  }
19413
19416
 
19414
19417
  // src/moneyMarket/MoneyMarketService.ts
19415
- var MoneyMarketService = class _MoneyMarketService {
19418
+ var MoneyMarketService2 = class _MoneyMarketService {
19416
19419
  config;
19417
19420
  hubProvider;
19418
19421
  data;
@@ -20152,8 +20155,7 @@ var MoneyMarketService = class _MoneyMarketService {
20152
20155
  withdrawInfo,
20153
20156
  params.amount,
20154
20157
  spokeProvider,
20155
- this,
20156
- hubWallet
20158
+ this
20157
20159
  );
20158
20160
  } else {
20159
20161
  data = this.buildWithdrawData(
@@ -20695,6 +20697,6 @@ var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
20695
20697
  return SolverIntentErrorCode2;
20696
20698
  })(SolverIntentErrorCode || {});
20697
20699
 
20698
- export { BackendApiService, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BnUSDMigrationService, BridgeService, ChainIdToIntentRelayChainId, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HALF_RAY, HALF_WAD, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LTV_PRECISION, LendingPoolService, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketDataService, MoneyMarketService, RAY, RAY_DECIMALS, SECONDS_PER_YEAR, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, SodaTokens, SodaTokensAsHubAssets, SodaVaultTokensSet, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StakingLogic, StakingService, StellarSpokeProvider, StellarSpokeService, SuiSpokeProvider, SuiSpokeService, SupportedMigrationTokens, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, WalletAbstractionService, adjustAmountByFee, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, deriveUserWalletAddress, encodeAddress, encodeContractCalls, erc20Abi, findSupportedTokenBySymbol, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getCompoundedBalance, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getHubVaultTokenByAddress, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getMoneyMarketConfig, getOriginalAssetAddress, getOriginalAssetInfoFromVault, getOriginalTokenFromOriginalAssetAddress, getPacket, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaultTokensMap, hubVaults, hubVaultsAddressSet, hyper, 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, isSodaVaultToken, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isUnifiedBnUSDMigrateParams, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isValidVault, isWaitUntilIntentExecutedFailed, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, nativeToUSD, newbnUSDSpokeChainIds, normalize, normalizeBN, normalizedToUsd, originalAssetTohubAssetMap, parseToStroops, poolAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sleep, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, stakedSodaAbi, stakingRouterAbi, submitTransaction, supportedHubAssets, supportedHubChains, supportedSodaAssets, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, wadToRay, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
20700
+ export { BackendApiService, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BnUSDMigrationService, BridgeService, ChainIdToIntentRelayChainId, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HALF_RAY, HALF_WAD, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LTV_PRECISION, LendingPoolService, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketDataService, MoneyMarketService2 as MoneyMarketService, RAY, RAY_DECIMALS, SECONDS_PER_YEAR, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, SodaTokens, SodaTokensAsHubAssets, SodaVaultTokensSet, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StakingLogic, StakingService, StellarSpokeProvider, StellarSpokeService, SuiSpokeProvider, SuiSpokeService, SupportedMigrationTokens, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, WalletAbstractionService, adjustAmountByFee, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, deriveUserWalletAddress, encodeAddress, encodeContractCalls, erc20Abi, findSupportedTokenBySymbol, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getCompoundedBalance, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getHubVaultTokenByAddress, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getMoneyMarketConfig, getOriginalAssetAddress, getOriginalAssetInfoFromVault, getOriginalTokenFromOriginalAssetAddress, getPacket, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaultTokensMap, hubVaults, hubVaultsAddressSet, hyper, 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, isSodaVaultToken, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isUnifiedBnUSDMigrateParams, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isValidVault, isWaitUntilIntentExecutedFailed, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, nativeToUSD, newbnUSDSpokeChainIds, normalize, normalizeBN, normalizedToUsd, originalAssetTohubAssetMap, parseToStroops, poolAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sleep, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, stakedSodaAbi, stakingRouterAbi, submitTransaction, supportedHubAssets, supportedHubChains, supportedSodaAssets, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, wadToRay, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
20699
20701
  //# sourceMappingURL=index.mjs.map
20700
20702
  //# sourceMappingURL=index.mjs.map