Skip to content
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

Update acknowledgements and code references #180

Merged
merged 6 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 13 additions & 8 deletions v4-client-py-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Install from github:

```bash
pip install git+https://github.com/NethermindEth/dydx-v4-client
pip install git+https://github.com/dydxprotocol/v4-clients/blob/main/v4-client-py-v2
```

## Quickstart
Expand All @@ -35,7 +35,7 @@ asyncio.run(main())
### Node
`NodeClient` allows to send transactions and fetch node state. E.g. you can deposit funds using the `deposit` method:

https://github.com/NethermindEth/dydx-v4-client/blob/f8be7bf9165fb052e831fcafb8086d14e5af13aa/examples/transfer_example_deposit.py#L1-L24
https://github.com/dydxprotocol/v4-clients/blob/3330f67752d430f9e0a20b419da4dc9daf7f7be0/v4-client-py-v2/examples/transfer_example_deposit.py#L1-L24

**Note:** It's possible to create a read only node client which doesn't allow to send transactions:
```python
Expand Down Expand Up @@ -65,7 +65,7 @@ async def test_account():
### Websocket indexer
Websocket indexer allows to subscribe to channels to obtain live updates:

https://github.com/NethermindEth/dydx-v4-client/blob/18eb769dde2a8691fc13445a34f46f0ecb266ec8/examples/websocket_example.py#L1-L24
https://github.com/dydxprotocol/v4-clients/blob/3330f67752d430f9e0a20b419da4dc9daf7f7be0/v4-client-py-v2/examples/websocket_example.py#L1-L24

### Networks

Expand Down Expand Up @@ -121,7 +121,7 @@ indexer = IndexerClient("https://dydx-testnet.imperator.co")
```
### Faucet
Faucet allows to obtain usdc on testnet. To use it create `FaucetClient`:
https://github.com/NethermindEth/dydx-v4-client/blob/18eb769dde2a8691fc13445a34f46f0ecb266ec8/examples/faucet_endpoint.py#L1-L15
https://github.com/dydxprotocol/v4-clients/blob/3330f67752d430f9e0a20b419da4dc9daf7f7be0/v4-client-py-v2/examples/faucet_endpoint.py#L1-L15

### Placing order
To place order first you have to build the order.
Expand Down Expand Up @@ -247,6 +247,12 @@ The project employs [`poetry`](https://python-poetry.org/). To install dependenc
poetry install
```

### Preparing development environment
Install git hooks:
```bash
pre-commit install
```

### Testing
To run tests use:

Expand All @@ -255,8 +261,7 @@ poetry run pytest
```

## Acknowledgements
Developed by:
- [Saul M.](https://github.com/samtin0x)
- [Piotr P.](https://github.com/piwonskp)

For more details, check out the [grant](https://www.dydxgrants.com/grants/python-trading-client).
Built by Nethermind: [@piwonskp](https://github.com/piwonskp), [@samtin0x](https://github.com/samtin0x), [@therustmonk](https://github.com/therustmonk)

For more details about the grant see [link](https://www.dydxgrants.com/grants/python-trading-client).
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import ssl
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Callable, Optional, Self, Union

import websocket
from typing_extensions import Any, Callable, Optional, Self, Union


class CandlesResolution(Enum):
Expand Down
2 changes: 1 addition & 1 deletion v4-client-py-v2/dydx_v4_client/node/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dataclasses import dataclass
from typing import List, Optional, Self

import grpc
from google.protobuf.message import Message
from typing_extensions import List, Optional, Self
from v4_proto.cosmos.auth.v1beta1 import query_pb2_grpc as auth
from v4_proto.cosmos.auth.v1beta1.auth_pb2 import BaseAccount
from v4_proto.cosmos.auth.v1beta1.query_pb2 import QueryAccountRequest
Expand Down
111 changes: 96 additions & 15 deletions v4-client-py-v2/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion v4-client-py-v2/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ authors = ["Piotr Piwoński <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.9"
v4-proto = "^4.0.1"
httpx = "^0.27.0"
websocket-client = "^1.7.0"
bip-utils = "^2.9.3"
ecdsa = "^0.19.0"
typing-extensions = "^4.12.2"


[tool.poetry.group.dev.dependencies]
Expand Down
9 changes: 7 additions & 2 deletions v4-client-py-v2/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@pytest.fixture
def indexer_rest_client():
return IndexerClient(TESTNET.rest_indexer)
return IndexerClient("https://indexer.v4testnet.dydx.exchange")


@pytest.fixture
Expand Down Expand Up @@ -103,7 +103,7 @@ async def wallet(node_client, private_key, test_address):
return await get_wallet(node_client, private_key, test_address)


def retry_on_forbidden(max_retries=3, delay=1):
def retry_on_forbidden(max_retries=3, delay=1, skip=False):
def decorator(func):
@wraps(func)
async def wrapper(*args, **kwargs):
Expand All @@ -115,6 +115,11 @@ async def wrapper(*args, **kwargs):
if attempt < max_retries - 1:
await asyncio.sleep(delay)
continue
else:
if skip:
pytest.skip("403 Forbidden error. Skipping the test.")
else:
raise
raise
raise httpx.HTTPStatusError(
request=e.request,
Expand Down
Loading
Loading