Skip to content

feat(forge script): preview, batch, and execute Gnosis Safe transactions (ape-safe) #1232

Open
@Anish-Agnihotri

Description

@Anish-Agnihotri

Component

Forge

Describe the feature you would like

Description:

My favorite tool from the Brownie/Vyper ecosystem is ape-safe. It lets you:

  1. Setup some actions (calling various functions, piping data together in Python)
  2. Preview the side effects, running those actions via a Brownie mainnet fork
  3. Once everything looks good, batch all the actions via MultiSend and send as one transaction for signers to approve

Now that Foundry is adding support for a local node and deploy scripts, it would be useful to have similar functionality out of the box.

Example:

I'm not sure what this looks like practically yet, but it might just be an executable Solidity script (transcribing the ape-safe Python example):

function script() public {
  Safe gnosis = Safe(0xfeb4acf3df3cdea7399794d0869ef76a6efaff52);

  ERC20 public dai = ERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
  yVault public vault = yVault(0x19D3364A399d251E894aC732651be8B0E4e85001);

  uint256 amount = dai.balanceOf(address(gnosis));
  dai.approve(vault, amount);
  vault.deposit(amount);

  // Generate preview transaction
  cheats.preview();
  // Batch transaction
  cheats.batch();
  // Broadcast transaction
  cheats.broadcast(address(gnosis));
}

Potential use-cases:

Some potential applications:

  • Automating contract setups or common governance actions
  • Using like Hardhat tasks, see example in dYdX repo
  • Using like optimism's chug-splash as a mass-deployment system

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions