@gearbox-protocol/sdk 13.4.0 → 13.5.0-next.1
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/310/iSecuritizeDegenNFT.js +263 -0
- package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +278 -0
- package/dist/cjs/{sdk/pools/PoolServiceV310.js → abi/iStateSerializer.js} +14 -8
- package/dist/cjs/dev/AccountOpener.js +45 -5
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +375 -13
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -5
- package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -1
- package/dist/cjs/sdk/base/TokensMeta.js +255 -32
- package/dist/cjs/sdk/base/index.js +2 -0
- package/dist/cjs/sdk/{constants/phantom-tokens.js → base/token-types.js} +9 -3
- package/dist/cjs/sdk/chain/chains.js +2 -1
- package/dist/cjs/sdk/constants/index.js +0 -2
- package/dist/cjs/sdk/market/MarketRegister.js +5 -2
- package/dist/cjs/sdk/market/MarketSuite.js +6 -0
- package/dist/cjs/{plugins/zappers/extraZappers.js → sdk/market/ZapperRegister.js} +110 -6
- package/dist/cjs/sdk/market/index.js +3 -1
- package/dist/cjs/sdk/market/pool/PoolSuite.js +3 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +17 -2
- package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +97 -0
- package/dist/cjs/sdk/market/pool/index.js +4 -0
- package/dist/cjs/sdk/pools/PoolService.js +391 -0
- package/dist/cjs/sdk/pools/index.js +2 -4
- package/dist/esm/abi/310/iSecuritizeDegenNFT.js +239 -0
- package/dist/esm/abi/310/iSecuritizeKYCFactory.js +254 -0
- package/dist/esm/abi/iStateSerializer.js +12 -0
- package/dist/esm/dev/AccountOpener.js +47 -6
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +375 -13
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +16 -5
- package/dist/esm/sdk/base/ChainContractsRegister.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +261 -32
- package/dist/esm/sdk/base/index.js +1 -0
- package/dist/esm/sdk/{constants/phantom-tokens.js → base/token-types.js} +4 -0
- package/dist/esm/sdk/chain/chains.js +2 -1
- package/dist/esm/sdk/constants/index.js +0 -1
- package/dist/esm/sdk/market/MarketRegister.js +5 -2
- package/dist/esm/sdk/market/MarketSuite.js +6 -0
- package/dist/esm/{plugins/zappers/extraZappers.js → sdk/market/ZapperRegister.js} +109 -2
- package/dist/esm/sdk/market/index.js +1 -0
- package/dist/esm/sdk/market/pool/PoolSuite.js +3 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +17 -2
- package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +73 -0
- package/dist/esm/sdk/market/pool/index.js +2 -0
- package/dist/esm/sdk/pools/PoolService.js +371 -0
- package/dist/esm/sdk/pools/index.js +1 -2
- package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +324 -0
- package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +322 -0
- package/dist/types/abi/iStateSerializer.d.ts +11 -0
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +114 -3
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +96 -6
- package/dist/types/sdk/base/TokensMeta.d.ts +34 -21
- package/dist/types/sdk/base/index.d.ts +1 -0
- package/dist/types/sdk/base/token-types.d.ts +33 -0
- package/dist/types/sdk/base/types.d.ts +0 -7
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/constants/index.d.ts +0 -1
- package/dist/types/sdk/market/MarketRegister.d.ts +2 -2
- package/dist/types/sdk/market/MarketSuite.d.ts +3 -0
- package/dist/types/sdk/market/ZapperRegister.d.ts +17 -0
- package/dist/types/sdk/market/index.d.ts +1 -0
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +6 -2
- package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +345 -0
- package/dist/types/sdk/market/pool/index.d.ts +2 -0
- package/dist/types/sdk/market/types.d.ts +10 -0
- package/dist/types/sdk/pools/PoolService.d.ts +14 -0
- package/dist/types/sdk/pools/index.d.ts +1 -2
- package/dist/types/sdk/pools/types.d.ts +85 -111
- package/package.json +1 -1
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +0 -144
- package/dist/cjs/plugins/zappers/index.js +0 -26
- package/dist/cjs/plugins/zappers/package.json +0 -1
- package/dist/cjs/sdk/pools/AbstractPoolService.js +0 -143
- package/dist/cjs/sdk/pools/createPoolService.js +0 -35
- package/dist/esm/plugins/zappers/ZappersPlugin.js +0 -126
- package/dist/esm/plugins/zappers/index.js +0 -3
- package/dist/esm/plugins/zappers/package.json +0 -1
- package/dist/esm/sdk/pools/AbstractPoolService.js +0 -119
- package/dist/esm/sdk/pools/PoolServiceV310.js +0 -6
- package/dist/esm/sdk/pools/createPoolService.js +0 -11
- package/dist/types/plugins/zappers/ZappersPlugin.d.ts +0 -18
- package/dist/types/plugins/zappers/extraZappers.d.ts +0 -6
- package/dist/types/plugins/zappers/index.d.ts +0 -3
- package/dist/types/plugins/zappers/types.d.ts +0 -12
- package/dist/types/sdk/constants/phantom-tokens.d.ts +0 -2
- package/dist/types/sdk/pools/AbstractPoolService.d.ts +0 -21
- package/dist/types/sdk/pools/PoolServiceV310.d.ts +0 -4
- package/dist/types/sdk/pools/createPoolService.d.ts +0 -3
- /package/dist/cjs/{plugins/zappers → sdk/market}/types.js +0 -0
- /package/dist/esm/{plugins/zappers → sdk/market}/types.js +0 -0
|
@@ -21,21 +21,39 @@ __export(TokensMeta_exports, {
|
|
|
21
21
|
TokensMeta: () => TokensMeta
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(TokensMeta_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_iSecuritizeDegenNFT = require("../../abi/310/iSecuritizeDegenNFT.js");
|
|
26
|
+
var import_iSecuritizeKYCFactory = require("../../abi/310/iSecuritizeKYCFactory.js");
|
|
27
|
+
var import_iStateSerializer = require("../../abi/iStateSerializer.js");
|
|
24
28
|
var import_iVersion = require("../../abi/iVersion.js");
|
|
25
29
|
var import_utils = require("../utils/index.js");
|
|
30
|
+
var import_token_types = require("./token-types.js");
|
|
26
31
|
class TokensMeta extends import_utils.AddressMap {
|
|
27
32
|
#client;
|
|
28
|
-
#
|
|
29
|
-
|
|
33
|
+
#tokenDataLoaded = new import_utils.AddressSet();
|
|
34
|
+
#logger;
|
|
35
|
+
constructor(client, logger) {
|
|
30
36
|
super(void 0, "tokensMeta");
|
|
31
37
|
this.#client = client;
|
|
38
|
+
this.#logger = logger?.child?.({ name: "TokensMeta" }) ?? logger;
|
|
32
39
|
}
|
|
33
40
|
/**
|
|
34
41
|
* Clears all token metadata
|
|
35
42
|
**/
|
|
36
43
|
reset() {
|
|
37
44
|
this.clear();
|
|
38
|
-
this.#
|
|
45
|
+
this.#tokenDataLoaded.clear();
|
|
46
|
+
}
|
|
47
|
+
upsert(address, value) {
|
|
48
|
+
let v = value;
|
|
49
|
+
const existing = this.get(address);
|
|
50
|
+
if (existing && v) {
|
|
51
|
+
v = {
|
|
52
|
+
...existing,
|
|
53
|
+
...v
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
super.upsert(address, v);
|
|
39
57
|
}
|
|
40
58
|
/**
|
|
41
59
|
* Returns the symbol string for a token.
|
|
@@ -54,27 +72,78 @@ class TokensMeta extends import_utils.AddressMap {
|
|
|
54
72
|
return this.mustGet(token).decimals;
|
|
55
73
|
}
|
|
56
74
|
/**
|
|
57
|
-
* Returns the
|
|
58
|
-
*
|
|
75
|
+
* Returns true if the token is a phantom token, throws if the token data is not loaded
|
|
76
|
+
* @param t
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
isPhantomToken(t) {
|
|
80
|
+
if (!this.#tokenDataLoaded.has(t.addr)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`extended token data not loaded for ${t.symbol} (${t.addr})`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return !!t.contractType?.startsWith("PHANTOM_TOKEN::");
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns true if the token is a KYC underlying token, throws if the token data is not loaded
|
|
89
|
+
* @param t
|
|
90
|
+
* @returns
|
|
59
91
|
*/
|
|
60
|
-
|
|
61
|
-
if (!this.#
|
|
62
|
-
throw new Error(
|
|
92
|
+
isKYCUnderlying(t) {
|
|
93
|
+
if (!this.#tokenDataLoaded.has(t.addr)) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`extended token data not loaded for ${t.symbol} (${t.addr})`
|
|
96
|
+
);
|
|
63
97
|
}
|
|
64
|
-
return
|
|
98
|
+
return !!t.contractType?.startsWith("KYC_UNDERLYING::");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns true if the token is a DSToken, throws if the token data is not loaded
|
|
102
|
+
* @param t
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
isDSToken(t) {
|
|
106
|
+
if (!this.#tokenDataLoaded.has(t.addr)) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`extended token data not loaded for ${t.symbol} (${t.addr})`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return !!t.isDSToken;
|
|
65
112
|
}
|
|
66
113
|
/**
|
|
67
114
|
* Returns a map of all phantom tokens
|
|
68
|
-
* Throws if
|
|
115
|
+
* Throws if token data is not loaded
|
|
69
116
|
*/
|
|
70
117
|
get phantomTokens() {
|
|
71
|
-
|
|
72
|
-
|
|
118
|
+
const result = new import_utils.AddressMap();
|
|
119
|
+
for (const [token, meta] of this.entries()) {
|
|
120
|
+
if (this.isPhantomToken(meta)) {
|
|
121
|
+
result.upsert(token, meta);
|
|
122
|
+
}
|
|
73
123
|
}
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns a map of all KYC underlying tokens
|
|
128
|
+
* Throws if token data is not loaded
|
|
129
|
+
*/
|
|
130
|
+
get kycUnderlyings() {
|
|
131
|
+
const result = new import_utils.AddressMap();
|
|
132
|
+
for (const [token, meta] of this.entries()) {
|
|
133
|
+
if (this.isKYCUnderlying(meta)) {
|
|
134
|
+
result.upsert(token, meta);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
get dsTokens() {
|
|
140
|
+
const result = new import_utils.AddressMap();
|
|
141
|
+
for (const [token, meta] of this.entries()) {
|
|
142
|
+
if (this.isDSToken(meta)) {
|
|
143
|
+
result.upsert(token, meta);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
78
147
|
}
|
|
79
148
|
formatBN(arg0, arg1, arg2) {
|
|
80
149
|
const token = typeof arg0 === "object" ? arg0.token : arg0;
|
|
@@ -105,30 +174,184 @@ class TokensMeta extends import_utils.AddressMap {
|
|
|
105
174
|
return meta;
|
|
106
175
|
}
|
|
107
176
|
/**
|
|
108
|
-
* Loads
|
|
177
|
+
* Loads token information about phantom tokens, KYC underlying tokens and DSTokens
|
|
178
|
+
*
|
|
179
|
+
* @param tokens - tokens to load data for, defaults to all tokens
|
|
109
180
|
*/
|
|
110
|
-
async
|
|
111
|
-
|
|
112
|
-
const
|
|
181
|
+
async loadTokenData(...tokens) {
|
|
182
|
+
const tokenz = new import_utils.AddressSet(tokens.length > 0 ? tokens : this.keys());
|
|
183
|
+
const tokensToLoad = Array.from(tokenz.difference(this.#tokenDataLoaded));
|
|
184
|
+
if (tokensToLoad.length === 0) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
113
187
|
const resp = await this.#client.multicall({
|
|
114
|
-
contracts:
|
|
115
|
-
(t) =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
188
|
+
contracts: tokensToLoad.flatMap(
|
|
189
|
+
(t) => [
|
|
190
|
+
{
|
|
191
|
+
address: t,
|
|
192
|
+
abi: import_iVersion.iVersionAbi,
|
|
193
|
+
functionName: "contractType"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
address: t,
|
|
197
|
+
abi: import_iStateSerializer.iStateSerializerAbi,
|
|
198
|
+
functionName: "serialize"
|
|
199
|
+
}
|
|
200
|
+
]
|
|
120
201
|
),
|
|
121
202
|
allowFailure: true,
|
|
122
203
|
batchSize: 0
|
|
123
204
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
205
|
+
this.#logger?.debug(`loaded ${resp.length} contract types`);
|
|
206
|
+
const kycFactories = new import_utils.AddressSet();
|
|
207
|
+
for (let i = 0; i < tokensToLoad.length; i++) {
|
|
208
|
+
const meta = this.#overrideTokenMeta(
|
|
209
|
+
tokensToLoad[i],
|
|
210
|
+
resp[2 * i],
|
|
211
|
+
resp[2 * i + 1]
|
|
212
|
+
);
|
|
213
|
+
this.#tokenDataLoaded.add(tokensToLoad[i]);
|
|
214
|
+
if (this.isKYCUnderlying(meta)) {
|
|
215
|
+
kycFactories.add(meta.kycFactory);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
this.#logger?.debug(`found ${kycFactories.size} KYC factories`);
|
|
219
|
+
await this.#loadDSTokens(kycFactories);
|
|
220
|
+
}
|
|
221
|
+
#overrideTokenMeta(token, contractTypeResp, serializeResp) {
|
|
222
|
+
const meta = this.mustGet(token);
|
|
223
|
+
if (contractTypeResp.status === "success") {
|
|
224
|
+
const contractType = (0, import_utils.bytes32ToString)(contractTypeResp.result);
|
|
225
|
+
if (contractType.startsWith("KYC_UNDERLYING::")) {
|
|
226
|
+
if (serializeResp.status === "success") {
|
|
227
|
+
this.#overrideKYCUnderlying(meta, contractType, serializeResp.result);
|
|
228
|
+
} else {
|
|
229
|
+
throw new Error(
|
|
230
|
+
`token ${meta.symbol} (${token}) is ${contractType} but serialize failed: ${serializeResp.error}`
|
|
231
|
+
);
|
|
129
232
|
}
|
|
233
|
+
} else {
|
|
234
|
+
this.upsert(token, {
|
|
235
|
+
...meta,
|
|
236
|
+
contractType
|
|
237
|
+
});
|
|
130
238
|
}
|
|
131
|
-
this.#
|
|
239
|
+
this.#logger?.debug(`token ${meta.symbol} is ${contractType}`);
|
|
240
|
+
}
|
|
241
|
+
return this.mustGet(token);
|
|
242
|
+
}
|
|
243
|
+
#overrideKYCUnderlying(meta, contractType, serialized) {
|
|
244
|
+
if (contractType === import_token_types.KYC_UNDERLYING_DEFAULT) {
|
|
245
|
+
const decoded = (0, import_viem.decodeAbiParameters)(
|
|
246
|
+
[
|
|
247
|
+
{ type: "address", name: "kycFactory" },
|
|
248
|
+
{ type: "address", name: "asset" }
|
|
249
|
+
],
|
|
250
|
+
serialized
|
|
251
|
+
);
|
|
252
|
+
this.upsert(meta.addr, {
|
|
253
|
+
...meta,
|
|
254
|
+
contractType,
|
|
255
|
+
kycFactory: decoded[0],
|
|
256
|
+
asset: decoded[1]
|
|
257
|
+
});
|
|
258
|
+
} else if (contractType === import_token_types.KYC_UNDERLYING_ON_DEMAND) {
|
|
259
|
+
const decoded = (0, import_viem.decodeAbiParameters)(
|
|
260
|
+
[
|
|
261
|
+
{ type: "address", name: "kycFactory" },
|
|
262
|
+
{ type: "address", name: "asset" },
|
|
263
|
+
{ type: "address", name: "pool" },
|
|
264
|
+
{ type: "address", name: "liquidityProvider" }
|
|
265
|
+
],
|
|
266
|
+
serialized
|
|
267
|
+
);
|
|
268
|
+
this.upsert(meta.addr, {
|
|
269
|
+
...meta,
|
|
270
|
+
contractType,
|
|
271
|
+
kycFactory: decoded[0],
|
|
272
|
+
asset: decoded[1],
|
|
273
|
+
pool: decoded[2],
|
|
274
|
+
liquidityProvider: decoded[3]
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async #loadDSTokens(kycFactories) {
|
|
279
|
+
const degenNFTs = await this.#client.multicall({
|
|
280
|
+
contracts: kycFactories.map((address) => {
|
|
281
|
+
return {
|
|
282
|
+
address,
|
|
283
|
+
abi: import_iSecuritizeKYCFactory.iSecuritizeKYCFactoryAbi,
|
|
284
|
+
functionName: "getDegenNFT"
|
|
285
|
+
};
|
|
286
|
+
}),
|
|
287
|
+
allowFailure: false,
|
|
288
|
+
batchSize: 0
|
|
289
|
+
});
|
|
290
|
+
const resp = await this.#client.multicall({
|
|
291
|
+
contracts: degenNFTs.map((address) => {
|
|
292
|
+
return {
|
|
293
|
+
address,
|
|
294
|
+
abi: import_iSecuritizeDegenNFT.iSecuritizeDegenNFTAbi,
|
|
295
|
+
functionName: "getDSTokens"
|
|
296
|
+
};
|
|
297
|
+
}),
|
|
298
|
+
allowFailure: false,
|
|
299
|
+
batchSize: 0
|
|
300
|
+
});
|
|
301
|
+
const dsToken = new import_utils.AddressSet(resp.flat());
|
|
302
|
+
const tokensToLoad = dsToken.difference(new Set(this.keys()));
|
|
303
|
+
this.#logger?.debug(
|
|
304
|
+
`found ${dsToken.size} DSTokens in KYC factories, need to load ${tokensToLoad.size} basic metadata`
|
|
305
|
+
);
|
|
306
|
+
await this.#loadWithoutCompressor(tokensToLoad);
|
|
307
|
+
for (const token of dsToken) {
|
|
308
|
+
const meta = this.mustGet(token);
|
|
309
|
+
this.upsert(token, {
|
|
310
|
+
...meta,
|
|
311
|
+
isDSToken: true
|
|
312
|
+
});
|
|
313
|
+
this.#tokenDataLoaded.add(token);
|
|
314
|
+
this.#logger?.debug(`token ${meta.symbol} (${token}) is a DSToken`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
async #loadWithoutCompressor(tokens_) {
|
|
318
|
+
if (tokens_.size === 0) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const tokens = Array.from(tokens_);
|
|
322
|
+
const resp = await this.#client.multicall({
|
|
323
|
+
contracts: tokens.flatMap(
|
|
324
|
+
(t) => [
|
|
325
|
+
{
|
|
326
|
+
address: t,
|
|
327
|
+
abi: import_viem.erc20Abi,
|
|
328
|
+
functionName: "symbol"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
address: t,
|
|
332
|
+
abi: import_viem.erc20Abi,
|
|
333
|
+
functionName: "name"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
address: t,
|
|
337
|
+
abi: import_viem.erc20Abi,
|
|
338
|
+
functionName: "decimals"
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
),
|
|
342
|
+
allowFailure: false,
|
|
343
|
+
batchSize: 0
|
|
344
|
+
});
|
|
345
|
+
this.#logger?.debug(
|
|
346
|
+
`loaded ${resp.length} basic metadata without compressor`
|
|
347
|
+
);
|
|
348
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
349
|
+
this.upsert(tokens[i], {
|
|
350
|
+
addr: tokens[i],
|
|
351
|
+
symbol: resp[3 * i],
|
|
352
|
+
name: resp[3 * i + 1],
|
|
353
|
+
decimals: resp[3 * i + 2]
|
|
354
|
+
});
|
|
132
355
|
}
|
|
133
356
|
}
|
|
134
357
|
}
|
|
@@ -22,6 +22,7 @@ __reExport(base_exports, require("./errors.js"), module.exports);
|
|
|
22
22
|
__reExport(base_exports, require("./PlaceholderContract.js"), module.exports);
|
|
23
23
|
__reExport(base_exports, require("./SDKConstruct.js"), module.exports);
|
|
24
24
|
__reExport(base_exports, require("./TokensMeta.js"), module.exports);
|
|
25
|
+
__reExport(base_exports, require("./token-types.js"), module.exports);
|
|
25
26
|
__reExport(base_exports, require("./types.js"), module.exports);
|
|
26
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
28
|
0 && (module.exports = {
|
|
@@ -32,5 +33,6 @@ __reExport(base_exports, require("./types.js"), module.exports);
|
|
|
32
33
|
...require("./PlaceholderContract.js"),
|
|
33
34
|
...require("./SDKConstruct.js"),
|
|
34
35
|
...require("./TokensMeta.js"),
|
|
36
|
+
...require("./token-types.js"),
|
|
35
37
|
...require("./types.js")
|
|
36
38
|
});
|
|
@@ -16,11 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var token_types_exports = {};
|
|
20
|
+
__export(token_types_exports, {
|
|
21
|
+
KYC_UNDERLYING_DEFAULT: () => KYC_UNDERLYING_DEFAULT,
|
|
22
|
+
KYC_UNDERLYING_ON_DEMAND: () => KYC_UNDERLYING_ON_DEMAND,
|
|
21
23
|
PHANTOM_TOKEN_CONTRACT_TYPES: () => PHANTOM_TOKEN_CONTRACT_TYPES
|
|
22
24
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(token_types_exports);
|
|
24
26
|
const PHANTOM_TOKEN_CONTRACT_TYPES = [
|
|
25
27
|
"PHANTOM_TOKEN::CONVEX",
|
|
26
28
|
"PHANTOM_TOKEN::INFINIFI_UNWIND",
|
|
@@ -30,7 +32,11 @@ const PHANTOM_TOKEN_CONTRACT_TYPES = [
|
|
|
30
32
|
"PHANTOM_TOKEN::STAKING_REWARDS",
|
|
31
33
|
"PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
|
|
32
34
|
];
|
|
35
|
+
const KYC_UNDERLYING_DEFAULT = "KYC_UNDERLYING::DEFAULT";
|
|
36
|
+
const KYC_UNDERLYING_ON_DEMAND = "KYC_UNDERLYING::ON_DEMAND";
|
|
33
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
38
|
0 && (module.exports = {
|
|
39
|
+
KYC_UNDERLYING_DEFAULT,
|
|
40
|
+
KYC_UNDERLYING_ON_DEMAND,
|
|
35
41
|
PHANTOM_TOKEN_CONTRACT_TYPES
|
|
36
42
|
});
|
|
@@ -79,7 +79,8 @@ const chains = {
|
|
|
79
79
|
"0x601067eba24bb5b558a184fc082525637e96a42d": "Gami Labs"
|
|
80
80
|
},
|
|
81
81
|
testMarketConfigurators: {
|
|
82
|
-
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit"
|
|
82
|
+
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit",
|
|
83
|
+
"0xE0527dE5908B3fc2e054B7eEE0DeF6c9965AbF24": "Securitize"
|
|
83
84
|
},
|
|
84
85
|
isPublic: true,
|
|
85
86
|
wellKnownToken: {
|
|
@@ -21,7 +21,6 @@ __reExport(constants_exports, require("./bot-permissions.js"), module.exports);
|
|
|
21
21
|
__reExport(constants_exports, require("./math.js"), module.exports);
|
|
22
22
|
__reExport(constants_exports, require("./networks.js"), module.exports);
|
|
23
23
|
__reExport(constants_exports, require("./periphery.js"), module.exports);
|
|
24
|
-
__reExport(constants_exports, require("./phantom-tokens.js"), module.exports);
|
|
25
24
|
__reExport(constants_exports, require("./versions.js"), module.exports);
|
|
26
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
26
|
0 && (module.exports = {
|
|
@@ -31,6 +30,5 @@ __reExport(constants_exports, require("./versions.js"), module.exports);
|
|
|
31
30
|
...require("./math.js"),
|
|
32
31
|
...require("./networks.js"),
|
|
33
32
|
...require("./periphery.js"),
|
|
34
|
-
...require("./phantom-tokens.js"),
|
|
35
33
|
...require("./versions.js")
|
|
36
34
|
});
|
|
@@ -22,13 +22,16 @@ __export(MarketRegister_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(MarketRegister_exports);
|
|
24
24
|
var import_marketCompressor = require("../../abi/compressors/marketCompressor.js");
|
|
25
|
-
var import_base = require("../base/index.js");
|
|
26
25
|
var import_constants = require("../constants/index.js");
|
|
27
26
|
var import_utils = require("../utils/index.js");
|
|
28
27
|
var import_viem = require("../utils/viem/index.js");
|
|
29
28
|
var import_MarketConfiguratorContract = require("./MarketConfiguratorContract.js");
|
|
30
29
|
var import_MarketSuite = require("./MarketSuite.js");
|
|
31
|
-
|
|
30
|
+
var import_ZapperRegister = require("./ZapperRegister.js");
|
|
31
|
+
class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
32
|
+
/**
|
|
33
|
+
* Mapping pool.address -> MarketSuite
|
|
34
|
+
*/
|
|
32
35
|
#markets = new import_utils.AddressMap(void 0, "markets");
|
|
33
36
|
#marketFilter;
|
|
34
37
|
#marketConfigurators = new import_utils.AddressMap(
|
|
@@ -62,6 +62,12 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
62
62
|
this.priceOracle = (0, import_oracle.createPriceOracle)(sdk, marketData.priceOracle);
|
|
63
63
|
this.lossPolicy = (0, import_loss_policy.createLossPolicy)(sdk, marketData.lossPolicy);
|
|
64
64
|
}
|
|
65
|
+
get underlying() {
|
|
66
|
+
return this.pool.underlying;
|
|
67
|
+
}
|
|
68
|
+
async getKYCFactory() {
|
|
69
|
+
return this.pool.getKYCFactory();
|
|
70
|
+
}
|
|
65
71
|
get dirty() {
|
|
66
72
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
67
73
|
}
|
|
@@ -16,12 +16,115 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var ZapperRegister_exports = {};
|
|
20
|
+
__export(ZapperRegister_exports, {
|
|
21
|
+
ZapperRegister: () => ZapperRegister
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
23
|
+
module.exports = __toCommonJS(ZapperRegister_exports);
|
|
24
|
+
var import_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
|
|
25
|
+
var import_base = require("../base/index.js");
|
|
26
|
+
var import_constants = require("../constants/index.js");
|
|
27
|
+
var import_utils = require("../utils/index.js");
|
|
28
|
+
class ZapperRegister extends import_base.SDKConstruct {
|
|
29
|
+
/**
|
|
30
|
+
* Mapping pool.address -> ZapperData[]
|
|
31
|
+
* Needs to be loaded explicitly using loadZappers method
|
|
32
|
+
*/
|
|
33
|
+
#zappers;
|
|
34
|
+
/**
|
|
35
|
+
* Load zappers for all pools using periphery compressor, adds hardcoded zappers
|
|
36
|
+
*/
|
|
37
|
+
async loadZappers(force) {
|
|
38
|
+
if (!force && this.#zappers) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
42
|
+
import_constants.AP_PERIPHERY_COMPRESSOR,
|
|
43
|
+
import_constants.VERSION_RANGE_310
|
|
44
|
+
);
|
|
45
|
+
this.logger?.debug(`loading zappers with periphery compressor ${pcAddr}`);
|
|
46
|
+
const markets = this.sdk.marketRegister.markets;
|
|
47
|
+
const resp = await this.client.multicall({
|
|
48
|
+
contracts: markets.map(
|
|
49
|
+
(m) => ({
|
|
50
|
+
abi: import_peripheryCompressor.peripheryCompressorAbi,
|
|
51
|
+
address: pcAddr,
|
|
52
|
+
functionName: "getZappers",
|
|
53
|
+
args: [m.configurator.address, m.pool.pool.address]
|
|
54
|
+
})
|
|
55
|
+
),
|
|
56
|
+
allowFailure: true,
|
|
57
|
+
batchSize: 0
|
|
58
|
+
});
|
|
59
|
+
this.#zappers = new import_utils.AddressMap(void 0, "zappers");
|
|
60
|
+
for (let i = 0; i < resp.length; i++) {
|
|
61
|
+
const { status, result, error } = resp[i];
|
|
62
|
+
const marketConfigurator = markets[i].configurator.address;
|
|
63
|
+
const pool = markets[i].pool.pool.address;
|
|
64
|
+
if (status === "success") {
|
|
65
|
+
for (const z of result) {
|
|
66
|
+
this.#addZapper({ ...z, pool, type: "base" });
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
this.logger?.error(
|
|
70
|
+
`failed to load zapper for market configurator ${this.labelAddress(
|
|
71
|
+
marketConfigurator
|
|
72
|
+
)} and pool ${this.labelAddress(pool)}: ${error}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const z of KYC_ZAPPERS[this.networkType] ?? []) {
|
|
77
|
+
this.#addZapper({ ...z, type: "kyc" });
|
|
78
|
+
}
|
|
79
|
+
for (const z of MIGRATION_ZAPPERS[this.networkType] ?? []) {
|
|
80
|
+
this.#addZapper({ ...z, type: "migration" });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
#addZapper(z) {
|
|
84
|
+
if (BROKEN_ZAPPERS.has(z.baseParams.addr)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const existing = this.zappers.get(z.pool);
|
|
88
|
+
if (existing) {
|
|
89
|
+
const hasZapper = existing.some(
|
|
90
|
+
(zz) => (0, import_utils.hexEq)(zz.baseParams.addr, z.baseParams.addr)
|
|
91
|
+
);
|
|
92
|
+
if (!hasZapper) {
|
|
93
|
+
existing.push(z);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
this.zappers.upsert(z.pool, [z]);
|
|
97
|
+
}
|
|
98
|
+
const zappersTokens = [z.tokenIn, z.tokenOut];
|
|
99
|
+
for (const t of zappersTokens) {
|
|
100
|
+
this.sdk.tokensMeta.upsert(t.addr, t);
|
|
101
|
+
this.sdk.setAddressLabel(t.addr, t.symbol);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
get zappers() {
|
|
105
|
+
if (!this.#zappers) {
|
|
106
|
+
throw new Error("zappers not loaded, call loadZappers first");
|
|
107
|
+
}
|
|
108
|
+
return this.#zappers;
|
|
109
|
+
}
|
|
110
|
+
poolZappers(pool) {
|
|
111
|
+
return this.zappers.get(pool) ?? [];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Can return multiple zappers if there are multiple zappers for the same tokenIn and tokenOut
|
|
115
|
+
*/
|
|
116
|
+
getZapper(pool, tokenIn, tokenOut) {
|
|
117
|
+
const zappers = this.zappers.get(pool)?.filter(
|
|
118
|
+
(z) => (0, import_utils.hexEq)(z.tokenIn.addr, tokenIn) && (0, import_utils.hexEq)(z.tokenOut.addr, tokenOut)
|
|
119
|
+
);
|
|
120
|
+
return zappers;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const BROKEN_ZAPPERS = new import_utils.AddressMap(
|
|
124
|
+
[["0x90D66b03EC4D462e42e3c7741049FB46a4a03B69", true]],
|
|
125
|
+
"brokenZappers"
|
|
126
|
+
);
|
|
127
|
+
const MIGRATION_ZAPPERS = {
|
|
25
128
|
Mainnet: [
|
|
26
129
|
{
|
|
27
130
|
baseParams: {
|
|
@@ -130,7 +233,8 @@ const extraZappers = {
|
|
|
130
233
|
}
|
|
131
234
|
]
|
|
132
235
|
};
|
|
236
|
+
const KYC_ZAPPERS = {};
|
|
133
237
|
// Annotate the CommonJS export names for ESM import in node:
|
|
134
238
|
0 && (module.exports = {
|
|
135
|
-
|
|
239
|
+
ZapperRegister
|
|
136
240
|
});
|
|
@@ -22,6 +22,7 @@ __reExport(market_exports, require("./MarketSuite.js"), module.exports);
|
|
|
22
22
|
__reExport(market_exports, require("./oracle/index.js"), module.exports);
|
|
23
23
|
__reExport(market_exports, require("./pool/index.js"), module.exports);
|
|
24
24
|
__reExport(market_exports, require("./pricefeeds/index.js"), module.exports);
|
|
25
|
+
__reExport(market_exports, require("./types.js"), module.exports);
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
27
|
0 && (module.exports = {
|
|
27
28
|
...require("./adapters/index.js"),
|
|
@@ -30,5 +31,6 @@ __reExport(market_exports, require("./pricefeeds/index.js"), module.exports);
|
|
|
30
31
|
...require("./MarketSuite.js"),
|
|
31
32
|
...require("./oracle/index.js"),
|
|
32
33
|
...require("./pool/index.js"),
|
|
33
|
-
...require("./pricefeeds/index.js")
|
|
34
|
+
...require("./pricefeeds/index.js"),
|
|
35
|
+
...require("./types.js")
|
|
34
36
|
});
|
|
@@ -88,6 +88,9 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
88
88
|
get underlying() {
|
|
89
89
|
return this.pool.underlying;
|
|
90
90
|
}
|
|
91
|
+
async getKYCFactory() {
|
|
92
|
+
return this.pool.getKYCFactory();
|
|
93
|
+
}
|
|
91
94
|
get dirty() {
|
|
92
95
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
93
96
|
}
|
|
@@ -25,16 +25,20 @@ var import_generated = require("../../../abi/310/generated.js");
|
|
|
25
25
|
var import_iPausable = require("../../../abi/iPausable.js");
|
|
26
26
|
var import_base = require("../../base/index.js");
|
|
27
27
|
var import_utils = require("../../utils/index.js");
|
|
28
|
+
var import_SecuritizeKYCFactory = require("./SecuritizeKYCFactory.js");
|
|
28
29
|
const abi = [...import_generated.iPoolV310Abi, ...import_iPausable.iPausableAbi];
|
|
29
30
|
class PoolV310Contract extends import_base.BaseContract {
|
|
30
31
|
creditManagerDebtParams;
|
|
31
|
-
|
|
32
|
+
#sdk;
|
|
33
|
+
#kycFactory;
|
|
34
|
+
constructor(sdk, data) {
|
|
32
35
|
const { baseParams, creditManagerDebtParams, ...rest } = data;
|
|
33
|
-
super(
|
|
36
|
+
super(sdk, {
|
|
34
37
|
...data.baseParams,
|
|
35
38
|
name: `PoolV3(${data.name})`,
|
|
36
39
|
abi
|
|
37
40
|
});
|
|
41
|
+
this.#sdk = sdk;
|
|
38
42
|
Object.assign(this, rest);
|
|
39
43
|
this.creditManagerDebtParams = new import_utils.AddressMap(
|
|
40
44
|
creditManagerDebtParams.map((p) => [p.creditManager, p])
|
|
@@ -46,6 +50,17 @@ class PoolV310Contract extends import_base.BaseContract {
|
|
|
46
50
|
symbol: data.symbol
|
|
47
51
|
});
|
|
48
52
|
}
|
|
53
|
+
async getKYCFactory() {
|
|
54
|
+
if (this.#kycFactory) {
|
|
55
|
+
return this.#kycFactory;
|
|
56
|
+
}
|
|
57
|
+
await this.#sdk.tokensMeta.loadTokenData(this.underlying);
|
|
58
|
+
const u = this.#sdk.tokensMeta.mustGet(this.underlying);
|
|
59
|
+
if (this.#sdk.tokensMeta.isKYCUnderlying(u)) {
|
|
60
|
+
this.#kycFactory = new import_SecuritizeKYCFactory.SecuritizeKYCFactory(this.#sdk, u.kycFactory);
|
|
61
|
+
}
|
|
62
|
+
return this.#kycFactory;
|
|
63
|
+
}
|
|
49
64
|
stateHuman(raw = true) {
|
|
50
65
|
return {
|
|
51
66
|
...super.stateHuman(raw),
|