Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
fix: Number to BigInt conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeychr committed Dec 12, 2023
1 parent 07a8f3f commit 0b007d5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 4 additions & 3 deletions src/chain-evm/bumpedFeeManager.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
);

Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/chain-evm/order-estimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`,
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function safeIntToBigInt(v: number): bigint {
return BigInt(Math.trunc(v));
}

0 comments on commit 0b007d5

Please sign in to comment.