@gearbox-protocol/sdk 14.5.5 → 14.5.7
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/kyc/iDSRegistryService.js +265 -0
- package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +53 -6
- package/dist/cjs/history/assembleOperations.js +18 -4
- package/dist/cjs/history/classifyMulticallOperations.js +20 -4
- package/dist/cjs/history/errors.js +12 -2
- package/dist/cjs/history/extractTransfers.js +12 -1
- package/dist/cjs/history/parseCreditAccountTransaction.js +3 -1
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeDegenNFT.js +41 -0
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +3 -2
- package/dist/esm/abi/kyc/iDSRegistryService.js +265 -0
- package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +53 -6
- package/dist/esm/history/assembleOperations.js +18 -4
- package/dist/esm/history/classifyMulticallOperations.js +25 -5
- package/dist/esm/history/errors.js +10 -1
- package/dist/esm/history/extractTransfers.js +12 -1
- package/dist/esm/history/parseCreditAccountTransaction.js +3 -1
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeDegenNFT.js +17 -0
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +3 -2
- package/dist/types/abi/kyc/iDSRegistryService.d.ts +210 -0
- package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +78 -6
- package/dist/types/history/assembleOperations.d.ts +2 -0
- package/dist/types/history/classifyMulticallOperations.d.ts +2 -0
- package/dist/types/history/errors.d.ts +3 -0
- package/dist/types/history/extractTransfers.d.ts +19 -0
- package/dist/types/sdk/market/kyc/securitize/SecuritizeDegenNFT.d.ts +412 -0
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +80 -7
- package/package.json +1 -1
|
@@ -118,6 +118,271 @@ const iDSRegistryServiceAbi = [
|
|
|
118
118
|
],
|
|
119
119
|
outputs: [],
|
|
120
120
|
stateMutability: "nonpayable"
|
|
121
|
+
},
|
|
122
|
+
// Events below are copied from contract to interface
|
|
123
|
+
{
|
|
124
|
+
anonymous: false,
|
|
125
|
+
inputs: [
|
|
126
|
+
{
|
|
127
|
+
indexed: false,
|
|
128
|
+
internalType: "string",
|
|
129
|
+
name: "investorId",
|
|
130
|
+
type: "string"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
indexed: false,
|
|
134
|
+
internalType: "address",
|
|
135
|
+
name: "sender",
|
|
136
|
+
type: "address"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
name: "DSRegistryServiceInvestorAdded",
|
|
140
|
+
type: "event"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
anonymous: false,
|
|
144
|
+
inputs: [
|
|
145
|
+
{
|
|
146
|
+
indexed: false,
|
|
147
|
+
internalType: "string",
|
|
148
|
+
name: "investorId",
|
|
149
|
+
type: "string"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
indexed: false,
|
|
153
|
+
internalType: "uint256",
|
|
154
|
+
name: "attributeId",
|
|
155
|
+
type: "uint256"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
indexed: false,
|
|
159
|
+
internalType: "uint256",
|
|
160
|
+
name: "value",
|
|
161
|
+
type: "uint256"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
indexed: false,
|
|
165
|
+
internalType: "uint256",
|
|
166
|
+
name: "expiry",
|
|
167
|
+
type: "uint256"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
indexed: false,
|
|
171
|
+
internalType: "string",
|
|
172
|
+
name: "proofHash",
|
|
173
|
+
type: "string"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
indexed: false,
|
|
177
|
+
internalType: "address",
|
|
178
|
+
name: "sender",
|
|
179
|
+
type: "address"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
name: "DSRegistryServiceInvestorAttributeChanged",
|
|
183
|
+
type: "event"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
anonymous: false,
|
|
187
|
+
inputs: [
|
|
188
|
+
{
|
|
189
|
+
indexed: false,
|
|
190
|
+
internalType: "string",
|
|
191
|
+
name: "investorId",
|
|
192
|
+
type: "string"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
indexed: false,
|
|
196
|
+
internalType: "string",
|
|
197
|
+
name: "country",
|
|
198
|
+
type: "string"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
indexed: false,
|
|
202
|
+
internalType: "address",
|
|
203
|
+
name: "sender",
|
|
204
|
+
type: "address"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
name: "DSRegistryServiceInvestorCountryChanged",
|
|
208
|
+
type: "event"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
anonymous: false,
|
|
212
|
+
inputs: [
|
|
213
|
+
{
|
|
214
|
+
indexed: false,
|
|
215
|
+
internalType: "string",
|
|
216
|
+
name: "investorId",
|
|
217
|
+
type: "string"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
indexed: false,
|
|
221
|
+
internalType: "address",
|
|
222
|
+
name: "sender",
|
|
223
|
+
type: "address"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
name: "DSRegistryServiceInvestorRemoved",
|
|
227
|
+
type: "event"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
anonymous: false,
|
|
231
|
+
inputs: [
|
|
232
|
+
{
|
|
233
|
+
indexed: false,
|
|
234
|
+
internalType: "address",
|
|
235
|
+
name: "omnibusWallet",
|
|
236
|
+
type: "address"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
indexed: false,
|
|
240
|
+
internalType: "string",
|
|
241
|
+
name: "investorId",
|
|
242
|
+
type: "string"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
indexed: false,
|
|
246
|
+
internalType: "contract IDSOmnibusWalletController",
|
|
247
|
+
name: "omnibusWalletController",
|
|
248
|
+
type: "address"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
name: "DSRegistryServiceOmnibusWalletAdded",
|
|
252
|
+
type: "event"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
anonymous: false,
|
|
256
|
+
inputs: [
|
|
257
|
+
{
|
|
258
|
+
indexed: false,
|
|
259
|
+
internalType: "address",
|
|
260
|
+
name: "omnibusWallet",
|
|
261
|
+
type: "address"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
indexed: false,
|
|
265
|
+
internalType: "string",
|
|
266
|
+
name: "investorId",
|
|
267
|
+
type: "string"
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
name: "DSRegistryServiceOmnibusWalletRemoved",
|
|
271
|
+
type: "event"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
anonymous: false,
|
|
275
|
+
inputs: [
|
|
276
|
+
{
|
|
277
|
+
indexed: false,
|
|
278
|
+
internalType: "address",
|
|
279
|
+
name: "wallet",
|
|
280
|
+
type: "address"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
indexed: false,
|
|
284
|
+
internalType: "string",
|
|
285
|
+
name: "investorId",
|
|
286
|
+
type: "string"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
indexed: false,
|
|
290
|
+
internalType: "address",
|
|
291
|
+
name: "sender",
|
|
292
|
+
type: "address"
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
name: "DSRegistryServiceWalletAdded",
|
|
296
|
+
type: "event"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
anonymous: false,
|
|
300
|
+
inputs: [
|
|
301
|
+
{
|
|
302
|
+
indexed: false,
|
|
303
|
+
internalType: "address",
|
|
304
|
+
name: "wallet",
|
|
305
|
+
type: "address"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
indexed: false,
|
|
309
|
+
internalType: "string",
|
|
310
|
+
name: "investorId",
|
|
311
|
+
type: "string"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
indexed: false,
|
|
315
|
+
internalType: "address",
|
|
316
|
+
name: "sender",
|
|
317
|
+
type: "address"
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
name: "DSRegistryServiceWalletRemoved",
|
|
321
|
+
type: "event"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
anonymous: false,
|
|
325
|
+
inputs: [
|
|
326
|
+
{
|
|
327
|
+
indexed: false,
|
|
328
|
+
internalType: "uint256",
|
|
329
|
+
name: "serviceId",
|
|
330
|
+
type: "uint256"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
indexed: false,
|
|
334
|
+
internalType: "address",
|
|
335
|
+
name: "serviceAddress",
|
|
336
|
+
type: "address"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
name: "DSServiceSet",
|
|
340
|
+
type: "event"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
anonymous: false,
|
|
344
|
+
inputs: [
|
|
345
|
+
{
|
|
346
|
+
indexed: false,
|
|
347
|
+
internalType: "uint64",
|
|
348
|
+
name: "version",
|
|
349
|
+
type: "uint64"
|
|
350
|
+
}
|
|
351
|
+
],
|
|
352
|
+
name: "Initialized",
|
|
353
|
+
type: "event"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
anonymous: false,
|
|
357
|
+
inputs: [
|
|
358
|
+
{
|
|
359
|
+
indexed: true,
|
|
360
|
+
internalType: "address",
|
|
361
|
+
name: "previousOwner",
|
|
362
|
+
type: "address"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
indexed: true,
|
|
366
|
+
internalType: "address",
|
|
367
|
+
name: "newOwner",
|
|
368
|
+
type: "address"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
name: "OwnershipTransferred",
|
|
372
|
+
type: "event"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
anonymous: false,
|
|
376
|
+
inputs: [
|
|
377
|
+
{
|
|
378
|
+
indexed: true,
|
|
379
|
+
internalType: "address",
|
|
380
|
+
name: "implementation",
|
|
381
|
+
type: "address"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
name: "Upgraded",
|
|
385
|
+
type: "event"
|
|
121
386
|
}
|
|
122
387
|
];
|
|
123
388
|
export {
|
|
@@ -165,7 +165,28 @@ const iSecuritizeKYCFactoryAbi = [
|
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
type: "function",
|
|
168
|
-
name: "
|
|
168
|
+
name: "setAllCreditAccountsFrozenStatus",
|
|
169
|
+
inputs: [
|
|
170
|
+
{ name: "creditManager", type: "address", internalType: "address" },
|
|
171
|
+
{ name: "investor", type: "address", internalType: "address" },
|
|
172
|
+
{ name: "frozen", type: "bool", internalType: "bool" }
|
|
173
|
+
],
|
|
174
|
+
outputs: [],
|
|
175
|
+
stateMutability: "nonpayable"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: "function",
|
|
179
|
+
name: "setAllCreditAccountsFrozenStatus",
|
|
180
|
+
inputs: [
|
|
181
|
+
{ name: "investor", type: "address", internalType: "address" },
|
|
182
|
+
{ name: "frozen", type: "bool", internalType: "bool" }
|
|
183
|
+
],
|
|
184
|
+
outputs: [],
|
|
185
|
+
stateMutability: "nonpayable"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
type: "function",
|
|
189
|
+
name: "setCreditAccountFrozenStatus",
|
|
169
190
|
inputs: [
|
|
170
191
|
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
171
192
|
{ name: "frozen", type: "bool", internalType: "bool" }
|
|
@@ -175,10 +196,31 @@ const iSecuritizeKYCFactoryAbi = [
|
|
|
175
196
|
},
|
|
176
197
|
{
|
|
177
198
|
type: "function",
|
|
178
|
-
name: "
|
|
199
|
+
name: "transferAllCreditAccounts",
|
|
200
|
+
inputs: [
|
|
201
|
+
{ name: "investor", type: "address", internalType: "address" },
|
|
202
|
+
{ name: "newInvestor", type: "address", internalType: "address" }
|
|
203
|
+
],
|
|
204
|
+
outputs: [],
|
|
205
|
+
stateMutability: "nonpayable"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
type: "function",
|
|
209
|
+
name: "transferAllCreditAccounts",
|
|
210
|
+
inputs: [
|
|
211
|
+
{ name: "creditManager", type: "address", internalType: "address" },
|
|
212
|
+
{ name: "investor", type: "address", internalType: "address" },
|
|
213
|
+
{ name: "newInvestor", type: "address", internalType: "address" }
|
|
214
|
+
],
|
|
215
|
+
outputs: [],
|
|
216
|
+
stateMutability: "nonpayable"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
type: "function",
|
|
220
|
+
name: "transferCreditAccount",
|
|
179
221
|
inputs: [
|
|
180
222
|
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
181
|
-
{ name: "
|
|
223
|
+
{ name: "newInvestor", type: "address", internalType: "address" }
|
|
182
224
|
],
|
|
183
225
|
outputs: [],
|
|
184
226
|
stateMutability: "nonpayable"
|
|
@@ -192,7 +234,7 @@ const iSecuritizeKYCFactoryAbi = [
|
|
|
192
234
|
},
|
|
193
235
|
{
|
|
194
236
|
type: "event",
|
|
195
|
-
name: "
|
|
237
|
+
name: "OpenKYCCreditAccount",
|
|
196
238
|
inputs: [
|
|
197
239
|
{
|
|
198
240
|
name: "creditAccount",
|
|
@@ -217,7 +259,7 @@ const iSecuritizeKYCFactoryAbi = [
|
|
|
217
259
|
},
|
|
218
260
|
{
|
|
219
261
|
type: "event",
|
|
220
|
-
name: "
|
|
262
|
+
name: "SetCreditAccountFrozenStatus",
|
|
221
263
|
inputs: [
|
|
222
264
|
{
|
|
223
265
|
name: "creditAccount",
|
|
@@ -231,7 +273,7 @@ const iSecuritizeKYCFactoryAbi = [
|
|
|
231
273
|
},
|
|
232
274
|
{
|
|
233
275
|
type: "event",
|
|
234
|
-
name: "
|
|
276
|
+
name: "TransferCreditAccount",
|
|
235
277
|
inputs: [
|
|
236
278
|
{
|
|
237
279
|
name: "creditAccount",
|
|
@@ -281,6 +323,11 @@ const iSecuritizeKYCFactoryAbi = [
|
|
|
281
323
|
name: "InvalidUnderlyingTokenException",
|
|
282
324
|
inputs: [{ name: "underlying", type: "address", internalType: "address" }]
|
|
283
325
|
},
|
|
326
|
+
{
|
|
327
|
+
type: "error",
|
|
328
|
+
name: "TooManyCreditAccountsException",
|
|
329
|
+
inputs: [{ name: "investor", type: "address", internalType: "address" }]
|
|
330
|
+
},
|
|
284
331
|
{
|
|
285
332
|
type: "error",
|
|
286
333
|
name: "UnknownCreditAccountException",
|
|
@@ -9,16 +9,24 @@ function assembleOperations(input) {
|
|
|
9
9
|
underlying,
|
|
10
10
|
liquidationRemainingFunds,
|
|
11
11
|
phantomTokens,
|
|
12
|
+
withdrawCollateralEvents = [],
|
|
12
13
|
strict
|
|
13
14
|
} = input;
|
|
14
|
-
let
|
|
15
|
+
let executeOffset = 0;
|
|
16
|
+
let withdrawOffset = 0;
|
|
15
17
|
return facadeCalls.map((fc) => {
|
|
16
18
|
if (fc.operation === "PartiallyLiquidateCreditAccount") {
|
|
17
19
|
return assemblePartialLiquidation(fc);
|
|
18
20
|
}
|
|
19
21
|
const count = countAdapterCalls(fc.innerCalls, register);
|
|
20
|
-
const sliced = executeResults.slice(
|
|
21
|
-
|
|
22
|
+
const sliced = executeResults.slice(executeOffset, executeOffset + count);
|
|
23
|
+
executeOffset += count;
|
|
24
|
+
const withdrawCount = countWithdrawCollateralCalls(fc.innerCalls);
|
|
25
|
+
const slicedWithdrawEvents = withdrawCollateralEvents.slice(
|
|
26
|
+
withdrawOffset,
|
|
27
|
+
withdrawOffset + withdrawCount
|
|
28
|
+
);
|
|
29
|
+
withdrawOffset += withdrawCount;
|
|
22
30
|
const protocolCalldatas = extractProtocolCalls(fc.trace, sliced);
|
|
23
31
|
const multicall = classifyMulticallOperations({
|
|
24
32
|
innerCalls: fc.innerCalls,
|
|
@@ -28,7 +36,8 @@ function assembleOperations(input) {
|
|
|
28
36
|
creditAccount: fc.creditAccount,
|
|
29
37
|
underlying,
|
|
30
38
|
strict,
|
|
31
|
-
phantomTokens
|
|
39
|
+
phantomTokens,
|
|
40
|
+
withdrawCollateralEvents: slicedWithdrawEvents
|
|
32
41
|
});
|
|
33
42
|
switch (fc.operation) {
|
|
34
43
|
case "OpenCreditAccount":
|
|
@@ -63,6 +72,11 @@ function countAdapterCalls(innerCalls, register) {
|
|
|
63
72
|
return !contract || contract instanceof AbstractAdapterContract;
|
|
64
73
|
}).length;
|
|
65
74
|
}
|
|
75
|
+
function countWithdrawCollateralCalls(innerCalls) {
|
|
76
|
+
return innerCalls.filter(
|
|
77
|
+
(call) => call.functionName.startsWith("withdrawCollateral")
|
|
78
|
+
).length;
|
|
79
|
+
}
|
|
66
80
|
function assemblePartialLiquidation(fc) {
|
|
67
81
|
const { rawArgs } = fc.parsed;
|
|
68
82
|
return {
|
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
swapFromTransfers,
|
|
5
5
|
toNetTransfers
|
|
6
6
|
} from "../plugins/adapters/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
TransferAlignmentError,
|
|
9
|
+
UnknownAdapterError,
|
|
10
|
+
WithdrawCollateralAlignmentError
|
|
11
|
+
} from "./errors.js";
|
|
8
12
|
function classifyMulticallOperations(input) {
|
|
9
13
|
const {
|
|
10
14
|
innerCalls,
|
|
@@ -14,9 +18,11 @@ function classifyMulticallOperations(input) {
|
|
|
14
18
|
creditAccount,
|
|
15
19
|
underlying,
|
|
16
20
|
strict,
|
|
17
|
-
phantomTokens
|
|
21
|
+
phantomTokens,
|
|
22
|
+
withdrawCollateralEvents
|
|
18
23
|
} = input;
|
|
19
24
|
let transferIdx = 0;
|
|
25
|
+
let withdrawIdx = 0;
|
|
20
26
|
const result = [];
|
|
21
27
|
for (const call of innerCalls) {
|
|
22
28
|
const contract = register.getContract(call.target);
|
|
@@ -39,7 +45,14 @@ function classifyMulticallOperations(input) {
|
|
|
39
45
|
continue;
|
|
40
46
|
}
|
|
41
47
|
if (contract !== void 0) {
|
|
42
|
-
const
|
|
48
|
+
const isWithdraw = call.functionName.startsWith("withdrawCollateral");
|
|
49
|
+
const withdrawEvent = isWithdraw ? withdrawCollateralEvents?.[withdrawIdx++] : void 0;
|
|
50
|
+
const op = classifyFacadeInnerCall(
|
|
51
|
+
call,
|
|
52
|
+
underlying,
|
|
53
|
+
phantomTokens,
|
|
54
|
+
withdrawEvent
|
|
55
|
+
);
|
|
43
56
|
if (op) result.push(op);
|
|
44
57
|
continue;
|
|
45
58
|
}
|
|
@@ -74,9 +87,15 @@ function classifyMulticallOperations(input) {
|
|
|
74
87
|
if (transferIdx !== executeResults.length) {
|
|
75
88
|
throw new TransferAlignmentError(executeResults.length, transferIdx);
|
|
76
89
|
}
|
|
90
|
+
if (withdrawCollateralEvents && withdrawCollateralEvents.length > 0 && withdrawIdx !== withdrawCollateralEvents.length) {
|
|
91
|
+
throw new WithdrawCollateralAlignmentError(
|
|
92
|
+
withdrawCollateralEvents.length,
|
|
93
|
+
withdrawIdx
|
|
94
|
+
);
|
|
95
|
+
}
|
|
77
96
|
return result;
|
|
78
97
|
}
|
|
79
|
-
function classifyFacadeInnerCall(call, underlying, phantomTokens) {
|
|
98
|
+
function classifyFacadeInnerCall(call, underlying, phantomTokens, withdrawEvent) {
|
|
80
99
|
const { functionName: sig, rawArgs } = call;
|
|
81
100
|
const functionName = sig.split("(")[0];
|
|
82
101
|
switch (functionName) {
|
|
@@ -105,10 +124,11 @@ function classifyFacadeInnerCall(call, underlying, phantomTokens) {
|
|
|
105
124
|
calldataToken,
|
|
106
125
|
phantomTokens
|
|
107
126
|
);
|
|
127
|
+
const amount = withdrawEvent ? withdrawEvent.amount : rawArgs.amount;
|
|
108
128
|
return {
|
|
109
129
|
operation: "WithdrawCollateral",
|
|
110
130
|
token: depositedToken ?? calldataToken,
|
|
111
|
-
amount
|
|
131
|
+
amount,
|
|
112
132
|
to: rawArgs.to,
|
|
113
133
|
...depositedToken ? { phantomToken: calldataToken } : {}
|
|
114
134
|
};
|
|
@@ -14,6 +14,14 @@ class TransferAlignmentError extends Error {
|
|
|
14
14
|
this.name = "TransferAlignmentError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
class WithdrawCollateralAlignmentError extends Error {
|
|
18
|
+
constructor(expected, actual) {
|
|
19
|
+
super(
|
|
20
|
+
`withdrawCollateral event alignment mismatch: expected ${expected} events, consumed ${actual}`
|
|
21
|
+
);
|
|
22
|
+
this.name = "WithdrawCollateralAlignmentError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
17
25
|
class ProtocolCallNotFoundError extends Error {
|
|
18
26
|
targetContract;
|
|
19
27
|
executeIndex;
|
|
@@ -60,5 +68,6 @@ export {
|
|
|
60
68
|
TransferAlignmentError,
|
|
61
69
|
UnexpectedFacadeEventOrderError,
|
|
62
70
|
UnknownAdapterError,
|
|
63
|
-
UnknownFacadeCallError
|
|
71
|
+
UnknownFacadeCallError,
|
|
72
|
+
WithdrawCollateralAlignmentError
|
|
64
73
|
};
|
|
@@ -13,6 +13,7 @@ function extractTransfers(logs, creditAccount, pool, creditFacade) {
|
|
|
13
13
|
const executeResults = [];
|
|
14
14
|
const directTransfers = [];
|
|
15
15
|
const phantomTokens = new AddressMap();
|
|
16
|
+
const withdrawCollateralEvents = [];
|
|
16
17
|
let liquidationRemainingFunds;
|
|
17
18
|
for (const log of logs) {
|
|
18
19
|
const facadeEvent = tryDecodeFacadeEvent(log, creditFacade);
|
|
@@ -43,6 +44,12 @@ function extractTransfers(logs, creditAccount, pool, creditFacade) {
|
|
|
43
44
|
facadeEvent.args.token,
|
|
44
45
|
getAddress(rawDeposit.token)
|
|
45
46
|
);
|
|
47
|
+
} else if (isWithdrawCollateral(facadeEvent, creditAccount)) {
|
|
48
|
+
withdrawCollateralEvents.push({
|
|
49
|
+
token: getAddress(facadeEvent.args.token),
|
|
50
|
+
amount: facadeEvent.args.amount,
|
|
51
|
+
to: getAddress(facadeEvent.args.to)
|
|
52
|
+
});
|
|
46
53
|
}
|
|
47
54
|
currentEntries = [];
|
|
48
55
|
continue;
|
|
@@ -67,7 +74,8 @@ function extractTransfers(logs, creditAccount, pool, creditFacade) {
|
|
|
67
74
|
executeResults,
|
|
68
75
|
directTransfers,
|
|
69
76
|
liquidationRemainingFunds,
|
|
70
|
-
phantomTokens
|
|
77
|
+
phantomTokens,
|
|
78
|
+
withdrawCollateralEvents
|
|
71
79
|
};
|
|
72
80
|
}
|
|
73
81
|
function buildOperationRanges(logs, facadeAddress, creditAccount) {
|
|
@@ -143,6 +151,9 @@ function isLiquidation(e, creditAccount) {
|
|
|
143
151
|
function isWithdrawPhantomToken(e, creditAccount) {
|
|
144
152
|
return e.eventName === "WithdrawPhantomToken" && isAddressEqual(e.args.creditAccount, creditAccount);
|
|
145
153
|
}
|
|
154
|
+
function isWithdrawCollateral(e, creditAccount) {
|
|
155
|
+
return e.eventName === "WithdrawCollateral" && isAddressEqual(e.args.creditAccount, creditAccount);
|
|
156
|
+
}
|
|
146
157
|
export {
|
|
147
158
|
extractTransfers
|
|
148
159
|
};
|
|
@@ -28,7 +28,8 @@ function parseCreditAccountTransaction(input) {
|
|
|
28
28
|
executeResults,
|
|
29
29
|
directTransfers,
|
|
30
30
|
liquidationRemainingFunds,
|
|
31
|
-
phantomTokens
|
|
31
|
+
phantomTokens,
|
|
32
|
+
withdrawCollateralEvents
|
|
32
33
|
} = extractTransfers(logs, creditAccount, pool, creditFacade);
|
|
33
34
|
const meta = {
|
|
34
35
|
creditManager,
|
|
@@ -44,6 +45,7 @@ function parseCreditAccountTransaction(input) {
|
|
|
44
45
|
underlying,
|
|
45
46
|
liquidationRemainingFunds,
|
|
46
47
|
phantomTokens,
|
|
48
|
+
withdrawCollateralEvents,
|
|
47
49
|
strict
|
|
48
50
|
}).map((o) => ({ ...o, ...meta }));
|
|
49
51
|
const directOps = directTransfers.map((dt) => ({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { iSecuritizeDegenNFTAbi } from "../../../../abi/kyc/iSecuritizeDegenNFT.js";
|
|
2
|
+
import { BaseContract } from "../../../base/index.js";
|
|
3
|
+
const abi = iSecuritizeDegenNFTAbi;
|
|
4
|
+
class SecuritizeDegenNFT extends BaseContract {
|
|
5
|
+
constructor(sdk, address) {
|
|
6
|
+
super(sdk, {
|
|
7
|
+
addr: address,
|
|
8
|
+
contractType: "DEGEN_NFT::SECURITIZE",
|
|
9
|
+
version: 310,
|
|
10
|
+
name: "SecuritizeDegenNFT",
|
|
11
|
+
abi
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
SecuritizeDegenNFT
|
|
17
|
+
};
|
|
@@ -3,6 +3,7 @@ import { iSecuritizeKYCFactoryAbi } from "../../../../abi/kyc/iSecuritizeKYCFact
|
|
|
3
3
|
import { BaseContract } from "../../../base/index.js";
|
|
4
4
|
import { AddressMap, AddressSet } from "../../../utils/index.js";
|
|
5
5
|
import { KYC_FACTORY_SECURITIZE } from "./constants.js";
|
|
6
|
+
import { SecuritizeDegenNFT } from "./SecuritizeDegenNFT.js";
|
|
6
7
|
import {
|
|
7
8
|
SECURITIZE_REGISTER_VAULT_TYPES
|
|
8
9
|
} from "./types.js";
|
|
@@ -38,7 +39,7 @@ class SecuritizeKYCFactory extends BaseContract {
|
|
|
38
39
|
data.baseParams.serializedParams
|
|
39
40
|
);
|
|
40
41
|
this.owner = decoded[0];
|
|
41
|
-
this.degenNFT = decoded[1];
|
|
42
|
+
this.degenNFT = new SecuritizeDegenNFT(sdk, decoded[1]);
|
|
42
43
|
for (const t of data.tokens) {
|
|
43
44
|
this.tokensMeta.upsert(t.addr, t);
|
|
44
45
|
}
|
|
@@ -182,7 +183,7 @@ class SecuritizeKYCFactory extends BaseContract {
|
|
|
182
183
|
return {
|
|
183
184
|
...super.stateHuman(_raw),
|
|
184
185
|
owner: this.labelAddress(this.owner),
|
|
185
|
-
degenNFT: this.labelAddress(this.degenNFT),
|
|
186
|
+
degenNFT: this.labelAddress(this.degenNFT.address),
|
|
186
187
|
dsTokens: this.dsTokens.map((t) => ({
|
|
187
188
|
...this.tokensMeta.mustGet(t.address),
|
|
188
189
|
registrar: this.labelAddress(t.registrar),
|