@t2000/sdk 0.8.6 → 0.9.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 +22 -24
- package/dist/adapters/index.cjs +0 -18
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +0 -18
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-DNjooNFy.d.cts → index-C7W686z2.d.cts} +1 -4
- package/dist/{index-DNjooNFy.d.ts → index-C7W686z2.d.ts} +1 -4
- package/dist/index.cjs +115 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -41
- package/dist/index.d.ts +7 -41
- package/dist/index.js +116 -80
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult,
|
|
5
|
-
export { A as AdapterCapability,
|
|
4
|
+
import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult, P as PositionsResult, f as RatesResult, g as LendingRates, h as RebalanceResult, E as EarningsResult, F as FundStatusResult, i as SentinelAgent, j as SentinelAttackResult, G as GasMethod } from './index-C7W686z2.cjs';
|
|
5
|
+
export { A as AdapterCapability, k as AdapterPositions, l as AdapterTxResult, m as AssetRates, C as CetusAdapter, n as GasReserve, o as HealthInfo, N as NaviAdapter, p as PositionEntry, q as ProtocolDescriptor, r as ProtocolRegistry, s as RebalanceStep, t as SentinelVerdict, u as SuilendAdapter, v as SwapQuote, w as SwapResult, x as allDescriptors, y as cetusDescriptor, z as getSentinelInfo, I as listSentinels, J as naviDescriptor, K as requestAttack, O as sentinelAttack, Q as sentinelDescriptor, U as settleAttack, V as submitPrompt, X as suilendDescriptor } from './index-C7W686z2.cjs';
|
|
6
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
7
|
|
|
8
|
-
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'SPONSOR_UNAVAILABLE' | 'AUTO_TOPUP_FAILED' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'FACILITATOR_TIMEOUT' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'UNKNOWN';
|
|
8
|
+
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'SPONSOR_UNAVAILABLE' | 'AUTO_TOPUP_FAILED' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'FACILITATOR_TIMEOUT' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'UNKNOWN';
|
|
9
9
|
interface T2000ErrorData {
|
|
10
10
|
reason?: string;
|
|
11
11
|
[key: string]: unknown;
|
|
@@ -102,48 +102,27 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
102
102
|
registerAdapter(adapter: LendingAdapter | SwapAdapter): Promise<void>;
|
|
103
103
|
save(params: {
|
|
104
104
|
amount: number | 'all';
|
|
105
|
-
asset?: string;
|
|
106
105
|
protocol?: string;
|
|
107
106
|
}): Promise<SaveResult>;
|
|
108
107
|
withdraw(params: {
|
|
109
108
|
amount: number | 'all';
|
|
110
|
-
asset?: string;
|
|
111
109
|
protocol?: string;
|
|
112
110
|
}): Promise<WithdrawResult>;
|
|
113
111
|
private withdrawAllProtocols;
|
|
112
|
+
private _swapToUsdc;
|
|
114
113
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
115
114
|
borrow(params: {
|
|
116
115
|
amount: number;
|
|
117
|
-
asset?: string;
|
|
118
116
|
protocol?: string;
|
|
119
117
|
}): Promise<BorrowResult>;
|
|
120
118
|
repay(params: {
|
|
121
119
|
amount: number | 'all';
|
|
122
|
-
asset?: string;
|
|
123
120
|
protocol?: string;
|
|
124
121
|
}): Promise<RepayResult>;
|
|
125
122
|
maxBorrow(): Promise<MaxBorrowResult>;
|
|
126
123
|
healthFactor(): Promise<HealthFactorResult>;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
to: string;
|
|
130
|
-
amount: number;
|
|
131
|
-
maxSlippage?: number;
|
|
132
|
-
protocol?: string;
|
|
133
|
-
}): Promise<SwapResult>;
|
|
134
|
-
swapQuote(params: {
|
|
135
|
-
from: string;
|
|
136
|
-
to: string;
|
|
137
|
-
amount: number;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
expectedOutput: number;
|
|
140
|
-
priceImpact: number;
|
|
141
|
-
poolPrice: number;
|
|
142
|
-
fee: {
|
|
143
|
-
amount: number;
|
|
144
|
-
rate: number;
|
|
145
|
-
};
|
|
146
|
-
}>;
|
|
124
|
+
private _swap;
|
|
125
|
+
private _swapQuote;
|
|
147
126
|
positions(): Promise<PositionsResult>;
|
|
148
127
|
rates(): Promise<RatesResult>;
|
|
149
128
|
allRates(asset?: string): Promise<{
|
|
@@ -209,8 +188,6 @@ declare const SUPPORTED_ASSETS: {
|
|
|
209
188
|
};
|
|
210
189
|
};
|
|
211
190
|
type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
|
|
212
|
-
type StableAsset = Exclude<SupportedAsset, 'SUI'>;
|
|
213
|
-
declare const STABLE_ASSETS: readonly StableAsset[];
|
|
214
191
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
215
192
|
declare const SENTINEL: {
|
|
216
193
|
readonly PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7";
|
|
@@ -236,12 +213,6 @@ declare function rawToStable(raw: bigint, decimals: number): number;
|
|
|
236
213
|
declare function getDecimals(asset: SupportedAsset): number;
|
|
237
214
|
declare function formatUsd(amount: number): string;
|
|
238
215
|
declare function formatSui(amount: number): string;
|
|
239
|
-
/**
|
|
240
|
-
* Case-insensitive lookup against SUPPORTED_ASSETS keys AND display names.
|
|
241
|
-
* 'usde' → 'USDe', 'suiusde' → 'USDe', 'suiusdt' → 'USDT', 'usdsui' → 'USDsui'.
|
|
242
|
-
* Returns the original input if not found so downstream validation can reject it.
|
|
243
|
-
*/
|
|
244
|
-
declare function normalizeAsset(input: string): string;
|
|
245
216
|
|
|
246
217
|
declare function generateKeypair(): Ed25519Keypair;
|
|
247
218
|
declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
|
|
@@ -282,11 +253,6 @@ declare function simulateTransaction(client: SuiJsonRpcClient, tx: Transaction,
|
|
|
282
253
|
declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
283
254
|
|
|
284
255
|
declare function getPoolPrice(client: SuiJsonRpcClient): Promise<number>;
|
|
285
|
-
declare function getSwapQuote(client: SuiJsonRpcClient, fromAsset: string, toAsset: string, amount: number): Promise<{
|
|
286
|
-
expectedOutput: number;
|
|
287
|
-
priceImpact: number;
|
|
288
|
-
poolPrice: number;
|
|
289
|
-
}>;
|
|
290
256
|
|
|
291
257
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
292
258
|
|
|
@@ -329,4 +295,4 @@ interface GasStatusResponse {
|
|
|
329
295
|
}
|
|
330
296
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
331
297
|
|
|
332
|
-
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL,
|
|
298
|
+
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type SupportedAsset, SwapAdapter, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, 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,11 +1,11 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult,
|
|
5
|
-
export { A as AdapterCapability,
|
|
4
|
+
import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult, P as PositionsResult, f as RatesResult, g as LendingRates, h as RebalanceResult, E as EarningsResult, F as FundStatusResult, i as SentinelAgent, j as SentinelAttackResult, G as GasMethod } from './index-C7W686z2.js';
|
|
5
|
+
export { A as AdapterCapability, k as AdapterPositions, l as AdapterTxResult, m as AssetRates, C as CetusAdapter, n as GasReserve, o as HealthInfo, N as NaviAdapter, p as PositionEntry, q as ProtocolDescriptor, r as ProtocolRegistry, s as RebalanceStep, t as SentinelVerdict, u as SuilendAdapter, v as SwapQuote, w as SwapResult, x as allDescriptors, y as cetusDescriptor, z as getSentinelInfo, I as listSentinels, J as naviDescriptor, K as requestAttack, O as sentinelAttack, Q as sentinelDescriptor, U as settleAttack, V as submitPrompt, X as suilendDescriptor } from './index-C7W686z2.js';
|
|
6
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
7
|
|
|
8
|
-
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'SPONSOR_UNAVAILABLE' | 'AUTO_TOPUP_FAILED' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'FACILITATOR_TIMEOUT' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'UNKNOWN';
|
|
8
|
+
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'SPONSOR_UNAVAILABLE' | 'AUTO_TOPUP_FAILED' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'FACILITATOR_TIMEOUT' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'UNKNOWN';
|
|
9
9
|
interface T2000ErrorData {
|
|
10
10
|
reason?: string;
|
|
11
11
|
[key: string]: unknown;
|
|
@@ -102,48 +102,27 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
102
102
|
registerAdapter(adapter: LendingAdapter | SwapAdapter): Promise<void>;
|
|
103
103
|
save(params: {
|
|
104
104
|
amount: number | 'all';
|
|
105
|
-
asset?: string;
|
|
106
105
|
protocol?: string;
|
|
107
106
|
}): Promise<SaveResult>;
|
|
108
107
|
withdraw(params: {
|
|
109
108
|
amount: number | 'all';
|
|
110
|
-
asset?: string;
|
|
111
109
|
protocol?: string;
|
|
112
110
|
}): Promise<WithdrawResult>;
|
|
113
111
|
private withdrawAllProtocols;
|
|
112
|
+
private _swapToUsdc;
|
|
114
113
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
115
114
|
borrow(params: {
|
|
116
115
|
amount: number;
|
|
117
|
-
asset?: string;
|
|
118
116
|
protocol?: string;
|
|
119
117
|
}): Promise<BorrowResult>;
|
|
120
118
|
repay(params: {
|
|
121
119
|
amount: number | 'all';
|
|
122
|
-
asset?: string;
|
|
123
120
|
protocol?: string;
|
|
124
121
|
}): Promise<RepayResult>;
|
|
125
122
|
maxBorrow(): Promise<MaxBorrowResult>;
|
|
126
123
|
healthFactor(): Promise<HealthFactorResult>;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
to: string;
|
|
130
|
-
amount: number;
|
|
131
|
-
maxSlippage?: number;
|
|
132
|
-
protocol?: string;
|
|
133
|
-
}): Promise<SwapResult>;
|
|
134
|
-
swapQuote(params: {
|
|
135
|
-
from: string;
|
|
136
|
-
to: string;
|
|
137
|
-
amount: number;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
expectedOutput: number;
|
|
140
|
-
priceImpact: number;
|
|
141
|
-
poolPrice: number;
|
|
142
|
-
fee: {
|
|
143
|
-
amount: number;
|
|
144
|
-
rate: number;
|
|
145
|
-
};
|
|
146
|
-
}>;
|
|
124
|
+
private _swap;
|
|
125
|
+
private _swapQuote;
|
|
147
126
|
positions(): Promise<PositionsResult>;
|
|
148
127
|
rates(): Promise<RatesResult>;
|
|
149
128
|
allRates(asset?: string): Promise<{
|
|
@@ -209,8 +188,6 @@ declare const SUPPORTED_ASSETS: {
|
|
|
209
188
|
};
|
|
210
189
|
};
|
|
211
190
|
type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
|
|
212
|
-
type StableAsset = Exclude<SupportedAsset, 'SUI'>;
|
|
213
|
-
declare const STABLE_ASSETS: readonly StableAsset[];
|
|
214
191
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
215
192
|
declare const SENTINEL: {
|
|
216
193
|
readonly PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7";
|
|
@@ -236,12 +213,6 @@ declare function rawToStable(raw: bigint, decimals: number): number;
|
|
|
236
213
|
declare function getDecimals(asset: SupportedAsset): number;
|
|
237
214
|
declare function formatUsd(amount: number): string;
|
|
238
215
|
declare function formatSui(amount: number): string;
|
|
239
|
-
/**
|
|
240
|
-
* Case-insensitive lookup against SUPPORTED_ASSETS keys AND display names.
|
|
241
|
-
* 'usde' → 'USDe', 'suiusde' → 'USDe', 'suiusdt' → 'USDT', 'usdsui' → 'USDsui'.
|
|
242
|
-
* Returns the original input if not found so downstream validation can reject it.
|
|
243
|
-
*/
|
|
244
|
-
declare function normalizeAsset(input: string): string;
|
|
245
216
|
|
|
246
217
|
declare function generateKeypair(): Ed25519Keypair;
|
|
247
218
|
declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
|
|
@@ -282,11 +253,6 @@ declare function simulateTransaction(client: SuiJsonRpcClient, tx: Transaction,
|
|
|
282
253
|
declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
283
254
|
|
|
284
255
|
declare function getPoolPrice(client: SuiJsonRpcClient): Promise<number>;
|
|
285
|
-
declare function getSwapQuote(client: SuiJsonRpcClient, fromAsset: string, toAsset: string, amount: number): Promise<{
|
|
286
|
-
expectedOutput: number;
|
|
287
|
-
priceImpact: number;
|
|
288
|
-
poolPrice: number;
|
|
289
|
-
}>;
|
|
290
256
|
|
|
291
257
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
292
258
|
|
|
@@ -329,4 +295,4 @@ interface GasStatusResponse {
|
|
|
329
295
|
}
|
|
330
296
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
331
297
|
|
|
332
|
-
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL,
|
|
298
|
+
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type SupportedAsset, SwapAdapter, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, 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
|
@@ -122,10 +122,25 @@ function mapMoveAbortCode(code) {
|
|
|
122
122
|
7: "Package version mismatch \u2014 upgrade required",
|
|
123
123
|
8: "Timelock is active \u2014 wait for expiry",
|
|
124
124
|
9: "No pending change to execute",
|
|
125
|
-
10: "Already at current version"
|
|
125
|
+
10: "Already at current version",
|
|
126
|
+
// NAVI Protocol abort codes
|
|
127
|
+
1502: "Oracle price is stale \u2014 try again in a moment",
|
|
128
|
+
1600: "Health factor too low \u2014 withdrawal would risk liquidation",
|
|
129
|
+
1605: "Asset borrowing is disabled or at capacity on this protocol"
|
|
126
130
|
};
|
|
127
131
|
return abortMessages[code] ?? `Move abort code: ${code}`;
|
|
128
132
|
}
|
|
133
|
+
function isMoveAbort(msg) {
|
|
134
|
+
return msg.includes("MoveAbort") || msg.includes("MovePrimitiveRuntimeError");
|
|
135
|
+
}
|
|
136
|
+
function parseMoveAbortMessage(msg) {
|
|
137
|
+
const abortMatch = msg.match(/abort code:\s*(\d+)/i) ?? msg.match(/MoveAbort[^,]*,\s*(\d+)/);
|
|
138
|
+
if (abortMatch) {
|
|
139
|
+
const code = parseInt(abortMatch[1], 10);
|
|
140
|
+
return mapMoveAbortCode(code);
|
|
141
|
+
}
|
|
142
|
+
return msg;
|
|
143
|
+
}
|
|
129
144
|
|
|
130
145
|
// src/utils/sui.ts
|
|
131
146
|
var cachedClient = null;
|
|
@@ -1300,24 +1315,6 @@ var ProtocolRegistry = class {
|
|
|
1300
1315
|
listSwap() {
|
|
1301
1316
|
return [...this.swap.values()];
|
|
1302
1317
|
}
|
|
1303
|
-
isSupportedAsset(asset, capability) {
|
|
1304
|
-
for (const adapter of this.lending.values()) {
|
|
1305
|
-
if (!adapter.supportedAssets.includes(asset)) continue;
|
|
1306
|
-
if (capability && !adapter.capabilities.includes(capability)) continue;
|
|
1307
|
-
return true;
|
|
1308
|
-
}
|
|
1309
|
-
return false;
|
|
1310
|
-
}
|
|
1311
|
-
getSupportedAssets(capability) {
|
|
1312
|
-
const assets = /* @__PURE__ */ new Set();
|
|
1313
|
-
for (const adapter of this.lending.values()) {
|
|
1314
|
-
if (capability && !adapter.capabilities.includes(capability)) continue;
|
|
1315
|
-
for (const a of adapter.supportedAssets) {
|
|
1316
|
-
assets.add(a);
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
return [...assets];
|
|
1320
|
-
}
|
|
1321
1318
|
};
|
|
1322
1319
|
|
|
1323
1320
|
// src/adapters/navi.ts
|
|
@@ -2235,7 +2232,11 @@ async function executeWithGas(client, keypair, buildTx) {
|
|
|
2235
2232
|
if (result) return result;
|
|
2236
2233
|
errors.push("self-funded: SUI below threshold");
|
|
2237
2234
|
} catch (err) {
|
|
2238
|
-
|
|
2235
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2236
|
+
if (isMoveAbort(msg)) {
|
|
2237
|
+
throw new T2000Error("TRANSACTION_FAILED", parseMoveAbortMessage(msg));
|
|
2238
|
+
}
|
|
2239
|
+
errors.push(`self-funded: ${msg}`);
|
|
2239
2240
|
}
|
|
2240
2241
|
try {
|
|
2241
2242
|
const tx = await buildTx();
|
|
@@ -2412,43 +2413,34 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2412
2413
|
}
|
|
2413
2414
|
// -- Savings --
|
|
2414
2415
|
async save(params) {
|
|
2415
|
-
const asset =
|
|
2416
|
-
if (!this.registry.isSupportedAsset(asset, "save")) {
|
|
2417
|
-
const supported = this.registry.getSupportedAssets("save").join(", ");
|
|
2418
|
-
throw new T2000Error("ASSET_NOT_SUPPORTED", `${asset} is not supported for save. Supported: ${supported}`);
|
|
2419
|
-
}
|
|
2416
|
+
const asset = "USDC";
|
|
2420
2417
|
let amount;
|
|
2421
2418
|
if (params.amount === "all") {
|
|
2422
2419
|
const bal = await queryBalance(this.client, this._address);
|
|
2423
|
-
const assetBalance = bal.stables
|
|
2424
|
-
|
|
2425
|
-
amount = assetBalance - reserve;
|
|
2420
|
+
const assetBalance = bal.stables.USDC ?? 0;
|
|
2421
|
+
amount = assetBalance - 1;
|
|
2426
2422
|
if (amount <= 0) {
|
|
2427
|
-
throw new T2000Error("INSUFFICIENT_BALANCE",
|
|
2428
|
-
reason:
|
|
2423
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", "Balance too low to save after $1 gas reserve", {
|
|
2424
|
+
reason: "gas_reserve_required",
|
|
2429
2425
|
available: assetBalance
|
|
2430
2426
|
});
|
|
2431
2427
|
}
|
|
2432
2428
|
} else {
|
|
2433
2429
|
amount = params.amount;
|
|
2434
2430
|
const bal = await queryBalance(this.client, this._address);
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${asset}. Available: $${assetBalance.toFixed(2)}, requested: $${amount.toFixed(2)}`);
|
|
2431
|
+
if (amount > (bal.stables.USDC ?? 0)) {
|
|
2432
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient USDC. Available: $${(bal.stables.USDC ?? 0).toFixed(2)}, requested: $${amount.toFixed(2)}`);
|
|
2438
2433
|
}
|
|
2439
2434
|
}
|
|
2440
|
-
const
|
|
2441
|
-
const fee = shouldCollectFee ? calculateFee("save", amount) : { amount: 0, rate: 0};
|
|
2435
|
+
const fee = calculateFee("save", amount);
|
|
2442
2436
|
const saveAmount = amount;
|
|
2443
2437
|
const adapter = await this.resolveLending(params.protocol, asset, "save");
|
|
2444
2438
|
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
2445
|
-
const { tx } = await adapter.buildSaveTx(this._address, saveAmount, asset, { collectFee:
|
|
2439
|
+
const { tx } = await adapter.buildSaveTx(this._address, saveAmount, asset, { collectFee: true });
|
|
2446
2440
|
return tx;
|
|
2447
2441
|
});
|
|
2448
2442
|
const rates = await adapter.getRates(asset);
|
|
2449
|
-
|
|
2450
|
-
reportFee(this._address, "save", fee.amount, fee.rate, gasResult.digest);
|
|
2451
|
-
}
|
|
2443
|
+
reportFee(this._address, "save", fee.amount, fee.rate, gasResult.digest);
|
|
2452
2444
|
this.emitBalanceChange(asset, saveAmount, "save", gasResult.digest);
|
|
2453
2445
|
let savingsBalance = saveAmount;
|
|
2454
2446
|
try {
|
|
@@ -2460,7 +2452,6 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2460
2452
|
success: true,
|
|
2461
2453
|
tx: gasResult.digest,
|
|
2462
2454
|
amount: saveAmount,
|
|
2463
|
-
asset,
|
|
2464
2455
|
apy: rates.saveApy,
|
|
2465
2456
|
fee: fee.amount,
|
|
2466
2457
|
gasCost: gasResult.gasCostSui,
|
|
@@ -2469,14 +2460,27 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2469
2460
|
};
|
|
2470
2461
|
}
|
|
2471
2462
|
async withdraw(params) {
|
|
2472
|
-
const asset = normalizeAsset(params.asset ?? "USDC");
|
|
2473
2463
|
if (params.amount === "all" && !params.protocol) {
|
|
2474
|
-
return this.withdrawAllProtocols(
|
|
2464
|
+
return this.withdrawAllProtocols();
|
|
2465
|
+
}
|
|
2466
|
+
const allPositions = await this.registry.allPositions(this._address);
|
|
2467
|
+
const supplies = [];
|
|
2468
|
+
for (const pos of allPositions) {
|
|
2469
|
+
if (params.protocol && pos.protocolId !== params.protocol) continue;
|
|
2470
|
+
for (const s of pos.positions.supplies) {
|
|
2471
|
+
if (s.amount > 1e-3) supplies.push({ protocolId: pos.protocolId, asset: s.asset, amount: s.amount, apy: s.apy });
|
|
2472
|
+
}
|
|
2475
2473
|
}
|
|
2476
|
-
|
|
2474
|
+
if (supplies.length === 0) {
|
|
2475
|
+
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw");
|
|
2476
|
+
}
|
|
2477
|
+
supplies.sort((a, b) => a.apy - b.apy);
|
|
2478
|
+
const target = supplies[0];
|
|
2479
|
+
const adapter = this.registry.getLending(target.protocolId);
|
|
2480
|
+
if (!adapter) throw new T2000Error("PROTOCOL_UNAVAILABLE", `Protocol ${target.protocolId} not found`);
|
|
2477
2481
|
let amount;
|
|
2478
2482
|
if (params.amount === "all") {
|
|
2479
|
-
const maxResult = await adapter.maxWithdraw(this._address, asset);
|
|
2483
|
+
const maxResult = await adapter.maxWithdraw(this._address, target.asset);
|
|
2480
2484
|
amount = maxResult.maxAmount;
|
|
2481
2485
|
if (amount <= 0) {
|
|
2482
2486
|
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw");
|
|
@@ -2485,7 +2489,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2485
2489
|
amount = params.amount;
|
|
2486
2490
|
const hf = await adapter.getHealth(this._address);
|
|
2487
2491
|
if (hf.borrowed > 0) {
|
|
2488
|
-
const maxResult = await adapter.maxWithdraw(this._address, asset);
|
|
2492
|
+
const maxResult = await adapter.maxWithdraw(this._address, target.asset);
|
|
2489
2493
|
if (amount > maxResult.maxAmount) {
|
|
2490
2494
|
throw new T2000Error(
|
|
2491
2495
|
"WITHDRAW_WOULD_LIQUIDATE",
|
|
@@ -2502,20 +2506,37 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2502
2506
|
const withdrawAmount = amount;
|
|
2503
2507
|
let effectiveAmount = withdrawAmount;
|
|
2504
2508
|
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
2505
|
-
const built = await adapter.buildWithdrawTx(this._address, withdrawAmount, asset);
|
|
2509
|
+
const built = await adapter.buildWithdrawTx(this._address, withdrawAmount, target.asset);
|
|
2506
2510
|
effectiveAmount = built.effectiveAmount;
|
|
2507
2511
|
return built.tx;
|
|
2508
2512
|
});
|
|
2509
|
-
|
|
2513
|
+
let totalGasCost = gasResult.gasCostSui;
|
|
2514
|
+
let finalAmount = effectiveAmount;
|
|
2515
|
+
let lastDigest = gasResult.digest;
|
|
2516
|
+
if (target.asset !== "USDC") {
|
|
2517
|
+
try {
|
|
2518
|
+
const swapResult = await this._swapToUsdc(target.asset, effectiveAmount);
|
|
2519
|
+
finalAmount = swapResult.usdcReceived;
|
|
2520
|
+
lastDigest = swapResult.digest;
|
|
2521
|
+
totalGasCost += swapResult.gasCost;
|
|
2522
|
+
} catch (err) {
|
|
2523
|
+
throw new T2000Error(
|
|
2524
|
+
"SWAP_FAILED",
|
|
2525
|
+
`Withdrew $${effectiveAmount.toFixed(2)} ${target.asset} but swap to USDC failed. Your ${target.asset} is safe in your wallet.`,
|
|
2526
|
+
{ withdrawDigest: gasResult.digest, originalError: err instanceof Error ? err.message : String(err) }
|
|
2527
|
+
);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
this.emitBalanceChange("USDC", finalAmount, "withdraw", lastDigest);
|
|
2510
2531
|
return {
|
|
2511
2532
|
success: true,
|
|
2512
|
-
tx:
|
|
2513
|
-
amount:
|
|
2514
|
-
gasCost:
|
|
2533
|
+
tx: lastDigest,
|
|
2534
|
+
amount: finalAmount,
|
|
2535
|
+
gasCost: totalGasCost,
|
|
2515
2536
|
gasMethod: gasResult.gasMethod
|
|
2516
2537
|
};
|
|
2517
2538
|
}
|
|
2518
|
-
async withdrawAllProtocols(
|
|
2539
|
+
async withdrawAllProtocols() {
|
|
2519
2540
|
const allPositions = await this.registry.allPositions(this._address);
|
|
2520
2541
|
const withdrawable = [];
|
|
2521
2542
|
for (const pos of allPositions) {
|
|
@@ -2528,7 +2549,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2528
2549
|
if (withdrawable.length === 0) {
|
|
2529
2550
|
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw across any protocol");
|
|
2530
2551
|
}
|
|
2531
|
-
let
|
|
2552
|
+
let totalUsdcReceived = 0;
|
|
2532
2553
|
let lastDigest = "";
|
|
2533
2554
|
let totalGasCost = 0;
|
|
2534
2555
|
let lastGasMethod = "self-funded";
|
|
@@ -2543,30 +2564,55 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2543
2564
|
effectiveAmount = built.effectiveAmount;
|
|
2544
2565
|
return built.tx;
|
|
2545
2566
|
});
|
|
2546
|
-
totalWithdrawn += effectiveAmount;
|
|
2547
2567
|
lastDigest = gasResult.digest;
|
|
2548
2568
|
totalGasCost += gasResult.gasCostSui;
|
|
2549
2569
|
lastGasMethod = gasResult.gasMethod;
|
|
2550
2570
|
this.emitBalanceChange(entry.asset, effectiveAmount, "withdraw", gasResult.digest);
|
|
2571
|
+
if (entry.asset !== "USDC") {
|
|
2572
|
+
try {
|
|
2573
|
+
const swapResult = await this._swapToUsdc(entry.asset, effectiveAmount);
|
|
2574
|
+
totalUsdcReceived += swapResult.usdcReceived;
|
|
2575
|
+
lastDigest = swapResult.digest;
|
|
2576
|
+
totalGasCost += swapResult.gasCost;
|
|
2577
|
+
} catch {
|
|
2578
|
+
totalUsdcReceived += effectiveAmount;
|
|
2579
|
+
}
|
|
2580
|
+
} else {
|
|
2581
|
+
totalUsdcReceived += effectiveAmount;
|
|
2582
|
+
}
|
|
2551
2583
|
}
|
|
2552
|
-
if (
|
|
2584
|
+
if (totalUsdcReceived <= 0) {
|
|
2553
2585
|
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw across any protocol");
|
|
2554
2586
|
}
|
|
2555
2587
|
return {
|
|
2556
2588
|
success: true,
|
|
2557
2589
|
tx: lastDigest,
|
|
2558
|
-
amount:
|
|
2590
|
+
amount: totalUsdcReceived,
|
|
2559
2591
|
gasCost: totalGasCost,
|
|
2560
2592
|
gasMethod: lastGasMethod
|
|
2561
2593
|
};
|
|
2562
2594
|
}
|
|
2595
|
+
async _swapToUsdc(asset, amount) {
|
|
2596
|
+
const swapAdapter = this.registry.listSwap()[0];
|
|
2597
|
+
if (!swapAdapter) throw new T2000Error("PROTOCOL_UNAVAILABLE", "No swap adapter available");
|
|
2598
|
+
let estimatedOut = 0;
|
|
2599
|
+
let toDecimals = 6;
|
|
2600
|
+
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
2601
|
+
const built = await swapAdapter.buildSwapTx(this._address, asset, "USDC", amount);
|
|
2602
|
+
estimatedOut = built.estimatedOut;
|
|
2603
|
+
toDecimals = built.toDecimals;
|
|
2604
|
+
return built.tx;
|
|
2605
|
+
});
|
|
2606
|
+
const usdcReceived = estimatedOut / 10 ** toDecimals;
|
|
2607
|
+
return { usdcReceived, digest: gasResult.digest, gasCost: gasResult.gasCostSui };
|
|
2608
|
+
}
|
|
2563
2609
|
async maxWithdraw() {
|
|
2564
2610
|
const adapter = await this.resolveLending(void 0, "USDC", "withdraw");
|
|
2565
2611
|
return adapter.maxWithdraw(this._address, "USDC");
|
|
2566
2612
|
}
|
|
2567
2613
|
// -- Borrowing --
|
|
2568
2614
|
async borrow(params) {
|
|
2569
|
-
const asset =
|
|
2615
|
+
const asset = "USDC";
|
|
2570
2616
|
const adapter = await this.resolveLending(params.protocol, asset, "borrow");
|
|
2571
2617
|
const maxResult = await adapter.maxBorrow(this._address, asset);
|
|
2572
2618
|
if (maxResult.maxAmount <= 0) {
|
|
@@ -2578,17 +2624,14 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2578
2624
|
currentHF: maxResult.currentHF
|
|
2579
2625
|
});
|
|
2580
2626
|
}
|
|
2581
|
-
const
|
|
2582
|
-
const fee = shouldCollectFee ? calculateFee("borrow", params.amount) : { amount: 0, rate: 0};
|
|
2627
|
+
const fee = calculateFee("borrow", params.amount);
|
|
2583
2628
|
const borrowAmount = params.amount;
|
|
2584
2629
|
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
2585
|
-
const { tx } = await adapter.buildBorrowTx(this._address, borrowAmount, asset, { collectFee:
|
|
2630
|
+
const { tx } = await adapter.buildBorrowTx(this._address, borrowAmount, asset, { collectFee: true });
|
|
2586
2631
|
return tx;
|
|
2587
2632
|
});
|
|
2588
2633
|
const hf = await adapter.getHealth(this._address);
|
|
2589
|
-
|
|
2590
|
-
reportFee(this._address, "borrow", fee.amount, fee.rate, gasResult.digest);
|
|
2591
|
-
}
|
|
2634
|
+
reportFee(this._address, "borrow", fee.amount, fee.rate, gasResult.digest);
|
|
2592
2635
|
this.emitBalanceChange(asset, borrowAmount, "borrow", gasResult.digest);
|
|
2593
2636
|
return {
|
|
2594
2637
|
success: true,
|
|
@@ -2601,7 +2644,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2601
2644
|
};
|
|
2602
2645
|
}
|
|
2603
2646
|
async repay(params) {
|
|
2604
|
-
const asset =
|
|
2647
|
+
const asset = "USDC";
|
|
2605
2648
|
const adapter = await this.resolveLending(params.protocol, asset, "repay");
|
|
2606
2649
|
let amount;
|
|
2607
2650
|
if (params.amount === "all") {
|
|
@@ -2643,25 +2686,18 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2643
2686
|
}
|
|
2644
2687
|
return hf;
|
|
2645
2688
|
}
|
|
2646
|
-
// -- Swap --
|
|
2647
|
-
async
|
|
2648
|
-
const fromAsset =
|
|
2649
|
-
const toAsset =
|
|
2689
|
+
// -- Swap (internal — used by rebalance and withdraw auto-swap) --
|
|
2690
|
+
async _swap(params) {
|
|
2691
|
+
const fromAsset = params.from;
|
|
2692
|
+
const toAsset = params.to;
|
|
2650
2693
|
if (!(fromAsset in SUPPORTED_ASSETS) || !(toAsset in SUPPORTED_ASSETS)) {
|
|
2651
2694
|
throw new T2000Error("ASSET_NOT_SUPPORTED", `Swap pair ${fromAsset}/${toAsset} is not supported`);
|
|
2652
2695
|
}
|
|
2653
2696
|
if (fromAsset === toAsset) {
|
|
2654
2697
|
throw new T2000Error("INVALID_AMOUNT", "Cannot swap same asset");
|
|
2655
2698
|
}
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
const found = this.registry.getSwap(params.protocol);
|
|
2659
|
-
if (!found) throw new T2000Error("ASSET_NOT_SUPPORTED", `Swap adapter '${params.protocol}' not found`);
|
|
2660
|
-
adapter = found;
|
|
2661
|
-
} else {
|
|
2662
|
-
const best = await this.registry.bestSwapQuote(fromAsset, toAsset, params.amount);
|
|
2663
|
-
adapter = best.adapter;
|
|
2664
|
-
}
|
|
2699
|
+
const best = await this.registry.bestSwapQuote(fromAsset, toAsset, params.amount);
|
|
2700
|
+
const adapter = best.adapter;
|
|
2665
2701
|
const fee = calculateFee("swap", params.amount);
|
|
2666
2702
|
const swapAmount = params.amount;
|
|
2667
2703
|
const slippageBps = params.maxSlippage ? params.maxSlippage * 100 : void 0;
|
|
@@ -2704,9 +2740,9 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2704
2740
|
gasMethod: gasResult.gasMethod
|
|
2705
2741
|
};
|
|
2706
2742
|
}
|
|
2707
|
-
async
|
|
2708
|
-
const fromAsset =
|
|
2709
|
-
const toAsset =
|
|
2743
|
+
async _swapQuote(params) {
|
|
2744
|
+
const fromAsset = params.from;
|
|
2745
|
+
const toAsset = params.to;
|
|
2710
2746
|
const best = await this.registry.bestSwapQuote(fromAsset, toAsset, params.amount);
|
|
2711
2747
|
const fee = calculateFee("swap", params.amount);
|
|
2712
2748
|
return { ...best.quote, fee: { amount: fee.amount, rate: fee.rate } };
|
|
@@ -3143,6 +3179,6 @@ var allDescriptors = [
|
|
|
3143
3179
|
descriptor
|
|
3144
3180
|
];
|
|
3145
3181
|
|
|
3146
|
-
export { BPS_DENOMINATOR, CLOCK_ID, CetusAdapter, DEFAULT_NETWORK, MIST_PER_SUI, NaviAdapter, ProtocolRegistry, SENTINEL,
|
|
3182
|
+
export { BPS_DENOMINATOR, CLOCK_ID, CetusAdapter, DEFAULT_NETWORK, MIST_PER_SUI, NaviAdapter, ProtocolRegistry, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, SuilendAdapter, T2000, T2000Error, USDC_DECIMALS, addCollectFeeToTx, allDescriptors, calculateFee, descriptor3 as cetusDescriptor, executeAutoTopUp, executeWithGas, exportPrivateKey, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, getSentinelInfo, keypairFromPrivateKey, listSentinels, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, descriptor2 as naviDescriptor, rawToStable, rawToUsdc, requestAttack, saveKey, attack as sentinelAttack, descriptor as sentinelDescriptor, settleAttack, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, submitPrompt, suiToMist, descriptor4 as suilendDescriptor, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
3147
3183
|
//# sourceMappingURL=index.js.map
|
|
3148
3184
|
//# sourceMappingURL=index.js.map
|