Contracts
$SUB Token
$SUB — ERC-20 with burn, permits and a testnet faucet
- Contract
- LayerSubToken
- Source
- src/LayerSubToken.sol
- Pragma
- 0.8.24
- Decimals
- 18
Overview
$SUB is the core utility token of the LayerSub ecosystem: a standard 18-decimal ERC-20 with burn mechanics, EIP-2612 permits, and an open faucet so anyone can self-serve testnet tokens for the staking demo.
It is the only token the staking vault touches — the same asset is both the staked principal and the reward, which is what makes the vault's solvency model necessary.
Constructor
constructor(uint256 initialSupply, address initialOwner)Notes
- `initialSupply` is in whole tokens, not wei — the constructor scales it by `10 ** decimals()` internally. The Sepolia deployment passed 1,000,000.
- The entire initial supply is minted to `initialOwner`, which also receives contract ownership.
- Reverts with ZeroAddress if initialOwner is the zero address. An initialSupply of zero is allowed and mints nothing.
State
- FAUCET_MAX_AMOUNTuint256constant= 1000e18
Largest amount a single mintFaucet call may mint — 1,000 $SUB.
- FAUCET_COOLDOWNuint256constant= 1 hours
Minimum delay between two successful faucet claims for the same recipient.
- lastFaucetClaimmapping(address => uint256)public storage
Timestamp of each recipient's last successful faucet claim. Zero means never claimed.
Functions
6 documented functions. Owner-gated calls are flagged in red.
mintFaucet
PermissionlessmintFaucet(address to, uint256 amount) externalMints up to 1,000 $SUB to any address, once per hour per recipient.
Permissionless by design so Sepolia users can fund themselves without a deployer in the loop. It is rate limited per recipient, but supply is otherwise unbounded.
Parameters
- toaddress
Recipient of the minted tokens. Cannot be the zero address.
- amountuint256
Amount in wei-denominated $SUB. Must be non-zero and at most FAUCET_MAX_AMOUNT.
Reverts
- ZeroAddress
when to is the zero address
- ZeroAmount
when amount is zero
- FaucetAmountTooLarge
when amount exceeds FAUCET_MAX_AMOUNT (1,000 $SUB)
- FaucetCooldownActive
when the recipient claimed less than FAUCET_COOLDOWN ago
Notes
- The cooldown is keyed on `to`, not on the caller, so one wallet can fund many recipients but cannot top up the same recipient twice within the hour.
- A recipient's first claim is always allowed: the cooldown branch is skipped while lastFaucetClaim is still zero.
- This function must be removed, or gated behind access control, before any mainnet deployment. Its presence is why $SUB carries no monetary value today.
mint
Owner onlymint(address to, uint256 amount) external onlyOwnerMints arbitrary $SUB. Used to seed the vault's reward budget.
Parameters
- toaddress
Recipient. Cannot be the zero address.
- amountuint256
Amount in wei-denominated $SUB. Must be non-zero.
Reverts
- ZeroAddress
when to is the zero address
- ZeroAmount
when amount is zero
faucetAvailableAt
ViewfaucetAvailableAt(address account) external view returns (uint256)Timestamp at which account may next call mintFaucet.
Returns
- availableAtuint256
lastFaucetClaim + FAUCET_COOLDOWN, or 0 if the account has never claimed.
Notes
- The dApp polls this to drive the faucet button's countdown state.
burn
Permissionlessburn(uint256 value) publicDestroys the caller's own tokens. Inherited from ERC20Burnable.
burnFrom
PermissionlessburnFrom(address account, uint256 value) publicDestroys tokens from an account that has approved the caller. Inherited from ERC20Burnable.
permit
Permissionlesspermit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) publicSets an allowance from a signature instead of a transaction. EIP-2612, via ERC20Permit.
Notes
- Lets a staker approve the vault without spending gas on a separate approve, using the domain name "LayerSub".
Events
FaucetMinted
FaucetMinted(address indexed to, uint256 amount)Emitted on every successful faucet claim.
- toindexedaddress
Recipient of the minted tokens.
- amountuint256
Amount minted, in wei-denominated $SUB.
Custom errors
ZeroAddress()A zero address was supplied where one is not allowed.
ZeroAmount()A zero amount was supplied where one is not allowed.
FaucetAmountTooLarge(uint256 requested, uint256 maximum)The requested faucet amount exceeds FAUCET_MAX_AMOUNT. Carries both values.
FaucetCooldownActive(uint256 availableAt)The recipient is still within the faucet cooldown. Carries the timestamp at which they may retry.