@enzymefinance/testutils 4.0.0 → 4.0.3
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/index.d.ts +1566 -0
- package/dist/index.js +3375 -0
- package/dist/index.mjs +3375 -0
- package/package.json +74 -11
- package/CHANGELOG.md +0 -84
- package/dist/declarations/src/assertions.d.ts +0 -4
- package/dist/declarations/src/deployment.d.ts +0 -188
- package/dist/declarations/src/gasRelayer.d.ts +0 -56
- package/dist/declarations/src/helpers.d.ts +0 -16
- package/dist/declarations/src/index.d.ts +0 -6
- package/dist/declarations/src/scaffolding/assets.d.ts +0 -10
- package/dist/declarations/src/scaffolding/chainlink.d.ts +0 -3
- package/dist/declarations/src/scaffolding/common.d.ts +0 -7
- package/dist/declarations/src/scaffolding/core.d.ts +0 -16
- package/dist/declarations/src/scaffolding/extensions/common.d.ts +0 -11
- package/dist/declarations/src/scaffolding/extensions/external-positions/aave-debt.d.ts +0 -51
- package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +0 -36
- package/dist/declarations/src/scaffolding/extensions/external-positions/compound.d.ts +0 -56
- package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +0 -5
- package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +0 -56
- package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +0 -100
- package/dist/declarations/src/scaffolding/extensions/fees.d.ts +0 -12
- package/dist/declarations/src/scaffolding/extensions/index.d.ts +0 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +0 -20
- package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +0 -56
- package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +0 -106
- package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +0 -28
- package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +0 -14
- package/dist/declarations/src/scaffolding/extensions/integrations/mock.d.ts +0 -32
- package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +0 -17
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV5.d.ts +0 -23
- package/dist/declarations/src/scaffolding/extensions/integrations/poolTogetherV4.d.ts +0 -29
- package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +0 -28
- package/dist/declarations/src/scaffolding/extensions/integrations/trackedAssets.d.ts +0 -15
- package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV2.d.ts +0 -46
- package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV3.d.ts +0 -15
- package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +0 -22
- package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +0 -12
- package/dist/declarations/src/scaffolding/extensions/policies.d.ts +0 -17
- package/dist/declarations/src/scaffolding/index.d.ts +0 -8
- package/dist/declarations/src/scaffolding/setup.d.ts +0 -77
- package/dist/declarations/src/scaffolding/shares.d.ts +0 -35
- package/dist/declarations/src/scaffolding/vaultCalls.d.ts +0 -32
- package/dist/declarations/src/whales.d.ts +0 -49
- package/dist/enzymefinance-testutils.browser.cjs.js +0 -4158
- package/dist/enzymefinance-testutils.browser.esm.js +0 -4028
- package/dist/enzymefinance-testutils.cjs.d.ts +0 -1
- package/dist/enzymefinance-testutils.cjs.dev.js +0 -4158
- package/dist/enzymefinance-testutils.cjs.js +0 -7
- package/dist/enzymefinance-testutils.cjs.prod.js +0 -4158
- package/dist/enzymefinance-testutils.esm.js +0 -4028
- package/src/assertions.ts +0 -23
- package/src/deployment.ts +0 -280
- package/src/gasRelayer.ts +0 -95
- package/src/helpers.ts +0 -39
- package/src/index.ts +0 -6
- package/src/scaffolding/assets.ts +0 -37
- package/src/scaffolding/chainlink.ts +0 -8
- package/src/scaffolding/common.ts +0 -11
- package/src/scaffolding/core.ts +0 -103
- package/src/scaffolding/extensions/common.ts +0 -30
- package/src/scaffolding/extensions/external-positions/aave-debt.ts +0 -179
- package/src/scaffolding/extensions/external-positions/actions.ts +0 -108
- package/src/scaffolding/extensions/external-positions/compound.ts +0 -190
- package/src/scaffolding/extensions/external-positions/index.ts +0 -5
- package/src/scaffolding/extensions/external-positions/mocks.ts +0 -191
- package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +0 -284
- package/src/scaffolding/extensions/fees.ts +0 -70
- package/src/scaffolding/extensions/index.ts +0 -5
- package/src/scaffolding/extensions/integrations/aave.ts +0 -78
- package/src/scaffolding/extensions/integrations/compound.ts +0 -255
- package/src/scaffolding/extensions/integrations/curve.ts +0 -354
- package/src/scaffolding/extensions/integrations/idle.ts +0 -104
- package/src/scaffolding/extensions/integrations/index.ts +0 -14
- package/src/scaffolding/extensions/integrations/mock.ts +0 -116
- package/src/scaffolding/extensions/integrations/olympusV2.ts +0 -71
- package/src/scaffolding/extensions/integrations/paraSwapV5.ts +0 -73
- package/src/scaffolding/extensions/integrations/poolTogetherV4.ts +0 -117
- package/src/scaffolding/extensions/integrations/synthetix.ts +0 -111
- package/src/scaffolding/extensions/integrations/trackedAssets.ts +0 -48
- package/src/scaffolding/extensions/integrations/uniswapV2.ts +0 -175
- package/src/scaffolding/extensions/integrations/uniswapV3.ts +0 -55
- package/src/scaffolding/extensions/integrations/yearn.ts +0 -79
- package/src/scaffolding/extensions/integrations/zeroExV2.ts +0 -47
- package/src/scaffolding/extensions/policies.ts +0 -112
- package/src/scaffolding/index.ts +0 -8
- package/src/scaffolding/setup.ts +0 -243
- package/src/scaffolding/shares.ts +0 -80
- package/src/scaffolding/vaultCalls.ts +0 -105
- package/src/types.d.ts +0 -2
- package/src/whales.ts +0 -82
- package/tsconfig.json +0 -5
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { IPolicy, PolicyHook, policyManagerConfigArgs } from '@enzymefinance/protocol';
|
|
2
|
-
import type { Signer } from 'ethers';
|
|
3
|
-
import { constants, utils } from 'ethers';
|
|
4
|
-
|
|
5
|
-
// Policy Manager
|
|
6
|
-
|
|
7
|
-
export async function generatePolicyManagerConfigWithMockPolicies({ deployer }: { deployer: Signer }) {
|
|
8
|
-
const policies = Object.values(
|
|
9
|
-
await generateMockPolicies({
|
|
10
|
-
deployer,
|
|
11
|
-
}),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
// Guarantees one policy has settings data
|
|
15
|
-
const policiesSettingsData = [...new Array(policies.length - 1).fill(constants.HashZero), utils.randomBytes(10)];
|
|
16
|
-
|
|
17
|
-
return policyManagerConfigArgs({
|
|
18
|
-
policies,
|
|
19
|
-
settings: policiesSettingsData,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function generateMockPolicies({ deployer }: { deployer: Signer }) {
|
|
24
|
-
// Create mock policies
|
|
25
|
-
const mockAddTrackedAssetsPolicy = await IPolicy.mock(deployer);
|
|
26
|
-
const mockCreateExternalPositionPolicy = await IPolicy.mock(deployer);
|
|
27
|
-
const mockPostBuySharesPolicy = await IPolicy.mock(deployer);
|
|
28
|
-
const mockPostCallOnExternalPositionPolicy = await IPolicy.mock(deployer);
|
|
29
|
-
const mockPostCoIPolicy = await IPolicy.mock(deployer);
|
|
30
|
-
const mockRedeemSharesForSpecificAssetsPolicy = await IPolicy.mock(deployer);
|
|
31
|
-
const mockPreTransferSharesPolicy = await IPolicy.mock(deployer);
|
|
32
|
-
const mockRemoveExternalPositionPolicy = await IPolicy.mock(deployer);
|
|
33
|
-
|
|
34
|
-
// Initialize mock policy return values
|
|
35
|
-
await Promise.all([
|
|
36
|
-
// AddTrackedAssets
|
|
37
|
-
mockAddTrackedAssetsPolicy.identifier.returns(`MOCK_ADD_TRACKED_ASSETS`),
|
|
38
|
-
mockAddTrackedAssetsPolicy.addFundSettings.returns(undefined),
|
|
39
|
-
mockAddTrackedAssetsPolicy.activateForFund.returns(undefined),
|
|
40
|
-
mockAddTrackedAssetsPolicy.canDisable.returns(false),
|
|
41
|
-
mockAddTrackedAssetsPolicy.validateRule.returns(true),
|
|
42
|
-
mockAddTrackedAssetsPolicy.implementedHooks.returns([PolicyHook.AddTrackedAssets]),
|
|
43
|
-
mockAddTrackedAssetsPolicy.updateFundSettings.returns(undefined),
|
|
44
|
-
// CreateExternalPosition
|
|
45
|
-
mockCreateExternalPositionPolicy.identifier.returns(`MOCK_CREATE_EXTERNAL_POSITION`),
|
|
46
|
-
mockCreateExternalPositionPolicy.addFundSettings.returns(undefined),
|
|
47
|
-
mockCreateExternalPositionPolicy.activateForFund.returns(undefined),
|
|
48
|
-
mockCreateExternalPositionPolicy.canDisable.returns(false),
|
|
49
|
-
mockCreateExternalPositionPolicy.validateRule.returns(true),
|
|
50
|
-
mockCreateExternalPositionPolicy.implementedHooks.returns([PolicyHook.CreateExternalPosition]),
|
|
51
|
-
mockCreateExternalPositionPolicy.updateFundSettings.returns(undefined),
|
|
52
|
-
// PostBuyShares
|
|
53
|
-
mockPostBuySharesPolicy.identifier.returns(`MOCK_POST_BUY_SHARES`),
|
|
54
|
-
mockPostBuySharesPolicy.addFundSettings.returns(undefined),
|
|
55
|
-
mockPostBuySharesPolicy.activateForFund.returns(undefined),
|
|
56
|
-
mockPostBuySharesPolicy.canDisable.returns(false),
|
|
57
|
-
mockPostBuySharesPolicy.validateRule.returns(true),
|
|
58
|
-
mockPostBuySharesPolicy.implementedHooks.returns([PolicyHook.PostBuyShares]),
|
|
59
|
-
mockPostBuySharesPolicy.updateFundSettings.returns(undefined),
|
|
60
|
-
// PostCallOnExternalPosition
|
|
61
|
-
mockPostCallOnExternalPositionPolicy.identifier.returns(`MOCK_POST_CALL_ON_EXTERNAL_POSITION`),
|
|
62
|
-
mockPostCallOnExternalPositionPolicy.addFundSettings.returns(undefined),
|
|
63
|
-
mockPostCallOnExternalPositionPolicy.activateForFund.returns(undefined),
|
|
64
|
-
mockPostCallOnExternalPositionPolicy.canDisable.returns(false),
|
|
65
|
-
mockPostCallOnExternalPositionPolicy.validateRule.returns(true),
|
|
66
|
-
mockPostCallOnExternalPositionPolicy.implementedHooks.returns([PolicyHook.PostCallOnExternalPosition]),
|
|
67
|
-
mockPostCallOnExternalPositionPolicy.updateFundSettings.returns(undefined),
|
|
68
|
-
// PostCallOnIntegration
|
|
69
|
-
mockPostCoIPolicy.identifier.returns(`MOCK_POST_CALL_ON_INTEGRATION`),
|
|
70
|
-
mockPostCoIPolicy.addFundSettings.returns(undefined),
|
|
71
|
-
mockPostCoIPolicy.activateForFund.returns(undefined),
|
|
72
|
-
mockPostCoIPolicy.canDisable.returns(false),
|
|
73
|
-
mockPostCoIPolicy.validateRule.returns(true),
|
|
74
|
-
mockPostCoIPolicy.implementedHooks.returns([PolicyHook.PostCallOnIntegration]),
|
|
75
|
-
mockPostCoIPolicy.updateFundSettings.returns(undefined),
|
|
76
|
-
// PreTransferSharesPolicy
|
|
77
|
-
mockPreTransferSharesPolicy.identifier.returns(`MOCK_PRE_TRANSFER_SHARES`),
|
|
78
|
-
mockPreTransferSharesPolicy.addFundSettings.returns(undefined),
|
|
79
|
-
mockPreTransferSharesPolicy.activateForFund.returns(undefined),
|
|
80
|
-
mockPreTransferSharesPolicy.canDisable.returns(false),
|
|
81
|
-
mockPreTransferSharesPolicy.validateRule.returns(true),
|
|
82
|
-
mockPreTransferSharesPolicy.implementedHooks.returns([PolicyHook.PreTransferShares]),
|
|
83
|
-
mockPreTransferSharesPolicy.updateFundSettings.returns(undefined),
|
|
84
|
-
// RedeemSharesForSpecificAssets
|
|
85
|
-
mockRedeemSharesForSpecificAssetsPolicy.identifier.returns(`MOCK_REDEEM_SHARES_FOR_SPECIFIC_ASSETS`),
|
|
86
|
-
mockRedeemSharesForSpecificAssetsPolicy.addFundSettings.returns(undefined),
|
|
87
|
-
mockRedeemSharesForSpecificAssetsPolicy.activateForFund.returns(undefined),
|
|
88
|
-
mockRedeemSharesForSpecificAssetsPolicy.canDisable.returns(false),
|
|
89
|
-
mockRedeemSharesForSpecificAssetsPolicy.validateRule.returns(true),
|
|
90
|
-
mockRedeemSharesForSpecificAssetsPolicy.implementedHooks.returns([PolicyHook.RedeemSharesForSpecificAssets]),
|
|
91
|
-
mockRedeemSharesForSpecificAssetsPolicy.updateFundSettings.returns(undefined),
|
|
92
|
-
// RemoveExternalPosition
|
|
93
|
-
mockRemoveExternalPositionPolicy.identifier.returns(`MOCK_REMOVE_EXTERNAL_POSITION`),
|
|
94
|
-
mockRemoveExternalPositionPolicy.addFundSettings.returns(undefined),
|
|
95
|
-
mockRemoveExternalPositionPolicy.activateForFund.returns(undefined),
|
|
96
|
-
mockRemoveExternalPositionPolicy.canDisable.returns(false),
|
|
97
|
-
mockRemoveExternalPositionPolicy.validateRule.returns(true),
|
|
98
|
-
mockRemoveExternalPositionPolicy.implementedHooks.returns([PolicyHook.RedeemSharesForSpecificAssets]),
|
|
99
|
-
mockRemoveExternalPositionPolicy.updateFundSettings.returns(undefined),
|
|
100
|
-
]);
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
mockAddTrackedAssetsPolicy,
|
|
104
|
-
mockCreateExternalPositionPolicy,
|
|
105
|
-
mockPostBuySharesPolicy,
|
|
106
|
-
mockPostCallOnExternalPositionPolicy,
|
|
107
|
-
mockPostCoIPolicy,
|
|
108
|
-
mockPreTransferSharesPolicy,
|
|
109
|
-
mockRedeemSharesForSpecificAssetsPolicy,
|
|
110
|
-
mockRemoveExternalPositionPolicy,
|
|
111
|
-
};
|
|
112
|
-
}
|
package/src/scaffolding/index.ts
DELETED
package/src/scaffolding/setup.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
|
2
|
-
import { randomAddress } from '@enzymefinance/ethers';
|
|
3
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
|
4
|
-
import type { FundDeployer, StandardToken } from '@enzymefinance/protocol';
|
|
5
|
-
import {
|
|
6
|
-
ComptrollerLib,
|
|
7
|
-
ComptrollerProxy,
|
|
8
|
-
encodeFunctionData,
|
|
9
|
-
GasRelayPaymasterLib,
|
|
10
|
-
VaultLib,
|
|
11
|
-
VaultProxy,
|
|
12
|
-
} from '@enzymefinance/protocol';
|
|
13
|
-
import type { BigNumberish, BytesLike } from 'ethers';
|
|
14
|
-
import { BigNumber, utils } from 'ethers';
|
|
15
|
-
|
|
16
|
-
import { assertEvent } from '../assertions';
|
|
17
|
-
import type { BuySharesParams } from './shares';
|
|
18
|
-
import { buyShares } from './shares';
|
|
19
|
-
|
|
20
|
-
export type InitialInvestmentParams = Omit<BuySharesParams, 'comptrollerProxy' | 'denominationAsset'>;
|
|
21
|
-
|
|
22
|
-
export interface CreateMigrationRequestParams {
|
|
23
|
-
signer: SignerWithAddress;
|
|
24
|
-
fundDeployer: FundDeployer;
|
|
25
|
-
vaultProxy: AddressLike;
|
|
26
|
-
denominationAsset: AddressLike;
|
|
27
|
-
sharesActionTimelock?: BigNumberish;
|
|
28
|
-
feeManagerConfigData?: BytesLike;
|
|
29
|
-
policyManagerConfigData?: BytesLike;
|
|
30
|
-
bypassPrevReleaseFailure?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface CreateNewFundParams {
|
|
34
|
-
signer: SignerWithAddress;
|
|
35
|
-
fundDeployer: FundDeployer;
|
|
36
|
-
denominationAsset: StandardToken;
|
|
37
|
-
sharesActionTimelock?: BigNumberish;
|
|
38
|
-
fundOwner?: AddressLike;
|
|
39
|
-
fundName?: string;
|
|
40
|
-
fundSymbol?: string;
|
|
41
|
-
feeManagerConfig?: BytesLike;
|
|
42
|
-
policyManagerConfig?: BytesLike;
|
|
43
|
-
investment?: InitialInvestmentParams;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface CreateReconfigurationRequestParams {
|
|
47
|
-
signer: SignerWithAddress;
|
|
48
|
-
fundDeployer: FundDeployer;
|
|
49
|
-
vaultProxy: AddressLike;
|
|
50
|
-
denominationAsset: AddressLike;
|
|
51
|
-
sharesActionTimelock?: BigNumberish;
|
|
52
|
-
feeManagerConfigData?: BytesLike;
|
|
53
|
-
policyManagerConfigData?: BytesLike;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function createComptrollerProxy({
|
|
57
|
-
signer,
|
|
58
|
-
comptrollerLib,
|
|
59
|
-
denominationAsset,
|
|
60
|
-
sharesActionTimelock = 0,
|
|
61
|
-
}: {
|
|
62
|
-
signer: SignerWithAddress;
|
|
63
|
-
comptrollerLib: ComptrollerLib;
|
|
64
|
-
denominationAsset: AddressLike;
|
|
65
|
-
sharesActionTimelock?: BigNumberish;
|
|
66
|
-
}) {
|
|
67
|
-
const constructData = encodeFunctionData(comptrollerLib.init.fragment, [denominationAsset, sharesActionTimelock]);
|
|
68
|
-
|
|
69
|
-
const comptrollerProxyContract = await ComptrollerProxy.deploy(signer, constructData, comptrollerLib);
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
comptrollerProxy: new ComptrollerLib(comptrollerProxyContract, signer),
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
-
receipt: comptrollerProxyContract.deployment!,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function createMigrationRequest({
|
|
79
|
-
signer,
|
|
80
|
-
fundDeployer,
|
|
81
|
-
vaultProxy,
|
|
82
|
-
denominationAsset,
|
|
83
|
-
sharesActionTimelock = 0,
|
|
84
|
-
feeManagerConfigData = '0x',
|
|
85
|
-
policyManagerConfigData = '0x',
|
|
86
|
-
bypassPrevReleaseFailure = false,
|
|
87
|
-
}: CreateMigrationRequestParams) {
|
|
88
|
-
const receipt = await fundDeployer
|
|
89
|
-
.connect(signer)
|
|
90
|
-
.createMigrationRequest(
|
|
91
|
-
vaultProxy,
|
|
92
|
-
denominationAsset,
|
|
93
|
-
sharesActionTimelock,
|
|
94
|
-
feeManagerConfigData,
|
|
95
|
-
policyManagerConfigData,
|
|
96
|
-
bypassPrevReleaseFailure,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const comptrollerDeployedArgs = assertEvent(receipt, 'ComptrollerProxyDeployed', {
|
|
100
|
-
comptrollerProxy: expect.any(String) as string,
|
|
101
|
-
creator: signer,
|
|
102
|
-
denominationAsset,
|
|
103
|
-
sharesActionTimelock: BigNumber.from(sharesActionTimelock),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
comptrollerProxy: new ComptrollerLib(comptrollerDeployedArgs.comptrollerProxy, signer),
|
|
108
|
-
receipt,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// TODO: should we pass in the fundOwner as a signer also so we can connect comptroller proxy and vault proxy to that acct instead?
|
|
113
|
-
export async function createNewFund({
|
|
114
|
-
signer,
|
|
115
|
-
fundDeployer,
|
|
116
|
-
denominationAsset,
|
|
117
|
-
sharesActionTimelock = 0,
|
|
118
|
-
fundOwner = randomAddress(),
|
|
119
|
-
fundName = 'My Fund',
|
|
120
|
-
fundSymbol = '',
|
|
121
|
-
feeManagerConfig = '0x',
|
|
122
|
-
policyManagerConfig = '0x',
|
|
123
|
-
investment,
|
|
124
|
-
}: CreateNewFundParams) {
|
|
125
|
-
const receipt = await fundDeployer
|
|
126
|
-
.connect(signer)
|
|
127
|
-
.createNewFund(
|
|
128
|
-
fundOwner,
|
|
129
|
-
fundName,
|
|
130
|
-
fundSymbol,
|
|
131
|
-
denominationAsset,
|
|
132
|
-
sharesActionTimelock,
|
|
133
|
-
feeManagerConfig,
|
|
134
|
-
policyManagerConfig,
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const comptrollerDeployedArgs = assertEvent(receipt, 'ComptrollerProxyDeployed', {
|
|
138
|
-
comptrollerProxy: expect.any(String) as string,
|
|
139
|
-
creator: signer,
|
|
140
|
-
denominationAsset,
|
|
141
|
-
sharesActionTimelock: BigNumber.from(sharesActionTimelock),
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const comptrollerProxy = new ComptrollerLib(comptrollerDeployedArgs.comptrollerProxy, signer);
|
|
145
|
-
|
|
146
|
-
const newFundDeployedArgs = assertEvent(receipt, 'NewFundCreated', {
|
|
147
|
-
comptrollerProxy,
|
|
148
|
-
creator: signer,
|
|
149
|
-
vaultProxy: expect.any(String) as string,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const vaultProxy = new VaultLib(newFundDeployedArgs.vaultProxy, signer);
|
|
153
|
-
|
|
154
|
-
if (investment != null) {
|
|
155
|
-
await buyShares({
|
|
156
|
-
comptrollerProxy,
|
|
157
|
-
denominationAsset,
|
|
158
|
-
...investment,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
comptrollerProxy,
|
|
164
|
-
receipt,
|
|
165
|
-
vaultProxy,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export async function createReconfigurationRequest({
|
|
170
|
-
signer,
|
|
171
|
-
fundDeployer,
|
|
172
|
-
vaultProxy,
|
|
173
|
-
denominationAsset,
|
|
174
|
-
sharesActionTimelock = 0,
|
|
175
|
-
feeManagerConfigData = '0x',
|
|
176
|
-
policyManagerConfigData = '0x',
|
|
177
|
-
}: CreateReconfigurationRequestParams) {
|
|
178
|
-
const receipt = await fundDeployer
|
|
179
|
-
.connect(signer)
|
|
180
|
-
.createReconfigurationRequest(
|
|
181
|
-
vaultProxy,
|
|
182
|
-
denominationAsset,
|
|
183
|
-
sharesActionTimelock,
|
|
184
|
-
feeManagerConfigData,
|
|
185
|
-
policyManagerConfigData,
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
const comptrollerDeployedArgs = assertEvent(receipt, 'ComptrollerProxyDeployed', {
|
|
189
|
-
comptrollerProxy: expect.any(String) as string,
|
|
190
|
-
creator: signer,
|
|
191
|
-
denominationAsset,
|
|
192
|
-
sharesActionTimelock: BigNumber.from(sharesActionTimelock),
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
comptrollerProxy: new ComptrollerLib(comptrollerDeployedArgs.comptrollerProxy, signer),
|
|
197
|
-
receipt,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export async function createVaultProxy({
|
|
202
|
-
signer,
|
|
203
|
-
vaultLib,
|
|
204
|
-
fundOwner,
|
|
205
|
-
fundAccessor,
|
|
206
|
-
fundName = 'My Fund',
|
|
207
|
-
}: {
|
|
208
|
-
signer: SignerWithAddress;
|
|
209
|
-
vaultLib: VaultLib;
|
|
210
|
-
fundOwner: AddressLike;
|
|
211
|
-
fundAccessor: SignerWithAddress;
|
|
212
|
-
fundName?: string;
|
|
213
|
-
}) {
|
|
214
|
-
const constructData = encodeFunctionData(vaultLib.init.fragment, [fundOwner, fundAccessor, fundName]);
|
|
215
|
-
|
|
216
|
-
const vaultProxyContract = await VaultProxy.deploy(signer, constructData, vaultLib);
|
|
217
|
-
|
|
218
|
-
return new VaultLib(vaultProxyContract, fundAccessor);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export async function setupGasRelayerPaymaster({
|
|
222
|
-
signer,
|
|
223
|
-
vaultProxy,
|
|
224
|
-
fundAccessor,
|
|
225
|
-
weth,
|
|
226
|
-
startingBalance = utils.parseUnits('10', 18),
|
|
227
|
-
}: {
|
|
228
|
-
signer: SignerWithAddress;
|
|
229
|
-
vaultProxy: AddressLike;
|
|
230
|
-
fundAccessor: AddressLike;
|
|
231
|
-
weth: StandardToken;
|
|
232
|
-
startingBalance?: BigNumberish;
|
|
233
|
-
}) {
|
|
234
|
-
await weth.transfer(vaultProxy, startingBalance);
|
|
235
|
-
const comptrollerProxy = new ComptrollerLib(fundAccessor, signer);
|
|
236
|
-
const receipt = await comptrollerProxy.deployGasRelayPaymaster();
|
|
237
|
-
|
|
238
|
-
const eventArgs = assertEvent(receipt, 'GasRelayPaymasterSet', {
|
|
239
|
-
gasRelayPaymaster: expect.any(String) as string,
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
return new GasRelayPaymasterLib(eventArgs.gasRelayPaymaster, signer);
|
|
243
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
|
2
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
|
3
|
-
import type { ComptrollerLib, StandardToken } from '@enzymefinance/protocol';
|
|
4
|
-
import type { BigNumberish } from 'ethers';
|
|
5
|
-
import { constants, utils } from 'ethers';
|
|
6
|
-
|
|
7
|
-
export interface BuySharesParams {
|
|
8
|
-
comptrollerProxy: ComptrollerLib;
|
|
9
|
-
denominationAsset: StandardToken;
|
|
10
|
-
buyer: SignerWithAddress;
|
|
11
|
-
investmentAmount?: BigNumberish;
|
|
12
|
-
minSharesQuantity?: BigNumberish;
|
|
13
|
-
seedBuyer?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface RedeemSharesForSpecificAssetsParams {
|
|
17
|
-
comptrollerProxy: ComptrollerLib;
|
|
18
|
-
signer: SignerWithAddress;
|
|
19
|
-
recipient?: AddressLike;
|
|
20
|
-
quantity?: BigNumberish;
|
|
21
|
-
payoutAssets: AddressLike[];
|
|
22
|
-
payoutAssetPercentages: BigNumberish[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface RedeemSharesInKindParams {
|
|
26
|
-
comptrollerProxy: ComptrollerLib;
|
|
27
|
-
signer: SignerWithAddress;
|
|
28
|
-
recipient?: AddressLike;
|
|
29
|
-
quantity?: BigNumberish;
|
|
30
|
-
additionalAssets?: AddressLike[];
|
|
31
|
-
assetsToSkip?: AddressLike[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function buyShares(options: BuySharesParams) {
|
|
35
|
-
return (await buySharesFunction(options)).send();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function buySharesFunction({
|
|
39
|
-
comptrollerProxy,
|
|
40
|
-
denominationAsset,
|
|
41
|
-
buyer,
|
|
42
|
-
investmentAmount,
|
|
43
|
-
minSharesQuantity = 1,
|
|
44
|
-
seedBuyer = false,
|
|
45
|
-
}: BuySharesParams) {
|
|
46
|
-
if (investmentAmount == undefined) {
|
|
47
|
-
investmentAmount = utils.parseUnits('1', await denominationAsset.decimals());
|
|
48
|
-
}
|
|
49
|
-
if (seedBuyer) {
|
|
50
|
-
await denominationAsset.transfer(buyer, investmentAmount);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
await denominationAsset.connect(buyer).approve(comptrollerProxy, investmentAmount);
|
|
54
|
-
|
|
55
|
-
return comptrollerProxy.connect(buyer).buyShares.args(investmentAmount, minSharesQuantity).ref;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function redeemSharesForSpecificAssets({
|
|
59
|
-
comptrollerProxy,
|
|
60
|
-
signer,
|
|
61
|
-
recipient = signer,
|
|
62
|
-
quantity = constants.MaxUint256,
|
|
63
|
-
payoutAssets,
|
|
64
|
-
payoutAssetPercentages,
|
|
65
|
-
}: RedeemSharesForSpecificAssetsParams) {
|
|
66
|
-
return comptrollerProxy
|
|
67
|
-
.connect(signer)
|
|
68
|
-
.redeemSharesForSpecificAssets(recipient, quantity, payoutAssets, payoutAssetPercentages);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export async function redeemSharesInKind({
|
|
72
|
-
comptrollerProxy,
|
|
73
|
-
signer,
|
|
74
|
-
recipient = signer,
|
|
75
|
-
quantity = constants.MaxUint256,
|
|
76
|
-
additionalAssets = [],
|
|
77
|
-
assetsToSkip = [],
|
|
78
|
-
}: RedeemSharesInKindParams) {
|
|
79
|
-
return comptrollerProxy.connect(signer).redeemSharesInKind(recipient, quantity, additionalAssets, assetsToSkip);
|
|
80
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
|
2
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
|
3
|
-
import type { AddressListRegistry, AddressListUpdateType, ComptrollerLib } from '@enzymefinance/protocol';
|
|
4
|
-
import {
|
|
5
|
-
addressListRegistryCreateListSelector,
|
|
6
|
-
curveMinterMintManySelector,
|
|
7
|
-
curveMinterMintSelector,
|
|
8
|
-
curveMinterToggleApproveMintSelector,
|
|
9
|
-
encodeArgs,
|
|
10
|
-
sighash,
|
|
11
|
-
} from '@enzymefinance/protocol';
|
|
12
|
-
import { constants, utils } from 'ethers';
|
|
13
|
-
|
|
14
|
-
export async function vaultCallCreateNewList({
|
|
15
|
-
addressListRegistry,
|
|
16
|
-
comptrollerProxy,
|
|
17
|
-
items,
|
|
18
|
-
owner,
|
|
19
|
-
signer,
|
|
20
|
-
updateType,
|
|
21
|
-
}: {
|
|
22
|
-
addressListRegistry: AddressListRegistry;
|
|
23
|
-
comptrollerProxy: ComptrollerLib;
|
|
24
|
-
items: AddressLike[];
|
|
25
|
-
owner: AddressLike;
|
|
26
|
-
signer: SignerWithAddress;
|
|
27
|
-
updateType: AddressListUpdateType;
|
|
28
|
-
}) {
|
|
29
|
-
await comptrollerProxy
|
|
30
|
-
.connect(signer)
|
|
31
|
-
.vaultCallOnContract(
|
|
32
|
-
addressListRegistry.address,
|
|
33
|
-
addressListRegistryCreateListSelector,
|
|
34
|
-
encodeArgs(['address', 'uint8', 'address[]'], [owner, updateType, items]),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const listCount = await addressListRegistry.getListCount();
|
|
38
|
-
|
|
39
|
-
return listCount.sub(1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function vaultCallCurveMinterMint({
|
|
43
|
-
comptrollerProxy,
|
|
44
|
-
minter,
|
|
45
|
-
gauge,
|
|
46
|
-
}: {
|
|
47
|
-
comptrollerProxy: ComptrollerLib;
|
|
48
|
-
minter: AddressLike;
|
|
49
|
-
gauge: AddressLike;
|
|
50
|
-
}) {
|
|
51
|
-
return comptrollerProxy.vaultCallOnContract(minter, curveMinterMintSelector, encodeArgs(['address'], [gauge]));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function vaultCallCurveMinterMintMany({
|
|
55
|
-
comptrollerProxy,
|
|
56
|
-
minter,
|
|
57
|
-
gauges,
|
|
58
|
-
}: {
|
|
59
|
-
comptrollerProxy: ComptrollerLib;
|
|
60
|
-
minter: AddressLike;
|
|
61
|
-
gauges: AddressLike[];
|
|
62
|
-
}) {
|
|
63
|
-
const gaugesFormatted = new Array(8).fill(constants.AddressZero);
|
|
64
|
-
for (const i in gauges) {
|
|
65
|
-
gaugesFormatted[i] = gauges[i];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return comptrollerProxy.vaultCallOnContract(
|
|
69
|
-
minter,
|
|
70
|
-
curveMinterMintManySelector,
|
|
71
|
-
encodeArgs(['address[8]'], [gaugesFormatted]),
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function vaultCallCurveMinterToggleApproveMint({
|
|
76
|
-
comptrollerProxy,
|
|
77
|
-
minter,
|
|
78
|
-
account,
|
|
79
|
-
}: {
|
|
80
|
-
comptrollerProxy: ComptrollerLib;
|
|
81
|
-
minter: AddressLike;
|
|
82
|
-
account: AddressLike;
|
|
83
|
-
}) {
|
|
84
|
-
return comptrollerProxy.vaultCallOnContract(
|
|
85
|
-
minter,
|
|
86
|
-
curveMinterToggleApproveMintSelector,
|
|
87
|
-
encodeArgs(['address'], [account]),
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function vaultCallStartAssetBypassTimelock({
|
|
92
|
-
comptrollerProxy,
|
|
93
|
-
contract,
|
|
94
|
-
asset,
|
|
95
|
-
}: {
|
|
96
|
-
comptrollerProxy: ComptrollerLib;
|
|
97
|
-
contract: AddressLike;
|
|
98
|
-
asset: AddressLike;
|
|
99
|
-
}) {
|
|
100
|
-
return comptrollerProxy.vaultCallOnContract(
|
|
101
|
-
contract,
|
|
102
|
-
sighash(utils.FunctionFragment.fromString('startAssetBypassTimelock(address)')),
|
|
103
|
-
encodeArgs(['address'], [asset]),
|
|
104
|
-
);
|
|
105
|
-
}
|
package/src/types.d.ts
DELETED
package/src/whales.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { resolveAddress } from '@enzymefinance/ethers';
|
|
2
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
|
3
|
-
|
|
4
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
5
|
-
const whales = {
|
|
6
|
-
// primitives
|
|
7
|
-
bat: '0x12274c71304bc0e6b38a56b94d2949b118feb838',
|
|
8
|
-
bnb: '0xbe0eb53f46cd790cd13851d5eff43d12404d33e8',
|
|
9
|
-
bnt: '0x7d1ed1601a12a172269436fa95fe156650603c1d',
|
|
10
|
-
busd: '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503',
|
|
11
|
-
comp: '0x0f50d31b3eaefd65236dd3736b863cffa4c63c4e',
|
|
12
|
-
crv: '0x4ce799e6eD8D64536b67dD428565d52A531B3640',
|
|
13
|
-
dai: '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503',
|
|
14
|
-
knc: '0x09d51654bd9efbfcb56da3491989cc1444095fff',
|
|
15
|
-
ldo: '0x3dba737ccc50a32a1764b493285dd51c8af6c278',
|
|
16
|
-
link: '0xbe6977e08d4479c0a6777539ae0e8fa27be4e9d6',
|
|
17
|
-
mana: '0xefb94ac00f1cee8a89d5c3f49faa799da6f03024',
|
|
18
|
-
mln: '0xd8f8a53945bcfbbc19da162aa405e662ef71c40d',
|
|
19
|
-
ohm: '0x71a53aff36a699110d66d6bdfff2320caf8d2d59',
|
|
20
|
-
rep: '0xc6a043b07d33b6f30d8cb501026c391cfd25abe1',
|
|
21
|
-
ren: '0xbe0eb53f46cd790cd13851d5eff43d12404d33e8',
|
|
22
|
-
susd: '0xa5f7a39e55d7878bc5bd754ee5d6bd7a7662355b',
|
|
23
|
-
sohm: '0xf280f037cdbda99727ddf5dfede91e68fa78605c',
|
|
24
|
-
uni: '0x47173b170c64d16393a52e6c480b3ad8c302ba1e',
|
|
25
|
-
usdc: '0xae2d4617c862309a3d75a0ffb358c7a5009c673f',
|
|
26
|
-
usdt: '0x5041ed759dd4afc3a72b8192c143f72f4724081a',
|
|
27
|
-
weth: '0xe08A8b19e5722a201EaF20A6BC595eF655397bd5',
|
|
28
|
-
zrx: '0x206376e8940e42538781cd94ef024df3c1e0fd43',
|
|
29
|
-
// aTokens
|
|
30
|
-
ausdc: '0x3DdfA8eC3052539b6C9549F12cEA2C295cfF5296',
|
|
31
|
-
ausdt: '0x7d6149ad9a573a6e2ca6ebf7d4897c1b766841b4',
|
|
32
|
-
// cTokens
|
|
33
|
-
ccomp: '0xd74f186194ab9219fafac5c2fe4b3270169666db',
|
|
34
|
-
cdai: '0xab4ce310054a11328685ece1043211b68ba5d082',
|
|
35
|
-
ceth: '0x8aceab8167c80cb8b3de7fa6228b889bb1130ee8',
|
|
36
|
-
cuni: '0x39d8014b4f40d2cbc441137011d32023f4f1fd87',
|
|
37
|
-
cusdc: '0xe1ed4da4284924ddaf69983b4d813fb1be58c380',
|
|
38
|
-
// fTokens
|
|
39
|
-
fdai7: '0x88884e35d7006ae84efef09ee6bc6a43dd8e2bb8',
|
|
40
|
-
feth7: '0xcd2ba6a4d50745b0b4096186f925115387852c15',
|
|
41
|
-
fdai8: '0x93f3f612a525a59523e91cc5552f718df9fc0746',
|
|
42
|
-
ftribe8: '0xdb5ac83c137321da29a59a7592232bc4ed461730',
|
|
43
|
-
// ptTokens
|
|
44
|
-
ptUsdc: '0xd18236cd213f39d078177b6f6908f0e44e88e4aa',
|
|
45
|
-
// synths (unsupported)
|
|
46
|
-
seth: '0xc34a7c65aa08cb36744bda8eeec7b8e9891e147c',
|
|
47
|
-
sxag: '0x40d68c490bf7262ec40048099aec23535f734be2',
|
|
48
|
-
sxau: '0x92eb453b7b5b8d41edb44e2c8b8b53eb70a482c7',
|
|
49
|
-
// misc
|
|
50
|
-
lidoSteth: '0x31f644e2dd5d74f5c8d6d9de89dd517474d51800',
|
|
51
|
-
ust: '0xf584f8728b874a6a5c7a8d4d387c9aae9172d621',
|
|
52
|
-
// Curve steth pool related
|
|
53
|
-
stecrv: '0x56c915758ad3f76fd287fff7563ee313142fb663',
|
|
54
|
-
} as const;
|
|
55
|
-
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
56
|
-
|
|
57
|
-
export type Whale = keyof typeof whales;
|
|
58
|
-
export type WhaleSigners<T extends Partial<Whale> = Whale> = Record<T, SignerWithAddress>;
|
|
59
|
-
|
|
60
|
-
export async function unlockWhale(token: Whale) {
|
|
61
|
-
const address = resolveAddress(whales[token]);
|
|
62
|
-
await provider.send('hardhat_impersonateAccount', [address]);
|
|
63
|
-
|
|
64
|
-
return provider.getSignerWithAddress(address);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function unlockAllWhales() {
|
|
68
|
-
const keys = Object.keys(whales) as Whale[];
|
|
69
|
-
const signers = await Promise.all(keys.map(async (token) => unlockWhale(token)));
|
|
70
|
-
|
|
71
|
-
return keys.reduce((carry, key, index) => {
|
|
72
|
-
return { ...carry, [key]: signers[index] };
|
|
73
|
-
}, {} as WhaleSigners);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export async function unlockWhales<T extends Whale>(...tokens: T[]) {
|
|
77
|
-
const signers = await Promise.all(tokens.map(async (token) => unlockWhale(token)));
|
|
78
|
-
|
|
79
|
-
return tokens.reduce((carry, key, index) => {
|
|
80
|
-
return { ...carry, [key]: signers[index] };
|
|
81
|
-
}, {} as WhaleSigners<T>);
|
|
82
|
-
}
|