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

FIP-33b: Move BAL to 80% BAL / 20% WETH pool (new Balancer WeightedPool deposit) #373

Merged
merged 17 commits into from
Dec 25, 2021

Conversation

eswak
Copy link
Contributor

@eswak eswak commented Dec 13, 2021

FIP-33b

Move the BAL from the Timelock to the 80% BAL / 20% WETH pool.

New contracts :

BalancerPCVDepositBase

This PCV Deposit is abstract, and intended to be inherited by deposits for Balancer WeightedPools, StablePools, MetaStablePools, etc.

It can :

  • exit pool (burn all LP tokens to get underlying tokens in proportions respecting the current pool state)
  • wrap and unwrap ETH (Balancer uses WETH mostly)
  • set slippage tolerance
  • claim BAL rewards

BalancerPCVDepositWeightedPool

This PCV Deposit is intended to deposit PCV in Balancer WeightedPools (2 tokens, i.e. PoolTwo, or more).

An oracle price feed for each tokens of the pool is required.

Accounting is made in one of the tokens of the pool.

FEI can be minted to match the other tokens deposited - if the deposit is granted minter role.


Unit tests :
image

contract-addresses/dependencies.ts Outdated Show resolved Hide resolved
contracts/pcv/balancer/math/ABDKMath64x64.sol Outdated Show resolved Hide resolved
contracts/pcv/balancer/math/ExtendedMath.sol Outdated Show resolved Hide resolved
target: 'collateralizationOracle',
values: '0',
method: 'swapDeposit(address,address)',
arguments: ['{balDepositWrapper}', '{balancerDepositBalWeth}'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a WETH lens?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess fully reporting in BAL is cool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spicier: what will we do for the 80% TRIBE 20% WETH pool ?

proposals/dao/fip_999.ts Outdated Show resolved Hide resolved
'0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014', // poolId
'300', // max 3% slippage
'0xba100000625a3754423978a60c9317c58a424e3D', // BAL token
[addresses.balUsdCompositeOracle, addresses.chainlinkEthUsdOracleWrapper]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you verified the oracle ordering both in the array and price reporting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will make it more clear with additional tests / invariant checks in validation step

}

/// @notice redeeem all assets from LP pool
function exitPool() external whenNotPaused onlyPCVController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not include a to address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we want to burn the FEI if the pool contains FEI, and if we exitPool on a target directly, it may not be able to burn FEI held or report it properly as protocol-owned. That was my reasoning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still think we should give ourselves the option

}

/// @notice claim BAL rewards associated to this PCV Deposit.
/// Note that if dual incentives are active, this will only claim BAL rewards.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to handle dual incentives case?

Copy link
Contributor Author

@eswak eswak Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can pass an array of distributionIds, amounts, merkle proofs, token addresses, and token distributors, but at this point we might as well call the MerkleOrchard directly 😅 I'm not very convinced about this claimRewards function btw, there are so many parameters, it's going to be more convenient to make an offline documentation on how to claim directly on the merkle orchard (or make a front-end / use Balancer's front-end after they allow to claim for another address)

contracts/pcv/balancer/BalancerPCVDepositWeightedPool.sol Outdated Show resolved Hide resolved
}

// @notice returns the manipulation-resistant balance of tokens & FEI held.
function resistantBalanceAndFei() public view override returns (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about just reusing Lenses for this instead of duplicating code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not. We'd have to improve the Lens to handle more than 2 assets and be able to account only the liquidity owned by the PCVDeposit, and not the whole pool content. But it's doable

@Joeysantoro
Copy link
Contributor

I'd also like to see an integration test probably more than one

@Joeysantoro Joeysantoro mentioned this pull request Dec 14, 2021
20 tasks
@eswak eswak changed the title Balancer WeightedPool deposit FIP-33b: Move BAL to 80% BAL / 20% WETH pool (new Balancer WeightedPool deposit) Dec 23, 2021
@eswak
Copy link
Contributor Author

eswak commented Dec 24, 2021

Added a bunch of e2e tests to use the PCVDeposit in various situations, and took Jeff's review into account

image

Joeysantoro
Joeysantoro previously approved these changes Dec 24, 2021
@Joeysantoro Joeysantoro merged commit 67efb24 into develop Dec 25, 2021
@Joeysantoro Joeysantoro deleted the feat/balancer-weighted-pool branch December 25, 2021 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants