@n1xyz/nord-ts 0.0.4 → 0.0.5
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/bridge/client.d.ts +4 -4
- package/dist/bridge/client.js +4 -4
- package/dist/bridge/const.d.ts +2 -2
- package/dist/bridge/const.js +22 -22
- package/dist/bridge/index.d.ts +4 -4
- package/dist/bridge/types.d.ts +3 -3
- package/dist/bridge/utils.d.ts +4 -4
- package/dist/bridge/utils.js +10 -10
- package/dist/const.d.ts +1 -1
- package/dist/const.js +17 -17
- package/dist/gen/nord.d.ts +1 -4
- package/dist/idl/bridge.d.ts +1 -1
- package/dist/idl/bridge.js +185 -185
- package/dist/index.d.ts +8 -8
- package/dist/nord/api/actions.d.ts +3 -3
- package/dist/nord/api/actions.js +21 -21
- package/dist/nord/api/core.d.ts +3 -3
- package/dist/nord/api/core.js +12 -12
- package/dist/nord/api/market.d.ts +1 -1
- package/dist/nord/api/market.js +12 -12
- package/dist/nord/api/metrics.d.ts +1 -1
- package/dist/nord/api/metrics.js +6 -6
- package/dist/nord/api/queries.d.ts +1 -1
- package/dist/nord/api/queries.js +9 -9
- package/dist/nord/client/Nord.d.ts +4 -4
- package/dist/nord/client/Nord.js +18 -18
- package/dist/nord/client/NordUser.d.ts +7 -7
- package/dist/nord/client/NordUser.js +45 -49
- package/dist/nord/index.d.ts +9 -9
- package/dist/nord/models/Subscriber.d.ts +6 -6
- package/dist/nord/models/Subscriber.js +1 -5
- package/dist/nord/utils/NordError.js +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +8 -8
- package/dist/websocket/NordWebSocketClient.d.ts +2 -2
- package/dist/websocket/NordWebSocketClient.js +38 -38
- package/dist/websocket/events.d.ts +1 -1
- package/dist/websocket/index.d.ts +2 -2
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +16 -16
- package/docs/assets/icons.js +17 -14
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +5 -4
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1423 -1227
- package/docs/classes/Nord.html +190 -31
- package/docs/classes/NordError.html +24 -0
- package/docs/classes/NordUser.html +120 -35
- package/docs/classes/NordWebSocketClient.html +335 -0
- package/docs/classes/SolanaBridgeClient.html +86 -0
- package/docs/classes/Subscriber.html +10 -0
- package/docs/enums/FillMode.html +5 -5
- package/docs/enums/KeyType.html +4 -4
- package/docs/enums/MetricPeriod.html +9 -0
- package/docs/enums/PdaSeedType.html +9 -0
- package/docs/enums/PeakTpsPeriodUnit.html +7 -7
- package/docs/enums/Side.html +3 -3
- package/docs/enums/WebSocketMessageType.html +7 -0
- package/docs/functions/actionQueryRollman.html +6 -0
- package/docs/functions/actionsQueryRollman.html +6 -0
- package/docs/functions/aggregateMetrics-1.html +7 -0
- package/docs/functions/assert.html +1 -1
- package/docs/functions/bigIntToProtoU128.html +3 -3
- package/docs/functions/blockQueryRollman.html +6 -0
- package/docs/functions/blockSummaryQueryRollman.html +6 -0
- package/docs/functions/bridgeToBN.html +5 -0
- package/docs/functions/bufferToHex.html +4 -0
- package/docs/functions/cancelOrder.html +1 -0
- package/docs/functions/checkPubKeyLength.html +1 -1
- package/docs/functions/checkedFetch.html +4 -4
- package/docs/functions/createSession.html +1 -0
- package/docs/functions/decodeLengthDelimited.html +7 -6
- package/docs/functions/encodeLengthDelimited.html +4 -4
- package/docs/functions/fillModeToProtoFillMode.html +4 -4
- package/docs/functions/findMarket.html +1 -1
- package/docs/functions/findPda.html +6 -0
- package/docs/functions/findToken.html +1 -1
- package/docs/functions/fromBN.html +5 -0
- package/docs/functions/getAccount.html +6 -0
- package/docs/functions/getActionNonce.html +5 -0
- package/docs/functions/getCurrentTps.html +6 -0
- package/docs/functions/getInfo.html +5 -0
- package/docs/functions/getMedianLatency.html +6 -0
- package/docs/functions/getOrderbook.html +6 -0
- package/docs/functions/getPeakTps.html +6 -0
- package/docs/functions/getTimestamp.html +5 -0
- package/docs/functions/getTotalTransactions.html +5 -0
- package/docs/functions/getTrades.html +6 -0
- package/docs/functions/getUserAccountIds.html +6 -0
- package/docs/functions/hexToBuffer.html +4 -0
- package/docs/functions/initWebSocketClient.html +12 -0
- package/docs/functions/keypairFromPrivateKey.html +4 -0
- package/docs/functions/makeSigningFunction.html +4 -0
- package/docs/functions/makeWalletSignFn.html +5 -5
- package/docs/functions/marketsStats.html +5 -0
- package/docs/functions/optExpect.html +4 -4
- package/docs/functions/optMap.html +5 -5
- package/docs/functions/optUnwrap.html +2 -2
- package/docs/functions/panic.html +1 -1
- package/docs/functions/placeOrder.html +1 -0
- package/docs/functions/queryAction.html +6 -0
- package/docs/functions/queryBlock.html +6 -0
- package/docs/functions/queryLastNBlocks.html +5 -0
- package/docs/functions/queryPrometheus.html +6 -0
- package/docs/functions/queryRecentActions.html +6 -0
- package/docs/functions/queryRecentBlocks.html +6 -0
- package/docs/functions/revokeSession.html +1 -0
- package/docs/functions/shortenPublicKey.html +5 -0
- package/docs/functions/signAction.html +2 -2
- package/docs/functions/toBN.html +5 -0
- package/docs/functions/toScaledU128.html +5 -5
- package/docs/functions/toScaledU64.html +5 -5
- package/docs/functions/transfer.html +1 -0
- package/docs/functions/withdraw.html +1 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +39 -20
- package/docs/interfaces/Account.html +8 -8
- package/docs/interfaces/ActionInfo.html +8 -8
- package/docs/interfaces/ActionNonceResponse.html +3 -0
- package/docs/interfaces/ActionQuery.html +4 -4
- package/docs/interfaces/ActionResponse.html +8 -8
- package/docs/interfaces/ActionsExtendedInfo.html +10 -10
- package/docs/interfaces/ActionsQuery.html +5 -5
- package/docs/interfaces/ActionsResponse.html +6 -6
- package/docs/interfaces/AggregateMetrics.html +12 -12
- package/docs/interfaces/BlockFacts.html +10 -0
- package/docs/interfaces/BlockQuery.html +6 -6
- package/docs/interfaces/BlockResponse.html +6 -6
- package/docs/interfaces/BlockSummary.html +8 -8
- package/docs/interfaces/BlockSummaryResponse.html +6 -6
- package/docs/interfaces/DeltaEvent.html +6 -6
- package/docs/interfaces/DepositSplParams.html +10 -0
- package/docs/interfaces/Info.html +3 -3
- package/docs/interfaces/Market.html +8 -6
- package/docs/interfaces/MarketStats.html +7 -7
- package/docs/interfaces/MarketsStatsResponse.html +2 -2
- package/docs/interfaces/NordConfig.html +14 -5
- package/docs/interfaces/NordWebSocketClientEvents.html +4 -0
- package/docs/interfaces/NordWebSocketEvents.html +8 -0
- package/docs/interfaces/Order.html +6 -6
- package/docs/interfaces/OrderInfo.html +6 -6
- package/docs/interfaces/OrderbookEntry.html +4 -0
- package/docs/interfaces/OrderbookQuery.html +6 -0
- package/docs/interfaces/OrderbookResponse.html +6 -0
- package/docs/interfaces/OrderbookSubscription.html +159 -0
- package/docs/interfaces/PerpMarketStats.html +5 -5
- package/docs/interfaces/RollmanActionExtendedInfo.html +4 -4
- package/docs/interfaces/RollmanActionInfo.html +4 -4
- package/docs/interfaces/RollmanActionResponse.html +4 -4
- package/docs/interfaces/RollmanActionsResponse.html +2 -2
- package/docs/interfaces/RollmanBlockResponse.html +3 -3
- package/docs/interfaces/SPLTokenInfo.html +10 -0
- package/docs/interfaces/SolanaBridgeConfig.html +10 -0
- package/docs/interfaces/StateFacts.html +10 -0
- package/docs/interfaces/SubscriberConfig.html +3 -3
- package/docs/interfaces/TimestampResponse.html +3 -0
- package/docs/interfaces/Token.html +5 -5
- package/docs/interfaces/TokenInfo.html +5 -0
- package/docs/interfaces/Trade.html +5 -5
- package/docs/interfaces/TradeSubscription.html +159 -0
- package/docs/interfaces/Trades.html +5 -5
- package/docs/interfaces/TradesQuery.html +6 -0
- package/docs/interfaces/TradesResponse.html +7 -0
- package/docs/interfaces/TransferParams.html +8 -0
- package/docs/interfaces/UserAccountIdsQuery.html +3 -0
- package/docs/interfaces/UserAccountIdsResponse.html +3 -0
- package/docs/interfaces/WebSocketDeltaUpdate.html +9 -0
- package/docs/interfaces/WebSocketSubscription.html +4 -0
- package/docs/interfaces/WebSocketTradeUpdate.html +6 -0
- package/docs/interfaces/WebSocketUserUpdate.html +6 -0
- package/docs/interfaces/WithdrawalClaim.html +14 -0
- package/docs/interfaces/WithdrawalParams.html +8 -0
- package/docs/modules.html +1 -70
- package/docs/types/BigIntValue.html +2 -2
- package/docs/types/WebSocketMessage.html +1 -0
- package/docs/variables/DEBUG_KEYS.html +1 -1
- package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -1
- package/docs/variables/DEV_TOKEN_INFOS.html +1 -1
- package/docs/variables/DEV_URL.html +1 -1
- package/docs/variables/MAX_BUFFER_LEN.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/docs/variables/_private.html +2 -0
- package/eslint.config.mjs +66 -0
- package/package.json +12 -13
- package/src/bridge/client.ts +10 -10
- package/src/bridge/const.ts +24 -24
- package/src/bridge/index.ts +4 -4
- package/src/bridge/types.ts +10 -10
- package/src/bridge/utils.ts +14 -14
- package/src/const.ts +18 -18
- package/src/gen/nord.ts +1 -4
- package/src/idl/bridge.ts +186 -186
- package/src/index.ts +8 -8
- package/src/nord/api/actions.ts +25 -25
- package/src/nord/api/core.ts +16 -16
- package/src/nord/api/market.ts +15 -15
- package/src/nord/api/metrics.ts +16 -16
- package/src/nord/api/queries.ts +12 -12
- package/src/nord/client/Nord.ts +27 -27
- package/src/nord/client/NordUser.ts +59 -63
- package/src/nord/index.ts +9 -9
- package/src/nord/models/Subscriber.ts +11 -12
- package/src/nord/utils/NordError.ts +2 -2
- package/src/types.ts +12 -12
- package/src/utils.ts +20 -20
- package/src/websocket/NordWebSocketClient.ts +42 -42
- package/src/websocket/events.ts +1 -1
- package/src/websocket/index.ts +2 -2
- package/tests/utils.spec.ts +24 -24
- package/tsconfig.eslint.json +12 -0
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -31
- package/dist/abis/ERC20_ABI.d.ts +0 -39
- package/dist/abis/ERC20_ABI.js +0 -313
- package/dist/abis/NORD_GETTERS_FACET_ABI.d.ts +0 -34
- package/dist/abis/NORD_GETTERS_FACET_ABI.js +0 -195
- package/dist/abis/NORD_RAMP_FACET_ABI.d.ts +0 -35
- package/dist/abis/NORD_RAMP_FACET_ABI.js +0 -144
- package/dist/abis/index.d.ts +0 -3
- package/dist/abis/index.js +0 -9
- package/dist/bridge/NordUser.d.ts +0 -78
- package/dist/bridge/NordUser.js +0 -196
- package/dist/client.d.ts +0 -70
- package/dist/client.js +0 -129
- package/dist/constants/endpoints.d.ts +0 -65
- package/dist/constants/endpoints.js +0 -68
- package/dist/models/account.d.ts +0 -58
- package/dist/models/account.js +0 -6
- package/dist/models/index.d.ts +0 -8
- package/dist/models/index.js +0 -28
- package/dist/models/market.d.ts +0 -137
- package/dist/models/market.js +0 -6
- package/dist/models/order.d.ts +0 -211
- package/dist/models/order.js +0 -6
- package/dist/models/token.d.ts +0 -50
- package/dist/models/token.js +0 -6
- package/dist/nord/Nord.d.ts +0 -249
- package/dist/nord/Nord.js +0 -388
- package/dist/nord/NordError.d.ts +0 -23
- package/dist/nord/NordError.js +0 -48
- package/dist/nord/NordImpl.d.ts +0 -11
- package/dist/nord/NordImpl.js +0 -26
- package/dist/nord/NordUser.d.ts +0 -243
- package/dist/nord/NordUser.js +0 -481
- package/dist/nord/Subscriber.d.ts +0 -37
- package/dist/nord/Subscriber.js +0 -29
- package/dist/nord/actions.d.ts +0 -101
- package/dist/nord/actions.js +0 -254
- package/dist/nord/api/index.d.ts +0 -1
- package/dist/nord/api/index.js +0 -17
- package/dist/nord/api/orderFunctions.d.ts +0 -168
- package/dist/nord/api/orderFunctions.js +0 -133
- package/dist/nord/core.d.ts +0 -48
- package/dist/nord/core.js +0 -97
- package/dist/nord/market.d.ts +0 -36
- package/dist/nord/market.js +0 -90
- package/dist/nord/metrics.d.ts +0 -67
- package/dist/nord/metrics.js +0 -124
- package/dist/nord/queries.d.ts +0 -81
- package/dist/nord/queries.js +0 -181
- package/dist/nord/types.d.ts +0 -88
- package/dist/nord/types.js +0 -2
- package/dist/nord/websocket.d.ts +0 -49
- package/dist/nord/websocket.js +0 -107
- package/dist/operations/account.d.ts +0 -58
- package/dist/operations/account.js +0 -112
- package/dist/operations/market.d.ts +0 -65
- package/dist/operations/market.js +0 -131
- package/dist/operations/orders.d.ts +0 -57
- package/dist/operations/orders.js +0 -129
- package/dist/solana/NordUser.d.ts +0 -78
- package/dist/solana/NordUser.js +0 -196
- package/dist/solana/client.d.ts +0 -139
- package/dist/solana/client.js +0 -360
- package/dist/solana/const.d.ts +0 -23
- package/dist/solana/const.js +0 -47
- package/dist/solana/index.d.ts +0 -5
- package/dist/solana/index.js +0 -23
- package/dist/solana/types.d.ts +0 -118
- package/dist/solana/types.js +0 -16
- package/dist/solana/utils.d.ts +0 -64
- package/dist/solana/utils.js +0 -131
- package/dist/types/api.d.ts +0 -152
- package/dist/types/api.js +0 -6
- package/dist/types/config.d.ts +0 -34
- package/dist/types/config.js +0 -6
- package/dist/utils/errors.d.ts +0 -96
- package/dist/utils/errors.js +0 -132
- package/dist/utils/http.d.ts +0 -35
- package/dist/utils/http.js +0 -105
- package/dist/websocket/client.d.ts +0 -93
- package/dist/websocket/client.js +0 -222
- package/dist/websocket.d.ts +0 -55
- package/dist/websocket.js +0 -211
- package/docs/interfaces/ERC20TokenInfo.html +0 -5
- package/docs/variables/DEV_CONTRACT_ADDRESS.html +0 -1
- package/docs/variables/ERC20_ABI.html +0 -1
- package/docs/variables/EVM_DEV_URL.html +0 -1
- package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +0 -1
- package/docs/variables/NORD_GETTERS_FACET_ABI.html +0 -1
- package/docs/variables/NORD_RAMP_FACET_ABI.html +0 -1
package/dist/nord/types.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import Decimal from "decimal.js";
|
|
3
|
-
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { FillMode, Side } from "../types";
|
|
5
|
-
import { Nord } from "./Nord";
|
|
6
|
-
import { OrderbookResponse, Trade } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* Parameters for creating a NordUser instance
|
|
9
|
-
*/
|
|
10
|
-
export interface NordUserParams {
|
|
11
|
-
/** Nord client instance */
|
|
12
|
-
nord: Nord;
|
|
13
|
-
/** User's blockchain address */
|
|
14
|
-
address: string;
|
|
15
|
-
/** Function to sign messages with the user's wallet */
|
|
16
|
-
walletSignFn: (message: Uint8Array | string) => Promise<string>;
|
|
17
|
-
/** Function to sign messages with the user's session key */
|
|
18
|
-
sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
|
|
19
|
-
/** Solana public key (optional) */
|
|
20
|
-
solanaPublicKey?: PublicKey | string;
|
|
21
|
-
/** Solana keypair (optional) */
|
|
22
|
-
keypair?: Keypair;
|
|
23
|
-
/** Solana connection (optional) */
|
|
24
|
-
connection?: Connection;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Parameters for placing an order
|
|
28
|
-
*/
|
|
29
|
-
export interface PlaceOrderParams {
|
|
30
|
-
/** Market ID */
|
|
31
|
-
marketId: number;
|
|
32
|
-
/** Order side (bid or ask) */
|
|
33
|
-
side: Side;
|
|
34
|
-
/** Fill mode (limit, market, etc.) */
|
|
35
|
-
fillMode: FillMode;
|
|
36
|
-
/** Whether the order is reduce-only */
|
|
37
|
-
isReduceOnly: boolean;
|
|
38
|
-
/** Order size */
|
|
39
|
-
size?: Decimal.Value;
|
|
40
|
-
/** Order price */
|
|
41
|
-
price?: Decimal.Value;
|
|
42
|
-
/** Quote size (for market orders) */
|
|
43
|
-
quoteSize?: Decimal.Value;
|
|
44
|
-
/** Account ID to place the order from */
|
|
45
|
-
accountId?: number;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Parameters for transferring tokens between accounts
|
|
49
|
-
*/
|
|
50
|
-
export interface TransferParams {
|
|
51
|
-
/** Recipient user */
|
|
52
|
-
to: any;
|
|
53
|
-
/** Token ID to transfer */
|
|
54
|
-
tokenId: number;
|
|
55
|
-
/** Amount to transfer */
|
|
56
|
-
amount: Decimal.Value;
|
|
57
|
-
/** Source account ID */
|
|
58
|
-
fromAccountId: number;
|
|
59
|
-
/** Destination account ID */
|
|
60
|
-
toAccountId: number;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Parameters for creating a new account
|
|
64
|
-
*/
|
|
65
|
-
export interface CreateAccountParams {
|
|
66
|
-
/** Token ID for initial funding */
|
|
67
|
-
tokenId: number;
|
|
68
|
-
/** Initial funding amount */
|
|
69
|
-
amount: Decimal.Value;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Interface for orderbook subscription events
|
|
73
|
-
*/
|
|
74
|
-
export interface OrderbookSubscription extends EventEmitter {
|
|
75
|
-
on(event: 'message', listener: (data: OrderbookResponse) => void): this;
|
|
76
|
-
on(event: 'error', listener: (error: Error) => void): this;
|
|
77
|
-
close(): void;
|
|
78
|
-
removeAllListeners(event?: string): this;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Interface for trade subscription events
|
|
82
|
-
*/
|
|
83
|
-
export interface TradeSubscription extends EventEmitter {
|
|
84
|
-
on(event: 'message', listener: (data: Trade[]) => void): this;
|
|
85
|
-
on(event: 'error', listener: (error: Error) => void): this;
|
|
86
|
-
close(): void;
|
|
87
|
-
removeAllListeners(event?: string): this;
|
|
88
|
-
}
|
package/dist/nord/types.js
DELETED
package/dist/nord/websocket.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { DeltaEvent, Trades, Account } from "../types";
|
|
2
|
-
import { OrderbookSubscription, TradeSubscription } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for the Subscriber class
|
|
5
|
-
*/
|
|
6
|
-
export interface SubscriberConfig {
|
|
7
|
-
/** WebSocket stream URL */
|
|
8
|
-
streamURL: string;
|
|
9
|
-
/** Maximum buffer length */
|
|
10
|
-
maxBufferLen?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Subscriber class for handling WebSocket subscriptions
|
|
14
|
-
*/
|
|
15
|
-
export declare class Subscriber {
|
|
16
|
-
/** WebSocket stream URL */
|
|
17
|
-
streamURL: string;
|
|
18
|
-
/** Buffer for events */
|
|
19
|
-
buffer: (DeltaEvent | Trades | Account)[];
|
|
20
|
-
/** Maximum buffer length */
|
|
21
|
-
maxBufferLen: number;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new Subscriber instance
|
|
24
|
-
* @param config Subscriber configuration
|
|
25
|
-
*/
|
|
26
|
-
constructor(config: SubscriberConfig);
|
|
27
|
-
/**
|
|
28
|
-
* Subscribe to WebSocket events
|
|
29
|
-
*/
|
|
30
|
-
subscribe(): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create an orderbook subscription
|
|
34
|
-
*
|
|
35
|
-
* @param ws - WebSocket client
|
|
36
|
-
* @param symbol - Market symbol to subscribe to
|
|
37
|
-
* @returns EventEmitter that emits orderbook updates
|
|
38
|
-
*/
|
|
39
|
-
export declare function createOrderbookSubscription(ws: any, // Using 'any' to avoid circular dependency, will be NordWebSocketClient
|
|
40
|
-
symbol: string): OrderbookSubscription;
|
|
41
|
-
/**
|
|
42
|
-
* Create a trade subscription
|
|
43
|
-
*
|
|
44
|
-
* @param ws - WebSocket client
|
|
45
|
-
* @param symbol - Market symbol to subscribe to
|
|
46
|
-
* @returns EventEmitter that emits trade updates
|
|
47
|
-
*/
|
|
48
|
-
export declare function createTradeSubscription(ws: any, // Using 'any' to avoid circular dependency, will be NordWebSocketClient
|
|
49
|
-
symbol: string): TradeSubscription;
|
package/dist/nord/websocket.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
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
|
-
exports.createOrderbookSubscription = createOrderbookSubscription;
|
|
8
|
-
exports.createTradeSubscription = createTradeSubscription;
|
|
9
|
-
const events_1 = require("events");
|
|
10
|
-
const ws_1 = __importDefault(require("ws"));
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
/**
|
|
13
|
-
* Subscriber class for handling WebSocket subscriptions
|
|
14
|
-
*/
|
|
15
|
-
class Subscriber {
|
|
16
|
-
/**
|
|
17
|
-
* Create a new Subscriber instance
|
|
18
|
-
* @param config Subscriber configuration
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.streamURL = config.streamURL;
|
|
22
|
-
this.buffer = [];
|
|
23
|
-
this.maxBufferLen = config.maxBufferLen ?? utils_1.MAX_BUFFER_LEN;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Subscribe to WebSocket events
|
|
27
|
-
*/
|
|
28
|
-
subscribe() {
|
|
29
|
-
const ws = new ws_1.default(this.streamURL);
|
|
30
|
-
ws.on("open", () => { });
|
|
31
|
-
ws.on("message", (rawData) => {
|
|
32
|
-
const message = rawData.toLocaleString();
|
|
33
|
-
const event = JSON.parse(message);
|
|
34
|
-
this.buffer.push(event);
|
|
35
|
-
if (this.buffer.length > this.maxBufferLen) {
|
|
36
|
-
this.buffer.shift();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
ws.on("close", () => { });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.Subscriber = Subscriber;
|
|
43
|
-
/**
|
|
44
|
-
* Create an orderbook subscription
|
|
45
|
-
*
|
|
46
|
-
* @param ws - WebSocket client
|
|
47
|
-
* @param symbol - Market symbol to subscribe to
|
|
48
|
-
* @returns EventEmitter that emits orderbook updates
|
|
49
|
-
*/
|
|
50
|
-
function createOrderbookSubscription(ws, // Using 'any' to avoid circular dependency, will be NordWebSocketClient
|
|
51
|
-
symbol) {
|
|
52
|
-
if (!symbol) {
|
|
53
|
-
throw new Error("Market symbol is required for orderbook subscription");
|
|
54
|
-
}
|
|
55
|
-
const emitter = new events_1.EventEmitter();
|
|
56
|
-
// Add close method
|
|
57
|
-
emitter.close = () => {
|
|
58
|
-
ws.unsubscribe([`deltas@${symbol}`]);
|
|
59
|
-
emitter.removeAllListeners();
|
|
60
|
-
};
|
|
61
|
-
// Subscribe to the orderbook stream
|
|
62
|
-
ws.on('delta', (update) => {
|
|
63
|
-
if (update.market_symbol === symbol) {
|
|
64
|
-
const orderbookUpdate = {
|
|
65
|
-
symbol: update.market_symbol,
|
|
66
|
-
asks: update.asks,
|
|
67
|
-
bids: update.bids,
|
|
68
|
-
timestamp: update.timestamp
|
|
69
|
-
};
|
|
70
|
-
emitter.emit('message', orderbookUpdate);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
ws.on('error', (error) => {
|
|
74
|
-
emitter.emit('error', error);
|
|
75
|
-
});
|
|
76
|
-
// Start the subscription
|
|
77
|
-
ws.subscribe([`deltas@${symbol}`]);
|
|
78
|
-
return emitter;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Create a trade subscription
|
|
82
|
-
*
|
|
83
|
-
* @param ws - WebSocket client
|
|
84
|
-
* @param symbol - Market symbol to subscribe to
|
|
85
|
-
* @returns EventEmitter that emits trade updates
|
|
86
|
-
*/
|
|
87
|
-
function createTradeSubscription(ws, // Using 'any' to avoid circular dependency, will be NordWebSocketClient
|
|
88
|
-
symbol) {
|
|
89
|
-
const emitter = new events_1.EventEmitter();
|
|
90
|
-
// Add close method
|
|
91
|
-
emitter.close = () => {
|
|
92
|
-
ws.unsubscribe([`trades@${symbol}`]);
|
|
93
|
-
emitter.removeAllListeners();
|
|
94
|
-
};
|
|
95
|
-
// Subscribe to the trades stream
|
|
96
|
-
ws.on('trade', (update) => {
|
|
97
|
-
if (update.symbol === symbol) {
|
|
98
|
-
emitter.emit('message', update.trades);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
ws.on('error', (error) => {
|
|
102
|
-
emitter.emit('error', error);
|
|
103
|
-
});
|
|
104
|
-
// Start the subscription
|
|
105
|
-
ws.subscribe([`trades@${symbol}`]);
|
|
106
|
-
return emitter;
|
|
107
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Account-related operations
|
|
3
|
-
* @module operations/account
|
|
4
|
-
*/
|
|
5
|
-
import { NordClientConfig } from '../types/config';
|
|
6
|
-
import { Account, Balance } from '../models';
|
|
7
|
-
/**
|
|
8
|
-
* Account operations implementation
|
|
9
|
-
*/
|
|
10
|
-
export declare class AccountOperations {
|
|
11
|
-
/**
|
|
12
|
-
* Client configuration
|
|
13
|
-
*/
|
|
14
|
-
private readonly config;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new AccountOperations instance
|
|
17
|
-
*
|
|
18
|
-
* @param config - Client configuration
|
|
19
|
-
*/
|
|
20
|
-
constructor(config: NordClientConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Get account information
|
|
23
|
-
*
|
|
24
|
-
* @param accountId - Account ID
|
|
25
|
-
* @returns Promise resolving to account information
|
|
26
|
-
* @throws {NordValidationError} If the accountId parameter is invalid
|
|
27
|
-
* @throws {NordApiError} If the API request fails
|
|
28
|
-
*/
|
|
29
|
-
getAccount(accountId: number): Promise<Account>;
|
|
30
|
-
/**
|
|
31
|
-
* Get all accounts for a specific address
|
|
32
|
-
*
|
|
33
|
-
* @param address - User's blockchain address
|
|
34
|
-
* @returns Promise resolving to an array of account IDs
|
|
35
|
-
* @throws {NordValidationError} If the address parameter is invalid
|
|
36
|
-
* @throws {NordApiError} If the API request fails
|
|
37
|
-
*/
|
|
38
|
-
getAccounts(address: string): Promise<number[]>;
|
|
39
|
-
/**
|
|
40
|
-
* Get balance for a specific token in an account
|
|
41
|
-
*
|
|
42
|
-
* @param accountId - Account ID
|
|
43
|
-
* @param token - Token symbol (e.g., "BTC")
|
|
44
|
-
* @returns Promise resolving to balance information
|
|
45
|
-
* @throws {NordValidationError} If any parameters are invalid
|
|
46
|
-
* @throws {NordApiError} If the API request fails
|
|
47
|
-
*/
|
|
48
|
-
getBalance(accountId: number, token: string): Promise<Balance>;
|
|
49
|
-
/**
|
|
50
|
-
* Get all balances for an account
|
|
51
|
-
*
|
|
52
|
-
* @param accountId - Account ID
|
|
53
|
-
* @returns Promise resolving to an array of balances
|
|
54
|
-
* @throws {NordValidationError} If the accountId parameter is invalid
|
|
55
|
-
* @throws {NordApiError} If the API request fails
|
|
56
|
-
*/
|
|
57
|
-
getBalances(accountId: number): Promise<Balance[]>;
|
|
58
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Account-related operations
|
|
4
|
-
* @module operations/account
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.AccountOperations = void 0;
|
|
8
|
-
const errors_1 = require("../utils/errors");
|
|
9
|
-
const http_1 = require("../utils/http");
|
|
10
|
-
const endpoints_1 = require("../constants/endpoints");
|
|
11
|
-
/**
|
|
12
|
-
* Account operations implementation
|
|
13
|
-
*/
|
|
14
|
-
class AccountOperations {
|
|
15
|
-
/**
|
|
16
|
-
* Create a new AccountOperations instance
|
|
17
|
-
*
|
|
18
|
-
* @param config - Client configuration
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.config = config;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get account information
|
|
25
|
-
*
|
|
26
|
-
* @param accountId - Account ID
|
|
27
|
-
* @returns Promise resolving to account information
|
|
28
|
-
* @throws {NordValidationError} If the accountId parameter is invalid
|
|
29
|
-
* @throws {NordApiError} If the API request fails
|
|
30
|
-
*/
|
|
31
|
-
async getAccount(accountId) {
|
|
32
|
-
if (accountId === undefined || accountId === null) {
|
|
33
|
-
throw new errors_1.NordValidationError('Account ID is required', 'accountId');
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const endpoint = `${endpoints_1.ENDPOINTS.ACCOUNT}/${accountId}`;
|
|
37
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
38
|
-
return response;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
throw new errors_1.NordApiError(`Failed to fetch account ${accountId}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.ACCOUNT, error instanceof Error ? error : undefined);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Get all accounts for a specific address
|
|
46
|
-
*
|
|
47
|
-
* @param address - User's blockchain address
|
|
48
|
-
* @returns Promise resolving to an array of account IDs
|
|
49
|
-
* @throws {NordValidationError} If the address parameter is invalid
|
|
50
|
-
* @throws {NordApiError} If the API request fails
|
|
51
|
-
*/
|
|
52
|
-
async getAccounts(address) {
|
|
53
|
-
if (!address) {
|
|
54
|
-
throw new errors_1.NordValidationError('Address is required', 'address');
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const endpoint = `${endpoints_1.ENDPOINTS.ACCOUNTS}?address=${encodeURIComponent(address)}`;
|
|
58
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
59
|
-
return response.accountIds;
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
throw new errors_1.NordApiError(`Failed to fetch accounts for address ${address}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.ACCOUNTS, error instanceof Error ? error : undefined);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get balance for a specific token in an account
|
|
67
|
-
*
|
|
68
|
-
* @param accountId - Account ID
|
|
69
|
-
* @param token - Token symbol (e.g., "BTC")
|
|
70
|
-
* @returns Promise resolving to balance information
|
|
71
|
-
* @throws {NordValidationError} If any parameters are invalid
|
|
72
|
-
* @throws {NordApiError} If the API request fails
|
|
73
|
-
*/
|
|
74
|
-
async getBalance(accountId, token) {
|
|
75
|
-
if (accountId === undefined || accountId === null) {
|
|
76
|
-
throw new errors_1.NordValidationError('Account ID is required', 'accountId');
|
|
77
|
-
}
|
|
78
|
-
if (!token) {
|
|
79
|
-
throw new errors_1.NordValidationError('Token symbol is required', 'token');
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
const endpoint = `${endpoints_1.ENDPOINTS.BALANCE}?accountId=${accountId}&token=${encodeURIComponent(token)}`;
|
|
83
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
84
|
-
return response;
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
throw new errors_1.NordApiError(`Failed to fetch balance for account ${accountId} and token ${token}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.BALANCE, error instanceof Error ? error : undefined);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get all balances for an account
|
|
92
|
-
*
|
|
93
|
-
* @param accountId - Account ID
|
|
94
|
-
* @returns Promise resolving to an array of balances
|
|
95
|
-
* @throws {NordValidationError} If the accountId parameter is invalid
|
|
96
|
-
* @throws {NordApiError} If the API request fails
|
|
97
|
-
*/
|
|
98
|
-
async getBalances(accountId) {
|
|
99
|
-
if (accountId === undefined || accountId === null) {
|
|
100
|
-
throw new errors_1.NordValidationError('Account ID is required', 'accountId');
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
const endpoint = `${endpoints_1.ENDPOINTS.BALANCES}?accountId=${accountId}`;
|
|
104
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
105
|
-
return response;
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
throw new errors_1.NordApiError(`Failed to fetch balances for account ${accountId}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.BALANCES, error instanceof Error ? error : undefined);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.AccountOperations = AccountOperations;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Market-related operations
|
|
3
|
-
* @module operations/market
|
|
4
|
-
*/
|
|
5
|
-
import { NordClientConfig } from '../types/config';
|
|
6
|
-
import { Market, OrderbookData, Trade, Candle } from '../models';
|
|
7
|
-
/**
|
|
8
|
-
* Market operations implementation
|
|
9
|
-
*/
|
|
10
|
-
export declare class MarketOperations {
|
|
11
|
-
/**
|
|
12
|
-
* Client configuration
|
|
13
|
-
*/
|
|
14
|
-
private readonly config;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new MarketOperations instance
|
|
17
|
-
*
|
|
18
|
-
* @param config - Client configuration
|
|
19
|
-
*/
|
|
20
|
-
constructor(config: NordClientConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Get all available markets
|
|
23
|
-
*
|
|
24
|
-
* @returns Promise resolving to an array of markets
|
|
25
|
-
* @throws {NordApiError} If the API request fails
|
|
26
|
-
*/
|
|
27
|
-
getMarkets(): Promise<Market[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Get orderbook data for a specific market
|
|
30
|
-
*
|
|
31
|
-
* @param market - Market symbol (e.g., "BTCUSDC")
|
|
32
|
-
* @returns Promise resolving to orderbook data
|
|
33
|
-
* @throws {NordValidationError} If the market parameter is invalid
|
|
34
|
-
* @throws {NordApiError} If the API request fails
|
|
35
|
-
*/
|
|
36
|
-
getOrderbook(market: string): Promise<OrderbookData>;
|
|
37
|
-
/**
|
|
38
|
-
* Get recent trades for a specific market
|
|
39
|
-
*
|
|
40
|
-
* @param market - Market symbol (e.g., "BTCUSDC")
|
|
41
|
-
* @param limit - Maximum number of trades to return (optional)
|
|
42
|
-
* @returns Promise resolving to an array of trades
|
|
43
|
-
* @throws {NordValidationError} If the market parameter is invalid
|
|
44
|
-
* @throws {NordApiError} If the API request fails
|
|
45
|
-
*/
|
|
46
|
-
getTrades(market: string, limit?: number): Promise<Trade[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Get candle data for a specific market and timeframe
|
|
49
|
-
*
|
|
50
|
-
* @param market - Market symbol (e.g., "BTCUSDC")
|
|
51
|
-
* @param timeframe - Candle timeframe (e.g., "1m", "5m", "1h", "1d")
|
|
52
|
-
* @param limit - Maximum number of candles to return (optional)
|
|
53
|
-
* @returns Promise resolving to an array of candles
|
|
54
|
-
* @throws {NordValidationError} If any parameters are invalid
|
|
55
|
-
* @throws {NordApiError} If the API request fails
|
|
56
|
-
*/
|
|
57
|
-
getCandles(market: string, timeframe: string, limit?: number): Promise<Candle[]>;
|
|
58
|
-
/**
|
|
59
|
-
* Get current server timestamp
|
|
60
|
-
*
|
|
61
|
-
* @returns Promise resolving to the current server timestamp in milliseconds
|
|
62
|
-
* @throws {NordApiError} If the API request fails
|
|
63
|
-
*/
|
|
64
|
-
getTimestamp(): Promise<number>;
|
|
65
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Market-related operations
|
|
4
|
-
* @module operations/market
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.MarketOperations = void 0;
|
|
8
|
-
const errors_1 = require("../utils/errors");
|
|
9
|
-
const http_1 = require("../utils/http");
|
|
10
|
-
const endpoints_1 = require("../constants/endpoints");
|
|
11
|
-
/**
|
|
12
|
-
* Market operations implementation
|
|
13
|
-
*/
|
|
14
|
-
class MarketOperations {
|
|
15
|
-
/**
|
|
16
|
-
* Create a new MarketOperations instance
|
|
17
|
-
*
|
|
18
|
-
* @param config - Client configuration
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.config = config;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get all available markets
|
|
25
|
-
*
|
|
26
|
-
* @returns Promise resolving to an array of markets
|
|
27
|
-
* @throws {NordApiError} If the API request fails
|
|
28
|
-
*/
|
|
29
|
-
async getMarkets() {
|
|
30
|
-
try {
|
|
31
|
-
const endpoint = `${endpoints_1.ENDPOINTS.MARKETS}`;
|
|
32
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
33
|
-
return response;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
throw new errors_1.NordApiError('Failed to fetch markets', error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.MARKETS, error instanceof Error ? error : undefined);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get orderbook data for a specific market
|
|
41
|
-
*
|
|
42
|
-
* @param market - Market symbol (e.g., "BTCUSDC")
|
|
43
|
-
* @returns Promise resolving to orderbook data
|
|
44
|
-
* @throws {NordValidationError} If the market parameter is invalid
|
|
45
|
-
* @throws {NordApiError} If the API request fails
|
|
46
|
-
*/
|
|
47
|
-
async getOrderbook(market) {
|
|
48
|
-
if (!market) {
|
|
49
|
-
throw new errors_1.NordValidationError('Market symbol is required', 'market');
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
const endpoint = `${endpoints_1.ENDPOINTS.ORDERBOOK}?market=${encodeURIComponent(market)}`;
|
|
53
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
54
|
-
return response;
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
throw new errors_1.NordApiError(`Failed to fetch orderbook for market ${market}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.ORDERBOOK, error instanceof Error ? error : undefined);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get recent trades for a specific market
|
|
62
|
-
*
|
|
63
|
-
* @param market - Market symbol (e.g., "BTCUSDC")
|
|
64
|
-
* @param limit - Maximum number of trades to return (optional)
|
|
65
|
-
* @returns Promise resolving to an array of trades
|
|
66
|
-
* @throws {NordValidationError} If the market parameter is invalid
|
|
67
|
-
* @throws {NordApiError} If the API request fails
|
|
68
|
-
*/
|
|
69
|
-
async getTrades(market, limit) {
|
|
70
|
-
if (!market) {
|
|
71
|
-
throw new errors_1.NordValidationError('Market symbol is required', 'market');
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
let endpoint = `${endpoints_1.ENDPOINTS.TRADES}?market=${encodeURIComponent(market)}`;
|
|
75
|
-
if (limit) {
|
|
76
|
-
endpoint += `&limit=${limit}`;
|
|
77
|
-
}
|
|
78
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
79
|
-
return response;
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
throw new errors_1.NordApiError(`Failed to fetch trades for market ${market}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.TRADES, error instanceof Error ? error : undefined);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get candle data for a specific market and timeframe
|
|
87
|
-
*
|
|
88
|
-
* @param market - Market symbol (e.g., "BTCUSDC")
|
|
89
|
-
* @param timeframe - Candle timeframe (e.g., "1m", "5m", "1h", "1d")
|
|
90
|
-
* @param limit - Maximum number of candles to return (optional)
|
|
91
|
-
* @returns Promise resolving to an array of candles
|
|
92
|
-
* @throws {NordValidationError} If any parameters are invalid
|
|
93
|
-
* @throws {NordApiError} If the API request fails
|
|
94
|
-
*/
|
|
95
|
-
async getCandles(market, timeframe, limit) {
|
|
96
|
-
if (!market) {
|
|
97
|
-
throw new errors_1.NordValidationError('Market symbol is required', 'market');
|
|
98
|
-
}
|
|
99
|
-
if (!timeframe) {
|
|
100
|
-
throw new errors_1.NordValidationError('Timeframe is required', 'timeframe');
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
let endpoint = `${endpoints_1.ENDPOINTS.CANDLES}?market=${encodeURIComponent(market)}&timeframe=${encodeURIComponent(timeframe)}`;
|
|
104
|
-
if (limit) {
|
|
105
|
-
endpoint += `&limit=${limit}`;
|
|
106
|
-
}
|
|
107
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
108
|
-
return response;
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
throw new errors_1.NordApiError(`Failed to fetch candles for market ${market} with timeframe ${timeframe}`, error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.CANDLES, error instanceof Error ? error : undefined);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get current server timestamp
|
|
116
|
-
*
|
|
117
|
-
* @returns Promise resolving to the current server timestamp in milliseconds
|
|
118
|
-
* @throws {NordApiError} If the API request fails
|
|
119
|
-
*/
|
|
120
|
-
async getTimestamp() {
|
|
121
|
-
try {
|
|
122
|
-
const endpoint = endpoints_1.ENDPOINTS.TIMESTAMP;
|
|
123
|
-
const response = await (0, http_1.httpGet)(this.config.webServerUrl, endpoint);
|
|
124
|
-
return response.timestamp;
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new errors_1.NordApiError('Failed to fetch server timestamp', error instanceof errors_1.NordApiError ? error.statusCode : 500, endpoints_1.ENDPOINTS.TIMESTAMP, error instanceof Error ? error : undefined);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.MarketOperations = MarketOperations;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Order-related operations
|
|
3
|
-
* @module operations/orders
|
|
4
|
-
*/
|
|
5
|
-
import { NordClientConfig } from '../types/config';
|
|
6
|
-
import { Order, OrderResult, PlaceOrderParams } from '../models';
|
|
7
|
-
/**
|
|
8
|
-
* Order operations implementation
|
|
9
|
-
*/
|
|
10
|
-
export declare class OrderOperations {
|
|
11
|
-
/**
|
|
12
|
-
* Client configuration
|
|
13
|
-
*/
|
|
14
|
-
private readonly config;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new OrderOperations instance
|
|
17
|
-
*
|
|
18
|
-
* @param config - Client configuration
|
|
19
|
-
*/
|
|
20
|
-
constructor(config: NordClientConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Place a new order
|
|
23
|
-
*
|
|
24
|
-
* @param params - Order parameters
|
|
25
|
-
* @returns Promise resolving to order result
|
|
26
|
-
* @throws {NordValidationError} If any parameters are invalid
|
|
27
|
-
* @throws {NordApiError} If the API request fails
|
|
28
|
-
*/
|
|
29
|
-
placeOrder(params: PlaceOrderParams): Promise<OrderResult>;
|
|
30
|
-
/**
|
|
31
|
-
* Cancel an existing order
|
|
32
|
-
*
|
|
33
|
-
* @param orderId - Order ID to cancel
|
|
34
|
-
* @returns Promise resolving to true if successful
|
|
35
|
-
* @throws {NordValidationError} If the orderId parameter is invalid
|
|
36
|
-
* @throws {NordApiError} If the API request fails
|
|
37
|
-
*/
|
|
38
|
-
cancelOrder(orderId: number): Promise<boolean>;
|
|
39
|
-
/**
|
|
40
|
-
* Get information about a specific order
|
|
41
|
-
*
|
|
42
|
-
* @param orderId - Order ID
|
|
43
|
-
* @returns Promise resolving to order information
|
|
44
|
-
* @throws {NordValidationError} If the orderId parameter is invalid
|
|
45
|
-
* @throws {NordApiError} If the API request fails
|
|
46
|
-
*/
|
|
47
|
-
getOrder(orderId: number): Promise<Order>;
|
|
48
|
-
/**
|
|
49
|
-
* Get all orders for an account
|
|
50
|
-
*
|
|
51
|
-
* @param accountId - Account ID
|
|
52
|
-
* @returns Promise resolving to an array of orders
|
|
53
|
-
* @throws {NordValidationError} If the accountId parameter is invalid
|
|
54
|
-
* @throws {NordApiError} If the API request fails
|
|
55
|
-
*/
|
|
56
|
-
getOrders(accountId: number): Promise<Order[]>;
|
|
57
|
-
}
|