ConverterRegistry
This contract maintains a list of all active converters in the Bancor Network.
Since converters can be upgraded and thus their address can change, the registry actually keeps
converter anchors internally and not the converters themselves.
The active converter for each anchor can be easily accessed by querying the anchor's owner.
The registry exposes 3 different lists that can be accessed and iterated, based on the use-case of the caller:
Anchors - can be used to get all the latest / historical data in the network
Liquidity pools - can be used to get all liquidity pools for funding, liquidation etc.
Convertible tokens - can be used to get all tokens that can be converted in the network (excluding pool
tokens), and for each one - all anchors that hold it in their reserves
The contract fires events whenever one of the primitives is added to or removed from the registry
The contract is upgradable.
Functions:
Events:
Function constructor(contract IContractRegistry _registry)
constructor(contract IContractRegistry _registry)
initializes a new ConverterRegistry instance
Parameters:
_registry
: address of a contract registry contract
Function newConverter(uint16 _type, string _name, string _symbol, uint8 _decimals, uint32 _maxConversionFee, contract IReserveToken[] _reserveTokens, uint32[] _reserveWeights) → contract IConverter
newConverter(uint16 _type, string _name, string _symbol, uint8 _decimals, uint32 _maxConversionFee, contract IReserveToken[] _reserveTokens, uint32[] _reserveWeights) → contract IConverter
creates a zero supply liquid token / empty liquidity pool and adds its converter to the registry
Parameters:
_type
: converter type, see ConverterBase contract main doc_name
: token / pool name_symbol
: token / pool symbol_decimals
: token / pool decimals_maxConversionFee
: maximum conversion-fee_reserveTokens
: reserve tokens_reserveWeights
: reserve weights
Return Values:
new converter
Function addConverter(contract IConverter _converter)
addConverter(contract IConverter _converter)
adds an existing converter to the registry
can only be called by the owner
Parameters:
_converter
: converter
Function removeConverter(contract IConverter _converter)
removeConverter(contract IConverter _converter)
removes a converter from the registry
anyone can remove an existing converter from the registry, as long as the converter is invalid
note that the owner can also remove valid converters
Parameters:
_converter
: converter
Function getAnchorCount() → uint256
getAnchorCount() → uint256
returns the number of converter anchors in the registry
Return Values:
number of anchors
Function getAnchors() → address[]
getAnchors() → address[]
returns the list of converter anchors in the registry
Return Values:
list of anchors
Function getAnchor(uint256 _index) → contract IConverterAnchor
getAnchor(uint256 _index) → contract IConverterAnchor
returns the converter anchor at a given index
Parameters:
_index
: index
Return Values:
anchor at the given index
Function isAnchor(address _value) → bool
isAnchor(address _value) → bool
checks whether or not a given value is a converter anchor
Parameters:
_value
: value
Return Values:
true if the given value is an anchor, false if not
Function getLiquidityPoolCount() → uint256
getLiquidityPoolCount() → uint256
returns the number of liquidity pools in the registry
Return Values:
number of liquidity pools
Function getLiquidityPools() → address[]
getLiquidityPools() → address[]
returns the list of liquidity pools in the registry
Return Values:
list of liquidity pools
Function getLiquidityPool(uint256 _index) → contract IConverterAnchor
getLiquidityPool(uint256 _index) → contract IConverterAnchor
returns the liquidity pool at a given index
Parameters:
_index
: index
Return Values:
liquidity pool at the given index
Function isLiquidityPool(address _value) → bool
isLiquidityPool(address _value) → bool
checks whether or not a given value is a liquidity pool
Parameters:
_value
: value
Return Values:
true if the given value is a liquidity pool, false if not
Function getConvertibleTokenCount() → uint256
getConvertibleTokenCount() → uint256
returns the number of convertible tokens in the registry
Return Values:
number of convertible tokens
Function getConvertibleTokens() → address[]
getConvertibleTokens() → address[]
returns the list of convertible tokens in the registry
Return Values:
list of convertible tokens
Function getConvertibleToken(uint256 _index) → contract IReserveToken
getConvertibleToken(uint256 _index) → contract IReserveToken
returns the convertible token at a given index
Parameters:
_index
: index
Return Values:
convertible token at the given index
Function isConvertibleToken(address _value) → bool
isConvertibleToken(address _value) → bool
checks whether or not a given value is a convertible token
Parameters:
_value
: value
Return Values:
true if the given value is a convertible token, false if not
Function getConvertibleTokenAnchorCount(contract IReserveToken _convertibleToken) → uint256
getConvertibleTokenAnchorCount(contract IReserveToken _convertibleToken) → uint256
returns the number of converter anchors associated with a given convertible token
Parameters:
_convertibleToken
: convertible token
Return Values:
number of anchors associated with the given convertible token
Function getConvertibleTokenAnchors(contract IReserveToken _convertibleToken) → address[]
getConvertibleTokenAnchors(contract IReserveToken _convertibleToken) → address[]
returns the list of converter anchors associated with a given convertible token
Parameters:
_convertibleToken
: convertible token
Return Values:
list of anchors associated with the given convertible token
Function getConvertibleTokenAnchor(contract IReserveToken _convertibleToken, uint256 _index) → contract IConverterAnchor
getConvertibleTokenAnchor(contract IReserveToken _convertibleToken, uint256 _index) → contract IConverterAnchor
returns the converter anchor associated with a given convertible token at a given index
Parameters:
_index
: index
Return Values:
anchor associated with the given convertible token at the given index
Function isConvertibleTokenAnchor(contract IReserveToken _convertibleToken, address _value) → bool
isConvertibleTokenAnchor(contract IReserveToken _convertibleToken, address _value) → bool
checks whether or not a given value is a converter anchor of a given convertible token
Parameters:
_convertibleToken
: convertible token_value
: value
Return Values:
true if the given value is an anchor of the given convertible token, false if not
Function getConvertersByAnchors(address[] _anchors) → contract IConverter[]
getConvertersByAnchors(address[] _anchors) → contract IConverter[]
returns a list of converters for a given list of anchors
this is a utility function that can be used to reduce the number of calls to the contract
Parameters:
_anchors
: list of converter anchors
Return Values:
list of converters
Function isConverterValid(contract IConverter _converter) → bool
isConverterValid(contract IConverter _converter) → bool
checks whether or not a given converter is valid
Parameters:
_converter
: converter
Return Values:
true if the given converter is valid, false if not
Function isSimilarLiquidityPoolRegistered(contract IConverter _converter) → bool
isSimilarLiquidityPoolRegistered(contract IConverter _converter) → bool
checks if a liquidity pool with given configuration is already registered
Parameters:
_converter
: converter with specific configuration
Return Values:
if a liquidity pool with the same configuration is already registered
Function getLiquidityPoolByConfig(uint16 _type, contract IReserveToken[] _reserveTokens, uint32[] _reserveWeights) → contract IConverterAnchor
getLiquidityPoolByConfig(uint16 _type, contract IReserveToken[] _reserveTokens, uint32[] _reserveWeights) → contract IConverterAnchor
searches for a liquidity pool with specific configuration
Parameters:
_type
: converter type, see ConverterBase contract main doc_reserveTokens
: reserve tokens_reserveWeights
: reserve weights
Return Values:
the liquidity pool, or zero if no such liquidity pool exists
Function getSmartTokenCount() → uint256
getSmartTokenCount() → uint256
deprecated, backward compatibility, use getAnchorCount
Function getSmartTokens() → address[]
getSmartTokens() → address[]
deprecated, backward compatibility, use getAnchors
Function getSmartToken(uint256 _index) → contract IConverterAnchor
getSmartToken(uint256 _index) → contract IConverterAnchor
deprecated, backward compatibility, use getAnchor
Function isSmartToken(address _value) → bool
isSmartToken(address _value) → bool
deprecated, backward compatibility, use isAnchor
Function getConvertibleTokenSmartTokenCount(contract IReserveToken _convertibleToken) → uint256
getConvertibleTokenSmartTokenCount(contract IReserveToken _convertibleToken) → uint256
deprecated, backward compatibility, use getConvertibleTokenAnchorCount
Function getConvertibleTokenSmartTokens(contract IReserveToken _convertibleToken) → address[]
getConvertibleTokenSmartTokens(contract IReserveToken _convertibleToken) → address[]
deprecated, backward compatibility, use getConvertibleTokenAnchors
Function getConvertibleTokenSmartToken(contract IReserveToken _convertibleToken, uint256 _index) → contract IConverterAnchor
getConvertibleTokenSmartToken(contract IReserveToken _convertibleToken, uint256 _index) → contract IConverterAnchor
deprecated, backward compatibility, use getConvertibleTokenAnchor
Function isConvertibleTokenSmartToken(contract IReserveToken _convertibleToken, address _value) → bool
isConvertibleTokenSmartToken(contract IReserveToken _convertibleToken, address _value) → bool
deprecated, backward compatibility, use isConvertibleTokenAnchor
Function getConvertersBySmartTokens(address[] _smartTokens) → contract IConverter[]
getConvertersBySmartTokens(address[] _smartTokens) → contract IConverter[]
deprecated, backward compatibility, use getConvertersByAnchors
Function getLiquidityPoolByReserveConfig(contract IReserveToken[] _reserveTokens, uint32[] _reserveWeights) → contract IConverterAnchor
getLiquidityPoolByReserveConfig(contract IReserveToken[] _reserveTokens, uint32[] _reserveWeights) → contract IConverterAnchor
deprecated, backward compatibility, use getLiquidityPoolByConfig
Event ConverterAnchorAdded(contract IConverterAnchor _anchor)
ConverterAnchorAdded(contract IConverterAnchor _anchor)
triggered when a converter anchor is added to the registry
Parameters:
_anchor
: anchor token
Event ConverterAnchorRemoved(contract IConverterAnchor _anchor)
ConverterAnchorRemoved(contract IConverterAnchor _anchor)
triggered when a converter anchor is removed from the registry
Parameters:
_anchor
: anchor token
Event LiquidityPoolAdded(contract IConverterAnchor _liquidityPool)
LiquidityPoolAdded(contract IConverterAnchor _liquidityPool)
triggered when a liquidity pool is added to the registry
Parameters:
_liquidityPool
: liquidity pool
Event LiquidityPoolRemoved(contract IConverterAnchor _liquidityPool)
LiquidityPoolRemoved(contract IConverterAnchor _liquidityPool)
triggered when a liquidity pool is removed from the registry
Parameters:
_liquidityPool
: liquidity pool
Event ConvertibleTokenAdded(contract IReserveToken _convertibleToken, contract IConverterAnchor _smartToken)
ConvertibleTokenAdded(contract IReserveToken _convertibleToken, contract IConverterAnchor _smartToken)
triggered when a convertible token is added to the registry
Parameters:
_convertibleToken
: convertible token_smartToken
: associated anchor token
Event ConvertibleTokenRemoved(contract IReserveToken _convertibleToken, contract IConverterAnchor _smartToken)
ConvertibleTokenRemoved(contract IReserveToken _convertibleToken, contract IConverterAnchor _smartToken)
triggered when a convertible token is removed from the registry
Parameters:
_convertibleToken
: convertible token_smartToken
: associated anchor token
Event SmartTokenAdded(contract IConverterAnchor _smartToken)
SmartTokenAdded(contract IConverterAnchor _smartToken)
deprecated, backward compatibility, use ConverterAnchorAdded
Event SmartTokenRemoved(contract IConverterAnchor _smartToken)
SmartTokenRemoved(contract IConverterAnchor _smartToken)
deprecated, backward compatibility, use ConverterAnchorRemoved
Last updated