Skip to content

Commit

Permalink
feat: multiple allowed cash tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
deluca-mike committed Nov 23, 2023
1 parent d89083c commit fb95e7d
Show file tree
Hide file tree
Showing 26 changed files with 442 additions and 93 deletions.
70 changes: 65 additions & 5 deletions abi/DualGovernor.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
"name": "registrar_",
"type": "address"
},
{
"internalType": "address",
"name": "cashToken_",
"type": "address"
},
{
"internalType": "address",
"name": "powerToken_",
Expand All @@ -26,6 +21,11 @@
"name": "vault_",
"type": "address"
},
{
"internalType": "address[]",
"name": "allowedCashTokens_",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "proposalFee_",
Expand Down Expand Up @@ -76,6 +76,11 @@
"name": "InvalidCalldatasLength",
"type": "error"
},
{
"inputs": [],
"name": "InvalidCashToken",
"type": "error"
},
{
"inputs": [],
"name": "InvalidPowerTokenAddress",
Expand Down Expand Up @@ -126,6 +131,11 @@
"name": "MalleableSignature",
"type": "error"
},
{
"inputs": [],
"name": "NoAllowedCashTokens",
"type": "error"
},
{
"inputs": [],
"name": "NotSelf",
Expand Down Expand Up @@ -220,6 +230,19 @@
"name": "ZeroVaultAddress",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "cashToken",
"type": "address"
}
],
"name": "CashTokenSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -1056,6 +1079,25 @@
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "token_",
"type": "address"
}
],
"name": "isAllowedCashToken",
"outputs": [
{
"internalType": "bool",
"name": "isAllowed_",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "markEpochActive",
Expand Down Expand Up @@ -1338,6 +1380,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newCashToken_",
"type": "address"
},
{
"internalType": "uint256",
"name": "newProposalFee_",
"type": "uint256"
}
],
"name": "setCashToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
41 changes: 39 additions & 2 deletions abi/DualGovernorDeployer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"internalType": "address",
"name": "zeroToken_",
"type": "address"
},
{
"internalType": "address[]",
"name": "allowedCashTokens_",
"type": "address[]"
}
],
"stateMutability": "nonpayable",
Expand All @@ -25,6 +30,11 @@
"name": "CallerIsNotRegistrar",
"type": "error"
},
{
"inputs": [],
"name": "ZeroCashTokenAddress",
"type": "error"
},
{
"inputs": [],
"name": "ZeroRegistrarAddress",
Expand All @@ -40,13 +50,40 @@
"name": "ZeroZeroTokenAddress",
"type": "error"
},
{
"inputs": [],
"name": "allowedCashTokens",
"outputs": [
{
"internalType": "address[]",
"name": "tokens_",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "index_",
"type": "uint256"
}
],
"name": "allowedCashTokensAt",
"outputs": [
{
"internalType": "address",
"name": "cashToken_",
"name": "token_",
"type": "address"
},
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "powerToken_",
Expand Down
13 changes: 13 additions & 0 deletions abi/PowerToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "nextCashToken_",
"type": "address"
}
],
"name": "setNextCashToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
Expand Down
5 changes: 0 additions & 5 deletions abi/Registrar.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
"internalType": "address",
"name": "bootstrapToken_",
"type": "address"
},
{
"internalType": "address",
"name": "cashToken_",
"type": "address"
}
],
"stateMutability": "nonpayable",
Expand Down
2 changes: 1 addition & 1 deletion bytecode/DualGovernor.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bytecode/DualGovernorDeployer.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bytecode/PowerToken.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bytecode/PowerTokenDeployer.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bytecode/Registrar.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ pragma solidity 0.8.21;
import { DeployBase } from "./DeployBase.s.sol";

contract Deploy is DeployBase {
// NOTE: Ensure this is the correct cash token address (current mainnet WETH).
address internal constant _CASH_TOKEN = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // WETH
// NOTE: Ensure these are the correct cash token addresses.
address[] internal _ALLOWED_CASH_TOKENS = [
address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) // mainnet WETH
];

// NOTE: Ensure this is the current nonce (transaction count) of the deploying address.
uint256 internal constant _DEPLOYER_NONCE = 0;
Expand All @@ -30,7 +32,7 @@ contract Deploy is DeployBase {
_initialPowerBalances,
_initialZeroAccounts,
_initialZeroBalances,
_CASH_TOKEN
_ALLOWED_CASH_TOKENS
);
}
}
26 changes: 16 additions & 10 deletions script/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.21;

import { Script, console } from "../lib/forge-std/src/Script.sol";
import { Script, console2 } from "../lib/forge-std/src/Script.sol";

import { IDualGovernor } from "../src/interfaces/IDualGovernor.sol";
import { IRegistrar } from "../src/interfaces/IRegistrar.sol";
Expand All @@ -23,9 +23,9 @@ contract DeployBase is Script {
uint256[] memory initialPowerBalances_,
address[] memory initialZeroAccounts_,
uint256[] memory initialZeroBalances_,
address cashToken_
address[] memory allowedCashTokens_
) public returns (address registrar_) {
console.log("deployer: ", deployer_);
console2.log("deployer: ", deployer_);

// ZeroToken needs registrar address.
// DistributionVault needs zeroToken address.
Expand All @@ -39,21 +39,27 @@ contract DeployBase is Script {
vm.startBroadcast(deployer_);

address zeroToken_ = address(new ZeroToken(expectedRegistrar_, initialZeroAccounts_, initialZeroBalances_));

address vault_ = address(new DistributionVault(zeroToken_));
address governorDeployer_ = address(new DualGovernorDeployer(expectedRegistrar_, vault_, zeroToken_));

address governorDeployer_ = address(
new DualGovernorDeployer(expectedRegistrar_, vault_, zeroToken_, allowedCashTokens_)
);

address powerTokenDeployer_ = address(new PowerTokenDeployer(expectedRegistrar_, vault_));

address bootstrapToken_ = address(new PowerBootstrapToken(initialPowerAccounts_, initialPowerBalances_));

registrar_ = address(new Registrar(governorDeployer_, powerTokenDeployer_, bootstrapToken_, cashToken_));
registrar_ = address(new Registrar(governorDeployer_, powerTokenDeployer_, bootstrapToken_));

vm.stopBroadcast();

address governor_ = IRegistrar(registrar_).governor();

console.log("Zero Token Address:", zeroToken_);
console.log("Distribution Vault Address:", vault_);
console.log("Registrar address:", registrar_);
console.log("DualGovernor Address:", governor_);
console.log("Power Token Address:", IDualGovernor(governor_).powerToken());
console2.log("Zero Token Address:", zeroToken_);
console2.log("Distribution Vault Address:", vault_);
console2.log("Registrar address:", registrar_);
console2.log("DualGovernor Address:", governor_);
console2.log("Power Token Address:", IDualGovernor(governor_).powerToken());
}
}
Loading

0 comments on commit fb95e7d

Please sign in to comment.