DEV Community

SwiftNodes
SwiftNodes

Posted on • Originally published at swiftnodes.io

Osmosis RPC: Querying the Cosmos DEX Where the AMM Is a Chain Module

Osmosis is the largest DEX in the Cosmos ecosystem, and if you're arriving from Ethereum it will feel familiar and alien at the same time. Familiar: it's an AMM with liquidity pools, swaps, and concentrated liquidity. Alien: there is no DEX smart contract to call. The AMM is the chain — a set of native Cosmos SDK modules baked into the protocol. That one fact rewrites how you query it. Here's the map for building on osmosis-1.

The essentials

Osmosis mainnet is the Cosmos chain-id string osmosis-1 — not a numeric EVM chain ID, because Osmosis is non-EVM. It's a Cosmos SDK application chain running CometBFT (Tendermint) consensus, with:

  • ~5-6 second blocks and instant single-block finality — once a block commits, it's final. There are no reorgs (contrast the probabilistic finality you design around in the reorg-handling guide; on a BFT chain that whole class of bug disappears).
  • OSMO as the gas and governance token, with 6 decimals — the base denomination is uosmo (1 OSMO = 1,000,000 uosmo). This trips up everyone once: amounts on the wire are in uosmo, not OSMO.
  • No EVM, no Solidity, no eth_*. You talk to it the Cosmos way.

Three endpoints, three jobs

Unlike an EVM chain where one JSON-RPC endpoint does everything, a Cosmos chain exposes three interfaces, and you'll use different ones for different tasks:

  1. Tendermint RPC (the "RPC" people mean by default) — consensus and block data: status, block, block_results, tx_search, broadcast_tx_sync, and the generic abci_query for reading app state. This is what SwiftNodes serves at /rpc/osmosis.
  2. LCD / REST — a RESTful gateway that maps HTTP GET paths to the same module queries (/cosmos/bank/v1beta1/balances/{addr}, /osmosis/poolmanager/v1beta1/pools). Convenient for browsers and quick reads.
  3. gRPC — the typed, protobuf interface the SDK modules define natively; best for backends that want generated clients and strong types.

We'll do the full REST-vs-Tendermint-RPC-vs-gRPC breakdown in an upcoming Cosmos explainer. For Osmosis the thing to internalize now is which queries matter — and that's where the DEX-as-a-module design bites.

The twist: the AMM is a module, not a contract

On an EVM DEX you'd eth_call a router or pool contract to read a price or simulate a swap. On Osmosis there is no such contract. The exchange logic lives in native chain modules — chiefly poolmanager (routing across pool types), gamm (the classic balancer-style AMM pools), and concentrated liquidity (Uniswap-v3-style ranges). You query these modules directly.

Reading state over Tendermint RPC uses abci_query with a module query path:

# Query a specific pool via abci_query over Tendermint RPC
curl -s -X POST https://rpc.swiftnodes.io/rpc/osmosis?key=YOUR_API_KEY \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"status","params":[]}'
Enter fullscreen mode Exit fullscreen mode

In practice most teams read Osmosis app state through the LCD/REST paths or gRPC because the module queries are already typed there — for example the pool list and a spot-price estimate:

# LCD/REST — list pools and get a spot price (module queries, no contract call)
GET /osmosis/poolmanager/v1beta1/pools
GET /osmosis/poolmanager/v1beta1/pools/{pool_id}/prices?base_asset_denom=...&quote_asset_denom=...
Enter fullscreen mode Exit fullscreen mode

The mental shift: "which module and query?" replaces "which contract and function selector?" Once that clicks, Osmosis is straightforward — the modules are documented, versioned parts of the chain, not opaque bytecode you have to reverse-engineer an ABI for.

The denom gotcha: everything is ibc/<HASH>

Osmosis is an IBC hub, so most assets in its pools didn't originate on Osmosis — they arrived over IBC from the Cosmos Hub, Celestia, Injective, and dozens of others. On the wire those assets are not friendly symbols like ATOM or TIA; they're denoms of the form ibc/1234ABCD... — a hash of the transfer path. When you read balances or pool reserves you'll get ibc/... denoms and uosmo-style micro-units. To display anything human-readable you resolve the denom trace (/ibc/apps/transfer/v1/denom_traces/{hash}) or use the chain registry. Budget for this — it's the #1 thing that surprises EVM developers reading Cosmos DeFi state.

Sending a swap

Transactions are Cosmos SDK messages, not EVM calldata. A swap is a MsgSwapExactAmountIn (poolmanager) you build, sign with CosmJS or the Osmosis SDK, and broadcast via broadcast_tx_sync over Tendermint RPC. Because finality is single-block, once your broadcast returns a committed height you're done — no confirmation-count heuristics, no reorg watch.

// Reading the chain tip with CosmJS (Tendermint RPC under the hood)
import { StargateClient } from "@cosmjs/stargate";
const client = await StargateClient.connect(
  "https://rpc.swiftnodes.io/rpc/osmosis?key=YOUR_API_KEY"
);
console.log(await client.getHeight());   // current osmosis-1 height
Enter fullscreen mode Exit fullscreen mode

The short version

Osmosis (osmosis-1) is a non-EVM Cosmos SDK DEX chain on CometBFT: ~5-6s blocks, single-block BFT finality (no reorgs), OSMO with 6 decimals (uosmo). It exposes three interfaces — Tendermint RPC, LCD/REST, and gRPC — and the defining difference from an EVM DEX is that the AMM is a native chain module (poolmanager/gamm/concentrated liquidity), not a smart contract: you ask "which module and query?" instead of "which contract and selector?". Watch the two Cosmos gotchas — micro-denominations (uosmo) and IBC assets showing as ibc/<HASH> denoms you must resolve.

If you're building on the Cosmos DeFi stack — Osmosis alongside Celestia for DA — a flat-rate Osmosis RPC endpoint gives you Tendermint RPC across dozens of chains under one key. Grab a free key and point CosmJS at:

https://rpc.swiftnodes.io/rpc/osmosis?key=YOUR_API_KEY
Enter fullscreen mode Exit fullscreen mode

Originally published on the SwiftNodes blog. SwiftNodes provides flat-rate multi-chain RPC endpoints — HTTP + WebSocket, 75+ chains, no per-request metering. Grab a free key.

Top comments (0)