Skip to content

Commit

Permalink
add more beefy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trmid committed Jul 9, 2024
1 parent 9cfb528 commit 28a648d
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 3 deletions.
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ max_test_rejects = 100000
runs = 100
max_test_rejects = 1000

[profile.cancun]
evm_version = "cancun"

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
arbitrum = "${ARBITRUM_RPC_URL}"
Expand Down
78 changes: 78 additions & 0 deletions test/integration/beefy/BeefyBaseAeroWethVlp.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { BaseIntegration, IERC20, IERC4626 } from "../BaseIntegration.t.sol";

contract BeefyBaseAeroWethVlpIntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 16873531;
uint256 forkBlockTimestamp = 1720536409;

address internal _beefyWrapper = address(0x917447f8f52E7Db26cE7f52BE2F3fcb4d4D00832);

address internal _asset = address(0x6cDcb1C4A4D1C3C6d054b27AC5B77e89eAFb971d);
address internal _assetWhale = address(0xc1342eE2B9d9E8f1B7A612131b69cf03261957E0);
address internal _yieldVault;
address internal _mooVault = address(0xc005B9833deBcF5fe6cc5bC9ba4fD74Bb382ae55);
address internal _mooYieldSource = address(0xedE4Dd6758634007Eb1f4cF8A203bf237A44ea4C);

/* ============ setup ============ */

function setUpUnderlyingAsset() public virtual override returns (IERC20 asset, uint8 decimals, uint256 approxAssetUsdExchangeRate) {
return (IERC20(_asset), 18, 82460000e18);
}

function setUpYieldVault() public virtual override returns (IERC4626) {
(bool success, bytes memory data) = _beefyWrapper.call(abi.encodeWithSignature("clone(address)", _mooVault));
require(success, "beefy vault wrapper failed");
(_yieldVault) = abi.decode(data, (address));
return IERC4626(_yieldVault);
}

function setUpFork() public virtual override {
fork = vm.createFork(vm.rpcUrl("base"), forkBlock);
vm.selectFork(fork);
vm.warp(forkBlockTimestamp);
}

function beforeSetup() public virtual override {
assetPrecisionLoss = 1; // rounding errors exceed 1 wei, so a slightly larger yield buffer should be used for consistency
lowGasPriceEstimate = 0.05 gwei; // just L2 gas, we ignore L1 costs for a super low estimate
ignoreLoss = true; // loss would occur on the LP token, not the reward contract
}

function afterSetup() public virtual override { }

/* ============ helpers to override ============ */

/// @dev The max amount of assets than can be dealt.
function maxDeal() public virtual override returns (uint256) {
return underlyingAsset.balanceOf(_assetWhale);
}

/// @dev May revert if the amount requested exceeds the amount available to deal.
function dealAssets(address to, uint256 amount) public virtual override prankception(_assetWhale) {
underlyingAsset.transfer(to, amount);
}

/// @dev Accrues yield by letting time pass and triggering multiple yield accruals
function _accrueYield() internal virtual override prankception(_assetWhale) {
// yield accrues on deposit / withdraw so we can do a deposit and withdraw to the yield vault directly to trigger some yield accrual
uint256 amount = 10 ** (assetDecimals - 1); // some small amount of assets
underlyingAsset.approve(_yieldVault, amount);
yieldVault.deposit(amount, _assetWhale);
vm.warp(block.timestamp + 1 days); // let 1 day pass by
uint256 maxRedeem = yieldVault.maxRedeem(_assetWhale);
yieldVault.redeem(maxRedeem, _assetWhale, _assetWhale);

// we also call a deposit directly on the moo vault to ensure it triggers a yield accrual
underlyingAsset.approve(_mooVault, amount);
(bool success,) = _mooVault.call(abi.encodeWithSignature("deposit(uint256)", amount));
assertEq(success, true, "moo vault deposit success");
}

function _simulateLoss() internal virtual override {

}

}
7 changes: 4 additions & 3 deletions test/integration/beefy/BeefyBaseWellWethVlpV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { BaseIntegration, IERC20, IERC4626 } from "../BaseIntegration.t.sol";

