diff --git a/src/pages/swap.tsx b/src/pages/swap.tsx new file mode 100644 index 0000000..6da17cc --- /dev/null +++ b/src/pages/swap.tsx @@ -0,0 +1,209 @@ +import * as React from 'react' +import Head from 'next/head' +import { utils } from 'near-api-js' +import { Box, Text, Tabs, Tab, Button } from 'grommet' + +import { NearContext } from 'src/near/nearContext' +import { PledgeType, PoolStatsType } from 'src/near/types' + +import { CryptoInput } from 'src/components/CryptoInput' + +const Stake: React.FC = () => { + const { contract, currentUser } = React.useContext(NearContext) + const [depositAmnt, setDepositAmnt] = React.useState() + const [withdrawAmnt, setWithdrawAmnt] = React.useState() + const [isQuid, setIsQuid] = React.useState(false) + const [pledged, setPledged] = React.useState() + const [stats, setStats] = React.useState() + + const currentBalance = isQuid + ? utils.format.formatNearAmount(pledged?.credit || '0') + : utils.format.formatNearAmount(currentUser?.balance || '0') + + const currentSpBalance = isQuid + ? utils.format.formatNearAmount(pledged?.quid_sp || '0') + : utils.format.formatNearAmount(pledged?.near_sp || '0') + + const getNewPledgedAmnt = async () => { + const newPledges = await contract?.get_pledge({ + account: currentUser?.accountId, + }) + setPledged(newPledges) + } + const getStats = async () => { + const newStats = await contract?.get_pool_stats({}) + setStats(newStats) + } + + React.useEffect(() => { + getNewPledgedAmnt() + getStats() + }, [contract]) + + return ( + <> + + qUid Stable Currency - Stake + + + + + + Stake on qUid Solvency Pool + + {/* Deposit and Withdraw Box*/} + + + +
+ + setIsQuid(!isQuid)} + /> +
+