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

Change ratio for sol usdc #867

Merged
merged 4 commits into from
Jan 22, 2025
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
10 changes: 5 additions & 5 deletions src/components/PopularPools/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ const Card: React.FC<ICard> = ({
const handleOpenPosition = () => {
if (fee === undefined) return

const revertRatio = initialXtoY(addressFrom ?? '', addressTo ?? '')
const isXToY = initialXtoY(addressFrom ?? '', addressTo ?? '')

const tokenA = revertRatio
? addressToTicker(network, addressTo ?? '')
: addressToTicker(network, addressFrom ?? '')
const tokenB = revertRatio
const tokenA = isXToY
? addressToTicker(network, addressFrom ?? '')
: addressToTicker(network, addressTo ?? '')
const tokenB = isXToY
? addressToTicker(network, addressTo ?? '')
: addressToTicker(network, addressFrom ?? '')

navigate(
`/newPosition/${tokenA}/${tokenB}/${parseFeeToPathFee(Math.round(fee * 10 ** (DECIMAL - 2)))}`,
Expand Down
4 changes: 2 additions & 2 deletions src/components/PositionDetails/PositionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ const PositionDetails: React.FC<IProps> = ({
className={classes.button}
variant='contained'
onClick={() => {
const parsedFee = parseFeeToPathFee(fee)
const parsedFee = parseFeeToPathFee(fee.v)
const address1 = addressToTicker(network, tokenXAddress.toString())
const address2 = addressToTicker(network, tokenYAddress.toString())

const revertRatio = !initialXtoY(
const revertRatio = initialXtoY(
tokenXAddress.toString() ?? '',
tokenYAddress.toString() ?? ''
)
Expand Down
10 changes: 5 additions & 5 deletions src/components/Stats/PoolListItem/PoolListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ const PoolListItem: React.FC<IProps> = ({
const isMd = useMediaQuery(theme.breakpoints.down('md'))

const handleOpenPosition = () => {
const revertRatio = initialXtoY(addressFrom ?? '', addressTo ?? '')
const isXtoY = initialXtoY(addressFrom ?? '', addressTo ?? '')

const tokenA = revertRatio
? addressToTicker(network, addressTo ?? '')
: addressToTicker(network, addressFrom ?? '')
const tokenB = revertRatio
const tokenA = isXtoY
? addressToTicker(network, addressFrom ?? '')
: addressToTicker(network, addressTo ?? '')
const tokenB = isXtoY
? addressToTicker(network, addressTo ?? '')
: addressToTicker(network, addressFrom ?? '')

navigate(
`/newPosition/${tokenA}/${tokenB}/${parseFeeToPathFee(Math.round(fee * 10 ** (DECIMAL - 2)))}`,
Expand Down
11 changes: 8 additions & 3 deletions src/store/consts/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,16 @@ export const SIGNING_SNACKBAR_CONFIG: Omit<ISnackbar, 'open'> = {
persist: true
}

export const ADDRESSES_TO_REVERT_TOKEN_PAIRS: string[] = [
export const ADDRESSES_ORDER_TO_REVERT: string[] = [
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
'So11111111111111111111111111111111111111112', //SOL
'7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs' //ETH
'USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX', // USDH
'So11111111111111111111111111111111111111112', // SOL
'J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn', // JitoSOL
'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So', // mSol
'27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4', // JLP
'jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v', // JupSOL
'7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs' // ETH
]

export const REFRESHER_INTERVAL = 120
Expand Down
22 changes: 18 additions & 4 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
SUI_MAIN,
WRAPPED_SOL_ADDRESS,
NATIVE_TICK_CROSSES_PER_IX,
ADDRESSES_TO_REVERT_TOKEN_PAIRS
ADDRESSES_ORDER_TO_REVERT
} from '@store/consts/static'
import mainnetList from '@store/consts/tokenLists/mainnet.json'
import { FormatConfig, subNumbers } from '@store/consts/static'
Expand Down Expand Up @@ -1638,10 +1638,24 @@ export const initialXtoY = (tokenXAddress?: string | null, tokenYAddress?: strin
return true
}

const tokenXIndex = ADDRESSES_TO_REVERT_TOKEN_PAIRS.findIndex(token => token === tokenXAddress)
const tokenYIndex = ADDRESSES_TO_REVERT_TOKEN_PAIRS.findIndex(token => token === tokenYAddress)
const tokenXIndex = ADDRESSES_ORDER_TO_REVERT.findIndex(token => token === tokenXAddress)
const tokenYIndex = ADDRESSES_ORDER_TO_REVERT.findIndex(token => token === tokenYAddress)

return tokenXIndex < tokenYIndex
if (tokenXIndex === -1 || tokenYIndex === -1) {
return true
}

if (tokenXIndex !== -1 && tokenYIndex !== -1) {
if (tokenXIndex < tokenYIndex) {
return false
} else {
return true
}
} else if (tokenXIndex > tokenYIndex) {
return true
} else {
return false
}
}

export const parseFeeToPathFee = (fee: BN): string => {
Expand Down
Loading