From 7f55b2ae6611d1461331beabf54f43bb6a0fe772 Mon Sep 17 00:00:00 2001 From: DaveVodrazka Date: Tue, 17 Sep 2024 15:53:53 +0200 Subject: [PATCH] fix: cannot serialize bigint --- .../ImpermanentLoss/ImpermanentLossWidget.tsx | 17 +++++++++++++---- src/components/ImpermanentLoss/getPrice.ts | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/ImpermanentLoss/ImpermanentLossWidget.tsx b/src/components/ImpermanentLoss/ImpermanentLossWidget.tsx index b4f0cf33..1796bc52 100644 --- a/src/components/ImpermanentLoss/ImpermanentLossWidget.tsx +++ b/src/components/ImpermanentLoss/ImpermanentLossWidget.tsx @@ -15,6 +15,7 @@ import { longInteger, shortInteger } from "../../utils/computations"; import { TransactionState } from "../../types/network"; import { useAccount } from "../../hooks/useAccount"; import { useCurrency } from "../../hooks/useCurrency"; +import { openWalletConnectDialog } from "../ConnectWallet/Button"; import styles from "./imp_loss.module.css"; @@ -279,7 +280,15 @@ export const ImpermanentLossWidget = () => {
- {txStatus === TransactionState.Initial && ( + {account === undefined && ( + + )} + {account && txStatus === TransactionState.Initial && ( )} - {txStatus === TransactionState.Success && ( + {account && txStatus === TransactionState.Success && ( )} - {txStatus === TransactionState.Fail && ( + {account && txStatus === TransactionState.Fail && ( )} - {txStatus === TransactionState.Processing && ( + {account && txStatus === TransactionState.Processing && ( diff --git a/src/components/ImpermanentLoss/getPrice.ts b/src/components/ImpermanentLoss/getPrice.ts index 8918ada2..a96d9f3c 100644 --- a/src/components/ImpermanentLoss/getPrice.ts +++ b/src/components/ImpermanentLoss/getPrice.ts @@ -101,7 +101,7 @@ export const buyImpLoss = async ( } const getSizeWithSlippage = (size: bigint, slippage: bigint) => { - return (size * (200n + slippage)) / 100n; + return (size * (100n + slippage)) / 100n; }; const approveBase: Call = { @@ -109,7 +109,7 @@ export const buyImpLoss = async ( entrypoint: "approve", calldata: [ IMP_LOSS_ADDRESS, - getSizeWithSlippage(price.basePrice, 25n), + getSizeWithSlippage(price.basePrice, 10n).toString(10), "0", ], }; @@ -119,7 +119,7 @@ export const buyImpLoss = async ( entrypoint: "approve", calldata: [ IMP_LOSS_ADDRESS, - getSizeWithSlippage(price.quotePrice, 25n), + getSizeWithSlippage(price.quotePrice, 10n).toString(10), "0", ], };