Skip to content

Commit

Permalink
fix invariant_votingPower
Browse files Browse the repository at this point in the history
  • Loading branch information
haythemsellami committed Jul 22, 2024
1 parent 0ab9e1c commit 45ff916
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/invariant/EulerAggregationLayerInvariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract EulerAggregationVaultInvariants is EulerAggregationVaultBase {
function setUp() public override {
super.setUp();

actorUtil = new Actor();
actorUtil = new Actor(address(eulerAggregationVault));
actorUtil.includeActor(manager);
actorUtil.includeActor(deployer);
actorUtil.includeActor(user1);
Expand Down Expand Up @@ -76,7 +76,9 @@ contract EulerAggregationVaultInvariants is EulerAggregationVaultBase {
skip(eulerAggregationVault.INTEREST_SMEAR()); // make sure smear has passed
eulerAggregationVault.updateInterestAccrued();

assertEq(eulerAggregationVault.totalAssets(), eulerAggregationVault.totalAssetsAllocatable());
if (eulerAggregationVault.totalSupply() >= eulerAggregationVault.MIN_SHARES_FOR_GULP()) {
assertEq(eulerAggregationVault.totalAssets(), eulerAggregationVault.totalAssetsAllocatable());
}
}

// total allocation points should be equal to the sum of the allocation points of all strategies.
Expand Down
8 changes: 8 additions & 0 deletions test/invariant/handler/EulerAggregationVaultHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ contract EulerAggregationVaultHandler is Test {

(currentActor, currentActorIndex) = actorUtil.fetchActor(_actorIndexSeed);

if (eulerAggVault.totalSupply() == 0) {
uint256 minAssets = eulerAggVault.previewMint(eulerAggVault.MIN_SHARES_FOR_GULP());
vm.assume(_assets >= minAssets);
}
_fillBalance(currentActor, eulerAggVault.asset(), _assets);

(currentActor, success, returnData) = actorUtil.initiateExactActorCall(
Expand All @@ -288,6 +292,10 @@ contract EulerAggregationVaultHandler is Test {

(currentActor, currentActorIndex) = actorUtil.fetchActor(_actorIndexSeed);

if (eulerAggVault.totalSupply() == 0) {
vm.assume(_shares >= eulerAggVault.MIN_SHARES_FOR_GULP());
}

uint256 assets = eulerAggVault.previewMint(_shares);
_fillBalance(currentActor, eulerAggVault.asset(), assets);

Expand Down
10 changes: 10 additions & 0 deletions test/invariant/util/Actor.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
import {Test} from "forge-std/Test.sol";

contract Actor is Test {
address eulerAggregationVault;

/// @dev actor[0] will always be a manager address that have access to all EulerAggregationVault roles.
address[] public actors;

constructor(address _eulerAggregationVault) {
eulerAggregationVault = _eulerAggregationVault;
}

function includeActor(address _actor) external {
actors.push(_actor);

vm.prank(_actor);
IVotes(eulerAggregationVault).delegate(_actor);
}

function initiateExactActorCall(uint256 _actorIndex, address _target, bytes memory _calldata)
Expand Down

0 comments on commit 45ff916

Please sign in to comment.