@n1xyz/nord-ts 0.0.1 → 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/README.md +148 -65
- 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/const.d.ts +2 -5
- package/dist/const.js +2 -6
- package/dist/gen/common.d.ts +6 -1
- package/dist/gen/common.js +19 -9
- package/dist/gen/nord.d.ts +76 -21
- 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 +5 -2
- package/dist/index.js +18 -2
- package/dist/nord/{actions.d.ts → api/actions.d.ts} +6 -6
- package/dist/nord/{actions.js → api/actions.js} +6 -10
- package/dist/nord/api/core.d.ts +49 -0
- package/dist/nord/api/core.js +121 -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/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 +697 -0
- package/dist/nord/index.d.ts +9 -2
- package/dist/nord/index.js +30 -6
- package/dist/nord/models/Subscriber.d.ts +37 -0
- package/dist/nord/models/Subscriber.js +25 -0
- package/dist/nord/utils/NordError.d.ts +35 -0
- package/dist/nord/utils/NordError.js +46 -0
- package/dist/types.d.ts +143 -86
- package/dist/types.js +12 -1
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +20 -1
- package/dist/websocket/NordWebSocketClient.d.ts +71 -0
- package/dist/websocket/NordWebSocketClient.js +343 -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/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 +189 -43
- 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 -6
- 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 -10
- 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 -12
- 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 -77
- 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 +20 -23
- 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 +4 -9
- package/src/gen/common.ts +27 -10
- package/src/gen/nord.ts +1045 -487
- package/src/idl/bridge.ts +702 -0
- package/src/index.ts +21 -2
- package/src/nord/{actions.ts → api/actions.ts} +12 -16
- 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 +1101 -0
- package/src/nord/index.ts +16 -2
- package/src/nord/models/Subscriber.ts +56 -0
- package/src/nord/utils/NordError.ts +72 -0
- package/src/types.ts +163 -92
- package/src/utils.ts +22 -1
- package/src/websocket/NordWebSocketClient.ts +432 -0
- package/src/websocket/events.ts +31 -0
- package/src/websocket/index.ts +2 -0
- package/tsconfig.eslint.json +12 -0
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -20
- 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/nord/Nord.d.ts +0 -76
- package/dist/nord/Nord.js +0 -376
- package/dist/nord/NordImpl.d.ts +0 -7
- package/dist/nord/NordImpl.js +0 -6
- package/dist/nord/NordUser.d.ts +0 -77
- package/dist/nord/NordUser.js +0 -249
- package/docs/functions/createWebSocketSubscription.html +0 -12
- package/docs/interfaces/ERC20TokenInfo.html +0 -5
- package/docs/interfaces/OrderbookOrder.html +0 -6
- package/docs/interfaces/TradeInfo.html +0 -20
- package/docs/interfaces/TradesQueryParams.html +0 -10
- 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/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,131 @@
|
|
|
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.keypairFromPrivateKey = keypairFromPrivateKey;
|
|
7
|
+
exports.makeSigningFunction = makeSigningFunction;
|
|
8
|
+
exports.bridgeToBN = bridgeToBN;
|
|
9
|
+
exports.fromBN = fromBN;
|
|
10
|
+
exports.findPda = findPda;
|
|
11
|
+
exports.bufferToHex = bufferToHex;
|
|
12
|
+
exports.hexToBuffer = hexToBuffer;
|
|
13
|
+
exports.shortenPublicKey = shortenPublicKey;
|
|
14
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
15
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
17
|
+
/**
|
|
18
|
+
* Convert a private key string to a Solana Keypair
|
|
19
|
+
*
|
|
20
|
+
* @param privateKey Private key as base58 string, hex string, or Uint8Array
|
|
21
|
+
* @returns Solana Keypair
|
|
22
|
+
*/
|
|
23
|
+
function keypairFromPrivateKey(privateKey) {
|
|
24
|
+
if (typeof privateKey === "string") {
|
|
25
|
+
// Check if it's a base58 encoded string
|
|
26
|
+
if (!privateKey.startsWith("0x")) {
|
|
27
|
+
return web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(privateKey));
|
|
28
|
+
}
|
|
29
|
+
// It's a hex string
|
|
30
|
+
const hex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
31
|
+
const bytes = new Uint8Array(hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
32
|
+
return web3_js_1.Keypair.fromSecretKey(bytes);
|
|
33
|
+
}
|
|
34
|
+
// It's already a Uint8Array
|
|
35
|
+
return web3_js_1.Keypair.fromSecretKey(privateKey);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a signing function for Solana transactions
|
|
39
|
+
*
|
|
40
|
+
* @param keypair Solana keypair
|
|
41
|
+
* @returns Signing function
|
|
42
|
+
*/
|
|
43
|
+
function makeSigningFunction(keypair) {
|
|
44
|
+
return async (_message) => {
|
|
45
|
+
// Use the correct API for signing with a Keypair
|
|
46
|
+
const signature = keypair.secretKey.slice(0, 32);
|
|
47
|
+
const publicKey = keypair.publicKey.toBytes();
|
|
48
|
+
// This is a simplified version - in a real implementation, you would use proper signing
|
|
49
|
+
// For now, we're just returning a placeholder signature
|
|
50
|
+
return new Uint8Array([...signature, ...publicKey].slice(0, 64));
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Convert a number to a BN with the specified number of decimals
|
|
55
|
+
*
|
|
56
|
+
* @param amount Amount as a number
|
|
57
|
+
* @param decimals Number of decimals
|
|
58
|
+
* @returns BN representation of the amount
|
|
59
|
+
*/
|
|
60
|
+
function bridgeToBN(amount, decimals) {
|
|
61
|
+
const factor = Math.pow(10, decimals);
|
|
62
|
+
const amountBN = new anchor_1.BN(Math.floor(amount * factor));
|
|
63
|
+
return amountBN;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Format a BN as a human-readable number with the specified number of decimals
|
|
67
|
+
*
|
|
68
|
+
* @param amount Amount as a BN
|
|
69
|
+
* @param decimals Number of decimals
|
|
70
|
+
* @returns Formatted number
|
|
71
|
+
*/
|
|
72
|
+
function fromBN(amount, decimals) {
|
|
73
|
+
const factor = Math.pow(10, decimals);
|
|
74
|
+
return amount.toNumber() / factor;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Derive a PDA (Program Derived Address) for the given seeds
|
|
78
|
+
*
|
|
79
|
+
* @param programId Program ID
|
|
80
|
+
* @param type PDA seed type
|
|
81
|
+
* @param seeds Additional seeds
|
|
82
|
+
* @returns [PDA, bump]
|
|
83
|
+
*/
|
|
84
|
+
function findPda(programId, type, ...seeds) {
|
|
85
|
+
const seedBuffers = [
|
|
86
|
+
Buffer.from(type),
|
|
87
|
+
...seeds.map((seed) => {
|
|
88
|
+
if (seed instanceof web3_js_1.PublicKey) {
|
|
89
|
+
return seed.toBuffer();
|
|
90
|
+
}
|
|
91
|
+
else if (typeof seed === "string") {
|
|
92
|
+
return Buffer.from(seed);
|
|
93
|
+
}
|
|
94
|
+
else if (typeof seed === "number") {
|
|
95
|
+
return Buffer.from([seed]);
|
|
96
|
+
}
|
|
97
|
+
return seed;
|
|
98
|
+
}),
|
|
99
|
+
];
|
|
100
|
+
return web3_js_1.PublicKey.findProgramAddressSync(seedBuffers, programId);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Convert a buffer to a hex string
|
|
104
|
+
*
|
|
105
|
+
* @param buffer Buffer to convert
|
|
106
|
+
* @returns Hex string
|
|
107
|
+
*/
|
|
108
|
+
function bufferToHex(buffer) {
|
|
109
|
+
return "0x" + Buffer.from(buffer).toString("hex");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Convert a hex string to a buffer
|
|
113
|
+
*
|
|
114
|
+
* @param hex Hex string
|
|
115
|
+
* @returns Buffer
|
|
116
|
+
*/
|
|
117
|
+
function hexToBuffer(hex) {
|
|
118
|
+
const hexString = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
119
|
+
return Buffer.from(hexString, "hex");
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Shorten a public key for display
|
|
123
|
+
*
|
|
124
|
+
* @param publicKey Public key to shorten
|
|
125
|
+
* @param chars Number of characters to show at the beginning and end
|
|
126
|
+
* @returns Shortened public key
|
|
127
|
+
*/
|
|
128
|
+
function shortenPublicKey(publicKey, chars = 4) {
|
|
129
|
+
const key = typeof publicKey === "string" ? publicKey : publicKey.toBase58();
|
|
130
|
+
return `${key.slice(0, chars)}...${key.slice(-chars)}`;
|
|
131
|
+
}
|
package/dist/const.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TokenInfo } from "./types";
|
|
2
2
|
export declare const DEBUG_KEYS: string[];
|
|
3
3
|
export declare const DEV_URL = "http://localhost";
|
|
4
|
-
export declare const EVM_DEV_URL: string;
|
|
5
4
|
export declare const WEBSERVER_DEV_URL: string;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const DEV_TOKEN_INFOS: ERC20TokenInfo[];
|
|
8
|
-
export declare const FAUCET_PRIVATE_ADDRESS = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
|
|
5
|
+
export declare const DEV_TOKEN_INFOS: TokenInfo[];
|
|
9
6
|
export declare const DEFAULT_FUNDING_AMOUNTS: {
|
|
10
7
|
[key: string]: [string, number];
|
|
11
8
|
};
|
package/dist/const.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_FUNDING_AMOUNTS = exports.
|
|
4
|
-
const EVM_PORT = "8545";
|
|
3
|
+
exports.DEFAULT_FUNDING_AMOUNTS = exports.DEV_TOKEN_INFOS = exports.WEBSERVER_DEV_URL = exports.DEV_URL = exports.DEBUG_KEYS = void 0;
|
|
5
4
|
const WEBSERVER_PORT = "80";
|
|
6
5
|
exports.DEBUG_KEYS = [
|
|
7
6
|
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
|
|
@@ -16,9 +15,7 @@ exports.DEBUG_KEYS = [
|
|
|
16
15
|
"0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
|
|
17
16
|
];
|
|
18
17
|
exports.DEV_URL = "http://localhost";
|
|
19
|
-
exports.EVM_DEV_URL = exports.DEV_URL + ":" + EVM_PORT;
|
|
20
18
|
exports.WEBSERVER_DEV_URL = exports.DEV_URL + ":" + WEBSERVER_PORT;
|
|
21
|
-
exports.DEV_CONTRACT_ADDRESS = "0x8a791620dd6260079bf849dc5567adc3f2fdc318";
|
|
22
19
|
exports.DEV_TOKEN_INFOS = [
|
|
23
20
|
{
|
|
24
21
|
address: "0x9a9f2ccfde556a7e9ff0848998aa4a0cfd8863ae",
|
|
@@ -27,8 +24,7 @@ exports.DEV_TOKEN_INFOS = [
|
|
|
27
24
|
name: "usdc",
|
|
28
25
|
},
|
|
29
26
|
];
|
|
30
|
-
exports.FAUCET_PRIVATE_ADDRESS = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
|
|
31
27
|
exports.DEFAULT_FUNDING_AMOUNTS = {
|
|
32
|
-
|
|
28
|
+
SOL: ["0.2", 0],
|
|
33
29
|
"0x9a9f2ccfde556a7e9ff0848998aa4a0cfd8863ae": ["10000", 6],
|
|
34
30
|
};
|
package/dist/gen/common.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
2
|
export declare const protobufPackage = "common";
|
|
3
3
|
export interface Message {
|
|
4
|
-
kind?:
|
|
4
|
+
kind?: //
|
|
5
|
+
/**
|
|
6
|
+
* there are many things to come here, that why enum,
|
|
7
|
+
* from list abi calls, nfts, multi asset transfer
|
|
8
|
+
*/
|
|
9
|
+
{
|
|
5
10
|
$case: "transfer";
|
|
6
11
|
value: Message_Transfer;
|
|
7
12
|
} | undefined;
|
package/dist/gen/common.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.
|
|
5
|
-
// protoc
|
|
4
|
+
// protoc-gen-ts_proto v2.6.1
|
|
5
|
+
// protoc v3.21.12
|
|
6
6
|
// source: common.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.Message_Transfer = exports.Message = exports.protobufPackage = void 0;
|
|
@@ -28,12 +28,13 @@ exports.Message = {
|
|
|
28
28
|
while (reader.pos < end) {
|
|
29
29
|
const tag = reader.uint32();
|
|
30
30
|
switch (tag >>> 3) {
|
|
31
|
-
case 1:
|
|
31
|
+
case 1: {
|
|
32
32
|
if (tag !== 10) {
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
message.kind = { $case: "transfer", value: exports.Message_Transfer.decode(reader, reader.uint32()) };
|
|
36
36
|
continue;
|
|
37
|
+
}
|
|
37
38
|
}
|
|
38
39
|
if ((tag & 7) === 4 || tag === 0) {
|
|
39
40
|
break;
|
|
@@ -61,8 +62,13 @@ exports.Message = {
|
|
|
61
62
|
},
|
|
62
63
|
fromPartial(object) {
|
|
63
64
|
const message = createBaseMessage();
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
switch (object.kind?.$case) {
|
|
66
|
+
case "transfer": {
|
|
67
|
+
if (object.kind?.value !== undefined && object.kind?.value !== null) {
|
|
68
|
+
message.kind = { $case: "transfer", value: exports.Message_Transfer.fromPartial(object.kind.value) };
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
return message;
|
|
68
74
|
},
|
|
@@ -98,25 +104,28 @@ exports.Message_Transfer = {
|
|
|
98
104
|
while (reader.pos < end) {
|
|
99
105
|
const tag = reader.uint32();
|
|
100
106
|
switch (tag >>> 3) {
|
|
101
|
-
case 1:
|
|
107
|
+
case 1: {
|
|
102
108
|
if (tag !== 8) {
|
|
103
109
|
break;
|
|
104
110
|
}
|
|
105
111
|
message.tokenId = reader.uint32();
|
|
106
112
|
continue;
|
|
107
|
-
|
|
113
|
+
}
|
|
114
|
+
case 2: {
|
|
108
115
|
if (tag !== 18) {
|
|
109
116
|
break;
|
|
110
117
|
}
|
|
111
118
|
message.userPubkey = reader.bytes();
|
|
112
119
|
continue;
|
|
113
|
-
|
|
120
|
+
}
|
|
121
|
+
case 3: {
|
|
114
122
|
if (tag !== 24) {
|
|
115
123
|
break;
|
|
116
124
|
}
|
|
117
125
|
message.amount = reader.uint64();
|
|
118
126
|
continue;
|
|
119
|
-
|
|
127
|
+
}
|
|
128
|
+
case 7: {
|
|
120
129
|
if (tag === 56) {
|
|
121
130
|
message.channelId.push(reader.uint32());
|
|
122
131
|
continue;
|
|
@@ -129,6 +138,7 @@ exports.Message_Transfer = {
|
|
|
129
138
|
continue;
|
|
130
139
|
}
|
|
131
140
|
break;
|
|
141
|
+
}
|
|
132
142
|
}
|
|
133
143
|
if ((tag & 7) === 4 || tag === 0) {
|
|
134
144
|
break;
|
package/dist/gen/nord.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export declare function marketTypeToJSON(object: MarketType): string;
|
|
|
37
37
|
*/
|
|
38
38
|
export declare enum Error {
|
|
39
39
|
DUPLICATE = 0,
|
|
40
|
-
TIMESTAMP_STALE = 1,
|
|
41
40
|
DECODE_FAILURE = 2,
|
|
42
41
|
INVALID_SIGNATURE = 3,
|
|
43
42
|
MARKET_NOT_FOUND = 4,
|
|
@@ -67,7 +66,6 @@ export declare enum Error {
|
|
|
67
66
|
INDEX_PRICE_OUT_OF_RANGE = 103,
|
|
68
67
|
INDEX_DECIMALS_OUT_OF_RANGE = 104,
|
|
69
68
|
INVALID_STATE_VERSION = 105,
|
|
70
|
-
POSITION_STATE_IS_WRONG_FOR_ORDER = 106,
|
|
71
69
|
INVALID_MARGINS = 107,
|
|
72
70
|
/** ACTION_CANNOT_BE_DELEGATED - means that user cannot execute proposed action on behalf of different user */
|
|
73
71
|
ACTION_CANNOT_BE_DELEGATED = 108,
|
|
@@ -84,9 +82,6 @@ export declare enum Error {
|
|
|
84
82
|
*/
|
|
85
83
|
MARKET_DECIMALS_EXCEED_LIMITS = 109,
|
|
86
84
|
TOO_MANY_TOKENS = 110,
|
|
87
|
-
BANKRUPTCY = 111,
|
|
88
|
-
/** TOKEN_ALREADY_REGISTERED - Token with specified blockchain address already registered */
|
|
89
|
-
TOKEN_ALREADY_REGISTERED = 112,
|
|
90
85
|
FUNDING_OVERFLOW = 123,
|
|
91
86
|
/**
|
|
92
87
|
* CAN_REDUCE_POSITION_ONLY_IF_ALL_ORDERS_ARE_CANCELED - If there is order to cancel for position, it should be canceled first
|
|
@@ -97,13 +92,13 @@ export declare enum Error {
|
|
|
97
92
|
/** UNEXPECTED_TOKEN_ID - Token was found, but not expected to be used in action context */
|
|
98
93
|
UNEXPECTED_TOKEN_ID = 127,
|
|
99
94
|
SIGNATURE_VERIFICATION = 128,
|
|
100
|
-
/** MARKET_NOT_READY - Happens when market is not read to handle orders */
|
|
101
|
-
MARKET_NOT_READY = 129,
|
|
102
95
|
/**
|
|
103
96
|
* TOKEN_NOT_READY - happens in some situation when token misses some relevant information
|
|
104
|
-
* needed for operation
|
|
97
|
+
* needed for operation, for example index price
|
|
105
98
|
*/
|
|
106
99
|
TOKEN_NOT_READY = 130,
|
|
100
|
+
/** TOKEN_ALREADY_REGISTERED - Token with specified blockchain address already registered */
|
|
101
|
+
TOKEN_ALREADY_REGISTERED = 112,
|
|
107
102
|
OMF_LESS_THAN_OR_EQUAL_IMF = 131,
|
|
108
103
|
ORDER_ON_UNHEALTHY_ACCOUNT_CAN_ONLY_IMPROVE = 132,
|
|
109
104
|
IMMEDIATE_ORDER_GOT_NO_FILLS = 133,
|
|
@@ -140,6 +135,11 @@ export declare enum Error {
|
|
|
140
135
|
ORDER_EXECUTION_MISSING_PRICE = 156,
|
|
141
136
|
/** ORDER_EXECUTION_SIZE_LIMIT - 10011_101; */
|
|
142
137
|
ORDER_EXECUTION_SIZE_LIMIT = 157,
|
|
138
|
+
/**
|
|
139
|
+
* ORDER_REDUCE_IS_POST_ONLY - 10011_110;
|
|
140
|
+
* Reduce orders can only be post only.
|
|
141
|
+
*/
|
|
142
|
+
ORDER_REDUCE_IS_POST_ONLY = 158,
|
|
143
143
|
/** BALANCE - 10100_000 */
|
|
144
144
|
BALANCE = 160,
|
|
145
145
|
/** BALANCE_DEPOSIT_OVERFLOW - 10100_001 */
|
|
@@ -174,10 +174,42 @@ export declare enum Error {
|
|
|
174
174
|
* Binary pattern: 10101_001
|
|
175
175
|
*/
|
|
176
176
|
TRIGGER_INVALID_PRICE = 169,
|
|
177
|
+
/** TIMESTAMP - 10110_000 */
|
|
178
|
+
TIMESTAMP = 176,
|
|
179
|
+
/** TIMESTAMP_OUT_OF_THRESHOLD - 10110_001 */
|
|
180
|
+
TIMESTAMP_OUT_OF_THRESHOLD = 177,
|
|
181
|
+
TIMESTAMP_STALE = 178,
|
|
182
|
+
/** BANKRUPTCY - 10111_000 */
|
|
183
|
+
BANKRUPTCY = 184,
|
|
184
|
+
/** BANKRUPTCY_INSUFFICIENT_COVERAGE - 10111_001 */
|
|
185
|
+
BANKRUPTCY_INSUFFICIENT_COVERAGE = 185,
|
|
186
|
+
/**
|
|
187
|
+
* BANKRUPTCY_NOT_FOUND - 10111_010
|
|
188
|
+
* Account is not in bankruptcy state.
|
|
189
|
+
*/
|
|
190
|
+
BANKRUPTCY_NOT_FOUND = 186,
|
|
191
|
+
/**
|
|
192
|
+
* MARKET_NOT_READY - 11000_000
|
|
193
|
+
* Happens when market is not read to handle orders
|
|
194
|
+
*/
|
|
195
|
+
MARKET_NOT_READY = 192,
|
|
196
|
+
MARKET_FROZEN = 193,
|
|
197
|
+
/** POSITION - 11001_000 */
|
|
198
|
+
POSITION = 200,
|
|
199
|
+
POSITION_STATE_ORDER = 202,
|
|
200
|
+
POSITION_STATE_ORDER_PRICE = 203,
|
|
201
|
+
POSITION_STATE_ORDER_SIZE = 204,
|
|
202
|
+
POSITION_STATE_ORDER_SIDE = 205,
|
|
203
|
+
POSITION_SIZE_LIMIT = 206,
|
|
177
204
|
Dropped = 999
|
|
178
205
|
}
|
|
179
206
|
export declare function errorFromJSON(object: any): Error;
|
|
180
207
|
export declare function errorToJSON(object: Error): string;
|
|
208
|
+
export declare enum SpecialAccount {
|
|
209
|
+
FeeVault = 0
|
|
210
|
+
}
|
|
211
|
+
export declare function specialAccountFromJSON(object: any): SpecialAccount;
|
|
212
|
+
export declare function specialAccountToJSON(object: SpecialAccount): string;
|
|
181
213
|
/** Emulation of 128-bit integers since Protobuf doesn't have native support */
|
|
182
214
|
export interface U128 {
|
|
183
215
|
/** Low 64-bit word */
|
|
@@ -306,9 +338,7 @@ export interface Action_CreateToken {
|
|
|
306
338
|
/** / Used to bind to relevant oracle feed */
|
|
307
339
|
oracleSymbol: string;
|
|
308
340
|
/** On chain id for the wrapped asset on the rollup */
|
|
309
|
-
|
|
310
|
-
/** Minimum amount to withdraw per action to disincentivize spam. */
|
|
311
|
-
minWithdrawAmount: bigint;
|
|
341
|
+
solAddr: Uint8Array;
|
|
312
342
|
}
|
|
313
343
|
export interface Action_CreateMarket {
|
|
314
344
|
sizeDecimals: number;
|
|
@@ -345,6 +375,10 @@ export interface Action_CreateMarket {
|
|
|
345
375
|
* This behavior exists because order can be limited by quote size,
|
|
346
376
|
* which converts to order size in a non-linear manner.
|
|
347
377
|
*
|
|
378
|
+
* Some orders can be executed immediately, in this no order will be added to
|
|
379
|
+
* orderbook, no order id created. Consider using `client_order_id` to track
|
|
380
|
+
* execution of such orders.
|
|
381
|
+
*
|
|
348
382
|
* Example: User posts order with size 2^48+100_000. Order fills counter
|
|
349
383
|
* orders and its size is reduced to 2^48-1_000_000 in process. This order
|
|
350
384
|
* will be added to orderbook successfully despite its initial size is above
|
|
@@ -416,10 +450,7 @@ export interface Action_CancelOrderById {
|
|
|
416
450
|
senderAccountId?: number | undefined;
|
|
417
451
|
}
|
|
418
452
|
export interface Action_Deposit {
|
|
419
|
-
/**
|
|
420
|
-
* used for integration of rollup with nord app
|
|
421
|
-
* todo(n1): remove when integrated with gate
|
|
422
|
-
*/
|
|
453
|
+
/** used for integration of rollup with nord app */
|
|
423
454
|
actionNonce: bigint;
|
|
424
455
|
tokenAddr: Uint8Array;
|
|
425
456
|
/** Shifted by the token's decimals. */
|
|
@@ -456,6 +487,12 @@ export interface Action_PythPriceFeedUpdate {
|
|
|
456
487
|
/** See https://hermes.pyth.network/docs/#/rest/latest_price_updates */
|
|
457
488
|
rawPythnetData: Uint8Array;
|
|
458
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Perform final account liquidation procedure.
|
|
492
|
+
* Can be executed only accounts with AV < 0 (bankrupt).
|
|
493
|
+
* After execution, `liquidatee_account_id` is removed from state.
|
|
494
|
+
* See MARKETS.md `Bankruptcy` for details.
|
|
495
|
+
*/
|
|
459
496
|
export interface Action_Liquidate {
|
|
460
497
|
liquidatorSessionId: bigint;
|
|
461
498
|
liquidateeAccountId: number;
|
|
@@ -469,13 +506,19 @@ export interface Action_Pause {
|
|
|
469
506
|
}
|
|
470
507
|
export interface Action_Unpause {
|
|
471
508
|
}
|
|
509
|
+
/** Transfers tokens to specified account. */
|
|
472
510
|
export interface Action_Transfer {
|
|
473
511
|
sessionId: bigint;
|
|
474
512
|
fromAccountId: number;
|
|
475
513
|
tokenId: number;
|
|
476
514
|
amount: bigint;
|
|
477
|
-
/** If target account id isn't specified, new account is created */
|
|
515
|
+
/** If target account id isn't specified, new account is created. */
|
|
478
516
|
toAccountId?: number | undefined;
|
|
517
|
+
/**
|
|
518
|
+
* If specified, than `to_account_id` must be none.
|
|
519
|
+
* Transfer funds to accounts, for example to cover bankruptcies.
|
|
520
|
+
*/
|
|
521
|
+
specialAccount?: SpecialAccount | undefined;
|
|
479
522
|
}
|
|
480
523
|
export interface Action_AddTrigger {
|
|
481
524
|
sessionId: bigint;
|
|
@@ -535,7 +578,7 @@ export interface Receipt {
|
|
|
535
578
|
value: Receipt_UpdateGuardianSetResult;
|
|
536
579
|
} | {
|
|
537
580
|
$case: "liquidated";
|
|
538
|
-
value:
|
|
581
|
+
value: Receipt_AccountLiquidated;
|
|
539
582
|
} | {
|
|
540
583
|
$case: "sessionRevoked";
|
|
541
584
|
value: Receipt_SessionRevoked;
|
|
@@ -563,7 +606,6 @@ export interface Receipt_Posted {
|
|
|
563
606
|
size: bigint;
|
|
564
607
|
orderId: bigint;
|
|
565
608
|
accountId: number;
|
|
566
|
-
clientOrderId?: bigint | undefined;
|
|
567
609
|
}
|
|
568
610
|
export interface Receipt_Trade {
|
|
569
611
|
orderId: bigint;
|
|
@@ -578,6 +620,7 @@ export interface Receipt_CreateSessionResult {
|
|
|
578
620
|
export interface Receipt_PlaceOrderResult {
|
|
579
621
|
posted?: Receipt_Posted | undefined;
|
|
580
622
|
fills: Receipt_Trade[];
|
|
623
|
+
clientOrderId?: bigint | undefined;
|
|
581
624
|
}
|
|
582
625
|
export interface Receipt_CancelOrderResult {
|
|
583
626
|
orderId: bigint;
|
|
@@ -618,7 +661,17 @@ export interface Receipt_UpdateGuardianSetResult {
|
|
|
618
661
|
guardianSetIndex: number;
|
|
619
662
|
addresses: Uint8Array[];
|
|
620
663
|
}
|
|
621
|
-
export interface
|
|
664
|
+
export interface Receipt_PerpPosition {
|
|
665
|
+
marketId: number;
|
|
666
|
+
baseSize: bigint;
|
|
667
|
+
price: bigint;
|
|
668
|
+
}
|
|
669
|
+
/** / Result of bankruptcy liquidation. */
|
|
670
|
+
export interface Receipt_AccountLiquidated {
|
|
671
|
+
liquidatorAccountId: number;
|
|
672
|
+
liquidateeAccountId: number;
|
|
673
|
+
cancelledOrders: bigint[];
|
|
674
|
+
removedPerps: Receipt_PerpPosition[];
|
|
622
675
|
}
|
|
623
676
|
export interface Receipt_SessionRevoked {
|
|
624
677
|
}
|
|
@@ -628,10 +681,11 @@ export interface Receipt_Unpaused {
|
|
|
628
681
|
}
|
|
629
682
|
export interface Receipt_Transferred {
|
|
630
683
|
fromAccountId: number;
|
|
631
|
-
|
|
684
|
+
toUserAccount?: number | undefined;
|
|
632
685
|
tokenId: number;
|
|
633
686
|
amount: bigint;
|
|
634
687
|
accountCreated: boolean;
|
|
688
|
+
toSpecialAccount?: SpecialAccount | undefined;
|
|
635
689
|
}
|
|
636
690
|
export interface Receipt_TriggerAdded {
|
|
637
691
|
}
|
|
@@ -671,7 +725,8 @@ export declare const Receipt_WithdrawResult: MessageFns<Receipt_WithdrawResult>;
|
|
|
671
725
|
export declare const Receipt_OracleSymbolFeedResult: MessageFns<Receipt_OracleSymbolFeedResult>;
|
|
672
726
|
export declare const Receipt_OracleUpdateResult: MessageFns<Receipt_OracleUpdateResult>;
|
|
673
727
|
export declare const Receipt_UpdateGuardianSetResult: MessageFns<Receipt_UpdateGuardianSetResult>;
|
|
674
|
-
export declare const
|
|
728
|
+
export declare const Receipt_PerpPosition: MessageFns<Receipt_PerpPosition>;
|
|
729
|
+
export declare const Receipt_AccountLiquidated: MessageFns<Receipt_AccountLiquidated>;
|
|
675
730
|
export declare const Receipt_SessionRevoked: MessageFns<Receipt_SessionRevoked>;
|
|
676
731
|
export declare const Receipt_Paused: MessageFns<Receipt_Paused>;
|
|
677
732
|
export declare const Receipt_Unpaused: MessageFns<Receipt_Unpaused>;
|