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

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
@@ -11837,15 +11837,10 @@ var SonicSpokeService = class _SonicSpokeService {
11837
11837
  throw new Error("[SonicSpokeService.getWithdrawInfo] Hub asset not found");
11838
11838
  }
11839
11839
  const vaultAddress = assetConfig.vault;
11840
- const [normalizedIncome, reserveData] = await Promise.all([
11841
- dataService.getReserveNormalizedIncome(vaultAddress),
11842
- dataService.getReserveData(vaultAddress)
11843
- ]);
11844
- const aTokenAddress = reserveData.aTokenAddress;
11845
- const aTokenAmount = MoneyMarketService.calculateATokenAmount(amount, normalizedIncome);
11840
+ const aTokenAddress = (await dataService.getReserveData(vaultAddress)).aTokenAddress;
11846
11841
  return {
11847
11842
  aTokenAddress,
11848
- aTokenAmount,
11843
+ aTokenAmount: amount,
11849
11844
  token
11850
11845
  };
11851
11846
  }
@@ -11883,7 +11878,7 @@ var SonicSpokeService = class _SonicSpokeService {
11883
11878
  try {
11884
11879
  const spenderAddress = spender ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
11885
11880
  return Erc20Service.isAllowanceValid(
11886
- withdrawInfo.token,
11881
+ withdrawInfo.aTokenAddress,
11887
11882
  withdrawInfo.aTokenAmount,
11888
11883
  from,
11889
11884
  spenderAddress,
@@ -11974,16 +11969,12 @@ var SonicSpokeService = class _SonicSpokeService {
11974
11969
  }
11975
11970
  return spokeProvider.walletProvider.sendTransaction(rawTx);
11976
11971
  }
11977
- static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService, userRouterAddress) {
11978
- const userRouter = userRouterAddress ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
11979
- let token = withdrawInfo.token;
11980
- if (withdrawInfo.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
11981
- token = spokeProvider.chainConfig.addresses.wrappedSonic;
11982
- }
11972
+ static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
11973
+ const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
11983
11974
  const withdrawCall = moneyMarketService.buildWithdrawData(
11984
11975
  userRouter,
11985
11976
  from,
11986
- token,
11977
+ withdrawInfo.token,
11987
11978
  amount,
11988
11979
  spokeProvider.chainConfig.chain.id
11989
11980
  );
@@ -12001,6 +11992,18 @@ var SonicSpokeService = class _SonicSpokeService {
12001
11992
  ],
12002
11993
  withdrawCall
12003
11994
  )[0];
11995
+ const transferFromCall = Erc20Service.encodeTransferFrom(
11996
+ withdrawInfo.aTokenAddress,
11997
+ from,
11998
+ userRouter,
11999
+ withdrawInfo.aTokenAmount
12000
+ );
12001
+ calls.unshift({
12002
+ address: transferFromCall.address,
12003
+ value: transferFromCall.value,
12004
+ data: transferFromCall.data
12005
+ });
12006
+ console.log("calls", calls);
12004
12007
  return encodeContractCalls(calls);
12005
12008
  }
12006
12009
  };
@@ -17830,7 +17833,7 @@ var Sodax = class {
17830
17833
  this.relayerApiEndpoint = config?.relayerApiEndpoint ?? DEFAULT_RELAYER_API_ENDPOINT;
17831
17834
  this.hubProvider = new EvmHubProvider(config?.hubProviderConfig);
17832
17835
  this.solver = config && config.solver ? new SolverService(config.solver, this.hubProvider, this.relayerApiEndpoint) : new SolverService(void 0, this.hubProvider, this.relayerApiEndpoint);
17833
- this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService(void 0, this.hubProvider, this.relayerApiEndpoint);
17836
+ this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService2(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService2(void 0, this.hubProvider, this.relayerApiEndpoint);
17834
17837
  this.migration = config && config.migration ? new MigrationService(this.hubProvider, config.migration) : new MigrationService(this.hubProvider);
17835
17838
  this.bridge = config && config.bridge ? new BridgeService(this.hubProvider, this.relayerApiEndpoint, config.bridge) : new BridgeService(this.hubProvider, this.relayerApiEndpoint);
17836
17839
  this.backendApiService = new BackendApiService(config?.backendApiConfig);
@@ -19440,7 +19443,7 @@ function formatBasisPoints(value) {
19440
19443
  }
19441
19444
 
19442
19445
  // src/moneyMarket/MoneyMarketService.ts
19443
- var MoneyMarketService = class _MoneyMarketService {
19446
+ var MoneyMarketService2 = class _MoneyMarketService {
19444
19447
  config;
19445
19448
  hubProvider;
19446
19449
  data;
@@ -20180,8 +20183,7 @@ var MoneyMarketService = class _MoneyMarketService {
20180
20183
  withdrawInfo,
20181
20184
  params.amount,
20182
20185
  spokeProvider,
20183
- this,
20184
- hubWallet
20186
+ this
20185
20187
  );
20186
20188
  } else {
20187
20189
  data = this.buildWithdrawData(
@@ -20766,7 +20768,7 @@ exports.LockupPeriod = LockupPeriod;
20766
20768
  exports.MAX_UINT256 = MAX_UINT256;
20767
20769
  exports.MigrationService = MigrationService;
20768
20770
  exports.MoneyMarketDataService = MoneyMarketDataService;
20769
- exports.MoneyMarketService = MoneyMarketService;
20771
+ exports.MoneyMarketService = MoneyMarketService2;
20770
20772
  exports.RAY = RAY;
20771
20773
  exports.RAY_DECIMALS = RAY_DECIMALS;
20772
20774
  exports.SECONDS_PER_YEAR = SECONDS_PER_YEAR;