Giter Site home page Giter Site logo

v4-clients's People

Contributors

adamfraser avatar aforaleka avatar bonny5151 avatar christopher-li avatar dmu1313 avatar dydxwill avatar jakob-dydx avatar jaredvu avatar jiajames avatar johnqh avatar jonfung-dydx avatar lcwik avatar lucas-dydx avatar mike-dydx avatar rosepuppy avatar ruixhuang avatar tqin7 avatar ttl33 avatar vincentwschau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v4-clients's Issues

get.py grpc_message:"DNS resolution failed...

post.py working with fix #99 (comment)

any fix for get.py?
tried many formats for VALIDATOR_GRPC_MAINNET and supported nodes from list

VALIDATOR_GRPC_MAINNET = 'grpc+https://dydx-ops-grpc.kingnodes.com:443'
# VALIDATOR_GRPC_MAINNET = 'https://dydx-ops-grpc.kingnodes.com:443'
# VALIDATOR_GRPC_MAINNET = 'https://dydx-ops-grpc.kingnodes.com'
NETWORK_ID_MAINNET = 'dydx-mainnet-1'
INDEXER_API_HOST_MAINNET = 'https://indexer.dydx.trade'
INDEXER_WS_HOST_MAINNET = 'wss://indexer.dydx.trade'
NETWORK=Network(
    env='mainnet',
    validator_config=ValidatorConfig(
        grpc_endpoint=VALIDATOR_GRPC_MAINNET, 
        chain_id=NETWORK_ID_MAINNET, 
        ssl_enabled=True
    ),
    indexer_config=IndexerConfig(
        rest_endpoint=INDEXER_API_HOST_MAINNET, 
        websocket_endpoint=INDEXER_WS_HOST_MAINNET, 
    ),
    faucet_endpoint='',
)
 
client = CompositeClient(
    NETWORK,
)

client.validator_client.get.bank_balance(subaccount.address, 'ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5')
raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "DNS resolution failed for grpc+https://dydx-ops-grpc.kingnodes.com:443: UNAVAILABLE: WSA Error"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"DNS resolution failed for grpc+https://dydx-ops-grpc.kingnodes.com:443: UNAVAILABLE: WSA Error", grpc_status:14, created_time:"2024-03-12T03:10:48.338824+00:00"}"

examples/composite_example.py not working

python3 examples/composite_example.py

return

E1205 11:14:25.853674000 4689714624 hpack_parser.cc:999]               Error parsing 'content-type' metadata: invalid value
**Order Failed**
<_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Stream removed"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2023-12-05T11:14:25.853876+08:00", grpc_status:2, grpc_message:"Stream removed"}"
>
E1205 11:14:32.285944000 4689714624 hpack_parser.cc:999]               Error parsing 'content-type' metadata: invalid value
**Order Failed**
<_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Stream removed"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Stream removed", grpc_status:2, created_time:"2023-12-05T11:14:32.286025+08:00"}"
>
E1205 11:14:38.746211000 4689714624 hpack_parser.cc:999]               Error parsing 'content-type' metadata: invalid value
**Order Failed**
<_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Stream removed"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2023-12-05T11:14:38.746286+08:00", grpc_status:2, grpc_message:"Stream removed"}"
>
E1205 11:14:45.148782000 4689714624 hpack_parser.cc:999]               Error parsing 'content-type' metadata: invalid value
**Order Failed**
<_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Stream removed"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2023-12-05T11:14:45.148867+08:00", grpc_status:2, grpc_message:"Stream removed"}"
>
E1205 11:14:51.021330000 4689714624 hpack_parser.cc:999]               Error parsing 'content-type' metadata: invalid value

Error in react-native ("Restricted in strict mode ")

Package version details

    "@dydxprotocol/v4-client-js": "^1.1.4",
    "react-native": "0.72.7"  

Hermes engine is enabled

Device iOS simulator

Actual issues

When just write import line code

import {
  ValidatorClient,
  Network,
  LocalWallet,
  BECH32_PREFIX,
} from '@dydxprotocol/v4-client-js';

getting following error. Did not get details log.
Restricted in strict mode

'Network' has no attribute 'config_network'

Script

from v4_client_py.clients import IndexerClient
from v4_client_py.clients.constants import Network

client = IndexerClient(
    config=Network.config_network().indexer_config,
)

def get_market():
    try:
        markets_response = client.markets.get_perpetual_markets()
        print(markets_response.data)
    except Exception as e:
        print(f"failed to get markets: {e}")

Response

    config=Network.config_network().indexer_config,
AttributeError: type object 'Network' has no attribute 'config_network'

As shown in your example: https://github.com/kaloureyes3/v4-clients/blob/main/v4-client-py/examples/markets_endpoints.py

getOrder api 错误

源代码如下:
1 async getOrder(orderId: string) : Promise {
2 const uri = /v4/orders${orderId};
3 return this.get(uri);
4 }
第2行错误,应该为 const uri = /v4/orders/${orderId}; 漏掉了一个"/"

