@gearbox-protocol/sdk 15.1.0-next.12 → 15.1.0-next.14

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 (68) hide show
  1. package/dist/cjs/dev/AccountOpener.js +1 -8
  2. package/dist/cjs/dev/index.js +2 -3
  3. package/dist/cjs/dev/midasUtils.js +0 -96
  4. package/dist/cjs/new-sdk/index.js +3 -3
  5. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +8 -8
  6. package/dist/cjs/new-sdk/{simulate/SimulateApi.js → prepare/PrepareApi.js} +21 -49
  7. package/dist/cjs/new-sdk/prepare/index.js +4 -0
  8. package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +7 -35
  9. package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +5 -26
  10. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -2
  11. package/dist/cjs/sdk/accounts/utils/midasUtils.js +70 -0
  12. package/dist/cjs/sdk/index.js +4 -0
  13. package/dist/cjs/sdk/market/adapters/createAdapter.js +8 -1
  14. package/dist/cjs/sdk/market/adapters/index.js +5 -0
  15. package/dist/cjs/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js +81 -0
  16. package/dist/cjs/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js +59 -0
  17. package/dist/cjs/sdk/market/adapters/midas/index.js +6 -0
  18. package/dist/cjs/sdk/market/adapters/midas/types.js +1 -0
  19. package/dist/cjs/sdk/market/index.js +4 -0
  20. package/dist/esm/common-utils/index.js +3 -3
  21. package/dist/esm/common-utils/utils/index.js +1 -1
  22. package/dist/esm/dev/AccountOpener.js +1 -8
  23. package/dist/esm/dev/index.js +3 -3
  24. package/dist/esm/dev/midasUtils.js +2 -97
  25. package/dist/esm/new-sdk/index.js +3 -3
  26. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +8 -8
  27. package/dist/esm/new-sdk/{simulate/SimulateApi.js → prepare/PrepareApi.js} +21 -49
  28. package/dist/esm/new-sdk/prepare/index.js +3 -0
  29. package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +8 -36
  30. package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +5 -26
  31. package/dist/esm/plugins/apy/ApyPlugin.js +2 -2
  32. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +16 -2
  33. package/dist/esm/sdk/accounts/utils/midasUtils.js +69 -0
  34. package/dist/esm/sdk/index.js +3 -1
  35. package/dist/esm/sdk/market/adapters/createAdapter.js +8 -1
  36. package/dist/esm/sdk/market/adapters/index.js +4 -1
  37. package/dist/esm/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js +80 -0
  38. package/dist/esm/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js +58 -0
  39. package/dist/esm/sdk/market/adapters/midas/index.js +4 -0
  40. package/dist/esm/sdk/market/adapters/midas/types.js +1 -0
  41. package/dist/esm/sdk/market/index.js +3 -1
  42. package/dist/types/dev/index.d.ts +2 -2
  43. package/dist/types/dev/midasUtils.d.ts +2 -35
  44. package/dist/types/new-sdk/execute/ExecuteApi.d.ts +9 -9
  45. package/dist/types/new-sdk/index.d.ts +4 -4
  46. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +4 -4
  47. package/dist/types/new-sdk/opportunities/types.d.ts +5 -5
  48. package/dist/types/new-sdk/{simulate/SimulateApi.d.ts → prepare/PrepareApi.d.ts} +19 -19
  49. package/dist/types/new-sdk/prepare/index.d.ts +3 -0
  50. package/dist/types/new-sdk/{simulate → prepare}/types.d.ts +35 -61
  51. package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +2 -1
  52. package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +2 -1
  53. package/dist/types/sdk/accounts/intents/testing/sdk-mock.d.ts +1 -1
  54. package/dist/types/sdk/accounts/intents/types.d.ts +12 -12
  55. package/dist/types/sdk/accounts/utils/midasUtils.d.ts +38 -0
  56. package/dist/types/sdk/index.d.ts +4 -1
  57. package/dist/types/sdk/market/adapters/index.d.ts +5 -1
  58. package/dist/types/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.d.ts +17 -0
  59. package/dist/types/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.d.ts +15 -0
  60. package/dist/types/sdk/market/adapters/midas/index.d.ts +4 -0
  61. package/dist/types/sdk/market/adapters/midas/types.d.ts +24 -0
  62. package/dist/types/sdk/market/index.d.ts +4 -1
  63. package/package.json +1 -1
  64. package/dist/cjs/new-sdk/simulate/index.js +0 -4
  65. package/dist/esm/new-sdk/simulate/index.js +0 -3
  66. package/dist/types/new-sdk/simulate/index.d.ts +0 -3
  67. /package/dist/cjs/new-sdk/{simulate → prepare}/types.js +0 -0
  68. /package/dist/esm/new-sdk/{simulate → prepare}/types.js +0 -0
