hot fix for asset composition formula

This commit is contained in:
Noah Zinsmeister 2021-05-04 14:58:29 -04:00
parent 06d6c711dd
commit 516e783be6
No known key found for this signature in database
GPG Key ID: 83022DD49188C9F2

@ -168,9 +168,13 @@ function getRatio(lower: Price, current: Price, upper: Price) {
const b = Number.parseFloat(upper.toSignificant(15)) const b = Number.parseFloat(upper.toSignificant(15))
const c = Number.parseFloat(current.toSignificant(15)) const c = Number.parseFloat(current.toSignificant(15))
const ratio = Math.floor(((Math.sqrt(a * b) - Math.sqrt(b * c)) / (c - Math.sqrt(b * c))) * 100) let ratio = Math.floor(((Math.sqrt(a * b) - Math.sqrt(b * c)) / (c - Math.sqrt(b * c))) * 100)
if (ratio > 100) {
ratio -= 100
}
if (ratio < 0 || ratio > 100) { if (ratio < 0 || ratio > 100) {
throw Error('Precision error') throw Error('Out of range')
} }
return ratio return ratio