@@ -43,7 +43,6 @@ describe("GeneralIndexModule", () => {
43
43
44
44
let index : SetToken ;
45
45
let indexWithWeth : SetToken ;
46
- let indexWithPositionModule : SetToken ;
47
46
let indexModule : GeneralIndexModule ;
48
47
49
48
let balancerExchangeAdapter : BalancerV1IndexExchangeAdapter ;
@@ -111,7 +110,7 @@ describe("GeneralIndexModule", () => {
111
110
index = await setup . createSetToken (
112
111
indexComponents ,
113
112
indexUnits , // $100 of each
114
- [ setup . issuanceModule . address , setup . streamingFeeModule . address , indexModule . address ] ,
113
+ [ setup . issuanceModule . address , setup . streamingFeeModule . address , indexModule . address , positionModule . address ] ,
115
114
) ;
116
115
117
116
const feeSettings = {
@@ -123,13 +122,7 @@ describe("GeneralIndexModule", () => {
123
122
124
123
await setup . streamingFeeModule . initialize ( index . address , feeSettings ) ;
125
124
await setup . issuanceModule . initialize ( index . address , ADDRESS_ZERO ) ;
126
-
127
- indexWithPositionModule = await setup . createSetToken (
128
- indexComponents ,
129
- indexUnits ,
130
- [ positionModule . address , indexModule . address ]
131
- ) ;
132
- await indexWithPositionModule . connect ( positionModule . wallet ) . initializeModule ( ) ;
125
+ await index . connect ( positionModule . wallet ) . initializeModule ( ) ;
133
126
134
127
indexWithWethComponents = [ uniswapSetup . uni . address , setup . wbtc . address , setup . dai . address , setup . weth . address ] ;
135
128
indexWithWethUnits = [ ether ( 86.9565217 ) , bitcoin ( .01111111 ) , ether ( 100 ) , ether ( 0.434782609 ) ] ;
@@ -256,25 +249,24 @@ describe("GeneralIndexModule", () => {
256
249
} ) ;
257
250
258
251
describe ( "when there are external positions for a component" , async ( ) => {
259
- beforeEach ( async ( ) => {
260
- subjectSetToken = indexWithPositionModule ;
261
- await subjectSetToken . connect ( positionModule . wallet ) . addExternalPositionModule (
262
- indexComponents [ 0 ] ,
263
- positionModule . address
264
- ) ;
265
- } ) ;
252
+ beforeEach ( async ( ) => {
253
+ await subjectSetToken . connect ( positionModule . wallet ) . addExternalPositionModule (
254
+ indexComponents [ 0 ] ,
255
+ positionModule . address
256
+ ) ;
257
+ } ) ;
266
258
267
- afterEach ( async ( ) => {
268
- await subjectSetToken . connect ( positionModule . wallet ) . removeExternalPositionModule (
269
- indexComponents [ 0 ] ,
270
- positionModule . address
271
- ) ;
272
- } ) ;
259
+ afterEach ( async ( ) => {
260
+ await subjectSetToken . connect ( positionModule . wallet ) . removeExternalPositionModule (
261
+ indexComponents [ 0 ] ,
262
+ positionModule . address
263
+ ) ;
264
+ } ) ;
273
265
274
- it ( "should revert" , async ( ) => {
275
- await expect ( subject ( ) ) . to . be . revertedWith ( "External positions not allowed" ) ;
276
- } ) ;
266
+ it ( "should revert" , async ( ) => {
267
+ await expect ( subject ( ) ) . to . be . revertedWith ( "External positions not allowed" ) ;
277
268
} ) ;
269
+ } ) ;
278
270
} ) ;
279
271
280
272
describe ( "when module is initalized" , async ( ) => {
@@ -313,14 +305,6 @@ describe("GeneralIndexModule", () => {
313
305
[ uniswapAdapterName , sushiswapAdapterName , balancerAdapterName , "" , sushiswapAdapterName ] ,
314
306
[ ONE_MINUTE_IN_SECONDS . mul ( 3 ) , ONE_MINUTE_IN_SECONDS , ONE_MINUTE_IN_SECONDS . mul ( 2 ) , ZERO , ONE_MINUTE_IN_SECONDS ] ,
315
307
) ;
316
-
317
- await initSetToken (
318
- indexWithPositionModule ,
319
- [ uniswapSetup . uni . address , setup . wbtc . address , setup . dai . address , sushiswapSetup . uni . address ] ,
320
- [ ether ( 800 ) , bitcoin ( .1 ) , ether ( 1000 ) , ether ( 500 ) ] ,
321
- [ uniswapAdapterName , sushiswapAdapterName , balancerAdapterName , sushiswapAdapterName ] ,
322
- [ ONE_MINUTE_IN_SECONDS . mul ( 3 ) , ONE_MINUTE_IN_SECONDS , ONE_MINUTE_IN_SECONDS . mul ( 2 ) , ONE_MINUTE_IN_SECONDS ]
323
- ) ;
324
308
} ) ;
325
309
326
310
describe ( "#startRebalance" , async ( ) => {
@@ -411,8 +395,6 @@ describe("GeneralIndexModule", () => {
411
395
412
396
describe ( "when there are external positions for a component" , async ( ) => {
413
397
beforeEach ( async ( ) => {
414
- subjectSetToken = indexWithPositionModule ;
415
-
416
398
await subjectSetToken . connect ( positionModule . wallet ) . addExternalPositionModule (
417
399
subjectNewComponents [ 0 ] ,
418
400
positionModule . address
@@ -427,7 +409,7 @@ describe("GeneralIndexModule", () => {
427
409
} ) ;
428
410
429
411
it ( "should revert" , async ( ) => {
430
- await expect ( subject ( ) ) . to . be . revertedWith ( "External positions not allowed" ) ;
412
+ await expect ( subject ( ) ) . to . be . revertedWith ( "External positions not allowed" ) ;
431
413
} ) ;
432
414
} ) ;
433
415
} ) ;
@@ -1081,6 +1063,26 @@ describe("GeneralIndexModule", () => {
1081
1063
} ) ;
1082
1064
} ) ;
1083
1065
1066
+ describe ( "when there are external positions for a component" , async ( ) => {
1067
+ beforeEach ( async ( ) => {
1068
+ await subjectSetToken . connect ( positionModule . wallet ) . addExternalPositionModule (
1069
+ subjectComponent ,
1070
+ positionModule . address
1071
+ ) ;
1072
+ } ) ;
1073
+
1074
+ afterEach ( async ( ) => {
1075
+ await subjectSetToken . connect ( positionModule . wallet ) . removeExternalPositionModule (
1076
+ subjectComponent ,
1077
+ positionModule . address
1078
+ ) ;
1079
+ } ) ;
1080
+
1081
+ it ( "should revert" , async ( ) => {
1082
+ await expect ( subject ( ) ) . to . be . revertedWith ( "External positions not allowed" ) ;
1083
+ } ) ;
1084
+ } ) ;
1085
+
1084
1086
describe ( "when caller is a contract" , async ( ) => {
1085
1087
let subjectTarget : Address ;
1086
1088
let subjectCallData : string ;
@@ -1662,6 +1664,26 @@ describe("GeneralIndexModule", () => {
1662
1664
} ) ;
1663
1665
} ) ;
1664
1666
1667
+ describe ( "when there are external positions for a component" , async ( ) => {
1668
+ beforeEach ( async ( ) => {
1669
+ await subjectSetToken . connect ( positionModule . wallet ) . addExternalPositionModule (
1670
+ subjectComponent ,
1671
+ positionModule . address
1672
+ ) ;
1673
+ } ) ;
1674
+
1675
+ afterEach ( async ( ) => {
1676
+ await subjectSetToken . connect ( positionModule . wallet ) . removeExternalPositionModule (
1677
+ subjectComponent ,
1678
+ positionModule . address
1679
+ ) ;
1680
+ } ) ;
1681
+
1682
+ it ( "should revert" , async ( ) => {
1683
+ await expect ( subject ( ) ) . to . be . revertedWith ( "External positions not allowed" ) ;
1684
+ } ) ;
1685
+ } ) ;
1686
+
1665
1687
describe ( "when the calling address is not a permissioned address" , async ( ) => {
1666
1688
beforeEach ( async ( ) => {
1667
1689
subjectCaller = await getRandomAccount ( ) ;
0 commit comments