@t2000/sdk 0.18.42 → 0.19.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 CHANGED
@@ -5,7 +5,7 @@ The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn y
5
5
  [![npm](https://img.shields.io/npm/v/@t2000/sdk)](https://www.npmjs.com/package/@t2000/sdk)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](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)** · **[x402](https://www.npmjs.com/package/@t2000/x402)** · **[MCP](https://www.npmjs.com/package/@t2000/mcp)**
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/x402`), the agent exposes:
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 (x402) | Free | Agent pays the API price, no t2000 surcharge |
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 { y as AdapterCapability, z as AdapterPositions, J as AdapterTxResult, N as CetusAdapter, Q as HealthInfo, L as LendingAdapter, u as LendingRates, V as NaviAdapter, X as PerpsAdapter, $ as ProtocolDescriptor, a0 as ProtocolRegistry, a3 as SuilendAdapter, d as SwapAdapter, a4 as SwapQuote, a7 as allDescriptors, a8 as cetusDescriptor, ab as naviDescriptor, ae as sentinelDescriptor, ah as suilendDescriptor } from '../index-HADTiik7.cjs';
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';
@@ -1,4 +1,4 @@
1
- export { y as AdapterCapability, z as AdapterPositions, J as AdapterTxResult, N as CetusAdapter, Q as HealthInfo, L as LendingAdapter, u as LendingRates, V as NaviAdapter, X as PerpsAdapter, $ as ProtocolDescriptor, a0 as ProtocolRegistry, a3 as SuilendAdapter, d as SwapAdapter, a4 as SwapQuote, a7 as allDescriptors, a8 as cetusDescriptor, ab as naviDescriptor, ae as sentinelDescriptor, ah as suilendDescriptor } from '../index-HADTiik7.js';
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 ProtocolDescriptor 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 AdapterTxResult as J, type AssetRates as K, type LendingAdapter as L, type MaxWithdrawResult as M, CetusAdapter as N, type GasReserve as O, type PendingReward$1 as P, type HealthInfo as Q, type RepayResult as R, type StrategyDefinition as S, type T2000Options as T, type InvestRebalanceMove as U, NaviAdapter as V, type WithdrawResult as W, type PerpsAdapter as X, type PerpsPosition as Y, type PositionEntry as Z, type PositionSide as _, type AutoInvestStatus as a, ProtocolRegistry as a0, type RebalanceStep as a1, type SentinelVerdict as a2, SuilendAdapter as a3, type SwapQuote as a4, type TradePositionsResult as a5, type TradeResult as a6, allDescriptors as a7, descriptor$2 as a8, getSentinelInfo as a9, listSentinels as aa, descriptor$3 as ab, requestAttack as ac, attack as ad, descriptor as ae, settleAttack as af, submitPrompt as ag, descriptor$1 as ah, type SendResult as b, type TransactionRecord as c, type SwapAdapter as d, type SaveResult as e, type BorrowResult as f, type MaxBorrowResult as g, type SwapResult as h, type InvestResult as i, type InvestEarnResult as j, type InvestRebalanceResult as k, type StrategyBuyResult as l, type StrategySellResult as m, type StrategyRebalanceResult as n, type StrategyStatusResult as o, type AutoInvestRunResult as p, type PortfolioResult as q, type InvestmentPosition as r, type PositionsResult as s, type RatesResult as t, type LendingRates as u, type RebalanceResult as v, type SentinelAgent as w, type SentinelAttackResult as x, type AdapterCapability as y, type AdapterPositions as z };
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 ProtocolDescriptor 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 AdapterTxResult as J, type AssetRates as K, type LendingAdapter as L, type MaxWithdrawResult as M, CetusAdapter as N, type GasReserve as O, type PendingReward$1 as P, type HealthInfo as Q, type RepayResult as R, type StrategyDefinition as S, type T2000Options as T, type InvestRebalanceMove as U, NaviAdapter as V, type WithdrawResult as W, type PerpsAdapter as X, type PerpsPosition as Y, type PositionEntry as Z, type PositionSide as _, type AutoInvestStatus as a, ProtocolRegistry as a0, type RebalanceStep as a1, type SentinelVerdict as a2, SuilendAdapter as a3, type SwapQuote as a4, type TradePositionsResult as a5, type TradeResult as a6, allDescriptors as a7, descriptor$2 as a8, getSentinelInfo as a9, listSentinels as aa, descriptor$3 as ab, requestAttack as ac, attack as ad, descriptor as ae, settleAttack as af, submitPrompt as ag, descriptor$1 as ah, type SendResult as b, type TransactionRecord as c, type SwapAdapter as d, type SaveResult as e, type BorrowResult as f, type MaxBorrowResult as g, type SwapResult as h, type InvestResult as i, type InvestEarnResult as j, type InvestRebalanceResult as k, type StrategyBuyResult as l, type StrategySellResult as m, type StrategyRebalanceResult as n, type StrategyStatusResult as o, type AutoInvestRunResult as p, type PortfolioResult as q, type InvestmentPosition as r, type PositionsResult as s, type RatesResult as t, type LendingRates as u, type RebalanceResult as v, type SentinelAgent as w, type SentinelAttackResult as x, type AdapterCapability as y, type AdapterPositions as z };
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,51 @@ 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 x402 and other integrations. */
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 x402 and other integrations. */
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 method = (options.method ?? "GET").toUpperCase();
57126
+ const canHaveBody = method !== "GET" && method !== "HEAD";
57127
+ const response = await mppx.fetch(options.url, {
57128
+ method,
57129
+ headers: options.headers,
57130
+ body: canHaveBody ? options.body : void 0
57131
+ });
57132
+ const contentType = response.headers.get("content-type") ?? "";
57133
+ let body;
57134
+ try {
57135
+ body = contentType.includes("application/json") ? await response.json() : await response.text();
57136
+ } catch {
57137
+ body = null;
57138
+ }
57139
+ const receiptHeader = response.headers.get("x-payment-receipt");
57140
+ const paid = !!receiptHeader;
57141
+ if (paid) {
57142
+ this.enforcer.recordUsage(options.maxPrice ?? 1);
57143
+ }
57144
+ return {
57145
+ status: response.status,
57146
+ body,
57147
+ paid,
57148
+ cost: paid ? options.maxPrice ?? void 0 : void 0,
57149
+ receipt: receiptHeader ? { reference: receiptHeader, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
57150
+ };
57151
+ }
57115
57152
  // -- Wallet --
57116
57153
  address() {
57117
57154
  return this._address;