BancorConverter

Group BancorConverter

Modules > BancorConverter

Bancor BancorConverter. More...

Modules

Type

Name

module

Accounts Table This table stores "temporary balances" that are transfered in by liquidity providers before they can get added to their respective reserves.

module

Converters Table This table stores the key information about all converters in this contract.

module

Reserves Table This table stores the reserve balances and related information for the reserves of every converter in this contract.

module

Settings Table This table stores the global settings affecting all the converters in this contract.

module

Reserves Table This table stores stats on the reserves of the converter, the actual balance is owned by converter account within the accounts.

module

Settings Table This table stores stats on the settings of the converter.

Public Types

Type

Name

typedef action_wrapper<"delconverter"_n, &BancorConverter::delconverter >

close_action

typedef action_wrapper<"create"_n, &BancorConverter::create >

create_action

typedef action_wrapper<"delreserve"_n, &BancorConverter::delreserve >

delreserve_action

typedef action_wrapper<"enablestake"_n, &BancorConverter::enablestake >

enablestake_action

typedef action_wrapper<"fund"_n, &BancorConverter::fund >

fund_action

typedef action_wrapper<"setmaxfee"_n, &BancorConverter::setmaxfee >

setmaxfee_action

typedef action_wrapper<"setmultitokn"_n, &BancorConverter::setmultitokn >

setmultitokn_action

typedef action_wrapper<"setreserve"_n, &BancorConverter::setreserve >

setreserve_action

typedef action_wrapper<"setstaking"_n, &BancorConverter::setstaking >

setstaking_action

typedef action_wrapper<"updatefee"_n, &BancorConverter::updatefee >

updatefee_action

typedef action_wrapper<"updateowner"_n, &BancorConverter::updateowner >

updateowner_action

typedef action_wrapper<"withdraw"_n, &BancorConverter::withdraw >

withdraw_action

Public Functions

Type

Name

ACTION

create (name owner, symbol_code token_code, double initial_supply) initializes a new converter

ACTION

delconverter (symbol_code converter_currency_code) deletes a converter with empty reserves

ACTION

delreserve (symbol_code converter, symbol_code reserve) deletes an empty reserve in the converter

ACTION

delreserve (symbol_code currency) deletes an empty reserve

ACTION

enablestake (symbol_code currency, bool enabled) flag indicating if the smart token can be staked, false if not

ACTION

fund (name sender, asset quantity) buys smart tokens with all connector tokens using the same percentage

ACTION

init (name smart_contract, asset smart_currency, bool smart_enabled, bool enabled, name network, bool require_balance, uint64_t max_fee, uint64_t fee) initializes the converter settings

void

on_transfer (name from, name to, asset quantity, string memo) transfer intercepts with standard transfer args

void

on_transfer (name from, name to, asset quantity, std::string memo) transfer intercepts

ACTION

setmaxfee (uint64_t maxfee) modify maxfee in this multi-converter's settings

ACTION

setmultitokn (name multi_token) creates the multi-converter settings, can only be called by multi-converter owner

ACTION

setnetwork (name network) sets the bancor network contract account

ACTION

setreserve (symbol_code converter_currency_code, symbol currency, name contract, uint64_t ratio) initializes a new reserve in the converter

ACTION

setreserve (name contract, symbol currency, uint64_t ratio, bool sale_enabled) initializes a new reserve in the converter

ACTION

setstaking (name staking) may only set staking/voting contract for this multi-converter once

ACTION

update (bool smart_enabled, bool enabled, bool require_balance, uint64_t fee) updates the converter settings

ACTION

updatefee (symbol_code currency, uint64_t fee) updates the converter fee

ACTION

updateowner (symbol_code currency, name new_owner) change converter's owner

ACTION

withdraw (name sender, asset quantity, symbol_code converter_currency_code) called by liquidity providers withdrawing "temporary balances" before fund ing them into the reserve

Macros

Type

Name

define

EMIT_CONVERSION_EVENT (converter_currency_symbol, memo, from_contract, from_symbol, to_contract, to_symbol, from_amount, to_amount, fee_amount) triggered when a conversion between two tokens occurs

define

EMIT_CONVERSION_EVENT (memo, from_contract, from_symbol, to_contract, to_symbol, from_amount, to_amount, fee_amount) triggered when a conversion between two tokens occurs

define

EMIT_CONVERSION_FEE_UPDATE_EVENT (converter_currency_symbol, prev_fee, new_fee) triggered after a fee update occurs for a converter

define

EMIT_CONVERSION_FEE_UPDATE_EVENT (prev_fee, new_fee) triggered when the conversion fee is updated

define

EMIT_PRICE_DATA_EVENT (converter_currency_symbol, smart_supply, reserve_contract, reserve_symbol, reserve_balance, reserve_ratio) triggered after a conversion with new tokens price data

define

