Skip to content

Commit

Permalink
fix: Invalid variable assignment in sqrt math (#10194)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->


<!-- start pr-codex -->

---

## PR-Codex overview
This PR fixes an invalid assignment in the `sqrtPriceMath.ts` file of
`@pancakeswap/v3-sdk`.

### Detailed summary
- Fixed invalid assignment in `sqrtPriceMath.ts`
- Swapped values using array destructuring instead of direct assignment

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
chefjackson authored Jul 15, 2024
1 parent 66d6646 commit fe96bb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-flowers-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pancakeswap/v3-sdk': patch
---

Fix invalid assignment in sqrt math
6 changes: 2 additions & 4 deletions packages/v3-sdk/src/utils/sqrtPriceMath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export abstract class SqrtPriceMath {
roundUp: boolean
): bigint {
if (sqrtRatioAX96 > sqrtRatioBX96) {
sqrtRatioAX96 = sqrtRatioBX96
sqrtRatioBX96 = sqrtRatioAX96
;[sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96]
}

const numerator1 = liquidity << 96n
Expand All @@ -47,8 +46,7 @@ export abstract class SqrtPriceMath {
roundUp: boolean
): bigint {
if (sqrtRatioAX96 > sqrtRatioBX96) {
sqrtRatioAX96 = sqrtRatioBX96
sqrtRatioBX96 = sqrtRatioAX96
;[sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96]
}

return roundUp
Expand Down

0 comments on commit fe96bb1

Please sign in to comment.