From dcb1e93390c621ea2c884543a08ebff143a5800c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pr=C3=A9vost?= <998369+prevostc@users.noreply.github.com> Date: Thu, 24 Oct 2024 23:24:45 +0200 Subject: [PATCH] Fix scroll --- package.json | 4 +-- src/lib/addressbook.ts | 36 +++++++------------ src/lib/config.ts | 16 ++++++--- .../rpc-actions/aggressivelyWriteContract.ts | 6 ++-- src/lib/rpc-config.ts | 6 +++- yarn.lock | 16 ++++----- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index e46d23a..a5e939d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@openzeppelin/contracts": "^4.9.3", "async-lock": "^1.4.0", "axios": "^1.5.0", - "blockchain-addressbook": "^0.47.39", + "blockchain-addressbook": "^0.47.54", "dotenv": "^16.3.1", "lodash": "^4.17.21", "pg": "^8.11.3", @@ -50,7 +50,7 @@ "pg-format": "^1.0.4", "pino": "^8.15.1", "table": "^6.8.1", - "viem": "^2.21.27", + "viem": "^2.21.34", "yaml": "^2.3.2", "yargs": "^17.7.2" }, diff --git a/src/lib/addressbook.ts b/src/lib/addressbook.ts index 78a2f46..a63bb89 100644 --- a/src/lib/addressbook.ts +++ b/src/lib/addressbook.ts @@ -3,45 +3,33 @@ import type { Hex } from 'viem'; import type { Chain } from './chain'; export function getChainWNativeTokenDecimals(chain: Chain): number { - if (chain === 'mode') { - return 18; - } - if (chain === 'scroll') { - return 18; - } + // if (chain === 'abc') { + // return 18; + // } const tokens = addressbook.addressBook[chain].tokens; return tokens.WNATIVE.decimals; } export function getChainWNativeTokenSymbol(chain: Chain): string { - if (chain === 'mode') { - return 'ETH'; - } - if (chain === 'scroll') { - return 'ETH'; - } + // if (chain === 'abc') { + // return 'ETH'; + // } const tokens = addressbook.addressBook[chain].tokens; return tokens.WNATIVE.symbol; } export function getChainWNativeTokenAddress(chain: Chain): Hex { - if (chain === 'mode') { - return '0x4200000000000000000000000000000000000006'; - } - if (chain === 'scroll') { - return '0x5300000000000000000000000000000000000004'; - } + // if (chain === 'abc') { + // return '0x0000000000000000000000000000000000000000'; + // } const tokens = addressbook.addressBook[chain].tokens; return tokens.WNATIVE.address as Hex; } export function getNetworkId(chain: Chain): number { - if (chain === 'mode') { - return 34443; - } - if (chain === 'scroll') { - return 534352; - } + // if (chain === 'abc') { + // return 123; + // } const tokens = addressbook.addressBook[chain].tokens; return tokens.WNATIVE.chainId; } diff --git a/src/lib/config.ts b/src/lib/config.ts index 58efa1f..9119e61 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -190,7 +190,11 @@ const defaultTransactionConfig: RpcConfig['transaction'] = { maxGasPricePerTransactionWei: null, maxNativePerTransactionWei: null, totalTries: 1, // by default, only try the trx once - retryGasMultiplier: 1.2, // up gas by 20% on each retry + retryGasMultiplier: { + gasPrice: 1.2, // up gas by 20% on each retry + maxFeePerGas: 1.2, // up gas by 20% on each retry + maxPriorityFeePerGas: 1.2, // up gas by 20% on each retry + }, baseFeeMultiplier: 1.25, // 25% above base fee receipt: { blockConfirmations: 3, @@ -793,17 +797,21 @@ export const RPC_CONFIG: Record = { type: 'eip1559', maxNativePerTransactionWei: bigintMultiplyFloat(ONE_ETHER, 0.01), maxGasPricePerTransactionWei: null, - totalTries: 3, // try 3 times as the first time we often get + // try 5 times as the first time we often get a tx failure due to max + totalTries: 5, + retryGasMultiplier: { + gasPrice: 1.2, + maxFeePerGas: 1.5, + maxPriorityFeePerGas: 1.3, + }, }, harvest: { ...defaultHarvestConfig, - setTransactionGasLimit: false, }, unwrap: { ...defaultUnwrapConfig, minAmountOfWNativeWei: bigintMultiplyFloat(ONE_ETHER, 0.01), maxAmountOfNativeWei: bigintMultiplyFloat(ONE_ETHER, 0.01), - setTransactionGasLimit: false, }, revenueBridgeHarvest: { ...defaultRevenueBridgeHarvestConfig, diff --git a/src/lib/rpc-actions/aggressivelyWriteContract.ts b/src/lib/rpc-actions/aggressivelyWriteContract.ts index ec4fc55..38aa922 100644 --- a/src/lib/rpc-actions/aggressivelyWriteContract.ts +++ b/src/lib/rpc-actions/aggressivelyWriteContract.ts @@ -219,19 +219,19 @@ export async function aggressivelyWriteContract< if (gasParams.gasPrice) { gasParams.gasPrice = bigintMultiplyFloat( gasParams.gasPrice, - rpcConfig.transaction.retryGasMultiplier + rpcConfig.transaction.retryGasMultiplier.gasPrice ); } if (gasParams.maxPriorityFeePerGas) { gasParams.maxPriorityFeePerGas = bigintMultiplyFloat( gasParams.maxPriorityFeePerGas, - rpcConfig.transaction.retryGasMultiplier + rpcConfig.transaction.retryGasMultiplier.maxPriorityFeePerGas ); } if (gasParams.maxFeePerGas) { gasParams.maxFeePerGas = bigintMultiplyFloat( gasParams.maxFeePerGas, - rpcConfig.transaction.retryGasMultiplier + rpcConfig.transaction.retryGasMultiplier.maxFeePerGas ); } logger.warn({ diff --git a/src/lib/rpc-config.ts b/src/lib/rpc-config.ts index 0d95232..4a77bb0 100644 --- a/src/lib/rpc-config.ts +++ b/src/lib/rpc-config.ts @@ -30,7 +30,11 @@ export type RpcConfig = { ) & { // @see aggressivelyWriteContract totalTries: number; - retryGasMultiplier: number; + retryGasMultiplier: { + gasPrice: number; + maxFeePerGas: number; + maxPriorityFeePerGas: number; + }; // default gas price multiplier, effective on the first try baseFeeMultiplier: number; receipt: { diff --git a/yarn.lock b/yarn.lock index 36aee75..15544b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1248,10 +1248,10 @@ base64-js@^1.3.1: resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -blockchain-addressbook@^0.47.39: - version "0.47.39" - resolved "https://registry.yarnpkg.com/blockchain-addressbook/-/blockchain-addressbook-0.47.39.tgz#464d721932bd034de767f8dcfcaa24f19af748e7" - integrity sha512-fI+QtImsySitVIq8NgpCInDzo4/EE58KRBBy1sh5u4Um0uZ6kBoIwkh3NhFx6IWCXtV8LA2WBNPFJwuKsuxuMg== +blockchain-addressbook@^0.47.54: + version "0.47.54" + resolved "https://registry.yarnpkg.com/blockchain-addressbook/-/blockchain-addressbook-0.47.54.tgz#1c117509c0ac410be5eab2e1bd4ec8bb952187f9" + integrity sha512-NP91iyX1HsiVO8R6wHFNQ7BjESga/XMO1JGf7n9DG+9hg4WMAkx7V4egEV6mNvJOrvWc4Etl3Xi0IJflQnaTAw== boxen@^7.0.0: version "7.1.1" @@ -4703,10 +4703,10 @@ validate-npm-package-name@^5.0.0: dependencies: builtins "^5.0.0" -viem@^2.21.27: - version "2.21.27" - resolved "https://registry.yarnpkg.com/viem/-/viem-2.21.27.tgz#4f47ae8df832e160c5a339238e823c0e56794e64" - integrity sha512-lBpldSmwmKZ8jIiVLqoplPnuMs2Cza8tK0/G9m+ZjqfbgEp4+BPviFBJWCDNFxSp8H3gPzAuqj8o1WKQyq3wlg== +viem@^2.21.34: + version "2.21.34" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.21.34.tgz#5206148a6aa659113d7844db53247a411d28569e" + integrity sha512-IR8ucya4dkVJv1jzv/qBz1TxYbSoXZuJPuqQk1/AybU9VuGdMUayittYwr0Navs97XFNml6UWGVya07apoaBmQ== dependencies: "@adraffy/ens-normalize" "1.11.0" "@noble/curves" "1.6.0"