@@ -3,9 +3,9 @@ import { MultichainConstruct } from "../../sdk/base/MultichainConstruct.js";
3
3
  import { fetchCreditAccountSlice } from "../../sdk/accounts/intents/utils/credit-account-slice.js";
4
4
  import { CreditAccountOperationsService } from "../../sdk/accounts/intents/index.js";
5
5
  import "../../sdk/index.js";
6
- //#region src/new-sdk/simulate/SimulateApi.ts
6
+ //#region src/new-sdk/prepare/PrepareApi.ts
7
7
  /**
8
- * {@inheritDoc OpportunitiesSimulate}
8
+ * {@inheritDoc OpportunitiesPrepare}
9
9
  *
10
10
  * Holds no state of its own: it owns the mapping from the public,
11
11
  * read-model-shaped request to the engine's intent, and nothing else. All
@@ -17,7 +17,7 @@ import "../../sdk/index.js";
17
17
  * to, hence a chain the SDK does not cover, or one that fails the read, throws
18
18
  * rather than answering with empty metadata.
19
19
  **/
20
- var SimulateApi = class extends MultichainConstruct {
20
+ var PrepareApi = class extends MultichainConstruct {
21
21
  #ensureFresh;
22
22
  constructor(sdk, ensureFresh) {
23
23
  super(sdk);
@@ -28,22 +28,10 @@ var SimulateApi = class extends MultichainConstruct {
28
28
  return super.queryChain(props);
29
29
  }
30
30
  /**
31
- * {@inheritDoc OpportunitiesSimulate.delayed}
31
+ * {@inheritDoc OpportunitiesPrepare.finalize}
32
32
  **/
33
- delayed = {
34
- withdrawStrategy: (position, params) => this.#startDelayedIntent(position, params, {
35
- type: "WITHDRAW",
36
- amount: params.amount,
37
- to: params.to,
38
- tokenOut: params.tokenOut,
39
- sourceToken: params.sourceToken
40
- }),
41
- adjustLeverage: (position, params) => this.#startDelayedIntent(position, params, {
42
- type: "ADJUST_LEVERAGE",
43
- targetLeverage: params.targetLeverage,
44
- token: params.token
45
- }),
46
- finish: (position, params) => this.queryChain({
33
+ async finalize(position, params) {
34
+ return this.queryChain({
47
35
  network: position.chainId,
48
36
  run: async (sdk) => {
49
37
  const intent = resumable(params.intent ?? params.claimable.intent);
@@ -60,10 +48,10 @@ var SimulateApi = class extends MultichainConstruct {
60
48
  quotaReserve: params.quotaReserve
61
49
  });
62
50
  }
63
- })
64
- };
51
+ });
52
+ }
65
53
  /**
66
- * {@inheritDoc OpportunitiesSimulate.deposit}
54
+ * {@inheritDoc OpportunitiesPrepare.deposit}
67
55
  **/
68
56
  deposit(pool, params) {
69
57
  const { marketRegister, pools } = this.sdk.chain(pool.chainId);
@@ -97,7 +85,7 @@ var SimulateApi = class extends MultichainConstruct {
97
85
  };
98
86
  }
99
87
  /**
100
- * {@inheritDoc OpportunitiesSimulate.withdraw}
88
+ * {@inheritDoc OpportunitiesPrepare.withdraw}
101
89
  **/
102
90
  withdraw(pool, params) {
103
91
  const { pools } = this.sdk.chain(pool.chainId);
@@ -129,7 +117,7 @@ var SimulateApi = class extends MultichainConstruct {
129
117
  };
130
118
  }
131
119
  /**
132
- * {@inheritDoc OpportunitiesSimulate.redeem}
120
+ * {@inheritDoc OpportunitiesPrepare.redeem}
133
121
  **/
134
122
  redeem(pool, params) {
135
123
  const { pools } = this.sdk.chain(pool.chainId);
@@ -161,7 +149,7 @@ var SimulateApi = class extends MultichainConstruct {
161
149
  };
162
150
  }
