@t2000/sdk 0.18.42 → 0.19.0
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 +3 -3
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{index-HADTiik7.d.cts → index-D-6pQwzx.d.cts} +18 -1
- package/dist/{index-HADTiik7.d.ts → index-D-6pQwzx.d.ts} +18 -1
- package/dist/index.cjs +37 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn y
|
|
|
5
5
|
[](https://www.npmjs.com/package/@t2000/sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
**[Website](https://t2000.ai)** · **[GitHub](https://github.com/mission69b/t2000)** · **[CLI](https://www.npmjs.com/package/@t2000/cli)** · **[
|
|
8
|
+
**[Website](https://t2000.ai)** · **[GitHub](https://github.com/mission69b/t2000)** · **[CLI](https://www.npmjs.com/package/@t2000/cli)** · **[MPP](https://www.npmjs.com/package/@t2000/mpp-sui)** · **[MCP](https://www.npmjs.com/package/@t2000/mcp)**
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -319,7 +319,7 @@ formatAssetAmount('SUI', 105.26); // "105.260000000" (9 decimals)
|
|
|
319
319
|
|
|
320
320
|
### Advanced: Exposed Internals
|
|
321
321
|
|
|
322
|
-
For integrations (like `@t2000/
|
|
322
|
+
For integrations (like `@t2000/mpp-sui`), the agent exposes:
|
|
323
323
|
|
|
324
324
|
```typescript
|
|
325
325
|
agent.suiClient; // SuiJsonRpcClient instance
|
|
@@ -437,7 +437,7 @@ SMOKE=1 pnpm --filter @t2000/sdk test -- src/__smoke__
|
|
|
437
437
|
| Withdraw | Free | |
|
|
438
438
|
| Repay | Free | |
|
|
439
439
|
| Send | Free | |
|
|
440
|
-
| Pay (
|
|
440
|
+
| Pay (MPP) | Free | Agent pays the API price, no t2000 surcharge |
|
|
441
441
|
|
|
442
442
|
Fees are collected by the t2000 protocol treasury on-chain.
|
|
443
443
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, Q as CetusAdapter, V as HealthInfo, L as LendingAdapter, w as LendingRates, Y as NaviAdapter, Z as PerpsAdapter, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a5 as SuilendAdapter, e as SwapAdapter, a6 as SwapQuote, a9 as allDescriptors, aa as cetusDescriptor, ad as naviDescriptor, ag as sentinelDescriptor, aj as suilendDescriptor } from '../index-D-6pQwzx.cjs';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, Q as CetusAdapter, V as HealthInfo, L as LendingAdapter, w as LendingRates, Y as NaviAdapter, Z as PerpsAdapter, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a5 as SuilendAdapter, e as SwapAdapter, a6 as SwapQuote, a9 as allDescriptors, aa as cetusDescriptor, ad as naviDescriptor, ag as sentinelDescriptor, aj as suilendDescriptor } from '../index-D-6pQwzx.js';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
|
@@ -421,6 +421,23 @@ interface TradePositionsResult {
|
|
|
421
421
|
totalMargin: number;
|
|
422
422
|
totalUnrealizedPnL: number;
|
|
423
423
|
}
|
|
424
|
+
interface PayOptions {
|
|
425
|
+
url: string;
|
|
426
|
+
method?: string;
|
|
427
|
+
body?: string;
|
|
428
|
+
headers?: Record<string, string>;
|
|
429
|
+
maxPrice?: number;
|
|
430
|
+
}
|
|
431
|
+
interface PayResult {
|
|
432
|
+
status: number;
|
|
433
|
+
body: unknown;
|
|
434
|
+
paid: boolean;
|
|
435
|
+
cost?: number;
|
|
436
|
+
receipt?: {
|
|
437
|
+
reference: string;
|
|
438
|
+
timestamp: string;
|
|
439
|
+
};
|
|
440
|
+
}
|
|
424
441
|
|
|
425
442
|
type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay' | 'swap' | 'perps';
|
|
426
443
|
/**
|
|
@@ -760,4 +777,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
|
|
|
760
777
|
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
761
778
|
declare const allDescriptors: ProtocolDescriptor[];
|
|
762
779
|
|
|
763
|
-
export { type
|
|
780
|
+
export { type PositionEntry as $, type AutoInvestSchedule as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, type InvestmentTrade as I, type AdapterCapability as J, type AdapterPositions as K, type LendingAdapter as L, type MaxWithdrawResult as M, type AdapterTxResult as N, type AssetRates as O, type PayOptions as P, CetusAdapter as Q, type RepayResult as R, type StrategyDefinition as S, type T2000Options as T, type GasReserve as U, type HealthInfo as V, type WithdrawResult as W, type InvestRebalanceMove as X, NaviAdapter as Y, type PerpsAdapter as Z, type PerpsPosition as _, type AutoInvestStatus as a, type PositionSide as a0, type ProtocolDescriptor as a1, ProtocolRegistry as a2, type RebalanceStep as a3, type SentinelVerdict as a4, SuilendAdapter as a5, type SwapQuote as a6, type TradePositionsResult as a7, type TradeResult as a8, allDescriptors as a9, descriptor$2 as aa, getSentinelInfo as ab, listSentinels as ac, descriptor$3 as ad, requestAttack as ae, attack as af, descriptor as ag, settleAttack as ah, submitPrompt as ai, descriptor$1 as aj, type PayResult as b, type SendResult as c, type TransactionRecord as d, type SwapAdapter as e, type SaveResult as f, type BorrowResult as g, type MaxBorrowResult as h, type SwapResult as i, type InvestResult as j, type InvestEarnResult as k, type InvestRebalanceResult as l, type PendingReward$1 as m, type StrategyBuyResult as n, type StrategySellResult as o, type StrategyRebalanceResult as p, type StrategyStatusResult as q, type AutoInvestRunResult as r, type PortfolioResult as s, type InvestmentPosition as t, type PositionsResult as u, type RatesResult as v, type LendingRates as w, type RebalanceResult as x, type SentinelAgent as y, type SentinelAttackResult as z };
|
|
@@ -421,6 +421,23 @@ interface TradePositionsResult {
|
|
|
421
421
|
totalMargin: number;
|
|
422
422
|
totalUnrealizedPnL: number;
|
|
423
423
|
}
|
|
424
|
+
interface PayOptions {
|
|
425
|
+
url: string;
|
|
426
|
+
method?: string;
|
|
427
|
+
body?: string;
|
|
428
|
+
headers?: Record<string, string>;
|
|
429
|
+
maxPrice?: number;
|
|
430
|
+
}
|
|
431
|
+
interface PayResult {
|
|
432
|
+
status: number;
|
|
433
|
+
body: unknown;
|
|
434
|
+
paid: boolean;
|
|
435
|
+
cost?: number;
|
|
436
|
+
receipt?: {
|
|
437
|
+
reference: string;
|
|
438
|
+
timestamp: string;
|
|
439
|
+
};
|
|
440
|
+
}
|
|
424
441
|
|
|
425
442
|
type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay' | 'swap' | 'perps';
|
|
426
443
|
/**
|
|
@@ -760,4 +777,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
|
|
|
760
777
|
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
761
778
|
declare const allDescriptors: ProtocolDescriptor[];
|
|
762
779
|
|
|
763
|
-
export { type
|
|
780
|
+
export { type PositionEntry as $, type AutoInvestSchedule as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, type InvestmentTrade as I, type AdapterCapability as J, type AdapterPositions as K, type LendingAdapter as L, type MaxWithdrawResult as M, type AdapterTxResult as N, type AssetRates as O, type PayOptions as P, CetusAdapter as Q, type RepayResult as R, type StrategyDefinition as S, type T2000Options as T, type GasReserve as U, type HealthInfo as V, type WithdrawResult as W, type InvestRebalanceMove as X, NaviAdapter as Y, type PerpsAdapter as Z, type PerpsPosition as _, type AutoInvestStatus as a, type PositionSide as a0, type ProtocolDescriptor as a1, ProtocolRegistry as a2, type RebalanceStep as a3, type SentinelVerdict as a4, SuilendAdapter as a5, type SwapQuote as a6, type TradePositionsResult as a7, type TradeResult as a8, allDescriptors as a9, descriptor$2 as aa, getSentinelInfo as ab, listSentinels as ac, descriptor$3 as ad, requestAttack as ae, attack as af, descriptor as ag, settleAttack as ah, submitPrompt as ai, descriptor$1 as aj, type PayResult as b, type SendResult as c, type TransactionRecord as d, type SwapAdapter as e, type SaveResult as f, type BorrowResult as g, type MaxBorrowResult as h, type SwapResult as i, type InvestResult as j, type InvestEarnResult as k, type InvestRebalanceResult as l, type PendingReward$1 as m, type StrategyBuyResult as n, type StrategySellResult as o, type StrategyRebalanceResult as p, type StrategyStatusResult as q, type AutoInvestRunResult as r, type PortfolioResult as s, type InvestmentPosition as t, type PositionsResult as u, type RatesResult as v, type LendingRates as w, type RebalanceResult as x, type SentinelAgent as y, type SentinelAttackResult as z };
|
package/dist/index.cjs
CHANGED
|
@@ -57104,14 +57104,49 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
57104
57104
|
return { agent, address, sponsored };
|
|
57105
57105
|
}
|
|
57106
57106
|
// -- Gas --
|
|
57107
|
-
/** SuiJsonRpcClient used by this agent — exposed for
|
|
57107
|
+
/** SuiJsonRpcClient used by this agent — exposed for integrations. */
|
|
57108
57108
|
get suiClient() {
|
|
57109
57109
|
return this.client;
|
|
57110
57110
|
}
|
|
57111
|
-
/** Ed25519Keypair used by this agent — exposed for
|
|
57111
|
+
/** Ed25519Keypair used by this agent — exposed for integrations. */
|
|
57112
57112
|
get signer() {
|
|
57113
57113
|
return this.keypair;
|
|
57114
57114
|
}
|
|
57115
|
+
// -- MPP Payments --
|
|
57116
|
+
async pay(options) {
|
|
57117
|
+
this.enforcer.assertNotLocked();
|
|
57118
|
+
this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
|
|
57119
|
+
const { Mppx } = await import('mppx/client');
|
|
57120
|
+
const { sui } = await import('@t2000/mpp-sui/client');
|
|
57121
|
+
const mppx = Mppx.create({
|
|
57122
|
+
polyfill: false,
|
|
57123
|
+
methods: [sui({ client: this.client, signer: this.keypair })]
|
|
57124
|
+
});
|
|
57125
|
+
const response = await mppx.fetch(options.url, {
|
|
57126
|
+
method: options.method,
|
|
57127
|
+
headers: options.headers,
|
|
57128
|
+
body: options.body
|
|
57129
|
+
});
|
|
57130
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
57131
|
+
let body;
|
|
57132
|
+
try {
|
|
57133
|
+
body = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
57134
|
+
} catch {
|
|
57135
|
+
body = null;
|
|
57136
|
+
}
|
|
57137
|
+
const receiptHeader = response.headers.get("x-payment-receipt");
|
|
57138
|
+
const paid = !!receiptHeader;
|
|
57139
|
+
if (paid) {
|
|
57140
|
+
this.enforcer.recordUsage(options.maxPrice ?? 1);
|
|
57141
|
+
}
|
|
57142
|
+
return {
|
|
57143
|
+
status: response.status,
|
|
57144
|
+
body,
|
|
57145
|
+
paid,
|
|
57146
|
+
cost: paid ? options.maxPrice ?? void 0 : void 0,
|
|
57147
|
+
receipt: receiptHeader ? { reference: receiptHeader, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
|
|
57148
|
+
};
|
|
57149
|
+
}
|
|
57115
57150
|
// -- Wallet --
|
|
57116
57151
|
address() {
|
|
57117
57152
|
return this._address;
|