From 9c90b8ebdfe7467f8aff6239a533fe18bfa8ff91 Mon Sep 17 00:00:00 2001 From: owen05 Date: Sun, 24 Apr 2022 11:29:20 +0800 Subject: [PATCH] update math --- contracts/lib/DODOMath.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/lib/DODOMath.sol b/contracts/lib/DODOMath.sol index 9347ce7..18e560d 100644 --- a/contracts/lib/DODOMath.sol +++ b/contracts/lib/DODOMath.sol @@ -68,9 +68,6 @@ library DODOMath { uint256 i, uint256 k ) internal pure returns (uint256) { - // if (V1 == 0) { - // return 0; - // } if (k == 0) { return V1.add(DecimalMath.mulFloor(i, delta)); } @@ -78,6 +75,10 @@ library DODOMath { // sqrt = √(1+4kidelta/V1) // premium = 1+(sqrt-1)/2k // uint256 sqrt = (4 * k).mul(i).mul(delta).div(V1).add(DecimalMath.ONE2).sqrt(); + + if (V1 == 0) { + return 0; + } uint256 sqrt; uint256 ki = (4 * k).mul(i); if (ki == 0) {