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: crosschain lp #1584

Open
wants to merge 152 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
8e1615a
refactor icon balances
swiftcc624 Dec 22, 2024
e6bbcfa
WIP: crosschain lp - LP Panel
swiftcc624 Dec 24, 2024
55d788d
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 3, 2025
833f39c
crosschain lp - send/remove token, add liquidity
swiftcc624 Jan 3, 2025
4afaafe
update balanced sdk
swiftcc624 Jan 8, 2025
20438ff
crosschain lp - remove liquidity
swiftcc624 Jan 8, 2025
be32b51
update url search params when pair is changed in supply page
swiftcc624 Jan 8, 2025
89d6749
crosschain lp - stake, unstake
swiftcc624 Jan 8, 2025
5a8e5fa
useXTokenDepositAmount refactor
swiftcc624 Jan 8, 2025
bbecdf0
select the correct xchain id in LP Panel when click a pool record
swiftcc624 Jan 8, 2025
2cabfb2
lp panel description - supply amount
swiftcc624 Jan 9, 2025
c91ea3e
rewrite XWalletClient classes to support crosschain lp
swiftcc624 Jan 9, 2025
17b6f80
implement lp functions in IconXWalletClient
swiftcc624 Jan 10, 2025
f6727b2
fix useHasLiquidity
swiftcc624 Jan 10, 2025
d725c38
fix liquidity pool list
swiftcc624 Jan 10, 2025
5bd625d
supply modal ui
swiftcc624 Jan 10, 2025
cd32349
use all signed accounts to get pools
swiftcc624 Jan 10, 2025
9c6b25f
orverride lessThan, equalTo, greaterThan in CurrencyAmount class for …
swiftcc624 Jan 10, 2025
ad69868
fix LPPanel
swiftcc624 Jan 10, 2025
4b2ace5
crosschain lp - SuiXWalletClient
swiftcc624 Jan 10, 2025
529068c
rewrite EvmXWalletClient
swiftcc624 Jan 10, 2025
88dc639
rewrite SuiXWalletClient
swiftcc624 Jan 10, 2025
cf0f769
refactor SolanaXWalletClient
swiftcc624 Jan 10, 2025
4a60018
refactor EvmXWalletClient
swiftcc624 Jan 10, 2025
3d9e8b1
refactor HavahXWalletClient
swiftcc624 Jan 10, 2025
d8dd141
refactor ArchwyXWalletClient
swiftcc624 Jan 10, 2025
d0010a0
refactor InjectiveXWalletClient
swiftcc624 Jan 10, 2025
c7e2d00
refactor SuiXWalletClient
swiftcc624 Jan 10, 2025
4a39e53
refactor StellarXWalletClient
swiftcc624 Jan 11, 2025
1f7e3f7
refactor XWalletClient classes
swiftcc624 Jan 11, 2025
3315ef2
refactor XWalletClient
swiftcc624 Jan 11, 2025
fac6b1c
refactor XWalletClient
swiftcc624 Jan 11, 2025
d6a7752
refactor XWalletClient
swiftcc624 Jan 11, 2025
25c9ab9
fix circular imports in xwagmi
swiftcc624 Jan 11, 2025
7df8564
refactor XWalletClient - make consistent data format
swiftcc624 Jan 12, 2025
4b5a3d1
refactor XWalletClient - make consistent data format
swiftcc624 Jan 12, 2025
0902f96
make PoolLogoWithNetwork component
swiftcc624 Jan 13, 2025
65c2544
implement _sendCall in ArchwayXWalletClient
swiftcc624 Jan 13, 2025
bdf3997
calculate correct xcall fee in crosschain lp hooks
swiftcc624 Jan 13, 2025
50dea00
implement _sendCall in HavahXWalletClient
swiftcc624 Jan 13, 2025
260dfb7
show xcall fee in supply modal
swiftcc624 Jan 13, 2025
2421c91
approve logic in supply modal
swiftcc624 Jan 13, 2025
72703fe
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 14, 2025
7f9a281
refactor code
0xmilktea Jan 14, 2025
6ca7a13
don't persist useXChainHeightStore
swiftcc624 Jan 14, 2025
30cdfba
crosschain lp - implement wICX
swiftcc624 Jan 14, 2025
f143553
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Jan 15, 2025
1e5b8cb
Merge remote-tracking branch 'origin/feat/add-sICX-bnUSD-on-SUI-Injec…
0xmilktea Jan 15, 2025
b92eb69
refactor code
0xmilktea Jan 15, 2025
3b445f1
update locales
0xmilktea Jan 15, 2025
7e32ba5
rewards panel chain selector, claim rewards
swiftcc624 Jan 16, 2025
ce0832d
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 16, 2025
ebf419a
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Jan 16, 2025
4f9dc8c
update locales
0xmilktea Jan 16, 2025
306f926
refactor code
0xmilktea Jan 16, 2025
5739784
improve ui
0xmilktea Jan 20, 2025
2fe3b86
remove stable coins in the supply input
0xmilktea Jan 20, 2025
8505cfb
crosschain rewards on homepage
swiftcc624 Jan 20, 2025
eb02dd1
Use rgb(15, 57, 90) for the chain background colour
swiftcc624 Jan 20, 2025
009ee99
Let's add a vertical divider to the modal, reduce the margin around t…
swiftcc624 Jan 21, 2025
e49b13b
If you click Cancel after supplying one/both assets, you'll see a me…
swiftcc624 Jan 21, 2025
5464936
supply modal - switch network for the wrong chain
swiftcc624 Jan 21, 2025
75c1ae9
add ICX in the default token list
0xmilktea Jan 21, 2025
aa6de97
refactor the code
0xmilktea Jan 21, 2025
0432c71
fix supply quote currency input
0xmilktea Jan 21, 2025
7a57c0d
The Your pools section should include the asset tickers
swiftcc624 Jan 21, 2025
de0330d
fix icx currency in the currency input panel
0xmilktea Jan 21, 2025
b02d5ad
fix a bug
0xmilktea Jan 21, 2025
1bfdc9f
update getTransactionText for crosschain lp transactions
swiftcc624 Jan 21, 2025
3e42514
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 21, 2025
b82fc89
fix ui
0xmilktea Jan 21, 2025
167cdbb
This pool should be ICX / sICX (remove the w)
swiftcc624 Jan 21, 2025
1c75819
improve code
0xmilktea Jan 21, 2025
07653b0
improve ui
0xmilktea Jan 21, 2025
186f125
fix currency input panel for crosschain lp
swiftcc624 Jan 21, 2025
2e3f9b3
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 21, 2025
71eec8e
fix liquidity pools
swiftcc624 Jan 22, 2025
214ef5e
fix liquidity pools
swiftcc624 Jan 22, 2025
70227a2
stake modal - gas checker and switch network for wrong chain
swiftcc624 Jan 22, 2025
7fc7b06
gas checker in supply modal
swiftcc624 Jan 22, 2025
c820e12
gas checker and switch network in withdraw modal
swiftcc624 Jan 22, 2025
8d67a78
gas checker and switch network in claim modal
swiftcc624 Jan 22, 2025
6ecd657
The Send button changes to Sending as soon as you click it. If possi…
swiftcc624 Jan 22, 2025
efb385b
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 22, 2025
6674aa8
remove debug code in PoolRecord
swiftcc624 Jan 23, 2025
e9f162d
chore: remove prettier-vscode from recommended extensions
hetfly Jan 23, 2025
009a092
fix: fix lp description component after merge
hetfly Jan 23, 2025
70608fd
fix: fix pool record component after merge
hetfly Jan 23, 2025
6756a4a
fix: fix respo rewards info apr
hetfly Jan 23, 2025
d9c5f4d
fix: There's too much space between the Rewards header and the chain …
swiftcc624 Jan 27, 2025
e8341a3
fix: The chain list keeps jumping around
swiftcc624 Jan 27, 2025
0e10a2b
fix: In case it's not related to the above issue, remove the prompt …
swiftcc624 Jan 27, 2025
c4face7
fix: I can still get it into a state where the assets are set to dif…
swiftcc624 Jan 28, 2025
e36c847
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Jan 28, 2025
396f621
fix: Update the APR tooltip:
swiftcc624 Jan 28, 2025
dcf9142
fix wallet section
0xmilktea Jan 28, 2025
c6583d1
refactor the code
0xmilktea Jan 28, 2025
565b493
fix: The slider should be maxed out by the time the first asset reac…
swiftcc624 Jan 28, 2025
05d163a
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 28, 2025
aa36d6b
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 28, 2025
c4a41fa
display address in the quote currency panel
0xmilktea Jan 28, 2025
dd4c1f7
fix: Let's add the button animation to Supplying, so it shows someth…
swiftcc624 Jan 28, 2025
0e5189b
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 28, 2025
fda15ce
fix: show baln apr range for icon pools only
hetfly Jan 28, 2025
555a09f
fix: I can't complete the Send transaction for the bnUSD on Sui, and…
swiftcc624 Jan 28, 2025
ced53dc
Merge branch 'feat/crosschain-lp' of https://github.com/balancednetwo…
hetfly Jan 28, 2025
6a4daa7
fix: fix external rewards info display
hetfly Jan 28, 2025
ad1975c
update locales
0xmilktea Jan 28, 2025
3d7ef94
fix jsonStorageOption bug
0xmilktea Jan 28, 2025
5c2d82d
fix: I removed the SUI to cancel this transaction, and when the amou…
swiftcc624 Jan 28, 2025
49078f8
refactor code
0xmilktea Jan 28, 2025
fb0115e
fix wICX symbol
swiftcc624 Jan 31, 2025
7a80b9d
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 31, 2025
045903d
fix exporting type in xwagmi
swiftcc624 Jan 31, 2025
f8c3c14
fix jsonStorage reviver for zustand in xwagmi
swiftcc624 Jan 31, 2025
5d1eccf
fix: When the final supply transaction is finished, the modal should …
swiftcc624 Jan 31, 2025
7bbd14a
extract WithdrawLiquidityModal from WithdrawPanel
swiftcc624 Jan 31, 2025
8c5274e
fix: show transfer fee, modal status in withdraw modal
swiftcc624 Jan 31, 2025
0fe52f9
fix: decimal issue when withdraw
0xmilktea Jan 31, 2025
cb8d834
refactor StakeLPPanel
0xmilktea Jan 31, 2025
a5ab14c
refactor RespoRewardInfo component
0xmilktea Jan 31, 2025
84ac9ff
ClaimLPRewardsModal
swiftcc624 Jan 31, 2025
eaa25af
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 31, 2025
7783ea2
StakeLPModal
swiftcc624 Jan 31, 2025
930551f
refactor mint hook
0xmilktea Jan 31, 2025
c747ae5
fix: 3x gas fee issue
0xmilktea Jan 31, 2025
e32abaa
fix: the slider doesn't work correctly when the token input amount is…
swiftcc624 Jan 31, 2025
6ce0dbf
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 31, 2025
7ff8c94
update locales
0xmilktea Feb 3, 2025
4340faa
update wallet modal
swiftcc624 Feb 3, 2025
a445dfd
update BALN text to rewards
0xmilktea Feb 3, 2025
90d5581
fix: This tooltip should have a , after the sICX amount (sICX (5.94%)…
swiftcc624 Feb 3, 2025
97388ed
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Feb 3, 2025
2c443b6
fix: Use a – for rewards on any chain that are less than $0.01
swiftcc624 Feb 3, 2025
c9f48ae
fix: Once a cross-chain transaction is in progress, we should change …
swiftcc624 Feb 3, 2025
77bf0b0
fix: I'm finding the transfer fee confusing, as I don't know at a gl…
swiftcc624 Feb 3, 2025
f9eafa4
fix: If you click on one of the liquidity pools to make it active in…
swiftcc624 Feb 3, 2025
78f3a38
fix: Update the transaction messages in the Bridge tab:
swiftcc624 Feb 3, 2025
b4943d9
fix: If the pool offers rewards, we should prompt people to stake th…
swiftcc624 Feb 3, 2025
1c11ceb
fix: disable sICX in archway & havah
0xmilktea Feb 3, 2025
8f8fc51
refactor: remove dead code
0xmilktea Feb 3, 2025
6bd9d2c
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 4, 2025
3f6968b
fix: If no chain is specified, tokens should default to their native…
swiftcc624 Feb 4, 2025
c0fa358
fix: I haven't been able to reproduce the issue with the AVAX pool y…
swiftcc624 Feb 4, 2025
a2b34ea
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Feb 5, 2025
af2be76
fix: There seems to be a gradient style applied to the Havah logo. I…
swiftcc624 Feb 6, 2025
ae7673b
fix: The Liquidity Pools section looks broken on mobile:
swiftcc624 Feb 6, 2025
5c562ff
fix: On mobile, the reward chain dropdown takes up more than the ava…
swiftcc624 Feb 6, 2025
f47397d
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 6, 2025
f1841e6
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 6, 2025
c5fdbd5
fix: Changed my mind regarding the 'switch network' handling, as the…
swiftcc624 Feb 6, 2025
009f7f9
fix: You can use the 25/50/75/100 buttons to exceed the amount avail…
swiftcc624 Feb 6, 2025
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 .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "jpoissonnier.vscode-styled-components"]
"recommendations": ["dbaeumer.vscode-eslint", "jpoissonnier.vscode-styled-components"]
}
6 changes: 3 additions & 3 deletions apps/hswap/src/app/components/WalletModal/HistoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import useElapsedTime from '@/hooks/useElapsedTime';
import { cn } from '@/lib/utils';
import { formatRelativeTime } from '@/utils';
import { formatBalance } from '@/utils/formatter';
import { getNetworkDisplayName, getTrackerLink } from '@balancednetwork/xwagmi';
import { XTransaction, XTransactionStatus, XTransactionType } from '@balancednetwork/xwagmi';
import { getNetworkDisplayName, getTrackerLink, isIconTransaction } from '@balancednetwork/xwagmi';
import { XTransaction, XTransactionStatus } from '@balancednetwork/xwagmi';
import { xMessageActions } from '@balancednetwork/xwagmi';
import { CheckIcon, ExternalLink, Loader2Icon } from 'lucide-react';

