@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
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NORD_RAMP_FACET_ABI = void 0;
|
|
4
|
-
exports.NORD_RAMP_FACET_ABI = [
|
|
5
|
-
{
|
|
6
|
-
type: "function",
|
|
7
|
-
name: "depositUnchecked",
|
|
8
|
-
inputs: [
|
|
9
|
-
{ name: "recipient", type: "bytes", internalType: "bytes" },
|
|
10
|
-
{
|
|
11
|
-
name: "assetId",
|
|
12
|
-
type: "uint256",
|
|
13
|
-
internalType: "uint256",
|
|
14
|
-
},
|
|
15
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
16
|
-
],
|
|
17
|
-
outputs: [],
|
|
18
|
-
stateMutability: "payable",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
type: "function",
|
|
22
|
-
name: "withdraw",
|
|
23
|
-
inputs: [
|
|
24
|
-
{ name: "receiver", type: "address", internalType: "address" },
|
|
25
|
-
{
|
|
26
|
-
name: "assetId",
|
|
27
|
-
type: "uint256",
|
|
28
|
-
internalType: "uint256",
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
outputs: [],
|
|
32
|
-
stateMutability: "nonpayable",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: "event",
|
|
36
|
-
name: "RampDeposit",
|
|
37
|
-
inputs: [
|
|
38
|
-
{
|
|
39
|
-
name: "caller",
|
|
40
|
-
type: "address",
|
|
41
|
-
indexed: true,
|
|
42
|
-
internalType: "address",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "receiverPublicKey",
|
|
46
|
-
type: "bytes",
|
|
47
|
-
indexed: false,
|
|
48
|
-
internalType: "bytes",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "assetId",
|
|
52
|
-
type: "uint256",
|
|
53
|
-
indexed: true,
|
|
54
|
-
internalType: "uint256",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "quantizedAmount",
|
|
58
|
-
type: "uint256",
|
|
59
|
-
indexed: false,
|
|
60
|
-
internalType: "uint256",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "actionNonce",
|
|
64
|
-
type: "uint256",
|
|
65
|
-
indexed: false,
|
|
66
|
-
internalType: "uint256",
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
anonymous: false,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
type: "event",
|
|
73
|
-
name: "RampWithdrawal",
|
|
74
|
-
inputs: [
|
|
75
|
-
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
76
|
-
{
|
|
77
|
-
name: "assetId",
|
|
78
|
-
type: "uint256",
|
|
79
|
-
indexed: true,
|
|
80
|
-
internalType: "uint256",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: "quantizedAmount",
|
|
84
|
-
type: "uint256",
|
|
85
|
-
indexed: false,
|
|
86
|
-
internalType: "uint256",
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
anonymous: false,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
type: "error",
|
|
93
|
-
name: "AddressEmptyCode",
|
|
94
|
-
inputs: [{ name: "target", type: "address", internalType: "address" }],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: "error",
|
|
98
|
-
name: "AddressInsufficientBalance",
|
|
99
|
-
inputs: [{ name: "account", type: "address", internalType: "address" }],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
type: "error",
|
|
103
|
-
name: "AssetNotAdded",
|
|
104
|
-
inputs: [{ name: "assetId", type: "uint256", internalType: "uint256" }],
|
|
105
|
-
},
|
|
106
|
-
{ type: "error", name: "FailedInnerCall", inputs: [] },
|
|
107
|
-
{
|
|
108
|
-
type: "error",
|
|
109
|
-
name: "IncorrectAmountTransferred",
|
|
110
|
-
inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: "error",
|
|
114
|
-
name: "InvalidAmount",
|
|
115
|
-
inputs: [
|
|
116
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
117
|
-
{
|
|
118
|
-
name: "quantum",
|
|
119
|
-
type: "uint256",
|
|
120
|
-
internalType: "uint256",
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
type: "error",
|
|
126
|
-
name: "InvalidPublicKeyLength",
|
|
127
|
-
inputs: [{ name: "publicKey", type: "bytes", internalType: "bytes" }],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
type: "error",
|
|
131
|
-
name: "InvalidRecipient",
|
|
132
|
-
inputs: [{ name: "recipient", type: "address", internalType: "address" }],
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
type: "error",
|
|
136
|
-
name: "QuantizedAmountTooLarge",
|
|
137
|
-
inputs: [{ name: "amount", type: "uint256", internalType: "uint256" }],
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
type: "error",
|
|
141
|
-
name: "SafeERC20FailedOperation",
|
|
142
|
-
inputs: [{ name: "token", type: "address", internalType: "address" }],
|
|
143
|
-
},
|
|
144
|
-
];
|
package/dist/abis/index.d.ts
DELETED
package/dist/abis/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NORD_GETTERS_FACET_ABI = exports.NORD_RAMP_FACET_ABI = exports.ERC20_ABI = void 0;
|
|
4
|
-
var ERC20_ABI_1 = require("./ERC20_ABI");
|
|
5
|
-
Object.defineProperty(exports, "ERC20_ABI", { enumerable: true, get: function () { return ERC20_ABI_1.ERC20_ABI; } });
|
|
6
|
-
var NORD_RAMP_FACET_ABI_1 = require("./NORD_RAMP_FACET_ABI");
|
|
7
|
-
Object.defineProperty(exports, "NORD_RAMP_FACET_ABI", { enumerable: true, get: function () { return NORD_RAMP_FACET_ABI_1.NORD_RAMP_FACET_ABI; } });
|
|
8
|
-
var NORD_GETTERS_FACET_ABI_1 = require("./NORD_GETTERS_FACET_ABI");
|
|
9
|
-
Object.defineProperty(exports, "NORD_GETTERS_FACET_ABI", { enumerable: true, get: function () { return NORD_GETTERS_FACET_ABI_1.NORD_GETTERS_FACET_ABI; } });
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
2
|
-
import { Nord } from '../nord/Nord';
|
|
3
|
-
import { Order } from '../types';
|
|
4
|
-
import { SolanaBridgeClient } from './client';
|
|
5
|
-
import { SPLTokenInfo } from './types';
|
|
6
|
-
export declare class NordUser {
|
|
7
|
-
nord: Nord;
|
|
8
|
-
publicKey: PublicKey;
|
|
9
|
-
walletSignFn: (message: Uint8Array | string) => Promise<Uint8Array>;
|
|
10
|
-
sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
|
|
11
|
-
balances: {
|
|
12
|
-
[key: string]: {
|
|
13
|
-
accountId: number;
|
|
14
|
-
balance: number;
|
|
15
|
-
symbol: string;
|
|
16
|
-
}[];
|
|
17
|
-
};
|
|
18
|
-
orders: {
|
|
19
|
-
[key: string]: Order[];
|
|
20
|
-
};
|
|
21
|
-
accountIds?: number[];
|
|
22
|
-
sessionId?: bigint;
|
|
23
|
-
keypair?: Keypair;
|
|
24
|
-
bridgeClient?: SolanaBridgeClient;
|
|
25
|
-
connection?: Connection;
|
|
26
|
-
splTokenInfos: SPLTokenInfo[];
|
|
27
|
-
lastTs: number;
|
|
28
|
-
lastNonce: number;
|
|
29
|
-
constructor(params: {
|
|
30
|
-
nord: Nord;
|
|
31
|
-
publicKey: PublicKey | string;
|
|
32
|
-
walletSignFn: (message: Uint8Array | string) => Promise<Uint8Array>;
|
|
33
|
-
sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
|
|
34
|
-
keypair?: Keypair;
|
|
35
|
-
connection?: Connection;
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Initialize the Solana bridge client
|
|
39
|
-
*/
|
|
40
|
-
private initBridgeClient;
|
|
41
|
-
/**
|
|
42
|
-
* Create a NordUser from a private key
|
|
43
|
-
*
|
|
44
|
-
* @param nord Nord instance
|
|
45
|
-
* @param privateKey Private key as string or Uint8Array
|
|
46
|
-
* @param connection Solana connection
|
|
47
|
-
* @returns NordUser instance
|
|
48
|
-
*/
|
|
49
|
-
static fromPrivateKey(nord: Nord, privateKey: string | Uint8Array, connection?: Connection): NordUser;
|
|
50
|
-
/**
|
|
51
|
-
* Get the associated token account for a token mint
|
|
52
|
-
*
|
|
53
|
-
* @param mint Token mint address
|
|
54
|
-
* @returns Associated token account address
|
|
55
|
-
*/
|
|
56
|
-
getAssociatedTokenAccount(mint: PublicKey): Promise<PublicKey>;
|
|
57
|
-
/**
|
|
58
|
-
* Deposit SPL tokens to the bridge
|
|
59
|
-
*
|
|
60
|
-
* @param amount Amount to deposit
|
|
61
|
-
* @param tokenId Token ID
|
|
62
|
-
* @returns Transaction signature
|
|
63
|
-
*/
|
|
64
|
-
depositSpl(amount: number, tokenId: number): Promise<string>;
|
|
65
|
-
/**
|
|
66
|
-
* Withdraw tokens from the bridge
|
|
67
|
-
*
|
|
68
|
-
* @param claim Withdrawal claim
|
|
69
|
-
* @returns Transaction signature
|
|
70
|
-
*/
|
|
71
|
-
withdrawSpl(claim: any): Promise<string>;
|
|
72
|
-
/**
|
|
73
|
-
* Fund the user's SPL token accounts for testing
|
|
74
|
-
*
|
|
75
|
-
* @param faucetKeypair Keypair with funds to distribute
|
|
76
|
-
*/
|
|
77
|
-
fundSplWallet(faucetKeypair: Keypair): Promise<void>;
|
|
78
|
-
}
|
package/dist/bridge/NordUser.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NordUser = void 0;
|
|
4
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
5
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
const client_1 = require("./client");
|
|
7
|
-
const const_1 = require("./const");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
class NordUser {
|
|
10
|
-
constructor(params) {
|
|
11
|
-
this.balances = {};
|
|
12
|
-
this.orders = {};
|
|
13
|
-
// Convert TokenInfo to SPLTokenInfo
|
|
14
|
-
this.splTokenInfos = [];
|
|
15
|
-
this.lastTs = 0;
|
|
16
|
-
this.lastNonce = 0;
|
|
17
|
-
this.nord = params.nord;
|
|
18
|
-
this.publicKey = typeof params.publicKey === 'string'
|
|
19
|
-
? new web3_js_1.PublicKey(params.publicKey)
|
|
20
|
-
: params.publicKey;
|
|
21
|
-
this.walletSignFn = params.walletSignFn;
|
|
22
|
-
this.sessionSignFn = params.sessionSignFn;
|
|
23
|
-
this.keypair = params.keypair;
|
|
24
|
-
this.connection = params.connection;
|
|
25
|
-
// Convert TokenInfo to SPLTokenInfo
|
|
26
|
-
this.splTokenInfos = this.nord.tokenInfos.map(tokenInfo => ({
|
|
27
|
-
mint: tokenInfo.address, // Use address as mint
|
|
28
|
-
precision: tokenInfo.precision,
|
|
29
|
-
tokenId: tokenInfo.tokenId,
|
|
30
|
-
name: tokenInfo.name
|
|
31
|
-
}));
|
|
32
|
-
// Initialize bridge client if keypair and connection are provided
|
|
33
|
-
if (this.keypair && this.connection && this.nord.solanaProgramId) {
|
|
34
|
-
this.initBridgeClient();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Initialize the Solana bridge client
|
|
39
|
-
*/
|
|
40
|
-
initBridgeClient() {
|
|
41
|
-
if (!this.keypair || !this.connection || !this.nord.solanaProgramId) {
|
|
42
|
-
throw new Error('Keypair, connection, and program ID are required to initialize bridge client');
|
|
43
|
-
}
|
|
44
|
-
// Create an Anchor wallet from the keypair
|
|
45
|
-
const wallet = {
|
|
46
|
-
publicKey: this.keypair.publicKey,
|
|
47
|
-
signTransaction: async (tx) => {
|
|
48
|
-
tx.partialSign(this.keypair);
|
|
49
|
-
return tx;
|
|
50
|
-
},
|
|
51
|
-
signAllTransactions: async (txs) => {
|
|
52
|
-
return txs.map(tx => {
|
|
53
|
-
tx.partialSign(this.keypair);
|
|
54
|
-
return tx;
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
// Add payer property to satisfy NodeWallet interface
|
|
58
|
-
payer: this.keypair
|
|
59
|
-
};
|
|
60
|
-
// Initialize the bridge client
|
|
61
|
-
this.bridgeClient = new client_1.SolanaBridgeClient({
|
|
62
|
-
rpcUrl: this.connection.rpcEndpoint,
|
|
63
|
-
programId: this.nord.solanaProgramId,
|
|
64
|
-
commitment: 'confirmed',
|
|
65
|
-
tokenInfos: this.splTokenInfos
|
|
66
|
-
}, wallet);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Create a NordUser from a private key
|
|
70
|
-
*
|
|
71
|
-
* @param nord Nord instance
|
|
72
|
-
* @param privateKey Private key as string or Uint8Array
|
|
73
|
-
* @param connection Solana connection
|
|
74
|
-
* @returns NordUser instance
|
|
75
|
-
*/
|
|
76
|
-
static fromPrivateKey(nord, privateKey, connection) {
|
|
77
|
-
const keypair = (0, utils_1.keypairFromPrivateKey)(privateKey);
|
|
78
|
-
// Create a signing function that returns Uint8Array
|
|
79
|
-
const walletSignFn = async (message) => {
|
|
80
|
-
const messageBuffer = typeof message === 'string'
|
|
81
|
-
? Buffer.from(message)
|
|
82
|
-
: Buffer.from(message);
|
|
83
|
-
// Use nacl for signing since Keypair doesn't have a sign method
|
|
84
|
-
// This is a simplified version - in a real implementation, you would use proper signing
|
|
85
|
-
return new Uint8Array(keypair.secretKey.slice(0, 64));
|
|
86
|
-
};
|
|
87
|
-
return new NordUser({
|
|
88
|
-
nord,
|
|
89
|
-
publicKey: keypair.publicKey,
|
|
90
|
-
walletSignFn,
|
|
91
|
-
sessionSignFn: walletSignFn,
|
|
92
|
-
keypair,
|
|
93
|
-
connection
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get the associated token account for a token mint
|
|
98
|
-
*
|
|
99
|
-
* @param mint Token mint address
|
|
100
|
-
* @returns Associated token account address
|
|
101
|
-
*/
|
|
102
|
-
async getAssociatedTokenAccount(mint) {
|
|
103
|
-
if (!this.connection) {
|
|
104
|
-
throw new Error('Connection is required to get associated token account');
|
|
105
|
-
}
|
|
106
|
-
const associatedTokenAddress = await (0, spl_token_1.getAssociatedTokenAddress)(mint, this.publicKey);
|
|
107
|
-
try {
|
|
108
|
-
await (0, spl_token_1.getAccount)(this.connection, associatedTokenAddress);
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
// Account doesn't exist, create it if keypair is available
|
|
112
|
-
if (this.keypair && this.bridgeClient) {
|
|
113
|
-
await this.bridgeClient.createTokenAccountIfNeeded(mint, this.publicKey, this.keypair);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return associatedTokenAddress;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Deposit SPL tokens to the bridge
|
|
120
|
-
*
|
|
121
|
-
* @param amount Amount to deposit
|
|
122
|
-
* @param tokenId Token ID
|
|
123
|
-
* @returns Transaction signature
|
|
124
|
-
*/
|
|
125
|
-
async depositSpl(amount, tokenId) {
|
|
126
|
-
if (!this.bridgeClient || !this.keypair || !this.connection) {
|
|
127
|
-
throw new Error('Bridge client, keypair, and connection are required for deposit');
|
|
128
|
-
}
|
|
129
|
-
// Find the token info
|
|
130
|
-
const tokenInfo = this.splTokenInfos.find(t => t.tokenId === tokenId);
|
|
131
|
-
if (!tokenInfo) {
|
|
132
|
-
throw new Error(`Token with ID ${tokenId} not found`);
|
|
133
|
-
}
|
|
134
|
-
const mint = new web3_js_1.PublicKey(tokenInfo.mint);
|
|
135
|
-
// Get the user's token account
|
|
136
|
-
const fromAccount = await this.getAssociatedTokenAccount(mint);
|
|
137
|
-
// Get the bridge's token account
|
|
138
|
-
const [authority] = await this.bridgeClient.findAuthorityPda();
|
|
139
|
-
const toAccount = await (0, spl_token_1.getAssociatedTokenAddress)(mint, authority, true);
|
|
140
|
-
// Convert amount to BN with proper decimals
|
|
141
|
-
const amountBN = (0, utils_1.toBN)(amount, tokenInfo.precision);
|
|
142
|
-
// Deposit tokens
|
|
143
|
-
return await this.bridgeClient.depositSpl({
|
|
144
|
-
amount: amountBN,
|
|
145
|
-
mint,
|
|
146
|
-
fromAccount,
|
|
147
|
-
toAccount
|
|
148
|
-
}, this.keypair);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Withdraw tokens from the bridge
|
|
152
|
-
*
|
|
153
|
-
* @param claim Withdrawal claim
|
|
154
|
-
* @returns Transaction signature
|
|
155
|
-
*/
|
|
156
|
-
async withdrawSpl(claim) {
|
|
157
|
-
if (!this.bridgeClient || !this.keypair || !this.connection) {
|
|
158
|
-
throw new Error('Bridge client, keypair, and connection are required for withdrawal');
|
|
159
|
-
}
|
|
160
|
-
// Get the user's token account
|
|
161
|
-
const toAccount = await this.getAssociatedTokenAccount(claim.mint);
|
|
162
|
-
// Get the bridge's token account
|
|
163
|
-
const [authority] = await this.bridgeClient.findAuthorityPda();
|
|
164
|
-
const fromAccount = await (0, spl_token_1.getAssociatedTokenAddress)(claim.mint, authority, true);
|
|
165
|
-
// Withdraw tokens
|
|
166
|
-
return await this.bridgeClient.withdraw({
|
|
167
|
-
claim,
|
|
168
|
-
toAccount,
|
|
169
|
-
fromAccount
|
|
170
|
-
}, this.keypair);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Fund the user's SPL token accounts for testing
|
|
174
|
-
*
|
|
175
|
-
* @param faucetKeypair Keypair with funds to distribute
|
|
176
|
-
*/
|
|
177
|
-
async fundSplWallet(faucetKeypair) {
|
|
178
|
-
if (!this.connection) {
|
|
179
|
-
throw new Error('Connection is required to fund wallet');
|
|
180
|
-
}
|
|
181
|
-
// Fund SOL if needed
|
|
182
|
-
const solBalance = await this.connection.getBalance(this.publicKey);
|
|
183
|
-
if (solBalance < 10000000) { // 0.01 SOL
|
|
184
|
-
const solFundingAmount = const_1.DEFAULT_FUNDING_AMOUNTS["SOL"];
|
|
185
|
-
// Implement SOL transfer logic here
|
|
186
|
-
}
|
|
187
|
-
// Fund SPL tokens
|
|
188
|
-
for (const tokenInfo of this.splTokenInfos) {
|
|
189
|
-
if (const_1.DEFAULT_FUNDING_AMOUNTS[tokenInfo.mint]) {
|
|
190
|
-
const tokenAccount = await this.getAssociatedTokenAccount(new web3_js_1.PublicKey(tokenInfo.mint));
|
|
191
|
-
// Implement SPL token transfer logic here
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
exports.NordUser = NordUser;
|
package/dist/client.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Main Nord client implementation with a flat API structure
|
|
3
|
-
* @module client
|
|
4
|
-
*/
|
|
5
|
-
import { NordClientConfig } from './types/config';
|
|
6
|
-
import { NordClient } from './types/api';
|
|
7
|
-
import { NordError, NordApiError, NordValidationError } from './utils/errors';
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new Nord client instance.
|
|
10
|
-
*
|
|
11
|
-
* @param {NordClientConfig} config - Configuration for the Nord client
|
|
12
|
-
* @returns {NordClient} A configured Nord client instance
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* import { createNordClient } from '@layer-n/nord-ts';
|
|
17
|
-
*
|
|
18
|
-
* const nord = createNordClient({
|
|
19
|
-
* webServerUrl: 'https://api.nord.io',
|
|
20
|
-
* tokenInfos: [
|
|
21
|
-
* { address: '0x...', precision: 8, tokenId: 1, name: 'BTC' },
|
|
22
|
-
* { address: '0x...', precision: 6, tokenId: 2, name: 'USDC' }
|
|
23
|
-
* ]
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* // Get market data
|
|
27
|
-
* const orderbook = await nord.getOrderbook('BTCUSDC');
|
|
28
|
-
* console.log(orderbook);
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function createNordClient(config: NordClientConfig): NordClient;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a Nord client for a specific user with authentication
|
|
34
|
-
*
|
|
35
|
-
* @param {NordClientConfig} config - Configuration for the Nord client
|
|
36
|
-
* @param {string} address - User's blockchain address
|
|
37
|
-
* @param {Function} signFn - Function to sign messages with the user's wallet
|
|
38
|
-
* @returns {Promise<NordClient>} A configured Nord client instance with user authentication
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* import { createNordUserClient } from '@layer-n/nord-ts';
|
|
43
|
-
*
|
|
44
|
-
* const userClient = await createNordUserClient(
|
|
45
|
-
* {
|
|
46
|
-
* webServerUrl: 'https://api.nord.io',
|
|
47
|
-
* tokenInfos: [
|
|
48
|
-
* { address: '0x...', precision: 8, tokenId: 1, name: 'BTC' },
|
|
49
|
-
* { address: '0x...', precision: 6, tokenId: 2, name: 'USDC' }
|
|
50
|
-
* ]
|
|
51
|
-
* },
|
|
52
|
-
* '0xYourAddress',
|
|
53
|
-
* async (message) => {
|
|
54
|
-
* // Sign message with wallet
|
|
55
|
-
* return signatureHex;
|
|
56
|
-
* }
|
|
57
|
-
* );
|
|
58
|
-
*
|
|
59
|
-
* // Place an order
|
|
60
|
-
* const order = await userClient.placeOrder({
|
|
61
|
-
* market: 'BTCUSDC',
|
|
62
|
-
* side: 'buy',
|
|
63
|
-
* type: 'limit',
|
|
64
|
-
* size: 1.0,
|
|
65
|
-
* price: 50000.0
|
|
66
|
-
* });
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare function createNordUserClient(config: NordClientConfig, address: string, signFn: (message: Uint8Array | string) => Promise<string>): Promise<NordClient>;
|
|
70
|
-
export { NordError, NordApiError, NordValidationError };
|
package/dist/client.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Main Nord client implementation with a flat API structure
|
|
4
|
-
* @module client
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.NordValidationError = exports.NordApiError = exports.NordError = void 0;
|
|
8
|
-
exports.createNordClient = createNordClient;
|
|
9
|
-
exports.createNordUserClient = createNordUserClient;
|
|
10
|
-
const errors_1 = require("./utils/errors");
|
|
11
|
-
Object.defineProperty(exports, "NordError", { enumerable: true, get: function () { return errors_1.NordError; } });
|
|
12
|
-
Object.defineProperty(exports, "NordApiError", { enumerable: true, get: function () { return errors_1.NordApiError; } });
|
|
13
|
-
Object.defineProperty(exports, "NordValidationError", { enumerable: true, get: function () { return errors_1.NordValidationError; } });
|
|
14
|
-
const client_1 = require("./websocket/client");
|
|
15
|
-
const market_1 = require("./operations/market");
|
|
16
|
-
const account_1 = require("./operations/account");
|
|
17
|
-
const orders_1 = require("./operations/orders");
|
|
18
|
-
const metrics_1 = require("./operations/metrics");
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new Nord client instance.
|
|
21
|
-
*
|
|
22
|
-
* @param {NordClientConfig} config - Configuration for the Nord client
|
|
23
|
-
* @returns {NordClient} A configured Nord client instance
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import { createNordClient } from '@layer-n/nord-ts';
|
|
28
|
-
*
|
|
29
|
-
* const nord = createNordClient({
|
|
30
|
-
* webServerUrl: 'https://api.nord.io',
|
|
31
|
-
* tokenInfos: [
|
|
32
|
-
* { address: '0x...', precision: 8, tokenId: 1, name: 'BTC' },
|
|
33
|
-
* { address: '0x...', precision: 6, tokenId: 2, name: 'USDC' }
|
|
34
|
-
* ]
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Get market data
|
|
38
|
-
* const orderbook = await nord.getOrderbook('BTCUSDC');
|
|
39
|
-
* console.log(orderbook);
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
function createNordClient(config) {
|
|
43
|
-
// Validate required config
|
|
44
|
-
if (!config.webServerUrl) {
|
|
45
|
-
throw new errors_1.NordValidationError('webServerUrl is required', 'webServerUrl');
|
|
46
|
-
}
|
|
47
|
-
// Initialize WebSocket client
|
|
48
|
-
const ws = new client_1.WebSocketClient(config.webServerUrl);
|
|
49
|
-
// Initialize operation modules
|
|
50
|
-
const marketOps = new market_1.MarketOperations(config);
|
|
51
|
-
const accountOps = new account_1.AccountOperations(config);
|
|
52
|
-
const orderOps = new orders_1.OrderOperations(config);
|
|
53
|
-
const metricsOps = new metrics_1.MetricsOperations(config);
|
|
54
|
-
// Create and return the client object with flat API
|
|
55
|
-
const client = {
|
|
56
|
-
// Core properties
|
|
57
|
-
config,
|
|
58
|
-
ws,
|
|
59
|
-
// Market operations
|
|
60
|
-
getMarkets: () => marketOps.getMarkets(),
|
|
61
|
-
getOrderbook: (market) => marketOps.getOrderbook(market),
|
|
62
|
-
getTrades: (market, limit) => marketOps.getTrades(market, limit),
|
|
63
|
-
getCandles: (market, timeframe, limit) => marketOps.getCandles(market, timeframe, limit),
|
|
64
|
-
getTimestamp: () => marketOps.getTimestamp(),
|
|
65
|
-
// Account operations
|
|
66
|
-
getAccount: (accountId) => accountOps.getAccount(accountId),
|
|
67
|
-
getAccounts: (address) => accountOps.getAccounts(address),
|
|
68
|
-
getBalance: (accountId, token) => accountOps.getBalance(accountId, token),
|
|
69
|
-
getBalances: (accountId) => accountOps.getBalances(accountId),
|
|
70
|
-
// Order operations
|
|
71
|
-
placeOrder: (params) => orderOps.placeOrder(params),
|
|
72
|
-
cancelOrder: (orderId) => orderOps.cancelOrder(orderId),
|
|
73
|
-
getOrder: (orderId) => orderOps.getOrder(orderId),
|
|
74
|
-
getOrders: (accountId) => orderOps.getOrders(accountId),
|
|
75
|
-
// Namespace for less common operations
|
|
76
|
-
metrics: {
|
|
77
|
-
getAggregate: () => metricsOps.getAggregate(),
|
|
78
|
-
getPeakTps: (timeframe) => metricsOps.getPeakTps(timeframe),
|
|
79
|
-
},
|
|
80
|
-
// WebSocket subscription methods
|
|
81
|
-
subscribeToOrderbook: (market, callback) => ws.subscribeToOrderbook(market, callback),
|
|
82
|
-
subscribeToTrades: (market, callback) => ws.subscribeToTrades(market, callback),
|
|
83
|
-
subscribeToUserUpdates: (accountId, callback) => ws.subscribeToUserUpdates(accountId, callback),
|
|
84
|
-
};
|
|
85
|
-
return client;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates a Nord client for a specific user with authentication
|
|
89
|
-
*
|
|
90
|
-
* @param {NordClientConfig} config - Configuration for the Nord client
|
|
91
|
-
* @param {string} address - User's blockchain address
|
|
92
|
-
* @param {Function} signFn - Function to sign messages with the user's wallet
|
|
93
|
-
* @returns {Promise<NordClient>} A configured Nord client instance with user authentication
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* import { createNordUserClient } from '@layer-n/nord-ts';
|
|
98
|
-
*
|
|
99
|
-
* const userClient = await createNordUserClient(
|
|
100
|
-
* {
|
|
101
|
-
* webServerUrl: 'https://api.nord.io',
|
|
102
|
-
* tokenInfos: [
|
|
103
|
-
* { address: '0x...', precision: 8, tokenId: 1, name: 'BTC' },
|
|
104
|
-
* { address: '0x...', precision: 6, tokenId: 2, name: 'USDC' }
|
|
105
|
-
* ]
|
|
106
|
-
* },
|
|
107
|
-
* '0xYourAddress',
|
|
108
|
-
* async (message) => {
|
|
109
|
-
* // Sign message with wallet
|
|
110
|
-
* return signatureHex;
|
|
111
|
-
* }
|
|
112
|
-
* );
|
|
113
|
-
*
|
|
114
|
-
* // Place an order
|
|
115
|
-
* const order = await userClient.placeOrder({
|
|
116
|
-
* market: 'BTCUSDC',
|
|
117
|
-
* side: 'buy',
|
|
118
|
-
* type: 'limit',
|
|
119
|
-
* size: 1.0,
|
|
120
|
-
* price: 50000.0
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
async function createNordUserClient(config, address, signFn) {
|
|
125
|
-
// Create base client
|
|
126
|
-
const baseClient = createNordClient(config);
|
|
127
|
-
// TODO: Implement user authentication and session creation
|
|
128
|
-
return baseClient;
|
|
129
|
-
}
|