Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add aave lido market weth integration test #130

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/integration/BaseIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ abstract contract BaseIntegration is Test, Permit {
address internal bob;
uint256 internal bobPrivateKey;

address internal karen;
uint256 internal karenPrivateKey;

PrizeVaultWrapper public prizeVault;
string public vaultName = "PoolTogether Test Vault";
string public vaultSymbol = "pTest";
Expand Down Expand Up @@ -102,6 +105,7 @@ abstract contract BaseIntegration is Test, Permit {
(owner, ownerPrivateKey) = makeAddrAndKey("Owner");
(alice, alicePrivateKey) = makeAddrAndKey("Alice");
(bob, bobPrivateKey) = makeAddrAndKey("Bob");
(karen, karenPrivateKey) = makeAddrAndKey("Karen");

setUpFork();
(underlyingAsset, assetDecimals, approxAssetUsdExchangeRate) = setUpUnderlyingAsset();
Expand Down Expand Up @@ -467,7 +471,7 @@ abstract contract BaseIntegration is Test, Permit {
address[] memory depositors = new address[](3);
depositors[0] = alice;
depositors[1] = bob;
depositors[2] = address(this);
depositors[2] = karen;

uint256[] memory amounts = new uint256[](3);

Expand Down Expand Up @@ -516,7 +520,7 @@ abstract contract BaseIntegration is Test, Permit {
address[] memory depositors = new address[](3);
depositors[0] = alice;
depositors[1] = bob;
depositors[2] = address(this);
depositors[2] = karen;

// deposit
for (uint256 i = 0; i < depositors.length; i++) {
Expand Down
76 changes: 76 additions & 0 deletions test/integration/aave/YieldDaddyAaveEthLidoWeth.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

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

import { AaveV3ERC4626, ERC20, IPool, IRewardsController } from "yield-daddy/aave-v3/AaveV3ERC4626.sol";

contract YieldDaddyAaveEthLidoWethIntegrationTest is BaseIntegration {
uint256 fork;
uint256 forkBlock = 20643320;
uint256 forkBlockTimestamp = 1725044111;

address internal _asset = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address internal _assetWhale = address(0xF04a5cC80B1E94C69B48f5ee68a08CD2F09A7c3E);
address internal _aToken = address(0xfA1fDbBD71B0aA16162D76914d69cD8CB3Ef92da);
address internal _aTokenWhale = address(0xc91FC9Dd7f1Bb6Ec429edDB577b9Ace6236B2147);

address internal _aavePool = address(0x4e033931ad43597d96D6bcc25c280717730B58B1);
address internal _aaveRewards = address(0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb);

address internal _yieldVault;

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

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

function setUpYieldVault() public virtual override returns (IERC4626) {
AaveV3ERC4626 wrappedVault = new AaveV3ERC4626(
ERC20(_asset),
ERC20(_aToken),
IPool(_aavePool),
address(this),
IRewardsController(_aaveRewards)
);
_yieldVault = address(wrappedVault);
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.1 gwei;
}

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 sending aTokens to the yield vault as well as letting some time pass
function _accrueYield() internal virtual override prankception(_aTokenWhale) {
IERC20(_aToken).transfer(_yieldVault, 10 ** assetDecimals);
vm.warp(block.timestamp + 1 days);
}

/// @dev Simulates loss by transferring some liquid aTokens out of the yield vault
function _simulateLoss() internal virtual override prankception(_yieldVault) {
IERC20(_aToken).transfer(_aTokenWhale, IERC20(_aToken).balanceOf(_yieldVault) / 2); // transfer aTokens out of the yield vault
}

}
Loading