@t2000/sdk 1.22.2 → 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.
- package/dist/adapters/index.cjs +53 -29
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +53 -29
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +74 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.js +74 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.cjs
CHANGED
|
@@ -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
|
-
|
|
4591
|
+
rewards = await vt(address, {
|
|
4591
4592
|
...sdkOptions(client),
|
|
4592
4593
|
markets: ["main"]
|
|
4593
4594
|
});
|
|
4594
|
-
|
|
4595
|
-
const
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
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
|
-
|
|
4627
|
+
rewards = await vt(address, {
|
|
4620
4628
|
...sdkOptions(client),
|
|
4621
4629
|
markets: ["main"]
|
|
4622
4630
|
});
|
|
4623
|
-
|
|
4624
|
-
const
|
|
4625
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
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();
|