Skip to content

Commit

Permalink
add comment and change enum types to uint8
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowDom committed Nov 13, 2023
1 parent 815c310 commit 1062b37
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
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,8 @@ contract BalancerMetaPoolStrategy is BaseAuraStrategy {

/* This check is triggered when the _deposit is called with
* a duplicate asset in the _strategyAssets array
*
*
*/
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

0 comments on commit 1062b37

Please sign in to comment.