Getting Started
This guide walks you through deploying MultiSub on an existing Safe multisig.
Prerequisites
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:
- Grants the sub-account
DEFI_EXECUTE_ROLE - Adds your initial protocol allowlist
- Sets spending limit (default: 5% of portfolio per 24h)
5. Set Up the Chainlink Oracle
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:
| Parameter | Default |
|---|---|
| Max spending | 5% of portfolio per window |
| Window size | 24 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
| Role | ID | Capabilities |
|---|---|---|
DEFI_EXECUTE_ROLE | 1 | Swaps, deposits, withdrawals, claims, approvals |
DEFI_TRANSFER_ROLE | 2 | Transfer tokens out of Safe |
Roles are granted and revoked by Safe multisig transactions — operators never control their own permissions.