Skip to content

Commit

Permalink
add more yearn v3 integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trmid committed Sep 27, 2024
1 parent 236be2a commit 3815046
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 0 deletions.
62 changes: 62 additions & 0 deletions test/integration/yearn-v3/YearnV3ArbUsdce1.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

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

contract YearnV3ArbUsdce1IntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 257937555;
uint256 forkBlockTimestamp = 1727451973;

address internal _asset = address(0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8);
address internal _assetWhale = address(0x25681Ab599B4E2CEea31F8B498052c53FC2D74db);
address internal _yieldVault = address(0xDa3b69a45797DCA697Ff5bB2c10682f14373c063);

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

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

function setUpYieldVault() public virtual override returns (IERC4626) {
return IERC4626(_yieldVault);
}

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

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.05 gwei;
ignoreLoss = true;
}

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
function _accrueYield() internal virtual override prankception(_assetWhale) {
vm.warp(block.timestamp + 1 days); // let 1 day pass by
}

/// @dev Yearn does not socialize losses automatically and instead realizes the loss when an account withdraws.
/// If there is any loss on the yearn vault, the prize vault may not be able to withdraw until the yearn vault
/// manager manually triggers the realization of loss through a harvestAndReport or similar call.
function _simulateLoss() internal virtual override prankception(_yieldVault) {

}

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

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

contract YearnV3ArbUsdce2IntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 257937555;
uint256 forkBlockTimestamp = 1727451973;

address internal _asset = address(0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8);
address internal _assetWhale = address(0x25681Ab599B4E2CEea31F8B498052c53FC2D74db);
address internal _yieldVault = address(0x9FA306b1F4a6a83FEC98d8eBbaBEDfF78C407f6B);

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

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

function setUpYieldVault() public virtual override returns (IERC4626) {
return IERC4626(_yieldVault);
}

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

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.05 gwei;
ignoreLoss = true;
}

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
function _accrueYield() internal virtual override prankception(_assetWhale) {
vm.warp(block.timestamp + 1 days); // let 1 day pass by
}

/// @dev Yearn does not socialize losses automatically and instead realizes the loss when an account withdraws.
/// If there is any loss on the yearn vault, the prize vault may not be able to withdraw until the yearn vault
/// manager manually triggers the realization of loss through a harvestAndReport or similar call.
function _simulateLoss() internal virtual override prankception(_yieldVault) {

}

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

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

contract YearnV3ArbUsdtIntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 257937555;
uint256 forkBlockTimestamp = 1727451973;

address internal _asset = address(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9);
address internal _assetWhale = address(0xF977814e90dA44bFA03b6295A0616a897441aceC);
address internal _yieldVault = address(0xc0ba9bfED28aB46Da48d2B69316A3838698EF3f5);

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

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

function setUpYieldVault() public virtual override returns (IERC4626) {
return IERC4626(_yieldVault);
}

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

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.05 gwei;
ignoreLoss = true;
}

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
function _accrueYield() internal virtual override prankception(_assetWhale) {
vm.warp(block.timestamp + 1 days); // let 1 day pass by
}

/// @dev Yearn does not socialize losses automatically and instead realizes the loss when an account withdraws.
/// If there is any loss on the yearn vault, the prize vault may not be able to withdraw until the yearn vault
/// manager manually triggers the realization of loss through a harvestAndReport or similar call.
function _simulateLoss() internal virtual override prankception(_yieldVault) {

}

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

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

contract YearnV3EthDaiIntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 20843072;
uint256 forkBlockTimestamp = 1727453495;

address internal _asset = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address internal _assetWhale = address(0xf6e72Db5454dd049d0788e411b06CfAF16853042);
address internal _yieldVault = address(0x028eC7330ff87667b6dfb0D94b954c820195336c);

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

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

function setUpYieldVault() public virtual override returns (IERC4626) {
return IERC4626(_yieldVault);
}

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

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.5 gwei;
ignoreLoss = true;
}

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
function _accrueYield() internal virtual override prankception(_assetWhale) {
vm.warp(block.timestamp + 1 days); // let 1 day pass by
}

/// @dev Yearn does not socialize losses automatically and instead realizes the loss when an account withdraws.
/// If there is any loss on the yearn vault, the prize vault may not be able to withdraw until the yearn vault
/// manager manually triggers the realization of loss through a harvestAndReport or similar call.
function _simulateLoss() internal virtual override prankception(_yieldVault) {

}

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

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

contract YearnV3EthUsdcIntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 20843072;
uint256 forkBlockTimestamp = 1727453495;

address internal _asset = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
address internal _assetWhale = address(0x37305B1cD40574E4C5Ce33f8e8306Be057fD7341);
address internal _yieldVault = address(0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204);

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

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

function setUpYieldVault() public virtual override returns (IERC4626) {
return IERC4626(_yieldVault);
}

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

function beforeSetup() public virtual override {
lowGasPriceEstimate = 0.5 gwei;
ignoreLoss = true;
}

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
function _accrueYield() internal virtual override prankception(_assetWhale) {
vm.warp(block.timestamp + 1 days); // let 1 day pass by
}

/// @dev Yearn does not socialize losses automatically and instead realizes the loss when an account withdraws.
/// If there is any loss on the yearn vault, the prize vault may not be able to withdraw until the yearn vault
/// manager manually triggers the realization of loss through a harvestAndReport or similar call.
function _simulateLoss() internal virtual override prankception(_yieldVault) {

}

}

0 comments on commit 3815046

Please sign in to comment.