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