From f54535b0f0d0d3035c11ce909335dad1dc4c96fc Mon Sep 17 00:00:00 2001 From: Polybius93 <99192647+Polybius93@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:24:12 +0100 Subject: [PATCH] feat: modifyi lib version, modify modified lib function usage (#214) --- package.json | 2 +- ...action-screen.transaction-form.protocol-fee-box.tsx | 10 ++++++---- yarn.lock | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 46d91a62..0e30fd93 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "concurrently": "^8.2.2", "d3": "^7.9.0", "decimal.js": "^10.4.3", - "dlc-btc-lib": "2.4.12", + "dlc-btc-lib": "2.4.17", "dotenv": "^16.3.1", "ethers": "5.7.2", "formik": "^2.4.5", diff --git a/src/app/components/transaction-screen/transaction-screen.transaction-form/components/transaction-screen.transaction-form/components/transaction-screen.transaction-form.protocol-fee-box.tsx b/src/app/components/transaction-screen/transaction-screen.transaction-form/components/transaction-screen.transaction-form/components/transaction-screen.transaction-form.protocol-fee-box.tsx index 83d75a06..f57abd35 100644 --- a/src/app/components/transaction-screen/transaction-screen.transaction-form/components/transaction-screen.transaction-form/components/transaction-screen.transaction-form.protocol-fee-box.tsx +++ b/src/app/components/transaction-screen/transaction-screen.transaction-form/components/transaction-screen.transaction-form/components/transaction-screen.transaction-form.protocol-fee-box.tsx @@ -2,6 +2,7 @@ import { HStack, Text, VStack } from '@chakra-ui/react'; import { Vault } from '@models/vault'; import Decimal from 'decimal.js'; import { getFeeAmount } from 'dlc-btc-lib/bitcoin-functions'; +import { shiftValue, unshiftValue } from 'dlc-btc-lib/utilities'; interface TransactionFormProtocolFeeStackProps { flow: 'mint' | 'burn'; @@ -37,8 +38,9 @@ export function TransactionFormProtocolFeeStack({ const amount = flow === 'burn' && currentStep === 1 - ? new Decimal(vault.valueLocked).minus(vault.valueMinted).toNumber() - : assetAmount; + ? shiftValue(new Decimal(vault.valueLocked).minus(vault.valueMinted).toNumber()) + : shiftValue(assetAmount!); + return ( - {`${amount && protocolFeeBasisPoints ? getFeeAmount(amount, protocolFeeBasisPoints) : 0} + {`${amount && protocolFeeBasisPoints ? unshiftValue(getFeeAmount(amount, protocolFeeBasisPoints)) : 0} BTC`} {' '} @@ -61,7 +63,7 @@ export function TransactionFormProtocolFeeStack({ {`~ ${ assetAmount && bitcoinPrice && protocolFeeBasisPoints - ? calculateProtocolFeeInUSD(assetAmount, bitcoinPrice, protocolFeeBasisPoints) + ? calculateProtocolFeeInUSD(amount, bitcoinPrice, protocolFeeBasisPoints) : 0 } $`} diff --git a/yarn.lock b/yarn.lock index 1ea11909..a5f40f86 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5195,10 +5195,10 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -dlc-btc-lib@2.4.12: - version "2.4.12" - resolved "https://registry.yarnpkg.com/dlc-btc-lib/-/dlc-btc-lib-2.4.12.tgz#ee206d2ebfa3fe73b9c51cc565d1f5c102b99f22" - integrity sha512-HE6xYFfKRnRp16jRcDhDCmIgcOGfjKWoiQmY2//E8G6Z+VYsJaXsojZmD5M+uMOSQ7B3pwR+MpyURwNNrzKQgQ== +dlc-btc-lib@2.4.17: + version "2.4.17" + resolved "https://registry.yarnpkg.com/dlc-btc-lib/-/dlc-btc-lib-2.4.17.tgz#44ff9dab788562cfa08ad299f65b275f7f7f5ff4" + integrity sha512-8gzJ40MttJHHtO8i0+qMoEtltVCwQ6U7y76w93lI/7jvVs4fBu+HlQvFtmfboNBJF1uAsoO1Hic5W6OzVlIrgQ== dependencies: "@gemwallet/api" "3.8.0" "@ledgerhq/hw-app-btc" "10.4.1"