@enzymefinance/testutils 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/index.d.ts +1548 -0
  2. package/dist/index.js +3352 -0
  3. package/dist/index.mjs +3352 -0
  4. package/package.json +74 -11
  5. package/CHANGELOG.md +0 -84
  6. package/dist/declarations/src/assertions.d.ts +0 -4
  7. package/dist/declarations/src/deployment.d.ts +0 -188
  8. package/dist/declarations/src/gasRelayer.d.ts +0 -56
  9. package/dist/declarations/src/helpers.d.ts +0 -16
  10. package/dist/declarations/src/index.d.ts +0 -6
  11. package/dist/declarations/src/scaffolding/assets.d.ts +0 -10
  12. package/dist/declarations/src/scaffolding/chainlink.d.ts +0 -3
  13. package/dist/declarations/src/scaffolding/common.d.ts +0 -7
  14. package/dist/declarations/src/scaffolding/core.d.ts +0 -16
  15. package/dist/declarations/src/scaffolding/extensions/common.d.ts +0 -11
  16. package/dist/declarations/src/scaffolding/extensions/external-positions/aave-debt.d.ts +0 -51
  17. package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +0 -36
  18. package/dist/declarations/src/scaffolding/extensions/external-positions/compound.d.ts +0 -56
  19. package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +0 -5
  20. package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +0 -56
  21. package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +0 -100
  22. package/dist/declarations/src/scaffolding/extensions/fees.d.ts +0 -12
  23. package/dist/declarations/src/scaffolding/extensions/index.d.ts +0 -5
  24. package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +0 -20
  25. package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +0 -56
  26. package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +0 -106
  27. package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +0 -28
  28. package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +0 -14
  29. package/dist/declarations/src/scaffolding/extensions/integrations/mock.d.ts +0 -32
  30. package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +0 -17
  31. package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV5.d.ts +0 -23
  32. package/dist/declarations/src/scaffolding/extensions/integrations/poolTogetherV4.d.ts +0 -29
  33. package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +0 -28
  34. package/dist/declarations/src/scaffolding/extensions/integrations/trackedAssets.d.ts +0 -15
  35. package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV2.d.ts +0 -46
  36. package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV3.d.ts +0 -15
  37. package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +0 -22
  38. package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +0 -12
  39. package/dist/declarations/src/scaffolding/extensions/policies.d.ts +0 -17
  40. package/dist/declarations/src/scaffolding/index.d.ts +0 -8
  41. package/dist/declarations/src/scaffolding/setup.d.ts +0 -77
  42. package/dist/declarations/src/scaffolding/shares.d.ts +0 -35
  43. package/dist/declarations/src/scaffolding/vaultCalls.d.ts +0 -32
  44. package/dist/declarations/src/whales.d.ts +0 -49
  45. package/dist/enzymefinance-testutils.browser.cjs.js +0 -4158
  46. package/dist/enzymefinance-testutils.browser.esm.js +0 -4028
  47. package/dist/enzymefinance-testutils.cjs.d.ts +0 -1
  48. package/dist/enzymefinance-testutils.cjs.dev.js +0 -4158
  49. package/dist/enzymefinance-testutils.cjs.js +0 -7
  50. package/dist/enzymefinance-testutils.cjs.prod.js +0 -4158
  51. package/dist/enzymefinance-testutils.esm.js +0 -4028
  52. package/src/assertions.ts +0 -23
  53. package/src/deployment.ts +0 -280
  54. package/src/gasRelayer.ts +0 -95
  55. package/src/helpers.ts +0 -39
  56. package/src/index.ts +0 -6
  57. package/src/scaffolding/assets.ts +0 -37
  58. package/src/scaffolding/chainlink.ts +0 -8
  59. package/src/scaffolding/common.ts +0 -11
  60. package/src/scaffolding/core.ts +0 -103
  61. package/src/scaffolding/extensions/common.ts +0 -30
  62. package/src/scaffolding/extensions/external-positions/aave-debt.ts +0 -179
  63. package/src/scaffolding/extensions/external-positions/actions.ts +0 -108
  64. package/src/scaffolding/extensions/external-positions/compound.ts +0 -190
  65. package/src/scaffolding/extensions/external-positions/index.ts +0 -5
  66. package/src/scaffolding/extensions/external-positions/mocks.ts +0 -191
  67. package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +0 -284
  68. package/src/scaffolding/extensions/fees.ts +0 -70
  69. package/src/scaffolding/extensions/index.ts +0 -5
  70. package/src/scaffolding/extensions/integrations/aave.ts +0 -78
  71. package/src/scaffolding/extensions/integrations/compound.ts +0 -255
  72. package/src/scaffolding/extensions/integrations/curve.ts +0 -354
  73. package/src/scaffolding/extensions/integrations/idle.ts +0 -104
  74. package/src/scaffolding/extensions/integrations/index.ts +0 -14
  75. package/src/scaffolding/extensions/integrations/mock.ts +0 -116
  76. package/src/scaffolding/extensions/integrations/olympusV2.ts +0 -71
  77. package/src/scaffolding/extensions/integrations/paraSwapV5.ts +0 -73
  78. package/src/scaffolding/extensions/integrations/poolTogetherV4.ts +0 -117
  79. package/src/scaffolding/extensions/integrations/synthetix.ts +0 -111
  80. package/src/scaffolding/extensions/integrations/trackedAssets.ts +0 -48
  81. package/src/scaffolding/extensions/integrations/uniswapV2.ts +0 -175
  82. package/src/scaffolding/extensions/integrations/uniswapV3.ts +0 -55
  83. package/src/scaffolding/extensions/integrations/yearn.ts +0 -79
  84. package/src/scaffolding/extensions/integrations/zeroExV2.ts +0 -47
  85. package/src/scaffolding/extensions/policies.ts +0 -112
  86. package/src/scaffolding/index.ts +0 -8
  87. package/src/scaffolding/setup.ts +0 -243
  88. package/src/scaffolding/shares.ts +0 -80
  89. package/src/scaffolding/vaultCalls.ts +0 -105
  90. package/src/types.d.ts +0 -2
  91. package/src/whales.ts +0 -82
  92. package/tsconfig.json +0 -5
