Skip to content

Commit

Permalink
chore: add static gas options
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Oct 18, 2023
1 parent c2c2517 commit df1c70f
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 8 deletions.
64 changes: 62 additions & 2 deletions axelar-chains-config/info/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"explorer": {
"url": "https://etherscan.io",
"api": "https://api.etherscan.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 150000000000
}
},
"avalanche": {
Expand Down Expand Up @@ -94,6 +98,10 @@
"explorer": {
"url": "https://snowtrace.io",
"api": "https://api.snowtrace.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 150000000000
}
},
"fantom": {
Expand Down Expand Up @@ -145,6 +153,10 @@
},
"gasOptions": {
"gasLimit": 5000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 1000000000000
}
},
"polygon": {
Expand Down Expand Up @@ -196,6 +208,10 @@
},
"gasOptions": {
"gasLimit": 6000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 350000000000
}
},
"moonbeam": {
Expand Down Expand Up @@ -244,6 +260,10 @@
"explorer": {
"url": "https://moonbeam.moonscan.io",
"api": "https://api-moonbeam.moonscan.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 625000000000
}
},
"binance": {
Expand Down Expand Up @@ -293,6 +313,10 @@
"explorer": {
"url": "https://bscscan.com",
"api": "https://api.bscscan.com/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 30000000000
}
},
"arbitrum": {
Expand Down Expand Up @@ -344,6 +368,10 @@
},
"gasOptions": {
"gasLimit": 20000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 2000000000
}
},
"celo": {
Expand Down Expand Up @@ -392,6 +420,10 @@
"explorer": {
"url": "https://celoscan.io",
"api": "https://api.celoscan.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 100000000000
}
},
"kava": {
Expand Down Expand Up @@ -440,6 +472,10 @@
"explorer": {
"url": "https://explorer.kava.io",
"api": "https://explorer.kava.io/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 50000000000
}
},
"filecoin": {
Expand Down Expand Up @@ -494,6 +530,10 @@
},
"gasOptions": {
"gasLimit": 500000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 1000000000
}
},
"optimism": {
Expand Down Expand Up @@ -550,7 +590,11 @@
"gasOptions": {
"gasLimit": 5000000
},
"confirmations": 3
"confirmations": 3,
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 10000000000
}
},
"linea": {
"name": "Linea",
Expand Down Expand Up @@ -602,6 +646,10 @@
"explorer": {
"url": "https://lineascan.build",
"api": "https://api.lineascan.build/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 10000000000
}
},
"base": {
Expand Down Expand Up @@ -654,6 +702,10 @@
"explorer": {
"url": "https://basescan.org",
"api": "https://api.basescan.org/api"
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 10000000000
}
},
"mantle": {
Expand Down Expand Up @@ -710,7 +762,11 @@
"gasOptions": {
"gasLimit": 8000000
},
"skipRevertTests": true
"skipRevertTests": true,
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 25000000000
}
},
"scroll": {
"name": "Scroll",
Expand Down Expand Up @@ -761,6 +817,10 @@
"confirmations": 2,
"gasOptions": {
"gasLimit": 8000000
},
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 25000000000
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion axelar-chains-config/info/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,11 @@
"gasOptions": {
"gasLimit": 8000000
},
"skipRevertTests": true
"skipRevertTests": true,
"staticGasOptions": {
"gasLimit": 3000000,
"gasPrice": 1000000000
}
},
"scroll": {
"name": "Scroll",
Expand Down
40 changes: 35 additions & 5 deletions evm/update-static-gas-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,51 @@ const { printInfo, mainProcessor, prompt } = require('./utils');
const defaultGasLimit = 3e6;
const gasPriceMultiplier = 5;

async function processCommand(config, chain, options) {
const { rpc, yes } = options;
const minGasPrices = {
mainnet: {
ethereum: 150,
moonbeam: 500,
avalanche: 150,
polygon: 350,
fantom: 1000,
binance: 30,
arbitrum: 2,
celo: 100,
kava: 50,
optimism: 10,
filecoin: 1,
base: 10,
linea: 10,
mantle: 25,
scroll: 25,
},
testnet: {
mantle: 1,
},
};

async function processCommand(_, chain, options) {
const { env, rpc, yes } = options;
const provider = rpc ? getDefaultProvider(rpc) : getDefaultProvider(chain.rpc);

if (prompt(`Proceed with the static gasOption update on ${chalk.green(chain.name)}`, yes)) {
return;
}

const gasPrice = parseUnits((await provider.getGasPrice()).toString(), 'wei') * gasPriceMultiplier;
const gasPriceWei = await provider.getGasPrice();
printInfo(`${chain.name} gas price`, `${gasPriceWei / 1e9} gwei`);

let gasPrice = parseUnits(gasPriceWei.toString(), 'wei') * gasPriceMultiplier;

Check failure on line 50 in evm/update-static-gas-options.js

View workflow job for this annotation

GitHub Actions / lint (18.x, ubuntu-latest)

'gasPrice' is never reassigned. Use 'const' instead

if (!(chain.staticGasOptions && chain.staticGasOptions.gasLimit !== undefined)) {
chain.staticGasOptions = { gasLimit: defaultGasLimit };
}

chain.staticGasOptions.gasPrice = gasPrice;
const minGasPrice = ((minGasPrices[env] || {})[chain.name.toLowerCase()] || 0) * 1e9;
chain.staticGasOptions.gasPrice = gasPrice < minGasPrice ? minGasPrice : gasPrice;

printInfo(`${chain.name} static gas price set to`, `${chain.staticGasOptions.gasPrice / 1e9} gwei`);

printInfo(`staticGasOptions updated succesfully and stored in config file`);
}

Expand All @@ -37,7 +67,7 @@ async function main(options) {

const program = new Command();

program.name('update-static-gas-options').description('Update staticGasOptions to be used when offline signing');
program.name('update-static-gas-options').description('Update staticGasOptions');

program.addOption(
new Option('-e, --env <env>', 'environment')
Expand Down

0 comments on commit df1c70f

Please sign in to comment.