@gearbox-protocol/sdk 15.1.0-next.13 → 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.
- package/dist/cjs/dev/AccountOpener.js +1 -8
- package/dist/cjs/dev/index.js +2 -3
- package/dist/cjs/dev/midasUtils.js +0 -96
- package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +7 -35
- package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +5 -26
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -2
- package/dist/cjs/sdk/accounts/utils/midasUtils.js +70 -0
- package/dist/cjs/sdk/index.js +4 -0
- package/dist/cjs/sdk/market/adapters/createAdapter.js +8 -1
- package/dist/cjs/sdk/market/adapters/index.js +5 -0
- package/dist/cjs/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js +81 -0
- package/dist/cjs/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js +59 -0
- package/dist/cjs/sdk/market/adapters/midas/index.js +6 -0
- package/dist/cjs/sdk/market/adapters/midas/types.js +1 -0
- package/dist/cjs/sdk/market/index.js +4 -0
- package/dist/esm/dev/AccountOpener.js +2 -9
- package/dist/esm/dev/index.js +3 -3
- package/dist/esm/dev/midasUtils.js +2 -97
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +8 -36
- package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +5 -26
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +18 -4
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/utils/midasUtils.js +69 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +3 -3
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/index.js +3 -1
- package/dist/esm/sdk/market/adapters/createAdapter.js +8 -1
- package/dist/esm/sdk/market/adapters/index.js +4 -1
- package/dist/esm/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js +80 -0
- package/dist/esm/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js +58 -0
- package/dist/esm/sdk/market/adapters/midas/index.js +4 -0
- package/dist/esm/sdk/market/adapters/midas/types.js +1 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/index.js +3 -1
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/dev/index.d.ts +2 -2
- package/dist/types/dev/midasUtils.d.ts +2 -35
- package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +2 -1
- package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +2 -1
- package/dist/types/sdk/accounts/utils/midasUtils.d.ts +38 -0
- package/dist/types/sdk/index.d.ts +4 -1
- package/dist/types/sdk/market/adapters/index.d.ts +5 -1
- package/dist/types/sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.d.ts +17 -0
- package/dist/types/sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.d.ts +15 -0
- package/dist/types/sdk/market/adapters/midas/index.d.ts +4 -0
- package/dist/types/sdk/market/adapters/midas/types.d.ts +24 -0
- package/dist/types/sdk/market/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
1
2
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../sdk/utils/AddressMap.js";
|
|
3
4
|
import { AddressSet } from "../sdk/utils/AddressSet.js";
|
|
4
5
|
import { AssetsMap } from "../sdk/utils/AssetsMap.js";
|
|
5
6
|
import { childLogger } from "../sdk/utils/childLogger.js";
|
|
6
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
7
7
|
import "../sdk/constants/addresses.js";
|
|
8
8
|
import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
|
|
9
9
|
import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
|
|
@@ -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:
|
|
280
|
+
calls: strategy.calls,
|
|
288
281
|
ethAmount: 0n,
|
|
289
282
|
permits: {},
|
|
290
283
|
to: borrower.address,
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -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,
|
|
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 {
|
|
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 {
|
|
107
|
+
export { unpauseMidasIssuanceVault };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { getNetworkType } from "../sdk/chain/chains.js";
|
|
2
3
|
import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../sdk/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
|
|
2
1
|
import { ierc4626AdapterAbi } from "../../../abi/ierc4626Adapter.js";
|
|
2
|
+
import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
|
|
3
3
|
import "../../../sdk/index.js";
|
|
4
4
|
import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
|
|
5
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
|
|
2
|
+
import { PlaceholderMidasGatewayAdapterContract } from "../../../sdk/market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js";
|
|
2
3
|
import "../../../sdk/index.js";
|
|
3
4
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
4
5
|
import { iMidasGatewayAdapterV311Abi } from "../abi/adapters/iMidasGatewayAdapterV311.js";
|
|
5
6
|
import "../abi/adapters/index.js";
|
|
6
7
|
import { iMidasGatewayV311Abi } from "../abi/midas/iMidasGatewayV311.js";
|
|
7
8
|
import "../abi/index.js";
|
|
8
|
-
import {
|
|
9
|
+
import { decodeFunctionData, isAddressEqual, zeroAddress } from "viem";
|
|
9
10
|
//#region src/plugins/adapters/contracts/MidasGatewayAdapterContract.ts
|
|
10
11
|
const abi = iMidasGatewayAdapterV311Abi;
|
|
11
12
|
const protocolAbi = iMidasGatewayV311Abi;
|
|
@@ -22,41 +23,12 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
|
|
|
22
23
|
protocolAbi
|
|
23
24
|
});
|
|
24
25
|
if (args.baseParams.serializedParams) {
|
|
25
|
-
const decoded =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type: "address",
|
|
32
|
-
name: "targetContract"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: "address",
|
|
36
|
-
name: "gateway"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
type: "address",
|
|
40
|
-
name: "mToken"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: "address",
|
|
44
|
-
name: "quoteToken"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
type: "address",
|
|
48
|
-
name: "phantomToken"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: "bytes32",
|
|
52
|
-
name: "referrerId"
|
|
53
|
-
}
|
|
54
|
-
], args.baseParams.serializedParams);
|
|
55
|
-
this.#gateway = decoded[2];
|
|
56
|
-
this.#mToken = decoded[3];
|
|
57
|
-
this.#quoteToken = decoded[4];
|
|
58
|
-
this.#phantomToken = decoded[5];
|
|
59
|
-
this.#referrerId = decoded[6];
|
|
26
|
+
const decoded = PlaceholderMidasGatewayAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
|
|
27
|
+
this.#gateway = decoded.gateway;
|
|
28
|
+
this.#mToken = decoded.mToken;
|
|
29
|
+
this.#quoteToken = decoded.quoteToken;
|
|
30
|
+
this.#phantomToken = decoded.phantomToken;
|
|
31
|
+
this.#referrerId = decoded.referrerId;
|
|
60
32
|
}
|
|
61
33
|
}
|
|
62
34
|
get gateway() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
|
|
2
|
+
import { PlaceholderMidasIssuanceVaultAdapterContract } from "../../../sdk/market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
|
|
2
3
|
import "../../../sdk/index.js";
|
|
3
4
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
4
5
|
import { iMidasIssuanceVaultAdapterV310Abi } from "../abi/adapters/iMidasIssuanceVaultAdapterV310.js";
|
|
5
6
|
import "../abi/adapters/index.js";
|
|
6
7
|
import { iMidasIssuanceVaultV310Abi } from "../abi/targetContractAbi.js";
|
|
7
|
-
import { decodeAbiParameters } from "viem";
|
|
8
8
|
//#region src/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.ts
|
|
9
9
|
const abi = iMidasIssuanceVaultAdapterV310Abi;
|
|
10
10
|
const protocolAbi = iMidasIssuanceVaultV310Abi;
|
|
@@ -19,31 +19,10 @@ var MidasIssuanceVaultAdapterContract = class extends AbstractAdapterContract {
|
|
|
19
19
|
protocolAbi
|
|
20
20
|
});
|
|
21
21
|
if (args.baseParams.serializedParams) {
|
|
22
|
-
const decoded =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: "address",
|
|
29
|
-
name: "targetContract"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: "address",
|
|
33
|
-
name: "mToken"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: "bytes32",
|
|
37
|
-
name: "referrerId"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: "address[]",
|
|
41
|
-
name: "allowedTokens"
|
|
42
|
-
}
|
|
43
|
-
], args.baseParams.serializedParams);
|
|
44
|
-
this.#mToken = decoded[2];
|
|
45
|
-
this.#referrerId = decoded[3];
|
|
46
|
-
this.#allowedTokens = [...decoded[4]];
|
|
22
|
+
const decoded = PlaceholderMidasIssuanceVaultAdapterContract.decodeSerializedParams(args.baseParams.serializedParams);
|
|
23
|
+
this.#mToken = decoded.mToken;
|
|
24
|
+
this.#referrerId = decoded.referrerId;
|
|
25
|
+
this.#allowedTokens = decoded.allowedTokens;
|
|
47
26
|
}
|
|
48
27
|
}
|
|
49
28
|
get mToken() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
|
+
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { asPreviewSimulationError } from "./errors.js";
|
|
4
4
|
//#region src/preview/simulate/simulatePoolOperation.ts
|
|
5
5
|
function previewRead(operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
1
2
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../sdk/utils/AddressMap.js";
|
|
3
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
4
4
|
import "../../sdk/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
6
6
|
import { getAddress, isAddressEqual, parseEventLogs } from "viem";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
1
3
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
4
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
3
5
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -8,13 +10,12 @@ import "../base/index.js";
|
|
|
8
10
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
9
11
|
import "./bots/index.js";
|
|
10
12
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
16
16
|
import "./credit-account-compressor/index.js";
|
|
17
17
|
import { extractPriceUpdates, extractQuotaTokens, mergePriceUpdates } from "./multicall-utils.js";
|
|
18
|
+
import { prependMidasReceiveGreenlist } from "./utils/midasUtils.js";
|
|
18
19
|
import { encodeFunctionData } from "viem";
|
|
19
20
|
//#region src/sdk/accounts/CreditAccountsServiceV310.ts
|
|
20
21
|
/**
|
|
@@ -212,7 +213,7 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
212
213
|
if (withdrawToken === true) tokenToWithdraw = cm.underlying;
|
|
213
214
|
else if (typeof withdrawToken === "string") tokenToWithdraw = withdrawToken;
|
|
214
215
|
const { creditFacade } = cmSuite;
|
|
215
|
-
|
|
216
|
+
let calls = [
|
|
216
217
|
creditFacade.prepareIncreaseDebt(debt),
|
|
217
218
|
...creditFacade.prepareAddCollateral(collateral, permits),
|
|
218
219
|
...openPathCalls,
|
|
@@ -223,7 +224,8 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
223
224
|
}),
|
|
224
225
|
...callsAfter ?? []
|
|
225
226
|
];
|
|
226
|
-
|
|
227
|
+
calls = await this.#prependMidasReceiveGreenlist(cm.address, calls);
|
|
228
|
+
calls = await this.prependPriceUpdates(cm.address, calls);
|
|
227
229
|
const tx = reopenCreditAccount ? cmSuite.multicallTx(reopenCreditAccount, calls) : cmSuite.openCreditAccountTx(to, calls, referralCode, rwaOptions);
|
|
228
230
|
tx.value = ethAmount.toString(10);
|
|
229
231
|
return tx;
|
|
@@ -449,6 +451,18 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
449
451
|
return this.sdk.addressProvider.mustGetLatest(AP_REWARDS_COMPRESSOR, VERSION_RANGE_310)[0];
|
|
450
452
|
}
|
|
451
453
|
/**
|
|
454
|
+
* {@inheritDoc ICreditAccountsService.prependMidasReceiveGreenlist}
|
|
455
|
+
*/
|
|
456
|
+
async #prependMidasReceiveGreenlist(creditManager, calls) {
|
|
457
|
+
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
458
|
+
return prependMidasReceiveGreenlist({
|
|
459
|
+
cm,
|
|
460
|
+
client: this.client,
|
|
461
|
+
calls,
|
|
462
|
+
logger: this.logger
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
452
466
|
* Withdrawal compressor of the current chain.
|
|
453
467
|
* @throws If no withdrawal compressor is supported on the current chain.
|
|
454
468
|
**/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
1
2
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
3
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
4
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
|
|
|
19
20
|
import "../../market/rwa/securitize/index.js";
|
|
20
21
|
import "../../market/index.js";
|
|
21
22
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
22
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
23
23
|
//#region src/sdk/accounts/liquidations/LiquidationsService.ts
|
|
24
24
|
/**
|
|
25
25
|
* Service for discovering liquidatable credit accounts and previewing manual
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AddressMap } from "../../utils/AddressMap.js";
|
|
2
|
+
import { encodeFunctionData, isAddressEqual, parseAbi } from "viem";
|
|
3
|
+
//#region src/sdk/accounts/utils/midasUtils.ts
|
|
4
|
+
const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
|
|
5
|
+
const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
|
|
6
|
+
/**
|
|
7
|
+
* Permissionless gateways have no greenlist and reject `receiveGreenlist`,
|
|
8
|
+
* see MidasMode in integrations-v3
|
|
9
|
+
*/
|
|
10
|
+
const MIDAS_MODE_PERMISSIONLESS = 0;
|
|
11
|
+
const iMidasGatewayAdapterExtAbi = parseAbi(["function receiveGreenlist() external returns (bool)"]);
|
|
12
|
+
const iMidasGatewayModeAbi = parseAbi(["function mode() external view returns (uint8)"]);
|
|
13
|
+
const receiveGreenlistCallData = encodeFunctionData({
|
|
14
|
+
abi: iMidasGatewayAdapterExtAbi,
|
|
15
|
+
functionName: "receiveGreenlist"
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
|
|
19
|
+
* multicall that mints an mToken through a Midas issuance vault.
|
|
20
|
+
*
|
|
21
|
+
* Permissioned and restricted-interface mTokens can only be held by greenlisted
|
|
22
|
+
* accounts, and a freshly opened credit account is never greenlisted, so the
|
|
23
|
+
* mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
|
|
24
|
+
* the greenlist first. Greenlisting the borrower is not enough — the role is
|
|
25
|
+
* checked on the token holder, which is the credit account.
|
|
26
|
+
*
|
|
27
|
+
* Returns `calls` unchanged when nothing has to be greenlisted: no issuance
|
|
28
|
+
* 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
|
+
*/
|
|
31
|
+
async function prependMidasReceiveGreenlist(props) {
|
|
32
|
+
const { cm, client, calls, logger } = props;
|
|
33
|
+
const adapters = Array.from(cm.creditManager.adapters.values());
|
|
34
|
+
const gatewayByMToken = AddressMap.fromMappedArray(adapters.filter((a) => a.contractType === ADAPTER_MIDAS_GATEWAY), (a) => a.mToken);
|
|
35
|
+
const calledVaults = adapters.filter((a) => a.contractType === ADAPTER_MIDAS_ISSUANCE_VAULT).filter((vault) => calls.some((call) => isAddressEqual(call.target, vault.address)));
|
|
36
|
+
if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
|
|
37
|
+
const gateways = new AddressMap();
|
|
38
|
+
for (const vault of calledVaults) {
|
|
39
|
+
const gateway = gatewayByMToken.get(vault.mToken);
|
|
40
|
+
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
|
+
else if (calls.some((call) => isAddressEqual(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
|
|
42
|
+
else gateways.upsert(gateway.address, gateway);
|
|
43
|
+
}
|
|
44
|
+
if (gateways.size === 0) return calls;
|
|
45
|
+
const uniqueGateways = gateways.values();
|
|
46
|
+
const modes = await client.multicall({
|
|
47
|
+
allowFailure: false,
|
|
48
|
+
contracts: uniqueGateways.map(({ targetContract }) => ({
|
|
49
|
+
address: targetContract,
|
|
50
|
+
abi: iMidasGatewayModeAbi,
|
|
51
|
+
functionName: "mode"
|
|
52
|
+
}))
|
|
53
|
+
});
|
|
54
|
+
const prepended = [];
|
|
55
|
+
for (const [i, gateway] of uniqueGateways.entries()) {
|
|
56
|
+
if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
|
|
57
|
+
logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
|
|
61
|
+
prepended.push({
|
|
62
|
+
target: gateway.address,
|
|
63
|
+
callData: receiveGreenlistCallData
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return prepended.length > 0 ? [...prepended, ...calls] : calls;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { prependMidasReceiveGreenlist };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
4
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
5
5
|
import { InvalidDelayedIntentError } from "./errors.js";
|
|
6
6
|
//#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
7
7
|
const abi = iRedemptionLoggerV310Abi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
2
3
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
2
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
3
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
4
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
5
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
6
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
4
7
|
import { getAssetType } from "../chain/chains.js";
|
|
5
8
|
import { formatBN } from "../utils/formatter.js";
|
|
6
9
|
import "../utils/index.js";
|
|
7
|
-
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
8
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
9
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
10
10
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
11
11
|
//#region src/sdk/base/TokensMeta.ts
|
|
12
12
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
2
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
3
|
import { isV310 } from "../constants/versions.js";
|
|
3
4
|
import "../constants/index.js";
|
|
4
5
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/sdk/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -45,6 +45,8 @@ import "./base/index.js";
|
|
|
45
45
|
import { PeripheryCompressorV310Contract } from "./accounts/bots/PeripheryCompressorV310Contract.js";
|
|
46
46
|
import { AccountBotsService } from "./accounts/bots/AccountBotsService.js";
|
|
47
47
|
import { PlaceholderAdapterContract } from "./market/adapters/PlaceholderAdapterContracts.js";
|
|
48
|
+
import { PlaceholderMidasGatewayAdapterContract } from "./market/adapters/midas/PlaceholderMidasGatewayAdapterContract.js";
|
|
49
|
+
import { PlaceholderMidasIssuanceVaultAdapterContract } from "./market/adapters/midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
|
|
48
50
|
import { createAdapter } from "./market/adapters/createAdapter.js";
|
|
49
51
|
import { CreditConfiguratorV310Contract } from "./market/credit/CreditConfiguratorV310Contract.js";
|
|
50
52
|
import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./market/credit/CreditFacadeV310BaseContract.js";
|
|
@@ -156,4 +158,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
|
|
|
156
158
|
import { MultichainSDK } from "./MultichainSDK.js";
|
|
157
159
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
158
160
|
import "./types/index.js";
|
|
159
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, IntentPreviewError, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcAdditionalBorrowApy, calcBorrowApy, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcPositionLeverage, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
161
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, IntentPreviewError, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PlaceholderMidasGatewayAdapterContract, PlaceholderMidasIssuanceVaultAdapterContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcAdditionalBorrowApy, calcBorrowApy, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcPositionLeverage, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
2
2
|
import "../../utils/index.js";
|
|
3
3
|
import { PlaceholderAdapterContract } from "./PlaceholderAdapterContracts.js";
|
|
4
|
+
import { PlaceholderMidasGatewayAdapterContract } from "./midas/PlaceholderMidasGatewayAdapterContract.js";
|
|
5
|
+
import { PlaceholderMidasIssuanceVaultAdapterContract } from "./midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
|
|
6
|
+
import "./midas/index.js";
|
|
4
7
|
//#region src/sdk/market/adapters/createAdapter.ts
|
|
5
8
|
function createAdapter(sdk, args) {
|
|
6
9
|
const adapterType = bytes32ToString(args.baseParams.contractType);
|
|
@@ -13,7 +16,11 @@ function createAdapter(sdk, args) {
|
|
|
13
16
|
} catch (e) {
|
|
14
17
|
sdk.logger?.warn(`plugin ${name} error while trying to create ${adapterType} v${args.baseParams.version} at ${args.baseParams.addr}: ${e}`);
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
switch (adapterType) {
|
|
20
|
+
case "ADAPTER::MIDAS_GATEWAY": return new PlaceholderMidasGatewayAdapterContract(sdk, args);
|
|
21
|
+
case "ADAPTER::MIDAS_ISSUANCE_VAULT": return new PlaceholderMidasIssuanceVaultAdapterContract(sdk, args);
|
|
22
|
+
default: return new PlaceholderAdapterContract(sdk, args);
|
|
23
|
+
}
|
|
17
24
|
}
|
|
18
25
|
//#endregion
|
|
19
26
|
export { createAdapter };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { PlaceholderAdapterContract } from "./PlaceholderAdapterContracts.js";
|
|
2
|
+
import { PlaceholderMidasGatewayAdapterContract } from "./midas/PlaceholderMidasGatewayAdapterContract.js";
|
|
3
|
+
import { PlaceholderMidasIssuanceVaultAdapterContract } from "./midas/PlaceholderMidasIssuanceVaultAdapterContract.js";
|
|
4
|
+
import "./midas/index.js";
|
|
2
5
|
import { createAdapter } from "./createAdapter.js";
|
|
3
6
|
import "./types.js";
|
|
4
|
-
export { PlaceholderAdapterContract, createAdapter };
|
|
7
|
+
export { PlaceholderAdapterContract, PlaceholderMidasGatewayAdapterContract, PlaceholderMidasIssuanceVaultAdapterContract, createAdapter };
|