@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
@@ -2,6 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_sdk_utils_bytes32ToString = require("../../utils/bytes32ToString.js");
3
3
  require("../../utils/index.js");
4
4
  const require_sdk_market_adapters_PlaceholderAdapterContracts = require("./PlaceholderAdapterContracts.js");
5
+ const require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract = require("./midas/PlaceholderMidasGatewayAdapterContract.js");
6
+ const require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract = require("./midas/PlaceholderMidasIssuanceVaultAdapterContract.js");
7
+ require("./midas/index.js");
5
8
  //#region src/sdk/market/adapters/createAdapter.ts
6
9
  function createAdapter(sdk, args) {
7
10
  const adapterType = require_sdk_utils_bytes32ToString.bytes32ToString(args.baseParams.contractType);
@@ -14,7 +17,11 @@ function createAdapter(sdk, args) {
14
17
  } catch (e) {
15
18
  sdk.logger?.warn(`plugin ${name} error while trying to create ${adapterType} v${args.baseParams.version} at ${args.baseParams.addr}: ${e}`);
16
19
  }
17
- return new require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract(sdk, args);
20
+ switch (adapterType) {
21
+ case "ADAPTER::MIDAS_GATEWAY": return new require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract.PlaceholderMidasGatewayAdapterContract(sdk, args);
22
+ case "ADAPTER::MIDAS_ISSUANCE_VAULT": return new require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract.PlaceholderMidasIssuanceVaultAdapterContract(sdk, args);
23
+ default: return new require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract(sdk, args);
24
+ }
18
25
  }
19
26
  //#endregion
20
27
  exports.createAdapter = createAdapter;
@@ -1,6 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_sdk_market_adapters_PlaceholderAdapterContracts = require("./PlaceholderAdapterContracts.js");
3
+ const require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract = require("./midas/PlaceholderMidasGatewayAdapterContract.js");
4
+ const require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract = require("./midas/PlaceholderMidasIssuanceVaultAdapterContract.js");
5
+ require("./midas/index.js");
3
6
  const require_sdk_market_adapters_createAdapter = require("./createAdapter.js");
4
7
  require("./types.js");
5
8
  exports.PlaceholderAdapterContract = require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract;
9
+ exports.PlaceholderMidasGatewayAdapterContract = require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract.PlaceholderMidasGatewayAdapterContract;
10
+ exports.PlaceholderMidasIssuanceVaultAdapterContract = require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract.PlaceholderMidasIssuanceVaultAdapterContract;
6
11
  exports.createAdapter = require_sdk_market_adapters_createAdapter.createAdapter;
