1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Various fixes (#1441)

* fixes

* more fixes
This commit is contained in:
mihaisc 2022-05-18 09:25:44 -07:00 committed by GitHub
parent 4b6baa9cd5
commit bf31cdfed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 10 deletions

View File

@ -38,7 +38,7 @@ function MarketMetadataProvider({
chainId: appConfig.chainIdsSupported[i], chainId: appConfig.chainIdsSupported[i],
approvedTokens: response.data?.opc.approvedTokens, approvedTokens: response.data?.opc.approvedTokens,
swapApprovedFee: response.data?.opc.swapOceanFee, swapApprovedFee: response.data?.opc.swapOceanFee,
swapNotApprovedFee: response.data.opc.swapNonOceanFee swapNotApprovedFee: response.data?.opc.swapNonOceanFee
} as OpcFee) } as OpcFee)
} }
setOpcFees(opcData) setOpcFees(opcData)

View File

@ -67,10 +67,10 @@ function PoolProvider({ children }: { children: ReactNode }): ReactElement {
poolInfoShares poolInfoShares
) )
// Pool share in %. // Pool share in %. We double it to compensate for ss bot
const poolSharePercentage = new Decimal(poolInfoShares) const poolSharePercentage = new Decimal(poolInfoShares)
.dividedBy(new Decimal(response.poolData.totalShares)) .dividedBy(new Decimal(response.poolData.totalShares))
.mul(100) .mul(200)
.toFixed(2) .toFixed(2)
setUserHasAddedLiquidity(Number(poolSharePercentage) > 0) setUserHasAddedLiquidity(Number(poolSharePercentage) > 0)
@ -143,10 +143,10 @@ function PoolProvider({ children }: { children: ReactNode }): ReactElement {
) )
return return
// Pool share tokens. // Pool share tokens. We double it to compensate for ss bot
const poolSharePercentage = new Decimal(poolData.shares[0]?.shares) const poolSharePercentage = new Decimal(poolData.shares[0]?.shares)
.dividedBy(poolInfo.totalPoolTokens) .dividedBy(poolInfo.totalPoolTokens)
.mul(100) .mul(200)
.toFixed(2) .toFixed(2)
const ownerLiquidity = calcSingleOutGivenPoolIn( const ownerLiquidity = calcSingleOutGivenPoolIn(

View File

@ -87,6 +87,10 @@ export default function Remove({
const getValues = useRef( const getValues = useRef(
debounce(async (poolInstance, id, poolInfo, newAmountPoolShares) => { debounce(async (poolInstance, id, poolInfo, newAmountPoolShares) => {
if (newAmountPoolShares === '0') {
setAmountOcean('0')
return
}
const newAmountOcean = await poolInstance.calcSingleOutGivenPoolIn( const newAmountOcean = await poolInstance.calcSingleOutGivenPoolIn(
id, id,
poolInfo.baseTokenAddress, poolInfo.baseTokenAddress,

View File

@ -3,7 +3,7 @@ import { usePool } from '@context/Pool'
import Tooltip from '@shared/atoms/Tooltip' import Tooltip from '@shared/atoms/Tooltip'
import ExplorerLink from '@shared/ExplorerLink' import ExplorerLink from '@shared/ExplorerLink'
import PriceUnit from '@shared/Price/PriceUnit' import PriceUnit from '@shared/Price/PriceUnit'
import React from 'react' import React, { useEffect, useState } from 'react'
import Graph from '../Graph' import Graph from '../Graph'
import PoolSection from '../Section' import PoolSection from '../Section'
import Token from '../../../../@shared/Token' import Token from '../../../../@shared/Token'
@ -11,11 +11,27 @@ import content from '../../../../../../content/price.json'
import styles from './index.module.css' import styles from './index.module.css'
import Update from './Update' import Update from './Update'
import { useMarketMetadata } from '@context/MarketMetadata' import { useMarketMetadata } from '@context/MarketMetadata'
import { OpcFeesQuery_opc as OpcFeesData } from '../../../../../@types/subgraph/OpcFeesQuery'
import { getOpcFees } from '@utils/subgraph'
import { useWeb3 } from '@context/Web3'
import Decimal from 'decimal.js'
export default function PoolSections() { export default function PoolSections() {
const { asset } = useAsset() const { asset } = useAsset()
const { poolData, poolInfo, poolInfoUser, poolInfoOwner } = usePool() const { poolData, poolInfo, poolInfoUser, poolInfoOwner } = usePool()
const { getOpcFeeForToken } = useMarketMetadata() const { getOpcFeeForToken } = useMarketMetadata()
const { chainId } = useWeb3()
const [oceanCommunitySwapFee, setOceanCommunitySwapFee] = useState<string>('')
useEffect(() => {
getOpcFees(chainId || 1).then((response: OpcFeesData) => {
setOceanCommunitySwapFee(
response?.swapOceanFee
? new Decimal(response.swapOceanFee).mul(100).toString()
: '0'
)
})
}, [chainId])
return ( return (
<> <>
<PoolSection className={styles.dataToken}> <PoolSection className={styles.dataToken}>
@ -119,10 +135,7 @@ export default function PoolSections() {
/> />
<Token <Token
symbol="% OPC fee" symbol="% OPC fee"
balance={getOpcFeeForToken( balance={oceanCommunitySwapFee}
poolInfo?.baseTokenAddress,
asset?.chainId
)}
noIcon noIcon
size="mini" size="mini"
/> />