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 tests for wstETH/WETH Balancer pool #1725

Merged
merged 4 commits into from
Jul 31, 2023
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
9 changes: 9 additions & 0 deletions contracts/contracts/proxies/Proxies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,12 @@ contract OETHBalancerMetaPoolrEthStrategyProxy is
{

}

/**
* @notice OETHBalancerMetaPoolwstEthStrategyProxy delegates calls to a BalancerMetaPoolStrategy implementation
*/
contract OETHBalancerMetaPoolwstEthStrategyProxy is
InitializeGovernedUpgradeabilityProxy
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ abstract contract BaseBalancerStrategy is InitializableAbstractStrategy {
{
if (asset == stETH) {
wrappedAsset = wstETH;
wrappedAmount = IWstETH(wstETH).wrap(amount);
if (amount > 0) {
wrappedAmount = IWstETH(wstETH).wrap(amount);
}
} else if (asset == frxETH) {
wrappedAsset = sfrxETH;
wrappedAmount = IERC4626(sfrxETH).deposit(amount, address(this));
if (amount > 0) {
wrappedAmount = IERC4626(sfrxETH).deposit(amount, address(this));
}
} else {
wrappedAsset = asset;
wrappedAmount = amount;
Expand Down
113 changes: 88 additions & 25 deletions contracts/test/_fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const hre = require("hardhat");
const { ethers } = hre;

const addresses = require("../utils/addresses");
const { balancer_rETH_WETH_PID } = require("../utils/constants");
const { balancer_rETH_WETH_PID, balancer_stETH_WETH_PID } = require("../utils/constants");
const {
fundAccounts,
fundAccountsForOETHUnitTests,
Expand All @@ -27,6 +27,7 @@ const threepoolSwapAbi = require("./abi/threepoolSwap.json");
const sfrxETHAbi = require("./abi/sfrxETH.json");
const { deployWithConfirmation } = require("../utils/deploy");
const { defaultAbiCoder, parseUnits, parseEther } = require("ethers/lib/utils");
const balancerStrategyDeployment = require("../utils/balancerStrategyDeployment");

const defaultFixture = deployments.createFixture(async () => {
await deployments.fixture(
Expand Down Expand Up @@ -828,34 +829,95 @@ async function convexVaultFixture() {
}

/**
* Configure a Vault with only the balancerREthStrategy
* Configure a Vault with the balancerREthStrategy
*/
async function balancerREthFixture() {
const fixture = await loadFixture(defaultFixture);
const { oethVault, timelock, weth, reth, balancerREthStrategy, josh } =
fixture;
function balancerREthFixtureSetup() {
return deployments.createFixture(async () => {
const fixture = await defaultFixture();
const { oethVault, timelock, weth, reth, balancerREthStrategy, josh } =
fixture;

await oethVault
.connect(timelock)
.setAssetDefaultStrategy(reth.address, balancerREthStrategy.address);
await oethVault
.connect(timelock)
.setAssetDefaultStrategy(weth.address, balancerREthStrategy.address);
await oethVault
.connect(timelock)
.setAssetDefaultStrategy(reth.address, balancerREthStrategy.address);
await oethVault
.connect(timelock)
.setAssetDefaultStrategy(weth.address, balancerREthStrategy.address);

fixture.rEthBPT = await ethers.getContractAt(
"IERC20Metadata",
addresses.mainnet.rETH_WETH_BPT,
josh
);
fixture.balancerREthPID = balancer_rETH_WETH_PID;
fixture.rEthBPT = await ethers.getContractAt(
"IERC20Metadata",
addresses.mainnet.rETH_WETH_BPT,
josh
);
fixture.balancerREthPID = balancer_rETH_WETH_PID;

fixture.balancerVault = await ethers.getContractAt(
"IBalancerVault",
addresses.mainnet.balancerVault,
josh
);
fixture.balancerVault = await ethers.getContractAt(
"IBalancerVault",
addresses.mainnet.balancerVault,
josh
);

return fixture;
return fixture;
})
}

/**
* Configure a Vault with the balancer strategy for wstETH/WETH pool
*/
function balancerWstEthFixtureSetup() {
return deployments.createFixture(async () => {
const fixture = await defaultFixture();

const d = balancerStrategyDeployment({
deploymentOpts: {
deployName: "99999_balancer_wstETH_WETH",
forceDeploy: true,
deployerIsProposer: true,
},
proxyContractName: "OETHBalancerMetaPoolwstEthStrategyProxy",

platformAddress: addresses.mainnet.wstETH_WETH_BPT,
poolId: balancer_stETH_WETH_PID,

auraRewardsContractAddress: addresses.mainnet.wstETH_WETH_AuraRewards,

rewardTokenAddresses: [addresses.mainnet.BAL, addresses.mainnet.AURA],
assets: [addresses.mainnet.stETH, addresses.mainnet.WETH],
})

await d(hre)


const balancerWstEthStrategyProxy = await ethers.getContract("OETHBalancerMetaPoolwstEthStrategyProxy")
const balancerWstEthStrategy = await ethers.getContractAt("BalancerMetaPoolStrategy", balancerWstEthStrategyProxy.address)

fixture.balancerWstEthStrategy = balancerWstEthStrategy

const { oethVault, timelock, weth, stETH, josh } =
fixture;

await oethVault
.connect(timelock)
.setAssetDefaultStrategy(stETH.address, balancerWstEthStrategy.address);
await oethVault
.connect(timelock)
.setAssetDefaultStrategy(weth.address, balancerWstEthStrategy.address);

fixture.stEthBPT = await ethers.getContractAt(
"IERC20Metadata",
addresses.mainnet.wstETH_WETH_BPT,
josh
);
fixture.balancerWstEthPID = balancer_stETH_WETH_PID;

fixture.balancerVault = await ethers.getContractAt(
"IBalancerVault",
addresses.mainnet.balancerVault,
josh
);

return fixture;
})
}

async function fundWith3Crv(address, maxAmount) {
Expand Down Expand Up @@ -1656,7 +1718,8 @@ module.exports = {
impersonateAndFundContract,
impersonateAccount,
fraxETHStrategyFixtureSetup,
balancerREthFixture,
balancerREthFixtureSetup,
balancerWstEthFixtureSetup,
oethMorphoAaveFixtureSetup,
mintWETH,
replaceContractAt,
Expand Down
Loading