Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#564): Improve Liquidity Section #572

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@soroban-react/xbull": "9.3.0",
"@stellar/freighter-api": "1.7.1",
"@stellar/stellar-sdk": "12.2.0",
"@tanstack/react-query": "^5.60.2",
"@types/qs": "^6.9.7",
"@types/react": "18.2.33",
"@types/react-dom": "18.2.14",
Expand Down Expand Up @@ -73,7 +74,7 @@
"react-window": "^1.8.9",
"redux": "^4.2.1",
"soroswap-router-sdk": "1.4.6",
"soroswap-ui": "^1.0.0",
"soroswap-ui": "^1.1.0",
"swr": "^2.2.0",
"typescript": "5.3.3",
"use-resize-observer": "^9.1.0"
Expand Down Expand Up @@ -105,4 +106,4 @@
"src"
]
}
}
}
13 changes: 13 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ import type { AppProps } from 'next/app';
import '../styles/globals.css';

import Providers from 'components/Providers/Providers';
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchInterval: Infinity,
staleTime: Infinity,
refetchOnWindowFocus: false,
},
},
});

export default function App({ Component, pageProps }: AppProps) {
return (
<QueryClientProvider client={queryClient}>
<Providers>
<Component {...pageProps} />
</Providers>
</QueryClientProvider>
);
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function AddLiquidityPage() {
if (!tokens) return;

const xlm = tokens.find((token) => token.code === 'XLM');
if (xlm) router.push(`/liquidity/add/${xlm.contract}`);
if (xlm) router.push(`/pools/add/${xlm.contract}`);
}, [tokens, router]);

return (
Expand Down
41 changes: 34 additions & 7 deletions pages/liquidity/index.tsx → pages/pools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ import { useContext, useState } from 'react';
import SEO from '../../src/components/SEO';
import { DEFAULT_SLIPPAGE_INPUT_VALUE } from 'components/Settings/MaxSlippageSettings';

import { useQueryPools } from '../../src/hooks/pools';
import PoolsTable from '../../src/components/pools-table/pools-table';

const PageWrapper = styled(AutoColumn)`
position: relative;
background: ${({ theme }) => `linear-gradient(${theme.palette.customBackground.bg2}, ${theme.palette.customBackground.bg2
}) padding-box,
linear-gradient(150deg, rgba(136,102,221,1) 0%, rgba(${theme.palette.mode == 'dark' ? '33,29,50,1' : '255,255,255,1'
}) 35%, rgba(${theme.palette.mode == 'dark' ? '33,29,50,1' : '255,255,255,1'
}) 65%, rgba(136,102,221,1) 100%) border-box`};
background: ${({ theme }) => `linear-gradient(${theme.palette.customBackground.bg2}, ${
theme.palette.customBackground.bg2
}) padding-box,
linear-gradient(150deg, rgba(136,102,221,1) 0%, rgba(${
theme.palette.mode == 'dark' ? '33,29,50,1' : '255,255,255,1'
}) 35%, rgba(${
theme.palette.mode == 'dark' ? '33,29,50,1' : '255,255,255,1'
}) 65%, rgba(136,102,221,1) 100%) border-box`};
border: 1px solid transparent;
border-radius: 16px;
padding: 32px;
Expand Down Expand Up @@ -76,6 +82,16 @@ const StatusWrapper = styled('div')`
border-radius: 16px;
`;

const Container = styled('div')`
display: flex;
flex-direction: column;
align-items: center;
gap: 24px;
width: 100%;
max-width: 875px;
margin: 0 auto;
`;

export default function LiquidityPage() {
const sorobanContext = useSorobanReact();
const { address } = sorobanContext;
Expand All @@ -90,6 +106,7 @@ export default function LiquidityPage() {
const isCreate = false;

const { lpTokens, isLoading, mutate } = useGetLpTokens();
const { data: pools, isLoading: isLoadingPools } = useQueryPools();

const [isModalOpen, setModalOpen] = useState<boolean>(false);
const [selectedLP, setSelectedLP] = useState<LpTokensObj>();
Expand All @@ -101,7 +118,8 @@ export default function LiquidityPage() {

return (
<>
<SEO title="Liquidity - Soroswap" description="Soroswap Liquidity Pool" />
<Container>
<SEO title="Pools - Soroswap" description="Soroswap Liquidity Pool" />
<PageWrapper>
<div style={{ width: '100%' }}>
<AutoRow style={{ justifyContent: 'space-between' }}>
Expand Down Expand Up @@ -154,18 +172,27 @@ export default function LiquidityPage() {
</LPTokensContainer>
)}
{address ? (
<ButtonPrimary onClick={() => router.push('/liquidity/add')}>
<ButtonPrimary onClick={() => router.push('/pools/add')}>
+ Add Liquidity
</ButtonPrimary>
) : (
<WalletButton />
)}
</PageWrapper>

<div style={{ width: '100%' }}>
<AutoRow style={{ marginBottom: '16px' }}>
<SubHeader>All Pools</SubHeader>
</AutoRow>
<PoolsTable rows={pools || []} isLoading={isLoadingPools} />
</div>

<LiquidityPoolInfoModal
selectedLP={selectedLP}
isOpen={isModalOpen}
onDismiss={() => setModalOpen(false)}
/>
</Container>
</>
);
}
2 changes: 1 addition & 1 deletion src/components/Liquidity/Add/AddLiquidityComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default function AddLiquidityComponent({
handleAddLiquidity,
]);

const baseRoute = `/liquidity/add/`;
const baseRoute = `/pools/add/`;

const handleCurrencyASelect = useCallback(
(currencyA: TokenType) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Liquidity/LiquidityPoolInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export default function LiquidityPoolInfoModal({
if (!selectedLP) return null;

const handleAddClick = () => {
router.push(`/liquidity/add/${selectedLP.token_0?.contract}/${selectedLP.token_1?.contract}`);
router.push(`/pools/add/${selectedLP.token_0?.contract}/${selectedLP.token_1?.contract}`);
};

const handleRemoveClick = () => {
router.push(
`/liquidity/remove/${selectedLP.token_0?.contract}/${selectedLP.token_1?.contract}`,
`/pools/remove/${selectedLP.token_0?.contract}/${selectedLP.token_1?.contract}`,
);
};

Expand Down
Loading