diff --git a/contracts/transmuter/libraries/LibHelpers.sol b/contracts/transmuter/libraries/LibHelpers.sol index c737ffc8..b6cbb026 100644 --- a/contracts/transmuter/libraries/LibHelpers.sol +++ b/contracts/transmuter/libraries/LibHelpers.sol @@ -73,7 +73,8 @@ library LibHelpers { /// @dev The values in the `xArray` must be increasing function piecewiseLinear(uint64 x, uint64[] memory xArray, int64[] memory yArray) internal pure returns (int64) { uint256 indexLowerBound = findLowerBound(true, xArray, 1, x); - if (indexLowerBound == xArray.length - 1) return yArray[xArray.length - 1]; + if (indexLowerBound == 0 && x < xArray[0]) return yArray[0]; + else if (indexLowerBound == xArray.length - 1) return yArray[xArray.length - 1]; return yArray[indexLowerBound] + ((yArray[indexLowerBound + 1] - yArray[indexLowerBound]) * int64(x - xArray[indexLowerBound])) /