Issues with GoodTilBlock

How avoid this?

[ERROR] **Long Term Order Failed**
[ERROR] The GoodTilBlock 5671920 exceeds the current blockHeight 5671897 plus ShortBlockWindow 20: The GoodTilBlock of the message is further than ShortBlockWindow blocks into the future
{'error': BroadcastError('The GoodTilBlock 5671920 exceeds the current blockHeight 5671897 plus ShortBlockWindow 20: The GoodTilBlock of the message is further than ShortBlockWindow blocks into the future')}

It happens time to time. Eventually the order passes through.

This thing with GoodTilBlock is driving me nuts to get in sync...

Cheers.

when will v4 rust sdk be out

also, possible providing some docs explaining how secp256k1 private key derives dydx signing key; and what is the signing algorithm used in dydx trading

Support of mainnet

Will mainnet will be supported anytime soon, to make real orders and use stop losses?

NestJS run on Docker issue

Versions:

"@dydxprotocol/v4-client-js": "1.0.25"
"@nestjs": "9.1.6",
"docker-image": "node:16.18.0-alpine3.16"

I got this error

node:internal/modules/cjs/loader:988
  throw err;
  ^
Error: Cannot find module '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/assets/genesis'
Require stack:
- /home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/clients/modules/proto-includes.js
- /home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/clients/types.js
- /home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/types.js
- /home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/index.js
- /home/node/app/dist/modules/dydx/dydx-order.service.js
- /home/node/app/dist/modules/dydx/dydx-order.module.js
- /home/node/app/dist/app.module.js
- /home/node/app/dist/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/clients/modules/proto-includes.js:52:14)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/clients/modules/proto-includes.js',
    '/home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/clients/types.js',
    '/home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/types.js',
    '/home/node/app/node_modules/@dydxprotocol/v4-client-js/build/src/index.js',
    '/home/node/app/dist/modules/dydx/dydx-order.service.js',
    '/home/node/app/dist/modules/dydx/dydx-order.module.js',
    '/home/node/app/dist/app.module.js',
    '/home/node/app/dist/main.js'
  ]
}

Tried to upgrade node to 18.20.1 but the same issue has been happened

grpc._channel._InactiveRpcError: DNS resolution failed

