@t2000/cli 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/{chunk-COE5RRNH.js → chunk-JKL4VB6Z.js} +76 -34
- package/dist/{chunk-COE5RRNH.js.map → chunk-JKL4VB6Z.js.map} +1 -1
- package/dist/{dist-7TDENFJA.js → dist-4BEH22UU.js} +71 -34
- package/dist/{dist-7TDENFJA.js.map → dist-4BEH22UU.js.map} +1 -1
- package/dist/{dist-XSJQIU5E.js → dist-4IHD5DO3.js} +4 -2
- package/dist/index.js +3 -3
- package/package.json +3 -3
- /package/dist/{dist-XSJQIU5E.js.map → dist-4IHD5DO3.js.map} +0 -0
|
@@ -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
|
-
|
|
136650
|
+
rewards = await vt(address2, {
|
|
136650
136651
|
...sdkOptions(client),
|
|
136651
136652
|
markets: ["main"]
|
|
136652
136653
|
});
|
|
136653
|
-
|
|
136654
|
-
const
|
|
136655
|
-
|
|
136656
|
-
|
|
136657
|
-
|
|
136658
|
-
|
|
136659
|
-
|
|
136660
|
-
|
|
136661
|
-
|
|
136662
|
-
|
|
136663
|
-
|
|
136664
|
-
|
|
136665
|
-
|
|
136666
|
-
|
|
136667
|
-
|
|
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
|
-
|
|
136686
|
+
rewards = await vt(address2, {
|
|
136679
136687
|
...sdkOptions(client),
|
|
136680
136688
|
markets: ["main"]
|
|
136681
136689
|
});
|
|
136682
|
-
|
|
136683
|
-
const
|
|
136684
|
-
|
|
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
|
-
|
|
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
|
-
|
|
136692
|
-
|
|
136693
|
-
|
|
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.
|
|
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.
|
|
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-
|
|
139802
|
+
//# sourceMappingURL=dist-4BEH22UU.js.map
|