Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
da66781
wip: feat: re-enable other options and fix contract sizes
Detoo Oct 23, 2025
6d0cc97
wip: feat: create MetaVestDeal library
Detoo Oct 23, 2025
960c016
wip: feat: create MetaVesTControllerStorage
Detoo Oct 23, 2025
10d7a99
wip: feat: first successfully contract size reduction
Detoo Oct 24, 2025
372cc3c
wip: feat: more aggressive external library logic
Detoo Oct 24, 2025
3e305bd
wip: feat: more aggressive external library logic with error code lookup
Detoo Oct 24, 2025
26d23e9
fix: msg.sig on external modifiers
Detoo Oct 26, 2025
e10a8f8
wip: feat: re-enable factories for token options and restricted tokens
Detoo Oct 26, 2025
971f857
wip: test: re-enable tests for token options and restricted tokens
Detoo Oct 26, 2025
7b22f37
test: distinguish vesting token from payment token
Detoo Oct 26, 2025
f8d87b6
test: re-enable tests for token options and restricted tokens (contd)
Detoo Oct 26, 2025
350ee12
fix: add extra parties verification. Allow external agreement signing…
Detoo Oct 27, 2025
f8b0944
fix: unify metavest type reporting
Detoo Oct 27, 2025
e09926d
feat: TokenOption and RestrictedToken to support recipient. Remove du…
Detoo Oct 27, 2025
25b7357
chore: simplify utility functions for testing
Detoo Oct 27, 2025
4292915
test: re-enable more TokenOption and RestrictedToken tests
Detoo Oct 27, 2025
df54c6f
chore: update README
Detoo Oct 27, 2025
5e503ef
wip: feat: add MetaVesTControllerFactory
Detoo Oct 31, 2025
3bc2eef
chore: remove unnecessary patch for pre-v5 openzeppelin
Detoo Nov 1, 2025
856d5e4
wip: feat: consolidate all metavest types creation into MetaVesTContr…
Detoo Nov 3, 2025
140029e
fix: contract sizes
Detoo Nov 3, 2025
0510241
chore: minor refactoring
Detoo Nov 6, 2025
c2531a9
chore: refactor and remove the unnecessary event restrictions
Detoo Dec 11, 2025
b4d6fa1
chore: cherry-pick test setup improvement from another branch
Detoo Dec 12, 2025
df2fcde
feat: MetavestControllerFactory to provide address pre-compute. More …
Detoo Dec 12, 2025
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ out/
test-command.txt
broadcast/
.DS_Store
foundry.toml
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,7 @@ forge script scripts/proposeAllGuardiansMetavestDeals.s.sol --rpc-url <your-targ

To run tests:
```bash
forge test --via-ir --fork-url <your-target-network-rpc> -vvv
# Excluding acceptance tests because deployment may have not happened yet
# Use Ethereum mainnet RPC for tests because YearnBorgCompensation integration tests depends on it
forge test --via-ir --fork-url <eth-mainnet-rpc> -vvv --nmc YearnBorgCompensationAcceptanceTest
```
4 changes: 4 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[fmt]
sort_imports = true

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 0 additions & 1 deletion scripts/createAllTemplates.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {CyberAgreementRegistry} from "cybercorps-contracts/src/CyberAgreementReg
import {ERC1967Proxy} from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";

Expand Down
1 change: 0 additions & 1 deletion scripts/createSafeTx.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.s
import {IZkCappedMinterV2} from "../src/interfaces/zk-governance/IZkCappedMinterV2.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";

Expand Down
7 changes: 3 additions & 4 deletions scripts/deployYearnBorgCompensation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {ERC1967Proxy} from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy.so
import {ERC20} from "openzeppelin-contracts/token/ERC20/ERC20.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";

