@gearbox-protocol/sdk 14.12.0-next.56 → 14.12.0-next.58

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 +43 -1
  2. package/dist/cjs/abi/IWithdrawalCompressorV313.js +71 -41
  3. package/dist/cjs/abi/compressors/liquidationCompressor.js +43 -1
  4. package/dist/cjs/abi/compressors/rwaCompressor.js +4 -4
  5. package/dist/cjs/abi/compressors/subcompressors/liquidation/midasLiquidationSubcompressor.js +43 -1
  6. package/dist/cjs/abi/compressors/subcompressors/liquidation/securitizeLiquidationSubcompressor.js +43 -1
  7. package/dist/cjs/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +20 -0
  8. package/dist/cjs/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +20 -0
  9. package/dist/cjs/abi/compressors/withdrawalCompressor.js +30 -0
  10. package/dist/cjs/plugins/adapters/abi/actionAbi.js +8 -2
  11. package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +8 -2
  12. package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +67 -36
  13. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +27 -43
  14. package/dist/cjs/sdk/accounts/liquidations/constants.js +1 -1
  15. package/dist/cjs/sdk/accounts/liquidations/helpers.js +4 -2
  16. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +12 -0
  17. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +10 -0
  18. package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +1 -1
  19. package/dist/esm/abi/ILiquidationCompressorV313.js +43 -1
  20. package/dist/esm/abi/IWithdrawalCompressorV313.js +71 -41
  21. package/dist/esm/abi/compressors/liquidationCompressor.js +43 -1
  22. package/dist/esm/abi/compressors/rwaCompressor.js +4 -4
  23. package/dist/esm/abi/compressors/subcompressors/liquidation/midasLiquidationSubcompressor.js +43 -1
  24. package/dist/esm/abi/compressors/subcompressors/liquidation/securitizeLiquidationSubcompressor.js +43 -1
  25. package/dist/esm/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +20 -0
  26. package/dist/esm/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +20 -0
  27. package/dist/esm/abi/compressors/withdrawalCompressor.js +30 -0
  28. package/dist/esm/plugins/adapters/abi/actionAbi.js +8 -2
  29. package/dist/esm/plugins/adapters/abi/conctructorAbi.js +8 -2
  30. package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +67 -36
  31. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +29 -45
  32. package/dist/esm/sdk/accounts/liquidations/constants.js +1 -1
  33. package/dist/esm/sdk/accounts/liquidations/helpers.js +4 -2
  34. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +12 -0
  35. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +10 -0
  36. package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +1 -1
  37. package/dist/types/abi/ILiquidationCompressorV313.d.ts +36 -1
  38. package/dist/types/abi/IWithdrawalCompressorV313.d.ts +62 -38
  39. package/dist/types/abi/compressors/liquidationCompressor.d.ts +36 -1
  40. package/dist/types/abi/compressors/rwaCompressor.d.ts +4 -4
  41. package/dist/types/abi/compressors/subcompressors/liquidation/midasLiquidationSubcompressor.d.ts +36 -1
  42. package/dist/types/abi/compressors/subcompressors/liquidation/securitizeLiquidationSubcompressor.d.ts +36 -1
  43. package/dist/types/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.d.ts +16 -0
  44. package/dist/types/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.d.ts +16 -0
  45. package/dist/types/abi/compressors/withdrawalCompressor.d.ts +24 -0
  46. package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +24 -0
  47. package/dist/types/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.d.ts +8 -5
  48. package/dist/types/sdk/accounts/liquidations/helpers.d.ts +8 -1
  49. package/dist/types/sdk/accounts/liquidations/types.d.ts +27 -5
  50. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +3 -3
  51. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +62 -38
  52. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +10 -0
  53. package/package.json +1 -1
@@ -259,18 +259,18 @@ const rwaCompressorAbi = [
259
259
  },
260
260
  {
261
261
  type: "error",
262
- name: "InvalidRWAFactoryException",
262
+ name: "InvalidMarketConfiguratorException",
263
263
  inputs: [{
264
- name: "factory",
264
+ name: "marketConfigurator",
265
265
  type: "address",
266
266
  internalType: "address"
267
267
  }]
268
268
  },
269
269
  {
270
270
  type: "error",
271
- name: "InvalidMarketConfiguratorException",
271
+ name: "InvalidRWAFactoryException",
272
272
  inputs: [{
273
- name: "marketConfigurator",
273
+ name: "factory",
274
274
  type: "address",
275
275
  internalType: "address"
276
276
  }]
@@ -51,7 +51,12 @@ const midasLiquidationSubcompressorAbi = [
51
51
  internalType: "struct LiquidationData",
52
52
  components: [
53
53
  {
54
- name: "requiredUnderlyingAmount",
54
+ name: "requiredToken",
55
+ type: "address",
56
+ internalType: "address"
57
+ },
58
+ {
59
+ name: "requiredAmount",
55
60
  type: "uint256",
56
61
  internalType: "uint256"
57
62
  },
@@ -106,6 +111,11 @@ const midasLiquidationSubcompressorAbi = [
106
111
  type: "bool",
107
112
  internalType: "bool"
108
113
  },
114
+ {
115
+ name: "isCreditAccountFrozen",
116
+ type: "bool",
117
+ internalType: "bool"
118
+ },
109
119
  {
110
120
  name: "kycProtocol",
111
121
  type: "string",
@@ -120,6 +130,38 @@ const midasLiquidationSubcompressorAbi = [
120
130
  }],
121
131
  stateMutability: "nonpayable"
122
132
  },
133
+ {
134
+ type: "function",
135
+ name: "getRWALiquidatorInfo",
136
+ inputs: [{
137
+ name: "token",
138
+ type: "address",
139
+ internalType: "address"
140
+ }],
141
+ outputs: [{
142
+ name: "info",
143
+ type: "tuple",
144
+ internalType: "struct RWALiquidatorInfo",
145
+ components: [
146
+ {
147
+ name: "gateway",
148
+ type: "address",
149
+ internalType: "address"
150
+ },
151
+ {
152
+ name: "liquidatorAddress",
153
+ type: "address",
154
+ internalType: "address"
155
+ },
156
+ {
157
+ name: "contractType",
158
+ type: "bytes32",
159
+ internalType: "bytes32"
160
+ }
161
+ ]
162
+ }],
163
+ stateMutability: "view"
164
+ },
123
165
  {
124
166
  type: "function",
125
167
  name: "version",
@@ -51,7 +51,12 @@ const securitizeLiquidationSubcompressorAbi = [
51
51
  internalType: "struct LiquidationData",
52
52
  components: [
53
53
  {
54
- name: "requiredUnderlyingAmount",
54
+ name: "requiredToken",
55
+ type: "address",
56
+ internalType: "address"
57
+ },
58
+ {
59
+ name: "requiredAmount",
55
60
  type: "uint256",
56
61
  internalType: "uint256"
57
62
  },
@@ -106,6 +111,11 @@ const securitizeLiquidationSubcompressorAbi = [
106
111
  type: "bool",
107
112
  internalType: "bool"
108
113
  },
114
+ {
115
+ name: "isCreditAccountFrozen",
116
+ type: "bool",
117
+ internalType: "bool"
118
+ },
109
119
  {
110
120
  name: "kycProtocol",
111
121
  type: "string",
@@ -120,6 +130,38 @@ const securitizeLiquidationSubcompressorAbi = [
120
130
  }],
121
131
  stateMutability: "nonpayable"
122
132
  },
133
+ {
134
+ type: "function",
135
+ name: "getRWALiquidatorInfo",
136
+ inputs: [{
137
+ name: "token",
138
+ type: "address",
139
+ internalType: "address"
140
+ }],
141
+ outputs: [{
142
+ name: "info",
143
+ type: "tuple",
144
+ internalType: "struct RWALiquidatorInfo",
145
+ components: [
146
+ {
147
+ name: "gateway",
148
+ type: "address",
149
+ internalType: "address"
150
+ },
151
+ {
152
+ name: "liquidatorAddress",
153
+ type: "address",
154
+ internalType: "address"
155
+ },
156
+ {
157
+ name: "contractType",
158
+ type: "bytes32",
159
+ internalType: "bytes32"
160
+ }
161
+ ]
162
+ }],
163
+ stateMutability: "view"
164
+ },
123
165
  {
124
166
  type: "function",
125
167
  name: "version",
@@ -79,6 +79,11 @@ const midasWithdrawalSubcompressorAbi = [
79
79
  internalType: "bytes"
80
80
  }]
81
81
  },
82
+ {
83
+ name: "redeemer",
84
+ type: "address",
85
+ internalType: "address"
86
+ },
82
87
  {
83
88
  name: "extraData",
84
89
  type: "bytes",
@@ -127,6 +132,11 @@ const midasWithdrawalSubcompressorAbi = [
127
132
  type: "uint256",
128
133
  internalType: "uint256"
129
134
  },
135
+ {
136
+ name: "redeemer",
137
+ type: "address",
138
+ internalType: "address"
139
+ },
130
140
  {
131
141
  name: "extraData",
132
142
  type: "bytes",
@@ -204,6 +214,11 @@ const midasWithdrawalSubcompressorAbi = [
204
214
  internalType: "bytes"
205
215
  }]
206
216
  },
217
+ {
218
+ name: "redeemer",
219
+ type: "address",
220
+ internalType: "address"
221
+ },
207
222
  {
208
223
  name: "extraData",
209
224
  type: "bytes",
@@ -252,6 +267,11 @@ const midasWithdrawalSubcompressorAbi = [
252
267
  type: "uint256",
253
268
  internalType: "uint256"
254
269
  },
270
+ {
271
+ name: "redeemer",
272
+ type: "address",
273
+ internalType: "address"
274
+ },
255
275
  {
256
276
  name: "extraData",
257
277
  type: "bytes",
@@ -79,6 +79,11 @@ const securitizeRedemptionSubcompressorAbi = [
79
79
  internalType: "bytes"
80
80
  }]
81
81
  },
82
+ {
83
+ name: "redeemer",
84
+ type: "address",
85
+ internalType: "address"
86
+ },
82
87
  {
83
88
  name: "extraData",
84
89
  type: "bytes",
@@ -127,6 +132,11 @@ const securitizeRedemptionSubcompressorAbi = [
127
132
  type: "uint256",
128
133
  internalType: "uint256"
129
134
  },
135
+ {
136
+ name: "redeemer",
137
+ type: "address",
138
+ internalType: "address"
139
+ },
130
140
  {
131
141
  name: "extraData",
132
142
  type: "bytes",
@@ -204,6 +214,11 @@ const securitizeRedemptionSubcompressorAbi = [
204
214
  internalType: "bytes"
205
215
  }]
206
216
  },
217
+ {
218
+ name: "redeemer",
219
+ type: "address",
220
+ internalType: "address"
221
+ },
207
222
  {
208
223
  name: "extraData",
209
224
  type: "bytes",
@@ -252,6 +267,11 @@ const securitizeRedemptionSubcompressorAbi = [
252
267
  type: "uint256",
253
268
  internalType: "uint256"
254
269
  },
270
+ {
271
+ name: "redeemer",
272
+ type: "address",
273
+ internalType: "address"
274
+ },
255
275
  {
256
276
  name: "extraData",
257
277
  type: "bytes",
@@ -118,6 +118,11 @@ const withdrawalCompressorAbi = [
118
118
  internalType: "bytes"
119
119
  }]
120
120
  },
121
+ {
122
+ name: "redeemer",
123
+ type: "address",
124
+ internalType: "address"
125
+ },
121
126
  {
122
127
  name: "extraData",
123
128
  type: "bytes",
@@ -166,6 +171,11 @@ const withdrawalCompressorAbi = [
166
171
  type: "uint256",
167
172
  internalType: "uint256"
168
173
  },
174
+ {
175
+ name: "redeemer",
176
+ type: "address",
177
+ internalType: "address"
178
+ },
169
179
  {
170
180
  name: "extraData",
171
181
  type: "bytes",
@@ -243,6 +253,11 @@ const withdrawalCompressorAbi = [
243
253
  internalType: "bytes"
244
254
  }]
245
255
  },
256
+ {
257
+ name: "redeemer",
258
+ type: "address",
259
+ internalType: "address"
260
+ },
246
261
  {
247
262
  name: "extraData",
248
263
  type: "bytes",
@@ -291,6 +306,11 @@ const withdrawalCompressorAbi = [
291
306
  type: "uint256",
292
307
  internalType: "uint256"
293
308
  },
309
+ {
310
+ name: "redeemer",
311
+ type: "address",
312
+ internalType: "address"
313
+ },
294
314
  {
295
315
  name: "extraData",
296
316
  type: "bytes",
@@ -368,6 +388,11 @@ const withdrawalCompressorAbi = [
368
388
  internalType: "bytes"
369
389
  }]
370
390
  },
391
+ {
392
+ name: "redeemer",
393
+ type: "address",
394
+ internalType: "address"
395
+ },
371
396
  {
372
397
  name: "extraData",
373
398
  type: "bytes",
@@ -416,6 +441,11 @@ const withdrawalCompressorAbi = [
416
441
  type: "uint256",
417
442
  internalType: "uint256"
418
443
  },
444
+ {
445
+ name: "redeemer",
446
+ type: "address",
447
+ internalType: "address"
448
+ },
419
449
  {
420
450
  name: "extraData",
421
451
  type: "bytes",
@@ -19,8 +19,14 @@ const adapterActionSignatures = {
19
19
  ["KELP_WITHDRAWAL"]: { 310: "function setTokensOutBatchStatus((address,address,bool)[])" },
20
20
  ["MELLOW_CLAIMER"]: { 310: "function setMultiVaultStatusBatch((address,address,bool)[])" },
21
21
  ["MELLOW_WRAPPER"]: { 310: "function setVaultStatusBatch((address,bool)[])" },
22
- ["MIDAS_ISSUANCE_VAULT"]: { 310: "function setTokenAllowedStatusBatch(address[],bool[])" },
23
- ["MIDAS_REDEMPTION_VAULT"]: { 310: "function setTokenAllowedStatusBatch((address,address,bool)[])" },
22
+ ["MIDAS_ISSUANCE_VAULT"]: {
23
+ 310: "function setTokenAllowedStatusBatch(address[],bool[])",
24
+ 311: "function setInputTokenStatusBatch(address[],bool[])"
25
+ },
26
+ ["MIDAS_REDEMPTION_VAULT"]: {
27
+ 310: "function setTokenAllowedStatusBatch((address,address,bool)[])",
28
+ 311: "function setOutputTokenStatusBatch(address[],bool[])"
29
+ },
24
30
  ["PENDLE_ROUTER"]: {
25
31
  310: "function setPairStatusBatch((address,address,address,uint8)[])",
26
32
  311: "function setPairStatusBatch((address,address,address,uint8,uint8)[])"
@@ -19,7 +19,10 @@ const adapterConstructorAbi = {
19
19
  ["INFINIFI_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
20
20
  ["LIDO_V1"]: { 310: BASIC_ADAPTER_ABI },
21
21
  ["LIDO_WSTETH_V1"]: { 310: BASIC_ADAPTER_ABI },
22
- ["MIDAS_REDEMPTION_VAULT"]: { 310: BASIC_ADAPTER_ABI },
22
+ ["MIDAS_REDEMPTION_VAULT"]: {
23
+ 310: BASIC_ADAPTER_ABI,
24
+ 311: BASIC_ADAPTER_ABI
25
+ },
23
26
  ["PENDLE_ROUTER"]: {
24
27
  310: BASIC_ADAPTER_ABI,
25
28
  311: BASIC_ADAPTER_ABI
@@ -64,7 +67,10 @@ const adapterConstructorAbi = {
64
67
  311: PHANTOM_TOKEN_ADAPTER_ABI
65
68
  },
66
69
  ["STAKING_REWARDS"]: { 312: STAKING_REWARDS_ADAPTER_ABI },
67
- ["MIDAS_ISSUANCE_VAULT"]: { 310: REFERER_ID_ADAPTER_ABI },
70
+ ["MIDAS_ISSUANCE_VAULT"]: {
71
+ 310: REFERER_ID_ADAPTER_ABI,
72
+ 311: REFERER_ID_ADAPTER_ABI
73
+ },
68
74
  ["MIDAS_GATEWAY"]: { 311: REFERER_ID_ADAPTER_ABI }
69
75
  };
70
76
  //#endregion
@@ -8,6 +8,7 @@ import { decodeAbiParameters } from "viem";
8
8
  const abi = iMidasRedemptionVaultAdapterV310Abi;
9
9
  const protocolAbi = iMidasRedemptionVaultGatewayV310Abi;
10
10
  var MidasRedemptionVaultAdapterContract = class extends AbstractAdapterContract {
11
+ #version;
11
12
  #gateway;
12
13
  #mToken;
13
14
  #allowedTokens;
@@ -18,41 +19,68 @@ var MidasRedemptionVaultAdapterContract = class extends AbstractAdapterContract
18
19
  protocolAbi
19
20
  });
20
21
  if (args.baseParams.serializedParams) {
21
- const decoded = decodeAbiParameters([
22
- {
23
- type: "address",
24
- name: "creditManager"
25
- },
26
- {
27
- type: "address",
28
- name: "targetContract"
29
- },
30
- {
31
- type: "address",
32
- name: "gateway"
33
- },
34
- {
35
- type: "address",
36
- name: "mToken"
37
- },
38
- {
39
- type: "address[]",
40
- name: "allowedTokens"
41
- },
42
- {
43
- type: "address[]",
44
- name: "allowedPhantomTokens"
45
- }
46
- ], args.baseParams.serializedParams);
47
- this.#gateway = decoded[2];
48
- this.#mToken = decoded[3];
49
- this.#allowedTokens = decoded[4].map((token, index) => ({
50
- token,
51
- phantomToken: decoded[5][index]
52
- }));
22
+ const version = Number(args.baseParams.version);
23
+ this.#version = version;
24
+ if (version <= 310) {
25
+ const decoded = decodeAbiParameters([
26
+ {
27
+ type: "address",
28
+ name: "creditManager"
29
+ },
30
+ {
31
+ type: "address",
32
+ name: "targetContract"
33
+ },
34
+ {
35
+ type: "address",
36
+ name: "gateway"
37
+ },
38
+ {
39
+ type: "address",
40
+ name: "mToken"
41
+ },
42
+ {
43
+ type: "address[]",
44
+ name: "allowedTokens"
45
+ },
46
+ {
47
+ type: "address[]",
48
+ name: "allowedPhantomTokens"
49
+ }
50
+ ], args.baseParams.serializedParams);
51
+ this.#gateway = decoded[2];
52
+ this.#mToken = decoded[3];
53
+ this.#allowedTokens = decoded[4].map((token, index) => ({
54
+ token,
55
+ phantomToken: decoded[5][index]
56
+ }));
57
+ } else {
58
+ const decoded = decodeAbiParameters([
59
+ {
60
+ type: "address",
61
+ name: "creditManager"
62
+ },
63
+ {
64
+ type: "address",
65
+ name: "targetContract"
66
+ },
67
+ {
68
+ type: "address",
69
+ name: "mToken"
70
+ },
71
+ {
72
+ type: "address[]",
73
+ name: "supportedInputTokens"
74
+ }
75
+ ], args.baseParams.serializedParams);
76
+ this.#mToken = decoded[2];
77
+ this.#allowedTokens = [...decoded[3]];
78
+ }
53
79
  }
54
80
  }
55
81
  get gateway() {
82
+ if (!this.#version) throw new MissingSerializedParamsError("version");
83
+ if (this.#version > 310) return void 0;
56
84
  if (!this.#gateway) throw new MissingSerializedParamsError("gateway");
57
85
  return this.#gateway;
58
86
  }
@@ -69,10 +97,13 @@ var MidasRedemptionVaultAdapterContract = class extends AbstractAdapterContract
69
97
  ...super.stateHuman(raw),
70
98
  gateway: this.#gateway ? this.labelAddress(this.#gateway) : void 0,
71
99
  mToken: this.#mToken ? this.labelAddress(this.#mToken) : void 0,
72
- allowedTokens: this.#allowedTokens?.map((t) => ({
73
- token: this.labelAddress(t.token),
74
- phantomToken: this.labelAddress(t.phantomToken)
75
- }))
100
+ allowedTokens: this.#allowedTokens?.map((t) => {
101
+ if (typeof t === "object") return {
102
+ token: this.labelAddress(t.token),
103
+ phantomToken: this.labelAddress(t.phantomToken)
104
+ };
105
+ return { token: this.labelAddress(t) };
106
+ })
76
107
  };
77
108
  }
78
109
  async applyBalanceChanges(balances, decoded) {
@@ -1,6 +1,6 @@
1
1
  import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
2
- import { iPhantomTokenAbi } from "../../../abi/iPhantomToken.js";
3
2
  import { AddressSet } from "../../utils/AddressSet.js";
3
+ import { bytes32ToString } from "../../utils/bytes32ToString.js";
4
4
  import { ADDRESS_0X0 } from "../../constants/addresses.js";
5
5
  import { WAD } from "../../constants/math.js";
6
6
  import "../../constants/index.js";
@@ -8,14 +8,13 @@ import { hexEq } from "../../utils/hex.js";
8
8
  import "../../utils/index.js";
9
9
  import { SDKConstruct } from "../../base/SDKConstruct.js";
10
10
  import "../../base/index.js";
11
- import { PHANTOM_TOKEN_MIDAS_REDEMPTION } from "../../market/rwa/midas/constants.js";
11
+ import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
12
12
  import { MidasLiquidatorContract } from "../../market/rwa/midas/MidasLiquidatorContract.js";
13
13
  import "../../market/rwa/midas/index.js";
14
- import { PHANTOM_TOKEN_SECURITIZE_REDEMPTION } from "../../market/rwa/securitize/constants.js";
14
+ import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants.js";
15
15
  import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/SecuritizeLiquidatorContract.js";
16
16
  import "../../market/rwa/securitize/index.js";
17
17
  import { LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
18
- import { iRWAGatewayAbi } from "../../../abi/rwa/iRWAGateway.js";
19
18
  import { calcEstimatedProfit, calcRepaymentAmount, liquidationCallToRawTx, pickMainAsset, toLiquidationApproval, toLiquidatorWithdrawals, toReceivedAssets } from "./helpers.js";
20
19
  //#region src/sdk/accounts/liquidations/LiquidationsService.ts
21
20
  /**
@@ -65,20 +64,21 @@ var LiquidationsService = class extends SDKConstruct {
65
64
  return {
66
65
  ...account,
67
66
  repaymentAmount: {
68
- token: account.totalValue.token,
69
- balance: data.requiredUnderlyingAmount
67
+ token: hexEq(data.requiredToken, "0x0000000000000000000000000000000000000000") ? account.totalValue.token : data.requiredToken,
68
+ balance: data.requiredAmount
70
69
  },
71
70
  isDelayed: data.expectedOutputs.some((o) => o.delayed),
72
71
  receivedAssets: toReceivedAssets(data.expectedOutputs),
73
72
  isLiquidatorEligible: data.isLiquidatorEligible,
73
+ isCreditAccountFrozen: data.isCreditAccountFrozen,
74
74
  kycProtocol: data.kycProtocol || void 0,
75
75
  kycToken: hexEq(data.kycToken, "0x0000000000000000000000000000000000000000") ? void 0 : data.kycToken,
76
76
  approve: toLiquidationApproval({
77
77
  target: data.liquidationCall.target,
78
78
  creditFacade: suite.creditFacade.address,
79
79
  creditManager: ca.creditManager,
80
- token: suite.underlying,
81
- amount: data.requiredUnderlyingAmount
80
+ token: data.requiredToken,
81
+ amount: data.requiredAmount
82
82
  })
83
83
  };
84
84
  }
@@ -106,56 +106,39 @@ var LiquidationsService = class extends SDKConstruct {
106
106
  * {@inheritDoc ILiquidationsService.loadRWALiquidators}
107
107
  **/
108
108
  async loadRWALiquidators() {
109
- await this.sdk.tokensMeta.loadTokenData();
110
- const phantomTokens = [];
111
- for (const meta of this.sdk.tokensMeta.phantomTokens.values()) switch (meta.contractType) {
112
- case PHANTOM_TOKEN_SECURITIZE_REDEMPTION:
113
- case PHANTOM_TOKEN_MIDAS_REDEMPTION: phantomTokens.push(meta);
114
- }
115
- if (phantomTokens.length === 0) return;
116
- const ptResp = await this.client.multicall({
117
- contracts: phantomTokens.map(({ addr }) => ({
118
- address: addr,
119
- abi: iPhantomTokenAbi,
120
- functionName: "getPhantomTokenInfo"
121
- })),
122
- allowFailure: false,
123
- batchSize: 0
124
- });
125
- const gateways = phantomTokens.map(({ contractType }, i) => ({
126
- gateway: ptResp[i][0],
127
- contractType
128
- }));
129
- const gwResp = await this.client.multicall({
130
- contracts: gateways.map(({ gateway }) => ({
131
- address: gateway,
132
- abi: iRWAGatewayAbi,
133
- functionName: "transferMaster"
109
+ const configurators = this.sdk.marketRegister.marketConfigurators;
110
+ if (configurators.length === 0) return;
111
+ const resp = await this.client.multicall({
112
+ contracts: configurators.map((mc) => ({
113
+ address: LIQUIDATION_COMPRESSOR_V313_ADDRESS,
114
+ abi: iLiquidationCompressorV313Abi,
115
+ functionName: "getRWALiquidators",
116
+ args: [mc.address]
134
117
  })),
135
118
  allowFailure: false,
136
119
  batchSize: 0
137
120
  });
138
- const refs = gateways.map(({ contractType }, i) => ({
139
- liquidator: gwResp[i],
140
- contractType
141
- }));
142
- for (const ref of refs) this.#createRWALiquidator(ref);
121
+ for (const info of resp.flat()) this.#createRWALiquidator(info);
143
122
  }
144
123
  /**
145
124
  * Instantiates the liquidator contract, which registers it and labels its
146
125
  * address (see `BaseContract`).
147
126
  *
148
- * @param ref - Discovered liquidator address and its phantom token type
127
+ * @param info - Liquidator discovered by the compressor. The same gateway
128
+ * can be configured in several credit managers, so duplicates are expected
129
+ * and skipped.
149
130
  **/
150
- #createRWALiquidator(ref) {
151
- const { liquidator, contractType } = ref;
131
+ #createRWALiquidator(info) {
132
+ const liquidator = info.liquidatorAddress;
152
133
  if (this.sdk.getContract(liquidator)) return;
153
- switch (contractType) {
154
- case PHANTOM_TOKEN_SECURITIZE_REDEMPTION:
134
+ switch (bytes32ToString(info.contractType)) {
135
+ case RWA_LIQUIDATOR_SECURITIZE:
155
136
  new SecuritizeLiquidatorContract(this.sdk, liquidator);
137
+ this.logger?.debug(`registered Securitize liquidator ${liquidator}`);
156
138
  return;
157
- case PHANTOM_TOKEN_MIDAS_REDEMPTION:
139
+ case RWA_LIQUIDATOR_MIDAS:
158
140
  new MidasLiquidatorContract(this.sdk, liquidator);
141
+ this.logger?.debug(`registered Midas liquidator ${liquidator}`);
159
142
  return;
160
143
  }
161
144
  }
@@ -250,7 +233,8 @@ var LiquidationsService = class extends SDKConstruct {
250
233
  token: unwrappedUnderlying,
251
234
  balance: calcEstimatedProfit(ca.totalValue, liquidationDiscount)
252
235
  },
253
- isDelayed: ca.tokens.some((t) => t.balance > 10n && !!compressor?.getWithdrawalSourceToken(t.token))
236
+ isDelayed: ca.tokens.some((t) => t.balance > 10n && !!compressor?.getWithdrawalSourceToken(t.token)),
237
+ paused: suite.creditFacade.isPaused
254
238
  };
255
239
  }
256
240
  };
@@ -1,4 +1,4 @@
1
1
  //#region src/sdk/accounts/liquidations/constants.ts
2
- const LIQUIDATION_COMPRESSOR_V313_ADDRESS = "0x04c5c47c3b9e29ce98fdd27103fbb6a0815b1712";
2
+ const LIQUIDATION_COMPRESSOR_V313_ADDRESS = "0xB70C4500a0afF02107eB983a348F22492fB6dC94";
3
3
  //#endregion
4
4
  export { LIQUIDATION_COMPRESSOR_V313_ADDRESS };
@@ -75,14 +75,16 @@ function toLiquidatorWithdrawals(current, network) {
75
75
  network,
76
76
  sourceToken: w.token,
77
77
  token: o.token,
78
- amount: o.amount
78
+ amount: o.amount,
79
+ redeemer: w.redeemer
79
80
  });
80
81
  for (const w of current.pending) for (const o of w.expectedOutputs) rows.push({
81
82
  network,
82
83
  sourceToken: w.token,
83
84
  token: o.token,
84
85
  amount: o.amount,
85
- claimableAt: w.claimableAt
86
+ claimableAt: w.claimableAt,
87
+ redeemer: w.redeemer
86
88
  });
87
89
  return rows;
88
90
  }