From 381581dfd92925967e721676af4d5b1829d906d6 Mon Sep 17 00:00:00 2001 From: mstfash Date: Wed, 24 May 2023 18:21:59 +0300 Subject: [PATCH 1/2] auctions addons --- src/containers/Auctions/index.tsx | 62 +++++++++++++++++++++++++++++++ src/hooks/useAuctions.ts | 62 ++++++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/src/containers/Auctions/index.tsx b/src/containers/Auctions/index.tsx index b2580086..4bf6a88c 100644 --- a/src/containers/Auctions/index.tsx +++ b/src/containers/Auctions/index.tsx @@ -8,6 +8,9 @@ import Modal from '../../components/Modals/Modal' import { useActiveWeb3React } from '../../hooks' import { useStoreActions } from '../../store' import AuctionsList from './AuctionsList' +import { useStartSurplusAuction } from 'src/hooks/useAuctions' +import { handleTransactionError } from 'src/hooks/TransactionHooks' +import { formatNumber } from 'src/utils/helper' export type AuctionEventType = 'DEBT' | 'SURPLUS' | 'STAKED_TOKEN' @@ -22,6 +25,26 @@ const Auctions = ({ const [showFaqs, setShowFaqs] = useState(false) const [type, setType] = useState('SURPLUS') const [error, setError] = useState('') + const [isLoading, setIsLoading] = useState(false) + const { startSurplusAcution, surplusAmountToSell } = + useStartSurplusAuction() + + const handleStartSurplusAuction = async () => { + setIsLoading(true) + try { + popupsActions.setIsWaitingModalOpen(true) + popupsActions.setWaitingPayload({ + title: 'Waiting For Confirmation', + hint: 'Confirm this transaction in your wallet', + status: 'loading', + }) + await startSurplusAcution() + } catch (e) { + handleTransactionError(e) + } finally { + setIsLoading(false) + } + } useEffect(() => { async function init() { @@ -118,6 +141,26 @@ const Auctions = ({ )} + {type === 'SURPLUS' && account ? ( + + + + + Surplus Amount to Sell:{' '} + + + {formatNumber(surplusAmountToSell, 2)} RAI + + +