@t2000/sdk 0.46.8 → 0.46.9

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.js CHANGED
@@ -5480,22 +5480,39 @@ async function addClaimRewardsToTx(tx, client, address) {
5480
5480
  (r) => Number(r.userClaimableReward) > 0
5481
5481
  );
5482
5482
  if (claimable.length === 0) return [];
5483
- const claimed = await Ct(tx, claimable, {
5483
+ await Ct(tx, claimable, {
5484
5484
  env: "prod",
5485
5485
  customCoinReceive: { type: "transfer", transfer: address }
5486
5486
  });
5487
- return claimed.map((c) => ({
5488
- protocol: "navi",
5489
- asset: "",
5490
- coinType: "",
5491
- symbol: "REWARD",
5492
- amount: 0,
5493
- estimatedValueUsd: 0
5494
- }));
5487
+ return aggregateClaimableRewards(claimable);
5495
5488
  } catch {
5496
5489
  return [];
5497
5490
  }
5498
5491
  }
5492
+ function aggregateClaimableRewards(claimable) {
5493
+ const aggregated = /* @__PURE__ */ new Map();
5494
+ for (const c of claimable) {
5495
+ const coinType = c.rewardCoinType;
5496
+ if (!coinType) continue;
5497
+ const symbol = coinType.split("::").pop() ?? "REWARD";
5498
+ const amount = Number(c.userClaimableReward);
5499
+ if (!Number.isFinite(amount) || amount <= 0) continue;
5500
+ const existing = aggregated.get(coinType);
5501
+ if (existing) {
5502
+ existing.amount += amount;
5503
+ } else {
5504
+ aggregated.set(coinType, {
5505
+ protocol: "navi",
5506
+ asset: String(c.assetId ?? ""),
5507
+ coinType,
5508
+ symbol,
5509
+ amount,
5510
+ estimatedValueUsd: 0
5511
+ });
5512
+ }
5513
+ }
5514
+ return Array.from(aggregated.values());
5515
+ }
5499
5516
 
5500
5517
  // src/protocols/yieldTracker.ts
5501
5518
  async function getEarnings(client, address) {