diff --git a/packages/protocol/contractPackages.ts b/packages/protocol/contractPackages.ts index ac7e96deb20..53db83815e7 100644 --- a/packages/protocol/contractPackages.ts +++ b/packages/protocol/contractPackages.ts @@ -48,12 +48,12 @@ export const SOLIDITY_08_PACKAGE = { proxiesPath: '/', // Proxies are still with 0.5 contracts // Proxies shouldn't have to be added to a list manually // https://github.com/celo-org/celo-monorepo/issues/10555 - contracts: ['GasPriceMinimum', 'FeeCurrencyDirectory', 'MintGoldSchedule'], + contracts: ['GasPriceMinimum', 'FeeCurrencyDirectory', 'MintCeloSchedule'], proxyContracts: [ 'GasPriceMinimumProxy', 'FeeCurrencyDirectoryProxy', 'MentoFeeCurrencyAdapterV1', - 'MintGoldScheduleProxy', + 'MintCeloScheduleProxy', ], truffleConfig: 'truffle-config0.8.js', } satisfies ContractPackage diff --git a/packages/protocol/contracts-0.8/common/MintGoldSchedule.sol b/packages/protocol/contracts-0.8/common/MintCeloSchedule.sol similarity index 88% rename from packages/protocol/contracts-0.8/common/MintGoldSchedule.sol rename to packages/protocol/contracts-0.8/common/MintCeloSchedule.sol index e423cf40b1d..4f508dc7575 100644 --- a/packages/protocol/contracts-0.8/common/MintGoldSchedule.sol +++ b/packages/protocol/contracts-0.8/common/MintCeloSchedule.sol @@ -14,11 +14,11 @@ import "../../contracts-0.8/common/interfaces/IGoldToken.sol"; /** * @title Contract for minting new CELO token based on a schedule. */ -contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2Check { +contract MintCeloSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2Check { using FixidityLib for FixidityLib.Fraction; - uint256 constant GENESIS_GOLD_SUPPLY = 600000000 ether; // 600 million Gold - uint256 constant GOLD_SUPPLY_CAP = 1000000000 ether; // 1 billion Gold + uint256 constant GENESIS_CELO_SUPPLY = 600000000 ether; // 600 million Celo + uint256 constant CELO_SUPPLY_CAP = 1000000000 ether; // 1 billion CELO uint256 constant YEARS_LINEAR = 15; uint256 constant SECONDS_LINEAR = YEARS_LINEAR * 365 * 1 days; @@ -49,7 +49,7 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 constructor(bool test) public Initializable(test) {} /** - * @notice A constructor for initialising a new instance of a MintGoldSchedule contract. + * @notice A constructor for initialising a new instance of a MintCeloSchedule contract. */ function initialize() external initializer { _transferOwnership(msg.sender); @@ -87,27 +87,27 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 */ function mintAccordingToSchedule() external nonReentrant onlyL2 returns (bool) { ( - uint256 targetGoldTotalSupply, + uint256 targetCeloTotalSupply, uint256 communityRewardFundMintAmount, uint256 carbonOffsettingPartnerMintAmount - ) = getTargetGoldTotalSupply(); + ) = getTargetCeloTotalSupply(); uint256 mintableAmount = Math.min( getRemainingBalanceToMint(), - targetGoldTotalSupply - getGoldToken().totalSupply() + targetCeloTotalSupply - getGoldToken().totalSupply() ); require(mintableAmount > 0, "Mintable amount must be greater than zero"); totalMintedBySchedule += mintableAmount; - IGoldToken goldToken = IGoldToken(address(getGoldToken())); + IGoldToken celoToken = IGoldToken(address(getGoldToken())); require( - goldToken.mint(communityRewardFund, communityRewardFundMintAmount), + celoToken.mint(communityRewardFund, communityRewardFundMintAmount), "Failed to mint to community partner." ); require( - goldToken.mint(carbonOffsettingPartner, carbonOffsettingPartnerMintAmount), + celoToken.mint(carbonOffsettingPartner, carbonOffsettingPartnerMintAmount), "Failed to mint to carbon offsetting partner." ); return true; @@ -204,11 +204,11 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 * @return The remaining CELO balance to mint. */ function getRemainingBalanceToMint() public view returns (uint256) { - return GOLD_SUPPLY_CAP - getGoldToken().totalSupply(); + return CELO_SUPPLY_CAP - getGoldToken().totalSupply(); } /** - * @return The total balance minted by the MintGoldSchedule contract. + * @return The total balance minted by the MintCeloSchedule contract. */ function getTotalMintedBySchedule() public view returns (uint256) { return totalMintedBySchedule; @@ -218,22 +218,22 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 * @return The currently mintable amount. */ function getMintableAmount() public view returns (uint256) { - (uint256 targetGoldTotalSupply, , ) = getTargetGoldTotalSupply(); - return targetGoldTotalSupply - getGoldToken().totalSupply(); + (uint256 targetCeloTotalSupply, , ) = getTargetCeloTotalSupply(); + return targetCeloTotalSupply - getGoldToken().totalSupply(); } /** * @notice Returns the target CELO supply according to the target schedule. - * @return targetGoldTotalSupply The target total CELO supply according to the target schedule. + * @return targetCeloTotalSupply The target total CELO supply according to the target schedule. * @return communityTargetRewards The community reward that can be minted according to the target schedule. * @return carbonFundTargetRewards The carbon offsetting reward that can be minted according to the target schedule. */ - function getTargetGoldTotalSupply() + function getTargetCeloTotalSupply() public view whenActivated returns ( - uint256 targetGoldTotalSupply, + uint256 targetCeloTotalSupply, uint256 communityTargetRewards, uint256 carbonFundTargetRewards ) @@ -243,20 +243,20 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 uint256 timeSinceL2Start = block.timestamp - l2StartTime; uint256 totalL2LinearSecondsAvailable = SECONDS_LINEAR - (l2StartTime - GENESIS_START_TIME); - uint256 mintedOnL1 = totalSupplyAtL2Start - GENESIS_GOLD_SUPPLY; + uint256 mintedOnL1 = totalSupplyAtL2Start - GENESIS_CELO_SUPPLY; bool isLinearDistribution = timeSinceL2Start < totalL2LinearSecondsAvailable; if (isLinearDistribution) { ( - targetGoldTotalSupply, + targetCeloTotalSupply, communityTargetRewards, carbonFundTargetRewards ) = _calculateTargetReward(timeSinceL2Start, totalL2LinearSecondsAvailable, mintedOnL1); - return (targetGoldTotalSupply, communityTargetRewards, carbonFundTargetRewards); + return (targetCeloTotalSupply, communityTargetRewards, carbonFundTargetRewards); } else { ( - targetGoldTotalSupply, + targetCeloTotalSupply, communityTargetRewards, carbonFundTargetRewards ) = _calculateTargetReward( @@ -266,12 +266,12 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 ); bool hasNotYetMintedAllLinearRewards = totalMintedBySchedule + - GENESIS_GOLD_SUPPLY + + GENESIS_CELO_SUPPLY + mintedOnL1 < - targetGoldTotalSupply; + targetCeloTotalSupply; if (hasNotYetMintedAllLinearRewards) { - return (targetGoldTotalSupply, communityTargetRewards, carbonFundTargetRewards); + return (targetCeloTotalSupply, communityTargetRewards, carbonFundTargetRewards); } revert("Block reward calculation for years 15-30 unimplemented"); return (0, 0, 0); @@ -286,7 +286,7 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 internal view returns ( - uint256 targetGoldTotalSupply, + uint256 targetCeloTotalSupply, uint256 communityTargetRewards, uint256 carbonFundTargetRewards ) @@ -296,7 +296,7 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 _totalL2LinearSecondsAvailable ); // Pay out half of all block rewards linearly. - uint256 totalLinearRewards = (GOLD_SUPPLY_CAP - GENESIS_GOLD_SUPPLY) / 2; //(200 million) includes validator rewards. + uint256 totalLinearRewards = (CELO_SUPPLY_CAP - GENESIS_CELO_SUPPLY) / 2; //(200 million) includes validator rewards. FixidityLib.Fraction memory l2LinearRewards = FixidityLib.newFixed( totalLinearRewards - _mintedOnL1 @@ -321,10 +321,10 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2 .divide(totalL2LinearSecondsAvailableFraction) .fromFixed(); - targetGoldTotalSupply = + targetCeloTotalSupply = communityTargetRewards + carbonFundTargetRewards + - GENESIS_GOLD_SUPPLY + + GENESIS_CELO_SUPPLY + _mintedOnL1; } } diff --git a/packages/protocol/contracts-0.8/common/interfaces/IGoldToken.sol b/packages/protocol/contracts-0.8/common/interfaces/IGoldToken.sol index aa2f579a7f3..1cd80448148 100644 --- a/packages/protocol/contracts-0.8/common/interfaces/IGoldToken.sol +++ b/packages/protocol/contracts-0.8/common/interfaces/IGoldToken.sol @@ -21,10 +21,10 @@ interface IGoldToken is IERC20 { function setRegistry(address registryAddress) external; /** - * @notice Used set the address of the MintGoldSchedule contract. - * @param goldTokenMintingScheduleAddress The address of the MintGoldSchedule contract. + * @notice Used set the address of the MintCeloSchedule contract. + * @param goldTokenMintingScheduleAddress The address of the MintCeloSchedule contract. */ - function setGoldTokenMintingScheduleAddress(address goldTokenMintingScheduleAddress) external; + function setCeloTokenMintingScheduleAddress(address goldTokenMintingScheduleAddress) external; /** * @dev Mints a new token. diff --git a/packages/protocol/contracts-0.8/common/interfaces/IMintGoldScheduleInitializer.sol b/packages/protocol/contracts-0.8/common/interfaces/IMintCeloScheduleInitializer.sol similarity index 73% rename from packages/protocol/contracts-0.8/common/interfaces/IMintGoldScheduleInitializer.sol rename to packages/protocol/contracts-0.8/common/interfaces/IMintCeloScheduleInitializer.sol index 37d71ed70c0..ac3bab213b0 100644 --- a/packages/protocol/contracts-0.8/common/interfaces/IMintGoldScheduleInitializer.sol +++ b/packages/protocol/contracts-0.8/common/interfaces/IMintCeloScheduleInitializer.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.5.13 <0.9.0; -interface IMintGoldScheduleInitializer { +interface IMintCeloScheduleInitializer { function initialize() external; } diff --git a/packages/protocol/contracts/common/GoldToken.sol b/packages/protocol/contracts/common/GoldToken.sol index f17862f439c..9a8b80a7c29 100644 --- a/packages/protocol/contracts/common/GoldToken.sol +++ b/packages/protocol/contracts/common/GoldToken.sol @@ -9,7 +9,7 @@ import "./CalledByVm.sol"; import "./Initializable.sol"; import "./interfaces/ICeloToken.sol"; import "./interfaces/ICeloVersionedContract.sol"; -import "./interfaces/IMintGoldSchedule.sol"; +import "./interfaces/IMintCeloSchedule.sol"; import "../../contracts-0.8/common/IsL2Check.sol"; contract GoldToken is @@ -37,7 +37,7 @@ contract GoldToken is // Burn address is 0xdEaD because truffle is having buggy behaviour with the zero address address constant BURN_ADDRESS = address(0x000000000000000000000000000000000000dEaD); - IMintGoldSchedule public goldTokenMintingSchedule; + IMintCeloSchedule public celoTokenMintingSchedule; event Transfer(address indexed from, address indexed to, uint256 value); @@ -45,11 +45,11 @@ contract GoldToken is event Approval(address indexed owner, address indexed spender, uint256 value); - event SetGoldTokenMintingScheduleAddress(address indexed newScheduleAddress); + event SetCeloTokenMintingScheduleAddress(address indexed newScheduleAddress); modifier onlySchedule() { if (isL2()) { - require(msg.sender == address(goldTokenMintingSchedule), "Only MintGoldSchedule can call."); + require(msg.sender == address(celoTokenMintingSchedule), "Only MintCeloSchedule can call."); } else { require(msg.sender == address(0), "Only VM can call."); } @@ -73,20 +73,20 @@ contract GoldToken is } /** - * @notice Used set the address of the MintGoldSchedule contract. - * @param goldTokenMintingScheduleAddress The address of the MintGoldSchedule contract. + * @notice Used set the address of the MintCeloSchedule contract. + * @param celoTokenMintingScheduleAddress The address of the MintCeloSchedule contract. */ - function setGoldTokenMintingScheduleAddress( - address goldTokenMintingScheduleAddress + function setCeloTokenMintingScheduleAddress( + address celoTokenMintingScheduleAddress ) external onlyOwner { require( - goldTokenMintingScheduleAddress != address(0) || - goldTokenMintingScheduleAddress != address(goldTokenMintingSchedule), + celoTokenMintingScheduleAddress != address(0) || + celoTokenMintingScheduleAddress != address(celoTokenMintingSchedule), "Invalid address." ); - goldTokenMintingSchedule = IMintGoldSchedule(goldTokenMintingScheduleAddress); + celoTokenMintingSchedule = IMintCeloSchedule(celoTokenMintingScheduleAddress); - emit SetGoldTokenMintingScheduleAddress(goldTokenMintingScheduleAddress); + emit SetCeloTokenMintingScheduleAddress(celoTokenMintingScheduleAddress); } /** diff --git a/packages/protocol/contracts/common/interfaces/IMintGoldSchedule.sol b/packages/protocol/contracts/common/interfaces/IMintCeloSchedule.sol similarity index 64% rename from packages/protocol/contracts/common/interfaces/IMintGoldSchedule.sol rename to packages/protocol/contracts/common/interfaces/IMintCeloSchedule.sol index 64f1eb2cae6..bfc5ace71dc 100644 --- a/packages/protocol/contracts/common/interfaces/IMintGoldSchedule.sol +++ b/packages/protocol/contracts/common/interfaces/IMintCeloSchedule.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.5.13 <0.9.0; -interface IMintGoldSchedule { +interface IMintCeloSchedule { /** * @notice Mints CELO to the beneficiaries according to the predefined schedule. */ @@ -13,8 +13,8 @@ interface IMintGoldSchedule { function getMintableAmount() external returns (uint256); /** - * @notice Returns the target Gold supply according to the target schedule. - * @return The target Gold supply according to the target schedule. + * @notice Returns the target CELO supply according to the target schedule. + * @return The target CELO supply according to the target schedule. */ - function getTargetGoldTotalSupply() external returns (uint256, uint256, uint256); + function getTargetCeloTotalSupply() external returns (uint256, uint256, uint256); } diff --git a/packages/protocol/contracts/common/proxies/MintGoldScheduleProxy.sol b/packages/protocol/contracts/common/proxies/MintCeloScheduleProxy.sol similarity index 69% rename from packages/protocol/contracts/common/proxies/MintGoldScheduleProxy.sol rename to packages/protocol/contracts/common/proxies/MintCeloScheduleProxy.sol index d9be7c6df68..e675dd5faec 100644 --- a/packages/protocol/contracts/common/proxies/MintGoldScheduleProxy.sol +++ b/packages/protocol/contracts/common/proxies/MintCeloScheduleProxy.sol @@ -3,4 +3,4 @@ pragma solidity ^0.5.13; import "../Proxy.sol"; /* solhint-disable-next-line no-empty-blocks */ -contract MintGoldScheduleProxy is Proxy {} +contract MintCeloScheduleProxy is Proxy {} diff --git a/packages/protocol/contracts/governance/EpochRewards.sol b/packages/protocol/contracts/governance/EpochRewards.sol index fc9135e3f39..ec5d98f63b4 100644 --- a/packages/protocol/contracts/governance/EpochRewards.sol +++ b/packages/protocol/contracts/governance/EpochRewards.sol @@ -411,7 +411,7 @@ contract EpochRewards is * @notice Returns the target Gold supply according to the epoch rewards target schedule. * @return The target Gold supply according to the epoch rewards target schedule. */ - function getTargetGoldTotalSupply() public view returns (uint256) { + function getTargetCeloTotalSupply() public view returns (uint256) { uint256 timeSinceInitialization = now.sub(startTime); if (timeSinceInitialization < SECONDS_LINEAR) { // Pay out half of all block rewards linearly. @@ -502,7 +502,7 @@ contract EpochRewards is function _getRewardsMultiplier( uint256 targetGoldSupplyIncrease ) internal view returns (FixidityLib.Fraction memory) { - uint256 targetSupply = getTargetGoldTotalSupply(); + uint256 targetSupply = getTargetCeloTotalSupply(); uint256 totalSupply = getGoldToken().totalSupply(); uint256 remainingSupply = GOLD_SUPPLY_CAP.sub(totalSupply.add(targetGoldSupplyIncrease)); uint256 targetRemainingSupply = GOLD_SUPPLY_CAP.sub(targetSupply); diff --git a/packages/protocol/lib/registry-utils.ts b/packages/protocol/lib/registry-utils.ts index 9b58e47cecd..31b3890ac98 100644 --- a/packages/protocol/lib/registry-utils.ts +++ b/packages/protocol/lib/registry-utils.ts @@ -35,7 +35,7 @@ export enum CeloContractName { GovernanceApproverMultiSig = 'GovernanceApproverMultiSig', GrandaMento = 'GrandaMento', LockedGold = 'LockedGold', - MintGoldSchedule = 'MintGoldSchedule', + MintCeloSchedule = 'MintCeloSchedule', OdisPayments = 'OdisPayments', Random = 'Random', Reserve = 'Reserve', diff --git a/packages/protocol/migrations_sol/Migration.s.sol b/packages/protocol/migrations_sol/Migration.s.sol index d7c4ab31209..7a8bc1405e9 100644 --- a/packages/protocol/migrations_sol/Migration.s.sol +++ b/packages/protocol/migrations_sol/Migration.s.sol @@ -41,7 +41,7 @@ import "@celo-contracts/identity/interfaces/IOdisPaymentsInitializer.sol"; import "@celo-contracts/identity/interfaces/IFederatedAttestationsInitializer.sol"; import "@celo-contracts/stability/interfaces/ISortedOracles.sol"; import "@celo-contracts-8/common/interfaces/IGasPriceMinimumInitializer.sol"; -import "@celo-contracts-8/common/interfaces/IMintGoldScheduleInitializer.sol"; +import "@celo-contracts-8/common/interfaces/IMintCeloScheduleInitializer.sol"; import "@migrations-sol/HelperInterFaces.sol"; import "@openzeppelin/contracts8/utils/math/Math.sol"; @@ -235,7 +235,7 @@ contract Migration is Script, UsingRegistry, Constants { migrateUniswapFeeHandlerSeller(); migrateFeeHandler(json); migrateOdisPayments(); - migrateMintGoldSchedule(); + migrateMintCeloSchedule(); migrateGovernance(json); vm.stopBroadcast(); @@ -907,10 +907,10 @@ contract Migration is Script, UsingRegistry, Constants { ); } - function migrateMintGoldSchedule() public { + function migrateMintCeloSchedule() public { deployProxiedContract( - "MintGoldSchedule", - abi.encodeWithSelector(IMintGoldScheduleInitializer.initialize.selector) + "MintCeloSchedule", + abi.encodeWithSelector(IMintCeloScheduleInitializer.initialize.selector) ); } diff --git a/packages/protocol/migrations_sol/constants.sol b/packages/protocol/migrations_sol/constants.sol index dcdec2c2d3a..70a52be7839 100644 --- a/packages/protocol/migrations_sol/constants.sol +++ b/packages/protocol/migrations_sol/constants.sol @@ -19,7 +19,7 @@ contract Constants { "Governance", "GovernanceSlasher", "LockedGold", - "MintGoldSchedule", + "MintCeloSchedule", "OdisPayments", "Random", "Registry", diff --git a/packages/protocol/migrations_ts/28_mintGoldSchedule.ts b/packages/protocol/migrations_ts/28_mintCeloSchedule.ts similarity index 68% rename from packages/protocol/migrations_ts/28_mintGoldSchedule.ts rename to packages/protocol/migrations_ts/28_mintCeloSchedule.ts index 8dd1f3820dc..622bdb6952a 100644 --- a/packages/protocol/migrations_ts/28_mintGoldSchedule.ts +++ b/packages/protocol/migrations_ts/28_mintCeloSchedule.ts @@ -1,16 +1,16 @@ import { CeloContractName } from '@celo/protocol/lib/registry-utils' import { deploymentForCoreContract } from '@celo/protocol/lib/web3-utils' -import { MintGoldScheduleInstance } from 'types/08' +import { MintCeloScheduleInstance } from 'types/08' import { SOLIDITY_08_PACKAGE } from '../contractPackages' const initializeArgs = async () => { return [] } -module.exports = deploymentForCoreContract( +module.exports = deploymentForCoreContract( web3, artifacts, - CeloContractName.MintGoldSchedule, + CeloContractName.MintCeloSchedule, initializeArgs, undefined, SOLIDITY_08_PACKAGE diff --git a/packages/protocol/releaseData/initializationData/release12.json b/packages/protocol/releaseData/initializationData/release12.json index fada832b995..6f1f459bba5 100644 --- a/packages/protocol/releaseData/initializationData/release12.json +++ b/packages/protocol/releaseData/initializationData/release12.json @@ -1,4 +1,4 @@ { "FeeCurrencyDirectory": [], - "MintGoldSchedule": [] + "MintCeloSchedule": [] } diff --git a/packages/protocol/scripts/consts.ts b/packages/protocol/scripts/consts.ts index 2aed53633ad..33fa0ae453a 100644 --- a/packages/protocol/scripts/consts.ts +++ b/packages/protocol/scripts/consts.ts @@ -35,7 +35,7 @@ export const ProxyContracts = [ 'RegistryProxy', 'SortedOraclesProxy', 'UniswapFeeHandlerSellerProxy', - 'MintGoldScheduleProxy', + 'MintCeloScheduleProxy', ] export const CoreContracts = [ @@ -51,7 +51,7 @@ export const CoreContracts = [ 'MultiSig', 'Registry', 'Freezer', - 'MintGoldSchedule', + 'MintCeloSchedule', // governance 'Election', diff --git a/packages/protocol/test-sol/unit/common/GoldToken.t.sol b/packages/protocol/test-sol/unit/common/GoldToken.t.sol index c422eef35c9..4372a257969 100644 --- a/packages/protocol/test-sol/unit/common/GoldToken.t.sol +++ b/packages/protocol/test-sol/unit/common/GoldToken.t.sol @@ -16,7 +16,7 @@ contract GoldTokenTest is Test, IsL2Check { event Transfer(address indexed from, address indexed to, uint256 value); event TransferComment(string comment); - event SetGoldTokenMintingScheduleAddress(address indexed newScheduleAddress); + event SetCeloTokenMintingScheduleAddress(address indexed newScheduleAddress); modifier _whenL2() { deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress); @@ -28,7 +28,7 @@ contract GoldTokenTest is Test, IsL2Check { goldTokenMintingSchedule = actor("goldTokenMintingSchedule"); vm.prank(goldTokenOwner); goldToken = new GoldToken(true); - deployCodeTo("MintGoldSchedule.sol", abi.encode(false), goldTokenMintingSchedule); + deployCodeTo("MintCeloSchedule.sol", abi.encode(false), goldTokenMintingSchedule); receiver = actor("receiver"); sender = actor("sender"); vm.deal(receiver, ONE_GOLDTOKEN); @@ -216,20 +216,20 @@ contract GoldTokenTest_mint_l2 is GoldTokenTest { function setUp() public _whenL2 { super.setUp(); vm.prank(goldTokenOwner); - goldToken.setGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + goldToken.setCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); } function test_Reverts_whenCalledByOtherThanMintingSchedule() public { vm.prank(address(0)); - vm.expectRevert("Only MintGoldSchedule can call."); + vm.expectRevert("Only MintCeloSchedule can call."); goldToken.mint(receiver, ONE_GOLDTOKEN); vm.prank(address(9)); - vm.expectRevert("Only MintGoldSchedule can call."); + vm.expectRevert("Only MintCeloSchedule can call."); goldToken.mint(receiver, ONE_GOLDTOKEN); vm.prank(goldTokenOwner); - vm.expectRevert("Only MintGoldSchedule can call."); + vm.expectRevert("Only MintCeloSchedule can call."); goldToken.mint(receiver, ONE_GOLDTOKEN); } @@ -257,30 +257,30 @@ contract GoldTokenTest_mint_l2 is GoldTokenTest { } } -contract GoldTokenTest_setGoldTokenMintingScheduleAddress is GoldTokenTest { +contract GoldTokenTest_setCeloTokenMintingScheduleAddress is GoldTokenTest { function test_Reverts_whenCalledByOtherThanL2Governance() public _whenL2 { vm.expectRevert("Ownable: caller is not the owner"); vm.prank(address(0)); - goldToken.setGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + goldToken.setCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); } function test_ShouldSucceedWhenCalledByOwner() public { vm.prank(goldTokenOwner); - goldToken.setGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + goldToken.setCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); - assertEq(address(goldToken.goldTokenMintingSchedule()), goldTokenMintingSchedule); + assertEq(address(goldToken.celoTokenMintingSchedule()), goldTokenMintingSchedule); } function test_ShouldSucceedWhenCalledByL2Governance() public _whenL2 { vm.prank(goldTokenOwner); - goldToken.setGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + goldToken.setCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); - assertEq(address(goldToken.goldTokenMintingSchedule()), goldTokenMintingSchedule); + assertEq(address(goldToken.celoTokenMintingSchedule()), goldTokenMintingSchedule); } - function test_Emits_SetGoldTokenMintingScheduleAddressEvent() public { + function test_Emits_setCeloTokenMintingScheduleAddressEvent() public { vm.expectEmit(true, true, true, true); - emit SetGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + emit SetCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); vm.prank(goldTokenOwner); - goldToken.setGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + goldToken.setCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); } } @@ -307,7 +307,7 @@ contract GoldTokenTest_increaseSupply_l2 is GoldTokenTest { function setUp() public _whenL2 { super.setUp(); vm.prank(goldTokenOwner); - goldToken.setGoldTokenMintingScheduleAddress(goldTokenMintingSchedule); + goldToken.setCeloTokenMintingScheduleAddress(goldTokenMintingSchedule); } function test_Reverts_WhenCalledByAnyone() public { diff --git a/packages/protocol/test-sol/unit/common/MintGoldSchedule.t.sol b/packages/protocol/test-sol/unit/common/MintCeloSchedule.t.sol similarity index 57% rename from packages/protocol/test-sol/unit/common/MintGoldSchedule.t.sol rename to packages/protocol/test-sol/unit/common/MintCeloSchedule.t.sol index 53fe8155d6e..b6f43d1daaf 100644 --- a/packages/protocol/test-sol/unit/common/MintGoldSchedule.t.sol +++ b/packages/protocol/test-sol/unit/common/MintCeloSchedule.t.sol @@ -7,27 +7,27 @@ import "@celo-contracts/common/FixidityLib.sol"; import "@celo-contracts/common/interfaces/IRegistry.sol"; import "@celo-contracts-8/common/interfaces/IGoldToken.sol"; import "@celo-contracts/governance/interfaces/IGovernance.sol"; -import "@celo-contracts-8/common/MintGoldSchedule.sol"; +import "@celo-contracts-8/common/MintCeloSchedule.sol"; import "@celo-contracts-8/common/IsL2Check.sol"; import { Constants } from "@test-sol/constants.sol"; import "@test-sol/unit/governance/mock/MockGovernance.sol"; -contract MintGoldScheduleTest is Test, Constants, IsL2Check { +contract MintCeloScheduleTest is Test, Constants, IsL2Check { using FixidityLib for FixidityLib.Fraction; IRegistry registry; - IGoldToken goldToken; + IGoldToken celoToken; MockGovernance governance; - MintGoldSchedule mintGoldSchedule; + MintCeloSchedule mintCeloSchedule; address owner = address(this); address registryAddress; - address goldTokenAddress = actor("goldTokenAddress"); + address celoTokenAddress = actor("celoTokenAddress"); - address mintGoldOwner = actor("mintGoldOwner"); + address mintCeloOwner = actor("mintCeloOwner"); address communityRewardFund = actor("communityRewardFund"); address carbonOffsettingPartner = actor("carbonOffsettingPartner"); @@ -36,22 +36,22 @@ contract MintGoldScheduleTest is Test, Constants, IsL2Check { address constant l1RegistryAddress = 0x000000000000000000000000000000000000ce10; - // uint256 constant DAILY_MINT_AMOUNT_UPPER = 6749 ether; // 6,749 Gold - uint256 constant DAILY_MINT_AMOUNT_LOWER = 6748256563599655349558; // 6,748 Gold - uint256 constant L1_MINTED_GOLD_SUPPLY = 692702432463315819704447326; // as of May 15 2024 + // uint256 constant DAILY_MINT_AMOUNT_UPPER = 6749 ether; // 6,749 Celo + uint256 constant DAILY_MINT_AMOUNT_LOWER = 6748256563599655349558; // 6,748 Celo + uint256 constant L1_MINTED_CELO_SUPPLY = 692702432463315819704447326; // as of May 15 2024 - uint256 constant GOLD_SUPPLY_CAP = 1000000000 ether; // 1 billion Gold - uint256 constant GENESIS_GOLD_SUPPLY = 600000000 ether; // 600 million Gold + uint256 constant CELO_SUPPLY_CAP = 1000000000 ether; // 1 billion Celo + uint256 constant GENESIS_CELO_SUPPLY = 600000000 ether; // 600 million Celo - uint256 constant FIFTEEN_YEAR_LINEAR_REWARD = (GOLD_SUPPLY_CAP - GENESIS_GOLD_SUPPLY) / 2; // 200 million Gold - uint256 constant FIFTEEN_YEAR_GOLD_SUPPLY = GENESIS_GOLD_SUPPLY + FIFTEEN_YEAR_LINEAR_REWARD; // 800 million Gold (includes GENESIS_GOLD_SUPPLY) + uint256 constant FIFTEEN_YEAR_LINEAR_REWARD = (CELO_SUPPLY_CAP - GENESIS_CELO_SUPPLY) / 2; // 200 million Celo + uint256 constant FIFTEEN_YEAR_CELO_SUPPLY = GENESIS_CELO_SUPPLY + FIFTEEN_YEAR_LINEAR_REWARD; // 800 million Celo (includes GENESIS_CELO_SUPPLY) - uint256 constant MAX_L2_DISTRIBUTION = FIFTEEN_YEAR_GOLD_SUPPLY - L1_MINTED_GOLD_SUPPLY; // 107.2 million Gold - uint256 constant MAX_L2_COMMUNITY_DISTRIBUTION = MAX_L2_DISTRIBUTION / 4; // 26.8 million Gold - uint256 constant MAX_L2_CARBON_FUND_DISTRIBUTION = MAX_L2_DISTRIBUTION / 1000; // 107,297 Gold + uint256 constant MAX_L2_DISTRIBUTION = FIFTEEN_YEAR_CELO_SUPPLY - L1_MINTED_CELO_SUPPLY; // 107.2 million Celo + uint256 constant MAX_L2_COMMUNITY_DISTRIBUTION = MAX_L2_DISTRIBUTION / 4; // 26.8 million Celo + uint256 constant MAX_L2_CARBON_FUND_DISTRIBUTION = MAX_L2_DISTRIBUTION / 1000; // 107,297 Celo - uint256 constant L2_FIFTEEN_YEAR_GOLD_SUPPLY = - L1_MINTED_GOLD_SUPPLY + MAX_L2_COMMUNITY_DISTRIBUTION + MAX_L2_CARBON_FUND_DISTRIBUTION; + uint256 constant L2_FIFTEEN_YEAR_CELO_SUPPLY = + L1_MINTED_CELO_SUPPLY + MAX_L2_COMMUNITY_DISTRIBUTION + MAX_L2_CARBON_FUND_DISTRIBUTION; uint256 constant l2StartTime = 1715808537; // Arbitary later date (May 15 2024) uint256 constant communityRewardFraction = FIXED1 / 4; // 25% @@ -70,10 +70,10 @@ contract MintGoldScheduleTest is Test, Constants, IsL2Check { deployCodeTo("Registry.sol", abi.encode(false), registryAddress); registry = IRegistry(registryAddress); - registry.setAddressFor("GoldToken", address(goldToken)); + registry.setAddressFor("GoldToken", address(celoToken)); registry.setAddressFor("Governance", address(governance)); - goldToken.setRegistry(registryAddress); + celoToken.setRegistry(registryAddress); } function setUpL1() public { @@ -82,37 +82,37 @@ contract MintGoldScheduleTest is Test, Constants, IsL2Check { deployCodeTo("Registry.sol", abi.encode(false), registryAddress); registry = IRegistry(registryAddress); - deployCodeTo("GoldToken.sol", abi.encode(false), goldTokenAddress); - goldToken = IGoldToken(goldTokenAddress); + deployCodeTo("GoldToken.sol", abi.encode(false), celoTokenAddress); + celoToken = IGoldToken(celoTokenAddress); // Using a mock contract, as foundry does not allow for library linking when using deployCodeTo governance = new MockGovernance(); - registry.setAddressFor("GoldToken", address(goldToken)); + registry.setAddressFor("GoldToken", address(celoToken)); registry.setAddressFor("Governance", address(governance)); - vm.deal(address(0), GOLD_SUPPLY_CAP); - assertEq(goldToken.totalSupply(), 0, "starting total supply not zero."); + vm.deal(address(0), CELO_SUPPLY_CAP); + assertEq(celoToken.totalSupply(), 0, "starting total supply not zero."); // Mint L1 supply vm.prank(address(0)); - goldToken.mint(randomAddress, L1_MINTED_GOLD_SUPPLY); - assertEq(goldToken.totalSupply(), L1_MINTED_GOLD_SUPPLY, "total supply incorrect."); + celoToken.mint(randomAddress, L1_MINTED_CELO_SUPPLY); + assertEq(celoToken.totalSupply(), L1_MINTED_CELO_SUPPLY, "total supply incorrect."); } - function newMintGold() internal returns (MintGoldSchedule) { + function newMintCelo() internal returns (MintCeloSchedule) { vm.warp(block.timestamp + l2StartTime); - vm.prank(mintGoldOwner); - mintGoldSchedule = new MintGoldSchedule(true); + vm.prank(mintCeloOwner); + mintCeloSchedule = new MintCeloSchedule(true); - goldToken.setGoldTokenMintingScheduleAddress(address(mintGoldSchedule)); + celoToken.setCeloTokenMintingScheduleAddress(address(mintCeloSchedule)); - vm.prank(mintGoldOwner); - mintGoldSchedule.initialize(); + vm.prank(mintCeloOwner); + mintCeloSchedule.initialize(); - vm.prank(mintGoldOwner); + vm.prank(mintCeloOwner); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, communityRewardFraction, carbonOffsettingPartner, @@ -122,49 +122,49 @@ contract MintGoldScheduleTest is Test, Constants, IsL2Check { } } -contract MintGoldScheduleTest_initialize is MintGoldScheduleTest { +contract MintCeloScheduleTest_initialize is MintCeloScheduleTest { function setUp() public override { super.setUp(); vm.warp(block.timestamp + l2StartTime); - vm.prank(mintGoldOwner); - mintGoldSchedule = new MintGoldSchedule(true); - goldToken.setGoldTokenMintingScheduleAddress(address(mintGoldSchedule)); + vm.prank(mintCeloOwner); + mintCeloSchedule = new MintCeloSchedule(true); + celoToken.setCeloTokenMintingScheduleAddress(address(mintCeloSchedule)); - vm.prank(mintGoldOwner); - mintGoldSchedule.initialize(); + vm.prank(mintCeloOwner); + mintCeloSchedule.initialize(); } - function test_ShouldSetAOwnerToMintGoldScheduleInstance() public { - assertEq(mintGoldSchedule.owner(), mintGoldOwner); + function test_ShouldSetAOwnerToMintCeloScheduleInstance() public { + assertEq(mintCeloSchedule.owner(), mintCeloOwner); } - function test_ShouldNotSetBeneficiariesToMintGoldScheduleInstance() public { - assertEq(mintGoldSchedule.communityRewardFund(), address(0)); - assertEq(mintGoldSchedule.carbonOffsettingPartner(), address(0)); + function test_ShouldNotSetBeneficiariesToMintCeloScheduleInstance() public { + assertEq(mintCeloSchedule.communityRewardFund(), address(0)); + assertEq(mintCeloSchedule.carbonOffsettingPartner(), address(0)); } function test_ShouldHaveZeroTotalMintedByScheduleOnInit() public { - assertEq(mintGoldSchedule.totalMintedBySchedule(), 0); + assertEq(mintCeloSchedule.totalMintedBySchedule(), 0); } function test_ShouldNotSetTheL2StartTime() public { - assertEq(mintGoldSchedule.l2StartTime(), 0); + assertEq(mintCeloSchedule.l2StartTime(), 0); } } -contract MintGoldScheduleTest_setDependencies_L1 is MintGoldScheduleTest { +contract MintCeloScheduleTest_setDependencies_L1 is MintCeloScheduleTest { function setUp() public override { super.setUpL1(); - mintGoldSchedule = new MintGoldSchedule(true); - mintGoldSchedule.initialize(); + mintCeloSchedule = new MintCeloSchedule(true); + mintCeloSchedule.initialize(); } function test_Reverts_WhenCalledOnL1() public { vm.warp(block.timestamp + l2StartTime); vm.expectRevert("This method is not supported in L1."); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, communityRewardFraction, carbonOffsettingPartner, @@ -173,28 +173,28 @@ contract MintGoldScheduleTest_setDependencies_L1 is MintGoldScheduleTest { ); } } -contract MintGoldScheduleTest_setDependencies is MintGoldScheduleTest { +contract MintCeloScheduleTest_setDependencies is MintCeloScheduleTest { function test_ShouldHaveZeroTotalMintedByScheduleOnInit() public { - newMintGold(); - assertEq(mintGoldSchedule.totalMintedBySchedule(), 0); + newMintCelo(); + assertEq(mintCeloSchedule.totalMintedBySchedule(), 0); } function test_ShouldUpdateDependencies() public { - newMintGold(); - assertEq(mintGoldSchedule.l2StartTime(), l2StartTime); - assertEq(mintGoldSchedule.totalSupplyAtL2Start(), L1_MINTED_GOLD_SUPPLY); - assertEq(mintGoldSchedule.communityRewardFund(), address(governance)); - assertEq(mintGoldSchedule.carbonOffsettingPartner(), carbonOffsettingPartner); - assertEq(mintGoldSchedule.getCarbonOffsettingFraction(), carbonOffsettingFraction); - assertEq(mintGoldSchedule.getCommunityRewardFraction(), communityRewardFraction); + newMintCelo(); + assertEq(mintCeloSchedule.l2StartTime(), l2StartTime); + assertEq(mintCeloSchedule.totalSupplyAtL2Start(), L1_MINTED_CELO_SUPPLY); + assertEq(mintCeloSchedule.communityRewardFund(), address(governance)); + assertEq(mintCeloSchedule.carbonOffsettingPartner(), carbonOffsettingPartner); + assertEq(mintCeloSchedule.getCarbonOffsettingFraction(), carbonOffsettingFraction); + assertEq(mintCeloSchedule.getCommunityRewardFraction(), communityRewardFraction); } function test_Reverts_WhenRegistryIsTheNullAddress() public { vm.warp(block.timestamp + l2StartTime); - mintGoldSchedule = new MintGoldSchedule(true); - mintGoldSchedule.initialize(); + mintCeloSchedule = new MintCeloSchedule(true); + mintCeloSchedule.initialize(); vm.expectRevert("The registry address cannot be the zero address"); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, communityRewardFraction, carbonOffsettingPartner, @@ -205,13 +205,13 @@ contract MintGoldScheduleTest_setDependencies is MintGoldScheduleTest { function test_Reverts_WhenCommunityFractionIsZero() public { vm.warp(block.timestamp + l2StartTime); - mintGoldSchedule = new MintGoldSchedule(true); - mintGoldSchedule.initialize(); + mintCeloSchedule = new MintCeloSchedule(true); + mintCeloSchedule.initialize(); vm.expectRevert( "Value must be different from existing community reward fraction and less than 1." ); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, 0, carbonOffsettingPartner, @@ -222,11 +222,11 @@ contract MintGoldScheduleTest_setDependencies is MintGoldScheduleTest { function test_Reverts_WhenCarbonOffsettingPartnerIsNullAddress() public { vm.warp(block.timestamp + l2StartTime); - mintGoldSchedule = new MintGoldSchedule(true); - mintGoldSchedule.initialize(); + mintCeloSchedule = new MintCeloSchedule(true); + mintCeloSchedule.initialize(); vm.expectRevert("Partner cannot be the zero address."); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, communityRewardFraction, address(0), @@ -238,12 +238,12 @@ contract MintGoldScheduleTest_setDependencies is MintGoldScheduleTest { function test_Reverts_WhenRegistryNotUpdated() public { vm.warp(block.timestamp + l2StartTime); registry.setAddressFor("Governance", address(0)); - mintGoldSchedule = new MintGoldSchedule(true); + mintCeloSchedule = new MintCeloSchedule(true); - mintGoldSchedule.initialize(); + mintCeloSchedule.initialize(); vm.expectRevert("identifier has no registry entry"); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, communityRewardFraction, carbonOffsettingPartner, @@ -253,12 +253,12 @@ contract MintGoldScheduleTest_setDependencies is MintGoldScheduleTest { } function test_Reverts_WhenCalledTwice() public { - newMintGold(); + newMintCelo(); vm.expectRevert("Contract has already been activated."); - vm.prank(mintGoldOwner); + vm.prank(mintCeloOwner); - mintGoldSchedule.activate( + mintCeloSchedule.activate( l2StartTime, communityRewardFraction, carbonOffsettingPartner, @@ -268,58 +268,58 @@ contract MintGoldScheduleTest_setDependencies is MintGoldScheduleTest { } } -contract MintGoldScheduleTest_setCommunityRewardFraction is MintGoldScheduleTest { +contract MintCeloScheduleTest_setCommunityRewardFraction is MintCeloScheduleTest { function setUp() public override { super.setUp(); - newMintGold(); + newMintCelo(); } function test_ShouldSetNewFraction() public { - vm.prank(mintGoldOwner); - mintGoldSchedule.setCommunityRewardFraction(newCommunityRewardFraction); - assertEq(mintGoldSchedule.getCommunityRewardFraction(), newCommunityRewardFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCommunityRewardFraction(newCommunityRewardFraction); + assertEq(mintCeloSchedule.getCommunityRewardFraction(), newCommunityRewardFraction); } function test_Emits_CommunityRewardFractionSetEvent() public { vm.expectEmit(true, true, true, true); emit CommunityRewardFractionSet(newCommunityRewardFraction); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCommunityRewardFraction(newCommunityRewardFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCommunityRewardFraction(newCommunityRewardFraction); } function test_Reverts_WhenCalledByOtherThanOwner() public { vm.expectRevert("Ownable: caller is not the owner"); vm.prank(randomAddress); - mintGoldSchedule.setCommunityRewardFraction(newCommunityRewardFraction); + mintCeloSchedule.setCommunityRewardFraction(newCommunityRewardFraction); } function test_Reverts_WhenFractionIsTheSame() public { vm.expectRevert( "Value must be different from existing community reward fraction and less than 1." ); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCommunityRewardFraction(communityRewardFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCommunityRewardFraction(communityRewardFraction); } function test_Reverts_WhenSumOfFractionsGtOne() public { vm.expectRevert("Sum of partner fractions must be less than or equal to 1."); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCommunityRewardFraction((FIXED1 - 1)); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCommunityRewardFraction((FIXED1 - 1)); } function test_Reverts_WhenDependenciesNotSet() public { - mintGoldSchedule = new MintGoldSchedule(true); + mintCeloSchedule = new MintCeloSchedule(true); - goldToken.setGoldTokenMintingScheduleAddress(address(mintGoldSchedule)); + celoToken.setCeloTokenMintingScheduleAddress(address(mintCeloSchedule)); - vm.prank(mintGoldOwner); - mintGoldSchedule.initialize(); + vm.prank(mintCeloOwner); + mintCeloSchedule.initialize(); vm.expectRevert("Minting schedule has not been activated."); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCommunityRewardFraction(communityRewardFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCommunityRewardFraction(communityRewardFraction); } function test_Reverts_WhenFractionChangesAfter15Years() public { vm.warp(block.timestamp + (15 * YEAR + 4 * DAY)); - assertEq(mintGoldSchedule.totalMintedBySchedule(), 0, "Incorrect mintableAmount"); + assertEq(mintCeloSchedule.totalMintedBySchedule(), 0, "Incorrect mintableAmount"); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); vm.warp(block.timestamp + (15 * YEAR) + (4 * DAY)); @@ -327,73 +327,73 @@ contract MintGoldScheduleTest_setCommunityRewardFraction is MintGoldScheduleTest "Can only update fraction once block reward calculation for years 15-30 has been implemented." ); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCommunityRewardFraction(((FIXED1 / 4) * 3)); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCommunityRewardFraction(((FIXED1 / 4) * 3)); } } -contract MintGoldScheduleTest_setCarbonOffsettingFund is MintGoldScheduleTest { +contract MintCeloScheduleTest_setCarbonOffsettingFund is MintCeloScheduleTest { function setUp() public override { super.setUp(); - newMintGold(); + newMintCelo(); } function test_ShouldSetNewPartner() public { - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(newPartner, carbonOffsettingFraction); - assertEq(mintGoldSchedule.carbonOffsettingPartner(), newPartner); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(newPartner, carbonOffsettingFraction); + assertEq(mintCeloSchedule.carbonOffsettingPartner(), newPartner); } function test_ShouldSetNewFraction() public { - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, newCarbonOffsettingFraction); - assertEq(mintGoldSchedule.getCarbonOffsettingFraction(), newCarbonOffsettingFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, newCarbonOffsettingFraction); + assertEq(mintCeloSchedule.getCarbonOffsettingFraction(), newCarbonOffsettingFraction); } function test_Emits_CarbonOffsettingFundSetEvent() public { vm.expectEmit(true, true, true, true); emit CarbonOffsettingFundSet(newPartner, carbonOffsettingFraction); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(newPartner, carbonOffsettingFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(newPartner, carbonOffsettingFraction); } function test_Reverts_WhenCalledByOtherThanOwner() public { vm.expectRevert("Ownable: caller is not the owner"); vm.prank(randomAddress); - mintGoldSchedule.setCarbonOffsettingFund(newPartner, carbonOffsettingFraction); + mintCeloSchedule.setCarbonOffsettingFund(newPartner, carbonOffsettingFraction); } function test_Reverts_WhenPartnerAndFractionAreTheSame() public { vm.expectRevert("Partner and value must be different from existing carbon offsetting fund."); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, carbonOffsettingFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, carbonOffsettingFraction); } function test_Reverts_WhenSumOfFractionsGtOne() public { vm.expectRevert("Sum of partner fractions must be less than or equal to 1."); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, (FIXED1 - 1)); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, (FIXED1 - 1)); } function test_Reverts_WhenDependenciesNotSet() public { - mintGoldSchedule = new MintGoldSchedule(true); + mintCeloSchedule = new MintCeloSchedule(true); - goldToken.setGoldTokenMintingScheduleAddress(address(mintGoldSchedule)); + celoToken.setCeloTokenMintingScheduleAddress(address(mintCeloSchedule)); - vm.prank(mintGoldOwner); - mintGoldSchedule.initialize(); + vm.prank(mintCeloOwner); + mintCeloSchedule.initialize(); vm.expectRevert("Minting schedule has not been activated."); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, carbonOffsettingFraction); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, carbonOffsettingFraction); } function test_Reverts_WhenFractionChangesAfter15Years() public { vm.warp(block.timestamp + (15 * YEAR + 4 * DAY)); - assertEq(mintGoldSchedule.totalMintedBySchedule(), 0, "Incorrect mintableAmount"); + assertEq(mintCeloSchedule.totalMintedBySchedule(), 0, "Incorrect mintableAmount"); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); vm.warp(block.timestamp + (15 * YEAR) + (4 * DAY)); @@ -401,19 +401,19 @@ contract MintGoldScheduleTest_setCarbonOffsettingFund is MintGoldScheduleTest { "Can only update fraction once block reward calculation for years 15-30 has been implemented." ); - vm.prank(mintGoldOwner); - mintGoldSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, ((FIXED1 / 4) * 3)); + vm.prank(mintCeloOwner); + mintCeloSchedule.setCarbonOffsettingFund(carbonOffsettingPartner, ((FIXED1 / 4) * 3)); } } -contract MintGoldScheduleTest_mintAccordingToSchedule_L1 is MintGoldScheduleTest { - uint256 initialMintGoldAmount; +contract MintCeloScheduleTest_mintAccordingToSchedule_L1 is MintCeloScheduleTest { + uint256 initialMintCeloAmount; function setUp() public override { super.setUpL1(); - mintGoldSchedule = new MintGoldSchedule(true); - mintGoldSchedule.initialize(); + mintCeloSchedule = new MintCeloSchedule(true); + mintCeloSchedule.initialize(); } function test_Reverts_WhenMintingOnL1() public { @@ -421,96 +421,96 @@ contract MintGoldScheduleTest_mintAccordingToSchedule_L1 is MintGoldScheduleTest vm.expectRevert("This method is not supported in L1."); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); } } -contract MintGoldScheduleTest_mintAccordingToSchedule is MintGoldScheduleTest { - uint256 initialMintGoldAmount; +contract MintCeloScheduleTest_mintAccordingToSchedule is MintCeloScheduleTest { + uint256 initialMintCeloAmount; uint256 mintPerPeriod; function setUp() public override { super.setUp(); - newMintGold(); + newMintCelo(); } function test_Reverts_WhenDependenciesAreNotSet() public { - mintGoldSchedule = new MintGoldSchedule(true); + mintCeloSchedule = new MintCeloSchedule(true); - vm.prank(mintGoldOwner); - mintGoldSchedule.initialize(); + vm.prank(mintCeloOwner); + mintCeloSchedule.initialize(); vm.expectRevert("Minting schedule has not been activated."); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); } function test_ShouldAllowMintingAsSoon1SecondAfterSettingDependencies() public { - uint256 communityFundBalanceBefore = goldToken.balanceOf(address(governance)); + uint256 communityFundBalanceBefore = celoToken.balanceOf(address(governance)); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); - uint256 communityFundBalanceAfter = goldToken.balanceOf(address(governance)); + mintCeloSchedule.mintAccordingToSchedule(); + uint256 communityFundBalanceAfter = celoToken.balanceOf(address(governance)); assertGt(communityFundBalanceAfter, communityFundBalanceBefore); } function test_Reverts_WhenMintableAmountIsZero() public { vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); vm.expectRevert("Mintable amount must be greater than zero"); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); } function test_ShouldAllowToMint25Percent2years9MonthsPostL2Launch() public { vm.warp(block.timestamp + 2 * YEAR + 267 * DAY + 63868); // 25% time since L2 - uint256 expectedMintedAmount = (L2_FIFTEEN_YEAR_GOLD_SUPPLY - L1_MINTED_GOLD_SUPPLY) / 4; + uint256 expectedMintedAmount = (L2_FIFTEEN_YEAR_CELO_SUPPLY - L1_MINTED_CELO_SUPPLY) / 4; vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); - assertApproxEqRel(mintGoldSchedule.totalMintedBySchedule(), expectedMintedAmount, 1e10); + assertApproxEqRel(mintCeloSchedule.totalMintedBySchedule(), expectedMintedAmount, 1e10); } function test_ShouldAllowToMint50Percent5AndHalfYearsPostL2Launch() public { vm.warp(block.timestamp + (5 * YEAR) + (170 * DAY) + 41338); - uint256 expectedMintedAmount = (L2_FIFTEEN_YEAR_GOLD_SUPPLY - L1_MINTED_GOLD_SUPPLY) / 2; + uint256 expectedMintedAmount = (L2_FIFTEEN_YEAR_CELO_SUPPLY - L1_MINTED_CELO_SUPPLY) / 2; vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); - assertApproxEqRel(mintGoldSchedule.totalMintedBySchedule(), expectedMintedAmount, 1e10); + assertApproxEqRel(mintCeloSchedule.totalMintedBySchedule(), expectedMintedAmount, 1e10); } function test_ShouldAllowToMint75Percent11YearsAnd3MonthsPostL2Launch() public { vm.warp(block.timestamp + 8 * YEAR + 73 * DAY + 18807); - uint256 expectedMintedAmount = ((L2_FIFTEEN_YEAR_GOLD_SUPPLY - L1_MINTED_GOLD_SUPPLY) / 4) * 3; + uint256 expectedMintedAmount = ((L2_FIFTEEN_YEAR_CELO_SUPPLY - L1_MINTED_CELO_SUPPLY) / 4) * 3; vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); - assertApproxEqRel(mintGoldSchedule.totalMintedBySchedule(), expectedMintedAmount, 1e10); + assertApproxEqRel(mintCeloSchedule.totalMintedBySchedule(), expectedMintedAmount, 1e10); } function test_ShouldAllowToMint100Percent11YearsPostL2Launch() public { - uint256 communityFundBalanceBefore = goldToken.balanceOf(address(governance)); - uint256 carbonOffsettingPartnerBalanceBefore = goldToken.balanceOf(carbonOffsettingPartner); + uint256 communityFundBalanceBefore = celoToken.balanceOf(address(governance)); + uint256 carbonOffsettingPartnerBalanceBefore = celoToken.balanceOf(carbonOffsettingPartner); vm.warp(block.timestamp + (11 * YEAR)); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); assertApproxEqRel( - mintGoldSchedule.totalMintedBySchedule(), + mintCeloSchedule.totalMintedBySchedule(), MAX_L2_COMMUNITY_DISTRIBUTION + MAX_L2_CARBON_FUND_DISTRIBUTION, 1e10 ); - uint256 communityFundBalanceAfter = goldToken.balanceOf(address(governance)); - uint256 carbonOffsettingPartnerBalanceAfter = goldToken.balanceOf(carbonOffsettingPartner); + uint256 communityFundBalanceAfter = celoToken.balanceOf(address(governance)); + uint256 carbonOffsettingPartnerBalanceAfter = celoToken.balanceOf(carbonOffsettingPartner); assertApproxEqRel( communityFundBalanceAfter - communityFundBalanceBefore, @@ -528,13 +528,13 @@ contract MintGoldScheduleTest_mintAccordingToSchedule is MintGoldScheduleTest { function test_ShouldMintUpToLinearSuppplyAfter15Years() public { vm.warp(block.timestamp + (15 * YEAR) + (4 * DAY)); - assertEq(mintGoldSchedule.totalMintedBySchedule(), 0, "Incorrect mintableAmount"); + assertEq(mintCeloSchedule.totalMintedBySchedule(), 0, "Incorrect mintableAmount"); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); assertApproxEqRel( - mintGoldSchedule.totalMintedBySchedule(), + mintCeloSchedule.totalMintedBySchedule(), MAX_L2_COMMUNITY_DISTRIBUTION + MAX_L2_CARBON_FUND_DISTRIBUTION, 1e10 ); @@ -544,10 +544,10 @@ contract MintGoldScheduleTest_mintAccordingToSchedule is MintGoldScheduleTest { vm.warp(block.timestamp + (15 * YEAR) + (1 * DAY)); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); assertApproxEqRel( - mintGoldSchedule.totalMintedBySchedule(), + mintCeloSchedule.totalMintedBySchedule(), MAX_L2_COMMUNITY_DISTRIBUTION + MAX_L2_CARBON_FUND_DISTRIBUTION, 1e10 ); @@ -555,37 +555,37 @@ contract MintGoldScheduleTest_mintAccordingToSchedule is MintGoldScheduleTest { vm.expectRevert("Block reward calculation for years 15-30 unimplemented"); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); } } -contract MintGoldScheduleTest_getMintableAmount is MintGoldScheduleTest { - uint256 initialMintGoldAmount; +contract MintCeloScheduleTest_getMintableAmount is MintCeloScheduleTest { + uint256 initialMintCeloAmount; function setUp() public override { super.setUp(); - newMintGold(); + newMintCelo(); } function test_ShouldReturnFullAmountAvailableForThisReleasePeriod() public { vm.warp(block.timestamp + 1 * DAY); - assertApproxEqRel(mintGoldSchedule.getMintableAmount(), DAILY_MINT_AMOUNT_LOWER, 1e10); + assertApproxEqRel(mintCeloSchedule.getMintableAmount(), DAILY_MINT_AMOUNT_LOWER, 1e10); } function test_ShouldReturnOnlyAmountNotYetMinted() public { vm.warp(block.timestamp + 1 * DAY); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); vm.warp(block.timestamp + 1 * DAY + 1); - assertApproxEqRel(mintGoldSchedule.getMintableAmount(), DAILY_MINT_AMOUNT_LOWER, 1e10); + assertApproxEqRel(mintCeloSchedule.getMintableAmount(), DAILY_MINT_AMOUNT_LOWER, 1e10); } function test_ShouldReturnOnlyUpToMaxL2DistributionBeforeItIsMinted() public { vm.warp(block.timestamp + 16 * YEAR); assertApproxEqRel( - mintGoldSchedule.getMintableAmount(), + mintCeloSchedule.getMintableAmount(), MAX_L2_COMMUNITY_DISTRIBUTION + MAX_L2_CARBON_FUND_DISTRIBUTION, 1e10 ); @@ -595,19 +595,19 @@ contract MintGoldScheduleTest_getMintableAmount is MintGoldScheduleTest { vm.warp(block.timestamp + 15 * YEAR); vm.prank(randomAddress); - mintGoldSchedule.mintAccordingToSchedule(); + mintCeloSchedule.mintAccordingToSchedule(); vm.expectRevert("Block reward calculation for years 15-30 unimplemented"); - mintGoldSchedule.getMintableAmount(); + mintCeloSchedule.getMintableAmount(); } function test_Reverts_WhenDependenciesNotSet() public { - mintGoldSchedule = new MintGoldSchedule(true); + mintCeloSchedule = new MintCeloSchedule(true); - vm.prank(mintGoldOwner); - mintGoldSchedule.initialize(); + vm.prank(mintCeloOwner); + mintCeloSchedule.initialize(); vm.expectRevert("Minting schedule has not been activated."); - mintGoldSchedule.getMintableAmount(); + mintCeloSchedule.getMintableAmount(); } } diff --git a/packages/protocol/test-sol/unit/governance/network/EpochRewards.t.sol b/packages/protocol/test-sol/unit/governance/network/EpochRewards.t.sol index 55ca1b3f58d..cdbf389175f 100644 --- a/packages/protocol/test-sol/unit/governance/network/EpochRewards.t.sol +++ b/packages/protocol/test-sol/unit/governance/network/EpochRewards.t.sol @@ -428,11 +428,11 @@ contract EpochRewardsTest_setTargetVotingYield is EpochRewardsTest { } } -contract EpochRewardsTest_getTargetGoldTotalSupply is EpochRewardsTest { +contract EpochRewardsTest_getTargetCeloTotalSupply is EpochRewardsTest { function test_ShouldReturn1B_WhenLessThan15YearsSinceGenesis() public { uint256 timeDelta = YEAR * 10; timeTravel(timeDelta); - assertEq(epochRewards.getTargetGoldTotalSupply(), getExpectedTargetTotalSupply(timeDelta)); + assertEq(epochRewards.getTargetCeloTotalSupply(), getExpectedTargetTotalSupply(timeDelta)); } }