163
151
  /**
164
- * {@inheritDoc OpportunitiesSimulate.openNewStrategy}
152
+ * {@inheritDoc OpportunitiesPrepare.openNewStrategy}
165
153
  **/
166
154
  async openNewStrategy(strategy, params) {
167
155
  return this.queryChain({
@@ -179,7 +167,7 @@ var SimulateApi = class extends MultichainConstruct {
179
167
  });
180
168
  }
181
169
  /**
182
- * {@inheritDoc OpportunitiesSimulate.depositStrategy}
170
+ * {@inheritDoc OpportunitiesPrepare.depositStrategy}
183
171
  **/
184
172
  async depositStrategy(position, params) {
185
173
  return this.#startIntent(position, params, {
@@ -192,7 +180,7 @@ var SimulateApi = class extends MultichainConstruct {
192
180
  });
193
181
  }
194
182
  /**
195
- * {@inheritDoc OpportunitiesSimulate.withdrawStrategy}
183
+ * {@inheritDoc OpportunitiesPrepare.withdrawStrategy}
196
184
  **/
197
185
  async withdrawStrategy(position, params) {
198
186
  return this.#startRoutes(position, params, {
@@ -204,7 +192,7 @@ var SimulateApi = class extends MultichainConstruct {
204
192
  });
205
193
  }
206
194
  /**
207
- * {@inheritDoc OpportunitiesSimulate.maxWithdraw}
195
+ * {@inheritDoc OpportunitiesPrepare.maxWithdraw}
208
196
  **/
209
197
  async maxWithdraw(position) {
210
198
  return this.queryChain({
@@ -216,7 +204,7 @@ var SimulateApi = class extends MultichainConstruct {
216
204
  });
217
205
  }
218
206
  /**
219
- * {@inheritDoc OpportunitiesSimulate.repayStrategy}
207
+ * {@inheritDoc OpportunitiesPrepare.repayStrategy}
220
208
  **/
221
209
  async repayStrategy(position, params) {
222
210
  return this.#startIntent(position, params, {
@@ -227,7 +215,7 @@ var SimulateApi = class extends MultichainConstruct {
227
215
  });
228
216
  }
229
217
  /**
230
- * {@inheritDoc OpportunitiesSimulate.maxRepay}
218
+ * {@inheritDoc OpportunitiesPrepare.maxRepay}
231
219
  **/
232
220
  async maxRepay(position) {
233
221
  return this.queryChain({
@@ -239,7 +227,7 @@ var SimulateApi = class extends MultichainConstruct {
239
227
  });
240
228
  }
241
229
  /**
242
- * {@inheritDoc OpportunitiesSimulate.adjustLeverage}
230
+ * {@inheritDoc OpportunitiesPrepare.adjustLeverage}
243
231
  **/
244
232
  async adjustLeverage(position, params) {
245
233
  return this.#startRoutes(position, params, {
@@ -249,7 +237,7 @@ var SimulateApi = class extends MultichainConstruct {
249
237
  });
250
238
  }
251
239
  /**
252
- * {@inheritDoc OpportunitiesSimulate.addCollateral}
240
+ * {@inheritDoc OpportunitiesPrepare.addCollateral}
253
241
  **/
254
242
  async addCollateral(position, params) {
255
243
  return this.#startIntent(position, params, {
@@ -260,7 +248,7 @@ var SimulateApi = class extends MultichainConstruct {
260
248
  });
261
249
  }
262
250
  /**
263
- * {@inheritDoc OpportunitiesSimulate.withdrawCollateral}
251
+ * {@inheritDoc OpportunitiesPrepare.withdrawCollateral}
264
252
  **/
265
253
  async withdrawCollateral(position, params) {
266
254
  return this.#startIntent(position, params, {
@@ -287,22 +275,6 @@ var SimulateApi = class extends MultichainConstruct {
287
275
  });
288
276
  }
289
277
  /**
290
- * Shared path of the same two flows when only the delayed route is asked for:
291
- * a planner that requests a redemption instead of swapping.
292
- **/
293
- async #startDelayedIntent(position, options, intent) {
294
- return this.queryChain({
295
- network: position.chainId,
296
- run: async (sdk) => service(sdk).startDelayedIntent({
297
- intent,
298
- creditAccount: await slice(sdk, position.creditAccount),
299
- sdk,
300
- slippage: options.slippage,
301
- quotaReserve: options.quotaReserve
302
- })
303
- });
304
- }
305
- /**
306
278
  * Shared path of the five flows that act on an existing account: read the
307
279
  * account, then run the intent through the engine.
308
280
  **/
