@t2000/sdk 0.19.21 → 0.19.23

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 CHANGED
@@ -173,14 +173,6 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
173
173
  | `agent.contacts.get(name)` | Get a contact by name | `Contact` |
174
174
  | `agent.contacts.resolve(nameOrAddress)` | Resolve name to address (passthrough if already an address) | `string` |
175
175
 
176
- ### Sentinel Methods
177
-
178
- | Method | Description | Returns |
179
- |--------|-------------|---------|
180
- | `agent.sentinelList()` | List active sentinels with prize pools | `SentinelAgent[]` |
181
- | `agent.sentinelInfo(id)` | Get sentinel details (from API or on-chain) | `SentinelAgent` |
182
- | `agent.sentinelAttack(id, prompt, fee?)` | Full attack flow: request → TEE → settle | `SentinelAttackResult` |
183
-
184
176
  ### Safeguards (Enforcer)
185
177
 
186
178
  | Method | Description | Returns |
@@ -426,7 +418,6 @@ SMOKE=1 pnpm --filter @t2000/sdk test -- src/__smoke__
426
418
  | `suilend.test.ts` | Suilend adapter (rates, positions, health, SDK mocks) |
427
419
  | `t2000.integration.test.ts` | End-to-end flows (save, withdraw, borrow, repay, rebalance, auto-swap) |
428
420
  | `protocolFee.test.ts` | Protocol fee calculation and collection |
429
- | `sentinel.test.ts` | Sentinel attack flow, listing, fee parsing |
430
421
  | `serialization.test.ts` | Transaction JSON serialization roundtrip |
431
422
 
