Adding New Markets

Adding a new market is a pretty straightforward endeavor. First, head over to our github. Defitrack Core is the code that powers the API. It contains all code specific to protocols and networks. Furthermore, it contains rest APIs for each and every supported protocol, as well as a few generic features (like prices, erc20, abi, etc...).

Adding a new market, be it Lending, Pooling or Farming, consists of following these basic steps.

Fork the repository

First off, fork the repository. You'll work by creating a fork, working on said fork and creating a pull request. We'll review the changes and will work together, in an async fashion towards a solution.

We'd love it if you could star the repo in the meantime in order to get more eyes on the project.

Adding a new protocol (optional)

protocol code

A protocol is an application or Defi native protocol, like compound, uniswap or beefy finance. Markets always belong to protocols. If the protocol you want to add does not exist in defitrack yet, you'll have to add it. Currently supported protocols can be found on our roadmap.

You can look at the examples under defitrack-protocols to get a feel of the existing structure. The core code of the specific protocol belongs here. Contract calls or graph protocol fetching is what needs to be added here. Don't forget to add the protocol to defitrack-protocol/protocol-dependencies/pom.xml.

protocol api

Next up, you'll be creating a new api microservice under defitrack-rest/defitrack-protocol-services. You can visit the existing APIs to see what the structure and pom.xml looks like.

ci

In order for our ci to automatically deliver a docker image containing the code, you'll have to add the protocol to ci/protocols.txt.

logo

clone the data repository and add the logo of the protocol to logos/. Remember the name and the extension.

enumeration

Defitrack core contains an enum called Protocol. Add the protocol to this enum. The logo is the one you added in the previous step.

Adding Pooling Markets

If you'd like to add new Pooling markets, like the ones on Curve or Uniswap, you'll need to create a new implementation of PoolingMarketService.

The domain model for Pooling Markets consists the following fields:

fieldtypedescription

id

string

unique id per market. Make it something logical like quickwap-polygon-$address

address

string

address of the LP token

name

string

name of the market, like Curve.fi DAI/USDC/USDT/PAX.

protocol

Protocol

One of the protocols in the enum, like CURVE

network

Network

One of the networks in the enum, like POLYGON

tokens

a list of underlying tokens

apr

Double

The APR of the LP in percentage. 0.5 = 0.5%

Adding Farming Markets

If you'd like to add new Farming markets, like the ones on Dinoswap or Convex, you'll need to create a new implementation of StakingMarketService.

Adding Lending Markets

If you'd like to add new Lending markets, like the ones on Compound or Aave, you'll need to create a new implementation of LendingMarketService.

Last updated