Skip to content

Commit

Permalink
feat: add ownable aave vault
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChin committed Aug 5, 2024
1 parent b146e17 commit 6762bdb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
36 changes: 36 additions & 0 deletions src/contracts/vaults/AaveV3Vault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {AaveV3ERC4626, ERC20, IPool, IRewardsController} from "yield-daddy/aave-v3/AaveV3ERC4626.sol";

contract AaveV3Vault is AaveV3ERC4626, Ownable {
constructor(
ERC20 asset_,
ERC20 aToken_,
IPool lendingPool_,
address rewardRecipient_,
IRewardsController rewardsController_,
address newOwner
) AaveV3ERC4626(asset_, aToken_, lendingPool_, rewardRecipient_, rewardsController_) Ownable(newOwner) {}

function deposit(uint256 assets, address receiver) public override onlyOwner returns (uint256 shares) {
return super.deposit(assets, receiver);
}

function mint(uint256 shares, address receiver) public override onlyOwner returns (uint256 assets) {
return super.mint(shares, receiver);
}

function withdraw(
uint256 assets,
address receiver,
address owner_
) public override onlyOwner returns (uint256 shares) {
return super.withdraw(assets, receiver, owner_);
}

function redeem(uint256 shares, address receiver, address owner_) public override onlyOwner returns (uint256 assets) {
return super.redeem(shares, receiver, owner_);
}
}
16 changes: 11 additions & 5 deletions test/integration/IntegrationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {Test} from "forge-std/Test.sol";

import {IERC20} from "forge-std/interfaces/IERC20.sol";

import {AaveV3Vault} from "contracts/vaults/AaveV3Vault.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";

Check warning on line 10 in test/integration/IntegrationBase.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Variable "ERC4626" is unused
import {ERC20} from "solmate/tokens/ERC20.sol";
import {AaveV3ERC4626, IPool, IRewardsController} from "yield-daddy/aave-v3/AaveV3ERC4626.sol";
import {IPool, IRewardsController} from "yield-daddy/aave-v3/AaveV3ERC4626.sol";

contract IntegrationBase is Test {
uint256 internal constant _FORK_BLOCK = 18_920_905;
Expand All @@ -24,19 +25,24 @@ contract IntegrationBase is Test {
address _rewardsController = 0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb;

Check warning on line 25 in test/integration/IntegrationBase.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Explicitly mark visibility of state
IPool internal _aavePool = IPool(0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2);
IGrateful internal _grateful;
AaveV3ERC4626 internal _vault;
AaveV3Vault internal _vault;
uint256 internal _amount = 1e25;

function setUp() public {
vm.startPrank(_owner);
vm.createSelectFork(vm.rpcUrl("mainnet"), _FORK_BLOCK);
_vault = new AaveV3ERC4626(
ERC20(address(_dai)), ERC20(_aDai), _aavePool, address(0), IRewardsController(_rewardsController)
);
vm.label(address(_vault), "Vault");
_tokens = new address[](1);
_tokens[0] = address(_dai);
_grateful = new Grateful(_tokens, _aavePool);
_vault = new AaveV3Vault(
ERC20(address(_dai)),
ERC20(_aDai),
_aavePool,
address(0),
IRewardsController(_rewardsController),
address(_grateful)
);
vm.label(address(_grateful), "Grateful");
_grateful.addVault(address(_dai), address(_vault));
vm.stopPrank();
Expand Down

0 comments on commit 6762bdb

Please sign in to comment.