@gearbox-protocol/sdk 16.5.3 → 16.6.0-next.2

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 (55) hide show
  1. package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +1 -14
  2. package/dist/cjs/onchain/constants/address-provider.js +0 -2
  3. package/dist/cjs/onchain/constants/index.js +0 -1
  4. package/dist/cjs/onchain/index.js +1 -1
  5. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +1 -1
  6. package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  7. package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +41 -5
  8. package/dist/cjs/onchain/market/credit/CreditSuite.js +7 -0
  9. package/dist/cjs/onchain/market/index.js +1 -0
  10. package/dist/cjs/onchain/market/rwa/RWARegistry.js +4 -7
  11. package/dist/cjs/onchain/market/rwa/index.js +1 -0
  12. package/dist/esm/dev/AccountOpener.js +1 -1
  13. package/dist/esm/dev/withdrawalUtils.js +1 -1
  14. package/dist/esm/history/trace/extractTransfers.js +1 -1
  15. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +3 -16
  16. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  17. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  18. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  19. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  20. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  21. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  22. package/dist/esm/onchain/constants/address-provider.js +1 -2
  23. package/dist/esm/onchain/constants/index.js +2 -2
  24. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  25. package/dist/esm/onchain/index.js +3 -3
  26. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +1 -1
  27. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  28. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  29. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  30. package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +42 -6
  31. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  32. package/dist/esm/onchain/market/credit/CreditSuite.js +7 -0
  33. package/dist/esm/onchain/market/index.js +2 -2
  34. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  35. package/dist/esm/onchain/market/rwa/RWARegistry.js +4 -8
  36. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  37. package/dist/esm/onchain/market/rwa/index.js +2 -2
  38. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  39. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  40. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  41. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  42. package/dist/types/onchain/constants/address-provider.d.ts +1 -2
  43. package/dist/types/onchain/constants/index.d.ts +2 -2
  44. package/dist/types/onchain/index.d.ts +3 -3
  45. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +6 -0
  46. package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +15 -5
  47. package/dist/types/onchain/market/adapters/types.d.ts +8 -0
  48. package/dist/types/onchain/market/credit/CreditSuite.d.ts +5 -0
  49. package/dist/types/onchain/market/index.d.ts +2 -2
  50. package/dist/types/onchain/market/rwa/RWARegistry.d.ts +2 -1
  51. package/dist/types/onchain/market/rwa/index.d.ts +2 -2
  52. package/package.json +1 -1
  53. package/dist/cjs/onchain/accounts/utils/midasUtils.js +0 -76
  54. package/dist/esm/onchain/accounts/utils/midasUtils.js +0 -75
  55. package/dist/types/onchain/accounts/utils/midasUtils.d.ts +0 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.5.3",
