@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.
- 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-D7SMKZQX.js → dist-4BEH22UU.js} +71 -34
- package/dist/{dist-D7SMKZQX.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
|
@@ -23028,53 +23028,77 @@ async function maxBorrowAmount(client, address) {
|
|
|
23028
23028
|
return { maxAmount, healthFactorAfter: MIN_HEALTH_FACTOR, currentHF: hf.healthFactor };
|
|
23029
23029
|
}
|
|
23030
23030
|
async function getPendingRewards(client, address) {
|
|
23031
|
+
let rewards;
|
|
23031
23032
|
try {
|
|
23032
|
-
|
|
23033
|
+
rewards = await vt(address, {
|
|
23033
23034
|
...sdkOptions(client),
|
|
23034
23035
|
markets: ["main"]
|
|
23035
23036
|
});
|
|
23036
|
-
|
|
23037
|
-
const
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
|
|
23041
|
-
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
|
|
23045
|
-
|
|
23046
|
-
|
|
23047
|
-
|
|
23048
|
-
|
|
23049
|
-
|
|
23050
|
-
|
|
23051
|
-
|
|
23052
|
-
|
|
23037
|
+
} catch (err) {
|
|
23038
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
23039
|
+
throw new T2000Error(
|
|
23040
|
+
"PROTOCOL_UNAVAILABLE",
|
|
23041
|
+
`NAVI rewards lookup failed: ${msg}`,
|
|
23042
|
+
{ source: "navi-rewards-read" },
|
|
23043
|
+
true
|
|
23044
|
+
);
|
|
23045
|
+
}
|
|
23046
|
+
if (!rewards || rewards.length === 0) return [];
|
|
23047
|
+
const summary = wt(rewards);
|
|
23048
|
+
const result = [];
|
|
23049
|
+
for (const s of summary) {
|
|
23050
|
+
for (const rw of s.rewards) {
|
|
23051
|
+
const available = Number(rw.available);
|
|
23052
|
+
if (available <= 0) continue;
|
|
23053
|
+
const symbol = rw.coinType.split("::").pop() ?? "UNKNOWN";
|
|
23054
|
+
result.push({
|
|
23055
|
+
protocol: "navi",
|
|
23056
|
+
asset: String(s.assetId),
|
|
23057
|
+
coinType: rw.coinType,
|
|
23058
|
+
symbol,
|
|
23059
|
+
amount: available,
|
|
23060
|
+
estimatedValueUsd: 0
|
|
23061
|
+
});
|
|
23053
23062
|
}
|
|
23054
|
-
return result;
|
|
23055
|
-
} catch {
|
|
23056
|
-
return [];
|
|
23057
23063
|
}
|
|
23064
|
+
return result;
|
|
23058
23065
|
}
|
|
23059
23066
|
async function addClaimRewardsToTx(tx, client, address) {
|
|
23067
|
+
let rewards;
|
|
23060
23068
|
try {
|
|
23061
|
-
|
|
23069
|
+
rewards = await vt(address, {
|
|
23062
23070
|
...sdkOptions(client),
|
|
23063
23071
|
markets: ["main"]
|
|
23064
23072
|
});
|
|
23065
|
-
|
|
23066
|
-
const
|
|
23067
|
-
|
|
23073
|
+
} catch (err) {
|
|
23074
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
23075
|
+
throw new T2000Error(
|
|
23076
|
+
"PROTOCOL_UNAVAILABLE",
|
|
23077
|
+
`NAVI rewards lookup failed: ${msg}`,
|
|
23078
|
+
{ source: "navi-rewards-claim-prelude" },
|
|
23079
|
+
true
|
|
23068
23080
|
);
|
|
23069
|
-
|
|
23081
|
+
}
|
|
23082
|
+
if (!rewards || rewards.length === 0) return [];
|
|
23083
|
+
const claimable = rewards.filter(
|
|
23084
|
+
(r) => Number(r.userClaimableReward) > 0
|
|
23085
|
+
);
|
|
23086
|
+
if (claimable.length === 0) return [];
|
|
23087
|
+
try {
|
|
23070
23088
|
await Ct(tx, claimable, {
|
|
23071
23089
|
env: "prod",
|
|
23072
23090
|
customCoinReceive: { type: "transfer", transfer: address }
|
|
23073
23091
|
});
|
|
23074
|
-
|
|
23075
|
-
|
|
23076
|
-
|
|
23092
|
+
} catch (err) {
|
|
23093
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
23094
|
+
throw new T2000Error(
|
|
23095
|
+
"PROTOCOL_UNAVAILABLE",
|
|
23096
|
+
`NAVI claim PTB build failed: ${msg}`,
|
|
23097
|
+
{ source: "navi-rewards-claim-ptb" },
|
|
23098
|
+
true
|
|
23099
|
+
);
|
|
23077
23100
|
}
|
|
23101
|
+
return aggregateClaimableRewards(claimable);
|
|
23078
23102
|
}
|
|
23079
23103
|
async function buildClaimRewardsTx(client, address) {
|
|
23080
23104
|
const tx = new Transaction();
|
|
@@ -24520,13 +24544,20 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
24520
24544
|
}
|
|
24521
24545
|
// -- Claim Rewards --
|
|
24522
24546
|
async getPendingRewards() {
|
|
24523
|
-
const adapters = this.registry.listLending();
|
|
24547
|
+
const adapters = this.registry.listLending().filter((a) => a.getPendingRewards);
|
|
24548
|
+
if (adapters.length === 0) return [];
|
|
24524
24549
|
const results = await Promise.allSettled(
|
|
24525
|
-
adapters.
|
|
24550
|
+
adapters.map((a) => a.getPendingRewards(this._address))
|
|
24526
24551
|
);
|
|
24527
24552
|
const all = [];
|
|
24553
|
+
const errors = [];
|
|
24528
24554
|
for (const r of results) {
|
|
24529
24555
|
if (r.status === "fulfilled") all.push(...r.value);
|
|
24556
|
+
else errors.push(r.reason);
|
|
24557
|
+
}
|
|
24558
|
+
if (all.length === 0 && errors.length === adapters.length) {
|
|
24559
|
+
const first = errors[0];
|
|
24560
|
+
throw first instanceof Error ? first : new Error(String(first));
|
|
24530
24561
|
}
|
|
24531
24562
|
return all;
|
|
24532
24563
|
}
|
|
@@ -24539,13 +24570,19 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
24539
24570
|
const tx = new Transaction();
|
|
24540
24571
|
tx.setSender(this._address);
|
|
24541
24572
|
const allRewards = [];
|
|
24573
|
+
const errors = [];
|
|
24542
24574
|
for (const adapter of adapters) {
|
|
24543
24575
|
try {
|
|
24544
24576
|
const claimed = await adapter.addClaimRewardsToTx(tx, this._address);
|
|
24545
24577
|
allRewards.push(...claimed);
|
|
24546
|
-
} catch {
|
|
24578
|
+
} catch (err) {
|
|
24579
|
+
errors.push(err);
|
|
24547
24580
|
}
|
|
24548
24581
|
}
|
|
24582
|
+
if (allRewards.length === 0 && errors.length === adapters.length) {
|
|
24583
|
+
const first = errors[0];
|
|
24584
|
+
throw first instanceof Error ? first : new Error(String(first));
|
|
24585
|
+
}
|
|
24549
24586
|
if (allRewards.length === 0) {
|
|
24550
24587
|
return { success: true, tx: "", rewards: [], totalValueUsd: 0, gasCost: 0 };
|
|
24551
24588
|
}
|
|
@@ -25387,6 +25424,10 @@ function buildRevokeLeafTx(suinsClient, { label }) {
|
|
|
25387
25424
|
function fullHandle(label) {
|
|
25388
25425
|
return `${label}.${AUDRIC_PARENT_NAME}`;
|
|
25389
25426
|
}
|
|
25427
|
+
function displayHandle(label) {
|
|
25428
|
+
const parentDisplay = AUDRIC_PARENT_NAME.replace(/\.sui$/, "");
|
|
25429
|
+
return `${label}@${parentDisplay}`;
|
|
25430
|
+
}
|
|
25390
25431
|
|
|
25391
25432
|
export {
|
|
25392
25433
|
mapWalletError,
|
|
@@ -25515,7 +25556,8 @@ export {
|
|
|
25515
25556
|
validateLabel,
|
|
25516
25557
|
buildAddLeafTx,
|
|
25517
25558
|
buildRevokeLeafTx,
|
|
25518
|
-
fullHandle
|
|
25559
|
+
fullHandle,
|
|
25560
|
+
displayHandle
|
|
25519
25561
|
};
|
|
25520
25562
|
/*! Bundled license information:
|
|
25521
25563
|
|
|
@@ -25540,4 +25582,4 @@ axios/dist/node/axios.cjs:
|
|
|
25540
25582
|
@scure/bip39/index.js:
|
|
25541
25583
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
25542
25584
|
*/
|
|
25543
|
-
//# sourceMappingURL=chunk-
|
|
25585
|
+
//# sourceMappingURL=chunk-JKL4VB6Z.js.map
|