@gearbox-protocol/sdk 8.8.0 → 8.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/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +5 -6
- package/dist/cjs/sdk/chain/chains.js +6 -0
- package/dist/cjs/sdk/router/AbstractRouterContract.js +5 -4
- package/dist/cjs/sdk/router/RouterV300Contract.js +3 -2
- package/dist/cjs/sdk/router/RouterV310Contract.js +9 -2
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/normal.js +15 -0
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/token.js +12 -3
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +5 -6
- package/dist/esm/sdk/chain/chains.js +6 -0
- package/dist/esm/sdk/router/AbstractRouterContract.js +5 -4
- package/dist/esm/sdk/router/RouterV300Contract.js +3 -2
- package/dist/esm/sdk/router/RouterV310Contract.js +9 -2
- package/dist/esm/sdk/sdk-gov-legacy/tokens/normal.js +15 -0
- package/dist/esm/sdk/sdk-gov-legacy/tokens/token.js +12 -3
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +3 -6
- package/dist/types/sdk/accounts/types.d.ts +24 -5
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/router/AbstractRouterContract.d.ts +3 -3
- package/dist/types/sdk/router/RouterV300Contract.d.ts +1 -1
- package/dist/types/sdk/router/types.d.ts +7 -1
- package/dist/types/sdk/sdk-gov-legacy/tokens/normal.d.ts +1 -1
- package/package.json +1 -1
|
@@ -210,19 +210,18 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
212
|
* Generates transaction to liquidate credit account
|
|
213
|
-
* @param
|
|
214
|
-
* @param to Address to transfer underlying left after liquidation
|
|
215
|
-
* @param slippage
|
|
216
|
-
* @param force TODO: legacy v3 option to remove
|
|
213
|
+
* @param props - {@link FullyLiquidateProps}
|
|
217
214
|
* @returns
|
|
218
215
|
*/
|
|
219
|
-
async fullyLiquidate(
|
|
216
|
+
async fullyLiquidate(props) {
|
|
217
|
+
const { account, to, slippage = 50n, force = false, keepAssets } = props;
|
|
220
218
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
221
219
|
const routerCloseResult = await this.sdk.routerFor(account).findBestClosePath({
|
|
222
220
|
creditAccount: account,
|
|
223
221
|
creditManager: cm.creditManager,
|
|
224
222
|
slippage,
|
|
225
|
-
force
|
|
223
|
+
force,
|
|
224
|
+
keepAssets
|
|
226
225
|
});
|
|
227
226
|
const priceUpdates = await this.getPriceUpdatesForFacade(
|
|
228
227
|
account.creditManager,
|
|
@@ -264,6 +264,9 @@ const chains = {
|
|
|
264
264
|
...import_chains.hemi,
|
|
265
265
|
network: "Hemi",
|
|
266
266
|
defaultMarketConfigurators: {},
|
|
267
|
+
testMarketConfigurators: {
|
|
268
|
+
"0xc9961b8a0c763779690577f2c76962c086af2fe3": "Invariant"
|
|
269
|
+
},
|
|
267
270
|
isPublic: false,
|
|
268
271
|
wellKnownToken: {
|
|
269
272
|
address: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
@@ -280,6 +283,9 @@ const chains = {
|
|
|
280
283
|
...import_chains.lisk,
|
|
281
284
|
network: "Lisk",
|
|
282
285
|
defaultMarketConfigurators: {},
|
|
286
|
+
testMarketConfigurators: {
|
|
287
|
+
"0x25778dbf0e56b7feb8358c4aa2f6f9e19a1c145a": "Re7"
|
|
288
|
+
},
|
|
283
289
|
isPublic: false,
|
|
284
290
|
wellKnownToken: {
|
|
285
291
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
@@ -28,8 +28,8 @@ class AbstractRouterContract extends import_base.BaseContract {
|
|
|
28
28
|
hooks = new import_internal.Hooks();
|
|
29
29
|
addHook = this.hooks.addHook.bind(this.hooks);
|
|
30
30
|
removeHook = this.hooks.removeHook.bind(this.hooks);
|
|
31
|
-
getExpectedAndLeftover(ca, cm, balances) {
|
|
32
|
-
const b = balances || this.getDefaultExpectedAndLeftover(ca);
|
|
31
|
+
getExpectedAndLeftover(ca, cm, balances, keepAssets) {
|
|
32
|
+
const b = balances || this.getDefaultExpectedAndLeftover(ca, keepAssets);
|
|
33
33
|
const { leftoverBalances, expectedBalances, tokensToClaim } = b;
|
|
34
34
|
const expected = new import_utils.AddressMap();
|
|
35
35
|
const leftover = new import_utils.AddressMap();
|
|
@@ -47,16 +47,17 @@ class AbstractRouterContract extends import_base.BaseContract {
|
|
|
47
47
|
tokensToClaim
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
getDefaultExpectedAndLeftover(ca) {
|
|
50
|
+
getDefaultExpectedAndLeftover(ca, keepAssets) {
|
|
51
51
|
const expectedBalances = new import_utils.AddressMap();
|
|
52
52
|
const leftoverBalances = new import_utils.AddressMap();
|
|
53
|
+
const keepAssetsSet = new Set(keepAssets?.map((a) => a.toLowerCase()));
|
|
53
54
|
for (const { token: t, balance, mask } of ca.tokens) {
|
|
54
55
|
const token = t;
|
|
55
56
|
const isEnabled = (mask & ca.enabledTokensMask) !== 0n;
|
|
56
57
|
expectedBalances.upsert(token, { token, balance });
|
|
57
58
|
const decimals = this.sdk.tokensMeta.decimals(token);
|
|
58
59
|
const minBalance = 10n ** BigInt(Math.max(8, decimals) - 8);
|
|
59
|
-
if (balance < minBalance || !isEnabled) {
|
|
60
|
+
if (keepAssetsSet.has(token.toLowerCase()) || balance < minBalance || !isEnabled) {
|
|
60
61
|
leftoverBalances.upsert(token, { token, balance });
|
|
61
62
|
}
|
|
62
63
|
}
|
|
@@ -260,11 +260,12 @@ class RouterV300Contract extends import_AbstractRouterContract.AbstractRouterCon
|
|
|
260
260
|
/**
|
|
261
261
|
* Implements {@link IRouterContract.getFindClosePathInput}
|
|
262
262
|
*/
|
|
263
|
-
getFindClosePathInput(ca, cm, balances) {
|
|
263
|
+
getFindClosePathInput(ca, cm, balances, keepAssets) {
|
|
264
264
|
const { expectedBalances, leftoverBalances } = this.getExpectedAndLeftover(
|
|
265
265
|
ca,
|
|
266
266
|
cm,
|
|
267
|
-
balances
|
|
267
|
+
balances,
|
|
268
|
+
keepAssets
|
|
268
269
|
);
|
|
269
270
|
const pathOptions = import_PathOptionFactory.PathOptionFactory.generatePathOptions(
|
|
270
271
|
ca.tokens,
|
|
@@ -164,7 +164,13 @@ class RouterV310Contract extends import_AbstractRouterContract.AbstractRouterCon
|
|
|
164
164
|
* Implements {@link IRouterContract.findBestClosePath}
|
|
165
165
|
*/
|
|
166
166
|
async findBestClosePath(props) {
|
|
167
|
-
const {
|
|
167
|
+
const {
|
|
168
|
+
creditAccount: ca,
|
|
169
|
+
creditManager: cm,
|
|
170
|
+
slippage,
|
|
171
|
+
balances,
|
|
172
|
+
keepAssets
|
|
173
|
+
} = props;
|
|
168
174
|
const { expectedBalances, leftoverBalances, tokensToClaim } = this.getExpectedAndLeftover(
|
|
169
175
|
ca,
|
|
170
176
|
cm,
|
|
@@ -172,7 +178,8 @@ class RouterV310Contract extends import_AbstractRouterContract.AbstractRouterCon
|
|
|
172
178
|
expectedBalances: (0, import_helpers.assetsMap)(balances.expectedBalances),
|
|
173
179
|
leftoverBalances: (0, import_helpers.assetsMap)(balances.leftoverBalances),
|
|
174
180
|
tokensToClaim: (0, import_helpers.assetsMap)(balances.tokensToClaim || [])
|
|
175
|
-
} : void 0
|
|
181
|
+
} : void 0,
|
|
182
|
+
keepAssets
|
|
176
183
|
);
|
|
177
184
|
const getNumSplits = this.#numSplitsGetter(cm, expectedBalances.values());
|
|
178
185
|
const tData = [];
|
|
@@ -520,6 +520,21 @@ const normalTokens = {
|
|
|
520
520
|
name: "Pendle PT sUSDX 1 September 2025 expiry",
|
|
521
521
|
symbol: "PT_sUSDX_1SEP2025",
|
|
522
522
|
type: { AllNetworks: import_tokenType.TokenType.NORMAL_TOKEN }
|
|
523
|
+
},
|
|
524
|
+
lskETH: {
|
|
525
|
+
name: "lskETH",
|
|
526
|
+
symbol: "lskETH",
|
|
527
|
+
type: { AllNetworks: import_tokenType.TokenType.NORMAL_TOKEN }
|
|
528
|
+
},
|
|
529
|
+
hemiBTC: {
|
|
530
|
+
name: "hemiBTC",
|
|
531
|
+
symbol: "hemiBTC",
|
|
532
|
+
type: { AllNetworks: import_tokenType.TokenType.NORMAL_TOKEN }
|
|
533
|
+
},
|
|
534
|
+
bfBTC: {
|
|
535
|
+
name: "bfBTC",
|
|
536
|
+
symbol: "bfBTC",
|
|
537
|
+
type: { AllNetworks: import_tokenType.TokenType.NORMAL_TOKEN }
|
|
523
538
|
}
|
|
524
539
|
};
|
|
525
540
|
const isNormalToken = (t) => typeof t === "string" && !!normalTokens[t];
|
|
@@ -348,7 +348,10 @@ const tokenDataByNetwork = {
|
|
|
348
348
|
WXTZ: import_constants.NOT_DEPLOYED,
|
|
349
349
|
mBASIS: import_constants.NOT_DEPLOYED,
|
|
350
350
|
mTBILL: import_constants.NOT_DEPLOYED,
|
|
351
|
-
PT_sUSDX_1SEP2025: import_constants.NOT_DEPLOYED
|
|
351
|
+
PT_sUSDX_1SEP2025: import_constants.NOT_DEPLOYED,
|
|
352
|
+
lskETH: import_constants.NOT_DEPLOYED,
|
|
353
|
+
hemiBTC: import_constants.NOT_DEPLOYED,
|
|
354
|
+
bfBTC: import_constants.NOT_DEPLOYED
|
|
352
355
|
},
|
|
353
356
|
///
|
|
354
357
|
///
|
|
@@ -559,8 +562,14 @@ const tokenDataByNetwork = {
|
|
|
559
562
|
WXTZ: "0xc9b53ab2679f573e480d01e0f49e2b5cfb7a3eab",
|
|
560
563
|
mTBILL: "0xdd629e5241cbc5919847783e6c96b2de4754e438"
|
|
561
564
|
},
|
|
562
|
-
Hemi: {
|
|
563
|
-
|
|
565
|
+
Hemi: {
|
|
566
|
+
hemiBTC: "0xAA40c0c7644e0b2B224509571e10ad20d9C4ef28",
|
|
567
|
+
bfBTC: "0x623F2774d9f27B59bc6b954544487532CE79d9DF"
|
|
568
|
+
},
|
|
569
|
+
Lisk: {
|
|
570
|
+
wstETH: "0x76D8de471F54aAA87784119c60Df1bbFc852C415",
|
|
571
|
+
lskETH: "0x1b10E2270780858923cdBbC9B5423e29fffD1A44"
|
|
572
|
+
}
|
|
564
573
|
};
|
|
565
574
|
const tickerInfoTokensByNetwork = {
|
|
566
575
|
Mainnet: {
|
|
@@ -201,19 +201,18 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Generates transaction to liquidate credit account
|
|
204
|
-
* @param
|
|
205
|
-
* @param to Address to transfer underlying left after liquidation
|
|
206
|
-
* @param slippage
|
|
207
|
-
* @param force TODO: legacy v3 option to remove
|
|
204
|
+
* @param props - {@link FullyLiquidateProps}
|
|
208
205
|
* @returns
|
|
209
206
|
*/
|
|
210
|
-
async fullyLiquidate(
|
|
207
|
+
async fullyLiquidate(props) {
|
|
208
|
+
const { account, to, slippage = 50n, force = false, keepAssets } = props;
|
|
211
209
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
212
210
|
const routerCloseResult = await this.sdk.routerFor(account).findBestClosePath({
|
|
213
211
|
creditAccount: account,
|
|
214
212
|
creditManager: cm.creditManager,
|
|
215
213
|
slippage,
|
|
216
|
-
force
|
|
214
|
+
force,
|
|
215
|
+
keepAssets
|
|
217
216
|
});
|
|
218
217
|
const priceUpdates = await this.getPriceUpdatesForFacade(
|
|
219
218
|
account.creditManager,
|
|
@@ -250,6 +250,9 @@ const chains = {
|
|
|
250
250
|
...hemi,
|
|
251
251
|
network: "Hemi",
|
|
252
252
|
defaultMarketConfigurators: {},
|
|
253
|
+
testMarketConfigurators: {
|
|
254
|
+
"0xc9961b8a0c763779690577f2c76962c086af2fe3": "Invariant"
|
|
255
|
+
},
|
|
253
256
|
isPublic: false,
|
|
254
257
|
wellKnownToken: {
|
|
255
258
|
address: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
@@ -266,6 +269,9 @@ const chains = {
|
|
|
266
269
|
...lisk,
|
|
267
270
|
network: "Lisk",
|
|
268
271
|
defaultMarketConfigurators: {},
|
|
272
|
+
testMarketConfigurators: {
|
|
273
|
+
"0x25778dbf0e56b7feb8358c4aa2f6f9e19a1c145a": "Re7"
|
|
274
|
+
},
|
|
269
275
|
isPublic: false,
|
|
270
276
|
wellKnownToken: {
|
|
271
277
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
@@ -5,8 +5,8 @@ class AbstractRouterContract extends BaseContract {
|
|
|
5
5
|
hooks = new Hooks();
|
|
6
6
|
addHook = this.hooks.addHook.bind(this.hooks);
|
|
7
7
|
removeHook = this.hooks.removeHook.bind(this.hooks);
|
|
8
|
-
getExpectedAndLeftover(ca, cm, balances) {
|
|
9
|
-
const b = balances || this.getDefaultExpectedAndLeftover(ca);
|
|
8
|
+
getExpectedAndLeftover(ca, cm, balances, keepAssets) {
|
|
9
|
+
const b = balances || this.getDefaultExpectedAndLeftover(ca, keepAssets);
|
|
10
10
|
const { leftoverBalances, expectedBalances, tokensToClaim } = b;
|
|
11
11
|
const expected = new AddressMap();
|
|
12
12
|
const leftover = new AddressMap();
|
|
@@ -24,16 +24,17 @@ class AbstractRouterContract extends BaseContract {
|
|
|
24
24
|
tokensToClaim
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
getDefaultExpectedAndLeftover(ca) {
|
|
27
|
+
getDefaultExpectedAndLeftover(ca, keepAssets) {
|
|
28
28
|
const expectedBalances = new AddressMap();
|
|
29
29
|
const leftoverBalances = new AddressMap();
|
|
30
|
+
const keepAssetsSet = new Set(keepAssets?.map((a) => a.toLowerCase()));
|
|
30
31
|
for (const { token: t, balance, mask } of ca.tokens) {
|
|
31
32
|
const token = t;
|
|
32
33
|
const isEnabled = (mask & ca.enabledTokensMask) !== 0n;
|
|
33
34
|
expectedBalances.upsert(token, { token, balance });
|
|
34
35
|
const decimals = this.sdk.tokensMeta.decimals(token);
|
|
35
36
|
const minBalance = 10n ** BigInt(Math.max(8, decimals) - 8);
|
|
36
|
-
if (balance < minBalance || !isEnabled) {
|
|
37
|
+
if (keepAssetsSet.has(token.toLowerCase()) || balance < minBalance || !isEnabled) {
|
|
37
38
|
leftoverBalances.upsert(token, { token, balance });
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -240,11 +240,12 @@ class RouterV300Contract extends AbstractRouterContract {
|
|
|
240
240
|
/**
|
|
241
241
|
* Implements {@link IRouterContract.getFindClosePathInput}
|
|
242
242
|
*/
|
|
243
|
-
getFindClosePathInput(ca, cm, balances) {
|
|
243
|
+
getFindClosePathInput(ca, cm, balances, keepAssets) {
|
|
244
244
|
const { expectedBalances, leftoverBalances } = this.getExpectedAndLeftover(
|
|
245
245
|
ca,
|
|
246
246
|
cm,
|
|
247
|
-
balances
|
|
247
|
+
balances,
|
|
248
|
+
keepAssets
|
|
248
249
|
);
|
|
249
250
|
const pathOptions = PathOptionFactory.generatePathOptions(
|
|
250
251
|
ca.tokens,
|
|
@@ -141,7 +141,13 @@ class RouterV310Contract extends AbstractRouterContract {
|
|
|
141
141
|
* Implements {@link IRouterContract.findBestClosePath}
|
|
142
142
|
*/
|
|
143
143
|
async findBestClosePath(props) {
|
|
144
|
-
const {
|
|
144
|
+
const {
|
|
145
|
+
creditAccount: ca,
|
|
146
|
+
creditManager: cm,
|
|
147
|
+
slippage,
|
|
148
|
+
balances,
|
|
149
|
+
keepAssets
|
|
150
|
+
} = props;
|
|
145
151
|
const { expectedBalances, leftoverBalances, tokensToClaim } = this.getExpectedAndLeftover(
|
|
146
152
|
ca,
|
|
147
153
|
cm,
|
|
@@ -149,7 +155,8 @@ class RouterV310Contract extends AbstractRouterContract {
|
|
|
149
155
|
expectedBalances: assetsMap(balances.expectedBalances),
|
|
150
156
|
leftoverBalances: assetsMap(balances.leftoverBalances),
|
|
151
157
|
tokensToClaim: assetsMap(balances.tokensToClaim || [])
|
|
152
|
-
} : void 0
|
|
158
|
+
} : void 0,
|
|
159
|
+
keepAssets
|
|
153
160
|
);
|
|
154
161
|
const getNumSplits = this.#numSplitsGetter(cm, expectedBalances.values());
|
|
155
162
|
const tData = [];
|
|
@@ -496,6 +496,21 @@ const normalTokens = {
|
|
|
496
496
|
name: "Pendle PT sUSDX 1 September 2025 expiry",
|
|
497
497
|
symbol: "PT_sUSDX_1SEP2025",
|
|
498
498
|
type: { AllNetworks: TokenType.NORMAL_TOKEN }
|
|
499
|
+
},
|
|
500
|
+
lskETH: {
|
|
501
|
+
name: "lskETH",
|
|
502
|
+
symbol: "lskETH",
|
|
503
|
+
type: { AllNetworks: TokenType.NORMAL_TOKEN }
|
|
504
|
+
},
|
|
505
|
+
hemiBTC: {
|
|
506
|
+
name: "hemiBTC",
|
|
507
|
+
symbol: "hemiBTC",
|
|
508
|
+
type: { AllNetworks: TokenType.NORMAL_TOKEN }
|
|
509
|
+
},
|
|
510
|
+
bfBTC: {
|
|
511
|
+
name: "bfBTC",
|
|
512
|
+
symbol: "bfBTC",
|
|
513
|
+
type: { AllNetworks: TokenType.NORMAL_TOKEN }
|
|
499
514
|
}
|
|
500
515
|
};
|
|
501
516
|
const isNormalToken = (t) => typeof t === "string" && !!normalTokens[t];
|
|
@@ -321,7 +321,10 @@ const tokenDataByNetwork = {
|
|
|
321
321
|
WXTZ: NOT_DEPLOYED,
|
|
322
322
|
mBASIS: NOT_DEPLOYED,
|
|
323
323
|
mTBILL: NOT_DEPLOYED,
|
|
324
|
-
PT_sUSDX_1SEP2025: NOT_DEPLOYED
|
|
324
|
+
PT_sUSDX_1SEP2025: NOT_DEPLOYED,
|
|
325
|
+
lskETH: NOT_DEPLOYED,
|
|
326
|
+
hemiBTC: NOT_DEPLOYED,
|
|
327
|
+
bfBTC: NOT_DEPLOYED
|
|
325
328
|
},
|
|
326
329
|
///
|
|
327
330
|
///
|
|
@@ -532,8 +535,14 @@ const tokenDataByNetwork = {
|
|
|
532
535
|
WXTZ: "0xc9b53ab2679f573e480d01e0f49e2b5cfb7a3eab",
|
|
533
536
|
mTBILL: "0xdd629e5241cbc5919847783e6c96b2de4754e438"
|
|
534
537
|
},
|
|
535
|
-
Hemi: {
|
|
536
|
-
|
|
538
|
+
Hemi: {
|
|
539
|
+
hemiBTC: "0xAA40c0c7644e0b2B224509571e10ad20d9C4ef28",
|
|
540
|
+
bfBTC: "0x623F2774d9f27B59bc6b954544487532CE79d9DF"
|
|
541
|
+
},
|
|
542
|
+
Lisk: {
|
|
543
|
+
wstETH: "0x76D8de471F54aAA87784119c60Df1bbFc852C415",
|
|
544
|
+
lskETH: "0x1b10E2270780858923cdBbC9B5423e29fffD1A44"
|
|
545
|
+
}
|
|
537
546
|
};
|
|
538
547
|
const tickerInfoTokensByNetwork = {
|
|
539
548
|
Mainnet: {
|
|
@@ -5,7 +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
|
+
import type { FullyLiquidateProps, GetConnectedBotsResult } from "./types";
|
|
9
9
|
import type { AddCollateralProps, ChangeDeptProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, EnableTokensProps, ExecuteSwapProps, GetCreditAccountsOptions, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, Rewards, UpdateQuotasProps } from "./types.js";
|
|
10
10
|
export interface CreditAccountServiceOptions {
|
|
11
11
|
batchSize?: number;
|
|
@@ -49,13 +49,10 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
49
49
|
}>): Promise<GetConnectedBotsResult>;
|
|
50
50
|
/**
|
|
51
51
|
* Generates transaction to liquidate credit account
|
|
52
|
-
* @param
|
|
53
|
-
* @param to Address to transfer underlying left after liquidation
|
|
54
|
-
* @param slippage
|
|
55
|
-
* @param force TODO: legacy v3 option to remove
|
|
52
|
+
* @param props - {@link FullyLiquidateProps}
|
|
56
53
|
* @returns
|
|
57
54
|
*/
|
|
58
|
-
fullyLiquidate(
|
|
55
|
+
fullyLiquidate(props: FullyLiquidateProps): Promise<CloseCreditAccountResult>;
|
|
59
56
|
/**
|
|
60
57
|
* Closes credit account or closes credit account and keeps it open with zero debt.
|
|
61
58
|
- Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
|
|
@@ -239,6 +239,28 @@ export interface ChangeDeptProps {
|
|
|
239
239
|
*/
|
|
240
240
|
amount: bigint;
|
|
241
241
|
}
|
|
242
|
+
export interface FullyLiquidateProps {
|
|
243
|
+
/**
|
|
244
|
+
* Credit account to liquidate
|
|
245
|
+
*/
|
|
246
|
+
account: RouterCASlice;
|
|
247
|
+
/**
|
|
248
|
+
* Address to transfer underlying left after liquidation
|
|
249
|
+
*/
|
|
250
|
+
to: Address;
|
|
251
|
+
/**
|
|
252
|
+
* Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
|
|
253
|
+
*/
|
|
254
|
+
slippage?: bigint;
|
|
255
|
+
/**
|
|
256
|
+
* TODO: legacy v3 option to remove
|
|
257
|
+
*/
|
|
258
|
+
force?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* List of assets to keep on account after liquidation
|
|
261
|
+
*/
|
|
262
|
+
keepAssets?: Address[];
|
|
263
|
+
}
|
|
242
264
|
export interface PermitResult {
|
|
243
265
|
r: Address;
|
|
244
266
|
s: Address;
|
|
@@ -338,13 +360,10 @@ export interface ICreditAccountsService extends SDKConstruct {
|
|
|
338
360
|
setBot: (props: SetBotProps) => Promise<CreditAccountOperationResult>;
|
|
339
361
|
/**
|
|
340
362
|
* Generates transaction to liquidate credit account
|
|
341
|
-
* @param
|
|
342
|
-
* @param to Address to transfer underlying left after liquidation
|
|
343
|
-
* @param slippage
|
|
344
|
-
* @param force TODO: legacy v3 option to remove
|
|
363
|
+
* @param props - {@link FullyLiquidateProps}
|
|
345
364
|
* @returns
|
|
346
365
|
*/
|
|
347
|
-
fullyLiquidate(
|
|
366
|
+
fullyLiquidate(props: FullyLiquidateProps): Promise<CloseCreditAccountResult>;
|
|
348
367
|
/**
|
|
349
368
|
* Closes credit account or closes credit account and keeps it open with zero debt.
|
|
350
369
|
* - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address, Chain } from "viem";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
|
-
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7";
|
|
3
|
+
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7" | "Invariant";
|
|
4
4
|
export interface GearboxChain extends Chain {
|
|
5
5
|
network: NetworkType;
|
|
6
6
|
defaultMarketConfigurators: Record<Address, Curator>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Abi } from "viem";
|
|
1
|
+
import type { Abi, Address } from "viem";
|
|
2
2
|
import { BaseContract } from "../base/index.js";
|
|
3
3
|
import { AddressMap } from "../utils/index.js";
|
|
4
4
|
import type { IHooks } from "../utils/internal/index.js";
|
|
@@ -13,6 +13,6 @@ export declare abstract class AbstractRouterContract<abi extends Abi | readonly
|
|
|
13
13
|
protected readonly hooks: Hooks<RouterHooks>;
|
|
14
14
|
readonly addHook: <K extends "foundPathOptions">(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
15
15
|
readonly removeHook: <K extends "foundPathOptions">(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
16
|
-
protected getExpectedAndLeftover(ca: RouterCASlice, cm: RouterCMSlice, balances?: Leftovers): Leftovers;
|
|
17
|
-
protected getDefaultExpectedAndLeftover(ca: RouterCASlice): Leftovers;
|
|
16
|
+
protected getExpectedAndLeftover(ca: RouterCASlice, cm: RouterCMSlice, balances?: Leftovers, keepAssets?: Address[]): Leftovers;
|
|
17
|
+
protected getDefaultExpectedAndLeftover(ca: RouterCASlice, keepAssets?: Address[]): Leftovers;
|
|
18
18
|
}
|
|
@@ -31,7 +31,7 @@ export declare class RouterV300Contract extends AbstractRouterContract<abi> impl
|
|
|
31
31
|
/**
|
|
32
32
|
* Implements {@link IRouterContract.getFindClosePathInput}
|
|
33
33
|
*/
|
|
34
|
-
getFindClosePathInput(ca: RouterCASlice, cm: RouterCMSlice, balances?: Leftovers): FindClosePathInput;
|
|
34
|
+
getFindClosePathInput(ca: RouterCASlice, cm: RouterCMSlice, balances?: Leftovers, keepAssets?: Address[]): FindClosePathInput;
|
|
35
35
|
/**
|
|
36
36
|
* Implements {@link IRouterContract.getAvailableConnectors}
|
|
37
37
|
*/
|
|
@@ -201,6 +201,11 @@ export interface FindBestClosePathProps {
|
|
|
201
201
|
* Balances {@link ClosePathBalances} to close account with, if not provided, all assets will be swapped according to inner logic.
|
|
202
202
|
*/
|
|
203
203
|
balances?: ClosePathBalances;
|
|
204
|
+
/**
|
|
205
|
+
* List of assets to keep on account after closing.
|
|
206
|
+
* When balances are explicitly provided, keepAssets is ignored.
|
|
207
|
+
*/
|
|
208
|
+
keepAssets?: Address[];
|
|
204
209
|
/**
|
|
205
210
|
* TODO: legacy v3 option to pass to contract
|
|
206
211
|
*/
|
|
@@ -281,9 +286,10 @@ export interface IRouterContract extends IBaseContract {
|
|
|
281
286
|
* @param ca
|
|
282
287
|
* @param cm
|
|
283
288
|
* @param balances
|
|
289
|
+
* @param keepAssets
|
|
284
290
|
* @returns
|
|
285
291
|
*/
|
|
286
|
-
getFindClosePathInput: (ca: RouterCASlice, cm: RouterCMSlice, balances?: Leftovers) => FindClosePathInput;
|
|
292
|
+
getFindClosePathInput: (ca: RouterCASlice, cm: RouterCMSlice, balances?: Leftovers, keepAssets?: Address[]) => FindClosePathInput;
|
|
287
293
|
}
|
|
288
294
|
export type RouterHooks = {
|
|
289
295
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TokenBase } from "./token.js";
|
|
2
2
|
import type { TokenNetwork } from "./tokenType.js";
|
|
3
3
|
import { TokenType } from "./tokenType.js";
|
|
4
|
-
export type NormalToken = "1INCH" | "AAVE" | "CRV" | "LINK" | "SNX" | "UNI" | "USDT" | "DOLA" | "USDC" | "USDC_e" | "DAI" | "WETH" | "WBTC" | "tBTC" | "YFI" | "WLD" | "OP" | "STETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "GMX" | "ARB" | "BAL" | "ARB" | "MKR" | "RPL" | "APE" | "rETH" | "AURA" | "LBTC" | "eBTC" | "solvBTC" | "pumpBTC" | "osETH" | "weETH" | "SWISE" | "ezETH" | "rsETH" | "PENDLE" | "frxETH" | "cbETH" | "rswETH" | "USDe" | "GHO" | "pufETH" | "wstETH" | "USDS" | "SKY" | "beraSTONE" | "wS" | "stS" | "scUSD" | "T" | "tETH" | "USDL" | "wUSDL" | "csUSDL" | "RLUSD" | "MORPHO" | "steakLRT" | "Re7LRT" | "amphrETH" | "rstETH" | "pzETH" | "DVstETH" | "waEthLidowstETH" | "PT_rsETH_26SEP2024" | "PT_sUSDe_26DEC2024" | "PT_eETH_26DEC2024" | "PT_ezETH_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "PT_corn_solvBTC_BBN_26DEC2024" | "PT_corn_pumpBTC_26DEC2024" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_sUSDe_27MAR2025" | "PT_sUSDe_29MAY2025" | "PT_beraSTONE_10APR2025" | "PT_sUSDX_1SEP2025" | "rstETH_Lido_wstETH" | "DVstETH_Prime_wstETH" | "SHIB" | "crvUSD" | "WBNB" | "BTCB" | "USD1" | "USDX" | "cp0xLRT" | "uptBTC" | "PT_uptBTC_14AUG2025" | "WXTZ" | "mTBILL" | "mBASIS";
|
|
4
|
+
export type NormalToken = "1INCH" | "AAVE" | "CRV" | "LINK" | "SNX" | "UNI" | "USDT" | "DOLA" | "USDC" | "USDC_e" | "DAI" | "WETH" | "WBTC" | "tBTC" | "YFI" | "WLD" | "OP" | "STETH" | "CVX" | "FRAX" | "FXS" | "LDO" | "LUSD" | "sUSD" | "GUSD" | "LQTY" | "GMX" | "ARB" | "BAL" | "ARB" | "MKR" | "RPL" | "APE" | "rETH" | "AURA" | "LBTC" | "eBTC" | "solvBTC" | "pumpBTC" | "osETH" | "weETH" | "SWISE" | "ezETH" | "rsETH" | "PENDLE" | "frxETH" | "cbETH" | "rswETH" | "USDe" | "GHO" | "pufETH" | "wstETH" | "USDS" | "SKY" | "beraSTONE" | "wS" | "stS" | "scUSD" | "T" | "tETH" | "USDL" | "wUSDL" | "csUSDL" | "RLUSD" | "MORPHO" | "steakLRT" | "Re7LRT" | "amphrETH" | "rstETH" | "pzETH" | "DVstETH" | "waEthLidowstETH" | "PT_rsETH_26SEP2024" | "PT_sUSDe_26DEC2024" | "PT_eETH_26DEC2024" | "PT_ezETH_26DEC2024" | "PT_eBTC_26DEC2024" | "PT_LBTC_27MAR2025" | "PT_corn_solvBTC_BBN_26DEC2024" | "PT_corn_pumpBTC_26DEC2024" | "PT_cornLBTC_26DEC2024" | "PT_corn_eBTC_27MAR2025" | "PT_sUSDe_27MAR2025" | "PT_sUSDe_29MAY2025" | "PT_beraSTONE_10APR2025" | "PT_sUSDX_1SEP2025" | "rstETH_Lido_wstETH" | "DVstETH_Prime_wstETH" | "SHIB" | "crvUSD" | "WBNB" | "BTCB" | "USD1" | "USDX" | "cp0xLRT" | "uptBTC" | "PT_uptBTC_14AUG2025" | "WXTZ" | "mTBILL" | "mBASIS" | "lskETH" | "hemiBTC" | "bfBTC";
|
|
5
5
|
export type NormalTokenData = {
|
|
6
6
|
symbol: NormalToken;
|
|
7
7
|
type: Partial<Record<TokenNetwork, TokenType.NORMAL_TOKEN>>;
|