Skip to content

AdapterRegistry v2

Igor Sobolev edited this page May 25, 2020 · 1 revision

Table of Contents

Registry holding array of protocol adapters and checking balances and rates via these adapters.

view functions


function getBalances(address account) returns (ProtocolBalance[])

Iterates over all the supported protocols, their adapters and supported tokens and appends balances.

NOTE! Filters out zero balances, adapters, and protocols without positive balances.


function getProtocolBalances(address account, string[] protocolNames) returns (ProtocolBalance[])

Iterates over the protocolNames, their adapters and supported tokens and appends balances.

NOTE! Filters out zero balances, adapters, and protocols without positive balances.


function getAdapterBalances(address account, address[] adapters) returns (AdapterBalance[])

Iterates over adapters and their tokens and appends balances.

NOTE! Filters out zero balances and adapters without positive balances.


function getAdapterBalance(address account, address adapter, address[] tokens) returns (AdapterBalance)

Iterates over tokens and appends balances.

NOTE! Filters out zero balances.


function getFullTokenBalance(string tokenType, address token) returns (FullTokenBalance)

Returns the representation of the token's full share (1e18) in the underlying tokens. This function will show the real underlying tokens (e.g. cDAI and cUSDC for Curve Compound pool).


function getFinalFullTokenBalance(string tokenType, address token) returns (FullTokenBalance)

Returns the representation of the token's full share (1e18) in the underlying tokens. This function will try to recover the "deepest" underlying tokens (e.g. DAI and USDC for Curve Compound pool).

ProtocolManager is Ownable (abstract contract)

Base contract for AdapterRegistry contract. Implements logic connected with ProtocolNames, ProtocolAdapters, and their supportedTokens management.

State variables

mapping (string => string) internal nextProtocolName;
mapping (string => ProtocolMetadata) internal protocolMetadata;
mapping (string => address[]) internal protocolAdapters;
mapping (address => address[]) internal supportedTokens;

onlyOwner functions


function addProtocols(string[] protocolNames, ProtocolMetadata[] metadata, address[][] adapters, address[][][] tokens)

function removeProtocols(string[] protocolNames)

function updateProtocolMetadata(string protocolName, string name, string description, string websiteURL, string iconURL)

Increases protocol version by 1.


function addProtocolAdapters(string protocolName, address[] adapters, address[][] tokens)

Increases protocol version by 1.


function removeProtocolAdapters(string protocolName, uint256[] adapterIndices)

Increases protocol version by 1.


function updateProtocolAdapter(string protocolName, uint256 index, address newAdapterAddress, address[] newSupportedTokens)

Increases protocol version by 1.

view functions


function getProtocolNames() returns (string[])

Returns list of protocols' names.


function getProtocolMetadata(string protocolName) returns (ProtocolMetadata)

Returns name, description, websiteURL, iconURL and version of the protocol.


function getProtocolAdapters(string protocolName) returns (address[])

Returns adapters addresses.


function getSupportedTokens(address adapter) returns (address[])

Returns adapter's supported tokens.


function isValidProtocol(string protocolName) returns (bool)

Returns true if protocol name is listed in the registry and false otherwise.

TokenAdapterManager is Ownable (abstract contract)

Base contract for AdapterRegistry contract. Implements logic connected with ProtocolNames, ProtocolAdapters, and their supportedTokens management.

State variables

mapping (string => string) internal nextTokenAdapterName;
mapping (string => address) internal tokenAdapter;

onlyOwner functions


function addTokenAdapters(string[] tokenAdapterNames, address[] adapters)

function removeTokenAdapters(string[] tokenAdapterNames)

function updateTokenAdapter(string tokenAdapterName, address adapter)

view functions


function getTokenAdapterNames() returns (string[])

Returns list of token adapters' names.


function getTokenAdapter(string tokenAdapterName) returns (address)

Returns token adapter address.


function isValidTokenAdapter(string tokenAdapterName) returns (bool)

Returns true if token adapter name is listed in the registry and false otherwise.

Ownable

Base contract for ProtocolManager and TokenAdapterManager contracts. Implements Ownable logic. Includes onlyOwner modifier, transferOwnership() function, and public state variable owner.