@@ -357,4 +329,4 @@ function lpRoute(requested, routes) {
357
329
  return options.length === 1 ? options[0] : void 0;
358
330
  }
359
331
  //#endregion
360
- export { SimulateApi };
332
+ export { PrepareApi };
@@ -0,0 +1,3 @@
1
+ import { PrepareApi } from "./PrepareApi.js";
2
+ import "./types.js";
3
+ export { PrepareApi };
@@ -1,11 +1,12 @@
1
1
  import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
2
+ import { PlaceholderMidasGatewayAdapterContract } from "../../../sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js";
2
3
  import "../../../sdk/index.js";
3
4
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
4
5
  import { iMidasGatewayAdapterV311Abi } from "../abi/adapters/iMidasGatewayAdapterV311.js";
5
6
  import "../abi/adapters/index.js";
6
7
  import { iMidasGatewayV311Abi } from "../abi/midas/iMidasGatewayV311.js";
7
8
  import "../abi/index.js";
8
- import { decodeAbiParameters, decodeFunctionData, isAddressEqual, zeroAddress } from "viem";
9
+ import { decodeFunctionData, isAddressEqual, zeroAddress } from "viem";
9
10
  //#region src/plugins/adapters/contracts/MidasGatewayAdapterContract.ts
10
11
  const abi = iMidasGatewayAdapterV311Abi;
11
12
  const protocolAbi = iMidasGatewayV311Abi;
@@ -22,41 +23,12 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
22
23
  protocolAbi
23
24
  });
24
25
  if (args.baseParams.serializedParams) {
25
- const decoded = decodeAbiParameters([
26
- {
27
- type: "address",
28
- name: "creditManager"
29
- },
30
- {
31
- type: "address",
32
- name: "targetContract"
33
- },
34
- {
35
- type: "address",
36
- name: "gateway"
37
- },
38
- {
39
- type: "address",
40
- name: "mToken"
41
- },
42
- {
43
- type: "address",
44
- name: "quoteToken"
45
- },
46
- {
47
- type: "address",
48
- name: "phantomToken"
49
- },
50
- {
51
- type: "bytes32",
52
- name: "referrerId"
53
- }
54
- ], args.baseParams.serializedParams);
55
- this.#gateway = decoded[2];
56
- this.#mToken = decoded[3];
57
- this.#quoteToken = decoded[4];
58
- this.#phantomToken = decoded[5];
59
- this.#referrerId = decoded[6];
26
+ const decoded = PlaceholderMidasGatewayAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
27
+ this.#gateway = decoded.gateway;
28
+ this.#mToken = decoded.mToken;
29
+ this.#quoteToken = decoded.quoteToken;
30
+ this.#phantomToken = decoded.phantomToken;
31
+ this.#referrerId = decoded.referrerId;
60
32
  }
61
33
  }
62
34
  get gateway() {
@@ -1,10 +1,10 @@
1
1
  import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
2
+ import { PlaceholderMidasIssuanceVaultAdapterContract } from "../../../sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
2
3
  import "../../../sdk/index.js";
3
4
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
4
5
  import { iMidasIssuanceVaultAdapterV310Abi } from "../abi/adapters/iMidasIssuanceVaultAdapterV310.js";
5
6
  import "../abi/adapters/index.js";
6
7
  import { iMidasIssuanceVaultV310Abi } from "../abi/targetContractAbi.js";
7
- import { decodeAbiParameters } from "viem";
8
8
  //#region src/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.ts
9
9
  const abi = iMidasIssuanceVaultAdapterV310Abi;
10
10
  const protocolAbi = iMidasIssuanceVaultV310Abi;
@@ -19,31 +19,10 @@ var MidasIssuanceVaultAdapterContract = class extends AbstractAdapterContract {
19
19
  protocolAbi
20
20
  });
