From 0887a418e7e737dd2bba2906ace9633545fd9990 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 24 Feb 2024 17:53:52 +0300 Subject: [PATCH 1/2] 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" }); } From 4f8bf2960508c5865c9cba912387d564d38f3ef8 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 26 Feb 2024 18:49:00 +0300 Subject: [PATCH 2/2] log deleted --- .../TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx | 1 - 1 file changed, 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 b7cd14a2..23201890 100644 --- a/spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx +++ b/spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx @@ -219,7 +219,6 @@ class CreateOrderSpotVM { 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();