Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall2112 committed Jan 2, 2025
1 parent 9348ac8 commit a9d289c
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 163 deletions.
4 changes: 2 additions & 2 deletions apps/dapp/src/assets/images/gold-auctions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,16 @@ const TableHeader = styled.th`
z-index: 1;
`;

const DataRow = styled.tr``;
const DataRow = styled.tr`
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
`;

const DataCell = styled.td`
font-size: 13px;
font-weight: 700;
line-height: 20px;
text-align: left;
padding: 20px 0px 20px 0px;
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
color: ${({ theme }) => theme.palette.brandLight};
&:first-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ const TableHeader = styled.th`
z-index: 1;
`;

const DataRow = styled.tr``;
const DataRow = styled.tr`
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
`;

const DataCell = styled.td`
font-size: 13px;
Expand All @@ -184,7 +186,6 @@ const DataCell = styled.td`
text-align: left;
padding: 20px 0px 20px 0px;
width: 33.33%;
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
color: ${({ theme }) => theme.palette.brandLight};
a {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import styled from 'styled-components';
import { DataTable } from './DataTable';
import { useBidsHistory } from '../hooks/use-bids-history';
import { DaiGoldAuctionInfo } from 'providers/SpiceBazaarProvider';

export const BidHistory = () => {
const { data, loading, error, refetch } = useBidsHistory();
export const BidHistory = ({
auctionInfo,
}: {
auctionInfo: DaiGoldAuctionInfo;
}) => {
const { data, loading, error, refetch } = useBidsHistory(auctionInfo);

return (
<BidHistoryContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { formatToken } from 'utils/formatter';
import { useEffect, useState } from 'react';
import { useSpiceBazaar } from 'providers/SpiceBazaarProvider';
import { formatBigNumber } from 'components/Vault/utils';
import { formatNumberAbbreviated } from 'utils/formatter';
import { ZERO } from 'utils/bigNumber';
import { getTokenInfo } from 'components/Vault/utils';

Expand Down Expand Up @@ -78,6 +79,13 @@ export const BidUSDS = ({
return (numericAmount / daiGoldAuctionInfo.data.priceRatio).toFixed(2);
};

const exceededAmount =
Number(
calculateTGLDAmount(
(Number(inputValue) + Number(currentBidAmount)).toString()
)
) > Number(daiGoldAuctionInfo?.data?.totalAuctionTokenAmount);

return (
<ContentContainer>
<TitleContainer>
Expand Down Expand Up @@ -142,11 +150,18 @@ export const BidUSDS = ({
<ReceiveContainer>
<TempleGoldIcon />
<ReceiveAmount>
{inputValue === ''
{inputValue === '' || exceededAmount
? '0'
: calculateTGLDAmount(
(Number(inputValue) + Number(currentBidAmount)).toString()
)}{' '}
: (() => {
const totalAmount =
Number(inputValue) + Number(currentBidAmount);
const calculatedAmount = calculateTGLDAmount(
totalAmount.toString()
);
return Number(calculatedAmount) > 1e8
? formatNumberAbbreviated(Number(calculatedAmount)).string
: calculatedAmount;
})()}{' '}
TGLD
</ReceiveAmount>
</ReceiveContainer>
Expand All @@ -160,6 +175,16 @@ export const BidUSDS = ({
USDS per TGLD
</ReceiveTextBottom>
</ReceiveAmountContainer>
{exceededAmount && (
<WarningMessage>
<InfoCircle>
<p>i</p>
</InfoCircle>
<MessageText>
<Text>Amount exceeds TGLD auction limit.</Text>
</MessageText>
</WarningMessage>
)}
<WarningMessage>
<InfoCircle>
<p>i</p>
Expand All @@ -176,7 +201,7 @@ export const BidUSDS = ({
<TradeButton
style={{ whiteSpace: 'nowrap', margin: '0px', alignSelf: 'center' }}
onClick={() => handleBidClick(inputValue)}
disabled={!inputValue}
disabled={!inputValue || exceededAmount}
>
SUBMIT BID
</TradeButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useEffect, useCallback } from 'react';
import { bidsHistoryGoldAuction, subgraphQuery } from 'utils/subgraph';
import env from 'constants/env';
import { DaiGoldAuctionInfo } from 'providers/SpiceBazaarProvider';

export type Bid = {
date: string;
Expand All @@ -17,7 +18,9 @@ type UseBidsHistoryReturn = {
refetch: () => void;
};

export const useBidsHistory = (): UseBidsHistoryReturn => {
export const useBidsHistory = (
auctionInfo: DaiGoldAuctionInfo
): UseBidsHistoryReturn => {
const [data, setData] = useState<Bid[] | null>(null);
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
Expand All @@ -27,14 +30,18 @@ export const useBidsHistory = (): UseBidsHistoryReturn => {
return `${hash.slice(0, 16)}...${hash.slice(-8)}`;
};

const daiGoldAuction = env.contracts.spiceBazaar.daiGoldAuction.toLowerCase();
const epoch = auctionInfo.currentEpoch.toString();
const auctionId = `${daiGoldAuction}-${epoch}`;

const fetchData = useCallback(async () => {
setLoading(true);
setError(null);

try {
const response = await subgraphQuery(
env.subgraph.spiceBazaar,
bidsHistoryGoldAuction()
bidsHistoryGoldAuction(auctionId)
);
setData(
response.stableGoldAuctionInstance.bidTransaction.map((r) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const Auctions = () => {
<Chart auctionInfo={daiGoldAuctionInfo} />
</ChartContainer>
<TableContainer>
<BidHistory />
<BidHistory auctionInfo={daiGoldAuctionInfo} />
</TableContainer>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,18 @@ export const StakeTemple = () => {
&nbsp;TEMPLE
</Sum>
<Title>
Your Stake (
{(
(stakePageMetricsData.yourStake /
stakePageMetricsData.stakedTemple) *
100
).toFixed(2)}
% of total)
Your Stake
{stakePageMetricsData.yourStake > 0 && (
<>
(
{(
(stakePageMetricsData.yourStake /
stakePageMetricsData.stakedTemple) *
100
).toFixed(2)}
% of total)
</>
)}
</Title>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,16 @@ const TableHeader = styled.th<{ name: string }>`
z-index: 1;
`;

const DataRow = styled.tr``;
const DataRow = styled.tr`
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
`;

const DataCell = styled.td`
font-size: 13px;
font-weight: 700;
line-height: 20px;
text-align: left;
padding: 20px 0px 20px 0px;
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
color: ${({ theme }) => theme.palette.brandLight};
&:first-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ const TableHeader = styled.th`
z-index: 1;
`;

