@t2000/sdk 0.19.24 → 0.20.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 +34 -150
- package/dist/adapters/descriptors.cjs +1 -42
- package/dist/adapters/descriptors.cjs.map +1 -1
- package/dist/adapters/descriptors.d.cts +1 -1
- package/dist/adapters/descriptors.d.ts +1 -1
- package/dist/adapters/descriptors.js +2 -41
- package/dist/adapters/descriptors.js.map +1 -1
- package/dist/adapters/index.cjs +3 -745
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +4 -171
- package/dist/adapters/index.d.ts +4 -171
- package/dist/adapters/index.js +4 -742
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.js +20 -178
- package/dist/browser.js.map +1 -1
- package/dist/descriptors-Be4FAgN5.d.cts +127 -0
- package/dist/descriptors-Be4FAgN5.d.ts +127 -0
- package/dist/index-D1DxZ1DK.d.ts +292 -0
- package/dist/index-MP_J_nSO.d.cts +292 -0
- package/dist/index.cjs +711 -3456
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -313
- package/dist/index.d.ts +42 -313
- package/dist/index.js +642 -3375
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
- package/dist/descriptors-B6qt_mwi.d.cts +0 -584
- package/dist/descriptors-B6qt_mwi.d.ts +0 -584
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { L as LendingAdapter, a as LendingRates, b as AdapterPositions, A as AdapterCapability, H as HealthInfo, c as AdapterTxResult, e as PendingReward$1 } from './descriptors-Be4FAgN5.cjs';
|
|
2
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
|
+
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
4
|
+
|
|
5
|
+
interface T2000Options {
|
|
6
|
+
keyPath?: string;
|
|
7
|
+
/** PIN to decrypt the key file. Accepts any string (4+ chars). */
|
|
8
|
+
pin?: string;
|
|
9
|
+
/** @deprecated Use `pin` instead. */
|
|
10
|
+
passphrase?: string;
|
|
11
|
+
network?: 'mainnet' | 'testnet';
|
|
12
|
+
rpcUrl?: string;
|
|
13
|
+
sponsored?: boolean;
|
|
14
|
+
name?: string;
|
|
15
|
+
}
|
|
16
|
+
interface GasReserve {
|
|
17
|
+
sui: number;
|
|
18
|
+
usdEquiv: number;
|
|
19
|
+
}
|
|
20
|
+
interface BalanceResponse {
|
|
21
|
+
available: number;
|
|
22
|
+
savings: number;
|
|
23
|
+
debt: number;
|
|
24
|
+
pendingRewards: number;
|
|
25
|
+
gasReserve: GasReserve;
|
|
26
|
+
total: number;
|
|
27
|
+
stables: Record<string, number>;
|
|
28
|
+
}
|
|
29
|
+
type GasMethod = 'self-funded' | 'sponsored' | 'auto-topup' | 'none';
|
|
30
|
+
interface SendResult {
|
|
31
|
+
success: boolean;
|
|
32
|
+
tx: string;
|
|
33
|
+
amount: number;
|
|
34
|
+
to: string;
|
|
35
|
+
contactName?: string;
|
|
36
|
+
gasCost: number;
|
|
37
|
+
gasCostUnit: string;
|
|
38
|
+
gasMethod: GasMethod;
|
|
39
|
+
balance: BalanceResponse;
|
|
40
|
+
}
|
|
41
|
+
interface SaveResult {
|
|
42
|
+
success: boolean;
|
|
43
|
+
tx: string;
|
|
44
|
+
amount: number;
|
|
45
|
+
apy: number;
|
|
46
|
+
fee: number;
|
|
47
|
+
gasCost: number;
|
|
48
|
+
gasMethod: GasMethod;
|
|
49
|
+
savingsBalance: number;
|
|
50
|
+
}
|
|
51
|
+
interface WithdrawResult {
|
|
52
|
+
success: boolean;
|
|
53
|
+
tx: string;
|
|
54
|
+
amount: number;
|
|
55
|
+
gasCost: number;
|
|
56
|
+
gasMethod: GasMethod;
|
|
57
|
+
}
|
|
58
|
+
interface BorrowResult {
|
|
59
|
+
success: boolean;
|
|
60
|
+
tx: string;
|
|
61
|
+
amount: number;
|
|
62
|
+
fee: number;
|
|
63
|
+
healthFactor: number;
|
|
64
|
+
gasCost: number;
|
|
65
|
+
gasMethod: GasMethod;
|
|
66
|
+
}
|
|
67
|
+
interface RepayResult {
|
|
68
|
+
success: boolean;
|
|
69
|
+
tx: string;
|
|
70
|
+
amount: number;
|
|
71
|
+
remainingDebt: number;
|
|
72
|
+
gasCost: number;
|
|
73
|
+
gasMethod: GasMethod;
|
|
74
|
+
}
|
|
75
|
+
interface HealthFactorResult {
|
|
76
|
+
healthFactor: number;
|
|
77
|
+
supplied: number;
|
|
78
|
+
borrowed: number;
|
|
79
|
+
maxBorrow: number;
|
|
80
|
+
liquidationThreshold: number;
|
|
81
|
+
}
|
|
82
|
+
interface MaxWithdrawResult {
|
|
83
|
+
maxAmount: number;
|
|
84
|
+
healthFactorAfter: number;
|
|
85
|
+
currentHF: number;
|
|
86
|
+
}
|
|
87
|
+
interface MaxBorrowResult {
|
|
88
|
+
maxAmount: number;
|
|
89
|
+
healthFactorAfter: number;
|
|
90
|
+
currentHF: number;
|
|
91
|
+
}
|
|
92
|
+
interface AssetRates {
|
|
93
|
+
saveApy: number;
|
|
94
|
+
borrowApy: number;
|
|
95
|
+
}
|
|
96
|
+
interface RatesResult {
|
|
97
|
+
[asset: string]: AssetRates;
|
|
98
|
+
}
|
|
99
|
+
interface PositionEntry {
|
|
100
|
+
protocol: string;
|
|
101
|
+
asset: string;
|
|
102
|
+
type: 'save' | 'borrow';
|
|
103
|
+
amount: number;
|
|
104
|
+
amountUsd?: number;
|
|
105
|
+
apy: number;
|
|
106
|
+
}
|
|
107
|
+
interface PositionsResult {
|
|
108
|
+
positions: PositionEntry[];
|
|
109
|
+
}
|
|
110
|
+
interface EarningsResult {
|
|
111
|
+
totalYieldEarned: number;
|
|
112
|
+
currentApy: number;
|
|
113
|
+
dailyEarning: number;
|
|
114
|
+
supplied: number;
|
|
115
|
+
}
|
|
116
|
+
interface FundStatusResult {
|
|
117
|
+
supplied: number;
|
|
118
|
+
apy: number;
|
|
119
|
+
earnedToday: number;
|
|
120
|
+
earnedAllTime: number;
|
|
121
|
+
projectedMonthly: number;
|
|
122
|
+
}
|
|
123
|
+
interface DepositInfo {
|
|
124
|
+
address: string;
|
|
125
|
+
network: string;
|
|
126
|
+
supportedAssets: string[];
|
|
127
|
+
instructions: string;
|
|
128
|
+
}
|
|
129
|
+
interface TransactionRecord {
|
|
130
|
+
digest: string;
|
|
131
|
+
action: string;
|
|
132
|
+
amount?: number;
|
|
133
|
+
asset?: string;
|
|
134
|
+
recipient?: string;
|
|
135
|
+
timestamp: number;
|
|
136
|
+
gasCost?: number;
|
|
137
|
+
gasMethod?: GasMethod;
|
|
138
|
+
}
|
|
139
|
+
interface PendingReward {
|
|
140
|
+
protocol: string;
|
|
141
|
+
asset: string;
|
|
142
|
+
coinType: string;
|
|
143
|
+
symbol: string;
|
|
144
|
+
amount: number;
|
|
145
|
+
estimatedValueUsd: number;
|
|
146
|
+
}
|
|
147
|
+
interface ClaimRewardsResult {
|
|
148
|
+
success: boolean;
|
|
149
|
+
tx: string;
|
|
150
|
+
rewards: PendingReward[];
|
|
151
|
+
totalValueUsd: number;
|
|
152
|
+
gasCost: number;
|
|
153
|
+
gasMethod: GasMethod;
|
|
154
|
+
}
|
|
155
|
+
interface StakeVSuiResult {
|
|
156
|
+
success: boolean;
|
|
157
|
+
tx: string;
|
|
158
|
+
amountSui: number;
|
|
159
|
+
vSuiReceived: number;
|
|
160
|
+
apy: number;
|
|
161
|
+
gasCost: number;
|
|
162
|
+
gasMethod: GasMethod;
|
|
163
|
+
}
|
|
164
|
+
interface UnstakeVSuiResult {
|
|
165
|
+
success: boolean;
|
|
166
|
+
tx: string;
|
|
167
|
+
vSuiAmount: number;
|
|
168
|
+
suiReceived: number;
|
|
169
|
+
gasCost: number;
|
|
170
|
+
gasMethod: GasMethod;
|
|
171
|
+
}
|
|
172
|
+
interface SwapResult {
|
|
173
|
+
success: boolean;
|
|
174
|
+
tx: string;
|
|
175
|
+
fromToken: string;
|
|
176
|
+
toToken: string;
|
|
177
|
+
fromAmount: number;
|
|
178
|
+
toAmount: number;
|
|
179
|
+
priceImpact: number;
|
|
180
|
+
route: string;
|
|
181
|
+
gasCost: number;
|
|
182
|
+
gasMethod: GasMethod;
|
|
183
|
+
}
|
|
184
|
+
interface SwapQuoteResult {
|
|
185
|
+
fromToken: string;
|
|
186
|
+
toToken: string;
|
|
187
|
+
fromAmount: number;
|
|
188
|
+
toAmount: number;
|
|
189
|
+
priceImpact: number;
|
|
190
|
+
route: string;
|
|
191
|
+
}
|
|
192
|
+
interface PayOptions {
|
|
193
|
+
url: string;
|
|
194
|
+
method?: string;
|
|
195
|
+
body?: string;
|
|
196
|
+
headers?: Record<string, string>;
|
|
197
|
+
maxPrice?: number;
|
|
198
|
+
}
|
|
199
|
+
interface PayResult {
|
|
200
|
+
status: number;
|
|
201
|
+
body: unknown;
|
|
202
|
+
paid: boolean;
|
|
203
|
+
cost?: number;
|
|
204
|
+
receipt?: {
|
|
205
|
+
reference: string;
|
|
206
|
+
timestamp: string;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare class ProtocolRegistry {
|
|
211
|
+
private lending;
|
|
212
|
+
registerLending(adapter: LendingAdapter): void;
|
|
213
|
+
bestSaveRate(asset: string): Promise<{
|
|
214
|
+
adapter: LendingAdapter;
|
|
215
|
+
rate: LendingRates;
|
|
216
|
+
}>;
|
|
217
|
+
bestBorrowRate(asset: string, opts?: {
|
|
218
|
+
requireSameAssetBorrow?: boolean;
|
|
219
|
+
}): Promise<{
|
|
220
|
+
adapter: LendingAdapter;
|
|
221
|
+
rate: LendingRates;
|
|
222
|
+
}>;
|
|
223
|
+
bestSaveRateAcrossAssets(): Promise<{
|
|
224
|
+
adapter: LendingAdapter;
|
|
225
|
+
rate: LendingRates;
|
|
226
|
+
asset: string;
|
|
227
|
+
}>;
|
|
228
|
+
allRatesAcrossAssets(): Promise<Array<{
|
|
229
|
+
protocol: string;
|
|
230
|
+
protocolId: string;
|
|
231
|
+
asset: string;
|
|
232
|
+
rates: LendingRates;
|
|
233
|
+
}>>;
|
|
234
|
+
allRates(asset: string): Promise<Array<{
|
|
235
|
+
protocol: string;
|
|
236
|
+
protocolId: string;
|
|
237
|
+
rates: LendingRates;
|
|
238
|
+
}>>;
|
|
239
|
+
allPositions(address: string): Promise<Array<{
|
|
240
|
+
protocol: string;
|
|
241
|
+
protocolId: string;
|
|
242
|
+
positions: AdapterPositions;
|
|
243
|
+
}>>;
|
|
244
|
+
getLending(id: string): LendingAdapter | undefined;
|
|
245
|
+
listLending(): LendingAdapter[];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare class NaviAdapter implements LendingAdapter {
|
|
249
|
+
readonly id = "navi";
|
|
250
|
+
readonly name = "NAVI Protocol";
|
|
251
|
+
readonly version = "1.0.0";
|
|
252
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
253
|
+
readonly supportedAssets: readonly string[];
|
|
254
|
+
readonly supportsSameAssetBorrow = true;
|
|
255
|
+
private client;
|
|
256
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
257
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
258
|
+
getRates(asset: string): Promise<LendingRates>;
|
|
259
|
+
getPositions(address: string): Promise<AdapterPositions>;
|
|
260
|
+
getHealth(address: string): Promise<HealthInfo>;
|
|
261
|
+
buildSaveTx(address: string, amount: number, asset: string, options?: {
|
|
262
|
+
collectFee?: boolean;
|
|
263
|
+
sponsored?: boolean;
|
|
264
|
+
}): Promise<AdapterTxResult>;
|
|
265
|
+
buildWithdrawTx(address: string, amount: number, asset: string, options?: {
|
|
266
|
+
sponsored?: boolean;
|
|
267
|
+
}): Promise<AdapterTxResult & {
|
|
268
|
+
effectiveAmount: number;
|
|
269
|
+
}>;
|
|
270
|
+
buildBorrowTx(address: string, amount: number, asset: string, options?: {
|
|
271
|
+
collectFee?: boolean;
|
|
272
|
+
sponsored?: boolean;
|
|
273
|
+
}): Promise<AdapterTxResult>;
|
|
274
|
+
buildRepayTx(address: string, amount: number, asset: string, options?: {
|
|
275
|
+
sponsored?: boolean;
|
|
276
|
+
skipOracle?: boolean;
|
|
277
|
+
}): Promise<AdapterTxResult>;
|
|
278
|
+
maxWithdraw(address: string, _asset: string): Promise<MaxWithdrawResult>;
|
|
279
|
+
maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
|
|
280
|
+
addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
|
|
281
|
+
coin: TransactionObjectArgument;
|
|
282
|
+
effectiveAmount: number;
|
|
283
|
+
}>;
|
|
284
|
+
addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
|
|
285
|
+
collectFee?: boolean;
|
|
286
|
+
}): Promise<void>;
|
|
287
|
+
addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
|
|
288
|
+
getPendingRewards(address: string): Promise<PendingReward$1[]>;
|
|
289
|
+
addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward$1[]>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export { type AssetRates 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 MaxWithdrawResult as M, NaviAdapter as N, type PayOptions as P, type RepayResult as R, type StakeVSuiResult as S, type T2000Options as T, type UnstakeVSuiResult as U, type WithdrawResult as W, type PayResult as a, type SwapResult as b, type SwapQuoteResult as c, type SendResult as d, type TransactionRecord as e, type SaveResult as f, type BorrowResult as g, type MaxBorrowResult as h, type PendingReward as i, type PositionsResult as j, type RatesResult as k, type GasReserve as l, type PositionEntry as m, ProtocolRegistry as n };
|