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