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

whale pools added to terra #173

Merged
merged 6 commits into from
Feb 27, 2023
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
16 changes: 10 additions & 6 deletions components/Pages/Pools/AllPoolsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { walletState } from 'state/atoms/walletAtoms'
import Loader from '../../Loader'
import Apr from './components/Apr'
import PoolName from './components/PoolName'
import TotalLiq from './components/TotalLiq'
import Volume from './components/Volume'
import useIgnoreCoinhall from './hooks/useIgnoreCoinhall'
import { Pool } from './types'
Expand Down Expand Up @@ -98,9 +99,12 @@ const columns = [
{`Total Liquidity`}
</Text>
),
cell: (info) => (
<Text align="right">{`$${formatPrice(info.getValue())}`}</Text>
),
cell: (info) => <TotalLiq
poolId={info.row.original?.poolId}
liquidity={info.row.original?.liquidity}
totalLiq={info.getValue()}
poolAssets={info.row.original?.poolAssets}
/>
}),
columnHelper.accessor('cta', {
header: '',
Expand Down Expand Up @@ -180,9 +184,9 @@ const PoolsTable = ({
{header.isPlaceholder
? null
: flexRender(
header.column.columnDef.header,
header.getContext()
)}
header.column.columnDef.header,
header.getContext()
)}
</Th>
))}
</Tr>
Expand Down
17 changes: 13 additions & 4 deletions components/Pages/Pools/MyPoolsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import { formatPrice } from 'libs/num'

