Skip to main content
Injective’s Swap Precompile exposes the native spot exchange to EVM applications at 0x0000000000000000000000000000000000000068. Use it to read an order-book quote, set a minimum output and deadline, and execute a swap in one call.
V1 exact-input methods and quoteExactOutputV1 are available from v1.20.4. The V2 methods, exact-output execution, and EVM-native MTS token resolution ship in v1.21, including testnet v1.21.0-beta.

Walkthrough

Follow the swap precompile demo to check the testnet allowlist, quote and simulate both swap types, submit a transaction, or run the full flow on a fresh local chain.

How it works

  1. Select a network and a supported spot market.
  2. Resolve the input token and express the amount in its native integer units.
  3. Read a quote, then derive a minimum output and a deadline.
  4. Simulate the swap from the funded caller, submit it, and wait for a successful receipt.
Quotes read the current order book without changing state. Execution places an atomic spot market order on the caller’s default subaccount and credits the output to the recipient. If the minimum output or deadline check fails, the swap’s state changes revert. Transaction gas can still be charged. For exact input, amountIn is an input budget. Thin liquidity or quantity ticks can leave part of it unspent. The remainder stays with the caller and minOut sets the minimum output for the fill. For exact output, execution must deliver at least amountOut within maxAmountIn or revert. Quantity ticks can cause slightly more output to be delivered. Orders can change between quoting and execution. Quotes use the undiscounted taker fee, and execution applies the caller’s fee discount and skips paused or frozen makers. Use a fresh quote to set your limits. Execution enforces minOut for exact input or maxAmountIn for exact output, along with any deadline you set.

Swap Precompile Interface

  • marketId is a 0x-prefixed, 32-byte spot market ID passed as an ABI string.
  • tokenIn selects the input side for exact input. tokenOut selects the asset to receive for exact output. Use the zero address for native INJ. Other tokens resolve through a registered ERC20 pair or an EVM-native MTS erc20: denom on v1.21.
  • Amounts use the token’s smallest units. For example, 10 USDC is 10000000. Use output units for minOut and input units for maxAmountIn.
  • recipient defaults to the caller when set to the zero address. The precompile spends the immediate caller’s bank balance, including when a contract calls it. Invoke it with zero transaction value. ERC20 approval is unnecessary.
  • deadline is a Unix timestamp in seconds. Set it to zero to disable the time check.
The V1 and V2 suffixes refer to the precompile’s ABI versions. The exchange module versions its protobuf types independently. When checking a settled swap against the amounts returned by the precompile, allow for a difference of one smallest token unit. Fractional amounts accumulate in the caller’s default subaccount and can affect when a whole unit moves into or out of the bank balance.

Market allowlist

Swappable markets are governed by SwapParams, an enable flag plus a market allowlist inside the exchange module parameters. Calling the precompile on a market that is not allowlisted reverts with:

Checking the current allowlist

Choose your network to query the exchange module’s v2 swap parameters.
Use jq '.params.exchange_admins' to list the exchange admins on the selected network.

Requesting a market

If you are building on the swap precompile and need a market allowlisted, reach out in the #developers channel of the Injective Discord with the spot market id, or raise it with your Injective partner contact. Market ids for active spot markets are listed at /injective/exchange/v2/spot/markets?status=Active.

Updating the allowlist (exchange admins)

MsgUpdateSwapParams is callable by the governance authority or any address in the exchange_admins parameter. It takes effect immediately, with no governance vote required when sent by an admin. The message fully replaces the swap parameter group. Always include every market that should remain allowlisted and keep enabled: true, because omitting an existing market removes it and omitting the flag pauses all swaps.
Sign and broadcast the transaction document with injectived tx sign and injectived tx broadcast from the admin key.
Last modified on November 19, 2026