-
Notifications
You must be signed in to change notification settings - Fork 85
Ndatta/revenue share #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+345
−4
Merged
Ndatta/revenue share #423
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f908416
Implemented revenue share related apis
ndatta-nethermind e5b2880
Implemented API to set order router revenue share
ndatta-nethermind 5b922dc
Using MsgStub instead of MsfService
ndatta-nethermind de1ba4c
Implemented revenue share apis
ndatta-nethermind 5e14ca8
Added tests to test the order router address during place order
ndatta-nethermind f55d81f
Removed POST method for revenue share
ndatta-nethermind 2cce1ee
Using size and price and remove twap parameters
ndatta-nethermind cc1b51e
Using market.order
ndatta-nethermind bec461a
Renamed test() to run_revenue_share_example()
ndatta-nethermind cd4ddd1
Fixed test code
ndatta-nethermind c476dfa
Fixed revenue share issue
ndatta-nethermind 0f68c07
Fixed order router test issue
ndatta-nethermind 51fd5dc
Resolved pr comments
ndatta-nethermind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from typing import List, Optional | ||
| from typing import List, Optional, Any | ||
|
|
||
| import grpc | ||
| from typing import Any | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import asyncio | ||
| import random | ||
| import time | ||
|
|
||
| from dydx_v4_client import MAX_CLIENT_ID, OrderFlags | ||
| from dydx_v4_client.indexer.rest.constants import OrderType | ||
| from dydx_v4_client.indexer.rest.indexer_client import IndexerClient | ||
| from dydx_v4_client.key_pair import KeyPair | ||
| from dydx_v4_client.network import TESTNET | ||
| from dydx_v4_client.node.client import NodeClient | ||
| from dydx_v4_client.node.market import Market | ||
| from dydx_v4_client.node.message import order_id | ||
| from dydx_v4_client.wallet import Wallet | ||
| from tests.conftest import TEST_ADDRESS_2, TEST_ADDRESS, DYDX_TEST_MNEMONIC | ||
| from v4_proto.dydxprotocol.clob.order_pb2 import Order | ||
|
|
||
|
|
||
| async def run_revenue_share_example(): | ||
| node = await NodeClient.connect(TESTNET.node) | ||
| try: | ||
| indexer = IndexerClient(TESTNET.rest_indexer) | ||
| MARKET_ID = "ETH-USD" | ||
| market = Market( | ||
| (await indexer.markets.get_perpetual_markets(MARKET_ID))["markets"][ | ||
| MARKET_ID | ||
| ] | ||
| ) | ||
varex83 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| wallet = await Wallet.from_mnemonic(node, DYDX_TEST_MNEMONIC, TEST_ADDRESS) | ||
|
|
||
| order_id = market.order_id( | ||
| TEST_ADDRESS, 0, random.randint(0, MAX_CLIENT_ID), OrderFlags.SHORT_TERM | ||
| ) | ||
|
|
||
| current_block = await node.latest_block_height() | ||
|
|
||
| new_order = market.order( | ||
| order_id=order_id, | ||
| order_type=OrderType.MARKET, | ||
| side=Order.Side.SIDE_SELL, | ||
| size=0.0001, | ||
| price=0, # Recommend set to oracle price - 5% or lower for SELL, oracle price + 5% for BUY | ||
| time_in_force=Order.TimeInForce.TIME_IN_FORCE_UNSPECIFIED, | ||
| reduce_only=False, | ||
| good_til_block=current_block + 10, | ||
| order_router_address=TEST_ADDRESS_2, | ||
| ) | ||
|
|
||
| transaction = await node.place_order( | ||
| wallet=wallet, | ||
| order=new_order, | ||
| ) | ||
|
|
||
| print(transaction) | ||
|
|
||
| await asyncio.sleep(5) | ||
|
|
||
| fills = await indexer.account.get_subaccount_fills( | ||
| address=TEST_ADDRESS, subaccount_number=0, limit=1 | ||
| ) | ||
|
|
||
| print(f"Fills: {fills}") | ||
|
|
||
| except Exception as e: | ||
| print(f"Error during placing order with order_router_address: {e}") | ||
|
|
||
| try: | ||
| response = await node.get_market_mapper_revenue_share_param() | ||
| print(response) | ||
| except Exception as e: | ||
| print(f"Error during fetching get_market_mapper_revenue_share_param: {e}") | ||
|
|
||
| try: | ||
| response = await node.get_order_router_revenue_share(TEST_ADDRESS_2) | ||
| print(response) | ||
| except Exception as e: | ||
| print(f"Error during fetching get_order_router_revenue_share: {e}") | ||
|
|
||
|
|
||
| asyncio.run(run_revenue_share_example()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.