432
423
  ## Protocol Fees
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ // src/constants.ts
4
+ process.env.T2000_PACKAGE_ID ?? "0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3";
5
+ process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a";
6
+ process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
7
+ process.env.T2000_API_URL ?? "https://api.t2000.ai";
8
+ var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
9
+
10
+ // src/adapters/descriptors.ts
11
+ var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
12
+ var naviDescriptor = {
13
+ id: "navi",
14
+ name: "NAVI Protocol",
15
+ packages: [],
16
+ dynamicPackageId: true,
17
+ actionMap: {
18
+ "incentive_v3::entry_deposit": "save",
19
+ "incentive_v3::deposit": "save",
20
+ "incentive_v3::withdraw_v2": "withdraw",
21
+ "incentive_v3::entry_withdraw": "withdraw",
22
+ "incentive_v3::borrow_v2": "borrow",
23
+ "incentive_v3::entry_borrow": "borrow",
24
+ "incentive_v3::entry_repay": "repay",
25
+ "incentive_v3::repay": "repay"
26
+ }
27
+ };
28
+ var suilendDescriptor = {
29
+ id: "suilend",
30
+ name: "Suilend",
31
+ packages: [SUILEND_PACKAGE],
32
+ actionMap: {
33
+ "lending_market::deposit_liquidity_and_mint_ctokens": "save",
34
+ "lending_market::deposit_ctokens_into_obligation": "save",
35
+ "lending_market::create_obligation": "save",
36
+ "lending_market::withdraw_ctokens": "withdraw",
37
+ "lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
38
+ "lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
39
+ "lending_market::fulfill_liquidity_request": "withdraw",
40
+ "lending_market::unstake_sui_from_staker": "withdraw",
41
+ "lending_market::borrow": "borrow",
42
+ "lending_market::repay": "repay"
43
+ }
44
+ };
45
+ var cetusDescriptor = {
46
+ id: "cetus",
47
+ name: "Cetus DEX",
48
+ packages: [CETUS_PACKAGE],
49
+ actionMap: {
50
+ "router::swap": "swap",
51
+ "router::swap_ab_bc": "swap",
52
+ "router::swap_ab_cb": "swap",
53
+ "router::swap_ba_bc": "swap",
54
+ "router::swap_ba_cb": "swap"
55
+ }
56
+ };
57
+ var allDescriptors = [
58
+ naviDescriptor,
59
+ suilendDescriptor,
60
+ cetusDescriptor
61
+ ];
62
+
63
+ exports.allDescriptors = allDescriptors;
64
+ exports.cetusDescriptor = cetusDescriptor;
65
+ exports.naviDescriptor = naviDescriptor;
66
+ exports.suilendDescriptor = suilendDescriptor;
67
+ //# sourceMappingURL=descriptors.cjs.map
68
+ //# sourceMappingURL=descriptors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants.ts","../../src/adapters/descriptors.ts"],"names":[],"mappings":";;;AA6EgC,OAAA,CAAQ,GAAA,CAAI,gBAAA,IAAoB;AACjC,OAAA,CAAQ,GAAA,CAAI,eAAA,IAAmB;AAE7B,OAAA,CAAQ,GAAA,CAAI,iBAAA,IAAqB;AAOtC,OAAA,CAAQ,GAAA,CAAI,aAAA,IAAiB;AAIlD,IAAM,aAAA,GAAgB,oEAAA;;;ACtF7B,IAAM,eAAA,GAAkB,oEAAA;AAEjB,IAAM,cAAA,GAAqC;AAAA,EAChD,EAAA,EAAI,MAAA;AAAA,EACJ,IAAA,EAAM,eAAA;AAAA,EACN,UAAU,EAAC;AAAA,EACX,gBAAA,EAAkB,IAAA;AAAA,EAClB,SAAA,EAAW;AAAA,IACT,6BAAA,EAA+B,MAAA;AAAA,IAC/B,uBAAA,EAAyB,MAAA;AAAA,IACzB,2BAAA,EAA6B,UAAA;AAAA,IAC7B,8BAAA,EAAgC,UAAA;AAAA,IAChC,yBAAA,EAA2B,QAAA;AAAA,IAC3B,4BAAA,EAA8B,QAAA;AAAA,IAC9B,2BAAA,EAA6B,OAAA;AAAA,IAC7B,qBAAA,EAAuB;AAAA;AAE3B;AAEO,IAAM,iBAAA,GAAwC;AAAA,EACnD,EAAA,EAAI,SAAA;AAAA,EACJ,IAAA,EAAM,SAAA;AAAA,EACN,QAAA,EAAU,CAAC,eAAe,CAAA;AAAA,EAC1B,SAAA,EAAW;AAAA,IACT,oDAAA,EAAsD,MAAA;AAAA,IACtD,iDAAA,EAAmD,MAAA;AAAA,IACnD,mCAAA,EAAqC,MAAA;AAAA,IACrC,kCAAA,EAAoC,UAAA;AAAA,IACpC,uDAAA,EAAyD,UAAA;AAAA,IACzD,+DAAA,EAAiE,UAAA;AAAA,IACjE,2CAAA,EAA6C,UAAA;AAAA,IAC7C,yCAAA,EAA2C,UAAA;AAAA,IAC3C,wBAAA,EAA0B,QAAA;AAAA,IAC1B,uBAAA,EAAyB;AAAA;AAE7B;AAEO,IAAM,eAAA,GAAsC;AAAA,EACjD,EAAA,EAAI,OAAA;AAAA,EACJ,IAAA,EAAM,WAAA;AAAA,EACN,QAAA,EAAU,CAAC,aAAa,CAAA;AAAA,EACxB,SAAA,EAAW;AAAA,IACT,cAAA,EAAgB,MAAA;AAAA,IAChB,oBAAA,EAAsB,MAAA;AAAA,IACtB,oBAAA,EAAsB,MAAA;AAAA,IACtB,oBAAA,EAAsB,MAAA;AAAA,IACtB,oBAAA,EAAsB;AAAA;AAE1B;AAEO,IAAM,cAAA,GAAuC;AAAA,EAClD,cAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF","file":"descriptors.cjs","sourcesContent":["export const MIST_PER_SUI = 1_000_000_000n;\nexport const SUI_DECIMALS = 9;\nexport const USDC_DECIMALS = 6;\n\nexport const BPS_DENOMINATOR = 10_000n;\nexport const PRECISION = 1_000_000_000_000_000_000n;\n\nexport const MIN_DEPOSIT = 1_000_000n; // 1 USDC (6 decimals)\nexport const GAS_RESERVE_USDC = 1_000_000n; // $1 USDC reserved for gas\nexport const AUTO_TOPUP_THRESHOLD = 50_000_000n; // 0.05 SUI — minimum to attempt self-funded TX\nexport const GAS_RESERVE_TARGET = 150_000_000n; // 0.15 SUI — proactive top-up target (covers complex TXs)\nexport const AUTO_TOPUP_AMOUNT = 1_000_000n; // $1 USDC worth of SUI\nexport const AUTO_TOPUP_MIN_USDC = 2_000_000n; // $2 USDC minimum to trigger auto-topup\nexport const BOOTSTRAP_LIMIT = 10;\nexport const GAS_FEE_CEILING_USD = 0.05;\n\nexport const SAVE_FEE_BPS = 10n; // 0.1%\nexport const SWAP_FEE_BPS = 0n; // Free — Cetus already charges pool fees\nexport const BORROW_FEE_BPS = 5n; // 0.05%\n\nexport const CLOCK_ID = '0x6';\n\nexport const SUPPORTED_ASSETS = {\n USDC: {\n type: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',\n decimals: 6,\n symbol: 'USDC',\n displayName: 'USDC',\n },\n USDT: {\n type: '0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT',\n decimals: 6,\n symbol: 'USDT',\n displayName: 'suiUSDT',\n },\n USDe: {\n type: '0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE',\n decimals: 6,\n symbol: 'USDe',\n displayName: 'suiUSDe',\n },\n USDsui: {\n type: '0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI',\n decimals: 6,\n symbol: 'USDsui',\n displayName: 'USDsui',\n },\n SUI: {\n type: '0x2::sui::SUI',\n decimals: 9,\n symbol: 'SUI',\n displayName: 'SUI',\n },\n BTC: {\n type: '0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC',\n decimals: 8,\n symbol: 'BTC',\n displayName: 'Bitcoin',\n },\n ETH: {\n type: '0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH',\n decimals: 8,\n symbol: 'ETH',\n displayName: 'Ethereum',\n },\n GOLD: {\n type: '0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM',\n decimals: 9,\n symbol: 'GOLD',\n displayName: 'Gold',\n },\n} as const;\n\nexport type SupportedAsset = keyof typeof SUPPORTED_ASSETS;\nexport type StableAsset = Exclude<SupportedAsset, 'SUI' | 'BTC' | 'ETH' | 'GOLD'>;\nexport const STABLE_ASSETS: readonly StableAsset[] = ['USDC', 'USDT', 'USDe', 'USDsui'] as const;\n\nexport const T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? '0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3';\nexport const T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? '0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a';\nexport const T2000_ADMIN_CAP_ID = '0x863d1b02cba1b93d0fe9b87eb92d58b60c1e85c001022cb2a760e07bade47e65';\nexport const T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? '0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91';\n\nexport const DEFAULT_NETWORK = 'mainnet' as const;\nexport const DEFAULT_RPC_URL = 'https://fullnode.mainnet.sui.io:443';\nexport const DEFAULT_KEY_PATH = '~/.t2000/wallet.key';\nexport const DEFAULT_CONFIG_PATH = '~/.t2000/config.json';\n\nexport const API_BASE_URL = process.env.T2000_API_URL ?? 'https://api.t2000.ai';\n\nexport const CETUS_USDC_SUI_POOL = '0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab';\nexport const CETUS_GLOBAL_CONFIG = '0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f';\nexport const CETUS_PACKAGE = '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb';\n\n// --- Investment ---\n\nexport const INVESTMENT_ASSETS = {\n SUI: SUPPORTED_ASSETS.SUI,\n BTC: SUPPORTED_ASSETS.BTC,\n ETH: SUPPORTED_ASSETS.ETH,\n GOLD: SUPPORTED_ASSETS.GOLD,\n} as const;\n\nexport type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;\n\nexport const DEFAULT_STRATEGIES = {\n bluechip: {\n name: 'Bluechip / Large-Cap',\n allocations: { BTC: 50, ETH: 30, SUI: 20 },\n description: 'Large-cap crypto index',\n custom: false,\n },\n layer1: {\n name: 'Smart Contract Platforms',\n allocations: { ETH: 50, SUI: 50 },\n description: 'Smart contract platforms',\n custom: false,\n },\n 'sui-heavy': {\n name: 'Sui-Weighted Portfolio',\n allocations: { BTC: 20, ETH: 20, SUI: 60 },\n description: 'Sui-weighted portfolio',\n custom: false,\n },\n 'all-weather': {\n name: 'All-Weather Portfolio',\n allocations: { BTC: 30, ETH: 20, SUI: 20, GOLD: 30 },\n description: 'Crypto and commodities',\n custom: false,\n },\n 'safe-haven': {\n name: 'Safe Haven',\n allocations: { BTC: 50, GOLD: 50 },\n description: 'Store-of-value assets',\n custom: false,\n },\n} as const;\n\nexport const PERPS_MARKETS = ['SUI-PERP'] as const;\nexport type PerpsMarket = (typeof PERPS_MARKETS)[number];\n\nexport const DEFAULT_MAX_LEVERAGE = 5;\nexport const DEFAULT_MAX_POSITION_SIZE = 1000;\nexport const INVEST_FEE_BPS = 0n;\nexport const GAS_RESERVE_MIN = 0.05; // minimum SUI to keep for gas\n","import type { ProtocolDescriptor } from './types.js';\nimport { CETUS_PACKAGE } from '../constants.js';\n\nexport type { ProtocolDescriptor } from './types.js';\n\nconst SUILEND_PACKAGE = '0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf';\n\nexport const naviDescriptor: ProtocolDescriptor = {\n id: 'navi',\n name: 'NAVI Protocol',\n packages: [],\n dynamicPackageId: true,\n actionMap: {\n 'incentive_v3::entry_deposit': 'save',\n 'incentive_v3::deposit': 'save',\n 'incentive_v3::withdraw_v2': 'withdraw',\n 'incentive_v3::entry_withdraw': 'withdraw',\n 'incentive_v3::borrow_v2': 'borrow',\n 'incentive_v3::entry_borrow': 'borrow',\n 'incentive_v3::entry_repay': 'repay',\n 'incentive_v3::repay': 'repay',\n },\n};\n\nexport const suilendDescriptor: ProtocolDescriptor = {\n id: 'suilend',\n name: 'Suilend',\n packages: [SUILEND_PACKAGE],\n actionMap: {\n 'lending_market::deposit_liquidity_and_mint_ctokens': 'save',\n 'lending_market::deposit_ctokens_into_obligation': 'save',\n 'lending_market::create_obligation': 'save',\n 'lending_market::withdraw_ctokens': 'withdraw',\n 'lending_market::redeem_ctokens_and_withdraw_liquidity': 'withdraw',\n 'lending_market::redeem_ctokens_and_withdraw_liquidity_request': 'withdraw',\n 'lending_market::fulfill_liquidity_request': 'withdraw',\n 'lending_market::unstake_sui_from_staker': 'withdraw',\n 'lending_market::borrow': 'borrow',\n 'lending_market::repay': 'repay',\n },\n};\n\nexport const cetusDescriptor: ProtocolDescriptor = {\n id: 'cetus',\n name: 'Cetus DEX',\n packages: [CETUS_PACKAGE],\n actionMap: {\n 'router::swap': 'swap',\n 'router::swap_ab_bc': 'swap',\n 'router::swap_ab_cb': 'swap',\n 'router::swap_ba_bc': 'swap',\n 'router::swap_ba_cb': 'swap',\n },\n};\n\nexport const allDescriptors: ProtocolDescriptor[] = [\n naviDescriptor,\n suilendDescriptor,\n cetusDescriptor,\n];\n"]}
@@ -0,0 +1,3 @@
1
+ export { $ as ProtocolDescriptor, a2 as allDescriptors, a3 as cetusDescriptor, a4 as naviDescriptor, a5 as suilendDescriptor } from '../descriptors-B6qt_mwi.cjs';
2
+ import '@mysten/sui/transactions';
3
+ import '@mysten/sui/jsonRpc';
@@ -0,0 +1,3 @@
1
+ export { $ as ProtocolDescriptor, a2 as allDescriptors, a3 as cetusDescriptor, a4 as naviDescriptor, a5 as suilendDescriptor } from '../descriptors-B6qt_mwi.js';
2
+ import '@mysten/sui/transactions';
3
+ import '@mysten/sui/jsonRpc';
@@ -0,0 +1,63 @@
1
+ // src/constants.ts
2
+ process.env.T2000_PACKAGE_ID ?? "0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3";
3
+ process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a";
4
+ process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
5
+ process.env.T2000_API_URL ?? "https://api.t2000.ai";
6
+ var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
7
+
8
+ // src/adapters/descriptors.ts
9
+ var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
10
+ var naviDescriptor = {
11
+ id: "navi",
12
+ name: "NAVI Protocol",
13
+ packages: [],
14
+ dynamicPackageId: true,
15
+ actionMap: {
16
+ "incentive_v3::entry_deposit": "save",
17
+ "incentive_v3::deposit": "save",
18
+ "incentive_v3::withdraw_v2": "withdraw",
19
+ "incentive_v3::entry_withdraw": "withdraw",
20
+ "incentive_v3::borrow_v2": "borrow",
21
+ "incentive_v3::entry_borrow": "borrow",
22
+ "incentive_v3::entry_repay": "repay",
23
+ "incentive_v3::repay": "repay"
24
+ }
25
+ };
26
+ var suilendDescriptor = {
27
+ id: "suilend",
28
+ name: "Suilend",
29
+ packages: [SUILEND_PACKAGE],
30
+ actionMap: {
31
+ "lending_market::deposit_liquidity_and_mint_ctokens": "save",
32
+ "lending_market::deposit_ctokens_into_obligation": "save",
33
+ "lending_market::create_obligation": "save",
34
+ "lending_market::withdraw_ctokens": "withdraw",
35
+ "lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
36
+ "lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
37
+ "lending_market::fulfill_liquidity_request": "withdraw",
38
+ "lending_market::unstake_sui_from_staker": "withdraw",
39
+ "lending_market::borrow": "borrow",
40
+ "lending_market::repay": "repay"
41
+ }
42
+ };
43
+ var cetusDescriptor = {
44
+ id: "cetus",
45
+ name: "Cetus DEX",
46
+ packages: [CETUS_PACKAGE],
47
+ actionMap: {
48
+ "router::swap": "swap",
49
+ "router::swap_ab_bc": "swap",
50
+ "router::swap_ab_cb": "swap",
51
+ "router::swap_ba_bc": "swap",
52
+ "router::swap_ba_cb": "swap"
53
+ }
54
+ };
55
+ var allDescriptors = [
56
+ naviDescriptor,
57
+ suilendDescriptor,
58
+ cetusDescriptor
59
+ ];
60
+
61
+ export { allDescriptors, cetusDescriptor, naviDescriptor, suilendDescriptor };
62
+ //# sourceMappingURL=descriptors.js.map
63
+ //# sourceMappingURL=descriptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants.ts","../../src/adapters/descriptors.ts"],"names":[],"mappings":";AA6EgC,OAAA,CAAQ,GAAA,CAAI,gBAAA,IAAoB;AACjC,OAAA,CAAQ,GAAA,CAAI,eAAA,IAAmB;AAE7B,OAAA,CAAQ,GAAA,CAAI,iBAAA,IAAqB;AAOtC,OAAA,CAAQ,GAAA,CAAI,aAAA,IAAiB;AAIlD,IAAM,aAAA,GAAgB,oEAAA;;;ACtF7B,IAAM,eAAA,GAAkB,oEAAA;AAEjB,IAAM,cAAA,GAAqC;AAAA,EAChD,EAAA,EAAI,MAAA;AAAA,EACJ,IAAA,EAAM,eAAA;AAAA,EACN,UAAU,EAAC;AAAA,EACX,gBAAA,EAAkB,IAAA;AAAA,EAClB,SAAA,EAAW;AAAA,IACT,6BAAA,EAA+B,MAAA;AAAA,IAC/B,uBAAA,EAAyB,MAAA;AAAA,IACzB,2BAAA,EAA6B,UAAA;AAAA,IAC7B,8BAAA,EAAgC,UAAA;AAAA,IAChC,yBAAA,EAA2B,QAAA;AAAA,IAC3B,4BAAA,EAA8B,QAAA;AAAA,IAC9B,2BAAA,EAA6B,OAAA;AAAA,IAC7B,qBAAA,EAAuB;AAAA;AAE3B;AAEO,IAAM,iBAAA,GAAwC;AAAA,EACnD,EAAA,EAAI,SAAA;AAAA,EACJ,IAAA,EAAM,SAAA;AAAA,EACN,QAAA,EAAU,CAAC,eAAe,CAAA;AAAA,EAC1B,SAAA,EAAW;AAAA,IACT,oDAAA,EAAsD,MAAA;AAAA,IACtD,iDAAA,EAAmD,MAAA;AAAA,IACnD,mCAAA,EAAqC,MAAA;AAAA,IACrC,kCAAA,EAAoC,UAAA;AAAA,IACpC,uDAAA,EAAyD,UAAA;AAAA,IACzD,+DAAA,EAAiE,UAAA;AAAA,IACjE,2CAAA,EAA6C,UAAA;AAAA,IAC7C,yCAAA,EAA2C,UAAA;AAAA,IAC3C,wBAAA,EAA0B,QAAA;AAAA,IAC1B,uBAAA,EAAyB;AAAA;AAE7B;AAEO,IAAM,eAAA,GAAsC;AAAA,EACjD,EAAA,EAAI,OAAA;AAAA,EACJ,IAAA,EAAM,WAAA;AAAA,EACN,QAAA,EAAU,CAAC,aAAa,CAAA;AAAA,EACxB,SAAA,EAAW;AAAA,IACT,cAAA,EAAgB,MAAA;AAAA,IAChB,oBAAA,EAAsB,MAAA;AAAA,IACtB,oBAAA,EAAsB,MAAA;AAAA,IACtB,oBAAA,EAAsB,MAAA;AAAA,IACtB,oBAAA,EAAsB;AAAA;AAE1B;AAEO,IAAM,cAAA,GAAuC;AAAA,EAClD,cAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF","file":"descriptors.js","sourcesContent":["export const MIST_PER_SUI = 1_000_000_000n;\nexport const SUI_DECIMALS = 9;\nexport const USDC_DECIMALS = 6;\n\nexport const BPS_DENOMINATOR = 10_000n;\nexport const PRECISION = 1_000_000_000_000_000_000n;\n\nexport const MIN_DEPOSIT = 1_000_000n; // 1 USDC (6 decimals)\nexport const GAS_RESERVE_USDC = 1_000_000n; // $1 USDC reserved for gas\nexport const AUTO_TOPUP_THRESHOLD = 50_000_000n; // 0.05 SUI — minimum to attempt self-funded TX\nexport const GAS_RESERVE_TARGET = 150_000_000n; // 0.15 SUI — proactive top-up target (covers complex TXs)\nexport const AUTO_TOPUP_AMOUNT = 1_000_000n; // $1 USDC worth of SUI\nexport const AUTO_TOPUP_MIN_USDC = 2_000_000n; // $2 USDC minimum to trigger auto-topup\nexport const BOOTSTRAP_LIMIT = 10;\nexport const GAS_FEE_CEILING_USD = 0.05;\n\nexport const SAVE_FEE_BPS = 10n; // 0.1%\nexport const SWAP_FEE_BPS = 0n; // Free — Cetus already charges pool fees\nexport const BORROW_FEE_BPS = 5n; // 0.05%\n\nexport const CLOCK_ID = '0x6';\n\nexport const SUPPORTED_ASSETS = {\n USDC: {\n type: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',\n decimals: 6,\n symbol: 'USDC',\n displayName: 'USDC',\n },\n USDT: {\n type: '0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT',\n decimals: 6,\n symbol: 'USDT',\n displayName: 'suiUSDT',\n },\n USDe: {\n type: '0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE',\n decimals: 6,\n symbol: 'USDe',\n displayName: 'suiUSDe',\n },\n USDsui: {\n type: '0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI',\n decimals: 6,\n symbol: 'USDsui',\n displayName: 'USDsui',\n },\n SUI: {\n type: '0x2::sui::SUI',\n decimals: 9,\n symbol: 'SUI',\n displayName: 'SUI',\n },\n BTC: {\n type: '0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC',\n decimals: 8,\n symbol: 'BTC',\n displayName: 'Bitcoin',\n },\n ETH: {\n type: '0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH',\n decimals: 8,\n symbol: 'ETH',\n displayName: 'Ethereum',\n },\n GOLD: {\n type: '0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM',\n decimals: 9,\n symbol: 'GOLD',\n displayName: 'Gold',\n },\n} as const;\n\nexport type SupportedAsset = keyof typeof SUPPORTED_ASSETS;\nexport type StableAsset = Exclude<SupportedAsset, 'SUI' | 'BTC' | 'ETH' | 'GOLD'>;\nexport const STABLE_ASSETS: readonly StableAsset[] = ['USDC', 'USDT', 'USDe', 'USDsui'] as const;\n\nexport const T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? '0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3';\nexport const T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? '0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a';\nexport const T2000_ADMIN_CAP_ID = '0x863d1b02cba1b93d0fe9b87eb92d58b60c1e85c001022cb2a760e07bade47e65';\nexport const T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? '0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91';\n\nexport const DEFAULT_NETWORK = 'mainnet' as const;\nexport const DEFAULT_RPC_URL = 'https://fullnode.mainnet.sui.io:443';\nexport const DEFAULT_KEY_PATH = '~/.t2000/wallet.key';\nexport const DEFAULT_CONFIG_PATH = '~/.t2000/config.json';\n\nexport const API_BASE_URL = process.env.T2000_API_URL ?? 'https://api.t2000.ai';\n\nexport const CETUS_USDC_SUI_POOL = '0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab';\nexport const CETUS_GLOBAL_CONFIG = '0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f';\nexport const CETUS_PACKAGE = '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb';\n\n// --- Investment ---\n\nexport const INVESTMENT_ASSETS = {\n SUI: SUPPORTED_ASSETS.SUI,\n BTC: SUPPORTED_ASSETS.BTC,\n ETH: SUPPORTED_ASSETS.ETH,\n GOLD: SUPPORTED_ASSETS.GOLD,\n} as const;\n\nexport type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;\n\nexport const DEFAULT_STRATEGIES = {\n bluechip: {\n name: 'Bluechip / Large-Cap',\n allocations: { BTC: 50, ETH: 30, SUI: 20 },\n description: 'Large-cap crypto index',\n custom: false,\n },\n layer1: {\n name: 'Smart Contract Platforms',\n allocations: { ETH: 50, SUI: 50 },\n description: 'Smart contract platforms',\n custom: false,\n },\n 'sui-heavy': {\n name: 'Sui-Weighted Portfolio',\n allocations: { BTC: 20, ETH: 20, SUI: 60 },\n description: 'Sui-weighted portfolio',\n custom: false,\n },\n 'all-weather': {\n name: 'All-Weather Portfolio',\n allocations: { BTC: 30, ETH: 20, SUI: 20, GOLD: 30 },\n description: 'Crypto and commodities',\n custom: false,\n },\n 'safe-haven': {\n name: 'Safe Haven',\n allocations: { BTC: 50, GOLD: 50 },\n description: 'Store-of-value assets',\n custom: false,\n },\n} as const;\n\nexport const PERPS_MARKETS = ['SUI-PERP'] as const;\nexport type PerpsMarket = (typeof PERPS_MARKETS)[number];\n\nexport const DEFAULT_MAX_LEVERAGE = 5;\nexport const DEFAULT_MAX_POSITION_SIZE = 1000;\nexport const INVEST_FEE_BPS = 0n;\nexport const GAS_RESERVE_MIN = 0.05; // minimum SUI to keep for gas\n","import type { ProtocolDescriptor } from './types.js';\nimport { CETUS_PACKAGE } from '../constants.js';\n\nexport type { ProtocolDescriptor } from './types.js';\n\nconst SUILEND_PACKAGE = '0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf';\n\nexport const naviDescriptor: ProtocolDescriptor = {\n id: 'navi',\n name: 'NAVI Protocol',\n packages: [],\n dynamicPackageId: true,\n actionMap: {\n 'incentive_v3::entry_deposit': 'save',\n 'incentive_v3::deposit': 'save',\n 'incentive_v3::withdraw_v2': 'withdraw',\n 'incentive_v3::entry_withdraw': 'withdraw',\n 'incentive_v3::borrow_v2': 'borrow',\n 'incentive_v3::entry_borrow': 'borrow',\n 'incentive_v3::entry_repay': 'repay',\n 'incentive_v3::repay': 'repay',\n },\n};\n\nexport const suilendDescriptor: ProtocolDescriptor = {\n id: 'suilend',\n name: 'Suilend',\n packages: [SUILEND_PACKAGE],\n actionMap: {\n 'lending_market::deposit_liquidity_and_mint_ctokens': 'save',\n 'lending_market::deposit_ctokens_into_obligation': 'save',\n 'lending_market::create_obligation': 'save',\n 'lending_market::withdraw_ctokens': 'withdraw',\n 'lending_market::redeem_ctokens_and_withdraw_liquidity': 'withdraw',\n 'lending_market::redeem_ctokens_and_withdraw_liquidity_request': 'withdraw',\n 'lending_market::fulfill_liquidity_request': 'withdraw',\n 'lending_market::unstake_sui_from_staker': 'withdraw',\n 'lending_market::borrow': 'borrow',\n 'lending_market::repay': 'repay',\n },\n};\n\nexport const cetusDescriptor: ProtocolDescriptor = {\n id: 'cetus',\n name: 'Cetus DEX',\n packages: [CETUS_PACKAGE],\n actionMap: {\n 'router::swap': 'swap',\n 'router::swap_ab_bc': 'swap',\n 'router::swap_ab_cb': 'swap',\n 'router::swap_ba_bc': 'swap',\n 'router::swap_ba_cb': 'swap',\n },\n};\n\nexport const allDescriptors: ProtocolDescriptor[] = [\n naviDescriptor,\n suilendDescriptor,\n cetusDescriptor,\n];\n"]}
@@ -7,7 +7,6 @@ var utils = require('@mysten/sui/utils');
7
7
  var client = require('@suilend/sdk/client');
