@gearbox-protocol/sdk 16.6.0-next.6 → 16.6.0-next.8

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.
@@ -188,12 +188,15 @@ async function discoverMidasGateways(sdk) {
188
188
  return new require_onchain_utils_AddressSet.AddressSet(suites.map((suite) => suite.gateway)).asArray();
189
189
  }
190
190
  /**
191
- * mTokens of all Midas gateway adapters of the loaded credit managers
191
+ * mTokens of the Midas credit suites of the loaded credit managers.
192
+ *
193
+ * A manager with a gateway adapter contributes that adapter's mToken, so its
194
+ * degen NFT is not consulted. Suites that only have a Midas degen NFT
195
+ * contribute the mToken read from the gateway.
192
196
  */
193
- function discoverMidasMTokens(sdk) {
194
- const mTokens = new require_onchain_utils_AddressSet.AddressSet();
195
- for (const cm of sdk.marketRegister.creditManagers) for (const adapter of cm.creditManager.adapters.values()) if (adapter instanceof require_onchain_market_adapters_contracts_MidasGatewayAdapterContract.MidasGatewayAdapterContract) mTokens.add(adapter.mToken);
196
- return mTokens.asArray();
197
+ async function discoverMidasMTokens(sdk) {
198
+ const suites = await discoverMidasCreditSuites(sdk);
199
+ return new require_onchain_utils_AddressSet.AddressSet(suites.map((suite) => suite.mToken)).asArray();
197
200
  }
198
201
  //#endregion
199
202
  exports.discoverMidasCreditSuites = discoverMidasCreditSuites;
@@ -55,7 +55,6 @@ function buildSwapOperation(input) {
55
55
  * underlying comes out.
56
56
  */
57
57
  function buildCloseSwapOperation(input) {
58
- if (input.calls.length === 0) throw new Error("swap: missing router calls");
59
58
  return {
60
59
  type: "swap",
61
60
  from: input.from,
@@ -3,11 +3,8 @@ const require_onchain_accounts_intents_utils_common = require("./common.js");
3
3
  const require_onchain_accounts_intents_utils_price_impact = require("./price-impact.js");
4
4
  //#region src/onchain/accounts/intents/utils/router-path.ts
5
5
  /**
6
- * The engine's only door to the pathfinder.
7
- *
8
- * Deliberately not a quoter abstraction with an oracle-priced twin: paths are
9
- * always resolved on-chain, because a preview whose swap amounts came from
10
- * oracle prices could not produce the calldata that realises them.
6
+ * The engine's only door to the pathfinder, and the only quoter whose legs can
7
+ * be sent. {@link createOraclePaths} is the twin for a walk that only projects.
11
8
  */
12
9
  function createRouterPaths(args) {
13
10
  const { sdk, creditAccount, slippage } = args;
@@ -92,6 +89,7 @@ function createRouterPaths(args) {
92
89
  amount,
93
90
  keep
94
91
  });
92
+ if (leg.calls.length === 0) throw new Error("swap: missing router calls");
95
93
  return {
96
94
  ...leg,
97
95
  probe: probe && {
@@ -108,6 +106,7 @@ function createRouterPaths(args) {
108
106
  route: async (quoted) => (await quoteClose(quoted)).amount
109
107
  });
110
108
  const { amount, minAmount, calls } = await quoteClose(balances);
109
+ if (calls.length === 0 && minAmount > 0n) throw new Error("closeAll: missing router calls");
111
110
  const leg = {
112
111
  amount,
113
112
  minAmount,
@@ -187,12 +187,15 @@ async function discoverMidasGateways(sdk) {
187
187
  return new AddressSet(suites.map((suite) => suite.gateway)).asArray();
188
188
  }
189
189
  /**
190
- * mTokens of all Midas gateway adapters of the loaded credit managers
190
+ * mTokens of the Midas credit suites of the loaded credit managers.
191
+ *
192
+ * A manager with a gateway adapter contributes that adapter's mToken, so its
193
+ * degen NFT is not consulted. Suites that only have a Midas degen NFT
194
+ * contribute the mToken read from the gateway.
191
195
  */
192
- function discoverMidasMTokens(sdk) {
193
- const mTokens = new AddressSet();
194
- for (const cm of sdk.marketRegister.creditManagers) for (const adapter of cm.creditManager.adapters.values()) if (adapter instanceof MidasGatewayAdapterContract) mTokens.add(adapter.mToken);
195
- return mTokens.asArray();
196
+ async function discoverMidasMTokens(sdk) {
197
+ const suites = await discoverMidasCreditSuites(sdk);
198
+ return new AddressSet(suites.map((suite) => suite.mToken)).asArray();
196
199
  }
197
200
  //#endregion
198
201
  export { discoverMidasCreditSuites, discoverMidasGateways, discoverMidasMTokens, unpauseMidasIssuanceVault };
@@ -54,7 +54,6 @@ function buildSwapOperation(input) {
54
54
  * underlying comes out.
55
55
  */
56
56
  function buildCloseSwapOperation(input) {
57
- if (input.calls.length === 0) throw new Error("swap: missing router calls");
58
57
  return {
59
58
  type: "swap",
60
59
  from: input.from,
@@ -2,11 +2,8 @@ import { toRouterCaSlice } from "./common.js";
2
2
  import { startProbe } from "./price-impact.js";
3
3
  //#region src/onchain/accounts/intents/utils/router-path.ts
4
4
  /**
5
- * The engine's only door to the pathfinder.
6
- *
7
- * Deliberately not a quoter abstraction with an oracle-priced twin: paths are
8
- * always resolved on-chain, because a preview whose swap amounts came from
9
- * oracle prices could not produce the calldata that realises them.
5
+ * The engine's only door to the pathfinder, and the only quoter whose legs can
6
+ * be sent. {@link createOraclePaths} is the twin for a walk that only projects.
10
7
  */
11
8
  function createRouterPaths(args) {
12
9
  const { sdk, creditAccount, slippage } = args;
@@ -91,6 +88,7 @@ function createRouterPaths(args) {
91
88
  amount,
92
89
  keep
93
90
  });
91
+ if (leg.calls.length === 0) throw new Error("swap: missing router calls");
94
92
  return {
95
93
  ...leg,
96
94
  probe: probe && {
@@ -107,6 +105,7 @@ function createRouterPaths(args) {
107
105
  route: async (quoted) => (await quoteClose(quoted)).amount
108
106
  });
109
107
  const { amount, minAmount, calls } = await quoteClose(balances);
108
+ if (calls.length === 0 && minAmount > 0n) throw new Error("closeAll: missing router calls");
110
109
  const leg = {
111
110
  amount,
112
111
  minAmount,
@@ -55,8 +55,12 @@ declare function discoverMidasCreditSuites(sdk: OnchainSDK): Promise<MidasCredit
55
55
  */
56
56
  declare function discoverMidasGateways(sdk: OnchainSDK): Promise<Address[]>;
57
57
  /**
58
- * mTokens of all Midas gateway adapters of the loaded credit managers
58
+ * mTokens of the Midas credit suites of the loaded credit managers.
59
+ *
60
+ * A manager with a gateway adapter contributes that adapter's mToken, so its
61
+ * degen NFT is not consulted. Suites that only have a Midas degen NFT
62
+ * contribute the mToken read from the gateway.
59
63
  */
60
- declare function discoverMidasMTokens(sdk: OnchainSDK): Address[];
64
+ declare function discoverMidasMTokens(sdk: OnchainSDK): Promise<Address[]>;
61
65
  //#endregion
62
66
  export { MidasCreditSuite, RestoreMidasIssuanceVaultPause, UnpauseMidasIssuanceVaultProps, discoverMidasCreditSuites, discoverMidasGateways, discoverMidasMTokens, unpauseMidasIssuanceVault };
@@ -64,11 +64,8 @@ interface RouterPaths {
64
64
  }): Promise<OpenStrategyLeg>;
65
65
  }
66
66
  /**
67
- * The engine's only door to the pathfinder.
68
- *
69
- * Deliberately not a quoter abstraction with an oracle-priced twin: paths are
70
- * always resolved on-chain, because a preview whose swap amounts came from
71
- * oracle prices could not produce the calldata that realises them.
67
+ * The engine's only door to the pathfinder, and the only quoter whose legs can
68
+ * be sent. {@link createOraclePaths} is the twin for a walk that only projects.
72
69
  */
73
70
  declare function createRouterPaths(args: {
74
71
  sdk: OnchainSDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.6.0-next.6",
3
+ "version": "16.6.0-next.8",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {