Closed sherlock-admin2 closed 3 months ago
unix515
medium
getLiquidityQuote()
liquidityQuote
HOT#getLiquidityQuote() is always reverted because liquidityQuote was not be updated from HOT#_ammSwap() and HOT#`_hotSwap().
_ammSwap()
function getLiquidityQuote( ALMLiquidityQuoteInput memory _almLiquidityQuoteInput, bytes calldata _externalContext, bytes calldata /*_verifierData*/ ) external override onlyPool onlyUnpaused returns (ALMLiquidityQuote memory liquidityQuote) { if (_externalContext.length == 0) { //<---------- @audit _ammSwap(_almLiquidityQuoteInput, liquidityQuote); } else { //<---------- @audit _hotSwap(_almLiquidityQuoteInput, _externalContext, liquidityQuote); ... } ... }
memory
storage
function _ammSwap( ALMLiquidityQuoteInput memory almLiquidityQuoteInput, ALMLiquidityQuote memory liquidityQuote ) internal { ... } function _hotSwap( ALMLiquidityQuoteInput memory almLiquidityQuoteInput, bytes memory externalContext, ALMLiquidityQuote memory liquidityQuote ) internal { ... }
function getLiquidityQuote( ALMLiquidityQuoteInput memory _almLiquidityQuoteInput, bytes calldata _externalContext, bytes calldata /*_verifierData*/ ) external override onlyPool onlyUnpaused returns (ALMLiquidityQuote memory liquidityQuote) { ... //<-------------- @audit if (liquidityQuote.amountOut == 0) { revert HOT__getLiquidityQuote_zeroAmountOut(); } }
HOT#getLiquidityQuote() is always reverted.
https://github.com/sherlock-audit/2024-03-arrakis/tree/main/valantis-hot/src/HOT.sol#L840-L875
https://github.com/sherlock-audit/2024-03-arrakis/tree/main/valantis-hot/src/HOT.sol#L880-L999
Manual Review
Please update HOT#_ammSwap() and HOT#_hotSwap() as follows.
_hotSwap()
function _ammSwap( ALMLiquidityQuoteInput memory almLiquidityQuoteInput, -- ALMLiquidityQuote memory liquidityQuote ++ ALMLiquidityQuote storage liquidityQuote ) internal { ... } function _hotSwap( ALMLiquidityQuoteInput memory almLiquidityQuoteInput, bytes memory externalContext, -- ALMLiquidityQuote memory liquidityQuote ++ ALMLiquidityQuote storage liquidityQuote ) internal { ... }
unix515
medium
HOT#
getLiquidityQuote()
is always reverted becauseliquidityQuote
is never updated.Summary
HOT#
getLiquidityQuote()
is always reverted becauseliquidityQuote
was not be updated from HOT#_ammSwap()
and HOT#`_hotSwap().Vulnerability Detail
getLiquidityQuote()
,liquidityQuote
should be updated from HOT#_ammSwap()
and HOT#`_hotSwap().liquidityQuote
will keep as initial value, sinceliquidityQuote
is transferred asmemory
, notstorage
.getLiquidityQuote()
is always reverted on the last check statement.Impact
HOT#
getLiquidityQuote()
is always reverted.Code Snippet
https://github.com/sherlock-audit/2024-03-arrakis/tree/main/valantis-hot/src/HOT.sol#L840-L875
https://github.com/sherlock-audit/2024-03-arrakis/tree/main/valantis-hot/src/HOT.sol#L880-L999
Tool used
Manual Review
Recommendation
Please update HOT#
_ammSwap()
and HOT#_hotSwap()
as follows.