Skip to content

Latest commit

 

History

History
142 lines (112 loc) · 6 KB

File metadata and controls

142 lines (112 loc) · 6 KB

Chainlink External Adapter for Uniswap V2

2.0.20 v2

This adapter allows querying Uniswap V2 contracts

This document was generated automatically. Please see README Generator for more info.

Environment Variables

Required? Name Description Type Options Default
ETHEREUM_RPC_URL An http(s) RPC URL to a blockchain node that can read the UniswapV2 contracts string
RPC_URL A fallback http(s) RPC URL to a backup blockchain node that can read the UniswapV2 contracts string
ETHEREUM_CHAIN_ID The chain id to connect to string 1
BLOCKCHAIN_NETWORK The network to get pre-defined token addresses from. NOTE: THIS SHOULD NOT BE CHANGED ON ETHEREUM MAINNET string ethereum
ROUTER_CONTRACT The Uniswap router address to get price from. NOTE: THIS SHOULD NOT BE CHANGED ON ETHEREUM MAINNET string 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D

Data Provider Rate Limits

There are no rate limits for this adapter.


Input Parameters

Every EA supports base input parameters from this list

Required? Name Description Type Options Default
endpoint The endpoint to use string crypto crypto

Crypto Endpoint

Gets the exchange rate between two tokens

crypto is the only supported name for this endpoint.

Input Params

Required? Name Aliases Description Type Options Default Depends On Not Valid With
from base, coin The symbol or address of the currency to query string
fromAddress Optional param to pre-define the address to convert from. If set, it takes precedence over from string
fromDecimals Optional param to pre-define the number of decimals in the from token. Setting this will make the query run faster number
to market, quote The symbol or address of the currency to convert to string
toAddress Optional param to pre-define the address to convert to. If set, it takes precedence over to string
toDecimals Optional param to pre-define the number of decimals in the to token. Setting this will make the query run faster number
amount The exchange amount to get the rate of. The amount is in full units, e.g. 1 USDC, 1 ETH number 1

Example

Request:

{
  "id": "1",
  "data": {
    "from": "USDC",
    "to": "USDT",
    "amount": 1,
    "endpoint": "crypto",
    "resultPath": "rate"
  },
  "debug": {
    "cacheKey": "8+57VCexLY5xpa6wBMELqPDkP4w="
  }
}

Response:

{
  "jobRunID": "1",
  "data": {
    "input": "1000000",
    "inputToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "inputDecimals": 6,
    "output": "999856",
    "outputToken": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    "outputDecimals": 6,
    "rate": 0.999856,
    "result": 0.999856
  },
  "result": 0.999856,
  "statusCode": 200,
  "providerStatusCode": 200
}
Additional Examples

Request:

{
  "id": "1",
  "data": {
    "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "fromDecimals": 18,
    "to": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
    "toDecimals": 18,
    "amount": 10,
    "endpoint": "crypto",
    "resultPath": "rate"
  },
  "debug": {
    "cacheKey": "vDDkmKyrSIMCbdoztDdiWyIDYmQ="
  }
}

Response:

{
  "jobRunID": "1",
  "data": {
    "input": "10000000000000000000",
    "inputToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "inputDecimals": 18,
    "output": "2108971134647913998340",
    "outputToken": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
    "outputDecimals": 18,
    "rate": 210.8971134647914,
    "result": 210.8971134647914
  },
  "result": 210.8971134647914,
  "statusCode": 200,
  "providerStatusCode": 200
}

MIT License