The easiest way to integrate DeFi protocols
Zerion has been working hard to stay up to date with innovations in the DeFi space. This means integrating as many protocols as possible, allowing users to track and manage their entire DeFi portfolio from one place. However, adding new protocols is nowhere near efficient. Our team has spent months designing a solution that makes this process significantly easier. Today, we’re excited to announce DeFi SDK, an open-source system of smart contracts that makes it easier for developers to integrate DeFi protocols.
Building the bridges that DeFi needs
Over the past year, we added support for numerous protocols including Uniswap, MakerDAO CDPs and Vaults, Compound, Bancor, 0x, Uniswap Pools, DSR, Fulcrum and Tokensets. The DeFi ecosystem is growing at an unprecedented speed. This is exciting and challenging at the same time. More and more financial products that were previously available to only a few are now globally accessible. As a company, we recognize that in order to keep up with this growth, we need to scale the way we approach integrations with DeFi protocols.
In the past, we’ve spent a lot of time researching the ins and outs of each protocol we want to work with — thinking through the UX and how it fits our interface and developing the backend and frontend for all our clients on web, iOS and Android. The pipeline has often been fragmented and time-consuming.
DeFi SDK changes everything, not just for Zerion, but for all dApp and wallet developers. The best part? It’s trustless and completely open-source.
We’ve designed DeFi SDK with three goals in mind:
- For developers: If you’re a dApp developer, integrating DeFi protocols is as easy as using a single library. DeFi SDK gives you instant access to 17+ leading DeFi protocols instead of manually integrating each of them. If you’re a protocol developer, any updates you make are automatically reflected on all dApps that use DeFi SDK.
- For the community: We’re sharing open-source solutions to common problems. DeFi SDK increases interoperability of different DeFi products and make it easier to build DeFi apps
- For users: dApps can now support your favourite DeFi assets and protocols with ease. This means faster updates and a better user experience.
How DeFi SDK works
At the core of DeFi SDK are token adapters and protocol adapters.
Token Adapters
Token adapters are smart contracts that provide an on-chain solution to fetch the underlying tokens of derivative assets. Think of these as decoders that make sense of complex ERC20 tokens.
Imagine a Uniswap ETH-cDAI Pool token. On the surface, it is a very complicated token, but under the hood, it just consists of a pair of yield-earning DAI (cDAI) and ETH. The token adapter for UniTokens is able to “unwrap” the token and return the underlying components of the derivative token. Similarly, an adapter for cTokens is able to fetch the underlying interest-earning token. You can take a look at the Uniswap adapter on our Github.
Protocol Adapters
Protocol adapters are responsible for the on-chain representation of a DeFi protocol and include user-specific information such as debt and deposit balance.
Currently, DeFi faces a fragmentation problem because wallets like Fortmatic or MetaMask can fetch balances of basic ERC20 tokens, but have no standard for reading more complicated DeFi derivatives such as Set tokens. Rather than query user balances on-chain, this information often needs to be hardcoded or pulled through API integrations. This is not ideal.
DeFi SDK contains metadata for each protocol. For dApp developers, this allows the interface to fetch all information related to the protocol using one call to the Adapter Registry, which is a whitelist of the protocol adapters and token adapters supported by each interface.struct ProtocolMetadata {
string name;
string description;
string websiteURL;
string iconURL;
uint256 version;
}
Anyone can create a token adapter for their protocol and anyone can maintain their own registry for their wallet or dApp. For example, Zerion’s Adapter Registry is a vetted list that contains all the protocols that we support. You can find the addresses of deployed contracts, including the Adapter Registry here.
For protocol developers: adding a new protocol to DeFi SDK
The advantage to protocols that add an Adapter to DeFi SDK is that once integrated, their protocol data is accessible to every wallet and dApp that has DeFi SDK integration. When you update the protocol, these changes are automatically reflected in the dApps.
Applications currently using DeFi SDK are:
So, you have a new protocol that you think DeFi users will love — now what? Just follow these simple steps:
- Check out our open-source examples of Adapters here.
- Create your own adapter smart contract, deploy it on the Ethereum mainnet and verify it on Etherscan. (If you have any problems, reach out to us on Discord and we will be more than happy to help you!)
- Once the adapter is complete, open a pull request on Github, we will need to review it and add it to the Zerion AdapterRegistry. Check out Github for more info on this.
Once this process is complete, your protocol will be almost instantly visible to the users of Zerion and other dApps that use DeFi SDK.
For wallet and dApp developers: How to integrate DeFi SDK in your app
Wallet and dApp developers can make use of the Adapter Registry as a way to keep track of all DeFi assets for their users. Standardizing the way complex derivatives get integrated across wallets and protocols means that you can easily fetch key information such as user balance, protocol metadata, derivative token metadata, etc. Doing this is as easy as running a single function on the Registry:function getBalances(address account) returns (ProtocolBalance[]);
For each protocol listed on the Registry, this function returns all balances of a user across all tokens listed in the protocol adapter.
The advantage of integrating DeFi SDK just once is that your app will automatically support all existing and future protocols added to DeFi SDK.
🚀 So what’s next for DeFi SDK?
This first version of DeFi SDK is for precise DeFi accounting. Our next step is to introduce Interactive Adapters that standardize the way dApps interact with multiple DeFi protocols. We are incredibly excited to work with developers, users and the wider DeFi community to make these integrations as secure and accessible as possible.
DeFi SDK solves the fragmentation problem across the DeFi space while staying trustless and open-source.
The way DeFi should be.
Give us a ⭐️ on Github!
🏦 Follow us on Twitter to get latest updates and join our Discord server!