@gearbox-protocol/sdk 16.5.0 → 16.5.1
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.
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +1 -0
- package/dist/cjs/onchain/accounts/utils/midasUtils.js +7 -1
- package/dist/cjs/onchain/core/createAddressProvider.js +2 -5
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +1 -0
- package/dist/esm/onchain/accounts/utils/midasUtils.js +8 -2
- package/dist/esm/onchain/core/createAddressProvider.js +2 -5
- package/dist/types/onchain/accounts/utils/midasUtils.d.ts +2 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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`);
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_abi_iVersion = require("../../abi/iVersion.js");
|
|
3
|
-
|
|
3
|
+
require("../constants/address-provider.js");
|
|
4
4
|
const require_onchain_constants_versions = require("../constants/versions.js");
|
|
5
5
|
require("../constants/index.js");
|
|
6
6
|
const require_onchain_utils_hex = require("../utils/hex.js");
|
|
7
7
|
const require_onchain_core_AddressProviderV310Contract = require("./AddressProviderV310Contract.js");
|
|
8
8
|
//#region src/onchain/core/createAddressProvider.ts
|
|
9
|
-
const OVERRIDE_ADDRESSES = {
|
|
10
|
-
[require_onchain_constants_address_provider.AP_PRICE_FEED_COMPRESSOR]: { 311: "0x1fA2637B9fab0CD14290A7EE908DDc9688a15120" },
|
|
11
|
-
[require_onchain_constants_address_provider.AP_MARKET_COMPRESSOR]: { 311: "0x0C27F242f6e9F2A9AD3261bE6e439De3B948bcA2" }
|
|
12
|
-
} };
|
|
9
|
+
const OVERRIDE_ADDRESSES = {};
|
|
13
10
|
async function createAddressProvider(sdk, address) {
|
|
14
11
|
let v;
|
|
15
12
|
if (require_onchain_utils_hex.hexEq(address, "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38")) v = 310n;
|
|
@@ -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,
|
|
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`);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
|
-
import
|
|
2
|
+
import "../constants/address-provider.js";
|
|
3
3
|
import { isV310 } from "../constants/versions.js";
|
|
4
4
|
import "../constants/index.js";
|
|
5
5
|
import { hexEq } from "../utils/hex.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
|
-
const OVERRIDE_ADDRESSES = {
|
|
9
|
-
[AP_PRICE_FEED_COMPRESSOR]: { 311: "0x1fA2637B9fab0CD14290A7EE908DDc9688a15120" },
|
|
10
|
-
[AP_MARKET_COMPRESSOR]: { 311: "0x0C27F242f6e9F2A9AD3261bE6e439De3B948bcA2" }
|
|
11
|
-
} };
|
|
8
|
+
const OVERRIDE_ADDRESSES = {};
|
|
12
9
|
async function createAddressProvider(sdk, address) {
|
|
13
10
|
let v;
|
|
14
11
|
if (hexEq(address, "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38")) v = 310n;
|
|
@@ -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,
|
|
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
|