Skip to content

Commit

Permalink
Merge pull request #433 from HausDAO/feat/default-gas-estimate-boost-2
Browse files Browse the repository at this point in the history
change gas multipler to 5, move constant to file and update multicall…
  • Loading branch information
dekanbro authored Oct 6, 2023
2 parents 06117f2 + 3fd0917 commit 8a064d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libs/tx-builder/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LOCAL_ABI } from '@daohaus/abis';
export const EXPIRY = '.proposalExpiry';
export const FORM = '.formValues';
export const CURRENT_DAO = '.daoId';
export const gasBufferMultiplier = 3;
export const gasBufferMultiplier = 5;
export const BaalContractBase = {
type: 'local',
contractName: 'Baal',
Expand Down
5 changes: 5 additions & 0 deletions libs/utils/src/constants/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,8 @@ export const PROPOSAL_FILTERS: Record<string, string> = {
failed: 'Defeated',
expired: 'Expired',
};

export const GAS_BUFFER_MULTIPLIER = 5;
// Adding to the gas limit to account for cost of processProposal
export const PROCESS_PROPOSAL_GAS_LIMIT_ADDITION = 150000;
export const L2_ADDITIONAL_GAS = 5000000;
14 changes: 8 additions & 6 deletions libs/utils/src/utils/gas.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ValidNetwork } from '@daohaus/keychain-utils';
import { weiUnits, formatUnits, parseGwei } from 'viem';
import { createViemClient } from './viem';

// Adding to the gas limit to account for cost of processProposal
export const PROCESS_PROPOSAL_GAS_LIMIT_ADDITION = 150000;
export const L2_ADDITIONAL_GAS = 5000000;
import {
GAS_BUFFER_MULTIPLIER,
L2_ADDITIONAL_GAS,
PROCESS_PROPOSAL_GAS_LIMIT_ADDITION,
} from '../constants';

// OPTIMISM challenge - how to display this estimated gas fee like we do on other networks.
// ethers.js getFeeData returns maxFeePerGas as undefined, might need to use gasPrice some how, then fetch the L1 amount
Expand Down Expand Up @@ -32,13 +33,14 @@ export const getProcessingGasLimit = (
? Number(actionGasEstimate) +
PROCESS_PROPOSAL_GAS_LIMIT_ADDITION +
L2_ADDITIONAL_GAS
: PROCESS_PROPOSAL_GAS_LIMIT_ADDITION * 3.6 + L2_ADDITIONAL_GAS
: PROCESS_PROPOSAL_GAS_LIMIT_ADDITION * GAS_BUFFER_MULTIPLIER +
L2_ADDITIONAL_GAS
);
}
return BigInt(
Number(actionGasEstimate) > 0
? Number(actionGasEstimate) + PROCESS_PROPOSAL_GAS_LIMIT_ADDITION
: PROCESS_PROPOSAL_GAS_LIMIT_ADDITION * 3.6
: PROCESS_PROPOSAL_GAS_LIMIT_ADDITION * GAS_BUFFER_MULTIPLIER
);
};

Expand Down

0 comments on commit 8a064d9

Please sign in to comment.