-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration test for beefy pool/lusd on base
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 BeefyBasePoolLusdVlpV2IntegrationTest is BaseIntegration { | ||
uint256 fork; | ||
uint256 forkBlock = 18181822; | ||
uint256 forkBlockTimestamp = 1723152991; | ||
|
||
address internal _beefyWrapper = address(0x917447f8f52E7Db26cE7f52BE2F3fcb4d4D00832); | ||
|
||
address internal _asset = address(0x0b15b1d434f86eCaa83d14398C8Db6d162F3921e); | ||
address internal _assetWhale = address(0x5b41A91Cc14496E7fcc381595Dc2680EF71B6462); | ||
address internal _yieldVault; | ||
address internal _mooVault = address(0xbF93166bE905Cb8E3C16bDA16a4eF3c3e46e1C1d); | ||
address internal _mooYieldSource = address(0xb4823f5da6c37301C700C47517afc2A46ebD6c82); | ||
|
||
/* ============ setup ============ */ | ||
|
||
function setUpUnderlyingAsset() public virtual override returns (IERC20 asset, uint8 decimals, uint256 approxAssetUsdExchangeRate) { | ||
return (IERC20(_asset), 18, 0.91e18); | ||
} | ||
|
||
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 { | ||
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 { | ||
|
||
} | ||
|
||
} |