Tellor Docs
Search…
Index Tracker
The Index Tracker module collects and stores data from HTTP or Blockchain endpoints.
The index tracker module uses an index.json file.
The structure of the file is as follow:
1
{
2
"AMPL/USD/VWAP": {
3
"interval": "10m",
4
"endpoints": [
5
{
6
"URL": "https://api.anyblock.tools/market/AMPL_USD_via_ALL/daily-volume?roundDay=false&debug=false&access_token=$ANYBLOCK_KEY&start=$NOW&end=$EOD",
7
"param": "$.overallVWAP"
8
}
9
]
10
},
11
...
12
"AMPL/ETH": [
13
"interval": "1m",
14
"endpoints": [
15
{
16
"URL": "Mainnet:0xc5be99a02c6857f9eac67bbce58df5572498f40c,Rinkeby:0x7e62a502232f1feB77Adf8b8ca023cc9fB133418",
17
"type": "ethereum",
18
"parser": "Uniswap"
19
}
20
]
21
],
22
...
23
}
Copied!
Any env variable is substituted in the API URL. The example above uses an env variable to provide the api key required to access the endpoint.
There are some special env variables that can be added to the url and are dinamycly expanded before each request - $NOW, $EOD. This is required for some APIs that require specifying start and end timestamp like in the example above.

Index Tracker types

HTTP trackers

If not set the default type of an index tracker is http type.

On-chain trackers

If the index tracker type was set to ethereum then it's an on-chain tracker that fetches data using on-chain calls on an Ethereum blockchain network.
Currently supported on-chain parsers are Uniswap and Balancer parsers.

Parsers

Jsonpath parser

When not set this is the default parser. It parses data from the JSON payload using the param as an instruction on how to parse the output. More info.

Balancer parser

Balancer is a parser that fetches tracker info from a Balancer pool. Balancer pools are liquidity pools for pair of ERC20 tokens. a Balancer pool could exist on both Ethereum mainnet and testnets. for Balancer smart contract addresses see here.
There is an on-chain registry smart contract for Balancer that could be queried to get the best pools for an input pair of ERC20 tokens:
1
getBestPools(address fromToken, address destToken)
Copied!
This method will retrieve an array of pool addresses for a token pair that is ordered by liquidity value.
Sometimes there is no deployed testnet Balancer pool to use in the On-chain index tracker. Here are some steps to deploy a Balancer pool on the Rinkeby testnet and add some liquidity to it based on this Balancer doc.
1- Deploy ERC20 tokens as required
Here is a simple JavaScript project that could be used to deploy an ERC20 token on the Rinkeby testnet.
2- Install and configure the seth client
Install and configure seth client using this Github repository guides.
3- Pool creation
Set address variables:
1
export BFACTORY=0x9C84391B443ea3a48788079a5f98e2EaD55c9309
2
export TOKEN1=<token#1-address-from-the-first-step>
3
export TOKEN2=<token#2-address-from-the-first-step>
Copied!
Create a new pool:
1
seth send --gas 5000000 $BFACTORY "newBPool()"
Copied!
Set BPOOL variable:
1
export BPOOL=0x... (address returned from the previous command)
Copied!
Approve ERC20 tokens on the BPool smart contract:
1
amount=$(seth --to-uint256 $(seth --to-wei 1000000 ether))
2
seth send $TOKEN1 "approve(address,uint256)" $BPOOL $amount
3
seth send $TOKEN2 "approve(address,uint256)" $BPOOL $amount
Copied!
Wait for confirmations. after that bind tokens using the bind method. for example:
1
# Bind 1000000 TOKEN1 with a denormalized weight of 5
2
amount=$(seth --to-uint256 $(seth --to-wei 1000000 ether))
3
weight=$(seth --to-uint256 $(seth --to-wei 5 ether))
4
seth send $BPOOL "bind(address, uint256, uint256)" $TOKEN1 $amount $weight
Copied!
Let's confirm that all the tokens were added by using some query method:
1
seth call $BPOOL "getNumTokens()"
Copied!
Set a swap fee and finalize:
1
fee=$(seth --to-uint256 $(seth --to-wei 0.003 ether))
2
seth send $BPOOL "setSwapFee(uint256)" $fee
3
seth send $BPOOL "finalize()"
Copied!
All done. Let's confirm that we received BPTs by calling balanceOf directly on the pool address (since the pools themselves are ERC20 tokens):
1
seth --from-wei $(seth --to-dec $(seth call $BPOOL "balanceOf(address)" $ETH_FROM))
Copied!

Uniswap parser

Uniswap is a parser that fetches tracker info from a UniswapV2 pair. the easiest way to add UniswapV2 testnet pair is to call the addLiquidity contract method on Uniswap RouterV2 smart contract on different Ethereum networks. see addresses. the method is as follow:
1
function addLiquidity(
2
address tokenA,
3
address tokenB,
4
uint amountADesired,
5
uint amountBDesired,
6
uint amountAMin,
7
uint amountBMin,
8
address to,
9
uint deadline
10
) external returns (uint amountA, uint amountB, uint liquidity);
Copied!
This required to deploy some ERC20 token beforehand and will create a Uniswap V2 pair if already not exists for the provided pair. there is a factory method that could be used to get the pair address here.
Last modified 27d ago