diff --git a/package-lock.json b/package-lock.json index 74fb53f..19f2cef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@debridge-finance/dln-taker", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@debridge-finance/dln-taker", - "version": "3.0.1", + "version": "3.0.2", "license": "GPL-3.0-only", "dependencies": { "@debridge-finance/dln-client": "8.3.1", diff --git a/package.json b/package.json index 34e907b..e21625e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@debridge-finance/dln-taker", - "version": "3.0.1", + "version": "3.0.2", "description": "DLN executor is the rule-based daemon service developed to automatically execute orders placed on the deSwap Liquidity Network (DLN) across supported blockchains", "license": "GPL-3.0-only", "author": "deBridge", diff --git a/src/chain-evm/bumpedFeeManager.ts b/src/chain-evm/bumpedFeeManager.ts index cb7c1b4..97f5f4a 100644 --- a/src/chain-evm/bumpedFeeManager.ts +++ b/src/chain-evm/bumpedFeeManager.ts @@ -1,5 +1,6 @@ import { ChainId } from '@debridge-finance/dln-client'; import Web3 from 'web3'; +import { safeIntToBigInt } from '../utils'; import { EIP1551Fee, EvmFeeManager, findMaxBigInt } from './feeManager'; import { BroadcastedTx } from './signer'; @@ -23,14 +24,14 @@ export class BumpedFeeManager extends EvmFeeManager { fees.maxPriorityFeePerGas = findMaxBigInt( fees.maxPriorityFeePerGas, (BigInt(replaceTx.tx.maxPriorityFeePerGas?.toString() || 0n) * - BigInt(this.#bumpGasPriceMultiplier * 10_000)) / + safeIntToBigInt(this.#bumpGasPriceMultiplier * 10_000)) / 10_000n, ); fees.maxFeePerGas = findMaxBigInt( fees.baseFee + fees.maxPriorityFeePerGas, (BigInt(replaceTx.tx.maxFeePerGas?.toString() || 0n) * - BigInt(this.#bumpGasPriceMultiplier * 10_000)) / + safeIntToBigInt(this.#bumpGasPriceMultiplier * 10_000)) / 10_000n, ); @@ -43,7 +44,7 @@ export class BumpedFeeManager extends EvmFeeManager { if (replaceTx) { const replacementTxGasPrice = (BigInt(replaceTx.tx.gasPrice?.toString() || 0n) * - BigInt(this.#bumpGasPriceMultiplier * 10_000)) / + safeIntToBigInt(this.#bumpGasPriceMultiplier * 10_000)) / 10_000n; if (replacementTxGasPrice > gasPrice) gasPrice = replacementTxGasPrice; } diff --git a/src/chain-evm/order-estimator.ts b/src/chain-evm/order-estimator.ts index 71f8936..72f81d9 100644 --- a/src/chain-evm/order-estimator.ts +++ b/src/chain-evm/order-estimator.ts @@ -2,6 +2,7 @@ import { calculateExpectedTakeAmount } from '@debridge-finance/legacy-dln-profit import { OrderEstimator } from '../chain-common/order-estimator'; import { EVMOrderValidator } from './order-validator'; import { EvmFeeManager } from './feeManager'; +import { safeIntToBigInt } from '../utils'; export class EVMOrderEstimator extends OrderEstimator { // Must cover up to 12.5% block base fee increase. Must be in sync with EVMOrderValidator.EVM_FULFILL_GAS_LIMIT_MULTIPLIER @@ -26,7 +27,7 @@ export class EVMOrderEstimator extends OrderEstimator { const estimatedNextGasPrice = await feeManager.estimateNextGasPrice(); const bufferedGasPrice = (estimatedNextGasPrice * - BigInt(EVMOrderEstimator.EVM_FULFILL_GAS_PRICE_MULTIPLIER * 10_000)) / + safeIntToBigInt(EVMOrderEstimator.EVM_FULFILL_GAS_PRICE_MULTIPLIER * 10_000)) / 10_000n; this.logger.debug( `estimated gas price for the next block: ${estimatedNextGasPrice}, buffered: ${bufferedGasPrice}`, diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..475f8ff --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,3 @@ +export function safeIntToBigInt(v: number): bigint { + return BigInt(Math.trunc(v)); +}