Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
09a5bd0
fix(contracts): Require a timelock canceller in the governance deploy
ebma Oct 21, 2026
5097117
fix(contracts): Check the permanent values in the migration deploy sc…
ebma Oct 22, 2026
62f3d66
fix(contracts): Validate every governance deploy parameter
ebma Oct 22, 2026
886f270
test(contracts): Give the timelock canceller its own address in the g…
ebma Oct 22, 2026
89c1a50
fix(contracts): Require the timelock canceller to be a separate Safe
ebma Oct 22, 2026
3ceaf19
fix(contracts): Bound the governance voting windows from below
ebma Oct 22, 2026
56b8157
docs(contracts): Point the quorum note at the PRD section
ebma Oct 22, 2026
2ae3473
fix(contracts): Name the reason a timelock canceller is not a Safe
ebma Oct 22, 2026
60c2502
fix(contracts): Require a timelock canceller Safe with at least two s…
ebma Oct 22, 2026
a3a17b7
fix(contracts): Require a non-zero quorum fraction in the governance …
ebma Oct 22, 2026
9ad8679
test(contracts): Run both deploy scripts' cases in one test function
ebma Oct 22, 2026
937e18a
fix(contracts): Require the bootstrap vault admin to be a Safe
ebma Oct 22, 2026
e164828
fix(contracts): Require a sweep floor at least 30 days after the deploy
ebma Oct 22, 2026
301c1b6
fix(testing): Write the governance drill's quorum floor as a string
ebma Oct 22, 2026
4bc5421
test(contracts): Run the production deploy paths on Base mainnet's ch…
ebma Oct 22, 2026
d0e3258
refactor(contracts): Move the multisig Safe check into a shared helper
ebma Oct 22, 2026
1ed5b6d
fix(contracts): Require a bootstrap admin Safe with at least two signers
ebma Oct 22, 2026
2b52384
docs: Note every value TEST_DEPLOY admits and set it in the manual An…
ebma Oct 22, 2026
3adaa11
docs: Tidy comments
ebma Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 44 additions & 18 deletions contracts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

# Bootstrap Safe that becomes vault admin (accepts via vault.acceptAdmin()).
# Changeable later via transferAdmin; handed to the Timelock at phase 5.
# Create the Safe on this chain first: the script refuses an address that is
# not a Safe (no code, an EIP-7702 delegated EOA) and a Safe whose threshold
# (getThreshold()) is below 2.
ADMIN_SAFE=
# Fast pause guardian (small-threshold Safe). Can pause but NOT unpause, so a
# compromised guardian can only halt, never release. Its signers must hold no
Expand All @@ -21,7 +24,8 @@ ATTESTOR_2=
ATTESTOR_3=
ATTESTOR_4=

# PERMANENT. Max issuance in 18-decimal units. Decision D3: 150M PEN.
# PERMANENT. Max issuance in 18-decimal units. Decision D3: 150M PEN. The
# script refuses any other value (Deploy.s.sol EXPECTED_MAX_ISSUANCE).
MAX_ISSUANCE=150000000000000000000000000

# Caps in 18-decimal units. Set equal to each other on purpose: a release
Expand All @@ -37,10 +41,12 @@ MAX_ISSUANCE=150000000000000000000000000
PER_RELEASE_CAP=1000000000000000000000000
DAILY_CAP=1000000000000000000000000

# PERMANENT. Unix timestamp before which the remainder CANNOT be swept. This is
# a floor on the earliest a sweep could happen, not a deadline for holders:
# closing the window is a separate governance decision and can be deferred
# indefinitely.
# PERMANENT. Unix timestamp in SECONDS before which the remainder CANNOT be
# swept; the script refuses a value less than 30 days after the deploy block
# (2027-03-01 below passes for any deploy up to 2027-01-30) or more than two
# years ahead (a milliseconds value lands far beyond that). This is a floor on
# the earliest a sweep could happen, not a deadline for holders: closing the
# window is a separate governance decision and can be deferred indefinitely.
#
# Deliberately set beyond the ~3-month window we intend to advertise: a later
# floor costs nothing operationally (the remainder simply waits in the vault,
Expand All @@ -53,22 +59,42 @@ DAILY_CAP=1000000000000000000000000
# 1803859200 = 2027-03-01 00:00 UTC
EARLIEST_SWEEP_TS=1803859200

