Links
- Deployments: Contract addresses
- Types:
contracts/hatom/src/msg.rs. The schema binary is incontracts/hatom/src/bin. TypeScript types are ints_types/, generated with ts-codegen 1.7.2. - Contract repository: informalsystems/hatom-contracts
- Audits: Security and audits
Conventions
- Amounts are strings in base units:
uatomfor ATOM (1 ATOM = 1,000,000uatom), and the same 6 decimals for hATOM. DecimalandDecimal256values 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,MintFromLsmandBurnaccept funds. Every other message refuses them. - Every operation ends with an internal
AssertInvariantsmessage. If a check fails, the whole transaction reverts. min_outis 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 plusinitial_deposit, both in ATOM. Read the fee with gaiad q tokenfactory params.
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.
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.
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.
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.
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
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.
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.