Expand Down Expand Up @@ -47,23 +46,23 @@ contract DeployYearnBorgCompensationScript is SafeTxHelper, Script {
console2.log("Salt string: ", saltStr);
console2.log("Guardian Safe: ", address(config.borgSafe));
console2.log("CyberAgreementRegistry: ", address(config.registry));
console2.log("VestingAllocationFactory: ", address(config.vestingAllocationFactory));
console2.log("MetavestControllerFactory: ", address(config.metavestControllerFactory));
console2.log("");

bytes32 salt = keccak256(bytes(saltStr));

vm.startBroadcast(deployerPrivateKey);

// Deploy MetaVesT Controller

// TODO fixme: next time use MetavestControllerFactory to deploy the controller
metavestController controller = metavestController(address(new ERC1967Proxy{salt: salt}(
address(new metavestController{salt: salt}()),
abi.encodeWithSelector(
metavestController.initialize.selector,
address(config.borgSafe),
address(config.borgSafe),
address(config.registry),
address(config.vestingAllocationFactory)
address(config.metavestControllerFactory)
)
)));

Expand Down
22 changes: 17 additions & 5 deletions scripts/deployYearnBorgCompensationPrerequisites.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {CyberAgreementRegistry} from "cybercorps-contracts/src/CyberAgreementReg
import {ERC1967Proxy} from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {MetaVesTControllerFactory} from "../src/MetaVesTControllerFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";

Expand Down Expand Up @@ -37,14 +37,18 @@ contract DeployYearnBorgCompensationPrerequisitesScript is SafeTxHelper, Script
string memory saltStr,
YearnBorgCompensation2025_2026.Config memory config
) public virtual returns(
VestingAllocationFactory
MetaVesTControllerFactory
) {
address deployer = vm.addr(deployerPrivateKey);

BorgAuth auth = config.registry.AUTH();

console2.log("");
console2.log("=== DeployYearnBorgCompensationPrerequisitesScript ===");
console2.log("Deployer: ", deployer);
console2.log("Salt string: ", saltStr);
console2.log("CyberAgreementRegistry: ", address(config.registry));
console2.log("Auth: ", address(auth));
console2.log("");

bytes32 salt = keccak256(bytes(saltStr));
Expand All @@ -53,16 +57,24 @@ contract DeployYearnBorgCompensationPrerequisitesScript is SafeTxHelper, Script

// Deploy MetaVesT pre-requisites

VestingAllocationFactory vestingAllocationFactory = new VestingAllocationFactory{salt: salt}();
MetaVesTControllerFactory metavestControllerFactory = MetaVesTControllerFactory(address(new ERC1967Proxy{salt: salt}(
address(new MetaVesTControllerFactory{salt: salt}()),
abi.encodeWithSelector(
MetaVesTControllerFactory.initialize.selector,
address(auth),
address(config.registry),
new metavestController{salt: salt}()
)
)));

vm.stopBroadcast();

// Output logs

console2.log("Deployed addresses:");
console2.log(" VestingAllocationFactory: ", address(vestingAllocationFactory));
console2.log(" MetaVesTControllerFactory: ", address(metavestControllerFactory));
console2.log("");

return vestingAllocationFactory;
return metavestControllerFactory;
}
}
1 change: 0 additions & 1 deletion scripts/executeSafeTx.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {ZkCappedMinterV2} from "zk-governance/l2-contracts/src/ZkCappedMinterV2.
import {IZkCappedMinterV2Factory} from "../src/interfaces/zk-governance/IZkCappedMinterV2Factory.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";

Expand Down
6 changes: 3 additions & 3 deletions scripts/lib/YearnBorgCompensation2025_2026.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {CommonBase} from "forge-std/Base.sol";
import {CyberAgreementRegistry} from "cybercorps-contracts/src/CyberAgreementRegistry.sol";
import {IGnosisSafe} from "../../test/lib/safe.sol";
import {BaseAllocation} from "../../src/BaseAllocation.sol";
import {VestingAllocationFactory} from "../../src/VestingAllocationFactory.sol";
import {metavestController} from "../../src/MetaVesTController.sol";
import {MetaVesTControllerFactory} from "../../src/MetaVesTControllerFactory.sol";

