Skip to content

Commit

Permalink
display all swaps in SwapPro, not per user
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Jun 21, 2024
1 parent c3d8271 commit 3b14f17
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 45 deletions.
17 changes: 17 additions & 0 deletions web/src/components/SwapPro/SwapProPoolFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,22 @@ export const SwapProPoolFragment = graphql(`
}
}
}
swaps {
swaps {
timestamp
amountIn {
valueScaled
token {
symbol
}
}
amountOut {
valueScaled
token {
symbol
}
}
}
}
}
`);
31 changes: 4 additions & 27 deletions web/src/components/SwapPro/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Graph } from "@/components/SwapPro/SwapProGraph";
import { useSwapStore } from "@/stores/useSwapStore";
import { columns, Transaction } from "@/app/_DataTable/columns";
import { DataTable } from "@/app/_DataTable/DataTable";
import { useGraphqlGlobal, useGraphqlUser } from "@/hooks/useGraphql";
import { graphql, useFragment } from "@/gql";
import { useGraphqlGlobal } from "@/hooks/useGraphql";
import { useFragment } from "@/gql";
import { SwapProPoolFragment } from "@/components/SwapPro/SwapProPoolFragment";
import { useMemo } from "react";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
Expand All @@ -24,24 +24,6 @@ const variants = {
visible: { opacity: 1, width: "auto" },
};

const SwapProTransactionsFragment = graphql(`
fragment SwapProTransactionsFragment on SeawaterSwap {
timestamp
amountIn {
valueScaled
token {
symbol
}
}
amountOut {
valueScaled
token {
symbol
}
}
}
`);

