πŸ”₯DeFi (new)

πŸ”₯ getPairAddress (new)

Fetches and returns pair data of the provided token0+token1 combination (asynchronous).
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).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • to_date (optional): Get the pair address 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.
  • to_block (optional): To get the pair address at this block number
  • exchange (required): The factory name or address of the token exchange. Available values : uniswapv2, uniswapv3, sushiswapv2, pancakeswapv2, pancakeswapv1, quickswap
  • token0_address (required): Token0 address
  • token1_address (required): Token1 address
1
const options = {
2
token0_address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
3
token1_address: "0xe9e7cea3dedca5984780bafc599bd69add087d56",
4
exchange: "pancakeswapv2",
5
chain: "bsc"
6
};
7
const pairAddress = await Moralis.Web3API.defi.getPairAddress(options);
Copied!

Example result:

1
{
2
"token0": {
3
"address": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
4
"name": "Wrapped BNB",
5
"symbol": "WBNB",
6
"logo": null,
7
"logo_hash": null,
8
"thumbnail": null,
9
"decimals": "18",
10
"block_number": "8242108",
11
"validated": 1
12
},
13
"token1": {
14
"address": "0xe9e7cea3dedca5984780bafc599bd69add087d56",
15
"name": "BUSD Token",
16
"symbol": "BUSD",
17
"logo": null,
18
"logo_hash": null,
19
"thumbnail": null,
20
"decimals": "18",
21
"block_number": "8242108",
22
"validated": 1
23
},
24
"pairAddress": "0x58f876857a02d6762e0101bb5c46a8c1ed44dc16"
25
}
Copied!

πŸ”₯ getPairReserves (new)

Get the liquidity reserves for a given pair address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth.
  • to_date (optional): Get the reserves 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.
  • to_block (optional): To get the reserves at this block number
  • pair_address (required): Liquidity pair address
1
const options = {
2
pair_address: "0xa527a61703d82139f8a06bc30097cc9caa2df5a6",
3
chain: "bsc"
4
};
5
const reserves = await Moralis.Web3API.defi.getPairReserves(options);
Copied!

Example result:

1
{
2
"reserve0": "168322120697847448277111",
3
"reserve1": "7119912071113173800533"
Copied!
Last modified 1mo ago