From e7785d0ccf065771a095f2e30b801dc0ab1f2dfc Mon Sep 17 00:00:00 2001 From: Brean0 Date: Wed, 2 Aug 2023 10:51:43 -0500 Subject: [PATCH] safeMath --- protocol/contracts/ecosystem/price/BeanstalkPrice.sol | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/protocol/contracts/ecosystem/price/BeanstalkPrice.sol b/protocol/contracts/ecosystem/price/BeanstalkPrice.sol index b3fc4698d5..c2e7dfa3e8 100644 --- a/protocol/contracts/ecosystem/price/BeanstalkPrice.sol +++ b/protocol/contracts/ecosystem/price/BeanstalkPrice.sol @@ -3,10 +3,10 @@ pragma solidity =0.7.6; pragma experimental ABIEncoderV2; import "./CurvePrice.sol"; -import {WellPrice, C} from "./WellPrice.sol"; +import {WellPrice, C, SafeMath} from "./WellPrice.sol"; contract BeanstalkPrice is CurvePrice, WellPrice { - + using SafeMath for uint256; struct Prices { uint256 price; @@ -20,13 +20,11 @@ contract BeanstalkPrice is CurvePrice, WellPrice { p.ps[0] = getCurve(); p.ps[1] = getConstantProductWell(C.BEAN_ETH_WELL); - - for (uint256 i = 0; i < p.ps.length; i++) { - p.price += p.ps[i].price * p.ps[i].liquidity; + p.price += p.ps[i].price.mul(p.ps[i].liquidity); p.liquidity += p.ps[i].liquidity; p.deltaB += p.ps[i].deltaB; } - p.price /= p.liquidity; + p.price = p.price.div(p.liquidity); } } \ No newline at end of file