export const SwapPro = ({
override,
badgeTitle,
Expand All @@ -60,9 +42,7 @@ export const SwapPro = ({

const { data: dataGlobal, isLoading: isLoadingGlobal } = useGraphqlGlobal();

const { data: dataUser, isLoading: isLoadingUser } = useGraphqlUser();

const isLoading = isLoadingUser || isLoadingGlobal;
const isLoading = isLoadingGlobal;

// the selected pool
const pool = useMemo(
Expand All @@ -77,10 +57,7 @@ export const SwapPro = ({

const poolSwapPro = useFragment(SwapProPoolFragment, pool);

const transactions = useFragment(
SwapProTransactionsFragment,
dataUser?.getSwapsForUser?.swaps,
);
const transactions = poolSwapPro?.swaps.swaps

const showMockData = useFeatureFlag("ui show demo data");
const showStakeApy = useFeatureFlag("ui show stake apy");
Expand Down
13 changes: 4 additions & 9 deletions web/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ const documents = {
"\n fragment TradeTabTransactionsFragment on SeawaterSwap {\n timestamp\n amountIn {\n token {\n symbol\n }\n valueScaled\n }\n amountOut {\n token {\n symbol\n }\n valueScaled\n }\n }\n": types.TradeTabTransactionsFragmentFragmentDoc,
"\n fragment StakeFormFragment on SeawaterPool {\n address\n earnedFeesAPRFUSDC\n }\n": types.StakeFormFragmentFragmentDoc,
"\nfragment DepositPositionsFragment on Wallet {\n positions {\n positions {\n positionId\n lower\n upper\n }\n }\n}\n": types.DepositPositionsFragmentFragmentDoc,
"\n fragment SwapProPoolFragment on SeawaterPool {\n address\n token {\n address\n symbol\n }\n priceOverTime {\n daily\n monthly\n }\n volumeOverTime {\n monthly {\n timestamp\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n daily {\n timestamp # TODO: timestamp is always 0\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n }\n liquidityOverTime {\n daily {\n timestamp\n fusdc {\n valueUsd\n }\n }\n monthly {\n timestamp\n fusdc {\n valueUsd\n }\n }\n }\n }\n": types.SwapProPoolFragmentFragmentDoc,
"\n fragment SwapProTransactionsFragment on SeawaterSwap {\n timestamp\n amountIn {\n valueScaled\n token {\n symbol\n }\n }\n amountOut {\n valueScaled\n token {\n symbol\n }\n }\n }\n": types.SwapProTransactionsFragmentFragmentDoc,
"\n fragment SwapProPoolFragment on SeawaterPool {\n address\n token {\n address\n symbol\n }\n priceOverTime {\n daily\n monthly\n }\n volumeOverTime {\n monthly {\n timestamp\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n daily {\n timestamp # TODO: timestamp is always 0\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n }\n liquidityOverTime {\n daily {\n timestamp\n fusdc {\n valueUsd\n }\n }\n monthly {\n timestamp\n fusdc {\n valueUsd\n }\n }\n }\n swaps {\n swaps {\n timestamp\n amountIn {\n valueScaled\n token {\n symbol\n }\n }\n amountOut {\n valueScaled\n token {\n symbol\n }\n }\n }\n }\n }\n": types.SwapProPoolFragmentFragmentDoc,
"\n query AllData {\n pools {\n # used for the pool selector\n address\n\n # add general fragments here\n ...SwapProPoolFragment\n ...AllPoolsFragment\n ...SelectPrimeAssetFragment\n ...SwapExploreFragment\n ...ManagePoolFragment\n ...SwapFormFragment\n ...StakeFormFragment\n }\n }\n": types.AllDataDocument,
"\n query ForUser($wallet: String!) {\n getSwapsForUser(wallet: $wallet, first: 10) {\n swaps {\n # add transaction fragments here\n ...SwapProTransactionsFragment\n ...TradeTabTransactionsFragment\n }\n }\n\n getWallet(address: $wallet) {\n # add wallet fragments here\n ...MyPositionsWalletFragment\n ...MyPositionsInventoryWalletFragment\n ...PositionsFragment\n ...WithdrawPositionsFragment\n ...DepositPositionsFragment\n }\n }\n": types.ForUserDocument,
"\n query ForUser($wallet: String!) {\n getSwapsForUser(wallet: $wallet, first: 10) {\n swaps {\n # add transaction fragments here\n ...TradeTabTransactionsFragment\n }\n }\n\n getWallet(address: $wallet) {\n # add wallet fragments here\n ...MyPositionsWalletFragment\n ...MyPositionsInventoryWalletFragment\n ...PositionsFragment\n ...WithdrawPositionsFragment\n ...DepositPositionsFragment\n }\n }\n": types.ForUserDocument,
};

/**
Expand Down Expand Up @@ -96,19 +95,15 @@ export function graphql(source: "\nfragment DepositPositionsFragment on Wallet {
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n fragment SwapProPoolFragment on SeawaterPool {\n address\n token {\n address\n symbol\n }\n priceOverTime {\n daily\n monthly\n }\n volumeOverTime {\n monthly {\n timestamp\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n daily {\n timestamp # TODO: timestamp is always 0\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n }\n liquidityOverTime {\n daily {\n timestamp\n fusdc {\n valueUsd\n }\n }\n monthly {\n timestamp\n fusdc {\n valueUsd\n }\n }\n }\n }\n"): (typeof documents)["\n fragment SwapProPoolFragment on SeawaterPool {\n address\n token {\n address\n symbol\n }\n priceOverTime {\n daily\n monthly\n }\n volumeOverTime {\n monthly {\n timestamp\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n daily {\n timestamp # TODO: timestamp is always 0\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n }\n liquidityOverTime {\n daily {\n timestamp\n fusdc {\n valueUsd\n }\n }\n monthly {\n timestamp\n fusdc {\n valueUsd\n }\n }\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n fragment SwapProTransactionsFragment on SeawaterSwap {\n timestamp\n amountIn {\n valueScaled\n token {\n symbol\n }\n }\n amountOut {\n valueScaled\n token {\n symbol\n }\n }\n }\n"): (typeof documents)["\n fragment SwapProTransactionsFragment on SeawaterSwap {\n timestamp\n amountIn {\n valueScaled\n token {\n symbol\n }\n }\n amountOut {\n valueScaled\n token {\n symbol\n }\n }\n }\n"];
export function graphql(source: "\n fragment SwapProPoolFragment on SeawaterPool {\n address\n token {\n address\n symbol\n }\n priceOverTime {\n daily\n monthly\n }\n volumeOverTime {\n monthly {\n timestamp\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n daily {\n timestamp # TODO: timestamp is always 0\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n }\n liquidityOverTime {\n daily {\n timestamp\n fusdc {\n valueUsd\n }\n }\n monthly {\n timestamp\n fusdc {\n valueUsd\n }\n }\n }\n swaps {\n swaps {\n timestamp\n amountIn {\n valueScaled\n token {\n symbol\n }\n }\n amountOut {\n valueScaled\n token {\n symbol\n }\n }\n }\n }\n }\n"): (typeof documents)["\n fragment SwapProPoolFragment on SeawaterPool {\n address\n token {\n address\n symbol\n }\n priceOverTime {\n daily\n monthly\n }\n volumeOverTime {\n monthly {\n timestamp\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n daily {\n timestamp # TODO: timestamp is always 0\n token1 {\n valueUsd\n }\n fusdc {\n valueUsd\n }\n }\n }\n liquidityOverTime {\n daily {\n timestamp\n fusdc {\n valueUsd\n }\n }\n monthly {\n timestamp\n fusdc {\n valueUsd\n }\n }\n }\n swaps {\n swaps {\n timestamp\n amountIn {\n valueScaled\n token {\n symbol\n }\n }\n amountOut {\n valueScaled\n token {\n symbol\n }\n }\n }\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query AllData {\n pools {\n # used for the pool selector\n address\n\n # add general fragments here\n ...SwapProPoolFragment\n ...AllPoolsFragment\n ...SelectPrimeAssetFragment\n ...SwapExploreFragment\n ...ManagePoolFragment\n ...SwapFormFragment\n ...StakeFormFragment\n }\n }\n"): (typeof documents)["\n query AllData {\n pools {\n # used for the pool selector\n address\n\n # add general fragments here\n ...SwapProPoolFragment\n ...AllPoolsFragment\n ...SelectPrimeAssetFragment\n ...SwapExploreFragment\n ...ManagePoolFragment\n ...SwapFormFragment\n ...StakeFormFragment\n }\n }\n"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query ForUser($wallet: String!) {\n getSwapsForUser(wallet: $wallet, first: 10) {\n swaps {\n # add transaction fragments here\n ...SwapProTransactionsFragment\n ...TradeTabTransactionsFragment\n }\n }\n\n getWallet(address: $wallet) {\n # add wallet fragments here\n ...MyPositionsWalletFragment\n ...MyPositionsInventoryWalletFragment\n ...PositionsFragment\n ...WithdrawPositionsFragment\n ...DepositPositionsFragment\n }\n }\n"): (typeof documents)["\n query ForUser($wallet: String!) {\n getSwapsForUser(wallet: $wallet, first: 10) {\n swaps {\n # add transaction fragments here\n ...SwapProTransactionsFragment\n ...TradeTabTransactionsFragment\n }\n }\n\n getWallet(address: $wallet) {\n # add wallet fragments here\n ...MyPositionsWalletFragment\n ...MyPositionsInventoryWalletFragment\n ...PositionsFragment\n ...WithdrawPositionsFragment\n ...DepositPositionsFragment\n }\n }\n"];
export function graphql(source: "\n query ForUser($wallet: String!) {\n getSwapsForUser(wallet: $wallet, first: 10) {\n swaps {\n # add transaction fragments here\n ...TradeTabTransactionsFragment\n }\n }\n\n getWallet(address: $wallet) {\n # add wallet fragments here\n ...MyPositionsWalletFragment\n ...MyPositionsInventoryWalletFragment\n ...PositionsFragment\n ...WithdrawPositionsFragment\n ...DepositPositionsFragment\n }\n }\n"): (typeof documents)["\n query ForUser($wallet: String!) {\n getSwapsForUser(wallet: $wallet, first: 10) {\n swaps {\n # add transaction fragments here\n ...TradeTabTransactionsFragment\n }\n }\n\n getWallet(address: $wallet) {\n # add wallet fragments here\n ...MyPositionsWalletFragment\n ...MyPositionsInventoryWalletFragment\n ...PositionsFragment\n ...WithdrawPositionsFragment\n ...DepositPositionsFragment\n }\n }\n"];

export function graphql(source: string) {
return (documents as any)[source] ?? {};
Expand Down
Loading

0 comments on commit 3b14f17

Please sign in to comment.