Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .changeset/curvy-maps-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'frontend': patch
'@sovryn/contracts': patch
'@sovryn/sdk': patch
'@sovryn/ui': patch
---

chore: USDT and WBTC on BOB migration
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.container {
@apply flex items-center mr-2;
@apply flex items-center mr-2 gap-2;
}

.assetLogo svg {
@apply mr-2 w-5 h-5 bg-gray-80 rounded-full overflow-hidden;
@apply w-5 h-5 bg-gray-80 rounded-full overflow-hidden;
}

.asset {
@apply font-semibold text-xs;
}

.longName {
@apply text-gray-40;
}
31 changes: 24 additions & 7 deletions apps/frontend/src/app/2_molecules/AssetRenderer/AssetRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from 'react';
import React, { FC, PropsWithChildren, useState } from 'react';
import { useEffect } from 'react';

import classNames from 'classnames';
Expand Down Expand Up @@ -50,17 +50,21 @@ type AssetRendererProps = {
assetLongNameClassName?: string;
};

export const AssetRenderer: FC<AssetRendererProps> = ({
export const AssetRenderer: FC<PropsWithChildren<AssetRendererProps>> = ({
asset,
chainId = ChainIds.RSK_MAINNET,
address,
showAssetLogo,
showLongName,
assetLongNameClassName,
assetClassName,
className,
dataAttribute,
logoClassName,
children,
}) => {
const [token, setToken] = useState(asset);
const [longName, setLongName] = useState<string | undefined>();
const [logo, setLogo] = useState<string | undefined>(undefined);

useEffect(() => {
Expand All @@ -69,6 +73,7 @@ export const AssetRenderer: FC<AssetRendererProps> = ({
.then(item => {
setLogo(item.icon);
setToken(item.symbol);
setLongName(item.name);
})
.catch(() => setLogo(''));
}
Expand Down Expand Up @@ -96,11 +101,23 @@ export const AssetRenderer: FC<AssetRendererProps> = ({
dangerouslySetInnerHTML={{ __html: logo }}
/>
)}
{token && (
<span className={classNames(styles.asset, assetClassName)}>
{token}
</span>
)}
<div className="flex flex-col gap-0.5">
<div className="flex items-center gap-2">
{token && (
<span className={classNames(styles.asset, assetClassName)}>
{token}
</span>
)}
{showLongName && longName && (
<span
className={classNames(styles.longName, assetLongNameClassName)}
>
{longName}
</span>
)}
</div>
{children}
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { FC } from 'react';

import { t } from 'i18next';

import { Button, ButtonSize, ButtonStyle } from '@sovryn/ui';

import { BOB_MIGRATION_LINK } from '../../3_organisms/RuneBridgeDialog/constants';
import { useChainStore } from '../../../hooks/useChainStore';
import { translations } from '../../../locales/i18n';
import { isBobChain } from '../../../utils/chain';

export const DeprecatedBadge: FC = () => {
const { currentChainId } = useChainStore();

if (!isBobChain(currentChainId)) {
return null;
}

return (
<div className="flex items-center gap-1.5">
<span className="text-gray-10 font-medium text-[10px] border border-primary-30 rounded-sm px-1 py-0.5">
{t(translations.ambientMarketMaking.deprecated)}
</span>
<Button
text={t(translations.ambientMarketMaking.migrate)}
size={ButtonSize.small}
style={ButtonStyle.ghost}
href={BOB_MIGRATION_LINK}
hrefExternal
onClick={e => e.stopPropagation()}
/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export const DEPOSITS_PATH = 'deposits';
export const RUNES_RSK_BRIDGE_NAME = 'runes';

export const RUNES_BOB_BRIDGE_NAME = 'runesbob';

export const BOB_MIGRATION_LINK = 'https://app.gobob.xyz/en/migrate';
29 changes: 28 additions & 1 deletion apps/frontend/src/app/5_pages/ConvertPage/ConvertPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ import { AmountRenderer } from '../../2_molecules/AmountRenderer/AmountRenderer'
import { AssetRenderer } from '../../2_molecules/AssetRenderer/AssetRenderer';
import { MaxButton } from '../../2_molecules/MaxButton/MaxButton';
import { TradingChart } from '../../2_molecules/TradingChart/TradingChart';
import { BOB_MIGRATION_LINK } from '../../3_organisms/RuneBridgeDialog/constants';
import { TOKEN_RENDER_PRECISION, USD } from '../../../constants/currencies';
import { getTokenDisplayName } from '../../../constants/tokens';
import {
getBobDeprecatedAssetTooltips,
getTokenDisplayName,
} from '../../../constants/tokens';
import { useAccount } from '../../../hooks/useAccount';
import { useAssetBalance } from '../../../hooks/useAssetBalance';
import { useCurrentChain } from '../../../hooks/useChainStore';
Expand All @@ -52,6 +56,7 @@ import {
findAsset,
listAssetsOfChain,
} from '../../../utils/asset';
import { isBobChain } from '../../../utils/chain';
import { removeTrailingZerosFromString } from '../../../utils/helpers';
import { decimalic, fromWei, toWei } from '../../../utils/math';
import {
Expand Down Expand Up @@ -593,6 +598,11 @@ const ConvertPage: FC = () => {
[isSlippageHigh, quote],
);

const deprecatedTooltips =
isBobChain(currentChainId) &&
(getBobDeprecatedAssetTooltips(sourceToken) ||
getBobDeprecatedAssetTooltips(destinationToken));

useEffect(() => {
if (fromToken) {
setSourceToken(fromToken);
Expand Down Expand Up @@ -900,6 +910,23 @@ const ConvertPage: FC = () => {
/>
</div>
)}
{deprecatedTooltips && (
<div className="flex flex-col items-center mt-4 bg-gray-80 rounded p-3 gap-1">
{deprecatedTooltips && (
<ErrorBadge
className="lg:max-w-80"
level={ErrorLevel.Warning}
message={t(deprecatedTooltips.convert)}
/>
)}
<Button
text={t(translations.common.learnMore)}
style={ButtonStyle.ghost}
href={BOB_MIGRATION_LINK}
hrefExternal
/>
</div>
)}
<Button
type={ButtonType.reset}
style={ButtonStyle.primary}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { useQuery } from '@tanstack/react-query';

import React, { FC, useMemo, useState } from 'react';

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

import {
Heading,
Icon,
IconNames,
Input,
InputSize,
Paragraph,
Expand All @@ -15,25 +19,24 @@ import { RSK_CHAIN_ID } from '../../../../../config/chains';

import { MarketMakingNetworkBanner } from '../../../../2_molecules/MarketMakingNetworkBanner/MarketMakingNetworkBanner';
import { BOB_STORAGE_KEY } from '../../../../2_molecules/MarketMakingNetworkBanner/MarketMakingNetworkBanner.constants';
import { useCacheCall } from '../../../../../hooks';
import { useCurrentChain } from '../../../../../hooks/useChainStore';
import { loadIndexer } from '../../../../../lib/indexer';
import { translations } from '../../../../../locales/i18n';
import { AmbientPoolsTable } from './components/AmbientPoolsTable/AmbientPoolsTable';
import { BOBMigrationBanner } from './components/BOBMigrationBanner/BOBMigrationBanner';

export const AmbientMarketMaking: FC = () => {
const chainId = useCurrentChain();
const { value } = useCacheCall(
'mm',
chainId,
async () => {

const { data: value } = useQuery({
queryKey: ['mm', chainId],
initialData: [],
queryFn: async () => {
return (await loadIndexer(chainId).pools.list()).sort((a, b) =>
a.base.symbol < b.base.symbol ? -1 : 1,
);
},
[chainId],
[],
);
});

const newPools = useMemo(
() => (value ?? []).filter(pool => pool.featured),
Expand Down Expand Up @@ -61,16 +64,27 @@ export const AmbientMarketMaking: FC = () => {
{t(translations.ambientMarketMaking.title)}
</Heading>

<BOBMigrationBanner />

<div className="w-full my-4">
<Input
value={searchInputValue}
className="w-full"
onChangeText={setSearchInputValue}
size={InputSize.large}
placeholder={t(
translations.marketMakingPage.searchInputPlaceholder,
)}
/>
<div className="relative flex items-center">
<Icon
className="absolute left-1.5 z-10"
icon={IconNames.FILTER}
size={16}
viewBox="0 0 16 16"
/>
<Input
value={searchInputValue}
className="w-full"
classNameInput="pl-8"
onChangeText={setSearchInputValue}
size={InputSize.large}
placeholder={t(
translations.marketMakingPage.searchInputPlaceholder,
)}
/>
</div>
</div>

{newPools.length > 0 && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

import classNames from 'classnames';
import { t } from 'i18next';

import { numberToChainId } from '@sovryn/ethers-provider';
Expand All @@ -8,7 +9,10 @@ import { HelperButton } from '@sovryn/ui';

import { AmountRenderer } from '../../../../../../2_molecules/AmountRenderer/AmountRenderer';
import { AssetPairRenderer } from '../../../../../../2_molecules/AssetPairRenderer/AssetPairRenderer';
import { DeprecatedBadge } from '../../../../../../2_molecules/DeprecatedBadge/DeprecatedBadge';
import { getBobDeprecatedAssetTooltips } from '../../../../../../../constants/tokens';
import { translations } from '../../../../../../../locales/i18n';
import { findAsset } from '../../../../../../../utils/asset';
import { decimalic } from '../../../../../../../utils/math';
import { AmbientPool24Volume } from './components/AmbientPool24Volume/AmbientPool24Volume';
import { AmbientPoolDeposit } from './components/AmbientPoolDeposit/AmbientPoolDeposit';
Expand All @@ -21,15 +25,37 @@ export const COLUMNS_CONFIG = [
{
id: 'pair',
title: t(translations.ambientMarketMaking.poolsTable.pair),
cellRenderer: (pool: Pool) => (
<div className="inline-flex" data-pool-key={pool.identifier}>
<AssetPairRenderer
asset1={pool.base.symbol}
asset2={pool.quote.symbol}
chainId={numberToChainId(pool.chainId)}
/>
</div>
),
cellRenderer: (pool: Pool) => {
const chainId = numberToChainId(pool.chainId);
const isDeprecated =
!!getBobDeprecatedAssetTooltips(pool.base.symbol) ||
!!getBobDeprecatedAssetTooltips(pool.quote.symbol);

return (
<div
className="inline-flex items-center gap-2"
data-pool-key={pool.identifier}
>
<AssetPairRenderer
asset1={pool.base.symbol}
asset2={pool.quote.symbol}
chainId={chainId}
hideSymbol
/>
<div
className={classNames('flex flex-col gap-1 font-medium text-xs', {
'text-gray-40': isDeprecated,
})}
>
<span>
{findAsset(pool.base.symbol, chainId)?.symbol}/
{findAsset(pool.quote.symbol, chainId)?.symbol}
</span>
{isDeprecated && <DeprecatedBadge />}
</div>
</div>
);
},
},
{
id: 'liquidity',
Expand Down
Loading