Settlement slippage is not implemented correctly which may lead to some vaults being impossible to settle
The settlement function ignores the user-supplied oracle slippage parameter and instead applies a fixed pool slippage limit. If market slippage exceeds that fixed limit, settlement becomes impossible.
Source: https://github.com/sherlock-audit/2022-09-notional-judging/issues/42
Found by
0x52
Summary
The contract is supposed to implement a different max slippage value depending on the settlement type, but these values have no impact because they are never actually applied. Instead, regardless of settlement type or function inputs, max slippage will always be limited to the value of balancerPoolSlippageLimitPercent. This can be problematic because the default value allows only 1% slippage. If settlement slippage goes outside of 1% then settlement of any kind will become impossible.
Vulnerability Detail
Boosted3TokenAuraHelper.sol#L95-L99
params.minPrimary = poolContext._getTimeWeightedPrimaryBalance(
oracleContext, strategyContext, bptToSettle
);
params.minPrimary = params.minPrimary * strategyContext.vaultSettings.balancerPoolSlippageLimitPercent /
uint256(BalancerConstants.VAULT_PERCENT_BASIS);
Boosted3TokenAuraHelper#_executeSettlement first sets params.minPrimary overwriting any value from function input. Next it adjusts minPrimary by balancerPoolSlippageLimitPercent, which is a constant set at pool creation; however it doesn't ever adjust it by Params.DynamicTradeParams.oracleSlippagePercent. This means that the max possible slippage regardless of settlement type is limited to the slippage allowed by balancerPoolSlippageLimitPercent. If the max slippage ever goes outside of this range, then settlement of any kind will become impossible.
Impact
Settlement may become impossible
Code Snippet
Boosted3TokenAuraHelper.sol#L85-L113
Tool used
Manual Review
Recommendation
Params.DynamicTradeParams.oracleSlippagePercent is validated in every scenario before Boosted3TokenAuraHelper#_executeSettlement is called, so we can apply these values directly when calculating minPrimary:
params.minPrimary = poolContext._getTimeWeightedPrimaryBalance(
oracleContext, strategyContext, bptToSettle
);
+ DynamicTradeParams memory callbackData = abi.decode(
+ params.secondaryTradeParams, (DynamicTradeParams)
+ );
- params.minPrimary = params.minPrimary * strategyContext.vaultSettings.balancerPoolSlippageLimitPercent /
+ params.minPrimary = params.minPrimary *
+ (strategyContext.vaultSettings.balancerPoolSlippageLimitPercent - callbackData.oracleSlippagePercent) /
uint256(BalancerConstants.VAULT_PERCENT_BASIS);
Discussion
jeffywu
@weitianjie2000
weitianjie2000
not valid, balancerPoolSlippageLimitPercent is configurable and can be updated by governance
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The settlement function overwrites the minimum primary balance using only the pool's fixed slippage limit, ignoring the dynamic oracle slippage parameter.
Impact
Settlement of any kind may become impossible if the required slippage exceeds the fixed pool limit.
What the attacker needed
Settlement slippage exceeds pool limit
The fix
The contract should incorporate the dynamic oracle slippage parameter when calculating the minimum primary balance, as shown in the recommendation.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When settling a trade, the contract is supposed to allow a user-specified amount of price slippage. Instead, it always uses a fixed limit set when the pool was created. If the real price moves more than that fixed limit, the settlement fails and cannot be completed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.