diff --git a/src/containers/Auctions/index.tsx b/src/containers/Auctions/index.tsx index b2580086..b00c70e7 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,31 @@ const Auctions = ({ const [showFaqs, setShowFaqs] = useState(false) const [type, setType] = useState('SURPLUS') const [error, setError] = useState('') + const [isLoading, setIsLoading] = useState(false) + const { + startSurplusAcution, + surplusAmountToSell, + accountingEngineSurplus, + allowStartSurplusAuction, + deltaToStartSurplusAuction, + } = 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 +146,57 @@ const Auctions = ({ )} + {type === 'SURPLUS' && account ? ( + + +
+ + + System Surplus:{' '} + + + {formatNumber( + accountingEngineSurplus as string, + 2 + )}{' '} + RAI + + + + + Surplus Amount to Sell:{' '} + + + {formatNumber( + surplusAmountToSell as string, + 2 + )}{' '} + RAI + + + + {allowStartSurplusAuction ? null : ( + + ( + {formatNumber( + String(deltaToStartSurplusAuction), + 2 + )}{' '} + RAI) to start an auction + + )} +
+