@@ -7,17 +7,27 @@ import {TickHelpers} from "@src/lib/TickHelpers.sol";
7
7
import {UniswapV3PoolUpgradeable, IUniswapV3Pool} from "@uni-core/UniswapV3PoolUpgradeable.sol " ;
8
8
import {INFTXRouter} from "@src/NFTXRouter.sol " ;
9
9
import {INFTXFeeDistributorV3} from "@src/interfaces/INFTXFeeDistributorV3.sol " ;
10
+ import {Pausable} from "@src/custom/Pausable.sol " ;
10
11
11
12
import {TestBase} from "@test/TestBase.sol " ;
12
13
13
14
contract NFTXFeeDistributorV3Tests is TestBase {
15
+ uint256 constant DISTRIBUTE_LOCK_ID = 0 ;
16
+ uint256 constant DISTRIBUTE_VTOKENS_LOCK_ID = 1 ;
17
+
14
18
event AddFeeReceiver (address receiver , uint256 allocPoint );
15
19
event UpdateFeeReceiverAlloc (address receiver , uint256 allocPoint );
16
20
event UpdateFeeReceiverAddress (address oldReceiver , address newReceiver );
17
21
event RemoveFeeReceiver (address receiver );
18
22
event UpdateTreasuryAddress (address oldTreasury , address newTreasury );
19
23
event PauseDistribution (bool paused );
20
24
25
+ // constructor
26
+
27
+ function test_feeDistributor_constructor () external {
28
+ assertEq (feeDistributor.owner (), address (this ));
29
+ }
30
+
21
31
// UniswapV3FactoryUpgradeable#setFeeDistributor
22
32
23
33
function test_setFeeDistributor_RevertsForNonOwner () external {
@@ -52,27 +62,28 @@ contract NFTXFeeDistributorV3Tests is TestBase {
52
62
53
63
// FeeDistributor#distribute
54
64
55
- function test_feeDistribuion_whenDistributionPaused () external {
65
+ function test_feeDistribution_whenDistributionPaused () external {
56
66
_mintPosition (1 );
57
67
58
- // Pause distribution
59
- feeDistributor.pauseFeeDistribution (true );
60
- assertEq (feeDistributor.distributionPaused (), true );
68
+ // add to guardians
69
+ feeDistributor.setIsGuardian (address (this ), true );
61
70
62
- uint256 preTreasuryWethBalance = weth.balanceOf (TREASURY);
71
+ // Pause distribution
72
+ feeDistributor.pause (DISTRIBUTE_LOCK_ID);
73
+ assertEq (feeDistributor.isPaused (DISTRIBUTE_LOCK_ID), true );
63
74
64
75
uint256 wethFees = 2 ether ;
65
76
66
77
// distribute fees
67
78
weth.deposit {value: wethFees}();
68
79
weth.transfer (address (feeDistributor), wethFees);
69
- feeDistributor.distribute (0 );
70
80
71
- uint256 postTreasuryWethBalance = weth.balanceOf (TREASURY);
72
- assertEq (postTreasuryWethBalance - preTreasuryWethBalance, wethFees);
81
+ hoax (makeAddr ("nonOwner " ));
82
+ vm.expectRevert (Pausable.Paused.selector );
83
+ feeDistributor.distribute (0 );
73
84
}
74
85
75
- function test_feeDistribuion_whenZeroAllocTotal () external {
86
+ function test_feeDistribution_whenZeroAllocTotal () external {
76
87
_mintPosition (1 );
77
88
78
89
// Remove all receivers
@@ -271,6 +282,36 @@ contract NFTXFeeDistributorV3Tests is TestBase {
271
282
console.log ("ETH received " , ethReceived);
272
283
}
273
284
285
+ // FeeDistributor#distributeVTokensToPool
286
+
287
+ function test_distributeVTokensToPool_whenPaused () external {
288
+ // minting so that Pool is deployed
289
+ _mintPosition (1 );
290
+
291
+ // add to guardians
292
+ feeDistributor.setIsGuardian (address (this ), true );
293
+
294
+ // Pause distribution
295
+ feeDistributor.pause (DISTRIBUTE_VTOKENS_LOCK_ID);
296
+ assertEq (feeDistributor.isPaused (DISTRIBUTE_VTOKENS_LOCK_ID), true );
297
+
298
+ (uint256 mintedVTokens , ) = _mintVToken ({
299
+ qty: 1 ,
300
+ depositor: address (this ),
301
+ receiver: address (feeDistributor)
302
+ });
303
+
304
+ address pool = nftxRouter.getPool (address (vtoken), DEFAULT_FEE_TIER);
305
+
306
+ hoax (makeAddr ("nonOwner " ));
307
+ vm.expectRevert (Pausable.Paused.selector );
308
+ feeDistributor.distributeVTokensToPool ({
309
+ pool: pool,
310
+ vToken: address (vtoken),
311
+ vTokenAmount: mintedVTokens
312
+ });
313
+ }
314
+
274
315
// FeeDistributor#setTreasuryAddress
275
316
276
317
function test_setTreasuryAddress_RevertsForNonOwner () external {
@@ -324,30 +365,6 @@ contract NFTXFeeDistributorV3Tests is TestBase {
324
365
assertEq (postNFTXRouter, newNFTXRouter);
325
366
}
326
367
327
- // FeeDistributor#pauseFeeDistribution
328
-
329
- function test_pauseFeeDistribution_RevertsForNonOwner () external {
330
- bool newPause = true ;
331
-
332
- hoax (makeAddr ("nonOwner " ));
333
- vm.expectRevert ("Ownable: caller is not the owner " );
334
- feeDistributor.pauseFeeDistribution (newPause);
335
- }
336
-
337
- function test_pauseFeeDistribution_Success () external {
338
- bool preDistributionPaused = feeDistributor.distributionPaused ();
339
-
340
- bool newPause = ! preDistributionPaused;
341
-
342
- vm.expectEmit (false , false , false , true );
343
- emit PauseDistribution (newPause);
344
- feeDistributor.pauseFeeDistribution (newPause);
345
-
346
- bool postDistributionPaused = feeDistributor.distributionPaused ();
347
-
348
- assertEq (postDistributionPaused, newPause);
349
- }
350
-
351
368
// FeeDistributor#rescueTokens
352
369
353
370
function test_rescueTokens_RevertsForNonOwner () external {
0 commit comments