You should start by forking the DefiLlama/DefiLlama-Adapters repository on github. Afterwards, just create a new folder on `/projects` and write your adapter there.
At it's core, an adapter is just some code that takes in a UNIX timestamp and an Ethereum block height and returns the balances of assets locked in a protocol, including all the decimals (that is, the way it's stored on chain).
For example, the following adapter would return a TVL that increases by 1 WBTC and 3 BAT every block:
Which our SDK would then convert into their USD equivalent and sum to obtain total TVL.
So, all in all, adapters just do that, take in a time and return a list of assets locked at that moment, specified by the address of their token, and their respective balances as strings and with all the decimals.
Now let's move on to a real adapter, here's the one we use for PoolTogether:
What we are doing here is getting all their pools from their subgraph, then making an Ethereum call to each of them to get how many tokens are locked in each and then just returning each of these tokens along with the balances we got.
On top of all this, it's also important to notice that all calls are done through an SDK, this allows our adapters to be compatible with DeFi Pulse's and makes it so you only have to write them once and can submit them to multiple pages.