Verified contractPartialMIT
Emission
Address0x5b3cd42a2d41ff0894135b296900a100d184667b
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- prague
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,322,272
- Creation transaction
- 0xcc4722d875…d763b6efbb
src/Emission.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IGuardToken {
function mint(address to, uint256 amount) external;
function totalSupply() external view returns (uint256);
}
interface IStakingSink {
function notifyReward(uint256 amount) external;
}
/// @title Emission — Bitcoin-style schedule for URIEL with stretching eras.
/// A fixed amount per epoch that halves at the end of each era. Era lengths: eras[0], eras[1], eras[2], eras[3],
/// then eras[3] repeating (launch config: 30 days, 90 days, 180 days, then every 365 days).
/// Anyone can call `poke()`; it mints everything owed since the last poke straight
/// into the Staking contract, which splits it across staked nodes. No admin, no cap raise.
contract Emission {
uint256 public immutable EPOCH = 600; // 10 minutes
uint256 public immutable start;
uint256 public immutable initialPerEpoch; // GUARD per epoch in era 0
uint256 public immutable era0Epochs; // length of era 0
uint256 public immutable era1Epochs; // length of era 1
uint256 public immutable era2Epochs; // length of era 2
uint256 public immutable era3Epochs; // length of era 3 and every era after it
IGuardToken public immutable token;
IStakingSink public immutable staking;
uint256 public lastEpochPaid; // epochs [0, lastEpochPaid) are paid
uint256 public totalMinted;
event Poked(uint256 fromEpoch, uint256 toEpoch, uint256 minted);
constructor(address _token, address _staking, uint256 _initialPerEpoch, uint256[4] memory _eras, uint256 _start) {
require(_eras[0] > 0 && _eras[1] > 0 && _eras[2] > 0 && _eras[3] > 0, "eras");
token = IGuardToken(_token);
staking = IStakingSink(_staking);
initialPerEpoch = _initialPerEpoch;
era0Epochs = _eras[0];
era1Epochs = _eras[1];
era2Epochs = _eras[2];
era3Epochs = _eras[3];
start = _start == 0 ? block.timestamp : _start;
}
function currentEpoch() public view returns (uint256) {
if (block.timestamp < start) return 0;
return (block.timestamp - start) / EPOCH;
}
/// Era index of an epoch.
function eraOf(uint256 epoch) public view returns (uint256) {
uint256 b1 = era0Epochs;
if (epoch < b1) return 0;
uint256 b2 = b1 + era1Epochs;
if (epoch < b2) return 1;
uint256 b3 = b2 + era2Epochs;
if (epoch < b3) return 2;
return 3 + (epoch - b3) / era3Epochs;
}
/// First epoch of the era after `era` (the epoch at which the next halving happens).
function eraEnd(uint256 era) public view returns (uint256) {
if (era == 0) return era0Epochs;
if (era == 1) return era0Epochs + era1Epochs;
if (era == 2) return era0Epochs + era1Epochs + era2Epochs;
return era0Epochs + era1Epochs + era2Epochs + (era - 2) * era3Epochs;
}
/// Length of the era that `epoch` is in (kept for UIs that read a halving interval).
function halvingEpochs() external view returns (uint256) {
uint256 era = eraOf(currentEpoch());
return era == 0 ? era0Epochs : era == 1 ? era1Epochs : era == 2 ? era2Epochs : era3Epochs;
}
/// Unix time of the next halving.
function nextHalvingAt() external view returns (uint256) {
return start + eraEnd(eraOf(currentEpoch())) * EPOCH;
}
function perEpoch(uint256 epoch) public view returns (uint256) {
uint256 era = eraOf(epoch);
if (era >= 64) return 0;
return initialPerEpoch >> era;
}
/// Sum of per-epoch amounts for epochs in [from, to).
function owed(uint256 from, uint256 to) public view returns (uint256 sum) {
uint256 e = from;
while (e < to) {
uint256 era = eraOf(e);
if (era >= 64) break;
uint256 end_ = eraEnd(era);
uint256 stop = to < end_ ? to : end_;
sum += (stop - e) * perEpoch(e);
e = stop;
}
}
function pending() external view returns (uint256) {
return owed(lastEpochPaid, currentEpoch());
}
function poke() external returns (uint256 minted) {
uint256 to = currentEpoch();
uint256 from = lastEpochPaid;
if (to <= from) return 0;
minted = owed(from, to);
lastEpochPaid = to;
if (minted > 0) {
token.mint(address(staking), minted);
staking.notifyReward(minted);
totalMinted += minted;
}
emit Poked(from, to, minted);
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "prague",
"remappings": [
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"forge-std/=lib/forge-std/src/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"solmate/=lib/v4-core/lib/solmate/",
"v4-core/=lib/v4-core/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.