@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 +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 +39 -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 +39 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, P as PayOptions, b as PayResult, c as SendResult, B as BalanceResponse, d as TransactionRecord, D as DepositInfo, L as LendingAdapter, e as SwapAdapter, f as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, g as BorrowResult, R as RepayResult, h as MaxBorrowResult, H as HealthFactorResult, i as SwapResult, j as InvestResult, k as InvestEarnResult, l as InvestRebalanceResult, m as PendingReward, C as ClaimRewardsResult, n as StrategyBuyResult, o as StrategySellResult, p as StrategyRebalanceResult, q as StrategyStatusResult, r as AutoInvestRunResult, s as PortfolioResult, t as InvestmentPosition, u as PositionsResult, v as RatesResult, w as LendingRates, x as RebalanceResult, E as EarningsResult, F as FundStatusResult, y as SentinelAgent, z as SentinelAttackResult, G as GasMethod } from './index-D-6pQwzx.cjs';
|
|
2
|
+
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, O as AssetRates, Q as CetusAdapter, U as GasReserve, V as HealthInfo, X as InvestRebalanceMove, Y as NaviAdapter, Z as PerpsAdapter, _ as PerpsPosition, $ as PositionEntry, a0 as PositionSide, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a3 as RebalanceStep, a4 as SentinelVerdict, a5 as SuilendAdapter, a6 as SwapQuote, a7 as TradePositionsResult, a8 as TradeResult, a9 as allDescriptors, aa as cetusDescriptor, ab as getSentinelInfo, ac as listSentinels, ad as naviDescriptor, ae as requestAttack, af as sentinelAttack, ag as sentinelDescriptor, ah as settleAttack, ai as submitPrompt, aj as suilendDescriptor } from './index-D-6pQwzx.cjs';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
@@ -381,10 +381,11 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
381
381
|
address: string;
|
|
382
382
|
sponsored: boolean;
|
|
383
383
|
}>;
|
|
384
|
-
/** SuiJsonRpcClient used by this agent — exposed for
|
|
384
|
+
/** SuiJsonRpcClient used by this agent — exposed for integrations. */
|
|
385
385
|
get suiClient(): SuiJsonRpcClient;
|
|
386
|
-
/** Ed25519Keypair used by this agent — exposed for
|
|
386
|
+
/** Ed25519Keypair used by this agent — exposed for integrations. */
|
|
387
387
|
get signer(): Ed25519Keypair;
|
|
388
|
+
pay(options: PayOptions): Promise<PayResult>;
|
|
388
389
|
address(): string;
|
|
389
390
|
send(params: {
|
|
390
391
|
to: string;
|
|
@@ -662,4 +663,4 @@ interface GasStatusResponse {
|
|
|
662
663
|
}
|
|
663
664
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
664
665
|
|
|
665
|
-
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, ClaimRewardsResult, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestRebalanceResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, PendingReward, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
666
|
+
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, ClaimRewardsResult, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestRebalanceResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, PayOptions, PayResult, PendingReward, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, P as PayOptions, b as PayResult, c as SendResult, B as BalanceResponse, d as TransactionRecord, D as DepositInfo, L as LendingAdapter, e as SwapAdapter, f as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, g as BorrowResult, R as RepayResult, h as MaxBorrowResult, H as HealthFactorResult, i as SwapResult, j as InvestResult, k as InvestEarnResult, l as InvestRebalanceResult, m as PendingReward, C as ClaimRewardsResult, n as StrategyBuyResult, o as StrategySellResult, p as StrategyRebalanceResult, q as StrategyStatusResult, r as AutoInvestRunResult, s as PortfolioResult, t as InvestmentPosition, u as PositionsResult, v as RatesResult, w as LendingRates, x as RebalanceResult, E as EarningsResult, F as FundStatusResult, y as SentinelAgent, z as SentinelAttackResult, G as GasMethod } from './index-D-6pQwzx.js';
|
|
2
|
+
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, O as AssetRates, Q as CetusAdapter, U as GasReserve, V as HealthInfo, X as InvestRebalanceMove, Y as NaviAdapter, Z as PerpsAdapter, _ as PerpsPosition, $ as PositionEntry, a0 as PositionSide, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a3 as RebalanceStep, a4 as SentinelVerdict, a5 as SuilendAdapter, a6 as SwapQuote, a7 as TradePositionsResult, a8 as TradeResult, a9 as allDescriptors, aa as cetusDescriptor, ab as getSentinelInfo, ac as listSentinels, ad as naviDescriptor, ae as requestAttack, af as sentinelAttack, ag as sentinelDescriptor, ah as settleAttack, ai as submitPrompt, aj as suilendDescriptor } from './index-D-6pQwzx.js';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
@@ -381,10 +381,11 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
381
381
|
address: string;
|
|
382
382
|
sponsored: boolean;
|
|
383
383
|
}>;
|
|
384
|
-
/** SuiJsonRpcClient used by this agent — exposed for
|
|
384
|
+
/** SuiJsonRpcClient used by this agent — exposed for integrations. */
|
|
385
385
|
get suiClient(): SuiJsonRpcClient;
|
|
386
|
-
/** Ed25519Keypair used by this agent — exposed for
|
|
386
|
+
/** Ed25519Keypair used by this agent — exposed for integrations. */
|
|
387
387
|
get signer(): Ed25519Keypair;
|
|
388
|
+
pay(options: PayOptions): Promise<PayResult>;
|
|
388
389
|
address(): string;
|
|
389
390
|
send(params: {
|
|
390
391
|
to: string;
|
|
@@ -662,4 +663,4 @@ interface GasStatusResponse {
|
|
|
662
663
|
}
|
|
663
664
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
664
665
|
|
|
665
|
-
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, ClaimRewardsResult, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestRebalanceResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, PendingReward, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
666
|
+
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, ClaimRewardsResult, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestRebalanceResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, PayOptions, PayResult, PendingReward, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.js
CHANGED
|
@@ -57101,14 +57101,51 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
57101
57101
|
return { agent, address, sponsored };
|
|
57102
57102
|
}
|
|
57103
57103
|
// -- Gas --
|
|
57104
|
-
/** SuiJsonRpcClient used by this agent — exposed for
|
|
57104
|
+
/** SuiJsonRpcClient used by this agent — exposed for integrations. */
|
|
57105
57105
|
get suiClient() {
|
|
57106
57106
|
return this.client;
|
|
57107
57107
|
}
|
|
57108
|
-
/** Ed25519Keypair used by this agent — exposed for
|
|
57108
|
+
/** Ed25519Keypair used by this agent — exposed for integrations. */
|
|
57109
57109
|
get signer() {
|
|
57110
57110
|
return this.keypair;
|
|
57111
57111
|
}
|
|
57112
|
+
// -- MPP Payments --
|
|
57113
|
+
async pay(options) {
|
|
57114
|
+
this.enforcer.assertNotLocked();
|
|
57115
|
+
this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
|
|
57116
|
+
const { Mppx } = await import('mppx/client');
|
|
57117
|
+
const { sui } = await import('@t2000/mpp-sui/client');
|
|
57118
|
+
const mppx = Mppx.create({
|
|
57119
|
+
polyfill: false,
|
|
57120
|
+
methods: [sui({ client: this.client, signer: this.keypair })]
|
|
57121
|
+
});
|
|
57122
|
+
const method = (options.method ?? "GET").toUpperCase();
|
|
57123
|
+
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
57124
|
+
const response = await mppx.fetch(options.url, {
|
|
57125
|
+
method,
|
|
57126
|
+
headers: options.headers,
|
|
57127
|
+
body: canHaveBody ? options.body : void 0
|
|
57128
|
+
});
|
|
57129
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
57130
|
+
let body;
|
|
57131
|
+
try {
|
|
57132
|
+
body = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
57133
|
+
} catch {
|
|
57134
|
+
body = null;
|
|
57135
|
+
}
|
|
57136
|
+
const receiptHeader = response.headers.get("x-payment-receipt");
|
|
57137
|
+
const paid = !!receiptHeader;
|
|
57138
|
+
if (paid) {
|
|
57139
|
+
this.enforcer.recordUsage(options.maxPrice ?? 1);
|
|
57140
|
+
}
|
|
57141
|
+
return {
|
|
57142
|
+
status: response.status,
|
|
57143
|
+
body,
|
|
57144
|
+
paid,
|
|
57145
|
+
cost: paid ? options.maxPrice ?? void 0 : void 0,
|
|
57146
|
+
receipt: receiptHeader ? { reference: receiptHeader, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
|
|
57147
|
+
};
|
|
57148
|
+
}
|
|
57112
57149
|
// -- Wallet --
|
|
57113
57150
|
address() {
|
|
57114
57151
|
return this._address;
|