From 616b3dbedcd9a3ca7c5e1b3dc14a5c13bc4c77a5 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Thu, 19 Oct 2023 15:36:35 -0400 Subject: [PATCH] sdk: fix bug in funding with BN.abs() --- sdk/src/math/funding.ts | 2 +- sdk/yarn.lock | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sdk/src/math/funding.ts b/sdk/src/math/funding.ts index 7e89104a5..46e1e3db5 100644 --- a/sdk/src/math/funding.ts +++ b/sdk/src/math/funding.ts @@ -158,7 +158,7 @@ export async function calculateAllEstimatedFundingRate( const twapSpread = markTwap.sub(oracleTwap); const twapSpreadWithOffset = twapSpread.add( - BN.abs(oracleTwap).div(FUNDING_RATE_OFFSET_DENOMINATOR) + oracleTwap.abs().div(FUNDING_RATE_OFFSET_DENOMINATOR) ); const twapSpreadPct = twapSpreadWithOffset diff --git a/sdk/yarn.lock b/sdk/yarn.lock index b840070f6..5be805b16 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -415,6 +415,13 @@ resolved "https://registry.yarnpkg.com/@types/big.js/-/big.js-6.2.0.tgz#e1f6a9a6ce64bc7c131137e71fbad34a5574f987" integrity sha512-ubLURWoc4tCw/8Yds0P3CE9cBG5q+aoycwWBiXXx4gp7XPYZy9ch0L9+Pv6osSoSRgvuQNqJdlwEhP5QhKKl6w== +"@types/bn.js@^5.1.3": + version "5.1.3" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.3.tgz#0857f00da3bf888a26a44b4a477c7819b17dacc5" + integrity sha512-wT1B4iIO82ecXkdN6waCK8Ou7E71WU+mP1osDA5Q8c6Ur+ozU2vIKUIhSpUr6uE5L2YHocKS1Z2jG2fBC1YVeg== + dependencies: + "@types/node" "*" + "@types/chai@^4.3.1": version "4.3.4" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4"