Once a protocol is added to ProtocolAdapterRegistry contract, it will immediately appear in all the interfaces that use DeFi SDK (including Zerion). In order to add protocol to to DeFi SDK one has to implement the following contracts.
getBalance(address token, address account) returns (int256)
The function has two arguments of address
type: the first one is token address and the second one is account address. The function MUST return balance of given asset held on the protocol for the given account.
To create new protocol adapter, one has to implement TokenAdapter interface.
getMetadata(address token) external view returns (ERC20Metadata memory)
The function has the only argument – token address. The function MUST return the ERC20-style token metadata, namely:
name
:string
with token name;symbol
:string
with token symbol;decimals
:uint8
number with token decimals.
getComponents(address token) external view returns (Component[] memory)
The function has the only argument – token address. The function MUST return all the underlying tokens info:
token
:address
of the underlying token contract;rate
:uint256
with price per base token share (1e18).
After the adapters are deployed and tested, one can contact Zerion team in order to add the adapters to AdapterRegistry contract.
To get a PR merged, one should write tests for all the functions implemented. Examples may be found in the repo.
In case ProtocolAdapter should work with the short list of tokens, these tokens should be added to the list of supported tokens in ProtocolAdapterRegistry contract. In order to do that, one should add tokens in PR's comments.