This document describes the public interface of the AMM contract for integration with third‑party applications and services. Message examples are provided in JSON format — exactly as they are sent to
Notation and conventions
Token denomination: a discriminator object indicating the type of asset. Exactly one of the following forms is used in requests/responses:
Native coin of the chain: { "native": "<denom>" }
CW20 token: { "cw20": "<address>" }
Numeric fields:
Amounts are strings with integer values in minimal units (e.g., uatom, uosmo, etc.). No separators.
Fee percentages are decimal fractions in the inclusive range [0, 1], also passed as strings (e.g., "0.003" = 0.3%).
Unless explicitly stated otherwise, all amounts are unsigned and specified in minimal units of their denomination.
Queries (QueryMsg)
The contract supports the following queries. Each entry lists its purpose, request structure, and expected response.
Both quotes are computed by the contract based on the current pool reserves and fee settings (lp_fee_percent, protocol_fee_percent).
How to obtain pool reserves and metadata
Call Info:
Check token1_reserve, token2_reserve, and the denominations token1_denom, token2_denom. You will also receive the LP token address (lp_token_address) and its total supply (lp_token_supply).
As a rule of thumb, the spot price is approximately token1_reserve / token2_reserve (depending on which way you quote).
How to obtain current fees
Call Fee:
The response includes the pool fee percentage and the protocol fee recipient. Percentages are fractions of 1 (e.g., "0.01" = 1%).
Instantiate message
Message for deploying the contract. Fields and their meaning:
InstantiateMsg:
Notes:
token1_denom, token2_denom — the assets that form the trading pair. Each is a discriminator object with either native or cw20 key.
lp_token_code_id — code ID of the CW20 contract used to mint the pool’s LP token.
owner — admin address (may be null/omitted). Has the right to update fee parameters and owner.
protocol_fee_recipient — recipient of the protocol fee (e.g., community pool).
protocol_fee_percent — protocol fee share (0..1).
lp_fee_percent — pool fee share (0..1).
Execute messages (ExecuteMsg) — brief
Below are the key execute commands. Full field formats follow the contract schema and examples. If a parameter is marked optional (?), it may be omitted.
Update fee parameters and owner. Requires owner privileges.
freeze_deposits { freeze }
Enable/disable accepting new liquidity deposits (administrative).
Security notes:
It is recommended to always set min_* parameters and expiration to avoid MEV/slippage and stale quotes.
For CW20 operations, you may need to perform approve/increase_allowance per the CW20 standard, depending on your execution environment.
Quick query examples
Pool reserves:
Price 1 -> 2 for 1 minimal unit:
Fees:
LP balance for an address:
Errors and general recommendations
If input parameters are invalid (e.g., negative values, zero amounts, denomination mismatch), the contract will return an execution error and the transaction will be reverted.
With low liquidity, the price query may return very small outputs; use min_* guards in execute messages.
To assess slippage, first call the corresponding price query, then form the execute message with a reasonable margin.
Compatibility and versions
Message formats are compatible with the CosmWasm ecosystem and assume the standard mechanisms of sending queries/transactions through the network’s RPC/REST services.
When upgrading the contract, follow the project’s changelog and verify whether field names or semantics have changed.