Skip to main content

Get DEX token pair address

GEThttps://deep-index.moralis.io/api/v2/:token0_address/:token1_address/pairAddress

Fetch the pair data of the provided token0+token1 combination. The token0 and token1 options are interchangable (ie. there is no different outcome in "token0=WETH and token1=USDT" or "token0=USDT and token1=WETH")

PATH PARAMS
token0_addressstringrequired
The token0 address
token1_addressstringrequired
The token1 address
QUERY PARAMS
chainstring
The chain to query
to_blockstring
The block number to get the reserves from
to_datestring

Get the reserves up to this date (any format that is accepted by momentjs)

  • Provide the param 'to_block' or 'to_date'
  • If 'to_date' and 'to_block' are provided, 'to_block' will be used.
exchangestringrequired
The factory name or address of the token exchange
Responses
API KEY
import Moralis  from 'moralis';
import { EvmChain } from '@moralisweb3/evm-utils';

try {
const chain = EvmChain.ETHEREUM;

const token0Address = '0x1234567890123456789012345678901234567890';

const token1Address = '0x1234567890123456789012345678901234567890';

await Moralis.start({
apiKey: 'YOUR_API_KEY',
// ...and any other configuration
});

const response = await Moralis.EvmApi.defi.getPairAddress({
token0Address,
token1Address,
chain,
});

console.log(response?.result);
} catch (e) {
console.error(e);
}

Response Example
{
"pairAddress": "0xbbb9bf440d0f686487925fef3b0a0f9aa67753f6"
}