AvoForwarder

AvoForwarder_V1

Handles executing authorized actions (through signatures) at Avocados, triggered by allow-listed broadcasters.

Only compatible with forwarding cast calls to Avocado smart wallet contracts. This is not a generic forwarder. This is NOT a "TrustedForwarder" as proposed in EIP-2770, see info in Avocado smart wallet contracts.

Does not validate the EIP712 signature (instead this is done in the smart wallet itself).

Upgradeable through AvoForwarderProxy

AvoForwarderConstants

avoFactory

contract IAvoFactory avoFactory

AvoFactory (proxy) used to deploy new Avocado smart wallets.

avocadoBytecode

bytes32 avocadoBytecode

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

AvoForwarderVariables

AvoForwarderErrors

AvoForwarder__InvalidParams

error AvoForwarder__InvalidParams()

thrown when a method is called with invalid params (e.g. zero address)

AvoForwarder__Unauthorized

error AvoForwarder__Unauthorized()

thrown when a caller is not authorized to execute a certain action

AvoForwarder__LegacyVersionNotDeployed

error AvoForwarder__LegacyVersionNotDeployed()

thrown when trying to execute legacy methods for a not yet deployed Avocado smart wallet

AvoForwarder__Unsupported

error AvoForwarder__Unsupported()

thrown when an unsupported method is called (e.g. renounceOwnership)

AvoForwarderStructs

AddressBool

struct AddressBool {
  address addr;
  bool value;
}

ExecuteBatchParams

struct ExecuteBatchParams {
  address from;
  uint32 index;
  struct AvocadoMultisigStructs.CastChainAgnosticParams params;
  struct AvocadoMultisigStructs.SignatureParams[] signaturesParams;
  struct AvocadoMultisigStructs.ChainAgnosticHash[] chainAgnosticHashes;
}

SimulateBatchResult

struct SimulateBatchResult {
  uint256 castGasUsed;
  bool success;
  string revertReason;
}

AvoForwarderEvents

Executed

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

ExecuteFailed

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

BroadcasterUpdated

event BroadcasterUpdated(address broadcaster, bool status)

emitted if a broadcaster's allowed status is updated

AuthUpdated

event AuthUpdated(address auth, bool status)

emitted if an auth's allowed status is updated

AvoForwarderCore

AvoForwarderViews

isBroadcaster

function isBroadcaster(address broadcaster_) external view returns (bool)

checks if a broadcaster_ address is an allowed broadcaster

isAuth

function isAuth(address auth_) external view returns (bool)

checks if an auth_ address is an allowed auth

AvoForwarderViewsAvocado

avoNonce

function avoNonce(address owner_, uint32 index_) external view returns (uint256)

Retrieves the current avoNonce of AvocadoMultisig for owner_ address. Needed for building signatures.

Parameters

NameTypeDescription
owner_addressAvocado owner to retrieve the nonce for.
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
0uint256returns the avoNonce for the owner_ necessary to sign a meta transaction

avocadoVersionName

function avocadoVersionName(address owner_, uint32 index_) external view returns (string)

Retrieves the current AvocadoMultisig implementation name for owner_ address. Needed for building signatures.

Parameters

NameTypeDescription
owner_addressAvocado owner to retrieve the name for.
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
0stringreturns the domain separator name for the owner_ necessary to sign a meta transaction

avocadoVersion

function avocadoVersion(address owner_, uint32 index_) external view returns (string)

Retrieves the current AvocadoMultisig implementation version for owner_ address. Needed for building signatures.

Parameters

NameTypeDescription
owner_addressAvocado owner to retrieve the version for.
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
0stringreturns the domain separator version for the owner_ necessary to sign a meta transaction

computeAvocado

function computeAvocado(address owner_, uint32 index_) external view returns (address)

Computes the deterministic Avocado address for owner_ and index_

getAvocadoChainAgnosticHashes

function getAvocadoChainAgnosticHashes(address from_, uint32 index_, struct AvocadoMultisigStructs.CastChainAgnosticParams[] params_) external returns (struct AvocadoMultisigStructs.ChainAgnosticHash[] chainAgnosticHashes_)

returns the hashes struct for each CastChainAgnosticParams element of params_. The returned array must be passed into castChainAgnostic() as the param chainAgnosticHashes_ there (order must be the same). The returned hash for each element is the EIP712 type hash for CAST_CHAIN_AGNOSTIC_PARAMS_TYPE_HASH, as used when the signature digest is built.

Deploys the Avocado if necessary. Expected to be called with callStatic.

AvoForwarderV1

executeV1

function executeV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external payable

