@gearbox-protocol/sdk 13.5.0-next.1 → 13.5.0-next.2

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 (56) hide show
  1. package/dist/cjs/dev/AccountOpener.js +5 -45
  2. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +6 -339
  3. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -13
  4. package/dist/cjs/sdk/base/TokensMeta.js +7 -151
  5. package/dist/cjs/sdk/base/token-types.js +0 -6
  6. package/dist/cjs/sdk/chain/chains.js +1 -2
  7. package/dist/cjs/sdk/constants/addresses.js +3 -0
  8. package/dist/cjs/sdk/market/MarketRegister.js +0 -3
  9. package/dist/cjs/sdk/market/MarketSuite.js +0 -3
  10. package/dist/cjs/sdk/market/ZapperRegister.js +0 -4
  11. package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
  12. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -17
  13. package/dist/cjs/sdk/market/pool/index.js +0 -4
  14. package/dist/cjs/sdk/pools/PoolService.js +43 -122
  15. package/dist/cjs/sdk/pools/constants.js +37 -0
  16. package/dist/esm/dev/AccountOpener.js +6 -47
  17. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +6 -339
  18. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -13
  19. package/dist/esm/sdk/base/TokensMeta.js +7 -155
  20. package/dist/esm/sdk/base/token-types.js +0 -4
  21. package/dist/esm/sdk/chain/chains.js +1 -2
  22. package/dist/esm/sdk/constants/addresses.js +2 -0
  23. package/dist/esm/sdk/market/MarketRegister.js +0 -3
  24. package/dist/esm/sdk/market/MarketSuite.js +0 -3
  25. package/dist/esm/sdk/market/ZapperRegister.js +0 -4
  26. package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
  27. package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -17
  28. package/dist/esm/sdk/market/pool/index.js +0 -2
  29. package/dist/esm/sdk/pools/PoolService.js +32 -115
  30. package/dist/esm/sdk/pools/constants.js +13 -0
  31. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +5 -103
  32. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +2 -4
  33. package/dist/types/sdk/accounts/types.d.ts +6 -130
  34. package/dist/types/sdk/base/TokensMeta.d.ts +3 -20
  35. package/dist/types/sdk/base/token-types.d.ts +1 -21
  36. package/dist/types/sdk/base/types.d.ts +3 -0
  37. package/dist/types/sdk/chain/chains.d.ts +1 -1
  38. package/dist/types/sdk/constants/addresses.d.ts +4 -0
  39. package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
  40. package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
  41. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
  42. package/dist/types/sdk/market/pool/index.d.ts +0 -2
  43. package/dist/types/sdk/market/types.d.ts +1 -1
  44. package/dist/types/sdk/pools/PoolService.d.ts +24 -0
  45. package/dist/types/sdk/pools/constants.d.ts +7 -0
  46. package/dist/types/sdk/pools/types.d.ts +9 -8
  47. package/package.json +1 -1
  48. package/dist/cjs/abi/310/iSecuritizeDegenNFT.js +0 -263
  49. package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +0 -278
  50. package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +0 -97
  51. package/dist/esm/abi/310/iSecuritizeDegenNFT.js +0 -239
  52. package/dist/esm/abi/310/iSecuritizeKYCFactory.js +0 -254
  53. package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +0 -73
  54. package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +0 -324
  55. package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +0 -322
  56. package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +0 -345
