Skip to content

Commit 1b4d41f

Browse files
committed
add integration test for TbtcCbbtc LP on Base
1 parent fd96711 commit 1b4d41f

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.24;
3+
4+
import { BaseIntegration, IERC20, IERC4626 } from "../BaseIntegration.t.sol";
5+
6+
/// NOTE: must be run with evm version set to "cancun" (this can be done by setting the env var FOUNDRY_PROFILE=cancun)
7+
8+
contract BeefyBaseAerodromeTbtcCbbtcIntegrationTest is BaseIntegration {
9+
uint256 fork;
10+
uint256 forkBlock = 25127069;
11+
uint256 forkBlockTimestamp = 1737043485;
12+
13+
address internal _beefyWrapper = address(0x917447f8f52E7Db26cE7f52BE2F3fcb4d4D00832);
14+
15+
address internal _asset = address(0x488d6ea6064eEE9352fdCDB7BC50d98A7fF3AD4E);
16+
address internal _assetWhale = address(0x7497B333895C64A56924B293e68a6468963f2A7e);
17+
address internal _yieldVault;
18+
address internal _mooVault = address(0x64AF54612646CcE0657374226e38B82B8001E674);
19+
address internal _mooYieldSource = address(0x6b4a9b0d4d7F363B787594524F351bDe49449EF7);
20+
21+
/* ============ setup ============ */
22+
23+
function setUpUnderlyingAsset() public virtual override returns (IERC20 asset, uint8 decimals, uint256 approxAssetUsdExchangeRate) {
24+
return (IERC20(_asset), 18, 19_710_000_000e18);
25+
}
26+
27+
function setUpYieldVault() public virtual override returns (IERC4626) {
28+
(bool success, bytes memory data) = _beefyWrapper.call(abi.encodeWithSignature("clone(address)", _mooVault));
29+
require(success, "beefy vault wrapper failed");
30+
(_yieldVault) = abi.decode(data, (address));
31+
return IERC4626(_yieldVault);
32+
}
33+
34+
function setUpFork() public virtual override {
35+
fork = vm.createFork(vm.rpcUrl("base"), forkBlock);
36+
vm.selectFork(fork);
37+
vm.warp(forkBlockTimestamp);
38+
}
39+
40+
function beforeSetup() public virtual override {
41+
lowGasPriceEstimate = 0.05 gwei; // just L2 gas, we ignore L1 costs for a super low estimate
42+
ignoreLoss = true; // loss would occur on the LP token, not the reward contract
43+
}
44+
45+
function afterSetup() public virtual override { }
46+
47+
/* ============ helpers to override ============ */
48+
49+
/// @dev The max amount of assets than can be dealt.
50+
function maxDeal() public virtual override returns (uint256) {
51+
return underlyingAsset.balanceOf(_assetWhale);
52+
}
53+
54+
/// @dev May revert if the amount requested exceeds the amount available to deal.
55+
function dealAssets(address to, uint256 amount) public virtual override prankception(_assetWhale) {
56+
underlyingAsset.transfer(to, amount);
57+
}
58+
59+
/// @dev Accrues yield by letting time pass and triggering multiple yield accruals
60+
function _accrueYield() internal virtual override prankception(_assetWhale) {
61+
// yield accrues on deposit / withdraw so we can do a deposit and withdraw to the yield vault directly to trigger some yield accrual
62+
uint256 amount = maxDeal() / 100; // some small amount of assets
63+
underlyingAsset.approve(_yieldVault, amount);
64+
yieldVault.deposit(amount, _assetWhale);
65+
vm.warp(block.timestamp + 1 days); // let 1 day pass by
66+
uint256 maxRedeem = yieldVault.maxRedeem(_assetWhale);
67+
yieldVault.redeem(maxRedeem, _assetWhale, _assetWhale);
68+
69+
// we also call a deposit directly on the moo vault to ensure it triggers a yield accrual
70+
underlyingAsset.approve(_mooVault, amount);
71+
(bool success,) = _mooVault.call(abi.encodeWithSignature("deposit(uint256)", amount));
72+
assertEq(success, true, "moo vault deposit success");
73+
}
74+
75+
function _simulateLoss() internal virtual override {
76+
77+
}
78+
79+
}

0 commit comments

Comments
 (0)