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

WIP: Generalised AMOs for Curve and Balancer #1806

Closed
wants to merge 176 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
b7df446
Updated ConvexEthMetaStrategy natspec
naddison36 Jul 11, 2023
670cc5c
Deploy 070 OETH AMO upgrade script
naddison36 Jul 11, 2023
44e9914
Removed debug comments from OETH AMO tests
naddison36 Jul 11, 2023
ff10573
Added AMO rebalance functions
naddison36 Jul 12, 2023
4a7f68c
Gas optimizations to the OETH AMO strategy (#1696)
naddison36 Jul 17, 2023
78d58f5
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Jul 17, 2023
dbc81f8
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 2, 2023
2edb42e
Added env vars to .env template
naddison36 Aug 2, 2023
5766353
Update AMO value flows
naddison36 Aug 2, 2023
34a55ed
deprecated old storage slots
naddison36 Aug 2, 2023
2f75d25
Refactor OETH AMO fork tests
naddison36 Aug 2, 2023
875d99b
Updated AMO fork tests
naddison36 Aug 2, 2023
606c16f
More AMO fork tests
naddison36 Aug 2, 2023
c209ed0
AMO fork tests
naddison36 Aug 2, 2023
ac11e48
AMO fork testing
naddison36 Aug 2, 2023
2352d0d
removed minAmounts from AMO repeg functions
naddison36 Aug 2, 2023
e35ab7a
Updated AMO tests
naddison36 Aug 2, 2023
e0d5912
Added improveMetapoolBalance modifier to ETH AMO Strategy
naddison36 Aug 2, 2023
898099e
Added config to OETH AMO fixture to tilt the OETH Metapool
naddison36 Aug 3, 2023
74d9304
Disable slither constable-states
naddison36 Aug 3, 2023
03ef96a
Fix build
naddison36 Aug 3, 2023
559fbd0
Added negative repeg fork tests
naddison36 Aug 3, 2023
41dd487
Updated ConvexEthMetaStrategy diagram with new modifier
naddison36 Aug 3, 2023
7b5f4ef
Fix safeApproveAllTokens on ConvexEthMetaStrategy
naddison36 Aug 3, 2023
9ea511f
Added depositAll OETH AMO fork test
naddison36 Aug 3, 2023
1c77ee3
Remove WETH approval in ConvexEthMetaStrategy
naddison36 Aug 3, 2023
ccf5cf6
HH task amoStrat support OUSD AMO
naddison36 Aug 4, 2023
49f039e
Changed OETH AMO approvals to just approve
naddison36 Aug 4, 2023
d0a181d
Added oeth_meta_strat to Brownie
naddison36 Aug 7, 2023
d767e75
Added AMO Hardhat tasks
naddison36 Aug 7, 2023
9d10b30
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 7, 2023
c4adb0f
Disable slither of approve
naddison36 Aug 7, 2023
14c238e
Renamed createFixture to createFixtureLoader
naddison36 Aug 7, 2023
c75ccf1
Fix the AMO peg keeping fork test
naddison36 Aug 8, 2023
093846e
Remove rebase on mintForStrategy and burnForStrategy (#1736)
naddison36 Aug 8, 2023
6f612c6
Added Deposit and Withdrawal events to AMO strat for OETH mints and b…
naddison36 Aug 8, 2023
0efb694
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 10, 2023
2c30e5c
Prettier
naddison36 Aug 10, 2023
c9edb8b
Moved the deploy AMO peg keeping files to 073
naddison36 Aug 10, 2023
1ecddc1
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 11, 2023
5845555
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 14, 2023
b35c9a8
fix: edge case in improveMetapoolBalance modifier when the pool was e…
naddison36 Aug 14, 2023
22e63d3
chore: refactored out the common code in removeAndBurnOTokens and rem…
naddison36 Aug 14, 2023
e0df797
Moved oethWhaleAddress to addresses.mainnet.oethWhaleAddress
naddison36 Aug 14, 2023
b2f9b2f
Fix reduceQueueTime after AMO upgrade
naddison36 Aug 14, 2023
c724c8c
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 16, 2023
216d5bd
Added proxyUpgrades hardhat task
naddison36 Aug 16, 2023
14bc8c5
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 21, 2023
49fa348
Add Maker DSR strategy to possible defaults for DAI
naddison36 Aug 21, 2023
b9180f1
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 21, 2023
8d578c8
fix build as OETH Metapool is imbalanced on mainnet
naddison36 Aug 21, 2023
67647c1
Update OETH AMO fork tests
naddison36 Aug 21, 2023
74805a0
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 25, 2023
29d6339
Improved OUSD AMO fork tests
naddison36 Aug 25, 2023
06b4a67
Fix OUSD collateral swap fork test
naddison36 Aug 25, 2023
ef86ac7
temp fix to vault test as this will be fixed after the OUSD upgrade
naddison36 Aug 25, 2023
e3460ab
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 30, 2023
9c1c9b4
Made the collateral swap fork tests more resilient
naddison36 Aug 30, 2023
b5d9a2d
Fix build
naddison36 Aug 30, 2023
28eb270
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 30, 2023
5551a8c
Merge remote-tracking branch 'origin/master' into nicka/amo-peg-keeping
naddison36 Aug 31, 2023
f1de2b0
renamed deploy script to 075
naddison36 Aug 31, 2023
2b1000c
Added proposal to 074 deploy script for frxETH Oracle
naddison36 Aug 31, 2023
4ee26ce
Changed VaultCore and VaultAdmin to inherit from VaultInitializer
naddison36 Aug 31, 2023
1871217
Gas saving to OETH AMO Strategy's checkBalance
naddison36 Aug 31, 2023
a6c593e
Check asset is WETH when initializing the ETH AMO
naddison36 Aug 31, 2023
e1d192e
Added reentry checks on new AMO pre keeping functions
naddison36 Sep 1, 2023
4ee8d0e
Added improveMetapoolBalance checks to existing functions
naddison36 Sep 1, 2023
6f0d148
Removed improveMetapoolBalance from existing ETH AMO functions
naddison36 Sep 1, 2023
fb3cf20
removed 074 proposalId as it hasn't passed voting yet
naddison36 Sep 1, 2023
3fa460f
Added AMO peg keeping value flows
naddison36 Sep 1, 2023
dc07a8a
Changed Metapool to Curve pool in the AMO strategy
naddison36 Sep 1, 2023
65dd92e
Create base contract for Convex AMO strategy
naddison36 Sep 1, 2023
16ea456
Added ConvexFrxETHAMOStrategy
naddison36 Sep 1, 2023
76ba61c
Add more Natspec
naddison36 Sep 1, 2023
a6050ad
WIP OUSD AMO refactor
naddison36 Sep 1, 2023
4ac35dc
Fixed OUSD AMO unit tests
naddison36 Sep 4, 2023
43bae82
Refactoring of AMO strategies
naddison36 Sep 4, 2023
27879d7
Got OUSD AMO working
naddison36 Sep 4, 2023
4a7ba7c
Refactor Base AMO
naddison36 Sep 4, 2023
bf6c967
Before splitting out Curve from Base AMO strategy
naddison36 Sep 5, 2023
5d1a98c
Split Convex stuff out of Base AMO strategy
naddison36 Sep 5, 2023
908d020
Added Balancer AMO
naddison36 Sep 5, 2023
b5f426b
Added new ConvexFrxETHAMOStrategy to OETH contracts diagram
naddison36 Sep 5, 2023
7eb2348
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Sep 15, 2023
5eafb24
Fix build
naddison36 Sep 15, 2023
bf49e7d
Add frxETH deploy script
naddison36 Sep 15, 2023
53f6a6f
Added multi asset deposit and withdraw support to base AMO
naddison36 Sep 18, 2023
6d624cd
Fix slither
naddison36 Sep 18, 2023
e215332
fix deploy of frxETH AMO for OETH Vault
naddison36 Sep 19, 2023
6ab09b4
Fix stETH price from OETH Oracle Router
naddison36 Sep 19, 2023
8b7e6bc
Handle AMO withdrawAll when there is no liquidity in the pool
naddison36 Sep 19, 2023
6f26579
Rename OETH AMO fixture in prep for other AMOs
naddison36 Sep 19, 2023
126d555
added frxETH AMO to fixture
naddison36 Sep 19, 2023
072224e
Vault support for multiple AMOs
naddison36 Sep 19, 2023
15fef1d
Fix linter
naddison36 Sep 19, 2023
2877dfc
Fix slither
naddison36 Sep 19, 2023
91eb968
Updated frxETH AMO config for latest blocks
naddison36 Sep 20, 2023
a890a95
Fix frxETH AMO withdrawAll test
naddison36 Sep 20, 2023
367aa2a
Fix frxETH AMO fork tests
naddison36 Sep 20, 2023
245eb8a
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Sep 20, 2023
e746b3e
strategies on Vault now external so tests can get config
naddison36 Sep 20, 2023
a30178a
fix collateral swap tests
naddison36 Sep 20, 2023
f0f64d7
Finished Vault support got multiple AMO.
naddison36 Sep 20, 2023
b349635
fix slither
naddison36 Sep 21, 2023
1f47edf
Updated frxETH AMO config for latest block
naddison36 Sep 21, 2023
efb424a
Ignore coverage of echidna solidity test files
naddison36 Sep 21, 2023
0eaec97
Generated latest contract diagrams
naddison36 Sep 21, 2023
8ebbc0e
Renaming of AMO fork tests and fixtures
naddison36 Sep 21, 2023
f56e831
Update frxETH AMO for latest block
naddison36 Sep 21, 2023
b518991
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Sep 21, 2023
773d53c
refactored Curve names
naddison36 Sep 21, 2023
bceb74d
prettier
naddison36 Sep 21, 2023
9ae0a1d
OUSD AMO Strategy renamed in fixture
naddison36 Sep 21, 2023
2029fd8
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Sep 25, 2023
da46964
Update OUSD AMO unit tests
naddison36 Sep 25, 2023
4ee2bb7
Removed external initialize from InitializableAbstractStrategy. Imple…
naddison36 Sep 25, 2023
7886394
Updated OUSD AMO unit tests
naddison36 Sep 25, 2023
2aa5db7
fix linter
naddison36 Sep 25, 2023
7115a7c
Updated frxETH/OETH deploy now gauge has been added to the Curve gaug…
naddison36 Sep 26, 2023
b5903f4
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Sep 26, 2023
0560572
Fixed Convex OETH/ETH rewards pool address
naddison36 Sep 26, 2023
9364eee
Add final config of Convex frxETH/OETH pool
naddison36 Sep 26, 2023
32604aa
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Oct 16, 2023
9013758
regenerated all diagrams
naddison36 Oct 16, 2023
2cecdda
Removed creating frxETH/OETH Convex pool as it has now been done on m…
naddison36 Oct 16, 2023
153d9c1
Merge remote-tracking branch 'origin/nicka/amo-frxeth' into nicka/amo…
naddison36 Oct 16, 2023
cb2135e
updated deploy numbers for AMOs
naddison36 Oct 16, 2023
1525f06
restored deploy script order
naddison36 Oct 17, 2023
c2efc49
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
naddison36 Oct 17, 2023
6799b6b
Fix collateral swap fork tests
naddison36 Oct 17, 2023
960fa49
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 17, 2023
5864d6e
fix collateral swaps to USDT
naddison36 Oct 17, 2023
82b9206
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 18, 2023
a13b181
Updated Balancer reward token comments
naddison36 Oct 18, 2023
1849ca7
Strategy behaviour tests to handle multi asset deposit and withdraws
naddison36 Oct 18, 2023
81ca290
Fixed frxETH AMO deploy script
naddison36 Oct 18, 2023
d2c9948
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 18, 2023
e2515ab
Add unit tests for ETH and frxETH AMOs
naddison36 Oct 20, 2023
ba30372
Moved _fixture.js to help with later merge
naddison36 Oct 20, 2023
cc2d5cd
Merge remote-tracking branch 'origin/master' into nicka/convex-frxeth…
naddison36 Oct 20, 2023
8341dec
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 20, 2023
5ad4f01
Got harvestor behaviour tests working with OETH strategies
naddison36 Oct 20, 2023
0fec111
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 25, 2023
5d5f49c
prettier
naddison36 Oct 25, 2023
2774dd8
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 25, 2023
1362172
Added onlyGovernor to safeApproveAllTokens on CompoundStrategy
naddison36 Oct 25, 2023
baf1052
Merge remote-tracking branch 'origin/master' into nicka/amo-frxeth
sparrowDom Oct 25, 2023
d07c9ca
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Oct 30, 2023
1dcad93
fix Mock Curve pool remove liquidity
naddison36 Oct 30, 2023
9926d19
No longer collected rewards when withdrawing from Convex pool
naddison36 Oct 30, 2023
0871c63
Fix compound unit test as this is now covered by the strategy behaviour
naddison36 Oct 30, 2023
c8d7a82
Added ETH support for Curve mocks
naddison36 Oct 30, 2023
96405f4
Fixed ETH/OETH AMO unit tests
naddison36 Oct 30, 2023
3616f94
fixed linter
naddison36 Oct 30, 2023
fbadbbd
Merge remote-tracking branch 'origin/nicka/amo-frxeth' into nicka/amo…
naddison36 Oct 30, 2023
2ba985e
prettier js
naddison36 Oct 30, 2023
3c7e4e8
Fixed OUSD AMO fork tests
naddison36 Oct 30, 2023
5920a00
Fixed ConvexEthMetaStrategy._addLiquidityToPool to include ETH value
naddison36 Oct 31, 2023
4b132ba
AMO contracts split asset into vaultAsset and poolAsset
naddison36 Oct 31, 2023
fa2ac69
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Nov 1, 2023
167440c
More AMO behaviour tests
naddison36 Nov 1, 2023
6125107
findBalancesSlot handle edge case of balances in first slot
naddison36 Nov 1, 2023
0fd016b
Updated AMO behaviour tests
naddison36 Nov 2, 2023
ad02870
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Nov 6, 2023
bea4b2f
Merge remote-tracking branch 'origin/nicka/convex-frxeth-weth-libs' i…
naddison36 Nov 8, 2023
357cd1f
Merge branch 'nicka/convex-frxeth-weth-libs' into nicka/amo-frxeth
naddison36 Dec 5, 2023
45946a1
Fix linter
naddison36 Dec 5, 2023
d44ed5f
Prettier
naddison36 Dec 5, 2023
499ee89
Fix Slither
naddison36 Dec 5, 2023
cb65e9f
Fix fork tests
naddison36 Dec 5, 2023
f113745
Fix OUSD AMO fork test
naddison36 Dec 5, 2023
e521318
Merge branch 'nicka/convex-frxeth-weth-libs' into nicka/amo-frxeth
naddison36 Dec 5, 2023
738e802
Skip deploy of Convex Frax strategy
naddison36 Dec 5, 2023
95d005b
Skip Convex frxETH/WETH fork tests
naddison36 Dec 5, 2023
3f367ae
fix unit tests
naddison36 Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions contracts/contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ interface IVault {
event YieldDistribution(address _to, uint256 _yield, uint256 _fee);
event TrusteeFeeBpsChanged(uint256 _basis);
event TrusteeAddressChanged(address _address);
event AMOStrategyUpdated(address _addr, bool _isAMO);
event MintForStrategyThresholdChanged(
address _strategy,
uint256 _threshold
);
event SwapperChanged(address _address);
event SwapAllowedUndervalueChanged(uint256 _basis);
event SwapSlippageChanged(address _asset, uint256 _basis);
Expand Down Expand Up @@ -79,8 +84,6 @@ interface IVault {

function trusteeFeeBps() external view returns (uint256);

function ousdMetaStrategy() external view returns (address);

function setSwapper(address _swapperAddr) external;

function setSwapAllowedUndervalue(uint16 _percentageBps) external;
Expand Down Expand Up @@ -189,13 +192,15 @@ interface IVault {

function getAllStrategies() external view returns (address[] memory);

function isSupportedAsset(address _asset) external view returns (bool);

function netOusdMintForStrategyThreshold() external view returns (uint256);
function getStrategyConfig(address _addr)
external
view
returns (VaultStorage.Strategy memory);

function setOusdMetaStrategy(address _ousdMetaStrategy) external;
function isSupportedAsset(address _asset) external view returns (bool);

function setNetOusdMintForStrategyThreshold(uint256 _threshold) external;
function setAMOStrategy(address _address, bool _isAMO) external;

function netOusdMintedForStrategy() external view returns (int256);
function setMintForStrategyThreshold(address _strategy, uint256 _threshold)
external;
}
83 changes: 62 additions & 21 deletions contracts/contracts/mocks/curve/MockCurveAbstractMetapool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,36 @@ import "../../utils/Helpers.sol";
abstract contract MockCurveAbstractMetapool is MintableERC20 {
using StableMath for uint256;

address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

address[] public coins;
uint256[2] public balances;

function get_balances() external view returns (uint256[2] memory) {
return balances;
}

// Returns the same amount of LP tokens in 1e18 decimals
function add_liquidity(uint256[2] calldata _amounts, uint256 _minAmount)
external
payable
returns (uint256 lpAmount)
{
for (uint256 i = 0; i < _amounts.length; i++) {
if (_amounts[i] > 0) {
IERC20(coins[i]).transferFrom(
msg.sender,
address(this),
_amounts[i]
);
uint256 assetDecimals = Helpers.getDecimals(coins[i]);
// Convert to 1e18 and add to sum
lpAmount += _amounts[i].scaleBy(18, assetDecimals);
if (coins[i] == ETH) {
require(msg.value == _amounts[i], "no ETH sent");
lpAmount += _amounts[i];
} else {
IERC20(coins[i]).transferFrom(
msg.sender,
address(this),
_amounts[i]
);
uint256 assetDecimals = Helpers.getDecimals(coins[i]);
// Convert to 1e18 and add to sum
lpAmount += _amounts[i].scaleBy(18, assetDecimals);
}
balances[i] = balances[i] + _amounts[i];
}
}
Expand All @@ -39,13 +51,12 @@ abstract contract MockCurveAbstractMetapool is MintableERC20 {
}

// Dumb implementation that returns the same amount
function calc_withdraw_one_coin(uint256 _amount, int128 _index)
function calc_withdraw_one_coin(uint256 _burn_amount, int128)
public
view
returns (uint256 lpAmount)
pure
returns (uint256 coinAmount)
{
uint256 assetDecimals = Helpers.getDecimals(coins[uint128(_index)]);
lpAmount = _amount.scaleBy(assetDecimals, 18);
coinAmount = _burn_amount;
}

function remove_liquidity_one_coin(
Expand All @@ -54,12 +65,32 @@ abstract contract MockCurveAbstractMetapool is MintableERC20 {
// solhint-disable-next-line no-unused-vars
uint256 _minAmount
) external returns (uint256 amount) {
amount = remove_liquidity_one_coin(
_lpAmount,
_index,
_minAmount,
msg.sender
);
}

function remove_liquidity_one_coin(
uint256 _lpAmount,
int128 _index,
// solhint-disable-next-line no-unused-vars
uint256 _minAmount,
address _receiver
) public returns (uint256 amount) {
_burn(msg.sender, _lpAmount);
uint256[] memory amounts = new uint256[](coins.length);
amounts[uint128(_index)] = _lpAmount;
amount = calc_withdraw_one_coin(_lpAmount, _index);
balances[uint128(_index)] -= amount;
IERC20(coins[uint128(_index)]).transfer(msg.sender, amount);
if (coins[uint128(_index)] == ETH) {
require(address(this).balance >= amount, "not enough ETH");
payable(_receiver).transfer(amount);
} else {
IERC20(coins[uint128(_index)]).transfer(_receiver, amount);
}
}

function get_virtual_price() external pure returns (uint256) {
Expand All @@ -71,15 +102,21 @@ abstract contract MockCurveAbstractMetapool is MintableERC20 {
public
returns (uint256[2] memory amounts)
{
_burn(msg.sender, _amount);
uint256 totalSupply = totalSupply();
if (totalSupply == 0) return amounts;

_burn(msg.sender, _amount);
for (uint256 i = 0; i < 2; i++) {
amounts[i] = totalSupply > 0
? (_amount * IERC20(coins[i]).balanceOf(address(this))) /
totalSupply
: IERC20(coins[i]).balanceOf(address(this));
balances[i] -= amounts[i];
IERC20(coins[i]).transfer(msg.sender, amounts[i]);
if (coins[i] == ETH) {
amounts[i] = (_amount * address(this).balance) / totalSupply;
payable(msg.sender).transfer(amounts[i]);
} else {
amounts[i] =
(_amount * IERC20(coins[i]).balanceOf(address(this))) /
totalSupply;
IERC20(coins[i]).transfer(msg.sender, amounts[i]);
}
}
}

Expand Down Expand Up @@ -118,7 +155,11 @@ abstract contract MockCurveAbstractMetapool is MintableERC20 {
for (uint256 i = 0; i < _amounts.length; i++) {
balances[i] -= _amounts[i];
if (_amounts[i] > 0) {
IERC20(coins[i]).transfer(_reveiver, _amounts[i]);
if (coins[i] == ETH) {
payable(msg.sender).transfer(_amounts[i]);
} else {
IERC20(coins[i]).transfer(_reveiver, _amounts[i]);
}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions contracts/contracts/mocks/curve/MockCurveFrxEthOethPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { MockCurveAbstractMetapool } from "./MockCurveAbstractMetapool.sol";
import "../MintableERC20.sol";

contract MockCurveFrxEthOethPool is MockCurveAbstractMetapool {
constructor(address[2] memory _coins)
ERC20("Curve.fi Factory Plain Pool: frxETH/OETH", "frxETHOETH-f")
{
coins = _coins;
}
}
15 changes: 15 additions & 0 deletions contracts/contracts/mocks/curve/MockCurveOethEthPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { MockCurveAbstractMetapool } from "./MockCurveAbstractMetapool.sol";
import "../MintableERC20.sol";

contract MockCurveOethEthPool is MockCurveAbstractMetapool {
constructor(address[2] memory _coins)
ERC20("Curve.fi Factory Pool: OETH", "OETHCRV-f")
{
coins = _coins;
}

// TODO need to handle native ETH transfers
}
14 changes: 7 additions & 7 deletions contracts/contracts/mocks/curve/MockCurvePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract MockCurvePool {
function add_liquidity(uint256[3] calldata _amounts, uint256 _minAmount)
external
{
uint256 sum = 0;
uint256 lpAmount = 0;
for (uint256 i = 0; i < _amounts.length; i++) {
if (_amounts[i] > 0) {
IERC20(coins[i]).transferFrom(
Expand All @@ -40,16 +40,16 @@ contract MockCurvePool {
);
uint256 assetDecimals = Helpers.getDecimals(coins[i]);
// Convert to 1e18 and add to sum
sum += _amounts[i].scaleBy(18, assetDecimals);
lpAmount += _amounts[i].scaleBy(18, assetDecimals);
balances[i] = balances[i] + _amounts[i];
}
}
// Hacky way of simulating slippage to check _minAmount
if (sum == 29000e18) sum = 14500e18;
require(sum >= _minAmount, "Slippage ruined your day");
if (lpAmount == 29000e18) lpAmount = 14500e18;
require(lpAmount >= _minAmount, "Slippage ruined your day");
// Send LP token to sender, e.g. 3CRV
IMintableERC20(lpToken).mint(sum);
IERC20(lpToken).transfer(msg.sender, sum);
IMintableERC20(lpToken).mint(lpAmount);
IERC20(lpToken).transfer(msg.sender, lpAmount);
}

// Dumb implementation that returns the same amount
Expand Down Expand Up @@ -85,9 +85,9 @@ contract MockCurvePool {
function remove_liquidity(uint256 _lpAmount, uint256[3] memory _min_amounts)
public
{
uint256 totalSupply = IERC20(lpToken).totalSupply();
// Burn the Curve LP tokens
IBurnableERC20(lpToken).burnFrom(msg.sender, _lpAmount);
uint256 totalSupply = IERC20(lpToken).totalSupply();
for (uint256 i = 0; i < 3; i++) {
uint256 coinAmount = totalSupply > 0
? (_lpAmount * IERC20(coins[i]).balanceOf(address(this))) /
Expand Down
7 changes: 7 additions & 0 deletions contracts/contracts/proxies/Proxies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,10 @@ contract ConvexFrxEthWethStrategyProxy is
{

}

/**
* @notice ConvexFrxETHAMOStrategyProxy delegates calls to a ConvexFrxETHAMOStrategy implementation
*/
contract ConvexFrxETHAMOStrategyProxy is InitializeGovernedUpgradeabilityProxy {

}
2 changes: 1 addition & 1 deletion contracts/contracts/strategies/CompoundStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ contract CompoundStrategy is BaseCompoundStrategy {
* @notice Approve the spending of all assets by their corresponding cToken,
* if for some reason is it necessary.
*/
function safeApproveAllTokens() external override {
function safeApproveAllTokens() external override onlyGovernor {
uint256 assetCount = assetsMapped.length;
for (uint256 i = 0; i < assetCount; ++i) {
IERC20 asset = IERC20(assetsMapped[i]);
Expand Down