@@ -0,0 +1,81 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_base_errors = require("../../../base/errors.js");
3
+ require("../../../base/index.js");
4
+ const require_sdk_market_adapters_PlaceholderAdapterContracts = require("../PlaceholderAdapterContracts.js");
5
+ let viem = require("viem");
6
+ //#region src/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.ts
7
+ var PlaceholderMidasGatewayAdapterContract = class PlaceholderMidasGatewayAdapterContract extends require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract {
8
+ #gateway;
9
+ #mToken;
10
+ #quoteToken;
11
+ #phantomToken;
12
+ constructor(options, args) {
13
+ super(options, args);
14
+ if (args.baseParams.serializedParams) {
15
+ const decoded = PlaceholderMidasGatewayAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
16
+ this.#gateway = decoded.gateway;
17
+ this.#mToken = decoded.mToken;
18
+ this.#quoteToken = decoded.quoteToken;
19
+ this.#phantomToken = decoded.phantomToken;
20
+ }
21
+ }
22
+ static decodeSerializedParams(serialized) {
23
+ const [creditManager, targetContract, gateway, mToken, quoteToken, phantomToken, referrerId] = (0, viem.decodeAbiParameters)([
24
+ {
25
+ type: "address",
26
+ name: "creditManager"
27
+ },
28
+ {
29
+ type: "address",
30
+ name: "targetContract"
31
+ },
32
+ {
33
+ type: "address",
34
+ name: "gateway"
35
+ },
36
+ {
37
+ type: "address",
38
+ name: "mToken"
39
+ },
40
+ {
41
+ type: "address",
42
+ name: "quoteToken"
43
+ },
44
+ {
45
+ type: "address",
46
+ name: "phantomToken"
47
+ },
48
+ {
49
+ type: "bytes32",
50
+ name: "referrerId"
51
+ }
52
+ ], serialized);
53
+ return {
54
+ creditManager,
55
+ targetContract,
56
+ gateway,
57
+ mToken,
58
+ quoteToken,
59
+ phantomToken,
60
+ referrerId
61
+ };
62
+ }
63
+ get gateway() {
64
+ if (!this.#gateway) throw new require_sdk_base_errors.MissingSerializedParamsError("gateway");
65
+ return this.#gateway;
66
+ }
67
+ get mToken() {
68
+ if (!this.#mToken) throw new require_sdk_base_errors.MissingSerializedParamsError("mToken");
69
+ return this.#mToken;
70
+ }
71
+ get quoteToken() {
72
+ if (!this.#quoteToken) throw new require_sdk_base_errors.MissingSerializedParamsError("quoteToken");
73
+ return this.#quoteToken;
74
+ }
75
+ get phantomToken() {
76
+ if (!this.#phantomToken) throw new require_sdk_base_errors.MissingSerializedParamsError("phantomToken");
77
+ return this.#phantomToken;
78
+ }
79
+ };
80
+ //#endregion
81
+ exports.PlaceholderMidasGatewayAdapterContract = PlaceholderMidasGatewayAdapterContract;
@@ -0,0 +1,59 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_base_errors = require("../../../base/errors.js");
3
+ require("../../../base/index.js");
4
+ const require_sdk_market_adapters_PlaceholderAdapterContracts = require("../PlaceholderAdapterContracts.js");
5
+ let viem = require("viem");
6
+ //#region src/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.ts
7
+ var PlaceholderMidasIssuanceVaultAdapterContract = class PlaceholderMidasIssuanceVaultAdapterContract extends require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract {
8
+ #mToken;
9
+ #allowedTokens;
10
+ constructor(options, args) {
11
+ super(options, args);
12
+ if (args.baseParams.serializedParams) {
13
+ const decoded = PlaceholderMidasIssuanceVaultAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
14
+ this.#mToken = decoded.mToken;
15
+ this.#allowedTokens = decoded.allowedTokens;
16
+ }
17
+ }
18
+ static decodeSerializedParams(serialized) {
19
+ const [creditManager, targetContract, mToken, referrerId, allowedTokens] = (0, viem.decodeAbiParameters)([
20
+ {
21
+ type: "address",
22
+ name: "creditManager"
23
+ },
24
+ {
25
+ type: "address",
26
+ name: "targetContract"
27
+ },
28
+ {
29
+ type: "address",
30
+ name: "mToken"
31
+ },
32
+ {
33
+ type: "bytes32",
34
+ name: "referrerId"
35
+ },
36
+ {
37
+ type: "address[]",
38
+ name: "allowedTokens"
39
+ }
40
+ ], serialized);
41
+ return {
42
+ creditManager,
43
+ targetContract,
44
+ mToken,
45
+ referrerId,
46
+ allowedTokens: [...allowedTokens]
47
+ };
48
+ }
49
+ get mToken() {
50
+ if (!this.#mToken) throw new require_sdk_base_errors.MissingSerializedParamsError("mToken");
51
+ return this.#mToken;
52
+ }
53
+ get allowedTokens() {
54
+ if (!this.#allowedTokens) throw new require_sdk_base_errors.MissingSerializedParamsError("allowedTokens");
55
+ return this.#allowedTokens;
56
+ }
57
+ };
58
+ //#endregion
59
+ exports.PlaceholderMidasIssuanceVaultAdapterContract = PlaceholderMidasIssuanceVaultAdapterContract;
@@ -0,0 +1,6 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract = require("./PlaceholderMidasGatewayAdapterContract.js");
3
+ const require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract = require("./PlaceholderMidasIssuanceVaultAdapterContract.js");
4
+ require("./types.js");
5
+ exports.PlaceholderMidasGatewayAdapterContract = require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract.PlaceholderMidasGatewayAdapterContract;
6
+ exports.PlaceholderMidasIssuanceVaultAdapterContract = require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract.PlaceholderMidasIssuanceVaultAdapterContract;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_sdk_market_adapters_PlaceholderAdapterContracts = require("./adapters/PlaceholderAdapterContracts.js");
3
+ const require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract = require("./adapters/midas/PlaceholderMidasGatewayAdapterContract.js");
4
+ const require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract = require("./adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js");
3
5
  const require_sdk_market_adapters_createAdapter = require("./adapters/createAdapter.js");
4
6
  require("./adapters/index.js");
5
7
  const require_sdk_market_credit_CreditConfiguratorV310Contract = require("./credit/CreditConfiguratorV310Contract.js");
@@ -94,6 +96,8 @@ exports.PHANTOM_TOKEN_SECURITIZE_REDEMPTION = require_sdk_market_rwa_securitize_
94
96
  exports.PartialPriceFeedInitError = require_sdk_market_pricefeeds_AbstractPriceFeed.PartialPriceFeedInitError;
95
97
  exports.PendleTWAPPTPriceFeed = require_sdk_market_pricefeeds_PendleTWAPPTPriceFeed.PendleTWAPPTPriceFeed;
96
98
  exports.PlaceholderAdapterContract = require_sdk_market_adapters_PlaceholderAdapterContracts.PlaceholderAdapterContract;
99
+ exports.PlaceholderMidasGatewayAdapterContract = require_sdk_market_adapters_midas_PlaceholderMidasGatewayAdapterContract.PlaceholderMidasGatewayAdapterContract;
100
+ exports.PlaceholderMidasIssuanceVaultAdapterContract = require_sdk_market_adapters_midas_PlaceholderMidasIssuanceVaultAdapterContract.PlaceholderMidasIssuanceVaultAdapterContract;
97
101
  exports.PoolSuite = require_sdk_market_pool_PoolSuite.PoolSuite;
98
102
  exports.PoolV310Contract = require_sdk_market_pool_PoolV310Contract.PoolV310Contract;
99
103
  exports.PriceFeedRef = require_sdk_market_pricefeeds_PriceFeedRef.PriceFeedRef;
@@ -1,8 +1,7 @@
1
- import { BigIntMath } from "../sdk/utils/bigint-math.js";
2
- import { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./utils/creditAccount/quota-utils.js";
3
- import { EXECUTE_BYTES_SELECTOR, collectTraces, findCallTo, findCallWithInput, findExecuteBytes, resolveProtocolCall } from "./utils/trace.js";
4
1
  import { AxiosCache } from "./axios-cache/AxiosCache.js";
5
2
  import "./axios-cache/index.js";
3
+ import { BigIntMath } from "../sdk/utils/bigint-math.js";
4
+ import { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./utils/creditAccount/quota-utils.js";
6
5
  import { ChartsCreditManagerData } from "./charts/credit-manager.js";
7
6
  import { CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, CreditSession, CreditSessionFiltered, UserCreditSessionsBuilder } from "./charts/credit-session.js";
8
7
  import { ChartsPoolData, UserPoolData } from "./charts/pool.js";
@@ -92,5 +91,6 @@ import { getCMYouCanEarn } from "./utils/strategies/strategy-info/get-cm-you-can
92
91
  import { getStrategyInfoCore } from "./utils/strategies/strategy-info/get-strategy-info-core.js";
93
92
  import { getStrategyInfo } from "./utils/strategies/strategy-info/get-strategy-info.js";
94
93
  import { getStrategyYouCanEarn } from "./utils/strategies/strategy-info/get-strategy-you-can-earn.js";
94
+ import { EXECUTE_BYTES_SELECTOR, collectTraces, findCallTo, findCallWithInput, findExecuteBytes, resolveProtocolCall } from "./utils/trace.js";
95
95
  import "./utils/index.js";
96
96
  export { AssetUtils, AxiosCache, BONUS_APY_FROM_POINTS, BigIntMath, CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, ChartsCreditManagerData, ChartsPoolData, CreditSession, CreditSessionFiltered, EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT, EXECUTE_BYTES_SELECTOR, MIN_HF_LIMITED, PriceUtils, RST_ETH_ADDRESS, TokenData, UserCreditSessionsBuilder, UserPoolData, addAmountInTarget, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, calculateBorrowRateFromUtilization, calculateEarnings, calculateEffectiveBorrowRate, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateSafeBorrowRate, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkDegenNFT, cmAvailabilityCondition, collectTraces, createLegacyStrategyDataSource, findCallTo, findCallWithInput, findExecuteBytes, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexAPYList, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRateWithFee, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getSafeBaseBorrowRate, getSingleQuotaBorrowRate, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getTimeToLiquidation, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, isZeroBalance, liquidationPrice, maxAPYFormula, maxLeverage, maxLeverageThreshold, resolveProtocolCall, roundUpQuota, sortAssets, sortBalances, sortStrategyCMsByAvailability, tokensAbcComparator, validateBalance, validateBalances, validateCreditManager, validateHF, validateOpenAccount, validateOpenAccountPoolQuotaStatus, validateOpenAccountPoolStatus, validateQuota, validateTokenToObtain, wrapTokenAddress };
@@ -1,6 +1,5 @@
1
1
  import { BigIntMath } from "../../sdk/utils/bigint-math.js";
2
2
  import { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./creditAccount/quota-utils.js";
3
- import { EXECUTE_BYTES_SELECTOR, collectTraces, findCallTo, findCallWithInput, findExecuteBytes, resolveProtocolCall } from "./trace.js";
4
3
  import { BONUS_APY_FROM_POINTS } from "./apy/bonus-apy-from-points.js";
5
4
  import { calculateBorrowRateFromUtilization } from "./apy/calculate-borrow-rate-from-utilization.js";
6
5
  import { PriceUtils } from "./price-math.js";
@@ -87,5 +86,6 @@ import { getStrategyInfoCore } from "./strategies/strategy-info/get-strategy-inf
87
86
  import { getStrategyInfo } from "./strategies/strategy-info/get-strategy-info.js";
88
87
  import { getStrategyYouCanEarn } from "./strategies/strategy-info/get-strategy-you-can-earn.js";
89
88
  import "./strategies/index.js";
89
+ import { EXECUTE_BYTES_SELECTOR, collectTraces, findCallTo, findCallWithInput, findExecuteBytes, resolveProtocolCall } from "./trace.js";
90
90
  import "./validation/index.js";
91
91
  export { AssetUtils, BONUS_APY_FROM_POINTS, BigIntMath, EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT, EXECUTE_BYTES_SELECTOR, MIN_HF_LIMITED, PriceUtils, RST_ETH_ADDRESS, addAmountInTarget, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, calculateBorrowRateFromUtilization, calculateEarnings, calculateEffectiveBorrowRate, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateSafeBorrowRate, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkDegenNFT, cmAvailabilityCondition, collectTraces, createLegacyStrategyDataSource, findCallTo, findCallWithInput, findExecuteBytes, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexAPYList, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRateWithFee, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getSafeBaseBorrowRate, getSingleQuotaBorrowRate, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getTimeToLiquidation, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, isZeroBalance, liquidationPrice, maxAPYFormula, maxLeverage, maxLeverageThreshold, resolveProtocolCall, roundUpQuota, sortAssets, sortBalances, sortStrategyCMsByAvailability, tokensAbcComparator, validateBalance, validateBalances, validateCreditManager, validateHF, validateOpenAccount, validateOpenAccountPoolQuotaStatus, validateOpenAccountPoolStatus, validateQuota, validateTokenToObtain, wrapTokenAddress };
@@ -13,7 +13,6 @@ import "../sdk/index.js";
13
13
  import { iDegenNftv2Abi } from "./abi.js";
14
14
  import { claimFromFaucet } from "./claimFromFaucet.js";
15
15
  import { extendAnvilClient } from "./createAnvilClient.js";
16
- import { prependMidasReceiveGreenlist } from "./midasUtils.js";
17
16
  import { createMinter } from "./mint/factory.js";
18
17
  import "./mint/index.js";
19
18
  import { BaseError, erc20Abi, isAddress, parseEther, parseEventLogs } from "viem";
@@ -252,12 +251,6 @@ var AccountOpener = class extends SDKConstruct {
252
251
  target
253
252
  });
254
253
  logger?.debug(strategy, "found open strategy");
255
- const strategyCalls = await prependMidasReceiveGreenlist({
256
- cm,
257
- client: this.#anvil,
258
- calls: strategy.calls,
259
- logger
260
- });
261
254
  const debt = minDebt * (leverage - PERCENTAGE_FACTOR) / PERCENTAGE_FACTOR;
262
255
  const averageQuota = this.#getCollateralQuota(cm, target, strategy.amount, debt, logger);
263
256
  const minQuota = this.#getCollateralQuota(cm, target, strategy.minAmount, debt, logger);
@@ -284,7 +277,7 @@ var AccountOpener = class extends SDKConstruct {
284
277
  balance: minDebt
285
278
  }],
286
279
  debt,
287
- calls: strategyCalls,
280
+ calls: strategy.calls,
288
281
  ethAmount: 0n,
289
282
  permits: {},
290
283
  to: borrower.address,
@@ -1,8 +1,6 @@
1
1
  import { faucetAbi, iDegenNftv2Abi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi } from "./abi.js";
2
2
  import { claimFromFaucet } from "./claimFromFaucet.js";
3
3
  import { anvilNodeInfo, createAnvilClient, evmMineDetailed, extendAnvilClient, isAnvil } from "./createAnvilClient.js";
4
- import { greenlistMidasGateway, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, writeAndWait } from "./kycUtils.js";
5
- import { prependMidasReceiveGreenlist, unpauseMidasIssuanceVault } from "./midasUtils.js";
6
4
  import { createMinter } from "./mint/factory.js";
7
5
  import "./mint/index.js";
8
6
  import { AccountOpener, OpenTxRevertedError } from "./AccountOpener.js";
@@ -15,8 +13,10 @@ import { detectChain } from "./detectChain.js";
15
13
  import { isOutOfSyncError } from "./isOutOfSyncError.js";
16
14
  import { isRateLimitError } from "./isRateLimitError.js";
17
15
  import { isTransientError } from "./isTransientError.js";
16
+ import { greenlistMidasGateway, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, writeAndWait } from "./kycUtils.js";
18
17
  import { isRangeError, logSplitterTransport } from "./logSplitterTransport.js";
19
18
  import { setLTZero, setLTs } from "./ltUtils.js";
19
+ import { unpauseMidasIssuanceVault } from "./midasUtils.js";
20
20
  import { migrateFaucet } from "./migrateFaucet.js";
21
21
  import { SUPPORTED_RPC_PROVIDERS, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getRpcProviderUrl, getThirdWebUrl, rpcProvidersSchema } from "./providers.js";
22
22
  import { replaceStorage } from "./replaceStorage.js";
@@ -25,4 +25,4 @@ import { claimDSToken, claimDSTokens, enableDSTokenBackDating } from "./securiti
25
25
  import "./types.js";
26
26
  import { ONCHAIN_EXECUTION_ID_ADDRESS, verifyTestnet } from "./verifyTestnet.js";
27
27
  import { makePendingWithdrawalsClaimable } from "./withdrawalUtils.js";
28
- export { AccountOpener, Create2Deployer, DEFAULT_CREATE2_SALT, EthCallSpy, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, RevolverTransport, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain, enableDSTokenBackDating, evmMineDetailed, extendAnvilClient, faucetAbi, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getPublicCreate2Address, getRpcProviderUrl, getThirdWebUrl, greenlistMidasGateway, httpTransportOptionsSchema, iDegenNftv2Abi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi, isAnvil, isDeployedUsingPublicCreate2, isOutOfSyncError, isRangeError, isRateLimitError, isTransientError, logSplitterTransport, makePendingWithdrawalsClaimable, migrateFaucet, prependMidasReceiveGreenlist, providerConfigSchema, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, replaceStorage, resilientTransport, resilientTransportOptionsSchema, revolverTransportConfigBaseSchema, revolverTransportConfigSchema, rpcProvidersSchema, setLTZero, setLTs, unpauseMidasIssuanceVault, verifyTestnet, writeAndWait };
28
+ export { AccountOpener, Create2Deployer, DEFAULT_CREATE2_SALT, EthCallSpy, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, RevolverTransport, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain, enableDSTokenBackDating, evmMineDetailed, extendAnvilClient, faucetAbi, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getPublicCreate2Address, getRpcProviderUrl, getThirdWebUrl, greenlistMidasGateway, httpTransportOptionsSchema, iDegenNftv2Abi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi, isAnvil, isDeployedUsingPublicCreate2, isOutOfSyncError, isRangeError, isRateLimitError, isTransientError, logSplitterTransport, makePendingWithdrawalsClaimable, migrateFaucet, providerConfigSchema, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, replaceStorage, resilientTransport, resilientTransportOptionsSchema, revolverTransportConfigBaseSchema, revolverTransportConfigSchema, rpcProvidersSchema, setLTZero, setLTs, unpauseMidasIssuanceVault, verifyTestnet, writeAndWait };
@@ -1,21 +1,6 @@
1
- import { midasGatewayAbi } from "./withdrawalAbi.js";
2
1
  import { writeAndWait } from "./kycUtils.js";
3
- import { encodeFunctionData, isAddressEqual, parseAbi, parseEther } from "viem";
2
+ import { parseAbi, parseEther } from "viem";
4
3
  //#region src/dev/midasUtils.ts
5
- const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
6
- const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
7
- /**
8
- * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
9
- * see MidasMode in integrations-v3
10
- */
11
- const MIDAS_MODE_PERMISSIONLESS = 0;
12
- /**
13
- * Gateways and issuance vaults both expose their mToken, but only on-chain:
14
- * without the adapters plugin the SDK represents adapters as placeholders that
15
- * expose nothing but their target contract
16
- */
17
- const iMidasMTokenAbi = parseAbi(["function mToken() external view returns (address)"]);
18
- const iMidasGatewayAdapterExtAbi = parseAbi(["function receiveGreenlist() external returns (bool)"]);
19
4
  /**
20
5
  * Midas vaults inherit their own `Pausable`, whose global pause is guarded by
21
6
  * `pauseAdminRole()` in the vault's access control instead of `Ownable`
@@ -28,76 +13,6 @@ const iMidasPausableVaultAbi = parseAbi([
28
13
  "function accessControl() external view returns (address)"
29
14
  ]);
30
15
  const iMidasAccessControlAbi = parseAbi(["function hasRole(bytes32 role, address account) external view returns (bool)", "function grantRole(bytes32 role, address account) external"]);
31
- const receiveGreenlistCallData = encodeFunctionData({
32
- abi: iMidasGatewayAdapterExtAbi,
33
- functionName: "receiveGreenlist"
34
- });
35
- /**
36
- * Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
37
- * multicall that mints an mToken through a Midas issuance vault.
38
- *
39
- * Permissioned and restricted-interface mTokens can only be held by greenlisted
40
- * accounts, and a freshly opened credit account is never greenlisted, so the
41
- * mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
42
- * the greenlist first. Greenlisting the borrower (see `registerMidasInvestor`)
43
- * is not enough — the role is checked on the token holder, which is the credit
44
- * account.
45
- *
46
- * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
47
- * vault is called, its mToken has no gateway adapter on this credit manager,
48
- * the gateway is permissionless, or the call is already there.
49
- */
50
- async function prependMidasReceiveGreenlist(props) {
51
- const { cm, client, calls, logger } = props;
52
- const gatewayAdapters = [];
53
- const issuanceAdapters = [];
54
- for (const adapter of cm.creditManager.adapters.values()) switch (adapter.contractType) {
55
- case ADAPTER_MIDAS_GATEWAY:
56
- gatewayAdapters.push(adapter);
57
- break;
58
- case ADAPTER_MIDAS_ISSUANCE_VAULT: issuanceAdapters.push(adapter);
59
- }
60
- if (gatewayAdapters.length === 0) return calls;
61
- const calledIssuanceAdapters = issuanceAdapters.filter((adapter) => calls.some((call) => isAddressEqual(call.target, adapter.address)));
62
- if (calledIssuanceAdapters.length === 0) return calls;
63
- const [gatewayMTokens, issuanceMTokens] = await Promise.all([readMTokens(client, gatewayAdapters), readMTokens(client, calledIssuanceAdapters)]);
64
- const gateways = [];
65
- for (const [i, mToken] of issuanceMTokens.entries()) {
66
- const gateway = gatewayAdapters.find((_, j) => isAddressEqual(gatewayMTokens[j], mToken));
67
- if (!gateway) {
68
- logger?.debug(`midas: no gateway adapter for mToken ${mToken} minted by ${calledIssuanceAdapters[i].address} on ${cm.name}, cannot greenlist the credit account`);
69
- continue;
70
- }
71
- if (gateways.some((g) => isAddressEqual(g.address, gateway.address))) continue;
72
- if (calls.some((call) => isAddressEqual(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) {
73
- logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
74
- continue;
75
- }
76
- gateways.push(gateway);
77
- }
78
- if (gateways.length === 0) return calls;
79
- const modes = await client.multicall({
80
- allowFailure: false,
81
- contracts: gateways.map(({ targetContract }) => ({
82
- address: targetContract,
83
- abi: midasGatewayAbi,
84
- functionName: "mode"
85
- }))
86
- });
87
- const prepended = [];
88
- for (const [i, gateway] of gateways.entries()) {
89
- if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
90
- logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
91
- continue;
92
- }
93
- logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
94
- prepended.push({
95
- target: gateway.address,
96
- callData: receiveGreenlistCallData
97
- });
98
- }
99
- return prepended.length > 0 ? [...prepended, ...calls] : calls;
100
- }
101
16
  /**
102
17
  * Unpauses a globally paused Midas issuance vault on an anvil fork, so that
103
18
  * `depositInstant` stops reverting with `Pausable: paused`, and returns a
@@ -188,15 +103,5 @@ async function unpauseMidasIssuanceVault(props) {
188
103
  }
189
104
  };
190
105
  }
191
- async function readMTokens(client, adapters) {
192
- return await client.multicall({
193
- allowFailure: false,
194
- contracts: adapters.map(({ targetContract }) => ({
195
- address: targetContract,
196
- abi: iMidasMTokenAbi,
197
- functionName: "mToken"
198
- }))
199
- });
200
- }
201
106
  //#endregion
202
- export { prependMidasReceiveGreenlist, unpauseMidasIssuanceVault };
107
+ export { unpauseMidasIssuanceVault };
@@ -9,8 +9,8 @@ import "./errors/index.js";
9
9
  import { AbstractNamespace } from "./AbstractNamespace.js";
10
10
  import { ExecuteApi } from "./execute/ExecuteApi.js";
11
11
  import "./execute/index.js";
12
- import { SimulateApi } from "./simulate/SimulateApi.js";
13
- import "./simulate/index.js";
12
+ import { PrepareApi } from "./prepare/PrepareApi.js";
13
+ import "./prepare/index.js";
14
14
  import { filterResponse } from "./utils/filterResponse.js";
15
15
  import { DEFAULT_MAX_OFFCHAIN_LAG, mergeChainList, mergeChainOne } from "./utils/mergeChains.js";
16
16
  import "./utils/index.js";
@@ -20,4 +20,4 @@ import { PositionsNamespace } from "./positions/PositionsNamespace.js";
20
20
  import "./positions/index.js";
21
21
  import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
22
22
  import "./types.js";
23
- export { AbstractNamespace, AllSourcesFailedError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, SimulateApi, SourceChainMismatchError, SourceUnavailableError, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
23
+ export { AbstractNamespace, AllSourcesFailedError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, SourceChainMismatchError, SourceUnavailableError, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
@@ -5,8 +5,8 @@ import "../errors/index.js";
5
5
  import { AbstractNamespace } from "../AbstractNamespace.js";
6
6
  import { ExecuteApi } from "../execute/ExecuteApi.js";
7
7
  import "../execute/index.js";
8
- import { SimulateApi } from "../simulate/SimulateApi.js";
9
- import "../simulate/index.js";
8
+ import { PrepareApi } from "../prepare/PrepareApi.js";
9
+ import "../prepare/index.js";
10
10
  import { filterResponse } from "../utils/filterResponse.js";
11
11
  import { mergeChainList, mergeChainOne } from "../utils/mergeChains.js";
12
12
  import "../utils/index.js";
@@ -24,19 +24,19 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
24
24
  pool: (onchain, offchain) => mergeChainOne(onchain, offchain, this.maxOffchainLagSeconds),
25
25
  strategy: (onchain, offchain) => mergeChainOne(onchain, offchain, this.maxOffchainLagSeconds)
26
26
  };
27
- #simulate;
27
+ #prepare;
28
28
  #execute;
29
29
  constructor(onchain, offchain, options) {
30
30
  super("Opportunities", onchain?.opportunities, offchain?.opportunities, options);
31
- this.#simulate = onchain && new SimulateApi(onchain, options.ensureFresh);
31
+ this.#prepare = onchain && new PrepareApi(onchain, options.ensureFresh);
32
32
  this.#execute = onchain && new ExecuteApi((chainId) => onchain.chain(chainId));
33
33
  }
34
34
  /**
35
- * {@inheritDoc OpportunitiesOnchainOnly.simulate}
35
+ * {@inheritDoc OpportunitiesOnchainOnly.prepare}
36
36
  **/
37
- get simulate() {
38
- if (!this.#simulate) throw new SourceUnavailableError("Opportunities", "onchain");
39
- return this.#simulate;
37
+ get prepare() {
38
+ if (!this.#prepare) throw new SourceUnavailableError("Opportunities", "onchain");
39
+ return this.#prepare;
40
40
  }
41
41
  /**
42
42
  * {@inheritDoc OpportunitiesOnchainOnly.execute}