mirror of
https://github.com/oceanprotocol/react.git
synced 2024-12-23 17:54:03 +01:00
decimal fix
This commit is contained in:
parent
53ca5ad6cb
commit
6d33304c9a
@ -1,5 +1,5 @@
|
||||
import { Logger, Ocean, Account } from '@oceanprotocol/lib'
|
||||
const Decimal = await require('decimal.js')
|
||||
import { Decimal } from 'decimal.js'
|
||||
export async function getCheapestPool(
|
||||
ocean: Ocean,
|
||||
accountId: string,
|
||||
@ -11,7 +11,7 @@ export async function getCheapestPool(
|
||||
)
|
||||
Logger.log('DT Pool found', tokenPools)
|
||||
let cheapestPoolAddress
|
||||
let cheapestPoolPrice = 999999
|
||||
let cheapestPoolPrice = new Decimal(999999999999)
|
||||
|
||||
if (tokenPools) {
|
||||
for (let i = 0; i < tokenPools.length; i++) {
|
||||
@ -20,9 +20,10 @@ export async function getCheapestPool(
|
||||
tokenPools[i],
|
||||
'1'
|
||||
)
|
||||
const decimalPoolPrice = new Decimal(poolPrice)
|
||||
Logger.log('Pool price ', tokenPools[i], poolPrice)
|
||||
if (Decimal(poolPrice) < cheapestPoolPrice) {
|
||||
cheapestPoolPrice = Decimal(poolPrice)
|
||||
if (decimalPoolPrice < cheapestPoolPrice) {
|
||||
cheapestPoolPrice = decimalPoolPrice
|
||||
cheapestPoolAddress = tokenPools[i]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user