@t2000/sdk 0.17.15 → 0.17.17

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.
@@ -934,15 +934,13 @@ function stripPrefix(coinType) {
934
934
  return coinType.replace(/^0x0*/, "");
935
935
  }
936
936
  async function getPendingRewards(client, address) {
937
- const [pools, states, rules] = await Promise.all([
937
+ const [pools, states] = await Promise.all([
938
938
  getPools(),
939
- getUserState(client, address),
940
- getIncentiveRules(client)
939
+ getUserState(client, address)
941
940
  ]);
942
941
  const rewards = [];
943
942
  const deposited = states.filter((s) => s.supplyBalance > 0n);
944
943
  if (deposited.length === 0) return rewards;
945
- const rewardTotals = /* @__PURE__ */ new Map();
946
944
  for (const state of deposited) {
947
945
  const pool = pools.find((p) => p.id === state.assetId);
948
946
  if (!pool) continue;
@@ -951,21 +949,14 @@ async function getPendingRewards(client, address) {
951
949
  const rewardCoins = pool.supplyIncentiveApyInfo?.rewardCoin;
952
950
  if (!Array.isArray(rewardCoins) || rewardCoins.length === 0) continue;
953
951
  const rewardType = rewardCoins[0];
954
- const supplyBal = compoundBalance(state.supplyBalance, pool.currentSupplyIndex, pool);
955
- const price = pool.token?.price ?? 0;
956
- const depositUsd = supplyBal * price;
957
- const annualRewardUsd = depositUsd * (boostedApr / 100);
958
- const estimatedUsd = annualRewardUsd / 365;
959
- rewardTotals.set(rewardType, (rewardTotals.get(rewardType) ?? 0) + estimatedUsd);
960
- }
961
- for (const [coinType, dailyUsd] of rewardTotals) {
962
- if (dailyUsd < 1e-3) continue;
952
+ const assetSymbol = resolvePoolSymbol(pool);
963
953
  rewards.push({
964
954
  protocol: "navi",
965
- coinType,
966
- symbol: REWARD_SYMBOLS[coinType] ?? coinType.split("::").pop() ?? "UNKNOWN",
955
+ asset: assetSymbol,
956
+ coinType: rewardType,
957
+ symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
967
958
  amount: 0,
968
- estimatedValueUsd: dailyUsd
959
+ estimatedValueUsd: 0
969
960
  });
970
961
  }
971
962
  return rewards;
@@ -1026,6 +1017,7 @@ async function addClaimRewardsToTx(tx, client, address) {
1026
1017
  tx.transferObjects([coin], address);
1027
1018
  claimed.push({
1028
1019
  protocol: "navi",
1020
+ asset: assets.join(", "),
1029
1021
  coinType: rewardType,
1030
1022
  symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
1031
1023
  amount: 0,
@@ -2025,46 +2017,24 @@ var SuilendAdapter = class {
2025
2017
  this.fetchObligation(caps[0].obligationId)
2026
2018
  ]);
2027
2019
  const rewards = [];
2028
- const rewardEstimates = /* @__PURE__ */ new Map();
2029
2020
  for (const dep of obligation.deposits) {
2030
2021
  const reserve = reserves[dep.reserveIdx];
2031
2022
  if (!reserve) continue;
2032
- const ratio = cTokenRatio(reserve);
2033
- const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
2034
- const price = reserve.price;
2035
- const depositUsd = amount * price;
2036
2023
  for (const rw of reserve.depositPoolRewards) {
2037
2024
  if (!this.isClaimableReward(rw.coinType)) continue;
2038
- const rewardReserve = reserves.find((r) => {
2039
- try {
2040
- return utils.normalizeStructTag(r.coinType) === utils.normalizeStructTag(rw.coinType);
2041
- } catch {
2042
- return false;
2043
- }
2044
- });
2045
- const rewardPrice = rewardReserve?.price ?? 0;
2046
- const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
2047
2025
  const durationMs = rw.endTimeMs - rw.startTimeMs;
2048
2026
  if (durationMs <= 0) continue;
2049
- const annualTokens = rw.totalRewards / 10 ** rewardDecimals * (MS_PER_YEAR / durationMs);
2050
- const totalDepositValue = reserve.depositTotalShares / 10 ** reserve.mintDecimals * price;
2051
- if (totalDepositValue <= 0) continue;
2052
- const userShare = depositUsd / totalDepositValue;
2053
- const dailyRewardUsd = annualTokens * rewardPrice / 365 * userShare;
2054
- rewardEstimates.set(rw.coinType, (rewardEstimates.get(rw.coinType) ?? 0) + dailyRewardUsd);
2027
+ const assetSymbol = this.resolveSymbol(reserve.coinType);
2028
+ rewards.push({
2029
+ protocol: "suilend",
2030
+ asset: assetSymbol,
2031
+ coinType: rw.coinType,
2032
+ symbol: rw.coinType.includes("spring_sui") ? "sSUI" : rw.coinType.includes("deep::") ? "DEEP" : rw.coinType.split("::").pop() ?? "UNKNOWN",
2033
+ amount: 0,
2034
+ estimatedValueUsd: 0
2035
+ });
2055
2036
  }
2056
2037
  }
2057
- for (const [coinType, dailyUsd] of rewardEstimates) {
2058
- if (dailyUsd < 1e-3) continue;
2059
- const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
2060
- rewards.push({
2061
- protocol: "suilend",
2062
- coinType,
2063
- symbol,
2064
- amount: 0,
2065
- estimatedValueUsd: dailyUsd
2066
- });
2067
- }
2068
2038
  return rewards;
2069
2039
  }
2070
2040
  async addClaimRewardsToTx(tx, address) {
@@ -2107,6 +2077,7 @@ var SuilendAdapter = class {
2107
2077
  const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
2108
2078
  claimed.push({
2109
2079
  protocol: "suilend",
2080
+ asset: "",
2110
2081
  coinType,
2111
2082
  symbol,
2112
2083
  amount: 0,