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

L-01, L-02 & L-03 addendum #1929

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
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ contract BalancerComposablePoolStrategy is BalancerMetaPoolStrategy {
internal
pure
override
returns (uint256)
returns (uint8)
{
return
uint256(
uint8(
IBalancerVault
.ComposablePoolExitKind
.BPT_IN_FOR_EXACT_TOKENS_OUT
Expand All @@ -65,10 +65,10 @@ contract BalancerComposablePoolStrategy is BalancerMetaPoolStrategy {
internal
pure
override
returns (uint256)
returns (uint8)
{
return
uint256(
uint8(
IBalancerVault
.ComposablePoolExitKind
.EXACT_BPT_IN_FOR_ALL_TOKENS_OUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract BalancerMetaPoolStrategy is BaseAuraStrategy {
using StableMath for uint256;

/// @dev Special ExitKind for all Balancer pools, used in Recovery Mode.
uint256 constant RECOVERY_MODE_EXIT_KIND = 255;
uint8 constant RECOVERY_MODE_EXIT_KIND = 255;

int256[50] private ___reserved;

Expand All @@ -37,14 +37,9 @@ contract BalancerMetaPoolStrategy is BaseAuraStrategy {
* request exactly specifies the amount of underlying assets
* to be returned.
*/
function _btpInExactTokensOutIndex()
internal
pure
virtual
returns (uint256)
{
function _btpInExactTokensOutIndex() internal pure virtual returns (uint8) {
return
uint256(
uint8(
IBalancerVault
.MetaStablePoolExitKind
.BPT_IN_FOR_EXACT_TOKENS_OUT
Expand All @@ -55,14 +50,9 @@ contract BalancerMetaPoolStrategy is BaseAuraStrategy {
* @dev enum Value that represents exit encoding where BPT tokens are supplied for
* proportional exit is required when calling a withdrawAll.
*/
function _exactBptInTokensOutIndex()
internal
pure
virtual
returns (uint256)
{
function _exactBptInTokensOutIndex() internal pure virtual returns (uint8) {
return
uint256(
uint8(
IBalancerVault
.MetaStablePoolExitKind
.EXACT_BPT_IN_FOR_TOKENS_OUT
Expand Down Expand Up @@ -169,6 +159,9 @@ contract BalancerMetaPoolStrategy is BaseAuraStrategy {

/* This check is triggered when the _deposit is called with
* a duplicate asset in the _strategyAssets array
*
* A duplicate asset supplied with 0 amount or an amount close to
* 0 that wraps to a 0 amount will still pass this check.
*/
require(
amountsIn[assetIndex] == 0,
Expand Down
21 changes: 21 additions & 0 deletions contracts/test/strategies/balancerMetaStablePool.fork-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,27 @@ describe("ForkTest: Balancer MetaStablePool rETH/WETH Strategy", function () {
).to.be.revertedWith("No duplicate withdrawal assets");
});

/* Ideally this would also revert, but that would make the withdrawal function more gas expensive
* and doesn't seem like a good trade-off.
*/
it(`Should succeed when duplicating an asset and first amount being 0`, async function () {
const { balancerREthStrategy, oethVault, weth } = fixture;

const oethVaultSigner = await impersonateAndFund(oethVault.address);
const zeroAmount = await units("0", weth);
const wethWithdrawAmount = await units("1", weth);

// prettier-ignore
await expect(
balancerREthStrategy
.connect(oethVaultSigner)["withdraw(address,address[],uint256[])"](
oethVault.address,
[weth.address, weth.address],
[zeroAmount, wethWithdrawAmount]
)
).to.not.be.reverted;
});

it("Should be able to withdraw all of pool liquidity", async function () {
const { oethVault, weth, reth, balancerREthStrategy } = fixture;

Expand Down
Loading