@t2000/sdk 0.21.15 → 0.22.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 +37 -9
- package/dist/adapters/index.cjs +1 -1
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +89 -4
- package/dist/adapters/index.d.ts +89 -4
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.cjs +791 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +11 -0
- package/dist/browser.d.ts +11 -0
- package/dist/browser.js +38 -23
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +63 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -339
- package/dist/index.d.ts +7 -339
- package/dist/index.js +60 -58
- package/dist/index.js.map +1 -1
- package/dist/token-registry-BBAPkvGS.d.ts +355 -0
- package/dist/token-registry-abuw6uo0.d.cts +355 -0
- package/dist/{index-BwknZes_.d.ts → types-XWEUAS-X.d.cts} +1 -87
- package/dist/{index-HeR6WZTF.d.cts → types-XWEUAS-X.d.ts} +1 -87
- package/package.json +1 -1
package/dist/browser.cjs
ADDED
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@mysten/sui/jsonRpc');
|
|
4
|
+
var utils = require('@mysten/sui/utils');
|
|
5
|
+
|
|
6
|
+
// src/wallet/keypairSigner.ts
|
|
7
|
+
var KeypairSigner = class {
|
|
8
|
+
constructor(keypair) {
|
|
9
|
+
this.keypair = keypair;
|
|
10
|
+
}
|
|
11
|
+
getAddress() {
|
|
12
|
+
return this.keypair.getPublicKey().toSuiAddress();
|
|
13
|
+
}
|
|
14
|
+
async signTransaction(txBytes) {
|
|
15
|
+
return this.keypair.signTransaction(txBytes);
|
|
16
|
+
}
|
|
17
|
+
/** Access the underlying keypair for APIs that still require it directly. */
|
|
18
|
+
getKeypair() {
|
|
19
|
+
return this.keypair;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/wallet/zkLoginSigner.ts
|
|
24
|
+
var ZkLoginSigner = class {
|
|
25
|
+
constructor(ephemeralKeypair, zkProof, userAddress, maxEpoch) {
|
|
26
|
+
this.ephemeralKeypair = ephemeralKeypair;
|
|
27
|
+
this.zkProof = zkProof;
|
|
28
|
+
this.userAddress = userAddress;
|
|
29
|
+
this.maxEpoch = maxEpoch;
|
|
30
|
+
}
|
|
31
|
+
getAddress() {
|
|
32
|
+
return this.userAddress;
|
|
33
|
+
}
|
|
34
|
+
async signTransaction(txBytes) {
|
|
35
|
+
const { getZkLoginSignature } = await import('@mysten/zklogin');
|
|
36
|
+
const ephSig = await this.ephemeralKeypair.signTransaction(txBytes);
|
|
37
|
+
return {
|
|
38
|
+
signature: getZkLoginSignature({
|
|
39
|
+
inputs: this.zkProof,
|
|
40
|
+
maxEpoch: this.maxEpoch,
|
|
41
|
+
userSignature: ephSig.signature
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
isExpired(currentEpoch) {
|
|
46
|
+
return currentEpoch >= this.maxEpoch;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/errors.ts
|
|
51
|
+
var T2000Error = class extends Error {
|
|
52
|
+
code;
|
|
53
|
+
data;
|
|
54
|
+
retryable;
|
|
55
|
+
constructor(code, message, data, retryable = false) {
|
|
56
|
+
super(message);
|
|
57
|
+
this.name = "T2000Error";
|
|
58
|
+
this.code = code;
|
|
59
|
+
this.data = data;
|
|
60
|
+
this.retryable = retryable;
|
|
61
|
+
}
|
|
62
|
+
toJSON() {
|
|
63
|
+
return {
|
|
64
|
+
error: this.code,
|
|
65
|
+
message: this.message,
|
|
66
|
+
...this.data && { data: this.data },
|
|
67
|
+
retryable: this.retryable
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function mapWalletError(error) {
|
|
72
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
73
|
+
if (msg.includes("rejected") || msg.includes("cancelled")) {
|
|
74
|
+
return new T2000Error("TRANSACTION_FAILED", "Transaction cancelled");
|
|
75
|
+
}
|
|
76
|
+
if (msg.includes("Insufficient") || msg.includes("insufficient")) {
|
|
77
|
+
return new T2000Error("INSUFFICIENT_BALANCE", "Insufficient balance");
|
|
78
|
+
}
|
|
79
|
+
return new T2000Error("UNKNOWN", msg, void 0, true);
|
|
80
|
+
}
|
|
81
|
+
function mapMoveAbortCode(code) {
|
|
82
|
+
const abortMessages = {
|
|
83
|
+
1: "Protocol is temporarily paused",
|
|
84
|
+
2: "Amount must be greater than zero",
|
|
85
|
+
3: "Invalid operation type",
|
|
86
|
+
4: "Fee rate exceeds maximum",
|
|
87
|
+
5: "Insufficient treasury balance",
|
|
88
|
+
6: "Not authorized",
|
|
89
|
+
7: "Package version mismatch \u2014 upgrade required",
|
|
90
|
+
8: "Timelock is active \u2014 wait for expiry",
|
|
91
|
+
9: "No pending change to execute",
|
|
92
|
+
10: "Already at current version",
|
|
93
|
+
// NAVI Protocol abort codes
|
|
94
|
+
1502: "Oracle price is stale \u2014 try again in a moment",
|
|
95
|
+
1503: 'Withdrawal amount is invalid (zero or dust) \u2014 try a specific amount instead of "all"',
|
|
96
|
+
1600: "Health factor too low \u2014 withdrawal would risk liquidation",
|
|
97
|
+
1605: "Asset borrowing is disabled or at capacity on this protocol",
|
|
98
|
+
// NAVI utils abort codes
|
|
99
|
+
46e3: "Insufficient balance to repay \u2014 withdraw some savings first to get cash"
|
|
100
|
+
};
|
|
101
|
+
return abortMessages[code] ?? `Move abort code: ${code}`;
|
|
102
|
+
}
|
|
103
|
+
function isMoveAbort(msg) {
|
|
104
|
+
return msg.includes("MoveAbort") || msg.includes("MovePrimitiveRuntimeError");
|
|
105
|
+
}
|
|
106
|
+
function parseMoveAbortMessage(msg) {
|
|
107
|
+
const abortMatch = msg.match(/abort code:\s*(\d+)/i) ?? msg.match(/MoveAbort[^,]*,\s*(\d+)/);
|
|
108
|
+
if (abortMatch) {
|
|
109
|
+
const code = parseInt(abortMatch[1], 10);
|
|
110
|
+
const moduleMatch = msg.match(/Identifier\("([^"]+)"\)/) ?? msg.match(/in '([^']+)'/);
|
|
111
|
+
const fnMatch = msg.match(/function_name:\s*Some\("([^"]+)"\)/);
|
|
112
|
+
const context = `${moduleMatch?.[1] ?? ""}${fnMatch ? `::${fnMatch[1]}` : ""}`.toLowerCase();
|
|
113
|
+
const suffix = moduleMatch ? ` [${moduleMatch[1]}${fnMatch ? `::${fnMatch[1]}` : ""}]` : "";
|
|
114
|
+
if (context.includes("slippage")) {
|
|
115
|
+
return `Slippage too high \u2014 price moved during execution${suffix}`;
|
|
116
|
+
}
|
|
117
|
+
if (context.includes("balance::split") || context.includes("balance::ENotEnough")) {
|
|
118
|
+
return `Insufficient on-chain balance${suffix}`;
|
|
119
|
+
}
|
|
120
|
+
const mapped = mapMoveAbortCode(code);
|
|
121
|
+
return `${mapped}${suffix}`;
|
|
122
|
+
}
|
|
123
|
+
return msg;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/constants.ts
|
|
127
|
+
var MIST_PER_SUI = 1000000000n;
|
|
128
|
+
var SUI_DECIMALS = 9;
|
|
129
|
+
var USDC_DECIMALS = 6;
|
|
130
|
+
var BPS_DENOMINATOR = 10000n;
|
|
131
|
+
var AUTO_TOPUP_THRESHOLD = 50000000n;
|
|
132
|
+
var GAS_RESERVE_TARGET = 150000000n;
|
|
133
|
+
var AUTO_TOPUP_MIN_USDC = 2000000n;
|
|
134
|
+
var SAVE_FEE_BPS = 10n;
|
|
135
|
+
var BORROW_FEE_BPS = 5n;
|
|
136
|
+
var CLOCK_ID = "0x6";
|
|
137
|
+
var SUPPORTED_ASSETS = {
|
|
138
|
+
USDC: {
|
|
139
|
+
type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
140
|
+
decimals: 6,
|
|
141
|
+
symbol: "USDC",
|
|
142
|
+
displayName: "USDC"
|
|
143
|
+
},
|
|
144
|
+
USDT: {
|
|
145
|
+
type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
146
|
+
decimals: 6,
|
|
147
|
+
symbol: "USDT",
|
|
148
|
+
displayName: "suiUSDT"
|
|
149
|
+
},
|
|
150
|
+
USDe: {
|
|
151
|
+
type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE",
|
|
152
|
+
decimals: 6,
|
|
153
|
+
symbol: "USDe",
|
|
154
|
+
displayName: "suiUSDe"
|
|
155
|
+
},
|
|
156
|
+
USDsui: {
|
|
157
|
+
type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI",
|
|
158
|
+
decimals: 6,
|
|
159
|
+
symbol: "USDsui",
|
|
160
|
+
displayName: "USDsui"
|
|
161
|
+
},
|
|
162
|
+
SUI: {
|
|
163
|
+
type: "0x2::sui::SUI",
|
|
164
|
+
decimals: 9,
|
|
165
|
+
symbol: "SUI",
|
|
166
|
+
displayName: "SUI"
|
|
167
|
+
},
|
|
168
|
+
WAL: {
|
|
169
|
+
type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL",
|
|
170
|
+
decimals: 9,
|
|
171
|
+
symbol: "WAL",
|
|
172
|
+
displayName: "WAL"
|
|
173
|
+
},
|
|
174
|
+
ETH: {
|
|
175
|
+
type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH",
|
|
176
|
+
decimals: 8,
|
|
177
|
+
symbol: "ETH",
|
|
178
|
+
displayName: "suiETH"
|
|
179
|
+
},
|
|
180
|
+
NAVX: {
|
|
181
|
+
type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
|
|
182
|
+
decimals: 9,
|
|
183
|
+
symbol: "NAVX",
|
|
184
|
+
displayName: "NAVX"
|
|
185
|
+
},
|
|
186
|
+
GOLD: {
|
|
187
|
+
type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM",
|
|
188
|
+
decimals: 6,
|
|
189
|
+
symbol: "GOLD",
|
|
190
|
+
displayName: "XAUM"
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var STABLE_ASSETS = ["USDC"];
|
|
194
|
+
var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
|
|
195
|
+
var T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? "0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3";
|
|
196
|
+
var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a";
|
|
197
|
+
var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
|
|
198
|
+
var DEFAULT_NETWORK = "mainnet";
|
|
199
|
+
var API_BASE_URL = process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
200
|
+
var GAS_RESERVE_MIN = 0.05;
|
|
201
|
+
|
|
202
|
+
// src/gas/autoTopUp.ts
|
|
203
|
+
async function shouldAutoTopUp(client, address) {
|
|
204
|
+
const [suiBalance, usdcBalance] = await Promise.all([
|
|
205
|
+
client.getBalance({ owner: address, coinType: SUPPORTED_ASSETS.SUI.type }),
|
|
206
|
+
client.getBalance({ owner: address, coinType: SUPPORTED_ASSETS.USDC.type })
|
|
207
|
+
]);
|
|
208
|
+
const suiRaw = BigInt(suiBalance.totalBalance);
|
|
209
|
+
const usdcRaw = BigInt(usdcBalance.totalBalance);
|
|
210
|
+
if (suiRaw < GAS_RESERVE_TARGET && usdcRaw >= AUTO_TOPUP_MIN_USDC) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
async function executeAutoTopUp(_client, _signer) {
|
|
216
|
+
return { success: false, tx: "", usdcSpent: 0, suiReceived: 0 };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/utils/base64.ts
|
|
220
|
+
function toBase64(bytes) {
|
|
221
|
+
let binary = "";
|
|
222
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
223
|
+
return btoa(binary);
|
|
224
|
+
}
|
|
225
|
+
function fromBase64(b64) {
|
|
226
|
+
const binary = atob(b64);
|
|
227
|
+
const bytes = new Uint8Array(binary.length);
|
|
228
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
229
|
+
return bytes;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/gas/gasStation.ts
|
|
233
|
+
async function requestGasSponsorship(txJson, sender, type, txBcsBytes) {
|
|
234
|
+
const payload = { sender, type };
|
|
235
|
+
if (txBcsBytes) {
|
|
236
|
+
payload.txBcsBytes = txBcsBytes;
|
|
237
|
+
} else {
|
|
238
|
+
payload.txJson = txJson;
|
|
239
|
+
payload.txBytes = toBase64(new TextEncoder().encode(txJson));
|
|
240
|
+
}
|
|
241
|
+
const res = await fetch(`${API_BASE_URL}/api/gas`, {
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers: { "Content-Type": "application/json" },
|
|
244
|
+
body: JSON.stringify(payload)
|
|
245
|
+
});
|
|
246
|
+
const data = await res.json();
|
|
247
|
+
if (!res.ok) {
|
|
248
|
+
const errorCode = data.error;
|
|
249
|
+
if (errorCode === "CIRCUIT_BREAKER" || errorCode === "POOL_DEPLETED" || errorCode === "PRICE_STALE") {
|
|
250
|
+
throw new T2000Error(
|
|
251
|
+
"GAS_STATION_UNAVAILABLE",
|
|
252
|
+
data.message ?? "Gas station temporarily unavailable",
|
|
253
|
+
{ retryAfter: data.retryAfter, reason: errorCode },
|
|
254
|
+
true
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
if (errorCode === "GAS_FEE_EXCEEDED") {
|
|
258
|
+
throw new T2000Error(
|
|
259
|
+
"GAS_FEE_EXCEEDED",
|
|
260
|
+
data.message ?? "Gas fee exceeds ceiling",
|
|
261
|
+
{ retryAfter: data.retryAfter },
|
|
262
|
+
true
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
throw new T2000Error(
|
|
266
|
+
"GAS_STATION_UNAVAILABLE",
|
|
267
|
+
data.message ?? "Gas sponsorship request failed",
|
|
268
|
+
{ reason: errorCode },
|
|
269
|
+
true
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return data;
|
|
273
|
+
}
|
|
274
|
+
async function reportGasUsage(sender, txDigest, gasCostSui, usdcCharged, type) {
|
|
275
|
+
try {
|
|
276
|
+
await fetch(`${API_BASE_URL}/api/gas/report`, {
|
|
277
|
+
method: "POST",
|
|
278
|
+
headers: { "Content-Type": "application/json" },
|
|
279
|
+
body: JSON.stringify({ sender, txDigest, gasCostSui, usdcCharged, type })
|
|
280
|
+
});
|
|
281
|
+
} catch {
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
async function getGasStatus(address) {
|
|
285
|
+
const url = new URL(`${API_BASE_URL}/api/gas/status`);
|
|
286
|
+
if (address) url.searchParams.set("address", address);
|
|
287
|
+
const res = await fetch(url.toString());
|
|
288
|
+
if (!res.ok) {
|
|
289
|
+
throw new T2000Error("GAS_STATION_UNAVAILABLE", "Failed to fetch gas status", void 0, true);
|
|
290
|
+
}
|
|
291
|
+
return await res.json();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/gas/manager.ts
|
|
295
|
+
function extractGasCost(effects) {
|
|
296
|
+
if (!effects?.gasUsed) return 0;
|
|
297
|
+
return (Number(effects.gasUsed.computationCost) + Number(effects.gasUsed.storageCost) - Number(effects.gasUsed.storageRebate)) / 1e9;
|
|
298
|
+
}
|
|
299
|
+
async function getSuiBalance(client, address) {
|
|
300
|
+
const bal = await client.getBalance({ owner: address, coinType: SUPPORTED_ASSETS.SUI.type });
|
|
301
|
+
return BigInt(bal.totalBalance);
|
|
302
|
+
}
|
|
303
|
+
async function assertTxSuccess(effects, digest) {
|
|
304
|
+
const eff = effects;
|
|
305
|
+
if (eff?.status?.status === "failure") {
|
|
306
|
+
const errMsg = eff.status.error ?? "unknown on-chain error";
|
|
307
|
+
if (isMoveAbort(errMsg)) {
|
|
308
|
+
throw new T2000Error("TRANSACTION_FAILED", parseMoveAbortMessage(errMsg));
|
|
309
|
+
}
|
|
310
|
+
throw new T2000Error("TRANSACTION_FAILED", `Transaction ${digest} failed on-chain: ${errMsg}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async function trySelfFunded(client, signer, tx) {
|
|
314
|
+
const address = signer.getAddress();
|
|
315
|
+
const suiBalance = await getSuiBalance(client, address);
|
|
316
|
+
if (suiBalance < AUTO_TOPUP_THRESHOLD) return null;
|
|
317
|
+
tx.setSender(address);
|
|
318
|
+
const builtBytes = await tx.build({ client });
|
|
319
|
+
const { signature } = await signer.signTransaction(builtBytes);
|
|
320
|
+
const result = await client.executeTransactionBlock({
|
|
321
|
+
transactionBlock: toBase64(builtBytes),
|
|
322
|
+
signature: [signature],
|
|
323
|
+
options: { showEffects: true, showBalanceChanges: true }
|
|
324
|
+
});
|
|
325
|
+
await client.waitForTransaction({ digest: result.digest });
|
|
326
|
+
await assertTxSuccess(result.effects, result.digest);
|
|
327
|
+
return {
|
|
328
|
+
digest: result.digest,
|
|
329
|
+
effects: result.effects,
|
|
330
|
+
balanceChanges: result.balanceChanges,
|
|
331
|
+
gasMethod: "self-funded",
|
|
332
|
+
gasCostSui: extractGasCost(result.effects),
|
|
333
|
+
preTxSuiMist: suiBalance
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
async function tryAutoTopUpThenSelfFund(client, signer, buildTx) {
|
|
337
|
+
const address = signer.getAddress();
|
|
338
|
+
const canTopUp = await shouldAutoTopUp(client, address);
|
|
339
|
+
if (!canTopUp) return null;
|
|
340
|
+
await executeAutoTopUp();
|
|
341
|
+
const tx = await buildTx();
|
|
342
|
+
tx.setSender(address);
|
|
343
|
+
const suiAfterTopUp = await getSuiBalance(client, address);
|
|
344
|
+
const builtBytes = await tx.build({ client });
|
|
345
|
+
const { signature } = await signer.signTransaction(builtBytes);
|
|
346
|
+
const result = await client.executeTransactionBlock({
|
|
347
|
+
transactionBlock: toBase64(builtBytes),
|
|
348
|
+
signature: [signature],
|
|
349
|
+
options: { showEffects: true, showBalanceChanges: true }
|
|
350
|
+
});
|
|
351
|
+
await client.waitForTransaction({ digest: result.digest });
|
|
352
|
+
await assertTxSuccess(result.effects, result.digest);
|
|
353
|
+
return {
|
|
354
|
+
digest: result.digest,
|
|
355
|
+
effects: result.effects,
|
|
356
|
+
balanceChanges: result.balanceChanges,
|
|
357
|
+
gasMethod: "auto-topup",
|
|
358
|
+
gasCostSui: extractGasCost(result.effects),
|
|
359
|
+
preTxSuiMist: suiAfterTopUp
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
async function trySponsored(client, signer, tx) {
|
|
363
|
+
const address = signer.getAddress();
|
|
364
|
+
const suiBalance = await getSuiBalance(client, address);
|
|
365
|
+
tx.setSender(address);
|
|
366
|
+
let txJson;
|
|
367
|
+
let txBcsBase64;
|
|
368
|
+
try {
|
|
369
|
+
txJson = tx.serialize();
|
|
370
|
+
} catch {
|
|
371
|
+
const bcsBytes = await tx.build({ client });
|
|
372
|
+
txBcsBase64 = toBase64(bcsBytes);
|
|
373
|
+
}
|
|
374
|
+
const sponsoredResult = await requestGasSponsorship(txJson ?? "", address, void 0, txBcsBase64);
|
|
375
|
+
const sponsoredTxBytes = fromBase64(sponsoredResult.txBytes);
|
|
376
|
+
const { signature: agentSig } = await signer.signTransaction(sponsoredTxBytes);
|
|
377
|
+
const result = await client.executeTransactionBlock({
|
|
378
|
+
transactionBlock: sponsoredResult.txBytes,
|
|
379
|
+
signature: [agentSig, sponsoredResult.sponsorSignature],
|
|
380
|
+
options: { showEffects: true, showBalanceChanges: true }
|
|
381
|
+
});
|
|
382
|
+
await client.waitForTransaction({ digest: result.digest });
|
|
383
|
+
await assertTxSuccess(result.effects, result.digest);
|
|
384
|
+
const gasCost = extractGasCost(result.effects);
|
|
385
|
+
reportGasUsage(address, result.digest, gasCost, 0, sponsoredResult.type);
|
|
386
|
+
return {
|
|
387
|
+
digest: result.digest,
|
|
388
|
+
effects: result.effects,
|
|
389
|
+
balanceChanges: result.balanceChanges,
|
|
390
|
+
gasMethod: "sponsored",
|
|
391
|
+
gasCostSui: gasCost,
|
|
392
|
+
preTxSuiMist: suiBalance
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
async function waitForIndexer(client, digest) {
|
|
396
|
+
for (let i = 0; i < 3; i++) {
|
|
397
|
+
try {
|
|
398
|
+
await client.getTransactionBlock({ digest, options: { showObjectChanges: true } });
|
|
399
|
+
return;
|
|
400
|
+
} catch {
|
|
401
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
async function executeWithGas(client, signer, buildTx, options) {
|
|
406
|
+
if (options?.enforcer && options?.metadata) {
|
|
407
|
+
options.enforcer.check(options.metadata);
|
|
408
|
+
}
|
|
409
|
+
const result = await resolveGas(client, signer, buildTx);
|
|
410
|
+
try {
|
|
411
|
+
if (result.preTxSuiMist !== void 0) {
|
|
412
|
+
const gasCostMist = result.gasMethod === "sponsored" ? 0n : BigInt(Math.round(result.gasCostSui * 1e9));
|
|
413
|
+
const estimatedRemaining = result.preTxSuiMist - gasCostMist;
|
|
414
|
+
if (estimatedRemaining < GAS_RESERVE_TARGET) {
|
|
415
|
+
const address = signer.getAddress();
|
|
416
|
+
const usdcBal = await client.getBalance({
|
|
417
|
+
owner: address,
|
|
418
|
+
coinType: SUPPORTED_ASSETS.USDC.type
|
|
419
|
+
});
|
|
420
|
+
if (BigInt(usdcBal.totalBalance) >= AUTO_TOPUP_MIN_USDC) {
|
|
421
|
+
await executeAutoTopUp(client, signer);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
} catch {
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
429
|
+
var GAS_RESOLUTION_CODES = /* @__PURE__ */ new Set([
|
|
430
|
+
"INSUFFICIENT_GAS",
|
|
431
|
+
"GAS_STATION_UNAVAILABLE",
|
|
432
|
+
"GAS_FEE_EXCEEDED",
|
|
433
|
+
"AUTO_TOPUP_FAILED",
|
|
434
|
+
"SPONSOR_UNAVAILABLE"
|
|
435
|
+
]);
|
|
436
|
+
function isBuildError(err) {
|
|
437
|
+
return err instanceof T2000Error && !GAS_RESOLUTION_CODES.has(err.code);
|
|
438
|
+
}
|
|
439
|
+
async function resolveGas(client, signer, buildTx) {
|
|
440
|
+
const errors = [];
|
|
441
|
+
let lastBuildError;
|
|
442
|
+
try {
|
|
443
|
+
const tx = await buildTx();
|
|
444
|
+
const result = await trySelfFunded(client, signer, tx);
|
|
445
|
+
if (result) {
|
|
446
|
+
await waitForIndexer(client, result.digest);
|
|
447
|
+
return result;
|
|
448
|
+
}
|
|
449
|
+
errors.push("self-funded: SUI below threshold");
|
|
450
|
+
} catch (err) {
|
|
451
|
+
if (err instanceof T2000Error && err.code === "TRANSACTION_FAILED") throw err;
|
|
452
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
453
|
+
if (isMoveAbort(msg)) {
|
|
454
|
+
throw new T2000Error("TRANSACTION_FAILED", parseMoveAbortMessage(msg));
|
|
455
|
+
}
|
|
456
|
+
if (isBuildError(err)) lastBuildError = err;
|
|
457
|
+
errors.push(`self-funded: ${msg}`);
|
|
458
|
+
}
|
|
459
|
+
try {
|
|
460
|
+
const result = await tryAutoTopUpThenSelfFund(client, signer, buildTx);
|
|
461
|
+
if (result) {
|
|
462
|
+
await waitForIndexer(client, result.digest);
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
errors.push("auto-topup: not eligible (low USDC or sufficient SUI)");
|
|
466
|
+
} catch (err) {
|
|
467
|
+
if (err instanceof T2000Error && err.code === "TRANSACTION_FAILED") throw err;
|
|
468
|
+
errors.push(`auto-topup: ${err instanceof Error ? err.message : String(err)}`);
|
|
469
|
+
}
|
|
470
|
+
try {
|
|
471
|
+
const tx = await buildTx();
|
|
472
|
+
const result = await trySelfFunded(client, signer, tx);
|
|
473
|
+
if (result) {
|
|
474
|
+
await waitForIndexer(client, result.digest);
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
} catch (err) {
|
|
478
|
+
if (err instanceof T2000Error && err.code === "TRANSACTION_FAILED") throw err;
|
|
479
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
480
|
+
if (isMoveAbort(msg)) {
|
|
481
|
+
throw new T2000Error("TRANSACTION_FAILED", parseMoveAbortMessage(msg));
|
|
482
|
+
}
|
|
483
|
+
if (isBuildError(err)) lastBuildError = err;
|
|
484
|
+
errors.push(`self-funded-retry: ${msg}`);
|
|
485
|
+
}
|
|
486
|
+
try {
|
|
487
|
+
const tx = await buildTx();
|
|
488
|
+
const result = await trySponsored(client, signer, tx);
|
|
489
|
+
if (result) {
|
|
490
|
+
await waitForIndexer(client, result.digest);
|
|
491
|
+
return result;
|
|
492
|
+
}
|
|
493
|
+
errors.push("sponsored: returned null");
|
|
494
|
+
} catch (err) {
|
|
495
|
+
if (err instanceof T2000Error && err.code === "TRANSACTION_FAILED") throw err;
|
|
496
|
+
if (isBuildError(err)) lastBuildError = err;
|
|
497
|
+
errors.push(`sponsored: ${err instanceof Error ? err.message : String(err)}`);
|
|
498
|
+
}
|
|
499
|
+
if (lastBuildError) throw lastBuildError;
|
|
500
|
+
throw new T2000Error(
|
|
501
|
+
"INSUFFICIENT_GAS",
|
|
502
|
+
`No SUI for gas and sponsorship unavailable. Fund your wallet with SUI or USDC. [${errors.join(" | ")}]`,
|
|
503
|
+
{ reason: "all_gas_methods_exhausted", errors }
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
function validateAddress(address) {
|
|
507
|
+
const normalized = utils.normalizeSuiAddress(address);
|
|
508
|
+
if (!utils.isValidSuiAddress(normalized)) {
|
|
509
|
+
throw new T2000Error("INVALID_ADDRESS", `Invalid Sui address: ${address}`);
|
|
510
|
+
}
|
|
511
|
+
return normalized;
|
|
512
|
+
}
|
|
513
|
+
function truncateAddress(address) {
|
|
514
|
+
if (address.length <= 10) return address;
|
|
515
|
+
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/utils/format.ts
|
|
519
|
+
function mistToSui(mist) {
|
|
520
|
+
return Number(mist) / Number(MIST_PER_SUI);
|
|
521
|
+
}
|
|
522
|
+
function suiToMist(sui) {
|
|
523
|
+
return BigInt(Math.round(sui * Number(MIST_PER_SUI)));
|
|
524
|
+
}
|
|
525
|
+
function usdcToRaw(amount) {
|
|
526
|
+
return BigInt(Math.round(amount * 10 ** USDC_DECIMALS));
|
|
527
|
+
}
|
|
528
|
+
function rawToUsdc(raw) {
|
|
529
|
+
return Number(raw) / 10 ** USDC_DECIMALS;
|
|
530
|
+
}
|
|
531
|
+
function stableToRaw(amount, decimals) {
|
|
532
|
+
return BigInt(Math.round(amount * 10 ** decimals));
|
|
533
|
+
}
|
|
534
|
+
function rawToStable(raw, decimals) {
|
|
535
|
+
return Number(raw) / 10 ** decimals;
|
|
536
|
+
}
|
|
537
|
+
function getDecimals(asset) {
|
|
538
|
+
return SUPPORTED_ASSETS[asset].decimals;
|
|
539
|
+
}
|
|
540
|
+
function formatUsd(amount) {
|
|
541
|
+
return `$${amount.toFixed(2)}`;
|
|
542
|
+
}
|
|
543
|
+
function formatSui(amount) {
|
|
544
|
+
if (amount < 1e-3) return `${amount.toFixed(6)} SUI`;
|
|
545
|
+
return `${amount.toFixed(3)} SUI`;
|
|
546
|
+
}
|
|
547
|
+
function formatAssetAmount(amount, asset) {
|
|
548
|
+
if (asset === "BTC") return amount.toFixed(8);
|
|
549
|
+
if (asset === "GOLD") return amount.toFixed(6);
|
|
550
|
+
if (asset === "ETH") return amount.toFixed(6);
|
|
551
|
+
return amount.toFixed(4);
|
|
552
|
+
}
|
|
553
|
+
var ASSET_LOOKUP = /* @__PURE__ */ new Map();
|
|
554
|
+
for (const [key, info] of Object.entries(SUPPORTED_ASSETS)) {
|
|
555
|
+
ASSET_LOOKUP.set(key.toUpperCase(), key);
|
|
556
|
+
if (info.displayName && info.displayName.toUpperCase() !== key.toUpperCase()) {
|
|
557
|
+
ASSET_LOOKUP.set(info.displayName.toUpperCase(), key);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/protocols/protocolFee.ts
|
|
562
|
+
var FEE_RATES = {
|
|
563
|
+
save: SAVE_FEE_BPS,
|
|
564
|
+
borrow: BORROW_FEE_BPS
|
|
565
|
+
};
|
|
566
|
+
var OP_CODES = {
|
|
567
|
+
save: 0,
|
|
568
|
+
borrow: 2
|
|
569
|
+
};
|
|
570
|
+
function calculateFee(operation, amount) {
|
|
571
|
+
const bps = FEE_RATES[operation];
|
|
572
|
+
const feeAmount = amount * Number(bps) / Number(BPS_DENOMINATOR);
|
|
573
|
+
const rawAmount = usdcToRaw(feeAmount);
|
|
574
|
+
return {
|
|
575
|
+
amount: feeAmount,
|
|
576
|
+
asset: "USDC",
|
|
577
|
+
rate: Number(bps) / Number(BPS_DENOMINATOR),
|
|
578
|
+
rawAmount
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function addCollectFeeToTx(tx, paymentCoin, operation) {
|
|
582
|
+
const bps = FEE_RATES[operation];
|
|
583
|
+
if (bps <= 0n) return;
|
|
584
|
+
tx.moveCall({
|
|
585
|
+
target: `${T2000_PACKAGE_ID}::treasury::collect_fee`,
|
|
586
|
+
typeArguments: [SUPPORTED_ASSETS.USDC.type],
|
|
587
|
+
arguments: [
|
|
588
|
+
tx.object(T2000_TREASURY_ID),
|
|
589
|
+
tx.object(T2000_CONFIG_ID),
|
|
590
|
+
paymentCoin,
|
|
591
|
+
tx.pure.u8(OP_CODES[operation])
|
|
592
|
+
]
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// src/safeguards/errors.ts
|
|
597
|
+
var SafeguardError = class extends T2000Error {
|
|
598
|
+
rule;
|
|
599
|
+
details;
|
|
600
|
+
constructor(rule, details, message) {
|
|
601
|
+
const msg = message ?? buildMessage(rule, details);
|
|
602
|
+
super("SAFEGUARD_BLOCKED", msg, { rule, ...details });
|
|
603
|
+
this.name = "SafeguardError";
|
|
604
|
+
this.rule = rule;
|
|
605
|
+
this.details = details;
|
|
606
|
+
}
|
|
607
|
+
toJSON() {
|
|
608
|
+
return {
|
|
609
|
+
error: "SAFEGUARD_BLOCKED",
|
|
610
|
+
message: this.message,
|
|
611
|
+
retryable: this.retryable,
|
|
612
|
+
data: { rule: this.rule, ...this.details }
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
function buildMessage(rule, details) {
|
|
617
|
+
switch (rule) {
|
|
618
|
+
case "locked":
|
|
619
|
+
return "Agent is locked. All operations are frozen.";
|
|
620
|
+
case "maxPerTx":
|
|
621
|
+
return `Amount $${(details.attempted ?? 0).toFixed(2)} exceeds per-transaction limit ($${(details.limit ?? 0).toFixed(2)})`;
|
|
622
|
+
case "maxDailySend":
|
|
623
|
+
return `Daily send limit reached ($${(details.current ?? 0).toFixed(2)}/$${(details.limit ?? 0).toFixed(2)} used today)`;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/safeguards/types.ts
|
|
628
|
+
var OUTBOUND_OPS = /* @__PURE__ */ new Set([
|
|
629
|
+
"send",
|
|
630
|
+
"pay"
|
|
631
|
+
]);
|
|
632
|
+
var DEFAULT_SAFEGUARD_CONFIG = {
|
|
633
|
+
locked: false,
|
|
634
|
+
maxPerTx: 0,
|
|
635
|
+
maxDailySend: 0,
|
|
636
|
+
dailyUsed: 0,
|
|
637
|
+
dailyResetDate: ""
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// src/token-registry.ts
|
|
641
|
+
var COIN_REGISTRY = {
|
|
642
|
+
// ── Tier 1 — Financial layer ──────────────────────────────────────────
|
|
643
|
+
USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
|
|
644
|
+
// ── Tier 2 — Swap assets (13 tokens) ──────────────────────────────────
|
|
645
|
+
SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
|
|
646
|
+
wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
|
|
647
|
+
ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
|
|
648
|
+
GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 6, symbol: "GOLD", tier: 2 },
|
|
649
|
+
DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
|
|
650
|
+
WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
|
|
651
|
+
NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
|
|
652
|
+
IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
|
|
653
|
+
CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
|
|
654
|
+
NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
|
|
655
|
+
vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
|
|
656
|
+
LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
|
|
657
|
+
MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
|
|
658
|
+
// ── Legacy — no tier, kept for display accuracy on existing positions ──
|
|
659
|
+
USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
|
|
660
|
+
USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
|
|
661
|
+
USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
|
|
662
|
+
};
|
|
663
|
+
var BY_TYPE = /* @__PURE__ */ new Map();
|
|
664
|
+
for (const meta of Object.values(COIN_REGISTRY)) {
|
|
665
|
+
BY_TYPE.set(meta.type, meta);
|
|
666
|
+
}
|
|
667
|
+
function isTier1(coinType) {
|
|
668
|
+
const meta = BY_TYPE.get(coinType);
|
|
669
|
+
return meta?.tier === 1;
|
|
670
|
+
}
|
|
671
|
+
function isTier2(coinType) {
|
|
672
|
+
const meta = BY_TYPE.get(coinType);
|
|
673
|
+
return meta?.tier === 2;
|
|
674
|
+
}
|
|
675
|
+
function isSupported(coinType) {
|
|
676
|
+
const meta = BY_TYPE.get(coinType);
|
|
677
|
+
return meta?.tier !== void 0;
|
|
678
|
+
}
|
|
679
|
+
function getTier(coinType) {
|
|
680
|
+
return BY_TYPE.get(coinType)?.tier;
|
|
681
|
+
}
|
|
682
|
+
function getDecimalsForCoinType(coinType) {
|
|
683
|
+
const direct = BY_TYPE.get(coinType);
|
|
684
|
+
if (direct) return direct.decimals;
|
|
685
|
+
const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
|
|
686
|
+
if (suffix) {
|
|
687
|
+
for (const meta of BY_TYPE.values()) {
|
|
688
|
+
const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
|
|
689
|
+
if (metaSuffix === suffix) return meta.decimals;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
return 9;
|
|
693
|
+
}
|
|
694
|
+
function resolveSymbol(coinType) {
|
|
695
|
+
const direct = BY_TYPE.get(coinType);
|
|
696
|
+
if (direct) return direct.symbol;
|
|
697
|
+
const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
|
|
698
|
+
if (suffix) {
|
|
699
|
+
for (const meta of BY_TYPE.values()) {
|
|
700
|
+
const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
|
|
701
|
+
if (metaSuffix === suffix) return meta.symbol;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return coinType.split("::").pop() ?? coinType;
|
|
705
|
+
}
|
|
706
|
+
var TOKEN_MAP = (() => {
|
|
707
|
+
const map = {};
|
|
708
|
+
for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
|
|
709
|
+
map[name] = meta.type;
|
|
710
|
+
map[name.toUpperCase()] = meta.type;
|
|
711
|
+
}
|
|
712
|
+
return map;
|
|
713
|
+
})();
|
|
714
|
+
function resolveTokenType(nameOrType) {
|
|
715
|
+
if (nameOrType.includes("::")) return nameOrType;
|
|
716
|
+
return TOKEN_MAP[nameOrType] ?? TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
|
|
717
|
+
}
|
|
718
|
+
var SUI_TYPE = COIN_REGISTRY.SUI.type;
|
|
719
|
+
var USDC_TYPE = COIN_REGISTRY.USDC.type;
|
|
720
|
+
var USDT_TYPE = COIN_REGISTRY.USDT.type;
|
|
721
|
+
var USDSUI_TYPE = COIN_REGISTRY.USDSUI.type;
|
|
722
|
+
var USDE_TYPE = COIN_REGISTRY.USDe.type;
|
|
723
|
+
var ETH_TYPE = COIN_REGISTRY.ETH.type;
|
|
724
|
+
var WBTC_TYPE = COIN_REGISTRY.wBTC.type;
|
|
725
|
+
var WAL_TYPE = COIN_REGISTRY.WAL.type;
|
|
726
|
+
var NAVX_TYPE = COIN_REGISTRY.NAVX.type;
|
|
727
|
+
var IKA_TYPE = COIN_REGISTRY.IKA.type;
|
|
728
|
+
var LOFI_TYPE = COIN_REGISTRY.LOFI.type;
|
|
729
|
+
var MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
|
|
730
|
+
|
|
731
|
+
exports.ALL_NAVI_ASSETS = ALL_NAVI_ASSETS;
|
|
732
|
+
exports.BPS_DENOMINATOR = BPS_DENOMINATOR;
|
|
733
|
+
exports.CLOCK_ID = CLOCK_ID;
|
|
734
|
+
exports.COIN_REGISTRY = COIN_REGISTRY;
|
|
735
|
+
exports.DEFAULT_NETWORK = DEFAULT_NETWORK;
|
|
736
|
+
exports.DEFAULT_SAFEGUARD_CONFIG = DEFAULT_SAFEGUARD_CONFIG;
|
|
737
|
+
exports.ETH_TYPE = ETH_TYPE;
|
|
738
|
+
exports.GAS_RESERVE_MIN = GAS_RESERVE_MIN;
|
|
739
|
+
exports.IKA_TYPE = IKA_TYPE;
|
|
740
|
+
exports.KeypairSigner = KeypairSigner;
|
|
741
|
+
exports.LOFI_TYPE = LOFI_TYPE;
|
|
742
|
+
exports.MANIFEST_TYPE = MANIFEST_TYPE;
|
|
743
|
+
exports.MIST_PER_SUI = MIST_PER_SUI;
|
|
744
|
+
exports.NAVX_TYPE = NAVX_TYPE;
|
|
745
|
+
exports.OUTBOUND_OPS = OUTBOUND_OPS;
|
|
746
|
+
exports.STABLE_ASSETS = STABLE_ASSETS;
|
|
747
|
+
exports.SUI_DECIMALS = SUI_DECIMALS;
|
|
748
|
+
exports.SUI_TYPE = SUI_TYPE;
|
|
749
|
+
exports.SUPPORTED_ASSETS = SUPPORTED_ASSETS;
|
|
750
|
+
exports.SafeguardError = SafeguardError;
|
|
751
|
+
exports.T2000Error = T2000Error;
|
|
752
|
+
exports.TOKEN_MAP = TOKEN_MAP;
|
|
753
|
+
exports.USDC_DECIMALS = USDC_DECIMALS;
|
|
754
|
+
exports.USDC_TYPE = USDC_TYPE;
|
|
755
|
+
exports.USDE_TYPE = USDE_TYPE;
|
|
756
|
+
exports.USDSUI_TYPE = USDSUI_TYPE;
|
|
757
|
+
exports.USDT_TYPE = USDT_TYPE;
|
|
758
|
+
exports.WAL_TYPE = WAL_TYPE;
|
|
759
|
+
exports.WBTC_TYPE = WBTC_TYPE;
|
|
760
|
+
exports.ZkLoginSigner = ZkLoginSigner;
|
|
761
|
+
exports.addCollectFeeToTx = addCollectFeeToTx;
|
|
762
|
+
exports.calculateFee = calculateFee;
|
|
763
|
+
exports.executeAutoTopUp = executeAutoTopUp;
|
|
764
|
+
exports.executeWithGas = executeWithGas;
|
|
765
|
+
exports.formatAssetAmount = formatAssetAmount;
|
|
766
|
+
exports.formatSui = formatSui;
|
|
767
|
+
exports.formatUsd = formatUsd;
|
|
768
|
+
exports.fromBase64 = fromBase64;
|
|
769
|
+
exports.getDecimals = getDecimals;
|
|
770
|
+
exports.getDecimalsForCoinType = getDecimalsForCoinType;
|
|
771
|
+
exports.getGasStatus = getGasStatus;
|
|
772
|
+
exports.getTier = getTier;
|
|
773
|
+
exports.isSupported = isSupported;
|
|
774
|
+
exports.isTier1 = isTier1;
|
|
775
|
+
exports.isTier2 = isTier2;
|
|
776
|
+
exports.mapMoveAbortCode = mapMoveAbortCode;
|
|
777
|
+
exports.mapWalletError = mapWalletError;
|
|
778
|
+
exports.mistToSui = mistToSui;
|
|
779
|
+
exports.rawToStable = rawToStable;
|
|
780
|
+
exports.rawToUsdc = rawToUsdc;
|
|
781
|
+
exports.resolveSymbol = resolveSymbol;
|
|
782
|
+
exports.resolveTokenType = resolveTokenType;
|
|
783
|
+
exports.shouldAutoTopUp = shouldAutoTopUp;
|
|
784
|
+
exports.stableToRaw = stableToRaw;
|
|
785
|
+
exports.suiToMist = suiToMist;
|
|
786
|
+
exports.toBase64 = toBase64;
|
|
787
|
+
exports.truncateAddress = truncateAddress;
|
|
788
|
+
exports.usdcToRaw = usdcToRaw;
|
|
789
|
+
exports.validateAddress = validateAddress;
|
|
790
|
+
//# sourceMappingURL=browser.cjs.map
|
|
791
|
+
//# sourceMappingURL=browser.cjs.map
|