diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca0e9f..1ff5897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v5.0.13 + +### Fix: + + - Bring BN division fix from @glitchful-dev/sol-apy-sdk + ## v5.0.12 ### Chore: diff --git a/package.json b/package.json index 5ccc0e1..1e7fd42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@marinade.finance/marinade-ts-sdk", - "version": "5.0.12", + "version": "5.0.13", "description": "Marinade SDK for Typescript", "main": "dist/src/index.js", "repository": { diff --git a/src/util/conversion.ts b/src/util/conversion.ts index 12a1265..b64328b 100644 --- a/src/util/conversion.ts +++ b/src/util/conversion.ts @@ -25,10 +25,15 @@ export function divideBnToNumber(numerator: BN, denominator: BN): number { if (denominator.isZero()) { return 0 } - const quotient = numerator.div(denominator).toNumber() + const quotient = numerator.div(denominator) const rem = numerator.umod(denominator) const gcd = rem.gcd(denominator) - return quotient + rem.div(gcd).toNumber() / denominator.div(gcd).toNumber() + + const quotientNumber = parseFloat(quotient.toString()) + const remNumber = parseFloat(rem.div(gcd).toString()) + const denominatorNumber = parseFloat(denominator.div(gcd).toString()) + + return quotientNumber + remNumber / denominatorNumber } export function calcLamportsWithdrawAmount(