3
+ "version": "16.6.0-next.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,76 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_onchain_utils_AddressMap = require("../../utils/AddressMap.js");
3
- let viem = require("viem");
4
- //#region src/onchain/accounts/utils/midasUtils.ts
5
- const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
6
- const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
7
- const MGLOBAL_MTOKEN = (0, viem.getAddress)("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
8
- /**
9
- * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
10
- * see MidasMode in integrations-v3
11
- */
12
- const MIDAS_MODE_PERMISSIONLESS = 0;
13
- const iMidasGatewayAdapterExtAbi = (0, viem.parseAbi)(["function receiveGreenlist() external returns (bool)"]);
14
- const iMidasGatewayModeAbi = (0, viem.parseAbi)(["function mode() external view returns (uint8)"]);
15
- const receiveGreenlistCallData = (0, viem.encodeFunctionData)({
16
- abi: iMidasGatewayAdapterExtAbi,
17
- functionName: "receiveGreenlist"
18
- });
19
- /**
20
- * Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
21
- * multicall that mints an mToken through a Midas issuance vault.
22
- *
23
- * Permissioned and restricted-interface mTokens can only be held by greenlisted
24
- * accounts, and a freshly opened credit account is never greenlisted, so the
25
- * mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
26
- * the greenlist first. Greenlisting the borrower is not enough — the role is
27
- * checked on the token holder, which is the credit account.
28
- *
29
- * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
30
- * vault is called, its mToken has no gateway adapter on this credit manager,
31
- * the gateway is permissionless, the call is already there, or the mToken is
32
- * mGLOBAL (temporary: its gateway cannot grant the greenlist).
33
- */
34
- async function prependMidasReceiveGreenlist(props) {
35
- const { cm, client, calls, logger } = props;
36
- const adapters = Array.from(cm.creditManager.adapters.values());
37
- const gatewayByMToken = require_onchain_utils_AddressMap.AddressMap.fromMappedArray(adapters.filter((a) => a.contractType === ADAPTER_MIDAS_GATEWAY), (a) => a.mToken);
38
- const calledVaults = adapters.filter((a) => a.contractType === ADAPTER_MIDAS_ISSUANCE_VAULT).filter((vault) => calls.some((call) => (0, viem.isAddressEqual)(call.target, vault.address)));
39
- if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
40
- const gateways = new require_onchain_utils_AddressMap.AddressMap();
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
- }
46
- const gateway = gatewayByMToken.get(vault.mToken);
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`);
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`);
49
- else gateways.upsert(gateway.address, gateway);
50
- }
51
- if (gateways.size === 0) return calls;
52
- const uniqueGateways = gateways.values();
53
- const modes = await client.multicall({
54
- allowFailure: false,
55
- contracts: uniqueGateways.map(({ targetContract }) => ({
56
- address: targetContract,
57
- abi: iMidasGatewayModeAbi,
58
- functionName: "mode"
59
- }))
60
- });
61
- const prepended = [];
62
- for (const [i, gateway] of uniqueGateways.entries()) {
63
- if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
64
- logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
65
- continue;
66
- }
67
- logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
68
- prepended.push({
69
- target: gateway.address,
70
- callData: receiveGreenlistCallData
71
- });
72
- }
73
- return prepended.length > 0 ? [...prepended, ...calls] : calls;
74
- }
75
- //#endregion
76
- exports.prependMidasReceiveGreenlist = prependMidasReceiveGreenlist;
@@ -1,75 +0,0 @@
1
- import { AddressMap } from "../../utils/AddressMap.js";
2
- import { encodeFunctionData, getAddress, isAddressEqual, parseAbi } from "viem";
3
- //#region src/onchain/accounts/utils/midasUtils.ts
4
- const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
5
- const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
6
- const MGLOBAL_MTOKEN = getAddress("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
7
- /**
8
- * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
9
- * see MidasMode in integrations-v3
10
- */
11
- const MIDAS_MODE_PERMISSIONLESS = 0;
12
- const iMidasGatewayAdapterExtAbi = parseAbi(["function receiveGreenlist() external returns (bool)"]);
13
- const iMidasGatewayModeAbi = parseAbi(["function mode() external view returns (uint8)"]);
14
- const receiveGreenlistCallData = encodeFunctionData({
15
- abi: iMidasGatewayAdapterExtAbi,
16
- functionName: "receiveGreenlist"
17
- });
18
- /**
19
- * Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
20
- * multicall that mints an mToken through a Midas issuance vault.
21
- *
22
- * Permissioned and restricted-interface mTokens can only be held by greenlisted
23
- * accounts, and a freshly opened credit account is never greenlisted, so the
24
- * mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
25
- * the greenlist first. Greenlisting the borrower is not enough — the role is
26
- * checked on the token holder, which is the credit account.
27
- *
28
- * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
29
- * vault is called, its mToken has no gateway adapter on this credit manager,
30
- * the gateway is permissionless, the call is already there, or the mToken is
31
- * mGLOBAL (temporary: its gateway cannot grant the greenlist).
32
- */
33
- async function prependMidasReceiveGreenlist(props) {
34
- const { cm, client, calls, logger } = props;
35
- const adapters = Array.from(cm.creditManager.adapters.values());
36
- const gatewayByMToken = AddressMap.fromMappedArray(adapters.filter((a) => a.contractType === ADAPTER_MIDAS_GATEWAY), (a) => a.mToken);
37
- const calledVaults = adapters.filter((a) => a.contractType === ADAPTER_MIDAS_ISSUANCE_VAULT).filter((vault) => calls.some((call) => isAddressEqual(call.target, vault.address)));
38
- if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
39
- const gateways = new AddressMap();
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
- }
45
- const gateway = gatewayByMToken.get(vault.mToken);
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`);
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`);
48
- else gateways.upsert(gateway.address, gateway);
49
- }
50
- if (gateways.size === 0) return calls;
51
- const uniqueGateways = gateways.values();
52
- const modes = await client.multicall({
53
- allowFailure: false,
54
- contracts: uniqueGateways.map(({ targetContract }) => ({
55
- address: targetContract,
56
- abi: iMidasGatewayModeAbi,
57
- functionName: "mode"
58
- }))
59
- });
60
- const prepended = [];
61
- for (const [i, gateway] of uniqueGateways.entries()) {
62
- if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
63
- logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
64
- continue;
65
- }
66
- logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
67
- prepended.push({
68
- target: gateway.address,
69
- callData: receiveGreenlistCallData
70
- });
71
- }
72
- return prepended.length > 0 ? [...prepended, ...calls] : calls;
73
- }
74
- //#endregion
75
- export { prependMidasReceiveGreenlist };
@@ -1,39 +0,0 @@
1
- import { ILogger } from "../../types/logger.js";
2
- import { CreditSuite } from "../../market/credit/CreditSuite.js";
3
- import { MultiCall } from "../../types/transactions.js";
4
- import "../../types/index.js";
5
- import { PublicClient } from "viem";
6
- //#region src/onchain/accounts/utils/midasUtils.d.ts
7
- interface PrependMidasReceiveGreenlistProps {
8
- /**
9
- * Credit manager the account is opened on
10
- */
11
- cm: CreditSuite;
12
- /**
13
- * Client to read gateway `mode` with
14
- */
15
- client: PublicClient;
16
- /**
17
- * Calls to run in the credit facade multicall, as produced by the router
18
- */
19
- calls: MultiCall[];
20
- logger?: ILogger;
21
- }
22
- /**
23
- * Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
24
- * multicall that mints an mToken through a Midas issuance vault.
25
- *
26
- * Permissioned and restricted-interface mTokens can only be held by greenlisted
27
- * accounts, and a freshly opened credit account is never greenlisted, so the
28
- * mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
29
- * the greenlist first. Greenlisting the borrower is not enough — the role is
30
- * checked on the token holder, which is the credit account.
31
- *
32
- * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
33
- * vault is called, its mToken has no gateway adapter on this credit manager,
34
- * the gateway is permissionless, the call is already there, or the mToken is
35
- * mGLOBAL (temporary: its gateway cannot grant the greenlist).
36
- */
37
- declare function prependMidasReceiveGreenlist(props: PrependMidasReceiveGreenlistProps): Promise<MultiCall[]>;
38
- //#endregion
39
- export { PrependMidasReceiveGreenlistProps, prependMidasReceiveGreenlist };