# Testnet drills and local runs only: TEST_DEPLOY=true admits an ADMIN_SAFE
# that is not a Safe and an EARLIEST_SWEEP_TS less than 30 days ahead. Refused
# on Base mainnet; leave it unset for production.
# TEST_DEPLOY=

# --- DeployGovernance.s.sol (phase 5) ---
PEN_TOKEN=
TIMELOCK_DELAY=172800 # 48h (PRD V5)
VOTING_DELAY=86400 # 1 day, seconds (timestamp clock)
VOTING_PERIOD=432000 # 5 days
PROPOSAL_THRESHOLD= # token units required to propose
# The script checks every value below before broadcasting.
PEN_TOKEN= # must be the token of VAULT_ADDRESS
VAULT_ADDRESS= # the MigrationVault deployed above
TIMELOCK_DELAY=172800 # 48h (PRD V5); seconds, 48h to 30 days
VOTING_DELAY=86400 # 1 day, seconds (timestamp clock), 1h to 30 days
VOTING_PERIOD=432000 # 5 days, seconds, 1 to 30 days
# 18-decimal token units required to propose, NOT whole PEN: the script
# refuses anything below 1 PEN (1e18) or above the total supply.
PROPOSAL_THRESHOLD=
# Percent of CIRCULATING supply (total minus the vault's unmigrated balance,
# which setToken parks at the vote sink), counting For+Abstain
# votes actually cast. Bounded below by QUORUM_FLOOR.
# votes actually cast. Bounded below by QUORUM_FLOOR. 1 to 100; the script
# refuses 0, which would leave quorum at the floor for good.
QUORUM_FRACTION=2
# Absolute quorum floor, 18-decimal token units. Decide this before phase 5 —
# there is no safe default and the script refuses to run without it. Size it
# so quorum is reachable soon after launch, or no proposal (an unpause
# included) can pass.
# PERMANENT (immutable in the governor). Absolute quorum floor, 18-decimal
# token units, NOT whole PEN: the script refuses anything below 1 PEN (1e18)
# or above the total supply. Decide this before phase 5 — there is no safe
# default and the script refuses to run without it. Size it so quorum is
# reachable soon after launch, or no proposal (an unpause included) can pass.
QUORUM_FLOOR=
# Strongly recommended: a multisig granted CANCELLER_ROLE on the timelock, so a
# queued operation can still be vetoed during the 48h delay (OZ Governor alone
# lets only the proposer cancel, and only before voting starts).
# Required: a dedicated canceller Safe, separate from the guardian, granted
# CANCELLER_ROLE on the timelock so a queued operation can still be vetoed
# during the 48h delay (OZ Governor alone lets only the proposer cancel, and
# only before voting starts). Create the Safe on this chain first: the script
# refuses to run without it, with an address that is not a Safe, with a Safe
# whose threshold (getThreshold()) is below 2, or with the deployer,
# PEN_TOKEN, VAULT_ADDRESS or the vault's guardian.
TIMELOCK_CANCELLER=
# Testnet drills only: TEST_DEPLOY=true admits a shorter TIMELOCK_DELAY,
# VOTING_DELAY and VOTING_PERIOD, a TIMELOCK_CANCELLER that is not a Safe or
# is the guardian, QUORUM_FRACTION=0 and QUORUM_FLOOR=0. Refused on Base
# mainnet; leave it unset for production.
# TEST_DEPLOY=
51 changes: 44 additions & 7 deletions contracts/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Script, console} from "forge-std/Script.sol";
import {PEN} from "../src/PEN.sol";
import {MigrationVault} from "../src/MigrationVault.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {requireMultisigSafe} from "./SafeCheck.sol";

