Git Product home page Git Product logo

dydx4examples's Introduction

Examples for the v4-Client Typescript client to place an order and query the dYdX chain. For more information, on a step-by-step guide, check here: https://zinc-bongo-636.notion.site/DYDX-Orders-74952ac102584dfcbed8542cb9506b64?pvs=4

Development

v4-client-js uses node v18 for development. You can use nvm to manage different versions of node.

nvm install
nvm use
nvm alias default $(nvm version) # optional

You can run the following commands to ensure that you are running the correct node and npm versions.

node -v # expected: v18.x.x (should match .nvmrc)
npm -v  # expected: 8.x.x

Quickstart

1. Clone or fork the examples repo

git clone [email protected]:gaonip/dydx4examples.git

2. Setup your mnemonic and define your orders

  • Go to /src/orderExample.ts and fill out a mnemonic for testnet. Feel free to use DYDX_TEST_MNEMONIC from the official TS client library under v4-client-js/examples/constants for development purposes

  • Now modify or add your orders in the /src/human_readable_orders.json file.

3a. Run the scripts with node

npm install
npm run build

You should now see a /build dir generated with JS files. We will use node to run these scripts

  • Run the websocket first to see orders for a given subaccount
node build/websocketExample.js
  • Open a separate terminal to run the example orders. The first order is a BTC limit sell order.
  • The second order is an order that is not expected to be filed immediately, in that case the cancel order will cancel if not executed within 5 minutes.
  • See example outputs in the /output dir
node build/orderExample.js

3b. Run the scripts with ts-node

Alternatively you can run directly with ts-node for development purpose.

npm install
npm install typescript ts-node
  • Run the websocket first to see orders for a given subaccount
npx ts-node build/websocketExample.ts
  • Open a separate terminal to run the example orders. The first order is a BTC limit sell order.
  • The second order is an order that is not expected to be filed immediately, in that case the cancel order will cancel if not executed within 5 minutes.
npx ts-node build/orderExample.ts

dydx4examples's People

Contributors

gaonip avatar

Watchers

 avatar

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.