@gearbox-protocol/sdk 16.4.0-next.10 → 16.4.0-next.11

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.
@@ -213,6 +213,7 @@ var CreditAccountsServiceV310 = class extends require_onchain_base_SDKConstruct.
213
213
  }),
214
214
  ...callsAfter ?? []
215
215
  ];
216
+ calls = await this.#prependMidasReceiveGreenlist(cm.address, calls);
216
217
  calls = await this.prependPriceUpdates(cm.address, calls);
217
218
  const tx = reopenCreditAccount ? cmSuite.multicallTx(reopenCreditAccount, calls, rwaOptions) : cmSuite.openCreditAccountTx(to, calls, referralCode, rwaOptions);
218
219
  tx.value = ethAmount.toString(10);
@@ -4,6 +4,7 @@ let viem = require("viem");
4
4
  //#region src/onchain/accounts/utils/midasUtils.ts
5
5
  const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
6
6
  const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
7
+ const MGLOBAL_MTOKEN = (0, viem.getAddress)("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
7
8
  /**
8
9
  * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
9
10
  * see MidasMode in integrations-v3
@@ -27,7 +28,8 @@ const receiveGreenlistCallData = (0, viem.encodeFunctionData)({
27
28
  *
28
29
  * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
29
30
  * vault is called, its mToken has no gateway adapter on this credit manager,
30
- * the gateway is permissionless, or the call is already there.
31
+ * the gateway is permissionless, the call is already there, or the mToken is
32
+ * mGLOBAL (temporary: its gateway cannot grant the greenlist).
31
33
  */
32
34
  async function prependMidasReceiveGreenlist(props) {
33
35
  const { cm, client, calls, logger } = props;
@@ -37,6 +39,10 @@ async function prependMidasReceiveGreenlist(props) {
37
39
  if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
38
40
  const gateways = new require_onchain_utils_AddressMap.AddressMap();
39
41
  for (const vault of calledVaults) {
42
+ if ((0, viem.isAddressEqual)(vault.mToken, MGLOBAL_MTOKEN)) {
43
+ logger?.debug(`midas: skipping receiveGreenlist for mGLOBAL ${vault.mToken}`);
44
+ continue;
45
+ }
40
46
  const gateway = gatewayByMToken.get(vault.mToken);
41
47
  if (!gateway) logger?.debug(`midas: no gateway adapter for mToken ${vault.mToken} minted by ${vault.address} on ${cm.name}, cannot greenlist the credit account`);
42
48
  else if (calls.some((call) => (0, viem.isAddressEqual)(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
@@ -212,6 +212,7 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
212
212
  }),
213
213
  ...callsAfter ?? []
214
214
  ];
215
+ calls = await this.#prependMidasReceiveGreenlist(cm.address, calls);
215
216
  calls = await this.prependPriceUpdates(cm.address, calls);
216
217
  const tx = reopenCreditAccount ? cmSuite.multicallTx(reopenCreditAccount, calls, rwaOptions) : cmSuite.openCreditAccountTx(to, calls, referralCode, rwaOptions);
217
218
  tx.value = ethAmount.toString(10);
@@ -1,8 +1,9 @@
1
1
  import { AddressMap } from "../../utils/AddressMap.js";
2
- import { encodeFunctionData, isAddressEqual, parseAbi } from "viem";
2
+ import { encodeFunctionData, getAddress, isAddressEqual, parseAbi } from "viem";
3
3
  //#region src/onchain/accounts/utils/midasUtils.ts
4
4
  const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
5
5
  const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
6
+ const MGLOBAL_MTOKEN = getAddress("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
6
7
  /**
7
8
  * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
8
9
  * see MidasMode in integrations-v3
@@ -26,7 +27,8 @@ const receiveGreenlistCallData = encodeFunctionData({
26
27
  *
27
28
  * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
28
29
  * 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
+ * the gateway is permissionless, the call is already there, or the mToken is
31
+ * mGLOBAL (temporary: its gateway cannot grant the greenlist).
30
32
  */
31
33
  async function prependMidasReceiveGreenlist(props) {
32
34
  const { cm, client, calls, logger } = props;
@@ -36,6 +38,10 @@ async function prependMidasReceiveGreenlist(props) {
36
38
  if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
37
39
  const gateways = new AddressMap();
38
40
  for (const vault of calledVaults) {
41
+ if (isAddressEqual(vault.mToken, MGLOBAL_MTOKEN)) {
42
+ logger?.debug(`midas: skipping receiveGreenlist for mGLOBAL ${vault.mToken}`);
43
+ continue;
44
+ }
39
45
  const gateway = gatewayByMToken.get(vault.mToken);
40
46
  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
47
  else if (calls.some((call) => isAddressEqual(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
@@ -31,7 +31,8 @@ interface PrependMidasReceiveGreenlistProps {
31
31
  *
32
32
  * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
33
33
  * vault is called, its mToken has no gateway adapter on this credit manager,
34
- * the gateway is permissionless, or the call is already there.
34
+ * the gateway is permissionless, the call is already there, or the mToken is
35
+ * mGLOBAL (temporary: its gateway cannot grant the greenlist).
35
36
  */
36
37
  declare function prependMidasReceiveGreenlist(props: PrependMidasReceiveGreenlistProps): Promise<MultiCall[]>;
37
38
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.4.0-next.10",
3
+ "version": "16.4.0-next.11",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {