@n1xyz/nord-ts 0.0.1 → 0.0.4
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/.eslintrc.js +11 -0
- package/README.md +148 -65
- package/dist/bridge/NordUser.d.ts +78 -0
- package/dist/bridge/NordUser.js +196 -0
- package/dist/bridge/client.d.ts +150 -0
- package/dist/bridge/client.js +394 -0
- package/dist/bridge/const.d.ts +23 -0
- package/dist/bridge/const.js +47 -0
- package/dist/bridge/index.d.ts +5 -0
- package/dist/bridge/index.js +23 -0
- package/dist/bridge/types.d.ts +118 -0
- package/dist/bridge/types.js +16 -0
- package/dist/bridge/utils.d.ts +64 -0
- package/dist/bridge/utils.js +131 -0
- package/dist/client.d.ts +70 -0
- package/dist/client.js +129 -0
- package/dist/const.d.ts +2 -5
- package/dist/const.js +18 -22
- package/dist/constants/endpoints.d.ts +65 -0
- package/dist/constants/endpoints.js +68 -0
- package/dist/gen/common.d.ts +6 -1
- package/dist/gen/common.js +19 -9
- package/dist/gen/nord.d.ts +75 -17
- package/dist/gen/nord.js +987 -423
- package/dist/idl/bridge.d.ts +2 -0
- package/dist/idl/bridge.js +703 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +18 -2
- package/dist/models/account.d.ts +58 -0
- package/dist/models/account.js +6 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +28 -0
- package/dist/models/market.d.ts +137 -0
- package/dist/models/market.js +6 -0
- package/dist/models/order.d.ts +211 -0
- package/dist/models/order.js +6 -0
- package/dist/models/token.d.ts +50 -0
- package/dist/models/token.js +6 -0
- package/dist/nord/Nord.d.ts +222 -49
- package/dist/nord/Nord.js +290 -278
- package/dist/nord/NordError.d.ts +23 -0
- package/dist/nord/NordError.js +48 -0
- package/dist/nord/NordImpl.d.ts +6 -2
- package/dist/nord/NordImpl.js +21 -1
- package/dist/nord/NordUser.d.ts +208 -42
- package/dist/nord/NordUser.js +389 -157
- package/dist/nord/Subscriber.d.ts +37 -0
- package/dist/nord/Subscriber.js +29 -0
- package/dist/nord/api/actions.d.ts +101 -0
- package/dist/nord/api/actions.js +250 -0
- package/dist/nord/api/core.d.ts +49 -0
- package/dist/nord/api/core.js +121 -0
- package/dist/nord/api/index.d.ts +1 -0
- package/dist/nord/api/index.js +17 -0
- package/dist/nord/api/market.d.ts +36 -0
- package/dist/nord/api/market.js +98 -0
- package/dist/nord/api/metrics.d.ts +67 -0
- package/dist/nord/api/metrics.js +132 -0
- package/dist/nord/api/orderFunctions.d.ts +168 -0
- package/dist/nord/api/orderFunctions.js +133 -0
- package/dist/nord/api/queries.d.ts +81 -0
- package/dist/nord/api/queries.js +187 -0
- package/dist/nord/client/Nord.d.ts +335 -0
- package/dist/nord/client/Nord.js +532 -0
- package/dist/nord/client/NordUser.d.ts +320 -0
- package/dist/nord/client/NordUser.js +701 -0
- package/dist/nord/core.d.ts +48 -0
- package/dist/nord/core.js +97 -0
- package/dist/nord/index.d.ts +9 -2
- package/dist/nord/index.js +30 -6
- package/dist/nord/market.d.ts +36 -0
- package/dist/nord/market.js +90 -0
- package/dist/nord/metrics.d.ts +67 -0
- package/dist/nord/metrics.js +124 -0
- package/dist/nord/models/Subscriber.d.ts +37 -0
- package/dist/nord/models/Subscriber.js +29 -0
- package/dist/nord/queries.d.ts +81 -0
- package/dist/nord/queries.js +181 -0
- package/dist/nord/types.d.ts +88 -0
- package/dist/nord/types.js +2 -0
- package/dist/nord/utils/NordError.d.ts +35 -0
- package/dist/nord/utils/NordError.js +46 -0
- package/dist/nord/websocket.d.ts +49 -0
- package/dist/nord/websocket.js +107 -0
- package/dist/operations/account.d.ts +58 -0
- package/dist/operations/account.js +112 -0
- package/dist/operations/market.d.ts +65 -0
- package/dist/operations/market.js +131 -0
- package/dist/operations/orders.d.ts +57 -0
- package/dist/operations/orders.js +129 -0
- package/dist/solana/NordUser.d.ts +78 -0
- package/dist/solana/NordUser.js +196 -0
- package/dist/solana/client.d.ts +139 -0
- package/dist/solana/client.js +360 -0
- package/dist/solana/const.d.ts +23 -0
- package/dist/solana/const.js +47 -0
- package/dist/solana/index.d.ts +5 -0
- package/dist/solana/index.js +23 -0
- package/dist/solana/types.d.ts +118 -0
- package/dist/solana/types.js +16 -0
- package/dist/solana/utils.d.ts +64 -0
- package/dist/solana/utils.js +131 -0
- package/dist/types/api.d.ts +152 -0
- package/dist/types/api.js +6 -0
- package/dist/types/config.d.ts +34 -0
- package/dist/types/config.js +6 -0
- package/dist/types.d.ts +144 -87
- package/dist/types.js +13 -2
- package/dist/utils/errors.d.ts +96 -0
- package/dist/utils/errors.js +132 -0
- package/dist/utils/http.d.ts +35 -0
- package/dist/utils/http.js +105 -0
- package/dist/utils.d.ts +14 -5
- package/dist/utils.js +26 -7
- package/dist/websocket/NordWebSocketClient.d.ts +71 -0
- package/dist/websocket/NordWebSocketClient.js +343 -0
- package/dist/websocket/client.d.ts +93 -0
- package/dist/websocket/client.js +222 -0
- package/dist/websocket/events.d.ts +19 -0
- package/dist/websocket/events.js +2 -0
- package/dist/websocket/index.d.ts +2 -0
- package/dist/websocket/index.js +5 -0
- package/dist/websocket.d.ts +55 -0
- package/dist/websocket.js +211 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Nord.html +2 -15
- package/docs/classes/NordUser.html +4 -4
- package/docs/enums/FillMode.html +2 -2
- package/docs/enums/KeyType.html +2 -2
- package/docs/enums/PeakTpsPeriodUnit.html +2 -2
- package/docs/enums/Side.html +2 -2
- package/docs/functions/assert.html +1 -1
- package/docs/functions/bigIntToProtoU128.html +1 -1
- package/docs/functions/checkPubKeyLength.html +1 -1
- package/docs/functions/checkedFetch.html +1 -1
- package/docs/functions/decodeLengthDelimited.html +1 -1
- package/docs/functions/encodeLengthDelimited.html +1 -1
- package/docs/functions/fillModeToProtoFillMode.html +1 -1
- package/docs/functions/findMarket.html +1 -1
- package/docs/functions/findToken.html +1 -1
- package/docs/functions/makeWalletSignFn.html +1 -1
- package/docs/functions/optExpect.html +1 -1
- package/docs/functions/optMap.html +1 -1
- package/docs/functions/optUnwrap.html +1 -1
- package/docs/functions/panic.html +1 -1
- package/docs/functions/signAction.html +1 -1
- package/docs/functions/toScaledU128.html +1 -1
- package/docs/functions/toScaledU64.html +1 -1
- package/docs/interfaces/Account.html +2 -2
- package/docs/interfaces/ActionInfo.html +2 -2
- package/docs/interfaces/ActionQuery.html +2 -2
- package/docs/interfaces/ActionResponse.html +2 -2
- package/docs/interfaces/ActionsExtendedInfo.html +2 -2
- package/docs/interfaces/ActionsQuery.html +2 -2
- package/docs/interfaces/ActionsResponse.html +2 -2
- package/docs/interfaces/AggregateMetrics.html +2 -2
- package/docs/interfaces/BlockQuery.html +2 -2
- package/docs/interfaces/BlockResponse.html +2 -2
- package/docs/interfaces/BlockSummary.html +2 -2
- package/docs/interfaces/BlockSummaryResponse.html +2 -2
- package/docs/interfaces/DeltaEvent.html +2 -2
- package/docs/interfaces/ERC20TokenInfo.html +2 -2
- package/docs/interfaces/Info.html +2 -2
- package/docs/interfaces/Market.html +2 -2
- package/docs/interfaces/MarketStats.html +2 -2
- package/docs/interfaces/MarketsStatsResponse.html +2 -2
- package/docs/interfaces/NordConfig.html +2 -2
- package/docs/interfaces/Order.html +2 -2
- package/docs/interfaces/OrderInfo.html +2 -2
- package/docs/interfaces/PerpMarketStats.html +2 -2
- package/docs/interfaces/RollmanActionExtendedInfo.html +2 -2
- package/docs/interfaces/RollmanActionInfo.html +2 -2
- package/docs/interfaces/RollmanActionResponse.html +2 -2
- package/docs/interfaces/RollmanActionsResponse.html +2 -2
- package/docs/interfaces/RollmanBlockResponse.html +2 -2
- package/docs/interfaces/SubscriberConfig.html +2 -2
- package/docs/interfaces/Token.html +2 -2
- package/docs/interfaces/Trade.html +2 -2
- package/docs/interfaces/Trades.html +2 -2
- package/docs/modules.html +0 -7
- package/docs/types/BigIntValue.html +1 -1
- package/docs/variables/DEBUG_KEYS.html +1 -1
- package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -1
- package/docs/variables/DEV_CONTRACT_ADDRESS.html +1 -1
- package/docs/variables/DEV_TOKEN_INFOS.html +1 -1
- package/docs/variables/DEV_URL.html +1 -1
- package/docs/variables/ERC20_ABI.html +1 -1
- package/docs/variables/EVM_DEV_URL.html +1 -1
- package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +1 -1
- package/docs/variables/MAX_BUFFER_LEN.html +1 -1
- package/docs/variables/NORD_GETTERS_FACET_ABI.html +1 -1
- package/docs/variables/NORD_RAMP_FACET_ABI.html +1 -1
- package/docs/variables/SESSION_TTL.html +1 -1
- package/docs/variables/WEBSERVER_DEV_URL.html +1 -1
- package/docs/variables/ZERO_DECIMAL.html +1 -1
- package/package.json +10 -12
- package/src/bridge/client.ts +487 -0
- package/src/bridge/const.ts +53 -0
- package/src/bridge/index.ts +7 -0
- package/src/bridge/types.ts +127 -0
- package/src/bridge/utils.ts +140 -0
- package/src/const.ts +20 -25
- package/src/gen/common.ts +27 -10
- package/src/gen/nord.ts +1044 -483
- package/src/idl/bridge.ts +702 -0
- package/src/index.ts +24 -5
- package/src/nord/{actions.ts → api/actions.ts} +33 -37
- package/src/nord/api/core.ts +130 -0
- package/src/nord/api/market.ts +125 -0
- package/src/nord/api/metrics.ts +154 -0
- package/src/nord/api/queries.ts +236 -0
- package/src/nord/client/Nord.ts +652 -0
- package/src/nord/client/NordUser.ts +1105 -0
- package/src/nord/index.ts +16 -2
- package/src/nord/models/Subscriber.ts +57 -0
- package/src/nord/utils/NordError.ts +72 -0
- package/src/types.ts +170 -99
- package/src/utils.ts +40 -19
- package/src/websocket/NordWebSocketClient.ts +432 -0
- package/src/websocket/events.ts +31 -0
- package/src/websocket/index.ts +2 -0
- package/tests/utils.spec.ts +24 -24
- package/docs/classes/Subscriber.html +0 -6
- package/docs/functions/createWebSocketSubscription.html +0 -12
- package/docs/interfaces/OrderbookOrder.html +0 -6
- package/docs/interfaces/OrderbookResponse.html +0 -10
- package/docs/interfaces/TradeInfo.html +0 -20
- package/docs/interfaces/TradesQueryParams.html +0 -10
- package/docs/interfaces/TradesResponse.html +0 -12
- package/src/abis/ERC20_ABI.ts +0 -310
- package/src/abis/NORD_GETTERS_FACET_ABI.ts +0 -192
- package/src/abis/NORD_RAMP_FACET_ABI.ts +0 -141
- package/src/abis/index.ts +0 -3
- package/src/nord/Nord.ts +0 -504
- package/src/nord/NordImpl.ts +0 -8
- package/src/nord/NordUser.ts +0 -469
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Subscriber = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
/**
|
|
10
|
+
* Subscriber class for handling WebSocket subscriptions
|
|
11
|
+
*/
|
|
12
|
+
class Subscriber {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new Subscriber instance
|
|
15
|
+
* @param config Subscriber configuration
|
|
16
|
+
*/
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.streamURL = config.streamURL;
|
|
19
|
+
this.buffer = [];
|
|
20
|
+
this.maxBufferLen = config.maxBufferLen ?? utils_1.MAX_BUFFER_LEN;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to WebSocket events
|
|
24
|
+
*/
|
|
25
|
+
subscribe() {
|
|
26
|
+
const ws = new ws_1.default(this.streamURL);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Subscriber = Subscriber;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { FillMode, Side } from '../../types';
|
|
3
|
+
import { BigIntValue } from '../../utils';
|
|
4
|
+
declare function createSessionImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, walletSignFn: (message: string | Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
5
|
+
userPubkey: Uint8Array;
|
|
6
|
+
sessionPubkey: Uint8Array;
|
|
7
|
+
expiryTimestamp?: bigint;
|
|
8
|
+
}): Promise<bigint>;
|
|
9
|
+
export declare function createSession(serverUrl: string, walletSignFn: (message: string | Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
10
|
+
userPubkey: Uint8Array;
|
|
11
|
+
sessionPubkey: Uint8Array;
|
|
12
|
+
expiryTimestamp?: bigint;
|
|
13
|
+
}): Promise<bigint>;
|
|
14
|
+
declare function revokeSessionImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, walletSignFn: (message: string | Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
15
|
+
sessionId: BigIntValue;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
export declare function revokeSession(serverUrl: string, walletSignFn: (message: string | Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
18
|
+
sessionId: BigIntValue;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
declare function withdrawImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
21
|
+
sizeDecimals: number;
|
|
22
|
+
sessionId: BigIntValue;
|
|
23
|
+
tokenId: number;
|
|
24
|
+
amount: Decimal.Value;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export declare function withdraw(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
27
|
+
sizeDecimals: number;
|
|
28
|
+
sessionId: BigIntValue;
|
|
29
|
+
tokenId: number;
|
|
30
|
+
amount: number;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
declare function placeOrderImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
33
|
+
sessionId: BigIntValue;
|
|
34
|
+
senderId?: number;
|
|
35
|
+
liquidateeId?: number;
|
|
36
|
+
sizeDecimals: number;
|
|
37
|
+
priceDecimals: number;
|
|
38
|
+
marketId: number;
|
|
39
|
+
side: Side;
|
|
40
|
+
fillMode: FillMode;
|
|
41
|
+
isReduceOnly: boolean;
|
|
42
|
+
size?: Decimal.Value;
|
|
43
|
+
price?: Decimal.Value;
|
|
44
|
+
quoteSize?: Decimal.Value;
|
|
45
|
+
clientOrderId?: BigIntValue;
|
|
46
|
+
}): Promise<bigint | undefined>;
|
|
47
|
+
export declare function placeOrder(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
48
|
+
sessionId: BigIntValue;
|
|
49
|
+
senderId?: number;
|
|
50
|
+
sizeDecimals: number;
|
|
51
|
+
priceDecimals: number;
|
|
52
|
+
marketId: number;
|
|
53
|
+
side: Side;
|
|
54
|
+
fillMode: FillMode;
|
|
55
|
+
isReduceOnly: boolean;
|
|
56
|
+
size?: Decimal.Value;
|
|
57
|
+
price?: Decimal.Value;
|
|
58
|
+
quoteSize?: Decimal.Value;
|
|
59
|
+
liquidateeId?: number;
|
|
60
|
+
clientOrderId?: BigIntValue;
|
|
61
|
+
}): Promise<bigint | undefined>;
|
|
62
|
+
declare function cancelOrderImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
63
|
+
sessionId: BigIntValue;
|
|
64
|
+
senderId?: number;
|
|
65
|
+
orderId: BigIntValue;
|
|
66
|
+
liquidateeId?: number;
|
|
67
|
+
}): Promise<bigint>;
|
|
68
|
+
export declare function cancelOrder(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
69
|
+
sessionId: BigIntValue;
|
|
70
|
+
senderId?: number;
|
|
71
|
+
orderId: BigIntValue;
|
|
72
|
+
liquidateeId?: number;
|
|
73
|
+
}): Promise<bigint>;
|
|
74
|
+
declare function transferImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
75
|
+
sessionId: BigIntValue;
|
|
76
|
+
fromAccountId: number;
|
|
77
|
+
toAccountId?: number;
|
|
78
|
+
tokenId: number;
|
|
79
|
+
tokenDecimals: number;
|
|
80
|
+
amount: Decimal.Value;
|
|
81
|
+
}): Promise<number | undefined>;
|
|
82
|
+
export declare function transfer(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
83
|
+
sessionId: BigIntValue;
|
|
84
|
+
fromAccountId: number;
|
|
85
|
+
toAccountId?: number;
|
|
86
|
+
tokenId: number;
|
|
87
|
+
tokenDecimals: number;
|
|
88
|
+
amount: Decimal.Value;
|
|
89
|
+
}): Promise<number | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* For testing purposes
|
|
92
|
+
*/
|
|
93
|
+
export declare const _private: {
|
|
94
|
+
createSessionImpl: typeof createSessionImpl;
|
|
95
|
+
revokeSessionImpl: typeof revokeSessionImpl;
|
|
96
|
+
withdrawImpl: typeof withdrawImpl;
|
|
97
|
+
placeOrderImpl: typeof placeOrderImpl;
|
|
98
|
+
cancelOrderImpl: typeof cancelOrderImpl;
|
|
99
|
+
transferImpl: typeof transferImpl;
|
|
100
|
+
};
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports._private = void 0;
|
|
37
|
+
exports.createSession = createSession;
|
|
38
|
+
exports.revokeSession = revokeSession;
|
|
39
|
+
exports.withdraw = withdraw;
|
|
40
|
+
exports.placeOrder = placeOrder;
|
|
41
|
+
exports.cancelOrder = cancelOrder;
|
|
42
|
+
exports.transfer = transfer;
|
|
43
|
+
const proto = __importStar(require("../../gen/nord"));
|
|
44
|
+
const types_1 = require("../../types");
|
|
45
|
+
const utils_1 = require("../../utils");
|
|
46
|
+
async function sessionSign(signFn, message) {
|
|
47
|
+
const signature = await signFn(message);
|
|
48
|
+
return new Uint8Array([...message, ...signature]);
|
|
49
|
+
}
|
|
50
|
+
async function walletSign(walletSignFn, message) {
|
|
51
|
+
const signature = await walletSignFn(message);
|
|
52
|
+
return new Uint8Array([...message, ...signature]);
|
|
53
|
+
}
|
|
54
|
+
function makeSendHttp(serverUrl) {
|
|
55
|
+
return async (body) => {
|
|
56
|
+
const response = await (0, utils_1.checkedFetch)(`${serverUrl}/action`, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
'Content-Type': 'application/json',
|
|
60
|
+
},
|
|
61
|
+
body,
|
|
62
|
+
});
|
|
63
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function sendAction(sendFn, makeSignedMessage, action, actionErrorDesc) {
|
|
67
|
+
const encoded = (0, utils_1.encodeLengthDelimited)(action, proto.Action);
|
|
68
|
+
const body = await makeSignedMessage(encoded);
|
|
69
|
+
const rawResp = await sendFn(body);
|
|
70
|
+
const resp = (0, utils_1.decodeLengthDelimited)(rawResp, proto.Receipt);
|
|
71
|
+
if (resp.kind?.$case === 'err') {
|
|
72
|
+
throw new Error(`Could not ${actionErrorDesc}, reason: ${proto.errorToJSON(resp.kind.value)}`);
|
|
73
|
+
}
|
|
74
|
+
return resp;
|
|
75
|
+
}
|
|
76
|
+
async function createSessionImpl(sendFn, walletSignFn, currentTimestamp, nonce, params) {
|
|
77
|
+
(0, utils_1.checkPubKeyLength)(types_1.KeyType.Ed25519, params.userPubkey.length);
|
|
78
|
+
(0, utils_1.checkPubKeyLength)(types_1.KeyType.Ed25519, params.sessionPubkey.length);
|
|
79
|
+
let expiry = 0n;
|
|
80
|
+
if (params.expiryTimestamp !== undefined) {
|
|
81
|
+
expiry = params.expiryTimestamp;
|
|
82
|
+
(0, utils_1.assert)(expiry > currentTimestamp, 'Cannot set expiry timestamp in the past');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
expiry = currentTimestamp + utils_1.SESSION_TTL;
|
|
86
|
+
}
|
|
87
|
+
const action = {
|
|
88
|
+
currentTimestamp,
|
|
89
|
+
nonce,
|
|
90
|
+
kind: {
|
|
91
|
+
$case: 'createSession',
|
|
92
|
+
value: {
|
|
93
|
+
userPubkey: params.userPubkey,
|
|
94
|
+
blstPubkey: params.sessionPubkey,
|
|
95
|
+
expiryTimestamp: expiry,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
const resp = await sendAction(sendFn, (m) => walletSign(walletSignFn, m), action, 'create a new session');
|
|
100
|
+
if (resp.kind?.$case === 'createSessionResult') {
|
|
101
|
+
return resp.kind.value.sessionId;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function createSession(serverUrl, walletSignFn, currentTimestamp, nonce, params) {
|
|
108
|
+
return createSessionImpl(makeSendHttp(serverUrl), walletSignFn, currentTimestamp, nonce, params);
|
|
109
|
+
}
|
|
110
|
+
async function revokeSessionImpl(sendFn, walletSignFn, currentTimestamp, nonce, params) {
|
|
111
|
+
const action = {
|
|
112
|
+
currentTimestamp,
|
|
113
|
+
nonce,
|
|
114
|
+
kind: {
|
|
115
|
+
$case: 'revokeSession',
|
|
116
|
+
value: {
|
|
117
|
+
sessionId: BigInt(params.sessionId),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
await sendAction(sendFn, (m) => walletSign(walletSignFn, m), action, 'create a new session');
|
|
122
|
+
}
|
|
123
|
+
async function revokeSession(serverUrl, walletSignFn, currentTimestamp, nonce, params) {
|
|
124
|
+
return revokeSessionImpl(makeSendHttp(serverUrl), walletSignFn, currentTimestamp, nonce, params);
|
|
125
|
+
}
|
|
126
|
+
async function withdrawImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
127
|
+
const amount = (0, utils_1.toScaledU64)(params.amount, params.sizeDecimals);
|
|
128
|
+
if (amount <= 0) {
|
|
129
|
+
throw new Error('Withdraw amount must be positive');
|
|
130
|
+
}
|
|
131
|
+
const action = {
|
|
132
|
+
currentTimestamp,
|
|
133
|
+
nonce,
|
|
134
|
+
kind: {
|
|
135
|
+
$case: 'withdraw',
|
|
136
|
+
value: {
|
|
137
|
+
sessionId: BigInt(params.sessionId),
|
|
138
|
+
tokenId: params.tokenId,
|
|
139
|
+
amount,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
await sendAction(sendFn, (m) => sessionSign(signFn, m), action, 'withdraw');
|
|
144
|
+
}
|
|
145
|
+
async function withdraw(serverUrl, signFn, currentTimestamp, nonce, params) {
|
|
146
|
+
return withdrawImpl(makeSendHttp(serverUrl), signFn, currentTimestamp, nonce, params);
|
|
147
|
+
}
|
|
148
|
+
async function placeOrderImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
149
|
+
const price = (0, utils_1.toScaledU64)(params.price ?? 0, params.priceDecimals);
|
|
150
|
+
const size = (0, utils_1.toScaledU64)(params.size ?? 0, params.sizeDecimals);
|
|
151
|
+
const quoteSize = (0, utils_1.toScaledU128)(params.quoteSize ?? 0, params.priceDecimals + params.sizeDecimals);
|
|
152
|
+
// Compose action object
|
|
153
|
+
const action = {
|
|
154
|
+
currentTimestamp,
|
|
155
|
+
nonce,
|
|
156
|
+
kind: {
|
|
157
|
+
$case: 'placeOrder',
|
|
158
|
+
value: {
|
|
159
|
+
sessionId: BigInt(params.sessionId),
|
|
160
|
+
senderAccountId: params.senderId,
|
|
161
|
+
marketId: params.marketId,
|
|
162
|
+
side: params.side === types_1.Side.Bid ? proto.Side.BID : proto.Side.ASK,
|
|
163
|
+
fillMode: (0, types_1.fillModeToProtoFillMode)(params.fillMode),
|
|
164
|
+
isReduceOnly: params.isReduceOnly,
|
|
165
|
+
price,
|
|
166
|
+
size,
|
|
167
|
+
quoteSize: (0, utils_1.bigIntToProtoU128)(quoteSize),
|
|
168
|
+
clientOrderId: (0, utils_1.optMap)(params.clientOrderId, (x) => BigInt(x)),
|
|
169
|
+
delegatorAccountId: params.liquidateeId,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action, 'place the order');
|
|
174
|
+
if (resp.kind?.$case === 'placeOrderResult') {
|
|
175
|
+
return resp.kind.value.posted?.orderId;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function placeOrder(serverUrl, signFn, currentTimestamp, nonce, params) {
|
|
182
|
+
return placeOrderImpl(makeSendHttp(serverUrl), signFn, currentTimestamp, nonce, params);
|
|
183
|
+
}
|
|
184
|
+
async function cancelOrderImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
185
|
+
const action = {
|
|
186
|
+
currentTimestamp,
|
|
187
|
+
nonce: nonce,
|
|
188
|
+
kind: {
|
|
189
|
+
$case: 'cancelOrderById',
|
|
190
|
+
value: {
|
|
191
|
+
orderId: BigInt(params.orderId),
|
|
192
|
+
sessionId: BigInt(params.sessionId),
|
|
193
|
+
senderAccountId: params.senderId,
|
|
194
|
+
delegatorAccountId: params.liquidateeId,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action, 'cancel the order');
|
|
199
|
+
if (resp.kind?.$case === 'cancelOrderResult') {
|
|
200
|
+
return resp.kind.value.orderId;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function cancelOrder(serverUrl, signFn, currentTimestamp, nonce, params) {
|
|
207
|
+
return cancelOrderImpl(makeSendHttp(serverUrl), signFn, currentTimestamp, nonce, params);
|
|
208
|
+
}
|
|
209
|
+
async function transferImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
210
|
+
const action = {
|
|
211
|
+
currentTimestamp,
|
|
212
|
+
nonce: nonce,
|
|
213
|
+
kind: {
|
|
214
|
+
$case: 'transfer',
|
|
215
|
+
value: {
|
|
216
|
+
sessionId: BigInt(params.sessionId),
|
|
217
|
+
fromAccountId: params.fromAccountId,
|
|
218
|
+
toAccountId: params.toAccountId,
|
|
219
|
+
tokenId: params.tokenId,
|
|
220
|
+
amount: (0, utils_1.toScaledU64)(params.amount ?? 0, params.tokenDecimals),
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action, 'transfer asset to other account');
|
|
225
|
+
if (resp.kind?.$case === 'transferred') {
|
|
226
|
+
if (resp.kind.value.accountCreated) {
|
|
227
|
+
return resp.kind.value.toUserAccount;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async function transfer(serverUrl, signFn, currentTimestamp, nonce, params) {
|
|
238
|
+
return transferImpl(makeSendHttp(serverUrl), signFn, currentTimestamp, nonce, params);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* For testing purposes
|
|
242
|
+
*/
|
|
243
|
+
exports._private = {
|
|
244
|
+
createSessionImpl,
|
|
245
|
+
revokeSessionImpl,
|
|
246
|
+
withdrawImpl,
|
|
247
|
+
placeOrderImpl,
|
|
248
|
+
cancelOrderImpl,
|
|
249
|
+
transferImpl,
|
|
250
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Account, Info } from '../../types';
|
|
2
|
+
import { NordWebSocketClient } from '../../websocket/index';
|
|
3
|
+
/**
|
|
4
|
+
* Get the current timestamp from the Nord server
|
|
5
|
+
*
|
|
6
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
7
|
+
* @returns Current timestamp as a bigint
|
|
8
|
+
* @throws {NordError} If the request fails
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTimestamp(webServerUrl: string): Promise<bigint>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the next action nonce from the Nord server
|
|
13
|
+
*
|
|
14
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
15
|
+
* @returns Next action nonce
|
|
16
|
+
* @throws {NordError} If the request fails
|
|
17
|
+
*/
|
|
18
|
+
export declare function getActionNonce(webServerUrl: string): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Get information about the Nord server
|
|
21
|
+
*
|
|
22
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
23
|
+
* @returns Information about markets and tokens
|
|
24
|
+
* @throws {NordError} If the request fails
|
|
25
|
+
*/
|
|
26
|
+
export declare function getInfo(webServerUrl: string): Promise<Info>;
|
|
27
|
+
/**
|
|
28
|
+
* Get account information
|
|
29
|
+
*
|
|
30
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
31
|
+
* @param accountId - Account ID to get information for
|
|
32
|
+
* @returns Account information
|
|
33
|
+
* @throws {NordError} If the request fails
|
|
34
|
+
*/
|
|
35
|
+
export declare function getAccount(webServerUrl: string, accountId: number): Promise<Account>;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize a WebSocket client for Nord
|
|
38
|
+
*
|
|
39
|
+
* Connects to one of the specific Nord WebSocket endpoints:
|
|
40
|
+
* - /ws/trades - For trade updates (default)
|
|
41
|
+
* - /ws/deltas - For orderbook delta updates
|
|
42
|
+
* - /ws/user - For user-specific updates
|
|
43
|
+
*
|
|
44
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
45
|
+
* @param endpoint - Specific WebSocket endpoint to connect to (trades, deltas, or user)
|
|
46
|
+
* @param initialSubscriptions - Optional array of initial subscriptions (e.g., ["trades@BTCUSDC"])
|
|
47
|
+
* @returns WebSocket client
|
|
48
|
+
*/
|
|
49
|
+
export declare function initWebSocketClient(webServerUrl: string, endpoint?: 'trades' | 'deltas' | 'user', initialSubscriptions?: string[]): NordWebSocketClient;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTimestamp = getTimestamp;
|
|
4
|
+
exports.getActionNonce = getActionNonce;
|
|
5
|
+
exports.getInfo = getInfo;
|
|
6
|
+
exports.getAccount = getAccount;
|
|
7
|
+
exports.initWebSocketClient = initWebSocketClient;
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const NordError_1 = require("../utils/NordError");
|
|
10
|
+
const index_1 = require("../../websocket/index");
|
|
11
|
+
/**
|
|
12
|
+
* Get the current timestamp from the Nord server
|
|
13
|
+
*
|
|
14
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
15
|
+
* @returns Current timestamp as a bigint
|
|
16
|
+
* @throws {NordError} If the request fails
|
|
17
|
+
*/
|
|
18
|
+
async function getTimestamp(webServerUrl) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/timestamp`);
|
|
21
|
+
return BigInt(await response.json());
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new NordError_1.NordError('Failed to get timestamp', { cause: error });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the next action nonce from the Nord server
|
|
29
|
+
*
|
|
30
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
31
|
+
* @returns Next action nonce
|
|
32
|
+
* @throws {NordError} If the request fails
|
|
33
|
+
*/
|
|
34
|
+
async function getActionNonce(webServerUrl) {
|
|
35
|
+
try {
|
|
36
|
+
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/action_nonce`);
|
|
37
|
+
const data = await response.json();
|
|
38
|
+
return data.nonce;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
throw new NordError_1.NordError('Failed to get action nonce', { cause: error });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get information about the Nord server
|
|
46
|
+
*
|
|
47
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
48
|
+
* @returns Information about markets and tokens
|
|
49
|
+
* @throws {NordError} If the request fails
|
|
50
|
+
*/
|
|
51
|
+
async function getInfo(webServerUrl) {
|
|
52
|
+
try {
|
|
53
|
+
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/info`);
|
|
54
|
+
return await response.json();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new NordError_1.NordError('Failed to get info', { cause: error });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get account information
|
|
62
|
+
*
|
|
63
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
64
|
+
* @param accountId - Account ID to get information for
|
|
65
|
+
* @returns Account information
|
|
66
|
+
* @throws {NordError} If the request fails
|
|
67
|
+
*/
|
|
68
|
+
async function getAccount(webServerUrl, accountId) {
|
|
69
|
+
try {
|
|
70
|
+
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/account?account_id=${accountId}`);
|
|
71
|
+
return await response.json();
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new NordError_1.NordError(`Failed to get account ${accountId}`, { cause: error });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Initialize a WebSocket client for Nord
|
|
79
|
+
*
|
|
80
|
+
* Connects to one of the specific Nord WebSocket endpoints:
|
|
81
|
+
* - /ws/trades - For trade updates (default)
|
|
82
|
+
* - /ws/deltas - For orderbook delta updates
|
|
83
|
+
* - /ws/user - For user-specific updates
|
|
84
|
+
*
|
|
85
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
86
|
+
* @param endpoint - Specific WebSocket endpoint to connect to (trades, deltas, or user)
|
|
87
|
+
* @param initialSubscriptions - Optional array of initial subscriptions (e.g., ["trades@BTCUSDC"])
|
|
88
|
+
* @returns WebSocket client
|
|
89
|
+
*/
|
|
90
|
+
function initWebSocketClient(webServerUrl, endpoint, initialSubscriptions) {
|
|
91
|
+
try {
|
|
92
|
+
// Convert HTTP URL to WebSocket URL with specific endpoint
|
|
93
|
+
// If no specific endpoint is provided, we'll connect to trades by default
|
|
94
|
+
const specificEndpoint = endpoint || 'trades';
|
|
95
|
+
const wsUrl = webServerUrl.replace(/^http/, 'ws') + `/ws/${specificEndpoint}`;
|
|
96
|
+
console.log(`Initializing WebSocket client with URL: ${wsUrl}`);
|
|
97
|
+
// Create and connect the WebSocket client
|
|
98
|
+
const ws = new index_1.NordWebSocketClient(wsUrl);
|
|
99
|
+
// Add error handler
|
|
100
|
+
ws.on('error', (error) => {
|
|
101
|
+
console.error('Nord WebSocket error:', error);
|
|
102
|
+
});
|
|
103
|
+
// Add connected handler for debugging
|
|
104
|
+
ws.on('connected', () => {
|
|
105
|
+
console.log('Nord WebSocket connected successfully');
|
|
106
|
+
// Subscribe to initial subscriptions if provided
|
|
107
|
+
if (initialSubscriptions && initialSubscriptions.length > 0) {
|
|
108
|
+
ws.subscribe(initialSubscriptions);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
// Connect the WebSocket
|
|
112
|
+
ws.connect();
|
|
113
|
+
return ws;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error('Failed to initialize WebSocket client:', error);
|
|
117
|
+
throw new NordError_1.NordError('Failed to initialize WebSocket client', {
|
|
118
|
+
cause: error,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./orderFunctions";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./orderFunctions"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MarketsStatsResponse, OrderbookQuery, OrderbookResponse, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get market statistics
|
|
4
|
+
*
|
|
5
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
6
|
+
* @returns Market statistics response
|
|
7
|
+
* @throws {NordError} If the request fails
|
|
8
|
+
*/
|
|
9
|
+
export declare function marketsStats(webServerUrl: string): Promise<MarketsStatsResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Get trades for a market
|
|
12
|
+
*
|
|
13
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
14
|
+
* @param query - Trades query parameters
|
|
15
|
+
* @returns Trades response
|
|
16
|
+
* @throws {NordError} If the request fails
|
|
17
|
+
*/
|
|
18
|
+
export declare function getTrades(webServerUrl: string, query: TradesQuery): Promise<TradesResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Get user account IDs
|
|
21
|
+
*
|
|
22
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
23
|
+
* @param query - User account IDs query parameters
|
|
24
|
+
* @returns User account IDs response
|
|
25
|
+
* @throws {NordError} If the request fails
|
|
26
|
+
*/
|
|
27
|
+
export declare function getUserAccountIds(webServerUrl: string, query: UserAccountIdsQuery): Promise<UserAccountIdsResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Get orderbook for a market
|
|
30
|
+
*
|
|
31
|
+
* @param webServerUrl - Base URL for the Nord web server
|
|
32
|
+
* @param query - Orderbook query parameters
|
|
33
|
+
* @returns Orderbook response
|
|
34
|
+
* @throws {NordError} If the request fails
|
|
35
|
+
*/
|
|
36
|
+
export declare function getOrderbook(webServerUrl: string, query: OrderbookQuery): Promise<OrderbookResponse>;
|