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

Update staging #312

Merged
merged 37 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9b7ed21
remove price change from stats
zielvna Sep 16, 2024
cdd1067
change action buttons colors
zielvna Sep 16, 2024
5fef31e
Merge pull request #301 from invariant-labs/staging
kuba80-02 Sep 16, 2024
c9e3136
Merge pull request #300 from invariant-labs/remove-price-change
zielvna Sep 16, 2024
477cca9
add validation for insufficient azero balance
p6te Sep 16, 2024
8294bb2
clear console logs
p6te Sep 16, 2024
e98a1dd
fix build
p6te Sep 16, 2024
e92ce0b
change azero naming
p6te Sep 17, 2024
132824c
Merge pull request #302 from invariant-labs/validate-insufficient-azero
p6te Sep 17, 2024
a27d36c
fix: add wallet address check in position saga and reorder status ini…
kuba80-02 Sep 17, 2024
97046fd
fix: restore defaultMainnetRPC usage in Header component
kuba80-02 Sep 17, 2024
8ee4e6d
fix: update StatsPage to use WrappedStats component and remove coming…
kuba80-02 Sep 17, 2024
c80880c
Merge pull request #304 from invariant-labs/fix-loading-position-issue
kuba80-02 Sep 17, 2024
1eb7803
feat: add Vara logo and update chain constants
kuba80-02 Sep 17, 2024
ca47958
fix: update exchange URLs for AlephZero and Vara chains
kuba80-02 Sep 17, 2024
0625226
Merge pull request #305 from invariant-labs/add-vara-to-chain-list
kuba80-02 Sep 17, 2024
f0a944b
fix load custom tokens from url on new position view
p6te Sep 18, 2024
9f82f52
fix build
p6te Sep 18, 2024
fde61fc
bump sdk version
zielvna Sep 18, 2024
b6b8d36
fix build
zielvna Sep 18, 2024
4a807fb
Merge pull request #307 from invariant-labs/fix-init-pool-view-after-…
p6te Sep 18, 2024
792d003
Merge branch 'dev' into bump-sdk-version
zielvna Sep 18, 2024
13d2983
add tooltips
p6te Sep 18, 2024
ca63a71
fix wording
p6te Sep 18, 2024
dae9f06
update mock eth decimal
zielvna Sep 18, 2024
0f9861d
Merge pull request #308 from invariant-labs/bump-sdk-version
zielvna Sep 19, 2024
ebceb1a
Update src/components/PositionsList/PositionsList.tsx
p6te Sep 19, 2024
d2b301e
Update src/components/Swap/Swap.tsx
p6te Sep 19, 2024
3294a5b
Update src/components/NewPosition/DepositSelector/DepositSelector.tsx
p6te Sep 19, 2024
7a19d4c
Merge branch 'dev' into add-tooltips
p6te Sep 19, 2024
b2b65a3
Merge pull request #309 from invariant-labs/add-tooltips
p6te Sep 19, 2024
049f518
fix convert bigInt
p6te Sep 19, 2024
ea86e70
fix jumping window in new position
p6te Sep 19, 2024
0868b87
improve code semantic
p6te Sep 20, 2024
4fb63e1
Merge pull request #311 from invariant-labs/fix-bugs
p6te Sep 20, 2024
f768958
show stats
p6te Sep 20, 2024
28bf37a
fix build
p6te Sep 20, 2024
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
18,730 changes: 10,283 additions & 8,447 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@invariant-labs/a0-sdk": "^0.2.20",
"@invariant-labs/a0-sdk": "^0.2.24",
"@mui/icons-material": "^5.15.15",
"@mui/material": "^5.15.15",
"@nightlylabs/wallet-selector-polkadot": "^0.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export const Primary: Story = {
isBalanceLoading: false,
isGetLiquidityError: false,
ticksLoading: false,
network: Network.Testnet
network: Network.Testnet,
azeroBalance: 20000000000000 as any
},
render: args => <PrimaryComponent {...args} />
}
103 changes: 66 additions & 37 deletions src/components/NewPosition/DepositSelector/DepositSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import DepositAmountInput from '@components/Inputs/DepositAmountInput/DepositAmo
import Select from '@components/Inputs/Select/Select'
import { Grid, Typography } from '@mui/material'
import SwapList from '@static/svg/swap-list.svg'
import { ALL_FEE_TIERS_DATA } from '@store/consts/static'
import { ALL_FEE_TIERS_DATA, POOL_SAFE_TRANSACTION_FEE } from '@store/consts/static'
import {
convertBalanceToBigint,
getScaleFromString,
Expand Down Expand Up @@ -63,6 +63,7 @@ export interface IDepositSelector {
isGetLiquidityError: boolean
ticksLoading: boolean
network: Network
azeroBalance: bigint
}

export const DepositSelector: React.FC<IDepositSelector> = ({
Expand Down Expand Up @@ -96,7 +97,8 @@ export const DepositSelector: React.FC<IDepositSelector> = ({
isBalanceLoading,
isGetLiquidityError,
ticksLoading,
network
network,
azeroBalance
}) => {
const { classes } = useStyles()

Expand All @@ -120,27 +122,28 @@ export const DepositSelector: React.FC<IDepositSelector> = ({
const [isLoaded, setIsLoaded] = useState<boolean>(false)

useEffect(() => {
if (isLoaded || Object.keys(tokens).length === 0 || ALL_FEE_TIERS_DATA.length === 0) {
return
if (!isLoaded || Object.keys(tokens).length !== 0 || ALL_FEE_TIERS_DATA.length !== 0) {
const tokenAFromPath =
tokens[tickerToAddress(network, initialTokenFrom)]?.assetAddress || null
const tokenBFromPath = tokens[tickerToAddress(network, initialTokenTo)]?.assetAddress || null
let feeTierIndexFromPath = 0

const parsedFee = parsePathFeeToFeeString(initialFee)

ALL_FEE_TIERS_DATA.forEach((feeTierData, index) => {
if (feeTierData.tier.fee.toString() === parsedFee) {
feeTierIndexFromPath = index
}
})

setTokenA(tokenAFromPath)
setTokenB(tokenBFromPath)
setPositionTokens(tokenAFromPath, tokenBFromPath, feeTierIndexFromPath)

setIsLoaded(true)
} else {
setIsLoaded(false)
}

const tokenAFromPath = tokens[tickerToAddress(network, initialTokenFrom)]?.assetAddress || null
const tokenBFromPath = tokens[tickerToAddress(network, initialTokenTo)]?.assetAddress || null
let feeTierIndexFromPath = 0

const parsedFee = parsePathFeeToFeeString(initialFee)

ALL_FEE_TIERS_DATA.forEach((feeTierData, index) => {
if (feeTierData.tier.fee.toString() === parsedFee) {
feeTierIndexFromPath = index
}
})

setTokenA(tokenAFromPath)
setTokenB(tokenBFromPath)
setPositionTokens(tokenAFromPath, tokenBFromPath, feeTierIndexFromPath)

setIsLoaded(true)
}, [Object.keys(tokens).length])

const getButtonMessage = useCallback(() => {
Expand Down Expand Up @@ -178,6 +181,10 @@ export const DepositSelector: React.FC<IDepositSelector> = ({
return `Not enough ${tokens[tokenB].symbol}`
}

if (azeroBalance < POOL_SAFE_TRANSACTION_FEE) {
return `Insufficient AZERO`
}

if (
(!tokenAInputState.blocked && +tokenAInputState.value === 0) ||
(!tokenBInputState.blocked && +tokenBInputState.value === 0)
Expand Down Expand Up @@ -380,21 +387,43 @@ export const DepositSelector: React.FC<IDepositSelector> = ({
isBalanceLoading={isBalanceLoading}
/>
</Grid>

<AnimatedButton
className={classNames(
classes.addButton,
progress === 'none' ? classes.hoverButton : undefined
)}
onClick={() => {
if (progress === 'none') {
onAddLiquidity()
}
}}
disabled={getButtonMessage() !== 'Add Position'}
content={getButtonMessage()}
progress={progress}
/>
{getButtonMessage() === 'Insufficient AZERO' ? (
<TooltipHover
text='More AZERO is required to cover the transaction fee. Obtain more AZERO to complete this transaction.'
top={-10}>
<div>
<AnimatedButton
className={classNames(
classes.addButton,
progress === 'none' ? classes.hoverButton : undefined
)}
onClick={() => {
if (progress === 'none') {
onAddLiquidity()
}
}}
disabled={getButtonMessage() !== 'Add Position'}
content={getButtonMessage()}
progress={progress}
/>
</div>
</TooltipHover>
) : (
<AnimatedButton
className={classNames(
classes.addButton,
progress === 'none' ? classes.hoverButton : undefined
)}
onClick={() => {
if (progress === 'none') {
onAddLiquidity()
}
}}
disabled={getButtonMessage() !== 'Add Position'}
content={getButtonMessage()}
progress={progress}
/>
)}
</Grid>
)
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/NewPosition/DepositSelector/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export const useStyles = makeStyles()(theme => {
wrapper: {
borderRadius: 10,
backgroundColor: colors.invariant.component,
padding: 24,
paddingTop: 16,
padding: '16px 24px 16px 24px',
flex: '1 1 0%',

[theme.breakpoints.down('sm')]: {
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 @@ -76,7 +76,8 @@ export const Primary: Story = {
onlyUserPositions: false,
setOnlyUserPositions: fn(),
network: Network.Testnet,
isLoadingTokens: false
isLoadingTokens: false,
azeroBalance: 20000000000000 as any
},
render: () => {
return (
Expand Down Expand Up @@ -137,6 +138,7 @@ export const Primary: Story = {
setOnlyUserPositions={fn()}
network={Network.Testnet}
isLoadingTokens={false}
azeroBalance={20000000000000n}
/>
)
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/NewPosition/NewPosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface INewPosition {
setOnlyUserPositions: (val: boolean) => void
network: Network
isLoadingTokens: boolean
azeroBalance: bigint
}

export const NewPosition: React.FC<INewPosition> = ({
Expand Down Expand Up @@ -158,7 +159,8 @@ export const NewPosition: React.FC<INewPosition> = ({
onlyUserPositions,
setOnlyUserPositions,
network,
isLoadingTokens
isLoadingTokens,
azeroBalance
}) => {
const { classes } = useStyles()
const navigate = useNavigate()
Expand Down Expand Up @@ -682,6 +684,7 @@ export const NewPosition: React.FC<INewPosition> = ({
isGetLiquidityError={isGetLiquidityError}
ticksLoading={ticksLoading}
network={network}
azeroBalance={azeroBalance}
/>
<Hidden mdUp>
<Grid container justifyContent='end' mb={2}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/PositionsList/PositionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export const PositionsList: React.FC<IProps> = ({
<Grid className={classes.searchRoot}>
<Grid className={classes.titleBar}>
<Typography className={classes.title}>Your Positions</Typography>
<Typography className={classes.positionsNumber}>{String(length)}</Typography>
<TooltipHover text='Total number of your positions'>
<Typography className={classes.positionsNumber}>{String(length)}</Typography>
</TooltipHover>
</Grid>
<Grid className={classes.searchWrapper}>
<InputBase
Expand Down
33 changes: 18 additions & 15 deletions src/components/Refresher/Refresher.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRef, useEffect, useState } from 'react'
import { useStyles } from './style'
import { Box } from '@mui/material'

type Props = {
currentIndex: number
Expand Down Expand Up @@ -30,21 +31,23 @@ export const Refresher = ({ currentIndex, maxIndex, onClick }: Props) => {
}, [circleRef, currentIndex, maxIndex])

return (
<svg className={classes.ring} width='20' height='20' onClick={onClick}>
<circle stroke='#3A466B' strokeWidth='2' fill='transparent' r='8' cx='10' cy='10' />
<circle
className={classes.innerCircle}
strokeDasharray='0'
strokeDashoffset='0'
stroke='#EF84F5'
strokeWidth='2'
fill='transparent'
r='8'
cx='10'
cy='10'
ref={circleRef}
/>
</svg>
<Box width={20} height={20}>
<svg className={classes.ring} width='20' height='20' onClick={onClick}>
<circle stroke='#3A466B' strokeWidth='2' fill='transparent' r='8' cx='10' cy='10' />
<circle
className={classes.innerCircle}
strokeDasharray='0'
strokeDashoffset='0'
stroke='#EF84F5'
strokeWidth='2'
fill='transparent'
r='8'
cx='10'
cy='10'
ref={circleRef}
/>
</svg>
</Box>
)
}

Expand Down
14 changes: 7 additions & 7 deletions src/components/Stats/TokenListItem/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IProps {
name?: string
symbol?: string
price?: number
priceChange?: number
// priceChange?: number
volume?: number
TVL?: number
sortType?: SortTypeTokenList
Expand All @@ -29,15 +29,15 @@ const TokenListItem: React.FC<IProps> = ({
name = 'Bitcoin',
symbol = 'BTCIcon',
price = 0,
priceChange = 0,
// priceChange = 0,
volume = 0,
TVL = 0,
sortType,
onSort,
hideBottomLine = false
}) => {
const { classes } = useStyles()
const isNegative = priceChange < 0
// const isNegative = priceChange < 0

const isXDown = useMediaQuery(theme.breakpoints.down('sm'))
const hideName = useMediaQuery(theme.breakpoints.down('xs'))
Expand All @@ -58,11 +58,11 @@ const TokenListItem: React.FC<IProps> = ({
</Typography>
</Grid>
<Typography>{`~$${formatNumbers()(price.toString())}${showPrefix(price)}`}</Typography>
{!hideName && (
{/* {!hideName && (
<Typography style={{ color: isNegative ? colors.invariant.Error : colors.green.main }}>
{isNegative ? `${priceChange.toFixed(2)}%` : `+${priceChange.toFixed(2)}%`}
</Typography>
)}
)} */}
<Typography>{`$${formatNumbers()(volume.toString())}${showPrefix(volume)}`}</Typography>
<Typography>{`$${formatNumbers()(TVL.toString())}${showPrefix(TVL)}`}</Typography>
</Grid>
Expand Down Expand Up @@ -108,7 +108,7 @@ const TokenListItem: React.FC<IProps> = ({
<ArrowDropDownIcon className={classes.icon} />
) : null}
</Typography>
{!hideName && (
{/* {!hideName && (
<Typography
style={{ cursor: 'pointer' }}
onClick={() => {
Expand All @@ -125,7 +125,7 @@ const TokenListItem: React.FC<IProps> = ({
<ArrowDropDownIcon className={classes.icon} />
) : null}
</Typography>
)}
)} */}
<Typography
style={{ cursor: 'pointer' }}
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Stats/TokenListItem/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { makeStyles } from 'tss-react/mui'
export const useStyles = makeStyles()((theme: Theme) => ({
container: {
display: 'grid',
gridTemplateColumns: '5% 35% 15% 15% 15% 15%',
gridTemplateColumns: '5% 35% 20% 20% 20%',
padding: '18px 0 ',
backgroundColor: colors.invariant.component,
borderBottom: `1px solid ${colors.invariant.light}`,
Expand Down
11 changes: 5 additions & 6 deletions src/components/Stats/TokensList/TokensList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface ITokensListData {
name: string
symbol: string
price: number
priceChange: number
volume: number
TVL: number
}
Expand Down Expand Up @@ -45,10 +44,10 @@ const TokensList: React.FC<ITokensList> = ({ data }) => {
return data.sort((a, b) => a.price - b.price)
case SortTypeTokenList.PRICE_DESC:
return data.sort((a, b) => b.price - a.price)
case SortTypeTokenList.CHANGE_ASC:
return data.sort((a, b) => a.priceChange - b.priceChange)
case SortTypeTokenList.CHANGE_DESC:
return data.sort((a, b) => b.priceChange - a.priceChange)
// case SortTypeTokenList.CHANGE_ASC:
// return data.sort((a, b) => a.priceChange - b.priceChange)
// case SortTypeTokenList.CHANGE_DESC:
// return data.sort((a, b) => b.priceChange - a.priceChange)
case SortTypeTokenList.VOLUME_ASC:
return data.sort((a, b) => (a.volume === b.volume ? a.TVL - b.TVL : a.volume - b.volume))
case SortTypeTokenList.VOLUME_DESC:
Expand Down Expand Up @@ -96,7 +95,7 @@ const TokensList: React.FC<ITokensList> = ({ data }) => {
name={token.name}
symbol={token.symbol}
price={token.price}
priceChange={token.priceChange}
// priceChange={token.priceChange}
volume={token.volume}
TVL={token.TVL}
hideBottomLine={pages === 1 && index + 1 === data.length}
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 @@ -67,7 +67,8 @@ export const Primary: Story = {
},
simulateSwap: fn(),
copyTokenAddressHandler: fn(),
network: Network.Testnet
network: Network.Testnet,
azeroBalance: 20000000000000 as any
},
render: args => {
return (
Expand Down
Loading
Loading