@t2000/cli 0.26.1 → 0.27.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/README.md +1 -0
- package/dist/{ccip-XP27NGI7.js → ccip-JEEJV65M.js} +3 -3
- package/dist/{chunk-FSE25UF3.js → chunk-2JUMTEBB.js} +325 -12
- package/dist/chunk-2JUMTEBB.js.map +1 -0
- package/dist/chunk-77SWBATH.js +204 -0
- package/dist/chunk-77SWBATH.js.map +1 -0
- package/dist/{chunk-3I6VJOM6.js → chunk-A5X4KG7U.js} +970 -210
- package/dist/chunk-A5X4KG7U.js.map +1 -0
- package/dist/{chunk-TYYJRUQI.js → chunk-HGA6AHN5.js} +644 -70
- package/dist/chunk-HGA6AHN5.js.map +1 -0
- package/dist/{client-YNWQPUC5.js → client-2MUO6VAJ.js} +4 -4
- package/dist/{client-YNWQPUC5.js.map → client-2MUO6VAJ.js.map} +1 -1
- package/dist/{client-IXUBQ3HM.js → client-KQCHOXLV.js} +197 -197
- package/dist/client-KQCHOXLV.js.map +1 -0
- package/dist/{dist-ZKTRDHRL.js → dist-F462ZUVT.js} +38 -2
- package/dist/{dist-AY4QEDAC.js → dist-UDCEDQVB.js} +20 -2
- package/dist/{dist-AY4QEDAC.js.map → dist-UDCEDQVB.js.map} +1 -1
- package/dist/index.js +54 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-3I6VJOM6.js.map +0 -1
- package/dist/chunk-EI3GHTKX.js +0 -968
- package/dist/chunk-EI3GHTKX.js.map +0 -1
- package/dist/chunk-FSE25UF3.js.map +0 -1
- package/dist/chunk-TYYJRUQI.js.map +0 -1
- package/dist/client-IXUBQ3HM.js.map +0 -1
- /package/dist/{ccip-XP27NGI7.js.map → ccip-JEEJV65M.js.map} +0 -0
- /package/dist/{dist-ZKTRDHRL.js.map → dist-F462ZUVT.js.map} +0 -0
package/README.md
CHANGED
|
@@ -144,6 +144,7 @@ t2000 init
|
|
|
144
144
|
| Command | Description |
|
|
145
145
|
|---------|-------------|
|
|
146
146
|
| `t2000 send <amount> <asset> [to] <address>` | Send USDC, SUI, or other assets to any Sui address (the `to` keyword is optional) |
|
|
147
|
+
| `t2000 receive` | Generate a payment request with address and QR URI. Options: `--amount`, `--currency`, `--memo`, `--label` |
|
|
147
148
|
|
|
148
149
|
### Savings & DeFi
|
|
149
150
|
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
offchainLookup,
|
|
5
5
|
offchainLookupAbiItem,
|
|
6
6
|
offchainLookupSignature
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-A5X4KG7U.js";
|
|
8
|
+
import "./chunk-77SWBATH.js";
|
|
9
9
|
import "./chunk-7LGHVVIJ.js";
|
|
10
10
|
import "./chunk-YPWSCLE3.js";
|
|
11
11
|
export {
|
|
@@ -14,4 +14,4 @@ export {
|
|
|
14
14
|
offchainLookupAbiItem,
|
|
15
15
|
offchainLookupSignature
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=ccip-
|
|
17
|
+
//# sourceMappingURL=ccip-JEEJV65M.js.map
|
|
@@ -63907,7 +63907,7 @@ var init_token_registry = __esm2({
|
|
|
63907
63907
|
SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
|
|
63908
63908
|
wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
|
|
63909
63909
|
ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
|
|
63910
|
-
GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals:
|
|
63910
|
+
GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
|
|
63911
63911
|
DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
|
|
63912
63912
|
WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
|
|
63913
63913
|
NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
|
|
@@ -64139,6 +64139,7 @@ var init_cetus_swap = __esm2({
|
|
|
64139
64139
|
clientInstance = null;
|
|
64140
64140
|
}
|
|
64141
64141
|
});
|
|
64142
|
+
init_errors();
|
|
64142
64143
|
var MIST_PER_SUI2 = 1000000000n;
|
|
64143
64144
|
var SUI_DECIMALS2 = 9;
|
|
64144
64145
|
var USDC_DECIMALS = 6;
|
|
@@ -64207,15 +64208,51 @@ var SUPPORTED_ASSETS = {
|
|
|
64207
64208
|
};
|
|
64208
64209
|
var STABLE_ASSETS = ["USDC"];
|
|
64209
64210
|
var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
|
|
64210
|
-
var
|
|
64211
|
-
|
|
64212
|
-
|
|
64211
|
+
var OPERATION_ASSETS = {
|
|
64212
|
+
save: ["USDC"],
|
|
64213
|
+
borrow: ["USDC"],
|
|
64214
|
+
withdraw: "*",
|
|
64215
|
+
repay: "*",
|
|
64216
|
+
send: "*",
|
|
64217
|
+
swap: "*"
|
|
64218
|
+
};
|
|
64219
|
+
function isAllowedAsset(op, asset) {
|
|
64220
|
+
const allowed = OPERATION_ASSETS[op];
|
|
64221
|
+
if (allowed === "*") return true;
|
|
64222
|
+
return allowed.includes(asset.toUpperCase());
|
|
64223
|
+
}
|
|
64224
|
+
function assertAllowedAsset(op, asset) {
|
|
64225
|
+
if (!asset) return;
|
|
64226
|
+
if (!isAllowedAsset(op, asset)) {
|
|
64227
|
+
const allowed = OPERATION_ASSETS[op];
|
|
64228
|
+
const list = Array.isArray(allowed) ? allowed.join(", ") : "any";
|
|
64229
|
+
throw new T2000Error(
|
|
64230
|
+
"INVALID_ASSET",
|
|
64231
|
+
`${op} only supports ${list}. Cannot use ${asset}.${op === "save" ? " Swap to USDC first." : ""}`
|
|
64232
|
+
);
|
|
64233
|
+
}
|
|
64234
|
+
}
|
|
64235
|
+
var T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? "0xd775fcc66eae26797654d435d751dea56b82eeb999de51fd285348e573b968ad";
|
|
64236
|
+
var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "0x08ba26f0d260b5edf6a19c71492b3eb914906a7419baf2df1426765157e5862a";
|
|
64237
|
+
var T2000_ADMIN_CAP_ID = "0xa97bfff140f5a2c268a03fe5422d382c228057deb7bcfdaf2967ca18b9bdbbd9";
|
|
64238
|
+
var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0xf420ec0dcad44433042fb56e1413fb88d3ff65be94fcf425ef9ff750164590e8";
|
|
64213
64239
|
var DEFAULT_NETWORK = "mainnet";
|
|
64214
64240
|
var DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
|
|
64215
64241
|
var DEFAULT_KEY_PATH = "~/.t2000/wallet.key";
|
|
64216
64242
|
var API_BASE_URL = process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
64217
64243
|
var CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
64218
64244
|
var GAS_RESERVE_MIN = 0.05;
|
|
64245
|
+
var ALLOWANCE_FEATURES = {
|
|
64246
|
+
BRIEFING: 0,
|
|
64247
|
+
YIELD_ALERT: 1,
|
|
64248
|
+
PAYMENT_ALERT: 2,
|
|
64249
|
+
ACTION_REMIND: 3,
|
|
64250
|
+
SESSION: 4,
|
|
64251
|
+
AUTO_COMPOUND: 5,
|
|
64252
|
+
DCA: 6,
|
|
64253
|
+
HF_ALERT: 7
|
|
64254
|
+
};
|
|
64255
|
+
var FEATURES_ALL = 255;
|
|
64219
64256
|
init_errors();
|
|
64220
64257
|
var cachedClient = null;
|
|
64221
64258
|
function getSuiClient(rpcUrl) {
|
|
@@ -64592,7 +64629,7 @@ function extractCommands(txBlock) {
|
|
|
64592
64629
|
if (!data || typeof data !== "object") return result;
|
|
64593
64630
|
const inner = "transaction" in data ? data.transaction : void 0;
|
|
64594
64631
|
if (!inner || typeof inner !== "object") return result;
|
|
64595
|
-
const commands = "commands" in inner ? inner.commands : void 0;
|
|
64632
|
+
const commands = "commands" in inner ? inner.commands : "transactions" in inner ? inner.transactions : void 0;
|
|
64596
64633
|
if (!Array.isArray(commands)) return result;
|
|
64597
64634
|
for (const cmd of commands) {
|
|
64598
64635
|
if (cmd.MoveCall) {
|
|
@@ -65980,8 +66017,8 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
65980
66017
|
async pay(options) {
|
|
65981
66018
|
this.enforcer.assertNotLocked();
|
|
65982
66019
|
this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
|
|
65983
|
-
const { Mppx } = await import("./client-
|
|
65984
|
-
const { sui } = await import("./client-
|
|
66020
|
+
const { Mppx } = await import("./client-KQCHOXLV.js");
|
|
66021
|
+
const { sui } = await import("./client-2MUO6VAJ.js");
|
|
65985
66022
|
const client = this.client;
|
|
65986
66023
|
const signer = this._signer;
|
|
65987
66024
|
const signerAddress = signer.getAddress();
|
|
@@ -66284,6 +66321,32 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66284
66321
|
].join("\n")
|
|
66285
66322
|
};
|
|
66286
66323
|
}
|
|
66324
|
+
receive(params) {
|
|
66325
|
+
const amount = params?.amount ?? null;
|
|
66326
|
+
const currency = params?.currency ?? "USDC";
|
|
66327
|
+
const memo = params?.memo ?? null;
|
|
66328
|
+
const label = params?.label ?? null;
|
|
66329
|
+
const qrParts = [`sui:${this._address}`];
|
|
66330
|
+
const queryParams = [];
|
|
66331
|
+
if (amount != null) queryParams.push(`amount=${amount}`);
|
|
66332
|
+
if (currency !== "SUI") queryParams.push(`currency=${currency}`);
|
|
66333
|
+
if (memo) queryParams.push(`memo=${encodeURIComponent(memo)}`);
|
|
66334
|
+
if (label) queryParams.push(`label=${encodeURIComponent(label)}`);
|
|
66335
|
+
const qrUri = queryParams.length > 0 ? `${qrParts[0]}?${queryParams.join("&")}` : qrParts[0];
|
|
66336
|
+
const amountStr = amount != null ? `$${amount.toFixed(2)} ` : "";
|
|
66337
|
+
const displayParts = [`Send ${amountStr}${currency} to ${truncateAddress(this._address)}`];
|
|
66338
|
+
if (memo) displayParts.push(`Memo: ${memo}`);
|
|
66339
|
+
return {
|
|
66340
|
+
address: this._address,
|
|
66341
|
+
network: "mainnet",
|
|
66342
|
+
amount,
|
|
66343
|
+
currency,
|
|
66344
|
+
memo,
|
|
66345
|
+
label,
|
|
66346
|
+
qrUri,
|
|
66347
|
+
displayText: displayParts.join("\n")
|
|
66348
|
+
};
|
|
66349
|
+
}
|
|
66287
66350
|
exportKey() {
|
|
66288
66351
|
return exportPrivateKey(this.keypair);
|
|
66289
66352
|
}
|
|
@@ -66299,9 +66362,7 @@ var T2000 = class _T2000 extends import_index.default {
|
|
|
66299
66362
|
// -- Savings --
|
|
66300
66363
|
async save(params) {
|
|
66301
66364
|
this.enforcer.assertNotLocked();
|
|
66302
|
-
|
|
66303
|
-
throw new T2000Error("INVALID_ASSET", "Only USDC deposits are supported. Swap to USDC first.");
|
|
66304
|
-
}
|
|
66365
|
+
assertAllowedAsset("save", params.asset);
|
|
66305
66366
|
const asset = "USDC";
|
|
66306
66367
|
const assetInfo = SUPPORTED_ASSETS[asset];
|
|
66307
66368
|
let amount;
|
|
@@ -66930,6 +66991,188 @@ async function callUsdcSponsorApi(address) {
|
|
|
66930
66991
|
}
|
|
66931
66992
|
}
|
|
66932
66993
|
init_errors();
|
|
66994
|
+
var USDC_TYPE2 = SUPPORTED_ASSETS.USDC.type;
|
|
66995
|
+
function buildCreateAllowanceTx(options = {}) {
|
|
66996
|
+
const tx = new Transaction();
|
|
66997
|
+
tx.moveCall({
|
|
66998
|
+
target: `${T2000_PACKAGE_ID}::allowance::create`,
|
|
66999
|
+
typeArguments: [USDC_TYPE2],
|
|
67000
|
+
arguments: [
|
|
67001
|
+
tx.pure.u64(options.permittedFeatures ?? BigInt(FEATURES_ALL)),
|
|
67002
|
+
tx.pure.u64(options.expiresAt ?? 0n),
|
|
67003
|
+
tx.pure.u64(options.dailyLimit ?? 0n),
|
|
67004
|
+
tx.object(CLOCK_ID)
|
|
67005
|
+
]
|
|
67006
|
+
});
|
|
67007
|
+
return tx;
|
|
67008
|
+
}
|
|
67009
|
+
function addDepositAllowanceTx(tx, allowanceId, paymentCoin) {
|
|
67010
|
+
tx.moveCall({
|
|
67011
|
+
target: `${T2000_PACKAGE_ID}::allowance::deposit`,
|
|
67012
|
+
typeArguments: [USDC_TYPE2],
|
|
67013
|
+
arguments: [tx.object(allowanceId), paymentCoin]
|
|
67014
|
+
});
|
|
67015
|
+
}
|
|
67016
|
+
function buildDepositAllowanceTx(allowanceId, usdcCoin, amount) {
|
|
67017
|
+
const tx = new Transaction();
|
|
67018
|
+
const [split2] = tx.splitCoins(tx.object(usdcCoin), [tx.pure.u64(amount)]);
|
|
67019
|
+
addDepositAllowanceTx(tx, allowanceId, split2);
|
|
67020
|
+
return tx;
|
|
67021
|
+
}
|
|
67022
|
+
function buildAdminDepositAllowanceTx(allowanceId, usdcCoin, amount) {
|
|
67023
|
+
const tx = new Transaction();
|
|
67024
|
+
const [split2] = tx.splitCoins(tx.object(usdcCoin), [tx.pure.u64(amount)]);
|
|
67025
|
+
tx.moveCall({
|
|
67026
|
+
target: `${T2000_PACKAGE_ID}::allowance::admin_deposit`,
|
|
67027
|
+
typeArguments: [USDC_TYPE2],
|
|
67028
|
+
arguments: [
|
|
67029
|
+
tx.object(allowanceId),
|
|
67030
|
+
tx.object(T2000_ADMIN_CAP_ID),
|
|
67031
|
+
split2
|
|
67032
|
+
]
|
|
67033
|
+
});
|
|
67034
|
+
return tx;
|
|
67035
|
+
}
|
|
67036
|
+
function buildDeductAllowanceTx(allowanceId, amount, feature) {
|
|
67037
|
+
const tx = new Transaction();
|
|
67038
|
+
tx.moveCall({
|
|
67039
|
+
target: `${T2000_PACKAGE_ID}::allowance::deduct`,
|
|
67040
|
+
typeArguments: [USDC_TYPE2],
|
|
67041
|
+
arguments: [
|
|
67042
|
+
tx.object(allowanceId),
|
|
67043
|
+
tx.object(T2000_CONFIG_ID),
|
|
67044
|
+
tx.object(T2000_ADMIN_CAP_ID),
|
|
67045
|
+
tx.pure.u64(amount),
|
|
67046
|
+
tx.pure.u8(feature),
|
|
67047
|
+
tx.object(CLOCK_ID)
|
|
67048
|
+
]
|
|
67049
|
+
});
|
|
67050
|
+
return tx;
|
|
67051
|
+
}
|
|
67052
|
+
function buildWithdrawAllowanceTx(allowanceId) {
|
|
67053
|
+
const tx = new Transaction();
|
|
67054
|
+
tx.moveCall({
|
|
67055
|
+
target: `${T2000_PACKAGE_ID}::allowance::withdraw`,
|
|
67056
|
+
typeArguments: [USDC_TYPE2],
|
|
67057
|
+
arguments: [tx.object(allowanceId)]
|
|
67058
|
+
});
|
|
67059
|
+
return tx;
|
|
67060
|
+
}
|
|
67061
|
+
function buildWithdrawAmountAllowanceTx(allowanceId, amount) {
|
|
67062
|
+
const tx = new Transaction();
|
|
67063
|
+
tx.moveCall({
|
|
67064
|
+
target: `${T2000_PACKAGE_ID}::allowance::withdraw_amount`,
|
|
67065
|
+
typeArguments: [USDC_TYPE2],
|
|
67066
|
+
arguments: [tx.object(allowanceId), tx.pure.u64(amount)]
|
|
67067
|
+
});
|
|
67068
|
+
return tx;
|
|
67069
|
+
}
|
|
67070
|
+
async function getAllowance(client, allowanceId) {
|
|
67071
|
+
const obj = await client.getObject({
|
|
67072
|
+
id: allowanceId,
|
|
67073
|
+
options: { showContent: true, showType: true }
|
|
67074
|
+
});
|
|
67075
|
+
if (!obj.data?.content || obj.data.content.dataType !== "moveObject") {
|
|
67076
|
+
throw new Error(`Allowance ${allowanceId} not found or is not a Move object`);
|
|
67077
|
+
}
|
|
67078
|
+
const fields = obj.data.content.fields;
|
|
67079
|
+
const coinType = extractCoinType(obj.data.content.type);
|
|
67080
|
+
return {
|
|
67081
|
+
id: allowanceId,
|
|
67082
|
+
owner: fields.owner,
|
|
67083
|
+
balance: parseU64Field(fields.balance),
|
|
67084
|
+
totalDeposited: parseU64Field(fields.total_deposited),
|
|
67085
|
+
totalSpent: parseU64Field(fields.total_spent),
|
|
67086
|
+
createdAt: Number(fields.created_at),
|
|
67087
|
+
coinType,
|
|
67088
|
+
permittedFeatures: parseU64Field(fields.permitted_features),
|
|
67089
|
+
expiresAt: Number(fields.expires_at),
|
|
67090
|
+
dailyLimit: parseU64Field(fields.daily_limit),
|
|
67091
|
+
dailySpent: parseU64Field(fields.daily_spent),
|
|
67092
|
+
windowStart: Number(fields.window_start)
|
|
67093
|
+
};
|
|
67094
|
+
}
|
|
67095
|
+
async function getAllowanceBalance(client, allowanceId) {
|
|
67096
|
+
const info = await getAllowance(client, allowanceId);
|
|
67097
|
+
return info.balance;
|
|
67098
|
+
}
|
|
67099
|
+
function parseU64Field(raw) {
|
|
67100
|
+
if (typeof raw === "string" || typeof raw === "number") return BigInt(raw);
|
|
67101
|
+
if (typeof raw === "object" && raw !== null && "value" in raw) {
|
|
67102
|
+
return BigInt(raw.value);
|
|
67103
|
+
}
|
|
67104
|
+
return 0n;
|
|
67105
|
+
}
|
|
67106
|
+
function extractCoinType(objectType2) {
|
|
67107
|
+
const match = objectType2.match(/<(.+)>/);
|
|
67108
|
+
return match ? match[1] : "unknown";
|
|
67109
|
+
}
|
|
67110
|
+
var HF_WARN_THRESHOLD = 1.8;
|
|
67111
|
+
var HF_CRITICAL_THRESHOLD = 1.3;
|
|
67112
|
+
var HF_FALLBACK = {
|
|
67113
|
+
healthFactor: Infinity,
|
|
67114
|
+
supplied: 0,
|
|
67115
|
+
borrowed: 0,
|
|
67116
|
+
maxBorrow: 0,
|
|
67117
|
+
liquidationThreshold: 0.75
|
|
67118
|
+
};
|
|
67119
|
+
function classifyHF(hf, hasBorrow) {
|
|
67120
|
+
if (!hasBorrow || !Number.isFinite(hf)) return "none";
|
|
67121
|
+
if (hf <= HF_CRITICAL_THRESHOLD) return "critical";
|
|
67122
|
+
if (hf <= HF_WARN_THRESHOLD) return "warn";
|
|
67123
|
+
return "none";
|
|
67124
|
+
}
|
|
67125
|
+
async function fetchSuiPriceUsd(client) {
|
|
67126
|
+
try {
|
|
67127
|
+
const pool = await client.getObject({
|
|
67128
|
+
id: CETUS_USDC_SUI_POOL,
|
|
67129
|
+
options: { showContent: true }
|
|
67130
|
+
});
|
|
67131
|
+
if (pool.data?.content?.dataType === "moveObject") {
|
|
67132
|
+
const fields = pool.data.content.fields;
|
|
67133
|
+
const sqrtPrice = BigInt(String(fields.current_sqrt_price ?? "0"));
|
|
67134
|
+
if (sqrtPrice > 0n) {
|
|
67135
|
+
const Q64 = 2n ** 64n;
|
|
67136
|
+
const sqrtFloat = Number(sqrtPrice) / Number(Q64);
|
|
67137
|
+
const price = 1e3 / (sqrtFloat * sqrtFloat);
|
|
67138
|
+
if (price > 0.01 && price < 1e3) return price;
|
|
67139
|
+
}
|
|
67140
|
+
}
|
|
67141
|
+
} catch {
|
|
67142
|
+
}
|
|
67143
|
+
return 1;
|
|
67144
|
+
}
|
|
67145
|
+
async function getFinancialSummary(client, walletAddress, options = {}) {
|
|
67146
|
+
const [usdcBal, suiBal, hf, rates, suiPrice, allowance] = await Promise.all([
|
|
67147
|
+
client.getBalance({ owner: walletAddress, coinType: SUPPORTED_ASSETS.USDC.type }).catch(() => ({ totalBalance: "0" })),
|
|
67148
|
+
client.getBalance({ owner: walletAddress, coinType: SUPPORTED_ASSETS.SUI.type }).catch(() => ({ totalBalance: "0" })),
|
|
67149
|
+
getHealthFactor(client, walletAddress).catch(() => HF_FALLBACK),
|
|
67150
|
+
getRates(client),
|
|
67151
|
+
fetchSuiPriceUsd(client),
|
|
67152
|
+
options.allowanceId ? getAllowanceBalance(client, options.allowanceId).catch(() => null) : Promise.resolve(null)
|
|
67153
|
+
]);
|
|
67154
|
+
const usdcAvailable = Number(usdcBal.totalBalance) / 10 ** SUPPORTED_ASSETS.USDC.decimals;
|
|
67155
|
+
const gasReserveSui = Number(suiBal.totalBalance) / Number(MIST_PER_SUI2);
|
|
67156
|
+
const saveApy = rates.USDC?.saveApy ?? 0;
|
|
67157
|
+
const borrowApy = rates.USDC?.borrowApy ?? 0;
|
|
67158
|
+
const dailyYield = hf.supplied * (saveApy / 365);
|
|
67159
|
+
return {
|
|
67160
|
+
walletAddress,
|
|
67161
|
+
usdcAvailable,
|
|
67162
|
+
savingsBalance: hf.supplied,
|
|
67163
|
+
debtBalance: hf.borrowed,
|
|
67164
|
+
idleUsdc: Math.max(0, usdcAvailable),
|
|
67165
|
+
healthFactor: hf.healthFactor,
|
|
67166
|
+
hfAlertLevel: classifyHF(hf.healthFactor, hf.borrowed > 0),
|
|
67167
|
+
saveApy,
|
|
67168
|
+
borrowApy,
|
|
67169
|
+
dailyYield,
|
|
67170
|
+
gasReserveSui,
|
|
67171
|
+
gasReserveUsd: gasReserveSui * suiPrice,
|
|
67172
|
+
allowanceBalance: allowance,
|
|
67173
|
+
fetchedAt: Date.now()
|
|
67174
|
+
};
|
|
67175
|
+
}
|
|
66933
67176
|
init_errors();
|
|
66934
67177
|
init_errors();
|
|
66935
67178
|
async function simulateTransaction(client, tx, sender) {
|
|
@@ -67035,6 +67278,58 @@ async function getSwapQuote(params) {
|
|
|
67035
67278
|
init_cetus_swap();
|
|
67036
67279
|
init_token_registry();
|
|
67037
67280
|
init_volo();
|
|
67281
|
+
var DEFAULT_TTL_MS = 6e4;
|
|
67282
|
+
async function buildScopedIntent(adminKeypair, params) {
|
|
67283
|
+
const now = Date.now();
|
|
67284
|
+
const nonceBytes = new Uint8Array(32);
|
|
67285
|
+
crypto.getRandomValues(nonceBytes);
|
|
67286
|
+
const nonce = Buffer.from(nonceBytes).toString("hex");
|
|
67287
|
+
const payload = {
|
|
67288
|
+
version: 1,
|
|
67289
|
+
userId: params.userId,
|
|
67290
|
+
walletAddress: params.walletAddress,
|
|
67291
|
+
allowanceObjectId: params.allowanceObjectId,
|
|
67292
|
+
featureCode: params.featureCode,
|
|
67293
|
+
maxAmount: params.maxAmount,
|
|
67294
|
+
issuedAt: now,
|
|
67295
|
+
expiresAt: now + (params.ttlMs ?? DEFAULT_TTL_MS),
|
|
67296
|
+
nonce
|
|
67297
|
+
};
|
|
67298
|
+
const message = canonicalIntentBytes(payload);
|
|
67299
|
+
const signature = await adminKeypair.sign(message);
|
|
67300
|
+
return {
|
|
67301
|
+
...payload,
|
|
67302
|
+
signature: Buffer.from(signature).toString("hex")
|
|
67303
|
+
};
|
|
67304
|
+
}
|
|
67305
|
+
async function verifyScopedIntent(intent, adminPublicKeyBytes) {
|
|
67306
|
+
if (Date.now() > intent.expiresAt) return false;
|
|
67307
|
+
const payload = {
|
|
67308
|
+
version: intent.version,
|
|
67309
|
+
userId: intent.userId,
|
|
67310
|
+
walletAddress: intent.walletAddress,
|
|
67311
|
+
allowanceObjectId: intent.allowanceObjectId,
|
|
67312
|
+
featureCode: intent.featureCode,
|
|
67313
|
+
maxAmount: intent.maxAmount,
|
|
67314
|
+
issuedAt: intent.issuedAt,
|
|
67315
|
+
expiresAt: intent.expiresAt,
|
|
67316
|
+
nonce: intent.nonce
|
|
67317
|
+
};
|
|
67318
|
+
const message = canonicalIntentBytes(payload);
|
|
67319
|
+
const signatureBytes = Buffer.from(intent.signature, "hex");
|
|
67320
|
+
try {
|
|
67321
|
+
const publicKey = new Ed25519PublicKey(adminPublicKeyBytes);
|
|
67322
|
+
return await publicKey.verify(message, signatureBytes);
|
|
67323
|
+
} catch {
|
|
67324
|
+
return false;
|
|
67325
|
+
}
|
|
67326
|
+
}
|
|
67327
|
+
function canonicalIntentBytes(payload) {
|
|
67328
|
+
const sorted = Object.fromEntries(
|
|
67329
|
+
Object.entries(payload).sort(([a], [b2]) => a.localeCompare(b2))
|
|
67330
|
+
);
|
|
67331
|
+
return new TextEncoder().encode(JSON.stringify(sorted));
|
|
67332
|
+
}
|
|
67038
67333
|
|
|
67039
67334
|
export {
|
|
67040
67335
|
ZodOptional,
|
|
@@ -67082,9 +67377,13 @@ export {
|
|
|
67082
67377
|
SUPPORTED_ASSETS,
|
|
67083
67378
|
STABLE_ASSETS,
|
|
67084
67379
|
ALL_NAVI_ASSETS,
|
|
67380
|
+
OPERATION_ASSETS,
|
|
67381
|
+
isAllowedAsset,
|
|
67382
|
+
assertAllowedAsset,
|
|
67085
67383
|
DEFAULT_NETWORK,
|
|
67086
67384
|
CETUS_USDC_SUI_POOL,
|
|
67087
67385
|
GAS_RESERVE_MIN,
|
|
67386
|
+
ALLOWANCE_FEATURES,
|
|
67088
67387
|
validateAddress,
|
|
67089
67388
|
truncateAddress,
|
|
67090
67389
|
generateKeypair,
|
|
@@ -67124,9 +67423,23 @@ export {
|
|
|
67124
67423
|
SafeguardEnforcer,
|
|
67125
67424
|
ContactManager,
|
|
67126
67425
|
T2000,
|
|
67426
|
+
buildCreateAllowanceTx,
|
|
67427
|
+
addDepositAllowanceTx,
|
|
67428
|
+
buildDepositAllowanceTx,
|
|
67429
|
+
buildAdminDepositAllowanceTx,
|
|
67430
|
+
buildDeductAllowanceTx,
|
|
67431
|
+
buildWithdrawAllowanceTx,
|
|
67432
|
+
buildWithdrawAmountAllowanceTx,
|
|
67433
|
+
getAllowance,
|
|
67434
|
+
getAllowanceBalance,
|
|
67435
|
+
HF_WARN_THRESHOLD,
|
|
67436
|
+
HF_CRITICAL_THRESHOLD,
|
|
67437
|
+
getFinancialSummary,
|
|
67127
67438
|
simulateTransaction,
|
|
67128
67439
|
throwIfSimulationFailed,
|
|
67129
|
-
getSwapQuote
|
|
67440
|
+
getSwapQuote,
|
|
67441
|
+
buildScopedIntent,
|
|
67442
|
+
verifyScopedIntent
|
|
67130
67443
|
};
|
|
67131
67444
|
/*! Bundled license information:
|
|
67132
67445
|
|
|
@@ -67175,4 +67488,4 @@ axios/dist/node/axios.cjs:
|
|
|
67175
67488
|
@scure/bip39/index.js:
|
|
67176
67489
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
67177
67490
|
*/
|
|
67178
|
-
//# sourceMappingURL=chunk-
|
|
67491
|
+
//# sourceMappingURL=chunk-2JUMTEBB.js.map
|