@t2000/sdk 0.19.21 → 0.19.22
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 +0 -9
- package/dist/adapters/descriptors.cjs +68 -0
- package/dist/adapters/descriptors.cjs.map +1 -0
- package/dist/adapters/descriptors.d.cts +3 -0
- package/dist/adapters/descriptors.d.ts +3 -0
- package/dist/adapters/descriptors.js +63 -0
- package/dist/adapters/descriptors.js.map +1 -0
- package/dist/adapters/index.cjs +46 -58
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +171 -3
- package/dist/adapters/index.d.ts +171 -3
- package/dist/adapters/index.js +44 -55
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.js +2 -15
- package/dist/browser.js.map +1 -1
- package/dist/{index-CRyFiIZm.d.cts → descriptors-B6qt_mwi.d.cts} +4 -226
- package/dist/{index-CRyFiIZm.d.ts → descriptors-B6qt_mwi.d.ts} +4 -226
- package/dist/index.cjs +47 -279
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -20
- package/dist/index.d.ts +18 -20
- package/dist/index.js +45 -269
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
|
@@ -1,3 +1,171 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '@mysten/sui/jsonRpc';
|
|
1
|
+
import { L as LendingAdapter, e as SwapAdapter, w as LendingRates, a1 as SwapQuote, z as AdapterPositions, y as AdapterCapability, O as HealthInfo, J as AdapterTxResult, M as MaxWithdrawResult, h as MaxBorrowResult, a6 as PendingReward } from '../descriptors-B6qt_mwi.cjs';
|
|
2
|
+
export { U as PerpsAdapter, $ as ProtocolDescriptor, a2 as allDescriptors, a3 as cetusDescriptor, a4 as naviDescriptor, a5 as suilendDescriptor } from '../descriptors-B6qt_mwi.cjs';
|
|
3
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
4
|
+
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
5
|
+
|
|
6
|
+
declare class ProtocolRegistry {
|
|
7
|
+
private lending;
|
|
8
|
+
private swap;
|
|
9
|
+
registerLending(adapter: LendingAdapter): void;
|
|
10
|
+
registerSwap(adapter: SwapAdapter): void;
|
|
11
|
+
bestSaveRate(asset: string): Promise<{
|
|
12
|
+
adapter: LendingAdapter;
|
|
13
|
+
rate: LendingRates;
|
|
14
|
+
}>;
|
|
15
|
+
bestBorrowRate(asset: string, opts?: {
|
|
16
|
+
requireSameAssetBorrow?: boolean;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
adapter: LendingAdapter;
|
|
19
|
+
rate: LendingRates;
|
|
20
|
+
}>;
|
|
21
|
+
bestSwapQuote(from: string, to: string, amount: number): Promise<{
|
|
22
|
+
adapter: SwapAdapter;
|
|
23
|
+
quote: SwapQuote;
|
|
24
|
+
}>;
|
|
25
|
+
bestSaveRateAcrossAssets(): Promise<{
|
|
26
|
+
adapter: LendingAdapter;
|
|
27
|
+
rate: LendingRates;
|
|
28
|
+
asset: string;
|
|
29
|
+
}>;
|
|
30
|
+
allRatesAcrossAssets(): Promise<Array<{
|
|
31
|
+
protocol: string;
|
|
32
|
+
protocolId: string;
|
|
33
|
+
asset: string;
|
|
34
|
+
rates: LendingRates;
|
|
35
|
+
}>>;
|
|
36
|
+
allRates(asset: string): Promise<Array<{
|
|
37
|
+
protocol: string;
|
|
38
|
+
protocolId: string;
|
|
39
|
+
rates: LendingRates;
|
|
40
|
+
}>>;
|
|
41
|
+
allPositions(address: string): Promise<Array<{
|
|
42
|
+
protocol: string;
|
|
43
|
+
protocolId: string;
|
|
44
|
+
positions: AdapterPositions;
|
|
45
|
+
}>>;
|
|
46
|
+
getLending(id: string): LendingAdapter | undefined;
|
|
47
|
+
getSwap(id: string): SwapAdapter | undefined;
|
|
48
|
+
listLending(): LendingAdapter[];
|
|
49
|
+
listSwap(): SwapAdapter[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare class NaviAdapter implements LendingAdapter {
|
|
53
|
+
readonly id = "navi";
|
|
54
|
+
readonly name = "NAVI Protocol";
|
|
55
|
+
readonly version = "1.0.0";
|
|
56
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
57
|
+
readonly supportedAssets: readonly string[];
|
|
58
|
+
readonly supportsSameAssetBorrow = true;
|
|
59
|
+
private client;
|
|
60
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
61
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
62
|
+
getRates(asset: string): Promise<LendingRates>;
|
|
63
|
+
getPositions(address: string): Promise<AdapterPositions>;
|
|
64
|
+
getHealth(address: string): Promise<HealthInfo>;
|
|
65
|
+
buildSaveTx(address: string, amount: number, asset: string, options?: {
|
|
66
|
+
collectFee?: boolean;
|
|
67
|
+
sponsored?: boolean;
|
|
68
|
+
}): Promise<AdapterTxResult>;
|
|
69
|
+
buildWithdrawTx(address: string, amount: number, asset: string, options?: {
|
|
70
|
+
sponsored?: boolean;
|
|
71
|
+
}): Promise<AdapterTxResult & {
|
|
72
|
+
effectiveAmount: number;
|
|
73
|
+
}>;
|
|
74
|
+
buildBorrowTx(address: string, amount: number, asset: string, options?: {
|
|
75
|
+
collectFee?: boolean;
|
|
76
|
+
sponsored?: boolean;
|
|
77
|
+
}): Promise<AdapterTxResult>;
|
|
78
|
+
buildRepayTx(address: string, amount: number, asset: string, options?: {
|
|
79
|
+
sponsored?: boolean;
|
|
80
|
+
skipOracle?: boolean;
|
|
81
|
+
}): Promise<AdapterTxResult>;
|
|
82
|
+
maxWithdraw(address: string, _asset: string): Promise<MaxWithdrawResult>;
|
|
83
|
+
maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
|
|
84
|
+
addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
|
|
85
|
+
coin: TransactionObjectArgument;
|
|
86
|
+
effectiveAmount: number;
|
|
87
|
+
}>;
|
|
88
|
+
addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
|
|
89
|
+
collectFee?: boolean;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
|
|
92
|
+
getPendingRewards(address: string): Promise<PendingReward[]>;
|
|
93
|
+
addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward[]>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare class CetusAdapter implements SwapAdapter {
|
|
97
|
+
readonly id = "cetus";
|
|
98
|
+
readonly name = "Cetus";
|
|
99
|
+
readonly version = "1.0.0";
|
|
100
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
101
|
+
private client;
|
|
102
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
103
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
104
|
+
getQuote(from: string, to: string, amount: number): Promise<SwapQuote>;
|
|
105
|
+
buildSwapTx(address: string, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<AdapterTxResult & {
|
|
106
|
+
estimatedOut: number;
|
|
107
|
+
toDecimals: number;
|
|
108
|
+
}>;
|
|
109
|
+
getSupportedPairs(): Array<{
|
|
110
|
+
from: string;
|
|
111
|
+
to: string;
|
|
112
|
+
}>;
|
|
113
|
+
getPoolPrice(): Promise<number>;
|
|
114
|
+
addSwapToTx(tx: Transaction, address: string, inputCoin: TransactionObjectArgument, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<{
|
|
115
|
+
outputCoin: TransactionObjectArgument;
|
|
116
|
+
estimatedOut: number;
|
|
117
|
+
toDecimals: number;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare class SuilendAdapter implements LendingAdapter {
|
|
122
|
+
readonly id = "suilend";
|
|
123
|
+
readonly name = "Suilend";
|
|
124
|
+
readonly version = "3.0.0";
|
|
125
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
126
|
+
readonly supportedAssets: readonly string[];
|
|
127
|
+
readonly supportsSameAssetBorrow = false;
|
|
128
|
+
private client;
|
|
129
|
+
private sdkClient;
|
|
130
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
131
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
132
|
+
private getSdkClient;
|
|
133
|
+
private resolveSymbol;
|
|
134
|
+
getRates(asset: string): Promise<LendingRates>;
|
|
135
|
+
getPositions(address: string): Promise<AdapterPositions>;
|
|
136
|
+
getHealth(address: string): Promise<HealthInfo>;
|
|
137
|
+
buildSaveTx(address: string, amount: number, asset: string, options?: {
|
|
138
|
+
collectFee?: boolean;
|
|
139
|
+
}): Promise<AdapterTxResult>;
|
|
140
|
+
buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
|
|
141
|
+
effectiveAmount: number;
|
|
142
|
+
}>;
|
|
143
|
+
addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
|
|
144
|
+
coin: TransactionObjectArgument;
|
|
145
|
+
effectiveAmount: number;
|
|
146
|
+
}>;
|
|
147
|
+
addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
|
|
148
|
+
collectFee?: boolean;
|
|
149
|
+
}): Promise<void>;
|
|
150
|
+
buildBorrowTx(address: string, amount: number, asset: string, options?: {
|
|
151
|
+
collectFee?: boolean;
|
|
152
|
+
}): Promise<AdapterTxResult>;
|
|
153
|
+
buildRepayTx(address: string, amount: number, asset: string): Promise<AdapterTxResult>;
|
|
154
|
+
addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
|
|
155
|
+
private resolveWithdrawCTokens;
|
|
156
|
+
maxWithdraw(address: string, _asset: string): Promise<{
|
|
157
|
+
maxAmount: number;
|
|
158
|
+
healthFactorAfter: number;
|
|
159
|
+
currentHF: number;
|
|
160
|
+
}>;
|
|
161
|
+
maxBorrow(address: string, _asset: string): Promise<{
|
|
162
|
+
maxAmount: number;
|
|
163
|
+
healthFactorAfter: number;
|
|
164
|
+
currentHF: number;
|
|
165
|
+
}>;
|
|
166
|
+
private fetchAllCoins;
|
|
167
|
+
getPendingRewards(address: string): Promise<PendingReward[]>;
|
|
168
|
+
addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward[]>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { AdapterCapability, AdapterPositions, AdapterTxResult, CetusAdapter, HealthInfo, LendingAdapter, LendingRates, NaviAdapter, ProtocolRegistry, SuilendAdapter, SwapAdapter, SwapQuote };
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,3 +1,171 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '@mysten/sui/jsonRpc';
|
|
1
|
+
import { L as LendingAdapter, e as SwapAdapter, w as LendingRates, a1 as SwapQuote, z as AdapterPositions, y as AdapterCapability, O as HealthInfo, J as AdapterTxResult, M as MaxWithdrawResult, h as MaxBorrowResult, a6 as PendingReward } from '../descriptors-B6qt_mwi.js';
|
|
2
|
+
export { U as PerpsAdapter, $ as ProtocolDescriptor, a2 as allDescriptors, a3 as cetusDescriptor, a4 as naviDescriptor, a5 as suilendDescriptor } from '../descriptors-B6qt_mwi.js';
|
|
3
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
4
|
+
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
5
|
+
|
|
6
|
+
declare class ProtocolRegistry {
|
|
7
|
+
private lending;
|
|
8
|
+
private swap;
|
|
9
|
+
registerLending(adapter: LendingAdapter): void;
|
|
10
|
+
registerSwap(adapter: SwapAdapter): void;
|
|
11
|
+
bestSaveRate(asset: string): Promise<{
|
|
12
|
+
adapter: LendingAdapter;
|
|
13
|
+
rate: LendingRates;
|
|
14
|
+
}>;
|
|
15
|
+
bestBorrowRate(asset: string, opts?: {
|
|
16
|
+
requireSameAssetBorrow?: boolean;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
adapter: LendingAdapter;
|
|
19
|
+
rate: LendingRates;
|
|
20
|
+
}>;
|
|
21
|
+
bestSwapQuote(from: string, to: string, amount: number): Promise<{
|
|
22
|
+
adapter: SwapAdapter;
|
|
23
|
+
quote: SwapQuote;
|
|
24
|
+
}>;
|
|
25
|
+
bestSaveRateAcrossAssets(): Promise<{
|
|
26
|
+
adapter: LendingAdapter;
|
|
27
|
+
rate: LendingRates;
|
|
28
|
+
asset: string;
|
|
29
|
+
}>;
|
|
30
|
+
allRatesAcrossAssets(): Promise<Array<{
|
|
31
|
+
protocol: string;
|
|
32
|
+
protocolId: string;
|
|
33
|
+
asset: string;
|
|
34
|
+
rates: LendingRates;
|
|
35
|
+
}>>;
|
|
36
|
+
allRates(asset: string): Promise<Array<{
|
|
37
|
+
protocol: string;
|
|
38
|
+
protocolId: string;
|
|
39
|
+
rates: LendingRates;
|
|
40
|
+
}>>;
|
|
41
|
+
allPositions(address: string): Promise<Array<{
|
|
42
|
+
protocol: string;
|
|
43
|
+
protocolId: string;
|
|
44
|
+
positions: AdapterPositions;
|
|
45
|
+
}>>;
|
|
46
|
+
getLending(id: string): LendingAdapter | undefined;
|
|
47
|
+
getSwap(id: string): SwapAdapter | undefined;
|
|
48
|
+
listLending(): LendingAdapter[];
|
|
49
|
+
listSwap(): SwapAdapter[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare class NaviAdapter implements LendingAdapter {
|
|
53
|
+
readonly id = "navi";
|
|
54
|
+
readonly name = "NAVI Protocol";
|
|
55
|
+
readonly version = "1.0.0";
|
|
56
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
57
|
+
readonly supportedAssets: readonly string[];
|
|
58
|
+
readonly supportsSameAssetBorrow = true;
|
|
59
|
+
private client;
|
|
60
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
61
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
62
|
+
getRates(asset: string): Promise<LendingRates>;
|
|
63
|
+
getPositions(address: string): Promise<AdapterPositions>;
|
|
64
|
+
getHealth(address: string): Promise<HealthInfo>;
|
|
65
|
+
buildSaveTx(address: string, amount: number, asset: string, options?: {
|
|
66
|
+
collectFee?: boolean;
|
|
67
|
+
sponsored?: boolean;
|
|
68
|
+
}): Promise<AdapterTxResult>;
|
|
69
|
+
buildWithdrawTx(address: string, amount: number, asset: string, options?: {
|
|
70
|
+
sponsored?: boolean;
|
|
71
|
+
}): Promise<AdapterTxResult & {
|
|
72
|
+
effectiveAmount: number;
|
|
73
|
+
}>;
|
|
74
|
+
buildBorrowTx(address: string, amount: number, asset: string, options?: {
|
|
75
|
+
collectFee?: boolean;
|
|
76
|
+
sponsored?: boolean;
|
|
77
|
+
}): Promise<AdapterTxResult>;
|
|
78
|
+
buildRepayTx(address: string, amount: number, asset: string, options?: {
|
|
79
|
+
sponsored?: boolean;
|
|
80
|
+
skipOracle?: boolean;
|
|
81
|
+
}): Promise<AdapterTxResult>;
|
|
82
|
+
maxWithdraw(address: string, _asset: string): Promise<MaxWithdrawResult>;
|
|
83
|
+
maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
|
|
84
|
+
addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
|
|
85
|
+
coin: TransactionObjectArgument;
|
|
86
|
+
effectiveAmount: number;
|
|
87
|
+
}>;
|
|
88
|
+
addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
|
|
89
|
+
collectFee?: boolean;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
|
|
92
|
+
getPendingRewards(address: string): Promise<PendingReward[]>;
|
|
93
|
+
addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward[]>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare class CetusAdapter implements SwapAdapter {
|
|
97
|
+
readonly id = "cetus";
|
|
98
|
+
readonly name = "Cetus";
|
|
99
|
+
readonly version = "1.0.0";
|
|
100
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
101
|
+
private client;
|
|
102
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
103
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
104
|
+
getQuote(from: string, to: string, amount: number): Promise<SwapQuote>;
|
|
105
|
+
buildSwapTx(address: string, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<AdapterTxResult & {
|
|
106
|
+
estimatedOut: number;
|
|
107
|
+
toDecimals: number;
|
|
108
|
+
}>;
|
|
109
|
+
getSupportedPairs(): Array<{
|
|
110
|
+
from: string;
|
|
111
|
+
to: string;
|
|
112
|
+
}>;
|
|
113
|
+
getPoolPrice(): Promise<number>;
|
|
114
|
+
addSwapToTx(tx: Transaction, address: string, inputCoin: TransactionObjectArgument, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<{
|
|
115
|
+
outputCoin: TransactionObjectArgument;
|
|
116
|
+
estimatedOut: number;
|
|
117
|
+
toDecimals: number;
|
|
118
|
+
}>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare class SuilendAdapter implements LendingAdapter {
|
|
122
|
+
readonly id = "suilend";
|
|
123
|
+
readonly name = "Suilend";
|
|
124
|
+
readonly version = "3.0.0";
|
|
125
|
+
readonly capabilities: readonly AdapterCapability[];
|
|
126
|
+
readonly supportedAssets: readonly string[];
|
|
127
|
+
readonly supportsSameAssetBorrow = false;
|
|
128
|
+
private client;
|
|
129
|
+
private sdkClient;
|
|
130
|
+
init(client: SuiJsonRpcClient): Promise<void>;
|
|
131
|
+
initSync(client: SuiJsonRpcClient): void;
|
|
132
|
+
private getSdkClient;
|
|
133
|
+
private resolveSymbol;
|
|
134
|
+
getRates(asset: string): Promise<LendingRates>;
|
|
135
|
+
getPositions(address: string): Promise<AdapterPositions>;
|
|
136
|
+
getHealth(address: string): Promise<HealthInfo>;
|
|
137
|
+
buildSaveTx(address: string, amount: number, asset: string, options?: {
|
|
138
|
+
collectFee?: boolean;
|
|
139
|
+
}): Promise<AdapterTxResult>;
|
|
140
|
+
buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
|
|
141
|
+
effectiveAmount: number;
|
|
142
|
+
}>;
|
|
143
|
+
addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
|
|
144
|
+
coin: TransactionObjectArgument;
|
|
145
|
+
effectiveAmount: number;
|
|
146
|
+
}>;
|
|
147
|
+
addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
|
|
148
|
+
collectFee?: boolean;
|
|
149
|
+
}): Promise<void>;
|
|
150
|
+
buildBorrowTx(address: string, amount: number, asset: string, options?: {
|
|
151
|
+
collectFee?: boolean;
|
|
152
|
+
}): Promise<AdapterTxResult>;
|
|
153
|
+
buildRepayTx(address: string, amount: number, asset: string): Promise<AdapterTxResult>;
|
|
154
|
+
addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
|
|
155
|
+
private resolveWithdrawCTokens;
|
|
156
|
+
maxWithdraw(address: string, _asset: string): Promise<{
|
|
157
|
+
maxAmount: number;
|
|
158
|
+
healthFactorAfter: number;
|
|
159
|
+
currentHF: number;
|
|
160
|
+
}>;
|
|
161
|
+
maxBorrow(address: string, _asset: string): Promise<{
|
|
162
|
+
maxAmount: number;
|
|
163
|
+
healthFactorAfter: number;
|
|
164
|
+
currentHF: number;
|
|
165
|
+
}>;
|
|
166
|
+
private fetchAllCoins;
|
|
167
|
+
getPendingRewards(address: string): Promise<PendingReward[]>;
|
|
168
|
+
addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward[]>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { AdapterCapability, AdapterPositions, AdapterTxResult, CetusAdapter, HealthInfo, LendingAdapter, LendingRates, NaviAdapter, ProtocolRegistry, SuilendAdapter, SwapAdapter, SwapQuote };
|
package/dist/adapters/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { normalizeStructTag } from '@mysten/sui/utils';
|
|
|
5
5
|
import { SuilendClient, LENDING_MARKET_ID, LENDING_MARKET_TYPE } from '@suilend/sdk/client';
|
|
6
6
|
import { initializeSuilend, initializeObligations } from '@suilend/sdk/lib/initialize';
|
|
7
7
|
import { Side } from '@suilend/sdk/lib/types';
|
|
8
|
-
import '@mysten/sui/bcs';
|
|
9
8
|
|
|
10
9
|
// src/constants.ts
|
|
11
10
|
var SAVE_FEE_BPS = 10n;
|
|
@@ -74,8 +73,6 @@ var INVESTMENT_ASSETS = {
|
|
|
74
73
|
ETH: SUPPORTED_ASSETS.ETH,
|
|
75
74
|
GOLD: SUPPORTED_ASSETS.GOLD
|
|
76
75
|
};
|
|
77
|
-
var SENTINEL = {
|
|
78
|
-
PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7"};
|
|
79
76
|
|
|
80
77
|
// src/errors.ts
|
|
81
78
|
var T2000Error = class extends Error {
|
|
@@ -508,6 +505,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
508
505
|
}
|
|
509
506
|
async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
510
507
|
const asset = options.asset ?? "USDC";
|
|
508
|
+
const sponsored = options.sponsored ?? true;
|
|
511
509
|
const assetInfo = resolveAssetInfo(asset);
|
|
512
510
|
const posResult = await getPositions(client, address);
|
|
513
511
|
const supply = posResult.positions.find(
|
|
@@ -525,7 +523,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
525
523
|
});
|
|
526
524
|
return { coin, effectiveAmount: 0 };
|
|
527
525
|
}
|
|
528
|
-
await refreshOracle(tx, client, address);
|
|
526
|
+
await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
|
|
529
527
|
try {
|
|
530
528
|
const coin = await withdrawCoinPTB(tx, assetInfo.type, rawAmount, sdkOptions(client));
|
|
531
529
|
return { coin, effectiveAmount };
|
|
@@ -549,8 +547,9 @@ async function addSaveToTx(tx, _client, _address, coin, options = {}) {
|
|
|
549
547
|
}
|
|
550
548
|
async function addRepayToTx(tx, client, address, coin, options = {}) {
|
|
551
549
|
const asset = options.asset ?? "USDC";
|
|
550
|
+
const sponsored = options.sponsored ?? true;
|
|
552
551
|
const assetInfo = resolveAssetInfo(asset);
|
|
553
|
-
await refreshOracle(tx, client, address);
|
|
552
|
+
await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
|
|
554
553
|
try {
|
|
555
554
|
await repayCoinPTB(tx, assetInfo.type, coin, { env: "prod" });
|
|
556
555
|
} catch (err) {
|
|
@@ -685,8 +684,9 @@ async function addClaimRewardsToTx(tx, client, address) {
|
|
|
685
684
|
}
|
|
686
685
|
}
|
|
687
686
|
|
|
688
|
-
// src/adapters/
|
|
689
|
-
var
|
|
687
|
+
// src/adapters/descriptors.ts
|
|
688
|
+
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
689
|
+
var naviDescriptor = {
|
|
690
690
|
id: "navi",
|
|
691
691
|
name: "NAVI Protocol",
|
|
692
692
|
packages: [],
|
|
@@ -702,6 +702,42 @@ var descriptor = {
|
|
|
702
702
|
"incentive_v3::repay": "repay"
|
|
703
703
|
}
|
|
704
704
|
};
|
|
705
|
+
var suilendDescriptor = {
|
|
706
|
+
id: "suilend",
|
|
707
|
+
name: "Suilend",
|
|
708
|
+
packages: [SUILEND_PACKAGE],
|
|
709
|
+
actionMap: {
|
|
710
|
+
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
711
|
+
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
712
|
+
"lending_market::create_obligation": "save",
|
|
713
|
+
"lending_market::withdraw_ctokens": "withdraw",
|
|
714
|
+
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
715
|
+
"lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
|
|
716
|
+
"lending_market::fulfill_liquidity_request": "withdraw",
|
|
717
|
+
"lending_market::unstake_sui_from_staker": "withdraw",
|
|
718
|
+
"lending_market::borrow": "borrow",
|
|
719
|
+
"lending_market::repay": "repay"
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
var cetusDescriptor = {
|
|
723
|
+
id: "cetus",
|
|
724
|
+
name: "Cetus DEX",
|
|
725
|
+
packages: [CETUS_PACKAGE],
|
|
726
|
+
actionMap: {
|
|
727
|
+
"router::swap": "swap",
|
|
728
|
+
"router::swap_ab_bc": "swap",
|
|
729
|
+
"router::swap_ab_cb": "swap",
|
|
730
|
+
"router::swap_ba_bc": "swap",
|
|
731
|
+
"router::swap_ba_cb": "swap"
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
var allDescriptors = [
|
|
735
|
+
naviDescriptor,
|
|
736
|
+
suilendDescriptor,
|
|
737
|
+
cetusDescriptor
|
|
738
|
+
];
|
|
739
|
+
|
|
740
|
+
// src/adapters/navi.ts
|
|
705
741
|
var NaviAdapter = class {
|
|
706
742
|
id = "navi";
|
|
707
743
|
name = "NAVI Protocol";
|
|
@@ -942,18 +978,6 @@ function fallbackQuote(fromAsset, amount, poolPrice) {
|
|
|
942
978
|
}
|
|
943
979
|
|
|
944
980
|
// src/adapters/cetus.ts
|
|
945
|
-
var descriptor2 = {
|
|
946
|
-
id: "cetus",
|
|
947
|
-
name: "Cetus DEX",
|
|
948
|
-
packages: [CETUS_PACKAGE],
|
|
949
|
-
actionMap: {
|
|
950
|
-
"router::swap": "swap",
|
|
951
|
-
"router::swap_ab_bc": "swap",
|
|
952
|
-
"router::swap_ab_cb": "swap",
|
|
953
|
-
"router::swap_ba_bc": "swap",
|
|
954
|
-
"router::swap_ba_cb": "swap"
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
981
|
var CetusAdapter = class {
|
|
958
982
|
id = "cetus";
|
|
959
983
|
name = "Cetus";
|
|
@@ -1012,7 +1036,6 @@ var CetusAdapter = class {
|
|
|
1012
1036
|
});
|
|
1013
1037
|
}
|
|
1014
1038
|
};
|
|
1015
|
-
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
1016
1039
|
var MIN_HEALTH_FACTOR2 = 1.5;
|
|
1017
1040
|
async function quietSuilend(fn) {
|
|
1018
1041
|
const origLog = console.log;
|
|
@@ -1029,23 +1052,6 @@ async function quietSuilend(fn) {
|
|
|
1029
1052
|
console.warn = origWarn;
|
|
1030
1053
|
});
|
|
1031
1054
|
}
|
|
1032
|
-
var descriptor3 = {
|
|
1033
|
-
id: "suilend",
|
|
1034
|
-
name: "Suilend",
|
|
1035
|
-
packages: [SUILEND_PACKAGE],
|
|
1036
|
-
actionMap: {
|
|
1037
|
-
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
1038
|
-
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
1039
|
-
"lending_market::create_obligation": "save",
|
|
1040
|
-
"lending_market::withdraw_ctokens": "withdraw",
|
|
1041
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
1042
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
|
|
1043
|
-
"lending_market::fulfill_liquidity_request": "withdraw",
|
|
1044
|
-
"lending_market::unstake_sui_from_staker": "withdraw",
|
|
1045
|
-
"lending_market::borrow": "borrow",
|
|
1046
|
-
"lending_market::repay": "repay"
|
|
1047
|
-
}
|
|
1048
|
-
};
|
|
1049
1055
|
var SuilendAdapter = class {
|
|
1050
1056
|
id = "suilend";
|
|
1051
1057
|
name = "Suilend";
|
|
@@ -1456,24 +1462,7 @@ var SuilendAdapter = class {
|
|
|
1456
1462
|
}
|
|
1457
1463
|
}
|
|
1458
1464
|
};
|
|
1459
|
-
var descriptor4 = {
|
|
1460
|
-
id: "sentinel",
|
|
1461
|
-
name: "Sui Sentinel",
|
|
1462
|
-
packages: [SENTINEL.PACKAGE],
|
|
1463
|
-
actionMap: {
|
|
1464
|
-
"sentinel::request_attack": "sentinel_attack",
|
|
1465
|
-
"sentinel::consume_prompt": "sentinel_settle"
|
|
1466
|
-
}
|
|
1467
|
-
};
|
|
1468
|
-
|
|
1469
|
-
// src/adapters/index.ts
|
|
1470
|
-
var allDescriptors = [
|
|
1471
|
-
descriptor,
|
|
1472
|
-
descriptor3,
|
|
1473
|
-
descriptor2,
|
|
1474
|
-
descriptor4
|
|
1475
|
-
];
|
|
1476
1465
|
|
|
1477
|
-
export { CetusAdapter, NaviAdapter, ProtocolRegistry, SuilendAdapter, allDescriptors,
|
|
1466
|
+
export { CetusAdapter, NaviAdapter, ProtocolRegistry, SuilendAdapter, allDescriptors, cetusDescriptor, naviDescriptor, suilendDescriptor };
|
|
1478
1467
|
//# sourceMappingURL=index.js.map
|
|
1479
1468
|
//# sourceMappingURL=index.js.map
|