@scallop-io/sui-scallop-sdk 2.0.4 → 2.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -852,7 +852,7 @@ export const getUserPortfolio = async (
852
852
  walletAddress: string,
853
853
  indexer: boolean = false
854
854
  ) => {
855
- const coinPrices = await query.utils.getCoinPrices();
855
+ const coinPrices = await query.getAllCoinPrices({ indexer });
856
856
  const market = await query.getMarketPools(undefined, { indexer, coinPrices });
857
857
 
858
858
  const [lendings, obligationAccounts, borrowIncentivePools, veScas] =
@@ -953,19 +953,22 @@ export const getUserPortfolio = async (
953
953
  };
954
954
  });
955
955
 
956
+ const LENDING_SPOOL_REWARD_COIN_NAME = 'sui' as const;
957
+ const LENDING_SPOOL_REWARD_COIN_SYMBOL = 'SUI' as const;
956
958
  const pendingLendingRewards = Object.values(lendings).reduce(
957
959
  (acc, reward) => {
958
960
  if (reward) {
959
961
  if (reward.availableClaimCoin === 0) return acc;
960
- if (!acc[reward.symbol]) {
961
- acc[reward.symbol] = {
962
- symbol: reward.symbol,
962
+ if (!acc[LENDING_SPOOL_REWARD_COIN_NAME]) {
963
+ acc[LENDING_SPOOL_REWARD_COIN_NAME] = {
964
+ symbol: LENDING_SPOOL_REWARD_COIN_SYMBOL,
963
965
  coinType: normalizeStructTag(SUI_TYPE_ARG), // @TODO: for now lending reward is all in SUI
964
- coinPrice: reward.coinPrice,
966
+ coinPrice: coinPrices[LENDING_SPOOL_REWARD_COIN_NAME] ?? 0,
965
967
  pendingRewardInCoin: reward.availableClaimCoin,
966
968
  };
967
969
  } else {
968
- acc[reward.symbol].pendingRewardInCoin += reward.availableClaimCoin;
970
+ acc[LENDING_SPOOL_REWARD_COIN_NAME].pendingRewardInCoin +=
971
+ reward.availableClaimCoin;
969
972
  }
970
973
  }
971
974
  return acc;
@@ -1054,10 +1057,10 @@ export const getUserPortfolio = async (
1054
1057
  borrowings: parsedObligationAccounts,
1055
1058
  pendingRewards: {
1056
1059
  lendings: Object.entries(pendingLendingRewards).reduce(
1057
- (acc, [key, value]) => {
1060
+ (acc, [_, value]) => {
1058
1061
  acc.push({
1059
1062
  ...value,
1060
- coinName: key,
1063
+ coinName: 'sui',
1061
1064
  pendingRewardInUsd: value.coinPrice * value.pendingRewardInCoin,
1062
1065
  });
1063
1066
  return acc;