@t2000/cli 1.22.1 → 1.23.0

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.
@@ -136645,53 +136645,77 @@ async function maxBorrowAmount(client, address2) {
136645
136645
  return { maxAmount, healthFactorAfter: MIN_HEALTH_FACTOR, currentHF: hf.healthFactor };
136646
136646
  }
136647
136647
  async function getPendingRewards2(client, address2) {
136648
+ let rewards;
136648
136649
  try {
136649
- const rewards = await vt(address2, {
136650
+ rewards = await vt(address2, {
136650
136651
  ...sdkOptions(client),
136651
136652
  markets: ["main"]
136652
136653
  });
136653
- if (!rewards || rewards.length === 0) return [];
136654
- const summary = wt(rewards);
136655
- const result = [];
136656
- for (const s of summary) {
136657
- for (const rw of s.rewards) {
136658
- const available = Number(rw.available);
136659
- if (available <= 0) continue;
136660
- const symbol2 = rw.coinType.split("::").pop() ?? "UNKNOWN";
136661
- result.push({
136662
- protocol: "navi",
136663
- asset: String(s.assetId),
136664
- coinType: rw.coinType,
136665
- symbol: symbol2,
136666
- amount: available,
136667
- estimatedValueUsd: 0
136668
- });
136669
- }
136654
+ } catch (err) {
136655
+ const msg = err instanceof Error ? err.message : String(err);
136656
+ throw new T2000Error(
136657
+ "PROTOCOL_UNAVAILABLE",
136658
+ `NAVI rewards lookup failed: ${msg}`,
136659
+ { source: "navi-rewards-read" },
136660
+ true
136661
+ );
136662
+ }
136663
+ if (!rewards || rewards.length === 0) return [];
136664
+ const summary = wt(rewards);
136665
+ const result = [];
136666
+ for (const s of summary) {
136667
+ for (const rw of s.rewards) {
136668
+ const available = Number(rw.available);
136669
+ if (available <= 0) continue;
136670
+ const symbol2 = rw.coinType.split("::").pop() ?? "UNKNOWN";
136671
+ result.push({
136672
+ protocol: "navi",
136673
+ asset: String(s.assetId),
136674
+ coinType: rw.coinType,
136675
+ symbol: symbol2,
136676
+ amount: available,
136677
+ estimatedValueUsd: 0
136678
+ });
136670
136679
  }
136671
- return result;
136672
- } catch {
136673
- return [];
136674
136680
  }
136681
+ return result;
136675
136682
  }
136676
136683
  async function addClaimRewardsToTx(tx, client, address2) {
136684
+ let rewards;
136677
136685
  try {
136678
- const rewards = await vt(address2, {
136686
+ rewards = await vt(address2, {
136679
136687
  ...sdkOptions(client),
136680
136688
  markets: ["main"]
136681
136689
  });
136682
- if (!rewards || rewards.length === 0) return [];
136683
- const claimable = rewards.filter(
136684
- (r) => Number(r.userClaimableReward) > 0
136690
+ } catch (err) {
136691
+ const msg = err instanceof Error ? err.message : String(err);
136692
+ throw new T2000Error(
136693
+ "PROTOCOL_UNAVAILABLE",
136694
+ `NAVI rewards lookup failed: ${msg}`,
136695
+ { source: "navi-rewards-claim-prelude" },
136696
+ true
136685
136697
  );
136686
- if (claimable.length === 0) return [];
136698
+ }
136699
+ if (!rewards || rewards.length === 0) return [];
136700
+ const claimable = rewards.filter(
136701
+ (r) => Number(r.userClaimableReward) > 0
136702
+ );
136703
+ if (claimable.length === 0) return [];
136704
+ try {
136687
136705
  await Ct(tx, claimable, {
136688
136706
  env: "prod",
136689
136707
  customCoinReceive: { type: "transfer", transfer: address2 }
136690
136708
  });
136691
- return aggregateClaimableRewards(claimable);
136692
- } catch {
136693
- return [];
136709
+ } catch (err) {
136710
+ const msg = err instanceof Error ? err.message : String(err);
136711
+ throw new T2000Error(
136712
+ "PROTOCOL_UNAVAILABLE",
136713
+ `NAVI claim PTB build failed: ${msg}`,
136714
+ { source: "navi-rewards-claim-ptb" },
136715
+ true
136716
+ );
136694
136717
  }
136718
+ return aggregateClaimableRewards(claimable);
136695
136719
  }
136696
136720
  function aggregateClaimableRewards(claimable) {
136697
136721
  const aggregated = /* @__PURE__ */ new Map();
@@ -138112,13 +138136,20 @@ var T2000 = class _T2000 extends import_index2.default {
138112
138136
  }
138113
138137
  // -- Claim Rewards --
138114
138138
  async getPendingRewards() {
138115
- const adapters = this.registry.listLending();
138139
+ const adapters = this.registry.listLending().filter((a) => a.getPendingRewards);
138140
+ if (adapters.length === 0) return [];
138116
138141
  const results = await Promise.allSettled(
138117
- adapters.filter((a) => a.getPendingRewards).map((a) => a.getPendingRewards(this._address))
138142
+ adapters.map((a) => a.getPendingRewards(this._address))
138118
138143
  );
138119
138144
  const all3 = [];
138145
+ const errors = [];
138120
138146
  for (const r of results) {
138121
138147
  if (r.status === "fulfilled") all3.push(...r.value);
138148
+ else errors.push(r.reason);
138149
+ }
138150
+ if (all3.length === 0 && errors.length === adapters.length) {
138151
+ const first = errors[0];
138152
+ throw first instanceof Error ? first : new Error(String(first));
138122
138153
  }
138123
138154
  return all3;
138124
138155
  }
@@ -138131,13 +138162,19 @@ var T2000 = class _T2000 extends import_index2.default {
138131
138162
  const tx = new Transaction();
138132
138163
  tx.setSender(this._address);
138133
138164
  const allRewards = [];
138165
+ const errors = [];
138134
138166
  for (const adapter2 of adapters) {
138135
138167
  try {
138136
138168
  const claimed = await adapter2.addClaimRewardsToTx(tx, this._address);
138137
138169
  allRewards.push(...claimed);
138138
- } catch {
138170
+ } catch (err) {
138171
+ errors.push(err);
138139
138172
  }
138140
138173
  }
138174
+ if (allRewards.length === 0 && errors.length === adapters.length) {
138175
+ const first = errors[0];
138176
+ throw first instanceof Error ? first : new Error(String(first));
138177
+ }
138141
138178
  if (allRewards.length === 0) {
138142
138179
  return { success: true, tx: "", rewards: [], totalValueUsd: 0, gasCost: 0 };
138143
138180
  }
@@ -139672,7 +139709,7 @@ ${context}
139672
139709
  })
139673
139710
  );
139674
139711
  }
139675
- var PKG_VERSION = "1.22.1";
139712
+ var PKG_VERSION = "1.23.0";
139676
139713
  console.log = (...args) => console.error("[log]", ...args);
139677
139714
  console.warn = (...args) => console.error("[warn]", ...args);
139678
139715
  async function startMcpServer(opts) {
@@ -139762,4 +139799,4 @@ axios/dist/node/axios.cjs:
139762
139799
  @scure/bip39/index.js:
139763
139800
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
139764
139801
  */
139765
- //# sourceMappingURL=dist-D7SMKZQX.js.map
139802
+ //# sourceMappingURL=dist-4BEH22UU.js.map