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

Wrong Implementation of Continuous Gradual Dutch Auction #85

Closed
code423n4 opened this issue Aug 7, 2023 · 6 comments
Closed

Wrong Implementation of Continuous Gradual Dutch Auction #85

code423n4 opened this issue Aug 7, 2023 · 6 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-24 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/GenerationSoftware/pt-v5-cgda-liquidator/blob/7f95bcacd4a566c2becb98d55c1886cadbaa8897/src/libraries/ContinuousGDA.sol#L39

Vulnerability details

Impact

Breaks the core functionality of the Liquidation Pair contract.

Usage of wrong formula for calculation of Continuous Gradual Dutch Auction results in wrong calculation of purchase price which is basically used to find the swapAmountIn during liquidations .

Proof of Concept

Statements from PoolTogether Code4rena docs:

The LiquidationPair prices yield liquidations using a periodic Continuous Gradual Dutch Auction. It's periodic in the sense that the auction runs in periods that will be aligned with the prize pool periods. At the beginning of each period, the CGDA adjusts the emissions rate and target price so that it adapts to changing market conditions.

PoolTogether implementation of Continuous Gradual Dutch Auction uses formula:

(k/(r))*(e**((lambda)*q)/r)-1)/(e**((lambda)*T)) 

at:
https://github.com/GenerationSoftware/pt-v5-cgda-liquidator/blob/7f95bcacd4a566c2becb98d55c1886cadbaa8897/src/libraries/ContinuousGDA.sol#L39

The original formula of Continuous Gradual Dutch Auction:

(k/(lambda))*(e**((lambda)*q)/r)-1)/(e**((lambda)*T)) 

First Term is k/(lambda) not (k/(r).

Reference :

Official Paradigm Article on CGDA’s which shows the correct formula

Official Github Link of Correct Implementaion of CGDA’s by Paradigm

Tools Used

Manual Review

Recommended Mitigation Steps

Reimplement the first term of Formula as k/(lambda) that is k.div(_decayConstant).

Assessed type

Error

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Aug 7, 2023
code423n4 added a commit that referenced this issue Aug 7, 2023
@raymondfam
Copy link

raymondfam commented Aug 7, 2023

The doc says "... many different price functions can work." So it needs not to be the exact example in the doc.

https://www.paradigm.xyz/2022/04/gda

If ever valid, the severity should be medium.

@c4-pre-sort
Copy link

raymondfam marked the issue as low quality report

@c4-pre-sort c4-pre-sort added the low quality report This report is of especially low quality label Aug 7, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as remove high or low quality report

@c4-pre-sort c4-pre-sort removed the low quality report This report is of especially low quality label Aug 9, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #24

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Aug 14, 2023
@c4-judge
Copy link
Contributor

HickupHH3 marked the issue as satisfactory

@c4-judge
Copy link
Contributor

HickupHH3 changed the severity to 2 (Med Risk)

@c4-judge c4-judge added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-24 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants