1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-28 16:47:52 +02:00

fixed compute algorithm pool price value (#553)

This commit is contained in:
Bogdan Fazakas 2021-04-23 16:44:31 +03:00 committed by GitHub
parent 1f9f22cbc1
commit 369b075aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -58,6 +58,7 @@ const poolQuery = gql`
query AlgorithmPoolPrice($datatoken: String) {
pools(where: { datatokenAddress: $datatoken }) {
spotPrice
consumePrice
}
}
`
@ -234,7 +235,10 @@ export default function Compute({
return
setAlgorithmPrice((prevState) => ({
...prevState,
value: poolPrice.pools[0].spotPrice
value:
poolPrice.pools[0].consumePrice === '-1'
? poolPrice.pools[0].spotPrice
: poolPrice.pools[0].consumePrice
}))
}, [poolPrice])

View File

@ -24,6 +24,7 @@ const poolQuery = gql`
query AssetPoolPrice($datatokenAddress_in: [String!]) {
pools(where: { datatokenAddress_in: $datatokenAddress_in }) {
spotPrice
consumePrice
id
datatokenAddress
}
@ -106,7 +107,10 @@ export async function getAssetPrices(assets: DDO[]): Promise<PriceList> {
}
const poolPriceResponse: any = await fetchData(poolQuery, poolVariables)
for (const poolPrice of poolPriceResponse.data?.pools) {
priceList[didDTMap[poolPrice.datatokenAddress]] = poolPrice.spotPrice
priceList[didDTMap[poolPrice.datatokenAddress]] =
poolPrice.consumePrice === '-1'
? poolPrice.spotPrice
: poolPrice.consumePrice
}
const frePriceResponse: any = await fetchData(freQuery, freVariables)
for (const frePrice of frePriceResponse.data?.fixedRateExchanges) {