@sodax/sdk 0.0.1-rc.43 → 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.cjs CHANGED
@@ -7530,6 +7530,13 @@ var spokeChainConfig = {
7530
7530
  decimals: 18,
7531
7531
  address: "0xA28C70F92a1B2513edCdDD29c2E5195a4B785aB2",
7532
7532
  xChainId: types.HYPEREVM_MAINNET_CHAIN_ID
7533
+ },
7534
+ USDC: {
7535
+ symbol: "USDC",
7536
+ name: "USD Coin",
7537
+ decimals: 6,
7538
+ address: "0xb88339CB7199b77E23DB6E890353E22632Ba630f",
7539
+ xChainId: types.HYPEREVM_MAINNET_CHAIN_ID
7533
7540
  }
7534
7541
  }
7535
7542
  },
@@ -8539,6 +8546,13 @@ var hubAssets = {
8539
8546
  symbol: "SODA",
8540
8547
  name: "SODAX",
8541
8548
  vault: hubVaults.sodaSODA.address
8549
+ },
8550
+ [spokeChainConfig[types.HYPEREVM_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
8551
+ asset: "0x0f78b995d113712deeb17d96638e9d7525d409c6",
8552
+ decimal: 6,
8553
+ symbol: "USDC",
8554
+ name: "USD Coin",
8555
+ vault: hubVaults.sodaUSDC.address
8542
8556
  }
8543
8557
  },
8544
8558
  [types.LIGHTLINK_MAINNET_CHAIN_ID]: {
@@ -8917,7 +8931,12 @@ var solverSupportedTokens = {
8917
8931
  spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
8918
8932
  spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.USDC
8919
8933
  ],
8920
- [types.HYPEREVM_MAINNET_CHAIN_ID]: [],
8934
+ [types.HYPEREVM_MAINNET_CHAIN_ID]: [
8935
+ spokeChainConfig[types.HYPEREVM_MAINNET_CHAIN_ID].supportedTokens.HYPE,
8936
+ spokeChainConfig[types.HYPEREVM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
8937
+ spokeChainConfig[types.HYPEREVM_MAINNET_CHAIN_ID].supportedTokens.SODA,
8938
+ spokeChainConfig[types.HYPEREVM_MAINNET_CHAIN_ID].supportedTokens.USDC
8939
+ ],
8921
8940
  [types.LIGHTLINK_MAINNET_CHAIN_ID]: [
8922
8941
  spokeChainConfig[types.LIGHTLINK_MAINNET_CHAIN_ID].supportedTokens.ETH,
8923
8942
  spokeChainConfig[types.LIGHTLINK_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
@@ -11818,15 +11837,10 @@ var SonicSpokeService = class _SonicSpokeService {
11818
11837
  throw new Error("[SonicSpokeService.getWithdrawInfo] Hub asset not found");
11819
11838
  }
11820
11839
  const vaultAddress = assetConfig.vault;
11821
- const [normalizedIncome, reserveData] = await Promise.all([
11822
- dataService.getReserveNormalizedIncome(vaultAddress),
11823
- dataService.getReserveData(vaultAddress)
11824
- ]);
11825
- const aTokenAddress = reserveData.aTokenAddress;
11826
- const aTokenAmount = MoneyMarketService.calculateATokenAmount(amount, normalizedIncome);
11840
+ const aTokenAddress = (await dataService.getReserveData(vaultAddress)).aTokenAddress;
11827
11841
  return {
11828
11842
  aTokenAddress,
11829
- aTokenAmount,
11843
+ aTokenAmount: amount,
11830
11844
  token
11831
11845
  };
11832
11846
  }
@@ -11864,7 +11878,7 @@ var SonicSpokeService = class _SonicSpokeService {
11864
11878
  try {
11865
11879
  const spenderAddress = spender ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
11866
11880
  return Erc20Service.isAllowanceValid(
11867
- withdrawInfo.token,
11881
+ withdrawInfo.aTokenAddress,
11868
11882
  withdrawInfo.aTokenAmount,
11869
11883
  from,
11870
11884
  spenderAddress,
@@ -11955,16 +11969,12 @@ var SonicSpokeService = class _SonicSpokeService {
11955
11969
  }
11956
11970
  return spokeProvider.walletProvider.sendTransaction(rawTx);
11957
11971
  }
11958
- static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService, userRouterAddress) {
11959
- const userRouter = userRouterAddress ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
11960
- let token = withdrawInfo.token;
11961
- if (withdrawInfo.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
11962
- token = spokeProvider.chainConfig.addresses.wrappedSonic;
11963
- }
11972
+ static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
11973
+ const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
11964
11974
  const withdrawCall = moneyMarketService.buildWithdrawData(
11965
11975
  userRouter,
11966
11976
  from,
11967
- token,
11977
+ withdrawInfo.token,
11968
11978
  amount,
11969
11979
  spokeProvider.chainConfig.chain.id
11970
11980
  );
@@ -11982,6 +11992,18 @@ var SonicSpokeService = class _SonicSpokeService {
11982
11992
  ],
11983
11993
  withdrawCall
11984
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);
11985
12007
  return encodeContractCalls(calls);
11986
12008
  }
11987
12009
  };
@@ -17811,7 +17833,7 @@ var Sodax = class {
17811
17833
  this.relayerApiEndpoint = config?.relayerApiEndpoint ?? DEFAULT_RELAYER_API_ENDPOINT;
17812
17834
  this.hubProvider = new EvmHubProvider(config?.hubProviderConfig);
17813
17835
  this.solver = config && config.solver ? new SolverService(config.solver, this.hubProvider, this.relayerApiEndpoint) : new SolverService(void 0, this.hubProvider, this.relayerApiEndpoint);
17814
- 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);
17815
17837
  this.migration = config && config.migration ? new MigrationService(this.hubProvider, config.migration) : new MigrationService(this.hubProvider);
17816
17838
  this.bridge = config && config.bridge ? new BridgeService(this.hubProvider, this.relayerApiEndpoint, config.bridge) : new BridgeService(this.hubProvider, this.relayerApiEndpoint);
17817
17839
  this.backendApiService = new BackendApiService(config?.backendApiConfig);
@@ -19421,7 +19443,7 @@ function formatBasisPoints(value) {
19421
19443
  }
19422
19444
 
19423
19445
  // src/moneyMarket/MoneyMarketService.ts
19424
- var MoneyMarketService = class _MoneyMarketService {
19446
+ var MoneyMarketService2 = class _MoneyMarketService {
19425
19447
  config;
19426
19448
  hubProvider;
19427
19449
  data;
@@ -20161,8 +20183,7 @@ var MoneyMarketService = class _MoneyMarketService {
20161
20183
  withdrawInfo,
20162
20184
  params.amount,
20163
20185
  spokeProvider,
20164
- this,
20165
- hubWallet
20186
+ this
20166
20187
  );
20167
20188
  } else {
20168
20189
  data = this.buildWithdrawData(
@@ -20747,7 +20768,7 @@ exports.LockupPeriod = LockupPeriod;
20747
20768
  exports.MAX_UINT256 = MAX_UINT256;
20748
20769
  exports.MigrationService = MigrationService;
20749
20770
  exports.MoneyMarketDataService = MoneyMarketDataService;
20750
- exports.MoneyMarketService = MoneyMarketService;
20771
+ exports.MoneyMarketService = MoneyMarketService2;
20751
20772
  exports.RAY = RAY;
20752
20773
  exports.RAY_DECIMALS = RAY_DECIMALS;
20753
20774
  exports.SECONDS_PER_YEAR = SECONDS_PER_YEAR;