After closing synthetix position we don't update global data for liquidations
*issue-contents*
0 CONTENTS
- 1................................................................................
- 2................................................................................
- 3................................................................................
- 4................................................................................
- 5................................................................................
- 6................................................................................
- 7................................................................................
- 8................................................................................
- 9................................................................................
1 METADATA
Number | 178 |
---|---|
Severity | High |
Author | valuevalk |
Contest | Autonomint |
Platform | Sherlock |
2 SUMMARY
After admin closes synthetix position we don’t update any global variables, which means that dCDS depositors and the whole protocol cannot benefit from the liquidation and the potential gains from its shorted position.
3 ROOT CAUSE
closeThePositionInSynthetix()
function in
only closes the position and does not update any global variables like in the
borrowLiquidation.solliquidation type 1
function closeThePositionInSynthetix() external onlyBorrowingContract {
(, uint128 ethPrice) = borrowing.getUSDValue(borrowing.assetAddress(IBorrowing.AssetName.ETH));
// Submit an order to close all positions in synthetix
synthetixPerpsV2.submitOffchainDelayedOrder(-synthetixPerpsV2.positions(address(this)).size, ethPrice * 1e16);
}
For reference in liquidation type 1 we update many values to make the protocol aware of the fact that we have a position liquidated and its collateral is ready to be taken from dCDS depositors opted-in for that. ( other values related to yield for ABOND also shall be updated, just like in liquidation type 1 )
// Update the CDS data
cds.updateLiquidationInfo(omniChainData.noOfLiquidations, liquidationInfo);
cds.updateTotalCdsDepositedAmount(cdsAmountToGetFromThisChain);
cds.updateTotalCdsDepositedAmountWithOptionFees(cdsAmountToGetFromThisChain);
cds.updateTotalAvailableLiquidationAmount(cdsAmountToGetFromThisChain);
omniChainData.collateralProfitsOfLiquidators += depositDetail.depositedAmountInETH;
// Update the global data
omniChainData.totalCdsDepositedAmount -= liquidationAmountNeeded - cdsProfits; //! need to revisit this
omniChainData.totalCdsDepositedAmountWithOptionFees -= liquidationAmountNeeded - cdsProfits;
omniChainData.totalAvailableLiquidationAmount -= liquidationAmountNeeded - cdsProfits;
omniChainData.totalInterestFromLiquidation += uint256(borrowerDebt - depositDetail.borrowedAmount);
omniChainData.totalVolumeOfBorrowersAmountinWei -= depositDetail.depositedAmountInETH;
omniChainData.totalVolumeOfBorrowersAmountinUSD -= depositDetail.depositedAmountUsdValue;
omniChainData.totalVolumeOfBorrowersAmountLiquidatedInWei += depositDetail.depositedAmountInETH;
// Update totalInterestFromLiquidation
uint256 totalInterestFromLiquidation = uint256(borrowerDebt - depositDetail.borrowedAmount);
// Update individual collateral data
--collateralData.noOfIndices;
collateralData.totalDepositedAmount -= depositDetail.depositedAmount;
collateralData.totalDepositedAmountInETH -= depositDetail.depositedAmountInETH;
collateralData.totalLiquidatedAmount += depositDetail.depositedAmount;
// Calculate the yields
uint256 yields = depositDetail.depositedAmount - ((depositDetail.depositedAmountInETH * 1 ether) / exchangeRate);
// Update treasury data
treasury.updateTotalVolumeOfBorrowersAmountinWei(depositDetail.depositedAmountInETH);
treasury.updateTotalVolumeOfBorrowersAmountinUSD(depositDetail.depositedAmountUsdValue);
treasury.updateDepositedCollateralAmountInWei(depositDetail.assetName, depositDetail.depositedAmountInETH);
treasury.updateDepositedCollateralAmountInUsd(depositDetail.assetName, depositDetail.depositedAmountUsdValue);
treasury.updateTotalInterestFromLiquidation(totalInterestFromLiquidation);
treasury.updateYieldsFromLiquidatedLrts(yields);
treasury.updateDepositDetails(user, index, depositDetail);
globalVariables.updateCollateralData(depositDetail.assetName, collateralData);
globalVariables.setOmniChainData(omniChainData);
4 INTERNAL PRE-CONDITIONS
No response
5 EXTERNAL PRE-CONDITIONS
No response
6 ATTACK PATH
- Liquidation Type 2 occurs.
- 1x short position is submitted for the liquidated collateral
- After some time and profits from the short position, admin closes it
- Global variables are not updated, which means that the collateral is unused.
7 IMPACT
- The dCDS depositors won’t be able to withdraw their portion of that liquidation, as we never registered it on the global omnichain fields.
8 POC
No response
9 MITIGATION
After closing the short position update the global variables, so the protocol can work with the collateral thats now available to be withdrawn from dCDS depositors. Other factors such as yield for abond apply as well.
LINKS
*issue-links*
- 1.