1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 09:44:53 +01:00

fix price value (#544)

* fix price value

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* proper price

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
mihaisc 2021-04-21 18:03:13 +03:00 committed by GitHub
parent e21780530a
commit e4803fda9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -44,6 +44,7 @@ const poolLiquidityQuery = gql`
id id
totalShares totalShares
swapFee swapFee
spotPrice
tokens { tokens {
tokenAddress tokenAddress
balance balance
@ -141,7 +142,8 @@ export default function Pool(): ReactElement {
setCreatorLiquidity(creatorLiquidity) setCreatorLiquidity(creatorLiquidity)
const totalCreatorLiquidityInOcean = const totalCreatorLiquidityInOcean =
creatorLiquidity?.ocean + creatorLiquidity?.datatoken * price?.value creatorLiquidity?.ocean +
creatorLiquidity?.datatoken * dataLiquidity.pool.spotPrice
setCreatorTotalLiquidityInOcean(totalCreatorLiquidityInOcean) setCreatorTotalLiquidityInOcean(totalCreatorLiquidityInOcean)
const creatorPoolShare = const creatorPoolShare =
price?.ocean && price?.ocean &&

View File

@ -36,6 +36,7 @@ const poolQuery = gql`
query PoolPrice($datatoken: String) { query PoolPrice($datatoken: String) {
pools(where: { datatokenAddress: $datatoken }) { pools(where: { datatokenAddress: $datatoken }) {
spotPrice spotPrice
consumePrice
datatokenReserve datatokenReserve
oceanReserve oceanReserve
} }
@ -123,9 +124,13 @@ function AssetProvider({
return return
setPrice((prevState) => ({ setPrice((prevState) => ({
...prevState, ...prevState,
value: poolPrice.pools[0].spotPrice, value:
poolPrice.pools[0].consumePrice === '-1'
? poolPrice.pools[0].spotPrice
: poolPrice.pools[0].consumePrice,
ocean: poolPrice.pools[0].oceanReserve, ocean: poolPrice.pools[0].oceanReserve,
datatoken: poolPrice.pools[0].datatokenReserve datatoken: poolPrice.pools[0].datatokenReserve,
isConsumable: poolPrice.pools[0].consumePrice === '-1' ? 'false' : 'true'
})) }))
}, [poolPrice]) }, [poolPrice])