The documentation states that the max collateral ratio on a short is 15x. When you open a short or increase collateral, there is a check to be sure that your position isn't over the max collateral ratio, but there is no check for this when you combine shorts. If the purpose is to enforce that people are capital efficient, then it makes sense to prevent the combined short from exceeding the max collateral ratio when shorts are combined as well.
function combineShorts(address asset, uint8[] memory ids)
external
isNotFrozen(asset)
nonReentrant
onlyValidShortRecord(asset, msg.sender, ids[0])
{
if (ids.length < 2) revert Errors.InsufficientNumberOfShorts();
STypes.ShortRecord storage firstShort = s.shortRecords[asset][msg.sender][ids[0]];
MTypes.CombineShorts memory c;
c.shortFlagExists = firstShort.flaggerId != 0;
c.shortUpdatedAt = firstShort.updatedAt;
address _asset = asset;
uint88 collateral;
uint88 ercDebt;
uint256 yield;
uint256 ercDebtSocialized;
for (uint256 i = ids.length - 1; i > 0; i--) {
uint8 _id = ids[i];
_onlyValidShortRecord(_asset, msg.sender, _id);
STypes.ShortRecord storage currentShort =
s.shortRecords[_asset][msg.sender][_id];
if (!c.shortFlagExists) {
if (currentShort.flaggerId != 0) {
c.shortFlagExists = true;
}
}
if (currentShort.updatedAt > c.shortUpdatedAt) {
c.shortUpdatedAt = currentShort.updatedAt;
}
{
uint88 currentShortCollateral = currentShort.collateral;
uint88 currentShortErcDebt = currentShort.ercDebt;
collateral += currentShortCollateral;
ercDebt += currentShortErcDebt;
yield += currentShortCollateral.mul(currentShort.zethYieldRate);
ercDebtSocialized += currentShortErcDebt.mul(currentShort.ercDebtRate);
}
if (currentShort.tokenId != 0) {
if (firstShort.tokenId == 0) {
revert Errors.FirstShortMustBeNFT();
}
LibShortRecord.burnNFT(currentShort.tokenId);
}
LibShortRecord.deleteShortRecord(_asset, msg.sender, _id);
}
firstShort.merge(ercDebt, ercDebtSocialized, collateral, yield, c.shortUpdatedAt);
if (c.shortFlagExists) {
if (
firstShort.getCollateralRatioSpotPrice(
LibOracle.getSavedOrSpotOraclePrice(_asset)
) < LibAsset.primaryLiquidationCR(_asset)
) revert Errors.InsufficientCollateral();
firstShort.resetFlag();
}
emit Events.CombineShorts(asset, msg.sender, ids);
You are allowing people to be less capital efficient than you want. If you are going to have a max collateral ratio to encourage capital efficency, it should also apply to combined shorts.