@t2000/cli 0.50.2 → 0.51.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-Q52KM4VI.js → chunk-6QF7QYS4.js} +38 -14
- package/dist/{chunk-Q52KM4VI.js.map → chunk-6QF7QYS4.js.map} +1 -1
- package/dist/{dist-4KFY6MX6.js → dist-53IAVMW6.js} +2 -2
- package/dist/{dist-UU3LLOLE.js → dist-LBQE6JNT.js} +39 -15
- package/dist/{dist-UU3LLOLE.js.map → dist-LBQE6JNT.js.map} +1 -1
- package/dist/index.js +3 -3
- package/package.json +3 -3
- /package/dist/{dist-4KFY6MX6.js.map → dist-53IAVMW6.js.map} +0 -0
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
usdcToRaw,
|
|
111
111
|
validateAddress,
|
|
112
112
|
walletExists
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-6QF7QYS4.js";
|
|
114
114
|
import "./chunk-V7PXDEKG.js";
|
|
115
115
|
import "./chunk-Q2LY5BHK.js";
|
|
116
116
|
import "./chunk-3XUF7GM3.js";
|
|
@@ -227,4 +227,4 @@ export {
|
|
|
227
227
|
validateAddress,
|
|
228
228
|
walletExists
|
|
229
229
|
};
|
|
230
|
-
//# sourceMappingURL=dist-
|
|
230
|
+
//# sourceMappingURL=dist-53IAVMW6.js.map
|
|
@@ -130243,8 +130243,8 @@ var SUPPORTED_ASSETS = {
|
|
|
130243
130243
|
var STABLE_ASSETS = ["USDC"];
|
|
130244
130244
|
var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
|
|
130245
130245
|
var OPERATION_ASSETS = {
|
|
130246
|
-
save: ["USDC"],
|
|
130247
|
-
borrow: ["USDC"],
|
|
130246
|
+
save: ["USDC", "USDsui"],
|
|
130247
|
+
borrow: ["USDC", "USDsui"],
|
|
130248
130248
|
withdraw: "*",
|
|
130249
130249
|
repay: "*",
|
|
130250
130250
|
send: "*",
|
|
@@ -130253,7 +130253,8 @@ var OPERATION_ASSETS = {
|
|
|
130253
130253
|
function isAllowedAsset(op, asset) {
|
|
130254
130254
|
const allowed = OPERATION_ASSETS[op];
|
|
130255
130255
|
if (allowed === "*") return true;
|
|
130256
|
-
|
|
130256
|
+
const target = asset.toLowerCase();
|
|
130257
|
+
return allowed.some((a) => a.toLowerCase() === target);
|
|
130257
130258
|
}
|
|
130258
130259
|
function assertAllowedAsset(op, asset) {
|
|
130259
130260
|
if (!asset) return;
|
|
@@ -130262,7 +130263,7 @@ function assertAllowedAsset(op, asset) {
|
|
|
130262
130263
|
const list2 = Array.isArray(allowed) ? allowed.join(", ") : "any";
|
|
130263
130264
|
throw new T2000Error(
|
|
130264
130265
|
"INVALID_ASSET",
|
|
130265
|
-
`${op} only supports ${list2}. Cannot use ${asset}.${" Swap to USDC first."}`
|
|
130266
|
+
`${op} only supports ${list2}. Cannot use ${asset}.${op === "save" ? " Swap to USDC or USDsui first." : ""}`
|
|
130266
130267
|
);
|
|
130267
130268
|
}
|
|
130268
130269
|
}
|
|
@@ -136024,23 +136025,26 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
136024
136025
|
async save(params) {
|
|
136025
136026
|
this.enforcer.assertNotLocked();
|
|
136026
136027
|
assertAllowedAsset("save", params.asset);
|
|
136027
|
-
const asset = "USDC";
|
|
136028
|
+
const asset = params.asset ?? "USDC";
|
|
136028
136029
|
const assetInfo = SUPPORTED_ASSETS[asset];
|
|
136029
136030
|
let amount2;
|
|
136030
136031
|
if (params.amount === "all") {
|
|
136031
|
-
const
|
|
136032
|
-
amount2 =
|
|
136032
|
+
const assetBalance = await this._queryAssetBalance(assetInfo.type, assetInfo.decimals);
|
|
136033
|
+
amount2 = assetBalance - 1;
|
|
136033
136034
|
if (amount2 <= 0) {
|
|
136034
|
-
throw new T2000Error("INSUFFICIENT_BALANCE", `No
|
|
136035
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} available to save`, {
|
|
136035
136036
|
reason: "insufficient_balance",
|
|
136036
136037
|
asset
|
|
136037
136038
|
});
|
|
136038
136039
|
}
|
|
136039
136040
|
} else {
|
|
136040
136041
|
amount2 = params.amount;
|
|
136041
|
-
const
|
|
136042
|
-
if (amount2 >
|
|
136043
|
-
throw new T2000Error(
|
|
136042
|
+
const assetBalance = await this._queryAssetBalance(assetInfo.type, assetInfo.decimals);
|
|
136043
|
+
if (amount2 > assetBalance) {
|
|
136044
|
+
throw new T2000Error(
|
|
136045
|
+
"INSUFFICIENT_BALANCE",
|
|
136046
|
+
`Insufficient ${assetInfo.displayName} balance. Available: ${assetBalance.toFixed(assetInfo.decimals === 6 ? 2 : 4)}, requested: ${amount2.toFixed(assetInfo.decimals === 6 ? 2 : 4)}`
|
|
136047
|
+
);
|
|
136044
136048
|
}
|
|
136045
136049
|
}
|
|
136046
136050
|
const fee = calculateFee("save", amount2);
|
|
@@ -136052,7 +136056,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
136052
136056
|
const tx2 = new Transaction();
|
|
136053
136057
|
tx2.setSender(this._address);
|
|
136054
136058
|
const coins = await this._fetchCoins(assetInfo.type);
|
|
136055
|
-
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE",
|
|
136059
|
+
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins found`);
|
|
136056
136060
|
const merged = this._mergeCoinsInTx(tx2, coins);
|
|
136057
136061
|
const rawAmount = BigInt(Math.floor(saveAmount * 10 ** assetInfo.decimals));
|
|
136058
136062
|
const [inputCoin] = tx2.splitCoins(merged, [rawAmount]);
|
|
@@ -136236,6 +136240,24 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
136236
136240
|
gasMethod: gasResult.gasMethod
|
|
136237
136241
|
};
|
|
136238
136242
|
}
|
|
136243
|
+
/**
|
|
136244
|
+
* [v0.51.0] Per-asset wallet balance lookup.
|
|
136245
|
+
*
|
|
136246
|
+
* `queryBalance.available` rolls up only `STABLE_ASSETS` (USDC), so it cannot
|
|
136247
|
+
* answer "do they have enough USDsui to save 10?". This helper hits
|
|
136248
|
+
* `getBalance` for the specific coin type — same mechanism `queryBalance`
|
|
136249
|
+
* uses internally — and converts to a human-readable amount using the asset's
|
|
136250
|
+
* decimals. Returns 0 (not a throw) when the address holds none of the asset,
|
|
136251
|
+
* matching the caller's existing "insufficient balance" error path.
|
|
136252
|
+
*/
|
|
136253
|
+
async _queryAssetBalance(coinType, decimals2) {
|
|
136254
|
+
try {
|
|
136255
|
+
const bal = await this.client.getBalance({ owner: this._address, coinType });
|
|
136256
|
+
return Number(bal.totalBalance) / 10 ** decimals2;
|
|
136257
|
+
} catch {
|
|
136258
|
+
return 0;
|
|
136259
|
+
}
|
|
136260
|
+
}
|
|
136239
136261
|
async _fetchCoins(coinType) {
|
|
136240
136262
|
const all3 = [];
|
|
136241
136263
|
let cursor;
|
|
@@ -136318,7 +136340,8 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
136318
136340
|
// -- Borrowing --
|
|
136319
136341
|
async borrow(params) {
|
|
136320
136342
|
this.enforcer.assertNotLocked();
|
|
136321
|
-
|
|
136343
|
+
assertAllowedAsset("borrow", params.asset);
|
|
136344
|
+
const asset = params.asset ?? "USDC";
|
|
136322
136345
|
const adapter2 = await this.resolveLending(params.protocol, asset, "borrow");
|
|
136323
136346
|
const maxResult = await adapter2.maxBorrow(this._address, asset);
|
|
136324
136347
|
if (maxResult.maxAmount <= 0) {
|
|
@@ -136343,6 +136366,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
136343
136366
|
success: true,
|
|
136344
136367
|
tx: gasResult.digest,
|
|
136345
136368
|
amount: borrowAmount,
|
|
136369
|
+
asset,
|
|
136346
136370
|
fee: fee.amount,
|
|
136347
136371
|
healthFactor: hf.healthFactor,
|
|
136348
136372
|
gasCost: gasResult.gasCostSui,
|
|
@@ -138081,7 +138105,7 @@ ${context}
|
|
|
138081
138105
|
})
|
|
138082
138106
|
);
|
|
138083
138107
|
}
|
|
138084
|
-
var PKG_VERSION = "0.
|
|
138108
|
+
var PKG_VERSION = "0.51.0";
|
|
138085
138109
|
console.log = (...args) => console.error("[log]", ...args);
|
|
138086
138110
|
console.warn = (...args) => console.error("[warn]", ...args);
|
|
138087
138111
|
async function startMcpServer(opts) {
|
|
@@ -138171,4 +138195,4 @@ axios/dist/node/axios.cjs:
|
|
|
138171
138195
|
*)
|
|
138172
138196
|
*)
|
|
138173
138197
|
*/
|
|
138174
|
-
//# sourceMappingURL=dist-
|
|
138198
|
+
//# sourceMappingURL=dist-LBQE6JNT.js.map
|