File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ library CurveLib {
54
54
unchecked {
55
55
int256 term1 = int256 (Math.mulDiv (py * 1e18 , y - y0, px, Math.Rounding.Ceil)); // scale: 1e36
56
56
int256 term2 = (2 * int256 (c) - int256 (1e18 )) * int256 (x0); // scale: 1e36
57
- B = (term1 - term2) / int256 (1e18 ); // scale: 1e18
57
+ B = (term1 - term2) / int256 (1e18 ); // scale: 1e18
58
58
C = Math.mulDiv ((1e18 - c), x0 * x0, 1e18 , Math.Rounding.Ceil); // scale: 1e36
59
59
fourAC = Math.mulDiv (4 * c, C, 1e18 , Math.Rounding.Ceil); // scale: 1e36
60
60
}
@@ -63,15 +63,15 @@ library CurveLib {
63
63
uint256 squaredB;
64
64
uint256 discriminant;
65
65
uint256 sqrt;
66
- if (absB < 1e36 ) {
66
+ if (absB < 1e36 ) {
67
67
// B^2 can be calculated directly at 1e18 scale without overflowing
68
68
unchecked {
69
69
squaredB = absB * absB; // scale: 1e36
70
70
discriminant = squaredB + fourAC; // scale: 1e36
71
71
sqrt = Math.sqrt (discriminant); // // scale: 1e18
72
72
sqrt = (sqrt * sqrt < discriminant) ? sqrt + 1 : sqrt;
73
73
}
74
- } else {
74
+ } else {
75
75
// B^2 cannot be calculated directly at 1e18 scale without overflowing
76
76
uint256 scale = computeScale (absB); // calculate the scaling factor such that B^2 can be calculated without overflowing
77
77
squaredB = Math.mulDiv (absB / scale, absB, scale, Math.Rounding.Ceil);
You can’t perform that action at this time.
0 commit comments