@t2000/sdk 0.6.2 → 0.7.1
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 +6 -6
- package/dist/adapters/index.cjs +68 -1
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +2 -1
- package/dist/adapters/index.d.ts +2 -1
- package/dist/adapters/index.js +64 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-DMDq8uxe.d.cts → index-rT0oHn8M.d.cts} +52 -1
- package/dist/{index-DMDq8uxe.d.ts → index-rT0oHn8M.d.ts} +52 -1
- package/dist/index.cjs +113 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -16
- package/dist/index.d.ts +4 -16
- package/dist/index.js +109 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
|
+
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
3
4
|
|
|
4
5
|
type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay' | 'swap';
|
|
6
|
+
/**
|
|
7
|
+
* Describes a protocol for indexer event classification.
|
|
8
|
+
* Each adapter exports one of these so the server can auto-build
|
|
9
|
+
* detection rules without manual sync.
|
|
10
|
+
*
|
|
11
|
+
* To add a new protocol: export a `descriptor` from your adapter file.
|
|
12
|
+
*/
|
|
13
|
+
interface ProtocolDescriptor {
|
|
14
|
+
/** Unique protocol ID — must match the adapter's `id` field */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Human-readable name */
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* On-chain package IDs that identify this protocol's transactions.
|
|
20
|
+
* For protocols with upgradeable packages, list the original/base package.
|
|
21
|
+
*/
|
|
22
|
+
packages: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Maps `module::function` patterns to action types.
|
|
25
|
+
* The indexer matches Move call targets against these patterns.
|
|
26
|
+
* For dynamic package IDs (e.g. NAVI), matching is done on module::function only.
|
|
27
|
+
*/
|
|
28
|
+
actionMap: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* If true, the indexer matches by module::function suffix only,
|
|
31
|
+
* ignoring the package ID prefix. Use for protocols with frequently
|
|
32
|
+
* upgraded (dynamic) package IDs.
|
|
33
|
+
*/
|
|
34
|
+
dynamicPackageId?: boolean;
|
|
35
|
+
}
|
|
5
36
|
interface AdapterTxResult {
|
|
6
37
|
tx: Transaction;
|
|
7
38
|
feeCoin?: TransactionObjectArgument;
|
|
@@ -292,6 +323,7 @@ declare class ProtocolRegistry {
|
|
|
292
323
|
listSwap(): SwapAdapter[];
|
|
293
324
|
}
|
|
294
325
|
|
|
326
|
+
declare const descriptor$3: ProtocolDescriptor;
|
|
295
327
|
declare class NaviAdapter implements LendingAdapter {
|
|
296
328
|
readonly id = "navi";
|
|
297
329
|
readonly name = "NAVI Protocol";
|
|
@@ -319,6 +351,7 @@ declare class NaviAdapter implements LendingAdapter {
|
|
|
319
351
|
maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
|
|
320
352
|
}
|
|
321
353
|
|
|
354
|
+
declare const descriptor$2: ProtocolDescriptor;
|
|
322
355
|
declare class CetusAdapter implements SwapAdapter {
|
|
323
356
|
readonly id = "cetus";
|
|
324
357
|
readonly name = "Cetus";
|
|
@@ -339,6 +372,7 @@ declare class CetusAdapter implements SwapAdapter {
|
|
|
339
372
|
getPoolPrice(): Promise<number>;
|
|
340
373
|
}
|
|
341
374
|
|
|
375
|
+
declare const descriptor$1: ProtocolDescriptor;
|
|
342
376
|
/**
|
|
343
377
|
* Suilend adapter — contract-first, no SDK dependency.
|
|
344
378
|
* Interacts directly with Suilend Move contracts via RPC + PTB moveCall.
|
|
@@ -387,4 +421,21 @@ declare class SuilendAdapter implements LendingAdapter {
|
|
|
387
421
|
private fetchAllCoins;
|
|
388
422
|
}
|
|
389
423
|
|
|
390
|
-
|
|
424
|
+
declare const descriptor: ProtocolDescriptor;
|
|
425
|
+
declare function listSentinels(): Promise<SentinelAgent[]>;
|
|
426
|
+
declare function getSentinelInfo(client: SuiJsonRpcClient, sentinelObjectId: string): Promise<SentinelAgent>;
|
|
427
|
+
declare function requestAttack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelObjectId: string, feeMist: bigint): Promise<{
|
|
428
|
+
attackObjectId: string;
|
|
429
|
+
digest: string;
|
|
430
|
+
}>;
|
|
431
|
+
declare function submitPrompt(agentId: string, attackObjectId: string, prompt: string): Promise<SentinelVerdict>;
|
|
432
|
+
declare function settleAttack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelObjectId: string, attackObjectId: string, prompt: string, verdict: SentinelVerdict): Promise<{
|
|
433
|
+
digest: string;
|
|
434
|
+
success: boolean;
|
|
435
|
+
}>;
|
|
436
|
+
declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelId: string, prompt: string, feeMist?: bigint): Promise<SentinelAttackResult>;
|
|
437
|
+
|
|
438
|
+
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
439
|
+
declare const allDescriptors: ProtocolDescriptor[];
|
|
440
|
+
|
|
441
|
+
export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, attack as I, descriptor as J, settleAttack as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, submitPrompt as O, type PositionsResult as P, descriptor$1 as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, type WithdrawResult as W, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type RatesResult as g, type LendingRates as h, type SentinelAgent as i, type SentinelAttackResult as j, type AdapterPositions as k, type AdapterTxResult as l, type GasReserve as m, type HealthInfo as n, type PositionEntry as o, type ProtocolDescriptor as p, ProtocolRegistry as q, type SentinelVerdict as r, SuilendAdapter as s, type SwapQuote as t, allDescriptors as u, descriptor$2 as v, getSentinelInfo as w, listSentinels as x, descriptor$3 as y, requestAttack as z };
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
|
+
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
3
4
|
|
|
4
5
|
type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay' | 'swap';
|
|
6
|
+
/**
|
|
7
|
+
* Describes a protocol for indexer event classification.
|
|
8
|
+
* Each adapter exports one of these so the server can auto-build
|
|
9
|
+
* detection rules without manual sync.
|
|
10
|
+
*
|
|
11
|
+
* To add a new protocol: export a `descriptor` from your adapter file.
|
|
12
|
+
*/
|
|
13
|
+
interface ProtocolDescriptor {
|
|
14
|
+
/** Unique protocol ID — must match the adapter's `id` field */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Human-readable name */
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* On-chain package IDs that identify this protocol's transactions.
|
|
20
|
+
* For protocols with upgradeable packages, list the original/base package.
|
|
21
|
+
*/
|
|
22
|
+
packages: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Maps `module::function` patterns to action types.
|
|
25
|
+
* The indexer matches Move call targets against these patterns.
|
|
26
|
+
* For dynamic package IDs (e.g. NAVI), matching is done on module::function only.
|
|
27
|
+
*/
|
|
28
|
+
actionMap: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* If true, the indexer matches by module::function suffix only,
|
|
31
|
+
* ignoring the package ID prefix. Use for protocols with frequently
|
|
32
|
+
* upgraded (dynamic) package IDs.
|
|
33
|
+
*/
|
|
34
|
+
dynamicPackageId?: boolean;
|
|
35
|
+
}
|
|
5
36
|
interface AdapterTxResult {
|
|
6
37
|
tx: Transaction;
|
|
7
38
|
feeCoin?: TransactionObjectArgument;
|
|
@@ -292,6 +323,7 @@ declare class ProtocolRegistry {
|
|
|
292
323
|
listSwap(): SwapAdapter[];
|
|
293
324
|
}
|
|
294
325
|
|
|
326
|
+
declare const descriptor$3: ProtocolDescriptor;
|
|
295
327
|
declare class NaviAdapter implements LendingAdapter {
|
|
296
328
|
readonly id = "navi";
|
|
297
329
|
readonly name = "NAVI Protocol";
|
|
@@ -319,6 +351,7 @@ declare class NaviAdapter implements LendingAdapter {
|
|
|
319
351
|
maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
|
|
320
352
|
}
|
|
321
353
|
|
|
354
|
+
declare const descriptor$2: ProtocolDescriptor;
|
|
322
355
|
declare class CetusAdapter implements SwapAdapter {
|
|
323
356
|
readonly id = "cetus";
|
|
324
357
|
readonly name = "Cetus";
|
|
@@ -339,6 +372,7 @@ declare class CetusAdapter implements SwapAdapter {
|
|
|
339
372
|
getPoolPrice(): Promise<number>;
|
|
340
373
|
}
|
|
341
374
|
|
|
375
|
+
declare const descriptor$1: ProtocolDescriptor;
|
|
342
376
|
/**
|
|
343
377
|
* Suilend adapter — contract-first, no SDK dependency.
|
|
344
378
|
* Interacts directly with Suilend Move contracts via RPC + PTB moveCall.
|
|
@@ -387,4 +421,21 @@ declare class SuilendAdapter implements LendingAdapter {
|
|
|
387
421
|
private fetchAllCoins;
|
|
388
422
|
}
|
|
389
423
|
|
|
390
|
-
|
|
424
|
+
declare const descriptor: ProtocolDescriptor;
|
|
425
|
+
declare function listSentinels(): Promise<SentinelAgent[]>;
|
|
426
|
+
declare function getSentinelInfo(client: SuiJsonRpcClient, sentinelObjectId: string): Promise<SentinelAgent>;
|
|
427
|
+
declare function requestAttack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelObjectId: string, feeMist: bigint): Promise<{
|
|
428
|
+
attackObjectId: string;
|
|
429
|
+
digest: string;
|
|
430
|
+
}>;
|
|
431
|
+
declare function submitPrompt(agentId: string, attackObjectId: string, prompt: string): Promise<SentinelVerdict>;
|
|
432
|
+
declare function settleAttack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelObjectId: string, attackObjectId: string, prompt: string, verdict: SentinelVerdict): Promise<{
|
|
433
|
+
digest: string;
|
|
434
|
+
success: boolean;
|
|
435
|
+
}>;
|
|
436
|
+
declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelId: string, prompt: string, feeMist?: bigint): Promise<SentinelAttackResult>;
|
|
437
|
+
|
|
438
|
+
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
439
|
+
declare const allDescriptors: ProtocolDescriptor[];
|
|
440
|
+
|
|
441
|
+
export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, attack as I, descriptor as J, settleAttack as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, submitPrompt as O, type PositionsResult as P, descriptor$1 as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, type WithdrawResult as W, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type RatesResult as g, type LendingRates as h, type SentinelAgent as i, type SentinelAttackResult as j, type AdapterPositions as k, type AdapterTxResult as l, type GasReserve as m, type HealthInfo as n, type PositionEntry as o, type ProtocolDescriptor as p, ProtocolRegistry as q, type SentinelVerdict as r, SuilendAdapter as s, type SwapQuote as t, allDescriptors as u, descriptor$2 as v, getSentinelInfo as w, listSentinels as x, descriptor$3 as y, requestAttack as z };
|
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ var DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
|
|
|
47
47
|
var DEFAULT_KEY_PATH = "~/.t2000/wallet.key";
|
|
48
48
|
var API_BASE_URL = process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
49
49
|
var CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
50
|
+
var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
|
|
50
51
|
var SENTINEL = {
|
|
51
52
|
PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7",
|
|
52
53
|
AGENT_REGISTRY: "0xc47564f5f14c12b31e0dfa1a3dc99a6380a1edf8929c28cb0eaa3359c8db36ac",
|
|
@@ -854,6 +855,15 @@ async function getFundStatus(client, keypair) {
|
|
|
854
855
|
projectedMonthly: earnings.dailyEarning * 30
|
|
855
856
|
};
|
|
856
857
|
}
|
|
858
|
+
var descriptor = {
|
|
859
|
+
id: "sentinel",
|
|
860
|
+
name: "Sui Sentinel",
|
|
861
|
+
packages: [SENTINEL.PACKAGE],
|
|
862
|
+
actionMap: {
|
|
863
|
+
"sentinel::request_attack": "sentinel_attack",
|
|
864
|
+
"sentinel::consume_prompt": "sentinel_settle"
|
|
865
|
+
}
|
|
866
|
+
};
|
|
857
867
|
function mapAgent(raw) {
|
|
858
868
|
return {
|
|
859
869
|
id: raw.agent_id,
|
|
@@ -1141,6 +1151,22 @@ var ProtocolRegistry = class {
|
|
|
1141
1151
|
};
|
|
1142
1152
|
|
|
1143
1153
|
// src/adapters/navi.ts
|
|
1154
|
+
var descriptor2 = {
|
|
1155
|
+
id: "navi",
|
|
1156
|
+
name: "NAVI Protocol",
|
|
1157
|
+
packages: [],
|
|
1158
|
+
dynamicPackageId: true,
|
|
1159
|
+
actionMap: {
|
|
1160
|
+
"incentive_v3::entry_deposit": "save",
|
|
1161
|
+
"incentive_v3::deposit": "save",
|
|
1162
|
+
"incentive_v3::withdraw_v2": "withdraw",
|
|
1163
|
+
"incentive_v3::entry_withdraw": "withdraw",
|
|
1164
|
+
"incentive_v3::borrow_v2": "borrow",
|
|
1165
|
+
"incentive_v3::entry_borrow": "borrow",
|
|
1166
|
+
"incentive_v3::entry_repay": "repay",
|
|
1167
|
+
"incentive_v3::repay": "repay"
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1144
1170
|
var NaviAdapter = class {
|
|
1145
1171
|
id = "navi";
|
|
1146
1172
|
name = "NAVI Protocol";
|
|
@@ -1285,6 +1311,18 @@ function fallbackQuote(fromAsset, amount, poolPrice) {
|
|
|
1285
1311
|
}
|
|
1286
1312
|
|
|
1287
1313
|
// src/adapters/cetus.ts
|
|
1314
|
+
var descriptor3 = {
|
|
1315
|
+
id: "cetus",
|
|
1316
|
+
name: "Cetus DEX",
|
|
1317
|
+
packages: [CETUS_PACKAGE],
|
|
1318
|
+
actionMap: {
|
|
1319
|
+
"router::swap": "swap",
|
|
1320
|
+
"router::swap_ab_bc": "swap",
|
|
1321
|
+
"router::swap_ab_cb": "swap",
|
|
1322
|
+
"router::swap_ba_bc": "swap",
|
|
1323
|
+
"router::swap_ba_cb": "swap"
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1288
1326
|
var CetusAdapter = class {
|
|
1289
1327
|
id = "cetus";
|
|
1290
1328
|
name = "Cetus";
|
|
@@ -1338,7 +1376,21 @@ var LENDING_MARKET_ID = "0x84030d26d85eaa7035084a057f2f11f701b7e2e4eda87551becbc
|
|
|
1338
1376
|
var LENDING_MARKET_TYPE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::suilend::MAIN_POOL";
|
|
1339
1377
|
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
1340
1378
|
var UPGRADE_CAP_ID = "0x3d4ef1859c3ee9fc72858f588b56a09da5466e64f8cc4e90a7b3b909fba8a7ae";
|
|
1341
|
-
var FALLBACK_PUBLISHED_AT = "
|
|
1379
|
+
var FALLBACK_PUBLISHED_AT = "0x3d4353f3bd3565329655e6b77bc2abfd31e558b86662ebd078ae453d416bc10f";
|
|
1380
|
+
var descriptor4 = {
|
|
1381
|
+
id: "suilend",
|
|
1382
|
+
name: "Suilend",
|
|
1383
|
+
packages: [SUILEND_PACKAGE],
|
|
1384
|
+
actionMap: {
|
|
1385
|
+
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
1386
|
+
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
1387
|
+
"lending_market::create_obligation": "save",
|
|
1388
|
+
"lending_market::withdraw_ctokens": "withdraw",
|
|
1389
|
+
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
1390
|
+
"lending_market::borrow": "borrow",
|
|
1391
|
+
"lending_market::repay": "repay"
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1342
1394
|
function interpolateRate(utilBreakpoints, aprBreakpoints, utilizationPct) {
|
|
1343
1395
|
if (utilBreakpoints.length === 0) return 0;
|
|
1344
1396
|
if (utilizationPct <= utilBreakpoints[0]) return aprBreakpoints[0];
|
|
@@ -2112,6 +2164,10 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
2112
2164
|
}
|
|
2113
2165
|
} else {
|
|
2114
2166
|
amount = params.amount;
|
|
2167
|
+
const bal = await queryBalance(this.client, this._address);
|
|
2168
|
+
if (amount > bal.available) {
|
|
2169
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient USDC. Available: $${bal.available.toFixed(2)}, requested: $${amount.toFixed(2)}`);
|
|
2170
|
+
}
|
|
2115
2171
|
}
|
|
2116
2172
|
const fee = calculateFee("save", amount);
|
|
2117
2173
|
const saveAmount = amount;
|
|
@@ -2145,6 +2201,9 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
2145
2201
|
if (asset !== "USDC") {
|
|
2146
2202
|
throw new T2000Error("ASSET_NOT_SUPPORTED", `Only USDC is supported for withdraw. Got: ${asset}`);
|
|
2147
2203
|
}
|
|
2204
|
+
if (params.amount === "all" && !params.protocol) {
|
|
2205
|
+
return this.withdrawAllProtocols(asset);
|
|
2206
|
+
}
|
|
2148
2207
|
const adapter = await this.resolveLending(params.protocol, asset, "withdraw");
|
|
2149
2208
|
let amount;
|
|
2150
2209
|
if (params.amount === "all") {
|
|
@@ -2187,6 +2246,46 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
2187
2246
|
gasMethod: gasResult.gasMethod
|
|
2188
2247
|
};
|
|
2189
2248
|
}
|
|
2249
|
+
async withdrawAllProtocols(asset) {
|
|
2250
|
+
const allPositions = await this.registry.allPositions(this._address);
|
|
2251
|
+
const withSupply = allPositions.filter(
|
|
2252
|
+
(p) => p.positions.supplies.some((s) => s.asset === asset && s.amount > 1e-3)
|
|
2253
|
+
);
|
|
2254
|
+
if (withSupply.length === 0) {
|
|
2255
|
+
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw across any protocol");
|
|
2256
|
+
}
|
|
2257
|
+
let totalWithdrawn = 0;
|
|
2258
|
+
let lastDigest = "";
|
|
2259
|
+
let totalGasCost = 0;
|
|
2260
|
+
let lastGasMethod = "self-funded";
|
|
2261
|
+
for (const pos of withSupply) {
|
|
2262
|
+
const adapter = this.registry.getLending(pos.protocolId);
|
|
2263
|
+
if (!adapter) continue;
|
|
2264
|
+
const maxResult = await adapter.maxWithdraw(this._address, asset);
|
|
2265
|
+
if (maxResult.maxAmount <= 1e-3) continue;
|
|
2266
|
+
let effectiveAmount = maxResult.maxAmount;
|
|
2267
|
+
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
2268
|
+
const built = await adapter.buildWithdrawTx(this._address, maxResult.maxAmount, asset);
|
|
2269
|
+
effectiveAmount = built.effectiveAmount;
|
|
2270
|
+
return built.tx;
|
|
2271
|
+
});
|
|
2272
|
+
totalWithdrawn += effectiveAmount;
|
|
2273
|
+
lastDigest = gasResult.digest;
|
|
2274
|
+
totalGasCost += gasResult.gasCostSui;
|
|
2275
|
+
lastGasMethod = gasResult.gasMethod;
|
|
2276
|
+
this.emitBalanceChange("USDC", effectiveAmount, "withdraw", gasResult.digest);
|
|
2277
|
+
}
|
|
2278
|
+
if (totalWithdrawn <= 0) {
|
|
2279
|
+
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw across any protocol");
|
|
2280
|
+
}
|
|
2281
|
+
return {
|
|
2282
|
+
success: true,
|
|
2283
|
+
tx: lastDigest,
|
|
2284
|
+
amount: totalWithdrawn,
|
|
2285
|
+
gasCost: totalGasCost,
|
|
2286
|
+
gasMethod: lastGasMethod
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2190
2289
|
async maxWithdraw() {
|
|
2191
2290
|
const adapter = await this.resolveLending(void 0, "USDC", "withdraw");
|
|
2192
2291
|
return adapter.maxWithdraw(this._address, "USDC");
|
|
@@ -2517,6 +2616,14 @@ function parseMoveAbort(errorStr) {
|
|
|
2517
2616
|
return { reason: errorStr };
|
|
2518
2617
|
}
|
|
2519
2618
|
|
|
2619
|
+
// src/adapters/index.ts
|
|
2620
|
+
var allDescriptors = [
|
|
2621
|
+
descriptor2,
|
|
2622
|
+
descriptor4,
|
|
2623
|
+
descriptor3,
|
|
2624
|
+
descriptor
|
|
2625
|
+
];
|
|
2626
|
+
|
|
2520
2627
|
exports.BPS_DENOMINATOR = BPS_DENOMINATOR;
|
|
2521
2628
|
exports.CLOCK_ID = CLOCK_ID;
|
|
2522
2629
|
exports.CetusAdapter = CetusAdapter;
|
|
@@ -2532,7 +2639,9 @@ exports.T2000 = T2000;
|
|
|
2532
2639
|
exports.T2000Error = T2000Error;
|
|
2533
2640
|
exports.USDC_DECIMALS = USDC_DECIMALS;
|
|
2534
2641
|
exports.addCollectFeeToTx = addCollectFeeToTx;
|
|
2642
|
+
exports.allDescriptors = allDescriptors;
|
|
2535
2643
|
exports.calculateFee = calculateFee;
|
|
2644
|
+
exports.cetusDescriptor = descriptor3;
|
|
2536
2645
|
exports.executeAutoTopUp = executeAutoTopUp;
|
|
2537
2646
|
exports.executeWithGas = executeWithGas;
|
|
2538
2647
|
exports.exportPrivateKey = exportPrivateKey;
|
|
@@ -2551,16 +2660,19 @@ exports.loadKey = loadKey;
|
|
|
2551
2660
|
exports.mapMoveAbortCode = mapMoveAbortCode;
|
|
2552
2661
|
exports.mapWalletError = mapWalletError;
|
|
2553
2662
|
exports.mistToSui = mistToSui;
|
|
2663
|
+
exports.naviDescriptor = descriptor2;
|
|
2554
2664
|
exports.rawToUsdc = rawToUsdc;
|
|
2555
2665
|
exports.requestAttack = requestAttack;
|
|
2556
2666
|
exports.saveKey = saveKey;
|
|
2557
2667
|
exports.sentinelAttack = attack;
|
|
2668
|
+
exports.sentinelDescriptor = descriptor;
|
|
2558
2669
|
exports.settleAttack = settleAttack;
|
|
2559
2670
|
exports.shouldAutoTopUp = shouldAutoTopUp;
|
|
2560
2671
|
exports.simulateTransaction = simulateTransaction;
|
|
2561
2672
|
exports.solveHashcash = solveHashcash;
|
|
2562
2673
|
exports.submitPrompt = submitPrompt;
|
|
2563
2674
|
exports.suiToMist = suiToMist;
|
|
2675
|
+
exports.suilendDescriptor = descriptor4;
|
|
2564
2676
|
exports.throwIfSimulationFailed = throwIfSimulationFailed;
|
|
2565
2677
|
exports.truncateAddress = truncateAddress;
|
|
2566
2678
|
exports.usdcToRaw = usdcToRaw;
|