Appearance
Reference: contracts
The launch deployment is three contracts plus a shared base. Signatures are abbreviated; the authoritative source is contracts/ and the interfaces under contracts/interfaces/. Parameter values live in parameters.md.
An earlier single-sided staking pool (
HAMDistributionPool) was removed before launch; see Liquidity strategy for why.
HAM — the token (contracts/HAM.sol)
UUPS-upgradeable rebasing ERC-20. Ownership: Ownable2StepUpgradeable. Deployed behind an ERC1967Proxy.
| Function | Access | Notes |
|---|---|---|
balanceOf(addr) | view | Display balance (fragments, 18 dec); scales every rebase. |
balanceOfUnderlying(addr) | view | Rebase-invariant share (internal units, 1e24). |
totalSupply() | view | Derived from initSupply × scalingFactor. |
hamsScalingFactor() | view | Global rebase multiplier (genesis 1e18). |
transfer / approve / allowance | public | Standard ERC-20, denominated in fragments. |
mint(to, amount) | rebaser or incentivizer | Mints fragments; increases initSupply. |
rebase(epoch, indexDelta, positive) | rebaser only | Moves the scaling factor within bounds. |
setRebaser(addr) / setIncentivizer(addr) | owner | Set the two privileged roles. |
upgradeToAndCall(impl, data) | owner | UUPS upgrade — no timelock. |
Events: standard Transfer / Approval, plus Rebase(epoch, previousScalingFactor, newScalingFactor), Mint, NewRebaser, NewIncentivizer. Rebase outcomes are also observable via the rebaser's RebaseExecuted and the changed hamsScalingFactor.
HAMRebaser — rebase policy (contracts/HAMRebaser.sol)
Ownership: Ownable2Step + ReentrancyGuard. Holds immutable yam (HAM), reserveToken, uniswapPair, isToken0, and usdPegMode.
Views
| Function | Notes |
|---|---|
getCurrentExchangeRate() | Peg-denominated rate. USD mode: TWAP × reserveUsd. Use this, not getCurrentTWAP, for USD-mode price. |
getCurrentTWAP() | Pool TWAP only (reserve per HAM); returns 0 if no time elapsed. |
getReserveUsdPrice() | Primary reserve/USD feed (USD mode); reverts on bad/stale answer. |
computeOffPegPerc(rate) | (offPegPerc, positive) vs targetRate, capped at MAX_RATE. |
inRebaseWindow() · epoch · targetRate · usdPegMode · rebasingActive | state getters |
Rebase flow
| Function | Access | Notes |
|---|---|---|
init_twap() | owner | Snapshot TWAP; once. |
activate_rebasing() | anyone | After rebaseDelay warmup; one-way. |
commitRebase(hash) | keeper | In-window; hash = keccak256(committer, salt, minReserveOut). |
revealAndRebase(salt, minReserveOut) | keeper | 25–50 blocks after commit; USD mode enforces oracle-drift bound. |
cancelCommit() / cancelExpiredCommit() | committer·owner / anyone | Recover a stuck commit. |
forceRebase(minReserveOut) | owner | Emergency, owner-only; bypasses commit/reveal (and its sandwich protection) but still requires the rebase window and interval. |
Admin — setKeeper, setTreasury, setDeviationThreshold, setRebaseLag, setRebaseMintPerc, setMaxSlippageFactor, setRebaseTimingParameters, setRebaseDelay, secondary-oracle setters; and USD-mode: proposeReserveUsdOracles → applyReserveUsdOracles (24h timelock) / cancelReserveUsdOracleProposal, setMaxReserveOracleAge, setMaxCommitRevealOracleDrift. setTargetRate reverts in USD mode.
Key events: RebaseExecuted, UsdPegPriceComputed, RebaseCommitted, ReserveUsdOraclesProposed, NewTreasury, KeeperSet.
HAMIncentivizer — LP genesis farm (contracts/rewards/HAMIncentivizer.sol)
Synthetix-style staking on the HAM/WHYPE LP token, halving HAM emissions. Ownership: Ownable. Extends LPTokenWrapper (shared stake/withdraw base).
| Function | Access | Notes |
|---|---|---|
stake(amount) / withdraw(amount) / exit() | public | Stake/unstake the LP token; exit withdraws all + claims. |
getReward() | public | Claims earned HAM (scaled by hamsScalingFactor at payout). |
earned(addr) · balanceOf(addr) · totalSupply() · rewardRate() · periodFinish() | view | Reward + stake accounting (pre-scaling units for earned/rewardRate). |
notifyRewardAmount(reward) | rewardDistribution | Starts/extends a reward period (one-time bootstrap mint before START_TIME; later periods self-fund via the halving mint). |
setRewardDistribution(addr) | owner | Authorize the notifier. |
governanceRecoverUnsupported(token, amt, to) | owner | Rescue stray ERC-20s (not the staking token or HAM). |