- Fork this repository
- Create a new folder within src/adaptors/ with your protocol name (use your project
slugfromhttps://api.llama.fi/protocols) - Write an adaptor for your protocol (tutorial below)
- Test your adaptor by running
node src/adaptors/test.js src/adaptors/YOUR_ADAPTOR/index.js(remember to install dependencies withnpm ifirst!) - Submit a PR
An adaptor is just a javascript file that exports an async function that returns an array of objects that represent pools of a protocol. The pools follow the following schema (all values are just examples):
{pool: "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae90xb53c1a33016b2dc2ff3653530bff1848a515c8c5",// unique identifier for the poolchain: "Ethereum",// chain where the pool isproject: 'aave',// protocol (using the slug again)symbol: "USDT",// symbol of the tokens in pool, can be a single symbol if pool is single-sided or multiple symbols (eg: USDT-ETH) if it's an LPtvlUsd: 1000.1,// number representing current USD TVL in poolapy: 1.2,// current APY of the pool in %};An example of the most basic adaptor is the following for Anchor on terra:
constutils=require('../utils');constpoolsFunction=async()=>{constapyData=awaitutils.getData('https://api.anchorprotocol.com/api/v1/market/ust');constdataTvl=awaitutils.getData('https://api.anchorprotocol.com/api/v1/deposit');constustPool={pool: 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu',chain: utils.formatChain('terra'),project: 'anchor',symbol: utils.formatSymbol('UST'),tvlUsd: Number(dataTvl.total_ust_deposits)/1e6,apy: apyData.deposit_apy*100,};return[ustPool];// Anchor only has a single pool with APY};module.exports={timetravel: false,apy: poolsFunction,};You can find examples for a bunch of other protocols in the src/adaptors/ folder, and if you have any questions feel free to ask them on our discord.
This is not needed if you just want to contribute an a new protocol through an adapter, only needed if you want to fork defillama.
ETHERSCAN=
FANTOMSCAN=
POLYGONSCAN=
SNOWTRACE=
ARBISCAN=
OPTIMISM=
INFURA_CONNECTION=