Skip to main content

Getting Started

This guide walks you through deploying MultiSub on an existing Safe multisig.

Prerequisites

  • Foundry installed
  • A deployed Safe on your target network
  • A deployer EOA with enough ETH for gas

1. Install

git clone <repository-url>
cd multisub/contracts
forge install && forge build

2. Deploy the Module

Deploy the DeFiInteractorModule and enable it on your Safe:

SAFE_ADDRESS=0x...            \
AUTHORIZED_UPDATER=0x... \
forge script script/Deploy.s.sol \
--rpc-url $RPC_URL \
--broadcast \
--private-key $DEPLOYER_PRIVATE_KEY

AUTHORIZED_UPDATER is the address (typically your Chainlink CRE workflow) that is allowed to push spending allowance updates on-chain.

After deployment, you must enable the module from your Safe's transaction builder:

Safe UI → Apps → Transaction Builder
→ call enableModule(DEFI_MODULE_ADDRESS)

3. Deploy Parsers & Register Selectors

Parsers decode calldata for each supported protocol. Deploy them and register their function selectors:

SAFE_ADDRESS=0x...            \
DEFI_MODULE_ADDRESS=0x... \
forge script script/ConfigureParsersAndSelectors.s.sol \
--rpc-url $RPC_URL \
--broadcast \
--private-key $DEPLOYER_PRIVATE_KEY

4. Configure a Sub-Account

Grant a hot wallet the DEFI_EXECUTE_ROLE and set its permissions:

SAFE_ADDRESS=0x...            \
DEFI_MODULE_ADDRESS=0x... \
SUB_ACCOUNT_ADDRESS=0x... \
forge script script/ConfigureSubaccount.s.sol \
--rpc-url $RPC_URL \
--broadcast \
--private-key $DEPLOYER_PRIVATE_KEY

This script:

  1. Grants the sub-account DEFI_EXECUTE_ROLE
  2. Adds your initial protocol allowlist
  3. Sets spending limit (default: 5% of portfolio per 24h)

The Chainlink Runtime Environment (CRE) workflow monitors your Safe, tracks spending in rolling 24h windows, and pushes updated spendingAllowance values on-chain. Configure it with:

chainlink-runtime-environment/safe-value/config.safe-monitor.json

Set safeAddress, rpcUrl, and moduleAddress in the config, then deploy the workflow to your CRE node.

Default Limits

If no custom limits are configured, sub-accounts default to:

ParameterDefault
Max spending5% of portfolio per window
Window size24 hours (rolling)

Running Tests

# Run all 109 tests
forge test

# With gas report
forge test --gas-report

# Single test with verbose output
forge test --match-test testGrantRole -vvv

Roles

RoleIDCapabilities
DEFI_EXECUTE_ROLE1Swaps, deposits, withdrawals, claims, approvals
DEFI_TRANSFER_ROLE2Transfer tokens out of Safe

Roles are granted and revoked by Safe multisig transactions — operators never control their own permissions.