Deploys Avocado for owner if necessary and calls cast() on it. For Avocado v1. Only callable by allowed broadcasters.

Parameters

NameTypeDescription
from_addressAvocado 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

verifyV1

function verifyV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external returns (bool)

Verify the transaction is valid and can be executed. IMPORTANT: Expected to be called via callStatic.

                     Returns true if valid, reverts otherwise:
                     e.g. if input params, signature or avoNonce etc. are invalid.

Parameters

NameTypeDescription
from_addressAvocado 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

NameTypeDescription
0boolreturns true if everything is valid, otherwise reverts.

AvoForwarderChainAgnosticV1

executeChainAgnosticV1

function executeChainAgnosticV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastChainAgnosticParams params_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_, struct AvocadoMultisigStructs.ChainAgnosticHash[] chainAgnosticHashes_) external payable

Deploys Avocado for owner if necessary and calls castChainAgnostic() on it. For Avocado v1. Only callable by allowed broadcasters.

Parameters

NameTypeDescription
from_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastChainAgnosticParamsChain agnostic params containing CastParams, ForwardParams and chain id. Note chain id must match block.chainid.
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
chainAgnosticHashes_struct AvocadoMultisigStructs.ChainAgnosticHashhashes struct for each original CastChainAgnosticParams struct as used when signing the txs to be executed. Result of .getChainAgnosticHashes().

verifyChainAgnosticV1

function verifyChainAgnosticV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastChainAgnosticParams params_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_, struct AvocadoMultisigStructs.ChainAgnosticHash[] chainAgnosticHashes_) external returns (bool)

Verify the transaction is a valid chain agnostic tx and can be executed. IMPORTANT: Expected to be called via callStatic.

                        Returns true if valid, reverts otherwise:
                        e.g. if input params, signature or avoNonce etc. are invalid.

Parameters

NameTypeDescription
from_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastChainAgnosticParamsChain agnostic params containing CastParams, ForwardParams and chain id. Note chain id must match block.chainid.
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
chainAgnosticHashes_struct AvocadoMultisigStructs.ChainAgnosticHashhashes struct for each original CastChainAgnosticParams struct as used when signing the txs to be executed. Result of .getChainAgnosticHashes().

Return Values

NameTypeDescription
0boolreturns true if everything is valid, otherwise reverts.

AvoForwarderBatchV1

executeBatchV1

function executeBatchV1(struct AvoForwarderStructs.ExecuteBatchParams[] batches_, bool continueOnRevert_) external payable

Executes multiple txs as batch. For Avocado v1. Only callable by allowed broadcasters.

Parameters

NameTypeDescription
batches_struct AvoForwarderStructs.ExecuteBatchParamsExecute batch txs array, same as inputs for executeChainAgnosticV1() just as struct array. If chainAgnosticHashes is set (length > 0), then executeChainAgnosticV1() is executed, otherwise executeV1() is executed with the given array element.
continueOnRevert_boolflag to signal if one ExecuteBatchParams in batches_ fails, should the rest of them still continue to be executed.

AvoForwarderSimulateV1

SimulationVars

struct SimulationVars {
  contract IAvocadoMultisigV1 avocadoMultisig;
  uint256 initialGas;
}

estimateV1

function estimateV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external payable

_see simulateV1(). Reverts on success_= false for accurate .estimateGas() usage. Helpful to estimate gas for an Avocado tx. Note: resulting gas usage will usually be with at least ~10k gas buffer compared to actual execution. 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)._

simulateV1

function simulateV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) public payable returns (uint256 castGasUsed_, uint256 deploymentGasUsed_, bool isDeployed_, bool success_, string revertReason_)

Simulates a executeV1() tx, callable only by msg.sender = dead address (0x000000000000000000000000000000000000dEaD). Useful to determine success / error and other return values of executeV1() with a .callstatic. For Avocado v1.

_- set signaturesParams_to empty to automatically simulate with required signers length. - ifsignaturesParams*first element signature is not set, or if first signer is set to 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF, then gas usage burn is simulated for verify signature functionality. DO NOT set signature to non-empty for subsequent elements then; set all signatures to empty! - ifsignaturesParams* is set normally, signatures are verified as in actual execute - buffer amounts for mock smart contract signers signature verification must be added off-chain as this varies on a case per case basis._

Parameters

NameTypeDescription
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

NameTypeDescription
castGasUsed_uint256amount of gas used for executing cast
deploymentGasUsed_uint256amount of gas used for deployment (or for getting the contract if already deployed)
isDeployed_boolboolean flag indicating if Avocado is already deployed
success_boolboolean flag indicating whether executing actions reverts or not
revertReason_stringrevert reason original error in default format "<action_index>_error"

estimateChainAgnosticV1

function estimateChainAgnosticV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastChainAgnosticParams params_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_, struct AvocadoMultisigStructs.ChainAgnosticHash[] chainAgnosticHashes_) external payable

_see simulateChainAgnosticV1(). Reverts on success_= false for accurate .estimateGas() usage. Helpful to estimate gas for an Avocado tx. Note: resulting gas usage will usually be with at least ~10k gas buffer compared to actual execution. 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)._

simulateChainAgnosticV1

function simulateChainAgnosticV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastChainAgnosticParams params_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_, struct AvocadoMultisigStructs.ChainAgnosticHash[] chainAgnosticHashes_) public payable returns (uint256 castGasUsed_, uint256 deploymentGasUsed_, bool isDeployed_, bool success_, string revertReason_)

Simulates a executeChainAgnosticV1() tx, callable only by msg.sender = dead address (0x000000000000000000000000000000000000dEaD). Useful to determine success / error and other return values of executeV1() with a .callstatic. For Avocado v1. Deploys the Avocado smart wallet if necessary.

_- set signaturesParams_to empty to automatically simulate with required signers length. - ifsignaturesParams*first element signature is not set, or if first signer is set to 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF, then gas usage burn is simulated for verify signature functionality. DO NOT set signature to non-empty for subsequent elements then; set all signatures to empty! - ifsignaturesParams* is set normally, signatures are verified as in actual execute - buffer amounts for mock smart contract signers signature verification must be added off-chain as this varies on a case per case basis._

Parameters

NameTypeDescription
from_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastChainAgnosticParamsChain agnostic params containing CastParams, ForwardParams and chain id. Note chain id must match block.chainid.
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
chainAgnosticHashes_struct AvocadoMultisigStructs.ChainAgnosticHashhashes struct for each original CastChainAgnosticParams struct as used when signing the txs to be executed. Result of .getChainAgnosticHashes().

Return Values

NameTypeDescription
castGasUsed_uint256amount of gas used for executing cast
deploymentGasUsed_uint256amount of gas used for deployment (or for getting the contract if already deployed)
isDeployed_boolboolean flag indicating if Avocado is already deployed
success_boolboolean flag indicating whether executing actions reverts or not
revertReason_stringrevert reason original error in default format "<action_index>_error"

simulateBatchV1

function simulateBatchV1(struct AvoForwarderStructs.ExecuteBatchParams[] batches_, bool continueOnRevert_) external payable returns (struct AvoForwarderStructs.SimulateBatchResult[] results_)

Simulates a executeBatchV1() tx, callable only by msg.sender = dead address (0x000000000000000000000000000000000000dEaD) Helpful to estimate gas for an Avocado tx. Note: resulting gas usage will usually be with at least ~10k gas buffer compared to actual execution. For Avocado v1. Deploys the Avocado smart wallet if necessary.

Expected use with .estimateGas(). Best to combine with a .callstatic to determine success / error and other return values of executeV1(). For indidividual measurements of each ExecuteBatchParams execute the respective simulate() single method for it.

Parameters

NameTypeDescription
batches_struct AvoForwarderStructs.ExecuteBatchParamsExecute batch txs array, same as inputs for simulateChainAgnosticV1() just as struct array.
continueOnRevert_boolflag to signal if one ExecuteBatchParams in batches_ fails, should the rest of them still continue to be executed.

AvoForwarderOwnerActions

updateBroadcasters

function updateBroadcasters(struct AvoForwarderStructs.AddressBool[] broadcastersStatus_) external

updates allowed status for broadcasters based on broadcastersStatus_ and emits BroadcastersUpdated. Executable by allowed auths or owner only.

updateAuths

function updateAuths(struct AvoForwarderStructs.AddressBool[] authsStatus_) external

updates allowed status for a auths based on authsStatus_ and emits AuthsUpdated. Executable by allowed auths or owner only (auths can only remove themselves).

AvoForwarder

constructor

constructor(contract IAvoFactory avoFactory_) public

constructor sets the immutable avoFactory (proxy) address and cached bytecodes derived from it

initialize

function initialize(address owner_, address[] allowedBroadcasters_) public

initializes the contract, setting owner_ and initial allowedBroadcasters_

Parameters

NameTypeDescription
owner_addressaddress of owner_ allowed to executed auth limited methods
allowedBroadcasters_addressinitial list of allowed broadcasters to be enabled right away

renounceOwnership

function renounceOwnership() public view

override renounce ownership as it could leave the contract in an unwanted state if called by mistake.