Skip to content

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.

FunctionAccessNotes
balanceOf(addr)viewDisplay balance (fragments, 18 dec); scales every rebase.
balanceOfUnderlying(addr)viewRebase-invariant share (internal units, 1e24).
totalSupply()viewDerived from initSupply × scalingFactor.
hamsScalingFactor()viewGlobal rebase multiplier (genesis 1e18).
transfer / approve / allowancepublicStandard ERC-20, denominated in fragments.
mint(to, amount)rebaser or incentivizerMints fragments; increases initSupply.
rebase(epoch, indexDelta, positive)rebaser onlyMoves the scaling factor within bounds.
setRebaser(addr) / setIncentivizer(addr)ownerSet the two privileged roles.
upgradeToAndCall(impl, data)ownerUUPS 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

FunctionNotes
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 · rebasingActivestate getters

Rebase flow

FunctionAccessNotes
init_twap()ownerSnapshot TWAP; once.
activate_rebasing()anyoneAfter rebaseDelay warmup; one-way.
commitRebase(hash)keeperIn-window; hash = keccak256(committer, salt, minReserveOut).
revealAndRebase(salt, minReserveOut)keeper25–50 blocks after commit; USD mode enforces oracle-drift bound.
cancelCommit() / cancelExpiredCommit()committer·owner / anyoneRecover a stuck commit.
forceRebase(minReserveOut)ownerEmergency, owner-only; bypasses commit/reveal (and its sandwich protection) but still requires the rebase window and interval.

AdminsetKeeper, setTreasury, setDeviationThreshold, setRebaseLag, setRebaseMintPerc, setMaxSlippageFactor, setRebaseTimingParameters, setRebaseDelay, secondary-oracle setters; and USD-mode: proposeReserveUsdOraclesapplyReserveUsdOracles (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).

FunctionAccessNotes
stake(amount) / withdraw(amount) / exit()publicStake/unstake the LP token; exit withdraws all + claims.
getReward()publicClaims earned HAM (scaled by hamsScalingFactor at payout).
earned(addr) · balanceOf(addr) · totalSupply() · rewardRate() · periodFinish()viewReward + stake accounting (pre-scaling units for earned/rewardRate).
notifyRewardAmount(reward)rewardDistributionStarts/extends a reward period (one-time bootstrap mint before START_TIME; later periods self-fund via the halving mint).
setRewardDistribution(addr)ownerAuthorize the notifier.
governanceRecoverUnsupported(token, amt, to)ownerRescue stray ERC-20s (not the staking token or HAM).

HAM // Elastic supply pegged to $1.00 · Not financial advice.