From b0fd0169c327c9e1b5b7c6639b761f7d7421ee72 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 28 May 2024 16:22:37 -0400 Subject: [PATCH] add fix --- .../LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol | 5 +++-- packages/contracts/hardhat.config.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol b/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol index 4b363d99..13c49b6b 100644 --- a/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol +++ b/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol @@ -556,8 +556,9 @@ contract LenderCommitmentGroup_Smart is returns (uint256 price_) { - uint256 priceX96 = (uint256(_sqrtPriceX96) * uint256(_sqrtPriceX96)) / - (2**96); + + + uint256 priceX96 = FullMath.mulDiv(uint256(_sqrtPriceX96), uint256(_sqrtPriceX96), (2**96) ); // sqrtPrice is in X96 format so we scale it down to get the price // Also note that this price is a relative price between the two tokens in the pool diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index e406e4c2..6e139ea8 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -37,7 +37,8 @@ import semver from 'semver' // import { logger as tenderlyLogger } from 'tenderly/utils/logger' const NODE_VERSION = 'v16' -if (!semver.satisfies(process.version, NODE_VERSION)) +const ALT_NODE_VERSION = 'v18' +if (!semver.satisfies(process.version, NODE_VERSION) && !semver.satisfies(process.version, ALT_NODE_VERSION)) throw new Error( `Incorrect NodeJS version being used (${process.version}). Expected: ${NODE_VERSION}` )