Skip to content

Commit

Permalink
Add dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
anikaraghu committed Feb 23, 2024
1 parent b03b25a commit a25a211
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 66 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ clean-lib:
.PHONY: forge-deps
forge-deps:
forge install --no-git github.com/foundry-rs/forge-std \
github.com/OpenZeppelin/openzeppelin-contracts@v4.7.3 \
github.com/OpenZeppelin/openzeppelin-contracts@v4.9.3 \
github.com/OpenZeppelin/openzeppelin-contracts-upgradeable@v4.7.3 \
github.com/rari-capital/solmate@8f9b23f8838670afda0fd8983f2c41e8037ae6bc \
github.com/Saw-mon-and-Natalie/clones-with-immutable-args@105efee1b9127ed7f6fedf139e1fc796ce8791f2
github.com/Saw-mon-and-Natalie/clones-with-immutable-args@105efee1b9127ed7f6fedf139e1fc796ce8791f2 \
github.com/Vectorized/solady@862a0afd3e66917f50e987e91886b9b90c4018a1

.PHONY: checkout-op-commit
checkout-op-commit:
Expand Down
10 changes: 5 additions & 5 deletions mainnet/2024-02-21-setup-smart-escrow/.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
OPTIMISM_RPC_URL=
OPTIMISM_RPC_URL=https://mainnet.optimism.io

OP_COMMIT=3580bf1b41d80fcb2b895d5610836bfad27fc989
BASE_CONTRACTS_COMMIT=3a566fcc0e01535cf93dbcef6704640cbde222aa
BASE_CONTRACTS_COMMIT=a147139671c09923f78ae46a6ebedc91209bb076

OP_TOKEN=0x4200000000000000000000000000000000000042

DEPLOYER=0xbebe472f467888b197b90693b8852ad12a50b261
BENEFACTOR=XXX
BENEFACTOR= # TODO
BENEFICIARY=0x07114fF6F815113729b579B4A233192BAEF0e0E18
BENEFACTOR_OWNER=0x2501c477D0A35545a387Aa4A3EEe4292A9a8B3F0
BENEFICIARY_OWNER=0x6e1DFd5C1E22A4677663A81D24C6BA03561ef0f6
Expand All @@ -17,7 +17,7 @@ VESTING_PERIOD_SECONDS=7889400
INITIAL_TOKENS=17895697
VESTING_EVENT_TOKENS=4473924

SMART_ESCROW_CONTRACT=TODO
SMART_ESCROW_CONTRACT= # TODO
COLLAB_GRANT_TOKENS=107374177
UPFRONT_GRANT_TOKENS=10737418
CB_GOVERNANCE_WALLET=
CB_GOVERNANCE_WALLET= # TODO
8 changes: 3 additions & 5 deletions mainnet/2024-02-21-setup-smart-escrow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ include .env
deploy-new-implementations:
forge script --rpc-url $(OPTIMISM_RPC_URL) DeploySmartEscrow



##
# TODO: fill in the following commands for the transfer token task
##

.PHONY: sign
sign:
$(GOPATH)/bin/eip712sign --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" -- \
forge script --rpc-url $(OPTIMISM_RPC_URL) TransferOPTokens \
forge script --rpc-url $(OPTIMISM_RPC_URL) TransferAndDelegateOPTokens \
--sig "sign(address)" $(SIGNER_SAFE_ADDR)

.PHONY: approve
approve:
forge script --rpc-url $(OPTIMISM_RPC_URL) TransferOPTokens \
forge script --rpc-url $(OPTIMISM_RPC_URL) TransferAndDelegateOPTokens \
--sig "approve(address,bytes)" $(SIGNER_SAFE_ADDR) $(SIGNATURES) \
--ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0"

