Helps to estimate gas costs for execution of arbitrary actions in an Avocado smart wallet, especially when the smart wallet is not deployed yet.



function _callTargets(struct AvocadoMultisigStructs.Action[] actions_, uint256 id_) external payable



event Executed(address avocadoOwner, uint32 index, address avocadoAddress, address source, bytes metadata)

emitted when all actions for cast() in an execute() method are executed successfully


event ExecuteFailed(address avocadoOwner, uint32 index, address avocadoAddress, address source, bytes metadata, string reason)

emitted if one of the actions for cast() in an execute() method fails



error AvoGasEstimationsHelper__InvalidParams()


error AvoGasEstimationsHelper__Unauthorized()


contract IAvoFactory avoFactory

AvoFactory that this contract uses to find or create Avocado smart wallet deployments


bytes32 avocadoBytecode

cached Avocado Bytecode to directly compute address in this contract to optimize gas usage.


constructor(contract IAvoFactory avoFactory_) public

constructor sets the immutable avoFactory address


avoFactory_contract IAvoFactoryaddress of AvoFactory (proxy)


struct SimulateResult {
  uint256 totalGasUsed;
  uint256 castGasUsed;
  uint256 deploymentGasUsed;
  bool isDeployed;
  bool success;
  string revertReason;


function simulateV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external payable returns (struct AvoGasEstimationsHelper.SimulateResult simulateResult_)

Simulates executeV1, callable only by msg.sender = dead address (0x000000000000000000000000000000000000dEaD) Helpful to estimate CastForwardParams.gas for an Avocado tx. For Avocado v1. Deploys the Avocado smart wallet if necessary.

Expected use with .estimateGas(). User signed CastForwardParams.gas should be set to the estimated amount minus gas used in AvoForwarder (until AvocadoMultisig logic where the gas param is validated). Best to simulate first with a .callstatic to determine success / error and other return values.


from_addressAvocadoMultisig owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastParamsCast params such as id, avoNonce and actions to execute
forwardParams_struct AvocadoMultisigStructs.CastForwardParamsCast params related to validity of forwarding as instructed and signed
signaturesParams_struct AvocadoMultisigStructs.SignatureParamsSignatureParams structs array for signature and signer: - signature: the EIP712 signature, 65 bytes ECDSA signature for a default EOA. For smart contract signatures it must fulfill the requirements for the relevant smart contract .isValidSignature() EIP1271 logic - signer: address of the signature signer. Must match the actual signature signer or refer to the smart contract that must be an allowed signer and validates signature via EIP1271

Return Values

simulateResult_struct AvoGasEstimationsHelper.SimulateResultresult struct with following values: - total amount of gas used - amount of gas used for executing cast - amount of gas used for deployment (or for getting the contract if already deployed) - boolean flag indicating if Avocado is already deployed - boolean flag indicating whether executing actions reverts or not - revert reason original error in default format "<action_index>_error"