@t2000/sdk 0.17.16 → 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.
@@ -352,6 +352,7 @@ interface AutoInvestRunResult {
352
352
  }
353
353
  interface PendingReward$1 {
354
354
  protocol: string;
355
+ asset: string;
355
356
  coinType: string;
356
357
  symbol: string;
357
358
  amount: number;
@@ -506,6 +507,7 @@ interface LendingAdapter {
506
507
  }
507
508
  interface PendingReward {
508
509
  protocol: string;
510
+ asset: string;
509
511
  coinType: string;
510
512
  symbol: string;
511
513
  amount: number;
@@ -352,6 +352,7 @@ interface AutoInvestRunResult {
352
352
  }
353
353
  interface PendingReward$1 {
354
354
  protocol: string;
355
+ asset: string;
355
356
  coinType: string;
356
357
  symbol: string;
357
358
  amount: number;
@@ -506,6 +507,7 @@ interface LendingAdapter {
506
507
  }
507
508
  interface PendingReward {
508
509
  protocol: string;
510
+ asset: string;
509
511
  coinType: string;
510
512
  symbol: string;
511
513
  amount: number;
package/dist/index.cjs CHANGED
@@ -1246,15 +1246,13 @@ function stripPrefix(coinType) {
1246
1246
  return coinType.replace(/^0x0*/, "");
1247
1247
  }
1248
1248
  async function getPendingRewards(client, address) {
1249
- const [pools, states, rules] = await Promise.all([
1249
+ const [pools, states] = await Promise.all([
1250
1250
  getPools(),
1251
- getUserState(client, address),
1252
- getIncentiveRules(client)
1251
+ getUserState(client, address)
1253
1252
  ]);
1254
1253
  const rewards = [];
1255
1254
  const deposited = states.filter((s) => s.supplyBalance > 0n);
1256
1255
  if (deposited.length === 0) return rewards;
1257
- const rewardTotals = /* @__PURE__ */ new Map();
1258
1256
  for (const state of deposited) {
1259
1257
  const pool = pools.find((p) => p.id === state.assetId);
1260
1258
  if (!pool) continue;
@@ -1263,20 +1261,14 @@ async function getPendingRewards(client, address) {
1263
1261
  const rewardCoins = pool.supplyIncentiveApyInfo?.rewardCoin;
1264
1262
  if (!Array.isArray(rewardCoins) || rewardCoins.length === 0) continue;
1265
1263
  const rewardType = rewardCoins[0];
1266
- const supplyBal = compoundBalance(state.supplyBalance, pool.currentSupplyIndex, pool);
1267
- const price = pool.token?.price ?? 0;
1268
- const depositUsd = supplyBal * price;
1269
- const annualRewardUsd = depositUsd * (boostedApr / 100);
1270
- const estimatedUsd = annualRewardUsd / 365;
1271
- rewardTotals.set(rewardType, (rewardTotals.get(rewardType) ?? 0) + estimatedUsd);
1272
- }
1273
- for (const [coinType, dailyUsd] of rewardTotals) {
1264
+ const assetSymbol = resolvePoolSymbol(pool);
1274
1265
  rewards.push({
1275
1266
  protocol: "navi",
1276
- coinType,
1277
- symbol: REWARD_SYMBOLS[coinType] ?? coinType.split("::").pop() ?? "UNKNOWN",
1267
+ asset: assetSymbol,
1268
+ coinType: rewardType,
1269
+ symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
1278
1270
  amount: 0,
1279
- estimatedValueUsd: dailyUsd
1271
+ estimatedValueUsd: 0
1280
1272
  });
1281
1273
  }
1282
1274
  return rewards;
@@ -1337,6 +1329,7 @@ async function addClaimRewardsToTx(tx, client, address) {
1337
1329
  tx.transferObjects([coin], address);
1338
1330
  claimed.push({
1339
1331
  protocol: "navi",
1332
+ asset: assets.join(", "),
1340
1333
  coinType: rewardType,
1341
1334
  symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
1342
1335
  amount: 0,
@@ -2697,45 +2690,24 @@ var SuilendAdapter = class {
2697
2690
  this.fetchObligation(caps[0].obligationId)
2698
2691
  ]);
2699
2692
  const rewards = [];
2700
- const rewardEstimates = /* @__PURE__ */ new Map();
2701
2693
  for (const dep of obligation.deposits) {
2702
2694
  const reserve = reserves[dep.reserveIdx];
2703
2695
  if (!reserve) continue;
2704
- const ratio = cTokenRatio(reserve);
2705
- const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
2706
- const price = reserve.price;
2707
- const depositUsd = amount * price;
2708
2696
  for (const rw of reserve.depositPoolRewards) {
2709
2697
  if (!this.isClaimableReward(rw.coinType)) continue;
2710
- const rewardReserve = reserves.find((r) => {
2711
- try {
2712
- return utils.normalizeStructTag(r.coinType) === utils.normalizeStructTag(rw.coinType);
2713
- } catch {
2714
- return false;
2715
- }
2716
- });
2717
- const rewardPrice = rewardReserve?.price ?? 0;
2718
- const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
2719
2698
  const durationMs = rw.endTimeMs - rw.startTimeMs;
2720
2699
  if (durationMs <= 0) continue;
2721
- const annualTokens = rw.totalRewards / 10 ** rewardDecimals * (MS_PER_YEAR / durationMs);
2722
- const totalDepositValue = reserve.depositTotalShares / 10 ** reserve.mintDecimals * price;
2723
- if (totalDepositValue <= 0) continue;
2724
- const userShare = depositUsd / totalDepositValue;
2725
- const dailyRewardUsd = annualTokens * rewardPrice / 365 * userShare;
2726
- rewardEstimates.set(rw.coinType, (rewardEstimates.get(rw.coinType) ?? 0) + dailyRewardUsd);
2700
+ const assetSymbol = this.resolveSymbol(reserve.coinType);
2701
+ rewards.push({
2702
+ protocol: "suilend",
2703
+ asset: assetSymbol,
2704
+ coinType: rw.coinType,
2705
+ symbol: rw.coinType.includes("spring_sui") ? "sSUI" : rw.coinType.includes("deep::") ? "DEEP" : rw.coinType.split("::").pop() ?? "UNKNOWN",
2706
+ amount: 0,
2707
+ estimatedValueUsd: 0
2708
+ });
2727
2709
  }
2728
2710
  }
2729
- for (const [coinType, dailyUsd] of rewardEstimates) {
2730
- const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
2731
- rewards.push({
2732
- protocol: "suilend",
2733
- coinType,
2734
- symbol,
2735
- amount: 0,
2736
- estimatedValueUsd: dailyUsd
2737
- });
2738
- }
2739
2711
  return rewards;
2740
2712
  }
2741
2713
  async addClaimRewardsToTx(tx, address) {
@@ -2778,6 +2750,7 @@ var SuilendAdapter = class {
2778
2750
  const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
2779
2751
  claimed.push({
2780
2752
  protocol: "suilend",
2753
+ asset: "",
2781
2754
  coinType,
2782
2755
  symbol,
2783
2756
  amount: 0,