8
8
  var initialize = require('@suilend/sdk/lib/initialize');
9
9
  var types = require('@suilend/sdk/lib/types');
10
- require('@mysten/sui/bcs');
11
10
 
12
11
  // src/constants.ts
13
12
  var SAVE_FEE_BPS = 10n;
@@ -76,8 +75,6 @@ var INVESTMENT_ASSETS = {
76
75
  ETH: SUPPORTED_ASSETS.ETH,
77
76
  GOLD: SUPPORTED_ASSETS.GOLD
78
77
  };
79
- var SENTINEL = {
80
- PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7"};
81
78
 
82
79
  // src/errors.ts
83
80
  var T2000Error = class extends Error {
@@ -510,6 +507,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
510
507
  }
511
508
  async function addWithdrawToTx(tx, client, address, amount, options = {}) {
512
509
  const asset = options.asset ?? "USDC";
510
+ const sponsored = options.sponsored ?? true;
513
511
  const assetInfo = resolveAssetInfo(asset);
514
512
  const posResult = await getPositions(client, address);
515
513
  const supply = posResult.positions.find(
@@ -527,7 +525,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
527
525
  });
528
526
  return { coin, effectiveAmount: 0 };
529
527
  }
530
- await refreshOracle(tx, client, address);
528
+ await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
531
529
  try {
532
530
  const coin = await lending.withdrawCoinPTB(tx, assetInfo.type, rawAmount, sdkOptions(client));
533
531
  return { coin, effectiveAmount };
@@ -551,8 +549,9 @@ async function addSaveToTx(tx, _client, _address, coin, options = {}) {
551
549
  }
552
550
  async function addRepayToTx(tx, client, address, coin, options = {}) {
553
551
  const asset = options.asset ?? "USDC";
552
+ const sponsored = options.sponsored ?? true;
554
553
  const assetInfo = resolveAssetInfo(asset);
555
- await refreshOracle(tx, client, address);
554
+ await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
556
555
  try {
557
556
  await lending.repayCoinPTB(tx, assetInfo.type, coin, { env: "prod" });
558
557
  } catch (err) {
@@ -589,12 +588,16 @@ async function buildRepayTx(client, address, amount, options = {}) {
589
588
  const asset = options.asset ?? "USDC";
590
589
  const assetInfo = resolveAssetInfo(asset);
591
590
  const coins = await fetchCoins(client, address, assetInfo.type);
592
- if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins to repay with`);
591
+ if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins to repay with. Withdraw some savings first to get cash.`);
593
592
  const totalBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), 0n);
593
+ const rawRequested = Number(stableToRaw(amount, assetInfo.decimals));
594
+ if (Number(totalBalance) < rawRequested && Number(totalBalance) < 1e3) {
595
+ throw new T2000Error("INSUFFICIENT_BALANCE", `Not enough ${assetInfo.displayName} to repay (need $${amount.toFixed(2)}, wallet has ~$${(Number(totalBalance) / 10 ** assetInfo.decimals).toFixed(4)}). Withdraw some savings first.`);
596
+ }
594
597
  const tx = new transactions.Transaction();
595
598
  tx.setSender(address);
596
599
  const coinObj = mergeCoins(tx, coins);
597
- const rawAmount = Math.min(Number(stableToRaw(amount, assetInfo.decimals)), Number(totalBalance));
600
+ const rawAmount = Math.min(rawRequested, Number(totalBalance));
598
601
  const [repayCoin] = tx.splitCoins(coinObj, [rawAmount]);
599
602
  await refreshOracle(tx, client, address, {
600
603
  skipPythUpdate: options.sponsored,
@@ -687,8 +690,9 @@ async function addClaimRewardsToTx(tx, client, address) {
687
690
  }
688
691
  }
689
692
 
690
- // src/adapters/navi.ts
691
- var descriptor = {
693
+ // src/adapters/descriptors.ts
694
+ var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
695
+ var naviDescriptor = {
692
696
  id: "navi",
693
697
  name: "NAVI Protocol",
694
698
  packages: [],
@@ -704,6 +708,42 @@ var descriptor = {
704
708
  "incentive_v3::repay": "repay"
705
709
  }
706
710
  };
711
+ var suilendDescriptor = {
712
+ id: "suilend",
713
+ name: "Suilend",
714
+ packages: [SUILEND_PACKAGE],
715
+ actionMap: {
716
+ "lending_market::deposit_liquidity_and_mint_ctokens": "save",
717
+ "lending_market::deposit_ctokens_into_obligation": "save",
718
+ "lending_market::create_obligation": "save",
719
+ "lending_market::withdraw_ctokens": "withdraw",
720
+ "lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
721
+ "lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
722
+ "lending_market::fulfill_liquidity_request": "withdraw",
723
+ "lending_market::unstake_sui_from_staker": "withdraw",
724
+ "lending_market::borrow": "borrow",
725
+ "lending_market::repay": "repay"
726
+ }
727
+ };
728
+ var cetusDescriptor = {
729
+ id: "cetus",
730
+ name: "Cetus DEX",
731
+ packages: [CETUS_PACKAGE],
732
+ actionMap: {
733
+ "router::swap": "swap",
734
+ "router::swap_ab_bc": "swap",
735
+ "router::swap_ab_cb": "swap",
736
+ "router::swap_ba_bc": "swap",
737
+ "router::swap_ba_cb": "swap"
738
+ }
739
+ };
740
+ var allDescriptors = [
741
+ naviDescriptor,
742
+ suilendDescriptor,
743
+ cetusDescriptor
744
+ ];
745
+
746
+ // src/adapters/navi.ts
707
747
  var NaviAdapter = class {
708
748
  id = "navi";
709
749
  name = "NAVI Protocol";
@@ -944,18 +984,6 @@ function fallbackQuote(fromAsset, amount, poolPrice) {
944
984
  }
945
985
 
946
986
  // src/adapters/cetus.ts
947
- var descriptor2 = {
948
- id: "cetus",
949
- name: "Cetus DEX",
950
- packages: [CETUS_PACKAGE],
951
- actionMap: {
952
- "router::swap": "swap",
953
- "router::swap_ab_bc": "swap",
954
- "router::swap_ab_cb": "swap",
955
- "router::swap_ba_bc": "swap",
956
- "router::swap_ba_cb": "swap"
957
- }
958
- };
959
987
  var CetusAdapter = class {
960
988
  id = "cetus";
961
989
  name = "Cetus";
@@ -1014,7 +1042,6 @@ var CetusAdapter = class {
1014
1042
  });
1015
1043
  }
1016
1044
  };
1017
- var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
1018
1045
  var MIN_HEALTH_FACTOR2 = 1.5;
1019
1046
  async function quietSuilend(fn) {
1020
1047
  const origLog = console.log;
@@ -1031,23 +1058,6 @@ async function quietSuilend(fn) {
1031
1058
  console.warn = origWarn;
1032
1059
  });
1033
1060
  }
1034
- var descriptor3 = {
1035
- id: "suilend",
1036
- name: "Suilend",
1037
- packages: [SUILEND_PACKAGE],
1038
- actionMap: {
1039
- "lending_market::deposit_liquidity_and_mint_ctokens": "save",
1040
- "lending_market::deposit_ctokens_into_obligation": "save",
1041
- "lending_market::create_obligation": "save",
1042
- "lending_market::withdraw_ctokens": "withdraw",
1043
- "lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
1044
- "lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
1045
- "lending_market::fulfill_liquidity_request": "withdraw",
1046
- "lending_market::unstake_sui_from_staker": "withdraw",
1047
- "lending_market::borrow": "borrow",
1048
- "lending_market::repay": "repay"
1049
- }
1050
- };
1051
1061
  var SuilendAdapter = class {
1052
1062
  id = "suilend";
1053
1063
  name = "Suilend";
@@ -1458,32 +1468,14 @@ var SuilendAdapter = class {
1458
1468
  }
1459
1469
  }
1460
1470
  };
