@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
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @t2000/sdk
|
|
2
2
|
|
|
3
|
-
The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn yield via NAVI
|
|
3
|
+
The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn yield via NAVI + Suilend, swap on Cetus DEX, borrow against collateral — all from a single class.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@t2000/sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -37,7 +37,7 @@ console.log(`$${balance.available} USDC available`);
|
|
|
37
37
|
// Send USDC
|
|
38
38
|
await agent.send({ to: '0x...', amount: 10 });
|
|
39
39
|
|
|
40
|
-
// Save (earn yield
|
|
40
|
+
// Save (earn yield — auto-selects best rate across NAVI + Suilend)
|
|
41
41
|
await agent.save({ amount: 50, asset: 'USDC' });
|
|
42
42
|
|
|
43
43
|
// Swap USDC → SUI (via Cetus DEX)
|
|
@@ -89,7 +89,7 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
89
89
|
| `agent.address()` | Wallet Sui address | `string` |
|
|
90
90
|
| `agent.balance()` | Available USDC + savings + gas reserve | `BalanceResponse` |
|
|
91
91
|
| `agent.send({ to, amount, asset? })` | Transfer USDC to any Sui address | `SendResult` |
|
|
92
|
-
| `agent.save({ amount, asset })` | Deposit USDC to
|
|
92
|
+
| `agent.save({ amount, asset, protocol? })` | Deposit USDC to savings (earn APY). Auto-selects best rate or specify `protocol`. `amount` can be `'all'`. | `SaveResult` |
|
|
93
93
|
| `agent.withdraw({ amount, asset })` | Withdraw USDC from savings. `amount` can be `'all'`. | `WithdrawResult` |
|
|
94
94
|
| `agent.swap({ from, to, amount, maxSlippage? })` | Swap via Cetus CLMM DEX. `maxSlippage` in % (default: 3). | `SwapResult` |
|
|
95
95
|
| `agent.swapQuote({ from, to, amount })` | Get swap quote without executing | `SwapQuote` |
|
|
@@ -103,7 +103,7 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
103
103
|
|--------|-------------|---------|
|
|
104
104
|
| `agent.healthFactor()` | Lending health factor | `HealthFactorResult` |
|
|
105
105
|
| `agent.earnings()` | Yield earned to date | `EarningsResult` |
|
|
106
|
-
| `agent.rates()` |
|
|
106
|
+
| `agent.rates()` | Best save/borrow APYs across protocols | `RatesResult` |
|
|
107
107
|
| `agent.positions()` | All open DeFi positions | `PositionsResult` |
|
|
108
108
|
| `agent.fundStatus()` | Complete savings summary | `FundStatusResult` |
|
|
109
109
|
| `agent.maxWithdraw()` | Max safe withdrawal amount | `MaxWithdrawResult` |
|
|
@@ -227,7 +227,7 @@ Every operation (send, save, borrow, repay, withdraw, swap) routes through a 3-s
|
|
|
227
227
|
|
|
228
228
|
Every transaction result includes a `gasMethod` field (`'self-funded'` | `'auto-topup'` | `'sponsored'`) indicating which strategy was used.
|
|
229
229
|
|
|
230
|
-
**Architecture:** Each protocol operation (NAVI, Cetus, send) exposes a `buildXxxTx()` function that returns a `Transaction` without executing it. `executeWithGas()` then handles execution with the fallback chain. This separation ensures gas management is consistent across all operations.
|
|
230
|
+
**Architecture:** Each protocol operation (NAVI, Suilend, Cetus, send) exposes a `buildXxxTx()` function that returns a `Transaction` without executing it. `executeWithGas()` then handles execution with the fallback chain. This separation ensures gas management is consistent across all operations.
|
|
231
231
|
|
|
232
232
|
## Configuration
|
|
233
233
|
|
|
@@ -264,7 +264,7 @@ Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOU
|
|
|
264
264
|
## Testing
|
|
265
265
|
|
|
266
266
|
```bash
|
|
267
|
-
# Run all SDK unit tests (
|
|
267
|
+
# Run all SDK unit tests (262 tests)
|
|
268
268
|
pnpm --filter @t2000/sdk test
|
|
269
269
|
```
|
|
270
270
|
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -150,6 +150,9 @@ var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523
|
|
|
150
150
|
var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
|
|
151
151
|
process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
152
152
|
var CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
153
|
+
var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
|
|
154
|
+
var SENTINEL = {
|
|
155
|
+
PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7"};
|
|
153
156
|
|
|
154
157
|
// src/utils/format.ts
|
|
155
158
|
function usdcToRaw(amount) {
|
|
@@ -586,6 +589,22 @@ async function maxBorrowAmount(client, addressOrKeypair) {
|
|
|
586
589
|
}
|
|
587
590
|
|
|
588
591
|
// src/adapters/navi.ts
|
|
592
|
+
var descriptor = {
|
|
593
|
+
id: "navi",
|
|
594
|
+
name: "NAVI Protocol",
|
|
595
|
+
packages: [],
|
|
596
|
+
dynamicPackageId: true,
|
|
597
|
+
actionMap: {
|
|
598
|
+
"incentive_v3::entry_deposit": "save",
|
|
599
|
+
"incentive_v3::deposit": "save",
|
|
600
|
+
"incentive_v3::withdraw_v2": "withdraw",
|
|
601
|
+
"incentive_v3::entry_withdraw": "withdraw",
|
|
602
|
+
"incentive_v3::borrow_v2": "borrow",
|
|
603
|
+
"incentive_v3::entry_borrow": "borrow",
|
|
604
|
+
"incentive_v3::entry_repay": "repay",
|
|
605
|
+
"incentive_v3::repay": "repay"
|
|
606
|
+
}
|
|
607
|
+
};
|
|
589
608
|
var NaviAdapter = class {
|
|
590
609
|
id = "navi";
|
|
591
610
|
name = "NAVI Protocol";
|
|
@@ -730,6 +749,18 @@ function fallbackQuote(fromAsset, amount, poolPrice) {
|
|
|
730
749
|
}
|
|
731
750
|
|
|
732
751
|
// src/adapters/cetus.ts
|
|
752
|
+
var descriptor2 = {
|
|
753
|
+
id: "cetus",
|
|
754
|
+
name: "Cetus DEX",
|
|
755
|
+
packages: [CETUS_PACKAGE],
|
|
756
|
+
actionMap: {
|
|
757
|
+
"router::swap": "swap",
|
|
758
|
+
"router::swap_ab_bc": "swap",
|
|
759
|
+
"router::swap_ab_cb": "swap",
|
|
760
|
+
"router::swap_ba_bc": "swap",
|
|
761
|
+
"router::swap_ba_cb": "swap"
|
|
762
|
+
}
|
|
763
|
+
};
|
|
733
764
|
var CetusAdapter = class {
|
|
734
765
|
id = "cetus";
|
|
735
766
|
name = "Cetus";
|
|
@@ -783,7 +814,21 @@ var LENDING_MARKET_ID = "0x84030d26d85eaa7035084a057f2f11f701b7e2e4eda87551becbc
|
|
|
783
814
|
var LENDING_MARKET_TYPE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::suilend::MAIN_POOL";
|
|
784
815
|
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
785
816
|
var UPGRADE_CAP_ID = "0x3d4ef1859c3ee9fc72858f588b56a09da5466e64f8cc4e90a7b3b909fba8a7ae";
|
|
786
|
-
var FALLBACK_PUBLISHED_AT = "
|
|
817
|
+
var FALLBACK_PUBLISHED_AT = "0x3d4353f3bd3565329655e6b77bc2abfd31e558b86662ebd078ae453d416bc10f";
|
|
818
|
+
var descriptor3 = {
|
|
819
|
+
id: "suilend",
|
|
820
|
+
name: "Suilend",
|
|
821
|
+
packages: [SUILEND_PACKAGE],
|
|
822
|
+
actionMap: {
|
|
823
|
+
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
824
|
+
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
825
|
+
"lending_market::create_obligation": "save",
|
|
826
|
+
"lending_market::withdraw_ctokens": "withdraw",
|
|
827
|
+
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
828
|
+
"lending_market::borrow": "borrow",
|
|
829
|
+
"lending_market::repay": "repay"
|
|
830
|
+
}
|
|
831
|
+
};
|
|
787
832
|
function interpolateRate(utilBreakpoints, aprBreakpoints, utilizationPct) {
|
|
788
833
|
if (utilBreakpoints.length === 0) return 0;
|
|
789
834
|
if (utilizationPct <= utilBreakpoints[0]) return aprBreakpoints[0];
|
|
@@ -1161,10 +1206,32 @@ var SuilendAdapter = class {
|
|
|
1161
1206
|
return all;
|
|
1162
1207
|
}
|
|
1163
1208
|
};
|
|
1209
|
+
var descriptor4 = {
|
|
1210
|
+
id: "sentinel",
|
|
1211
|
+
name: "Sui Sentinel",
|
|
1212
|
+
packages: [SENTINEL.PACKAGE],
|
|
1213
|
+
actionMap: {
|
|
1214
|
+
"sentinel::request_attack": "sentinel_attack",
|
|
1215
|
+
"sentinel::consume_prompt": "sentinel_settle"
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
// src/adapters/index.ts
|
|
1220
|
+
var allDescriptors = [
|
|
1221
|
+
descriptor,
|
|
1222
|
+
descriptor3,
|
|
1223
|
+
descriptor2,
|
|
1224
|
+
descriptor4
|
|
1225
|
+
];
|
|
1164
1226
|
|
|
1165
1227
|
exports.CetusAdapter = CetusAdapter;
|
|
1166
1228
|
exports.NaviAdapter = NaviAdapter;
|
|
1167
1229
|
exports.ProtocolRegistry = ProtocolRegistry;
|
|
1168
1230
|
exports.SuilendAdapter = SuilendAdapter;
|
|
1231
|
+
exports.allDescriptors = allDescriptors;
|
|
1232
|
+
exports.cetusDescriptor = descriptor2;
|
|
1233
|
+
exports.naviDescriptor = descriptor;
|
|
1234
|
+
exports.sentinelDescriptor = descriptor4;
|
|
1235
|
+
exports.suilendDescriptor = descriptor3;
|
|
1169
1236
|
//# sourceMappingURL=index.cjs.map
|
|
1170
1237
|
//# sourceMappingURL=index.cjs.map
|