@gearbox-protocol/sdk 14.12.0-next.47 → 14.12.0-next.49

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.
Files changed (53) hide show
  1. package/dist/cjs/abi/ILiquidationCompressorV313.js +103 -0
  2. package/dist/cjs/abi/compressors/liquidationCompressor.js +215 -0
  3. package/dist/cjs/abi/compressors/subcompressors/liquidation/midasLiquidationSubcompressor.js +104 -0
  4. package/dist/cjs/abi/compressors/subcompressors/liquidation/securitizeLiquidationSubcompressor.js +104 -0
  5. package/dist/cjs/dev/withdrawalAbi.js +104 -66
  6. package/dist/cjs/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +2 -306
  7. package/dist/cjs/plugins/adapters/abi/index.js +2 -0
  8. package/dist/cjs/plugins/adapters/abi/midas/iMidasGatewayV311.js +194 -0
  9. package/dist/cjs/plugins/adapters/abi/midas/index.js +22 -0
  10. package/dist/cjs/plugins/adapters/abi/securitize/iSecuritizeRedemptionGatewayV311.js +184 -24
  11. package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +2 -1
  12. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +81 -58
  13. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +6 -0
  14. package/dist/cjs/sdk/accounts/liquidations/constants.js +29 -0
  15. package/dist/cjs/sdk/accounts/liquidations/helpers.js +49 -2
  16. package/dist/cjs/sdk/accounts/liquidations/index.js +2 -2
  17. package/dist/esm/abi/ILiquidationCompressorV313.js +79 -0
  18. package/dist/esm/abi/compressors/liquidationCompressor.js +191 -0
  19. package/dist/esm/abi/compressors/subcompressors/liquidation/midasLiquidationSubcompressor.js +80 -0
  20. package/dist/esm/abi/compressors/subcompressors/liquidation/securitizeLiquidationSubcompressor.js +80 -0
  21. package/dist/esm/dev/withdrawalAbi.js +104 -66
  22. package/dist/esm/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +1 -304
  23. package/dist/esm/plugins/adapters/abi/index.js +1 -0
  24. package/dist/esm/plugins/adapters/abi/midas/iMidasGatewayV311.js +170 -0
  25. package/dist/esm/plugins/adapters/abi/midas/index.js +1 -0
  26. package/dist/esm/plugins/adapters/abi/securitize/iSecuritizeRedemptionGatewayV311.js +184 -24
  27. package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +2 -4
  28. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +87 -61
  29. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +6 -0
  30. package/dist/esm/sdk/accounts/liquidations/constants.js +5 -0
  31. package/dist/esm/sdk/accounts/liquidations/helpers.js +46 -2
  32. package/dist/esm/sdk/accounts/liquidations/index.js +1 -1
  33. package/dist/types/abi/ILiquidationCompressorV313.d.ts +107 -0
  34. package/dist/types/abi/compressors/liquidationCompressor.d.ts +262 -0
  35. package/dist/types/abi/compressors/subcompressors/liquidation/midasLiquidationSubcompressor.d.ts +111 -0
  36. package/dist/types/abi/compressors/subcompressors/liquidation/securitizeLiquidationSubcompressor.d.ts +111 -0
  37. package/dist/types/dev/withdrawalAbi.d.ts +81 -53
  38. package/dist/types/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.d.ts +0 -233
  39. package/dist/types/plugins/adapters/abi/index.d.ts +1 -0
  40. package/dist/types/plugins/adapters/abi/midas/iMidasGatewayV311.d.ts +261 -0
  41. package/dist/types/plugins/adapters/abi/midas/index.d.ts +1 -0
  42. package/dist/types/plugins/adapters/abi/securitize/iSecuritizeRedemptionGatewayV311.d.ts +24 -0
  43. package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +28 -0
  44. package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +24 -0
  45. package/dist/types/rewards/rewards/merkl-api.d.ts +1 -1
  46. package/dist/types/sdk/MultichainSDK.d.ts +1 -1
  47. package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +6 -1
  48. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +11 -6
  49. package/dist/types/sdk/accounts/liquidations/constants.d.ts +6 -0
  50. package/dist/types/sdk/accounts/liquidations/helpers.d.ts +73 -2
  51. package/dist/types/sdk/accounts/liquidations/index.d.ts +1 -1
  52. package/dist/types/sdk/accounts/liquidations/types.d.ts +142 -30
  53. package/package.json +9 -9
