Closed sherlock-admin closed 10 months ago
Target is updated with the current R state before each swap action.
Hi @Skyewwww could you point me to the logic where the swap action invokes update to the target based on current R state?
Hi @Skyewwww could you point me to the logic where the swap action invokes update to the target based on current R state?
Hi, please refer to the querySellQuote
/querySellBase
. The target is updated using getPMMState()
.
function getPMMState() public view returns (PMMPricing.PMMState memory state) {
state.i = _I_;
state.K = _K_;
state.B = _BASE_RESERVE_;
state.Q = _QUOTE_RESERVE_;
state.B0 = _BASE_TARGET_; // will be calculated in adjustedTarget
state.Q0 = _QUOTE_TARGET_;
state.R = PMMPricing.RState(_RState_);
PMMPricing.adjustedTarget(state);
}
function adjustedTarget(PMMState memory state) internal pure {
if (state.R == RState.BELOW_ONE) {
state.Q0 = DODOMath._SolveQuadraticFunctionForTarget(
state.Q,
state.B - state.B0,
state.i,
state.K
);
} else if (state.R == RState.ABOVE_ONE) {
state.B0 = DODOMath._SolveQuadraticFunctionForTarget(
state.B,
state.Q - state.Q0,
DecimalMath.reciprocalFloor(state.i),
state.K
);
}
}
nuthan2x
medium
Pool balancing swappers aren't attracted due to unupdated target state after sync action
Summary
More pool balancers could have been attracted whenever there's a reserve change. But DODO v3 GSP doesn't update on certain actions.
Vulnerability Detail
R state
and reserves.sellBase
andsellQuote
actions meaning the_BASE_TARGET_
is updated aftersellBase
action, but what if quote tokens are sent and sellBase action is called. Now reserves are changed, but the targets aren't. So reduction in attraction of pool balancers(arbitragers).Impact
Missing out the involvement of pool balancers due to unUpdated target states.
Code Snippet
Tool used
Manual Review
Recommendation
sync
function.