Skip to content

Commit

Permalink
Merge pull request #64 from superform-xyz/upgrades
Browse files Browse the repository at this point in the history
fix: Upgrades
  • Loading branch information
0xTimepunk authored Sep 13, 2023
2 parents d918307 + 313e8c3 commit 74a2c9d
Show file tree
Hide file tree
Showing 77 changed files with 1,023 additions and 881 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "lib/ds-test"]
path = lib/ds-test
url = https://github.com/dapphub/ds-test
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/Rari-Capital/solmate
Expand All @@ -20,3 +17,6 @@
[submodule "lib/v2-periphery"]
path = lib/v2-periphery
url = https://github.com/Uniswap/v2-periphery
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
15 changes: 0 additions & 15 deletions .prettierrc

This file was deleted.

12 changes: 11 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ remappings = [
'v2-periphery/=lib/v2-periphery/contracts/'
]

fs_permissions = [{ access = "read-write", path = "./"}]
fs_permissions = [{ access = "read-write", path = "./"}]

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
4 changes: 2 additions & 2 deletions src/_global/swapUtils.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";

interface IPair {
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
Expand Down
28 changes: 19 additions & 9 deletions src/aave-v2/AaveV2ERC4626Reinvest.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";

import {ILendingPool} from "./aave/ILendingPool.sol";
import {IAaveMining} from "./aave/IAaveMining.sol";
import { ILendingPool } from "./aave/ILendingPool.sol";
import { IAaveMining } from "./aave/IAaveMining.sol";

import {DexSwap} from "../_global/swapUtils.sol";
import { DexSwap } from "../_global/swapUtils.sol";

/// @title AaveV2ERC4626Reinvest
/// @notice Extended implementation of yield-daddy's ERC4626
Expand Down Expand Up @@ -89,7 +89,9 @@ contract AaveV2ERC4626Reinvest is ERC4626 {
ILendingPool lendingPool_,
address rewardToken_,
address manager_
) ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_)) {
)
ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_))
{
aToken = aToken_;
rewards = rewards_;
lendingPool = lendingPool_;
Expand Down Expand Up @@ -186,7 +188,11 @@ contract AaveV2ERC4626Reinvest is ERC4626 {
///@param assets_ Amount of assets to withdraw
///@param receiver_ Address to send withdrawn assets to
///@param owner_ Address to burn shares from
function withdraw(uint256 assets_, address receiver_, address owner_)
function withdraw(
uint256 assets_,
address receiver_,
address owner_
)
public
virtual
override
Expand Down Expand Up @@ -216,7 +222,11 @@ contract AaveV2ERC4626Reinvest is ERC4626 {
///@param shares_ Amount of shares to redeem
///@param receiver_ Address to send redeemed assets to
///@param owner_ Address to burn shares from
function redeem(uint256 shares_, address receiver_, address owner_)
function redeem(
uint256 shares_,
address receiver_,
address owner_
)
public
virtual
override
Expand Down
10 changes: 5 additions & 5 deletions src/aave-v2/AaveV2ERC4626ReinvestFactory.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";

import {AaveV2ERC4626Reinvest} from "./AaveV2ERC4626Reinvest.sol";
import {IAaveMining} from "./aave/IAaveMining.sol";
import {ILendingPool} from "./aave/ILendingPool.sol";
import { AaveV2ERC4626Reinvest } from "./AaveV2ERC4626Reinvest.sol";
import { IAaveMining } from "./aave/IAaveMining.sol";
import { ILendingPool } from "./aave/ILendingPool.sol";

/// @title AaveV2ERC4626ReinvestFactory
/// @notice Factory for creating AaveV2ERC4626 contracts
Expand Down
31 changes: 21 additions & 10 deletions src/aave-v2/AaveV2ERC4626ReinvestIncentive.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";

import {ILendingPool} from "./aave/ILendingPool.sol";
import {IAaveMining} from "./aave/IAaveMining.sol";
import { ILendingPool } from "./aave/ILendingPool.sol";
import { IAaveMining } from "./aave/IAaveMining.sol";

import {DexSwap} from "../_global/swapUtils.sol";
import { DexSwap } from "../_global/swapUtils.sol";

/// @title AaveV2ERC4626ReinvestIncentive
/// @notice Extended implementation of yield-daddy AaveV2 wrapper with reinvesting logic - with incentives to call harvest() built-in
/// @notice Extended implementation of yield-daddy AaveV2 wrapper with reinvesting logic - with incentives to call
/// harvest() built-in
/// @notice Reinvests rewards accrued for higher APY
/// @author ZeroPoint Labs
contract AaveV2ERC4626ReinvestIncentive is ERC4626 {
Expand Down Expand Up @@ -95,7 +96,9 @@ contract AaveV2ERC4626ReinvestIncentive is ERC4626 {
ILendingPool lendingPool_,
address rewardToken_,
address manager_
) ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_)) {
)
ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_))
{
aToken = aToken_;
rewards = rewards_;
lendingPool = lendingPool_;
Expand Down Expand Up @@ -162,7 +165,11 @@ contract AaveV2ERC4626ReinvestIncentive is ERC4626 {
ERC4626 OVERRIDE FUNCTIONS
//////////////////////////////////////////////////////////////*/

function withdraw(uint256 assets_, address receiver_, address owner_)
function withdraw(
uint256 assets_,
address receiver_,
address owner_
)
public
virtual
override
Expand All @@ -188,7 +195,11 @@ contract AaveV2ERC4626ReinvestIncentive is ERC4626 {
lendingPool.withdraw(address(asset), assets_, receiver_);
}

function redeem(uint256 shares_, address receiver_, address owner_)
function redeem(
uint256 shares_,
address receiver_,
address owner_
)
public
virtual
override
Expand Down
10 changes: 5 additions & 5 deletions src/aave-v2/AaveV2ERC4626ReinvestIncentiveFactory.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";

import {AaveV2ERC4626ReinvestIncentive} from "./AaveV2ERC4626ReinvestIncentive.sol";
import {IAaveMining} from "./aave/IAaveMining.sol";
import {ILendingPool} from "./aave/ILendingPool.sol";
import { AaveV2ERC4626ReinvestIncentive } from "./AaveV2ERC4626ReinvestIncentive.sol";
import { IAaveMining } from "./aave/IAaveMining.sol";
import { ILendingPool } from "./aave/ILendingPool.sol";

/// @title AaveV2ERC4626ReinvestFactory
/// @notice Factory for creating AaveV2ERC4626Reinvest contracts
Expand Down
22 changes: 11 additions & 11 deletions src/aave-v2/test/AaveV2ERC4626Reinvest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
pragma solidity 0.8.21;

import "forge-std/Test.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";

import {AaveV2ERC4626Reinvest} from "../AaveV2ERC4626Reinvest.sol";
import {AaveV2ERC4626ReinvestFactory} from "../AaveV2ERC4626ReinvestFactory.sol";
import { AaveV2ERC4626Reinvest } from "../AaveV2ERC4626Reinvest.sol";
import { AaveV2ERC4626ReinvestFactory } from "../AaveV2ERC4626ReinvestFactory.sol";

import {ILendingPool} from "../aave/ILendingPool.sol";
import {IAaveMining} from "../aave/IAaveMining.sol";
import {DexSwap} from "../../_global/swapUtils.sol";
import { ILendingPool } from "../aave/ILendingPool.sol";
import { IAaveMining } from "../aave/IAaveMining.sol";
import { DexSwap } from "../../_global/swapUtils.sol";

contract AaveV2ERC4626ReinvestTest is Test {
////////////////////////////////////////
Expand Down Expand Up @@ -54,7 +54,7 @@ contract AaveV2ERC4626ReinvestTest is Test {
manager = msg.sender;

vm.selectFork(polyFork);
vm.rollFork(39700000);
vm.rollFork(39_700_000);

/// @dev Original AAVE v2 reward mining is disabled on each network
/// @dev We can leave this set to whatever on V2, harvest() is just not used
Expand Down Expand Up @@ -92,8 +92,8 @@ contract AaveV2ERC4626ReinvestTest is Test {
function setUp() public {
alice = address(0x1);
bob = address(0x2);
deal(address(asset), alice, 10000 ether);
deal(address(asset), bob, 10000 ether);
deal(address(asset), alice, 10_000 ether);
deal(address(asset), bob, 10_000 ether);
}

function testFactoryDeploy() public {
Expand All @@ -112,7 +112,7 @@ contract AaveV2ERC4626ReinvestTest is Test {

/// @dev Just check if we can deposit
uint256 amount = 100 ether;
deal(address(vaultAsset), alice, 10000 ether);
deal(address(vaultAsset), alice, 10_000 ether);
uint256 aliceUnderlyingAmount = amount;
vaultAsset.approve(address(vault_), aliceUnderlyingAmount);
vault_.deposit(aliceUnderlyingAmount, alice);
Expand Down
28 changes: 19 additions & 9 deletions src/aave-v3/AaveV3ERC4626Reinvest.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";

import {IPool} from "./external/IPool.sol";
import {IRewardsController} from "./external/IRewardsController.sol";
import { IPool } from "./external/IPool.sol";
import { IRewardsController } from "./external/IRewardsController.sol";

import {DexSwap} from "../_global/swapUtils.sol";
import { DexSwap } from "../_global/swapUtils.sol";

/// @title AaveV3ERC4626Reinvest
/// @notice Extended implementation of yield-daddy's ERC4626 for Aave V3 with rewards reinvesting
Expand Down Expand Up @@ -101,7 +101,9 @@ contract AaveV3ERC4626Reinvest is ERC4626 {
IPool lendingPool_,
IRewardsController rewardsController_,
address manager_
) ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_)) {
)
ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_))
{
aToken = aToken_;
lendingPool = lendingPool_;
rewardsController = rewardsController_;
Expand Down Expand Up @@ -252,7 +254,11 @@ contract AaveV3ERC4626Reinvest is ERC4626 {
ERC4626 OVERRIDES
//////////////////////////////////////////////////////////////*/

function withdraw(uint256 assets_, address receiver_, address owner_)
function withdraw(
uint256 assets_,
address receiver_,
address owner_
)
public
virtual
override
Expand Down Expand Up @@ -280,7 +286,11 @@ contract AaveV3ERC4626Reinvest is ERC4626 {
lendingPool.withdraw(address(asset), assets_, receiver_);
}

function redeem(uint256 shares_, address receiver_, address owner_)
function redeem(
uint256 shares_,
address receiver_,
address owner_
)
public
virtual
override
Expand Down
16 changes: 9 additions & 7 deletions src/aave-v3/AaveV3ERC4626ReinvestFactory.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { ERC4626 } from "solmate/mixins/ERC4626.sol";

import {IPool} from "./external/IPool.sol";
import {AaveV3ERC4626Reinvest} from "./AaveV3ERC4626Reinvest.sol";
import {IRewardsController} from "./external/IRewardsController.sol";
import {Bytes32AddressLib} from "solmate/utils/Bytes32AddressLib.sol";
import { IPool } from "./external/IPool.sol";
import { AaveV3ERC4626Reinvest } from "./AaveV3ERC4626Reinvest.sol";
import { IRewardsController } from "./external/IRewardsController.sol";
import { Bytes32AddressLib } from "solmate/utils/Bytes32AddressLib.sol";

/// @title AaveV3ERC4626ReinvestFactory
/// @notice Factory for creating AaveV3ERC4626 contracts
Expand Down Expand Up @@ -129,7 +129,9 @@ contract AaveV3ERC4626ReinvestFactory {
address token_,
address pair1_,
address pair2_
) external {
)
external
{
if (msg.sender != manager) revert INVALID_ACCESS();
vault_.setRoutes(rewardToken_, token_, pair1_, pair2_);

Expand Down
Loading

0 comments on commit 74a2c9d

Please sign in to comment.