@n1xyz/nord-ts 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gen/nord_pb.d.ts +196 -105
- package/dist/gen/nord_pb.js +117 -89
- package/dist/gen/openapi.d.ts +137 -7
- package/dist/nord/api/actions.d.ts +22 -1
- package/dist/nord/api/actions.js +61 -2
- package/dist/nord/api/triggers.d.ts +7 -0
- package/dist/nord/api/triggers.js +38 -0
- package/dist/nord/client/Nord.d.ts +10 -1
- package/dist/nord/client/Nord.js +21 -0
- package/dist/nord/client/NordUser.d.ts +54 -1
- package/dist/nord/client/NordUser.js +97 -0
- package/dist/types.d.ts +16 -3
- package/dist/types.js +30 -4
- package/package.json +2 -2
- package/src/gen/nord_pb.ts +268 -173
- package/src/gen/openapi.ts +137 -7
- package/src/nord/api/actions.ts +100 -2
- package/src/nord/api/triggers.ts +57 -0
- package/src/nord/client/Nord.ts +27 -0
- package/src/nord/client/NordUser.ts +160 -1
- package/src/types.ts +34 -3
package/dist/types.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.QuoteSize = exports.WebSocketMessageType = exports.FillMode = exports.Side = exports.KeyType = exports.PeakTpsPeriodUnit = void 0;
|
|
39
|
+
exports.QuoteSize = exports.WebSocketMessageType = exports.TriggerStatus = exports.TriggerKind = exports.FillMode = exports.Side = exports.KeyType = exports.PeakTpsPeriodUnit = void 0;
|
|
40
40
|
exports.fillModeToProtoFillMode = fillModeToProtoFillMode;
|
|
41
41
|
const proto = __importStar(require("./gen/nord_pb"));
|
|
42
42
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
@@ -66,8 +66,8 @@ var KeyType;
|
|
|
66
66
|
})(KeyType || (exports.KeyType = KeyType = {}));
|
|
67
67
|
var Side;
|
|
68
68
|
(function (Side) {
|
|
69
|
-
Side[
|
|
70
|
-
Side[
|
|
69
|
+
Side["Ask"] = "ask";
|
|
70
|
+
Side["Bid"] = "bid";
|
|
71
71
|
})(Side || (exports.Side = Side = {}));
|
|
72
72
|
var FillMode;
|
|
73
73
|
(function (FillMode) {
|
|
@@ -76,6 +76,18 @@ var FillMode;
|
|
|
76
76
|
FillMode[FillMode["ImmediateOrCancel"] = 2] = "ImmediateOrCancel";
|
|
77
77
|
FillMode[FillMode["FillOrKill"] = 3] = "FillOrKill";
|
|
78
78
|
})(FillMode || (exports.FillMode = FillMode = {}));
|
|
79
|
+
var TriggerKind;
|
|
80
|
+
(function (TriggerKind) {
|
|
81
|
+
TriggerKind[TriggerKind["StopLoss"] = 0] = "StopLoss";
|
|
82
|
+
TriggerKind[TriggerKind["TakeProfit"] = 1] = "TakeProfit";
|
|
83
|
+
})(TriggerKind || (exports.TriggerKind = TriggerKind = {}));
|
|
84
|
+
var TriggerStatus;
|
|
85
|
+
(function (TriggerStatus) {
|
|
86
|
+
TriggerStatus[TriggerStatus["Active"] = 0] = "Active";
|
|
87
|
+
TriggerStatus[TriggerStatus["Success"] = 1] = "Success";
|
|
88
|
+
TriggerStatus[TriggerStatus["Cancel"] = 2] = "Cancel";
|
|
89
|
+
TriggerStatus[TriggerStatus["Remove"] = 4] = "Remove";
|
|
90
|
+
})(TriggerStatus || (exports.TriggerStatus = TriggerStatus = {}));
|
|
79
91
|
/**
|
|
80
92
|
* Converts a `FillMode` enum to its corresponding protobuf representation.
|
|
81
93
|
*
|
|
@@ -105,7 +117,19 @@ var WebSocketMessageType;
|
|
|
105
117
|
WebSocketMessageType["AccountUpdate"] = "account";
|
|
106
118
|
})(WebSocketMessageType || (exports.WebSocketMessageType = WebSocketMessageType = {}));
|
|
107
119
|
// Positive decimal price and size.
|
|
120
|
+
// Example:
|
|
121
|
+
// ```
|
|
122
|
+
// const limit = new QuoteSize(new Decimal(114000), new Decimal(0.00035)),
|
|
123
|
+
//```
|
|
124
|
+
// Gives 40$ USD limit.
|
|
125
|
+
//
|
|
126
|
+
// Given price is same(or very close) to the market price,
|
|
127
|
+
// limit gives size tick as close as possible to settlemnt size tick.
|
|
128
|
+
// If you want to get smaller tick on client (on server it will not change),
|
|
129
|
+
// do `new QuoteSize(new Decimal(114000/2), new Decimal(0.00070))`.
|
|
130
|
+
// It will be 40$ limit, but may help if BTC suddently moves fast.
|
|
108
131
|
class QuoteSize {
|
|
132
|
+
/// Input can be only positive values.
|
|
109
133
|
constructor(quotePrice, quoteSize) {
|
|
110
134
|
const p = new decimal_js_1.default(quotePrice);
|
|
111
135
|
const s = new decimal_js_1.default(quoteSize);
|
|
@@ -115,10 +139,12 @@ class QuoteSize {
|
|
|
115
139
|
this.price = p;
|
|
116
140
|
this.size = s;
|
|
117
141
|
}
|
|
142
|
+
// USD value of limit, use for debug
|
|
118
143
|
value() {
|
|
119
144
|
return this.price.mul(this.size);
|
|
120
145
|
}
|
|
121
|
-
|
|
146
|
+
// Converts to wire format to be send to server, scaling price and size according to market decimals.
|
|
147
|
+
toWire(marketPriceDecimals, marketSizeDecimals) {
|
|
122
148
|
return {
|
|
123
149
|
price: (0, utils_1.toScaledU64)(this.price, marketPriceDecimals),
|
|
124
150
|
size: (0, utils_1.toScaledU64)(this.size, marketSizeDecimals),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1xyz/nord-ts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Typescript for Nord",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@bufbuild/protobuf": "^2.6.3",
|
|
48
|
-
"@n1xyz/proton": "0.0.
|
|
48
|
+
"@n1xyz/proton": "0.0.4",
|
|
49
49
|
"@noble/curves": "^1.9.6",
|
|
50
50
|
"@noble/ed25519": "^2.3.0",
|
|
51
51
|
"@noble/hashes": "^1.8.0",
|