Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gdax

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gdax - npm Package Compare versions

Comparing version 0.3.1 to 0.4.2

38

lib/clients/authenticated.js

@@ -270,2 +270,40 @@ var util = require('util');

prototype.getFundings = function(callback) {
var self = this;
return prototype.get.call(self, ['funding'], callback);
};
prototype.repay = function(params, callback) {
var self = this;
_.forEach(['amount', 'currency'], function(param) {
if (params[param] === undefined) {
throw "`opts` must include param `" + param + "`";
}
});
var opts = { 'body': params };
return prototype.post.call(self, ['funding/repay'], opts, callback);
};
prototype.marginTransfer = function(params, callback) {
var self = this;
_.forEach(['margin_profile_id', 'type', 'currency', 'amount'], function(param) {
if (params[param] === undefined) {
throw "`opts` must include param `" + param + "`";
}
});
var opts = { 'body': params };
return prototype.post.call(self, ['profiles/margin-transfer'], opts, callback);
};
prototype.closePosition = function(params, callback) {
var self = this;
_.forEach(['repay_only'], function(param) {
if (params[param] === undefined) {
throw "`opts` must include param `" + param + "`";
}
});
var opts = { 'body': params };
return prototype.post.call(self, ['position/close'], opts, callback);
};
prototype.deposit = function(params, callback) {

@@ -272,0 +310,0 @@ var self = this;

1

lib/orderbook_sync.js

@@ -34,2 +34,3 @@ var WebsocketClient = require('./clients/websocket.js');

data = JSON.parse(data);
self.emit('message', data);

@@ -36,0 +37,0 @@ if (self._sequence === -1) {

2

package.json
{
"name": "gdax",
"version": "0.3.1",
"version": "0.4.2",
"author": "Coinbase",

@@ -5,0 +5,0 @@ "bugs": "https://github.com/coinbase/gdax-node/issues",

@@ -1,2 +0,2 @@

# GDAX [![CircleCI](https://circleci.com/gh/coinbase/gdax-node.svg?style=svg)](https://circleci.com/gh/coinbase/gdax-node)
# GDAX [![CircleCI](https://circleci.com/gh/coinbase/gdax-node.svg?style=svg)](https://circleci.com/gh/coinbase/gdax-node) [![npm version](https://badge.fury.io/js/gdax.svg)](https://badge.fury.io/js/gdax)
The official Node.js library for the [GDAX

@@ -125,8 +125,13 @@ API](https://docs.gdax.com/) (formerly Coinbase Exchange).

authenticate with an API key. You can create a new API key [in your exchange
account's settings](https://gdax.com/settings).
account's settings](https://gdax.com/settings). You can also specify the
API uri.
```javascript
var Gdax = require('gdax');
var apiURI = 'https://api.gdax.com';
var sandboxURI = 'https://api-public.sandbox.gdax.com';
// Defaults to https://api.gdax.com if apiURI omitted
var authedClient = new Gdax.AuthenticatedClient(
key, b64secret, passphrase);
key, b64secret, passphrase, apiURI);
```

@@ -239,2 +244,35 @@

* [`getFundings`](https://docs.gdax.com/#list-fundings)
```javascript
authedClient.getFundings({}, callback);
```
* [`repay`](https://docs.gdax.com/#repay)
```javascript
var params = {
'amount': '2000.00',
'currency': 'USD'
};
authedClient.repay(params, callback);
```
* [`marginTransfer`](https://docs.gdax.com/#margin-transfer)
```javascript
var params =
'margin_profile_id': '45fa9e3b-00ba-4631-b907-8a98cbdf21be',
'type': 'deposit',
'currency': 'USD',
'amount': 2
};
authedClient.marginTransfer(params, callback);
```
* [`closePosition`](https://docs.gdax.com/#close)
```javascript
var params = {
'repay_only': false
};
authedClient.closePosition(params, callback);
```
* [`deposit`, `withdraw`](https://docs.gdax.com/#list-fills)

@@ -241,0 +279,0 @@ ```javascript

@@ -308,2 +308,98 @@ var assert = require('assert');

test('get fundings', function(done) {
var expectedResponse = [{
"id": "280c0a56-f2fa-4d3b-a199-92df76fff5cd",
"order_id": "280c0a56-f2fa-4d3b-a199-92df76fff5cd",
"profile_id": "d881e5a6-58eb-47cd-b8e2-8d9f2e3ec6f6",
"amount": "545.2400000000000000",
"status": "outstanding",
"created_at": "2017-03-18T00:34:34.270484Z",
"currency": "USD",
"repaid_amount": "532.7580047716682500"
}];
nock(EXCHANGE_API_URL)
.get('/funding')
.reply(200, expectedResponse);
authClient.getFundings(function(err, resp, data) {
assert.ifError(err);
assert.deepEqual(data, expectedResponse);
nock.cleanAll();
done();
});
});
test('repay', function(done) {
var params = {
"amount" : 10000,
"currency": 'USD'
};
nock(EXCHANGE_API_URL)
.post('/funding/repay', params)
.reply(200, {});
authClient.repay(params, function(err, resp, data) {
assert.ifError(err);
nock.cleanAll();
done();
});
});
test('margin transfer', function(done) {
var params = {
"margin_profile_id": "45fa9e3b-00ba-4631-b907-8a98cbdf21be",
"type": "deposit",
"currency": "USD",
"amount": 2
};
var expectedResponse = {
"created_at": "2017-01-25T19:06:23.415126Z",
"id": "80bc6b74-8b1f-4c60-a089-c61f9810d4ab",
"user_id": "521c20b3d4ab09621f000011",
"profile_id": "cda95996-ac59-45a3-a42e-30daeb061867",
"margin_profile_id": "45fa9e3b-00ba-4631-b907-8a98cbdf21be",
"type": "deposit",
"amount": "2",
"currency": "USD",
"account_id": "23035fc7-0707-4b59-b0d2-95d0c035f8f5",
"margin_account_id": "e1d9862c-a259-4e83-96cd-376352a9d24d",
"margin_product_id": "BTC-USD",
"status": "completed",
"nonce": 25
};
nock(EXCHANGE_API_URL)
.post('/profiles/margin-transfer', params)
.reply(200, expectedResponse);
authClient.marginTransfer(params, function(err, resp, data) {
assert.ifError(err);
assert.deepEqual(data, expectedResponse);
nock.cleanAll();
done();
});
});
test('close position', function(done) {
var params = {
"repay_only" : false
};
nock(EXCHANGE_API_URL)
.post('/position/close', params)
.reply(200, {});
authClient.closePosition(params, function(err, resp, data) {
assert.ifError(err);
nock.cleanAll();
done();
});
});
test('deposit', function(done) {

@@ -310,0 +406,0 @@ var transfer = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc