@gearbox-protocol/sdk 14.12.0-next.57 → 14.12.0-next.59
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/abi/ILiquidationCompressorV313.js +43 -1
- package/dist/cjs/abi/IWithdrawalCompressorV313.js +71 -41
- package/dist/cjs/dev/claimDSToken.js +85 -6
- package/dist/cjs/dev/withdrawalUtils.js +173 -119
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +27 -43
- package/dist/cjs/sdk/accounts/liquidations/constants.js +1 -1
- package/dist/cjs/sdk/accounts/liquidations/helpers.js +4 -2
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +12 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +10 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +1 -1
- package/dist/esm/abi/ILiquidationCompressorV313.js +43 -1
- package/dist/esm/abi/IWithdrawalCompressorV313.js +71 -41
- package/dist/esm/dev/claimDSToken.js +86 -7
- package/dist/esm/dev/withdrawalUtils.js +173 -119
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +29 -45
- package/dist/esm/sdk/accounts/liquidations/constants.js +1 -1
- package/dist/esm/sdk/accounts/liquidations/helpers.js +4 -2
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +12 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +10 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +1 -1
- package/dist/types/abi/ILiquidationCompressorV313.d.ts +36 -1
- package/dist/types/abi/IWithdrawalCompressorV313.d.ts +62 -38
- package/dist/types/dev/withdrawalUtils.d.ts +9 -5
- package/dist/types/sdk/accounts/liquidations/helpers.d.ts +8 -1
- package/dist/types/sdk/accounts/liquidations/types.d.ts +27 -5
- package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +3 -3
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +62 -38
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +10 -0
- package/package.json +1 -1
|
@@ -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 {
|
|
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 {
|
|
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.
|
|
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:
|
|
81
|
-
amount: data.
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
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
|
|
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(
|
|
151
|
-
const
|
|
131
|
+
#createRWALiquidator(info) {
|
|
132
|
+
const liquidator = info.liquidatorAddress;
|
|
152
133
|
if (this.sdk.getContract(liquidator)) return;
|
|
153
|
-
switch (contractType) {
|
|
154
|
-
case
|
|
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
|
|
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 = "
|
|
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
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
2
|
+
import "../../constants/addresses.js";
|
|
3
|
+
import "../../constants/index.js";
|
|
4
|
+
import { hexEq } from "../../utils/hex.js";
|
|
2
5
|
import "../../utils/index.js";
|
|
3
6
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
4
7
|
import "../../base/index.js";
|
|
@@ -200,6 +203,13 @@ function toRequestableWithdrawal(resp) {
|
|
|
200
203
|
};
|
|
201
204
|
}
|
|
202
205
|
/**
|
|
206
|
+
* Normalizes the redeemer of a withdrawal: legacy compressors do not report
|
|
207
|
+
* one, and v313+ uses the zero address for "not applicable".
|
|
208
|
+
**/
|
|
209
|
+
function toRedeemer(redeemer) {
|
|
210
|
+
return !redeemer || hexEq(redeemer, "0x0000000000000000000000000000000000000000") ? void 0 : redeemer;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
203
213
|
* Normalizes a claimable withdrawal. The intent is decoded from `extraData`
|
|
204
214
|
* only when `creditManager` is provided (it is required to build
|
|
205
215
|
* {@link DelayedIntentExtended} and is only meaningful for credit account
|
|
@@ -217,6 +227,7 @@ function toClaimableWithdrawal(w, creditManager) {
|
|
|
217
227
|
withdrawalTokenSpent: w.withdrawalTokenSpent,
|
|
218
228
|
outputs: [...w.outputs],
|
|
219
229
|
claimCalls: [...w.claimCalls],
|
|
230
|
+
redeemer: toRedeemer(w.redeemer),
|
|
220
231
|
intent
|
|
221
232
|
};
|
|
222
233
|
}
|
|
@@ -235,6 +246,7 @@ function toPendingWithdrawal(w, creditManager) {
|
|
|
235
246
|
withdrawalPhantomToken: w.withdrawalPhantomToken,
|
|
236
247
|
expectedOutputs: [...w.expectedOutputs],
|
|
237
248
|
claimableAt: w.claimableAt,
|
|
249
|
+
redeemer: toRedeemer(w.redeemer),
|
|
238
250
|
intent
|
|
239
251
|
};
|
|
240
252
|
}
|
|
@@ -78,6 +78,11 @@ const iExternalWithdrawalsBatchAbi = [{
|
|
|
78
78
|
internalType: "bytes"
|
|
79
79
|
}]
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
name: "redeemer",
|
|
83
|
+
type: "address",
|
|
84
|
+
internalType: "address"
|
|
85
|
+
},
|
|
81
86
|
{
|
|
82
87
|
name: "extraData",
|
|
83
88
|
type: "bytes",
|
|
@@ -126,6 +131,11 @@ const iExternalWithdrawalsBatchAbi = [{
|
|
|
126
131
|
type: "uint256",
|
|
127
132
|
internalType: "uint256"
|
|
128
133
|
},
|
|
134
|
+
{
|
|
135
|
+
name: "redeemer",
|
|
136
|
+
type: "address",
|
|
137
|
+
internalType: "address"
|
|
138
|
+
},
|
|
129
139
|
{
|
|
130
140
|
name: "extraData",
|
|
131
141
|
type: "bytes",
|
|
@@ -39,7 +39,11 @@ declare const iLiquidationCompressorV313Abi: readonly [{
|
|
|
39
39
|
readonly type: "tuple";
|
|
40
40
|
readonly internalType: "struct LiquidationData";
|
|
41
41
|
readonly components: readonly [{
|
|
42
|
-
readonly name: "
|
|
42
|
+
readonly name: "requiredToken";
|
|
43
|
+
readonly type: "address";
|
|
44
|
+
readonly internalType: "address";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "requiredAmount";
|
|
43
47
|
readonly type: "uint256";
|
|
44
48
|
readonly internalType: "uint256";
|
|
45
49
|
}, {
|
|
@@ -84,6 +88,10 @@ declare const iLiquidationCompressorV313Abi: readonly [{
|
|
|
84
88
|
readonly name: "isLiquidatorEligible";
|
|
85
89
|
readonly type: "bool";
|
|
86
90
|
readonly internalType: "bool";
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "isCreditAccountFrozen";
|
|
93
|
+
readonly type: "bool";
|
|
94
|
+
readonly internalType: "bool";
|
|
87
95
|
}, {
|
|
88
96
|
readonly name: "kycProtocol";
|
|
89
97
|
readonly type: "string";
|
|
@@ -95,6 +103,33 @@ declare const iLiquidationCompressorV313Abi: readonly [{
|
|
|
95
103
|
}];
|
|
96
104
|
}];
|
|
97
105
|
readonly stateMutability: "nonpayable";
|
|
106
|
+
}, {
|
|
107
|
+
readonly type: "function";
|
|
108
|
+
readonly name: "getRWALiquidators";
|
|
109
|
+
readonly inputs: readonly [{
|
|
110
|
+
readonly name: "marketConfigurator";
|
|
111
|
+
readonly type: "address";
|
|
112
|
+
readonly internalType: "address";
|
|
113
|
+
}];
|
|
114
|
+
readonly outputs: readonly [{
|
|
115
|
+
readonly name: "";
|
|
116
|
+
readonly type: "tuple[]";
|
|
117
|
+
readonly internalType: "struct RWALiquidatorInfo[]";
|
|
118
|
+
readonly components: readonly [{
|
|
119
|
+
readonly name: "gateway";
|
|
120
|
+
readonly type: "address";
|
|
121
|
+
readonly internalType: "address";
|
|
122
|
+
}, {
|
|
123
|
+
readonly name: "liquidatorAddress";
|
|
124
|
+
readonly type: "address";
|
|
125
|
+
readonly internalType: "address";
|
|
126
|
+
}, {
|
|
127
|
+
readonly name: "contractType";
|
|
128
|
+
readonly type: "bytes32";
|
|
129
|
+
readonly internalType: "bytes32";
|
|
130
|
+
}];
|
|
131
|
+
}];
|
|
132
|
+
readonly stateMutability: "view";
|
|
98
133
|
}, {
|
|
99
134
|
readonly type: "function";
|
|
100
135
|
readonly name: "version";
|
|
@@ -63,6 +63,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
63
63
|
readonly type: "bytes";
|
|
64
64
|
readonly internalType: "bytes";
|
|
65
65
|
}];
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "redeemer";
|
|
68
|
+
readonly type: "address";
|
|
69
|
+
readonly internalType: "address";
|
|
66
70
|
}, {
|
|
67
71
|
readonly name: "extraData";
|
|
68
72
|
readonly type: "bytes";
|
|
@@ -101,6 +105,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
101
105
|
readonly name: "claimableAt";
|
|
102
106
|
readonly type: "uint256";
|
|
103
107
|
readonly internalType: "uint256";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "redeemer";
|
|
110
|
+
readonly type: "address";
|
|
111
|
+
readonly internalType: "address";
|
|
104
112
|
}, {
|
|
105
113
|
readonly name: "extraData";
|
|
106
114
|
readonly type: "bytes";
|
|
@@ -112,9 +120,9 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
112
120
|
readonly type: "function";
|
|
113
121
|
readonly name: "getExternalAccountCurrentWithdrawals";
|
|
114
122
|
readonly inputs: readonly [{
|
|
115
|
-
readonly name: "
|
|
116
|
-
readonly type: "address";
|
|
117
|
-
readonly internalType: "address";
|
|
123
|
+
readonly name: "withdrawalTokens";
|
|
124
|
+
readonly type: "address[]";
|
|
125
|
+
readonly internalType: "address[]";
|
|
118
126
|
}, {
|
|
119
127
|
readonly name: "account";
|
|
120
128
|
readonly type: "address";
|
|
@@ -166,6 +174,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
166
174
|
readonly type: "bytes";
|
|
167
175
|
readonly internalType: "bytes";
|
|
168
176
|
}];
|
|
177
|
+
}, {
|
|
178
|
+
readonly name: "redeemer";
|
|
179
|
+
readonly type: "address";
|
|
180
|
+
readonly internalType: "address";
|
|
169
181
|
}, {
|
|
170
182
|
readonly name: "extraData";
|
|
171
183
|
readonly type: "bytes";
|
|
@@ -204,6 +216,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
204
216
|
readonly name: "claimableAt";
|
|
205
217
|
readonly type: "uint256";
|
|
206
218
|
readonly internalType: "uint256";
|
|
219
|
+
}, {
|
|
220
|
+
readonly name: "redeemer";
|
|
221
|
+
readonly type: "address";
|
|
222
|
+
readonly internalType: "address";
|
|
207
223
|
}, {
|
|
208
224
|
readonly name: "extraData";
|
|
209
225
|
readonly type: "bytes";
|
|
@@ -215,9 +231,9 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
215
231
|
readonly type: "function";
|
|
216
232
|
readonly name: "getExternalAccountCurrentWithdrawals";
|
|
217
233
|
readonly inputs: readonly [{
|
|
218
|
-
readonly name: "
|
|
219
|
-
readonly type: "address
|
|
220
|
-
readonly internalType: "address
|
|
234
|
+
readonly name: "withdrawalToken";
|
|
235
|
+
readonly type: "address";
|
|
236
|
+
readonly internalType: "address";
|
|
221
237
|
}, {
|
|
222
238
|
readonly name: "account";
|
|
223
239
|
readonly type: "address";
|
|
@@ -269,6 +285,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
269
285
|
readonly type: "bytes";
|
|
270
286
|
readonly internalType: "bytes";
|
|
271
287
|
}];
|
|
288
|
+
}, {
|
|
289
|
+
readonly name: "redeemer";
|
|
290
|
+
readonly type: "address";
|
|
291
|
+
readonly internalType: "address";
|
|
272
292
|
}, {
|
|
273
293
|
readonly name: "extraData";
|
|
274
294
|
readonly type: "bytes";
|
|
@@ -307,6 +327,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
307
327
|
readonly name: "claimableAt";
|
|
308
328
|
readonly type: "uint256";
|
|
309
329
|
readonly internalType: "uint256";
|
|
330
|
+
}, {
|
|
331
|
+
readonly name: "redeemer";
|
|
332
|
+
readonly type: "address";
|
|
333
|
+
readonly internalType: "address";
|
|
310
334
|
}, {
|
|
311
335
|
readonly name: "extraData";
|
|
312
336
|
readonly type: "bytes";
|
|
@@ -314,34 +338,6 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
314
338
|
}];
|
|
315
339
|
}];
|
|
316
340
|
readonly stateMutability: "view";
|
|
317
|
-
}, {
|
|
318
|
-
readonly type: "function";
|
|
319
|
-
readonly name: "getWithdrawalStatus";
|
|
320
|
-
readonly inputs: readonly [{
|
|
321
|
-
readonly name: "redeemer";
|
|
322
|
-
readonly type: "address";
|
|
323
|
-
readonly internalType: "address";
|
|
324
|
-
}];
|
|
325
|
-
readonly outputs: readonly [{
|
|
326
|
-
readonly name: "";
|
|
327
|
-
readonly type: "uint8";
|
|
328
|
-
readonly internalType: "enum WithdrawalStatus";
|
|
329
|
-
}];
|
|
330
|
-
readonly stateMutability: "view";
|
|
331
|
-
}, {
|
|
332
|
-
readonly type: "function";
|
|
333
|
-
readonly name: "getWithdrawalStatus";
|
|
334
|
-
readonly inputs: readonly [{
|
|
335
|
-
readonly name: "redeemers";
|
|
336
|
-
readonly type: "address[]";
|
|
337
|
-
readonly internalType: "address[]";
|
|
338
|
-
}];
|
|
339
|
-
readonly outputs: readonly [{
|
|
340
|
-
readonly name: "";
|
|
341
|
-
readonly type: "uint8[]";
|
|
342
|
-
readonly internalType: "enum WithdrawalStatus[]";
|
|
343
|
-
}];
|
|
344
|
-
readonly stateMutability: "view";
|
|
345
341
|
}, {
|
|
346
342
|
readonly type: "function";
|
|
347
343
|
readonly name: "getWithdrawableAssets";
|
|
@@ -461,10 +457,6 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
461
457
|
readonly name: "token";
|
|
462
458
|
readonly type: "address";
|
|
463
459
|
readonly internalType: "address";
|
|
464
|
-
}, {
|
|
465
|
-
readonly name: "withdrawalToken";
|
|
466
|
-
readonly type: "address";
|
|
467
|
-
readonly internalType: "address";
|
|
468
460
|
}, {
|
|
469
461
|
readonly name: "amount";
|
|
470
462
|
readonly type: "uint256";
|
|
@@ -530,6 +522,10 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
530
522
|
readonly name: "token";
|
|
531
523
|
readonly type: "address";
|
|
532
524
|
readonly internalType: "address";
|
|
525
|
+
}, {
|
|
526
|
+
readonly name: "withdrawalToken";
|
|
527
|
+
readonly type: "address";
|
|
528
|
+
readonly internalType: "address";
|
|
533
529
|
}, {
|
|
534
530
|
readonly name: "amount";
|
|
535
531
|
readonly type: "uint256";
|
|
@@ -584,6 +580,34 @@ declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
584
580
|
}];
|
|
585
581
|
}];
|
|
586
582
|
readonly stateMutability: "view";
|
|
583
|
+
}, {
|
|
584
|
+
readonly type: "function";
|
|
585
|
+
readonly name: "getWithdrawalStatus";
|
|
586
|
+
readonly inputs: readonly [{
|
|
587
|
+
readonly name: "redeemers";
|
|
588
|
+
readonly type: "address[]";
|
|
589
|
+
readonly internalType: "address[]";
|
|
590
|
+
}];
|
|
591
|
+
readonly outputs: readonly [{
|
|
592
|
+
readonly name: "";
|
|
593
|
+
readonly type: "uint8[]";
|
|
594
|
+
readonly internalType: "enum WithdrawalStatus[]";
|
|
595
|
+
}];
|
|
596
|
+
readonly stateMutability: "view";
|
|
597
|
+
}, {
|
|
598
|
+
readonly type: "function";
|
|
599
|
+
readonly name: "getWithdrawalStatus";
|
|
600
|
+
readonly inputs: readonly [{
|
|
601
|
+
readonly name: "redeemer";
|
|
602
|
+
readonly type: "address";
|
|
603
|
+
readonly internalType: "address";
|
|
604
|
+
}];
|
|
605
|
+
readonly outputs: readonly [{
|
|
606
|
+
readonly name: "";
|
|
607
|
+
readonly type: "uint8";
|
|
608
|
+
readonly internalType: "enum WithdrawalStatus";
|
|
609
|
+
}];
|
|
610
|
+
readonly stateMutability: "view";
|
|
587
611
|
}, {
|
|
588
612
|
readonly type: "function";
|
|
589
613
|
readonly name: "version";
|
|
@@ -5,19 +5,23 @@ import { Address } from "viem";
|
|
|
5
5
|
//#region src/dev/withdrawalUtils.d.ts
|
|
6
6
|
interface MakePendingWithdrawalsClaimableOptions {
|
|
7
7
|
logger?: ILogger;
|
|
8
|
-
timeWarp?: boolean;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
|
-
* Makes pending delayed withdrawals
|
|
10
|
+
* Makes pending delayed withdrawals claimable on an anvil fork.
|
|
11
|
+
*
|
|
12
|
+
* Accepts either a credit account, in which case all its pending withdrawals are
|
|
13
|
+
* fulfilled, or a single redeemer. The latter is the only way to reach redeemers
|
|
14
|
+
* that were transferred away from a credit account during a liquidation: they are
|
|
15
|
+
* dropped from the gateway's pending sets, so the compressor no longer reports them.
|
|
12
16
|
*
|
|
13
17
|
* Replicates the `_fulfillWithdrawal` logic from periphery-v3 Foundry tests
|
|
14
18
|
* (WithdrawalCompressorMidasRWA.t.sol, WithdrawalCompressorSecuritize.t.sol)
|
|
15
19
|
* using anvil cheatcodes. Assumes the version 313 of WithdrawalCompressor.
|
|
16
20
|
*
|
|
17
21
|
* @param anvil
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
22
|
+
* @param address credit account or redeemer
|
|
23
|
+
* @param options
|
|
20
24
|
*/
|
|
21
|
-
declare function makePendingWithdrawalsClaimable(anvil: AnvilClient,
|
|
25
|
+
declare function makePendingWithdrawalsClaimable(anvil: AnvilClient, address: Address, options?: MakePendingWithdrawalsClaimableOptions): Promise<void>;
|
|
22
26
|
//#endregion
|
|
23
27
|
export { MakePendingWithdrawalsClaimableOptions, makePendingWithdrawalsClaimable };
|
|
@@ -22,6 +22,13 @@ type OnchainLiquidationOutput = OnchainLiquidationData["expectedOutputs"][number
|
|
|
22
22
|
* Single call built by the liquidation compressor.
|
|
23
23
|
**/
|
|
24
24
|
type OnchainLiquidationCall = OnchainLiquidationData["liquidationCall"];
|
|
25
|
+
/**
|
|
26
|
+
* A dedicated RWA liquidator contract (Midas / Securitize) discovered by
|
|
27
|
+
* `LiquidationCompressor.getRWALiquidators`. `contractType` is the bytes32
|
|
28
|
+
* contract type of the liquidator itself (e.g. `RWA_LIQUIDATOR::MIDAS`),
|
|
29
|
+
* not of the phantom token it was found through.
|
|
30
|
+
**/
|
|
31
|
+
type RWALiquidatorInfo = ContractFunctionReturnType<typeof iLiquidationCompressorV313Abi, "view", "getRWALiquidators">[number];
|
|
25
32
|
/**
|
|
26
33
|
* Token balances at or below this threshold are treated as dust and ignored,
|
|
27
34
|
* consistent with the rest of the SDK (see `filterDust`).
|
|
@@ -130,4 +137,4 @@ declare function toLiquidationApproval(props: ToLiquidationApprovalProps): Liqui
|
|
|
130
137
|
**/
|
|
131
138
|
declare function liquidationCallToRawTx(call: OnchainLiquidationCall, description?: string): RawTx;
|
|
132
139
|
//#endregion
|
|
133
|
-
export { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, ToLiquidationApprovalProps, calcEstimatedProfit, calcRepaymentAmount, liquidationCallToRawTx, pickMainAsset, toLiquidationApproval, toLiquidatorWithdrawals, toReceivedAssets };
|
|
140
|
+
export { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo, ToLiquidationApprovalProps, calcEstimatedProfit, calcRepaymentAmount, liquidationCallToRawTx, pickMainAsset, toLiquidationApproval, toLiquidatorWithdrawals, toReceivedAssets };
|
|
@@ -99,6 +99,11 @@ interface LiquidatableAccount {
|
|
|
99
99
|
* liquidator's ownership instead of instantly receivable tokens.
|
|
100
100
|
**/
|
|
101
101
|
isDelayed: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* `true` when the credit manager's facade is paused. Liquidations of such
|
|
104
|
+
* accounts only succeed for emergency liquidators approved in the market.
|
|
105
|
+
**/
|
|
106
|
+
paused: boolean;
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
109
|
* Chain-independent part of {@link GetLiquidationDetailsProps}.
|
|
@@ -213,10 +218,6 @@ type GetLiquidatorWithdrawalsProps<Multichain extends boolean = false> = GetLiqu
|
|
|
213
218
|
type LoadRWALiquidatorsProps<Multichain extends boolean = false> = WithMultichain<Multichain, MultichainNetworksProps>;
|
|
214
219
|
/**
|
|
215
220
|
* A single delayed-withdrawal position owned by the liquidator.
|
|
216
|
-
*
|
|
217
|
-
* The redeemer contract address is not included: it is not part of the
|
|
218
|
-
* on-chain withdrawal structs returned by the withdrawal compressor. It can
|
|
219
|
-
* be surfaced later if the compressor structs are extended.
|
|
220
221
|
**/
|
|
221
222
|
interface LiquidatorWithdrawal {
|
|
222
223
|
/**
|
|
@@ -241,6 +242,11 @@ interface LiquidatorWithdrawal {
|
|
|
241
242
|
* claimable. `undefined` means the withdrawal is claimable now.
|
|
242
243
|
**/
|
|
243
244
|
claimableAt?: bigint;
|
|
245
|
+
/**
|
|
246
|
+
* Redeemer contract the withdrawal is claimed from, owned by the liquidator.
|
|
247
|
+
* `undefined` on compressor versions below 313, which do not report it.
|
|
248
|
+
**/
|
|
249
|
+
redeemer?: Address;
|
|
244
250
|
}
|
|
245
251
|
/**
|
|
246
252
|
* ERC-20 approval the liquidator must grant before sending the liquidation
|
|
@@ -256,7 +262,9 @@ interface LiquidationApproval {
|
|
|
256
262
|
**/
|
|
257
263
|
spender: Address;
|
|
258
264
|
/**
|
|
259
|
-
* Token pulled from the liquidator
|
|
265
|
+
* Token pulled from the liquidator, as reported by the compressor for the
|
|
266
|
+
* liquidation path it selected: the credit manager underlying for standard
|
|
267
|
+
* liquidations, the unwrapped stablecoin (e.g. USDC) for RWA ones.
|
|
260
268
|
**/
|
|
261
269
|
token: Address;
|
|
262
270
|
/**
|
|
@@ -272,6 +280,14 @@ interface LiquidationApproval {
|
|
|
272
280
|
*
|
|
273
281
|
**/
|
|
274
282
|
interface LiquidationDetails extends LiquidatableAccount {
|
|
283
|
+
/**
|
|
284
|
+
* Exact amount the liquidator pays for the liquidation path the compressor
|
|
285
|
+
* selected, superseding the estimate of {@link LiquidatableAccount}. The
|
|
286
|
+
* token is {@link LiquidationApproval.token}, which for RWA markets is the
|
|
287
|
+
* unwrapped stablecoin rather than {@link LiquidatableAccount.totalValue}'s
|
|
288
|
+
* token; it falls back to the latter when nothing is pulled.
|
|
289
|
+
**/
|
|
290
|
+
repaymentAmount: Asset;
|
|
275
291
|
/**
|
|
276
292
|
* Assets the liquidator receives upon full liquidation: direct credit
|
|
277
293
|
* account balances plus outputs of delayed withdrawals (claimable and
|
|
@@ -285,6 +301,12 @@ interface LiquidationDetails extends LiquidatableAccount {
|
|
|
285
301
|
* particular wallet was rejected.
|
|
286
302
|
**/
|
|
287
303
|
isLiquidatorEligible: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* `true` when the credit account is frozen by the RWA factory
|
|
306
|
+
* (`isFrozen`) and cannot move its RWA collateral. Always `false` for
|
|
307
|
+
* non-RWA liquidation paths.
|
|
308
|
+
**/
|
|
309
|
+
isCreditAccountFrozen: boolean;
|
|
288
310
|
/**
|
|
289
311
|
* Name of the KYC protocol the liquidator must be whitelisted in
|
|
290
312
|
* (e.g. `"securitize"`). `undefined` when the liquidation is not KYC-gated.
|
package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ declare const iCreditAccountAbi: readonly [{
|
|
|
18
18
|
}];
|
|
19
19
|
/**
|
|
20
20
|
* v313 ABI is a type-level superset of v310/v311 for the read methods used
|
|
21
|
-
* here. Fields missing in older versions (`maxWithdrawals`, `
|
|
22
|
-
* required in the inferred types but absent at runtime on
|
|
23
|
-
* normalization helpers must not assume their presence.
|
|
21
|
+
* here. Fields missing in older versions (`maxWithdrawals`, `redeemer`,
|
|
22
|
+
* `extraData`) are required in the inferred types but absent at runtime on
|
|
23
|
+
* v310/v311, so the normalization helpers must not assume their presence.
|
|
24
24
|
**/
|
|
25
25
|
type CommonAbi = typeof iWithdrawalCompressorV313Abi;
|
|
26
26
|
type OnchainCurrentWithdrawals = ContractFunctionReturnType<CommonAbi, "view", "getCurrentWithdrawals">;
|