Verified contractExactMIT
BankrLaunchToken
Address0xd02639575e4520bb40ea12c634ca0c7e6c186ba3
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.26
- Same code
1 more contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,458,268
- Creation transaction
- 0xb4508d45fe…1492789237
8 files
- src/BankrLaunchToken.solmain9.06 KB
- lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol6.54 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol10.8 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol684 B
- lib/openzeppelin-contracts/contracts/utils/Context.sol963 B
- src/interfaces/IHolderRewards.sol9.32 KB
- src/interfaces/ITokenDeployer.sol2.82 KB
src/BankrLaunchToken.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IHolderHook} from "./interfaces/IHolderRewards.sol";
import {ITokenDeployer} from "./interfaces/ITokenDeployer.sol";
/// @title BankrLaunchToken (every chain, Base included) — fixed supply, no owner, no mint, the launch's own wallet cap
/// (an amount for a length of time, or none) with a controller kill switch, and the launch's hold-to-earn
/// distributor as an immutable transfer hook (spec §6).
/// One role, the metadata admin named at launch: it replaces the metadata URI string and nothing else, hands
/// itself on in two steps, and renounces for good. Zero at launch: the URI is fixed from the first block.
/// Vesting lives in CreatorVestingEscrow. The mint recipient (the factory) may add cap exclusions after deploy —
/// for the distributor, whose address depends on this token's and so cannot ride the initcode list (audit L-1).
contract BankrLaunchToken is ERC20 {
string public metadataUri;
/// @notice The most bytes the URI may hold, at launch and on every change. Read from the deployer like the reward
/// hook: the constructor has no room for another argument, and the address never depends on it.
uint32 public immutable metadataMaxBytes;
address public immutable controller;
address public immutable factory;
uint256 public immutable maxBalanceLimit;
/// @notice The launch's HolderRewardsDistributor, told of every balance change; read from the deployer while this
/// token is constructed, so the initcode (and the predicted address) never depends on it.
address public immutable rewardHook;
/// @notice The second trading opens: this launch's own, or its scheduled start when later. Read from the deployer
/// like the reward hook, so the predicted address never depends on it. No one can change it.
uint64 public immutable tradingStart;
/// @notice The second the wallet cap ends; 0: this coin never had one, and no transfer reads storage for it.
uint64 public immutable capEnd;
/// @notice The controller's switch, read only while the cap's window is open.
bool public capDisabled;
mapping(address => bool) public excludedFromBalanceLimit;
/// @notice The only account that may replace `metadataUri`; zero means fixed for good. Declared last: the two
/// role slots share storage with nothing a transfer reads.
address public metadataAdmin;
address public pendingMetadataAdmin;
event BalanceLimitDisabled();
event ExcludedFromBalanceLimit(address indexed account);
/// @dev The value it replaces is in this token's previous MetadataUriSet, else the factory's TokenLaunched.
event MetadataUriSet(address indexed by, string newUri);
event MetadataAdminTransferStarted(address indexed from, address indexed to);
/// @dev `to` zero: renounced, or launched with no admin; nothing can follow it.
event MetadataAdminSet(address indexed from, address indexed to);
error BalanceLimitExceeded(address to, uint256 wouldHold, uint256 limit);
error NotController();
error NotFactory();
error TradingNotStarted();
error NotMetadataAdmin();
error MetadataTooLong();
error HardBound(uint8 bound);
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_,
address recipient_,
string memory metadataUri_,
address metadataAdmin_,
uint256 maxBalanceLimit_,
uint64 capDuration_,
address controller_,
address[] memory excludedFromBalanceLimit_
) ERC20(name_, symbol_) {
metadataMaxBytes = ITokenDeployer(msg.sender).launchingMetadataMax();
if (bytes(metadataUri_).length > metadataMaxBytes) revert MetadataTooLong();
metadataUri = metadataUri_;
metadataAdmin = metadataAdmin_;
emit MetadataAdminSet(address(0), metadataAdmin_);
controller = controller_;
factory = recipient_;
// B11: one encoding of "no cap" (no amount and no length); a cap of zero tokens would block every buy.
if ((maxBalanceLimit_ == 0) != (capDuration_ == 0)) revert HardBound(11);
maxBalanceLimit = maxBalanceLimit_;
// A duration, not an end timestamp: the initcode stays block-independent for the deployer's CREATE2 prediction.
// The cap's window runs from the trading start, so a scheduled launch's first day is capped like any other.
uint64 start = ITokenDeployer(msg.sender).launchingStart();
if (start < block.timestamp) start = uint64(block.timestamp);
tradingStart = start;
// B5: a cap's end fits the suite's 40-bit clocks (no local for it: the constructor keeps its stack room).
// No cap stores 0, which no timestamp is under.
if (capDuration_ != 0 && (uint256(start) + capDuration_) >> 40 != 0) revert HardBound(5);
capEnd = capDuration_ == 0 ? 0 : start + capDuration_;
excludedFromBalanceLimit[recipient_] = true;
for (uint256 i; i < excludedFromBalanceLimit_.length; ++i) {
excludedFromBalanceLimit[excludedFromBalanceLimit_[i]] = true;
}
rewardHook = ITokenDeployer(msg.sender).launchingRewardHook();
_mint(recipient_, totalSupply_);
}
function tokenURI() external view returns (string memory) {
return metadataUri;
}
/// @notice Replaces the URI. Writes that one string: no balance, supply, cap or hook is reachable from here.
function setMetadataUri(string calldata newUri) external {
if (msg.sender != metadataAdmin) revert NotMetadataAdmin();
if (bytes(newUri).length > metadataMaxBytes) revert MetadataTooLong();
metadataUri = newUri;
emit MetadataUriSet(msg.sender, newUri);
}
/// @notice First of two steps; `to` zero withdraws an offer. The admin keeps the role until `to` accepts.
function transferMetadataAdmin(address to) external {
if (msg.sender != metadataAdmin) revert NotMetadataAdmin();
pendingMetadataAdmin = to;
emit MetadataAdminTransferStarted(msg.sender, to);
}
function acceptMetadataAdmin() external {
if (msg.sender != pendingMetadataAdmin) revert NotMetadataAdmin();
_setMetadataAdmin(msg.sender);
}
/// @notice Fixes the URI for good: no admin, no pending offer, and no path back.
function renounceMetadataAdmin() external {
if (msg.sender != metadataAdmin) revert NotMetadataAdmin();
_setMetadataAdmin(address(0));
}
function _setMetadataAdmin(address to) internal {
emit MetadataAdminSet(metadataAdmin, to);
metadataAdmin = to;
delete pendingMetadataAdmin;
}
function disableBalanceLimit() external {
if (msg.sender != controller) revert NotController();
capDisabled = true;
emit BalanceLimitDisabled();
}
/// @notice When the cap stops binding: `capEnd`, or 0 once the controller has ended it (and for a coin without one).
function balanceLimitEnd() external view returns (uint64) {
return capDisabled ? 0 : capEnd;
}
/// @notice Factory only (the launch's post-deploy step): a system contract whose address the initcode could not know.
function excludeFromBalanceLimit(address account) external {
if (msg.sender != factory) revert NotFactory();
excludedFromBalanceLimit[account] = true;
emit ExcludedFromBalanceLimit(account);
}
/// @dev The cap (a self-transfer moves nothing, so it never counts; H13 TOKEN-6), then the distributor with the
/// pre-transfer balances, then the move. Not wrapped in try/catch: a desynced reward ledger is worse than a
/// reverted transfer, and the distributor never reverts on a transfer the ERC-20 accepts nor calls out (spec §6,
/// I8).
function _update(address from, address to, uint256 value) internal override {
// Scheduled start: until trading opens only system contracts (the cap exclusions) move the token, so no wallet
// can sell, lend or pool it early. Not the controller's to lift; it ends by itself at tradingStart.
if (block.timestamp < tradingStart && from != address(0) && !excludedFromBalanceLimit[from]) {
revert TradingNotStarted();
}
// The window is an immutable compare: storage is read only while a cap is running.
if (
to != address(0) && to != from && block.timestamp < capEnd && !capDisabled
&& !excludedFromBalanceLimit[to]
) {
uint256 wouldHold = balanceOf(to) + value;
if (wouldHold > maxBalanceLimit) revert BalanceLimitExceeded(to, wouldHold, maxBalanceLimit);
}
address h = rewardHook;
if (h != address(0)) IHolderHook(h).onTransfer(from, to, value, balanceOf(from), balanceOf(to));
super._update(from, to, value);
}
}
lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation sets the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the `transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @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/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
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;
}
}
src/interfaces/IHolderRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/// @notice What a BankrLaunchToken calls on its distributor before every balance change, with the PRE-transfer balances,
/// so the distributor never calls back into the token (or anything else) from inside a transfer (spec §6, D16).
interface IHolderHook {
function onTransfer(address from, address to, uint256 value, uint256 fromBalance, uint256 toBalance) external;
}
/// @notice The chain's BNKR as its holder leg (BnkrHolderLeg, H17) names it; 0 until BNKR is set there.
interface IBnkrSource {
function bnkr() external view returns (address);
function minPile(address quote) external view returns (uint96);
function pending(bytes32 poolId) external view returns (uint256);
function poke(bytes32 poolId) external;
}
/// @notice Hold-to-earn distributor of one launch (spec §6): holders earn by holding, pro rata to their wallet balance, on
/// three legs that share one eligible supply: the launch token (vest-to-holders, donations), the pool's quote (the
/// creator's holder share, accrued in every swap; Bankr's 5 % where it is paid in quote) and BNKR. No owner, no
/// staking, no keeper (decision 1).
interface IHolderRewardsDistributor is IHolderHook {
/// @dev `amount`: what the notify added to the leg's stream (its floored rate's remainder is carried, not counted).
event RewardsNotified(uint8 indexed leg, uint256 amount, uint256 rewardRate, uint256 periodFinish);
event RewardClaimed(address indexed account, address indexed operator, uint256[3] amounts);
event RewardExcluded(address indexed account, uint256[3] forfeited);
event FeesPulled(uint256 amount);
event VestPushed(uint256 amount);
event BnkrLegEnabled(address indexed bnkr);
error NotToken();
error NotSelf();
error ExcludedAccount();
error NothingToClaim();
error PayoutRefused(); // every owed leg's asset refused its payout (H13 TOKEN-4); the rewards stay claimable
/// @dev claimFor or claimPastBnkr for an account whose ledger claim policy (Q9) refuses the caller.
error ClaimerNotAllowed();
error BadLeg();
error ZeroAddress();
/// @dev accrue from anyone but the fee ledger.
error NotLedger();
/// @dev onLegPush from anyone but the chain's holder leg.
error NotHolderLeg();
/// @dev openVest from anyone but the factory.
error NotFactory();
/// @dev openVest on a launch without a vest-to-holders slice, or a second time.
error VestOpen();
/// @dev A capped call could not be handed its whole cap (a lazy pull, reconcile's BNKR leg, a full claim's payout),
/// or a claimForMany element started under MIN_GAS_PER_CLAIM or ran out of gas.
error InsufficientGas();
/// @dev A hard bound of the design's section 2, by number. At construction: 7, a stream of 0 seconds or an
/// activation divisor under 10,000 (TOKEN) or 10,000,000 (BNKR); 4, a restart share outside 1 to 10,000 bps;
/// 21, a QUOTE floor past 112 bits. In openVest: 5, a vest stream ending past the 40-bit clocks.
error HardBound(uint8 bound);
/// @notice The fee ledger only, inside every swap that credits this coin's creator holder share (decision 1):
/// storage only. `bufferOnly` for a nested swap, which only buffers.
function accrue(uint256 h, bool bufferOnly) external;
/// @notice The holder leg only, after each push (decisions 1-2 seam): a forward's `quoteIn` joins the QUOTE buffer; 0
/// streams the BNKR it pushed. Storage and capped reads only; a no-op inside this distributor's own call.
function onLegPush(uint256 quoteIn) external;
/// @notice The factory only, once, at a launch with a vest-to-holders slice: the TOKEN leg's stream from the cliff.
function openVest(uint256 total, uint64 cliff, uint64 duration) external;
/// @notice Permissionless backstop: pulls the creator's holder share from the ledger, then streams each leg's surplus
/// (QUOTE with its buffer; TOKEN once the vest stream has ended; BNKR). Never reverts for a missing feature
/// (I12). Needs 1,030,873 gas left at its BNKR leg or reverts InsufficientGas.
function reconcile() external returns (uint256 pulled, uint256[3] memory notified);
/// @notice QUOTE taken in and not streaming yet: under the activation floor, under one wei a second while a period
/// is open, or the remainder a fold's floored rate left.
function pendingQuote() external view returns (uint256);
/// @notice Every leg: pulls the creator's holder share from the ledger first when the QUOTE balance cannot pay it,
/// and releases the vest from the escrow when the TOKEN balance cannot.
/// @notice Pays every leg first; then, with the gas the payouts left (POKE_GAS and its gate), pokes the holder leg for
/// this coin's pile when it is due (decision 2's claim retry). Reverts NothingToClaim only when it neither
/// paid nor poked.
function claim() external returns (uint256[3] memory amounts);
/// @notice One leg only, its asset handed all the gas: the escape hatch for an asset whose honest transfer needs
/// more than the 1,000,000 a full claim hands each payout. An asset that refuses reverts PayoutRefused
/// here; claim() pays the other legs and keeps it.
function claimLeg(uint8 leg) external returns (uint256 amount);
/// @notice Pays `account`, never the caller, under the ledger's one claim policy (Q9, mayClaimFor): anyone while
/// the account is open (the default), else only the account or a claim operator it named there.
function claimFor(address account) external returns (uint256[3] memory amounts);
/// @notice claimFor for each account, skipping any the policy refuses the caller.
function claimForMany(address[] calldata accounts) external returns (uint256 paid);
function claimForAuthorized(address account) external returns (uint256[3] memory amounts);
/// @notice One-way: the caller stops earning and forfeits what it accrued to everyone else (a contract that can
/// never claim, such as another launch's distributor holding this token as its quote).
function excludeSelf() external;
function token() external view returns (address);
function quote() external view returns (address);
function bnkr() external view returns (address);
function poolId() external view returns (bytes32);
function escrow() external view returns (address);
function hasHolderVest() external view returns (bool);
function eligibleSupply() external view returns (uint256);
function rewardExcluded(address account) external view returns (bool);
function assetOf(uint8 leg) external view returns (address);
function earned(uint8 leg, address account) external view returns (uint256);
function surplus(uint8 leg) external view returns (uint256);
/// @notice What a leg's first notify must reach before it goes live (review C finding 7).
function activationFloor(uint8 leg) external view returns (uint256);
function rewardsOwed(uint8 leg) external view returns (uint256);
function remainingStream(uint8 leg) external view returns (uint256);
function streamOf(uint8 leg)
external
view
returns (
bool streams,
uint256 periodFinish,
uint256 rewardRate,
uint256 rewardPerTokenStored,
uint256 rewardsAllocated,
uint256 rewardsClaimed
);
function rewardsOf(uint8 leg, address account) external view returns (uint256 settled, uint256 paidCheckpoint);
}
/// @notice Deploys one HolderRewardsDistributor for a token the factory is about to create at `token`, before the token
/// (its constructor binds the distributor as its reward hook), and records it by pool and by token.
interface IHolderRewardsDeployer {
/// @dev Factory only; CREATE2 with salt bytes32(uint256(uint160(token))). `escrow` is the launch's predicted vesting
/// escrow, excluded from rewards whether or not anything vests; `holderVest` says it holds a vest-to-holders
/// schedule for the distributor to push. `holderLeg` and `terms` are the coin's for life (see launchingTerms).
function deploy(
address token,
bytes32 poolId,
address quote,
address escrow,
bool holderVest,
address holderLeg,
uint256 terms
) external returns (address distributor);
/// @notice The terms word of the distributor being constructed right now (transient, so `predict` ignores it):
/// streamSecs | restartBps << 32 | tokenDivisor << 48 | bnkrDivisor << 80 | quoteActivation << 112.
function launchingTerms() external view returns (uint256);
/// @notice Its holder leg, handed over the same way.
function launchingLeg() external view returns (address);
function predict(address token, bytes32 poolId, address quote, address escrow, bool holderVest)
external
view
returns (address);
function distributorOf(bytes32 poolId) external view returns (address);
function distributorOfToken(address token) external view returns (address);
}
src/interfaces/ITokenDeployer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/// @dev What the deployer needs to create one launch token. `launcher` namespaces `salt`; `capController`,
/// `capExclusions`, `capAmount` and `capSecs` configure the token's own wallet cap (both 0: no cap).
struct TokenDeployParams {
string name;
string symbol;
string metadataUri;
address metadataAdmin;
uint256 totalSupply;
address launcher;
bytes32 salt;
address capController;
address[] capExclusions;
uint64 tradingStart; // scheduled start (0 = at launch); passed transiently, never in the initcode or the address
uint256 capAmount; // the most a capped wallet may hold, in raw units
uint32 capSecs; // the cap's length from the trading start
uint32 metadataMaxBytes; // the URI's limit for the coin's life; passed transiently, like the start
}
/// @notice Token creation behind one surface (spec v4.1 R4): a BankrLaunchToken ERC-20 on every chain, Base included
/// (founder ruling 2026-11-04).
interface ITokenDeployer {
/// @notice Pure function of (p, this deployer) — block-independent, so a prediction holds until the launch lands.
function predict(TokenDeployParams calldata p) external view returns (address);
/// @notice Factory only; mints p.totalSupply to msg.sender (the factory) and binds `rewardHook` (the launch's holder
/// distributor) into the token. Reverts PredictionMismatch otherwise.
function deploy(TokenDeployParams calldata p, address rewardHook) external returns (address token);
/// @notice The reward hook of the token being constructed right now (transient), which its constructor reads: the
/// initcode never carries it, so `predict` and salt mining ignore the distributor.
function launchingRewardHook() external view returns (address);
/// @notice The scheduled trading start of the token being constructed right now (transient; 0 = at launch): like
/// the reward hook it stays out of the initcode, so `predict` and salt mining ignore it.
function launchingStart() external view returns (uint64);
/// @notice The metadata URI limit of the token being constructed right now (transient): out of the initcode like
/// the start, so the token's constructor takes no new argument.
function launchingMetadataMax() external view returns (uint32);
event TokenDeployed(address indexed token, address indexed launcher, bytes32 salt);
error NotFactory();
error PredictionMismatch(address predicted, address actual);
error MetadataTooLong();
/// @dev A hard bound of the design's section 2, by number: 6, a supply outside 1e18 to 1e36; 11, a cap amount
/// without a length or a length without an amount.
error HardBound(uint8 bound);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"v4-core/=lib/v4-periphery/lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"v4-periphery/=lib/v4-periphery/",
"v4-hooks-public/=lib/v4-hooks-public/",
"permit2/=lib/permit2/",
"solady/=lib/solady/",
"solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"forge-std/=lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.