From fe96bb1e7751837502397d7a6150447877d329f3 Mon Sep 17 00:00:00 2001 From: chefjackson <116779127+chefjackson@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:39:28 +0800 Subject: [PATCH] fix: Invalid variable assignment in sqrt math (#10194) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## 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}` --- .changeset/weak-flowers-decide.md | 5 +++++ packages/v3-sdk/src/utils/sqrtPriceMath.ts | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changeset/weak-flowers-decide.md diff --git a/.changeset/weak-flowers-decide.md b/.changeset/weak-flowers-decide.md new file mode 100644 index 0000000000000..0349ccd52fec3 --- /dev/null +++ b/.changeset/weak-flowers-decide.md @@ -0,0 +1,5 @@ +--- +'@pancakeswap/v3-sdk': patch +--- + +Fix invalid assignment in sqrt math diff --git a/packages/v3-sdk/src/utils/sqrtPriceMath.ts b/packages/v3-sdk/src/utils/sqrtPriceMath.ts index 8d2b202e57447..46412e4c8d292 100644 --- a/packages/v3-sdk/src/utils/sqrtPriceMath.ts +++ b/packages/v3-sdk/src/utils/sqrtPriceMath.ts @@ -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 @@ -47,8 +46,7 @@ export abstract class SqrtPriceMath { roundUp: boolean ): bigint { if (sqrtRatioAX96 > sqrtRatioBX96) { - sqrtRatioAX96 = sqrtRatioBX96 - sqrtRatioBX96 = sqrtRatioAX96 + ;[sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96] } return roundUp