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
- Select a network and a supported spot market.
- Resolve the input token and express the amount in its native integer units.
- Read a quote, then derive a minimum output and a deadline.
- Simulate the swap from the funded caller, submit it, and wait for a successful receipt.
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
marketIdis a0x-prefixed, 32-byte spot market ID passed as an ABIstring.tokenInselects the input side for exact input.tokenOutselects 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 MTSerc20:denom on v1.21.- Amounts use the token’s smallest units. For example, 10 USDC is
10000000. Use output units forminOutand input units formaxAmountIn. recipientdefaults 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.deadlineis a Unix timestamp in seconds. Set it to zero to disable the time check.
Market allowlist
Swappable markets are governed bySwapParams, 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.- Testnet
- Mainnet
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.
injectived tx sign and injectived tx broadcast from the admin key.