Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
haythemsellami committed May 29, 2024
1 parent 801fd3d commit dd28b15
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
14 changes: 1 addition & 13 deletions src/FourSixTwoSixAgg.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {AccessControlEnumerable} from "@openzeppelin/access/AccessControlEnumera
import {EVCUtil, IEVC} from "ethereum-vault-connector/utils/EVCUtil.sol";
import {BalanceForwarder} from "./BalanceForwarder.sol";

import {Test, console2, stdError} from "forge-std/Test.sol";

/// @dev Do NOT use with fee on transfer tokens
/// @dev Do NOT use with rebasing tokens
/// @dev Based on https://github.com/euler-xyz/euler-vault-kit/blob/master/src/Synths/EulerSavingsRate.sol
Expand Down Expand Up @@ -425,8 +423,6 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
/// @dev the total assets allocatable is the amount of assets deposited into the aggregator + assets already deposited into strategies
/// @return uint256 total assets
function totalAssetsAllocatable() public view returns (uint256) {
console2.log("this balanceOf", IERC20(asset()).balanceOf(address(this)));
console2.log("totalAllocated", totalAllocated);
return IERC20(asset()).balanceOf(address(this)) + totalAllocated;
}

Expand All @@ -449,7 +445,6 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
totalAssetsDeposited -= assets;

uint256 assetsRetrieved = IERC20(asset()).balanceOf(address(this));
console2.log("assetsRetrieved", assetsRetrieved);
uint256 numStrategies = withdrawalQueue.length;
for (uint256 i; i < numStrategies; ++i) {
if (assetsRetrieved >= assets) {
Expand Down Expand Up @@ -478,23 +473,18 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
// Do actual withdraw from strategy
strategy.withdraw(withdrawAmount, address(this), address(this));
}
console2.log("assetsRetrieved done", assetsRetrieved);

_gulp();

console2.log("here");
if (assetsRetrieved < assets) {
revert NotEnoughAssets();
}
console2.log("shares", shares);

super._withdraw(caller, receiver, owner, assets, shares);
}

function _gulp() internal {
ESRSlot memory esrSlotCache = updateInterestAndReturnESRSlotCache();
console2.log("totalAssetsAllocatable()", totalAssetsAllocatable());
console2.log("totalAssetsDeposited", totalAssetsDeposited);
console2.log("esrSlotCache.interestLeft", esrSlotCache.interestLeft);

if (totalAssetsDeposited == 0) return;
uint256 toGulp = totalAssetsAllocatable() - totalAssetsDeposited - esrSlotCache.interestLeft;
Expand Down Expand Up @@ -592,8 +582,6 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
strategies[strategy].allocated = uint120(underlyingBalance);
totalAllocated += yield;

console2.log("yield", yield);

_accruePerformanceFee(yield);
} else {
// TODO handle losses
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/PerformanceFeeE2ETest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ contract PerformanceFeeE2ETest is FourSixTwoSixAggBase {
vm.prank(user1);
fourSixTwoSixAgg.redeem(amountToWithdraw, user1, user1);

// all yield is distributed
// assertApproxEqAbs(eTST.balanceOf(address(fourSixTwoSixAgg)), expectePerformanceFeeAssets, 1);
assertApproxEqAbs(fourSixTwoSixAgg.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedAssetTST, 1);
assertEq(fourSixTwoSixAgg.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw);
assertApproxEqAbs(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + expectedAssetTST, 1);
Expand All @@ -136,8 +134,6 @@ contract PerformanceFeeE2ETest is FourSixTwoSixAggBase {
vm.prank(feeRecipient);
fourSixTwoSixAgg.redeem(feeShares, feeRecipient, feeRecipient);

// all yield is distributed
// assertApproxEqAbs(eTST.balanceOf(address(fourSixTwoSixAgg)), 0, 1);
assertApproxEqAbs(fourSixTwoSixAgg.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedAssets, 1);
assertEq(fourSixTwoSixAgg.totalSupply(), 0);
assertApproxEqAbs(assetTST.balanceOf(feeRecipient), assetTSTBalanceBefore + expectedAssets, 1);
Expand Down

0 comments on commit dd28b15

Please sign in to comment.