EMIT_PRICE_DATA_EVENT (smart_supply, reserve_contract, reserve_symbol, reserve_balance, reserve_ratio) triggered after a conversion with new tokens price data

Detailed Description

Bancor Converter.

The Bancor converter allows conversions between a smart token and tokens that are defined as its reserves and between the different reserves directly.

Public Types Documentation

using close_action = action_wrapper<"delconverter"_n, &BancorConverter::delconverter>;

using create_action = action_wrapper<"create"_n, &BancorConverter::create>;

using delreserve_action = action_wrapper<"delreserve"_n, &BancorConverter::delreserve>;

using enablestake_action = action_wrapper<"enablestake"_n, &BancorConverter::enablestake>;

using fund_action = action_wrapper<"fund"_n, &BancorConverter::fund>;

using setmaxfee_action = action_wrapper<"setmaxfee"_n, &BancorConverter::setmaxfee>;

using setmultitokn_action = action_wrapper<"setmultitokn"_n, &BancorConverter::setmultitokn>;

using setreserve_action = action_wrapper<"setreserve"_n, &BancorConverter::setreserve>;

using setstaking_action = action_wrapper<"setstaking"_n, &BancorConverter::setstaking>;

using updatefee_action = action_wrapper<"updatefee"_n, &BancorConverter::updatefee>;

using updateowner_action = action_wrapper<"updateowner"_n, &BancorConverter::updateowner>;

using withdraw_action = action_wrapper<"withdraw"_n, &BancorConverter::withdraw>;

Public Functions Documentation

ACTION create (
name owner,
symbol_code token_code,
double initial_supply
)

Parameters:

  • owner - the converter creator

  • initial_supply - initial supply of the smart token governed by the converter

  • maximum_supply - maximum supply of the smart token governed by the converter

ACTION delconverter (
symbol_code converter_currency_code
)

Parameters:

  • converter_currency_code - the currency code of the currency governed by the converter

ACTION delreserve (
symbol_code converter,
symbol_code reserve
)

Parameters:

  • converter - the currency code of the smart token governed by the converter

  • currency - reserve token currency code

ACTION delreserve (
symbol_code currency
)

Parameters:

  • currency - reserve token currency symbol

ACTION enablestake (
symbol_code currency,
bool enabled
)

Parameters:

  • currency - the currency symbol governed by the converter

  • enabled - true if staking/voting for this symbol are enabled

ACTION fund (
name sender,
asset quantity
)

i.e. if the caller increases the supply by 10%, it will cost an amount equal to 10% of each connector token balance can only be called if the total ratio is exactly 100%

Parameters:

  • sender - sender of the quantity

  • quantity - amount to increase the supply by (in the smart token)

ACTION init (
name smart_contract,
asset smart_currency,
bool smart_enabled,
bool enabled,
name network,
bool require_balance,
uint64_t max_fee,
uint64_t fee
)

can only be called once, by the contract account

Parameters:

  • smart_contract - contract account name of the smart token governed by the converter

  • smart_currency - currency of the smart token governed by the converter

  • smart_enabled - true if the smart token can be converted to/from, false if not

  • enabled - true if conversions are enabled, false if not

  • require_balance - true if conversions that require creating new balance for the calling account should fail, false if not

  • network - bancor network contract name

  • max_fee - maximum conversion fee percentage, 0-30000, 4-pt precision a la eosio.asset

  • fee - conversion fee percentage, must be lower than the maximum fee, same precision

void on_transfer (
name from,
name to,
asset quantity,
string memo
)

memo containing a keyword following a semicolon at the end of the conversion path indicates special kind of transfer:

  • e.g. transferring smart tokens with keyword "liquidate", or

  • transferring reserve tokens with keyword "fund"

Parameters:

  • from - the sender of the transfer

  • to - the receiver of the transfer

  • quantity - the quantity for the transfer

  • memo - the memo for the transfer

void on_transfer (
name from,
name to,
asset quantity,
std::string memo
)

memo in csv format, may contain an extra keyword (e.g. "setup") following a semicolon at the end of the conversion path; indicates special transfer which otherwise would be interpreted as a standard conversion

Parameters:

  • from - the sender of the transfer

  • to - the receiver of the transfer

  • quantity - the quantity for the transfer

  • memo - the memo for the transfer

ACTION setmaxfee (
uint64_t maxfee
)

Parameters:

  • maxfee - maximum fee for all converters in this multi-converter

ACTION setmultitokn (
name multi_token
)

Parameters:

  • multi_token - may only set multi-token contract once

ACTION setnetwork (
name network
)

Parameters:

  • network - bancor network contract account

ACTION setreserve (
symbol_code converter_currency_code,
symbol currency,
name contract,
uint64_t ratio
)

can also be used to update an existing reserve, can only be called by the contract account

Parameters:

  • converter_currency_code - the currency code of the currency governed by the converter

  • currency - reserve token currency symbol

  • contract - reserve token contract name

  • ratio - reserve ratio, percentage, 0-1000000

