Skip to content

Commit

Permalink
feat(gm): Only fetch gas price once
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmDreamy committed Jul 26, 2024
1 parent 7af9cf9 commit 927a0e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
| Distributor Mainnet | [task](https://app.gelato.network/functions/task/0x4db2dd79637c5942307ebce48b85fa921c9229d3627d8790c1ed4d0052cfb4d2:1) |
| Withdrawer Arbitrum | [task](https://app.gelato.network/functions/task/0x1249301e1feb1610b5d9fdd84952e4bd9af1472689686b028590d4e119109fc0:42161) |
| Stargate S\*USDT | [task](https://app.gelato.network/functions/task/0x37ab785e9a1200fb8bac63b431e36da085b177841b24aa0dfab0a4981122da0a:1) |
| GM Strategy Harvester | [task](https://app.gelato.network/functions/task/0x4548f2678aa4dd88806c5bca64af504ee2c328106c18228222e4cb3af9830836:42161) |
| GM Strategy Harvester | [task](https://app.gelato.network/functions/task/0x40d7aadde626b52e7df27bcab3f92c42faf3f137d50fc98dffc79d20c9119314:42161) |
| Reward Distributor | [task](https://app.gelato.network/functions/task/0x1b62e611e8e3d87ec8c7ced57230d341802c0ac6c611afb9a9fb4a3c53dc6ac1:42161) |
11 changes: 10 additions & 1 deletion web3-functions/gm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Web3Function.onRun(
const client = createJsonRpcPublicClient(multiChainProvider.default());

const zeroxApiKeyPromise = secrets.get("ZEROX_API_KEY");
const gasPricePromise = client.getGasPrice().then(
(gasPrice) => ({ success: true as const, gasPrice }),
(error) => ({ success: false as const, error }),
);

const callData = R.pipe(
await Promise.all(
Expand Down Expand Up @@ -199,7 +203,12 @@ Web3Function.onRun(
Promise.all([
getDepositSingleTokenGasLimit({ client, dataStoreAddress }),
getSingleSwapGasLimit({ client, dataStoreAddress }),
client.getGasPrice(),
gasPricePromise.then((result) => {
if (!result.success) {
throw result.error;
}
return result.gasPrice;
}),
]).then(
([
depositSingleTokenGasLimit,
Expand Down

0 comments on commit 927a0e1

Please sign in to comment.