StandardPoolConverter
This contract is a specialized version of the converter, which is
optimized for a liquidity pool that has 2 reserves with 50%/50% weights.
Functions:
Events:
Function constructor(contract IConverterAnchor _anchor, contract IContractRegistry _registry, uint32 _maxConversionFee)
constructor(contract IConverterAnchor _anchor, contract IContractRegistry _registry, uint32 _maxConversionFee)
initializes a new StandardPoolConverter instance
Parameters:
_anchor
: anchor governed by the converter_registry
: address of a contract registry contract_maxConversionFee
: maximum conversion fee, represented in ppm
Function converterType() → uint16
converterType() → uint16
returns the converter type
Return Values:
see the converter types in the the main contract doc
Function receive()
receive()
deposits ether
can only be called if the converter has an ETH reserve
Function isV28OrHigher() → bool
isV28OrHigher() → bool
checks whether or not the converter version is 28 or higher
Return Values:
since the converter version is 28 or higher
Function isActive() → bool
isActive() → bool
returns true if the converter is active, false otherwise
Return Values:
true if the converter is active, false otherwise
Function transferAnchorOwnership(address _newOwner)
transferAnchorOwnership(address _newOwner)
transfers the anchor ownership
the new owner needs to accept the transfer
can only be called by the converter upgrader while the upgrader is the owner
note that prior to version 28, you should use 'transferAnchorOwnership' instead
Parameters:
_newOwner
: new token owner
Function acceptAnchorOwnership()
acceptAnchorOwnership()
accepts ownership of the anchor after an ownership transfer
most converters are also activated as soon as they accept the anchor ownership
can only be called by the contract owner
note that prior to version 28, you should use 'acceptTokenOwnership' instead
Function setConversionFee(uint32 _conversionFee)
setConversionFee(uint32 _conversionFee)
updates the current conversion fee
can only be called by the contract owner
Parameters:
_conversionFee
: new conversion fee, represented in ppm
Function transferReservesOnUpgrade(address _newConverter)
transferReservesOnUpgrade(address _newConverter)
transfers reserve balances to a new converter during an upgrade
can only be called by the converter upgraded which should be set at its owner
Parameters:
_newConverter
: address of the converter to receive the new amount
Function upgrade()
upgrade()
upgrades the converter to the latest version
can only be called by the owner
note that the owner needs to call acceptOwnership on the new converter after the upgrade
Function onUpgradeComplete()
onUpgradeComplete()
executed by the upgrader at the end of the upgrade process to handle custom pool logic
Function reserveTokenCount() → uint16
reserveTokenCount() → uint16
returns the number of reserve tokens
note that prior to version 17, you should use 'connectorTokenCount' instead
Return Values:
number of reserve tokens
Function reserveTokens() → contract IReserveToken[]
reserveTokens() → contract IReserveToken[]
returns the array of reserve tokens
Return Values:
array of reserve tokens
Function addReserve(contract IReserveToken _token, uint32 _weight)
addReserve(contract IReserveToken _token, uint32 _weight)
defines a new reserve token for the converter
can only be called by the owner while the converter is inactive
Parameters:
_token
: address of the reserve token_weight
: reserve weight, represented in ppm, 1-1000000
Function reserveWeight(contract IReserveToken _reserveToken) → uint32
reserveWeight(contract IReserveToken _reserveToken) → uint32
returns the reserve's weight
added in version 28
Parameters:
_reserveToken
: reserve token contract address
Return Values:
reserve weight
Function reserveBalance(contract IReserveToken _reserveToken) → uint256
reserveBalance(contract IReserveToken _reserveToken) → uint256
returns the balance of a given reserve token
Parameters:
_reserveToken
: reserve token contract address
Return Values:
the balance of the given reserve token
Function reserveBalances() → uint256, uint256
reserveBalances() → uint256, uint256
returns the balances of both reserve tokens
Return Values:
the balances of both reserve tokens
Function syncReserveBalances()
syncReserveBalances()
syncs all stored reserve balances
Function processNetworkFees()
processNetworkFees()
calculates the accumulated network fee and transfers it to the network fee wallet
Function convert(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount, address _trader, address payable _beneficiary) → uint256
convert(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount, address _trader, address payable _beneficiary) → uint256
converts a specific amount of source tokens to target tokens
can only be called by the bancor network contract
Parameters:
_sourceToken
: source reserve token_targetToken
: target reserve token_amount
: amount of tokens to convert (in units of the source token)_trader
: address of the caller who executed the conversion_beneficiary
: wallet to receive the conversion result
Return Values:
amount of tokens received (in units of the target token)
Function targetAmountAndFee(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount) → uint256, uint256
targetAmountAndFee(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount) → uint256, uint256
returns the expected amount and expected fee for converting one reserve to another
Parameters:
_sourceToken
: address of the source reserve token contract_targetToken
: address of the target reserve token contract_amount
: amount of source reserve tokens converted
Return Values:
expected amount in units of the target reserve token
expected fee in units of the target reserve token
Function sourceAmountAndFee(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount) → uint256, uint256
sourceAmountAndFee(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount) → uint256, uint256
returns the required amount and expected fee for converting one reserve to another
Parameters:
_sourceToken
: address of the source reserve token contract_targetToken
: address of the target reserve token contract_amount
: amount of target reserve tokens desired
Return Values:
required amount in units of the source reserve token
expected fee in units of the target reserve token
Function recentAverageRate(contract IReserveToken _token) → uint256, uint256
recentAverageRate(contract IReserveToken _token) → uint256, uint256
returns the recent average rate of 1 _token
in the other reserve token units
Parameters:
_token
: token to get the rate for
Return Values:
recent average rate between the reserves (numerator)
recent average rate between the reserves (denominator)
Function addLiquidity(contract IReserveToken[] _reserveTokens, uint256[] _reserveAmounts, uint256 _minReturn) → uint256
addLiquidity(contract IReserveToken[] _reserveTokens, uint256[] _reserveAmounts, uint256 _minReturn) → uint256
increases the pool's liquidity and mints new shares in the pool to the caller
Parameters:
_reserveTokens
: address of each reserve token_reserveAmounts
: amount of each reserve token_minReturn
: token minimum return-amount
Return Values:
amount of pool tokens issued
Function removeLiquidity(uint256 _amount, contract IReserveToken[] _reserveTokens, uint256[] _reserveMinReturnAmounts) → uint256[]
removeLiquidity(uint256 _amount, contract IReserveToken[] _reserveTokens, uint256[] _reserveMinReturnAmounts) → uint256[]
decreases the pool's liquidity and burns the caller's shares in the pool
Parameters:
_amount
: token amount_reserveTokens
: address of each reserve token_reserveMinReturnAmounts
: minimum return-amount of each reserve token
Return Values:
the amount of each reserve token granted for the given amount of pool tokens
Function addLiquidityCost(contract IReserveToken[] _reserveTokens, uint256 _reserveTokenIndex, uint256 _reserveAmount) → uint256[]
addLiquidityCost(contract IReserveToken[] _reserveTokens, uint256 _reserveTokenIndex, uint256 _reserveAmount) → uint256[]
given the amount of one of the reserve tokens to add liquidity of,
returns the required amount of each one of the other reserve tokens
since an empty pool can be funded with any list of non-zero input amounts,
this function assumes that the pool is not empty (has already been funded)
Parameters:
_reserveTokens
: address of each reserve token_reserveTokenIndex
: index of the relevant reserve token_reserveAmount
: amount of the relevant reserve token
Return Values:
the required amount of each one of the reserve tokens
Function addLiquidityReturn(contract IReserveToken[] _reserveTokens, uint256[] _reserveAmounts) → uint256
addLiquidityReturn(contract IReserveToken[] _reserveTokens, uint256[] _reserveAmounts) → uint256
returns the amount of pool tokens entitled for given amounts of reserve tokens
since an empty pool can be funded with any list of non-zero input amounts,
this function assumes that the pool is not empty (has already been funded)
Parameters:
_reserveTokens
: address of each reserve token_reserveAmounts
: amount of each reserve token
Return Values:
the amount of pool tokens entitled for the given amounts of reserve tokens
Function removeLiquidityReturn(uint256 _amount, contract IReserveToken[] _reserveTokens) → uint256[]
removeLiquidityReturn(uint256 _amount, contract IReserveToken[] _reserveTokens) → uint256[]
returns the amount of each reserve token entitled for a given amount of pool tokens
Parameters:
_amount
: amount of pool tokens_reserveTokens
: address of each reserve token
Return Values:
the amount of each reserve token entitled for the given amount of pool tokens
Function token() → contract IConverterAnchor
token() → contract IConverterAnchor
deprecated since version 28, backward compatibility - use only for earlier versions
Function transferTokenOwnership(address _newOwner)
transferTokenOwnership(address _newOwner)
deprecated, backward compatibility
Function acceptTokenOwnership()
acceptTokenOwnership()
deprecated, backward compatibility
Function connectors(contract IReserveToken _address) → uint256, uint32, bool, bool, bool
connectors(contract IReserveToken _address) → uint256, uint32, bool, bool, bool
deprecated, backward compatibility
Function connectorTokens(uint256 _index) → contract IReserveToken
connectorTokens(uint256 _index) → contract IReserveToken
deprecated, backward compatibility
Function connectorTokenCount() → uint16
connectorTokenCount() → uint16
deprecated, backward compatibility
Function getConnectorBalance(contract IReserveToken _connectorToken) → uint256
getConnectorBalance(contract IReserveToken _connectorToken) → uint256
deprecated, backward compatibility
Function getReturn(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount) → uint256, uint256
getReturn(contract IReserveToken _sourceToken, contract IReserveToken _targetToken, uint256 _amount) → uint256, uint256
deprecated, backward compatibility
Event LiquidityAdded(address _provider, contract IReserveToken _reserveToken, uint256 _amount, uint256 _newBalance, uint256 _newSupply)
LiquidityAdded(address _provider, contract IReserveToken _reserveToken, uint256 _amount, uint256 _newBalance, uint256 _newSupply)
triggered after liquidity is added
Parameters:
_provider
: liquidity provider_reserveToken
: reserve token address_amount
: reserve token amount_newBalance
: reserve token new balance_newSupply
: pool token new supply
Event LiquidityRemoved(address _provider, contract IReserveToken _reserveToken, uint256 _amount, uint256 _newBalance, uint256 _newSupply)
LiquidityRemoved(address _provider, contract IReserveToken _reserveToken, uint256 _amount, uint256 _newBalance, uint256 _newSupply)
triggered after liquidity is removed
Parameters:
_provider
: liquidity provider_reserveToken
: reserve token address_amount
: reserve token amount_newBalance
: reserve token new balance_newSupply
: pool token new supply
Last updated