library YearnBorgCompensation2025_2026 {

Expand All @@ -27,7 +27,7 @@ library YearnBorgCompensation2025_2026 {

IGnosisSafe metalexSafe;
CyberAgreementRegistry registry;
VestingAllocationFactory vestingAllocationFactory;
MetaVesTControllerFactory metavestControllerFactory;
metavestController controller;

// Yearn BORG Director Compensation Agreement (one template per director for now)
Expand Down Expand Up @@ -81,7 +81,7 @@ library YearnBorgCompensation2025_2026 {

metalexSafe: metalexSafe,
registry: CyberAgreementRegistry(0xa9E808B8eCBB60Bb19abF026B5b863215BC4c134),
vestingAllocationFactory: VestingAllocationFactory(0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF), // TODO TBD
metavestControllerFactory: MetaVesTControllerFactory(0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF), // TODO TBD
controller: metavestController(0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF), // TODO TBD

// Yearn BORG Compensation Agreement
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/YearnBorgCompensationSepolia2025_2026.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {CommonBase} from "forge-std/Base.sol";
import {CyberAgreementRegistry} from "cybercorps-contracts/src/CyberAgreementRegistry.sol";
import {IGnosisSafe} from "../../test/lib/safe.sol";
import {BaseAllocation} from "../../src/BaseAllocation.sol";
import {VestingAllocationFactory} from "../../src/VestingAllocationFactory.sol";
import {MetaVesTControllerFactory} from "../../src/MetaVesTControllerFactory.sol";
import {metavestController} from "../../src/MetaVesTController.sol";
import {YearnBorgCompensation2025_2026} from "./YearnBorgCompensation2025_2026.sol";

Expand Down Expand Up @@ -35,7 +35,7 @@ library YearnBorgCompensationSepolia2025_2026 {

metalexSafe: metalexSafe,
registry: CyberAgreementRegistry(0xa9E808B8eCBB60Bb19abF026B5b863215BC4c134),
vestingAllocationFactory: VestingAllocationFactory(0x87dC5e3FBFE8B5F2B74C64eE34da8bdc9fedCb0f),
metavestControllerFactory: MetaVesTControllerFactory(0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF), // TODO TBD
controller: metavestController(0xFa5Ab18bD5E02B1d6430e91C32C5CB5e7F43bB65),

// Yearn BORG Compensation Agreement
Expand Down
3 changes: 1 addition & 2 deletions scripts/proposeAllGuardiansMetavestDeals.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {ISafeProxyFactory, IGnosisSafe} from "../test/lib/safe.sol";
import {ProposeMetaVestDealScript} from "./proposeMetavestDeal.s.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {YearnBorgCompensation2025_2026} from "./lib/YearnBorgCompensation2025_2026.sol";
import {YearnBorgCompensationSepolia2025_2026} from "./lib/YearnBorgCompensationSepolia2025_2026.sol";
import {console2} from "forge-std/console2.sol";
Expand Down Expand Up @@ -49,7 +48,7 @@ contract ProposeAllGuardiansMetaVestDealScript is ProposeMetaVestDealScript {
console2.log("=== ProposeAllGuardiansMetaVestDealScript ===");
console2.log("Proposer: ", proposer);
console2.log("CyberAgreementRegistry: ", address(config.registry));
console2.log("VestingAllocationFactory: ", address(config.vestingAllocationFactory));
console2.log("MetavestControllerFactory: ", address(config.metavestControllerFactory));
console2.log("MetavesTController: ", address(config.controller));
console2.log("");

Expand Down
14 changes: 8 additions & 6 deletions scripts/proposeMetavestDeal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import {ISafeProxyFactory, IGnosisSafe} from "../test/lib/safe.sol";
import {CyberAgreementUtils} from "./lib/CyberAgreementUtils.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";
import {MetaVestDealLib, MetaVestDeal} from "../src/lib/MetaVestDealLib.sol";

contract ProposeMetaVestDealScript is SafeTxHelper, Script {
using MetaVestDealLib for MetaVestDeal;
using YearnBorgCompensation2025_2026 for YearnBorgCompensation2025_2026.Config;

/// @dev For running from `forge script`. Provide the deployer private key through env var.
Expand Down Expand Up @@ -67,7 +68,7 @@ contract ProposeMetaVestDealScript is SafeTxHelper, Script {
console2.log("Guardian Safe: ", address(config.borgSafe));
console2.log("Payment token: ", address(config.paymentToken));
console2.log("CyberAgreementRegistry: ", address(config.registry));
console2.log("VestingAllocationFactory: ", address(config.vestingAllocationFactory));
console2.log("MetavestControllerFactory: ", address(config.metavestControllerFactory));
console2.log("MetavesTController: ", address(config.controller));
console2.log("");

Expand Down Expand Up @@ -104,10 +105,11 @@ contract ProposeMetaVestDealScript is SafeTxHelper, Script {
bytes32 contractId = config.controller.proposeAndSignDeal(
guardianInfo.compTemplate.id,
agreementSalt,
metavestController.metavestType.Vesting,
guardianInfo.partyInfo.evmAddress,
allocation,
config.milestones,
MetaVestDealLib.draft().setVesting(
guardianInfo.partyInfo.evmAddress,
allocation,
config.milestones
),
globalValues,
parties,
partyValues,
Expand Down
1 change: 0 additions & 1 deletion scripts/signDealAndCreateMetavest.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {ERC1967Proxy} from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy.so
import {ISafeProxyFactory, IGnosisSafe} from "../test/lib/safe.sol";
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {console2} from "forge-std/console2.sol";
import {metavestController} from "../src/MetaVesTController.sol";

Expand Down
1 change: 0 additions & 1 deletion scripts/voidAgreement.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {IZkCappedMinterV2Factory} from "../src/interfaces/zk-governance/IZkCappe
import {SafeTxHelper} from "./lib/SafeTxHelper.sol";
import {CyberAgreementUtils} from "./lib/CyberAgreementUtils.sol";
import {Script} from "forge-std/Script.sol";
import {VestingAllocationFactory} from "../src/VestingAllocationFactory.sol";
import {ZkCappedMinterV2} from "zk-governance/l2-contracts/src/ZkCappedMinterV2.sol";
import {ZkTokenV2} from "zk-governance/l2-contracts/src/ZkTokenV2.sol";
import {console2} from "forge-std/console2.sol";
Expand Down
4 changes: 3 additions & 1 deletion src/BaseAllocation.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.28;

import {MetaVestType} from "./lib/MetaVestDealLib.sol";

/// @notice interface to a MetaLeX condition contract
/// @dev see https://github.com/MetaLex-Tech/BORG-CORE/tree/main/src/libs/conditions
interface IConditionM {
Expand Down Expand Up @@ -190,7 +192,7 @@ abstract contract BaseAllocation is ReentrancyGuard, SafeTransferLib{
govType = GovType.vested;
}

function getVestingType() external view virtual returns (uint256);
function getVestingType() external view virtual returns (MetaVestType);
function getGoverningPower() external virtual returns (uint256);
function updateStopTimes(uint48 _shortStopTime) external virtual;// onlyController;
function terminate() external virtual;// onlyController;
Expand Down
Loading