Skip to content

Commit

Permalink
Fix scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Oct 24, 2024
1 parent a3ee8d0 commit dcb1e93
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"@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",
"pg-connection-string": "^2.6.2",
"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"
},
Expand Down
36 changes: 12 additions & 24 deletions src/lib/addressbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
16 changes: 12 additions & 4 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -793,17 +797,21 @@ export const RPC_CONFIG: Record<Chain, RpcConfig> = {
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,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/rpc-actions/aggressivelyWriteContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 5 additions & 1 deletion src/lib/rpc-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit dcb1e93

Please sign in to comment.