Verified contractPartialMIT
Ledger
Address0x17e6d41160ab4cb18d99104f9b0a2128571f2483
- Balance
0 ETH
- Transactions
4
- Compiler
solc 0.8.34
- Same code
Only this contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- Yes, 800 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,452,567
- Creation transaction
- 0x366b4b90ea…fa7de0673e
src/Ledger.sol
// SPDX-License-Identifier: MIT
//
// StonkChef — https://stonkchef.fun
// X: https://x.com/StonkChef
//
pragma solidity ^0.8.26;
import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
/// @title Ledger
/// @notice On-chain index of every launch, and the list of launcher modules allowed to write
/// to it. New standards are added by authorising a new module.
/// @dev The owner can only add or remove modules. It has no power over any launch, any held
/// liquidity, or any fees.
contract Ledger is Ownable2Step {
/// @notice Contract version.
string public constant VSN = "1.0";
/// @notice Project X (Twitter) link.
string public constant x = "https://x.com/StonkChef";
/// @notice Project website.
string public constant web = "https://stonkchef.fun/";
/// @dev Launch kinds. Further kinds may be used by future modules.
uint8 public constant KIND_COIN = 1;
/// @dev The CHEPE token: a token whose liquidity is timelocked rather than held forever.
uint8 public constant KIND_LAUNCHPAD = 4;
struct Listing {
address asset; // the launched token / collection
address deployer; // who launched it
address pairCurrency; // currency it trades against (address(0) = native ETH)
address pool; // Uniswap V3 pool (the hook for CHEPE)
uint256 positionId; // held Uniswap V3 position id (0 for CHEPE)
uint64 timestamp;
uint8 kind;
}
mapping(address => bool) public isModule;
/// @notice The CHEPE launchpad token. Until it is launched, no other launch is accepted.
address public launchpadToken;
Listing[] private _listings;
mapping(uint8 kind => uint256[]) private _byKind;
mapping(address deployer => uint256[]) private _byDeployer;
/// @dev asset => listing index + 1 (0 = unknown)
mapping(address asset => uint256) private _indexOf;
event ModuleSet(address indexed module, bool allowed);
event LaunchpadSet(address indexed launchpadToken);
event LaunchAdded(
uint256 indexed id,
uint8 indexed kind,
address indexed asset,
address deployer,
address pairCurrency,
address pool,
uint256 positionId
);
error NotModule();
error AlreadyListed();
error LaunchesNotOpen();
error LaunchpadAlreadySet();
constructor(address owner_) Ownable(owner_) {}
function setModule(address module, bool allowed) external onlyOwner {
isModule[module] = allowed;
emit ModuleSet(module, allowed);
}
function addLaunch(
uint8 kind,
address asset,
address deployer,
address pairCurrency,
address pool,
uint256 positionId
) external returns (uint256 id) {
if (!isModule[msg.sender]) revert NotModule();
if (_indexOf[asset] != 0) revert AlreadyListed();
if (kind == KIND_LAUNCHPAD) {
if (launchpadToken != address(0)) revert LaunchpadAlreadySet();
launchpadToken = asset;
emit LaunchpadSet(asset);
} else if (launchpadToken == address(0)) {
revert LaunchesNotOpen();
}
id = _listings.length;
_listings.push(
Listing({
asset: asset,
deployer: deployer,
pairCurrency: pairCurrency,
pool: pool,
positionId: positionId,
timestamp: uint64(block.timestamp),
kind: kind
})
);
_byKind[kind].push(id);
_byDeployer[deployer].push(id);
_indexOf[asset] = id + 1;
emit LaunchAdded(id, kind, asset, deployer, pairCurrency, pool, positionId);
}
/*//////////////////////////////////////////////////////////////
VIEWS
//////////////////////////////////////////////////////////////*/
/// @notice True once CHEPE is live and public launches are accepted.
function isOpen() external view returns (bool) {
return launchpadToken != address(0);
}
function totalLaunches() external view returns (uint256) {
return _listings.length;
}
function totalByKind(uint8 kind) external view returns (uint256) {
return _byKind[kind].length;
}
function totalByDeployer(address deployer) external view returns (uint256) {
return _byDeployer[deployer].length;
}
function launchById(uint256 id) external view returns (Listing memory) {
return _listings[id];
}
function isListed(address asset) external view returns (bool) {
return _indexOf[asset] != 0;
}
function launchFor(address asset) external view returns (Listing memory) {
return _listings[_indexOf[asset] - 1];
}
/// @notice Page through all launches, newest first.
function recentLaunches(uint256 offset, uint256 limit) external view returns (Listing[] memory page) {
uint256 total = _listings.length;
if (offset >= total) return page;
uint256 n = total - offset < limit ? total - offset : limit;
page = new Listing[](n);
for (uint256 i; i < n; ++i) {
page[i] = _listings[total - 1 - offset - i];
}
}
/// @notice Page through launches of one kind, newest first.
function recentByKind(uint8 kind, uint256 offset, uint256 limit) external view returns (Listing[] memory) {
return _slice(_byKind[kind], offset, limit);
}
/// @notice Page through one deployer's launches, newest first.
function recentByDeployer(address deployer, uint256 offset, uint256 limit)
external
view
returns (Listing[] memory)
{
return _slice(_byDeployer[deployer], offset, limit);
}
function _slice(uint256[] storage ids, uint256 offset, uint256 limit)
private
view
returns (Listing[] memory page)
{
uint256 total = ids.length;
if (offset >= total) return page;
uint256 n = total - offset < limit ? total - offset : limit;
page = new Listing[](n);
for (uint256 i; i < n; ++i) {
page[i] = _listings[ids[total - 1 - offset - i]];
}
}
}
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/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;
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 800,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@uniswap/v4-core/=lib/v4-core/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solmate/=lib/v4-core/lib/solmate/",
"v4-core/=lib/v4-core/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.