Skip to content

Commit

Permalink
Rename CeloUnreleasedTreasure to CeloUnreleasedTreasury (#11220)
Browse files Browse the repository at this point in the history
* updated `CeloUnrealeasedTreasure` to `CeloUnreleasedTreasury`

* update `CeloUnreleasedTreasury` initial balance to use defined constant
  • Loading branch information
soloseng authored Sep 23, 2024
1 parent 02454f4 commit cac4a13
Show file tree
Hide file tree
Showing 33 changed files with 125 additions and 125 deletions.
4 changes: 2 additions & 2 deletions packages/protocol/contractPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const SOLIDITY_08_PACKAGE = {
contracts: [
'GasPriceMinimum',
'FeeCurrencyDirectory',
'CeloUnreleasedTreasure',
'CeloUnreleasedTreasury',
'Validators',
'EpochManager',
'EpochManagerEnabler',
Expand All @@ -61,7 +61,7 @@ export const SOLIDITY_08_PACKAGE = {
'GasPriceMinimumProxy',
'FeeCurrencyDirectoryProxy',
'MentoFeeCurrencyAdapterV1',
'CeloUnreleasedTreasureProxy',
'CeloUnreleasedTreasuryProxy',
'ValidatorsProxy',
'EpochManagerProxy',
'EpochManagerEnablerProxy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import "./UsingRegistry.sol";
import "../common/IsL2Check.sol";

import "../../contracts/common/Initializable.sol";
import "./interfaces/ICeloUnreleasedTreasureInitializer.sol";
import "./interfaces/ICeloUnreleasedTreasuryInitializer.sol";

/**
* @title Contract for unreleased Celo tokens.
*/
contract CeloUnreleasedTreasure is UsingRegistry, ReentrancyGuard, Initializable, IsL2Check {
contract CeloUnreleasedTreasury is UsingRegistry, ReentrancyGuard, Initializable, IsL2Check {
event Released(address indexed to, uint256 amount);

modifier onlyEpochManager() {
Expand All @@ -31,7 +31,7 @@ contract CeloUnreleasedTreasure is UsingRegistry, ReentrancyGuard, Initializable
constructor(bool test) public Initializable(test) {}

/**
* @notice A constructor for initialising a new instance of a CeloUnreleasedTreasure contract.
* @notice A constructor for initialising a new instance of a CeloUnreleasedTreasury contract.
* @param registryAddress The address of the registry core smart contract.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts-0.8/common/EpochManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ contract EpochManager is
address[] memory firstElected
) external onlyEpochManagerEnabler {
require(
getCeloToken().balanceOf(registry.getAddressForOrDie(CELO_UNRELEASED_TREASURE_REGISTRY_ID)) >
getCeloToken().balanceOf(registry.getAddressForOrDie(CELO_UNRELEASED_TREASURY_REGISTRY_ID)) >
0,
"CeloUnreleasedTreasury not yet funded."
);
Expand Down Expand Up @@ -232,11 +232,11 @@ contract EpochManager is

delete processedGroups[groups[i]];
}
getCeloUnreleasedTreasure().release(
getCeloUnreleasedTreasury().release(
registry.getAddressForOrDie(GOVERNANCE_REGISTRY_ID),
epochProcessing.totalRewardsCommunity
);
getCeloUnreleasedTreasure().release(
getCeloUnreleasedTreasury().release(
getEpochRewards().carbonOffsettingPartner(),
epochProcessing.totalRewardsCarbonFund
);
Expand Down Expand Up @@ -406,7 +406,7 @@ contract EpochManager is
);

uint256 CELOequivalent = (numerator * totalRewards) / denominator;
getCeloUnreleasedTreasure().release(
getCeloUnreleasedTreasury().release(
registry.getAddressForOrDie(RESERVE_REGISTRY_ID),
CELOequivalent
);
Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/contracts-0.8/common/UsingRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "../../contracts/common/interfaces/IRegistry.sol";
import "../../contracts/common/interfaces/IAccounts.sol";
import "../../contracts/common/interfaces/IEpochManager.sol";
import "../../contracts/common/interfaces/IFreezer.sol";
import "../../contracts/common/interfaces/ICeloUnreleasedTreasure.sol";
import "../../contracts/common/interfaces/ICeloUnreleasedTreasury.sol";
import "../../contracts/common/interfaces/IFeeCurrencyWhitelist.sol";
import "../../contracts/common/interfaces/IFeeHandlerSeller.sol";
import "../../contracts/common/interfaces/IEpochManager.sol";
Expand Down Expand Up @@ -52,8 +52,8 @@ contract UsingRegistry is Ownable {
keccak256(abi.encodePacked("MentoFeeHandlerSeller"));
bytes32 constant CELO_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("CeloToken"));
bytes32 constant LOCKED_CELO_REGISTRY_ID = keccak256(abi.encodePacked("LockedCelo"));
bytes32 constant CELO_UNRELEASED_TREASURE_REGISTRY_ID =
keccak256(abi.encodePacked("CeloUnreleasedTreasure"));
bytes32 constant CELO_UNRELEASED_TREASURY_REGISTRY_ID =
keccak256(abi.encodePacked("CeloUnreleasedTreasury"));
bytes32 constant EPOCH_MANAGER_ENABLER_REGISTRY_ID =
keccak256(abi.encodePacked("EpochManagerEnabler"));
bytes32 constant EPOCH_MANAGER_REGISTRY_ID = keccak256(abi.encodePacked("EpochManager"));
Expand Down Expand Up @@ -141,9 +141,9 @@ contract UsingRegistry is Ownable {
return IGovernance(registry.getAddressForOrDie(GOVERNANCE_REGISTRY_ID));
}

function getCeloUnreleasedTreasure() internal view returns (ICeloUnreleasedTreasure) {
function getCeloUnreleasedTreasury() internal view returns (ICeloUnreleasedTreasury) {
return
ICeloUnreleasedTreasure(registry.getAddressForOrDie(CELO_UNRELEASED_TREASURE_REGISTRY_ID));
ICeloUnreleasedTreasury(registry.getAddressForOrDie(CELO_UNRELEASED_TREASURY_REGISTRY_ID));
}

function getEpochManager() internal view returns (IEpochManager) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;

interface ICeloUnreleasedTreasureInitializer {
interface ICeloUnreleasedTreasuryInitializer {
function initialize(address registryAddress) external;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pragma solidity >=0.8.0 <0.9.0;
// solhint-disable no-unused-vars

import "../../../contracts/common/interfaces/ICeloUnreleasedTreasure.sol";
import "../../../contracts/common/interfaces/ICeloUnreleasedTreasury.sol";
import "../UsingRegistry.sol";

/**
* @title A mock CeloUnreleasedTreasure for testing.
* @title A mock CeloUnreleasedTreasury for testing.
*/
contract MockCeloUnreleasedTreasure is ICeloUnreleasedTreasure, UsingRegistry {
contract MockCeloUnreleasedTreasury is ICeloUnreleasedTreasury, UsingRegistry {
function release(address to, uint256 amount) external {
require(address(this).balance >= amount, "Insufficient balance.");
require(getCeloToken().transfer(to, amount), "CELO transfer failed.");
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/common/GoldToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "./Initializable.sol";
import "./interfaces/ICeloToken.sol";
import "./interfaces/ICeloTokenInitializer.sol";
import "./interfaces/ICeloVersionedContract.sol";
import "./interfaces/ICeloUnreleasedTreasure.sol";
import "./interfaces/ICeloUnreleasedTreasury.sol";
import "../../contracts-0.8/common/IsL2Check.sol";

contract GoldToken is
Expand Down Expand Up @@ -271,7 +271,7 @@ contract GoldToken is
function allocatedSupply() public view returns (uint256) {
if (isL2()) {
return
CELO_SUPPLY_CAP - registry.getAddressForOrDie(CELO_UNRELEASED_TREASURE_REGISTRY_ID).balance;
CELO_SUPPLY_CAP - registry.getAddressForOrDie(CELO_UNRELEASED_TREASURY_REGISTRY_ID).balance;
} else {
return totalSupply();
}
Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/contracts/common/UsingRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "./interfaces/IEpochManager.sol";
import "./interfaces/IFeeCurrencyWhitelist.sol";
import "./interfaces/IFreezer.sol";
import "./interfaces/IRegistry.sol";
import "./interfaces/ICeloUnreleasedTreasure.sol";
import "./interfaces/ICeloUnreleasedTreasury.sol";

import "../governance/interfaces/IElection.sol";
import "../governance/interfaces/IEpochRewards.sol";
Expand Down Expand Up @@ -51,8 +51,8 @@ contract UsingRegistry is Ownable {

bytes32 constant CELO_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("CeloToken"));
bytes32 constant LOCKED_CELO_REGISTRY_ID = keccak256(abi.encodePacked("LockedCelo"));
bytes32 constant CELO_UNRELEASED_TREASURE_REGISTRY_ID =
keccak256(abi.encodePacked("CeloUnreleasedTreasure"));
bytes32 constant CELO_UNRELEASED_TREASURY_REGISTRY_ID =
keccak256(abi.encodePacked("CeloUnreleasedTreasury"));
bytes32 constant EPOCH_REWARDS_REGISTRY_ID = keccak256(abi.encodePacked("EpochRewards"));
bytes32 constant EPOCH_MANAGER_ENABLER_REGISTRY_ID =
keccak256(abi.encodePacked("EpochManagerEnabler"));
Expand Down Expand Up @@ -145,9 +145,9 @@ contract UsingRegistry is Ownable {
return IValidators(registry.getAddressForOrDie(VALIDATORS_REGISTRY_ID));
}

function getCeloUnreleasedTreasure() internal view returns (ICeloUnreleasedTreasure) {
function getCeloUnreleasedTreasury() internal view returns (ICeloUnreleasedTreasury) {
return
ICeloUnreleasedTreasure(registry.getAddressForOrDie(CELO_UNRELEASED_TREASURE_REGISTRY_ID));
ICeloUnreleasedTreasury(registry.getAddressForOrDie(CELO_UNRELEASED_TREASURY_REGISTRY_ID));
}

function getEpochRewards() internal view returns (IEpochRewards) {
Expand Down
12 changes: 6 additions & 6 deletions packages/protocol/contracts/common/UsingRegistryV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "./interfaces/IEpochManager.sol";
import "./interfaces/IFeeCurrencyWhitelist.sol";
import "./interfaces/IFreezer.sol";
import "./interfaces/IRegistry.sol";
import "./interfaces/ICeloUnreleasedTreasure.sol";
import "./interfaces/ICeloUnreleasedTreasury.sol";

import "../governance/interfaces/IElection.sol";
import "../governance/interfaces/IEpochRewards.sol";
Expand Down Expand Up @@ -61,8 +61,8 @@ contract UsingRegistryV2 {
bytes32 internal constant STABLE_REAL_TOKEN_REGISTRY_ID =
keccak256(abi.encodePacked("StableTokenBRL"));
bytes32 internal constant VALIDATORS_REGISTRY_ID = keccak256(abi.encodePacked("Validators"));
bytes32 internal constant CELO_UNRELEASED_TREASURE_REGISTRY_ID =
keccak256(abi.encodePacked("CeloUnreleasedTreasure"));
bytes32 internal constant CELO_UNRELEASED_TREASURY_REGISTRY_ID =
keccak256(abi.encodePacked("CeloUnreleasedTreasury"));

bytes32 internal constant CELO_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("CeloToken"));
bytes32 internal constant LOCKED_CELO_REGISTRY_ID = keccak256(abi.encodePacked("LockedCelo"));
Expand Down Expand Up @@ -182,10 +182,10 @@ contract UsingRegistryV2 {
return IValidators(registryContract.getAddressForOrDie(VALIDATORS_REGISTRY_ID));
}

function getCeloUnreleasedTreasure() internal view returns (ICeloUnreleasedTreasure) {
function getCeloUnreleasedTreasury() internal view returns (ICeloUnreleasedTreasury) {
return
ICeloUnreleasedTreasure(
registryContract.getAddressForOrDie(CELO_UNRELEASED_TREASURE_REGISTRY_ID)
ICeloUnreleasedTreasury(
registryContract.getAddressForOrDie(CELO_UNRELEASED_TREASURY_REGISTRY_ID)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;

interface ICeloUnreleasedTreasure {
interface ICeloUnreleasedTreasury {
/**
* @notice Releases the Celo to the specified address.
* @param to The address to release the amount to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pragma solidity ^0.5.13;
import "../Proxy.sol";

/* solhint-disable-next-line no-empty-blocks */
contract CeloUnreleasedTreasureProxy is Proxy {}
contract CeloUnreleasedTreasuryProxy is Proxy {}
2 changes: 1 addition & 1 deletion packages/protocol/lib/registry-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export enum CeloContractName {
GrandaMento = 'GrandaMento',
LockedGold = 'LockedGold',
LockedCelo = 'LockedCelo',
CeloUnreleasedTreasure = 'CeloUnreleasedTreasure',
CeloUnreleasedTreasury = 'CeloUnreleasedTreasury',
OdisPayments = 'OdisPayments',
Random = 'Random',
Reserve = 'Reserve',
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/migrations_sol/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Starts a new anvil devchain serving at localhost (default port 8546).
You can now run commands against the local devchain. For example:

```sh
# Call `isL2()` on `CeloUnreleasedTreasure.sol`
# Call `isL2()` on `CeloUnreleasedTreasury.sol`
cast call \
0xA16cF67AFa80BB9Ce7a325597F80057c6B290fD4 \
"isL2()(bool)" \
Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/migrations_sol/Migration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import "@celo-contracts/stability/interfaces/ISortedOracles.sol";
// Core contract imports on Solidity 0.8
import "@celo-contracts-8/common/interfaces/IFeeCurrencyDirectoryInitializer.sol";
import "@celo-contracts-8/common/interfaces/IGasPriceMinimumInitializer.sol";
import "@celo-contracts-8/common/interfaces/ICeloUnreleasedTreasureInitializer.sol";
import "@celo-contracts-8/common/interfaces/ICeloUnreleasedTreasuryInitializer.sol";
import "@celo-contracts-8/common/interfaces/IEpochManagerEnablerInitializer.sol";
import "@celo-contracts-8/common/interfaces/IEpochManagerInitializer.sol";
import "@celo-contracts-8/common/interfaces/IScoreManagerInitializer.sol";
Expand Down Expand Up @@ -239,7 +239,7 @@ contract Migration is Script, UsingRegistry, MigrationsConstants {
migrateUniswapFeeHandlerSeller();
migrateFeeHandler(json);
migrateOdisPayments();
migrateCeloUnreleasedTreasure();
migrateCeloUnreleasedTreasury();
migrateEpochManagerEnabler();
migrateEpochManager(json);
migrateScoreManager();
Expand Down Expand Up @@ -935,11 +935,11 @@ contract Migration is Script, UsingRegistry, MigrationsConstants {
);
}

function migrateCeloUnreleasedTreasure() public {
function migrateCeloUnreleasedTreasury() public {
deployProxiedContract(
"CeloUnreleasedTreasure",
"CeloUnreleasedTreasury",
abi.encodeWithSelector(
ICeloUnreleasedTreasureInitializer.initialize.selector,
ICeloUnreleasedTreasuryInitializer.initialize.selector,
REGISTRY_ADDRESS
)
);
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/migrations_sol/MigrationL2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract MigrationL2 is Script, MigrationsConstants, UsingRegistry {
vm.startBroadcast(DEPLOYER_ACCOUNT);

setupUsingRegistry();
dealToCeloUnreleasedTreasure();
dealToCeloUnreleasedTreasury();

initializeEpochManagerSystem();

Expand All @@ -32,8 +32,8 @@ contract MigrationL2 is Script, MigrationsConstants, UsingRegistry {
setRegistry(REGISTRY_ADDRESS);
}

function dealToCeloUnreleasedTreasure() public {
vm.deal(address(getCeloUnreleasedTreasure()), 1_000_000 ether);
function dealToCeloUnreleasedTreasury() public {
vm.deal(address(getCeloUnreleasedTreasury()), L2_INITIAL_STASH_BALANCE);
}

function initializeEpochManagerSystem() public {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/migrations_sol/constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract MigrationsConstants is TestConstants {
string[27] contractsInRegistry = [
"Accounts",
"BlockchainParameters",
"CeloUnreleasedTreasure",
"CeloUnreleasedTreasury",
"CeloToken",
"DoubleSigningSlasher",
"DowntimeSlasher",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getDeployedProxiedContract,
} from '@celo/protocol/lib/web3-utils'
import { RegistryInstance } from '@celo/protocol/types'
import { CeloUnreleasedTreasureInstance } from 'types/08'
import { CeloUnreleasedTreasuryInstance } from '@celo/protocol/types/08'
import { SOLIDITY_08_PACKAGE } from '../contractPackages'

const initializeArgs = async (): Promise<[string]> => {
Expand All @@ -15,10 +15,10 @@ const initializeArgs = async (): Promise<[string]> => {
return [registry.address]
}

module.exports = deploymentForCoreContract<CeloUnreleasedTreasureInstance>(
module.exports = deploymentForCoreContract<CeloUnreleasedTreasuryInstance>(
web3,
artifacts,
CeloContractName.CeloUnreleasedTreasure,
CeloContractName.CeloUnreleasedTreasury,
initializeArgs,
undefined,
SOLIDITY_08_PACKAGE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CeloUnreleasedTreasure": ["0x000000000000000000000000000000000000ce10"],
"CeloUnreleasedTreasury": ["0x000000000000000000000000000000000000ce10"],
"EpochManager": ["0x000000000000000000000000000000000000ce10", 86400],
"EpochManagerEnabler": ["0x000000000000000000000000000000000000ce10"],
"ScoreManager": [],
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/scripts/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ProxyContracts = [
'RegistryProxy',
'SortedOraclesProxy',
'UniswapFeeHandlerSellerProxy',
'CeloUnreleasedTreasureProxy',
'CeloUnreleasedTreasuryProxy',
]

export const CoreContracts = [
Expand All @@ -52,7 +52,7 @@ export const CoreContracts = [
'MultiSig',
'Registry',
'Freezer',
'CeloUnreleasedTreasure',
'CeloUnreleasedTreasury',

// governance
'Election',
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/scripts/foundry/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export CARBON_OFFSETTING_FRACTION="10000000000000000000" # 0.001 in fixidity for
export REGISTRY_STORAGE_LOCATION="0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103" # Position is bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1);
GOLD_TOKEN_CELO_SUPPLY_CAP=1000000000 # `GoldToken.CELO_SUPPLY_CAP()`
GOLD_TOKEN_TOTAL_SUPPLY=700000000 # Arbitrary amount chosen to be approximately equal to `GoldToken.totalSupply()` on the L1 Mainnet (695,313,643 CELO as of this commit).
export CELO_UNRELEASED_TREASURE_INITIAL_BALANCE="$(($GOLD_TOKEN_CELO_SUPPLY_CAP - $GOLD_TOKEN_TOTAL_SUPPLY))" # During the real L2 genesis, the VM will calculate and set an appropriate balance.
export CELO_UNRELEASED_TREASURY_INITIAL_BALANCE="$(($GOLD_TOKEN_CELO_SUPPLY_CAP - $GOLD_TOKEN_TOTAL_SUPPLY))" # During the real L2 genesis, the VM will calculate and set an appropriate balance.

# Contract libraries
export LIBRARIES_PATH=("contracts/common/linkedlists/AddressSortedLinkedListWithMedian.sol:AddressSortedLinkedListWithMedian"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ cast rpc anvil_setCode \
--rpc-url $ANVIL_RPC_URL

# Fetch address of Celo distribution
CELO_UNRELEASED_TREASURE_ADDRESS=$(
CELO_UNRELEASED_TREASURY_ADDRESS=$(
cast call \
$REGISTRY_ADDRESS \
"getAddressForStringOrDie(string calldata identifier)(address)" \
"CeloUnreleasedTreasure" \
"CeloUnreleasedTreasury" \
--rpc-url $ANVIL_RPC_URL
)

# Set the balance of the CeloUnreleasedTreasure (like the Celo client would do during L2 genesis)
# Note: This can't be done from the migration script, because CeloUnreleasedTreasure.sol does not
# Set the balance of the CeloUnreleasedTreasury (like the Celo client would do during L2 genesis)
# Note: This can't be done from the migration script, because CeloUnreleasedTreasury.sol does not
# implement the receive function nor does it allow ERC20 transfers. This is the only way I
# managed to give the CeloUnreleasedTreasure a balance.
echo "Setting CeloUnreleasedTreasure balance..."
HEX_CELO_UNRELEASED_TREASURE_INITIAL_BALANCE=$(cast to-hex $CELO_UNRELEASED_TREASURE_INITIAL_BALANCE"000000000000000000")
# managed to give the CeloUnreleasedTreasury a balance.
echo "Setting CeloUnreleasedTreasury balance..."
HEX_CELO_UNRELEASED_TREASURY_INITIAL_BALANCE=$(cast to-hex $CELO_UNRELEASED_TREASURY_INITIAL_BALANCE"000000000000000000")
cast rpc \
anvil_setBalance \
$CELO_UNRELEASED_TREASURE_ADDRESS $HEX_CELO_UNRELEASED_TREASURE_INITIAL_BALANCE \
$CELO_UNRELEASED_TREASURY_ADDRESS $HEX_CELO_UNRELEASED_TREASURY_INITIAL_BALANCE \
--rpc-url $ANVIL_RPC_URL

# Run L2 migrations
Expand Down
Loading

0 comments on commit cac4a13

Please sign in to comment.