ACTION setreserve (
name contract,
symbol currency,
uint64_t ratio,
bool sale_enabled
)

can also be used to update an existing reserve, can only be called by the contract account

Parameters:

  • contract - reserve token contract name

  • currency - reserve token currency symbol

  • ratio - reserve ratio, percentage, 0-1000000, precision a la max_fee

  • sale_enabled - true if purchases are enabled with the reserve, false if not

ACTION setstaking (
name staking
)

Parameters:

  • staking - name of staking/voting contract

ACTION update (
bool smart_enabled,
bool enabled,
bool require_balance,
uint64_t fee
)

can only be called by the contract account

Parameters:

  • smart_enabled - true if the smart token can be converted to/from, false if not

  • enabled - true if conversions are enabled, false if not

  • require_balance - true if conversions that require creating new balance for the calling account should fail, false if not

  • fee - conversion fee percentage, must be lower than the maximum fee, same precision

ACTION updatefee (
symbol_code currency,
uint64_t fee
)

Parameters:

  • currency - the currency symbol governed by the converter

  • fee - the new fee % for this converter, must be lower than the maximum fee, 0-1000000

ACTION updateowner (
symbol_code currency,
name new_owner
)

Parameters:

  • currency - the currency symbol governed by the converter

  • new_owner - converter's new owner

ACTION withdraw (
name sender,
asset quantity,
symbol_code converter_currency_code
)

Parameters:

  • sender - sender of the quantity

  • quantity - amount to decrease the supply by (in the smart token)

  • converter_currency_code - the currency code of the currency governed by the converter

Macro Definition Documentation

#define EMIT_CONVERSION_EVENT (
converter_currency_symbol,
memo,
from_contract,
from_symbol,
to_contract,
to_symbol,
from_amount,
to_amount,
fee_amount
) { \
START_EVENT("conversion", "1.4") \
EVENTKV("converter_currency_symbol", converter_currency_symbol) \
EVENTKV("memo", memo) \
EVENTKV("from_contract", from_contract) \
EVENTKV("from_symbol", from_symbol) \
EVENTKV("to_contract", to_contract) \
EVENTKV("to_symbol", to_symbol) \
EVENTKV("amount", from_amount) \
EVENTKV("return", to_amount) \
EVENTKVL("conversion_fee", fee_amount) \
END_EVENT() \
}

#define EMIT_CONVERSION_EVENT (
memo,
from_contract,
from_symbol,
to_contract,
to_symbol,
from_amount,
to_amount,
fee_amount
) { \
START_EVENT("conversion", "1.3") \
EVENTKV("memo", memo) \
EVENTKV("from_contract", from_contract) \
EVENTKV("from_symbol", from_symbol) \
EVENTKV("to_contract", to_contract) \
EVENTKV("to_symbol", to_symbol) \
EVENTKV("amount", from_amount) \
EVENTKV("return", to_amount) \
EVENTKVL("conversion_fee", fee_amount) \
END_EVENT() \
}

#define EMIT_CONVERSION_FEE_UPDATE_EVENT (
converter_currency_symbol,
prev_fee,
new_fee
) { \
START_EVENT("conversion_fee_update", "1.2") \
EVENTKV("converter_currency_symbol", converter_currency_symbol) \
EVENTKV("prev_fee", prev_fee) \
EVENTKVL("new_fee", new_fee) \
END_EVENT() \
}

#define EMIT_CONVERSION_FEE_UPDATE_EVENT (
prev_fee,
new_fee
) { \
START_EVENT("conversion_fee_update", "1.1") \
EVENTKV("prev_fee", prev_fee) \
EVENTKVL("new_fee", new_fee) \
END_EVENT() \
}

#define EMIT_PRICE_DATA_EVENT (
converter_currency_symbol,
smart_supply,
reserve_contract,
reserve_symbol,
reserve_balance,
reserve_ratio
) { \
START_EVENT("price_data", "1.5") \
EVENTKV("converter_currency_symbol", converter_currency_symbol) \
EVENTKV("smart_supply", smart_supply) \
EVENTKV("reserve_contract", reserve_contract) \
EVENTKV("reserve_symbol", reserve_symbol) \
EVENTKV("reserve_balance", reserve_balance) \
EVENTKVL("reserve_ratio", reserve_ratio) \
END_EVENT() \
}

#define EMIT_PRICE_DATA_EVENT (
smart_supply,
reserve_contract,
reserve_symbol,
reserve_balance,
reserve_ratio
) { \
START_EVENT("price_data", "1.4") \
EVENTKV("smart_supply", smart_supply) \
EVENTKV("reserve_contract", reserve_contract) \
EVENTKV("reserve_symbol", reserve_symbol) \
EVENTKV("reserve_balance", reserve_balance) \
EVENTKVL("reserve_ratio", reserve_ratio) \
END_EVENT() \
}