package/dist/index.js ADDED
@@ -0,0 +1,3352 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/accounts.ts
22
+ var _ethers = require('@enzymefinance/ethers');
23
+
24
+ // src/helpers.ts
25
+ var _protocol = require('@enzymefinance/protocol');
26
+ var _ethers3 = require('ethers');
27
+ var _merkletreejs = require('merkletreejs');
28
+ async function calcMlnValueAndBurnAmountForSharesBuyback({
29
+ valueInterpreter,
30
+ mln,
31
+ denominationAsset,
32
+ sharesSupply,
33
+ gav,
34
+ buybackSharesAmount
35
+ }) {
36
+ const grossShareValue = _ethers3.BigNumber.from(gav).mul(_ethers3.utils.parseEther("1")).div(sharesSupply);
37
+ const denominationAssetValueOfBuyback = grossShareValue.mul(buybackSharesAmount).div(_ethers3.utils.parseEther("1"));
38
+ const mlnValueOfBuyback = await valueInterpreter.calcCanonicalAssetValue.args(denominationAsset, denominationAssetValueOfBuyback, mln).call();
39
+ const mlnAmountToBurn = mlnValueOfBuyback.div(2);
40
+ return { mlnAmountToBurn, mlnValue: mlnValueOfBuyback };
41
+ }
42
+ function generateMerkleTreeForContractProof({
43
+ itemArrays,
44
+ itemTypes
45
+ }) {
46
+ const leaves = itemArrays.map((itemArray) => _ethers3.utils.solidityKeccak256(itemTypes, itemArray));
47
+ const tree = new (0, _merkletreejs.MerkleTree)(leaves, _ethers3.utils.keccak256, { sort: true });
48
+ const root = tree.getHexRoot();
49
+ return { leaves, root, tree };
50
+ }
51
+ async function sendEthBySelfDestruct({
52
+ signer,
53
+ recipient,
54
+ amount = _ethers3.utils.parseEther("1")
55
+ }) {
56
+ const selfDestructEthPayer = await _protocol.SelfDestructEthPayer.deploy(signer);
57
+ await selfDestructEthPayer.destructTo.args(recipient).value(amount).send();
58
+ }
59
+ async function transactionTimestamp(receipt) {
60
+ const block = await provider.getBlock(receipt.blockNumber);
61
+ return block.timestamp;
62
+ }
63
+
64
+ // src/accounts.ts
65
+ async function impersonateContractSigner({
66
+ contractAddress,
67
+ ethSeeder,
68
+ provider: provider2
69
+ }) {
70
+ await sendEthBySelfDestruct({ recipient: contractAddress, signer: ethSeeder });
71
+ return impersonateSigner({
72
+ provider: provider2,
73
+ signerAddress: contractAddress
74
+ });
75
+ }
76
+ async function impersonateSigner({
77
+ signerAddress,
78
+ provider: provider2
79
+ }) {
80
+ await provider2.send("hardhat_impersonateAccount", [signerAddress]);
81
+ return provider2.getSignerWithAddress(_ethers.resolveAddress.call(void 0, signerAddress));
82
+ }
83
+
84
+ // src/assertions.ts
85
+
86
+ function assertEvent(receipt, event, match) {
87
+ var _a;
88
+ const events = _ethers.extractEvent.call(void 0, receipt, event);
89
+ expect(events.length).toBe(1);
90
+ expect(receipt).toHaveEmittedWith(event, match);
91
+ const args = (_a = events.shift()) == null ? void 0 : _a.args;
92
+ return args;
93
+ }
94
+ function assertNoEvent(receipt, event) {
95
+ const events = _ethers.extractEvent.call(void 0, receipt, event);
96
+ expect(events.length).toBe(0);
97
+ }
98
+
99
+ // src/deployment.ts
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+ async function getNamedSigner(name) {
180
+ const accounts = await hre.getNamedAccounts();
181
+ if (!accounts[name]) {
182
+ throw new Error(`Missing account with name ${name}`);
183
+ }
184
+ return provider.getSignerWithAddress(accounts[name]);
185
+ }
186
+ async function getUnnamedSigners() {
187
+ const accounts = await hre.getUnnamedAccounts();
188
+ return Promise.all(accounts.map((account) => provider.getSignerWithAddress(account)));
189
+ }
190
+ async function deployProtocolFixture() {
191
+ const fixture = await hre.deployments.fixture();
192
+ const deployer = await getNamedSigner("deployer");
193
+ const accounts = await getUnnamedSigners();
194
+ const config = fixture.Config.linkedData;
195
+ const deployment = {
196
+ aaveAdapter: new (0, _protocol.AaveAdapter)(fixture.AaveAdapter.address, deployer),
197
+ aaveDebtPositionLib: new (0, _protocol.AaveDebtPositionLib)(fixture.AaveDebtPositionLib.address, deployer),
198
+ aaveDebtPositionParser: new (0, _protocol.AaveDebtPositionParser)(fixture.AaveDebtPositionParser.address, deployer),
199
+ aavePriceFeed: new (0, _protocol.AavePriceFeed)(fixture.AavePriceFeed.address, deployer),
200
+ addressListRegistry: new (0, _protocol.AddressListRegistry)(fixture.AddressListRegistry.address, deployer),
201
+ allowedAdapterIncomingAssetsPolicy: new (0, _protocol.AllowedAdapterIncomingAssetsPolicy)(fixture.AllowedAdapterIncomingAssetsPolicy.address, deployer),
202
+ allowedAdaptersPolicy: new (0, _protocol.AllowedAdaptersPolicy)(fixture.AllowedAdaptersPolicy.address, deployer),
203
+ allowedAssetsForRedemptionPolicy: new (0, _protocol.AllowedAssetsForRedemptionPolicy)(fixture.AllowedAssetsForRedemptionPolicy.address, deployer),
204
+ allowedDepositRecipientsPolicy: new (0, _protocol.AllowedDepositRecipientsPolicy)(fixture.AllowedDepositRecipientsPolicy.address, deployer),
205
+ allowedExternalPositionTypesPolicy: new (0, _protocol.AllowedExternalPositionTypesPolicy)(fixture.AllowedExternalPositionTypesPolicy.address, deployer),
206
+ allowedSharesTransferRecipientsPolicy: new (0, _protocol.AllowedSharesTransferRecipientsPolicy)(fixture.AllowedSharesTransferRecipientsPolicy.address, deployer),
207
+ compoundAdapter: new (0, _protocol.CompoundAdapter)(fixture.CompoundAdapter.address, deployer),
208
+ compoundDebtPositionLib: new (0, _protocol.CompoundDebtPositionLib)(fixture.CompoundDebtPositionLib.address, deployer),
209
+ compoundDebtPositionParser: new (0, _protocol.CompoundDebtPositionParser)(fixture.CompoundDebtPositionParser.address, deployer),
210
+ compoundPriceFeed: new (0, _protocol.CompoundPriceFeed)(fixture.CompoundPriceFeed.address, deployer),
211
+ comptrollerLib: new (0, _protocol.ComptrollerLib)(fixture.ComptrollerLib.address, deployer),
212
+ convexCurveLpStakingAdapter: new (0, _protocol.ConvexCurveLpStakingAdapter)(fixture.ConvexCurveLpStakingAdapter.address, deployer),
213
+ convexCurveLpStakingWrapperFactory: new (0, _protocol.ConvexCurveLpStakingWrapperFactory)(fixture.ConvexCurveLpStakingWrapperFactory.address, deployer),
214
+ convexCurveLpStakingWrapperPriceFeed: new (0, _protocol.ConvexCurveLpStakingWrapperPriceFeed)(fixture.ConvexCurveLpStakingWrapperPriceFeed.address, deployer),
215
+ convexVotingPositionLib: new (0, _protocol.ConvexVotingPositionLib)(fixture.ConvexVotingPositionLib.address, deployer),
216
+ convexVotingPositionParser: new (0, _protocol.ConvexVotingPositionParser)(fixture.ConvexVotingPositionParser.address, deployer),
217
+ cumulativeSlippageTolerancePolicy: new (0, _protocol.CumulativeSlippageTolerancePolicy)(fixture.CumulativeSlippageTolerancePolicy.address, deployer),
218
+ curveExchangeAdapter: new (0, _protocol.CurveExchangeAdapter)(fixture.CurveExchangeAdapter.address, deployer),
219
+ curveLiquidityAdapter: new (0, _protocol.CurveLiquidityAdapter)(fixture.CurveLiquidityAdapter.address, deployer),
220
+ curvePriceFeed: new (0, _protocol.CurvePriceFeed)(fixture.CurvePriceFeed.address, deployer),
221
+ depositWrapper: new (0, _protocol.DepositWrapper)(fixture.DepositWrapper.address, deployer),
222
+ dispatcher: new (0, _protocol.Dispatcher)(fixture.Dispatcher.address, deployer),
223
+ entranceRateBurnFee: new (0, _protocol.EntranceRateBurnFee)(fixture.EntranceRateBurnFee.address, deployer),
224
+ entranceRateDirectFee: new (0, _protocol.EntranceRateDirectFee)(fixture.EntranceRateDirectFee.address, deployer),
225
+ exitRateBurnFee: new (0, _protocol.ExitRateBurnFee)(fixture.ExitRateBurnFee.address, deployer),
226
+ exitRateDirectFee: new (0, _protocol.ExitRateDirectFee)(fixture.ExitRateDirectFee.address, deployer),
227
+ externalPositionFactory: new (0, _protocol.ExternalPositionFactory)(fixture.ExternalPositionFactory.address, deployer),
228
+ externalPositionManager: new (0, _protocol.ExternalPositionManager)(fixture.ExternalPositionManager.address, deployer),
229
+ feeManager: new (0, _protocol.FeeManager)(fixture.FeeManager.address, deployer),
230
+ fundDeployer: new (0, _protocol.FundDeployer)(fixture.FundDeployer.address, deployer),
231
+ fundValueCalculator: new (0, _protocol.FundValueCalculator)(fixture.FundValueCalculator.address, deployer),
232
+ fundValueCalculatorRouter: new (0, _protocol.FundValueCalculatorRouter)(fixture.FundValueCalculatorRouter.address, deployer),
233
+ fundValueCalculatorUsdWrapper: new (0, _protocol.FundValueCalculatorUsdWrapper)(fixture.FundValueCalculatorUsdWrapper.address, deployer),
234
+ fuseAdapter: new (0, _protocol.FuseAdapter)(fixture.FuseAdapter.address, deployer),
235
+ fusePriceFeed: new (0, _protocol.FusePriceFeed)(fixture.FusePriceFeed.address, deployer),
236
+ gasRelayPaymasterFactory: new (0, _protocol.GasRelayPaymasterFactory)(fixture.GasRelayPaymasterFactory.address, deployer),
237
+ globalConfigLib: new (0, _protocol.GlobalConfigLib)(fixture.GlobalConfigLib.address, deployer),
238
+ globalConfigProxy: new (0, _protocol.GlobalConfigLib)(fixture.GlobalConfigProxy.address, deployer),
239
+ idleAdapter: new (0, _protocol.IdleAdapter)(fixture.IdleAdapter.address, deployer),
240
+ idlePriceFeed: new (0, _protocol.IdlePriceFeed)(fixture.IdlePriceFeed.address, deployer),
241
+ integrationManager: new (0, _protocol.IntegrationManager)(fixture.IntegrationManager.address, deployer),
242
+ lidoStethPriceFeed: new (0, _protocol.LidoStethPriceFeed)(fixture.LidoStethPriceFeed.address, deployer),
243
+ liquityDebtPositionLib: new (0, _protocol.LiquityDebtPositionLib)(fixture.LiquityDebtPositionLib.address, deployer),
244
+ liquityDebtPositionParser: new (0, _protocol.LiquityDebtPositionParser)(fixture.LiquityDebtPositionParser.address, deployer),
245
+ managementFee: new (0, _protocol.ManagementFee)(fixture.ManagementFee.address, deployer),
246
+ mapleLiquidityPositionLib: new (0, _protocol.MapleLiquidityPositionLib)(fixture.MapleLiquidityPositionLib.address, deployer),
247
+ mapleLiquidityPositionParser: new (0, _protocol.MapleLiquidityPositionParser)(fixture.MapleLiquidityPositionParser.address, deployer),
248
+ minAssetBalancesPostRedemptionPolicy: new (0, _protocol.MinAssetBalancesPostRedemptionPolicy)(fixture.MinAssetBalancesPostRedemptionPolicy.address, deployer),
249
+ minMaxInvestmentPolicy: new (0, _protocol.MinMaxInvestmentPolicy)(fixture.MinMaxInvestmentPolicy.address, deployer),
250
+ olympusV2Adapter: new (0, _protocol.OlympusV2Adapter)(fixture.OlympusV2Adapter.address, deployer),
251
+ onlyRemoveDustExternalPositionPolicy: new (0, _protocol.OnlyRemoveDustExternalPositionPolicy)(fixture.OnlyRemoveDustExternalPositionPolicy.address, deployer),
252
+ onlyUntrackDustOrPricelessAssetsPolicy: new (0, _protocol.OnlyUntrackDustOrPricelessAssetsPolicy)(fixture.OnlyUntrackDustOrPricelessAssetsPolicy.address, deployer),
253
+ paraSwapV5Adapter: new (0, _protocol.ParaSwapV5Adapter)(fixture.ParaSwapV5Adapter.address, deployer),
254
+ performanceFee: new (0, _protocol.PerformanceFee)(fixture.PerformanceFee.address, deployer),
255
+ policyManager: new (0, _protocol.PolicyManager)(fixture.PolicyManager.address, deployer),
256
+ poolTogetherV4Adapter: new (0, _protocol.PoolTogetherV4Adapter)(fixture.PoolTogetherV4Adapter.address, deployer),
257
+ poolTogetherV4PriceFeed: new (0, _protocol.PoolTogetherV4PriceFeed)(fixture.PoolTogetherV4PriceFeed.address, deployer),
258
+ protocolFeeReserveLib: new (0, _protocol.ProtocolFeeReserveLib)(fixture.ProtocolFeeReserveLib.address, deployer),
259
+ protocolFeeReserveProxy: new (0, _protocol.ProtocolFeeReserveLib)(fixture.ProtocolFeeReserveProxy.address, deployer),
260
+ protocolFeeTracker: new (0, _protocol.ProtocolFeeTracker)(fixture.ProtocolFeeTracker.address, deployer),
261
+ revertingPriceFeed: new (0, _protocol.RevertingPriceFeed)(fixture.RevertingPriceFeed.address, deployer),
262
+ sharesSplitterFactory: new (0, _protocol.SharesSplitterFactory)(fixture.SharesSplitterFactory.address, deployer),
263
+ synthetixAdapter: new (0, _protocol.SynthetixAdapter)(fixture.SynthetixAdapter.address, deployer),
264
+ uniswapV2ExchangeAdapter: new (0, _protocol.UniswapV2ExchangeAdapter)(fixture.UniswapV2ExchangeAdapter.address, deployer),
265
+ uniswapV2LiquidityAdapter: new (0, _protocol.UniswapV2LiquidityAdapter)(fixture.UniswapV2LiquidityAdapter.address, deployer),
266
+ uniswapV2PoolPriceFeed: new (0, _protocol.UniswapV2PoolPriceFeed)(fixture.UniswapV2PoolPriceFeed.address, deployer),
267
+ uniswapV3Adapter: new (0, _protocol.UniswapV3Adapter)(fixture.UniswapV3Adapter.address, deployer),
268
+ unpermissionedActionsWrapper: new (0, _protocol.UnpermissionedActionsWrapper)(fixture.UnpermissionedActionsWrapper.address, deployer),
269
+ usdEthSimulatedAggregator: new (0, _protocol.UsdEthSimulatedAggregator)(fixture.UsdEthSimulatedAggregator.address, deployer),
270
+ valueInterpreter: new (0, _protocol.ValueInterpreter)(fixture.ValueInterpreter.address, deployer),
271
+ vaultLib: new (0, _protocol.VaultLib)(fixture.VaultLib.address, deployer),
272
+ yearnVaultV2Adapter: new (0, _protocol.YearnVaultV2Adapter)(fixture.YearnVaultV2Adapter.address, deployer),
273
+ yearnVaultV2PriceFeed: new (0, _protocol.YearnVaultV2PriceFeed)(fixture.YearnVaultV2PriceFeed.address, deployer),
274
+ zeroExV2Adapter: new (0, _protocol.ZeroExV2Adapter)(fixture.ZeroExV2Adapter.address, deployer)
275
+ };
276
+ return {
277
+ accounts,
278
+ config,
279
+ deployer,
280
+ deployment
281
+ };
282
+ }
283
+
284
+ // src/gasRelayer.ts
285
+
286
+
287
+ async function relayTransaction(options) {
288
+ const signer = options.sendFunction.contract.signer;
289
+ if (!(signer && _protocol.isTypedDataSigner.call(void 0, signer))) {
290
+ throw new Error("Missing or invalid signer");
291
+ }
292
+ const { relayData, relayRequest, signedRelayRequest } = await _protocol.createSignedRelayRequest.call(void 0, options);
293
+ const defaultGasLimit = 1245e4;
294
+ const defaultMaxAcceptance = _ethers3.BigNumber.from(15e4);
295
+ const mergedRelayRequest = {
296
+ relayData,
297
+ request: relayRequest
298
+ };
299
+ const relayHub = new (0, _protocol.IGsnRelayHub)(options.relayHub, provider.getSigner(options.relayWorker));
300
+ return relayHub.relayCall.args(defaultMaxAcceptance, mergedRelayRequest, signedRelayRequest, "0x", defaultGasLimit).gas(defaultGasLimit, relayData.gasPrice).send();
301
+ }
302
+ var relayed = _ethers3.utils.EventFragment.fromString("TransactionRelayed(address indexed relayManager, address indexed relayWorker, address indexed from, address to, address paymaster, bytes4 selector, uint8 status, uint256 charge)");
303
+ var rejected = _ethers3.utils.EventFragment.fromString("TransactionRejectedByPaymaster(address indexed relayManager, address indexed paymaster, address indexed from, address to, address relayWorker, bytes4 selector, uint256 innerGasUsed, bytes reason)");
304
+ function assertDidRelay(receipt) {
305
+ return assertEvent(receipt, relayed, {
306
+ charge: expect.anything(),
307
+ from: expect.any(String),
308
+ paymaster: expect.any(String),
309
+ relayManager: expect.any(String),
310
+ relayWorker: expect.any(String),
311
+ selector: expect.any(String),
312
+ status: expect.anything(),
313
+ to: expect.any(String)
314
+ });
315
+ }
316
+ function assertDidRelaySuccessfully(receipt) {
317
+ const result = assertDidRelay(receipt);
318
+ expect(result.status).toEqBigNumber(0);
319
+ }
320
+ function assertDidRelayWithError(receipt) {
321
+ const result = assertDidRelay(receipt);
322
+ expect(result.status).toEqBigNumber(1);
323
+ }
324
+ function assertDidRelayWithCharge(receipt, amount, tolerance) {
325
+ const result = assertDidRelay(receipt);
326
+ expect(result.charge).toBeAroundBigNumber(amount, tolerance);
327
+ }
328
+ function assertPaymasterDidReject(receipt) {
329
+ return assertEvent(receipt, rejected, {
330
+ from: expect.any(String),
331
+ innerGasUsed: expect.anything(),
332
+ paymaster: expect.any(String),
333
+ reason: expect.any(String),
334
+ relayManager: expect.any(String),
335
+ relayWorker: expect.any(String),
336
+ selector: expect.any(String),
337
+ to: expect.any(String)
338
+ });
339
+ }
340
+ function assertPaymasterDidRejectForReason(receipt, reason) {
341
+ const params = assertPaymasterDidReject(receipt);
342
+ expect(_ethers3.utils.toUtf8String(`0x${params.reason.substr(138)}`)).toMatch(reason);
343
+ }
344
+
345
+ // src/scaffolding/extensions/integrations/trackedAssets.ts
346
+
347
+
348
+
349
+
350
+
351
+ function addTrackedAssetsToVault({
352
+ signer,
353
+ comptrollerProxy,
354
+ integrationManager,
355
+ assets
356
+ }) {
357
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.AddTrackedAssetsToVault, _protocol.addTrackedAssetsToVaultArgs.call(void 0, { assets }));
358
+ }
359
+ function removeTrackedAssetsFromVault({
360
+ signer,
361
+ comptrollerProxy,
362
+ integrationManager,
363
+ assets
364
+ }) {
365
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.RemoveTrackedAssetsFromVault, _protocol.removeTrackedAssetsFromVaultArgs.call(void 0, { assets }));
366
+ }
367
+
368
+ // src/scaffolding/assets.ts
369
+ async function addNewAssetsToFund({
370
+ signer,
371
+ comptrollerProxy,
372
+ integrationManager,
373
+ assets,
374
+ amounts = new Array(assets.length).fill(1)
375
+ }) {
376
+ const receipt = addTrackedAssetsToVault({
377
+ assets,
378
+ comptrollerProxy,
379
+ integrationManager,
380
+ signer
381
+ });
382
+ const vaultProxy = await comptrollerProxy.getVaultProxy();
383
+ for (const i in assets) {
384
+ if (amounts[i] > 0) {
385
+ await assets[i].transfer(vaultProxy, amounts[i]);
386
+ }
387
+ }
388
+ return receipt;
389
+ }
390
+
391
+ // src/scaffolding/chainlink.ts
392
+ async function updateChainlinkAggregator(aggregator, price) {
393
+ const answer = price != null ? price : await aggregator.latestAnswer();
394
+ const block = await aggregator.provider.getBlock("latest");
395
+ await aggregator.setLatestAnswer(answer, block.timestamp);
396
+ }
397
+
398
+ // src/scaffolding/common.ts
399
+
400
+
401
+ async function getAssetBalances({ account, assets }) {
402
+ return Promise.all(assets.map((asset) => new (0, _protocol.StandardToken)(asset, provider).balanceOf(account)));
403
+ }
404
+ async function getAssetUnit(asset) {
405
+ return _ethers3.utils.parseUnits("1", await asset.decimals());
406
+ }
407
+
408
+ // src/scaffolding/core.ts
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+ async function createFundDeployer({
420
+ deployer,
421
+ externalPositionManager,
422
+ dispatcher,
423
+ gasRelayPaymasterFactory,
424
+ valueInterpreter,
425
+ vaultLib,
426
+ setOnDispatcher = true,
427
+ setReleaseLive = true
428
+ }) {
429
+ const mlnToken = await vaultLib.getMlnToken();
430
+ const wethToken = await vaultLib.getWethToken();
431
+ const protocolFeeReserve = await vaultLib.getProtocolFeeReserve();
432
+ const nextFundDeployer = await _protocol.FundDeployer.deploy(deployer, dispatcher, gasRelayPaymasterFactory);
433
+ const nextPolicyManager = await _protocol.PolicyManager.deploy(deployer, nextFundDeployer, gasRelayPaymasterFactory);
434
+ const nextExternalPositionManager = await _protocol.ExternalPositionManager.deploy(deployer, nextFundDeployer, await externalPositionManager.getExternalPositionFactory(), nextPolicyManager);
435
+ const nextFeeManager = await _protocol.FeeManager.deploy(deployer, nextFundDeployer);
436
+ const nextIntegrationManager = await _protocol.IntegrationManager.deploy(deployer, nextFundDeployer, nextPolicyManager, valueInterpreter);
437
+ const nextComptrollerLib = await _protocol.ComptrollerLib.deploy(deployer, dispatcher, protocolFeeReserve, nextFundDeployer, valueInterpreter, nextExternalPositionManager, nextFeeManager, nextIntegrationManager, nextPolicyManager, gasRelayPaymasterFactory, mlnToken, wethToken);
438
+ await nextFundDeployer.setComptrollerLib(nextComptrollerLib);
439
+ const nextProtocolFeeTracker = await _protocol.ProtocolFeeTracker.deploy(deployer, nextFundDeployer);
440
+ await nextFundDeployer.setProtocolFeeTracker(nextProtocolFeeTracker);
441
+ const nextVaultLib = await _protocol.VaultLib.deploy(deployer, externalPositionManager, await vaultLib.getGasRelayPaymasterFactory(), await vaultLib.getProtocolFeeReserve(), nextProtocolFeeTracker, await vaultLib.getMlnToken(), await vaultLib.getMlnBurner(), await vaultLib.getWethToken(), await vaultLib.getPositionsLimit());
442
+ await nextFundDeployer.setVaultLib(nextVaultLib);
443
+ if (setReleaseLive) {
444
+ await nextFundDeployer.setReleaseLive();
445
+ }
446
+ if (setOnDispatcher) {
447
+ await dispatcher.setCurrentFundDeployer(nextFundDeployer);
448
+ }
449
+ return nextFundDeployer;
450
+ }
451
+
452
+ // src/scaffolding/extensions/common.ts
453
+ async function callOnExtension({
454
+ comptrollerProxy,
455
+ extension,
456
+ actionId,
457
+ callArgs = "0x",
458
+ signer
459
+ }) {
460
+ let callOnExtensionTx;
461
+ if (signer) {
462
+ callOnExtensionTx = comptrollerProxy.connect(signer).callOnExtension(extension, actionId, callArgs);
463
+ } else {
464
+ callOnExtensionTx = comptrollerProxy.callOnExtension(extension, actionId, callArgs);
465
+ }
466
+ await expect(callOnExtensionTx).resolves.toBeReceipt();
467
+ return callOnExtensionTx;
468
+ }
469
+
470
+ // src/scaffolding/extensions/external-positions/aave-debt.ts
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+ // src/scaffolding/extensions/external-positions/actions.ts
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+ async function callOnExternalPosition({
492
+ signer,
493
+ comptrollerProxy,
494
+ externalPositionManager,
495
+ externalPositionProxy,
496
+ actionId,
497
+ actionArgs
498
+ }) {
499
+ const callArgs = _protocol.callOnExternalPositionArgs.call(void 0, {
500
+ actionArgs,
501
+ actionId,
502
+ externalPositionProxy
503
+ });
504
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CallOnExternalPosition, callArgs);
505
+ }
506
+ async function createExternalPosition({
507
+ signer,
508
+ comptrollerProxy,
509
+ externalPositionManager,
510
+ externalPositionTypeId,
511
+ initializationData = "0x",
512
+ callOnExternalPositionData = "0x"
513
+ }) {
514
+ const receipt = await comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CreateExternalPosition, _protocol.encodeArgs.call(void 0, ["uint256", "bytes", "bytes"], [externalPositionTypeId, initializationData, callOnExternalPositionData]));
515
+ const event = _ethers.extractEvent.call(void 0, receipt, externalPositionManager.abi.getEvent("ExternalPositionDeployedForFund"));
516
+ const externalPositionProxy = new (0, _protocol.IExternalPositionProxy)(event[0].args.externalPosition, signer);
517
+ return { externalPositionProxy, receipt };
518
+ }
519
+ async function reactivateExternalPosition({
520
+ signer,
521
+ comptrollerProxy,
522
+ externalPositionManager,
523
+ externalPositionProxy
524
+ }) {
525
+ const callArgs = _protocol.externalPositionReactivateArgs.call(void 0, { externalPositionProxy });
526
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.ReactivateExternalPosition, callArgs);
527
+ }
528
+ async function removeExternalPosition({
529
+ signer,
530
+ comptrollerProxy,
531
+ externalPositionManager,
532
+ externalPositionProxy
533
+ }) {
534
+ const callArgs = _protocol.externalPositionRemoveArgs.call(void 0, { externalPositionProxy });
535
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.RemoveExternalPosition, callArgs);
536
+ }
537
+
538
+ // src/scaffolding/extensions/external-positions/aave-debt.ts
539
+ async function aaveDebtPositionAddCollateral({
540
+ comptrollerProxy,
541
+ externalPositionManager,
542
+ signer,
543
+ aTokens,
544
+ amounts,
545
+ externalPositionProxy
546
+ }) {
547
+ const actionArgs = _protocol.aaveDebtPositionAddCollateralArgs.call(void 0, {
548
+ aTokens,
549
+ amounts
550
+ });
551
+ return callOnExternalPosition({
552
+ actionArgs,
553
+ actionId: _protocol.AaveDebtPositionActionId.AddCollateralAssets,
554
+ comptrollerProxy,
555
+ externalPositionManager,
556
+ externalPositionProxy,
557
+ signer
558
+ });
559
+ }
560
+ async function aaveDebtPositionBorrow({
561
+ comptrollerProxy,
562
+ externalPositionManager,
563
+ signer,
564
+ tokens,
565
+ amounts,
566
+ externalPositionProxy
567
+ }) {
568
+ const actionArgs = _protocol.aaveDebtPositionBorrowArgs.call(void 0, {
569
+ amounts,
570
+ tokens
571
+ });
572
+ return callOnExternalPosition({
573
+ actionArgs,
574
+ actionId: _protocol.AaveDebtPositionActionId.BorrowAsset,
575
+ comptrollerProxy,
576
+ externalPositionManager,
577
+ externalPositionProxy,
578
+ signer
579
+ });
580
+ }
581
+ async function aaveDebtPositionClaimRewards({
582
+ comptrollerProxy,
583
+ externalPositionManager,
584
+ signer,
585
+ assets,
586
+ externalPositionProxy
587
+ }) {
588
+ const actionArgs = _protocol.aaveDebtPositionClaimRewardsArgs.call(void 0, {
589
+ assets
590
+ });
591
+ return callOnExternalPosition({
592
+ actionArgs,
593
+ actionId: _protocol.AaveDebtPositionActionId.ClaimRewards,
594
+ comptrollerProxy,
595
+ externalPositionManager,
596
+ externalPositionProxy,
597
+ signer
598
+ });
599
+ }
600
+ async function aaveDebtPositionRemoveCollateral({
601
+ comptrollerProxy,
602
+ externalPositionManager,
603
+ signer,
604
+ aTokens,
605
+ amounts,
606
+ externalPositionProxy
607
+ }) {
608
+ const actionArgs = _protocol.aaveDebtPositionRemoveCollateralArgs.call(void 0, {
609
+ aTokens,
610
+ amounts
611
+ });
612
+ return callOnExternalPosition({
613
+ actionArgs,
614
+ actionId: _protocol.AaveDebtPositionActionId.RemoveCollateralAssets,
615
+ comptrollerProxy,
616
+ externalPositionManager,
617
+ externalPositionProxy,
618
+ signer
619
+ });
620
+ }
621
+ async function aaveDebtPositionRepayBorrow({
622
+ comptrollerProxy,
623
+ externalPositionManager,
624
+ signer,
625
+ tokens,
626
+ amounts,
627
+ externalPositionProxy
628
+ }) {
629
+ const actionArgs = _protocol.aaveDebtPositionRepayBorrowArgs.call(void 0, {
630
+ amounts,
631
+ tokens
632
+ });
633
+ return callOnExternalPosition({
634
+ actionArgs,
635
+ actionId: _protocol.AaveDebtPositionActionId.RepayBorrowedAssets,
636
+ comptrollerProxy,
637
+ externalPositionManager,
638
+ externalPositionProxy,
639
+ signer
640
+ });
641
+ }
642
+ async function createAaveDebtPosition({
643
+ signer,
644
+ comptrollerProxy,
645
+ externalPositionManager
646
+ }) {
647
+ return createExternalPosition({
648
+ comptrollerProxy,
649
+ externalPositionManager,
650
+ externalPositionTypeId: _protocol.ExternalPositionType.AaveDebtPosition,
651
+ signer
652
+ });
653
+ }
654
+
655
+ // src/scaffolding/extensions/external-positions/compound.ts
656
+
657
+
658
+
659
+
660
+
661
+
662
+ async function compoundDebtPositionAddCollateral({
663
+ comptrollerProxy,
664
+ externalPositionManager,
665
+ fundOwner,
666
+ assets,
667
+ amounts,
668
+ externalPositionProxy,
669
+ cTokens
670
+ }) {
671
+ const actionArgs = _protocol.compoundExternalPositionActionArgs.call(void 0, {
672
+ amounts,
673
+ assets,
674
+ data: _protocol.encodeArgs.call(void 0, ["address[]"], [cTokens])
675
+ });
676
+ return callOnExternalPosition({
677
+ actionArgs,
678
+ actionId: _protocol.CompoundDebtPositionActionId.AddCollateralAssets,
679
+ comptrollerProxy,
680
+ externalPositionManager,
681
+ externalPositionProxy,
682
+ signer: fundOwner
683
+ });
684
+ }
685
+ async function compoundDebtPositionBorrow({
686
+ comptrollerProxy,
687
+ externalPositionManager,
688
+ fundOwner,
689
+ externalPositionProxy,
690
+ assets,
691
+ amounts,
692
+ cTokens
693
+ }) {
694
+ const actionArgs = _protocol.compoundExternalPositionActionArgs.call(void 0, {
695
+ amounts,
696
+ assets,
697
+ data: _protocol.encodeArgs.call(void 0, ["address[]"], [cTokens])
698
+ });
699
+ return callOnExternalPosition({
700
+ actionArgs,
701
+ actionId: _protocol.CompoundDebtPositionActionId.BorrowAsset,
702
+ comptrollerProxy,
703
+ externalPositionManager,
704
+ externalPositionProxy,
705
+ signer: fundOwner
706
+ });
707
+ }
708
+ async function compoundDebtPositionClaimComp({
709
+ comptrollerProxy,
710
+ externalPositionManager,
711
+ fundOwner,
712
+ externalPositionProxy
713
+ }) {
714
+ const actionArgs = _protocol.compoundExternalPositionActionArgs.call(void 0, {
715
+ amounts: [],
716
+ assets: [],
717
+ data: "0x"
718
+ });
719
+ return callOnExternalPosition({
720
+ actionArgs,
721
+ actionId: _protocol.CompoundDebtPositionActionId.ClaimComp,
722
+ comptrollerProxy,
723
+ externalPositionManager,
724
+ externalPositionProxy,
725
+ signer: fundOwner
726
+ });
727
+ }
728
+ async function compoundDebtPositionRemoveCollateral({
729
+ comptrollerProxy,
730
+ externalPositionManager,
731
+ fundOwner,
732
+ assets,
733
+ amounts,
734
+ externalPositionProxy,
735
+ cTokens
736
+ }) {
737
+ const actionArgs = _protocol.compoundExternalPositionActionArgs.call(void 0, {
738
+ amounts,
739
+ assets,
740
+ data: _protocol.encodeArgs.call(void 0, ["address[]"], [cTokens])
741
+ });
742
+ return callOnExternalPosition({
743
+ actionArgs,
744
+ actionId: _protocol.CompoundDebtPositionActionId.RemoveCollateralAssets,
745
+ comptrollerProxy,
746
+ externalPositionManager,
747
+ externalPositionProxy,
748
+ signer: fundOwner
749
+ });
750
+ }
751
+ async function compoundDebtPositionRepayBorrow({
752
+ comptrollerProxy,
753
+ externalPositionManager,
754
+ fundOwner,
755
+ assets,
756
+ amounts,
757
+ externalPositionProxy,
758
+ cTokens
759
+ }) {
760
+ const actionArgs = _protocol.compoundExternalPositionActionArgs.call(void 0, {
761
+ amounts,
762
+ assets,
763
+ data: _protocol.encodeArgs.call(void 0, ["address[]"], [cTokens])
764
+ });
765
+ return callOnExternalPosition({
766
+ actionArgs,
767
+ actionId: _protocol.CompoundDebtPositionActionId.RepayBorrowedAssets,
768
+ comptrollerProxy,
769
+ externalPositionManager,
770
+ externalPositionProxy,
771
+ signer: fundOwner
772
+ });
773
+ }
774
+ async function createCompoundDebtPosition({
775
+ signer,
776
+ comptrollerProxy,
777
+ externalPositionManager
778
+ }) {
779
+ return createExternalPosition({
780
+ comptrollerProxy,
781
+ externalPositionManager,
782
+ externalPositionTypeId: _protocol.ExternalPositionType.CompoundDebtPosition,
783
+ signer
784
+ });
785
+ }
786
+
787
+ // src/scaffolding/extensions/external-positions/convex-voting.ts
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+ function createConvexVotingPosition({
797
+ signer,
798
+ comptrollerProxy,
799
+ externalPositionManager
800
+ }) {
801
+ return createExternalPosition({
802
+ comptrollerProxy,
803
+ externalPositionManager,
804
+ externalPositionTypeId: _protocol.ExternalPositionType.ConvexVotingPosition,
805
+ signer
806
+ });
807
+ }
808
+ function convexVotingPositionClaimRewards({
809
+ comptrollerProxy,
810
+ externalPositionManager,
811
+ signer,
812
+ externalPositionProxy,
813
+ claimLockerRewards,
814
+ extraRewardTokens,
815
+ votiumClaims,
816
+ unstakeCvxCrv,
817
+ allTokensToTransfer
818
+ }) {
819
+ const actionArgs = _protocol.convexVotingPositionClaimRewardsArgs.call(void 0, {
820
+ allTokensToTransfer,
821
+ claimLockerRewards,
822
+ extraRewardTokens,
823
+ unstakeCvxCrv,
824
+ votiumClaims
825
+ });
826
+ return callOnExternalPosition({
827
+ actionArgs,
828
+ actionId: _protocol.ConvexVotingPositionActionId.ClaimRewards,
829
+ comptrollerProxy,
830
+ externalPositionManager,
831
+ externalPositionProxy,
832
+ signer
833
+ });
834
+ }
835
+ function convexVotingPositionDelegate({
836
+ comptrollerProxy,
837
+ externalPositionManager,
838
+ signer,
839
+ externalPositionProxy,
840
+ delegatee
841
+ }) {
842
+ const actionArgs = _protocol.convexVotingPositionDelegateArgs.call(void 0, {
843
+ delegatee
844
+ });
845
+ return callOnExternalPosition({
846
+ actionArgs,
847
+ actionId: _protocol.ConvexVotingPositionActionId.Delegate,
848
+ comptrollerProxy,
849
+ externalPositionManager,
850
+ externalPositionProxy,
851
+ signer
852
+ });
853
+ }
854
+ function convexVotingPositionLock({
855
+ comptrollerProxy,
856
+ externalPositionManager,
857
+ signer,
858
+ externalPositionProxy,
859
+ amount,
860
+ spendRatio = _ethers3.BigNumber.from(0)
861
+ }) {
862
+ const actionArgs = _protocol.convexVotingPositionLockArgs.call(void 0, {
863
+ amount,
864
+ spendRatio
865
+ });
866
+ return callOnExternalPosition({
867
+ actionArgs,
868
+ actionId: _protocol.ConvexVotingPositionActionId.Lock,
869
+ comptrollerProxy,
870
+ externalPositionManager,
871
+ externalPositionProxy,
872
+ signer
873
+ });
874
+ }
875
+ function convexVotingPositionRelock({
876
+ comptrollerProxy,
877
+ externalPositionManager,
878
+ signer,
879
+ externalPositionProxy
880
+ }) {
881
+ return callOnExternalPosition({
882
+ actionArgs: "0x",
883
+ actionId: _protocol.ConvexVotingPositionActionId.Relock,
884
+ comptrollerProxy,
885
+ externalPositionManager,
886
+ externalPositionProxy,
887
+ signer
888
+ });
889
+ }
890
+ function convexVotingPositionWithdraw({
891
+ comptrollerProxy,
892
+ externalPositionManager,
893
+ signer,
894
+ externalPositionProxy
895
+ }) {
896
+ return callOnExternalPosition({
897
+ actionArgs: "0x",
898
+ actionId: _protocol.ConvexVotingPositionActionId.Withdraw,
899
+ comptrollerProxy,
900
+ externalPositionManager,
901
+ externalPositionProxy,
902
+ signer
903
+ });
904
+ }
905
+
906
+ // src/scaffolding/extensions/external-positions/liquity-debt.ts
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+ var ILiquityTroveManager = _ethers.contract.call(void 0, )`
919
+ function getBorrowingFee(uint256) external returns (uint256)
920
+ `;
921
+ var ILiquityHintHelper = _ethers.contract.call(void 0, )`
922
+ function getApproxHint(uint256, uint256, uint256) external returns (address, uint256, uint256)
923
+ `;
924
+ var ILiquitySortedTroves = _ethers.contract.call(void 0, )`
925
+ function findInsertPosition(uint256, address, address) external view returns (address, address)
926
+ `;
927
+ async function createLiquityDebtPosition({
928
+ signer,
929
+ comptrollerProxy,
930
+ externalPositionManager
931
+ }) {
932
+ return createExternalPosition({
933
+ comptrollerProxy,
934
+ externalPositionManager,
935
+ externalPositionTypeId: _protocol.ExternalPositionType.LiquityDebtPosition,
936
+ signer
937
+ });
938
+ }
939
+ async function liquityCalcHints({
940
+ collateralAmount,
941
+ lusdAmount,
942
+ numTrials = _ethers3.BigNumber.from("15"),
943
+ liquitySortedTroves,
944
+ liquityHintHelper,
945
+ inputRandomSeed = _ethers3.BigNumber.from("4")
946
+ }) {
947
+ const nicr = collateralAmount.mul(_ethers3.utils.parseEther("100")).div(lusdAmount);
948
+ const approxHint = await liquityHintHelper.getApproxHint.args(nicr, numTrials, inputRandomSeed).call();
949
+ const hints = await liquitySortedTroves.findInsertPosition.args(nicr, approxHint[0], approxHint[0]).call();
950
+ return hints;
951
+ }
952
+ async function liquityDebtPositionAddCollateral({
953
+ comptrollerProxy,
954
+ externalPositionManager,
955
+ signer,
956
+ collateralAmount,
957
+ lowerHint,
958
+ upperHint,
959
+ externalPositionProxy
960
+ }) {
961
+ const actionArgs = _protocol.liquityDebtPositionAddCollateralArgs.call(void 0, {
962
+ collateralAmount,
963
+ lowerHint,
964
+ upperHint
965
+ });
966
+ return callOnExternalPosition({
967
+ actionArgs,
968
+ actionId: _protocol.LiquityDebtPositionActionId.AddCollateral,
969
+ comptrollerProxy,
970
+ externalPositionManager,
971
+ externalPositionProxy,
972
+ signer
973
+ });
974
+ }
975
+ async function liquityDebtPositionBorrow({
976
+ comptrollerProxy,
977
+ externalPositionManager,
978
+ signer,
979
+ maxFeePercentage,
980
+ lusdAmount,
981
+ lowerHint,
982
+ upperHint,
983
+ externalPositionProxy
984
+ }) {
985
+ const actionArgs = _protocol.liquityDebtPositionBorrowArgs.call(void 0, {
986
+ lowerHint,
987
+ lusdAmount,
988
+ maxFeePercentage,
989
+ upperHint
990
+ });
991
+ return callOnExternalPosition({
992
+ actionArgs,
993
+ actionId: _protocol.LiquityDebtPositionActionId.Borrow,
994
+ comptrollerProxy,
995
+ externalPositionManager,
996
+ externalPositionProxy,
997
+ signer
998
+ });
999
+ }
1000
+ async function liquityDebtPositionCloseTrove({
1001
+ comptrollerProxy,
1002
+ externalPositionManager,
1003
+ signer,
1004
+ externalPositionProxy
1005
+ }) {
1006
+ const actionArgs = "0x";
1007
+ return callOnExternalPosition({
1008
+ actionArgs,
1009
+ actionId: _protocol.LiquityDebtPositionActionId.CloseTrove,
1010
+ comptrollerProxy,
1011
+ externalPositionManager,
1012
+ externalPositionProxy,
1013
+ signer
1014
+ });
1015
+ }
1016
+ async function liquityDebtPositionOpenTrove({
1017
+ comptrollerProxy,
1018
+ externalPositionManager,
1019
+ signer,
1020
+ maxFeePercentage,
1021
+ collateralAmount,
1022
+ lusdAmount,
1023
+ lowerHint,
1024
+ upperHint,
1025
+ externalPositionProxy
1026
+ }) {
1027
+ const actionArgs = _protocol.liquityDebtPositionOpenTroveArgs.call(void 0, {
1028
+ collateralAmount,
1029
+ lowerHint,
1030
+ lusdAmount,
1031
+ maxFeePercentage,
1032
+ upperHint
1033
+ });
1034
+ return callOnExternalPosition({
1035
+ actionArgs,
1036
+ actionId: _protocol.LiquityDebtPositionActionId.OpenTrove,
1037
+ comptrollerProxy,
1038
+ externalPositionManager,
1039
+ externalPositionProxy,
1040
+ signer
1041
+ });
1042
+ }
1043
+ async function liquityDebtPositionRemoveCollateral({
1044
+ comptrollerProxy,
1045
+ externalPositionManager,
1046
+ signer,
1047
+ collateralAmount,
1048
+ lowerHint,
1049
+ upperHint,
1050
+ externalPositionProxy
1051
+ }) {
1052
+ const actionArgs = _protocol.liquityDebtPositionRemoveCollateralArgs.call(void 0, {
1053
+ collateralAmount,
1054
+ lowerHint,
1055
+ upperHint
1056
+ });
1057
+ return callOnExternalPosition({
1058
+ actionArgs,
1059
+ actionId: _protocol.LiquityDebtPositionActionId.RemoveCollateral,
1060
+ comptrollerProxy,
1061
+ externalPositionManager,
1062
+ externalPositionProxy,
1063
+ signer
1064
+ });
1065
+ }
1066
+ async function liquityDebtPositionRepay({
1067
+ comptrollerProxy,
1068
+ externalPositionManager,
1069
+ signer,
1070
+ lusdAmount,
1071
+ lowerHint,
1072
+ upperHint,
1073
+ externalPositionProxy
1074
+ }) {
1075
+ const actionArgs = _protocol.liquityDebtPositionRepayBorrowArgs.call(void 0, {
1076
+ lowerHint,
1077
+ lusdAmount,
1078
+ upperHint
1079
+ });
1080
+ return callOnExternalPosition({
1081
+ actionArgs,
1082
+ actionId: _protocol.LiquityDebtPositionActionId.Repay,
1083
+ comptrollerProxy,
1084
+ externalPositionManager,
1085
+ externalPositionProxy,
1086
+ signer
1087
+ });
1088
+ }
1089
+
1090
+ // src/scaffolding/extensions/external-positions/maple-liquidity.ts
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+ async function createMapleLiquidityPosition({
1105
+ signer,
1106
+ comptrollerProxy,
1107
+ externalPositionManager
1108
+ }) {
1109
+ return createExternalPosition({
1110
+ comptrollerProxy,
1111
+ externalPositionManager,
1112
+ externalPositionTypeId: _protocol.ExternalPositionType.MapleLiquidityPosition,
1113
+ signer
1114
+ });
1115
+ }
1116
+ async function mapleLiquidityPositionClaimInterest({
1117
+ comptrollerProxy,
1118
+ externalPositionManager,
1119
+ signer,
1120
+ pool,
1121
+ externalPositionProxy
1122
+ }) {
1123
+ const actionArgs = _protocol.mapleLiquidityPositionClaimInterestArgs.call(void 0, {
1124
+ pool
1125
+ });
1126
+ return callOnExternalPosition({
1127
+ actionArgs,
1128
+ actionId: _protocol.MapleLiquidityPositionActionId.ClaimInterest,
1129
+ comptrollerProxy,
1130
+ externalPositionManager,
1131
+ externalPositionProxy,
1132
+ signer
1133
+ });
1134
+ }
1135
+ async function mapleLiquidityPositionClaimRewards({
1136
+ comptrollerProxy,
1137
+ externalPositionManager,
1138
+ signer,
1139
+ rewardsContract,
1140
+ externalPositionProxy
1141
+ }) {
1142
+ const actionArgs = _protocol.mapleLiquidityPositionClaimRewardsArgs.call(void 0, {
1143
+ rewardsContract
1144
+ });
1145
+ return callOnExternalPosition({
1146
+ actionArgs,
1147
+ actionId: _protocol.MapleLiquidityPositionActionId.ClaimRewards,
1148
+ comptrollerProxy,
1149
+ externalPositionManager,
1150
+ externalPositionProxy,
1151
+ signer
1152
+ });
1153
+ }
1154
+ async function mapleLiquidityPositionIntendToRedeem({
1155
+ comptrollerProxy,
1156
+ externalPositionManager,
1157
+ signer,
1158
+ pool,
1159
+ externalPositionProxy
1160
+ }) {
1161
+ const actionArgs = _protocol.mapleLiquidityPositionIntendToRedeemArgs.call(void 0, {
1162
+ pool
1163
+ });
1164
+ return callOnExternalPosition({
1165
+ actionArgs,
1166
+ actionId: _protocol.MapleLiquidityPositionActionId.IntendToRedeem,
1167
+ comptrollerProxy,
1168
+ externalPositionManager,
1169
+ externalPositionProxy,
1170
+ signer
1171
+ });
1172
+ }
1173
+ async function mapleLiquidityPositionLend({
1174
+ comptrollerProxy,
1175
+ externalPositionManager,
1176
+ signer,
1177
+ liquidityAssetAmount,
1178
+ pool,
1179
+ externalPositionProxy
1180
+ }) {
1181
+ const actionArgs = _protocol.mapleLiquidityPositionLendArgs.call(void 0, {
1182
+ liquidityAssetAmount,
1183
+ pool
1184
+ });
1185
+ return callOnExternalPosition({
1186
+ actionArgs,
1187
+ actionId: _protocol.MapleLiquidityPositionActionId.Lend,
1188
+ comptrollerProxy,
1189
+ externalPositionManager,
1190
+ externalPositionProxy,
1191
+ signer
1192
+ });
1193
+ }
1194
+ async function mapleLiquidityPositionLendAndStake({
1195
+ comptrollerProxy,
1196
+ externalPositionManager,
1197
+ signer,
1198
+ liquidityAssetAmount,
1199
+ pool,
1200
+ rewardsContract,
1201
+ externalPositionProxy
1202
+ }) {
1203
+ const actionArgs = _protocol.mapleLiquidityPositionLendAndStakeArgs.call(void 0, {
1204
+ liquidityAssetAmount,
1205
+ pool,
1206
+ rewardsContract
1207
+ });
1208
+ return callOnExternalPosition({
1209
+ actionArgs,
1210
+ actionId: _protocol.MapleLiquidityPositionActionId.LendAndStake,
1211
+ comptrollerProxy,
1212
+ externalPositionManager,
1213
+ externalPositionProxy,
1214
+ signer
1215
+ });
1216
+ }
1217
+ async function mapleLiquidityPositionRedeem({
1218
+ comptrollerProxy,
1219
+ externalPositionManager,
1220
+ signer,
1221
+ liquidityAssetAmount,
1222
+ pool,
1223
+ externalPositionProxy
1224
+ }) {
1225
+ const actionArgs = _protocol.mapleLiquidityPositionRedeemArgs.call(void 0, {
1226
+ liquidityAssetAmount,
1227
+ pool
1228
+ });
1229
+ return callOnExternalPosition({
1230
+ actionArgs,
1231
+ actionId: _protocol.MapleLiquidityPositionActionId.Redeem,
1232
+ comptrollerProxy,
1233
+ externalPositionManager,
1234
+ externalPositionProxy,
1235
+ signer
1236
+ });
1237
+ }
1238
+ async function mapleLiquidityPositionStake({
1239
+ comptrollerProxy,
1240
+ externalPositionManager,
1241
+ signer,
1242
+ poolTokenAmount,
1243
+ pool,
1244
+ rewardsContract,
1245
+ externalPositionProxy
1246
+ }) {
1247
+ const actionArgs = _protocol.mapleLiquidityPositionStakeArgs.call(void 0, {
1248
+ pool,
1249
+ poolTokenAmount,
1250
+ rewardsContract
1251
+ });
1252
+ return callOnExternalPosition({
1253
+ actionArgs,
1254
+ actionId: _protocol.MapleLiquidityPositionActionId.Stake,
1255
+ comptrollerProxy,
1256
+ externalPositionManager,
1257
+ externalPositionProxy,
1258
+ signer
1259
+ });
1260
+ }
1261
+ async function mapleLiquidityPositionUnstake({
1262
+ comptrollerProxy,
1263
+ externalPositionManager,
1264
+ signer,
1265
+ poolTokenAmount,
1266
+ rewardsContract,
1267
+ externalPositionProxy
1268
+ }) {
1269
+ const actionArgs = _protocol.mapleLiquidityPositionUnstakeArgs.call(void 0, {
1270
+ poolTokenAmount,
1271
+ rewardsContract
1272
+ });
1273
+ return callOnExternalPosition({
1274
+ actionArgs,
1275
+ actionId: _protocol.MapleLiquidityPositionActionId.Unstake,
1276
+ comptrollerProxy,
1277
+ externalPositionManager,
1278
+ externalPositionProxy,
1279
+ signer
1280
+ });
1281
+ }
1282
+ async function mapleLiquidityPositionUnstakeAndRedeem({
1283
+ comptrollerProxy,
1284
+ externalPositionManager,
1285
+ signer,
1286
+ pool,
1287
+ poolTokenAmount,
1288
+ rewardsContract,
1289
+ externalPositionProxy
1290
+ }) {
1291
+ const actionArgs = _protocol.mapleLiquidityPositionUnstakeAndRedeemArgs.call(void 0, {
1292
+ pool,
1293
+ poolTokenAmount,
1294
+ rewardsContract
1295
+ });
1296
+ return callOnExternalPosition({
1297
+ actionArgs,
1298
+ actionId: _protocol.MapleLiquidityPositionActionId.UnstakeAndRedeem,
1299
+ comptrollerProxy,
1300
+ externalPositionManager,
1301
+ externalPositionProxy,
1302
+ signer
1303
+ });
1304
+ }
1305
+
1306
+ // src/scaffolding/extensions/external-positions/mocks.ts
1307
+
1308
+
1309
+
1310
+
1311
+
1312
+
1313
+
1314
+ async function createMockExternalPosition({
1315
+ comptrollerProxy,
1316
+ externalPositionManager,
1317
+ externalPositionFactory,
1318
+ defaultActionAssetsToTransfer,
1319
+ defaultActionAmountsToTransfer,
1320
+ defaultActionAssetsToReceive,
1321
+ fundOwner,
1322
+ deployer
1323
+ }) {
1324
+ const vaultProxy = new (0, _protocol.VaultLib)(await comptrollerProxy.getVaultProxy(), deployer);
1325
+ const typeId = await externalPositionFactory.getPositionTypeCounter();
1326
+ await externalPositionFactory.addNewPositionTypes(["TEST"]);
1327
+ const mockGenericExternalPositionLib = await _protocol.MockGenericExternalPositionLib.deploy(deployer);
1328
+ const mockExternalPositionParser = await _protocol.MockGenericExternalPositionParser.deploy(deployer);
1329
+ mockExternalPositionParser.setAssetsForAction(0, defaultActionAssetsToTransfer, defaultActionAmountsToTransfer, defaultActionAssetsToReceive);
1330
+ await externalPositionManager.updateExternalPositionTypesInfo([typeId], [mockGenericExternalPositionLib], [mockExternalPositionParser]);
1331
+ const receipt = await createExternalPosition({
1332
+ comptrollerProxy,
1333
+ externalPositionManager,
1334
+ externalPositionTypeId: typeId,
1335
+ signer: fundOwner
1336
+ });
1337
+ const externalPositionProxy = (await vaultProxy.getActiveExternalPositions())[0];
1338
+ return {
1339
+ externalPositionProxy,
1340
+ mockExternalPositionParser,
1341
+ mockGenericExternalPositionLib,
1342
+ receipt,
1343
+ typeId
1344
+ };
1345
+ }
1346
+ async function mockExternalPositionAddDebtAssets({
1347
+ signer,
1348
+ comptrollerProxy,
1349
+ externalPositionManager,
1350
+ externalPositionProxy,
1351
+ assets,
1352
+ amounts
1353
+ }) {
1354
+ const actionArgs = _protocol.mockGenericExternalPositionActionArgs.call(void 0, {
1355
+ amounts,
1356
+ assets
1357
+ });
1358
+ return callOnExternalPosition({
1359
+ actionArgs,
1360
+ actionId: _protocol.MockGenericExternalPositionActionId.AddDebtAssets,
1361
+ comptrollerProxy,
1362
+ externalPositionManager,
1363
+ externalPositionProxy,
1364
+ signer
1365
+ });
1366
+ }
1367
+ async function mockExternalPositionAddManagedAssets({
1368
+ signer,
1369
+ comptrollerProxy,
1370
+ externalPositionManager,
1371
+ externalPositionProxy,
1372
+ assets,
1373
+ amounts
1374
+ }) {
1375
+ const actionArgs = _protocol.mockGenericExternalPositionActionArgs.call(void 0, {
1376
+ amounts,
1377
+ assets
1378
+ });
1379
+ return callOnExternalPosition({
1380
+ actionArgs,
1381
+ actionId: _protocol.MockGenericExternalPositionActionId.AddManagedAssets,
1382
+ comptrollerProxy,
1383
+ externalPositionManager,
1384
+ externalPositionProxy,
1385
+ signer
1386
+ });
1387
+ }
1388
+ async function mockExternalPositionRemoveDebtAssets({
1389
+ signer,
1390
+ comptrollerProxy,
1391
+ externalPositionManager,
1392
+ externalPositionProxy,
1393
+ assets,
1394
+ amounts
1395
+ }) {
1396
+ const actionArgs = _protocol.mockGenericExternalPositionActionArgs.call(void 0, {
1397
+ amounts,
1398
+ assets
1399
+ });
1400
+ return callOnExternalPosition({
1401
+ actionArgs,
1402
+ actionId: _protocol.MockGenericExternalPositionActionId.RemoveDebtAssets,
1403
+ comptrollerProxy,
1404
+ externalPositionManager,
1405
+ externalPositionProxy,
1406
+ signer
1407
+ });
1408
+ }
1409
+ async function mockExternalPositionRemoveManagedAssets({
1410
+ signer,
1411
+ comptrollerProxy,
1412
+ externalPositionManager,
1413
+ externalPositionProxy,
1414
+ assets,
1415
+ amounts
1416
+ }) {
1417
+ const actionArgs = _protocol.mockGenericExternalPositionActionArgs.call(void 0, {
1418
+ amounts,
1419
+ assets
1420
+ });
1421
+ return callOnExternalPosition({
1422
+ actionArgs,
1423
+ actionId: _protocol.MockGenericExternalPositionActionId.RemoveManagedAssets,
1424
+ comptrollerProxy,
1425
+ externalPositionManager,
1426
+ externalPositionProxy,
1427
+ signer
1428
+ });
1429
+ }
1430
+
1431
+ // src/scaffolding/extensions/external-positions/the-graph-delegation.ts
1432
+
1433
+
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+ async function theGraphDelegationPositionDelegate({
1440
+ comptrollerProxy,
1441
+ externalPositionManager,
1442
+ signer,
1443
+ indexer,
1444
+ tokens,
1445
+ externalPositionProxy
1446
+ }) {
1447
+ const actionArgs = _protocol.theGraphDelegationPositionDelegateArgs.call(void 0, {
1448
+ indexer,
1449
+ tokens
1450
+ });
1451
+ return callOnExternalPosition({
1452
+ actionArgs,
1453
+ actionId: _protocol.TheGraphDelegationPositionActionId.Delegate,
1454
+ comptrollerProxy,
1455
+ externalPositionManager,
1456
+ externalPositionProxy,
1457
+ signer
1458
+ });
1459
+ }
1460
+ async function theGraphDelegationPositionUndelegate({
1461
+ comptrollerProxy,
1462
+ externalPositionManager,
1463
+ signer,
1464
+ indexer,
1465
+ shares,
1466
+ externalPositionProxy
1467
+ }) {
1468
+ const actionArgs = _protocol.theGraphDelegationPositionUndelegateArgs.call(void 0, {
1469
+ indexer,
1470
+ shares
1471
+ });
1472
+ return callOnExternalPosition({
1473
+ actionArgs,
1474
+ actionId: _protocol.TheGraphDelegationPositionActionId.Undelegate,
1475
+ comptrollerProxy,
1476
+ externalPositionManager,
1477
+ externalPositionProxy,
1478
+ signer
1479
+ });
1480
+ }
1481
+ async function theGraphDelegationPositionWithdraw({
1482
+ comptrollerProxy,
1483
+ externalPositionManager,
1484
+ signer,
1485
+ indexer,
1486
+ nextIndexer,
1487
+ externalPositionProxy
1488
+ }) {
1489
+ const actionArgs = _protocol.theGraphDelegationPositionWithdrawArgs.call(void 0, {
1490
+ indexer,
1491
+ nextIndexer
1492
+ });
1493
+ return callOnExternalPosition({
1494
+ actionArgs,
1495
+ actionId: _protocol.TheGraphDelegationPositionActionId.Withdraw,
1496
+ comptrollerProxy,
1497
+ externalPositionManager,
1498
+ externalPositionProxy,
1499
+ signer
1500
+ });
1501
+ }
1502
+ async function createTheGraphDelegationPosition({
1503
+ signer,
1504
+ comptrollerProxy,
1505
+ externalPositionManager
1506
+ }) {
1507
+ return createExternalPosition({
1508
+ comptrollerProxy,
1509
+ externalPositionManager,
1510
+ externalPositionTypeId: _protocol.ExternalPositionType.TheGraphDelegationPosition,
1511
+ signer
1512
+ });
1513
+ }
1514
+
1515
+ // src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1528
+
1529
+ var UniswapV3FeeAmount = /* @__PURE__ */ ((UniswapV3FeeAmount2) => {
1530
+ UniswapV3FeeAmount2[UniswapV3FeeAmount2["LOW"] = 500] = "LOW";
1531
+ UniswapV3FeeAmount2[UniswapV3FeeAmount2["MEDIUM"] = 3e3] = "MEDIUM";
1532
+ UniswapV3FeeAmount2[UniswapV3FeeAmount2["HIGH"] = 1e4] = "HIGH";
1533
+ return UniswapV3FeeAmount2;
1534
+ })(UniswapV3FeeAmount || {});
1535
+ var uniswapV3LiquidityPositionGetMinTick = (tickSpacing) => Math.ceil(-887272 / tickSpacing) * tickSpacing;
1536
+ var uniswapV3LiquidityPositionGetMaxTick = (tickSpacing) => Math.floor(887272 / tickSpacing) * tickSpacing;
1537
+ var IUniswapV3NonFungibleTokenManager = _ethers.contract.call(void 0, )`
1538
+ function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)
1539
+ `;
1540
+ async function createUniswapV3LiquidityPosition({
1541
+ signer,
1542
+ comptrollerProxy,
1543
+ externalPositionManager,
1544
+ callOnExternalPositionData = "0x"
1545
+ }) {
1546
+ const { externalPositionProxy: externalPositionProxyContract, receipt } = await createExternalPosition({
1547
+ callOnExternalPositionData,
1548
+ comptrollerProxy,
1549
+ externalPositionManager,
1550
+ externalPositionTypeId: _protocol.ExternalPositionType.UniswapV3LiquidityPosition,
1551
+ signer
1552
+ });
1553
+ return { externalPositionProxyAddress: externalPositionProxyContract.address, receipt };
1554
+ }
1555
+ async function uniswapV3LiquidityPositionAddLiquidity({
1556
+ signer,
1557
+ comptrollerProxy,
1558
+ externalPositionManager,
1559
+ externalPositionProxy,
1560
+ nftId,
1561
+ amount0Desired,
1562
+ amount1Desired,
1563
+ amount0Min = 0,
1564
+ amount1Min = 0
1565
+ }) {
1566
+ const actionArgs = _protocol.uniswapV3LiquidityPositionAddLiquidityArgs.call(void 0, {
1567
+ amount0Desired,
1568
+ amount0Min,
1569
+ amount1Desired,
1570
+ amount1Min,
1571
+ nftId
1572
+ });
1573
+ const callArgs = _protocol.callOnExternalPositionArgs.call(void 0, {
1574
+ actionArgs,
1575
+ actionId: _protocol.UniswapV3LiquidityPositionActionId.AddLiquidity,
1576
+ externalPositionProxy
1577
+ });
1578
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CallOnExternalPosition, callArgs);
1579
+ }
1580
+ async function uniswapV3LiquidityPositionCollect({
1581
+ signer,
1582
+ comptrollerProxy,
1583
+ externalPositionManager,
1584
+ externalPositionProxy,
1585
+ nftId
1586
+ }) {
1587
+ const actionArgs = _protocol.uniswapV3LiquidityPositionCollectArgs.call(void 0, {
1588
+ nftId
1589
+ });
1590
+ const callArgs = _protocol.callOnExternalPositionArgs.call(void 0, {
1591
+ actionArgs,
1592
+ actionId: _protocol.UniswapV3LiquidityPositionActionId.Collect,
1593
+ externalPositionProxy
1594
+ });
1595
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CallOnExternalPosition, callArgs);
1596
+ }
1597
+ async function uniswapV3LiquidityPositionMint({
1598
+ signer,
1599
+ comptrollerProxy,
1600
+ externalPositionManager,
1601
+ externalPositionProxy,
1602
+ token0,
1603
+ token1,
1604
+ fee,
1605
+ tickLower,
1606
+ tickUpper,
1607
+ amount0Desired,
1608
+ amount1Desired,
1609
+ amount0Min = 0,
1610
+ amount1Min = 0
1611
+ }) {
1612
+ const actionArgs = _protocol.uniswapV3LiquidityPositionMintArgs.call(void 0, {
1613
+ amount0Desired,
1614
+ amount0Min,
1615
+ amount1Desired,
1616
+ amount1Min,
1617
+ fee,
1618
+ tickLower,
1619
+ tickUpper,
1620
+ token0,
1621
+ token1
1622
+ });
1623
+ const callArgs = _protocol.callOnExternalPositionArgs.call(void 0, {
1624
+ actionArgs,
1625
+ actionId: _protocol.UniswapV3LiquidityPositionActionId.Mint,
1626
+ externalPositionProxy
1627
+ });
1628
+ const receipt = await comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CallOnExternalPosition, callArgs);
1629
+ const externalPosition = new (0, _protocol.UniswapV3LiquidityPositionLib)(externalPositionProxy, provider);
1630
+ const nftId = _ethers.extractEvent.call(void 0, receipt, externalPosition.abi.getEvent("NFTPositionAdded"))[0].args.tokenId;
1631
+ return { nftId, receipt };
1632
+ }
1633
+ async function uniswapV3LiquidityPositionPurge({
1634
+ signer,
1635
+ comptrollerProxy,
1636
+ externalPositionManager,
1637
+ externalPositionProxy,
1638
+ nftId,
1639
+ liquidity,
1640
+ amount0Min = 0,
1641
+ amount1Min = 0
1642
+ }) {
1643
+ const actionArgs = _protocol.uniswapV3LiquidityPositionPurgeArgs.call(void 0, {
1644
+ amount0Min,
1645
+ amount1Min,
1646
+ liquidity,
1647
+ nftId
1648
+ });
1649
+ const callArgs = _protocol.callOnExternalPositionArgs.call(void 0, {
1650
+ actionArgs,
1651
+ actionId: _protocol.UniswapV3LiquidityPositionActionId.Purge,
1652
+ externalPositionProxy
1653
+ });
1654
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CallOnExternalPosition, callArgs);
1655
+ }
1656
+ async function uniswapV3LiquidityPositionRemoveLiquidity({
1657
+ signer,
1658
+ comptrollerProxy,
1659
+ externalPositionManager,
1660
+ externalPositionProxy,
1661
+ nftId,
1662
+ liquidity,
1663
+ amount0Min = 0,
1664
+ amount1Min = 0
1665
+ }) {
1666
+ const actionArgs = _protocol.uniswapV3LiquidityPositionRemoveLiquidityArgs.call(void 0, {
1667
+ amount0Min,
1668
+ amount1Min,
1669
+ liquidity,
1670
+ nftId
1671
+ });
1672
+ const callArgs = _protocol.callOnExternalPositionArgs.call(void 0, {
1673
+ actionArgs,
1674
+ actionId: _protocol.UniswapV3LiquidityPositionActionId.RemoveLiquidity,
1675
+ externalPositionProxy
1676
+ });
1677
+ return comptrollerProxy.connect(signer).callOnExtension(externalPositionManager, _protocol.ExternalPositionManagerActionId.CallOnExternalPosition, callArgs);
1678
+ }
1679
+ function uniswapV3OrderTokenPair({ tokenA, tokenB }) {
1680
+ const tokenAAddress = _ethers.resolveAddress.call(void 0, tokenA);
1681
+ const tokenBAddress = _ethers.resolveAddress.call(void 0, tokenB);
1682
+ return tokenAAddress < tokenBAddress ? { token0: tokenAAddress, token1: tokenBAddress } : { token0: tokenBAddress, token1: tokenAAddress };
1683
+ }
1684
+
1685
+ // src/scaffolding/extensions/fees.ts
1686
+
1687
+
1688
+ async function generateFeeManagerConfigWithMockFees({ deployer }) {
1689
+ const fees = await generateMockFees({
1690
+ deployer
1691
+ });
1692
+ const feeManagerSettingsData = [_ethers3.utils.randomBytes(10), "0x", _ethers3.utils.randomBytes(2)];
1693
+ return _protocol.feeManagerConfigArgs.call(void 0, {
1694
+ fees: Object.values(fees),
1695
+ settings: feeManagerSettingsData
1696
+ });
1697
+ }
1698
+ async function generateMockFees({ deployer }) {
1699
+ const mockContinuousFeeSettleOnly = await _protocol.IFee.mock(deployer);
1700
+ const mockContinuousFeeWithGavAndUpdates = await _protocol.IFee.mock(deployer);
1701
+ const mockPostBuySharesFee = await _protocol.IFee.mock(deployer);
1702
+ await Promise.all([
1703
+ mockContinuousFeeSettleOnly.getRecipientForFund.returns(_ethers3.constants.AddressZero),
1704
+ mockContinuousFeeSettleOnly.settle.returns(_protocol.FeeSettlementType.None, _ethers3.constants.AddressZero, 0),
1705
+ mockContinuousFeeSettleOnly.payout.returns(false),
1706
+ mockContinuousFeeSettleOnly.addFundSettings.returns(void 0),
1707
+ mockContinuousFeeSettleOnly.activateForFund.returns(void 0),
1708
+ mockContinuousFeeSettleOnly.update.returns(void 0),
1709
+ mockContinuousFeeSettleOnly.settlesOnHook.returns(false, false),
1710
+ mockContinuousFeeSettleOnly.settlesOnHook.given(_protocol.FeeHook.Continuous).returns(true, false),
1711
+ mockContinuousFeeSettleOnly.settlesOnHook.given(_protocol.FeeHook.PreBuyShares).returns(true, false),
1712
+ mockContinuousFeeSettleOnly.settlesOnHook.given(_protocol.FeeHook.PreRedeemShares).returns(true, false),
1713
+ mockContinuousFeeSettleOnly.updatesOnHook.returns(false, false),
1714
+ mockContinuousFeeWithGavAndUpdates.getRecipientForFund.returns(_ethers3.constants.AddressZero),
1715
+ mockContinuousFeeWithGavAndUpdates.settle.returns(_protocol.FeeSettlementType.None, _ethers3.constants.AddressZero, 0),
1716
+ mockContinuousFeeWithGavAndUpdates.payout.returns(false),
1717
+ mockContinuousFeeWithGavAndUpdates.addFundSettings.returns(void 0),
1718
+ mockContinuousFeeWithGavAndUpdates.activateForFund.returns(void 0),
1719
+ mockContinuousFeeWithGavAndUpdates.update.returns(void 0),
1720
+ mockContinuousFeeWithGavAndUpdates.settlesOnHook.returns(false, false),
1721
+ mockContinuousFeeWithGavAndUpdates.settlesOnHook.given(_protocol.FeeHook.Continuous).returns(true, true),
1722
+ mockContinuousFeeWithGavAndUpdates.settlesOnHook.given(_protocol.FeeHook.PreBuyShares).returns(true, true),
1723
+ mockContinuousFeeWithGavAndUpdates.settlesOnHook.given(_protocol.FeeHook.PreRedeemShares).returns(true, true),
1724
+ mockContinuousFeeWithGavAndUpdates.updatesOnHook.returns(false, false),
1725
+ mockContinuousFeeWithGavAndUpdates.updatesOnHook.given(_protocol.FeeHook.Continuous).returns(true, true),
1726
+ mockContinuousFeeWithGavAndUpdates.updatesOnHook.given(_protocol.FeeHook.PostBuyShares).returns(true, true),
1727
+ mockContinuousFeeWithGavAndUpdates.updatesOnHook.given(_protocol.FeeHook.PreRedeemShares).returns(true, true),
1728
+ mockPostBuySharesFee.getRecipientForFund.returns(_ethers3.constants.AddressZero),
1729
+ mockPostBuySharesFee.settle.returns(_protocol.FeeSettlementType.None, _ethers3.constants.AddressZero, 0),
1730
+ mockPostBuySharesFee.payout.returns(false),
1731
+ mockPostBuySharesFee.addFundSettings.returns(void 0),
1732
+ mockPostBuySharesFee.activateForFund.returns(void 0),
1733
+ mockPostBuySharesFee.update.returns(void 0),
1734
+ mockPostBuySharesFee.settlesOnHook.returns(false, false),
1735
+ mockPostBuySharesFee.settlesOnHook.given(_protocol.FeeHook.PostBuyShares).returns(true, false),
1736
+ mockPostBuySharesFee.updatesOnHook.returns(false, false)
1737
+ ]);
1738
+ return {
1739
+ mockContinuousFeeSettleOnly,
1740
+ mockContinuousFeeWithGavAndUpdates,
1741
+ mockPostBuySharesFee
1742
+ };
1743
+ }
1744
+
1745
+ // src/scaffolding/extensions/integrations/aave.ts
1746
+
1747
+
1748
+
1749
+
1750
+
1751
+
1752
+
1753
+
1754
+
1755
+ async function aaveLend({
1756
+ comptrollerProxy,
1757
+ integrationManager,
1758
+ fundOwner,
1759
+ aaveAdapter,
1760
+ aToken,
1761
+ amount = _ethers3.utils.parseEther("1")
1762
+ }) {
1763
+ const lendArgs = _protocol.aaveLendArgs.call(void 0, {
1764
+ aToken,
1765
+ amount
1766
+ });
1767
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
1768
+ adapter: aaveAdapter,
1769
+ encodedCallArgs: lendArgs,
1770
+ selector: _protocol.lendSelector
1771
+ });
1772
+ const lendTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
1773
+ return lendTx;
1774
+ }
1775
+ async function aaveRedeem({
1776
+ comptrollerProxy,
1777
+ integrationManager,
1778
+ fundOwner,
1779
+ aaveAdapter,
1780
+ aToken,
1781
+ amount = _ethers3.utils.parseEther("1")
1782
+ }) {
1783
+ const redeemArgs = _protocol.aaveRedeemArgs.call(void 0, {
1784
+ aToken,
1785
+ amount
1786
+ });
1787
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
1788
+ adapter: aaveAdapter,
1789
+ encodedCallArgs: redeemArgs,
1790
+ selector: _protocol.redeemSelector
1791
+ });
1792
+ const redeemTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
1793
+ return redeemTx;
1794
+ }
1795
+
1796
+ // src/scaffolding/extensions/integrations/compound.ts
1797
+
1798
+
1799
+
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1806
+
1807
+
1808
+
1809
+ var ICompoundComptroller = _ethers.contract.call(void 0, )`
1810
+ function claimComp(address)
1811
+ `;
1812
+ async function assertCompoundLend({
1813
+ tokenWhale,
1814
+ comptrollerProxy,
1815
+ vaultProxy,
1816
+ integrationManager,
1817
+ fundOwner,
1818
+ compoundAdapter,
1819
+ tokenAmount = _ethers3.utils.parseEther("1"),
1820
+ cToken,
1821
+ compoundPriceFeed
1822
+ }) {
1823
+ const token = new (0, _protocol.StandardToken)(await compoundPriceFeed.getTokenFromCToken.args(cToken).call(), tokenWhale);
1824
+ await token.connect(tokenWhale).transfer(vaultProxy, tokenAmount);
1825
+ const rateBefore = await cToken.exchangeRateStored.call();
1826
+ const minIncomingCTokenAmount = tokenAmount.mul(_ethers3.utils.parseEther("1")).div(rateBefore).mul(_ethers3.BigNumber.from("999")).div(_ethers3.BigNumber.from("1000"));
1827
+ const [preTxIncomingAssetBalance, preTxOutgoingAssetBalance] = await getAssetBalances({
1828
+ account: vaultProxy,
1829
+ assets: [cToken, token]
1830
+ });
1831
+ const lendReceipt = await compoundLend({
1832
+ cToken,
1833
+ cTokenAmount: minIncomingCTokenAmount,
1834
+ compoundAdapter,
1835
+ comptrollerProxy,
1836
+ fundOwner,
1837
+ integrationManager,
1838
+ tokenAmount
1839
+ });
1840
+ const rate = await cToken.exchangeRateStored();
1841
+ const [postTxIncomingAssetBalance, postTxOutgoingAssetBalance] = await getAssetBalances({
1842
+ account: vaultProxy,
1843
+ assets: [cToken, token]
1844
+ });
1845
+ const expectedCTokenAmount = tokenAmount.mul(_ethers3.utils.parseEther("1")).div(rate);
1846
+ expect(postTxIncomingAssetBalance).toEqBigNumber(preTxIncomingAssetBalance.add(expectedCTokenAmount));
1847
+ expect(postTxOutgoingAssetBalance).toEqBigNumber(preTxOutgoingAssetBalance.sub(tokenAmount));
1848
+ return lendReceipt;
1849
+ }
1850
+ async function assertCompoundRedeem({
1851
+ comptrollerProxy,
1852
+ vaultProxy,
1853
+ integrationManager,
1854
+ fundOwner,
1855
+ compoundAdapter,
1856
+ cToken,
1857
+ compoundPriceFeed
1858
+ }) {
1859
+ const cTokenAmount = _ethers3.utils.parseUnits("1", await cToken.decimals());
1860
+ await cToken.transfer(vaultProxy, cTokenAmount);
1861
+ const token = new (0, _protocol.StandardToken)(await compoundPriceFeed.getTokenFromCToken.args(cToken).call(), provider);
1862
+ const [preTxIncomingAssetBalance, preTxOutgoingAssetBalance] = await getAssetBalances({
1863
+ account: vaultProxy,
1864
+ assets: [token, cToken]
1865
+ });
1866
+ const rateBefore = await cToken.exchangeRateStored();
1867
+ const minIncomingTokenAmount = cTokenAmount.mul(rateBefore).div(_ethers3.utils.parseEther("1"));
1868
+ const redeemReceipt = await compoundRedeem({
1869
+ cToken,
1870
+ cTokenAmount,
1871
+ compoundAdapter,
1872
+ comptrollerProxy,
1873
+ fundOwner,
1874
+ integrationManager,
1875
+ tokenAmount: minIncomingTokenAmount,
1876
+ vaultProxy
1877
+ });
1878
+ const [postTxIncomingAssetBalance, postTxOutgoingAssetBalance] = await getAssetBalances({
1879
+ account: vaultProxy,
1880
+ assets: [token, cToken]
1881
+ });
1882
+ const rate = await cToken.exchangeRateStored();
1883
+ const expectedTokenAmount = cTokenAmount.mul(rate).div(_ethers3.utils.parseEther("1"));
1884
+ expect(postTxIncomingAssetBalance).toEqBigNumber(preTxIncomingAssetBalance.add(expectedTokenAmount));
1885
+ expect(postTxOutgoingAssetBalance).toEqBigNumber(preTxOutgoingAssetBalance.sub(cTokenAmount));
1886
+ return redeemReceipt;
1887
+ }
1888
+ async function compoundClaim({
1889
+ comptrollerProxy,
1890
+ integrationManager,
1891
+ fundOwner,
1892
+ compoundAdapter,
1893
+ compoundComptroller,
1894
+ cTokens
1895
+ }) {
1896
+ const claimArgs = _protocol.compoundClaimRewardsArgs.call(void 0, {
1897
+ cTokens,
1898
+ compoundComptroller
1899
+ });
1900
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
1901
+ adapter: compoundAdapter,
1902
+ encodedCallArgs: claimArgs,
1903
+ selector: _protocol.claimRewardsSelector
1904
+ });
1905
+ const claimRewardsTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
1906
+ return claimRewardsTx;
1907
+ }
1908
+ async function compoundLend({
1909
+ comptrollerProxy,
1910
+ integrationManager,
1911
+ fundOwner,
1912
+ compoundAdapter,
1913
+ cToken,
1914
+ tokenAmount = _ethers3.utils.parseEther("1"),
1915
+ cTokenAmount = _ethers3.utils.parseEther("1")
1916
+ }) {
1917
+ const lendArgs = _protocol.compoundArgs.call(void 0, {
1918
+ cToken,
1919
+ minIncomingAssetAmount: cTokenAmount,
1920
+ outgoingAssetAmount: tokenAmount
1921
+ });
1922
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
1923
+ adapter: compoundAdapter,
1924
+ encodedCallArgs: lendArgs,
1925
+ selector: _protocol.lendSelector
1926
+ });
1927
+ const lendTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
1928
+ return lendTx;
1929
+ }
1930
+ async function compoundRedeem({
1931
+ comptrollerProxy,
1932
+ integrationManager,
1933
+ fundOwner,
1934
+ compoundAdapter,
1935
+ cToken,
1936
+ tokenAmount = _ethers3.utils.parseEther("1"),
1937
+ cTokenAmount = _ethers3.utils.parseEther("1")
1938
+ }) {
1939
+ const redeemArgs = _protocol.compoundArgs.call(void 0, {
1940
+ cToken: _ethers.resolveAddress.call(void 0, cToken),
1941
+ minIncomingAssetAmount: tokenAmount,
1942
+ outgoingAssetAmount: cTokenAmount
1943
+ });
1944
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
1945
+ adapter: compoundAdapter,
1946
+ encodedCallArgs: redeemArgs,
1947
+ selector: _protocol.redeemSelector
1948
+ });
1949
+ const redeemTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
1950
+ return redeemTx;
1951
+ }
1952
+
1953
+ // src/scaffolding/extensions/integrations/curve.ts
1954
+
1955
+
1956
+
1957
+
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+ var CurveLiquidityGaugeV2 = _ethers.contract.call(void 0, )`
1977
+ function claim_rewards(address)
1978
+ function integrate_fraction(address) view returns (uint256)
1979
+ `;
1980
+ var CurveRegistry = _ethers.contract.call(void 0, )`
1981
+ function get_coins(address) view returns (address[8])
1982
+ function get_lp_token(address) view returns (address)
1983
+ `;
1984
+ var CurveSwaps = _ethers.contract.call(void 0, )`
1985
+ function get_best_rate(address _from, address to, uint256 amount) view returns (address bestPool, uint256 amountReceived)
1986
+ `;
1987
+ var CurveMinter = _ethers.contract.call(void 0, )`
1988
+ function mint_for(address,address)
1989
+ `;
1990
+ async function curveTakeOrder({
1991
+ comptrollerProxy,
1992
+ integrationManager,
1993
+ fundOwner,
1994
+ curveExchangeAdapter,
1995
+ pool,
1996
+ outgoingAsset,
1997
+ outgoingAssetAmount = _ethers3.utils.parseEther("1"),
1998
+ incomingAsset,
1999
+ minIncomingAssetAmount = _ethers3.utils.parseEther("1")
2000
+ }) {
2001
+ const takeOrderArgs = _protocol.curveTakeOrderArgs.call(void 0, {
2002
+ incomingAsset,
2003
+ minIncomingAssetAmount,
2004
+ outgoingAsset,
2005
+ outgoingAssetAmount,
2006
+ pool
2007
+ });
2008
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2009
+ adapter: curveExchangeAdapter,
2010
+ encodedCallArgs: takeOrderArgs,
2011
+ selector: _protocol.takeOrderSelector
2012
+ });
2013
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2014
+ }
2015
+ function curveClaimRewards({
2016
+ comptrollerProxy,
2017
+ integrationManager,
2018
+ fundOwner,
2019
+ curveLiquidityAdapter,
2020
+ stakingToken
2021
+ }) {
2022
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2023
+ adapter: curveLiquidityAdapter,
2024
+ encodedCallArgs: _protocol.curveClaimRewardsArgs.call(void 0, { stakingToken }),
2025
+ selector: _protocol.claimRewardsSelector
2026
+ });
2027
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2028
+ }
2029
+ async function curveLend({
2030
+ comptrollerProxy,
2031
+ integrationManager,
2032
+ signer,
2033
+ curveLiquidityAdapter,
2034
+ pool,
2035
+ orderedOutgoingAssetAmounts,
2036
+ minIncomingLpTokenAmount = _ethers3.BigNumber.from(1),
2037
+ useUnderlyings
2038
+ }) {
2039
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2040
+ adapter: curveLiquidityAdapter,
2041
+ encodedCallArgs: _protocol.curveLendArgs.call(void 0, {
2042
+ minIncomingLpTokenAmount,
2043
+ orderedOutgoingAssetAmounts,
2044
+ pool,
2045
+ useUnderlyings
2046
+ }),
2047
+ selector: _protocol.lendSelector
2048
+ });
2049
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2050
+ }
2051
+ async function curveLendAndStake({
2052
+ comptrollerProxy,
2053
+ integrationManager,
2054
+ signer,
2055
+ curveLiquidityAdapter,
2056
+ pool,
2057
+ orderedOutgoingAssetAmounts,
2058
+ incomingStakingToken,
2059
+ minIncomingStakingTokenAmount = _ethers3.BigNumber.from(1),
2060
+ useUnderlyings
2061
+ }) {
2062
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2063
+ adapter: curveLiquidityAdapter,
2064
+ encodedCallArgs: _protocol.curveLendAndStakeArgs.call(void 0, {
2065
+ incomingStakingToken,
2066
+ minIncomingStakingTokenAmount,
2067
+ orderedOutgoingAssetAmounts,
2068
+ pool,
2069
+ useUnderlyings
2070
+ }),
2071
+ selector: _protocol.lendAndStakeSelector
2072
+ });
2073
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2074
+ }
2075
+ async function curveRedeem({
2076
+ comptrollerProxy,
2077
+ integrationManager,
2078
+ signer,
2079
+ curveLiquidityAdapter,
2080
+ pool,
2081
+ outgoingLpTokenAmount,
2082
+ useUnderlyings,
2083
+ redeemType,
2084
+ incomingAssetData
2085
+ }) {
2086
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2087
+ adapter: curveLiquidityAdapter,
2088
+ encodedCallArgs: _protocol.curveRedeemArgs.call(void 0, {
2089
+ incomingAssetData,
2090
+ outgoingLpTokenAmount,
2091
+ pool,
2092
+ redeemType,
2093
+ useUnderlyings
2094
+ }),
2095
+ selector: _protocol.redeemSelector
2096
+ });
2097
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2098
+ }
2099
+ async function curveStake({
2100
+ comptrollerProxy,
2101
+ integrationManager,
2102
+ signer,
2103
+ curveLiquidityAdapter,
2104
+ pool,
2105
+ incomingStakingToken,
2106
+ amount
2107
+ }) {
2108
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2109
+ adapter: curveLiquidityAdapter,
2110
+ encodedCallArgs: _protocol.curveStakeArgs.call(void 0, {
2111
+ amount,
2112
+ incomingStakingToken,
2113
+ pool
2114
+ }),
2115
+ selector: _protocol.stakeSelector
2116
+ });
2117
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2118
+ }
2119
+ async function curveUnstake({
2120
+ comptrollerProxy,
2121
+ integrationManager,
2122
+ signer,
2123
+ curveLiquidityAdapter,
2124
+ pool,
2125
+ outgoingStakingToken,
2126
+ amount
2127
+ }) {
2128
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2129
+ adapter: curveLiquidityAdapter,
2130
+ encodedCallArgs: _protocol.curveUnstakeArgs.call(void 0, {
2131
+ amount,
2132
+ outgoingStakingToken,
2133
+ pool
2134
+ }),
2135
+ selector: _protocol.unstakeSelector
2136
+ });
2137
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2138
+ }
2139
+ async function curveUnstakeAndRedeem({
2140
+ comptrollerProxy,
2141
+ integrationManager,
2142
+ signer,
2143
+ curveLiquidityAdapter,
2144
+ pool,
2145
+ outgoingStakingToken,
2146
+ outgoingStakingTokenAmount,
2147
+ useUnderlyings,
2148
+ redeemType,
2149
+ incomingAssetData
2150
+ }) {
2151
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2152
+ adapter: curveLiquidityAdapter,
2153
+ encodedCallArgs: _protocol.curveUnstakeAndRedeemArgs.call(void 0, {
2154
+ incomingAssetData,
2155
+ outgoingStakingToken,
2156
+ outgoingStakingTokenAmount,
2157
+ pool,
2158
+ redeemType,
2159
+ useUnderlyings
2160
+ }),
2161
+ selector: _protocol.unstakeAndRedeemSelector
2162
+ });
2163
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2164
+ }
2165
+
2166
+ // src/scaffolding/extensions/integrations/idle.ts
2167
+
2168
+
2169
+
2170
+
2171
+
2172
+
2173
+
2174
+
2175
+
2176
+
2177
+
2178
+ async function idleClaimRewards({
2179
+ comptrollerProxy,
2180
+ integrationManager,
2181
+ fundOwner,
2182
+ idleAdapter,
2183
+ idleToken
2184
+ }) {
2185
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2186
+ adapter: idleAdapter,
2187
+ encodedCallArgs: _protocol.idleClaimRewardsArgs.call(void 0, {
2188
+ idleToken
2189
+ }),
2190
+ selector: _protocol.claimRewardsSelector
2191
+ });
2192
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2193
+ }
2194
+ async function idleLend({
2195
+ comptrollerProxy,
2196
+ integrationManager,
2197
+ fundOwner,
2198
+ idleAdapter,
2199
+ idleToken,
2200
+ outgoingUnderlyingAmount,
2201
+ minIncomingIdleTokenAmount = _ethers3.BigNumber.from(1)
2202
+ }) {
2203
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2204
+ adapter: idleAdapter,
2205
+ encodedCallArgs: _protocol.idleLendArgs.call(void 0, {
2206
+ idleToken,
2207
+ minIncomingIdleTokenAmount,
2208
+ outgoingUnderlyingAmount
2209
+ }),
2210
+ selector: _protocol.lendSelector
2211
+ });
2212
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2213
+ }
2214
+ async function idleRedeem({
2215
+ comptrollerProxy,
2216
+ integrationManager,
2217
+ fundOwner,
2218
+ idleAdapter,
2219
+ idleToken,
2220
+ outgoingIdleTokenAmount,
2221
+ minIncomingUnderlyingAmount = _ethers3.BigNumber.from(1)
2222
+ }) {
2223
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2224
+ adapter: idleAdapter,
2225
+ encodedCallArgs: _protocol.idleRedeemArgs.call(void 0, {
2226
+ idleToken,
2227
+ minIncomingUnderlyingAmount,
2228
+ outgoingIdleTokenAmount
2229
+ }),
2230
+ selector: _protocol.redeemSelector
2231
+ });
2232
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2233
+ }
2234
+
2235
+ // src/scaffolding/extensions/integrations/mock.ts
2236
+
2237
+
2238
+ var mockGenericRemoveOnlySelector = _protocol.sighash.call(void 0, _ethers3.utils.FunctionFragment.fromString("removeOnly(address,bytes,bytes)"));
2239
+ var mockGenericSwapASelector = _protocol.sighash.call(void 0, _ethers3.utils.FunctionFragment.fromString("swapA(address,bytes,bytes)"));
2240
+ var mockGenericSwapBSelector = _protocol.sighash.call(void 0, _ethers3.utils.FunctionFragment.fromString("swapB(address,bytes,bytes)"));
2241
+ var mockGenericSwapDirectFromVaultSelector = _protocol.sighash.call(void 0, _ethers3.utils.FunctionFragment.fromString("swapDirectFromVault(address,bytes,bytes)"));
2242
+ var mockGenericSwapViaApprovalSelector = _protocol.sighash.call(void 0, _ethers3.utils.FunctionFragment.fromString("swapViaApproval(address,bytes,bytes)"));
2243
+ function mockGenericSwapArgs({
2244
+ spendAssets = [],
2245
+ actualSpendAssetAmounts = [],
2246
+ maxSpendAssetAmounts = actualSpendAssetAmounts,
2247
+ incomingAssets = [],
2248
+ actualIncomingAssetAmounts = [],
2249
+ minIncomingAssetAmounts = actualIncomingAssetAmounts
2250
+ }) {
2251
+ return _protocol.encodeArgs.call(void 0, ["address[]", "uint256[]", "uint256[]", "address[]", "uint256[]", "uint256[]"], [
2252
+ spendAssets,
2253
+ maxSpendAssetAmounts,
2254
+ actualSpendAssetAmounts,
2255
+ incomingAssets,
2256
+ minIncomingAssetAmounts,
2257
+ actualIncomingAssetAmounts
2258
+ ]);
2259
+ }
2260
+ async function mockGenericSwap({
2261
+ comptrollerProxy,
2262
+ vaultProxy,
2263
+ integrationManager,
2264
+ fundOwner,
2265
+ mockGenericAdapter,
2266
+ selector = mockGenericSwapASelector,
2267
+ spendAssets = [],
2268
+ actualSpendAssetAmounts = [],
2269
+ maxSpendAssetAmounts = actualSpendAssetAmounts,
2270
+ incomingAssets = [],
2271
+ actualIncomingAssetAmounts = [],
2272
+ minIncomingAssetAmounts = actualIncomingAssetAmounts,
2273
+ seedFund = false
2274
+ }) {
2275
+ if (seedFund) {
2276
+ for (const key in spendAssets) {
2277
+ await spendAssets[key].transfer(vaultProxy, maxSpendAssetAmounts[key]);
2278
+ }
2279
+ }
2280
+ const swapArgs = mockGenericSwapArgs({
2281
+ actualIncomingAssetAmounts,
2282
+ actualSpendAssetAmounts,
2283
+ incomingAssets,
2284
+ maxSpendAssetAmounts,
2285
+ minIncomingAssetAmounts,
2286
+ spendAssets
2287
+ });
2288
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2289
+ adapter: mockGenericAdapter,
2290
+ encodedCallArgs: swapArgs,
2291
+ selector
2292
+ });
2293
+ const swapTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2294
+ await expect(swapTx).resolves.toBeReceipt();
2295
+ return swapTx;
2296
+ }
2297
+
2298
+ // src/scaffolding/extensions/integrations/olympusV2.ts
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+
2306
+
2307
+ async function olympusV2Stake({
2308
+ comptrollerProxy,
2309
+ integrationManager,
2310
+ signer,
2311
+ olympusV2Adapter,
2312
+ amount
2313
+ }) {
2314
+ const stakeArgs = _protocol.olympusV2StakeArgs.call(void 0, {
2315
+ amount
2316
+ });
2317
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2318
+ adapter: olympusV2Adapter,
2319
+ encodedCallArgs: stakeArgs,
2320
+ selector: _protocol.stakeSelector
2321
+ });
2322
+ const stakeTx = comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2323
+ return stakeTx;
2324
+ }
2325
+ async function olympusV2Unstake({
2326
+ comptrollerProxy,
2327
+ integrationManager,
2328
+ signer,
2329
+ olympusV2Adapter,
2330
+ amount
2331
+ }) {
2332
+ const unstakeArgs = _protocol.olympusV2UnstakeArgs.call(void 0, {
2333
+ amount
2334
+ });
2335
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2336
+ adapter: olympusV2Adapter,
2337
+ encodedCallArgs: unstakeArgs,
2338
+ selector: _protocol.unstakeSelector
2339
+ });
2340
+ const unstakeTx = comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2341
+ return unstakeTx;
2342
+ }
2343
+
2344
+ // src/scaffolding/extensions/integrations/paraSwapV5.ts
2345
+
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+ function paraSwapV5GenerateDummyPaths({ toTokens }) {
2353
+ return toTokens.map((toToken) => {
2354
+ return {
2355
+ adapters: [],
2356
+ to: toToken,
2357
+ totalNetworkFee: 0
2358
+ };
2359
+ });
2360
+ }
2361
+ async function paraSwapV5TakeOrder({
2362
+ comptrollerProxy,
2363
+ integrationManager,
2364
+ fundOwner,
2365
+ paraSwapV5Adapter,
2366
+ outgoingAsset,
2367
+ outgoingAssetAmount,
2368
+ minIncomingAssetAmount = 1,
2369
+ expectedIncomingAssetAmount = minIncomingAssetAmount,
2370
+ uuid = _ethers3.utils.randomBytes(16),
2371
+ paths
2372
+ }) {
2373
+ const takeOrderArgs = _protocol.paraSwapV5TakeOrderArgs.call(void 0, {
2374
+ expectedIncomingAssetAmount,
2375
+ minIncomingAssetAmount,
2376
+ outgoingAsset,
2377
+ outgoingAssetAmount,
2378
+ paths,
2379
+ uuid
2380
+ });
2381
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2382
+ adapter: paraSwapV5Adapter,
2383
+ encodedCallArgs: takeOrderArgs,
2384
+ selector: _protocol.takeOrderSelector
2385
+ });
2386
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2387
+ }
2388
+
2389
+ // src/scaffolding/extensions/integrations/poolTogetherV4.ts
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2397
+
2398
+
2399
+
2400
+
2401
+ async function poolTogetherV4Lend({
2402
+ comptrollerProxy,
2403
+ integrationManager,
2404
+ fundOwner,
2405
+ poolTogetherV4Adapter,
2406
+ ptToken,
2407
+ amount = _ethers3.utils.parseEther("1")
2408
+ }) {
2409
+ const lendArgs = _protocol.poolTogetherV4LendArgs.call(void 0, {
2410
+ amount,
2411
+ ptToken
2412
+ });
2413
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2414
+ adapter: poolTogetherV4Adapter,
2415
+ encodedCallArgs: lendArgs,
2416
+ selector: _protocol.lendSelector
2417
+ });
2418
+ const lendTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2419
+ return lendTx;
2420
+ }
2421
+ async function poolTogetherV4Redeem({
2422
+ comptrollerProxy,
2423
+ integrationManager,
2424
+ fundOwner,
2425
+ poolTogetherV4Adapter,
2426
+ ptToken,
2427
+ amount = _ethers3.utils.parseEther("1")
2428
+ }) {
2429
+ const redeemArgs = _protocol.poolTogetherV4RedeemArgs.call(void 0, {
2430
+ amount,
2431
+ ptToken
2432
+ });
2433
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2434
+ adapter: poolTogetherV4Adapter,
2435
+ encodedCallArgs: redeemArgs,
2436
+ selector: _protocol.redeemSelector
2437
+ });
2438
+ const redeemTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2439
+ return redeemTx;
2440
+ }
2441
+ async function poolTogetherV4ClaimRewards({
2442
+ comptrollerProxy,
2443
+ integrationManager,
2444
+ fundOwner,
2445
+ poolTogetherV4Adapter,
2446
+ prizeDistributor,
2447
+ drawIds,
2448
+ winningPicks
2449
+ }) {
2450
+ const claimRewardsArgs = _protocol.poolTogetherV4ClaimRewardsArgs.call(void 0, {
2451
+ drawIds,
2452
+ prizeDistributor,
2453
+ winningPicks
2454
+ });
2455
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2456
+ adapter: poolTogetherV4Adapter,
2457
+ encodedCallArgs: claimRewardsArgs,
2458
+ selector: _protocol.claimRewardsSelector
2459
+ });
2460
+ const claimTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2461
+ return claimTx;
2462
+ }
2463
+
2464
+ // src/scaffolding/extensions/integrations/synthetix.ts
2465
+
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+
2472
+
2473
+
2474
+
2475
+
2476
+ async function synthetixAssignExchangeDelegate({
2477
+ comptrollerProxy,
2478
+ synthetixDelegateApprovals,
2479
+ fundOwner,
2480
+ delegate
2481
+ }) {
2482
+ await comptrollerProxy.connect(fundOwner).vaultCallOnContract(synthetixDelegateApprovals, _protocol.synthetixAssignExchangeDelegateSelector, _protocol.encodeArgs.call(void 0, ["address"], [delegate]));
2483
+ }
2484
+ async function synthetixRedeem({
2485
+ comptrollerProxy,
2486
+ integrationManager,
2487
+ signer,
2488
+ synthetixAdapter,
2489
+ synths
2490
+ }) {
2491
+ const redeemArgs = _protocol.synthetixRedeemArgs.call(void 0, {
2492
+ synths
2493
+ });
2494
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2495
+ adapter: synthetixAdapter,
2496
+ encodedCallArgs: redeemArgs,
2497
+ selector: _protocol.redeemSelector
2498
+ });
2499
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2500
+ }
2501
+ async function synthetixTakeOrder({
2502
+ comptrollerProxy,
2503
+ vaultProxy,
2504
+ integrationManager,
2505
+ fundOwner,
2506
+ synthetixAdapter,
2507
+ outgoingAsset,
2508
+ outgoingAssetAmount = _ethers3.utils.parseEther("1"),
2509
+ minIncomingSusdAmount = _ethers3.utils.parseEther("1"),
2510
+ seedFund = false
2511
+ }) {
2512
+ if (seedFund) {
2513
+ await outgoingAsset.transfer(vaultProxy, outgoingAssetAmount);
2514
+ }
2515
+ const takeOrderArgs = _protocol.synthetixTakeOrderArgs.call(void 0, {
2516
+ minIncomingSusdAmount,
2517
+ outgoingAsset,
2518
+ outgoingAssetAmount
2519
+ });
2520
+ const callArgs = await _protocol.callOnIntegrationArgs.call(void 0, {
2521
+ adapter: synthetixAdapter,
2522
+ encodedCallArgs: takeOrderArgs,
2523
+ selector: _protocol.takeOrderSelector
2524
+ });
2525
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2526
+ }
2527
+
2528
+ // src/scaffolding/extensions/integrations/uniswapV2.ts
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+ var UniswapV2Factory = _ethers.contract.call(void 0, )`
2541
+ function createPair(address,address) returns (address)
2542
+ function getPair(address,address) view returns (address)
2543
+ `;
2544
+ async function uniswapV2Lend({
2545
+ comptrollerProxy,
2546
+ vaultProxy,
2547
+ integrationManager,
2548
+ fundOwner,
2549
+ uniswapV2LiquidityAdapter,
2550
+ tokenA,
2551
+ tokenB,
2552
+ amountADesired,
2553
+ amountBDesired,
2554
+ amountAMin,
2555
+ amountBMin,
2556
+ minPoolTokenAmount,
2557
+ seedFund = false
2558
+ }) {
2559
+ if (seedFund) {
2560
+ await tokenA.transfer(vaultProxy, amountADesired);
2561
+ await tokenB.transfer(vaultProxy, amountBDesired);
2562
+ }
2563
+ const lendArgs = _protocol.uniswapV2LendArgs.call(void 0, {
2564
+ amountADesired,
2565
+ amountAMin,
2566
+ amountBDesired,
2567
+ amountBMin,
2568
+ minPoolTokenAmount,
2569
+ tokenA,
2570
+ tokenB
2571
+ });
2572
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2573
+ adapter: uniswapV2LiquidityAdapter,
2574
+ encodedCallArgs: lendArgs,
2575
+ selector: _protocol.lendSelector
2576
+ });
2577
+ const lendTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2578
+ await expect(lendTx).resolves.toBeReceipt();
2579
+ return lendTx;
2580
+ }
2581
+ async function uniswapV2Redeem({
2582
+ comptrollerProxy,
2583
+ integrationManager,
2584
+ fundOwner,
2585
+ uniswapV2LiquidityAdapter,
2586
+ poolTokenAmount,
2587
+ tokenA,
2588
+ tokenB,
2589
+ amountAMin,
2590
+ amountBMin
2591
+ }) {
2592
+ const redeemArgs = _protocol.uniswapV2RedeemArgs.call(void 0, {
2593
+ amountAMin,
2594
+ amountBMin,
2595
+ poolTokenAmount,
2596
+ tokenA,
2597
+ tokenB
2598
+ });
2599
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2600
+ adapter: uniswapV2LiquidityAdapter,
2601
+ encodedCallArgs: redeemArgs,
2602
+ selector: _protocol.redeemSelector
2603
+ });
2604
+ const redeemTx = comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2605
+ await expect(redeemTx).resolves.toBeReceipt();
2606
+ return redeemTx;
2607
+ }
2608
+ async function uniswapV2TakeOrder({
2609
+ comptrollerProxy,
2610
+ vaultProxy,
2611
+ integrationManager,
2612
+ fundOwner,
2613
+ uniswapV2ExchangeAdapter,
2614
+ path,
2615
+ outgoingAssetAmount,
2616
+ minIncomingAssetAmount,
2617
+ seedFund = false
2618
+ }) {
2619
+ if (seedFund) {
2620
+ await path[0].transfer(vaultProxy, outgoingAssetAmount);
2621
+ }
2622
+ const takeOrderArgs = _protocol.uniswapV2TakeOrderArgs.call(void 0, {
2623
+ minIncomingAssetAmount,
2624
+ outgoingAssetAmount,
2625
+ path
2626
+ });
2627
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2628
+ adapter: uniswapV2ExchangeAdapter,
2629
+ encodedCallArgs: takeOrderArgs,
2630
+ selector: _protocol.takeOrderSelector
2631
+ });
2632
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2633
+ }
2634
+
2635
+ // src/scaffolding/extensions/integrations/uniswapV3.ts
2636
+
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+ async function uniswapV3TakeOrder({
2643
+ comptrollerProxy,
2644
+ integrationManager,
2645
+ fundOwner,
2646
+ uniswapV3Adapter,
2647
+ pathAddresses,
2648
+ pathFees,
2649
+ outgoingAssetAmount,
2650
+ minIncomingAssetAmount = 1,
2651
+ seedFund = false
2652
+ }) {
2653
+ if (seedFund) {
2654
+ const vaultProxy = await comptrollerProxy.getVaultProxy();
2655
+ await pathAddresses[0].transfer(vaultProxy, outgoingAssetAmount);
2656
+ }
2657
+ const takeOrderArgs = _protocol.uniswapV3TakeOrderArgs.call(void 0, {
2658
+ minIncomingAssetAmount,
2659
+ outgoingAssetAmount,
2660
+ pathAddresses,
2661
+ pathFees
2662
+ });
2663
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2664
+ adapter: uniswapV3Adapter,
2665
+ encodedCallArgs: takeOrderArgs,
2666
+ selector: _protocol.takeOrderSelector
2667
+ });
2668
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2669
+ }
2670
+
2671
+ // src/scaffolding/extensions/integrations/yearn.ts
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+ async function yearnVaultV2Lend({
2682
+ signer,
2683
+ comptrollerProxy,
2684
+ integrationManager,
2685
+ yearnVaultV2Adapter,
2686
+ yVault,
2687
+ outgoingUnderlyingAmount,
2688
+ minIncomingYVaultSharesAmount = _ethers3.BigNumber.from(1)
2689
+ }) {
2690
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2691
+ adapter: yearnVaultV2Adapter,
2692
+ encodedCallArgs: _protocol.yearnVaultV2LendArgs.call(void 0, {
2693
+ minIncomingYVaultSharesAmount,
2694
+ outgoingUnderlyingAmount,
2695
+ yVault
2696
+ }),
2697
+ selector: _protocol.lendSelector
2698
+ });
2699
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2700
+ }
2701
+ async function yearnVaultV2Redeem({
2702
+ signer,
2703
+ comptrollerProxy,
2704
+ integrationManager,
2705
+ yearnVaultV2Adapter,
2706
+ yVault,
2707
+ maxOutgoingYVaultSharesAmount,
2708
+ minIncomingUnderlyingAmount = _ethers3.BigNumber.from(1),
2709
+ slippageToleranceBps = 1
2710
+ }) {
2711
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2712
+ adapter: yearnVaultV2Adapter,
2713
+ encodedCallArgs: _protocol.yearnVaultV2RedeemArgs.call(void 0, {
2714
+ maxOutgoingYVaultSharesAmount,
2715
+ minIncomingUnderlyingAmount,
2716
+ slippageToleranceBps,
2717
+ yVault
2718
+ }),
2719
+ selector: _protocol.redeemSelector
2720
+ });
2721
+ return comptrollerProxy.connect(signer).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2722
+ }
2723
+
2724
+ // src/scaffolding/extensions/integrations/zeroExV2.ts
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+ async function zeroExV2TakeOrder({
2732
+ comptrollerProxy,
2733
+ integrationManager,
2734
+ fundOwner,
2735
+ zeroExV2Adapter,
2736
+ signedOrder,
2737
+ takerAssetFillAmount
2738
+ }) {
2739
+ const takeOrderArgs = _protocol.zeroExV2TakeOrderArgs.call(void 0, {
2740
+ signedOrder,
2741
+ takerAssetFillAmount
2742
+ });
2743
+ const callArgs = _protocol.callOnIntegrationArgs.call(void 0, {
2744
+ adapter: zeroExV2Adapter,
2745
+ encodedCallArgs: takeOrderArgs,
2746
+ selector: _protocol.takeOrderSelector
2747
+ });
2748
+ return comptrollerProxy.connect(fundOwner).callOnExtension(integrationManager, _protocol.IntegrationManagerActionId.CallOnIntegration, callArgs);
2749
+ }
2750
+
2751
+ // src/scaffolding/extensions/policies.ts
2752
+
2753
+
2754
+ async function generatePolicyManagerConfigWithMockPolicies({ deployer }) {
2755
+ const policies = Object.values(await generateMockPolicies({
2756
+ deployer
2757
+ }));
2758
+ const policiesSettingsData = [...new Array(policies.length - 1).fill(_ethers3.constants.HashZero), _ethers3.utils.randomBytes(10)];
2759
+ return _protocol.policyManagerConfigArgs.call(void 0, {
2760
+ policies,
2761
+ settings: policiesSettingsData
2762
+ });
2763
+ }
2764
+ async function generateMockPolicies({ deployer }) {
2765
+ const mockAddTrackedAssetsPolicy = await _protocol.IPolicy.mock(deployer);
2766
+ const mockCreateExternalPositionPolicy = await _protocol.IPolicy.mock(deployer);
2767
+ const mockPostBuySharesPolicy = await _protocol.IPolicy.mock(deployer);
2768
+ const mockPostCallOnExternalPositionPolicy = await _protocol.IPolicy.mock(deployer);
2769
+ const mockPostCoIPolicy = await _protocol.IPolicy.mock(deployer);
2770
+ const mockRedeemSharesForSpecificAssetsPolicy = await _protocol.IPolicy.mock(deployer);
2771
+ const mockPreTransferSharesPolicy = await _protocol.IPolicy.mock(deployer);
2772
+ const mockRemoveExternalPositionPolicy = await _protocol.IPolicy.mock(deployer);
2773
+ await Promise.all([
2774
+ mockAddTrackedAssetsPolicy.identifier.returns(`MOCK_ADD_TRACKED_ASSETS`),
2775
+ mockAddTrackedAssetsPolicy.addFundSettings.returns(void 0),
2776
+ mockAddTrackedAssetsPolicy.activateForFund.returns(void 0),
2777
+ mockAddTrackedAssetsPolicy.canDisable.returns(false),
2778
+ mockAddTrackedAssetsPolicy.validateRule.returns(true),
2779
+ mockAddTrackedAssetsPolicy.implementedHooks.returns([_protocol.PolicyHook.AddTrackedAssets]),
2780
+ mockAddTrackedAssetsPolicy.updateFundSettings.returns(void 0),
2781
+ mockCreateExternalPositionPolicy.identifier.returns(`MOCK_CREATE_EXTERNAL_POSITION`),
2782
+ mockCreateExternalPositionPolicy.addFundSettings.returns(void 0),
2783
+ mockCreateExternalPositionPolicy.activateForFund.returns(void 0),
2784
+ mockCreateExternalPositionPolicy.canDisable.returns(false),
2785
+ mockCreateExternalPositionPolicy.validateRule.returns(true),
2786
+ mockCreateExternalPositionPolicy.implementedHooks.returns([_protocol.PolicyHook.CreateExternalPosition]),
2787
+ mockCreateExternalPositionPolicy.updateFundSettings.returns(void 0),
2788
+ mockPostBuySharesPolicy.identifier.returns(`MOCK_POST_BUY_SHARES`),
2789
+ mockPostBuySharesPolicy.addFundSettings.returns(void 0),
2790
+ mockPostBuySharesPolicy.activateForFund.returns(void 0),
2791
+ mockPostBuySharesPolicy.canDisable.returns(false),
2792
+ mockPostBuySharesPolicy.validateRule.returns(true),
2793
+ mockPostBuySharesPolicy.implementedHooks.returns([_protocol.PolicyHook.PostBuyShares]),
2794
+ mockPostBuySharesPolicy.updateFundSettings.returns(void 0),
2795
+ mockPostCallOnExternalPositionPolicy.identifier.returns(`MOCK_POST_CALL_ON_EXTERNAL_POSITION`),
2796
+ mockPostCallOnExternalPositionPolicy.addFundSettings.returns(void 0),
2797
+ mockPostCallOnExternalPositionPolicy.activateForFund.returns(void 0),
2798
+ mockPostCallOnExternalPositionPolicy.canDisable.returns(false),
2799
+ mockPostCallOnExternalPositionPolicy.validateRule.returns(true),
2800
+ mockPostCallOnExternalPositionPolicy.implementedHooks.returns([_protocol.PolicyHook.PostCallOnExternalPosition]),
2801
+ mockPostCallOnExternalPositionPolicy.updateFundSettings.returns(void 0),
2802
+ mockPostCoIPolicy.identifier.returns(`MOCK_POST_CALL_ON_INTEGRATION`),
2803
+ mockPostCoIPolicy.addFundSettings.returns(void 0),
2804
+ mockPostCoIPolicy.activateForFund.returns(void 0),
2805
+ mockPostCoIPolicy.canDisable.returns(false),
2806
+ mockPostCoIPolicy.validateRule.returns(true),
2807
+ mockPostCoIPolicy.implementedHooks.returns([_protocol.PolicyHook.PostCallOnIntegration]),
2808
+ mockPostCoIPolicy.updateFundSettings.returns(void 0),
2809
+ mockPreTransferSharesPolicy.identifier.returns(`MOCK_PRE_TRANSFER_SHARES`),
2810
+ mockPreTransferSharesPolicy.addFundSettings.returns(void 0),
2811
+ mockPreTransferSharesPolicy.activateForFund.returns(void 0),
2812
+ mockPreTransferSharesPolicy.canDisable.returns(false),
2813
+ mockPreTransferSharesPolicy.validateRule.returns(true),
2814
+ mockPreTransferSharesPolicy.implementedHooks.returns([_protocol.PolicyHook.PreTransferShares]),
2815
+ mockPreTransferSharesPolicy.updateFundSettings.returns(void 0),
2816
+ mockRedeemSharesForSpecificAssetsPolicy.identifier.returns(`MOCK_REDEEM_SHARES_FOR_SPECIFIC_ASSETS`),
2817
+ mockRedeemSharesForSpecificAssetsPolicy.addFundSettings.returns(void 0),
2818
+ mockRedeemSharesForSpecificAssetsPolicy.activateForFund.returns(void 0),
2819
+ mockRedeemSharesForSpecificAssetsPolicy.canDisable.returns(false),
2820
+ mockRedeemSharesForSpecificAssetsPolicy.validateRule.returns(true),
2821
+ mockRedeemSharesForSpecificAssetsPolicy.implementedHooks.returns([_protocol.PolicyHook.RedeemSharesForSpecificAssets]),
2822
+ mockRedeemSharesForSpecificAssetsPolicy.updateFundSettings.returns(void 0),
2823
+ mockRemoveExternalPositionPolicy.identifier.returns(`MOCK_REMOVE_EXTERNAL_POSITION`),
2824
+ mockRemoveExternalPositionPolicy.addFundSettings.returns(void 0),
2825
+ mockRemoveExternalPositionPolicy.activateForFund.returns(void 0),
2826
+ mockRemoveExternalPositionPolicy.canDisable.returns(false),
2827
+ mockRemoveExternalPositionPolicy.validateRule.returns(true),
2828
+ mockRemoveExternalPositionPolicy.implementedHooks.returns([_protocol.PolicyHook.RedeemSharesForSpecificAssets]),
2829
+ mockRemoveExternalPositionPolicy.updateFundSettings.returns(void 0)
2830
+ ]);
2831
+ return {
2832
+ mockAddTrackedAssetsPolicy,
2833
+ mockCreateExternalPositionPolicy,
2834
+ mockPostBuySharesPolicy,
2835
+ mockPostCallOnExternalPositionPolicy,
2836
+ mockPostCoIPolicy,
2837
+ mockPreTransferSharesPolicy,
2838
+ mockRedeemSharesForSpecificAssetsPolicy,
2839
+ mockRemoveExternalPositionPolicy
2840
+ };
2841
+ }
2842
+
2843
+ // src/scaffolding/external-interfaces.ts
2844
+
2845
+ var IConvexBaseRewardPool = _ethers.contract.call(void 0, )`
2846
+ function stakeFor(address, uint256) returns (bool)
2847
+ `;
2848
+ var IConvexCrvDepositor = _ethers.contract.call(void 0, )`
2849
+ function deposit(uint256, bool)
2850
+ `;
2851
+ var IConvexCvxLocker = _ethers.contract.call(void 0, )`
2852
+ function balanceOf(address) view returns (uint256)
2853
+ function checkpointEpoch()
2854
+ function getReward(address, bool)
2855
+ function lockedBalanceOf(address) view returns (uint256)
2856
+ `;
2857
+ var IConvexVlCvxExtraRewardDistribution = _ethers.contract.call(void 0, )`
2858
+ function claimableRewards(address, address) view returns (uint256)
2859
+ function addReward(address, uint256)
2860
+ `;
2861
+ var ISnapshotDelegateRegistry = _ethers.contract.call(void 0, )`
2862
+ function delegation(address, bytes32) view returns (address)
2863
+ `;
2864
+ var IVotiumMultiMerkleStash = _ethers.contract.call(void 0, )`
2865
+ function owner() view returns (address)
2866
+ function updateMerkleRoot(address, bytes32)
2867
+ `;
2868
+
2869
+ // src/scaffolding/peripheral/shares-splitter.ts
2870
+
2871
+ async function deploySharesSplitter({
2872
+ signer,
2873
+ sharesSplitterFactory,
2874
+ splitUsers,
2875
+ splitPercentages
2876
+ }) {
2877
+ const receipt = await sharesSplitterFactory.connect(signer).deploy(splitUsers, splitPercentages);
2878
+ const proxyDeployedArgs = assertEvent(receipt, "ProxyDeployed", {
2879
+ caller: signer,
2880
+ proxy: expect.any(String)
2881
+ });
2882
+ const sharesSplitterProxy = new (0, _protocol.SharesSplitterLib)(proxyDeployedArgs.proxy, provider);
2883
+ return { receipt, sharesSplitterProxy };
2884
+ }
2885
+
2886
+ // src/scaffolding/setup.ts
2887
+
2888
+
2889
+
2890
+
2891
+
2892
+
2893
+
2894
+
2895
+
2896
+
2897
+
2898
+ // src/scaffolding/shares.ts
2899
+
2900
+ async function buyShares(options) {
2901
+ return (await buySharesFunction(options)).send();
2902
+ }
2903
+ async function buySharesFunction({
2904
+ comptrollerProxy,
2905
+ denominationAsset,
2906
+ buyer,
2907
+ investmentAmount,
2908
+ minSharesQuantity = 1,
2909
+ seedBuyer = false
2910
+ }) {
2911
+ if (investmentAmount == null) {
2912
+ investmentAmount = _ethers3.utils.parseUnits("1", await denominationAsset.decimals());
2913
+ }
2914
+ if (seedBuyer) {
2915
+ await denominationAsset.transfer(buyer, investmentAmount);
2916
+ }
2917
+ await denominationAsset.connect(buyer).approve(comptrollerProxy, investmentAmount);
2918
+ return comptrollerProxy.connect(buyer).buyShares.args(investmentAmount, minSharesQuantity).ref;
2919
+ }
2920
+ async function redeemSharesForSpecificAssets({
2921
+ comptrollerProxy,
2922
+ signer,
2923
+ recipient = signer,
2924
+ quantity = _ethers3.constants.MaxUint256,
2925
+ payoutAssets,
2926
+ payoutAssetPercentages
2927
+ }) {
2928
+ return comptrollerProxy.connect(signer).redeemSharesForSpecificAssets(recipient, quantity, payoutAssets, payoutAssetPercentages);
2929
+ }
2930
+ async function redeemSharesInKind({
2931
+ comptrollerProxy,
2932
+ signer,
2933
+ recipient = signer,
2934
+ quantity = _ethers3.constants.MaxUint256,
2935
+ additionalAssets = [],
2936
+ assetsToSkip = []
2937
+ }) {
2938
+ return comptrollerProxy.connect(signer).redeemSharesInKind(recipient, quantity, additionalAssets, assetsToSkip);
2939
+ }
2940
+
2941
+ // src/scaffolding/setup.ts
2942
+ async function createComptrollerProxy({
2943
+ signer,
2944
+ comptrollerLib,
2945
+ denominationAsset,
2946
+ sharesActionTimelock = 0
2947
+ }) {
2948
+ const constructData = _protocol.encodeFunctionData.call(void 0, comptrollerLib.init.fragment, [denominationAsset, sharesActionTimelock]);
2949
+ const comptrollerProxyContract = await _protocol.ComptrollerProxy.deploy(signer, constructData, comptrollerLib);
2950
+ return {
2951
+ comptrollerProxy: new (0, _protocol.ComptrollerLib)(comptrollerProxyContract, signer),
2952
+ receipt: comptrollerProxyContract.deployment
2953
+ };
2954
+ }
2955
+ async function createMigrationRequest({
2956
+ signer,
2957
+ fundDeployer,
2958
+ vaultProxy,
2959
+ denominationAsset,
2960
+ sharesActionTimelock = 0,
2961
+ feeManagerConfigData = "0x",
2962
+ policyManagerConfigData = "0x",
2963
+ bypassPrevReleaseFailure = false
2964
+ }) {
2965
+ const receipt = await fundDeployer.connect(signer).createMigrationRequest(vaultProxy, denominationAsset, sharesActionTimelock, feeManagerConfigData, policyManagerConfigData, bypassPrevReleaseFailure);
2966
+ const comptrollerDeployedArgs = assertEvent(receipt, "ComptrollerProxyDeployed", {
2967
+ comptrollerProxy: expect.any(String),
2968
+ creator: signer,
2969
+ denominationAsset,
2970
+ sharesActionTimelock: _ethers3.BigNumber.from(sharesActionTimelock)
2971
+ });
2972
+ return {
2973
+ comptrollerProxy: new (0, _protocol.ComptrollerLib)(comptrollerDeployedArgs.comptrollerProxy, signer),
2974
+ receipt
2975
+ };
2976
+ }
2977
+ async function createNewFund({
2978
+ signer,
2979
+ fundDeployer,
2980
+ denominationAsset,
2981
+ sharesActionTimelock = 0,
2982
+ fundOwner = _ethers.randomAddress.call(void 0, ),
2983
+ fundName = "My Fund",
2984
+ fundSymbol = "",
2985
+ feeManagerConfig = "0x",
2986
+ policyManagerConfig = "0x",
2987
+ investment
2988
+ }) {
2989
+ const receipt = await fundDeployer.connect(signer).createNewFund(fundOwner, fundName, fundSymbol, denominationAsset, sharesActionTimelock, feeManagerConfig, policyManagerConfig);
2990
+ const comptrollerDeployedArgs = assertEvent(receipt, "ComptrollerProxyDeployed", {
2991
+ comptrollerProxy: expect.any(String),
2992
+ creator: signer,
2993
+ denominationAsset,
2994
+ sharesActionTimelock: _ethers3.BigNumber.from(sharesActionTimelock)
2995
+ });
2996
+ const comptrollerProxy = new (0, _protocol.ComptrollerLib)(comptrollerDeployedArgs.comptrollerProxy, signer);
2997
+ const newFundDeployedArgs = assertEvent(receipt, "NewFundCreated", {
2998
+ comptrollerProxy,
2999
+ creator: signer,
3000
+ vaultProxy: expect.any(String)
3001
+ });
3002
+ const vaultProxy = new (0, _protocol.VaultLib)(newFundDeployedArgs.vaultProxy, signer);
3003
+ if (investment != null) {
3004
+ await buyShares(__spreadValues({
3005
+ comptrollerProxy,
3006
+ denominationAsset
3007
+ }, investment));
3008
+ }
3009
+ return {
3010
+ comptrollerProxy,
3011
+ receipt,
3012
+ vaultProxy
3013
+ };
3014
+ }
3015
+ async function createReconfigurationRequest({
3016
+ signer,
3017
+ fundDeployer,
3018
+ vaultProxy,
3019
+ denominationAsset,
3020
+ sharesActionTimelock = 0,
3021
+ feeManagerConfigData = "0x",
3022
+ policyManagerConfigData = "0x"
3023
+ }) {
3024
+ const receipt = await fundDeployer.connect(signer).createReconfigurationRequest(vaultProxy, denominationAsset, sharesActionTimelock, feeManagerConfigData, policyManagerConfigData);
3025
+ const comptrollerDeployedArgs = assertEvent(receipt, "ComptrollerProxyDeployed", {
3026
+ comptrollerProxy: expect.any(String),
3027
+ creator: signer,
3028
+ denominationAsset,
3029
+ sharesActionTimelock: _ethers3.BigNumber.from(sharesActionTimelock)
3030
+ });
3031
+ return {
3032
+ comptrollerProxy: new (0, _protocol.ComptrollerLib)(comptrollerDeployedArgs.comptrollerProxy, signer),
3033
+ receipt
3034
+ };
3035
+ }
3036
+ async function createVaultProxy({
3037
+ signer,
3038
+ vaultLib,
3039
+ fundOwner,
3040
+ fundAccessor,
3041
+ fundName = "My Fund"
3042
+ }) {
3043
+ const constructData = _protocol.encodeFunctionData.call(void 0, vaultLib.init.fragment, [fundOwner, fundAccessor, fundName]);
3044
+ const vaultProxyContract = await _protocol.VaultProxy.deploy(signer, constructData, vaultLib);
3045
+ return new (0, _protocol.VaultLib)(vaultProxyContract, fundAccessor);
3046
+ }
3047
+ async function setupGasRelayerPaymaster({
3048
+ signer,
3049
+ vaultProxy,
3050
+ fundAccessor,
3051
+ weth,
3052
+ startingBalance = _ethers3.utils.parseUnits("10", 18)
3053
+ }) {
3054
+ await weth.transfer(vaultProxy, startingBalance);
3055
+ const comptrollerProxy = new (0, _protocol.ComptrollerLib)(fundAccessor, signer);
3056
+ const receipt = await comptrollerProxy.deployGasRelayPaymaster();
3057
+ const eventArgs = assertEvent(receipt, "GasRelayPaymasterSet", {
3058
+ gasRelayPaymaster: expect.any(String)
3059
+ });
3060
+ return new (0, _protocol.GasRelayPaymasterLib)(eventArgs.gasRelayPaymaster, signer);
3061
+ }
3062
+
3063
+ // src/scaffolding/vaultCalls.ts
3064
+
3065
+
3066
+
3067
+
3068
+
3069
+
3070
+
3071
+
3072
+
3073
+ async function vaultCallCreateNewList({
3074
+ addressListRegistry,
3075
+ comptrollerProxy,
3076
+ items,
3077
+ owner,
3078
+ signer,
3079
+ updateType
3080
+ }) {
3081
+ await comptrollerProxy.connect(signer).vaultCallOnContract(addressListRegistry.address, _protocol.addressListRegistryCreateListSelector, _protocol.encodeArgs.call(void 0, ["address", "uint8", "address[]"], [owner, updateType, items]));
3082
+ const listCount = await addressListRegistry.getListCount();
3083
+ return listCount.sub(1);
3084
+ }
3085
+ function vaultCallCurveMinterMint({
3086
+ comptrollerProxy,
3087
+ minter,
3088
+ gauge
3089
+ }) {
3090
+ return comptrollerProxy.vaultCallOnContract(minter, _protocol.curveMinterMintSelector, _protocol.encodeArgs.call(void 0, ["address"], [gauge]));
3091
+ }
3092
+ function vaultCallCurveMinterMintMany({
3093
+ comptrollerProxy,
3094
+ minter,
3095
+ gauges
3096
+ }) {
3097
+ const gaugesFormatted = new Array(8).fill(_ethers3.constants.AddressZero);
3098
+ for (const i in gauges) {
3099
+ gaugesFormatted[i] = gauges[i];
3100
+ }
3101
+ return comptrollerProxy.vaultCallOnContract(minter, _protocol.curveMinterMintManySelector, _protocol.encodeArgs.call(void 0, ["address[8]"], [gaugesFormatted]));
3102
+ }
3103
+ function vaultCallCurveMinterToggleApproveMint({
3104
+ comptrollerProxy,
3105
+ minter,
3106
+ account
3107
+ }) {
3108
+ return comptrollerProxy.vaultCallOnContract(minter, _protocol.curveMinterToggleApproveMintSelector, _protocol.encodeArgs.call(void 0, ["address"], [account]));
3109
+ }
3110
+ function vaultCallStartAssetBypassTimelock({
3111
+ comptrollerProxy,
3112
+ contract: contract7,
3113
+ asset
3114
+ }) {
3115
+ return comptrollerProxy.vaultCallOnContract(contract7, _protocol.sighash.call(void 0, _ethers3.utils.FunctionFragment.fromString("startAssetBypassTimelock(address)")), _protocol.encodeArgs.call(void 0, ["address"], [asset]));
3116
+ }
3117
+
3118
+ // src/whales.ts
3119
+
3120
+ var whales = {
3121
+ bat: "0x12274c71304bc0e6b38a56b94d2949b118feb838",
3122
+ bnb: "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8",
3123
+ bnt: "0x7d1ed1601a12a172269436fa95fe156650603c1d",
3124
+ busd: "0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503",
3125
+ comp: "0x0f50d31b3eaefd65236dd3736b863cffa4c63c4e",
3126
+ crv: "0xf89501b77b2fa6329f94f5a05fe84cebb5c8b1a0",
3127
+ dai: "0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503",
3128
+ grt: "0xf977814e90da44bfa03b6295a0616a897441acec",
3129
+ knc: "0x09d51654bd9efbfcb56da3491989cc1444095fff",
3130
+ ldo: "0x3dba737ccc50a32a1764b493285dd51c8af6c278",
3131
+ link: "0xbe6977e08d4479c0a6777539ae0e8fa27be4e9d6",
3132
+ lusd: "0x24cbbef882a77c5aaa9abd6558e68b4c648453c5",
3133
+ mana: "0xefb94ac00f1cee8a89d5c3f49faa799da6f03024",
3134
+ mln: "0xd8f8a53945bcfbbc19da162aa405e662ef71c40d",
3135
+ ohm: "0x2cfcbd233268c302996c767347eb45bec36fb08d",
3136
+ rep: "0xc6a043b07d33b6f30d8cb501026c391cfd25abe1",
3137
+ ren: "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8",
3138
+ susd: "0xa5f7a39e55d7878bc5bd754ee5d6bd7a7662355b",
3139
+ sohm: "0x3d5c83351c872fdf07da498c84ca3275222f284c",
3140
+ uni: "0x47173b170c64d16393a52e6c480b3ad8c302ba1e",
3141
+ usdc: "0xae2d4617c862309a3d75a0ffb358c7a5009c673f",
3142
+ usdt: "0x5041ed759dd4afc3a72b8192c143f72f4724081a",
3143
+ weth: "0xe08A8b19e5722a201EaF20A6BC595eF655397bd5",
3144
+ zrx: "0x206376e8940e42538781cd94ef024df3c1e0fd43",
3145
+ ausdc: "0x3DdfA8eC3052539b6C9549F12cEA2C295cfF5296",
3146
+ ausdt: "0x7d6149ad9a573a6e2ca6ebf7d4897c1b766841b4",
3147
+ ccomp: "0xd74f186194ab9219fafac5c2fe4b3270169666db",
3148
+ cdai: "0x22fa8cc33a42320385cbd3690ed60a021891cb32",
3149
+ ceth: "0x8aceab8167c80cb8b3de7fa6228b889bb1130ee8",
3150
+ cuni: "0x39d8014b4f40d2cbc441137011d32023f4f1fd87",
3151
+ cusdc: "0xb3bd459e0598dde1fe84b1d0a1430be175b5d5be",
3152
+ fdai7: "0xa993d62492f41703f6185881eae755b0966ea5b0",
3153
+ feth7: "0x05f284897641661fee9f1c1413a4f599a43a746f",
3154
+ fdai8: "0xd6bf9d9079139dbb3a4fdb84b07efc75ea77838f",
3155
+ ftribe8: "0xdb5ac83c137321da29a59a7592232bc4ed461730",
3156
+ ptUsdc: "0x8904ffc6aa039db5941de11309a42372f3f7d2fd",
3157
+ seth: "0xc34a7c65aa08cb36744bda8eeec7b8e9891e147c",
3158
+ sxag: "0x40d68c490bf7262ec40048099aec23535f734be2",
3159
+ sxau: "0x92eb453b7b5b8d41edb44e2c8b8b53eb70a482c7",
3160
+ cvx: "0x0aca67fa70b142a3b9bf2ed89a81b40ff85dacdc",
3161
+ lidoSteth: "0x06920c9fc643de77b99cb7670a944ad31eaaa260",
3162
+ ust: "0x738cf6903e6c4e699d1c2dd9ab8b67fcdb3121ea",
3163
+ stecrv: "0x56c915758ad3f76fd287fff7563ee313142fb663"
3164
+ };
3165
+ async function unlockWhale(token) {
3166
+ const address = _ethers.resolveAddress.call(void 0, whales[token]);
3167
+ await provider.send("hardhat_impersonateAccount", [address]);
3168
+ return provider.getSignerWithAddress(address);
3169
+ }
3170
+ async function unlockAllWhales() {
3171
+ const keys = Object.keys(whales);
3172
+ const signers = await Promise.all(keys.map(async (token) => unlockWhale(token)));
3173
+ const initial = {};
3174
+ return keys.reduce((carry, key, index) => {
3175
+ return __spreadProps(__spreadValues({}, carry), { [key]: signers[index] });
3176
+ }, initial);
3177
+ }
3178
+ async function unlockWhales(...tokens) {
3179
+ const signers = await Promise.all(tokens.map(async (token) => unlockWhale(token)));
3180
+ const initial = {};
3181
+ return tokens.reduce((carry, key, index) => {
3182
+ return __spreadProps(__spreadValues({}, carry), { [key]: signers[index] });
3183
+ }, initial);
3184
+ }
3185
+
3186
+
3187
+
3188
+
3189
+
3190
+
3191
+
3192
+
3193
+
3194
+
3195
+
3196
+
3197
+
3198
+
3199
+
3200
+
3201
+
3202
+
3203
+
3204
+
3205
+
3206
+
3207
+
3208
+
3209
+
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
3216
+
3217
+
3218
+
3219
+
3220
+
3221
+
3222
+
3223
+
3224
+
3225
+
3226
+
3227
+
3228
+
3229
+
3230
+
3231
+
3232
+
3233
+
3234
+
3235
+
3236
+
3237
+
3238
+
3239
+
3240
+
3241
+
3242
+
3243
+
3244
+
3245
+
3246
+
3247
+
3248
+
3249
+
3250
+
3251
+
3252
+
3253
+
3254
+
3255
+
3256
+
3257
+
3258
+
3259
+
3260
+
3261
+
3262
+
3263
+
3264
+
3265
+
3266
+
3267
+
3268
+
3269
+
3270
+
3271
+
3272
+
3273
+
3274
+
3275
+
3276
+
3277
+
3278
+
3279
+
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+
3287
+
3288
+
3289
+
3290
+
3291
+
3292
+
3293
+
3294
+
3295
+
3296
+
3297
+
3298
+
3299
+
3300
+
3301
+
3302
+
3303
+
3304
+
3305
+
3306
+
3307
+
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3317
+
3318
+
3319
+
3320
+
3321
+
3322
+
3323
+
3324
+
3325
+
3326
+
3327
+
3328
+
3329
+
3330
+
3331
+
3332
+
3333
+
3334
+
3335
+
3336
+
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+ exports.CurveLiquidityGaugeV2 = CurveLiquidityGaugeV2; exports.CurveMinter = CurveMinter; exports.CurveRegistry = CurveRegistry; exports.CurveSwaps = CurveSwaps; exports.ICompoundComptroller = ICompoundComptroller; exports.IConvexBaseRewardPool = IConvexBaseRewardPool; exports.IConvexCrvDepositor = IConvexCrvDepositor; exports.IConvexCvxLocker = IConvexCvxLocker; exports.IConvexVlCvxExtraRewardDistribution = IConvexVlCvxExtraRewardDistribution; exports.ILiquityHintHelper = ILiquityHintHelper; exports.ILiquitySortedTroves = ILiquitySortedTroves; exports.ILiquityTroveManager = ILiquityTroveManager; exports.ISnapshotDelegateRegistry = ISnapshotDelegateRegistry; exports.IUniswapV3NonFungibleTokenManager = IUniswapV3NonFungibleTokenManager; exports.IVotiumMultiMerkleStash = IVotiumMultiMerkleStash; exports.UniswapV2Factory = UniswapV2Factory; exports.UniswapV3FeeAmount = UniswapV3FeeAmount; exports.aaveDebtPositionAddCollateral = aaveDebtPositionAddCollateral; exports.aaveDebtPositionBorrow = aaveDebtPositionBorrow; exports.aaveDebtPositionClaimRewards = aaveDebtPositionClaimRewards; exports.aaveDebtPositionRemoveCollateral = aaveDebtPositionRemoveCollateral; exports.aaveDebtPositionRepayBorrow = aaveDebtPositionRepayBorrow; exports.aaveLend = aaveLend; exports.aaveRedeem = aaveRedeem; exports.addNewAssetsToFund = addNewAssetsToFund; exports.addTrackedAssetsToVault = addTrackedAssetsToVault; exports.assertCompoundLend = assertCompoundLend; exports.assertCompoundRedeem = assertCompoundRedeem; exports.assertDidRelay = assertDidRelay; exports.assertDidRelaySuccessfully = assertDidRelaySuccessfully; exports.assertDidRelayWithCharge = assertDidRelayWithCharge; exports.assertDidRelayWithError = assertDidRelayWithError; exports.assertEvent = assertEvent; exports.assertNoEvent = assertNoEvent; exports.assertPaymasterDidReject = assertPaymasterDidReject; exports.assertPaymasterDidRejectForReason = assertPaymasterDidRejectForReason; exports.buyShares = buyShares; exports.buySharesFunction = buySharesFunction; exports.calcMlnValueAndBurnAmountForSharesBuyback = calcMlnValueAndBurnAmountForSharesBuyback; exports.callOnExtension = callOnExtension; exports.callOnExternalPosition = callOnExternalPosition; exports.compoundClaim = compoundClaim; exports.compoundDebtPositionAddCollateral = compoundDebtPositionAddCollateral; exports.compoundDebtPositionBorrow = compoundDebtPositionBorrow; exports.compoundDebtPositionClaimComp = compoundDebtPositionClaimComp; exports.compoundDebtPositionRemoveCollateral = compoundDebtPositionRemoveCollateral; exports.compoundDebtPositionRepayBorrow = compoundDebtPositionRepayBorrow; exports.compoundLend = compoundLend; exports.compoundRedeem = compoundRedeem; exports.convexVotingPositionClaimRewards = convexVotingPositionClaimRewards; exports.convexVotingPositionDelegate = convexVotingPositionDelegate; exports.convexVotingPositionLock = convexVotingPositionLock; exports.convexVotingPositionRelock = convexVotingPositionRelock; exports.convexVotingPositionWithdraw = convexVotingPositionWithdraw; exports.createAaveDebtPosition = createAaveDebtPosition; exports.createCompoundDebtPosition = createCompoundDebtPosition; exports.createComptrollerProxy = createComptrollerProxy; exports.createConvexVotingPosition = createConvexVotingPosition; exports.createExternalPosition = createExternalPosition; exports.createFundDeployer = createFundDeployer; exports.createLiquityDebtPosition = createLiquityDebtPosition; exports.createMapleLiquidityPosition = createMapleLiquidityPosition; exports.createMigrationRequest = createMigrationRequest; exports.createMockExternalPosition = createMockExternalPosition; exports.createNewFund = createNewFund; exports.createReconfigurationRequest = createReconfigurationRequest; exports.createTheGraphDelegationPosition = createTheGraphDelegationPosition; exports.createUniswapV3LiquidityPosition = createUniswapV3LiquidityPosition; exports.createVaultProxy = createVaultProxy; exports.curveClaimRewards = curveClaimRewards; exports.curveLend = curveLend; exports.curveLendAndStake = curveLendAndStake; exports.curveRedeem = curveRedeem; exports.curveStake = curveStake; exports.curveTakeOrder = curveTakeOrder; exports.curveUnstake = curveUnstake; exports.curveUnstakeAndRedeem = curveUnstakeAndRedeem; exports.deployProtocolFixture = deployProtocolFixture; exports.deploySharesSplitter = deploySharesSplitter; exports.generateFeeManagerConfigWithMockFees = generateFeeManagerConfigWithMockFees; exports.generateMerkleTreeForContractProof = generateMerkleTreeForContractProof; exports.generateMockFees = generateMockFees; exports.generateMockPolicies = generateMockPolicies; exports.generatePolicyManagerConfigWithMockPolicies = generatePolicyManagerConfigWithMockPolicies; exports.getAssetBalances = getAssetBalances; exports.getAssetUnit = getAssetUnit; exports.getNamedSigner = getNamedSigner; exports.getUnnamedSigners = getUnnamedSigners; exports.idleClaimRewards = idleClaimRewards; exports.idleLend = idleLend; exports.idleRedeem = idleRedeem; exports.impersonateContractSigner = impersonateContractSigner; exports.impersonateSigner = impersonateSigner; exports.liquityCalcHints = liquityCalcHints; exports.liquityDebtPositionAddCollateral = liquityDebtPositionAddCollateral; exports.liquityDebtPositionBorrow = liquityDebtPositionBorrow; exports.liquityDebtPositionCloseTrove = liquityDebtPositionCloseTrove; exports.liquityDebtPositionOpenTrove = liquityDebtPositionOpenTrove; exports.liquityDebtPositionRemoveCollateral = liquityDebtPositionRemoveCollateral; exports.liquityDebtPositionRepay = liquityDebtPositionRepay; exports.mapleLiquidityPositionClaimInterest = mapleLiquidityPositionClaimInterest; exports.mapleLiquidityPositionClaimRewards = mapleLiquidityPositionClaimRewards; exports.mapleLiquidityPositionIntendToRedeem = mapleLiquidityPositionIntendToRedeem; exports.mapleLiquidityPositionLend = mapleLiquidityPositionLend; exports.mapleLiquidityPositionLendAndStake = mapleLiquidityPositionLendAndStake; exports.mapleLiquidityPositionRedeem = mapleLiquidityPositionRedeem; exports.mapleLiquidityPositionStake = mapleLiquidityPositionStake; exports.mapleLiquidityPositionUnstake = mapleLiquidityPositionUnstake; exports.mapleLiquidityPositionUnstakeAndRedeem = mapleLiquidityPositionUnstakeAndRedeem; exports.mockExternalPositionAddDebtAssets = mockExternalPositionAddDebtAssets; exports.mockExternalPositionAddManagedAssets = mockExternalPositionAddManagedAssets; exports.mockExternalPositionRemoveDebtAssets = mockExternalPositionRemoveDebtAssets; exports.mockExternalPositionRemoveManagedAssets = mockExternalPositionRemoveManagedAssets; exports.mockGenericRemoveOnlySelector = mockGenericRemoveOnlySelector; exports.mockGenericSwap = mockGenericSwap; exports.mockGenericSwapASelector = mockGenericSwapASelector; exports.mockGenericSwapArgs = mockGenericSwapArgs; exports.mockGenericSwapBSelector = mockGenericSwapBSelector; exports.mockGenericSwapDirectFromVaultSelector = mockGenericSwapDirectFromVaultSelector; exports.mockGenericSwapViaApprovalSelector = mockGenericSwapViaApprovalSelector; exports.olympusV2Stake = olympusV2Stake; exports.olympusV2Unstake = olympusV2Unstake; exports.paraSwapV5GenerateDummyPaths = paraSwapV5GenerateDummyPaths; exports.paraSwapV5TakeOrder = paraSwapV5TakeOrder; exports.poolTogetherV4ClaimRewards = poolTogetherV4ClaimRewards; exports.poolTogetherV4Lend = poolTogetherV4Lend; exports.poolTogetherV4Redeem = poolTogetherV4Redeem; exports.reactivateExternalPosition = reactivateExternalPosition; exports.redeemSharesForSpecificAssets = redeemSharesForSpecificAssets; exports.redeemSharesInKind = redeemSharesInKind; exports.relayTransaction = relayTransaction; exports.removeExternalPosition = removeExternalPosition; exports.removeTrackedAssetsFromVault = removeTrackedAssetsFromVault; exports.sendEthBySelfDestruct = sendEthBySelfDestruct; exports.setupGasRelayerPaymaster = setupGasRelayerPaymaster; exports.synthetixAssignExchangeDelegate = synthetixAssignExchangeDelegate; exports.synthetixRedeem = synthetixRedeem; exports.synthetixTakeOrder = synthetixTakeOrder; exports.theGraphDelegationPositionDelegate = theGraphDelegationPositionDelegate; exports.theGraphDelegationPositionUndelegate = theGraphDelegationPositionUndelegate; exports.theGraphDelegationPositionWithdraw = theGraphDelegationPositionWithdraw; exports.transactionTimestamp = transactionTimestamp; exports.uniswapV2Lend = uniswapV2Lend; exports.uniswapV2Redeem = uniswapV2Redeem; exports.uniswapV2TakeOrder = uniswapV2TakeOrder; exports.uniswapV3LiquidityPositionAddLiquidity = uniswapV3LiquidityPositionAddLiquidity; exports.uniswapV3LiquidityPositionCollect = uniswapV3LiquidityPositionCollect; exports.uniswapV3LiquidityPositionGetMaxTick = uniswapV3LiquidityPositionGetMaxTick; exports.uniswapV3LiquidityPositionGetMinTick = uniswapV3LiquidityPositionGetMinTick; exports.uniswapV3LiquidityPositionMint = uniswapV3LiquidityPositionMint; exports.uniswapV3LiquidityPositionPurge = uniswapV3LiquidityPositionPurge; exports.uniswapV3LiquidityPositionRemoveLiquidity = uniswapV3LiquidityPositionRemoveLiquidity; exports.uniswapV3OrderTokenPair = uniswapV3OrderTokenPair; exports.uniswapV3TakeOrder = uniswapV3TakeOrder; exports.unlockAllWhales = unlockAllWhales; exports.unlockWhale = unlockWhale; exports.unlockWhales = unlockWhales; exports.updateChainlinkAggregator = updateChainlinkAggregator; exports.vaultCallCreateNewList = vaultCallCreateNewList; exports.vaultCallCurveMinterMint = vaultCallCurveMinterMint; exports.vaultCallCurveMinterMintMany = vaultCallCurveMinterMintMany; exports.vaultCallCurveMinterToggleApproveMint = vaultCallCurveMinterToggleApproveMint; exports.vaultCallStartAssetBypassTimelock = vaultCallStartAssetBypassTimelock; exports.yearnVaultV2Lend = yearnVaultV2Lend; exports.yearnVaultV2Redeem = yearnVaultV2Redeem; exports.zeroExV2TakeOrder = zeroExV2TakeOrder;