const DataRow = styled.tr``;
const DataRow = styled.tr`
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
`;

const DataCell = styled.td`
font-size: 13px;
Expand All @@ -208,7 +210,6 @@ const DataCell = styled.td`
text-align: left;
padding: 20px 0px 20px 0px;
width: 33.33%;
border-bottom: 1px solid ${({ theme }) => theme.palette.brand};
color: ${({ theme }) => theme.palette.brandLight};
a {
Expand Down
2 changes: 1 addition & 1 deletion apps/dapp/src/constants/env/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ENABLE_SUBGRAPH_LOGS = ENV_VARS.VITE_ENABLE_SUBGRAPH_LOGS === 'true';

const env: Environment = {
alchemyId: 'AorwfDdHDsEjIX4HPwS70zkVjWqjv5vZ',
rpcUrl: 'https://rpc.ankr.com/eth',
rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
backendUrl: 'https://backend-stage.templedao.link',
tradeTokenListUrl:
'https://sf294otxgnbicood.public.blob.vercel-storage.com/testnet-tokens-BCYU6hCLdzUdj1TvvTOcw5ux8Wxmhj.json',
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/src/enums/ticker-symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum TICKER_SYMBOL {
ETH = 'ETH',
USDC = 'USDC',
USDT = 'USDT',
USDS = 'USDS',
DAI = 'DAI',
WETH = 'WETH',
OHM = 'OHM',
Expand Down
Loading

0 comments on commit a9d289c

Please sign in to comment.