LibConvert Manual Review Findings

LibConvert Manual Review Findings

LCT-01M: Inexistent Justification of Calculations

Description:

The calculations for the LP necessary to peg are not properly outlined in the whitepaper, utilizing an undocumented 1502253380070105 constant presumably representing ~0.15%.

Example:

protocol/contracts/libraries/LibConvert.sol
79function lpToPeg() internal view returns (uint256 lp) {
80 (uint e, uint b) = reserves();
81 (uint y, uint x) = pegReserves();
82 uint c = sqrt(y*b*1e18/(x*e)).mul(1e9);
83 if (c <= 1e18) return 0;
84 uint num = e*(c.sub(1e18));
85 uint denom = c.sub(1502253380070105);
86 uint eth = num.div(denom);
87 return eth.mul(totalLP()).div(e);
88}

Recommendation:

We advise this section of the code to be properly documented and outlined in the whitepaper for validation. Once that is performed, this finding will be replaced by new findings regarding the lpToPeg function (if any).

Alleviation:

The lpToPeg function has been extensively documented to indicate what the calculation is meant to represent and we have deem the code implementation true to its documentation.

View Fix on GitHub
Navigated to LibConvert Manual Review Findings