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