Verified contractPartialMIT
Allocator
Address0x8debe9a3ffcb99f315d4cbc7998a43dc96ccc26a
- Balance
0 ETH
- Transactions
7
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 1,000 runs
- EVM version
- cancun
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,349,935
- Creation transaction
- 0x362ae394ce…74b2826265
15 files
- src/Allocator.solmain11.34 KB
- lib/openzeppelin-contracts/contracts/access/Ownable.sol3.1 KB
- lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol2.48 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4.45 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol192 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol181 B
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol9.44 KB
- lib/openzeppelin-contracts/contracts/utils/Address.sol6.03 KB
- lib/openzeppelin-contracts/contracts/utils/Context.sol963 B
- lib/openzeppelin-contracts/contracts/utils/Errors.sol896 B
- lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol3.38 KB
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol870 B
- src/Auction.sol7.37 KB
- src/interfaces/ICoin.sol1.11 KB
src/Allocator.sol
// SPDX-License-Identifier: MIT
// https://beer.investments
// https://x.com/WallStreetBrews
//
// o . O
// . O o . o
// .-~~~~~~~~~~~~~~~~~-.
// ( o O o O )
// '-.~~.~~~.~~~.~~.~.-'
// | |====.
// | ___________ | ||
// | | | | ||
// | | B E E R | | ||
// | |___________| | ||
// | |===='
// |_________________|
// '================='
//
// WALL STREET BREWING CO
//
pragma solidity 0.8.26;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Auction} from "./Auction.sol";
/// @title Allocator
/// @notice Receives the treasury's share of every mining payment and decides which assets it buys.
///
/// Revenue lands here from the Mine and waits. `route()` folds the waiting balance into a seven-day stream, and the
/// stream is shared between the live strategies in proportion to their weights. A strategy is one Auction that sells
/// its share of the stream for one asset; the asset goes to the Fund.
///
/// The owner sets the weights, adds strategies and can kill them. The owner can never take the revenue: it only ever
/// leaves through an auction.
contract Allocator is Ownable2Step, ReentrancyGuard {
using SafeERC20 for IERC20;
struct Strategy {
bool registered;
bool live;
uint64 weight;
address paymentToken;
uint256 revenuePerWeightPaid;
uint256 accrued; // raw quote, scaled by PRECISION
}
/// @notice Length of every revenue stream.
uint256 public constant REWARD_DURATION = 7 days;
uint256 public constant PRECISION = 1e36;
uint256 public constant MAX_WEIGHT = 1_000_000;
IERC20 public immutable quote;
address public immutable fund;
address[] private _strategies;
mapping(address => Strategy) private _strategy;
uint256 public totalWeight;
uint256 public liveStrategyCount;
uint256 public periodFinish;
uint256 public revenueRate; // raw quote per second
uint256 public lastUpdateTime;
uint256 public revenuePerWeightStored; // scaled by PRECISION
/// @notice Quote already committed to the stream or accrued to strategies. The rest of the balance is waiting.
uint256 public reservedRevenue;
/// @notice Division remainder carried into the next stream.
uint256 public savedRemainder;
uint256 public lifetimeRevenueRouted;
event StrategyAdded(address indexed strategy, address indexed paymentToken);
event StrategyKilled(address indexed strategy);
event WeightSet(address indexed strategy, uint256 previousWeight, uint256 newWeight);
event RevenueRouted(address indexed caller, uint256 amount);
event RevenueHeld(address indexed caller, uint256 pending, uint256 minimum);
event RevenueDistributed(address indexed caller, address indexed strategy, uint256 amount);
error ZeroAddress();
error NotAContract(address account);
error StrategyNotFound(address strategy);
error StrategyAlreadyDead(address strategy);
error FinalLiveStrategy(address strategy);
error WeightTooLarge(uint256 weight);
error InvalidArrayLengths();
error NoActiveWeight();
error NoRevenue();
constructor(IERC20 quote_, address fund_, address initialOwner) Ownable(initialOwner) {
if (address(quote_) == address(0) || fund_ == address(0)) revert ZeroAddress();
quote = quote_;
fund = fund_;
}
// ------------------------------------------------------------------ routing
/// @notice Quote that has arrived from the Mine and is not in a stream yet.
function pendingRevenue() public view returns (uint256) {
return quote.balanceOf(address(this)) - reservedRevenue;
}
/// @notice Quote the current stream has still to pay out.
function remainingRevenue() public view returns (uint256) {
return block.timestamp >= periodFinish ? 0 : (periodFinish - block.timestamp) * revenueRate;
}
/// @notice Start a new seven-day stream with everything that is waiting. Anyone can call.
/// The waiting balance has to be at least one raw unit per second of the stream, and at least what the current
/// stream still owes; anything smaller is held until more arrives.
/// @return amount Quote moved into the stream (zero when held).
function route() external nonReentrant returns (uint256 amount) {
if (totalWeight == 0) revert NoActiveWeight();
uint256 pending;
(pending, amount) = _route();
if (pending == 0) revert NoRevenue();
if (amount == 0) {
uint256 remaining = remainingRevenue();
emit RevenueHeld(msg.sender, pending, remaining > REWARD_DURATION ? remaining : REWARD_DURATION);
}
}
/// @dev Bring the stream up to date, then fold the waiting balance into a new stream if it qualifies.
function _route() private returns (uint256 pending, uint256 routed) {
_checkpoint();
pending = pendingRevenue();
uint256 remaining = remainingRevenue();
if (pending < REWARD_DURATION || pending < remaining) return (pending, 0);
uint256 total = pending + remaining + savedRemainder;
revenueRate = total / REWARD_DURATION;
savedRemainder = total - revenueRate * REWARD_DURATION;
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp + REWARD_DURATION;
reservedRevenue += pending;
lifetimeRevenueRouted += pending;
emit RevenueRouted(msg.sender, pending);
return (pending, pending);
}
/// @notice Send a strategy everything it has accrued. Anyone can call; auctions call it for themselves on every
/// fill. Waiting revenue is routed first when it qualifies.
function distributeRevenue(address strategy) external nonReentrant returns (uint256 amount) {
Strategy storage s = _strategy[strategy];
if (!s.registered) revert StrategyNotFound(strategy);
if (totalWeight != 0) _route();
else _checkpoint();
_accrue(s);
amount = s.accrued / PRECISION;
if (amount != 0) {
s.accrued -= amount * PRECISION;
reservedRevenue -= amount;
quote.safeTransfer(strategy, amount);
}
emit RevenueDistributed(msg.sender, strategy, amount);
}
/// @dev Advance the global index to now (or to the end of the stream). Time that passes with no weight at all
/// is not lost: that part of the stream goes back to the waiting balance.
function _checkpoint() private {
uint256 until = block.timestamp < periodFinish ? block.timestamp : periodFinish;
uint256 last = lastUpdateTime;
if (until <= last) return;
uint256 streamed = (until - last) * revenueRate;
if (totalWeight != 0) revenuePerWeightStored += (streamed * PRECISION) / totalWeight;
else reservedRevenue -= streamed;
lastUpdateTime = until;
}
function _accrue(Strategy storage s) private {
uint256 index = revenuePerWeightStored;
s.accrued += uint256(s.weight) * (index - s.revenuePerWeightPaid);
s.revenuePerWeightPaid = index;
}
// ------------------------------------------------------------------ owner
/// @notice Create an auction that buys `paymentToken` for the treasury. It starts with no weight.
function addStrategy(IERC20 paymentToken, Auction.Config calldata config)
external
onlyOwner
returns (address strategy)
{
if (address(paymentToken).code.length == 0) revert NotAContract(address(paymentToken));
strategy = address(new Auction(quote, paymentToken, fund, address(this), config));
_strategies.push(strategy);
Strategy storage s = _strategy[strategy];
s.registered = true;
s.live = true;
s.paymentToken = address(paymentToken);
s.revenuePerWeightPaid = revenuePerWeightStored;
liveStrategyCount += 1;
emit StrategyAdded(strategy, address(paymentToken));
}
/// @notice Set one strategy's share of future revenue. What it has already accrued is untouched.
function setWeight(address strategy, uint256 weight) external onlyOwner {
_checkpoint();
_setWeight(strategy, weight);
}
/// @notice Set several weights at once.
function setWeights(address[] calldata list, uint256[] calldata weights) external onlyOwner {
if (list.length != weights.length) revert InvalidArrayLengths();
_checkpoint();
for (uint256 i; i < list.length; ++i) {
_setWeight(list[i], weights[i]);
}
}
function _setWeight(address strategy, uint256 weight) private {
Strategy storage s = _strategy[strategy];
if (!s.registered) revert StrategyNotFound(strategy);
if (!s.live) revert StrategyAlreadyDead(strategy);
if (weight > MAX_WEIGHT) revert WeightTooLarge(weight);
_accrue(s);
emit WeightSet(strategy, s.weight, weight);
totalWeight = totalWeight - s.weight + weight;
s.weight = uint64(weight);
}
/// @notice Stop a strategy for good. It keeps what it has accrued and its auction can still sell that, but it
/// earns nothing more. The last live strategy cannot be killed.
function killStrategy(address strategy) external onlyOwner {
Strategy storage s = _strategy[strategy];
if (!s.registered) revert StrategyNotFound(strategy);
if (!s.live) revert StrategyAlreadyDead(strategy);
if (liveStrategyCount == 1) revert FinalLiveStrategy(strategy);
_checkpoint();
_accrue(s);
totalWeight -= s.weight;
s.weight = 0;
s.live = false;
liveStrategyCount -= 1;
emit StrategyKilled(strategy);
}
// ------------------------------------------------------------------ views
function strategyCount() external view returns (uint256) {
return _strategies.length;
}
function strategies() external view returns (address[] memory) {
return _strategies;
}
function strategyInfo(address strategy)
external
view
returns (bool registered, bool live, uint256 weight, address paymentToken)
{
Strategy storage s = _strategy[strategy];
return (s.registered, s.live, s.weight, s.paymentToken);
}
/// @notice Quote a strategy has accrued and not been sent yet.
function earnedRevenue(address strategy) external view returns (uint256) {
Strategy storage s = _strategy[strategy];
uint256 index = revenuePerWeightStored;
uint256 until = block.timestamp < periodFinish ? block.timestamp : periodFinish;
if (until > lastUpdateTime && totalWeight != 0) {
index += ((until - lastUpdateTime) * revenueRate * PRECISION) / totalWeight;
}
return (s.accrued + uint256(s.weight) * (index - s.revenuePerWeightPaid)) / PRECISION;
}
}
lib/openzeppelin-contracts/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
lib/openzeppelin-contracts/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
lib/openzeppelin-contracts/contracts/utils/Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
src/Auction.sol
// SPDX-License-Identifier: MIT
// https://beer.investments
// https://x.com/WallStreetBrews
//
// o . O
// . O o . o
// .-~~~~~~~~~~~~~~~~~-.
// ( o O o O )
// '-.~~.~~~.~~~.~~.~.-'
// | |====.
// | ___________ | ||
// | | | | ||
// | | B E E R | | ||
// | |___________| | ||
// | |===='
// |_________________|
// '================='
//
// WALL STREET BREWING CO
//
pragma solidity 0.8.26;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IAllocatorRevenue} from "./interfaces/ICoin.sol";
/// @title Auction
/// @notice How the treasury turns mining revenue into one asset. The auction collects quote from the Allocator and
/// sells all of it, in one fill, for its payment token. The asking price falls in a straight line to zero over each
/// epoch; the buyer's payment goes straight to the treasury and the next epoch starts at a multiple of what they paid.
///
/// When the payment token is the Coin itself, the treasury ends up holding Coin, which anyone can burn: a buyback.
contract Auction is ReentrancyGuard {
using SafeERC20 for IERC20;
struct Config {
uint256 initialPrice; // starting price of the first epoch, raw payment-token units
uint256 epochDuration; // seconds for the price to fall to zero
uint256 priceMultiplier; // next start relative to the clearing payment, scaled by 1e18
uint256 minimumPrice; // floor for every later epoch's starting price (not a reserve at fill time)
}
uint256 public constant PRICE_SCALE = 1e18;
uint256 public constant MIN_EPOCH_DURATION = 1 hours;
uint256 public constant MAX_EPOCH_DURATION = 365 days;
uint256 public constant MIN_PRICE_MULTIPLIER = 1.1e18;
uint256 public constant MAX_PRICE_MULTIPLIER = 3e18;
uint256 public constant ABSOLUTE_MINIMUM_PRICE = 10;
uint256 public constant ABSOLUTE_MAXIMUM_PRICE = type(uint192).max;
/// @notice What the auction sells: the revenue token miners pay in.
IERC20 public immutable quote;
/// @notice What buyers pay with, and so what the treasury accumulates.
IERC20 public immutable paymentToken;
address public immutable fund;
address public immutable allocator;
uint256 public immutable epochDuration;
uint256 public immutable priceMultiplier;
uint256 public immutable minimumPrice;
uint256 public epochId;
uint192 private _initialPrice;
uint64 private _epochStartedAt;
event Purchased(
address indexed buyer,
address indexed revenueReceiver,
uint256 indexed epochId,
uint256 revenueAmount,
uint256 paymentAmount
);
error ZeroAddress();
error DeadlinePassed(uint256 deadline);
error EpochIdMismatch(uint256 expected, uint256 actual);
error MaximumPaymentExceeded(uint256 payment, uint256 maximum);
error EmptyRevenue();
error InitialPriceOutOfRange(uint256 price);
error MinimumPriceOutOfRange(uint256 price);
error EpochDurationOutOfRange(uint256 duration);
error PriceMultiplierOutOfRange(uint256 multiplier);
constructor(IERC20 quote_, IERC20 paymentToken_, address fund_, address allocator_, Config memory config) {
if (
address(quote_) == address(0) || address(paymentToken_) == address(0) || fund_ == address(0)
|| allocator_ == address(0)
) revert ZeroAddress();
if (config.epochDuration < MIN_EPOCH_DURATION || config.epochDuration > MAX_EPOCH_DURATION) {
revert EpochDurationOutOfRange(config.epochDuration);
}
if (config.priceMultiplier < MIN_PRICE_MULTIPLIER || config.priceMultiplier > MAX_PRICE_MULTIPLIER) {
revert PriceMultiplierOutOfRange(config.priceMultiplier);
}
if (config.minimumPrice < ABSOLUTE_MINIMUM_PRICE || config.minimumPrice > ABSOLUTE_MAXIMUM_PRICE) {
revert MinimumPriceOutOfRange(config.minimumPrice);
}
if (config.initialPrice < config.minimumPrice || config.initialPrice > ABSOLUTE_MAXIMUM_PRICE) {
revert InitialPriceOutOfRange(config.initialPrice);
}
quote = quote_;
paymentToken = paymentToken_;
fund = fund_;
allocator = allocator_;
epochDuration = config.epochDuration;
priceMultiplier = config.priceMultiplier;
minimumPrice = config.minimumPrice;
_initialPrice = uint192(config.initialPrice);
_epochStartedAt = uint64(block.timestamp);
}
/// @notice Buy the auction's whole quote balance at the current price.
/// @param revenueReceiver Where the quote goes. Need not be the caller, who pays.
/// @param expectedEpochId The epoch the caller quoted against. A competing fill makes this revert.
/// @param deadline Latest timestamp at which this may execute (inclusive).
/// @param maximumPayment Most raw payment token the caller will pay.
/// @return paymentAmount What the caller paid, all of it to the treasury.
function buy(address revenueReceiver, uint256 expectedEpochId, uint256 deadline, uint256 maximumPayment)
external
nonReentrant
returns (uint256 paymentAmount)
{
if (revenueReceiver == address(0)) revert ZeroAddress();
if (block.timestamp > deadline) revert DeadlinePassed(deadline);
uint256 epoch = epochId;
if (expectedEpochId != epoch) revert EpochIdMismatch(expectedEpochId, epoch);
// pull in whatever the Allocator has accrued for this auction; a dead Allocator must not stop a sale
try IAllocatorRevenue(allocator).distributeRevenue(address(this)) {} catch {}
uint256 revenue = quote.balanceOf(address(this));
if (revenue == 0) revert EmptyRevenue();
paymentAmount = currentPrice();
if (paymentAmount > maximumPayment) revert MaximumPaymentExceeded(paymentAmount, maximumPayment);
uint256 next = (paymentAmount * priceMultiplier) / PRICE_SCALE;
if (next < minimumPrice) next = minimumPrice;
if (next > ABSOLUTE_MAXIMUM_PRICE) next = ABSOLUTE_MAXIMUM_PRICE;
epochId = epoch + 1;
_initialPrice = uint192(next);
_epochStartedAt = uint64(block.timestamp);
if (paymentAmount != 0) paymentToken.safeTransferFrom(msg.sender, fund, paymentAmount);
quote.safeTransfer(revenueReceiver, revenue);
emit Purchased(msg.sender, revenueReceiver, epoch, revenue, paymentAmount);
}
/// @notice The asking price right now, in raw payment-token units. Zero once the epoch has run out.
function currentPrice() public view returns (uint256) {
uint256 elapsed = block.timestamp - _epochStartedAt;
if (elapsed >= epochDuration) return 0;
uint256 start = _initialPrice;
return start - (start * elapsed) / epochDuration;
}
function initialPrice() external view returns (uint256) {
return _initialPrice;
}
function epochStartedAt() external view returns (uint256) {
return _epochStartedAt;
}
}
src/interfaces/ICoin.sol
// SPDX-License-Identifier: MIT
// https://beer.investments
// https://x.com/WallStreetBrews
//
// o . O
// . O o . o
// .-~~~~~~~~~~~~~~~~~-.
// ( o O o O )
// '-.~~.~~~.~~~.~~.~.-'
// | |====.
// | ___________ | ||
// | | | | ||
// | | B E E R | | ||
// | |___________| | ||
// | |===='
// |_________________|
// '================='
//
// WALL STREET BREWING CO
//
pragma solidity 0.8.26;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface ICoin is IERC20 {
function mint(address to, uint256 amount) external;
function burn(uint256 amount) external;
function minter() external view returns (address);
function minterLocked() external view returns (bool);
}
interface IMineSupply {
function effectiveTotalSupply() external view returns (uint256);
}
interface IAllocatorRevenue {
function distributeRevenue(address strategy) external returns (uint256);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 1000,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"v4-core/=lib/v4-periphery/lib/v4-core/",
"v4-periphery/=lib/v4-periphery/",
"forge-std/=lib/forge-std/src/",
"solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"permit2/=lib/v4-periphery/lib/permit2/",
"lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"@ensdomains/=lib/v4-periphery/lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-periphery/lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.