.PHONY: execute
execute:
forge script --rpc-url $(OPTIMISM_RPC_URL) TransferOPTokens \
forge script --rpc-url $(OPTIMISM_RPC_URL) TransferAndDelegateOPTokens \
--sig "run()" --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0"
5 changes: 3 additions & 2 deletions mainnet/2024-02-21-setup-smart-escrow/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ broadcast = 'records'
fs_permissions = [ {access = "read-write", path = "./"} ]
optimizer = true
optimizer_runs = 999999
solc_version = "0.8.15"
solc_version = "0.8.19"
via-ir = true
remappings = [
'@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/',
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
'@rari-capital/solmate/=lib/solmate/',
'@base-contracts/=lib/base-contracts'
'@base-contracts/=lib/base-contracts',
'@agora=lib/optimism-gov/src',
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import "@base-contracts/src/smart-escrow/SmartEscrow.sol";


contract DeploySmartEscrow is Script {
address internal DEPLOYER = vm.envAddress("DEPLOYER");
address internal BENEFACTOR = vm.envAddress("BENEFACTOR");
address internal BENEFICIARY = vm.envAddress("BENEFICIARY");
address internal BENEFACTOR_OWNER = vm.envAddress("BENEFACTOR_OWNER");
address internal BENEFICIARY_OWNER = vm.envAddress("BENEFICIARY_OWNER");
address internal ESCROW_OWNER = vm.envAddress("NESTED_SAFE");
uint256 internal START = vm.envUint256("START");
uint256 internal END = vm.envUint256("END");
uint256 internal VESTING_PERIOD_SECONDS = vm.envUint256("VESTING_PERIOD_SECONDS");
uint256 internal INITIAL_TOKENS = vm.envUint256("INITIAL_TOKENS");
uint256 internal VESTING_EVENT_TOKENS = vm.envUint256("VESTING_EVENT_TOKENS");
uint256 internal START = vm.envUint("START");
uint256 internal END = vm.envUint("END");
uint256 internal VESTING_PERIOD_SECONDS = vm.envUint("VESTING_PERIOD_SECONDS");
uint256 internal INITIAL_TOKENS = vm.envUint("INITIAL_TOKENS");
uint256 internal VESTING_EVENT_TOKENS = vm.envUint("VESTING_EVENT_TOKENS");

function run() public {
vm.broadcast(deployer);
vm.broadcast(DEPLOYER);
SmartEscrow smartEscrow = new SmartEscrow(
BENEFACTOR,
BENEFICIARY,
Expand All @@ -31,14 +32,14 @@ contract DeploySmartEscrow is Script {
INITIAL_TOKENS,
VESTING_EVENT_TOKENS
);
require(smartEscrow.start() = START);
require(smartEscrow.end() = END);
require(smartEscrow.vestingPeriod() = VESTING_PERIOD_SECONDS);
require(smartEscrow.initialTokens() = INITIAL_TOKENS);
require(smartEscrow.vestingEventTokens() = VESTING_EVENT_TOKENS);
require(smartEscrow.benefactor() = BENEFATOR);
require(smartEscrow.beneficiary() = BENEFICIARY);
require(smartEscrow.released() = 0);
require(smartEscrow.contractTerminated() = false);
require(smartEscrow.start() == START, "DeploySmartEscrow: start time not set correctly");
require(smartEscrow.end() == END, "DeploySmartEscrow: end time not set correctly");
require(smartEscrow.vestingPeriod() == VESTING_PERIOD_SECONDS, "DeploySmartEscrow: vesting period not set correctly");
require(smartEscrow.initialTokens() == INITIAL_TOKENS, "DeploySmartEscrow: number of initial tokens not set correctly");
require(smartEscrow.vestingEventTokens() == VESTING_EVENT_TOKENS, "DeploySmartEscrow: number of vesting event tokens not set correctly");
require(smartEscrow.benefactor() == BENEFACTOR, "DeploySmartEscrow: benefactor not set correctly");
require(smartEscrow.beneficiary() == BENEFICIARY, "DeploySmartEscrow: beneficiary not set correctly");
require(smartEscrow.released() == 0, "DeploySmartEscrow: initial released value non zero");
require(smartEscrow.contractTerminated() == false, "DeploySmartEscrow: contract cannot initially be terminated");
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
pragma solidity 0.8.19;

import "@base-contracts/script/universal/NestedMultisigBuilder.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
import "@agora/structs/RulesV3.sol";
import "@agora/structs/AllowanceType.sol";
import "@agora/alligator/AlligatorOP_V5.sol";
// import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";

contract TransferOPTokens is NestedMultisigBuilder {

contract TransferAndDelegateOPTokens is NestedMultisigBuilder {
using SafeERC20 for IERC20;
using ERC20Votes for IERC20;
// using ERC20Votes for IERC20;

address constant internal NESTED_SAFE = vm.envAddress("NESTED_SAFE");
IERC20 public constant OP_TOKEN = IERC20(vm.envAddress("OP_TOKEN"));
address public constant SMART_ESCROW = vm.envAddress("SMART_ESCROW_CONTRACT");
address public constant ALLIGATOR_PROXY = vm.envAddress("ALLIGATOR_PROXY"); // Agora address which will allow for subdeletation
address public constant CB_GOVERNANCE_WALLET = vm.envAddress("CB_GOVERNANCE_WALLET");
address internal NESTED_SAFE = vm.envAddress("NESTED_SAFE");
IERC20 internal OP_TOKEN = IERC20(vm.envAddress("OP_TOKEN"));
address internal SMART_ESCROW = vm.envAddress("SMART_ESCROW_CONTRACT");
address internal ALLIGATOR_PROXY = vm.envAddress("ALLIGATOR_PROXY"); // Agora address which will allow for subdeletation
address internal CB_GOVERNANCE_WALLET = vm.envAddress("CB_GOVERNANCE_WALLET");

uint256 public constant COLLAB_GRANT_TOKENS = vm.envUint256("COLLAB_GRANT_TOKENS");
uint256 public constant UPFRONT_GRANT_TOKENS = vm.envUint256("UPFRONT_GRANT_TOKENS");
uint256 internal COLLAB_GRANT_TOKENS = vm.envUint("COLLAB_GRANT_TOKENS");
uint256 internal UPFRONT_GRANT_TOKENS = vm.envUint("UPFRONT_GRANT_TOKENS");

function _postCheck() internal override view {
// TODO
Expand All @@ -30,26 +32,23 @@ contract TransferOPTokens is NestedMultisigBuilder {

// Transfer collaboration grant tokens to smart escrow
calls[0] = IMulticall3.Call3({
target: OP_TOKEN,
target: address(OP_TOKEN),
allowFailure: false,
callData: abi.encodeCall(
token.safeTransferFrom(address, address, uint256);
NESTED_SAFE,
SMART_ESCROW,
COLLAB_GRANT_TOKENS
this.transferOPTokens, ()
)
});
// Delegate governance tokens for initial grant to Agora's Alligator proxy, which will allow for subdelegations
calls[1] = IMulticall3.Call3({
target: OP_TOKEN,
target: address(OP_TOKEN),
allowFailure: false,
callData: abi.encodeCall(
delegate(address),
ALLIGATOR_PROXY
ERC20Votes.delegate,
(ALLIGATOR_PROXY)
)
});

SubdelegationRules subdelegationRules = SubdelegationRules({
SubdelegationRules memory subdelegationRules = SubdelegationRules({
maxRedelegations: 2,
blocksBeforeVoteCloses: 0,
notValidBefore: 0,
Expand All @@ -64,16 +63,20 @@ contract TransferOPTokens is NestedMultisigBuilder {
target: ALLIGATOR_PROXY,
allowFailure: false,
callData: abi.encodeCall(
subdelegate(address, SubdelegationRules),
CB_GOVERNANCE_WALLET,
subdelegationRules
AlligatorOPV5.subdelegate,
(CB_GOVERNANCE_WALLET,
subdelegationRules)
)
});

return calls;
}

function transferOPTokens() public {
OP_TOKEN.safeTransfer(SMART_ESCROW, COLLAB_GRANT_TOKENS);
}

function _ownerSafe() internal override view returns (address) {
return NESTED_SAFE;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
pragma solidity 0.8.19;

import "@base-contracts/script/universal/NestedMultisigBuilder.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand All @@ -8,10 +8,10 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract TransferOPTokens is NestedMultisigBuilder {
using SafeERC20 for IERC20;

address constant internal NESTED_SAFE = vm.envAddress("NESTED_SAFE");
IERC20 public constant OP_TOKEN = IERC20(vm.envAddress("OP_TOKEN"));
address public constant BENEFICIARY = vm.envAddress("BENEFICIARY");
uint256 public constant UPFRONT_GRANT_TOKENS = vm.envUint256("UPFRONT_GRANT_TOKENS");
address internal NESTED_SAFE = vm.envAddress("NESTED_SAFE");
IERC20 public OP_TOKEN = IERC20(vm.envAddress("OP_TOKEN"));
address public BENEFICIARY = vm.envAddress("BENEFICIARY");
uint256 public UPFRONT_GRANT_TOKENS = vm.envUint("UPFRONT_GRANT_TOKENS");

function _postCheck() internal override view {
// TODO
Expand All @@ -22,19 +22,20 @@ contract TransferOPTokens is NestedMultisigBuilder {

// Transfer upfront grant tokens when they vest
calls[0] = IMulticall3.Call3({
target: OP_TOKEN,
target: address(OP_TOKEN),
allowFailure: false,
callData: abi.encodeCall(
token.safeTransferFrom(address, address, uint256);
NESTED_SAFE,
BENEFICIARY,
UPFRONT_GRANT_TOKENS // or maybe just the whole balance?
this.transferOPTokens, ()
)
});

return calls;
}

function transferOPTokens() public {
OP_TOKEN.safeTransfer(BENEFICIARY, UPFRONT_GRANT_TOKENS); // or maybe just the whole balance?
}

function _ownerSafe() internal override view returns (address) {
return NESTED_SAFE;
}
Expand Down
3 changes: 2 additions & 1 deletion setup-templates/template-deploy/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ remappings = [
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
'@rari-capital/solmate/=lib/solmate/',
'@base-contracts/=lib/base-contracts'
'@base-contracts/=lib/base-contracts',
'solady/=lib/solady/src/'
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
3 changes: 2 additions & 1 deletion setup-templates/template-generic/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ remappings = [
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
'@rari-capital/solmate/=lib/solmate/',
'@base-contracts/=lib/base-contracts'
'@base-contracts/=lib/base-contracts',
'solady/=lib/solady/src/'
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
3 changes: 2 additions & 1 deletion setup-templates/template-incident/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ remappings = [
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',
'@rari-capital/solmate/=lib/solmate/',
'@base-contracts/=lib/base-contracts'
'@base-contracts/=lib/base-contracts',
'solady/=lib/solady/src/'
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config

0 comments on commit a25a211

Please sign in to comment.