import Loader from '../../Loader'
import Apr from './components/Apr'
import MyPosition from './components/MyPosition'
import PoolName from './components/PoolName'
import TotalLiq from './components/TotalLiq'
import Volume from './components/Volume'
import useIgnoreCoinhall from './hooks/useIgnoreCoinhall'
import { Pool } from './types'
Expand Down Expand Up @@ -56,7 +58,11 @@ const columns = [
{`My Position`}
</Text>
),
cell: (info) => <Text align="right">${info.getValue()}</Text>,
cell: (info) => <MyPosition
myPositiionAmount={info.getValue()}
lpToken={info.row.original?.liquidity?.providedTotal?.tokenAmount}
/>
// cell: (info) => <Text align="right">${info.getValue()}</Text>,
}),
columnHelper.accessor('apr', {
header: () => (
Expand Down Expand Up @@ -103,9 +109,12 @@ const columns = [
{`Total Liquidity`}
</Text>
),
cell: (info) => (
<Text align="right">{`$${formatPrice(info.getValue())}`}</Text>
),
cell: (info) => <TotalLiq
poolId={info.row.original?.poolId}
liquidity={info.row.original?.liquidity}
totalLiq={info.getValue()}
poolAssets={info.row.original?.poolAssets}
/>
}),
columnHelper.accessor('cta', {
header: '',
Expand Down
7 changes: 5 additions & 2 deletions components/Pages/Pools/Pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Props = {}
const commingSoonNetworks = ['chihuahua', 'injective', 'comdex']
const subqueryNetorks = ['injective']
const COMING_SOON = 'coming soon'
const NoPrice = ["ASH-BDOG", 'ASH-GDOG', 'WHALE-axlUSDC', 'ampWHALE-WHALE', 'boneWHALE-WHALE']

const Pools: FC<Props> = () => {
const [allPools, setAllPools] = useState<any[]>([])
Expand Down Expand Up @@ -89,8 +90,9 @@ const Pools: FC<Props> = () => {
volume24hr: showCommingSoon
? COMING_SOON
: `$${formatPrice(pool.usdVolume24h)}`,
totalLiq: pool.liquidity?.available?.total?.dollarValue,
totalLiq: NoPrice.includes(pool?.pool_id)? 'NA' : pool.liquidity?.available?.total?.dollarValue,
liquidity: pool.liquidity,
poolAssets: pool.pool_assets,
price: `${isUSDPool ? '$' : ''}${Number(price).toFixed(3)}`,
isUSDPool: isUSDPool,
isSubqueryNetwork: subqueryNetorks.includes(chainId?.split('-')?.[0]),
Expand Down Expand Up @@ -121,7 +123,8 @@ const Pools: FC<Props> = () => {
.filter(({ liquidity }) => liquidity?.providedTotal?.tokenAmount > 0)
.map((item) => ({
...item,
myPosition: formatPrice(item?.liquidity?.providedTotal?.dollarValue),
// myPosition: formatPrice(item?.liquidity?.providedTotal?.dollarValue),
myPosition: NoPrice.includes(item?.poolId)? 'NA' : formatPrice(item?.liquidity?.providedTotal?.dollarValue),
cta: () =>
router.push(
`/${chainIdParam}/pools/manage_liquidity?poolId=${item.poolId}`
Expand Down
32 changes: 32 additions & 0 deletions components/Pages/Pools/components/MyPosition.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { InfoOutlineIcon } from '@chakra-ui/icons'
import { Box, HStack, Tooltip, VStack, Text } from '@chakra-ui/react'
import React from 'react'
import { formatPrice, fromChainAmount } from 'libs/num'

type Props = {
myPositiionAmount: string | number
lpToken: string | number
}



const MyPosition = ({
myPositiionAmount,
lpToken
}: Props) => {

return (
<HStack justifyContent="end">
<Text align="right">{myPositiionAmount !== 'NA' ? `$${formatPrice(myPositiionAmount)}` : myPositiionAmount}</Text>
<Tooltip label={<VStack>
<Text>lpTokens: {fromChainAmount(lpToken, 1)}</Text>
</VStack>} padding="20px" borderRadius="20px" bg="blackAlpha.900" fontSize="xs" maxW="330px">
<Box cursor="pointer" color="brand.50">
<InfoOutlineIcon width=".9rem" height=".9rem" />
</Box>
</Tooltip>
</HStack>
)
}

export default MyPosition
41 changes: 41 additions & 0 deletions components/Pages/Pools/components/TotalLiq.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { InfoOutlineIcon } from '@chakra-ui/icons'
import { Box, HStack, Tooltip, VStack, Text } from '@chakra-ui/react'
import React from 'react'
import { formatPrice, fromChainAmount } from 'libs/num'

type Props = {
poolId: string
liquidity: string
totalLiq: string | number
poolAssets: any[]
}



const TotalLiq = ({
poolId,
liquidity,
totalLiq,
poolAssets
}: Props) => {
const [tokenAReserve, tokenBReserve] = liquidity?.reserves?.total || []
const [tokenA, tokenB] = poolId?.split('-') || []
const [assetA, assetB] = poolAssets || []

return (
<HStack justifyContent="end">
{/* <Text align="right">{`$${formatPrice(totalLiq)}`}</Text> */}
<Text align="right">{ totalLiq !== 'NA' ? `$${formatPrice(totalLiq)}` : totalLiq}</Text>
<Tooltip label={<VStack>
<Text>{tokenA}: {fromChainAmount(tokenAReserve, assetA?.decimals)}</Text>
<Text>{tokenB}: {fromChainAmount(tokenBReserve, assetB?.decimals)}</Text>
</VStack>} padding="20px" borderRadius="20px" bg="blackAlpha.900" fontSize="xs" maxW="330px">
<Box cursor="pointer" color="brand.50">
<InfoOutlineIcon width=".9rem" height=".9rem" />
</Box>
</Tooltip>
</HStack>
)
}

export default TotalLiq
5 changes: 4 additions & 1 deletion components/Pages/Swap/hooks/useSimulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ const useSimulate = ({ client, msg, routerAddress }) => {
const simulatedError = useMemo(() => {
if (!error) return null

if (
if (/Operation disabled, swap/i.test(error?.toString()))
return 'Pair is disabled for swap'
else if (
/unreachable: query wasm contract failed: invalid request/i.test(
error?.toString()
) ||
/codespace: wasm, code: 9: query wasm/i.test(error?.toString())
)
return 'Insufficient liquidity'
else return null
}, [error])

return {
Expand Down
9 changes: 9 additions & 0 deletions public/ampWhale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/logos/ampWhale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/boneWHALE.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/migaloo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/logos/whale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading