Skip to main content

Why integrate hATOM

  • One chain. hATOM is a token on the Cosmos Hub, issued by one contract on the Hub. Reading its rate, minting and burning are Hub queries and Hub transactions. There is no IBC channel, relayer or second chain to follow.
  • A rate you can read on chain. The Rate query returns the exact value of hATOM in ATOM, from the contract’s own books.
  • An instant exit to staked ATOM. A burn pays LSM shares in the same transaction. Redeemed, they are delegations in the holder’s name.
  • Simulations. Each mint and burn has a simulation query that runs the same pricing as the execution.

Setup

The examples use CosmJS 0.39 and moonkittjs, a TypeScript library generated for the Cosmos Hub, including gaia’s x/liquid module. Messages to the hATOM contract are plain JSON sent with CosmJS execute. moonkittjs is only needed for the Hub’s x/liquid messages: tokenizing a delegation and redeeming LSM shares.
A Hydro JS library (planned) will cover these flows.
setup.ts
The hATOM contract address is cosmos1uwn9dv2tqzw5kzqyvksjygukkguwdpqwyu5u0fn239jaeckczltq960spc. See Contract addresses for the denom and the other accounts.

Read the rate

Rate doesn’t query the validators, so it is the cheapest query. A read-only client is enough.
Things to know about the rate:
  • Reward gains enter it at each Compound and are released over at least release_floor_s, so it rises smoothly.
  • Rewards since the last Compound are not in it yet.
  • A slash lowers it. A plain bank transfer of ATOM to the contract raises it at once.
  • Never compute the rate from bank balances. Use the query.

On-chain data

Every operation emits a wasm event with an action attribute: mint_from_native, mint_from_lsm, burn, compound, report_jailed, sweep, set_basket, set_fee, and so on. A mint’s event has minted and recipient. A burn’s has burned, value, out and one lsm_share per share paid. A Compound’s has rewards, fee and fee_minted.

Mint with ATOM

Simulate first, then send the mint with a min_out a little below the simulation.

Mint with staked ATOM

Use this when you already have a delegation to a basket validator. You keep your stake with that validator and skip any unbonding.
1

Tokenize the delegation

Send the Hub’s MsgTokenizeShares with moonkittjs. The response carries the LSM share coin.
2

Simulate the deposit

Quote one unit less than the tokens tokenized: a share can redeem one unit short.
3

Send the shares to the contract

The validator must be in the basket, bonded, and at or under the commission maximum, or the contract refuses the shares. Check with the basket query first.

Burn for staked ATOM

A burn pays LSM shares. Redeem them to hold the delegations in your own name. To get liquid ATOM, undelegate them afterwards and wait for the Hub’s unbonding period.
1

Simulate and burn

2

Collect the shares paid

Each share paid is a lsm_share attribute of the wasm event, as <amount><denom>.
3

Redeem the shares

Send the Hub’s MsgRedeemTokensForShares with moonkittjs, one per share.
If you burn with a different recipient, set share_owner to whoever will hold the shares. The Hub pays the rewards the shares earn until they are redeemed to the record’s owner, not to the holder.

Handle refusals

Send a Compound

Anyone can compound. Keepers and integrators can send it, for example before a large burn.