@t2000/sdk 1.23.0 → 1.23.1

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.cjs CHANGED
@@ -5101,35 +5101,6 @@ async function vt(e, n) {
5101
5101
  );
5102
5102
  return await De(e, t, n);
5103
5103
  }
5104
- function wt(e) {
5105
- const n = /* @__PURE__ */ new Map();
5106
- e.forEach((r) => {
5107
- const t = r.assetId, a = r.option, s = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
5108
- n.has(s) ? n.get(s).total += r.userClaimableReward : n.set(s, {
5109
- assetId: t,
5110
- rewardType: a,
5111
- coinType: r.rewardCoinType,
5112
- total: Number(r.userClaimableReward),
5113
- market: r.market
5114
- });
5115
- });
5116
- const o = /* @__PURE__ */ new Map();
5117
- for (const { assetId: r, rewardType: t, coinType: a, total: s, market: i } of n.values()) {
5118
- const c = `${r}-${t}-${i}`;
5119
- o.has(c) || o.set(c, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
5120
- const u = o.get(c);
5121
- u.rewards.set(a, (u.rewards.get(a) || 0) + s);
5122
- }
5123
- return Array.from(o.values()).map((r) => ({
5124
- assetId: r.assetId,
5125
- rewardType: r.rewardType,
5126
- market: r.market,
5127
- rewards: Array.from(r.rewards.entries()).map(([t, a]) => ({
5128
- coinType: t,
5129
- available: a.toFixed(6)
5130
- }))
5131
- }));
5132
- }
5133
5104
  async function Ct(e, n, o) {
5134
5105
  const r = await R({
5135
5106
  ...o,
@@ -5307,6 +5278,7 @@ async function Ct(e, n, o) {
5307
5278
 
5308
5279
  // src/protocols/navi.ts
5309
5280
  init_errors();
5281
+ init_token_registry();
5310
5282
  var MIN_HEALTH_FACTOR = 1.5;
5311
5283
  function sdkOptions(client) {
5312
5284
  return { env: "prod", client, cacheTime: 0, disableCache: true };
@@ -5681,24 +5653,8 @@ async function getPendingRewards(client, address) {
5681
5653
  );
5682
5654
  }
5683
5655
  if (!rewards || rewards.length === 0) return [];
5684
- const summary = wt(rewards);
5685
- const result = [];
5686
- for (const s of summary) {
5687
- for (const rw of s.rewards) {
5688
- const available = Number(rw.available);
5689
- if (available <= 0) continue;
5690
- const symbol = rw.coinType.split("::").pop() ?? "UNKNOWN";
5691
- result.push({
5692
- protocol: "navi",
5693
- asset: String(s.assetId),
5694
- coinType: rw.coinType,
5695
- symbol,
5696
- amount: available,
5697
- estimatedValueUsd: 0
5698
- });
5699
- }
5700
- }
5701
- return result;
5656
+ const claimable = rewards.filter((r) => Number(r.userClaimableReward) > 0);
5657
+ return aggregateClaimableRewards(claimable);
5702
5658
  }
5703
5659
  async function addClaimRewardsToTx(tx, client, address) {
5704
5660
  let rewards;
@@ -5748,7 +5704,8 @@ function aggregateClaimableRewards(claimable) {
5748
5704
  for (const c of claimable) {
5749
5705
  const coinType = c.rewardCoinType;
5750
5706
  if (!coinType) continue;
5751
- const symbol = coinType.split("::").pop() ?? "REWARD";
5707
+ const meta = getCoinMeta(coinType);
5708
+ const symbol = meta?.symbol ?? coinType.split("::").pop() ?? "REWARD";
5752
5709
  const amount = Number(c.userClaimableReward);
5753
5710
  if (!Number.isFinite(amount) || amount <= 0) continue;
5754
5711
  const existing = aggregated.get(coinType);
@@ -8133,11 +8090,13 @@ exports.T2000_OVERLAY_FEE_WALLET = T2000_OVERLAY_FEE_WALLET;
8133
8090
  exports.USDC_DECIMALS = USDC_DECIMALS;
8134
8091
  exports.WRITE_APPENDER_REGISTRY = WRITE_APPENDER_REGISTRY;
8135
8092
  exports.ZkLoginSigner = ZkLoginSigner;
8093
+ exports.addClaimRewardsToTx = addClaimRewardsToTx;
8136
8094
  exports.addFeeTransfer = addFeeTransfer;
8137
8095
  exports.addSendToTx = addSendToTx;
8138
8096
  exports.addStakeVSuiToTx = addStakeVSuiToTx;
8139
8097
  exports.addSwapToTx = addSwapToTx;
8140
8098
  exports.addUnstakeVSuiToTx = addUnstakeVSuiToTx;
8099
+ exports.aggregateClaimableRewards = aggregateClaimableRewards;
8141
8100
  exports.allDescriptors = allDescriptors;
8142
8101
  exports.assertAllowedAsset = assertAllowedAsset;
8143
8102
  exports.buildAddLeafTx = buildAddLeafTx;