From fd5ead5df7ce54692ae06fed51018085d3aaad19 Mon Sep 17 00:00:00 2001 From: zielvna Date: Fri, 29 Dec 2023 14:01:20 +0100 Subject: [PATCH 1/5] update add liquidity button redirect --- .../PositionDetails/PositionDetails.tsx | 21 ++++++---- .../SinglePositionWrapper.tsx | 38 ++++++++++--------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/components/PositionDetails/PositionDetails.tsx b/src/components/PositionDetails/PositionDetails.tsx index cb0c5def6..c0a57db1f 100644 --- a/src/components/PositionDetails/PositionDetails.tsx +++ b/src/components/PositionDetails/PositionDetails.tsx @@ -1,15 +1,18 @@ -import React, { useState } from 'react' import SinglePositionInfo from '@components/PositionDetails/SinglePositionInfo/SinglePositionInfo' -import SinglePositionPlot from '@components/PositionDetails/SinglePositionPlot/SinglePositionPlot' +import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' import { Button, Grid, Hidden, Typography } from '@material-ui/core' -import { Link, useHistory } from 'react-router-dom' -import backIcon from '@static/svg/back-arrow.svg' -import useStyles from './style' import { PlotTickData } from '@reducers/positions' -import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' +import { PublicKey } from '@solana/web3.js' +import backIcon from '@static/svg/back-arrow.svg' +import React, { useState } from 'react' +import { Link, useHistory } from 'react-router-dom' import { ILiquidityToken } from './SinglePositionInfo/consts' +import SinglePositionPlot from './SinglePositionPlot/SinglePositionPlot' +import useStyles from './style' interface IProps { + tokenXAddress: PublicKey + tokenYAddress: PublicKey detailsData: PlotTickData[] leftRange: TickPlotPositionData rightRange: TickPlotPositionData @@ -37,6 +40,8 @@ interface IProps { } const PositionDetails: React.FC = ({ + tokenXAddress, + tokenYAddress, detailsData, leftRange, rightRange, @@ -99,7 +104,9 @@ const PositionDetails: React.FC = ({ className={classes.button} variant='contained' onClick={() => { - history.push('/newPosition') + history.push( + `/newPosition/${tokenXAddress.toString()}/${tokenYAddress.toString()}/${fee}` + ) }}> + Add Liquidity diff --git a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx index c77039809..a5f6443f4 100644 --- a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx +++ b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx @@ -1,33 +1,33 @@ -import React, { useMemo, useEffect, useState } from 'react' -import { useHistory } from 'react-router' -import { useDispatch, useSelector } from 'react-redux' -import { actions } from '@reducers/positions' -import { - currentPositionRangeTicks, - isLoadingPositionsList, - plotTicks, - singlePositionData -} from '@selectors/positions' import PositionDetails from '@components/PositionDetails/PositionDetails' -import { Grid, Typography } from '@material-ui/core' import { + CoingeckoPriceData, calcPrice, calcYPerXPrice, - CoingeckoPriceData, createPlaceholderLiquidityPlot, getCoingeckoTokenPrice, printBN } from '@consts/utils' import { calculatePriceSqrt } from '@invariant-labs/sdk' -import { calculateClaimAmount, DECIMAL } from '@invariant-labs/sdk/src/utils' -import { getX, getY, MAX_TICK } from '@invariant-labs/sdk/lib/math' -import loader from '@static/gif/loader.gif' -import useStyles from './style' -import { hasTokens, volumeRanges } from '@selectors/pools' -import { hasFarms, hasUserStakes, stakesForPosition } from '@selectors/farms' +import { MAX_TICK, getX, getY } from '@invariant-labs/sdk/lib/math' +import { DECIMAL, calculateClaimAmount } from '@invariant-labs/sdk/src/utils' +import { Grid, Typography } from '@material-ui/core' import { actions as farmsActions } from '@reducers/farms' +import { actions } from '@reducers/positions' import { Status } from '@reducers/solanaWallet' +import { hasFarms, hasUserStakes, stakesForPosition } from '@selectors/farms' +import { hasTokens, volumeRanges } from '@selectors/pools' +import { + currentPositionRangeTicks, + isLoadingPositionsList, + plotTicks, + singlePositionData +} from '@selectors/positions' import { status } from '@selectors/solanaWallet' +import loader from '@static/gif/loader.gif' +import React, { useEffect, useMemo, useState } from 'react' +import { useDispatch, useSelector } from 'react-redux' +import { useHistory } from 'react-router' +import useStyles from './style' export interface IProps { id: string @@ -332,6 +332,8 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { return !isLoadingList && position ? ( Date: Fri, 29 Dec 2023 14:48:08 +0100 Subject: [PATCH 2/5] refactor path fee parsing --- .../DepositSelector/DepositSelector.tsx | 11 +++-- src/components/NewPosition/NewPosition.tsx | 44 +++---------------- .../PositionDetails/PositionDetails.tsx | 16 ++++--- .../SinglePositionWrapper.tsx | 4 +- src/store/consts/uiUtils.ts | 37 ++++++++++++++++ 5 files changed, 62 insertions(+), 50 deletions(-) diff --git a/src/components/NewPosition/DepositSelector/DepositSelector.tsx b/src/components/NewPosition/DepositSelector/DepositSelector.tsx index 5ee675676..017258b2f 100644 --- a/src/components/NewPosition/DepositSelector/DepositSelector.tsx +++ b/src/components/NewPosition/DepositSelector/DepositSelector.tsx @@ -7,6 +7,7 @@ import { WSOL_MIN_DEPOSIT_SWAP_FROM_AMOUNT, WSOL_POOL_INIT_LAMPORTS } from '@consts/static' +import { aliasToAddress, parsePathFeeToFeeString } from '@consts/uiUtils' import { getScaleFromString, printBN, printBNtoBN } from '@consts/utils' import { Grid, Typography } from '@material-ui/core' import { BN } from '@project-serum/anchor' @@ -30,7 +31,6 @@ export interface IDepositSelector { initialTokenFrom: string initialTokenTo: string initialFee: string - getAddress: (address: string) => string tokens: SwapToken[] setPositionTokens: ( tokenAIndex: number | null, @@ -65,7 +65,6 @@ export const DepositSelector: React.FC = ({ initialTokenFrom, initialTokenTo, initialFee, - getAddress, tokens, setPositionTokens, onAddLiquidity, @@ -108,18 +107,18 @@ export const DepositSelector: React.FC = ({ let feeTierIndexFromPath = 0 tokens.forEach((token, index) => { - if (token.assetAddress.toString() === getAddress(initialTokenFrom)) { + if (token.assetAddress.toString() === aliasToAddress(initialTokenFrom)) { tokenAIndexFromPath = index } - if (token.assetAddress.toString() === getAddress(initialTokenTo)) { + if (token.assetAddress.toString() === aliasToAddress(initialTokenTo)) { tokenBIndexFromPath = index } }) - ALL_FEE_TIERS_DATA.forEach((feeTierData, index) => { - const parsedFee = (+initialFee.replace('_', '') * Math.pow(10, 8)).toString() + const parsedFee = parsePathFeeToFeeString(initialFee) + ALL_FEE_TIERS_DATA.forEach((feeTierData, index) => { if (feeTierData.tier.fee.toString() === parsedFee) { feeTierIndexFromPath = index } diff --git a/src/components/NewPosition/NewPosition.tsx b/src/components/NewPosition/NewPosition.tsx index 64dbf0d56..93a953196 100644 --- a/src/components/NewPosition/NewPosition.tsx +++ b/src/components/NewPosition/NewPosition.tsx @@ -3,7 +3,7 @@ import Slippage from '@components/Modals/Slippage/Slippage' import { INoConnected, NoConnected } from '@components/NoConnected/NoConnected' import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' import { ALL_FEE_TIERS_DATA, BestTier } from '@consts/static' -import { blurContent, unblurContent } from '@consts/uiUtils' +import { addressToAlias, blurContent, parseFeeToPathFee, unblurContent } from '@consts/uiUtils' import { CoingeckoPriceData, PositionTokenBlock, @@ -25,7 +25,7 @@ import { PublicKey } from '@solana/web3.js' import backIcon from '@static/svg/back-arrow.svg' import settingIcon from '@static/svg/settings.svg' import { History } from 'history' -import React, { useEffect, useMemo, useState } from 'react' +import React, { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import ConcentrationTypeSwitch from './ConcentrationTypeSwitch/ConcentrationTypeSwitch' import DepositSelector from './DepositSelector/DepositSelector' @@ -314,47 +314,18 @@ export const NewPosition: React.FC = ({ onSlippageChange(slippage) } - const tokenAliasMap: { [key: string]: string } = { - SOL: 'So11111111111111111111111111111111111111112', - USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', - USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', - USDH: 'USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX', - mSOL: 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So', - bSOL: 'bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1', - stSOL: '7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj', - SNY: '4dmKkXNHdgYsXqBHCuMikNQWwVomZURhYvkkX5c4pQ7y', - ETH: '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs', - LFNTY: 'LFNTYraetVioAPnGJht4yNg2aUZFXR776cMeN9VMjXp' - } - - const reversedTokenAliasMap = useMemo(() => { - return Object.fromEntries(Object.entries(tokenAliasMap).map(([key, value]) => [value, key])) - }, [tokenAliasMap]) - - const getAlias = (address: string): string => { - return reversedTokenAliasMap[address] ?? address - } - - const getAddress = (alias: string): string => { - return tokenAliasMap[alias] ?? alias - } - const updatePath = (index1: number | null, index2: number | null, fee: number) => { - let parsedFee = (+ALL_FEE_TIERS_DATA[fee].tier.fee / Math.pow(10, 8)) - .toString() - .padStart(3, '0') - parsedFee = - parsedFee.slice(0, parsedFee.length - 2) + '_' + parsedFee.slice(parsedFee.length - 2) + const parsedFee = parseFeeToPathFee(+ALL_FEE_TIERS_DATA[fee].tier.fee) if (index1 != null && index2 != null) { - const address1 = getAlias(tokens[index1].assetAddress.toString()) - const address2 = getAlias(tokens[index2].assetAddress.toString()) + const address1 = addressToAlias(tokens[index1].assetAddress.toString()) + const address2 = addressToAlias(tokens[index2].assetAddress.toString()) history.replace(`/newPosition/${address1}/${address2}/${parsedFee}`) } else if (index1 != null) { - const address = getAlias(tokens[index1].assetAddress.toString()) + const address = addressToAlias(tokens[index1].assetAddress.toString()) history.replace(`/newPosition/${address}/${parsedFee}`) } else if (index2 != null) { - const address = getAlias(tokens[index2].assetAddress.toString()) + const address = addressToAlias(tokens[index2].assetAddress.toString()) history.replace(`/newPosition/${address}/${parsedFee}`) } else if (fee != null) { history.replace(`/newPosition/${parsedFee}`) @@ -408,7 +379,6 @@ export const NewPosition: React.FC = ({ initialTokenFrom={initialTokenFrom} initialTokenTo={initialTokenTo} initialFee={initialFee} - getAddress={getAddress} className={classes.deposit} tokens={tokens} setPositionTokens={(index1, index2, fee) => { diff --git a/src/components/PositionDetails/PositionDetails.tsx b/src/components/PositionDetails/PositionDetails.tsx index c0a57db1f..970ba97ce 100644 --- a/src/components/PositionDetails/PositionDetails.tsx +++ b/src/components/PositionDetails/PositionDetails.tsx @@ -1,5 +1,9 @@ import SinglePositionInfo from '@components/PositionDetails/SinglePositionInfo/SinglePositionInfo' import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' +import { addressToAlias, parseFeeToPathFee } from '@consts/uiUtils' +import { printBN } from '@consts/utils' +import { Decimal } from '@invariant-labs/sdk/lib/market' +import { DECIMAL } from '@invariant-labs/sdk/lib/utils' import { Button, Grid, Hidden, Typography } from '@material-ui/core' import { PlotTickData } from '@reducers/positions' import { PublicKey } from '@solana/web3.js' @@ -24,7 +28,7 @@ interface IProps { closePosition: (claimFarmRewards?: boolean) => void ticksLoading: boolean tickSpacing: number - fee: number + fee: Decimal min: number max: number initialIsDiscreteValue: boolean @@ -81,7 +85,7 @@ const PositionDetails: React.FC = ({ = ({ className={classes.button} variant='contained' onClick={() => { - history.push( - `/newPosition/${tokenXAddress.toString()}/${tokenYAddress.toString()}/${fee}` - ) + const parsedFee = parseFeeToPathFee(fee.v) + const address1 = addressToAlias(tokenXAddress.toString()) + const address2 = addressToAlias(tokenYAddress.toString()) + + history.push(`/newPosition/${address1}/${address2}/${parsedFee}`) }}> + Add Liquidity diff --git a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx index a5f6443f4..14cc78909 100644 --- a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx +++ b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx @@ -9,7 +9,7 @@ import { } from '@consts/utils' import { calculatePriceSqrt } from '@invariant-labs/sdk' import { MAX_TICK, getX, getY } from '@invariant-labs/sdk/lib/math' -import { DECIMAL, calculateClaimAmount } from '@invariant-labs/sdk/src/utils' +import { calculateClaimAmount } from '@invariant-labs/sdk/src/utils' import { Grid, Typography } from '@material-ui/core' import { actions as farmsActions } from '@reducers/farms' import { actions } from '@reducers/positions' @@ -379,7 +379,7 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { ? undefined : tokenYPriceData.price * +printBN(position.tokenY.balance, position.tokenY.decimals) }} - fee={+printBN(position.poolData.fee.v, DECIMAL - 2)} + fee={position.poolData.fee} min={min} max={max} initialIsDiscreteValue={initialIsDiscreteValue} diff --git a/src/store/consts/uiUtils.ts b/src/store/consts/uiUtils.ts index ab2dfc98b..82c6f7d7e 100644 --- a/src/store/consts/uiUtils.ts +++ b/src/store/consts/uiUtils.ts @@ -1,5 +1,24 @@ +import { BN } from '@project-serum/anchor' + export const toBlur = 'global-blur' +export const addressAliasMap: { [key: string]: string } = { + SOL: 'So11111111111111111111111111111111111111112', + USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', + USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', + USDH: 'USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX', + mSOL: 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So', + bSOL: 'bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1', + stSOL: '7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj', + SNY: '4dmKkXNHdgYsXqBHCuMikNQWwVomZURhYvkkX5c4pQ7y', + ETH: '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs', + LFNTY: 'LFNTYraetVioAPnGJht4yNg2aUZFXR776cMeN9VMjXp' +} + +export const reversedAddressAliasMap = Object.fromEntries( + Object.entries(addressAliasMap).map(([key, value]) => [value, key]) +) + // could use rewriting to backdrop-filter when browser support is better export const blurContent = () => { const el = document.getElementById(toBlur) @@ -22,3 +41,21 @@ export const importantStyles = (styleObject: { [key: string]: string | number }) }), styleObject ) + +export const parseFeeToPathFee = (fee: BN): string => { + let parsedFee = (fee / Math.pow(10, 8)).toString().padStart(3, '0') + return (parsedFee = + parsedFee.slice(0, parsedFee.length - 2) + '_' + parsedFee.slice(parsedFee.length - 2)) +} + +export const parsePathFeeToFeeString = (pathFee: string): string => { + return (+pathFee.replace('_', '') * Math.pow(10, 8)).toString() +} + +export const aliasToAddress = (alias: string): string => { + return addressAliasMap[alias] || alias +} + +export const addressToAlias = (address: string): string => { + return reversedAddressAliasMap[address] || address +} From ef1e35dd97cfef27a0f79f9f3f39120823703afb Mon Sep 17 00:00:00 2001 From: zielvna Date: Fri, 29 Dec 2023 15:01:26 +0100 Subject: [PATCH 3/5] update parse fee to path fee function in utils --- src/store/consts/uiUtils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/store/consts/uiUtils.ts b/src/store/consts/uiUtils.ts index 82c6f7d7e..5da55a9e2 100644 --- a/src/store/consts/uiUtils.ts +++ b/src/store/consts/uiUtils.ts @@ -43,9 +43,8 @@ export const importantStyles = (styleObject: { [key: string]: string | number }) ) export const parseFeeToPathFee = (fee: BN): string => { - let parsedFee = (fee / Math.pow(10, 8)).toString().padStart(3, '0') - return (parsedFee = - parsedFee.slice(0, parsedFee.length - 2) + '_' + parsedFee.slice(parsedFee.length - 2)) + const parsedFee = (fee / Math.pow(10, 8)).toString().padStart(3, '0') + return parsedFee.slice(0, parsedFee.length - 2) + '_' + parsedFee.slice(parsedFee.length - 2) } export const parsePathFeeToFeeString = (pathFee: string): string => { From e14e16a4b09e06fa3c3dc157e002440a10406642 Mon Sep 17 00:00:00 2001 From: zielvna Date: Tue, 2 Jan 2024 10:01:03 +0100 Subject: [PATCH 4/5] change alias to ticker --- .../DepositSelector/DepositSelector.tsx | 6 +++--- src/components/NewPosition/NewPosition.tsx | 10 +++++----- src/components/PositionDetails/PositionDetails.tsx | 6 +++--- src/store/consts/uiUtils.ts | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/NewPosition/DepositSelector/DepositSelector.tsx b/src/components/NewPosition/DepositSelector/DepositSelector.tsx index 017258b2f..f2fa575fa 100644 --- a/src/components/NewPosition/DepositSelector/DepositSelector.tsx +++ b/src/components/NewPosition/DepositSelector/DepositSelector.tsx @@ -7,7 +7,7 @@ import { WSOL_MIN_DEPOSIT_SWAP_FROM_AMOUNT, WSOL_POOL_INIT_LAMPORTS } from '@consts/static' -import { aliasToAddress, parsePathFeeToFeeString } from '@consts/uiUtils' +import { parsePathFeeToFeeString, tickerToAddress } from '@consts/uiUtils' import { getScaleFromString, printBN, printBNtoBN } from '@consts/utils' import { Grid, Typography } from '@material-ui/core' import { BN } from '@project-serum/anchor' @@ -107,11 +107,11 @@ export const DepositSelector: React.FC = ({ let feeTierIndexFromPath = 0 tokens.forEach((token, index) => { - if (token.assetAddress.toString() === aliasToAddress(initialTokenFrom)) { + if (token.assetAddress.toString() === tickerToAddress(initialTokenFrom)) { tokenAIndexFromPath = index } - if (token.assetAddress.toString() === aliasToAddress(initialTokenTo)) { + if (token.assetAddress.toString() === tickerToAddress(initialTokenTo)) { tokenBIndexFromPath = index } }) diff --git a/src/components/NewPosition/NewPosition.tsx b/src/components/NewPosition/NewPosition.tsx index 93a953196..d71825af7 100644 --- a/src/components/NewPosition/NewPosition.tsx +++ b/src/components/NewPosition/NewPosition.tsx @@ -3,7 +3,7 @@ import Slippage from '@components/Modals/Slippage/Slippage' import { INoConnected, NoConnected } from '@components/NoConnected/NoConnected' import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' import { ALL_FEE_TIERS_DATA, BestTier } from '@consts/static' -import { addressToAlias, blurContent, parseFeeToPathFee, unblurContent } from '@consts/uiUtils' +import { addressToTicker, blurContent, parseFeeToPathFee, unblurContent } from '@consts/uiUtils' import { CoingeckoPriceData, PositionTokenBlock, @@ -318,14 +318,14 @@ export const NewPosition: React.FC = ({ const parsedFee = parseFeeToPathFee(+ALL_FEE_TIERS_DATA[fee].tier.fee) if (index1 != null && index2 != null) { - const address1 = addressToAlias(tokens[index1].assetAddress.toString()) - const address2 = addressToAlias(tokens[index2].assetAddress.toString()) + const address1 = addressToTicker(tokens[index1].assetAddress.toString()) + const address2 = addressToTicker(tokens[index2].assetAddress.toString()) history.replace(`/newPosition/${address1}/${address2}/${parsedFee}`) } else if (index1 != null) { - const address = addressToAlias(tokens[index1].assetAddress.toString()) + const address = addressToTicker(tokens[index1].assetAddress.toString()) history.replace(`/newPosition/${address}/${parsedFee}`) } else if (index2 != null) { - const address = addressToAlias(tokens[index2].assetAddress.toString()) + const address = addressToTicker(tokens[index2].assetAddress.toString()) history.replace(`/newPosition/${address}/${parsedFee}`) } else if (fee != null) { history.replace(`/newPosition/${parsedFee}`) diff --git a/src/components/PositionDetails/PositionDetails.tsx b/src/components/PositionDetails/PositionDetails.tsx index 970ba97ce..69a380252 100644 --- a/src/components/PositionDetails/PositionDetails.tsx +++ b/src/components/PositionDetails/PositionDetails.tsx @@ -1,6 +1,6 @@ import SinglePositionInfo from '@components/PositionDetails/SinglePositionInfo/SinglePositionInfo' import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' -import { addressToAlias, parseFeeToPathFee } from '@consts/uiUtils' +import { addressToTicker, parseFeeToPathFee } from '@consts/uiUtils' import { printBN } from '@consts/utils' import { Decimal } from '@invariant-labs/sdk/lib/market' import { DECIMAL } from '@invariant-labs/sdk/lib/utils' @@ -109,8 +109,8 @@ const PositionDetails: React.FC = ({ variant='contained' onClick={() => { const parsedFee = parseFeeToPathFee(fee.v) - const address1 = addressToAlias(tokenXAddress.toString()) - const address2 = addressToAlias(tokenYAddress.toString()) + const address1 = addressToTicker(tokenXAddress.toString()) + const address2 = addressToTicker(tokenYAddress.toString()) history.push(`/newPosition/${address1}/${address2}/${parsedFee}`) }}> diff --git a/src/store/consts/uiUtils.ts b/src/store/consts/uiUtils.ts index 5da55a9e2..2e11e82d0 100644 --- a/src/store/consts/uiUtils.ts +++ b/src/store/consts/uiUtils.ts @@ -2,7 +2,7 @@ import { BN } from '@project-serum/anchor' export const toBlur = 'global-blur' -export const addressAliasMap: { [key: string]: string } = { +export const addressTickerMap: { [key: string]: string } = { SOL: 'So11111111111111111111111111111111111111112', USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', @@ -15,8 +15,8 @@ export const addressAliasMap: { [key: string]: string } = { LFNTY: 'LFNTYraetVioAPnGJht4yNg2aUZFXR776cMeN9VMjXp' } -export const reversedAddressAliasMap = Object.fromEntries( - Object.entries(addressAliasMap).map(([key, value]) => [value, key]) +export const reversedAddressTickerMap = Object.fromEntries( + Object.entries(addressTickerMap).map(([key, value]) => [value, key]) ) // could use rewriting to backdrop-filter when browser support is better @@ -51,10 +51,10 @@ export const parsePathFeeToFeeString = (pathFee: string): string => { return (+pathFee.replace('_', '') * Math.pow(10, 8)).toString() } -export const aliasToAddress = (alias: string): string => { - return addressAliasMap[alias] || alias +export const tickerToAddress = (alias: string): string => { + return addressTickerMap[alias] || alias } -export const addressToAlias = (address: string): string => { - return reversedAddressAliasMap[address] || address +export const addressToTicker = (address: string): string => { + return reversedAddressTickerMap[address] || address } From 16c42daaaec60a7c0bac1aa9004c9b110dbab3bf Mon Sep 17 00:00:00 2001 From: zielvna Date: Tue, 2 Jan 2024 10:36:10 +0100 Subject: [PATCH 5/5] update ticker to address function --- src/store/consts/uiUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/consts/uiUtils.ts b/src/store/consts/uiUtils.ts index 2e11e82d0..73c144918 100644 --- a/src/store/consts/uiUtils.ts +++ b/src/store/consts/uiUtils.ts @@ -51,8 +51,8 @@ export const parsePathFeeToFeeString = (pathFee: string): string => { return (+pathFee.replace('_', '') * Math.pow(10, 8)).toString() } -export const tickerToAddress = (alias: string): string => { - return addressTickerMap[alias] || alias +export const tickerToAddress = (ticker: string): string => { + return addressTickerMap[ticker] || ticker } export const addressToTicker = (address: string): string => {