contract BeefyBaseWellWethVlpV2IntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 16358565;
uint256 forkBlockTimestamp = 1719506477;
uint256 forkBlock = 16873531;
uint256 forkBlockTimestamp = 1720536409;

address internal _beefyWrapper = address(0x917447f8f52E7Db26cE7f52BE2F3fcb4d4D00832);

address internal _asset = address(0x89D0F320ac73dd7d9513FFC5bc58D1161452a657);
address internal _assetWhale = address(0x5388b3f735D47eD9a8151e9db01bCFc2b071105a);
address internal _assetWhale = address(0x2E6caE38078d715711Fc6132dF961f653c456CD2);
address internal _yieldVault;
address internal _mooVault = address(0xacDBb7c90C0F764cA7BB5307d18C5b211Fbd9C00);
address internal _mooYieldSource = address(0x5a6859C2f992B998837342d29911dD14E8DC2E1a);
Expand All @@ -36,6 +36,7 @@ contract BeefyBaseWellWethVlpV2IntegrationTest is BaseIntegration {
}

function beforeSetup() public virtual override {
assetPrecisionLoss = 1; // rounding errors exceed 1 wei, so a slightly larger yield buffer should be used for consistency
lowGasPriceEstimate = 0.05 gwei; // just L2 gas, we ignore L1 costs for a super low estimate
ignoreLoss = true; // loss would occur on the LP token, not the reward contract
}
Expand Down
77 changes: 77 additions & 0 deletions test/integration/beefy/BeefyOpBifiWethVlpV2.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { BaseIntegration, IERC20, IERC4626 } from "../BaseIntegration.t.sol";

contract BeefyOpBifiWethVlpV2IntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 122471326;
uint256 forkBlockTimestamp = 1720541429;

address internal _beefyWrapper = address(0x182be93E1C0C4d305fe43bD093292F21fd679797);

address internal _asset = address(0x6Ed6Df1C23C51cb7Cc67a348cC8d9E6108EA3BFE);
address internal _assetWhale = address(0xcFa050836C3E5dfA98D065d2f365Cfd78a9011F9);
address internal _yieldVault;
address internal _mooVault = address(0x57d00d036485B5fEE6A58c8763Bdc358906E6D19);
address internal _mooYieldSource = address(0x9E4342660e95568956Fe51f9AA6273b16d3f6B26);

/* ============ setup ============ */

function setUpUnderlyingAsset() public virtual override returns (IERC20 asset, uint8 decimals, uint256 approxAssetUsdExchangeRate) {
return (IERC20(_asset), 18, 1972e18);
}

function setUpYieldVault() public virtual override returns (IERC4626) {
(bool success, bytes memory data) = _beefyWrapper.call(abi.encodeWithSignature("clone(address)", _mooVault));
require(success, "beefy vault wrapper failed");
(_yieldVault) = abi.decode(data, (address));
return IERC4626(_yieldVault);
}

function setUpFork() public virtual override {
fork = vm.createFork(vm.rpcUrl("optimism"), forkBlock);
vm.selectFork(fork);
vm.warp(forkBlockTimestamp);
}

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.05 gwei; // just L2 gas, we ignore L1 costs for a super low estimate
ignoreLoss = true; // loss would occur on the LP token, not the reward contract
}

function afterSetup() public virtual override { }

/* ============ helpers to override ============ */

/// @dev The max amount of assets than can be dealt.
function maxDeal() public virtual override returns (uint256) {
return underlyingAsset.balanceOf(_assetWhale);
}

/// @dev May revert if the amount requested exceeds the amount available to deal.
function dealAssets(address to, uint256 amount) public virtual override prankception(_assetWhale) {
underlyingAsset.transfer(to, amount);
}

