Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6fd22a9
add ascendex candles
Jul 10, 2023
c2c417c
(feat) remove quantize for exchange py base since it's already in sup…
cardosofede Jul 10, 2023
ab2ce44
(feat) improve message for the user
cardosofede Jul 10, 2023
5f00232
(feat) diff between quantized and amount
cardosofede Jul 10, 2023
dcf1a0c
(feat) adapt exchange connector test
cardosofede Jul 10, 2023
a17db2d
(feat) adapt exchange connector test
cardosofede Jul 10, 2023
fedca25
Merge branch 'development' into feat/improve_trading_rules_logging
cardosofede Jul 10, 2023
f9dd486
(feat) increase order size to avoid min order errors
cardosofede Jul 10, 2023
40bbd1d
(feat) compute price before to use if and elif
cardosofede Jul 11, 2023
c768ad3
(feat) apply same changes to clob spot
cardosofede Jul 11, 2023
b84d7e5
(feat) adapt gateway clob spot test
cardosofede Jul 11, 2023
520409b
(feat) adapt gateway clob perp test
cardosofede Jul 11, 2023
ec53f3a
Merge branch 'development' into feat/improve_trading_rules_logging
cardosofede Jul 11, 2023
a9e9ffa
(feat) mock sleep
cardosofede Jul 11, 2023
99e110b
format code
Jul 11, 2023
99beb8f
Merge branch 'development' into feat/ascendex_spot_candles
rapcmia Jul 11, 2023
96caea8
format code
Jul 11, 2023
5914d51
fix unittest bug
Jul 11, 2023
8196c57
(feat) revert condition
cardosofede Jul 11, 2023
336bac1
(feat) add condition to catch decimal 0
cardosofede Jul 11, 2023
43f0174
(feat) refactor all test to don't query the price
cardosofede Jul 11, 2023
b35d9a4
(feat) Created the order book data source for Injective pure Python s…
Jun 29, 2023
510518d
(feat) Implemented exchange class for Injective pure Python connector…
Jul 11, 2023
14934b0
(feat) add fixed rate conversion for amm-arb
fengtality Jul 11, 2023
a14b3c1
(fix) Changed dependency for dydx-v3-python because it was forcing th…
Jul 12, 2023
8f9f01e
(fix) Added missing `eip712-structs` and fixed some issues in the uni…
Jul 12, 2023
e5b464c
(feat) add amm_gateway_data_feed.py
cardosofede Jul 12, 2023
eedbc0d
(feat) add test for gateway amm data feed
cardosofede Jul 12, 2023
fcf6b83
(feat) add script example to use data feed
cardosofede Jul 12, 2023
e10bee4
Fix the bug in mexc exchange, when the token price is super small, wh…
Jul 5, 2023
990ca60
(fix) Added a script to allow users to perform trading permission grants
Jul 12, 2023
538c432
(fix) address QA issues
fengtality Jul 12, 2023
63ef4ba
(fix) Solved issue handling sequence mismatch error during TX simulation
Jul 13, 2023
d4db953
Merge pull request #6471 from yancong001/feat/ascendex_spot_candles
cardosofede Jul 13, 2023
944167a
Merge branch 'development' into feat/improve_trading_rules_logging
cardosofede Jul 13, 2023
a700ba6
Merge branch 'development' into development
cardosofede Jul 13, 2023
12a4ebb
(fix) remove format status test
fengtality Jul 13, 2023
1433fa2
Merge branch 'development' into feat/fixed-rate-amm-arb
fengtality Jul 13, 2023
f6b08d4
(fix) remove unused functions
fengtality Jul 13, 2023
2a28010
Merge branch 'feat/fixed-rate-amm-arb' of github.com:hummingbot/hummi…
fengtality Jul 13, 2023
4f98d1d
(gov) epoch 5 changes
fengtality Jul 13, 2023
27ca4f5
Merge pull request #6467 from cardosofede/feat/improve_trading_rules_…
nikspz Jul 14, 2023
8470ca5
Merge branch 'development' into feat/fixed-rate-amm-arb
nikspz Jul 14, 2023
9b1c1ab
Merge branch 'development' into development
nikspz Jul 14, 2023
8c9b45b
Merge branch 'development' into feat/dex_data_feed
cardosofede Jul 14, 2023
0ea2967
Merge pull request #6473 from hlxwell/development
cardosofede Jul 14, 2023
d744968
Merge branch 'development' into feat/fixed-rate-amm-arb
nikspz Jul 14, 2023
5da2d7b
Merge pull request #6472 from hummingbot/feat/fixed-rate-amm-arb
nikspz Jul 14, 2023
0e25062
Merge branch 'development' into feat/dex_data_feed
fengtality Jul 15, 2023
03fc7c2
(fix) Fix Injective v2 connector name logic
Jul 16, 2023
75b6284
Merge branch 'development' into gov/epoch-5-connector-changes
nikspz Jul 17, 2023
db2a417
Merge pull request #6477 from cardosofede/feat/dex_data_feed
fengtality Jul 17, 2023
b95afbb
Merge branch 'development' into gov/epoch-5-connector-changes
fengtality Jul 17, 2023
0df4d60
Merge pull request #6478 from hummingbot/gov/epoch-5-connector-changes
nikspz Jul 17, 2023
b6cf83e
change_default_global_token_to_usdt
nikspz Jul 18, 2023
97794ee
Merge pull request #6490 from nikspz/development
nikspz Jul 18, 2023
ecc84cc
(feat) Added README file for the injective_v2 spot connector
Jul 19, 2023
411e8e8
(feat) Created the order book data source for Injective pure Python s…
Jun 29, 2023
f08e386
(feat) Implemented exchange class for Injective pure Python connector…
Jul 11, 2023
53fd87e
(fix) Changed dependency for dydx-v3-python because it was forcing th…
Jul 12, 2023
0f4dd75
(fix) Added missing `eip712-structs` and fixed some issues in the uni…
Jul 12, 2023
6b6f0ec
(fix) Added a script to allow users to perform trading permission grants
Jul 12, 2023
b2cda83
(fix) Solved issue handling sequence mismatch error during TX simulation
Jul 13, 2023
f7e73a2
(fix) Fix Injective v2 connector name logic
Jul 16, 2023
b0d4026
(feat) Added README file for the injective_v2 spot connector
Jul 19, 2023
2910c6b
Merge branch 'feat/injective_spot_with_delegation' of https://github.…
Jul 19, 2023
cd2ad70
(fix) Solve issues in unit tests after rebase with development branch
Jul 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ test:
--exclude-dir="test/debug" \
--exclude-dir="test/mock" \
--exclude-dir="test/hummingbot/connector/gateway/amm" \
--exclude-dir="test/hummingbot/connector/exchange/polkadex" \
--exclude-dir="test/hummingbot/connector/exchange/coinbase_pro" \
--exclude-dir="test/hummingbot/connector/exchange/kraken" \
--exclude-dir="test/hummingbot/connector/exchange/hitbtc" \
--exclude-dir="test/hummingbot/connector/exchange/bitmart" \
--exclude-dir="test/hummingbot/connector/exchange/ndax" \
--exclude-dir="test/hummingbot/connector/gateway/clob_spot/data_sources/dexalot" \
--exclude-dir="test/hummingbot/strategy/amm_arb" \
--exclude-dir="test/hummingbot/core/gateway" \
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Exchanges may be centralized (**CEX**), or decentralized (**DEX**), in which cas
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Bybit](https://docs.hummingbot.org/exchanges/bybit/) | SPOT CEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Bybit (perp)](https://docs.hummingbot.org/exchanges/bitmex-perpetual/) | PERP CEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Coinbase](https://docs.hummingbot.org/exchanges/coinbase/) | SPOT CEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [DeFi Kingdoms](https://docs.hummingbot.org/exchanges/defikingdoms/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Defira](https://docs.hummingbot.org/exchanges/defira/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Dexalot](https://docs.hummingbot.org/exchanges/dexalot/) | CLOB DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [HitBTC](https://docs.hummingbot.org/exchanges/hitbtc/) | SPOT CEX |
Expand All @@ -88,14 +87,13 @@ Exchanges may be centralized (**CEX**), or decentralized (**DEX**), in which cas
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Pancakeswap](https://docs.hummingbot.org/exchanges/pancakeswap/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Pangolin](https://docs.hummingbot.org/exchanges/pangolin/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Perpetual Protocol](https://docs.hummingbot.org/exchanges/perp/) | PERP DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Phemex Perpetual](https://docs.hummingbot.org/exchanges/perp/) | PERP DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Phemex Perpetual](https://docs.hummingbot.org/exchanges/perp/) | PERP CEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Polkadex](https://docs.hummingbot.org/exchanges/polkadex/) | SPOT DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Ref Finance](https://docs.hummingbot.org/exchanges/ref/) | SPOT DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Sushiswap](https://docs.hummingbot.org/exchanges/sushiswap/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Tinyman](https://docs.hummingbot.org/exchanges/tinyman/) | SPOT DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [VVS Finance](https://docs.hummingbot.org/exchanges/vvs/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [XSWAP](https://docs.hummingbot.org/exchanges/xswap/) | AMM DEX |
| ![](https://img.shields.io/static/v1?label=Hummingbot&message=BRONZE&color=green) | [Zigzag](https://docs.hummingbot.org/exchanges/zigzag/) | SPOT DEX |


Quarterly [Polls](https://docs.hummingbot.org/governance/polls/) allow the Hummingbot community to vote using HBOT tokens to decide which exchanges should be certified GOLD or SILVER, which means that they are maintained and continually improved by Hummingbot Foundation. In addition, the codebase includes BRONZE exchange connectors that are maintained by community members. See the [Hummingbot documentation](https://docs.hummingbot.org/exchanges) for all exchanges supported.
Expand Down
2 changes: 1 addition & 1 deletion hummingbot/client/config/client_config_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ class Config:

class GlobalTokenConfigMap(BaseClientModel):
global_token_name: str = Field(
default="USD",
default="USDT",
client_data=ClientFieldData(
prompt=lambda
cm: "What is your default display token? (e.g. USD,EUR,BTC)",
Expand Down
10 changes: 4 additions & 6 deletions hummingbot/connector/connector_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@
'perpetual_finance': 'bronze',
'uniswap': 'gold',
'uniswapLP': 'gold',
'pancakeswap': 'bronze',
'pancakeswap': 'silver',
'sushiswap': 'bronze',
'traderjoe': 'silver',
'quickswap': 'silver',
'traderjoe': 'bronze',
'quickswap': 'bronze',
'perp': 'bronze',
'openocean': 'bronze',
'pangolin': 'bronze',
'defikingdoms': 'bronze',
'defira': 'bronze',
'mad_meerkat': 'bronze',
'vvs': 'bronze',
'ref': 'bronze',
'injective': 'bronze',
'xswap': 'bronze',
'dexalot': 'bronze',
'dexalot': 'silver',
'kucoin_perpetual': 'silver',
'kucoin_perpetual_testnet': 'silver',
'injective_perpetual': 'bronze',
'zigzag': 'bronze',
'bit_com_perpetual': 'bronze',
'bit_com_perpetual_testnet': 'bronze',
'tinyman': 'bronze',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _get_fee(self,
trading_pair = combine_to_hb_trading_pair(base=base_currency, quote=quote_currency)
if trading_pair in self._trading_fees:
fee_schema: TradeFeeSchema = self._trading_fees[trading_pair]
fee_rate = fee_schema.maker_percent_fee_decimal if is_maker else fee_schema.maker_percent_fee_decimal
fee_rate = fee_schema.maker_percent_fee_decimal if is_maker else fee_schema.taker_percent_fee_decimal
fee = TradeFeeBase.new_spot_fee(
fee_schema=fee_schema,
trade_type=order_side,
Expand Down
17 changes: 17 additions & 0 deletions hummingbot/connector/exchange/injective_v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Injective v2

This is a spot connector created by **[Injective Labs](https://injectivelabs.org/)**.
The difference with `injective` connector is that v2 is a pure Python connector. That means that the user does not need to configure and run a Gateway instance to use the connector.
Also, `injective_v2` has been implemented to use delegated accounts. That means that the account used to send the transactions to the chain for trading is not the account holding the funds.
The user will need to have one portfolio account and at least one trading account. And permissions should be granted with the portfolio account to the trading account for it to operate using the portfolio account's funds.

### Trading permissions grant
To grant permissions from a portfolio account to a trading account to operate using the portfolio account funds please refer to the script `account_delegation_script.py`

### Connector parameters
When configuring a new instance of the connector in Hummingbot the following parameters are required:

- **injective_private_key**: the private key of the trading account (grantee account)
- **injective_subaccount_index**: the index (decimal number) of the subaccount from the trading account that the connector will be operating with
- **injective_granter_address**: the public key (injective format address) or the portfolio account
- **injective_granter_subaccount_index**: the index (decimal number) of the subaccount from the portfolio account (the subaccount holding the funds)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.composer import Composer
from pyinjective.constant import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey

# Values to be configured by the user
NETWORK = Network.testnet() # Select the correct network: mainnet, testnet, devnet, local or custom
GRANT_EXPIRATION_IN_DAYS = 365
GRANTER_ACCOUNT_PRIVATE_KEY = ""
GRANTER_SUBACCOUNT_INDEX = 0
GRANTEE_PUBLIC_INJECTIVE_ADDRESS = ""
MARKET_IDS = []
# List of the ids of all the markets the grant will include, for example:
# MARKET_IDS = ["0x0511ddc4e6586f3bfe1acb2dd905f8b8a82c97e1edaef654b12ca7e6031ca0fa"] # noqa: mock

# Fixed values, do not change
SECONDS_PER_DAY = 60 * 60 * 24


async def main() -> None:
composer = Composer(network=NETWORK.string())

# initialize grpc client
client = AsyncClient(NETWORK, insecure=False)
await client.sync_timeout_height()

# load account
granter_private_key = PrivateKey.from_hex(GRANTER_ACCOUNT_PRIVATE_KEY)
granter_public_key = granter_private_key.to_public_key()
granter_address = granter_public_key.to_address()
account = await client.get_account(granter_address.to_acc_bech32()) # noqa: F841
granter_subaccount_id = granter_address.get_subaccount_id(index=0)

msg = composer.MsgGrantTyped(
granter = granter_address.to_acc_bech32(),
grantee = GRANTEE_PUBLIC_INJECTIVE_ADDRESS,
msg_type = "BatchUpdateOrdersAuthz",
expire_in=GRANT_EXPIRATION_IN_DAYS * SECONDS_PER_DAY,
subaccount_id=granter_subaccount_id,
spot_markets=MARKET_IDS,
)

tx = (
Transaction()
.with_messages(msg)
.with_sequence(client.get_sequence())
.with_account_num(client.get_number())
.with_chain_id(NETWORK.chain_id)
)
sim_sign_doc = tx.get_sign_doc(granter_public_key)
sim_sig = granter_private_key.sign(sim_sign_doc.SerializeToString())
sim_tx_raw_bytes = tx.get_tx_data(sim_sig, granter_public_key)

# simulate tx
(sim_res, success) = await client.simulate_tx(sim_tx_raw_bytes)
if not success:
print(sim_res)
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
fee = [composer.Coin(
amount=gas_price * gas_limit,
denom=NETWORK.fee_denom,
)]

tx = tx.with_gas(gas_limit).with_fee(fee).with_memo("").with_timeout_height(client.timeout_height)
sign_doc = tx.get_sign_doc(granter_public_key)
sig = granter_private_key.sign(sign_doc.SerializeToString())
tx_raw_bytes = tx.get_tx_data(sig, granter_public_key)

res = await client.send_tx_sync_mode(tx_raw_bytes)
print(res)
print("gas wanted: {}".format(gas_limit))
print("gas fee: {} INJ".format(gas_fee))


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
52 changes: 52 additions & 0 deletions hummingbot/connector/exchange/injective_v2/injective_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sys

from hummingbot.core.api_throttler.data_types import RateLimit
from hummingbot.core.data_type.in_flight_order import OrderState

EXCHANGE_NAME = "injective_v2"

DEFAULT_DOMAIN = ""
TESTNET_DOMAIN = "testnet"

DEFAULT_SUBACCOUNT_INDEX = 0
EXTRA_TRANSACTION_GAS = 20000
DEFAULT_GAS_PRICE = 500000000

EXPECTED_BLOCK_TIME = 1.5
TRANSACTIONS_CHECK_INTERVAL = 3 * EXPECTED_BLOCK_TIME

# Public limit ids
ORDERBOOK_LIMIT_ID = "OrderBookSnapshot"
GET_TRANSACTION_LIMIT_ID = "GetTransaction"
GET_CHAIN_TRANSACTION_LIMIT_ID = "GetChainTransaction"

# Private limit ids
PORTFOLIO_BALANCES_LIMIT_ID = "AccountPortfolio"
SPOT_ORDERS_HISTORY_LIMIT_ID = "SpotOrdersHistory"
SPOT_TRADES_LIMIT_ID = "SpotTrades"
SIMULATE_TRANSACTION_LIMIT_ID = "SimulateTransaction"
SEND_TRANSACTION = "SendTransaction"

NO_LIMIT = sys.maxsize
ONE_SECOND = 1

RATE_LIMITS = [
RateLimit(limit_id=ORDERBOOK_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=GET_TRANSACTION_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=GET_CHAIN_TRANSACTION_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=PORTFOLIO_BALANCES_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=SPOT_ORDERS_HISTORY_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=SPOT_TRADES_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=SIMULATE_TRANSACTION_LIMIT_ID, limit=NO_LIMIT, time_interval=ONE_SECOND),
RateLimit(limit_id=SEND_TRANSACTION, limit=NO_LIMIT, time_interval=ONE_SECOND),
]

ORDER_STATE_MAP = {
"booked": OrderState.OPEN,
"partial_filled": OrderState.PARTIALLY_FILLED,
"filled": OrderState.FILLED,
"canceled": OrderState.CANCELED,
}

ORDER_NOT_FOUND_ERROR_MESSAGE = "order not found"
ACCOUNT_SEQUENCE_MISMATCH_ERROR = "account sequence mismatch"
Loading