evm_api.defi
evm_api.defi.get_pair_address()
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”)
from moralis import evm_api
api_key = "YOUR_API_KEY"
params = {
"exchange": "uniswapv2",
"token0_address": "0x2b591e99afe9f32eaa6214f7b7629768c40eeb39",
"token1_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"chain": "eth",
"to_block": "",
"to_date": "",
}
result = evm_api.defi.get_pair_address(
api_key=api_key,
params=params,
)
print(result)
Name | Type | Description | Required | Default | Example |
---|---|---|---|---|---|
exchange | enum[str]: - “uniswapv2” - “uniswapv3” - “sushiswapv2” - “pancakeswapv2” - “pancakeswapv1” - “quickswap” |
The factory name or address of the token exchange | Yes | “uniswapv2” | |
token0_address | str | The token0 address | Yes | “0x2b591e99afe9f32eaa6214f7b7629768c40eeb39” | |
token1_address | str | The token1 address | Yes | “0xdac17f958d2ee523a2206206994597c13d831ec7” | |
chain | enum[str]: - “eth” - “0x1” - “goerli” - “0x5” - “sepolia” - “0xaa36a7” - “polygon” - “0x89” - “mumbai” - “0x13881” - “bsc” - “0x38” - “bsc testnet” - “0x61” - “avalanche” - “0xa86a” - “fantom” - “0xfa” - “palm” - “0x2a15c308d” - “cronos” - “0x19” - “arbitrum” - “0xa4b1” |
The chain to query | “eth” | “eth” | |
to_block | str | The block number to get the reserves from | ”” | ||
to_date | str | 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. |
”” |
evm_api.defi.get_pair_reserves()
Get the liquidity reserves for a given pair address. Only Uniswap V2 based exchanges supported at the moment.
from moralis import evm_api
api_key = "YOUR_API_KEY"
params = {
"pair_address": "0xa2107fa5b38d9bbd2c461d6edf11b11a50f6b974",
"chain": "eth",
"to_block": "",
"to_date": "",
}
result = evm_api.defi.get_pair_reserves(
api_key=api_key,
params=params,
)
print(result)
Name | Type | Description | Required | Default | Example |
---|---|---|---|---|---|
pair_address | str | The liquidity pair address | Yes | “0xa2107fa5b38d9bbd2c461d6edf11b11a50f6b974” | |
chain | enum[str]: - “eth” - “0x1” - “goerli” - “0x5” - “sepolia” - “0xaa36a7” - “polygon” - “0x89” - “mumbai” - “0x13881” - “bsc” - “0x38” - “bsc testnet” - “0x61” - “avalanche” - “0xa86a” - “fantom” - “0xfa” - “palm” - “0x2a15c308d” - “cronos” - “0x19” - “arbitrum” - “0xa4b1” |
The chain to query | “eth” | “eth” | |
to_block | str | The block number to get the reserves from | ”” | ||
to_date | str | 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. |
”” |