How to code an adapter?
You can code an adapter for your project by simply following these steps.
Last updated
You can code an adapter for your project by simply following these steps.
Last updated
The first thing you have to do is to fork the spock-adapters repo on your GitHub workspace.
You have to clone the forked repo in your local machine.
Install dependencies through yarn install.
Prepare adapters through yarn prepare.
Now you have to set up your project directory inside . The file structure of the project directory will look like this.
First of all, create an abis folder in your project directory and add all the required abis of JSON format in it.
After that, you have to execute the command yarn generate PROJECT_NAME
which will generate the types of abis through typechain.
Now you are ready to code the core logic of your adapter.
Let's start coding from the transformer. For that, you have to create event handler functions in the index.ts
file and add them to the adapter object which will be exported in the end.
Here we have an example of a Uniswap V3 mint event handler.
In the end, return these events handlers w.r.t to their contract and chain in transformers.
For the TVL tracking of your protocol, you have to create an extractor function in the tvl.ts
which will return the balances of the asset locked inside your protocol.
Here we have an example of BullionFx TVL computation.
In the end, after you are done with the adapter development, you can write tests for validating the transformers and TVL extractors' logic. For that, you have to write tests in the index.test.ts
file of your project.
A member of our team will then review and merge your code with the main branch.
Once all the above steps are completed, your adapter is ready for syncing, push the code and create PR on the main branch of .
If you are stuck anywhere or have a suggestion or feedback, you can fill out the form , or reach out to our team at support@spockanalytics.xyz.