@@ -22,12 +22,9 @@ __export(TokensMeta_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(TokensMeta_exports);
24
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
25
  var import_iStateSerializer = require("../../abi/iStateSerializer.js");
28
26
  var import_iVersion = require("../../abi/iVersion.js");
29
27
  var import_utils = require("../utils/index.js");
30
- var import_token_types = require("./token-types.js");
31
28
  class TokensMeta extends import_utils.AddressMap {
32
29
  #client;
33
30
  #tokenDataLoaded = new import_utils.AddressSet();
@@ -84,32 +81,6 @@ class TokensMeta extends import_utils.AddressMap {
84
81
  }
85
82
  return !!t.contractType?.startsWith("PHANTOM_TOKEN::");
86
83
  }
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
91
- */
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
- );
97
- }
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;
112
- }
113
84
  /**
114
85
  * Returns a map of all phantom tokens
115
86
  * Throws if token data is not loaded
@@ -123,28 +94,6 @@ class TokensMeta extends import_utils.AddressMap {
123
94
  }
124
95
  return result;
125
96
  }
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;
147
- }
148
97
  formatBN(arg0, arg1, arg2) {
149
98
  const token = typeof arg0 === "object" ? arg0.token : arg0;
150
99
  const amount = typeof arg0 === "object" ? arg0.balance : arg1;
@@ -174,7 +123,8 @@ class TokensMeta extends import_utils.AddressMap {
174
123
  return meta;
175
124
  }
176
125
  /**
177
- * Loads token information about phantom tokens, KYC underlying tokens and DSTokens
126
+ * Loads token information about phantom tokens
127
+ * Other special tokens may be loaded here in the future
178
128
  *
179
129
  * @param tokens - tokens to load data for, defaults to all tokens
180
130
  */
@@ -203,116 +153,22 @@ class TokensMeta extends import_utils.AddressMap {
203
153
  batchSize: 0
204
154
  });
205
155
  this.#logger?.debug(`loaded ${resp.length} contract types`);
206
- const kycFactories = new import_utils.AddressSet();
207
156
  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
- );
157
+ this.#overrideTokenMeta(tokensToLoad[i], resp[2 * i], resp[2 * i + 1]);
213
158
  this.#tokenDataLoaded.add(tokensToLoad[i]);
214
- if (this.isKYCUnderlying(meta)) {
215
- kycFactories.add(meta.kycFactory);
216
- }
217
159
  }
218
- this.#logger?.debug(`found ${kycFactories.size} KYC factories`);
219
- await this.#loadDSTokens(kycFactories);
220
160
  }
221
- #overrideTokenMeta(token, contractTypeResp, serializeResp) {
161
+ #overrideTokenMeta(token, contractTypeResp, _serializeResp) {
222
162
  const meta = this.mustGet(token);
223
163
  if (contractTypeResp.status === "success") {
224
164
  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
- );
232
- }
233
- } else {
234
- this.upsert(token, {
235
- ...meta,
236
- contractType
237
- });
238
- }
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
165
  this.upsert(token, {
310
166
  ...meta,
311
- isDSToken: true
167
+ contractType
312
168
  });
313
- this.#tokenDataLoaded.add(token);
314
- this.#logger?.debug(`token ${meta.symbol} (${token}) is a DSToken`);
169
+ this.#logger?.debug(`token ${meta.symbol} is ${contractType}`);
315
170
  }
171
+ return this.mustGet(token);
316
172
  }
317
173
  async #loadWithoutCompressor(tokens_) {
