mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
17 lines
431 B
TypeScript
17 lines
431 B
TypeScript
import { Decimal } from 'decimal.js'
|
|
|
|
// Run decimal.js comparison
|
|
// http://mikemcl.github.io/decimal.js/#cmp
|
|
export default function compareAsBN(balance: string, price: string): boolean {
|
|
const aBN = new Decimal(balance)
|
|
const bBN = new Decimal(price)
|
|
const compare = aBN.comparedTo(bBN)
|
|
|
|
switch (compare) {
|
|
case 1 || 0: // balance is greater or equal to price
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|