BBLeverage::sellCollateral is unusable due to wrong asset deposit attempt in YieldBox
Summary
sellCollateral enable to leverage up on a borrow position in a BigBang market. However the endpoint is unusable as is due to collateralId used to deposit in YieldBox, instead of assetId
cergyk
medium
BBLeverage::sellCollateral is unusable due to wrong asset deposit attempt in YieldBox
Summary
sellCollateral
enable to leverage up on a borrow position in a BigBang market. However the endpoint is unusable as is due tocollateralId
used to deposit in YieldBox, instead ofassetId
Vulnerability Detail
We can see here that after withdrawing
collateral
, and swapping it forasset
,BBLeverage::sellCollateral
attempts to depositcollateralId
into YieldBox: https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLeverage.sol#L149Which will always revert, since at that point we always have
asset
and notcollateral
.This function is thus unusable
Impact
The function
BBLeverage::sellCollateral
will always revert and is unusableCode Snippet
Tool used
Manual Review
Recommendation
Change the deposit to use
assetId
, as is correctly done in SGLLeverage:https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/singularity/SGLLeverage.sol#L135