/// @notice Deploys the migration stack on Base (PRD rollout phase 3):
/// 1. MigrationVault with the deployer as interim admin
Expand All @@ -14,35 +15,71 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// must call acceptAdmin() to complete)
///
/// Environment:
/// ADMIN_SAFE bootstrap Safe that becomes vault admin
/// ADMIN_SAFE bootstrap Safe that becomes vault admin; must be a
/// Safe on this chain with a threshold of at least 2
/// (getThreshold(); no EIP-7702 delegated EOA)
/// GUARDIAN_SAFE fast pause guardian
/// ATTESTOR_1..4 attestor transaction-sender addresses (D4: 3-of-4)
/// MAX_ISSUANCE max issuance in 18-decimal units (decision D3)
/// MAX_ISSUANCE max issuance in 18-decimal units (decision D3);
/// must equal EXPECTED_MAX_ISSUANCE
/// PER_RELEASE_CAP initial per-release cap, 18-decimal units
/// DAILY_CAP initial daily cap, 18-decimal units
/// EARLIEST_SWEEP_TS unix timestamp before which no remainder sweep (D5)
/// EARLIEST_SWEEP_TS unix timestamp in SECONDS before which no remainder
/// sweep (D5); at least MIN_SWEEP_FLOOR_AHEAD after
/// the deploy block and at most MAX_SWEEP_FLOOR_AHEAD
/// TEST_DEPLOY optional, testnet drills and local runs only: allows
/// an ADMIN_SAFE that is not a Safe and an
/// EARLIEST_SWEEP_TS any time in the future. Refused
/// on Base mainnet.
contract Deploy is Script {
uint256 internal constant BASE_MAINNET = 8453;
// 12-decimal pallet amounts -> 18-decimal token amounts (decision D2).
uint256 internal constant CONVERSION_FACTOR = 1e6;
uint256 internal constant THRESHOLD = 3;
// MAX_ISSUANCE and EARLIEST_SWEEP_TS are permanent once deployed, so the
// script checks them instead of trusting the environment.
// Decision D3: 150M PEN.
uint256 internal constant EXPECTED_MAX_ISSUANCE = 150_000_000e18;
// A sweep floor further out than this is a units slip (milliseconds land
// ~1000x further) or a typo, not a decision.
uint256 internal constant MAX_SWEEP_FLOOR_AHEAD = 2 * 365 days;
// A sweep floor closer than this is a drill value, not a migration window.
uint256 internal constant MIN_SWEEP_FLOOR_AHEAD = 30 days;

function run() external {
function run() external returns (PEN pen, MigrationVault vault) {
bool testDeploy = vm.envOr("TEST_DEPLOY", false);
require(!testDeploy || block.chainid != BASE_MAINNET, "TEST_DEPLOY is refused on Base mainnet");

// The bootstrap admin holds every vault setting until governance takes
// over, so it must be a Safe, not a single key.
address adminSafe = vm.envAddress("ADMIN_SAFE");
if (!testDeploy) requireMultisigSafe(adminSafe, "ADMIN_SAFE");
address guardianSafe = vm.envAddress("GUARDIAN_SAFE");
uint256 maxIssuance = vm.envUint("MAX_ISSUANCE");
uint256 perReleaseCap = vm.envUint("PER_RELEASE_CAP");
uint256 dailyCap = vm.envUint("DAILY_CAP");
uint256 earliestSweepTs = vm.envUint("EARLIEST_SWEEP_TS");
require(maxIssuance == EXPECTED_MAX_ISSUANCE, "MAX_ISSUANCE must be 150M PEN in 18-decimal units");
require(
earliestSweepTs > block.timestamp && earliestSweepTs <= block.timestamp + MAX_SWEEP_FLOOR_AHEAD,
"EARLIEST_SWEEP_TS must be a future unix time in seconds, at most two years ahead"
);
require(
earliestSweepTs >= block.timestamp + MIN_SWEEP_FLOOR_AHEAD || testDeploy,
"EARLIEST_SWEEP_TS is less than 30 days after the deploy block"
);

address[] memory attestors = new address[](4);
attestors[0] = vm.envAddress("ATTESTOR_1");
attestors[1] = vm.envAddress("ATTESTOR_2");
attestors[2] = vm.envAddress("ATTESTOR_3");
attestors[3] = vm.envAddress("ATTESTOR_4");

vm.startBroadcast();
// Broadcast as msg.sender (forge sets it to --sender or the single
// signer), the address the interim admin role below is given to.
vm.startBroadcast(msg.sender);

MigrationVault vault = new MigrationVault(
vault = new MigrationVault(
msg.sender, // interim admin for setToken; handed over below
guardianSafe,
attestors,
Expand All @@ -52,7 +89,7 @@ contract Deploy is Script {
dailyCap,
earliestSweepTs
);
PEN pen = new PEN(address(vault), maxIssuance);
pen = new PEN(address(vault), maxIssuance);
vault.setToken(IERC20(address(pen)));
vault.transferAdmin(adminSafe);

Expand Down
Loading
Loading