From 126b6af391016cff11f819c5c25f489fd61a83e8 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 4 Oct 2024 11:24:36 -0700 Subject: [PATCH] Fix precision on toExchangeAmount Broken in b7b8bc5609b1adbb500ddee758a9ffeb8e367ef9 --- CHANGELOG.md | 1 + src/swap/defi/thorchain/common.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eda69a5..aba65f15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - added: (LI.FI) Added unique parent contract addresses +- fixed: Division precision for Thorchain `toExchangeAmount` ## 2.8.1 (2024-10-02) diff --git a/src/swap/defi/thorchain/common.ts b/src/swap/defi/thorchain/common.ts index 980c1f98..ae213b1b 100644 --- a/src/swap/defi/thorchain/common.ts +++ b/src/swap/defi/thorchain/common.ts @@ -1,4 +1,4 @@ -import { add, div, gt, mul, round, sub } from 'biggystring' +import { add, gt, mul, round, sub } from 'biggystring' import { asArray, asBoolean, @@ -888,7 +888,7 @@ const calcSwapFrom = async ({ log(`toThorAmountWithSpread = limit: ${toThorAmountWithSpread}`) - const toExchangeAmount = div(toThorAmountWithSpread, THOR_LIMIT_UNITS) + const toExchangeAmount = div18(toThorAmountWithSpread, THOR_LIMIT_UNITS) log(`toExchangeAmount: ${toExchangeAmount}`) const toNativeAmountFloat = await toWallet.denominationToNative(