Skip to main content
The hATOM contract is the liquid staking token. It holds the delegations, mints and burns hATOM, compounds rewards and keeps the basket. See Architecture for how the parts fit together.

Conventions

  • Amounts are strings in base units: uatom for ATOM (1 ATOM = 1,000,000 uatom), and the same 6 decimals for hATOM.
  • Decimal and Decimal256 values are strings, such as "0.05".
  • Timestamps are strings in nanoseconds since the Unix epoch.
  • Basis points (bps): 10,000 bps is 100%.
  • Optional fields can be left out.
  • Only MintFromNative, MintFromLsm and Burn accept funds. Every other message refuses them.
  • Every operation ends with an internal AssertInvariants message. If a check fails, the whole transaction reverts.
  • min_out is your guard against a price change between your simulation and your transaction. Set it on every mint and burn.

Instantiate

The funds sent are the tokenfactory’s denom creation fee plus initial_deposit, both in ATOM. Read the fee with gaiad q tokenfactory params.
The values shown are the ones recommended for the Hub in the repository’s deploy/ folder. The deployed contract uses the same fee and params: fee_bps is 0, and every params field equals the example above. Its basket is the current basket, and its admin, operators and fee recipient are on Contract addresses. params are fixed at instantiate. Only a migration can change them.

Execute messages

mint_from_native

Send ATOM as funds. The contract delegates it and mints hATOM at the rate before the mint, less the imbalance fee or plus the bonus.
Refused with NoMintTarget when no basket validator can take stake, and with ImbalanceTooHigh when the imbalance fee is above max_fee_bps. The response’s data is { "minted": "<amount>" }.

mint_from_lsm

Send LSM shares as funds. Each share must be of a basket validator that is bonded and at or under the commission maximum. The contract redeems each share into its own delegation, prices the whole deposit once and mints once.
To get LSM shares from your own delegation, tokenize it first with the Hub’s MsgTokenizeShares. See Integration examples. The response’s data is { "minted": "<amount>" }.

burn

Send hATOM as funds. The contract burns it and pays its value in LSM shares, tokenized from its delegations.
Without a split, the contract takes from the most over-weight validators it holds stake with. It widens the plan until the fee is within max_fee_bps, or until the plan covers every candidate or 50 of them. A burn is never refused for its imbalance fee, and never paid in part. It is refused with InsufficientDelegation when the delegations it may take from cannot cover the payout. The response’s data is { "shares": [<coin>, ...] }, the LSM shares sent. Each share is also in a lsm_share attribute of the wasm event. Redeem the shares with the Hub’s MsgRedeemTokensForShares to hold the delegations in your own name.

compound

Anyone can send it, at any time.
It reads every validator’s pending rewards, claims them, takes fee_bps of them, and delegates the rest to the default_legs most under-weight bonded validators at or under the commission maximum. The fee is minted as hATOM to fee_recipient. The holders’ gain is locked and released over time. It also records jail sightings and commission sightings for the basket.

report_jailed

Anyone can send it.
Records a sighting of a weighted basket validator in or out of the bonded set. Once a validator has been out for a third of unbonding_time_s, in sighted time, a report sets its weight to 0 and scales the other weights up pro rata. Once it has been bonded again for as long, its record clears. Refused with NotJailed for a bonded validator without a record.

sweep

Anyone can send it.
Sends the contract’s whole balance of denom to the fee recipient. Never ATOM or hATOM. This is how rewards paid in other denoms leave the contract.

Admin messages

Queries

rate

The rate and supply, without querying the validators. The cheapest query.
Query
Response
exchange_rate is ATOM per hATOM. For exact amounts, u base units of hATOM are worth floor(u × holders_value / supply) uatom.

state

The contract’s books.
Query
Response

config

The settings: denom, admin, pending_admin, fee_bps, fee_recipient, operators, paused and params.

basket

Every validator the contract tracks, with its weight, delegation and records.
Query
Response
A weight_bps of 0 means the validator is being removed: mints skip it and burns drain it first. expected is the delegation at the end of the last operation. A difference since then is the chain’s: rounding dust if delegated is higher, a slash if it is lower. The contract re-syncs it at the start of the next operation. jail is the jail record, if any.

simulate_mint_native

What mint_from_native would mint for amount of ATOM, in uatom. It uses the same pricing as the execution, on the same state.
Query
Response

simulate_deposit

What one mint_from_lsm would mint for these shares, given per validator as ATOM value. Quote one unit less per share: a share can redeem one unit short.
Returns the same fields as simulate_mint_native.

simulate_burn

What burn would pay for amount of hATOM.
Query
Response
value is the hATOM’s value at the rate. out is the ATOM value of the LSM shares paid. Use out, less a margin, as min_out.
The three simulations fail while the contract is paused. rate, state, config and basket still answer.

Errors