@@ -1,17 +1,35 @@
1
1
  import type { Address } from "viem";
2
2
  import type { Asset } from "../../base/index.js";
3
3
  import type { NetworkType } from "../../chain/index.js";
4
+ import type { RawTx } from "../../types/index.js";
4
5
  /**
5
- * Filters for {@link ILiquidationsService.getLiquidatableAccounts}.
6
- * All filters are optional and applied after liquidatable accounts are fetched.
6
+ * Selects the chain for single-account methods of a multichain service.
7
7
  **/
8
- export interface GetLiquidatableAccountsProps {
8
+ export interface MultichainNetworkProps {
9
9
  /**
10
- * Networks to query. On {@link MultichainLiquidationsService} selects which
11
- * chains to query; a single-chain service returns an empty list when its
12
- * own network is excluded.
10
+ * Network the credit account lives on.
11
+ **/
12
+ network: NetworkType;
13
+ }
14
+ /**
15
+ * Restricts which chains a multichain list method queries.
16
+ **/
17
+ export interface MultichainNetworksProps {
18
+ /**
19
+ * Networks to query. All chains configured in {@link MultichainSDK} when
20
+ * omitted.
13
21
  **/
14
22
  networks?: NetworkType[];
23
+ }
24
+ /**
25
+ * Adds chain-scoping props `T` only when the service spans multiple chains.
26
+ **/
27
+ export type WithMultichain<Multichain extends boolean, T extends object> = Multichain extends true ? T : {};
28
+ /**
29
+ * Chain-independent part of {@link GetLiquidatableAccountsProps}.
30
+ * All filters are optional and applied after liquidatable accounts are fetched.
31
+ **/
32
+ export interface GetLiquidatableAccountsPropsBase {
15
33
  /**
16
34
  * Only return accounts whose main liquidated {@link LiquidatableAccount.asset}
17
35
  * is one of these tokens.
@@ -23,6 +41,10 @@ export interface GetLiquidatableAccountsProps {
23
41
  **/
24
42
  delayed?: boolean;
25
43
  }
44
+ /**
45
+ * Props for {@link ILiquidationsService.getLiquidatableAccounts}.
46
+ **/
47
+ export type GetLiquidatableAccountsProps<Multichain extends boolean = false> = GetLiquidatableAccountsPropsBase & WithMultichain<Multichain, MultichainNetworksProps>;
26
48
  /**
27
49
  * A credit account that can be liquidated, with amounts precomputed for
28
50
  * manual liquidation via the frontend.
@@ -75,23 +97,54 @@ export interface LiquidatableAccount {
75
97
  isDelayed: boolean;
76
98
  }
77
99
  /**
78
- * Props for {@link ILiquidationsService.getLiquidationDetails}.
100
+ * Chain-independent part of {@link GetLiquidationDetailsProps}.
79
101
  **/
80
- export interface GetLiquidationDetailsProps {
81
- /**
82
- * Network the credit account lives on.
83
- **/
84
- network: NetworkType;
102
+ export interface GetLiquidationDetailsPropsBase {
85
103
  /**
86
104
  * Credit account to get liquidation details for.
87
105
  **/
88
106
  creditAccount: Address;
89
107
  /**
90
- * Liquidator wallet address. Reserved for future RWA KYC gating;
91
- * accepted but not checked yet.
108
+ * Liquidator wallet address, used by the liquidation compressor to check
109
+ * KYC eligibility. When omitted, the zero address is used: amounts and
110
+ * received assets are unaffected, but {@link LiquidationDetails.isLiquidatorEligible}
111
+ * then only tells whether the liquidation is KYC-gated at all
112
+ * (see {@link LiquidationDetails.kycProtocol}).
92
113
  **/
93
114
  liquidator?: Address;
115
+ /**
116
+ * If true, reserve price feed updates are excluded from the price updates
117
+ * applied by the compressor before computing amounts.
118
+ **/
119
+ ignoreReservePrices?: boolean;
120
+ }
121
+ /**
122
+ * Props for {@link ILiquidationsService.getLiquidationDetails}.
123
+ **/
124
+ export type GetLiquidationDetailsProps<Multichain extends boolean = false> = GetLiquidationDetailsPropsBase & WithMultichain<Multichain, MultichainNetworkProps>;
125
+ /**
126
+ * Chain-independent part of {@link BuildLiquidationTxProps}.
127
+ **/
128
+ export interface BuildLiquidationTxPropsBase {
129
+ /**
130
+ * Credit account to liquidate.
131
+ **/
132
+ creditAccount: Address;
133
+ /**
134
+ * Liquidator wallet address. Required: it is encoded into the transaction
135
+ * as the receiver of the liquidated collateral.
136
+ **/
137
+ liquidator: Address;
138
+ /**
139
+ * If true, reserve price feed updates are excluded from the price updates
140
+ * applied by the compressor before building the transaction.
141
+ **/
142
+ ignoreReservePrices?: boolean;
94
143
  }
144
+ /**
145
+ * Props for {@link ILiquidationsService.buildLiquidationTx}.
146
+ **/
147
+ export type BuildLiquidationTxProps<Multichain extends boolean = false> = BuildLiquidationTxPropsBase & WithMultichain<Multichain, MultichainNetworkProps>;
95
148
  /**
96
149
  * A token received directly from the credit account balance upon liquidation.
97
150
  **/
@@ -122,9 +175,10 @@ export interface DelayedReceivedAsset {
122
175
  **/
123
176
  amount: bigint;
124
177
  /**
125
- * Source asset spent by the delayed withdrawal (e.g. ACRED).
178
+ * Redeemer contract transferred to the liquidator, from which `token`
179
+ * becomes claimable. `undefined` when the compressor does not report one.
126
180
  **/
127
- sourceToken: Address;
181
+ redeemerAddress?: Address;
128
182
  /**
129
183
  * Estimated unix timestamp (in seconds) when a pending withdrawal becomes
130
184
  * claimable. `undefined` means the withdrawal is claimable now.
@@ -136,21 +190,19 @@ export interface DelayedReceivedAsset {
136
190
  **/
137
191
  export type ReceivedAsset = InstantReceivedAsset | DelayedReceivedAsset;
138
192
  /**
139
- * Props for {@link ILiquidationsService.getLiquidatorWithdrawals}.
193
+ * Chain-independent part of {@link GetLiquidatorWithdrawalsProps}.
140
194
  **/
141
- export interface GetLiquidatorWithdrawalsProps {
142
- /**
143
- * Networks to query. On {@link MultichainLiquidationsService} selects which
144
- * chains to query; a single-chain service returns an empty list when its
145
- * own network is excluded.
146
- **/
147
- networks?: NetworkType[];
195
+ export interface GetLiquidatorWithdrawalsPropsBase {
148
196
  /**
149
197
  * Liquidator wallet that owns the redemption receipts (redeemer contracts
150
198
  * received as a result of liquidations).
151
199
  **/
152
200
  liquidator: Address;
153
201
  }
202
+ /**
203
+ * Props for {@link ILiquidationsService.getLiquidatorWithdrawals}.
204
+ **/
205
+ export type GetLiquidatorWithdrawalsProps<Multichain extends boolean = false> = GetLiquidatorWithdrawalsPropsBase & WithMultichain<Multichain, MultichainNetworksProps>;
154
206
  /**
155
207
  * A single delayed-withdrawal position owned by the liquidator.
156
208
  *
@@ -183,8 +235,33 @@ export interface LiquidatorWithdrawal {
183
235
  claimableAt?: bigint;
184
236
  }
185
237
  /**
186
- * Detailed information about a liquidatable credit account, extending the
187
- * list row with the full breakdown of assets the liquidator receives.
238
+ * ERC-20 approval the liquidator must grant before sending the liquidation
239
+ * transaction.
240
+ **/
241
+ export interface LiquidationApproval {
242
+ /**
243
+ * Address to approve: the credit manager when the liquidation goes directly
244
+ * through the credit facade (the facade forwards `msg.sender` as the payer
245
+ * and the credit manager executes the transfer), or the dedicated liquidator
246
+ * contract (Midas / Securitize) when the liquidation goes through one, since
247
+ * such contracts pull the token to themselves first.
248
+ **/
249
+ spender: Address;
250
+ /**
251
+ * Token pulled from the liquidator: the credit manager underlying.
252
+ **/
253
+ token: Address;
254
+ /**
255
+ * Amount to approve, equal to the amount the liquidation transaction pulls.
256
+ * The Securitize liquidator recomputes it on-chain, so approving with some
257
+ * headroom is advisable in case prices move.
258
+ **/
259
+ amount: bigint;
260
+ }
261
+ /**
262
+ * Detailed information about a liquidatable credit account, including
263
+ * the full breakdown of assets the liquidator receives.
264
+ *
188
265
  **/
189
266
  export interface LiquidationDetails extends LiquidatableAccount {
190
267
  /**
@@ -193,13 +270,41 @@ export interface LiquidationDetails extends LiquidatableAccount {
193
270
  * pending).
194
271
  **/
195
272
  receivedAssets: ReceivedAsset[];
273
+ /**
274
+ * Whether the liquidator passes the KYC checks of the liquidated assets.
275
+ * When {@link GetLiquidationDetailsPropsBase.liquidator} was not provided,
276
+ * `false` only means that the liquidation is KYC-gated, not that a
277
+ * particular wallet was rejected.
278
+ **/
279
+ isLiquidatorEligible: boolean;
280
+ /**
281
+ * Name of the KYC protocol the liquidator must be whitelisted in
282
+ * (e.g. `"securitize"`). `undefined` when the liquidation is not KYC-gated.
283
+ **/
284
+ kycProtocol?: string;
285
+ /**
286
+ * Token the liquidator must be whitelisted for in {@link kycProtocol}.
287
+ * `undefined` when the liquidation is not KYC-gated.
288
+ **/
289
+ kycToken?: Address;
290
+ /**
291
+ * ERC-20 approval required before sending the liquidation transaction.
292
+ * `undefined` when the selected liquidation path needs no capital from the
293
+ * liquidator, i.e. {@link repaymentAmount} is zero.
294
+ **/
295
+ approve?: LiquidationApproval;
196
296
  }
197
297
  /**
198
298
  * Service for discovering liquidatable credit accounts and previewing manual
199
299
  * liquidations. Implemented per-chain by {@link LiquidationsService} and
200
300
  * across all configured chains by {@link MultichainLiquidationsService}.
301
+ *
302
+ * @typeParam Multichain - When `true`, props select the chain to operate on:
303
+ * {@link MultichainNetworkProps} for single-account methods and
304
+ * {@link MultichainNetworksProps} for list methods. A per-chain service
305
+ * operates on the network its SDK is attached to and takes no network props.
201
306
  **/
202
- export interface ILiquidationsService {
307
+ export interface ILiquidationsService<Multichain extends boolean = false> {
203
308
  /**
204
309
  * Returns all liquidatable credit accounts: accounts with health factor
205
310
  * below 1 plus accounts of expired credit managers with outstanding debt.
@@ -207,7 +312,7 @@ export interface ILiquidationsService {
207
312
  *
208
313
  * @param props - Optional filters, see {@link GetLiquidatableAccountsProps}
209
314
  **/
210
- getLiquidatableAccounts(props?: GetLiquidatableAccountsProps): Promise<LiquidatableAccount[]>;
315
+ getLiquidatableAccounts(props?: GetLiquidatableAccountsProps<Multichain>): Promise<LiquidatableAccount[]>;
211
316
  /**
212
317
  * Returns detailed information about a liquidatable credit account,
213
318
  * including the full list of assets the liquidator receives.
@@ -215,7 +320,14 @@ export interface ILiquidationsService {
215
320
  * @param props - See {@link GetLiquidationDetailsProps}
216
321
  * @throws When the account is not found or its collateral computation fails.
217
322
  **/
218
- getLiquidationDetails(props: GetLiquidationDetailsProps): Promise<LiquidationDetails>;
323
+ getLiquidationDetails(props: GetLiquidationDetailsProps<Multichain>): Promise<LiquidationDetails>;
324
+ /**
325
+ * Builds the transaction that fully liquidates a credit account, repaying
326
+ * the debt from own funds and receiving the collateral from the credit account.
327
+ *
328
+ * @param props - See {@link BuildLiquidationTxProps}
329
+ **/
330
+ buildLiquidationTx(props: BuildLiquidationTxProps<Multichain>): Promise<RawTx>;
219
331
  /**
220
332
  * Returns the status of delayed-withdrawal positions (redemption receipts)
221
333
  * owned by a liquidator wallet: what is receivable, how much, and when it
@@ -223,5 +335,5 @@ export interface ILiquidationsService {
223
335
  *
224
336
  * @param props - See {@link GetLiquidatorWithdrawalsProps}
225
337
  **/
226
- getLiquidatorWithdrawals(props: GetLiquidatorWithdrawalsProps): Promise<LiquidatorWithdrawal[]>;
338
+ getLiquidatorWithdrawals(props: GetLiquidatorWithdrawalsProps<Multichain>): Promise<LiquidatorWithdrawal[]>;
227
339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.47",
3
+ "version": "14.12.0-next.49",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -89,29 +89,29 @@
89
89
  "@redstone-finance/protocol": "^0.9.0",
90
90
  "@redstone-finance/sdk": "^0.9.0",
91
91
  "@redstone-finance/utils": "^0.9.0",
92
- "abitype": "^1.2.4",
92
+ "abitype": "^1.3.0",
93
93
  "buffer": "^6.0.3",
94
94
  "date-fns": "^4.4.0",
95
- "viem": ">=2.23.15 <3.0.0",
95
+ "viem": "^2.55.10",
96
96
  "zod": "^4.4.3"
97
97
  },
98
98
  "devDependencies": {
99
- "@biomejs/biome": "^2.5.3",
99
+ "@biomejs/biome": "^2.5.6",
100
100
  "@commitlint/cli": "^21.2.1",
101
101
  "@commitlint/config-conventional": "^21.2.0",
102
- "@gearbox-protocol/biome-config": "^1.1.2",
102
+ "@gearbox-protocol/biome-config": "^1.1.5",
103
103
  "@types/cross-spawn": "^6.0.6",
104
- "axios": "^1.18.1",
104
+ "axios": "^1.19.0",
105
105
  "cross-spawn": "^7.0.6",
106
106
  "husky": "^9.1.7",
107
- "lint-staged": "^17.0.8",
107
+ "lint-staged": "^17.2.0",
108
108
  "pino": "^10.3.1",
109
109
  "pino-pretty": "^13.1.3",
110
110
  "tsup": "^8.5.1",
111
- "tsx": "^4.23.0",
111
+ "tsx": "^4.23.1",
112
112
  "typescript": "^7.0.2",
113
113
  "viem-deal": "^2.0.4",
114
- "vite": "^8.1.3",
114
+ "vite": "^8.1.5",
115
115
  "vitest": "^4.1.10",
116
116
  "yaml": "^2.9.0"
117
117
  },