1461
- var descriptor4 = {
1462
- id: "sentinel",
1463
- name: "Sui Sentinel",
1464
- packages: [SENTINEL.PACKAGE],
1465
- actionMap: {
1466
- "sentinel::request_attack": "sentinel_attack",
1467
- "sentinel::consume_prompt": "sentinel_settle"
1468
- }
1469
- };
1470
-
1471
- // src/adapters/index.ts
1472
- var allDescriptors = [
1473
- descriptor,
1474
- descriptor3,
1475
- descriptor2,
1476
- descriptor4
1477
- ];
1478
1471
 
1479
1472
  exports.CetusAdapter = CetusAdapter;
1480
1473
  exports.NaviAdapter = NaviAdapter;
1481
1474
  exports.ProtocolRegistry = ProtocolRegistry;
1482
1475
  exports.SuilendAdapter = SuilendAdapter;
1483
1476
  exports.allDescriptors = allDescriptors;
1484
- exports.cetusDescriptor = descriptor2;
1485
- exports.naviDescriptor = descriptor;
1486
- exports.sentinelDescriptor = descriptor4;
1487
- exports.suilendDescriptor = descriptor3;
1477
+ exports.cetusDescriptor = cetusDescriptor;
1478
+ exports.naviDescriptor = naviDescriptor;
1479
+ exports.suilendDescriptor = suilendDescriptor;
1488
1480
  //# sourceMappingURL=index.cjs.map
1489
1481
  //# sourceMappingURL=index.cjs.map