Skip to content

Commit

Permalink
Add graphene
Browse files Browse the repository at this point in the history
  • Loading branch information
litepresence committed Mar 7, 2022
1 parent 10868b5 commit 34e9452
Show file tree
Hide file tree
Showing 28 changed files with 3,265 additions and 7 deletions.
Binary file added assets/bitshares-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/peerplays-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion hummingbot/client/command/connect_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ async def connect_exchange(self, # type: HummingbotApplication
network_timeout = float(global_config_map["other_commands_timeout"].value)
try:
err_msg = await asyncio.wait_for(
UserBalances.instance().add_exchange(exchange, **api_keys), network_timeout
UserBalances.instance().add_exchange(exchange, **api_keys),
network_timeout if exchange not in ["peerplays", "bitshares", "peerplays testnet", "bitshares testnet"] else 120 # CORE GRAPHENE EDIT
)
except asyncio.TimeoutError:
self._notify("\nA network error prevented the connection to complete. See logs for more details.")
Expand Down
2 changes: 1 addition & 1 deletion hummingbot/client/config/global_config_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def global_token_symbol_on_validated(value: str):
default="USD"),
"global_token_symbol":
ConfigVar(key="global_token_symbol",
prompt="What is your default display token symbol? (e.g. $,) >>> ",
prompt="What is your default display token symbol? (e.g. $, €, ₿, ¤) >>> ", # CORE GRAPHENE EDIT
type_str="str",
required_if=lambda: False,
on_validated=global_token_symbol_on_validated,
Expand Down
13 changes: 8 additions & 5 deletions hummingbot/client/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ def add_domain_parameter(self, params: Dict[str, Any]) -> Dict[str, Any]:

def base_name(self) -> str:
if self.is_sub_domain:
if self.parent_name == "peerplays": # CORE GRAPHENE EDIT
return "graphene"
return self.parent_name
else:
return self.name
return self.name if self.name != "peerplays" else "graphene" # CORE GRAPHENE EDIT


class AllConnectorSettings:
Expand Down Expand Up @@ -131,10 +133,11 @@ def create_connector_settings(cls):
util_module = importlib.import_module(path)
except ModuleNotFoundError:
continue
name = "peerplays" if connector_dir.name == "graphene" else connector_dir.name # CORE GRAPHENE EDIT
trade_fee_schema = getattr(util_module, "DEFAULT_FEES", None)
trade_fee_schema = cls._validate_trade_fee_schema(connector_dir.name, trade_fee_schema)
cls.all_connector_settings[connector_dir.name] = ConnectorSetting(
name=connector_dir.name,
trade_fee_schema = cls._validate_trade_fee_schema(name, trade_fee_schema)
cls.all_connector_settings[name] = ConnectorSetting( # CORE GRAPHENE EDIT
name=name, # CORE GRAPHENE EDIT
type=ConnectorType[type_dir.name.capitalize()],
centralised=getattr(util_module, "CENTRALIZED", True),
example_pair=getattr(util_module, "EXAMPLE_PAIR", ""),
Expand All @@ -151,7 +154,7 @@ def create_connector_settings(cls):
for domain in other_domains:
trade_fee_schema = getattr(util_module, "OTHER_DOMAINS_DEFAULT_FEES")[domain]
trade_fee_schema = cls._validate_trade_fee_schema(domain, trade_fee_schema)
parent = cls.all_connector_settings[connector_dir.name]
parent = cls.all_connector_settings[name] # CORE GRAPHENE EDIT
cls.all_connector_settings[domain] = ConnectorSetting(
name=domain,
type=parent.type,
Expand Down
6 changes: 6 additions & 0 deletions hummingbot/connector/connector_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
'binance_us': 'green',
'bitfinex': 'yellow',
'bitmart': 'yellow',
# CORE GRAPHENE EDIT
'bitshares': 'green',
'bitshares_testnet': 'green',
'bittrex': 'yellow',
'blocktane': 'yellow',
'bybit_perpetual': 'yellow',
Expand All @@ -35,6 +38,9 @@
'ndax': 'yellow',
'ndax_testnet': 'yellow',
'okex': 'yellow',
# CORE GRAPHENE EDIT
'peerplays': 'green',
'peerplays_testnet': 'green',
'perpetual_finance': 'yellow',
'probit': 'yellow',
'probit_kr': 'yellow',
Expand Down
23 changes: 23 additions & 0 deletions hummingbot/connector/exchange/graphene/README_core_changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
hummingbot/hummingbot/client/command/connect_command.py
Change timeout for graphene exchanges
Metanode may take some time to boot

hummingbot/hummingbot/client/config/global_config_map.py
Added currency symbol suggestions for decentralized tokens

hummingbot/hummingbot/client/settings.py
If the chain name is graphene change to peerplays by default

hummingbot/hummingbot/connector/connector_status.py
Add peerplays, bitshares, etc

hummingbot/hummingbot/core/data_type/order_book_tracker.py
Reverse pairs if they are not found

hummingbot/hummingbot/core/rate_oracle/rate_oracle.py
Add rate oracle for graphene

hummingbot/hummingbot/user/user_balances.py
FIXME

hummingbot/hummingbot/connector/exchange/graphene/*
1 change: 1 addition & 0 deletions hummingbot/connector/exchange/graphene/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
2 changes: 2 additions & 0 deletions hummingbot/connector/exchange/graphene/dummy.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cdef class dummy():
pass
2 changes: 2 additions & 0 deletions hummingbot/connector/exchange/graphene/dummy.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cdef class dummy():
pass
56 changes: 56 additions & 0 deletions hummingbot/connector/exchange/graphene/get_fee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# pylint: disable=bad-continuation



def get_fee(
self,
base_currency: str,
quote_currency: str,
order_type: OrderType,
order_side: TradeType, # TradeType.BUY TradeType.SELL
amount: Decimal,
price: Decimal = Decimal("nan"),
is_maker: Optional[bool] = None,
*_,
**__,
) -> TradeFeeBase:
"""
Calculates the estimated fee an order would pay
"""
# FIXME the hummingbot binance reference is a path to deprecation warning
# there appears to be no functional reference material, see:
# ~
# ~ BitshareExchange
## ~ ExchangeBase
### ~ ConnectorBase
#### ~ estimate_fee_pct
##### ~ core.utils.estimate_fee.estimate_fee << binance ends here not implemented
# self.logger().info("get_fee")
# I suspect the correct implementation will be:

account = dict(self.metanode.account) # DISCRETE SQL QUERY
objects = dict(self.metanode.objects) # DISCRETE SQL QUERY
assets = dict(sels.metanode.assets) # DISCRETE SQL QUERY
tx_currency = objects["1.3.0"]["name"]
tx_amount = account["fees_account"]["create"]
# you pay market fee on the currency you receive in the transaction
market_currency = quote_currency
maker_pct = assets[quote_currency]["fees_asset"]["maker"]
taker_pct = assets[quote_currency]["fees_asset"]["taker"]
if order_side == TradeType.BUY:
market_currency = base_currency
maker_pct = assets[base_currency]["fees_asset"]["maker"]
taker_pct = assets[base_currency]["fees_asset"]["taker"]
market_pct = maker_pct if is_maker else taker_pct
# build a TradeFeeBase class object
fee = TradeFeeBase()
flat_fee = TokenAmount()
flat_fee.token = tx_currency
flat_fee.amount = Decimal(tx_amount)
fee.flat_fees = [flat_fee]
fee.percent = Decimal(market_pct)
fee.percent_token = market_currency if market_currency != quote_currency else None

# return fee
# FIXME effectively ZERO
return DeductedFromReturnsTradeFee(percent=self.estimate_fee_pct(False))
Loading

0 comments on commit 34e9452

Please sign in to comment.