Git Product home page Git Product logo

amp-node-api-client's Introduction

amp-node-api-client

Very Preliminary Under Heavy Development SDK for using AMP API in node.js This library creates the messages for AMP exchange websocket API.

Clone repo, build the module:

npm run build

In your code use this module, e.g. to get the list of trades per specific pair:

import { ampMessages } from 'pathto/amp-node-api-client'

var ws = new WebSocket("ws://13.125.100.61:8081/socket");

let trades = new ampMessages.Trades();
trades.baseToken = "0x9fF229BcC9e64e36a9b396b90Fb1660888136CA6"
trades.quoteToken = "0x8c8c812ea7bb3c32B45645f7cbf84c7F902049d6"
trades.baseTokenSymbol = "AE"
trades.quoteTokenSymbol = "DAI"

ws.onopen = (ev) => {
  trades.subscribe().then( trd => ws.send( JSON.stringify( trd ) ) );
}

ws.onmessage = (ev) => {
  console.log(ev.data);
}

For writing you'll need to sign the message using the signer of your choice:

import { ampMessages } from 'pathto/amp-node-api-client'

var ws = new WebSocket("ws://13.125.100.61:8081/socket");

let wallet = new Wallet(privateKey, provider)

//pass your signer to the orders object
let orders = new ampMessages.Orders(wallet);

orders.amount = "1"
orders.price = "1"
orders.exchangeAddress = EXCHANGE_ADDRESS
orders.userAddress = wallet.address
orders.side = "BUY"
orders.baseTokenAddress = "0x9fF229BcC9e64e36a9b396b90Fb1660888136CA6"
orders.quoteTokenAddress = "0xe9b5da78abb9fda785f828836f5c7e7f20273779" //WETH

orders.makeFee = "0.01"
orders.takeFee = "0.01"
orders.makeFee = "0"
orders.takeFee = "0"

ws.onopen = (ev) => {
  orders.new_order().then( (order) => {
    console.log(order);
    ws.send(JSON.stringify(order));
  });
}

ws.onmessage = (ev) => {
  console.log(ev.data);
}

amp-node-api-client's People

Contributors

dreykiman 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.