Expand Down Expand Up @@ -54,7 +54,7 @@ const HistoryItem = ({ xTransaction }: HistoryItemProps) => {
</div>
<a
href={
xTransaction.type === XTransactionType.SWAP_ON_ICON
isIconTransaction(xTransaction.sourceChainId, xTransaction.finalDestinationChainId)
? getTrackerLink('0x1.icon', xTransaction.id.split('/')[1])
: `https://xcallscan.xyz/messages/search?value=${primaryMessage?.destinationTransactionHash || primaryMessage?.sourceTransactionHash}`
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import React, { useState } from 'react';

import { Percent } from '@balancednetwork/sdk-core';
import { useXCallFee } from '@balancednetwork/xwagmi';
import { XTransactionType } from '@balancednetwork/xwagmi';
import { Trans } from '@lingui/macro';
import BigNumber from 'bignumber.js';

import SlippageSetting from '@/app/components/SlippageSetting';
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
import { PRICE_IMPACT_WARNING_THRESHOLD } from '@/constants/misc';
import { useSetSlippageTolerance, useSwapSlippageTolerance } from '@/store/application/hooks';
import { useDerivedSwapInfo } from '@/store/swap/hooks';
import { Field } from '@/store/swap/reducer';
import { formatPercent } from '@/utils';
import { Percent } from '@balancednetwork/sdk-core';
import { isIconTransaction, useXCallFee } from '@balancednetwork/xwagmi';
import { Trans } from '@lingui/macro';
import BigNumber from 'bignumber.js';

import { ChevronDownGradientIcon, ChevronUpGradientIcon } from '@/app/components/Icons';
import { cn } from '@/lib/utils';
Expand Down Expand Up @@ -112,7 +110,7 @@ export default function AdvancedSwapDetails() {
</span>
</div>

{xTransactionType !== XTransactionType.SWAP_ON_ICON && (
{!isIconTransaction(direction.from, direction.to) && (
<div className="flex items-center justify-between">
<span className="text-[#d4c5f9] text-sm font-medium flex items-center gap-1">
<Trans>Bridge Fee</Trans>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Field } from '@/store/swap/reducer';
import { formatBigNumber, formatElapsedTime } from '@/utils';
import { Currency, TradeType } from '@balancednetwork/sdk-core';
import { Trade } from '@balancednetwork/v1-sdk';
import { xChainMap } from '@balancednetwork/xwagmi';
import { isIconTransaction, xChainMap } from '@balancednetwork/xwagmi';
import { XToken } from '@balancednetwork/xwagmi';
import { useXCallFee } from '@balancednetwork/xwagmi';
import { XTransactionInput, XTransactionStatus, XTransactionType } from '@balancednetwork/xwagmi';
Expand Down Expand Up @@ -164,7 +164,7 @@ const XSwapModal = ({
</span>
</div>
)}
{xTransactionType !== XTransactionType.SWAP_ON_ICON && (
{!isIconTransaction(currentXTransaction?.sourceChainId, currentXTransaction?.finalDestinationChainId) && (
<div className="flex justify-between">
<span className="text-[#d4c5f9] text-sm font-medium">Bridge Fee</span>
<span className="text-white text-sm">{formattedXCallFee}</span>
Expand Down
4 changes: 4 additions & 0 deletions apps/hswap/src/store/lists/wrappedTokenInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export class WrappedTokenInfo implements Token {
return this;
}

public get unwrapped(): Token {
return this;
}

public get isNativeToken() {
const nativeAddresses = [
'cx0000000000000000000000000000000000000000',
Expand Down
18 changes: 4 additions & 14 deletions apps/web/src/app/components/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { DEFAULT_TOKEN_CHAIN, getSupportedXChainForSwapToken } from '@balancedne
import { XChainId } from '@balancednetwork/xwagmi';
import { isMobile } from 'react-device-detect';
import { HorizontalList, Option } from '../List';
import { CurrencySelectionType, SelectorType } from '../SearchModal/CurrencySearch';
import { CurrencySelectionType } from '../SearchModal/CurrencySearch';
import CurrencySearchModal from '../SearchModal/CurrencySearchModal';
import CrossChainOptions from '../trade/CrossChainOptions';
import DollarValue from './DollarValue';
Expand Down Expand Up @@ -106,7 +106,6 @@ interface CurrencyInputPanelProps {
className?: string;
account?: string | null;
showCommunityListControl?: boolean;
selectorType?: SelectorType;
showDollarValue?: boolean;
showWarning?: boolean;

Expand Down Expand Up @@ -134,7 +133,6 @@ export default function CurrencyInputPanel({
className,
account,
showCommunityListControl = true,
selectorType,
showDollarValue = true,
showWarning = false,

Expand Down Expand Up @@ -178,10 +176,7 @@ export default function CurrencyInputPanel({
const [xChainOptionsOpen, setXChainOptionsOpen] = React.useState(false);
const xChains = useMemo(
() =>
currencySelectionType === CurrencySelectionType.TRADE_MINT_BASE ||
currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE
? []
: getSupportedXChainForSwapToken(currency),
currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE ? [] : getSupportedXChainForSwapToken(currency),
[currency, currencySelectionType],
);

Expand All @@ -190,19 +185,14 @@ export default function CurrencyInputPanel({
onCurrencySelect && onCurrencySelect(currency);

if (setDefaultChain && currency?.symbol) {
const xChains =
currencySelectionType === CurrencySelectionType.TRADE_MINT_BASE ||
currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE
? []
: getSupportedXChainForSwapToken(currency);
const defaultXChainId = DEFAULT_TOKEN_CHAIN[currency.symbol];
if (defaultXChainId && (xChains?.length ?? 0) > 1) {
onChainSelect && onChainSelect(defaultXChainId);
setTimeout(() => setXChainOptionsOpen(true), 100);
}
}
},
[onCurrencySelect, onChainSelect, currencySelectionType],
[onCurrencySelect, onChainSelect, xChains],
);

return (
Expand Down Expand Up @@ -244,7 +234,6 @@ export default function CurrencyInputPanel({
showCommunityListControl={showCommunityListControl}
xChainId={xChainId}
showCrossChainBreakdown={showCrossChainBreakdown}
selectorType={selectorType}
/>
)}
</div>
Expand Down Expand Up @@ -303,6 +292,7 @@ export default function CurrencyInputPanel({
width={width ? width + (!isMobile ? 40 : 0) : undefined}
containerRef={ref.current}
setManualAddress={setManualAddress}
showAddress={currencySelectionType !== CurrencySelectionType.TRADE_MINT_QUOTE}
/>
)}
</Box>
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/app/components/ModalContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const ModalContentWrapper = styled(Flex)`
`;

export default function ModalContent(props: Props) {
// TODO: deprecate
const hasEnoughICX = useHasEnoughICX();
const { noCurrencyBalanceErrorMessage, noMessages, children, ...rest } = props;

Expand Down
95 changes: 95 additions & 0 deletions apps/web/src/app/components/PoolLogoWithNetwork/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import React from 'react';

import { Currency, XChainId } from '@balancednetwork/sdk-core';
import { Box } from 'rebass/styled-components';
import styled, { css } from 'styled-components';

import { xChainMap } from '@balancednetwork/xwagmi';
import { ChainLogo } from '../ChainLogo';
import CurrencyLogo from '../CurrencyLogo';

const IconWrapper = styled(Box)<{ $respoVersion?: boolean }>`
width: 48px;
height: 48px;
border-radius: 50%;
border: 1px solid rgb(12, 42, 77);
background-color: rgb(20, 74, 104);
display: flex;
justify-content: center;
align-items: center;

${({ $respoVersion, theme }) =>
$respoVersion &&
css`
width: 30px;
height: 30px;

img {
width: 18px;
height: 18px;
}

${theme.mediaWidth.upMedium`
width: 48px;
height: 48px;

img {
width: 24px;
height: 24px;
}
`}
`};
`;

const NetworkWrap = styled.div`
position: absolute;
border-radius: 50%;
width: 14px;
height: 14px;
left: 50%;
bottom: 0;
margin-left: -7px;

background: #0c2a4d;
outline: 5px solid #0f395a;

img {
position: absolute;
top: 0;
left: 0;
}
`;

export const PoolLogoWrapper = styled(Box)`
position: relative;
display: flex;
min-width: 80px;
`;

function PoolLogoWithNetwork({
baseCurrency,
quoteCurrency,
respoVersion,
chainId,
}: {
baseCurrency: Currency;
quoteCurrency: Currency;
respoVersion?: boolean;
chainId: XChainId;
}) {
return (
<PoolLogoWrapper>
<IconWrapper $respoVersion={respoVersion}>
<CurrencyLogo currency={baseCurrency} />
</IconWrapper>
<IconWrapper ml={-2} $respoVersion={respoVersion}>
<CurrencyLogo currency={quoteCurrency} />
</IconWrapper>
<NetworkWrap>
<ChainLogo chain={xChainMap[chainId]} size="14px" />
</NetworkWrap>
</PoolLogoWrapper>
);
}

export default PoolLogoWithNetwork;
19 changes: 12 additions & 7 deletions apps/web/src/app/components/RewardsDisplay/RewardsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PairData } from '@/queries/backendv2';
import { useRatesWithOracle } from '@/queries/reward';
import { Source } from '@/store/bbaln/hooks';
import { formatValue } from '@/utils/formatter';
import { XChainId } from '@balancednetwork/xwagmi';
import { Trans } from '@lingui/macro';
import BigNumber from 'bignumber.js';
import React, { Fragment, useMemo } from 'react';
Expand All @@ -15,6 +16,7 @@ import styled from 'styled-components';

type RewardsDisplayProps = {
pair: PairData;
xChainId?: XChainId;
boost?: {
[x: string]: Source;
};
Expand Down Expand Up @@ -79,9 +81,10 @@ const TooltipContent = ({
</>
);

const RewardsDisplay: React.FC<RewardsDisplayProps> = ({ pair, boost }) => {
const RewardsDisplay: React.FC<RewardsDisplayProps> = ({ pair, boost, xChainId }) => {
const prices = useRatesWithOracle();
const pairName = pair.name;
const isICON = xChainId === undefined || xChainId === '0x1.icon';
const pairBoost = useMemo(() => {
if (boost) {
const pairBoostData = boost[pairName];
Expand Down Expand Up @@ -128,12 +131,14 @@ const RewardsDisplay: React.FC<RewardsDisplayProps> = ({ pair, boost }) => {
<Typography color="#d5d7db" fontSize={14} marginRight={'5px'}>
<Trans>BALN:</Trans>
</Typography>
{pairBoost
? `${formatValue((balnApy * pairBoost + externalApy).toFixed(4), false)}%`
: `${formatValue((balnApy + externalApy).toFixed(4), false)}% - ${formatValue(
(balnApy * 2.5 + externalApy).toFixed(4),
false,
)}%`}
{isICON
? pairBoost
? `${formatValue((balnApy * pairBoost + externalApy).toFixed(4), false)}%`
: `${formatValue((balnApy + externalApy).toFixed(4), false)}% - ${formatValue(
(balnApy * 2.5 + externalApy).toFixed(4),
false,
)}%`
: `${formatValue((balnApy + externalApy).toFixed(4), false)}%`}
</APYItem>
</Wrapper>
);
Expand Down
Loading