From ed059be5c2dae5fdda81af669d632c83bc3abb63 Mon Sep 17 00:00:00 2001 From: 0xBossanova <0xBossanova@proton.me> Date: Wed, 15 Feb 2023 10:04:04 +0100 Subject: [PATCH] Bug/maxfee index overflow (#42) * bug: index max fee assignment overflow * chore/update examples with MAX_PATH_HOPS --- .env.juno.example | 2 +- .env.terra.example | 2 +- src/core/types/arbitrageloops/mempoolLoop.ts | 4 +++- src/core/types/arbitrageloops/skipLoop.ts | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.env.juno.example b/.env.juno.example index 26373a6..3fc97d7 100644 --- a/.env.juno.example +++ b/.env.juno.example @@ -6,7 +6,7 @@ PROFIT_THRESHOLD="10000" # LOGGING ENVIRONMENT VARIABLES # SLACK_TOKEN = # SLACK_CHANNEL = - +MAX_PATH_HOPS="4" # # SKIP SPECIFIC ENVIRONMENT VARIABLES USE_SKIP = "1" SKIP_URL= "http://juno-1-api.skip.money" diff --git a/.env.terra.example b/.env.terra.example index b63e812..af57d0e 100644 --- a/.env.terra.example +++ b/.env.terra.example @@ -4,7 +4,7 @@ WALLET_MNEMONIC="" ##change this USE_MEMPOOL="1" GAS_USAGE_PER_HOP="700000" #defines the gas usage per hop, 2 hop arb pays 1400000 gas, 3 hop will pay 2100000 etc PROFIT_THRESHOLD="5000" - +MAX_PATH_HOPS="4" ##LOGGING ENVIRONMENT VARIABLES, optional #SLACK_TOKEN = "" diff --git a/src/core/types/arbitrageloops/mempoolLoop.ts b/src/core/types/arbitrageloops/mempoolLoop.ts index 3f837f7..98acfce 100644 --- a/src/core/types/arbitrageloops/mempoolLoop.ts +++ b/src/core/types/arbitrageloops/mempoolLoop.ts @@ -142,7 +142,9 @@ export class MempoolLoop { const TX_FEE = this.botConfig.txFees.get(arbTrade.path.pools.length) ?? - Array.from(this.botConfig.txFees.values())[this.botConfig.txFees.size]; + + Array.from(this.botConfig.txFees.values())[this.botConfig.gasFees.size - 1]; + // sign, encode and broadcast the transaction const txRaw = await this.botClients.SigningCWClient.sign( diff --git a/src/core/types/arbitrageloops/skipLoop.ts b/src/core/types/arbitrageloops/skipLoop.ts index ec6ca39..0907334 100644 --- a/src/core/types/arbitrageloops/skipLoop.ts +++ b/src/core/types/arbitrageloops/skipLoop.ts @@ -125,7 +125,8 @@ export class SkipLoop extends MempoolLoop { //if gas fee cannot be found in the botconfig based on pathlengths, pick highest available const TX_FEE = this.botConfig.txFees.get(arbTrade.path.pools.length) ?? - Array.from(this.botConfig.txFees.values())[this.botConfig.txFees.size]; + Array.from(this.botConfig.txFees.values())[this.botConfig.gasFees.size - 1]; + const txRaw: TxRaw = await this.botClients.SigningCWClient.sign( this.account.address, msgs,