From a3479ab245d8b09edeb1db6d226d5c2083bc61bb Mon Sep 17 00:00:00 2001 From: filipzeta <103913117+filipzeta@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:35:48 +1100 Subject: [PATCH] Extra fee util (#368) --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/utils.ts | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b49bc22..4d9b86498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ Version changes are pinned to SDK releases. ## [Unreleased] +## [1.23.6] + +- Extra util getFeeBps() ([#368](https://github.com/zetamarkets/sdk/pull/368)) + ## [1.23.5] - Add support for fee tiers. ([#358](https://github.com/zetamarkets/sdk/pull/358)) diff --git a/package.json b/package.json index b93c7ca09..e49174a74 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@zetamarkets/sdk", "repository": "https://github.com/zetamarkets/sdk/", - "version": "1.23.5", + "version": "1.23.6", "description": "Zeta SDK", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/utils.ts b/src/utils.ts index 73f9e9d2f..cf54c58d4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2172,3 +2172,18 @@ export function calculateTakeTriggerOrderExecutionPrice( } return executionPrice; } + +export function getFeeBps( + isTaker: boolean, + accountType: constants.MarginAccountType +): number { + let feeMap = isTaker + ? constants.FEE_TIER_MAP_BPS["taker"] + : constants.FEE_TIER_MAP_BPS["maker"]; + + let fee = feeMap[accountType]; + if (fee == undefined) { + return feeMap[constants.MarginAccountType.NORMAL]; + } + return fee; +}