@enzymefinance/testutils 4.0.0-next.5 → 4.0.0
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/CHANGELOG.md +40 -0
- package/dist/declarations/src/deployment.d.ts +34 -27
- package/dist/declarations/src/scaffolding/assets.d.ts +1 -1
- package/dist/declarations/src/scaffolding/core.d.ts +2 -3
- package/dist/declarations/src/scaffolding/extensions/external-positions/aave-debt.d.ts +51 -0
- package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +2 -1
- package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +1 -0
- package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +4 -1
- package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +12 -11
- package/dist/declarations/src/scaffolding/extensions/fees.d.ts +3 -3
- package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +2 -2
- package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +30 -2
- package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +63 -229
- package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +3 -3
- package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +1 -1
- package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +17 -0
- package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +5 -10
- package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +2 -2
- package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +1 -1
- package/dist/declarations/src/scaffolding/extensions/policies.d.ts +8 -8
- package/dist/declarations/src/whales.d.ts +12 -5
- package/dist/enzymefinance-testutils.browser.cjs.js +826 -721
- package/dist/enzymefinance-testutils.browser.esm.js +809 -692
- package/dist/enzymefinance-testutils.cjs.dev.js +826 -721
- package/dist/enzymefinance-testutils.cjs.prod.js +826 -721
- package/dist/enzymefinance-testutils.esm.js +809 -692
- package/package.json +6 -6
- package/src/deployment.ts +39 -31
- package/src/scaffolding/assets.ts +1 -1
- package/src/scaffolding/core.ts +3 -9
- package/src/scaffolding/extensions/external-positions/aave-debt.ts +179 -0
- package/src/scaffolding/extensions/external-positions/actions.ts +6 -1
- package/src/scaffolding/extensions/external-positions/index.ts +1 -0
- package/src/scaffolding/extensions/external-positions/mocks.ts +7 -10
- package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +18 -24
- package/src/scaffolding/extensions/integrations/compound.ts +163 -2
- package/src/scaffolding/extensions/integrations/curve.ts +152 -783
- package/src/scaffolding/extensions/integrations/index.ts +1 -1
- package/src/scaffolding/extensions/integrations/olympusV2.ts +71 -0
- package/src/scaffolding/extensions/integrations/synthetix.ts +6 -25
- package/src/types.d.ts +1 -0
- package/src/whales.ts +14 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV4.d.ts +0 -23
- package/src/scaffolding/extensions/integrations/paraSwapV4.ts +0 -70
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@enzymefinance/testutils",
|
3
|
-
"version": "4.0.0
|
3
|
+
"version": "4.0.0",
|
4
4
|
"main": "dist/enzymefinance-testutils.cjs.js",
|
5
5
|
"module": "dist/enzymefinance-testutils.esm.js",
|
6
6
|
"browser": {
|
@@ -8,10 +8,10 @@
|
|
8
8
|
"./dist/enzymefinance-testutils.esm.js": "./dist/enzymefinance-testutils.browser.esm.js"
|
9
9
|
},
|
10
10
|
"dependencies": {
|
11
|
-
"@babel/runtime": "^7.
|
12
|
-
"@enzymefinance/ethers": "^1.0.
|
13
|
-
"@enzymefinance/hardhat": "^1.0.
|
14
|
-
"@enzymefinance/protocol": "^4.0.0
|
15
|
-
"ethers": "^5.5.
|
11
|
+
"@babel/runtime": "^7.16.7",
|
12
|
+
"@enzymefinance/ethers": "^1.0.16",
|
13
|
+
"@enzymefinance/hardhat": "^1.0.16",
|
14
|
+
"@enzymefinance/protocol": "^4.0.0",
|
15
|
+
"ethers": "^5.5.4"
|
16
16
|
}
|
17
17
|
}
|
package/src/deployment.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
AaveAdapter,
|
3
|
+
AaveDebtPositionLib,
|
4
|
+
AaveDebtPositionParser,
|
3
5
|
AavePriceFeed,
|
4
6
|
AddressListRegistry,
|
5
7
|
AllowedAdapterIncomingAssetsPolicy,
|
@@ -8,18 +10,17 @@ import {
|
|
8
10
|
AllowedDepositRecipientsPolicy,
|
9
11
|
AllowedExternalPositionTypesPolicy,
|
10
12
|
AllowedSharesTransferRecipientsPolicy,
|
11
|
-
AssetFinalityResolver,
|
12
13
|
CompoundAdapter,
|
13
14
|
CompoundDebtPositionLib,
|
14
15
|
CompoundDebtPositionParser,
|
15
16
|
CompoundPriceFeed,
|
16
17
|
ComptrollerLib,
|
18
|
+
ConvexCurveLpStakingAdapter,
|
19
|
+
ConvexCurveLpStakingWrapperFactory,
|
20
|
+
ConvexCurveLpStakingWrapperPriceFeed,
|
17
21
|
CumulativeSlippageTolerancePolicy,
|
18
22
|
CurveExchangeAdapter,
|
19
|
-
|
20
|
-
CurveLiquidityEursAdapter,
|
21
|
-
CurveLiquiditySethAdapter,
|
22
|
-
CurveLiquidityStethAdapter,
|
23
|
+
CurveLiquidityAdapter,
|
23
24
|
CurvePriceFeed,
|
24
25
|
DepositWrapper,
|
25
26
|
Dispatcher,
|
@@ -34,8 +35,9 @@ import {
|
|
34
35
|
FundValueCalculator,
|
35
36
|
FundValueCalculatorRouter,
|
36
37
|
FundValueCalculatorUsdWrapper,
|
38
|
+
FuseAdapter,
|
39
|
+
FusePriceFeed,
|
37
40
|
GasRelayPaymasterFactory,
|
38
|
-
GuaranteedRedemptionPolicy,
|
39
41
|
IdleAdapter,
|
40
42
|
IdlePriceFeed,
|
41
43
|
IntegrationManager,
|
@@ -43,9 +45,9 @@ import {
|
|
43
45
|
ManagementFee,
|
44
46
|
MinAssetBalancesPostRedemptionPolicy,
|
45
47
|
MinMaxInvestmentPolicy,
|
48
|
+
OlympusV2Adapter,
|
46
49
|
OnlyRemoveDustExternalPositionPolicy,
|
47
50
|
OnlyUntrackDustOrPricelessAssetsPolicy,
|
48
|
-
ParaSwapV4Adapter,
|
49
51
|
ParaSwapV5Adapter,
|
50
52
|
PerformanceFee,
|
51
53
|
PolicyManager,
|
@@ -54,14 +56,13 @@ import {
|
|
54
56
|
ProtocolFeeReserveLib,
|
55
57
|
ProtocolFeeTracker,
|
56
58
|
RevertingPriceFeed,
|
57
|
-
StakehoundEthPriceFeed,
|
58
59
|
SynthetixAdapter,
|
59
|
-
SynthetixPriceFeed,
|
60
60
|
UniswapV2ExchangeAdapter,
|
61
61
|
UniswapV2LiquidityAdapter,
|
62
62
|
UniswapV2PoolPriceFeed,
|
63
63
|
UniswapV3Adapter,
|
64
64
|
UnpermissionedActionsWrapper,
|
65
|
+
UsdEthSimulatedAggregator,
|
65
66
|
ValueInterpreter,
|
66
67
|
VaultLib,
|
67
68
|
YearnVaultV2Adapter,
|
@@ -93,6 +94,8 @@ export async function deployProtocolFixture() {
|
|
93
94
|
// prettier-ignore
|
94
95
|
const deployment = {
|
95
96
|
aaveAdapter: new AaveAdapter(fixture['AaveAdapter'].address, deployer),
|
97
|
+
aaveDebtPositionLib: new AaveDebtPositionLib(fixture['AaveDebtPositionLib'].address, deployer),
|
98
|
+
aaveDebtPositionParser: new AaveDebtPositionParser(fixture['AaveDebtPositionParser'].address, deployer),
|
96
99
|
aavePriceFeed: new AavePriceFeed(fixture['AavePriceFeed'].address, deployer),
|
97
100
|
addressListRegistry: new AddressListRegistry(fixture['AddressListRegistry'].address, deployer),
|
98
101
|
allowedAdapterIncomingAssetsPolicy: new AllowedAdapterIncomingAssetsPolicy(fixture['AllowedAdapterIncomingAssetsPolicy'].address, deployer),
|
@@ -101,18 +104,17 @@ export async function deployProtocolFixture() {
|
|
101
104
|
allowedDepositRecipientsPolicy: new AllowedDepositRecipientsPolicy(fixture['AllowedDepositRecipientsPolicy'].address, deployer),
|
102
105
|
allowedExternalPositionTypesPolicy: new AllowedExternalPositionTypesPolicy(fixture['AllowedExternalPositionTypesPolicy'].address, deployer),
|
103
106
|
allowedSharesTransferRecipientsPolicy: new AllowedSharesTransferRecipientsPolicy(fixture['AllowedSharesTransferRecipientsPolicy'].address, deployer),
|
104
|
-
assetFinalityResolver: new AssetFinalityResolver(fixture['AssetFinalityResolver'].address, deployer),
|
105
107
|
compoundAdapter: new CompoundAdapter(fixture['CompoundAdapter'].address, deployer),
|
106
108
|
compoundDebtPositionLib: new CompoundDebtPositionLib(fixture['CompoundDebtPositionLib'].address, deployer),
|
107
109
|
compoundDebtPositionParser: new CompoundDebtPositionParser(fixture['CompoundDebtPositionParser'].address, deployer),
|
108
110
|
compoundPriceFeed: new CompoundPriceFeed(fixture['CompoundPriceFeed'].address, deployer),
|
109
111
|
comptrollerLib: new ComptrollerLib(fixture['ComptrollerLib'].address, deployer),
|
112
|
+
convexCurveLpStakingAdapter: new ConvexCurveLpStakingAdapter(fixture['ConvexCurveLpStakingAdapter'].address, deployer),
|
113
|
+
convexCurveLpStakingWrapperFactory: new ConvexCurveLpStakingWrapperFactory(fixture['ConvexCurveLpStakingWrapperFactory'].address, deployer),
|
114
|
+
convexCurveLpStakingWrapperPriceFeed: new ConvexCurveLpStakingWrapperPriceFeed(fixture['ConvexCurveLpStakingWrapperPriceFeed'].address, deployer),
|
110
115
|
cumulativeSlippageTolerancePolicy: new CumulativeSlippageTolerancePolicy(fixture['CumulativeSlippageTolerancePolicy'].address, deployer),
|
111
116
|
curveExchangeAdapter: new CurveExchangeAdapter(fixture['CurveExchangeAdapter'].address, deployer),
|
112
|
-
|
113
|
-
curveLiquidityEursAdapter: new CurveLiquidityEursAdapter(fixture['CurveLiquidityEursAdapter'].address, deployer),
|
114
|
-
curveLiquiditySethAdapter: new CurveLiquiditySethAdapter(fixture['CurveLiquiditySethAdapter'].address, deployer),
|
115
|
-
curveLiquidityStethAdapter: new CurveLiquidityStethAdapter(fixture['CurveLiquidityStethAdapter'].address, deployer),
|
117
|
+
curveLiquidityAdapter: new CurveLiquidityAdapter(fixture['CurveLiquidityAdapter'].address, deployer),
|
116
118
|
curvePriceFeed: new CurvePriceFeed(fixture['CurvePriceFeed'].address, deployer),
|
117
119
|
depositWrapper: new DepositWrapper(fixture['DepositWrapper'].address, deployer),
|
118
120
|
dispatcher: new Dispatcher(fixture['Dispatcher'].address, deployer),
|
@@ -127,8 +129,9 @@ export async function deployProtocolFixture() {
|
|
127
129
|
fundValueCalculator: new FundValueCalculator(fixture['FundValueCalculator'].address, deployer),
|
128
130
|
fundValueCalculatorRouter: new FundValueCalculatorRouter(fixture['FundValueCalculatorRouter'].address, deployer),
|
129
131
|
fundValueCalculatorUsdWrapper: new FundValueCalculatorUsdWrapper(fixture['FundValueCalculatorUsdWrapper'].address, deployer),
|
132
|
+
fuseAdapter: new FuseAdapter(fixture['FuseAdapter'].address, deployer),
|
133
|
+
fusePriceFeed: new FusePriceFeed(fixture['FusePriceFeed'].address, deployer),
|
130
134
|
gasRelayPaymasterFactory: new GasRelayPaymasterFactory(fixture['GasRelayPaymasterFactory'].address, deployer),
|
131
|
-
guaranteedRedemptionPolicy: new GuaranteedRedemptionPolicy(fixture['GuaranteedRedemptionPolicy'].address, deployer),
|
132
135
|
idleAdapter: new IdleAdapter(fixture['IdleAdapter'].address, deployer),
|
133
136
|
idlePriceFeed: new IdlePriceFeed(fixture['IdlePriceFeed'].address, deployer),
|
134
137
|
integrationManager: new IntegrationManager(fixture['IntegrationManager'].address, deployer),
|
@@ -136,9 +139,9 @@ export async function deployProtocolFixture() {
|
|
136
139
|
managementFee: new ManagementFee(fixture['ManagementFee'].address, deployer),
|
137
140
|
minAssetBalancesPostRedemptionPolicy: new MinAssetBalancesPostRedemptionPolicy(fixture['MinAssetBalancesPostRedemptionPolicy'].address, deployer),
|
138
141
|
minMaxInvestmentPolicy: new MinMaxInvestmentPolicy(fixture['MinMaxInvestmentPolicy'].address, deployer),
|
142
|
+
olympusV2Adapter: new OlympusV2Adapter(fixture['OlympusV2Adapter'].address, deployer),
|
139
143
|
onlyRemoveDustExternalPositionPolicy: new OnlyRemoveDustExternalPositionPolicy(fixture['OnlyRemoveDustExternalPositionPolicy'].address, deployer),
|
140
144
|
onlyUntrackDustOrPricelessAssetsPolicy: new OnlyUntrackDustOrPricelessAssetsPolicy(fixture['OnlyUntrackDustOrPricelessAssetsPolicy'].address, deployer),
|
141
|
-
paraSwapV4Adapter: new ParaSwapV4Adapter(fixture['ParaSwapV4Adapter'].address, deployer),
|
142
145
|
paraSwapV5Adapter: new ParaSwapV5Adapter(fixture['ParaSwapV5Adapter'].address, deployer),
|
143
146
|
performanceFee: new PerformanceFee(fixture['PerformanceFee'].address, deployer),
|
144
147
|
policyManager: new PolicyManager(fixture['PolicyManager'].address, deployer),
|
@@ -148,14 +151,13 @@ export async function deployProtocolFixture() {
|
|
148
151
|
protocolFeeReserveProxy: new ProtocolFeeReserveLib(fixture['ProtocolFeeReserveProxy'].address, deployer),
|
149
152
|
protocolFeeTracker: new ProtocolFeeTracker(fixture['ProtocolFeeTracker'].address, deployer),
|
150
153
|
revertingPriceFeed: new RevertingPriceFeed(fixture['RevertingPriceFeed'].address, deployer),
|
151
|
-
stakehoundEthPriceFeed: new StakehoundEthPriceFeed(fixture['StakehoundEthPriceFeed'].address, deployer),
|
152
154
|
synthetixAdapter: new SynthetixAdapter(fixture['SynthetixAdapter'].address, deployer),
|
153
|
-
synthetixPriceFeed: new SynthetixPriceFeed(fixture['SynthetixPriceFeed'].address, deployer),
|
154
155
|
uniswapV2ExchangeAdapter: new UniswapV2ExchangeAdapter(fixture['UniswapV2ExchangeAdapter'].address, deployer),
|
155
156
|
uniswapV2LiquidityAdapter: new UniswapV2LiquidityAdapter(fixture['UniswapV2LiquidityAdapter'].address, deployer),
|
156
157
|
uniswapV2PoolPriceFeed: new UniswapV2PoolPriceFeed(fixture['UniswapV2PoolPriceFeed'].address, deployer),
|
157
158
|
uniswapV3Adapter: new UniswapV3Adapter(fixture['UniswapV3Adapter'].address, deployer),
|
158
159
|
unpermissionedActionsWrapper: new UnpermissionedActionsWrapper(fixture['UnpermissionedActionsWrapper'].address, deployer),
|
160
|
+
usdEthSimulatedAggregator: new UsdEthSimulatedAggregator(fixture['UsdEthSimulatedAggregator'].address, deployer),
|
159
161
|
valueInterpreter: new ValueInterpreter(fixture['ValueInterpreter'].address, deployer),
|
160
162
|
vaultLib: new VaultLib(fixture['VaultLib'].address, deployer),
|
161
163
|
yearnVaultV2Adapter: new YearnVaultV2Adapter(fixture['YearnVaultV2Adapter'].address, deployer),
|
@@ -178,7 +180,13 @@ export type ProtocolDeployment = Resolve<typeof deployProtocolFixture>;
|
|
178
180
|
import type { ChainlinkRateAsset } from '@enzymefinance/protocol';
|
179
181
|
|
180
182
|
export interface DeploymentConfig {
|
183
|
+
feeBps: number;
|
181
184
|
feeToken: string;
|
185
|
+
feeTokenBurn: {
|
186
|
+
burnFromVault: boolean;
|
187
|
+
sendToProtocolFeeReserve: boolean;
|
188
|
+
externalBurnerAddress: string;
|
189
|
+
};
|
182
190
|
weth: string;
|
183
191
|
wrappedNativeAsset: string;
|
184
192
|
primitives: Record<string, string>;
|
@@ -194,19 +202,23 @@ export interface DeploymentConfig {
|
|
194
202
|
synthetix: {
|
195
203
|
snx: string;
|
196
204
|
susd: string;
|
197
|
-
synths: Record<string, string>;
|
198
|
-
addressResolver: string;
|
199
205
|
delegateApprovals: string;
|
200
206
|
originator: string;
|
201
207
|
redeemer: string;
|
202
208
|
trackingCode: string;
|
203
209
|
};
|
210
|
+
convex: {
|
211
|
+
booster: string;
|
212
|
+
crvToken: string;
|
213
|
+
cvxToken: string;
|
214
|
+
};
|
204
215
|
curve: {
|
205
216
|
addressProvider: string;
|
206
217
|
minter: string;
|
207
218
|
pools: Record<string, { pool: string; lpToken: string; liquidityGaugeToken: string; invariantProxyAsset: string }>;
|
208
219
|
};
|
209
220
|
aave: {
|
221
|
+
incentivesController: string;
|
210
222
|
lendingPoolAddressProvider: string;
|
211
223
|
protocolDataProvider: string;
|
212
224
|
atokens: Record<string, [string, string]>;
|
@@ -216,6 +228,10 @@ export interface DeploymentConfig {
|
|
216
228
|
comptroller: string;
|
217
229
|
ctokens: Record<string, string>;
|
218
230
|
};
|
231
|
+
fuse: {
|
232
|
+
fetherTokens: Record<string, string>;
|
233
|
+
ftokens: Record<string, string>;
|
234
|
+
};
|
219
235
|
idle: {
|
220
236
|
bestYieldIdleDai: string;
|
221
237
|
bestYieldIdleUsdc: string;
|
@@ -230,9 +246,8 @@ export interface DeploymentConfig {
|
|
230
246
|
lido: {
|
231
247
|
steth: string;
|
232
248
|
};
|
233
|
-
|
234
|
-
|
235
|
-
tokenTransferProxy: string;
|
249
|
+
olympusV2: {
|
250
|
+
stakingContract: string;
|
236
251
|
};
|
237
252
|
paraSwapV5: {
|
238
253
|
augustusSwapper: string;
|
@@ -241,9 +256,7 @@ export interface DeploymentConfig {
|
|
241
256
|
poolTogetherV4: {
|
242
257
|
ptTokens: Record<string, [string, string]>;
|
243
258
|
};
|
244
|
-
|
245
|
-
steth: string;
|
246
|
-
};
|
259
|
+
positionsLimit: number;
|
247
260
|
unsupportedAssets: Record<string, string>;
|
248
261
|
uniswap: {
|
249
262
|
factory: string;
|
@@ -264,9 +277,4 @@ export interface DeploymentConfig {
|
|
264
277
|
exchange: string;
|
265
278
|
allowedMakers: string[];
|
266
279
|
};
|
267
|
-
policies: {
|
268
|
-
guaranteedRedemption: {
|
269
|
-
redemptionWindowBuffer: number;
|
270
|
-
};
|
271
|
-
};
|
272
280
|
}
|
@@ -17,7 +17,7 @@ export async function addNewAssetsToFund({
|
|
17
17
|
assets: StandardToken[];
|
18
18
|
amounts?: BigNumberish[];
|
19
19
|
}) {
|
20
|
-
// First, add tracked assets
|
20
|
+
// First, add tracked assets
|
21
21
|
const receipt = addTrackedAssetsToVault({
|
22
22
|
assets,
|
23
23
|
comptrollerProxy,
|
package/src/scaffolding/core.ts
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
import type {
|
2
|
-
AssetFinalityResolver,
|
3
|
-
Dispatcher,
|
4
|
-
GasRelayPaymasterFactory,
|
5
|
-
ValueInterpreter,
|
6
|
-
} from '@enzymefinance/protocol';
|
1
|
+
import type { Dispatcher, GasRelayPaymasterFactory, ValueInterpreter } from '@enzymefinance/protocol';
|
7
2
|
import {
|
8
3
|
ComptrollerLib,
|
9
4
|
ExternalPositionManager,
|
@@ -20,7 +15,6 @@ import type { Signer } from 'ethers';
|
|
20
15
|
// unless overrides are passed-in
|
21
16
|
export async function createFundDeployer({
|
22
17
|
deployer,
|
23
|
-
assetFinalityResolver,
|
24
18
|
externalPositionManager,
|
25
19
|
dispatcher,
|
26
20
|
gasRelayPaymasterFactory,
|
@@ -30,7 +24,6 @@ export async function createFundDeployer({
|
|
30
24
|
setReleaseLive = true,
|
31
25
|
}: {
|
32
26
|
deployer: Signer;
|
33
|
-
assetFinalityResolver: AssetFinalityResolver;
|
34
27
|
externalPositionManager: ExternalPositionManager;
|
35
28
|
dispatcher: Dispatcher;
|
36
29
|
feeManager: FeeManager;
|
@@ -76,7 +69,6 @@ export async function createFundDeployer({
|
|
76
69
|
nextFeeManager,
|
77
70
|
nextIntegrationManager,
|
78
71
|
nextPolicyManager,
|
79
|
-
assetFinalityResolver,
|
80
72
|
gasRelayPaymasterFactory,
|
81
73
|
mlnToken,
|
82
74
|
wethToken,
|
@@ -94,7 +86,9 @@ export async function createFundDeployer({
|
|
94
86
|
await vaultLib.getProtocolFeeReserve(),
|
95
87
|
nextProtocolFeeTracker,
|
96
88
|
await vaultLib.getMlnToken(),
|
89
|
+
await vaultLib.getMlnBurner(),
|
97
90
|
await vaultLib.getWethToken(),
|
91
|
+
await vaultLib.getPositionsLimit(),
|
98
92
|
);
|
99
93
|
await nextFundDeployer.setVaultLib(nextVaultLib);
|
100
94
|
|
@@ -0,0 +1,179 @@
|
|
1
|
+
import type { AddressLike } from '@enzymefinance/ethers';
|
2
|
+
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
3
|
+
import type { ComptrollerLib, ExternalPositionManager } from '@enzymefinance/protocol';
|
4
|
+
import {
|
5
|
+
AaveDebtPositionActionId,
|
6
|
+
aaveDebtPositionAddCollateralArgs,
|
7
|
+
aaveDebtPositionBorrowArgs,
|
8
|
+
aaveDebtPositionClaimRewardsArgs,
|
9
|
+
aaveDebtPositionRemoveCollateralArgs,
|
10
|
+
aaveDebtPositionRepayBorrowArgs,
|
11
|
+
ExternalPositionType,
|
12
|
+
} from '@enzymefinance/protocol';
|
13
|
+
import type { BigNumberish } from 'ethers';
|
14
|
+
|
15
|
+
import { callOnExternalPosition, createExternalPosition } from './actions';
|
16
|
+
|
17
|
+
export async function aaveDebtPositionAddCollateral({
|
18
|
+
comptrollerProxy,
|
19
|
+
externalPositionManager,
|
20
|
+
signer,
|
21
|
+
aTokens,
|
22
|
+
amounts,
|
23
|
+
externalPositionProxy,
|
24
|
+
}: {
|
25
|
+
comptrollerProxy: ComptrollerLib;
|
26
|
+
externalPositionManager: ExternalPositionManager;
|
27
|
+
signer: SignerWithAddress;
|
28
|
+
aTokens: AddressLike[];
|
29
|
+
amounts: BigNumberish[];
|
30
|
+
externalPositionProxy: AddressLike;
|
31
|
+
}) {
|
32
|
+
const actionArgs = aaveDebtPositionAddCollateralArgs({
|
33
|
+
aTokens,
|
34
|
+
amounts,
|
35
|
+
});
|
36
|
+
|
37
|
+
return callOnExternalPosition({
|
38
|
+
actionArgs,
|
39
|
+
actionId: AaveDebtPositionActionId.AddCollateralAssets,
|
40
|
+
comptrollerProxy,
|
41
|
+
externalPositionManager,
|
42
|
+
externalPositionProxy,
|
43
|
+
signer,
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
export async function aaveDebtPositionBorrow({
|
48
|
+
comptrollerProxy,
|
49
|
+
externalPositionManager,
|
50
|
+
signer,
|
51
|
+
tokens,
|
52
|
+
amounts,
|
53
|
+
externalPositionProxy,
|
54
|
+
}: {
|
55
|
+
comptrollerProxy: ComptrollerLib;
|
56
|
+
externalPositionManager: ExternalPositionManager;
|
57
|
+
signer: SignerWithAddress;
|
58
|
+
tokens: AddressLike[];
|
59
|
+
amounts: BigNumberish[];
|
60
|
+
externalPositionProxy: AddressLike;
|
61
|
+
}) {
|
62
|
+
const actionArgs = aaveDebtPositionBorrowArgs({
|
63
|
+
amounts,
|
64
|
+
tokens,
|
65
|
+
});
|
66
|
+
|
67
|
+
return callOnExternalPosition({
|
68
|
+
actionArgs,
|
69
|
+
actionId: AaveDebtPositionActionId.BorrowAsset,
|
70
|
+
comptrollerProxy,
|
71
|
+
externalPositionManager,
|
72
|
+
externalPositionProxy,
|
73
|
+
signer,
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
export async function aaveDebtPositionClaimRewards({
|
78
|
+
comptrollerProxy,
|
79
|
+
externalPositionManager,
|
80
|
+
signer,
|
81
|
+
assets,
|
82
|
+
externalPositionProxy,
|
83
|
+
}: {
|
84
|
+
comptrollerProxy: ComptrollerLib;
|
85
|
+
externalPositionManager: ExternalPositionManager;
|
86
|
+
signer: SignerWithAddress;
|
87
|
+
assets: AddressLike[];
|
88
|
+
externalPositionProxy: AddressLike;
|
89
|
+
}) {
|
90
|
+
const actionArgs = aaveDebtPositionClaimRewardsArgs({
|
91
|
+
assets,
|
92
|
+
});
|
93
|
+
|
94
|
+
return callOnExternalPosition({
|
95
|
+
actionArgs,
|
96
|
+
actionId: AaveDebtPositionActionId.ClaimRewards,
|
97
|
+
comptrollerProxy,
|
98
|
+
externalPositionManager,
|
99
|
+
externalPositionProxy,
|
100
|
+
signer,
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
export async function aaveDebtPositionRemoveCollateral({
|
105
|
+
comptrollerProxy,
|
106
|
+
externalPositionManager,
|
107
|
+
signer,
|
108
|
+
aTokens,
|
109
|
+
amounts,
|
110
|
+
externalPositionProxy,
|
111
|
+
}: {
|
112
|
+
comptrollerProxy: ComptrollerLib;
|
113
|
+
externalPositionManager: ExternalPositionManager;
|
114
|
+
signer: SignerWithAddress;
|
115
|
+
aTokens: AddressLike[];
|
116
|
+
amounts: BigNumberish[];
|
117
|
+
externalPositionProxy: AddressLike;
|
118
|
+
}) {
|
119
|
+
const actionArgs = aaveDebtPositionRemoveCollateralArgs({
|
120
|
+
aTokens,
|
121
|
+
amounts,
|
122
|
+
});
|
123
|
+
|
124
|
+
return callOnExternalPosition({
|
125
|
+
actionArgs,
|
126
|
+
actionId: AaveDebtPositionActionId.RemoveCollateralAssets,
|
127
|
+
comptrollerProxy,
|
128
|
+
externalPositionManager,
|
129
|
+
externalPositionProxy,
|
130
|
+
signer,
|
131
|
+
});
|
132
|
+
}
|
133
|
+
|
134
|
+
export async function aaveDebtPositionRepayBorrow({
|
135
|
+
comptrollerProxy,
|
136
|
+
externalPositionManager,
|
137
|
+
signer,
|
138
|
+
tokens,
|
139
|
+
amounts,
|
140
|
+
externalPositionProxy,
|
141
|
+
}: {
|
142
|
+
comptrollerProxy: ComptrollerLib;
|
143
|
+
externalPositionManager: ExternalPositionManager;
|
144
|
+
signer: SignerWithAddress;
|
145
|
+
tokens: AddressLike[];
|
146
|
+
amounts: BigNumberish[];
|
147
|
+
externalPositionProxy: AddressLike;
|
148
|
+
}) {
|
149
|
+
const actionArgs = aaveDebtPositionRepayBorrowArgs({
|
150
|
+
amounts,
|
151
|
+
tokens,
|
152
|
+
});
|
153
|
+
|
154
|
+
return callOnExternalPosition({
|
155
|
+
actionArgs,
|
156
|
+
actionId: AaveDebtPositionActionId.RepayBorrowedAssets,
|
157
|
+
comptrollerProxy,
|
158
|
+
externalPositionManager,
|
159
|
+
externalPositionProxy,
|
160
|
+
signer,
|
161
|
+
});
|
162
|
+
}
|
163
|
+
|
164
|
+
export async function createAaveDebtPosition({
|
165
|
+
signer,
|
166
|
+
comptrollerProxy,
|
167
|
+
externalPositionManager,
|
168
|
+
}: {
|
169
|
+
signer: SignerWithAddress;
|
170
|
+
comptrollerProxy: ComptrollerLib;
|
171
|
+
externalPositionManager: ExternalPositionManager;
|
172
|
+
}) {
|
173
|
+
return createExternalPosition({
|
174
|
+
comptrollerProxy,
|
175
|
+
externalPositionManager,
|
176
|
+
externalPositionTypeId: ExternalPositionType.AaveDebtPosition,
|
177
|
+
signer,
|
178
|
+
});
|
179
|
+
}
|
@@ -44,19 +44,24 @@ export async function createExternalPosition({
|
|
44
44
|
externalPositionManager,
|
45
45
|
externalPositionTypeId,
|
46
46
|
initializationData = '0x',
|
47
|
+
callOnExternalPositionData = '0x',
|
47
48
|
}: {
|
48
49
|
signer: SignerWithAddress;
|
49
50
|
comptrollerProxy: ComptrollerLib;
|
50
51
|
externalPositionManager: ExternalPositionManager;
|
51
52
|
externalPositionTypeId: BigNumberish;
|
52
53
|
initializationData?: BytesLike;
|
54
|
+
callOnExternalPositionData?: BytesLike;
|
53
55
|
}) {
|
54
56
|
const receipt = await comptrollerProxy
|
55
57
|
.connect(signer)
|
56
58
|
.callOnExtension(
|
57
59
|
externalPositionManager,
|
58
60
|
ExternalPositionManagerActionId.CreateExternalPosition,
|
59
|
-
encodeArgs(
|
61
|
+
encodeArgs(
|
62
|
+
['uint256', 'bytes', 'bytes'],
|
63
|
+
[externalPositionTypeId, initializationData, callOnExternalPositionData],
|
64
|
+
),
|
60
65
|
);
|
61
66
|
|
62
67
|
const event = extractEvent(receipt, externalPositionManager.abi.getEvent('ExternalPositionDeployedForFund'));
|
@@ -2,8 +2,6 @@ import type { AddressLike } from '@enzymefinance/ethers';
|
|
2
2
|
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
3
3
|
import type { ComptrollerLib, ExternalPositionFactory, ExternalPositionManager } from '@enzymefinance/protocol';
|
4
4
|
import {
|
5
|
-
encodeArgs,
|
6
|
-
ExternalPositionManagerActionId,
|
7
5
|
mockGenericExternalPositionActionArgs,
|
8
6
|
MockGenericExternalPositionActionId,
|
9
7
|
MockGenericExternalPositionLib,
|
@@ -12,7 +10,7 @@ import {
|
|
12
10
|
} from '@enzymefinance/protocol';
|
13
11
|
import type { BigNumberish } from 'ethers';
|
14
12
|
|
15
|
-
import { callOnExternalPosition } from './actions';
|
13
|
+
import { callOnExternalPosition, createExternalPosition } from './actions';
|
16
14
|
|
17
15
|
export async function createMockExternalPosition({
|
18
16
|
comptrollerProxy,
|
@@ -54,13 +52,12 @@ export async function createMockExternalPosition({
|
|
54
52
|
[mockExternalPositionParser],
|
55
53
|
);
|
56
54
|
|
57
|
-
const receipt = await
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
);
|
55
|
+
const receipt = await createExternalPosition({
|
56
|
+
comptrollerProxy,
|
57
|
+
externalPositionManager,
|
58
|
+
externalPositionTypeId: typeId,
|
59
|
+
signer: fundOwner,
|
60
|
+
});
|
64
61
|
|
65
62
|
const externalPositionProxy = (await vaultProxy.getActiveExternalPositions())[0];
|
66
63
|
|
@@ -4,20 +4,19 @@ import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
|
4
4
|
import type { ComptrollerLib, ExternalPositionManager } from '@enzymefinance/protocol';
|
5
5
|
import {
|
6
6
|
callOnExternalPositionArgs,
|
7
|
-
encodeArgs,
|
8
7
|
ExternalPositionManagerActionId,
|
9
8
|
ExternalPositionType,
|
10
9
|
UniswapV3LiquidityPositionActionId,
|
11
10
|
uniswapV3LiquidityPositionAddLiquidityArgs,
|
12
11
|
uniswapV3LiquidityPositionCollectArgs,
|
13
|
-
uniswapV3LiquidityPositionInitArgs,
|
14
12
|
UniswapV3LiquidityPositionLib,
|
15
13
|
uniswapV3LiquidityPositionMintArgs,
|
16
14
|
uniswapV3LiquidityPositionPurgeArgs,
|
17
15
|
uniswapV3LiquidityPositionRemoveLiquidityArgs,
|
18
|
-
VaultLib,
|
19
16
|
} from '@enzymefinance/protocol';
|
20
|
-
import type { BigNumber, BigNumberish } from 'ethers';
|
17
|
+
import type { BigNumber, BigNumberish, BytesLike } from 'ethers';
|
18
|
+
|
19
|
+
import { createExternalPosition } from './actions';
|
21
20
|
|
22
21
|
export enum UniswapV3FeeAmount {
|
23
22
|
LOW = 500,
|
@@ -58,33 +57,22 @@ export async function createUniswapV3LiquidityPosition({
|
|
58
57
|
signer,
|
59
58
|
comptrollerProxy,
|
60
59
|
externalPositionManager,
|
61
|
-
|
62
|
-
token1,
|
60
|
+
callOnExternalPositionData = '0x',
|
63
61
|
}: {
|
64
62
|
signer: SignerWithAddress;
|
65
63
|
comptrollerProxy: ComptrollerLib;
|
66
64
|
externalPositionManager: ExternalPositionManager;
|
67
|
-
|
68
|
-
token1: AddressLike;
|
65
|
+
callOnExternalPositionData?: BytesLike;
|
69
66
|
}) {
|
70
|
-
const
|
71
|
-
|
72
|
-
|
67
|
+
const { externalPositionProxy: externalPositionProxyContract, receipt } = await createExternalPosition({
|
68
|
+
callOnExternalPositionData,
|
69
|
+
comptrollerProxy,
|
70
|
+
externalPositionManager,
|
71
|
+
externalPositionTypeId: ExternalPositionType.UniswapV3LiquidityPosition,
|
72
|
+
signer,
|
73
73
|
});
|
74
74
|
|
75
|
-
|
76
|
-
.connect(signer)
|
77
|
-
.callOnExtension(
|
78
|
-
externalPositionManager,
|
79
|
-
ExternalPositionManagerActionId.CreateExternalPosition,
|
80
|
-
encodeArgs(['uint256', 'bytes'], [ExternalPositionType.UniswapV3LiquidityPosition, initArgs]),
|
81
|
-
);
|
82
|
-
|
83
|
-
const vaultProxy = new VaultLib(await comptrollerProxy.getVaultProxy(), signer);
|
84
|
-
const externalPositions = await vaultProxy.getActiveExternalPositions.call();
|
85
|
-
const externalPositionProxyAddress = externalPositions[externalPositions.length - 1];
|
86
|
-
|
87
|
-
return { externalPositionProxyAddress, receipt };
|
75
|
+
return { externalPositionProxyAddress: externalPositionProxyContract.address, receipt };
|
88
76
|
}
|
89
77
|
|
90
78
|
export async function uniswapV3LiquidityPositionAddLiquidity({
|
@@ -160,6 +148,8 @@ export async function uniswapV3LiquidityPositionMint({
|
|
160
148
|
comptrollerProxy,
|
161
149
|
externalPositionManager,
|
162
150
|
externalPositionProxy,
|
151
|
+
token0,
|
152
|
+
token1,
|
163
153
|
fee,
|
164
154
|
tickLower,
|
165
155
|
tickUpper,
|
@@ -172,6 +162,8 @@ export async function uniswapV3LiquidityPositionMint({
|
|
172
162
|
comptrollerProxy: ComptrollerLib;
|
173
163
|
externalPositionManager: ExternalPositionManager;
|
174
164
|
externalPositionProxy: AddressLike;
|
165
|
+
token0: AddressLike;
|
166
|
+
token1: AddressLike;
|
175
167
|
fee: BigNumberish;
|
176
168
|
tickLower: BigNumberish;
|
177
169
|
tickUpper: BigNumberish;
|
@@ -188,6 +180,8 @@ export async function uniswapV3LiquidityPositionMint({
|
|
188
180
|
fee,
|
189
181
|
tickLower,
|
190
182
|
tickUpper,
|
183
|
+
token0,
|
184
|
+
token1,
|
191
185
|
});
|
192
186
|
|
193
187
|
const callArgs = callOnExternalPositionArgs({
|