> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hydro.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> How hATOM works on the Cosmos Hub: one contract, the Hub's own modules, the rate and the trust model.

hATOM is a liquid staking token for ATOM. It is one CosmWasm contract on the Cosmos Hub. The contract stakes ATOM with a weighted list of Hub validators, called the basket, and issues hATOM against that stake.

## Hub native by design

Everything happens on the Cosmos Hub:

* **One contract.** The hATOM contract holds the delegations and keeps the books.
* **The Hub's `x/liquid` module** (the liquid staking module, or LSM). The contract redeems LSM shares into delegations for deposits, and tokenizes delegations into LSM shares for exits.
* **The Hub's tokenfactory.** The contract creates the hATOM denom at instantiate and mints and burns it.
* **The Hub's staking module.** Delegations are ordinary Hub delegations to Hub validators.

There is no separate chain, no IBC transfer, no interchain account, no interchain query and no relayer. Your ATOM never leaves the Hub, and there is no bridging step.

Cross-chain liquid staking tokens work differently. The token lives on another chain. Your ATOM travels there over IBC, and that chain stakes it back on the Hub through an interchain account. It learns the state of the stake through interchain queries, and relayers carry every packet between the two chains. Each of those pieces is another system to trust and another step that can stall. hATOM has none of them: a mint, a burn or a reward cycle is one Hub transaction, settled in one block.

## The flows

| Flow | Message | What happens |
| - | - | - |
| Mint with ATOM | `MintFromNative` | The contract delegates the ATOM sent and mints hATOM at the current rate. |
| Mint with staked ATOM | `MintFromLsm` | You tokenize a delegation into LSM shares, then send the shares. The contract redeems them into its own delegations and mints hATOM. |
| Exit | `Burn` | The contract burns the hATOM sent and pays its value in LSM shares, tokenized from its delegations. You redeem the shares into a delegation in your own name. |
| Rewards | `Compound` | Anyone can send it. The contract claims every validator's rewards, takes the fee, and delegates the rest. |

A burn is an instant exit to **staked** ATOM. You hold a delegation as soon as you redeem the shares. To get liquid ATOM, you then undelegate it on the Hub and wait for the Hub's unbonding period.

## The rate

The exchange rate is the ATOM value of one hATOM. In base units:

```text theme={null}
rate = holders_value / supply
holders_value = D + (idle - U) + U × (1 - f) - budget - locked
```

| Term | Meaning |
| - | - |
| `D` | the contract's delegations |
| `idle` | the contract's undelegated ATOM held for holders |
| `U` | idle rewards that have not been through the fee yet |
| `f` | `fee_bps / 10,000` |
| `budget` | the imbalance pool, held for bonuses (capped) |
| `locked` | the part of recent reward gains still being released |

Rules that follow from it:

* Rewards not claimed yet count as 0. They enter the rate at the next `Compound`.
* Each gain is released linearly over `max(release_floor_s, time since the last Compound)`. The rate never jumps at a moment anyone can trigger.
* The rate never decreases for existing holders, except for a loss the locked amount cannot cover, such as a slash. The contract checks this after every operation.
* Every rounding favours existing holders over the caller.

Read the rate with the `Rate` query. See [Integration examples](https://docs.hydro.markets/hatom/developers/integration-examples.md#read-the-rate).

## The basket and the imbalance pool

The basket is a list of validators with target weights in basis points that sum to 10,000. Default mints go to the most under-weight validators, and default burns take from the most over-weight ones.

An operation that moves the stake away from the weights pays an imbalance fee: the caller receives fewer tokens. The fee stays in the contract as the imbalance pool. An operation that moves the stake toward the weights can receive a bonus (a rebate), paid only from that pool. The pool is left out of the rate, so holders never pay for bonuses and exits never take part of it. The fee is exact and grows with the square of the imbalance (steepness `imbalance.lambda`).

* Entries whose fee is above `imbalance.max_fee_bps` are refused.
* Exits are never refused for their fee. The contract widens its plan, or charges a caller's `split` its exact fee.
* Bonuses are switched off in some situations: after a basket change, while a weighted validator is out of the bonded set or above the commission maximum, and for a hold period after such a validator is back under it. `State.rebates_paused` shows whether bonuses are off.

## Validators out of the bonded set

Every operation reads the bonded set itself.

* New stake only goes to bonded validators at or under `max_validator_commission`.
* A burn can take from any validator the contract holds stake with, bonded or not.
* `ReportJailed` (anyone) records sightings of a weighted validator out of the bonded set. Once it 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. Its stake then leaves through burns.

## Roles and trust

| Role | Who | Can |
| - | - | - |
| wasm admin | set at instantiate, a DAO | migrate the contract to any code, at once |
| admin | `Config.admin` | `SetBasket`, `SetFee`, `SetOperators`, `TransferAdmin`, `Pause`, `Unpause` |
| operators | `Config.operators` | `Pause` only |
| anyone | | `MintFromNative`, `MintFromLsm`, `Burn`, `Compound`, `ReportJailed`, `Sweep`, every query |

What the roles mean for holders:

* The admin can pause every operation, exits included, for as long as it likes. Only the admin can unpause.
* The admin can change the fee at once. The fee only applies to rewards, never to the stake.
* The admin can change the basket at any time. Validators left out keep their stake at weight 0 until burns drain it. Nothing is redelegated.
* The wasm admin can migrate the contract to any code at once.
* The settings in `Params` are fixed at instantiate. Only a migration can change them.

On the [deployed contract](https://docs.hydro.markets/hatom/developers/addresses.md):

* The admin is the Hydro Committee, a [DAO DAO DAO](https://daodao.zone/dao/cosmos1elg0jdr2cn7jdqu4agqnvhmy8n4aayxg365esmudgk56vn7dlf0s8v0j39) (`cosmos1elg0jdr2cn7jdqu4agqnvhmy8n4aayxg365esmudgk56vn7dlf0s8v0j39`). It has 9 members. A proposal passes with 55% of the votes cast and a quorum of 20%, after 2 days of voting.
* The wasm admin is also the Hydro Committee (`cosmos1elg0jdr2cn7jdqu4agqnvhmy8n4aayxg365esmudgk56vn7dlf0s8v0j39`).
* Operators can only pause, so Hydro can react quickly to any circumstance without waiting for a Committee vote. Only the Hydro Committee can unpause.

See [Security and audits](https://docs.hydro.markets/hatom/developers/security-and-audits.md) for the full list of assumptions and protections.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.