编译器
0.8.19+commit.7dd6d404
文件 1 的 8:IERC20.sol
pragma solidity >=0.6.2;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 2 的 8:IERC20Mintable.sol
pragma solidity >=0.7.0 <0.9.0;
import {IERC20} from "forge-std/interfaces/IERC20.sol";
interface IERC20Mintable is IERC20 {
function mint(address to, uint256 amount) external;
}
文件 3 的 8:IGaugeController.sol
pragma solidity >=0.6.11;
interface IGaugeController {
struct Point {
uint256 bias;
uint256 slope;
}
struct VotedSlope {
uint256 slope;
uint256 power;
uint256 end;
}
function admin() external view returns (address);
function token() external view returns (address);
function voting_escrow() external view returns (address);
function n_gauge_types() external view returns (int128);
function n_gauges() external view returns (int128);
function gauge_type_names(int128) external view returns (string memory);
function gauges(uint256) external view returns (address);
function vote_user_slopes(
address,
address
) external view returns (VotedSlope memory);
function vote_user_power(address) external view returns (uint256);
function last_user_vote(address, address) external view returns (uint256);
function points_weight(
address,
uint256
) external view returns (Point memory);
function time_weight(address) external view returns (uint256);
function points_sum(int128, uint256) external view returns (Point memory);
function time_sum(uint256) external view returns (uint256);
function points_total(uint256) external view returns (uint256);
function time_total() external view returns (uint256);
function points_type_weight(
int128,
uint256
) external view returns (uint256);
function time_type_weight(uint256) external view returns (uint256);
function gauge_types(address) external view returns (int128);
function gauge_relative_weight(address) external view returns (uint256);
function gauge_relative_weight(
address,
uint256
) external view returns (uint256);
function get_gauge_weight(address) external view returns (uint256);
function get_type_weight(int128) external view returns (uint256);
function get_total_weight() external view returns (uint256);
function get_weights_sum_per_type(int128) external view returns (uint256);
function add_gauge(address, int128, uint256) external;
function checkpoint() external;
function checkpoint_gauge(address) external;
function gauge_relative_weight_write(address) external returns (uint256);
function gauge_relative_weight_write(
address,
uint256
) external returns (uint256);
function add_type(string memory, uint256) external;
function change_type_weight(int128, uint256) external;
function change_gauge_weight(address, uint256) external;
function vote_for_gauge_weights(address, uint256) external;
function change_pending_admin(address newPendingAdmin) external;
function claim_admin() external;
function vote_for_many_gauge_weights(
address[8] memory gauges,
uint256[8] memory weights
) external;
}
文件 4 的 8:ILiquidityGauge.sol
pragma solidity >=0.7.0 <0.9.0;
interface ILiquidityGauge {
event RelativeWeightCapChanged(uint256 new_relative_weight_cap);
function integrate_fraction(address user) external view returns (uint256);
function user_checkpoint(address user) external returns (bool);
function is_killed() external view returns (bool);
function killGauge() external;
function unkillGauge() external;
function makeGaugePermissionless() external;
function setRelativeWeightCap(uint256 relativeWeightCap) external;
function getRelativeWeightCap() external view returns (uint256);
function getCappedRelativeWeight(
uint256 time
) external view returns (uint256);
function initialize(
address lpToken,
uint256 relativeWeightCap,
address admin
) external;
function change_pending_admin(address newPendingAdmin) external;
function claim_admin() external;
function admin() external view returns (address);
function deposit(uint256 amount) external;
function deposit(uint256 amount, address recipient) external;
function withdraw(uint256 amount) external;
function balanceOf(address account) external view returns (uint256);
function claim_rewards() external;
function set_tokenless_production(uint8) external;
function lp_token() external view returns (address);
}
文件 5 的 8:IMinter.sol
pragma solidity >=0.7.0 <0.9.0;
import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {ITokenAdmin} from "./ITokenAdmin.sol";
import {IGaugeController} from "./IGaugeController.sol";
interface IMinter {
event Minted(address indexed recipient, address gauge, uint256 minted);
function getToken() external view returns (IERC20);
function getTokenAdmin() external view returns (ITokenAdmin);
function getGaugeController() external view returns (IGaugeController);
function mint(address gauge) external returns (uint256);
function mintMany(address[] calldata gauges) external returns (uint256);
function mintFor(address gauge, address user) external returns (uint256);
function mintManyFor(address[] calldata gauges, address user) external returns (uint256);
function minted(address user, address gauge) external view returns (uint256);
function getMinterApproval(address minter, address user) external view returns (bool);
function setMinterApproval(address minter, bool approval) external;
function allowed_to_mint_for(address minter, address user) external view returns (bool);
function mint_many(address[8] calldata gauges) external;
function mint_for(address gauge, address user) external;
function toggle_approve_mint(address minter) external;
}
文件 6 的 8:ITokenAdmin.sol
pragma solidity >=0.7.0 <0.9.0;
import {IERC20Mintable} from "./IERC20Mintable.sol";
interface ITokenAdmin {
function INITIAL_RATE() external view returns (uint256);
function RATE_REDUCTION_TIME() external view returns (uint256);
function RATE_REDUCTION_COEFFICIENT() external view returns (uint256);
function RATE_DENOMINATOR() external view returns (uint256);
function getToken() external view returns (IERC20Mintable);
function activate() external;
function rate() external view returns (uint256);
function startEpochTimeWrite() external returns (uint256);
function mint(address to, uint256 amount) external;
}
文件 7 的 8:Minter.sol
pragma solidity ^0.8.0;
import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {ReentrancyGuard} from "solmate/utils/ReentrancyGuard.sol";
import {IMinter} from "./interfaces/IMinter.sol";
import {ITokenAdmin} from "./interfaces/ITokenAdmin.sol";
import {ILiquidityGauge} from "./interfaces/ILiquidityGauge.sol";
import {IGaugeController} from "./interfaces/IGaugeController.sol";
contract Minter is IMinter, ReentrancyGuard {
IERC20 private immutable _token;
ITokenAdmin private immutable _tokenAdmin;
IGaugeController private immutable _gaugeController;
mapping(address => mapping(address => uint256)) private _minted;
mapping(address => mapping(address => bool)) private _allowedMinter;
event MinterApprovalSet(address indexed user, address indexed minter, bool approval);
constructor(ITokenAdmin tokenAdmin, IGaugeController gaugeController) {
_token = tokenAdmin.getToken();
_tokenAdmin = tokenAdmin;
_gaugeController = gaugeController;
}
function getToken() external view override returns (IERC20) {
return _token;
}
function getTokenAdmin() external view override returns (ITokenAdmin) {
return _tokenAdmin;
}
function getGaugeController() external view override returns (IGaugeController) {
return _gaugeController;
}
function mint(address gauge) external override nonReentrant returns (uint256) {
return _mintFor(gauge, msg.sender);
}
function mintMany(address[] calldata gauges) external override nonReentrant returns (uint256) {
return _mintForMany(gauges, msg.sender);
}
function mintFor(address gauge, address user) external override nonReentrant returns (uint256) {
require(_allowedMinter[msg.sender][user], "Caller not allowed to mint for user");
return _mintFor(gauge, user);
}
function mintManyFor(address[] calldata gauges, address user) external override nonReentrant returns (uint256) {
require(_allowedMinter[msg.sender][user], "Caller not allowed to mint for user");
return _mintForMany(gauges, user);
}
function minted(address user, address gauge) external view override returns (uint256) {
return _minted[user][gauge];
}
function getMinterApproval(address minter, address user) external view override returns (bool) {
return _allowedMinter[minter][user];
}
function setMinterApproval(address minter, bool approval) public override {
_setMinterApproval(minter, msg.sender, approval);
}
function _setMinterApproval(address minter, address user, bool approval) private {
_allowedMinter[minter][user] = approval;
emit MinterApprovalSet(user, minter, approval);
}
function _mintFor(address gauge, address user) internal returns (uint256 tokensToMint) {
tokensToMint = _updateGauge(gauge, user);
if (tokensToMint > 0) {
_tokenAdmin.mint(user, tokensToMint);
}
}
function _mintForMany(address[] calldata gauges, address user) internal returns (uint256 tokensToMint) {
uint256 length = gauges.length;
for (uint256 i = 0; i < length;) {
tokensToMint += _updateGauge(gauges[i], user);
unchecked {
++i;
}
}
if (tokensToMint > 0) {
_tokenAdmin.mint(user, tokensToMint);
}
}
function _updateGauge(address gauge, address user) internal returns (uint256 tokensToMint) {
require(_gaugeController.gauge_types(gauge) >= 0, "Gauge does not exist on Controller");
ILiquidityGauge(gauge).user_checkpoint(user);
uint256 totalMint = ILiquidityGauge(gauge).integrate_fraction(user);
tokensToMint = totalMint - _minted[user][gauge];
if (tokensToMint > 0) {
_minted[user][gauge] = totalMint;
emit Minted(user, gauge, totalMint);
}
}
function allowed_to_mint_for(address minter, address user) external view override returns (bool) {
return _allowedMinter[minter][user];
}
function mint_many(address[8] calldata gauges) external override nonReentrant {
for (uint256 i = 0; i < 8;) {
if (gauges[i] == address(0)) {
break;
}
_mintFor(gauges[i], msg.sender);
unchecked {
++i;
}
}
}
function mint_for(address gauge, address user) external override nonReentrant {
if (_allowedMinter[msg.sender][user]) {
_mintFor(gauge, user);
}
}
function toggle_approve_mint(address minter) external override {
setMinterApproval(minter, !_allowedMinter[minter][msg.sender]);
}
}
文件 8 的 8:ReentrancyGuard.sol
pragma solidity >=0.8.0;
abstract contract ReentrancyGuard {
uint256 private locked = 1;
modifier nonReentrant() virtual {
require(locked == 1, "REENTRANCY");
locked = 2;
_;
locked = 1;
}
}
{
"compilationTarget": {
"src/Minter.sol": "Minter"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": [
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":create3-factory/=lib/create3-factory/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/popcorn/lib/openzeppelin-contracts-upgradeable/contracts/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/popcorn/lib/openzeppelin-contracts-upgradeable/contracts/",
":popcorn/=lib/popcorn/",
":solmate/=lib/solmate/src/"
]
}
[{"inputs":[{"internalType":"contract ITokenAdmin","name":"tokenAdmin","type":"address"},{"internalType":"contract IGaugeController","name":"gaugeController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"gauge","type":"address"},{"indexed":false,"internalType":"uint256","name":"minted","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"bool","name":"approval","type":"bool"}],"name":"MinterApprovalSet","type":"event"},{"inputs":[{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"allowed_to_mint_for","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGaugeController","outputs":[{"internalType":"contract IGaugeController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getMinterApproval","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenAdmin","outputs":[{"internalType":"contract ITokenAdmin","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"gauge","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gauge","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"mintFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"gauges","type":"address[]"}],"name":"mintMany","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"gauges","type":"address[]"},{"internalType":"address","name":"user","type":"address"}],"name":"mintManyFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gauge","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"mint_for","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[8]","name":"gauges","type":"address[8]"}],"name":"mint_many","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"gauge","type":"address"}],"name":"minted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"},{"internalType":"bool","name":"approval","type":"bool"}],"name":"setMinterApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"}],"name":"toggle_approve_mint","outputs":[],"stateMutability":"nonpayable","type":"function"}]