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

Bumped sdk, update common tokens, added TIA and sTIA, fixed coingecko price #157

Merged
merged 19 commits into from
Nov 2, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
jobs:
upload:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
jobs:
upload:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:

upload:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@invariant-labs/sdk-eclipse": "^0.0.22",
"@invariant-labs/sdk-eclipse": "^0.0.25",
"@irys/web-upload": "^0.0.13",
"@irys/web-upload-solana": "^0.1.6",
"@metaplex-foundation/js": "^0.20.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export const Primary: Story = {
setTokenAIndex: fn(),
setTokenBIndex: fn(),
tokenAIndex: 0,
tokenBIndex: 1
tokenBIndex: 1,
canNavigate: true
},
render: args => <PrimaryComponent {...args} />
}
27 changes: 26 additions & 1 deletion src/components/NewPosition/DepositSelector/DepositSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface IDepositSelector {
tokenBIndex: number | null
setTokenAIndex: (index: number | null) => void
setTokenBIndex: (index: number | null) => void
canNavigate: boolean
}

export const DepositSelector: React.FC<IDepositSelector> = ({
Expand Down Expand Up @@ -121,7 +122,8 @@ export const DepositSelector: React.FC<IDepositSelector> = ({
walletStatus,
onConnectWallet,
onDisconnectWallet,
ethBalance
ethBalance,
canNavigate
}) => {
const { classes } = useStyles()

Expand Down Expand Up @@ -185,6 +187,29 @@ export const DepositSelector: React.FC<IDepositSelector> = ({
setIsLoaded(true)
}, [tokens, initialTokenFrom, initialTokenTo, initialFee])

const [wasRunTokenA, setWasRunTokenA] = useState(false)
const [wasRunTokenB, setWasRunTokenB] = useState(false)

useEffect(() => {
if (canNavigate) {
const tokenAIndex = tokens.findIndex(
token => token.assetAddress.toString() === tickerToAddress(network, initialTokenFrom)
)
if (!wasRunTokenA && tokenAIndex !== -1) {
setTokenAIndex(tokenAIndex)
setWasRunTokenA(true)
}

const tokenBIndex = tokens.findIndex(
token => token.assetAddress.toString() === tickerToAddress(network, initialTokenTo)
)
if (!wasRunTokenB && tokenBIndex !== -1) {
setTokenBIndex(tokenBIndex)
setWasRunTokenB(true)
}
}
}, [wasRunTokenA, wasRunTokenB, canNavigate, tokens.length])

const getButtonMessage = useCallback(() => {
if (tokenAIndex === null || tokenBIndex === null) {
return 'Select tokens'
Expand Down
4 changes: 3 additions & 1 deletion src/components/NewPosition/NewPosition.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export const Primary: Story = {
walletStatus: Status.Initialized,
onConnectWallet: () => {},
onDisconnectWallet: () => {},
poolAddress: ''
poolAddress: '',
canNavigate: true
},
render: () => {
return (
Expand Down Expand Up @@ -171,6 +172,7 @@ export const Primary: Story = {
onConnectWallet={() => {}}
onDisconnectWallet={() => {}}
poolAddress=''
canNavigate={true}
/>
)
}
Expand Down
34 changes: 19 additions & 15 deletions src/components/NewPosition/NewPosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export interface INewPosition {
walletStatus: Status
onConnectWallet: () => void
onDisconnectWallet: () => void
canNavigate: boolean
}

export const NewPosition: React.FC<INewPosition> = ({
Expand Down Expand Up @@ -174,7 +175,8 @@ export const NewPosition: React.FC<INewPosition> = ({
ethBalance,
walletStatus,
onConnectWallet,
onDisconnectWallet
onDisconnectWallet,
canNavigate
}) => {
const { classes } = useStyles()
const navigate = useNavigate()
Expand Down Expand Up @@ -431,20 +433,21 @@ export const NewPosition: React.FC<INewPosition> = ({
}

const updatePath = (index1: number | null, index2: number | null, fee: number) => {
const parsedFee = parseFeeToPathFee(+ALL_FEE_TIERS_DATA[fee].tier.fee)

if (index1 != null && index2 != null) {
const token1Symbol = addressToTicker(network, tokens[index1].assetAddress.toString())
const token2Symbol = addressToTicker(network, tokens[index2].assetAddress.toString())
navigate(`/newPosition/${token1Symbol}/${token2Symbol}/${parsedFee}`, { replace: true })
} else if (index1 != null) {
const tokenSymbol = addressToTicker(network, tokens[index1].assetAddress.toString())
navigate(`/newPosition/${tokenSymbol}/${parsedFee}`, { replace: true })
} else if (index2 != null) {
const tokenSymbol = addressToTicker(network, tokens[index2].assetAddress.toString())
navigate(`/newPosition/${tokenSymbol}/${parsedFee}`, { replace: true })
} else if (fee != null) {
navigate(`/newPosition/${parsedFee}`, { replace: true })
if (canNavigate) {
const parsedFee = parseFeeToPathFee(+ALL_FEE_TIERS_DATA[fee].tier.fee)
if (index1 != null && index2 != null) {
const token1Symbol = addressToTicker(network, tokens[index1].assetAddress.toString())
const token2Symbol = addressToTicker(network, tokens[index2].assetAddress.toString())
navigate(`/newPosition/${token1Symbol}/${token2Symbol}/${parsedFee}`, { replace: true })
} else if (index1 != null) {
const tokenSymbol = addressToTicker(network, tokens[index1].assetAddress.toString())
navigate(`/newPosition/${tokenSymbol}/${parsedFee}`, { replace: true })
} else if (index2 != null) {
const tokenSymbol = addressToTicker(network, tokens[index2].assetAddress.toString())
navigate(`/newPosition/${tokenSymbol}/${parsedFee}`, { replace: true })
} else if (fee != null) {
navigate(`/newPosition/${parsedFee}`, { replace: true })
}
}
}

Expand Down Expand Up @@ -703,6 +706,7 @@ export const NewPosition: React.FC<INewPosition> = ({
walletStatus={walletStatus}
onConnectWallet={onConnectWallet}
onDisconnectWallet={onDisconnectWallet}
canNavigate={canNavigate}
/>
<Hidden mdUp>
<Grid container justifyContent='end' mb={2}>
Expand Down
13 changes: 10 additions & 3 deletions src/components/Stats/PoolList/PoolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface PoolListInterface {
volume: number
TVL: number
fee: number
addressFrom: string
addressTo: string
apy: number
apyData: {
fees: number
Expand Down Expand Up @@ -79,7 +81,12 @@ const PoolList: React.FC<PoolListInterface> = ({ data, network }) => {

return (
<Grid container direction='column' classes={{ root: classes.container }}>
<PoolListItem displayType='header' onSort={setSortType} sortType={sortType} />
<PoolListItem
displayType='header'
onSort={setSortType}
sortType={sortType}
network={network}
/>
{paginator(page).map((element, index) => (
<PoolListItem
displayType='token'
Expand All @@ -95,8 +102,8 @@ const PoolList: React.FC<PoolListInterface> = ({ data, network }) => {
hideBottomLine={pages === 1 && index + 1 === data.length}
apyData={element.apyData}
key={index}
// addressFrom={element.addressFrom}
// addressTo={element.addressTo}
addressFrom={element.addressFrom}
addressTo={element.addressTo}
network={network}
isUnknownFrom={element.isUnknownFrom}
isUnknownTo={element.isUnknownTo}
Expand Down
21 changes: 13 additions & 8 deletions src/components/Stats/PoolListItem/PoolListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { useNavigate } from 'react-router-dom'
import icons from '@static/icons'
import { NetworkType, SortTypePoolList } from '@store/consts/static'
import { TooltipHover } from '@components/TooltipHover/TooltipHover'
import { parseFeeToPathFee } from '@utils/utils'
import { addressToTicker, parseFeeToPathFee } from '@utils/utils'
import { DECIMAL } from '@invariant-labs/sdk-eclipse/lib/utils'
import { formatNumber } from '@utils/utils'
import { shortenAddress } from '@utils/uiUtils'

interface IProps {
TVL?: number
Expand All @@ -27,7 +28,7 @@ interface IProps {
hideBottomLine?: boolean
addressFrom?: string
addressTo?: string
network?: NetworkType
network: NetworkType
apy?: number
apyData?: {
fees: number
Expand All @@ -51,9 +52,9 @@ const PoolListItem: React.FC<IProps> = ({
sortType,
onSort,
hideBottomLine = false,
// addressFrom,
// addressTo,
// network
addressFrom,
addressTo,
network,
// apy = 0,
// apyData = {
// fees: 0,
Expand All @@ -70,12 +71,16 @@ const PoolListItem: React.FC<IProps> = ({

const handleOpenPosition = () => {
navigate(
`/newPosition/${symbolFrom ?? ''}/${symbolTo ?? ''}/${parseFeeToPathFee(Math.round(fee * 10 ** (DECIMAL - 2)))}`
`/newPosition/${addressToTicker(network, addressFrom ?? '')}/${addressToTicker(network, addressTo ?? '')}/${parseFeeToPathFee(Math.round(fee * 10 ** (DECIMAL - 2)))}`,
{ state: { referer: 'stats' } }
)
}

const handleOpenSwap = () => {
navigate(`/exchange/${symbolFrom ?? ''}/${symbolTo ?? ''}`)
navigate(
`/exchange/${addressToTicker(network, addressFrom ?? '')}/${addressToTicker(network, addressTo ?? '')}`,
{ state: { referer: 'stats' } }
)
}

return (
Expand All @@ -101,7 +106,7 @@ const PoolListItem: React.FC<IProps> = ({
)}
<Grid className={classes.symbolsContainer}>
<Typography>
{symbolFrom}/{symbolTo}
{shortenAddress(symbolFrom ?? '')}/{shortenAddress(symbolTo ?? '')}
</Typography>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PoolListItem from './PoolListItem'
import { store } from '@store/index'
import { Provider } from 'react-redux'
import { fn } from '@storybook/test'
import { SortTypePoolList } from '@store/consts/static'
import { NetworkType, SortTypePoolList } from '@store/consts/static'

const meta = {
title: 'Stats/PoolListItem',
Expand All @@ -29,7 +29,8 @@ export const Header: Story = {
args: {
displayType: 'header',
onSort: fn(),
sortType: SortTypePoolList.TVL_DESC
sortType: SortTypePoolList.TVL_DESC,
network: NetworkType.Mainnet
}
}

Expand All @@ -46,6 +47,7 @@ export const Token: Story = {
fee: 0.3,
volume: 1000000000,
TVL: 500000000,
hideBottomLine: false
hideBottomLine: false,
network: NetworkType.Mainnet
}
}
7 changes: 5 additions & 2 deletions src/components/Stats/TokenListItem/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Box, Grid, Typography, useMediaQuery } from '@mui/material'
import { formatNumber } from '@utils/utils'
import { SortTypeTokenList } from '@store/consts/static'
import icons from '@static/icons'
import { shortenAddress } from '@utils/uiUtils'

interface IProps {
displayType: string
Expand Down Expand Up @@ -61,8 +62,10 @@ const TokenListItem: React.FC<IProps> = ({
</Box>
)}
<Typography>
{hideName ? symbol : name}
{!hideName && <span className={classes.tokenSymbol}>{` (${symbol})`}</span>}
{hideName ? shortenAddress(symbol) : name}
{!hideName && (
<span className={classes.tokenSymbol}>{` (${shortenAddress(symbol)})`}</span>
)}
</Typography>
</Grid>
<Typography>{`~$${formatNumber(price)}`}</Typography>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Swap/Swap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export const Primary: Story = {
unwrapWETH: fn(),
wrappedETHAccountExist: true,
deleteTimeoutError: fn(),
isTimeoutError: false
isTimeoutError: false,
canNavigate: true
},
render: args => {
return <Swap {...args} />
Expand Down
Loading
Loading