1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-01-24 09:13:29 +01:00

Merge pull request #72 from oceanprotocol/feature/getPrice

Feature/get price
This commit is contained in:
mihaisc 2020-08-06 12:52:27 +03:00 committed by GitHub
commit 4bff015c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,12 @@ export async function getCheapestPool(
dataTokenAddress
)
Logger.log('DT Pool found', tokenPools)
if (tokenPools === undefined || tokenPools.length === 0) {
return {
poolAddress: '',
poolPrice: ''
}
}
let cheapestPoolAddress
let cheapestPoolPrice = new Decimal(999999999999)
@ -21,7 +27,7 @@ export async function getCheapestPool(
'1'
)
const decimalPoolPrice = new Decimal(poolPrice)
Logger.log('Pool price ', tokenPools[i], poolPrice)
Logger.log('Pool price ', tokenPools[i], decimalPoolPrice.toString())
if (decimalPoolPrice < cheapestPoolPrice) {
cheapestPoolPrice = decimalPoolPrice
cheapestPoolAddress = tokenPools[i]