21
21
  if (args.baseParams.serializedParams) {
22
- const decoded = decodeAbiParameters([
23
- {
24
- type: "address",
25
- name: "creditManager"
26
- },
27
- {
28
- type: "address",
29
- name: "targetContract"
30
- },
31
- {
32
- type: "address",
33
- name: "mToken"
34
- },
35
- {
36
- type: "bytes32",
37
- name: "referrerId"
38
- },
39
- {
40
- type: "address[]",
41
- name: "allowedTokens"
42
- }
43
- ], args.baseParams.serializedParams);
44
- this.#mToken = decoded[2];
45
- this.#referrerId = decoded[3];
46
- this.#allowedTokens = [...decoded[4]];
22
+ const decoded = PlaceholderMidasIssuanceVaultAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
23
+ this.#mToken = decoded.mToken;
24
+ this.#referrerId = decoded.referrerId;
25
+ this.#allowedTokens = decoded.allowedTokens;
47
26
  }
48
27
  }
49
28
  get mToken() {
@@ -1,3 +1,5 @@
1
+ import { AxiosCache } from "../../common-utils/axios-cache/AxiosCache.js";
2
+ import "../../common-utils/axios-cache/index.js";
1
3
  import { AddressMap } from "../../sdk/utils/AddressMap.js";
2
4
  import { AP_MARKET_COMPRESSOR } from "../../sdk/constants/address-provider.js";
3
5
  import { PERCENTAGE_DECIMALS } from "../../sdk/constants/math.js";
@@ -8,8 +10,6 @@ import { hexEq } from "../../sdk/utils/hex.js";
8
10
  import { marketCompressorAbi } from "../../abi/compressors/marketCompressor.js";
9
11
  import { BasePlugin } from "../../sdk/plugins/BasePlugin.js";
10
12
  import "../../sdk/index.js";
11
- import { AxiosCache } from "../../common-utils/axios-cache/AxiosCache.js";
12
- import "../../common-utils/axios-cache/index.js";
13
13
  import { getStrategyCreditManagersListCore } from "../../common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list-core.js";
14
14
  import { getAvailableAndDisabledStrategies } from "../../common-utils/utils/strategies/lists/get-available-and-disabled-strategies.js";
15
15
  import { getReleasedStrategiesListCore } from "../../common-utils/utils/strategies/lists/get-released-strategies-list-core.js";
@@ -15,6 +15,7 @@ import "../market/index.js";
15
15
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
16
16
  import "./credit-account-compressor/index.js";
17
17
  import { extractPriceUpdates, extractQuotaTokens, mergePriceUpdates } from "./multicall-utils.js";
18
+ import { prependMidasReceiveGreenlist } from "./utils/midasUtils.js";
18
19
  import { encodeFunctionData } from "viem";
19
20
  //#region src/sdk/accounts/CreditAccountsServiceV310.ts
20
21
  /**
@@ -212,7 +213,7 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
212
213
  if (withdrawToken === true) tokenToWithdraw = cm.underlying;
213
214
  else if (typeof withdrawToken === "string") tokenToWithdraw = withdrawToken;
214
215
  const { creditFacade } = cmSuite;
215
- const operationCalls = [
216
+ let calls = [
216
217
  creditFacade.prepareIncreaseDebt(debt),
217
218
  ...creditFacade.prepareAddCollateral(collateral, permits),
218
219
  ...openPathCalls,
@@ -223,7 +224,8 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
223
224
  }),
224
225
  ...callsAfter ?? []
225
226
  ];
226
- const calls = await this.prependPriceUpdates(cm.address, operationCalls);
227
+ calls = await this.#prependMidasReceiveGreenlist(cm.address, calls);
228
+ calls = await this.prependPriceUpdates(cm.address, calls);
227
229
  const tx = reopenCreditAccount ? cmSuite.multicallTx(reopenCreditAccount, calls) : cmSuite.openCreditAccountTx(to, calls, referralCode, rwaOptions);
228
230
  tx.value = ethAmount.toString(10);
229
231
  return tx;
@@ -449,6 +451,18 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
449
451
  return this.sdk.addressProvider.mustGetLatest(AP_REWARDS_COMPRESSOR, VERSION_RANGE_310)[0];
450
452
  }
451
453
  /**
454
+ * {@inheritDoc ICreditAccountsService.prependMidasReceiveGreenlist}
455
+ */
456
+ async #prependMidasReceiveGreenlist(creditManager, calls) {
457
+ const cm = this.sdk.marketRegister.findCreditManager(creditManager);
458
+ return prependMidasReceiveGreenlist({
459
+ cm,
460
+ client: this.client,
461
+ calls,
462
+ logger: this.logger
463
+ });
464
+ }
465
+ /**
452
466
  * Withdrawal compressor of the current chain.
453
467
  * @throws If no withdrawal compressor is supported on the current chain.
454
468
  **/
