@gearbox-protocol/sdk 13.5.0-next.1 → 13.5.0-next.3
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/dev/AccountOpener.js +5 -45
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +6 -339
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -13
- package/dist/cjs/sdk/base/TokensMeta.js +7 -151
- package/dist/cjs/sdk/base/token-types.js +0 -6
- package/dist/cjs/sdk/chain/chains.js +1 -2
- package/dist/cjs/sdk/constants/addresses.js +3 -0
- package/dist/cjs/sdk/market/MarketRegister.js +0 -3
- package/dist/cjs/sdk/market/MarketSuite.js +0 -3
- package/dist/cjs/sdk/market/ZapperRegister.js +0 -123
- package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -17
- package/dist/cjs/sdk/market/pool/index.js +0 -4
- package/dist/cjs/sdk/pools/PoolService.js +84 -132
- package/dist/esm/dev/AccountOpener.js +6 -47
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +6 -339
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -13
- package/dist/esm/sdk/base/TokensMeta.js +7 -155
- package/dist/esm/sdk/base/token-types.js +0 -4
- package/dist/esm/sdk/chain/chains.js +1 -2
- package/dist/esm/sdk/constants/addresses.js +2 -0
- package/dist/esm/sdk/market/MarketRegister.js +0 -3
- package/dist/esm/sdk/market/MarketSuite.js +0 -3
- package/dist/esm/sdk/market/ZapperRegister.js +0 -123
- package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -17
- package/dist/esm/sdk/market/pool/index.js +0 -2
- package/dist/esm/sdk/pools/PoolService.js +75 -127
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +5 -103
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +2 -4
- package/dist/types/sdk/accounts/types.d.ts +6 -130
- package/dist/types/sdk/base/TokensMeta.d.ts +3 -20
- package/dist/types/sdk/base/token-types.d.ts +1 -21
- package/dist/types/sdk/base/types.d.ts +3 -0
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/constants/addresses.d.ts +4 -0
- package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
- package/dist/types/sdk/market/pool/index.d.ts +0 -2
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/pools/PoolService.d.ts +24 -0
- package/dist/types/sdk/pools/types.d.ts +9 -8
- package/package.json +1 -1
- package/dist/cjs/abi/310/iSecuritizeDegenNFT.js +0 -263
- package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +0 -278
- package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +0 -97
- package/dist/esm/abi/310/iSecuritizeDegenNFT.js +0 -239
- package/dist/esm/abi/310/iSecuritizeKYCFactory.js +0 -254
- package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +0 -73
- package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +0 -324
- package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +0 -322
- package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +0 -345
|
@@ -1,82 +1,34 @@
|
|
|
1
1
|
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
3
2
|
import { ierc20ZapperDepositsAbi } from "../../abi/iERC20ZapperDeposits.js";
|
|
4
3
|
import { iethZapperDepositsAbi } from "../../abi/iETHZapperDeposits.js";
|
|
5
4
|
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
SDKConstruct
|
|
10
|
-
} from "../base/index.js";
|
|
11
|
-
import { AddressSet, hexEq } from "../index.js";
|
|
12
|
-
import { AddressMap } from "../utils/index.js";
|
|
13
|
-
const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
14
|
-
const POOL_TOKENS_TO_MIGRATE = new AddressMap([
|
|
15
|
-
// v2 diesels
|
|
16
|
-
["0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA", "dDAI"],
|
|
17
|
-
["0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3", "dUSDC"],
|
|
18
|
-
["0xe753260F1955e8678DCeA8887759e07aa57E8c54", "dWBTC"],
|
|
19
|
-
["0xF21fc650C1B34eb0FDE786D52d23dA99Db3D6278", "dWETH"],
|
|
20
|
-
["0x2158034dB06f06dcB9A786D2F1F8c38781bA779d", "dwstETH"],
|
|
21
|
-
["0x8A1112AFef7F4FC7c066a77AABBc01b3Fff31D47", "dFRAX"]
|
|
22
|
-
]);
|
|
5
|
+
import { SDKConstruct } from "../base/index.js";
|
|
6
|
+
import { NATIVE_ADDRESS } from "../constants/index.js";
|
|
7
|
+
import { AddressSet, hexEq } from "../utils/index.js";
|
|
23
8
|
class PoolService extends SDKConstruct {
|
|
9
|
+
/**
|
|
10
|
+
* @inheritdoc IPoolsService.getDepositTokensIn
|
|
11
|
+
*/
|
|
24
12
|
getDepositTokensIn(pool) {
|
|
25
|
-
const underlying = this.#describeUnderlying(pool);
|
|
26
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
27
|
-
switch (underlying.contractType) {
|
|
28
|
-
case KYC_UNDERLYING_DEFAULT:
|
|
29
|
-
return this.#depositTokensIn(pool, false);
|
|
30
|
-
case KYC_UNDERLYING_ON_DEMAND:
|
|
31
|
-
return [underlying.asset];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
13
|
return this.#depositTokensIn(pool, true);
|
|
35
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @inheritdoc IPoolsService.getDepositTokensOut
|
|
17
|
+
*/
|
|
36
18
|
getDepositTokensOut(pool, tokenIn) {
|
|
37
|
-
const underlying = this.#describeUnderlying(pool);
|
|
38
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
39
|
-
switch (underlying.contractType) {
|
|
40
|
-
case KYC_UNDERLYING_DEFAULT:
|
|
41
|
-
return this.#depositTokensOut(pool, tokenIn, false);
|
|
42
|
-
case KYC_UNDERLYING_ON_DEMAND:
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
19
|
return this.#depositTokensOut(pool, tokenIn, true);
|
|
47
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritdoc IPoolsService.getDepositMetadata
|
|
23
|
+
*/
|
|
48
24
|
getDepositMetadata(pool, tokenIn, tokenOut) {
|
|
49
|
-
const underlying = this.#describeUnderlying(pool);
|
|
50
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
51
|
-
switch (underlying.contractType) {
|
|
52
|
-
case KYC_UNDERLYING_DEFAULT: {
|
|
53
|
-
return this.#depositMetadata(
|
|
54
|
-
"kyc-default",
|
|
55
|
-
pool,
|
|
56
|
-
tokenIn,
|
|
57
|
-
tokenOut,
|
|
58
|
-
false
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
case KYC_UNDERLYING_ON_DEMAND:
|
|
62
|
-
return {
|
|
63
|
-
zapper: void 0,
|
|
64
|
-
approveTarget: underlying.liquidityProvider,
|
|
65
|
-
permissible: false,
|
|
66
|
-
type: "kyc-on-demand"
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
25
|
return this.#depositMetadata("classic", pool, tokenIn, tokenOut, true);
|
|
71
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritdoc IPoolsService.addLiquidity
|
|
29
|
+
*/
|
|
72
30
|
addLiquidity(props) {
|
|
73
31
|
const { collateral, meta, permit, referralCode, pool, wallet } = props;
|
|
74
|
-
const underlying = this.#describeUnderlying(pool);
|
|
75
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
76
|
-
if (underlying.contractType === KYC_UNDERLYING_ON_DEMAND) {
|
|
77
|
-
return void 0;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
32
|
const { zapper } = meta;
|
|
81
33
|
if (zapper && hexEq(zapper.tokenIn.addr, NATIVE_ADDRESS)) {
|
|
82
34
|
return {
|
|
@@ -115,43 +67,23 @@ class PoolService extends SDKConstruct {
|
|
|
115
67
|
};
|
|
116
68
|
}
|
|
117
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @inheritdoc IPoolsService.getWithdrawalTokensIn
|
|
72
|
+
*/
|
|
118
73
|
getWithdrawalTokensIn(pool) {
|
|
119
|
-
const underlying = this.#describeUnderlying(pool);
|
|
120
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
121
|
-
switch (underlying.contractType) {
|
|
122
|
-
case KYC_UNDERLYING_DEFAULT:
|
|
123
|
-
return this.#withdrawalTokensIn(pool, false);
|
|
124
|
-
case KYC_UNDERLYING_ON_DEMAND:
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
74
|
return this.#withdrawalTokensIn(pool, true);
|
|
129
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @inheritdoc IPoolsService.getWithdrawalTokensOut
|
|
78
|
+
*/
|
|
130
79
|
getWithdrawalTokensOut(pool, tokenIn) {
|
|
131
|
-
const underlying = this.#describeUnderlying(pool);
|
|
132
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
133
|
-
switch (underlying.contractType) {
|
|
134
|
-
case KYC_UNDERLYING_DEFAULT:
|
|
135
|
-
return this.#withdrawalTokensOut(pool, tokenIn, false);
|
|
136
|
-
case KYC_UNDERLYING_ON_DEMAND:
|
|
137
|
-
return [underlying.asset];
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
80
|
return this.#withdrawalTokensOut(pool, tokenIn, true);
|
|
141
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* @inheritdoc IPoolsService.removeLiquidity
|
|
84
|
+
*/
|
|
142
85
|
removeLiquidity(props) {
|
|
143
86
|
const { pool, amount, meta, wallet, permit } = props;
|
|
144
|
-
const underlying = this.#describeUnderlying(pool);
|
|
145
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
146
|
-
if (underlying.contractType === KYC_UNDERLYING_ON_DEMAND) {
|
|
147
|
-
return {
|
|
148
|
-
abi: ierc20Abi,
|
|
149
|
-
functionName: "approve",
|
|
150
|
-
args: [underlying.liquidityProvider, 0n],
|
|
151
|
-
target: underlying.asset
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
87
|
if (meta.zapper) {
|
|
156
88
|
return permit ? {
|
|
157
89
|
target: meta.zapper.baseParams.addr,
|
|
@@ -179,40 +111,26 @@ class PoolService extends SDKConstruct {
|
|
|
179
111
|
args: [amount, wallet, wallet]
|
|
180
112
|
};
|
|
181
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* @inheritdoc IPoolsService.getWithdrawalMetadata
|
|
116
|
+
*/
|
|
182
117
|
getWithdrawalMetadata(pool, tokenIn, tokenOut) {
|
|
183
|
-
const underlying = this.#describeUnderlying(pool);
|
|
184
|
-
if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
|
|
185
|
-
switch (underlying.contractType) {
|
|
186
|
-
case KYC_UNDERLYING_DEFAULT: {
|
|
187
|
-
return this.#withdrawalMetadata(
|
|
188
|
-
"kyc-default",
|
|
189
|
-
pool,
|
|
190
|
-
tokenIn,
|
|
191
|
-
tokenOut,
|
|
192
|
-
false
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
case KYC_UNDERLYING_ON_DEMAND:
|
|
196
|
-
return {
|
|
197
|
-
zapper: void 0,
|
|
198
|
-
approveTarget: void 0,
|
|
199
|
-
permissible: false,
|
|
200
|
-
type: "kyc-on-demand"
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
118
|
return this.#withdrawalMetadata("classic", pool, tokenIn, tokenOut, true);
|
|
205
119
|
}
|
|
206
120
|
/**
|
|
207
|
-
*
|
|
208
|
-
* Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
|
|
121
|
+
* Returns non-migration zappers available for the pool.
|
|
209
122
|
*/
|
|
210
123
|
#getDepositZappers(poolAddr) {
|
|
211
124
|
const zappers = this.sdk.marketRegister.poolZappers(poolAddr);
|
|
212
|
-
return zappers.filter(
|
|
213
|
-
(z) => z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
|
|
214
|
-
);
|
|
125
|
+
return zappers.filter((z) => z.type !== "migration");
|
|
215
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns all supported deposit input tokens for a pool.
|
|
129
|
+
*
|
|
130
|
+
* Includes:
|
|
131
|
+
* - zapper `tokenIn` where zapper output is pool diesel token
|
|
132
|
+
* - pool underlying token when direct deposit is enabled
|
|
133
|
+
*/
|
|
216
134
|
#depositTokensIn(poolAddr, allowDirectDeposit) {
|
|
217
135
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
218
136
|
const result = new AddressSet();
|
|
@@ -232,6 +150,13 @@ class PoolService extends SDKConstruct {
|
|
|
232
150
|
}
|
|
233
151
|
return result.asArray();
|
|
234
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns all supported withdrawal input tokens for a pool.
|
|
155
|
+
*
|
|
156
|
+
* Includes:
|
|
157
|
+
* - pool diesel token when direct withdrawal is enabled
|
|
158
|
+
* - all zapper that can be redeemed from the pool
|
|
159
|
+
*/
|
|
235
160
|
#withdrawalTokensIn(poolAddr, allowDirectDeposit) {
|
|
236
161
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
237
162
|
const result = new AddressSet();
|
|
@@ -249,6 +174,13 @@ class PoolService extends SDKConstruct {
|
|
|
249
174
|
}
|
|
250
175
|
return result.asArray();
|
|
251
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns possible deposit outputs for a given input token.
|
|
179
|
+
*
|
|
180
|
+
* Includes:
|
|
181
|
+
* - zapper `tokenOut` for `z.tokenIn` matching `tokenIn`
|
|
182
|
+
* - pool diesel token for direct underlying deposit when enabled
|
|
183
|
+
*/
|
|
252
184
|
#depositTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
|
|
253
185
|
const result = new AddressSet();
|
|
254
186
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
@@ -271,6 +203,13 @@ class PoolService extends SDKConstruct {
|
|
|
271
203
|
const r = result.asArray();
|
|
272
204
|
return r;
|
|
273
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Returns possible withdrawal outputs for a given input token.
|
|
208
|
+
*
|
|
209
|
+
* Includes:
|
|
210
|
+
* - zapper `tokenIn` where zapper `z.tokenOut` matches requested `tokenIn`
|
|
211
|
+
* - pool underlying token for direct diesel-token redemption when enabled
|
|
212
|
+
*/
|
|
274
213
|
#withdrawalTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
|
|
275
214
|
const result = new AddressSet();
|
|
276
215
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
@@ -294,13 +233,12 @@ class PoolService extends SDKConstruct {
|
|
|
294
233
|
return r;
|
|
295
234
|
}
|
|
296
235
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
236
|
+
* Returns a single non-migration zapper route for the given token pair.
|
|
237
|
+
*
|
|
238
|
+
* Throws when multiple matching zappers exist to keep call construction deterministic.
|
|
299
239
|
*/
|
|
300
240
|
#getDepositZapper(poolAddr, tokenIn, tokenOut) {
|
|
301
|
-
const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter(
|
|
302
|
-
(z) => z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
|
|
303
|
-
);
|
|
241
|
+
const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter((z) => z.type !== "migration");
|
|
304
242
|
if (zappers && zappers.length > 1) {
|
|
305
243
|
throw new Error(
|
|
306
244
|
`Multiple zappers found for tokenIn ${this.labelAddress(
|
|
@@ -312,6 +250,11 @@ class PoolService extends SDKConstruct {
|
|
|
312
250
|
}
|
|
313
251
|
return zappers?.[0];
|
|
314
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Builds metadata required to execute a deposit operation.
|
|
255
|
+
*
|
|
256
|
+
* Includes selected zapper route (if any), approve target, and permit support flag.
|
|
257
|
+
*/
|
|
315
258
|
#depositMetadata(type, poolAddr, tokenIn, tokenOut, allowDirectDeposit) {
|
|
316
259
|
if (!tokenOut) {
|
|
317
260
|
throw new Error("tokenOut is required for classic pool deposit");
|
|
@@ -329,14 +272,19 @@ class PoolService extends SDKConstruct {
|
|
|
329
272
|
}
|
|
330
273
|
return {
|
|
331
274
|
zapper,
|
|
332
|
-
// zapper
|
|
275
|
+
// Approval target is zapper when routed, otherwise the pool contract.
|
|
333
276
|
approveTarget: zapper?.baseParams.addr ?? pool.pool.address,
|
|
334
|
-
// TODO: instead of permissible, return permitType
|
|
277
|
+
// TODO: instead of permissible, return permitType depending on tokenIn
|
|
335
278
|
// "none" | "eip2612" | "dai_like";
|
|
336
279
|
permissible: !!zapper && !hexEq(tokenIn, NATIVE_ADDRESS),
|
|
337
280
|
type
|
|
338
281
|
};
|
|
339
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Builds metadata required to execute a withdrawal operation.
|
|
285
|
+
*
|
|
286
|
+
* Includes selected zapper route (if any), approve target, and permit support flag.
|
|
287
|
+
*/
|
|
340
288
|
#withdrawalMetadata(type, poolAddr, tokenIn, tokenOut, allowDirectDeposit) {
|
|
341
289
|
if (!tokenOut) {
|
|
342
290
|
throw new Error("tokenOut is required for classic pool deposit");
|
|
@@ -353,9 +301,9 @@ class PoolService extends SDKConstruct {
|
|
|
353
301
|
}
|
|
354
302
|
return {
|
|
355
303
|
zapper,
|
|
356
|
-
//
|
|
304
|
+
// Approval target exists only for zapper-based withdrawals.
|
|
357
305
|
approveTarget: zapper?.baseParams.addr,
|
|
358
|
-
// TODO: instead of permissible, return permitType
|
|
306
|
+
// TODO: instead of permissible, return permitType depending on tokenIn
|
|
359
307
|
// "none" | "eip2612" | "dai_like";
|
|
360
308
|
permissible: !!zapper,
|
|
361
309
|
type
|
|
@@ -2,11 +2,11 @@ import type { Address } from "viem";
|
|
|
2
2
|
import type { CreditAccountData } from "../base/index.js";
|
|
3
3
|
import { SDKConstruct } from "../base/index.js";
|
|
4
4
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
5
|
-
import type { CreditSuite
|
|
5
|
+
import type { CreditSuite } from "../market/index.js";
|
|
6
6
|
import { type PriceUpdate, type UpdatePriceFeedsResult } from "../market/index.js";
|
|
7
7
|
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
8
|
-
import type {
|
|
9
|
-
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions,
|
|
8
|
+
import type { MultiCall, RawTx } from "../types/index.js";
|
|
9
|
+
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountOperationResult, CreditAccountTokensSlice, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Options for configuring the credit account service.
|
|
12
12
|
**/
|
|
@@ -33,42 +33,10 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
33
33
|
* {@inheritDoc ICreditAccountsService.getCreditAccountData}
|
|
34
34
|
**/
|
|
35
35
|
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns credit account data for a single account with the investor address resolved.
|
|
38
|
-
* Loads CA via getCreditAccountData; for KYC underlyings fetches the investor from the KYC factory's getInvestor(creditAccount), otherwise uses the account owner.
|
|
39
|
-
* @param account - Credit account address
|
|
40
|
-
* @param blockNumber - Optional block number for the read
|
|
41
|
-
* @returns CreditAccountDataWithInvestor (CA data + investor address), or undefined if the account is not found
|
|
42
|
-
*/
|
|
43
|
-
getCreditAccountDataWithInvestor(account: Address, blockNumber?: bigint): Promise<CreditAccountDataWithInvestor | undefined>;
|
|
44
36
|
/**
|
|
45
37
|
* {@inheritDoc ICreditAccountsService.getCreditAccounts}
|
|
46
38
|
**/
|
|
47
39
|
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
48
|
-
/**
|
|
49
|
-
* Returns all credit accounts matching the filter, with investor set on each item.
|
|
50
|
-
* Delegates to getCreditAccounts; when options.owner is set, also loads KYC credit accounts for that owner and merges them into the list. Result is sorted by health factor ascending.
|
|
51
|
-
* @param options - Filter options (owner, creditManager, health factor, etc.)
|
|
52
|
-
* @param blockNumber - Optional block number for the read
|
|
53
|
-
* @returns Array of credit accounts (with investor field), sorted by health factor ascending
|
|
54
|
-
*/
|
|
55
|
-
getCreditAccountsWithInvestor(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
|
|
56
|
-
protected getKYCCreditAccountsOfOwner(owner: Address, priceUpdateTxs: IPriceUpdateTx<{
|
|
57
|
-
priceFeed: `0x${string}`;
|
|
58
|
-
timestamp: number;
|
|
59
|
-
}>[], blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
|
|
60
|
-
/**
|
|
61
|
-
* Loads credit account data for the given addresses using simulateWithPriceUpdates.
|
|
62
|
-
* Applies the provided price update txs before reading, so returned data is consistent with up-to-date prices.
|
|
63
|
-
* @param accounts - Credit account addresses to load
|
|
64
|
-
* @param priceUpdateTxs - Price feed update txs to simulate before the read (e.g. from generatePriceFeedsUpdateTxs)
|
|
65
|
-
* @param blockNumber - Optional block number for the read
|
|
66
|
-
* @returns Array of CreditAccountData in the same order as accounts (throws if any getCreditAccountData call reverts)
|
|
67
|
-
*/
|
|
68
|
-
loadSpecifiedAccounts(accounts: Address[], priceUpdateTxs: IPriceUpdateTx<{
|
|
69
|
-
priceFeed: `0x${string}`;
|
|
70
|
-
timestamp: number;
|
|
71
|
-
}>[], blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
72
40
|
/**
|
|
73
41
|
* {@inheritDoc ICreditAccountsService.getRewards}
|
|
74
42
|
**/
|
|
@@ -81,8 +49,6 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
81
49
|
legacyMigration: GetConnectedMigrationBotsResult;
|
|
82
50
|
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
83
51
|
}>;
|
|
84
|
-
private getActiveBots;
|
|
85
|
-
private getActiveMigrationBots;
|
|
86
52
|
/**
|
|
87
53
|
* {@inheritDoc ICreditAccountsService.fullyLiquidate}
|
|
88
54
|
**/
|
|
@@ -123,13 +89,6 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
123
89
|
* {@inheritDoc ICreditAccountsService.claimDelayed}
|
|
124
90
|
**/
|
|
125
91
|
claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
126
|
-
/**
|
|
127
|
-
* Returns address to which approval should be given on collateral token
|
|
128
|
-
* It's credit manager for classical markets and special wallet for KYC markets
|
|
129
|
-
* @param options - {@link GetApprovalAddressProps}
|
|
130
|
-
* @returns
|
|
131
|
-
**/
|
|
132
|
-
getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
|
|
133
92
|
/**
|
|
134
93
|
* {@inheritDoc ICreditAccountsService.openCA}
|
|
135
94
|
**/
|
|
@@ -143,43 +102,6 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
143
102
|
**/
|
|
144
103
|
getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
|
|
145
104
|
/**
|
|
146
|
-
* Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
|
|
147
|
-
* Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
|
|
148
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
149
|
-
* @param amount - Number of vault shares (adapter tokens) to redeem
|
|
150
|
-
* @param creditManager - Credit manager address
|
|
151
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
152
|
-
*/
|
|
153
|
-
getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
154
|
-
/**
|
|
155
|
-
* Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
|
|
156
|
-
* Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
|
|
157
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
158
|
-
* @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
|
|
159
|
-
* @param creditManager - Credit manager address
|
|
160
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
161
|
-
*/
|
|
162
|
-
getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
163
|
-
/**
|
|
164
|
-
* Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
165
|
-
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
|
|
166
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
167
|
-
* @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
|
|
168
|
-
* @param creditManager - Credit manager address
|
|
169
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
170
|
-
*/
|
|
171
|
-
getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
172
|
-
/**
|
|
173
|
-
* Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
174
|
-
* Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
|
|
175
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
176
|
-
* @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
|
|
177
|
-
* @param creditManager - Credit manager address
|
|
178
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
179
|
-
*/
|
|
180
|
-
getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
181
|
-
/**
|
|
182
|
-
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
183
105
|
* {@inheritDoc ICreditAccountsService.getOnDemandPriceUpdates}
|
|
184
106
|
**/
|
|
185
107
|
getOnDemandPriceUpdates(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<PriceUpdate[]>;
|
|
@@ -200,25 +122,13 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
200
122
|
}): Promise<MultiCall[]>;
|
|
201
123
|
protected getUpdateForAccount(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<UpdatePriceFeedsResult>;
|
|
202
124
|
/**
|
|
203
|
-
*
|
|
204
|
-
* necessary on-demand price feed updates.
|
|
205
|
-
*
|
|
206
|
-
* @param creditAccount - Credit account to execute multicall on
|
|
207
|
-
* @param calls - Array of multicall operations (price updates will be inferred)
|
|
208
|
-
* @param options - Optional settings for price update generation
|
|
209
|
-
* @returns Raw transaction ready to be signed and sent
|
|
125
|
+
* {@inheritDoc ICreditAccountsService.multicall}
|
|
210
126
|
*/
|
|
211
127
|
multicall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
212
128
|
ignoreReservePrices?: boolean;
|
|
213
129
|
}): Promise<RawTx>;
|
|
214
130
|
/**
|
|
215
|
-
*
|
|
216
|
-
* necessary on-demand price feed updates.
|
|
217
|
-
*
|
|
218
|
-
* @param creditAccount - Credit account to execute bot multicall on
|
|
219
|
-
* @param calls - Array of multicall operations (price updates will be inferred)
|
|
220
|
-
* @param options - Optional settings for price update generation
|
|
221
|
-
* @returns Raw transaction ready to be signed and sent
|
|
131
|
+
* {@inheritDoc ICreditAccountsService.botMulticall}
|
|
222
132
|
*/
|
|
223
133
|
botMulticall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
224
134
|
ignoreReservePrices?: boolean;
|
|
@@ -260,12 +170,4 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
260
170
|
* @returns
|
|
261
171
|
*/
|
|
262
172
|
protected closeCreditAccountTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[], operation: CloseOptions): Promise<RawTx>;
|
|
263
|
-
/**
|
|
264
|
-
* Returns all KYC credit account addresses for an investor across the given market suites.
|
|
265
|
-
* Resolves KYC factory per suite, then multicalls each factory's getCreditAccounts(investor).
|
|
266
|
-
* @param investor - Owner address to query
|
|
267
|
-
* @param suites - Market suites (KYC factories are resolved for each; undefined entries are skipped)
|
|
268
|
-
* @returns Flat array of credit account addresses from all KYC markets
|
|
269
|
-
*/
|
|
270
|
-
protected getKYCCaOfInvestor(investor: Address, suites: Array<MarketSuite | undefined>): Promise<`0x${string}`[]>;
|
|
271
173
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
|
|
2
|
-
import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManagerOperationResult, ICreditAccountsService,
|
|
2
|
+
import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManagerOperationResult, ICreditAccountsService, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, SetBotProps, WithdrawCollateralProps } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Service for querying and operating on Gearbox credit accounts.
|
|
5
5
|
*
|
|
@@ -21,7 +21,7 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
21
21
|
/**
|
|
22
22
|
* {@inheritDoc ICreditAccountsService.repayCreditAccount}
|
|
23
23
|
*/
|
|
24
|
-
repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim,
|
|
24
|
+
repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, }: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
|
|
25
25
|
/**
|
|
26
26
|
* {@inheritDoc ICreditAccountsService.repayAndLiquidateCreditAccount}
|
|
27
27
|
*/
|
|
@@ -30,6 +30,4 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
30
30
|
* {@inheritDoc ICreditAccountsService.claimFarmRewards}
|
|
31
31
|
*/
|
|
32
32
|
claimFarmRewards({ calls: externalCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
|
|
33
|
-
previewWithdrawLlamathenaProportionally(_: PreviewWithdrawLlamathenaProportionallyProps): Promise<PreviewWithdrawLlamathenaProportionallyResult>;
|
|
34
|
-
withdrawLlamathenaProportionally(_: LlamathenaProportionalWithdrawProps): Promise<CreditAccountOperationResult>;
|
|
35
33
|
}
|