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

Sovryn LBDex base branch #978

Open
wants to merge 8 commits into
base: develop
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
5 changes: 5 additions & 0 deletions .changeset/chilly-kids-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sovryn/contracts": patch
---

SOV-4333: TraderJoe initial branch and config
5 changes: 5 additions & 0 deletions .changeset/nice-pots-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend': patch
---

SOV-4410: add liquidity modal
5 changes: 5 additions & 0 deletions .changeset/nice-pots-coverup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sovryn/sdk': patch
---

chore: retrieve pool pairs from subgraph
6 changes: 6 additions & 0 deletions .changeset/wicked-toes-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"frontend": patch
"@sovryn/sdk": patch
---

SOV-4376: trader joe smart route
1 change: 1 addition & 0 deletions apps/frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- 79b88d16: SOV-4328: BOB LP value display only showing one asset
- c93bae35: SOV-3346: paginate bitocracy proposal overview table


## 1.1.18

### Patch Changes
Expand Down
6 changes: 5 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"@sovryn-zero/lib-ethers": "0.2.5",
"@sovryn/contracts": "*",
"@sovryn/ethers-provider": "*",
"@sovryn/joe-core": "^2.0.4",
"@sovryn/joe-sdk": "^5.0.5",
"@sovryn/joe-sdk-v2": "^3.0.15",
"@sovryn/onboard-bitget": "1.0.1",
"@sovryn/onboard-common": "1.0.0",
"@sovryn/onboard-core": "1.0.6",
Expand Down Expand Up @@ -59,6 +62,7 @@
"sanitize-html": "2.11.0",
"socket.io-client": "4.5.4",
"utf8": "^3.0.0",
"viem": "^2.19.2",
"zustand": "^4.5.1"
},
"devDependencies": {
Expand Down Expand Up @@ -87,7 +91,7 @@
"stream-browserify": "^3.0.0",
"ts-loader": "^9.3.1",
"ts-prune": "0.10.3",
"typescript": "^4.7.4",
"typescript": "^5.5.4",
"webpack": "^5.74.0"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ export const FIXED_RATE_ROUTES = ['MyntBasset', 'MyntFixedRate'];
export const FIXED_MYNT_RATE = '0.004723550439442834'; // We need it here as well because ConvertPage slightly rounds maximum price

export const SWAP_ROUTES = [
smartRoutes.ammSwapRoute,
smartRoutes.myntBassetRoute,
smartRoutes.myntFixedRateRoute,
smartRoutes.mocIntegrationSwapRoute,
smartRoutes.ambientRoute,
// todo: uncomment after testing...
// smartRoutes.ammSwapRoute,
// smartRoutes.myntBassetRoute,
// smartRoutes.myntFixedRateRoute,
// smartRoutes.mocIntegrationSwapRoute,
// smartRoutes.ambientRoute,
smartRoutes.joeRoute,
// smartRoutes.zeroRedemptionSwapRoute,
];

Expand Down Expand Up @@ -45,6 +47,7 @@ export const DEFAULT_SWAP_ENTRIES: Partial<Record<ChainIds, string>> = {
[ChainIds.RSK_MAINNET]: COMMON_SYMBOLS.DLLR,
[ChainIds.RSK_TESTNET]: COMMON_SYMBOLS.DLLR,
[ChainIds.BOB_MAINNET]: COMMON_SYMBOLS.ETH,
[ChainIds.BOB_TESTNET]: COMMON_SYMBOLS.ETH,
// [ChainIds.BOB_TESTNET]: COMMON_SYMBOLS.ETH,
[ChainIds.BOB_TESTNET]: COMMON_SYMBOLS.SOV, // todo: switch back to ETH after testing joe route
[ChainIds.SEPOLIA]: COMMON_SYMBOLS.ETH,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const PAIR_VERSION = 'v22';
export const ALLOWED_SLIPPAGE_AMOUNT = 50;
/** @deprecated retrieve it from protocol contracts */
export const LB_ROUTER_CONTRACT = '0xC2Af3934F01FAFBD780e9BD572c9DC711A163cdc';
export const BINS_RANGE = 200;
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { FC } from 'react';

import { t } from 'i18next';
import { Helmet } from 'react-helmet-async';

import { Heading } from '@sovryn/ui';

import { BOB_CHAIN_ID } from '../../../config/chains';

import { NetworkBanner } from '../../2_molecules/NetworkBanner/NetworkBanner';
import { translations } from '../../../locales/i18n';
import { LiquidityBookModal } from './components/AddLiquidityModal/AddLiquidityModal';
import { BalanceRenderer } from './components/BalanceRenderer/BalanceRenderer';
import { LiquidityBookFrame } from './components/LiquidityBookFrame/LiquidityBookFrame';

const LiquidityBookPage: FC = () => (
<>
<Helmet>
<title>{t(translations.liquidityBookPage.meta.title)}</title>
</Helmet>
<div className="w-full max-w-[74.75rem]">
<div className="flex flex-col items-center text-gray-10 mt-6 mb-4 sm:mt-9">
<NetworkBanner requiredChainId={BOB_CHAIN_ID}>
<Heading className="text-center mb-3 lg:text-2xl">
{t(translations.liquidityBookPage.title)}
</Heading>

<BalanceRenderer />

<LiquidityBookFrame />
</NetworkBanner>
</div>
</div>
<LiquidityBookModal />
</>
);

export default LiquidityBookPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Token } from '@sovryn/joe-core';

/** @deprecated */
export type LiquidityBookPool = {
pair: Token[];
liquidity: string[];
contractAddress: string;
activeBinId: number;
binStep: number;
};

export type LiquidityBookProps = {
pool: LiquidityBookPool;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { useCallback, useEffect, useMemo } from 'react';

import { t } from 'i18next';

import { Dialog, DialogBody, DialogHeader } from '@sovryn/ui';

import { translations } from '../../../../../locales/i18n';
import { eventDriven } from '../../../../../store/rxjs/event-driven';
import { Nullable } from '../../../../../types/global';
import { LiquidityBookPool } from '../../LiquidityBookPage.types';
import { LBModalType } from '../../utils/constants';
import { Content } from './Content';

export const LiquidityBookModal = () => {
const { subscribe } = useMemo(
() => eventDriven<Nullable<LiquidityBookPool>>(LBModalType.deposit),
[],
);
const [isOpen, setIsOpen] = React.useState(false);
const [pool, setPool] = React.useState<Nullable<LiquidityBookPool>>(null);

useEffect(() => {
const sub = subscribe(value => {
setIsOpen(value !== null);
setPool(value);
});

return () => sub.unsubscribe();
}, [subscribe]);

const handleClose = useCallback(() => {
setIsOpen(false);
setPool(null);
}, []);

return (
<Dialog disableFocusTrap isOpen={isOpen}>
<DialogHeader
title={t(translations.liquidityBookDeposit.title)}
onClose={handleClose}
/>
<DialogBody>
{isOpen && pool && <Content pool={pool} onClose={handleClose} />}
</DialogBody>
</Dialog>
);
};
Loading
Loading