Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename MintGoldSchedule #11040

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/protocol/contractPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
)
Expand All @@ -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(
Expand All @@ -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);
Expand All @@ -286,7 +286,7 @@ contract MintGoldSchedule is UsingRegistry, ReentrancyGuard, Initializable, IsL2
internal
view
returns (
uint256 targetGoldTotalSupply,
uint256 targetCeloTotalSupply,
uint256 communityTargetRewards,
uint256 carbonFundTargetRewards
)
Expand All @@ -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
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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 IMintGoldScheduleInitializer {
interface IMintCeloScheduleInitializer {
function initialize() external;
}
24 changes: 12 additions & 12 deletions packages/protocol/contracts/common/GoldToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -37,19 +37,19 @@ 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);

event TransferComment(string comment);

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.");
}
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
pahor167 marked this conversation as resolved.
Show resolved Hide resolved
pragma solidity >=0.5.13 <0.9.0;

interface IMintGoldSchedule {
interface IMintCeloSchedule {
/**
* @notice Mints CELO to the beneficiaries according to the predefined schedule.
*/
Expand All @@ -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);
}
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 MintGoldScheduleProxy is Proxy {}
contract MintCeloScheduleProxy is Proxy {}
4 changes: 2 additions & 2 deletions packages/protocol/contracts/governance/EpochRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/lib/registry-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export enum CeloContractName {
GovernanceApproverMultiSig = 'GovernanceApproverMultiSig',
GrandaMento = 'GrandaMento',
LockedGold = 'LockedGold',
MintGoldSchedule = 'MintGoldSchedule',
MintCeloSchedule = 'MintCeloSchedule',
OdisPayments = 'OdisPayments',
Random = 'Random',
Reserve = 'Reserve',
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 @@ -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";
Expand Down Expand Up @@ -235,7 +235,7 @@ contract Migration is Script, UsingRegistry, Constants {
migrateUniswapFeeHandlerSeller();
migrateFeeHandler(json);
migrateOdisPayments();
migrateMintGoldSchedule();
migrateMintCeloSchedule();
migrateGovernance(json);

vm.stopBroadcast();
Expand Down Expand Up @@ -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)
);
}

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 @@ -19,7 +19,7 @@ contract Constants {
"Governance",
"GovernanceSlasher",
"LockedGold",
"MintGoldSchedule",
"MintCeloSchedule",
"OdisPayments",
"Random",
"Registry",
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MintGoldScheduleInstance>(
module.exports = deploymentForCoreContract<MintCeloScheduleInstance>(
web3,
artifacts,
CeloContractName.MintGoldSchedule,
CeloContractName.MintCeloSchedule,
initializeArgs,
undefined,
SOLIDITY_08_PACKAGE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"FeeCurrencyDirectory": [],
"MintGoldSchedule": []
"MintCeloSchedule": []
}
Loading
Loading