From 0887a418e7e737dd2bba2906ace9633545fd9990 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 24 Feb 2024 17:53:52 +0300 Subject: [PATCH] toDecima Places round up added for the input during approvement --- .../LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx b/spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx index dcc0910f..b7cd14a2 100644 --- a/spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx +++ b/spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx @@ -1,4 +1,5 @@ import React, { PropsWithChildren, useMemo } from "react"; +import BigNumber from "bignumber.js"; import { ethers } from "ethers"; import _ from "lodash"; import { makeAutoObservable, reaction } from "mobx"; @@ -212,12 +213,13 @@ class CreateOrderSpotVM { const quoteToken = market.quoteToken; const activeToken = this.isSell ? baseToken : quoteToken; - const approveAmount = this.isSell ? this.inputAmount : this.inputTotal; + const approveAmount = (this.isSell ? this.inputAmount : this.inputTotal).toDecimalPlaces(0, BigNumber.ROUND_UP); this.setLoading(true); try { const tokenContract = new ethers.Contract(activeToken.assetId, ERC20_ABI, accountStore.signer); + console.log(approveAmount.toString()); const approveTransaction = await tokenContract.approve(CONTRACT_ADDRESSES.spotMarket, approveAmount.toString()); await approveTransaction.wait(); @@ -225,6 +227,7 @@ class CreateOrderSpotVM { notificationStore.toast(`${activeToken.symbol} approved!`, { type: "success" }); } catch (error) { + console.error(error); notificationStore.toast(`Something goes wrong with ${activeToken.symbol} approve`, { type: "error" }); }