@@ -0,0 +1,69 @@
1
+ import { AddressMap } from "../../utils/AddressMap.js";
2
+ import { encodeFunctionData, isAddressEqual, parseAbi } from "viem";
3
+ //#region src/sdk/accounts/utils/midasUtils.ts
4
+ const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
5
+ const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
6
+ /**
7
+ * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
8
+ * see MidasMode in integrations-v3
9
+ */
10
+ const MIDAS_MODE_PERMISSIONLESS = 0;
11
+ const iMidasGatewayAdapterExtAbi = parseAbi(["function receiveGreenlist() external returns (bool)"]);
12
+ const iMidasGatewayModeAbi = parseAbi(["function mode() external view returns (uint8)"]);
13
+ const receiveGreenlistCallData = encodeFunctionData({
14
+ abi: iMidasGatewayAdapterExtAbi,
15
+ functionName: "receiveGreenlist"
16
+ });
17
+ /**
18
+ * Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
19
+ * multicall that mints an mToken through a Midas issuance vault.
20
+ *
21
+ * Permissioned and restricted-interface mTokens can only be held by greenlisted
22
+ * accounts, and a freshly opened credit account is never greenlisted, so the
23
+ * mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
24
+ * the greenlist first. Greenlisting the borrower is not enough — the role is
25
+ * checked on the token holder, which is the credit account.
26
+ *
27
+ * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
28
+ * vault is called, its mToken has no gateway adapter on this credit manager,
29
+ * the gateway is permissionless, or the call is already there.
30
+ */
31
+ async function prependMidasReceiveGreenlist(props) {
32
+ const { cm, client, calls, logger } = props;
33
+ const adapters = Array.from(cm.creditManager.adapters.values());
34
+ const gatewayByMToken = AddressMap.fromMappedArray(adapters.filter((a) => a.contractType === ADAPTER_MIDAS_GATEWAY), (a) => a.mToken);
35
+ const calledVaults = adapters.filter((a) => a.contractType === ADAPTER_MIDAS_ISSUANCE_VAULT).filter((vault) => calls.some((call) => isAddressEqual(call.target, vault.address)));
36
+ if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
37
+ const gateways = new AddressMap();
38
+ for (const vault of calledVaults) {
39
+ const gateway = gatewayByMToken.get(vault.mToken);
40
+ if (!gateway) logger?.debug(`midas: no gateway adapter for mToken ${vault.mToken} minted by ${vault.address} on ${cm.name}, cannot greenlist the credit account`);
41
+ else if (calls.some((call) => isAddressEqual(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
42
+ else gateways.upsert(gateway.address, gateway);
43
+ }
44
+ if (gateways.size === 0) return calls;
45
+ const uniqueGateways = gateways.values();
46
+ const modes = await client.multicall({
47
+ allowFailure: false,
48
+ contracts: uniqueGateways.map(({ targetContract }) => ({
49
+ address: targetContract,
50
+ abi: iMidasGatewayModeAbi,
51
+ functionName: "mode"
52
+ }))
53
+ });
54
+ const prepended = [];
55
+ for (const [i, gateway] of uniqueGateways.entries()) {
56
+ if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
57
+ logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
58
+ continue;
59
+ }
60
+ logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
61
+ prepended.push({
62
+ target: gateway.address,
63
+ callData: receiveGreenlistCallData
64
+ });
65
+ }
66
+ return prepended.length > 0 ? [...prepended, ...calls] : calls;
67
+ }
68
+ //#endregion
69
+ export { prependMidasReceiveGreenlist };
@@ -45,6 +45,8 @@ import "./base/index.js";
45
45
  import { PeripheryCompressorV310Contract } from "./accounts/bots/PeripheryCompressorV310Contract.js";
46
46
  import { AccountBotsService } from "./accounts/bots/AccountBotsService.js";
47
47
  import { PlaceholderAdapterContract } from "./market/adapters/PlaceholderAdapterContracts.js";
48
+ import { PlaceholderMidasGatewayAdapterContract } from "./market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js";
49
+ import { PlaceholderMidasIssuanceVaultAdapterContract } from "./market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
48
50
  import { createAdapter } from "./market/adapters/createAdapter.js";
49
51
  import { CreditConfiguratorV310Contract } from "./market/credit/CreditConfiguratorV310Contract.js";
50
52
  import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./market/credit/CreditFacadeV310BaseContract.js";
@@ -156,4 +158,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
156
158
  import { MultichainSDK } from "./MultichainSDK.js";
157
159
  import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
158
160
  import "./types/index.js";
159
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, IntentPreviewError, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcAdditionalBorrowApy, calcBorrowApy, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcPositionLeverage, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
161
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, IntentPreviewError, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PlaceholderMidasGatewayAdapterContract, PlaceholderMidasIssuanceVaultAdapterContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcAdditionalBorrowApy, calcBorrowApy, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcPositionLeverage, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
@@ -1,6 +1,9 @@
1
1
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
2
2
  import "../../utils/index.js";
3
3
  import { PlaceholderAdapterContract } from "./PlaceholderAdapterContracts.js";
4
+ import { PlaceholderMidasGatewayAdapterContract } from "./midas/PlaceholderMidasGatewayAdapterContract.js";
5
+ import { PlaceholderMidasIssuanceVaultAdapterContract } from "./midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
6
+ import "./midas/index.js";
4
7
  //#region src/sdk/market/adapters/createAdapter.ts
5
8
  function createAdapter(sdk, args) {
6
9
  const adapterType = bytes32ToString(args.baseParams.contractType);
@@ -13,7 +16,11 @@ function createAdapter(sdk, args) {
13
16
  } catch (e) {
14
17
  sdk.logger?.warn(`plugin ${name} error while trying to create ${adapterType} v${args.baseParams.version} at ${args.baseParams.addr}: ${e}`);
15
18
  }
16
- return new PlaceholderAdapterContract(sdk, args);
19
+ switch (adapterType) {
20
+ case "ADAPTER::MIDAS_GATEWAY": return new PlaceholderMidasGatewayAdapterContract(sdk, args);
21
+ case "ADAPTER::MIDAS_ISSUANCE_VAULT": return new PlaceholderMidasIssuanceVaultAdapterContract(sdk, args);
22
+ default: return new PlaceholderAdapterContract(sdk, args);
23
+ }
17
24
  }
18
25
  //#endregion
19
26
  export { createAdapter };
@@ -1,4 +1,7 @@
1
1
  import { PlaceholderAdapterContract } from "./PlaceholderAdapterContracts.js";
2
+ import { PlaceholderMidasGatewayAdapterContract } from "./midas/PlaceholderMidasGatewayAdapterContract.js";
3
+ import { PlaceholderMidasIssuanceVaultAdapterContract } from "./midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
4
+ import "./midas/index.js";
2
5
  import { createAdapter } from "./createAdapter.js";
3
6
  import "./types.js";
4
- export { PlaceholderAdapterContract, createAdapter };
7
+ export { PlaceholderAdapterContract, PlaceholderMidasGatewayAdapterContract, PlaceholderMidasIssuanceVaultAdapterContract, createAdapter };
@@ -0,0 +1,80 @@
1
+ import { MissingSerializedParamsError } from "../../../base/errors.js";
2
+ import "../../../base/index.js";
3
+ import { PlaceholderAdapterContract } from "../PlaceholderAdapterContracts.js";
4
+ import { decodeAbiParameters } from "viem";
5
+ //#region src/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.ts
6
+ var PlaceholderMidasGatewayAdapterContract = class PlaceholderMidasGatewayAdapterContract extends PlaceholderAdapterContract {
7
+ #gateway;
8
+ #mToken;
9
+ #quoteToken;
10
+ #phantomToken;
11
+ constructor(options, args) {
12
+ super(options, args);
13
+ if (args.baseParams.serializedParams) {
14
+ const decoded = PlaceholderMidasGatewayAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
15
+ this.#gateway = decoded.gateway;
16
+ this.#mToken = decoded.mToken;
17
+ this.#quoteToken = decoded.quoteToken;
18
+ this.#phantomToken = decoded.phantomToken;
19
+ }
20
+ }
21
+ static decodeSerializedParams(serialized) {
22
+ const [creditManager, targetContract, gateway, mToken, quoteToken, phantomToken, referrerId] = decodeAbiParameters([
23
+ {
24
+ type: "address",
25
+ name: "creditManager"
26
+ },
27
+ {
28
+ type: "address",
29
+ name: "targetContract"
30
+ },
31
+ {
32
+ type: "address",
33
+ name: "gateway"
34
+ },
35
+ {
36
+ type: "address",
37
+ name: "mToken"
38
+ },
39
+ {
40
+ type: "address",
41
+ name: "quoteToken"
42
+ },
43
+ {
44
+ type: "address",
45
+ name: "phantomToken"
46
+ },
47
+ {
48
+ type: "bytes32",
49
+ name: "referrerId"
50
+ }
51
+ ], serialized);
52
+ return {
53
+ creditManager,
54
+ targetContract,
55
+ gateway,
56
+ mToken,
57
+ quoteToken,
58
+ phantomToken,
59
+ referrerId
60
+ };
61
+ }
62
+ get gateway() {
63
+ if (!this.#gateway) throw new MissingSerializedParamsError("gateway");
64
+ return this.#gateway;
65
+ }
66
+ get mToken() {
67
+ if (!this.#mToken) throw new MissingSerializedParamsError("mToken");
68
+ return this.#mToken;
69
+ }
70
+ get quoteToken() {
71
+ if (!this.#quoteToken) throw new MissingSerializedParamsError("quoteToken");
72
+ return this.#quoteToken;
73
+ }
74
+ get phantomToken() {
75
+ if (!this.#phantomToken) throw new MissingSerializedParamsError("phantomToken");
76
+ return this.#phantomToken;
77
+ }
78
+ };
79
+ //#endregion
80
+ export { PlaceholderMidasGatewayAdapterContract };
@@ -0,0 +1,58 @@
1
+ import { MissingSerializedParamsError } from "../../../base/errors.js";
2
+ import "../../../base/index.js";
3
+ import { PlaceholderAdapterContract } from "../PlaceholderAdapterContracts.js";
4
+ import { decodeAbiParameters } from "viem";
5
+ //#region src/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.ts
6
+ var PlaceholderMidasIssuanceVaultAdapterContract = class PlaceholderMidasIssuanceVaultAdapterContract extends PlaceholderAdapterContract {
7
+ #mToken;
8
+ #allowedTokens;
9
+ constructor(options, args) {
10
+ super(options, args);
11
+ if (args.baseParams.serializedParams) {
12
+ const decoded = PlaceholderMidasIssuanceVaultAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
13
+ this.#mToken = decoded.mToken;
14
+ this.#allowedTokens = decoded.allowedTokens;
15
+ }
16
+ }
17
+ static decodeSerializedParams(serialized) {
18
+ const [creditManager, targetContract, mToken, referrerId, allowedTokens] = decodeAbiParameters([
19
+ {
20
+ type: "address",
21
+ name: "creditManager"
22
+ },
23
+ {
24
+ type: "address",
25
+ name: "targetContract"
26
+ },
27
+ {
28
+ type: "address",
29
+ name: "mToken"
30
+ },
31
+ {
32
+ type: "bytes32",
33
+ name: "referrerId"
34
+ },
35
+ {
36
+ type: "address[]",
37
+ name: "allowedTokens"
38
+ }
39
+ ], serialized);
40
+ return {
41
+ creditManager,
42
+ targetContract,
43
+ mToken,
44
+ referrerId,
45
+ allowedTokens: [...allowedTokens]
46
+ };
47
+ }
48
+ get mToken() {
49
+ if (!this.#mToken) throw new MissingSerializedParamsError("mToken");
50
+ return this.#mToken;
51
+ }
52
+ get allowedTokens() {
53
+ if (!this.#allowedTokens) throw new MissingSerializedParamsError("allowedTokens");
54
+ return this.#allowedTokens;
55
+ }
56
+ };
57
+ //#endregion
58
+ export { PlaceholderMidasIssuanceVaultAdapterContract };
@@ -0,0 +1,4 @@
1
+ import { PlaceholderMidasGatewayAdapterContract } from "./PlaceholderMidasGatewayAdapterContract.js";
2
+ import { PlaceholderMidasIssuanceVaultAdapterContract } from "./PlaceholderMidasIssuanceVaultAdapterContract.js";
3
+ import "./types.js";
4
+ export { PlaceholderMidasGatewayAdapterContract, PlaceholderMidasIssuanceVaultAdapterContract };
@@ -0,0 +1 @@
1
+ export {};