Having trouble with the python composite client... I am unable to even do a simple operation like getting the current block: compositeClient.get_current_block()

    current_block = compositeClient.get_current_block()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/v4_client_py/clients/dydx_composite_client.py", line 45, in get_current_block
    response = self.validator_client.get.latest_block()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/v4_client_py/clients/modules/get.py", line 116, in latest_block
    return self.stubCosmosTendermint.GetLatestBlock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/grpc/_channel.py", line 1160, in __call__
    return _end_unary_response_blocking(state, call, False, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/grpc/_channel.py", line 1003, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "DNS resolution failed for https://dydx-rpc.publicnode.com:443: C-ares status is not ARES_SUCCESS qtype=A name=https://dydx-rpc.publicnode.com:443 is_balancer=0: Domain name not found"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"--omitted--", grpc_status:14, grpc_message:"DNS resolution failed for https://dydx-rpc.publicnode.com:443: C-ares status is not ARES_SUCCESS qtype=A name=https://dydx-rpc.publicnode.com:443 is_balancer=0: Domain name not found"}"

I've tried multiple RPC endpoints from https://docs.dydx.trade/networks/network1/resources but keep on getting the same error.
This is how I am instantiating my CompositeClient:

    indexerConfig = IndexerConfig(
        rest_endpoint='https://indexer.dydx.trade',
        websocket_endpoint='wss://indexer.dydx.trade/v4/ws',
    )
    compositeClient = CompositeClient(
        network=Network(
            env='mainnet',
            validator_config=ValidatorConfig(
                grpc_endpoint='https://dydx-rpc.publicnode.com:443',
                chain_id='dydx-mainnet-1', 
                ssl_enabled=True
            ),
            indexer_config=indexerConfig,
            faucet_endpoint=None,
        )
    )

Any help would be much appreciated.

get_perpetual_market_candles specifications ?

Hello,

I can't find precise information on that function : does it always return the last 100 candles of the given resolution ?

Thanks !

Edit : I also wonder if there is a plan to add mainnet api urls as there are only the testnet ones in the Netwokr constants.

Unable to install SDK-python( v4-client-py)

(venv) ➜ DYDX python -V
Python 3.11.2

pip install v4-client-py

....

Downloading cbor2-5.5.1-cp311-cp311-macosx_11_0_arm64.whl (64 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.9/64.9 kB 6.4 MB/s eta 0:00:00
Downloading eth_abi-4.2.1-py3-none-any.whl (28 kB)
Downloading eth_typing-3.5.2-py3-none-any.whl (14 kB)
Downloading eth_utils-2.3.1-py3-none-any.whl (77 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.8/77.8 kB 8.4 MB/s eta 0:00:00
Building wheels for collected packages: ed25519-blake2b
Building wheel for ed25519-blake2b (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for ed25519-blake2b (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use sudo xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools, or use xcode-select --install to install the standalone command line developer tools.
See man xcode-select for more details.
UPDATING build/lib.macosx-10.9-universal2-cpython-311/ed25519_blake2b/_version.py
set build/lib.macosx-10.9-universal2-cpython-311/ed25519_blake2b/_version.py to '1.4'
error: command '/Users/quinn/bin/clang' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ed25519-blake2b
Failed to build ed25519-blake2b
ERROR: Could not build wheels for ed25519-blake2b, which is required to install pyproject.toml-based projects

What's the correct way to replay the events on v4 chain?

Hey,

I'm currently exploring what's stored on the chain with a goal to do some analysis (and maybe make my own indexer later).

I've successfully established the connection with some mainnet validators and checked a few blocks so far.
It looks like all blocks contain these four messages

"/dydxprotocol.clob.MsgProposedOperations"
"/dydxprotocol.bridge.MsgAcknowledgeBridges"
"/dydxprotocol.perpetuals.MsgAddPremiumVotes"
"/dydxprotocol.prices.MsgUpdateMarketPrices"

I'm wondering, what's the correct way to decode them?
This is what i came up with so far https://github.com/miran248/dydx-v4-test/blob/a6581251eacfa488c85f564287fb1955097a0555/validator-client.ts#L6
Feels wrong, and MsgProposedOperations was not fully decoded
Screenshot 2023-12-22 at 12 36 43

Are there any other ways to replay the events?
Indexer has some functions but there i can't target a specific block height.

(didn't know where to ask this question, hence the issue)

Thanks,
Miran

EDIT: It looks like i'll have to do the mapping myself, like here https://github.com/dydxprotocol/v4-clients/blob/c94bcbf4fc91bb896ea716ccd02ace32b0cb50d0/v4-client-js/src/clients/lib/registry.ts

ModuleNotFoundError: No module named 'v4_proto'

After installing the Python package via pip install v4-client-py and running a basic initialize the client example from the docs:

from v4_client_py.clients import CompositeClient
from v4_client_py.clients.constants import Network
client = CompositeClient(
    Network.testnet(),
)

I am getting the errors below:

Traceback (most recent call last):
  File "d:\work\dydx-v4\execution\utils\dydx_v4_utils.py", line 1, in <module>
    from v4_client_py import IndexerClient
  File "D:\miniconda3\envs\dydx\lib\site-packages\v4_client_py\__init__.py", line 1, in <module>
    from v4_client_py.clients.dydx_indexer_client import IndexerClient
  File "D:\miniconda3\envs\dydx\lib\site-packages\v4_client_py\clients\__init__.py", line 4, in <module>
    from .dydx_validator_client import ValidatorClient
  File "D:\miniconda3\envs\dydx\lib\site-packages\v4_client_py\clients\dydx_validator_client.py", line 4, in <module>
    from .modules.get import Get
  File "D:\miniconda3\envs\dydx\lib\site-packages\v4_client_py\clients\modules\get.py", line 9, in <module>
    from v4_proto.dydxprotocol.clob.order_pb2 import *
ModuleNotFoundError: No module named 'v4_proto'

What could be the issue?

[NodeJS Client] Unhandled Websocket Error Crashes Process

I'm unable to add a simple socket.on('error') handler, since the custom socket object exported by v4-client-js doesn't support it.

node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: Unexpected server response: 503
    at ClientRequest.<anonymous> (/home/node_modules/@dydxprotocol/v4-client-js/node_modules/ws/lib/websocket.js:912:7)
    at ClientRequest.emit (node:events:519:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:535:22)
    at TLSSocket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
Emitted 'error' event on WebSocket instance at:
    at emitErrorAndClose (/home/node_modules/@dydxprotocol/v4-client-js/node_modules/ws/lib/websocket.js:1033:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Create alternative GRPC validator endpoint for python

Hello,

  1. The python client implementation uses a GRPC validator client.
  2. The default testnet GRPC endpoint is https://dydx-testnet-archive.allthatnode.com (link). Currently, if I run the following query (via HTTP), I get that this RPC is 11 hours behind.
curl -X GET \
    -H "accept: application/json" \
    "https://dydx-testnet-archive.allthatnode.com/block" \
    | python3 -m json.tool
  1. Alternatively, we could use https:/test-dydx.kingnodes.com in the above curl command, but we can't use it as a GRPC validator, since it doesn't open up a GRPC port.
curl -X GET \
    -H "accept: application/json" \
    "https://test-dydx.kingnodes.com/block" \
    | python3 -m json.tool

I request that this repository maintain a list of viable testnet validator GRPCs, OR that it modify the python client to broadcast via HTTP rather than GRPC.

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC

Getting the following error while placing an error using Composite client example.

rpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Stream removed"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2023-12-21T08:49:46.070181+00:00", grpc_status:2, grpc_message:"Stream removed"}"
>

What could be the issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.