Skip to content

Commit

Permalink
sdk: fix bug in funding with BN.abs()
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Oct 19, 2023
1 parent 71ef972 commit 616b3db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/src/math/funding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions sdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 616b3db

Please sign in to comment.