@t2000/sdk 0.16.30 → 0.17.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 +4 -1
- package/dist/adapters/index.cjs +32 -13
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +32 -13
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +46 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ await agent.withdraw({ amount: 25 });
|
|
|
58
58
|
await agent.investBuy({ asset: 'SUI', usdAmount: 100 });
|
|
59
59
|
await agent.investBuy({ asset: 'BTC', usdAmount: 500 });
|
|
60
60
|
await agent.investBuy({ asset: 'ETH', usdAmount: 200 });
|
|
61
|
+
await agent.investBuy({ asset: 'GOLD', usdAmount: 100 });
|
|
61
62
|
|
|
62
63
|
// Check portfolio
|
|
63
64
|
const portfolio = await agent.getPortfolio();
|
|
@@ -73,6 +74,7 @@ await agent.investUnearn({ asset: 'SUI' });
|
|
|
73
74
|
await agent.investSell({ asset: 'SUI', usdAmount: 'all' });
|
|
74
75
|
|
|
75
76
|
// Buy into a strategy (single atomic PTB)
|
|
77
|
+
// bluechip: BTC 50%, ETH 30%, SUI 20%; all-weather: BTC 30%, ETH 20%, SUI 20%, GOLD 30%; safe-haven: BTC 50%, GOLD 50%
|
|
76
78
|
await agent.investStrategy({ strategy: 'bluechip', usdAmount: 200 });
|
|
77
79
|
|
|
78
80
|
// Check strategy status
|
|
@@ -358,6 +360,7 @@ debt is non-USDC (from rebalance). Rebalance optimizes across all stablecoins in
|
|
|
358
360
|
| SUI | SUI | `0x2::sui::SUI` | 9 | — | — | — | — | ✅ |
|
|
359
361
|
| BTC | Bitcoin | `0xaafb...::btc::BTC` | 8 | — | — | — | — | ✅ |
|
|
360
362
|
| ETH | Ethereum | `0xd0e8...::eth::ETH` | 8 | — | — | — | — | ✅ |
|
|
363
|
+
| GOLD | Gold (XAUm) | `0x9d29...::xaum::XAUM` | 9 | — | — | — | — | ✅ |
|
|
361
364
|
|
|
362
365
|
## Error Handling
|
|
363
366
|
|
|
@@ -420,7 +423,7 @@ Fees are collected by the t2000 protocol treasury on-chain.
|
|
|
420
423
|
|
|
421
424
|
## MCP Server
|
|
422
425
|
|
|
423
|
-
The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server — 21 tools and
|
|
426
|
+
The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server — 21 tools and 12 prompts for Claude Desktop, Cursor, and any MCP-compatible AI platform. Run `t2000 mcp` to start.
|
|
424
427
|
|
|
425
428
|
## License
|
|
426
429
|
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -51,6 +51,12 @@ var SUPPORTED_ASSETS = {
|
|
|
51
51
|
decimals: 8,
|
|
52
52
|
symbol: "ETH",
|
|
53
53
|
displayName: "Ethereum"
|
|
54
|
+
},
|
|
55
|
+
GOLD: {
|
|
56
|
+
type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM",
|
|
57
|
+
decimals: 9,
|
|
58
|
+
symbol: "GOLD",
|
|
59
|
+
displayName: "Gold"
|
|
54
60
|
}
|
|
55
61
|
};
|
|
56
62
|
var STABLE_ASSETS = ["USDC", "USDT", "USDe", "USDsui"];
|
|
@@ -63,7 +69,8 @@ var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35
|
|
|
63
69
|
var INVESTMENT_ASSETS = {
|
|
64
70
|
SUI: SUPPORTED_ASSETS.SUI,
|
|
65
71
|
BTC: SUPPORTED_ASSETS.BTC,
|
|
66
|
-
ETH: SUPPORTED_ASSETS.ETH
|
|
72
|
+
ETH: SUPPORTED_ASSETS.ETH,
|
|
73
|
+
GOLD: SUPPORTED_ASSETS.GOLD
|
|
67
74
|
};
|
|
68
75
|
var SENTINEL = {
|
|
69
76
|
PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7"};
|
|
@@ -273,7 +280,9 @@ function addCollectFeeToTx(tx, paymentCoin, operation) {
|
|
|
273
280
|
var RATE_DECIMALS = 27;
|
|
274
281
|
var LTV_DECIMALS = 27;
|
|
275
282
|
var MIN_HEALTH_FACTOR = 1.5;
|
|
276
|
-
|
|
283
|
+
function withdrawDustBuffer(decimals) {
|
|
284
|
+
return 1e3 / 10 ** decimals;
|
|
285
|
+
}
|
|
277
286
|
var CLOCK = "0x06";
|
|
278
287
|
var SUI_SYSTEM_STATE = "0x05";
|
|
279
288
|
var NAVI_BALANCE_DECIMALS = 9;
|
|
@@ -396,6 +405,16 @@ function rateToApy(rawRate) {
|
|
|
396
405
|
if (!rawRate || rawRate === "0") return 0;
|
|
397
406
|
return Number(BigInt(rawRate)) / 10 ** RATE_DECIMALS * 100;
|
|
398
407
|
}
|
|
408
|
+
function poolSaveApy(pool) {
|
|
409
|
+
const incentive = parseFloat(pool.supplyIncentiveApyInfo?.apy ?? "0");
|
|
410
|
+
if (incentive > 0) return incentive;
|
|
411
|
+
return rateToApy(pool.currentSupplyRate);
|
|
412
|
+
}
|
|
413
|
+
function poolBorrowApy(pool) {
|
|
414
|
+
const incentive = parseFloat(pool.borrowIncentiveApyInfo?.apy ?? "0");
|
|
415
|
+
if (incentive > 0) return incentive;
|
|
416
|
+
return rateToApy(pool.currentBorrowRate);
|
|
417
|
+
}
|
|
399
418
|
function parseLtv(rawLtv) {
|
|
400
419
|
if (!rawLtv || rawLtv === "0") return 0.75;
|
|
401
420
|
return Number(BigInt(rawLtv)) / 10 ** LTV_DECIMALS;
|
|
@@ -505,7 +524,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
505
524
|
]);
|
|
506
525
|
const assetState = states.find((s) => s.assetId === pool.id);
|
|
507
526
|
const deposited = assetState ? compoundBalance(assetState.supplyBalance, pool.currentSupplyIndex, pool) : 0;
|
|
508
|
-
const effectiveAmount = Math.min(amount, Math.max(0, deposited -
|
|
527
|
+
const effectiveAmount = Math.min(amount, Math.max(0, deposited - withdrawDustBuffer(assetInfo.decimals)));
|
|
509
528
|
if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
|
|
510
529
|
const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
|
|
511
530
|
if (rawAmount <= 0) {
|
|
@@ -548,7 +567,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
548
567
|
]);
|
|
549
568
|
const assetState = states.find((s) => s.assetId === pool.id);
|
|
550
569
|
const deposited = assetState ? compoundBalance(assetState.supplyBalance, pool.currentSupplyIndex, pool) : 0;
|
|
551
|
-
const effectiveAmount = Math.min(amount, Math.max(0, deposited -
|
|
570
|
+
const effectiveAmount = Math.min(amount, Math.max(0, deposited - withdrawDustBuffer(assetInfo.decimals)));
|
|
552
571
|
if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
|
|
553
572
|
const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
|
|
554
573
|
if (rawAmount <= 0) {
|
|
@@ -777,7 +796,7 @@ async function getHealthFactor(client, addressOrKeypair) {
|
|
|
777
796
|
liquidationThreshold: liqThreshold
|
|
778
797
|
};
|
|
779
798
|
}
|
|
780
|
-
var NAVI_SUPPORTED_ASSETS = [...STABLE_ASSETS, "SUI", "ETH"];
|
|
799
|
+
var NAVI_SUPPORTED_ASSETS = [...STABLE_ASSETS, "SUI", "ETH", "GOLD"];
|
|
781
800
|
async function getRates(client) {
|
|
782
801
|
try {
|
|
783
802
|
const pools = await getPools();
|
|
@@ -786,10 +805,10 @@ async function getRates(client) {
|
|
|
786
805
|
const targetType = SUPPORTED_ASSETS[asset].type;
|
|
787
806
|
const pool = pools.find((p) => matchesCoinType(p.suiCoinType || p.coinType || "", targetType));
|
|
788
807
|
if (!pool) continue;
|
|
789
|
-
let saveApy =
|
|
790
|
-
let borrowApy =
|
|
791
|
-
if (saveApy <= 0 || saveApy >
|
|
792
|
-
if (borrowApy <= 0 || borrowApy >
|
|
808
|
+
let saveApy = poolSaveApy(pool);
|
|
809
|
+
let borrowApy = poolBorrowApy(pool);
|
|
810
|
+
if (saveApy <= 0 || saveApy > 200) saveApy = 0;
|
|
811
|
+
if (borrowApy <= 0 || borrowApy > 200) borrowApy = 0;
|
|
793
812
|
result[asset] = { saveApy, borrowApy };
|
|
794
813
|
}
|
|
795
814
|
if (!result.USDC) result.USDC = { saveApy: 4, borrowApy: 6 };
|
|
@@ -814,7 +833,7 @@ async function getPositions(client, addressOrKeypair) {
|
|
|
814
833
|
asset: symbol,
|
|
815
834
|
type: "save",
|
|
816
835
|
amount: supplyBal,
|
|
817
|
-
apy:
|
|
836
|
+
apy: poolSaveApy(pool)
|
|
818
837
|
});
|
|
819
838
|
}
|
|
820
839
|
if (borrowBal > 1e-4) {
|
|
@@ -823,7 +842,7 @@ async function getPositions(client, addressOrKeypair) {
|
|
|
823
842
|
asset: symbol,
|
|
824
843
|
type: "borrow",
|
|
825
844
|
amount: borrowBal,
|
|
826
|
-
apy:
|
|
845
|
+
apy: poolBorrowApy(pool)
|
|
827
846
|
});
|
|
828
847
|
}
|
|
829
848
|
}
|
|
@@ -871,7 +890,7 @@ var NaviAdapter = class {
|
|
|
871
890
|
name = "NAVI Protocol";
|
|
872
891
|
version = "1.0.0";
|
|
873
892
|
capabilities = ["save", "withdraw", "borrow", "repay"];
|
|
874
|
-
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH"];
|
|
893
|
+
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "GOLD"];
|
|
875
894
|
supportsSameAssetBorrow = true;
|
|
876
895
|
client;
|
|
877
896
|
async init(client) {
|
|
@@ -1277,7 +1296,7 @@ var SuilendAdapter = class {
|
|
|
1277
1296
|
name = "Suilend";
|
|
1278
1297
|
version = "2.0.0";
|
|
1279
1298
|
capabilities = ["save", "withdraw", "borrow", "repay"];
|
|
1280
|
-
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "BTC"];
|
|
1299
|
+
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "BTC", "GOLD"];
|
|
1281
1300
|
supportsSameAssetBorrow = false;
|
|
1282
1301
|
client;
|
|
1283
1302
|
publishedAt = null;
|