Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export default function OpenOrdersTable(props: OpenOrdersTableProps) {
}, [data, selectedFilter, symbol]);

const viewAllLink = useMemo(() => {
return `${EXTERNAL_PAGE_URL_PREFIX}/openOrders/${debugWallet.address}`;
return debugWallet.address
? `${EXTERNAL_PAGE_URL_PREFIX}/openOrders/${debugWallet.address}`
: `${EXTERNAL_PAGE_URL_PREFIX}/openOrders`;
}, [debugWallet.address]);

return (
Expand Down
20 changes: 15 additions & 5 deletions packages/frontend/app/routes/fundingHistory/fundingHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@ import { useParams } from 'react-router';
import ExternalPage from '~/components/ExternalPage/ExternalPage';
import FundingHistoryTable from '~/components/Trade/FundingHistoryTable/FundingHistoryTable';
import { useInfoApi } from '~/hooks/useInfoApi';
import { useDebugStore } from '~/stores/DebugStore';
import type { UserFundingIF } from '~/utils/UserDataIFs';

function FundingHistory() {
const { address } = useParams<{ address: string }>();

const walletAddress = useDebugStore((s) => s.debugWallet.address);

const targetAddress = address ?? walletAddress;

const [isFetched, setIsFetched] = useState(false);

const [loading, setLoading] = useState(false);

const [fetchedHistoryData, setFetchedHistoryData] = useState<
UserFundingIF[]
>([]);

const { fetchFundingHistory } = useInfoApi();

useEffect(() => {
if (address) {
fetchFundingHistory(address).then((data) => {
if (!targetAddress) return;
setLoading(true);
fetchFundingHistory(targetAddress)
.then((data) => {
setFetchedHistoryData(data);
setIsFetched(true);
});
}
}, [address]);
})
.catch(console.error)
.finally(() => setLoading(false));
}, [targetAddress]);

return (
<ExternalPage title='Funding History'>
Expand Down
20 changes: 15 additions & 5 deletions packages/frontend/app/routes/openOrders/openOrders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,35 @@ import { useParams } from 'react-router';
import ExternalPage from '~/components/ExternalPage/ExternalPage';
import OpenOrdersTable from '~/components/Trade/OpenOrdersTable/OpenOrdersTable';
import { useInfoApi } from '~/hooks/useInfoApi';
import { useDebugStore } from '~/stores/DebugStore';
import type { OrderDataIF } from '~/utils/orderbook/OrderBookIFs';

function OpenOrders() {
const { address } = useParams<{ address: string }>();

const walletAddress = useDebugStore((s) => s.debugWallet.address);

const targetAddress = address ?? walletAddress;

const [isFetched, setIsFetched] = useState(false);

const [loading, setLoading] = useState(false);

const [fetchedData, setFetchedData] = useState<OrderDataIF[]>([]);

const { fetchOpenOrders } = useInfoApi();

useEffect(() => {
if (address) {
fetchOpenOrders(address).then((data) => {
if (!targetAddress) return;
setLoading(true);
fetchOpenOrders(targetAddress)
.then((data) => {
setFetchedData(data);
setIsFetched(true);
});
}
}, [address]);
})
.catch(console.error)
.finally(() => setLoading(false));
}, [targetAddress]);

return (
<ExternalPage title='Open Orders'>
Expand Down
18 changes: 18 additions & 0 deletions packages/frontend/app/routes/orderHistory/orderHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ import type { OrderDataIF } from '~/utils/orderbook/OrderBookIFs';
function OrderHistory() {
const { address } = useParams<{ address: string }>();

const walletAddress = useDebugStore((s) => s.debugWallet.address);

const targetAddress = address ?? walletAddress;

const [isFetched, setIsFetched] = useState(false);

const { debugWallet } = useDebugStore();

const { orderHistory, fetchedChannels } = useTradeDataStore();

const [loading, setLoading] = useState(false);

const orderHistoryFetched = useMemo(() => {
return fetchedChannels.has(WsChannels.USER_HISTORICAL_ORDERS);
}, [fetchedChannels]);
Expand All @@ -40,6 +46,18 @@ function OrderHistory() {
// }
}, [address, debugWallet.address]);

useEffect(() => {
if (!targetAddress) return;
setLoading(true);
fetchOrderHistory(targetAddress)
.then((data) => {
setFetchedHistoryData(data);
setIsFetched(true);
})
.catch(console.error)
.finally(() => setLoading(false));
}, [targetAddress]);

useEffect(() => {
if (!isCurrentUser && address) {
fetchOrderHistory(address).then((data) => {
Expand Down
20 changes: 15 additions & 5 deletions packages/frontend/app/routes/twapFillHistory/twapFillHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@ import { useParams } from 'react-router';
import ExternalPage from '~/components/ExternalPage/ExternalPage';
import FillTwapTable from '~/components/Trade/TwapTable/FillTwapTable/FillTwapTable';
import { useInfoApi } from '~/hooks/useInfoApi';
import { useDebugStore } from '~/stores/DebugStore';
import type { TwapSliceFillIF } from '~/utils/UserDataIFs';

function TwapFillHistory() {
const { address } = useParams<{ address: string }>();

const walletAddress = useDebugStore((s) => s.debugWallet.address);

const targetAddress = address ?? walletAddress;

const [isFetched, setIsFetched] = useState(false);

const [loading, setLoading] = useState(false);

const [fetchedHistoryData, setFetchedHistoryData] = useState<
TwapSliceFillIF[]
>([]);

const { fetchTwapSliceFills } = useInfoApi();

useEffect(() => {
if (address) {
fetchTwapSliceFills(address).then((data) => {
if (!targetAddress) return;
setLoading(true);
fetchTwapSliceFills(targetAddress)
.then((data) => {
setFetchedHistoryData(data);
setIsFetched(true);
});
}
}, [address]);
})
.catch(console.error)
.finally(() => setLoading(false));
}, [targetAddress]);

return (
<ExternalPage title='TWAP Fill History'>
Expand Down
20 changes: 15 additions & 5 deletions packages/frontend/app/routes/twapHistory/twapHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,36 @@ import HistoryTwapTable from '~/components/Trade/TwapTable/HistoryTwapTable/Hist
import { useInfoApi } from '~/hooks/useInfoApi';
import type { TwapHistoryIF } from '~/utils/UserDataIFs';
import ExternalPage from '~/components/ExternalPage/ExternalPage';
import { useDebugStore } from '~/stores/DebugStore';

function TwapHistory() {
const { address } = useParams<{ address: string }>();

const walletAddress = useDebugStore((s) => s.debugWallet.address);

const targetAddress = address ?? walletAddress;

const [isFetched, setIsFetched] = useState(false);

const [loading, setLoading] = useState(false);

const [fetchedHistoryData, setFetchedHistoryData] = useState<
TwapHistoryIF[]
>([]);

const { fetchTwapHistory } = useInfoApi();

useEffect(() => {
if (address) {
fetchTwapHistory(address).then((data) => {
if (!targetAddress) return;
setLoading(true);
fetchTwapHistory(targetAddress)
.then((data) => {
setFetchedHistoryData(data);
setIsFetched(true);
});
}
}, [address]);
})
.catch(console.error)
.finally(() => setLoading(false));
}, [targetAddress]);

return (
<ExternalPage title='TWAP History'>
Expand Down