From 9affef3af2e64b3ac8db0abd8a5d4b20c9655068 Mon Sep 17 00:00:00 2001 From: sebastienverreault Date: Sun, 19 Jun 2022 02:20:29 -0400 Subject: [PATCH] fix: convert string fees to number and use the min (#106) Co-authored-by: Sebastien Verreault --- dealer/src/OkexExchange.ts | 6 +++--- dealer/src/OkexPerpetualSwapStrategy.ts | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dealer/src/OkexExchange.ts b/dealer/src/OkexExchange.ts index 82013ea8..6b194bfd 100644 --- a/dealer/src/OkexExchange.ts +++ b/dealer/src/OkexExchange.ts @@ -434,11 +434,11 @@ export class OkexExchange extends ExchangeBase { "exchange.privateGetAssetCurrencies() returned: {response}", ) if (btcCurrency?.minWd) - config.minOnChainWithdrawalAmount = btcCurrency?.minWd + config.minOnChainWithdrawalAmount = Number(btcCurrency?.minWd) if (btcCurrency?.minFee) - config.minOnChainWithdrawalFee = btcCurrency?.minFee + config.minOnChainWithdrawalFee = Number(btcCurrency?.minFee) if (btcCurrency?.maxFee) - config.maxOnChainWithdrawalFee = btcCurrency?.maxFee + config.maxOnChainWithdrawalFee = Number(btcCurrency?.maxFee) this.logger.debug( { config, response: btcCurrency }, "ExchangeConfiguration after update: {config}", diff --git a/dealer/src/OkexPerpetualSwapStrategy.ts b/dealer/src/OkexPerpetualSwapStrategy.ts index e1445224..0197dae6 100644 --- a/dealer/src/OkexPerpetualSwapStrategy.ts +++ b/dealer/src/OkexPerpetualSwapStrategy.ts @@ -526,11 +526,10 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy { // then initiate the withdrawal which by default uses the funding account const config = this.exchangeConfig as OkexExchangeConfiguration - const averageFee = - (config.minOnChainWithdrawalFee + config.maxOnChainWithdrawalFee) / 2 + const averageFee = config.minOnChainWithdrawalFee const withdrawArgs = { currency: TradeCurrency.BTC, - quantity: transferSizeInBtc, + quantity: transferSizeInBtc - averageFee, address: withdrawOnChainAddress, params: { fee: averageFee,