@gearbox-protocol/sdk 8.6.4 → 8.6.6
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/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +0 -3
- package/dist/cjs/sdk/chain/chains.js +6 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +0 -3
- package/dist/esm/sdk/chain/chains.js +6 -0
- package/dist/types/dev/AccountOpener.d.ts +2 -2
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +4 -25
- package/dist/types/sdk/accounts/createCreditAccountService.d.ts +2 -2
- package/dist/types/sdk/accounts/types.d.ts +237 -17
- package/package.json +1 -1
|
@@ -94,9 +94,6 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
94
94
|
* Methods to get all credit accounts with some optional filtering
|
|
95
95
|
* Performs all necessary price feed updates under the hood
|
|
96
96
|
*
|
|
97
|
-
* TODO: do we want to expose pagination?
|
|
98
|
-
* TODO: do we want to expose "reverting"?
|
|
99
|
-
* TODO: do we want to expose MarketFilter in any way? If so, we need to check that the MarketFilter is compatibled with attached markets?
|
|
100
97
|
* @param options
|
|
101
98
|
* @param blockNumber
|
|
102
99
|
* @returns returned credit accounts are sorted by health factor in ascending order
|
|
@@ -268,6 +268,12 @@ const chains = {
|
|
|
268
268
|
wellKnownToken: {
|
|
269
269
|
address: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
270
270
|
symbol: "USDC.e"
|
|
271
|
+
},
|
|
272
|
+
contracts: {
|
|
273
|
+
multicall3: {
|
|
274
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
275
|
+
blockCreated: 484490
|
|
276
|
+
}
|
|
271
277
|
}
|
|
272
278
|
}),
|
|
273
279
|
Lisk: (0, import_viem.defineChain)({
|
|
@@ -85,9 +85,6 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
85
85
|
* Methods to get all credit accounts with some optional filtering
|
|
86
86
|
* Performs all necessary price feed updates under the hood
|
|
87
87
|
*
|
|
88
|
-
* TODO: do we want to expose pagination?
|
|
89
|
-
* TODO: do we want to expose "reverting"?
|
|
90
|
-
* TODO: do we want to expose MarketFilter in any way? If so, we need to check that the MarketFilter is compatibled with attached markets?
|
|
91
88
|
* @param options
|
|
92
89
|
* @param blockNumber
|
|
93
90
|
* @returns returned credit accounts are sorted by health factor in ascending order
|
|
@@ -254,6 +254,12 @@ const chains = {
|
|
|
254
254
|
wellKnownToken: {
|
|
255
255
|
address: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
256
256
|
symbol: "USDC.e"
|
|
257
|
+
},
|
|
258
|
+
contracts: {
|
|
259
|
+
multicall3: {
|
|
260
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
261
|
+
blockCreated: 484490
|
|
262
|
+
}
|
|
257
263
|
}
|
|
258
264
|
}),
|
|
259
265
|
Lisk: defineChain({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address, Hash, PrivateKeyAccount } from "viem";
|
|
2
2
|
import { BaseError } from "viem";
|
|
3
|
-
import type { CreditAccountData,
|
|
3
|
+
import type { CreditAccountData, ICreditAccountsService, RawTx } from "../sdk/index.js";
|
|
4
4
|
import { SDKConstruct } from "../sdk/index.js";
|
|
5
5
|
export declare class OpenTxRevertedError extends BaseError {
|
|
6
6
|
readonly txHash: Hash;
|
|
@@ -37,7 +37,7 @@ export interface OpenAccountResult {
|
|
|
37
37
|
}
|
|
38
38
|
export declare class AccountOpener extends SDKConstruct {
|
|
39
39
|
#private;
|
|
40
|
-
constructor(service:
|
|
40
|
+
constructor(service: ICreditAccountsService, options?: AccountOpenerOptions);
|
|
41
41
|
get borrower(): Address;
|
|
42
42
|
/**
|
|
43
43
|
* Tries to open account with underlying only in each CM
|
|
@@ -5,6 +5,7 @@ import type { GearboxSDK } from "../GearboxSDK.js";
|
|
|
5
5
|
import type { OnDemandPriceUpdate, UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
6
|
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
7
7
|
import type { MultiCall } from "../types/index.js";
|
|
8
|
+
import type { GetConnectedBotsResult } from "./types";
|
|
8
9
|
import type { AddCollateralProps, ChangeDeptProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, EnableTokensProps, ExecuteSwapProps, GetCreditAccountsOptions, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, Rewards, UpdateQuotasProps } from "./types.js";
|
|
9
10
|
export interface CreditAccountServiceOptions {
|
|
10
11
|
batchSize?: number;
|
|
@@ -24,9 +25,6 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
24
25
|
* Methods to get all credit accounts with some optional filtering
|
|
25
26
|
* Performs all necessary price feed updates under the hood
|
|
26
27
|
*
|
|
27
|
-
* TODO: do we want to expose pagination?
|
|
28
|
-
* TODO: do we want to expose "reverting"?
|
|
29
|
-
* TODO: do we want to expose MarketFilter in any way? If so, we need to check that the MarketFilter is compatibled with attached markets?
|
|
30
28
|
* @param options
|
|
31
29
|
* @param blockNumber
|
|
32
30
|
* @returns returned credit accounts are sorted by health factor in ascending order
|
|
@@ -48,26 +46,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
48
46
|
getConnectedBots(accountsToCheck: Array<{
|
|
49
47
|
creditAccount: Address;
|
|
50
48
|
creditManager: Address;
|
|
51
|
-
}>): Promise<
|
|
52
|
-
error: Error;
|
|
53
|
-
result?: undefined;
|
|
54
|
-
status: "failure";
|
|
55
|
-
} | {
|
|
56
|
-
error?: undefined;
|
|
57
|
-
result: readonly {
|
|
58
|
-
baseParams: {
|
|
59
|
-
addr: `0x${string}`;
|
|
60
|
-
version: bigint;
|
|
61
|
-
contractType: `0x${string}`;
|
|
62
|
-
serializedParams: `0x${string}`;
|
|
63
|
-
};
|
|
64
|
-
requiredPermissions: bigint;
|
|
65
|
-
creditAccount: `0x${string}`;
|
|
66
|
-
permissions: bigint;
|
|
67
|
-
forbidden: boolean;
|
|
68
|
-
}[];
|
|
69
|
-
status: "success";
|
|
70
|
-
})[]>;
|
|
49
|
+
}>): Promise<GetConnectedBotsResult>;
|
|
71
50
|
/**
|
|
72
51
|
* Generates transaction to liquidate credit account
|
|
73
52
|
* @param account
|
|
@@ -188,7 +167,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
188
167
|
* @returns
|
|
189
168
|
*/
|
|
190
169
|
getUpdateForAccounts(accounts: Array<RouterCASlice>): Promise<UpdatePriceFeedsResult>;
|
|
191
|
-
getUpdateForAccount(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<UpdatePriceFeedsResult>;
|
|
170
|
+
protected getUpdateForAccount(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<UpdatePriceFeedsResult>;
|
|
192
171
|
/**
|
|
193
172
|
* Returns account price updates in a non-encoded format
|
|
194
173
|
* @param acc
|
|
@@ -203,7 +182,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
203
182
|
* @param acc
|
|
204
183
|
* @returns
|
|
205
184
|
*/
|
|
206
|
-
getPriceUpdatesForFacade(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<Array<MultiCall>>;
|
|
185
|
+
protected getPriceUpdatesForFacade(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<Array<MultiCall>>;
|
|
207
186
|
protected prepareDisableQuotas(ca: RouterCASlice): Array<MultiCall>;
|
|
208
187
|
protected prepareUpdateQuotas(creditFacade: Address, { averageQuota, minQuota }: PrepareUpdateQuotasProps): Array<MultiCall>;
|
|
209
188
|
protected prepareDecreaseDebt(ca: RouterCASlice): Array<MultiCall>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
2
2
|
import type { CreditAccountServiceOptions } from "./AbstractCreditAccountsService.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ICreditAccountsService } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* @sdk
|
|
6
6
|
* @version version of desired credit facade; if no credit facade is considered (you only want to get ca list), either v300 or v310 is fine, because ca compressor has nothing to do with credit facade version
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function createCreditAccountService(sdk: GearboxSDK, version: number, options?: CreditAccountServiceOptions):
|
|
9
|
+
export declare function createCreditAccountService(sdk: GearboxSDK, version: number, options?: CreditAccountServiceOptions): ICreditAccountsService;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Address, ContractFunctionArgs } from "viem";
|
|
2
2
|
import type { iCreditAccountCompressorAbi } from "../../abi/compressors.js";
|
|
3
3
|
import type { BotType } from "../../plugins/bots/types.js";
|
|
4
|
+
import type { ConnectedBotData, CreditAccountData } from "../base/index.js";
|
|
4
5
|
import type { SDKConstruct } from "../base/SDKConstruct.js";
|
|
5
|
-
import type { CreditSuite } from "../market/index.js";
|
|
6
|
+
import type { CreditSuite, OnDemandPriceUpdate, UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
7
|
import type { Asset, RouterCASlice, RouterCloseResult } from "../router/index.js";
|
|
7
8
|
import type { MultiCall, RawTx } from "../types/index.js";
|
|
8
|
-
import type { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
|
|
9
9
|
export type GetCreditAccountsArgs = ContractFunctionArgs<typeof iCreditAccountCompressorAbi, "pure" | "view", "getCreditAccounts">;
|
|
10
10
|
export interface CreditAccountFilter {
|
|
11
11
|
owner: Address;
|
|
@@ -37,11 +37,32 @@ export interface CreditAccountOperationResult {
|
|
|
37
37
|
}
|
|
38
38
|
export type CloseOptions = "close" | "zeroDebt";
|
|
39
39
|
export interface CloseCreditAccountProps {
|
|
40
|
+
/**
|
|
41
|
+
* Close or zeroDebt
|
|
42
|
+
*/
|
|
40
43
|
operation: CloseOptions;
|
|
44
|
+
/**
|
|
45
|
+
* Minimal credit account data on which operation is performed
|
|
46
|
+
*/
|
|
41
47
|
creditAccount: RouterCASlice;
|
|
48
|
+
/**
|
|
49
|
+
* Tokens to withdraw from credit account.
|
|
50
|
+
* For credit account closing this is the underlying token, because during the closure,
|
|
51
|
+
* all tokens on account are swapped into the underlying,
|
|
52
|
+
* and only the underlying token will remain on the credit account
|
|
53
|
+
*/
|
|
42
54
|
assetsToWithdraw: Array<Address>;
|
|
55
|
+
/**
|
|
56
|
+
* Wallet address to withdraw underlying to
|
|
57
|
+
*/
|
|
43
58
|
to: Address;
|
|
59
|
+
/**
|
|
60
|
+
* Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
|
|
61
|
+
*/
|
|
44
62
|
slippage?: bigint;
|
|
63
|
+
/**
|
|
64
|
+
* Result of findBestClosePath method from router; if omited, calls marketRegister.findCreditManager {@link RouterCloseResult}
|
|
65
|
+
*/
|
|
45
66
|
closePath?: RouterCloseResult;
|
|
46
67
|
}
|
|
47
68
|
export interface RepayCreditAccountProps extends RepayAndLiquidateCreditAccountProps {
|
|
@@ -88,12 +109,27 @@ export interface PrepareUpdateQuotasProps {
|
|
|
88
109
|
minQuota: Array<Asset>;
|
|
89
110
|
}
|
|
90
111
|
export interface UpdateQuotasProps extends PrepareUpdateQuotasProps {
|
|
112
|
+
/**
|
|
113
|
+
* Minimal credit account data on which operation is performed
|
|
114
|
+
*/
|
|
91
115
|
creditAccount: RouterCASlice;
|
|
92
116
|
}
|
|
93
117
|
export interface AddCollateralProps extends PrepareUpdateQuotasProps {
|
|
118
|
+
/**
|
|
119
|
+
* Asset to add as collateral
|
|
120
|
+
*/
|
|
94
121
|
asset: Asset;
|
|
122
|
+
/**
|
|
123
|
+
* Native token amount to attach to tx
|
|
124
|
+
*/
|
|
95
125
|
ethAmount: bigint;
|
|
126
|
+
/**
|
|
127
|
+
* Permit of collateral asset if it is permittable
|
|
128
|
+
*/
|
|
96
129
|
permit: PermitResult | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Minimal credit account data on which operation is performed
|
|
132
|
+
*/
|
|
97
133
|
creditAccount: RouterCASlice;
|
|
98
134
|
}
|
|
99
135
|
export interface WithdrawCollateralProps extends PrepareUpdateQuotasProps {
|
|
@@ -111,7 +147,13 @@ export interface WithdrawCollateralProps extends PrepareUpdateQuotasProps {
|
|
|
111
147
|
creditAccount: RouterCASlice;
|
|
112
148
|
}
|
|
113
149
|
export interface ExecuteSwapProps extends PrepareUpdateQuotasProps {
|
|
150
|
+
/**
|
|
151
|
+
* Array of MultiCall from router methods getSingleSwap or getAllSwaps
|
|
152
|
+
*/
|
|
114
153
|
calls: Array<MultiCall>;
|
|
154
|
+
/**
|
|
155
|
+
* Minimal credit account data on which operation is performed
|
|
156
|
+
*/
|
|
115
157
|
creditAccount: RouterCASlice;
|
|
116
158
|
}
|
|
117
159
|
export interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
|
|
@@ -131,23 +173,70 @@ export interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
|
|
|
131
173
|
creditAccount: RouterCASlice;
|
|
132
174
|
}
|
|
133
175
|
export interface EnableTokensProps {
|
|
176
|
+
/**
|
|
177
|
+
* List of tokens to disable
|
|
178
|
+
*/
|
|
134
179
|
disabledTokens: Array<Address>;
|
|
180
|
+
/**
|
|
181
|
+
* List of tokens to enable
|
|
182
|
+
*/
|
|
135
183
|
enabledTokens: Array<Address>;
|
|
184
|
+
/**
|
|
185
|
+
* Minimal credit account data on which operation is performed
|
|
186
|
+
*/
|
|
136
187
|
creditAccount: RouterCASlice;
|
|
137
188
|
}
|
|
138
189
|
export interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
190
|
+
/**
|
|
191
|
+
* Native token amount to attach to tx
|
|
192
|
+
*/
|
|
139
193
|
ethAmount: bigint;
|
|
194
|
+
/**
|
|
195
|
+
* Array of collateral which can be just directly added or swapped using the path {@link Asset}
|
|
196
|
+
*/
|
|
140
197
|
collateral: Array<Asset>;
|
|
198
|
+
/**
|
|
199
|
+
* Debt to open credit account with
|
|
200
|
+
*/
|
|
141
201
|
debt: bigint;
|
|
202
|
+
/**
|
|
203
|
+
* Flag to withdraw debt to wallet after opening credit account;
|
|
204
|
+
* used for borrowing functionality
|
|
205
|
+
*/
|
|
142
206
|
withdrawDebt?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Permits of collateral tokens (in any permittable token is present) {@link PermitResult}
|
|
209
|
+
*/
|
|
143
210
|
permits: Record<string, PermitResult>;
|
|
211
|
+
/**
|
|
212
|
+
* Array of MultiCall from router methods findOpenStrategyPath {@link MultiCall}.
|
|
213
|
+
* Used for trading and strategy functionality
|
|
214
|
+
*/
|
|
144
215
|
calls: Array<MultiCall>;
|
|
216
|
+
/**
|
|
217
|
+
* Address of credit manager to open credit account on
|
|
218
|
+
*/
|
|
145
219
|
creditManager: Address;
|
|
220
|
+
/**
|
|
221
|
+
* Wallet address to transfer credit account to
|
|
222
|
+
*/
|
|
146
223
|
to: Address;
|
|
224
|
+
/**
|
|
225
|
+
* Referral code to open credit account with
|
|
226
|
+
*/
|
|
147
227
|
referralCode: bigint;
|
|
148
228
|
}
|
|
149
229
|
export interface ChangeDeptProps {
|
|
230
|
+
/**
|
|
231
|
+
* Minimal credit account data on which operation is performed
|
|
232
|
+
*/
|
|
150
233
|
creditAccount: RouterCASlice;
|
|
234
|
+
/**
|
|
235
|
+
* Amount to change debt by
|
|
236
|
+
* 0 - prohibited value;
|
|
237
|
+
* negative value for debt decrease;
|
|
238
|
+
* positive value for debt increase.
|
|
239
|
+
*/
|
|
151
240
|
amount: bigint;
|
|
152
241
|
}
|
|
153
242
|
export interface PermitResult {
|
|
@@ -197,48 +286,179 @@ export interface SetBotProps {
|
|
|
197
286
|
*/
|
|
198
287
|
creditAccount: RouterCASlice;
|
|
199
288
|
}
|
|
200
|
-
export type
|
|
289
|
+
export type GetConnectedBotsResult = Array<{
|
|
290
|
+
error?: undefined;
|
|
291
|
+
result: readonly ConnectedBotData[];
|
|
292
|
+
status: "success";
|
|
293
|
+
} | {
|
|
294
|
+
error: Error;
|
|
295
|
+
result?: undefined;
|
|
296
|
+
status: "failure";
|
|
297
|
+
}>;
|
|
201
298
|
export interface ICreditAccountsService extends SDKConstruct {
|
|
299
|
+
/**
|
|
300
|
+
* Returns single credit account data, or undefined if it's not found
|
|
301
|
+
* Performs all necessary price feed updates under the hood
|
|
302
|
+
* @param account
|
|
303
|
+
* @param blockNumber
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
|
|
307
|
+
/**
|
|
308
|
+
* Methods to get all credit accounts with some optional filtering
|
|
309
|
+
* Performs all necessary price feed updates under the hood
|
|
310
|
+
*
|
|
311
|
+
* @param options
|
|
312
|
+
* @param blockNumber
|
|
313
|
+
* @returns returned credit accounts are sorted by health factor in ascending order
|
|
314
|
+
*/
|
|
315
|
+
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
316
|
+
/**
|
|
317
|
+
* Method to get all claimable rewards for credit account (ex. stkUSDS SKY rewards)
|
|
318
|
+
* Assosiates rewards by adapter + stakedPhantomToken
|
|
319
|
+
* @param {Address} creditAccount - address of credit account to get rewards for
|
|
320
|
+
* @returns {Array<Rewards>} list of {@link Rewards} that can be claimed
|
|
321
|
+
*/
|
|
322
|
+
getRewards(creditAccount: Address): Promise<Array<Rewards>>;
|
|
323
|
+
/**
|
|
324
|
+
* Method to get all connected bots for credit account
|
|
325
|
+
* @param {Array<{ creditAccount: Address; creditManager: Address }>} accountsToCheck - list of credit accounts
|
|
326
|
+
* and their credit managers to check connected bots on
|
|
327
|
+
* @returns call result of getConnectedBots for each credit account
|
|
328
|
+
*/
|
|
329
|
+
getConnectedBots(accountsToCheck: Array<{
|
|
330
|
+
creditAccount: Address;
|
|
331
|
+
creditManager: Address;
|
|
332
|
+
}>): Promise<GetConnectedBotsResult>;
|
|
202
333
|
/**
|
|
203
334
|
* V3.1 method, throws in V3. Connects/disables a bot and updates prices
|
|
204
335
|
* @param props - {@link SetBotProps}
|
|
205
336
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
206
337
|
*/
|
|
207
338
|
setBot: (props: SetBotProps) => Promise<CreditAccountOperationResult>;
|
|
339
|
+
/**
|
|
340
|
+
* Generates transaction to liquidate credit account
|
|
341
|
+
* @param account
|
|
342
|
+
* @param to Address to transfer underlying left after liquidation
|
|
343
|
+
* @param slippage
|
|
344
|
+
* @param force TODO: legacy v3 option to remove
|
|
345
|
+
* @returns
|
|
346
|
+
*/
|
|
347
|
+
fullyLiquidate(account: RouterCASlice, to: Address, slippage?: bigint, force?: boolean): Promise<CloseCreditAccountResult>;
|
|
348
|
+
/**
|
|
349
|
+
* Closes credit account or closes credit account and keeps it open with zero debt.
|
|
350
|
+
* - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
|
|
351
|
+
* -> disable quotas of exiting tokens -> decrease debt -> disable exiting tokens tokens -> withdraw underlying tokenz
|
|
352
|
+
* @param props - {@link CloseCreditAccountProps}
|
|
353
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
354
|
+
*/
|
|
355
|
+
closeCreditAccount(props: CloseCreditAccountProps): Promise<CloseCreditAccountResult>;
|
|
356
|
+
/**
|
|
357
|
+
* Updates quota of credit account.
|
|
358
|
+
* CA quota updated in the following order: price update -> update quotas
|
|
359
|
+
* @param props - {@link UpdateQuotasProps}
|
|
360
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
361
|
+
*/
|
|
362
|
+
updateQuotas(props: UpdateQuotasProps): Promise<CreditAccountOperationResult>;
|
|
363
|
+
/**
|
|
364
|
+
* Adds a single collateral to credit account and updates quotas
|
|
365
|
+
* Collateral is added in the following order: price update -> add collateral (with permit) -> update quotas
|
|
366
|
+
* @param props - {@link AddCollateralProps}
|
|
367
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
368
|
+
*/
|
|
369
|
+
addCollateral(props: AddCollateralProps): Promise<CreditAccountOperationResult>;
|
|
370
|
+
/**
|
|
371
|
+
* Increases or decreases debt of credit account; debt decrease uses token ON CREDIT ACCOUNT
|
|
372
|
+
* Debt is changed in the following order: price update -> (enables underlying if it was disabled) -> change debt
|
|
373
|
+
* @param props - {@link ChangeDeptProps}
|
|
374
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
375
|
+
*/
|
|
376
|
+
changeDebt(props: ChangeDeptProps): Promise<CreditAccountOperationResult>;
|
|
377
|
+
/**
|
|
378
|
+
* Executes swap specified by given calls, update quotas of affected tokens
|
|
379
|
+
* Swap is executed in the following order: price update -> execute swap path -> update quotas
|
|
380
|
+
* @param props - {@link ExecuteSwapProps}
|
|
381
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
382
|
+
*/
|
|
383
|
+
executeSwap(props: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
|
|
384
|
+
/**
|
|
385
|
+
* Executes enable/disable tokens specified by given tokens lists and token prices
|
|
386
|
+
* @param props - {@link EnableTokensProps}
|
|
387
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
388
|
+
*/
|
|
389
|
+
enableTokens(props: EnableTokensProps): Promise<CreditAccountOperationResult>;
|
|
390
|
+
/**
|
|
391
|
+
* Executes swap specified by given calls, update quotas of affected tokens
|
|
392
|
+
* - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
|
|
393
|
+
* -> update quotas -> (optionally: execute swap path for trading/strategy) ->
|
|
394
|
+
* -> (optionally: withdraw debt for lending)
|
|
395
|
+
* - Basic open credit account: price update -> increase debt -> add collateral -> update quotas
|
|
396
|
+
* - Lending: price update -> increase debt -> add collateral -> update quotas -> withdraw debt
|
|
397
|
+
* - Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
|
|
398
|
+
* - In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
|
|
399
|
+
* @param props - {@link OpenCAProps}
|
|
400
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
401
|
+
*/
|
|
402
|
+
openCA(props: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
403
|
+
/**
|
|
404
|
+
* Returns borrow rate with 4 digits precision (10000 = 100%)
|
|
405
|
+
* @param ca
|
|
406
|
+
* @returns
|
|
407
|
+
*/
|
|
408
|
+
getBorrowRate(ca: CreditAccountData): bigint;
|
|
409
|
+
/**
|
|
410
|
+
* Returns optimal HF for partial liquidation with 4 digits precision (10000 = 100%)
|
|
411
|
+
* @param ca
|
|
412
|
+
*/
|
|
413
|
+
getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
|
|
414
|
+
/**
|
|
415
|
+
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
416
|
+
*
|
|
417
|
+
* This can be used by batch liquidator
|
|
418
|
+
* @param accounts
|
|
419
|
+
* @returns
|
|
420
|
+
*/
|
|
421
|
+
getUpdateForAccounts(accounts: Array<RouterCASlice>): Promise<UpdatePriceFeedsResult>;
|
|
422
|
+
/**
|
|
423
|
+
* Returns account price updates in a non-encoded format
|
|
424
|
+
* @param acc
|
|
425
|
+
* @returns
|
|
426
|
+
*/
|
|
427
|
+
getOnDemandPriceUpdates(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<Array<OnDemandPriceUpdate>>;
|
|
208
428
|
/**
|
|
209
429
|
* Withdraws a single collateral from credit account to wallet to and updates quotas;
|
|
210
|
-
|
|
211
|
-
|
|
430
|
+
* technically can withdraw several tokens at once
|
|
431
|
+
* - Collateral is withdrawn in the following order: price update -> withdraw token -> update quotas for affected tokens
|
|
212
432
|
* @param props - {@link WithdrawCollateralProps}
|
|
213
433
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
214
434
|
*/
|
|
215
435
|
withdrawCollateral(props: WithdrawCollateralProps): Promise<CreditAccountOperationResult>;
|
|
216
436
|
/**
|
|
217
437
|
* Fully repays credit account or repays credit account and keeps it open with zero debt
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
438
|
+
* - Repays in the following order: price update -> add collateral to cover the debt ->
|
|
439
|
+
* -> disable quotas for all tokens -> decrease debt -> disable tokens all tokens -> withdraw all tokens
|
|
440
|
+
* - V3.0 claims rewards for tokens which are specified in legacy SDK
|
|
441
|
+
* - V3.1 claims rewards for all tokens IF router is also V3.1
|
|
222
442
|
* @param props - {@link RepayCreditAccountProps}
|
|
223
443
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
224
444
|
*/
|
|
225
445
|
repayCreditAccount(props: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
|
|
226
446
|
/**
|
|
227
447
|
* Fully repays liquidatable account
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
448
|
+
* - Repay and liquidate is executed in the following order: price update -> add collateral to cover the debt ->
|
|
449
|
+
* withdraw all tokens from credit account
|
|
450
|
+
* - V3.0 claims rewards for tokens which are specified in legacy SDK
|
|
451
|
+
* - V3.1 claims rewards for all tokens IF router is also V3.1
|
|
232
452
|
* @param props - {@link RepayAndLiquidateCreditAccountProps}
|
|
233
453
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
234
454
|
*/
|
|
235
455
|
repayAndLiquidateCreditAccount(props: RepayAndLiquidateCreditAccountProps): Promise<CreditAccountOperationResult>;
|
|
236
456
|
/**
|
|
237
457
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
458
|
+
* - Claim rewards is executed in the following order: price update -> execute claim calls ->
|
|
459
|
+
* -> (optionally: disable reward tokens) -> (optionally: update quotas)
|
|
460
|
+
* - V3.0 claims rewards for tokens which are specified in legacy SDK
|
|
461
|
+
* - V3.1 claims rewards for all tokens IF router is also V3.1 and falls back to legacy calls if router is not v3.0
|
|
242
462
|
* @param props - {@link ClaimFarmRewardsProps}
|
|
243
463
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
244
464
|
*/
|