@gearbox-protocol/sdk 14.12.0-next.48 → 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.
@@ -35,6 +35,12 @@ class MultichainLiquidationsService {
35
35
  async getLiquidationDetails(props) {
36
36
  return this.#sdk.chain(props.network).liquidations.getLiquidationDetails(props);
37
37
  }
38
+ /**
39
+ * {@inheritDoc ILiquidationsService.buildLiquidationTx}
40
+ **/
41
+ async buildLiquidationTx(props) {
42
+ return this.#sdk.chain(props.network).liquidations.buildLiquidationTx(props);
43
+ }
38
44
  /**
39
45
  * {@inheritDoc ILiquidationsService.getLiquidatorWithdrawals}
40
46
  **/
@@ -0,0 +1,5 @@
1
+ import { ADDRESS_0X0 } from "../../constants/index.js";
2
+ const LIQUIDATION_COMPRESSOR_V313_ADDRESS = ADDRESS_0X0;
3
+ export {
4
+ LIQUIDATION_COMPRESSOR_V313_ADDRESS
5
+ };
@@ -1,4 +1,5 @@
1
- import { PERCENTAGE_FACTOR } from "../../constants/index.js";
1
+ import { slice } from "viem";
2
+ import { ADDRESS_0X0, PERCENTAGE_FACTOR } from "../../constants/index.js";
2
3
  import { hexEq } from "../../utils/index.js";
3
4
  const DUST_THRESHOLD = 10n;
4
5
  function calcRepaymentAmount(totalValue, liquidationDiscount) {
@@ -53,10 +54,53 @@ function toLiquidatorWithdrawals(current, network) {
53
54
  }
54
55
  return rows;
55
56
  }
57
+ function toReceivedAssets(outputs) {
58
+ return outputs.map((o) => {
59
+ if (!o.delayed) {
60
+ return { isDelayed: false, token: o.token, amount: o.amount };
61
+ }
62
+ return {
63
+ isDelayed: true,
64
+ token: o.token,
65
+ amount: o.amount,
66
+ redeemerAddress: hexEq(o.redeemerAddress, ADDRESS_0X0) ? void 0 : o.redeemerAddress,
67
+ claimableAt: o.claimableAt === 0n ? void 0 : o.claimableAt
68
+ };
69
+ });
70
+ }
71
+ function toLiquidationApproval(props) {
72
+ const { target, creditFacade, creditManager, token, amount } = props;
73
+ if (amount === 0n) {
74
+ return void 0;
75
+ }
76
+ return {
77
+ spender: hexEq(target, creditFacade) ? creditManager : target,
78
+ token,
79
+ amount
80
+ };
81
+ }
82
+ function liquidationCallToRawTx(call, description) {
83
+ return {
84
+ to: call.target,
85
+ value: "0",
86
+ signature: "",
87
+ callData: call.callData,
88
+ contractMethod: {
89
+ name: slice(call.callData, 0, 4),
90
+ inputs: [],
91
+ payable: false
92
+ },
93
+ contractInputsValues: {},
94
+ description
95
+ };
96
+ }
56
97
  export {
57
98
  DUST_THRESHOLD,
58
99
  calcEstimatedProfit,
59
100
  calcRepaymentAmount,
101
+ liquidationCallToRawTx,
60
102
  pickMainAsset,
61
- toLiquidatorWithdrawals
103
+ toLiquidationApproval,
104
+ toLiquidatorWithdrawals,
105
+ toReceivedAssets
62
106
  };
@@ -1,4 +1,4 @@
1
- export * from "./helpers.js";
1
+ export * from "./constants.js";
2
2
  export * from "./LiquidationsService.js";
3
3
  export * from "./MultichainLiquidationsService.js";
4
4
  export * from "./types.js";
@@ -0,0 +1,107 @@
1
+ export declare const iLiquidationCompressorV313Abi: readonly [{
2
+ readonly type: "function";
3
+ readonly name: "contractType";
4
+ readonly inputs: readonly [];
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly type: "bytes32";
8
+ readonly internalType: "bytes32";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }, {
12
+ readonly type: "function";
13
+ readonly name: "getLiquidationData";
14
+ readonly inputs: readonly [{
15
+ readonly name: "liquidator";
16
+ readonly type: "address";
17
+ readonly internalType: "address";
18
+ }, {
19
+ readonly name: "creditAccount";
20
+ readonly type: "address";
21
+ readonly internalType: "address";
22
+ }, {
23
+ readonly name: "priceUpdates";
24
+ readonly type: "tuple[]";
25
+ readonly internalType: "struct PriceUpdate[]";
26
+ readonly components: readonly [{
27
+ readonly name: "priceFeed";
28
+ readonly type: "address";
29
+ readonly internalType: "address";
30
+ }, {
31
+ readonly name: "data";
32
+ readonly type: "bytes";
33
+ readonly internalType: "bytes";
34
+ }];
35
+ }];
36
+ readonly outputs: readonly [{
37
+ readonly name: "";
38
+ readonly type: "tuple";
39
+ readonly internalType: "struct LiquidationData";
40
+ readonly components: readonly [{
41
+ readonly name: "requiredUnderlyingAmount";
42
+ readonly type: "uint256";
43
+ readonly internalType: "uint256";
44
+ }, {
45
+ readonly name: "expectedOutputs";
46
+ readonly type: "tuple[]";
47
+ readonly internalType: "struct LiquidationOutput[]";
48
+ readonly components: readonly [{
49
+ readonly name: "token";
50
+ readonly type: "address";
51
+ readonly internalType: "address";
52
+ }, {
53
+ readonly name: "amount";
54
+ readonly type: "uint256";
55
+ readonly internalType: "uint256";
56
+ }, {
57
+ readonly name: "delayed";
58
+ readonly type: "bool";
59
+ readonly internalType: "bool";
60
+ }, {
61
+ readonly name: "redeemerAddress";
62
+ readonly type: "address";
63
+ readonly internalType: "address";
64
+ }, {
65
+ readonly name: "claimableAt";
66
+ readonly type: "uint256";
67
+ readonly internalType: "uint256";
68
+ }];
69
+ }, {
70
+ readonly name: "liquidationCall";
71
+ readonly type: "tuple";
72
+ readonly internalType: "struct MultiCall";
73
+ readonly components: readonly [{
74
+ readonly name: "target";
75
+ readonly type: "address";
76
+ readonly internalType: "address";
77
+ }, {
78
+ readonly name: "callData";
79
+ readonly type: "bytes";
80
+ readonly internalType: "bytes";
81
+ }];
82
+ }, {
83
+ readonly name: "isLiquidatorEligible";
84
+ readonly type: "bool";
85
+ readonly internalType: "bool";
86
+ }, {
87
+ readonly name: "kycProtocol";
88
+ readonly type: "string";
89
+ readonly internalType: "string";
90
+ }, {
91
+ readonly name: "kycToken";
92
+ readonly type: "address";
93
+ readonly internalType: "address";
94
+ }];
95
+ }];
96
+ readonly stateMutability: "nonpayable";
97
+ }, {
98
+ readonly type: "function";
99
+ readonly name: "version";
100
+ readonly inputs: readonly [];
101
+ readonly outputs: readonly [{
102
+ readonly name: "";
103
+ readonly type: "uint256";
104
+ readonly internalType: "uint256";
105
+ }];
106
+ readonly stateMutability: "view";
107
+ }];
@@ -40,7 +40,7 @@ export declare class MerkleXYZApi {
40
40
  static defaultDomain: string;
41
41
  static angleDomain: string;
42
42
  static apiKeyHeader: string;
43
- static fetchWithFallback: <T>(getUrl: (domain: string) => string, apiKey?: string) => Promise<import("axios").AxiosResponse<T, any, {}>>;
43
+ static fetchWithFallback: <T>(getUrl: (domain: string) => string, apiKey?: string) => Promise<import("axios").AxiosResponse<T, any, {}, any>>;
44
44
  static getUserRewardsUrl: (options: UserOptions) => (domain: string) => string;
45
45
  }
46
46
  export {};
@@ -107,7 +107,7 @@ export declare class MultichainSDK<const Plugins extends PluginsMap = {}> {
107
107
  * Namespace for liquidatable credit accounts discovery across all
108
108
  * configured chains.
109
109
  */
110
- readonly liquidations: ILiquidationsService;
110
+ readonly liquidations: ILiquidationsService<true>;
111
111
  constructor(options: MultichainSDKOptions<Plugins>);
112
112
  /**
113
113
  * Attach all configured chains in parallel.
@@ -1,5 +1,6 @@
1
1
  import { SDKConstruct } from "../../base/index.js";
2
- import type { GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidatorWithdrawalsProps, ILiquidationsService, LiquidatableAccount, LiquidationDetails, LiquidatorWithdrawal } from "./types.js";
2
+ import type { RawTx } from "../../types/index.js";
3
+ import type { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidatorWithdrawalsProps, ILiquidationsService, LiquidatableAccount, LiquidationDetails, LiquidatorWithdrawal } from "./types.js";
3
4
  /**
4
5
  * Per-chain implementation of {@link ILiquidationsService}.
5
6
  *
@@ -17,6 +18,10 @@ export declare class LiquidationsService extends SDKConstruct implements ILiquid
17
18
  * {@inheritDoc ILiquidationsService.getLiquidationDetails}
18
19
  **/
19
20
  getLiquidationDetails(props: GetLiquidationDetailsProps): Promise<LiquidationDetails>;
21
+ /**
22
+ * {@inheritDoc ILiquidationsService.buildLiquidationTx}
23
+ **/
24
+ buildLiquidationTx(props: BuildLiquidationTxProps): Promise<RawTx>;
20
25
  /**
21
26
  * {@inheritDoc ILiquidationsService.getLiquidatorWithdrawals}
22
27
  **/
@@ -1,27 +1,32 @@
1
1
  import type { MultichainSDK } from "../../MultichainSDK.js";
2
2
  import type { PluginsMap } from "../../plugins/index.js";
3
- import type { GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidatorWithdrawalsProps, ILiquidationsService, LiquidatableAccount, LiquidationDetails, LiquidatorWithdrawal } from "./types.js";
3
+ import type { RawTx } from "../../types/index.js";
4
+ import type { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidatorWithdrawalsProps, ILiquidationsService, LiquidatableAccount, LiquidationDetails, LiquidatorWithdrawal } from "./types.js";
4
5
  /**
5
6
  * Cross-chain implementation of {@link ILiquidationsService}.
6
7
  *
7
8
  * Aggregates liquidatable accounts over all chains configured in
8
9
  * {@link MultichainSDK} (optionally restricted via
9
- * {@link GetLiquidatableAccountsProps.networks}). A failed chain is logged as
10
+ * {@link MultichainNetworksProps.networks}). A failed chain is logged as
10
11
  * a warning and skipped, so one dead RPC does not empty the whole list.
11
12
  **/
12
- export declare class MultichainLiquidationsService<const Plugins extends PluginsMap = {}> implements ILiquidationsService {
13
+ export declare class MultichainLiquidationsService<const Plugins extends PluginsMap = {}> implements ILiquidationsService<true> {
13
14
  #private;
14
15
  constructor(sdk: MultichainSDK<Plugins>);
15
16
  /**
16
17
  * {@inheritDoc ILiquidationsService.getLiquidatableAccounts}
17
18
  **/
18
- getLiquidatableAccounts(props?: GetLiquidatableAccountsProps): Promise<LiquidatableAccount[]>;
19
+ getLiquidatableAccounts(props?: GetLiquidatableAccountsProps<true>): Promise<LiquidatableAccount[]>;
19
20
  /**
20
21
  * {@inheritDoc ILiquidationsService.getLiquidationDetails}
21
22
  **/
22
- getLiquidationDetails(props: GetLiquidationDetailsProps): Promise<LiquidationDetails>;
23
+ getLiquidationDetails(props: GetLiquidationDetailsProps<true>): Promise<LiquidationDetails>;
24
+ /**
25
+ * {@inheritDoc ILiquidationsService.buildLiquidationTx}
26
+ **/
27
+ buildLiquidationTx(props: BuildLiquidationTxProps<true>): Promise<RawTx>;
23
28
  /**
24
29
  * {@inheritDoc ILiquidationsService.getLiquidatorWithdrawals}
25
30
  **/
26
- getLiquidatorWithdrawals(props: GetLiquidatorWithdrawalsProps): Promise<LiquidatorWithdrawal[]>;
31
+ getLiquidatorWithdrawals(props: GetLiquidatorWithdrawalsProps<true>): Promise<LiquidatorWithdrawal[]>;
27
32
  }
@@ -0,0 +1,6 @@
1
+ import type { Address } from "viem";
2
+ /**
3
+ * TODO: the contract is not deployed yet, replace with the real address
4
+ * (per-network lookup if it ends up being deployed on several chains).
5
+ **/
6
+ export declare const LIQUIDATION_COMPRESSOR_V313_ADDRESS: Address;
@@ -1,8 +1,22 @@
1
- import type { Address } from "viem";
1
+ import type { Address, ContractFunctionReturnType } from "viem";
2
+ import type { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
2
3
  import type { CreditAccountData } from "../../base/index.js";
3
4
  import type { NetworkType } from "../../chain/index.js";
5
+ import type { RawTx } from "../../types/index.js";
4
6
  import type { CurrentWithdrawals } from "../withdrawal-compressor/index.js";
5
- import type { LiquidatorWithdrawal } from "./types.js";
7
+ import type { LiquidationApproval, LiquidatorWithdrawal, ReceivedAsset } from "./types.js";
8
+ /**
9
+ * Raw `LiquidationData` returned by `LiquidationCompressor.getLiquidationData`.
10
+ **/
11
+ export type OnchainLiquidationData = ContractFunctionReturnType<typeof iLiquidationCompressorV313Abi, "nonpayable", "getLiquidationData">;
12
+ /**
13
+ * Single element of {@link OnchainLiquidationData.expectedOutputs}.
14
+ **/
15
+ export type OnchainLiquidationOutput = OnchainLiquidationData["expectedOutputs"][number];
16
+ /**
17
+ * Single call built by the liquidation compressor.
18
+ **/
19
+ export type OnchainLiquidationCall = OnchainLiquidationData["liquidationCall"];
6
20
  /**
7
21
  * Token balances at or below this threshold are treated as dust and ignored,
8
22
  * consistent with the rest of the SDK (see `filterDust`).
@@ -44,3 +58,60 @@ export declare function pickMainAsset(ca: CreditAccountData, convert: (token: Ad
44
58
  * @param network - Network the withdrawals live on
45
59
  **/
46
60
  export declare function toLiquidatorWithdrawals(current: CurrentWithdrawals, network: NetworkType): LiquidatorWithdrawal[];
61
+ /**
62
+ * Normalizes the liquidation compressor outputs into assets the liquidator
63
+ * receives. Zero `redeemerAddress` and `claimableAt` (used by the contracts
64
+ * for "not applicable") become `undefined`.
65
+ *
66
+ * @param outputs - `expectedOutputs` of the compressor's liquidation data
67
+ **/
68
+ export declare function toReceivedAssets(outputs: readonly OnchainLiquidationOutput[]): ReceivedAsset[];
69
+ /**
70
+ * Props for {@link toLiquidationApproval}.
71
+ **/
72
+ export interface ToLiquidationApprovalProps {
73
+ /**
74
+ * Target of the compressor's `liquidationCall`.
75
+ **/
76
+ target: Address;
77
+ /**
78
+ * Credit facade of the liquidated account's credit manager.
79
+ **/
80
+ creditFacade: Address;
81
+ /**
82
+ * Credit manager of the liquidated account.
83
+ **/
84
+ creditManager: Address;
85
+ /**
86
+ * Token the liquidation transaction pulls from the liquidator.
87
+ **/
88
+ token: Address;
89
+ /**
90
+ * Amount of `token` the liquidation transaction pulls.
91
+ **/
92
+ amount: bigint;
93
+ }
94
+ /**
95
+ * Resolves the approval the liquidator must grant for the liquidation call.
96
+ *
97
+ * A call targeting the credit facade is paid by `msg.sender` but transferred by
98
+ * the credit manager, so the latter is the spender. Any other target is a
99
+ * dedicated liquidator contract (Midas / Securitize) that pulls the token to
100
+ * itself and re-approves the credit manager, so it is the spender itself.
101
+ *
102
+ * @param props - See {@link ToLiquidationApprovalProps}
103
+ * @returns The approval, or `undefined` when the call pulls nothing
104
+ **/
105
+ export declare function toLiquidationApproval(props: ToLiquidationApprovalProps): LiquidationApproval | undefined;
106
+ /**
107
+ * Converts the compressor's liquidation call into a raw transaction.
108
+ *
109
+ * The calldata is passed through as-is: depending on the liquidated assets,
110
+ * the target is either the credit facade or a dedicated liquidator contract
111
+ * (with its own function signature), so it cannot be re-encoded from a single
112
+ * known ABI.
113
+ *
114
+ * @param call - `liquidationCall` of the compressor's liquidation data
115
+ * @param description - Optional human-readable description
116
+ **/
117
+ export declare function liquidationCallToRawTx(call: OnchainLiquidationCall, description?: string): RawTx;
@@ -1,4 +1,4 @@
1
- export * from "./helpers.js";
1
+ export * from "./constants.js";
2
2
  export * from "./LiquidationsService.js";
3
3
  export * from "./MultichainLiquidationsService.js";
4
4
  export * from "./types.js";
@@ -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
  }