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

bughuntoor - If position goes to 0, the funding fees it should've received are never redistributed and are forever stuck #93

Closed
sherlock-admin4 opened this issue Sep 9, 2024 · 8 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected Medium A Medium severity issue. Reward A payout will be made for this issue Sponsor Disputed The sponsor disputed this issue's validity

Comments

@sherlock-admin4
Copy link
Contributor

sherlock-admin4 commented Sep 9, 2024

bughuntoor

Medium

If position goes to 0, the funding fees it should've received are never redistributed and are forever stuck

Summary

If position goes to 0, the funding fees it should've received are never redistributed and are forever stuck

Vulnerability Detail

If a user position's collateral goes to 0, the user loses all of it, including any funding fees they should've received

  # 1) we penalize negative positions by setting their funding_received to zero
  funding_received: uint256       = 0 if remaining == 0 else (
    # 2) funding_received may add up to more than available collateral, and
    #    we will pay funding fees out on a first come first serve basis
                                    min(fees.funding_received, avail) )

However, the problem is that the amount they should've received is later not subtracted from the collateral and will remain permanently stuck.

For this reason, we can see that FeesPaid has a funding_received_want arg which is intended to be used for that exact reason but is actually never used.

Impact

Loss of funds

Code Snippet

https://github.com/sherlock-audit/2024-08-velar-artha/blob/main/gl-sherlock/contracts/positions.vy#L268

Tool used

Manual Review

Recommendation

Use the intended funding_received_want and subtract it from the collateral so it is not stuck and instead redistributed to LP providers

Duplicate of #83

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Sep 11, 2024
@sherlock-admin3 sherlock-admin3 changed the title Kind Banana Sloth - If position goes to 0, the funding fees it should've received are never redistributed and are forever stuck bughuntoor - If position goes to 0, the funding fees it should've received are never redistributed and are forever stuck Sep 11, 2024
@sherlock-admin3 sherlock-admin3 added the Non-Reward This issue will not receive a payout label Sep 11, 2024
@spacegliderrrr
Copy link
Collaborator

Escalate

Issue should be a dup of #18. However, sponsor comments must be taken into account:

this is intentional, if you read through the worst case scenario, skimming fees and keeping them in the collateral pool works as a kind of emergent insurance fund (obv both this and the worst case scenario are extremely unlikely to actually happen since liq bots would have to be down at just thw wrong time for quite a while)

Will leave at HoJ discretion whether this should be low.

@sherlock-admin3
Copy link
Contributor

Escalate

Issue should be a dup of #18. However, sponsor comments must be taken into account:

this is intentional, if you read through the worst case scenario, skimming fees and keeping them in the collateral pool works as a kind of emergent insurance fund (obv both this and the worst case scenario are extremely unlikely to actually happen since liq bots would have to be down at just thw wrong time for quite a while)

Will leave at HoJ discretion whether this should be low.

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@ami0x226
Copy link

ami0x226 commented Sep 12, 2024

This issue should be low. The position should be liquidated before collateral becomes zero by liquidation bot like #18

@WangSecurity
Copy link

WangSecurity commented Sep 18, 2024

This is indeed a duplicate of #18, but #18 is escalated. Hence, if #18 is in the end invalid, then this escalation will be rejected. If #18 is in the end valid, then this escalation will be accepted and the issue duplicated with #18.

The main discussion will remain on #18.

@rickkk137
Copy link

also #83

@WangSecurity
Copy link

Result:
Invalid
Unique

@sherlock-admin2 sherlock-admin2 removed the Escalated This issue contains a pending escalation label Sep 24, 2024
@sherlock-admin3 sherlock-admin3 added the Escalation Resolved This issue's escalations have been approved/rejected label Sep 24, 2024
@sherlock-admin4
Copy link
Contributor Author

Escalations have been resolved successfully!

Escalation status:

@WangSecurity
Copy link

This issue is duplicated with #83, look into this comment for details #83 (comment)

@WangSecurity WangSecurity added Medium A Medium severity issue. and removed Excluded Excluded by the judge without consulting the protocol or the senior labels Oct 12, 2024
@sherlock-admin2 sherlock-admin2 added Reward A payout will be made for this issue and removed Non-Reward This issue will not receive a payout labels Oct 12, 2024
@sherlock-admin3 sherlock-admin3 added the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Oct 12, 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 Escalation Resolved This issue's escalations have been approved/rejected Medium A Medium severity issue. Reward A payout will be made for this issue Sponsor Disputed The sponsor disputed this issue's validity
Projects
None yet
Development

No branches or pull requests

7 participants