@t2000/sdk 0.19.20 → 0.19.22
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 +0 -9
- package/dist/adapters/descriptors.cjs +68 -0
- package/dist/adapters/descriptors.cjs.map +1 -0
- package/dist/adapters/descriptors.d.cts +3 -0
- package/dist/adapters/descriptors.d.ts +3 -0
- package/dist/adapters/descriptors.js +63 -0
- package/dist/adapters/descriptors.js.map +1 -0
- package/dist/adapters/index.cjs +69 -64
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +171 -3
- package/dist/adapters/index.d.ts +171 -3
- package/dist/adapters/index.js +67 -61
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.js +2 -15
- package/dist/browser.js.map +1 -1
- package/dist/{index-DAxuyiS2.d.cts → descriptors-B6qt_mwi.d.cts} +5 -225
- package/dist/{index-DAxuyiS2.d.ts → descriptors-B6qt_mwi.d.ts} +5 -225
- package/dist/index.cjs +86 -291
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -20
- package/dist/index.d.ts +18 -20
- package/dist/index.js +84 -281
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
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,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"]}
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -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 {
|
|
@@ -294,6 +291,7 @@ function sdkOptions(client) {
|
|
|
294
291
|
return { env: "prod", client, cacheTime: 0, disableCache: true };
|
|
295
292
|
}
|
|
296
293
|
async function refreshOracle(tx, client, address, options) {
|
|
294
|
+
if (options?.skipOracle) return;
|
|
297
295
|
const origInfo = console.info;
|
|
298
296
|
const origWarn = console.warn;
|
|
299
297
|
console.info = (...args) => {
|
|
@@ -461,13 +459,14 @@ async function buildSaveTx(client, address, amount, options = {}) {
|
|
|
461
459
|
const assetInfo = resolveAssetInfo(asset);
|
|
462
460
|
const coins = await fetchCoins(client, address, assetInfo.type);
|
|
463
461
|
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins found`);
|
|
462
|
+
const totalBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), 0n);
|
|
464
463
|
const tx = new transactions.Transaction();
|
|
465
464
|
tx.setSender(address);
|
|
466
465
|
const coinObj = mergeCoins(tx, coins);
|
|
467
466
|
if (options.collectFee) {
|
|
468
467
|
addCollectFeeToTx(tx, coinObj, "save");
|
|
469
468
|
}
|
|
470
|
-
const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
|
|
469
|
+
const rawAmount = Math.min(Number(stableToRaw(amount, assetInfo.decimals)), Number(totalBalance));
|
|
471
470
|
try {
|
|
472
471
|
await lending.depositCoinPTB(tx, assetInfo.type, coinObj, {
|
|
473
472
|
...sdkOptions(client),
|
|
@@ -508,6 +507,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
508
507
|
}
|
|
509
508
|
async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
510
509
|
const asset = options.asset ?? "USDC";
|
|
510
|
+
const sponsored = options.sponsored ?? true;
|
|
511
511
|
const assetInfo = resolveAssetInfo(asset);
|
|
512
512
|
const posResult = await getPositions(client, address);
|
|
513
513
|
const supply = posResult.positions.find(
|
|
@@ -525,7 +525,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
525
525
|
});
|
|
526
526
|
return { coin, effectiveAmount: 0 };
|
|
527
527
|
}
|
|
528
|
-
await refreshOracle(tx, client, address);
|
|
528
|
+
await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
|
|
529
529
|
try {
|
|
530
530
|
const coin = await lending.withdrawCoinPTB(tx, assetInfo.type, rawAmount, sdkOptions(client));
|
|
531
531
|
return { coin, effectiveAmount };
|
|
@@ -549,8 +549,9 @@ async function addSaveToTx(tx, _client, _address, coin, options = {}) {
|
|
|
549
549
|
}
|
|
550
550
|
async function addRepayToTx(tx, client, address, coin, options = {}) {
|
|
551
551
|
const asset = options.asset ?? "USDC";
|
|
552
|
+
const sponsored = options.sponsored ?? true;
|
|
552
553
|
const assetInfo = resolveAssetInfo(asset);
|
|
553
|
-
await refreshOracle(tx, client, address);
|
|
554
|
+
await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
|
|
554
555
|
try {
|
|
555
556
|
await lending.repayCoinPTB(tx, assetInfo.type, coin, { env: "prod" });
|
|
556
557
|
} catch (err) {
|
|
@@ -588,12 +589,16 @@ async function buildRepayTx(client, address, amount, options = {}) {
|
|
|
588
589
|
const assetInfo = resolveAssetInfo(asset);
|
|
589
590
|
const coins = await fetchCoins(client, address, assetInfo.type);
|
|
590
591
|
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins to repay with`);
|
|
592
|
+
const totalBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), 0n);
|
|
591
593
|
const tx = new transactions.Transaction();
|
|
592
594
|
tx.setSender(address);
|
|
593
595
|
const coinObj = mergeCoins(tx, coins);
|
|
594
|
-
const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
|
|
596
|
+
const rawAmount = Math.min(Number(stableToRaw(amount, assetInfo.decimals)), Number(totalBalance));
|
|
595
597
|
const [repayCoin] = tx.splitCoins(coinObj, [rawAmount]);
|
|
596
|
-
await refreshOracle(tx, client, address, {
|
|
598
|
+
await refreshOracle(tx, client, address, {
|
|
599
|
+
skipPythUpdate: options.sponsored,
|
|
600
|
+
skipOracle: options.skipOracle
|
|
601
|
+
});
|
|
597
602
|
try {
|
|
598
603
|
await lending.repayCoinPTB(tx, assetInfo.type, repayCoin, {
|
|
599
604
|
...sdkOptions(client),
|
|
@@ -681,8 +686,9 @@ async function addClaimRewardsToTx(tx, client, address) {
|
|
|
681
686
|
}
|
|
682
687
|
}
|
|
683
688
|
|
|
684
|
-
// src/adapters/
|
|
685
|
-
var
|
|
689
|
+
// src/adapters/descriptors.ts
|
|
690
|
+
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
691
|
+
var naviDescriptor = {
|
|
686
692
|
id: "navi",
|
|
687
693
|
name: "NAVI Protocol",
|
|
688
694
|
packages: [],
|
|
@@ -698,6 +704,42 @@ var descriptor = {
|
|
|
698
704
|
"incentive_v3::repay": "repay"
|
|
699
705
|
}
|
|
700
706
|
};
|
|
707
|
+
var suilendDescriptor = {
|
|
708
|
+
id: "suilend",
|
|
709
|
+
name: "Suilend",
|
|
710
|
+
packages: [SUILEND_PACKAGE],
|
|
711
|
+
actionMap: {
|
|
712
|
+
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
713
|
+
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
714
|
+
"lending_market::create_obligation": "save",
|
|
715
|
+
"lending_market::withdraw_ctokens": "withdraw",
|
|
716
|
+
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
717
|
+
"lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
|
|
718
|
+
"lending_market::fulfill_liquidity_request": "withdraw",
|
|
719
|
+
"lending_market::unstake_sui_from_staker": "withdraw",
|
|
720
|
+
"lending_market::borrow": "borrow",
|
|
721
|
+
"lending_market::repay": "repay"
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
var cetusDescriptor = {
|
|
725
|
+
id: "cetus",
|
|
726
|
+
name: "Cetus DEX",
|
|
727
|
+
packages: [CETUS_PACKAGE],
|
|
728
|
+
actionMap: {
|
|
729
|
+
"router::swap": "swap",
|
|
730
|
+
"router::swap_ab_bc": "swap",
|
|
731
|
+
"router::swap_ab_cb": "swap",
|
|
732
|
+
"router::swap_ba_bc": "swap",
|
|
733
|
+
"router::swap_ba_cb": "swap"
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
var allDescriptors = [
|
|
737
|
+
naviDescriptor,
|
|
738
|
+
suilendDescriptor,
|
|
739
|
+
cetusDescriptor
|
|
740
|
+
];
|
|
741
|
+
|
|
742
|
+
// src/adapters/navi.ts
|
|
701
743
|
var NaviAdapter = class {
|
|
702
744
|
id = "navi";
|
|
703
745
|
name = "NAVI Protocol";
|
|
@@ -746,7 +788,11 @@ var NaviAdapter = class {
|
|
|
746
788
|
}
|
|
747
789
|
async buildRepayTx(address, amount, asset, options) {
|
|
748
790
|
const normalized = normalizeAsset(asset);
|
|
749
|
-
const tx = await buildRepayTx(this.client, address, amount, {
|
|
791
|
+
const tx = await buildRepayTx(this.client, address, amount, {
|
|
792
|
+
asset: normalized,
|
|
793
|
+
sponsored: options?.sponsored,
|
|
794
|
+
skipOracle: options?.skipOracle
|
|
795
|
+
});
|
|
750
796
|
return { tx };
|
|
751
797
|
}
|
|
752
798
|
async maxWithdraw(address, _asset) {
|
|
@@ -934,18 +980,6 @@ function fallbackQuote(fromAsset, amount, poolPrice) {
|
|
|
934
980
|
}
|
|
935
981
|
|
|
936
982
|
// src/adapters/cetus.ts
|
|
937
|
-
var descriptor2 = {
|
|
938
|
-
id: "cetus",
|
|
939
|
-
name: "Cetus DEX",
|
|
940
|
-
packages: [CETUS_PACKAGE],
|
|
941
|
-
actionMap: {
|
|
942
|
-
"router::swap": "swap",
|
|
943
|
-
"router::swap_ab_bc": "swap",
|
|
944
|
-
"router::swap_ab_cb": "swap",
|
|
945
|
-
"router::swap_ba_bc": "swap",
|
|
946
|
-
"router::swap_ba_cb": "swap"
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
983
|
var CetusAdapter = class {
|
|
950
984
|
id = "cetus";
|
|
951
985
|
name = "Cetus";
|
|
@@ -1004,7 +1038,6 @@ var CetusAdapter = class {
|
|
|
1004
1038
|
});
|
|
1005
1039
|
}
|
|
1006
1040
|
};
|
|
1007
|
-
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
1008
1041
|
var MIN_HEALTH_FACTOR2 = 1.5;
|
|
1009
1042
|
async function quietSuilend(fn) {
|
|
1010
1043
|
const origLog = console.log;
|
|
@@ -1021,23 +1054,6 @@ async function quietSuilend(fn) {
|
|
|
1021
1054
|
console.warn = origWarn;
|
|
1022
1055
|
});
|
|
1023
1056
|
}
|
|
1024
|
-
var descriptor3 = {
|
|
1025
|
-
id: "suilend",
|
|
1026
|
-
name: "Suilend",
|
|
1027
|
-
packages: [SUILEND_PACKAGE],
|
|
1028
|
-
actionMap: {
|
|
1029
|
-
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
1030
|
-
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
1031
|
-
"lending_market::create_obligation": "save",
|
|
1032
|
-
"lending_market::withdraw_ctokens": "withdraw",
|
|
1033
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
1034
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
|
|
1035
|
-
"lending_market::fulfill_liquidity_request": "withdraw",
|
|
1036
|
-
"lending_market::unstake_sui_from_staker": "withdraw",
|
|
1037
|
-
"lending_market::borrow": "borrow",
|
|
1038
|
-
"lending_market::repay": "repay"
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
1057
|
var SuilendAdapter = class {
|
|
1042
1058
|
id = "suilend";
|
|
1043
1059
|
name = "Suilend";
|
|
@@ -1380,16 +1396,23 @@ var SuilendAdapter = class {
|
|
|
1380
1396
|
if (obligationOwnerCaps.length === 0 || obligations.length === 0) return [];
|
|
1381
1397
|
const ob = obligations[0];
|
|
1382
1398
|
const rewards = [];
|
|
1399
|
+
const WAD = 1e18;
|
|
1383
1400
|
for (const dep of ob.deposits) {
|
|
1384
|
-
|
|
1401
|
+
const urm = dep.userRewardManager;
|
|
1402
|
+
for (const rw of dep.reserve.depositsPoolRewardManager?.poolRewards ?? []) {
|
|
1385
1403
|
if (rw.endTimeMs <= Date.now()) continue;
|
|
1404
|
+
let claimableAmount = 0;
|
|
1405
|
+
const userReward = urm?.rewards?.[rw.rewardIndex];
|
|
1406
|
+
if (userReward?.earnedRewards) {
|
|
1407
|
+
claimableAmount = Number(BigInt(userReward.earnedRewards.value.toString())) / WAD / 10 ** rw.mintDecimals;
|
|
1408
|
+
}
|
|
1386
1409
|
const symbol = rw.symbol || rw.coinType.split("::").pop() || "UNKNOWN";
|
|
1387
1410
|
rewards.push({
|
|
1388
1411
|
protocol: "suilend",
|
|
1389
1412
|
asset: this.resolveSymbol(dep.coinType),
|
|
1390
1413
|
coinType: rw.coinType,
|
|
1391
1414
|
symbol,
|
|
1392
|
-
amount:
|
|
1415
|
+
amount: claimableAmount,
|
|
1393
1416
|
estimatedValueUsd: 0
|
|
1394
1417
|
});
|
|
1395
1418
|
}
|
|
@@ -1441,32 +1464,14 @@ var SuilendAdapter = class {
|
|
|
1441
1464
|
}
|
|
1442
1465
|
}
|
|
1443
1466
|
};
|
|
1444
|
-
var descriptor4 = {
|
|
1445
|
-
id: "sentinel",
|
|
1446
|
-
name: "Sui Sentinel",
|
|
1447
|
-
packages: [SENTINEL.PACKAGE],
|
|
1448
|
-
actionMap: {
|
|
1449
|
-
"sentinel::request_attack": "sentinel_attack",
|
|
1450
|
-
"sentinel::consume_prompt": "sentinel_settle"
|
|
1451
|
-
}
|
|
1452
|
-
};
|
|
1453
|
-
|
|
1454
|
-
// src/adapters/index.ts
|
|
1455
|
-
var allDescriptors = [
|
|
1456
|
-
descriptor,
|
|
1457
|
-
descriptor3,
|
|
1458
|
-
descriptor2,
|
|
1459
|
-
descriptor4
|
|
1460
|
-
];
|
|
1461
1467
|
|
|
1462
1468
|
exports.CetusAdapter = CetusAdapter;
|
|
1463
1469
|
exports.NaviAdapter = NaviAdapter;
|
|
1464
1470
|
exports.ProtocolRegistry = ProtocolRegistry;
|
|
1465
1471
|
exports.SuilendAdapter = SuilendAdapter;
|
|
1466
1472
|
exports.allDescriptors = allDescriptors;
|
|
1467
|
-
exports.cetusDescriptor =
|
|
1468
|
-
exports.naviDescriptor =
|
|
1469
|
-
exports.
|
|
1470
|
-
exports.suilendDescriptor = descriptor3;
|
|
1473
|
+
exports.cetusDescriptor = cetusDescriptor;
|
|
1474
|
+
exports.naviDescriptor = naviDescriptor;
|
|
1475
|
+
exports.suilendDescriptor = suilendDescriptor;
|
|
1471
1476
|
//# sourceMappingURL=index.cjs.map
|
|
1472
1477
|
//# sourceMappingURL=index.cjs.map
|