318
174
  if (tokens_.size === 0) {
@@ -18,8 +18,6 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var token_types_exports = {};
20
20
  __export(token_types_exports, {
21
- KYC_UNDERLYING_DEFAULT: () => KYC_UNDERLYING_DEFAULT,
22
- KYC_UNDERLYING_ON_DEMAND: () => KYC_UNDERLYING_ON_DEMAND,
23
21
  PHANTOM_TOKEN_CONTRACT_TYPES: () => PHANTOM_TOKEN_CONTRACT_TYPES
24
22
  });
25
23
  module.exports = __toCommonJS(token_types_exports);
@@ -32,11 +30,7 @@ const PHANTOM_TOKEN_CONTRACT_TYPES = [
32
30
  "PHANTOM_TOKEN::STAKING_REWARDS",
33
31
  "PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
34
32
  ];
35
- const KYC_UNDERLYING_DEFAULT = "KYC_UNDERLYING::DEFAULT";
36
- const KYC_UNDERLYING_ON_DEMAND = "KYC_UNDERLYING::ON_DEMAND";
37
33
  // Annotate the CommonJS export names for ESM import in node:
38
34
  0 && (module.exports = {
39
- KYC_UNDERLYING_DEFAULT,
40
- KYC_UNDERLYING_ON_DEMAND,
41
35
  PHANTOM_TOKEN_CONTRACT_TYPES
42
36
  });
@@ -79,8 +79,7 @@ const chains = {
79
79
  "0x601067eba24bb5b558a184fc082525637e96a42d": "Gami Labs"
80
80
  },
81
81
  testMarketConfigurators: {
82
- "0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit",
83
- "0xE0527dE5908B3fc2e054B7eEE0DeF6c9965AbF24": "Securitize"
82
+ "0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit"
84
83
  },
85
84
  isPublic: true,
86
85
  wellKnownToken: {
@@ -20,15 +20,18 @@ var addresses_exports = {};
20
20
  __export(addresses_exports, {
21
21
  ADDRESS_0X0: () => ADDRESS_0X0,
22
22
  MULTICALL_ADDRESS: () => MULTICALL_ADDRESS,
23
+ NATIVE_ADDRESS: () => NATIVE_ADDRESS,
23
24
  NOT_DEPLOYED: () => NOT_DEPLOYED
24
25
  });
25
26
  module.exports = __toCommonJS(addresses_exports);
26
27
  const MULTICALL_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
27
28
  const ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
28
29
  const NOT_DEPLOYED = "0xNOT DEPLOYED";
30
+ const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
29
31
  // Annotate the CommonJS export names for ESM import in node:
30
32
  0 && (module.exports = {
31
33
  ADDRESS_0X0,
32
34
  MULTICALL_ADDRESS,
35
+ NATIVE_ADDRESS,
33
36
  NOT_DEPLOYED
34
37
  });
@@ -29,9 +29,6 @@ var import_MarketConfiguratorContract = require("./MarketConfiguratorContract.js
29
29
  var import_MarketSuite = require("./MarketSuite.js");
30
30
  var import_ZapperRegister = require("./ZapperRegister.js");
31
31
  class MarketRegister extends import_ZapperRegister.ZapperRegister {
32
- /**
33
- * Mapping pool.address -> MarketSuite
34
- */
35
32
  #markets = new import_utils.AddressMap(void 0, "markets");
36
33
  #marketFilter;
37
34
  #marketConfigurators = new import_utils.AddressMap(
@@ -65,9 +65,6 @@ class MarketSuite extends import_base.SDKConstruct {
65
65
  get underlying() {
66
66
  return this.pool.underlying;
67
67
  }
68
- async getKYCFactory() {
69
- return this.pool.getKYCFactory();
70
- }
71
68
  get dirty() {
72
69
  return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
73
70
  }
@@ -73,9 +73,6 @@ class ZapperRegister extends import_base.SDKConstruct {
73
73
  );
74
74
  }
75
75
  }
76
- for (const z of KYC_ZAPPERS[this.networkType] ?? []) {
77
- this.#addZapper({ ...z, type: "kyc" });
78
- }
79
76
  for (const z of MIGRATION_ZAPPERS[this.networkType] ?? []) {
80
77
  this.#addZapper({ ...z, type: "migration" });
81
78
  }
@@ -233,7 +230,6 @@ const MIGRATION_ZAPPERS = {
233
230
  }
234
231
  ]
235
232
  };
236
- const KYC_ZAPPERS = {};
237
233
  // Annotate the CommonJS export names for ESM import in node:
238
234
  0 && (module.exports = {
239
235
  ZapperRegister
@@ -88,9 +88,6 @@ 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
- }
94
91
  get dirty() {
95
92
  return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
96
93
  }
@@ -25,20 +25,16 @@ 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");
29
28
  const abi = [...import_generated.iPoolV310Abi, ...import_iPausable.iPausableAbi];
30
29
  class PoolV310Contract extends import_base.BaseContract {
31
30
  creditManagerDebtParams;
32
- #sdk;
33
- #kycFactory;
34
- constructor(sdk, data) {
31
+ constructor(options, data) {
35
32
  const { baseParams, creditManagerDebtParams, ...rest } = data;
36
- super(sdk, {
33
+ super(options, {
37
34
  ...data.baseParams,
38
35
  name: `PoolV3(${data.name})`,
39
36
  abi
40
37
  });
41
- this.#sdk = sdk;
42
38
  Object.assign(this, rest);
43
39
  this.creditManagerDebtParams = new import_utils.AddressMap(
44
40
  creditManagerDebtParams.map((p) => [p.creditManager, p])
@@ -50,17 +46,6 @@ class PoolV310Contract extends import_base.BaseContract {
50
46
  symbol: data.symbol
51
47
  });
52
48
  }
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
- }
64
49
  stateHuman(raw = true) {
65
50
  return {
66
51
  ...super.stateHuman(raw),
@@ -18,15 +18,11 @@ module.exports = __toCommonJS(pool_exports);
18
18
  __reExport(pool_exports, require("./GaugeContract.js"), module.exports);
19
19
  __reExport(pool_exports, require("./LinearInterestRateModelContract.js"), module.exports);
20
20
  __reExport(pool_exports, require("./PoolSuite.js"), module.exports);
21
- __reExport(pool_exports, require("./PoolV310Contract.js"), module.exports);
22
- __reExport(pool_exports, require("./SecuritizeKYCFactory.js"), module.exports);
23
21
  __reExport(pool_exports, require("./types.js"), module.exports);
24
22
  // Annotate the CommonJS export names for ESM import in node:
25
23
  0 && (module.exports = {
26
24
  ...require("./GaugeContract.js"),
27
25
  ...require("./LinearInterestRateModelContract.js"),
28
26
  ...require("./PoolSuite.js"),
29
- ...require("./PoolV310Contract.js"),
30
- ...require("./SecuritizeKYCFactory.js"),
31
27
  ...require("./types.js")
32
28
  });
@@ -22,82 +22,39 @@ __export(PoolService_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(PoolService_exports);
24
24
  var import_generated = require("../../abi/310/generated.js");
25
- var import_iERC20 = require("../../abi/iERC20.js");
26
25
  var import_iERC20ZapperDeposits = require("../../abi/iERC20ZapperDeposits.js");
27
26
  var import_iETHZapperDeposits = require("../../abi/iETHZapperDeposits.js");
28
27
  var import_iZapper = require("../../abi/iZapper.js");
29
28
  var import_base = require("../base/index.js");
30
- var import__ = require("../index.js");
29
+ var import_constants = require("../constants/index.js");
31
30
  var import_utils = require("../utils/index.js");
32
- const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
33
- const POOL_TOKENS_TO_MIGRATE = new import_utils.AddressMap([
34
- // v2 diesels
35
- ["0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA", "dDAI"],
36
- ["0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3", "dUSDC"],
37
- ["0xe753260F1955e8678DCeA8887759e07aa57E8c54", "dWBTC"],
38
- ["0xF21fc650C1B34eb0FDE786D52d23dA99Db3D6278", "dWETH"],
39
- ["0x2158034dB06f06dcB9A786D2F1F8c38781bA779d", "dwstETH"],
40
- ["0x8A1112AFef7F4FC7c066a77AABBc01b3Fff31D47", "dFRAX"]
41
- ]);
31
+ var import_constants2 = require("./constants.js");
42
32
  class PoolService extends import_base.SDKConstruct {
33
+ /**
34
+ * @inheritdoc IPoolsService.getDepositTokensIn
35
+ */
43
36
  getDepositTokensIn(pool) {
44
- const underlying = this.#describeUnderlying(pool);
45
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
46
- switch (underlying.contractType) {
47
- case import_base.KYC_UNDERLYING_DEFAULT:
48
- return this.#depositTokensIn(pool, false);
49
- case import_base.KYC_UNDERLYING_ON_DEMAND:
50
- return [underlying.asset];
51
- }
52
- }
53
37
  return this.#depositTokensIn(pool, true);
54
38
  }
39
+ /**
40
+ * @inheritdoc IPoolsService.getDepositTokensOut
41
+ */
55
42
  getDepositTokensOut(pool, tokenIn) {
56
- const underlying = this.#describeUnderlying(pool);
57
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
58
- switch (underlying.contractType) {
59
- case import_base.KYC_UNDERLYING_DEFAULT:
60
- return this.#depositTokensOut(pool, tokenIn, false);
61
- case import_base.KYC_UNDERLYING_ON_DEMAND:
62
- return [];
63
- }
64
- }
65
43
  return this.#depositTokensOut(pool, tokenIn, true);
66
44
  }
45
+ /**
46
+ * @inheritdoc IPoolsService.getDepositMetadata
47
+ */
67
48
  getDepositMetadata(pool, tokenIn, tokenOut) {
68
- const underlying = this.#describeUnderlying(pool);
69
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
70
- switch (underlying.contractType) {
71
- case import_base.KYC_UNDERLYING_DEFAULT: {
72
- return this.#depositMetadata(
73
- "kyc-default",
74
- pool,
75
- tokenIn,
76
- tokenOut,
77
- false
78
- );
79
- }
80
- case import_base.KYC_UNDERLYING_ON_DEMAND:
81
- return {
82
- zapper: void 0,
83
- approveTarget: underlying.liquidityProvider,
84
- permissible: false,
85
- type: "kyc-on-demand"
86
- };
87
- }
88
- }
89
49
  return this.#depositMetadata("classic", pool, tokenIn, tokenOut, true);
90
50
  }
51
+ /**
52
+ * @inheritdoc IPoolsService.addLiquidity
53
+ */
91
54
  addLiquidity(props) {
92
55
  const { collateral, meta, permit, referralCode, pool, wallet } = props;
93
- const underlying = this.#describeUnderlying(pool);
94
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
95
- if (underlying.contractType === import_base.KYC_UNDERLYING_ON_DEMAND) {
96
- return void 0;
97
- }
98
- }
99
56
  const { zapper } = meta;
100
- if (zapper && (0, import__.hexEq)(zapper.tokenIn.addr, NATIVE_ADDRESS)) {
57
+ if (zapper && (0, import_utils.hexEq)(zapper.tokenIn.addr, import_constants.NATIVE_ADDRESS)) {
101
58
  return {
102
59
  target: zapper.baseParams.addr,
103
60
  abi: import_iETHZapperDeposits.iethZapperDepositsAbi,
@@ -134,43 +91,23 @@ class PoolService extends import_base.SDKConstruct {
134
91
  };
135
92
  }
136
93
  }
94
+ /**
95
+ * @inheritdoc IPoolsService.getWithdrawalTokensIn
96
+ */
137
97
  getWithdrawalTokensIn(pool) {
138
- const underlying = this.#describeUnderlying(pool);
139
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
140
- switch (underlying.contractType) {
141
- case import_base.KYC_UNDERLYING_DEFAULT:
142
- return this.#withdrawalTokensIn(pool, false);
143
- case import_base.KYC_UNDERLYING_ON_DEMAND:
144
- return [];
145
- }
146
- }
147
98
  return this.#withdrawalTokensIn(pool, true);
148
99
  }
100
+ /**
101
+ * @inheritdoc IPoolsService.getWithdrawalTokensOut
102
+ */
149
103
  getWithdrawalTokensOut(pool, tokenIn) {
150
- const underlying = this.#describeUnderlying(pool);
151
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
152
- switch (underlying.contractType) {
153
- case import_base.KYC_UNDERLYING_DEFAULT:
154
- return this.#withdrawalTokensOut(pool, tokenIn, false);
155
- case import_base.KYC_UNDERLYING_ON_DEMAND:
156
- return [underlying.asset];
157
- }
158
- }
159
104
  return this.#withdrawalTokensOut(pool, tokenIn, true);
160
105
  }
106
+ /**
107
+ * @inheritdoc IPoolsService.removeLiquidity
108
+ */
161
109
  removeLiquidity(props) {
162
110
  const { pool, amount, meta, wallet, permit } = props;
163
- const underlying = this.#describeUnderlying(pool);
164
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
165
- if (underlying.contractType === import_base.KYC_UNDERLYING_ON_DEMAND) {
166
- return {
167
- abi: import_iERC20.ierc20Abi,
168
- functionName: "approve",
169
- args: [underlying.liquidityProvider, 0n],
170
- target: underlying.asset
171
- };
172
- }
173
- }
174
111
  if (meta.zapper) {
175
112
  return permit ? {
176
113
  target: meta.zapper.baseParams.addr,
@@ -198,49 +135,32 @@ class PoolService extends import_base.SDKConstruct {
198
135
  args: [amount, wallet, wallet]
199
136
  };
200
137
  }
138
+ /**
139
+ * @inheritdoc IPoolsService.getWithdrawalMetadata
140
+ */
201
141
  getWithdrawalMetadata(pool, tokenIn, tokenOut) {
202
- const underlying = this.#describeUnderlying(pool);
203
- if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
204
- switch (underlying.contractType) {
205
- case import_base.KYC_UNDERLYING_DEFAULT: {
206
- return this.#withdrawalMetadata(
207
- "kyc-default",
208
- pool,
209
- tokenIn,
210
- tokenOut,
211
- false
212
- );
213
- }
214
- case import_base.KYC_UNDERLYING_ON_DEMAND:
215
- return {
216
- zapper: void 0,
217
- approveTarget: void 0,
218
- permissible: false,
219
- type: "kyc-on-demand"
220
- };
221
- }
222
- }
223
142
  return this.#withdrawalMetadata("classic", pool, tokenIn, tokenOut, true);
224
143
  }
225
144
  /**
145
+ * TODO: do we still need this after v3.0 deprecation?
226
146
  * Filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
227
147
  * Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
228
148
  */
229
149
  #getDepositZappers(poolAddr) {
230
150
  const zappers = this.sdk.marketRegister.poolZappers(poolAddr);
231
151
  return zappers.filter(
232
- (z) => z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
152
+ (z) => z.type !== "migration" && !import_constants2.POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
233
153
  );
234
154
  }
235
155
  #depositTokensIn(poolAddr, allowDirectDeposit) {
236
156
  const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
237
- const result = new import__.AddressSet();
157
+ const result = new import_utils.AddressSet();
238
158
  if (allowDirectDeposit) {
239
159
  result.add(pool.underlying);
240
160
  }
241
161
  const zappers = this.#getDepositZappers(poolAddr);
242
162
  for (const z of zappers) {
243
- if ((0, import__.hexEq)(z.tokenOut.addr, poolAddr)) {
163
+ if ((0, import_utils.hexEq)(z.tokenOut.addr, poolAddr)) {
244
164
  result.add(z.tokenIn.addr);
245
165
  }
246
166
  }
@@ -253,7 +173,7 @@ class PoolService extends import_base.SDKConstruct {
253
173
  }
254
174
  #withdrawalTokensIn(poolAddr, allowDirectDeposit) {
255
175
  const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
256
- const result = new import__.AddressSet();
176
+ const result = new import_utils.AddressSet();
257
177
  if (allowDirectDeposit && pool) {
258
178
  result.add(poolAddr);
259
179
  }
@@ -269,15 +189,15 @@ class PoolService extends import_base.SDKConstruct {
269
189
  return result.asArray();
270
190
  }
271
191
  #depositTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
272
- const result = new import__.AddressSet();
192
+ const result = new import_utils.AddressSet();
273
193
  const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
274
194
  const zappers = this.#getDepositZappers(poolAddr);
275
195
  for (const z of zappers) {
276
- if ((0, import__.hexEq)(z.tokenIn.addr, tokenIn)) {
196
+ if ((0, import_utils.hexEq)(z.tokenIn.addr, tokenIn)) {
277
197
  result.add(z.tokenOut.addr);
278
198
  }
279
199
  }
280
- if (allowDirectDeposit && (0, import__.hexEq)(tokenIn, pool.underlying)) {
200
+ if (allowDirectDeposit && (0, import_utils.hexEq)(tokenIn, pool.underlying)) {
281
201
  result.add(poolAddr);
282
202
  }
283
203
  if (result.size === 0) {
@@ -291,15 +211,15 @@ class PoolService extends import_base.SDKConstruct {
291
211
  return r;
292
212
  }
293
213
  #withdrawalTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
294
- const result = new import__.AddressSet();
214
+ const result = new import_utils.AddressSet();
295
215
  const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
296
216
  const zappers = this.#getDepositZappers(poolAddr);
297
217
  for (const z of zappers) {
298
- if ((0, import__.hexEq)(z.tokenOut.addr, tokenIn)) {
218
+ if ((0, import_utils.hexEq)(z.tokenOut.addr, tokenIn)) {
299
219
  result.add(z.tokenIn.addr);
300
220
  }
301
221
  }
302
- if (allowDirectDeposit && (0, import__.hexEq)(tokenIn, poolAddr)) {
222
+ if (allowDirectDeposit && (0, import_utils.hexEq)(tokenIn, poolAddr)) {
303
223
  result.add(pool.underlying);
304
224
  }
305
225
  if (result.size === 0) {
@@ -313,12 +233,13 @@ class PoolService extends import_base.SDKConstruct {
313
233
  return r;
314
234
  }
315
235
  /**
236
+ * TODO: do we still need this after v3.0 deprecation?
316
237
  * Filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
317
238
  * Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
318
239
  */
319
240
  #getDepositZapper(poolAddr, tokenIn, tokenOut) {
320
241
  const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter(
321
- (z) => z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
242
+ (z) => z.type !== "migration" && !import_constants2.POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
322
243
  );
323
244
  if (zappers && zappers.length > 1) {
324
245
  throw new Error(
@@ -350,9 +271,9 @@ class PoolService extends import_base.SDKConstruct {
350
271
  zapper,
351
272
  // zapper or pool itself
352
273
  approveTarget: zapper?.baseParams.addr ?? pool.pool.address,
353
- // TODO: instead of permissible, return permitType зависимости от tokenIn
274
+ // TODO: instead of permissible, return permitType depending on tokenIn
354
275
  // "none" | "eip2612" | "dai_like";
355
- permissible: !!zapper && !(0, import__.hexEq)(tokenIn, NATIVE_ADDRESS),
276
+ permissible: !!zapper && !(0, import_utils.hexEq)(tokenIn, import_constants.NATIVE_ADDRESS),
356
277
  type
357
278
  };
358
279
  }
@@ -374,7 +295,7 @@ class PoolService extends import_base.SDKConstruct {
374
295
  zapper,
375
296
  // zapper or pool itself
376
297
  approveTarget: zapper?.baseParams.addr,
377
- // TODO: instead of permissible, return permitType зависимости от tokenIn
298
+ // TODO: instead of permissible, return permitType depending on tokenIn
378
299
  // "none" | "eip2612" | "dai_like";
379
300
  permissible: !!zapper,
380
301
  type