@t2000/sdk 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.
@@ -4586,53 +4586,77 @@ async function maxBorrowAmount(client, address) {
4586
4586
  return { maxAmount, healthFactorAfter: MIN_HEALTH_FACTOR, currentHF: hf.healthFactor };
4587
4587
  }
4588
4588
  async function getPendingRewards(client, address) {
4589
+ let rewards;
4589
4590
  try {
4590
- const rewards = await vt(address, {
4591
+ rewards = await vt(address, {
4591
4592
  ...sdkOptions(client),
4592
4593
  markets: ["main"]
4593
4594
  });
4594
- if (!rewards || rewards.length === 0) return [];
4595
- const summary = wt(rewards);
4596
- const result = [];
4597
- for (const s of summary) {
4598
- for (const rw of s.rewards) {
4599
- const available = Number(rw.available);
4600
- if (available <= 0) continue;
4601
- const symbol = rw.coinType.split("::").pop() ?? "UNKNOWN";
4602
- result.push({
4603
- protocol: "navi",
4604
- asset: String(s.assetId),
4605
- coinType: rw.coinType,
4606
- symbol,
4607
- amount: available,
4608
- estimatedValueUsd: 0
4609
- });
4610
- }
4595
+ } catch (err) {
4596
+ const msg = err instanceof Error ? err.message : String(err);
4597
+ throw new T2000Error(
4598
+ "PROTOCOL_UNAVAILABLE",
4599
+ `NAVI rewards lookup failed: ${msg}`,
4600
+ { source: "navi-rewards-read" },
4601
+ true
4602
+ );
4603
+ }
4604
+ if (!rewards || rewards.length === 0) return [];
4605
+ const summary = wt(rewards);
4606
+ const result = [];
4607
+ for (const s of summary) {
4608
+ for (const rw of s.rewards) {
4609
+ const available = Number(rw.available);
4610
+ if (available <= 0) continue;
4611
+ const symbol = rw.coinType.split("::").pop() ?? "UNKNOWN";
4612
+ result.push({
4613
+ protocol: "navi",
4614
+ asset: String(s.assetId),
4615
+ coinType: rw.coinType,
4616
+ symbol,
4617
+ amount: available,
4618
+ estimatedValueUsd: 0
4619
+ });
4611
4620
  }
4612
- return result;
4613
- } catch {
4614
- return [];
4615
4621
  }
4622
+ return result;
4616
4623
  }
4617
4624
  async function addClaimRewardsToTx(tx, client, address) {
4625
+ let rewards;
4618
4626
  try {
4619
- const rewards = await vt(address, {
4627
+ rewards = await vt(address, {
4620
4628
  ...sdkOptions(client),
4621
4629
  markets: ["main"]
4622
4630
  });
4623
- if (!rewards || rewards.length === 0) return [];
4624
- const claimable = rewards.filter(
4625
- (r) => Number(r.userClaimableReward) > 0
4631
+ } catch (err) {
4632
+ const msg = err instanceof Error ? err.message : String(err);
4633
+ throw new T2000Error(
4634
+ "PROTOCOL_UNAVAILABLE",
4635
+ `NAVI rewards lookup failed: ${msg}`,
4636
+ { source: "navi-rewards-claim-prelude" },
4637
+ true
4626
4638
  );
4627
- if (claimable.length === 0) return [];
4639
+ }
4640
+ if (!rewards || rewards.length === 0) return [];
4641
+ const claimable = rewards.filter(
4642
+ (r) => Number(r.userClaimableReward) > 0
4643
+ );
4644
+ if (claimable.length === 0) return [];
4645
+ try {
4628
4646
  await Ct(tx, claimable, {
4629
4647
  env: "prod",
4630
4648
  customCoinReceive: { type: "transfer", transfer: address }
4631
4649
  });
4632
- return aggregateClaimableRewards(claimable);
4633
- } catch {
4634
- return [];
4650
+ } catch (err) {
4651
+ const msg = err instanceof Error ? err.message : String(err);
4652
+ throw new T2000Error(
4653
+ "PROTOCOL_UNAVAILABLE",
4654
+ `NAVI claim PTB build failed: ${msg}`,
4655
+ { source: "navi-rewards-claim-ptb" },
4656
+ true
4657
+ );
4635
4658
  }
4659
+ return aggregateClaimableRewards(claimable);
4636
4660
  }
4637
4661
  function aggregateClaimableRewards(claimable) {
4638
4662
  const aggregated = /* @__PURE__ */ new Map();