Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X12 - Portocol fee on liquidations is calculated wrongly #105

Closed
sherlock-admin3 opened this issue Aug 24, 2024 · 0 comments
Closed

X12 - Portocol fee on liquidations is calculated wrongly #105

sherlock-admin3 opened this issue Aug 24, 2024 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. Reward A payout will be made for this issue

Comments

@sherlock-admin3
Copy link

sherlock-admin3 commented Aug 24, 2024

X12

Medium

Portocol fee on liquidations is calculated wrongly

Summary

Protocol fees on liquidations are calculated incorrectly, which could lead to bad debt if enabled.

Vulnerability Detail

The README indicates that the current liquidation fee is 0% but is expected to increase to 20%-30% in the near future.

Liquidation Fee = 0 (Might be increased to 20-30% in the future)

However, the fee is taken from the entire asset amount rather than the liquidator's profit. For example, if a liquidator repays $90 for a position and receives $100, a 20% fee would leave them with only $80 in value, causing him to occur a loss.

https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/main/protocol-v2/src/PositionManager.sol#L476-L480

    //@audit fee is taken from asset amount, not profit
    uint256 fee = liquidationFee.mulDiv(assetData[i].amt, 1e18);
    Position(payable(position)).transfer(owner(), assetData[i].asset, fee);
    Position(payable(position)).transfer(msg.sender, assetData[i].asset, assetData[i].amt - fee);

This approach means that a liquidation fee above LIQUIDATION_DISCOUNT (10%) could discourage liquidations, leading to bad debt. Even a fee below 10% could reduce liquidators' profits, making them less likely to liquidate if the price moves significantly.

Impact

Liquidators may not be incentivized to liquidate, leading to the system accruing bad debt.

Tool Used

Manual Review

Recommendation

Revise the formula to calculate the fee based on the liquidator's profit rather than the total asset value.

Duplicate of #91

@github-actions github-actions bot closed this as completed Sep 5, 2024
@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. labels Sep 5, 2024
@sherlock-admin4 sherlock-admin4 changed the title Sharp Sapphire Ferret - Portocol fee on liquidations is calculated wrongly X12 - Portocol fee on liquidations is calculated wrongly Sep 15, 2024
@sherlock-admin4 sherlock-admin4 added the Reward A payout will be made for this issue label Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A Medium severity issue. Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

2 participants