Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit Fix #243 - MulDiv for Uniswap Ratio #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
)
Expand Down
Loading