/// @dev Accrues yield by letting time pass and triggering multiple yield accruals
function _accrueYield() internal virtual override prankception(_assetWhale) {
// yield accrues on deposit / withdraw so we can do a deposit and withdraw to the yield vault directly to trigger some yield accrual
uint256 amount = 10 ** (assetDecimals - 1); // some small amount of assets
underlyingAsset.approve(_yieldVault, amount);
yieldVault.deposit(amount, _assetWhale);
vm.warp(block.timestamp + 1 days); // let 1 day pass by
uint256 maxRedeem = yieldVault.maxRedeem(_assetWhale);
yieldVault.redeem(maxRedeem, _assetWhale, _assetWhale);

// we also call a deposit directly on the moo vault to ensure it triggers a yield accrual
underlyingAsset.approve(_mooVault, amount);
(bool success,) = _mooVault.call(abi.encodeWithSignature("deposit(uint256)", amount));
assertEq(success, true, "moo vault deposit success");
}

function _simulateLoss() internal virtual override {

}

}
79 changes: 79 additions & 0 deletions test/integration/beefy/BeefyOpWbtcTbtc.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { BaseIntegration, IERC20, IERC4626 } from "../BaseIntegration.t.sol";

/// NOTE: must be run with evm version set to "cancun" (this can be done by setting the env var FOUNDRY_PROFILE=cancun)

contract BeefyOpWbtcTbtcIntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 122471326;
uint256 forkBlockTimestamp = 1720541429;

address internal _beefyWrapper = address(0x182be93E1C0C4d305fe43bD093292F21fd679797);

address internal _asset = address(0x1Dc5c0f8668a9F54ED922171d578011850ca0341);
address internal _assetWhale = address(0x952815eA349a0c10db5d854a16A27d768e85053e);
address internal _yieldVault;
address internal _mooVault = address(0x611bB2B496c9381CdcD07458b3cfC734583429f9);
address internal _mooYieldSource = address(0x8D8d9aD4EEdbe335B7dA4DEd5Af32808C1032276);

/* ============ setup ============ */

function setUpUnderlyingAsset() public virtual override returns (IERC20 asset, uint8 decimals, uint256 approxAssetUsdExchangeRate) {
return (IERC20(_asset), 18, 57385e18);
}

function setUpYieldVault() public virtual override returns (IERC4626) {
(bool success, bytes memory data) = _beefyWrapper.call(abi.encodeWithSignature("clone(address)", _mooVault));
require(success, "beefy vault wrapper failed");
(_yieldVault) = abi.decode(data, (address));
return IERC4626(_yieldVault);
}

function setUpFork() public virtual override {
fork = vm.createFork(vm.rpcUrl("optimism"), forkBlock);
vm.selectFork(fork);
vm.warp(forkBlockTimestamp);
}

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.05 gwei; // just L2 gas, we ignore L1 costs for a super low estimate
ignoreLoss = true; // loss would occur on the LP token, not the reward contract
}

function afterSetup() public virtual override { }

/* ============ helpers to override ============ */

/// @dev The max amount of assets than can be dealt.
function maxDeal() public virtual override returns (uint256) {
return underlyingAsset.balanceOf(_assetWhale);
}

/// @dev May revert if the amount requested exceeds the amount available to deal.
function dealAssets(address to, uint256 amount) public virtual override prankception(_assetWhale) {
underlyingAsset.transfer(to, amount);
}

/// @dev Accrues yield by letting time pass and triggering multiple yield accruals
function _accrueYield() internal virtual override prankception(_assetWhale) {
// yield accrues on deposit / withdraw so we can do a deposit and withdraw to the yield vault directly to trigger some yield accrual
uint256 amount = maxDeal() / 100; // some small amount of assets
underlyingAsset.approve(_yieldVault, amount);
yieldVault.deposit(amount, _assetWhale);
vm.warp(block.timestamp + 1 days); // let 1 day pass by
uint256 maxRedeem = yieldVault.maxRedeem(_assetWhale);
yieldVault.redeem(maxRedeem, _assetWhale, _assetWhale);

// we also call a deposit directly on the moo vault to ensure it triggers a yield accrual
underlyingAsset.approve(_mooVault, amount);
(bool success,) = _mooVault.call(abi.encodeWithSignature("deposit(uint256)", amount));
assertEq(success, true, "moo vault deposit success");
}

function _simulateLoss() internal virtual override {

}

}

0 comments on commit 28a648d

Please sign in to comment.