@proof-labs/trading-sdk 4.0.0

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.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +391 -0
  3. package/dist/client.d.ts +640 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +1730 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/codec-adapter.d.ts +33 -0
  8. package/dist/codec-adapter.d.ts.map +1 -0
  9. package/dist/codec-adapter.js +419 -0
  10. package/dist/codec-adapter.js.map +1 -0
  11. package/dist/codec.d.ts +137 -0
  12. package/dist/codec.d.ts.map +1 -0
  13. package/dist/codec.js +229 -0
  14. package/dist/codec.js.map +1 -0
  15. package/dist/crypto.d.ts +78 -0
  16. package/dist/crypto.d.ts.map +1 -0
  17. package/dist/crypto.js +145 -0
  18. package/dist/crypto.js.map +1 -0
  19. package/dist/errors.d.ts +122 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +397 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/governance-query.d.ts +47 -0
  24. package/dist/governance-query.d.ts.map +1 -0
  25. package/dist/governance-query.js +525 -0
  26. package/dist/governance-query.js.map +1 -0
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +22 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/testing.d.ts +25 -0
  32. package/dist/testing.d.ts.map +1 -0
  33. package/dist/testing.js +22 -0
  34. package/dist/testing.js.map +1 -0
  35. package/dist/trigger-history.d.ts +9 -0
  36. package/dist/trigger-history.d.ts.map +1 -0
  37. package/dist/trigger-history.js +442 -0
  38. package/dist/trigger-history.js.map +1 -0
  39. package/dist/triggers.d.ts +15 -0
  40. package/dist/triggers.d.ts.map +1 -0
  41. package/dist/triggers.js +399 -0
  42. package/dist/triggers.js.map +1 -0
  43. package/dist/tx-result.d.ts +53 -0
  44. package/dist/tx-result.d.ts.map +1 -0
  45. package/dist/tx-result.js +58 -0
  46. package/dist/tx-result.js.map +1 -0
  47. package/dist/types.d.ts +2085 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +121 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/wasm/proof_trading_sdk_wasm.d.ts +98 -0
  52. package/dist/wasm/proof_trading_sdk_wasm.js +698 -0
  53. package/dist/wasm/proof_trading_sdk_wasm_bg.wasm +0 -0
  54. package/dist/wasm/proof_trading_sdk_wasm_bg.wasm.d.ts +19 -0
  55. package/dist/wasm-loader.d.ts +42 -0
  56. package/dist/wasm-loader.d.ts.map +1 -0
  57. package/dist/wasm-loader.js +95 -0
  58. package/dist/wasm-loader.js.map +1 -0
  59. package/package.json +72 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Decoder for engine `ExecError` codes returned in `TxResult.code`.
3
+ *
4
+ * The Rust enum lives at `exchange-wire/src/types.rs::ExecError`. Codes
5
+ * are stable wire-format identifiers — adding a new variant goes at the
6
+ * end with the next free integer. **Keep this map in sync with that
7
+ * `code()` impl** (CI flags drift in the audit `api-drift` lane).
8
+ *
9
+ * Use `decodeExecError(code, log)` to translate a `TxResult.code` into a
10
+ * structured `{ name, description }`. UI can render `name` directly
11
+ * (machine-readable) or `description` (human-readable). Code `0` is
12
+ * success and returns `null` from this decoder — call sites should
13
+ * branch on `code === 0` first.
14
+ */
15
+ export interface ExecErrorInfo {
16
+ /** Rust variant name when the code is one-to-one, or a grouped wire-code name. Stable. */
17
+ name: string;
18
+ /** One-line human-readable message — what the engine prints in
19
+ * `Display`. Suitable for toast notifications. */
20
+ description: string;
21
+ }
22
+ /**
23
+ * Named engine `ExecError` codes — the machine-readable half of the {@link TABLE}
24
+ * below, so callers can branch on `code === ExecErrorCode.InsufficientMargin`
25
+ * instead of a bare `12`. Values are the stable wire codes; names mirror the
26
+ * Rust `ExecError` variants. `errors.test.ts` asserts this enum and `TABLE`
27
+ * stay in agreement.
28
+ */
29
+ export declare enum ExecErrorCode {
30
+ DecodeError = 1,
31
+ OrderNotFound = 2,
32
+ NotOwner = 3,
33
+ UnauthorizedOracle = 4,
34
+ Overflow = 5,
35
+ InvalidPrice = 6,
36
+ InvalidQuantity = 7,
37
+ InvalidSide = 8,
38
+ UnknownMarket = 9,
39
+ StateCorruption = 10,
40
+ InsufficientBalance = 11,
41
+ InsufficientMargin = 12,
42
+ UnauthorizedRelayer = 13,
43
+ WithdrawalNotFound = 14,
44
+ WithdrawalAlreadyProcessed = 15,
45
+ DuplicateDeposit = 16,
46
+ InvalidSignature = 17,
47
+ SignatureRequired = 18,
48
+ AgentNotAuthorized = 19,
49
+ AgentCannotWithdraw = 20,
50
+ /** Timestamp nonce failed replay-window validation. Named `InvalidNonce` to
51
+ * match the engine `ExecError` variant and the Rust/Python bindings. */
52
+ InvalidNonce = 21,
53
+ MarketAlreadyExists = 22,
54
+ InvalidMarketConfig = 23,
55
+ ImpactMarketAlreadyExists = 24,
56
+ ImpactMarketNotFound = 25,
57
+ MarketClosedForTrading = 26,
58
+ BinaryPriceOutOfRange = 27,
59
+ InvalidResolution = 28,
60
+ PositionLimitExceeded = 29,
61
+ OracleTimestampNotMonotonic = 30,
62
+ TooManyActiveImpactMarkets = 31,
63
+ SettlementPriceMismatch = 32,
64
+ OracleNotApplicable = 33,
65
+ PostOnlyWouldCross = 34,
66
+ ReduceOnlyWouldIncrease = 35,
67
+ TestActionRejected = 36,
68
+ StaleOracle = 37,
69
+ UserLeverageBelowMarketIm = 38,
70
+ TickSizeViolation = 39,
71
+ LotSizeViolation = 40,
72
+ OracleStaleNotElapsed = 41,
73
+ FeeBpsOutOfRange = 42,
74
+ FeeOverrideStaleSeq = 43,
75
+ ClientOrderIdNotFound = 44,
76
+ DuplicateClientOrderId = 45,
77
+ InvalidClientOrderId = 46,
78
+ FillOrKillWouldNotFill = 47,
79
+ InvalidCancelReplaceTarget = 48,
80
+ AmendBelowFilled = 49,
81
+ /**
82
+ * New engines use code 50 for AtomicBasketOrder `SlippageExceeded`. During
83
+ * the rolling upgrade, legacy engines may still emit code 50 for
84
+ * `OpenInterestLimitExceeded`, so pass the canonical DeliverTx log to
85
+ * {@link decodeExecError}. Without a recognized log the decoder returns
86
+ * `AmbiguousCode50`, never a guessed classification.
87
+ */
88
+ SlippageExceeded = 50,
89
+ /** Distinct open-interest-cap rejection emitted by upgraded engines. */
90
+ OpenInterestLimitExceeded = 51,
91
+ /** Admin governance action submitted while no signer registry exists. */
92
+ AdminGovernanceInactive = 52,
93
+ /** Signer is not the declared admin actor / not in the signer registry. */
94
+ NotAdminSigner = 53,
95
+ ProposalNotFound = 54,
96
+ ProposalNotPending = 55,
97
+ ProposalExpired = 56,
98
+ DuplicateApproval = 57,
99
+ DuplicateRejection = 58,
100
+ ProposalRegistryVersionMismatch = 59,
101
+ ProposalContentMismatch = 60,
102
+ InvalidAdminAction = 61,
103
+ AdminActionTooLarge = 62,
104
+ TooManyPendingProposals = 63,
105
+ ProposalIdExhausted = 64,
106
+ ConflictingVote = 65,
107
+ MarketIdOutOfRange = 66,
108
+ EmergencyRateLimited = 67,
109
+ EmergencyGlobalRateLimited = 68,
110
+ EmergencyActionRetired = 69,
111
+ AdminActionRequiresProposal = 70,
112
+ InvalidAdminRegistry = 71,
113
+ InternalError = 255
114
+ }
115
+ export declare function decodeExecError(code: number, log?: string): ExecErrorInfo | null;
116
+ /**
117
+ * Returns just the variant name for a code, or `"UnknownError"` if the
118
+ * code isn't in the table. Useful when you want to log a stable error
119
+ * tag without rendering the full description.
120
+ */
121
+ export declare function execErrorName(code: number, log?: string): string;
122
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,aAAa;IAC5B,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb;uDACmD;IACnD,WAAW,EAAE,MAAM,C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AK;IACvB,eAAe,KAAK;IACpB,iBAAiB,KAAK;IACtB,kBAAkB,KAAK;IACvB,+BAA+B,KAAK;IACpC,uBAAuB,KAAK;IAC5B,kBAAkB,KAAK;IACvB,mBAAmB,KAAK;IACxB,uBAAuB,KAAK;IAC5B,mBAAmB,KAAK;IACxB,eAAe,KAAK;IACpB,kBAAkB,KAAK;IACvB,oBAAoB,KAAK;IACzB,0BAA0B,KAAK;IAC/B,sBAAsB,KAAK;IAC3B,2BAA2B,KAAK;IAChC,oBAAoB,KAAK;IACzB,aAAa,MAAM;CACpB;AAqTD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX,aAAa,GAAG,IAAI,CAYtB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhE"}
package/dist/errors.js ADDED
@@ -0,0 +1,397 @@
1
+ /**
2
+ * Decoder for engine `ExecError` codes returned in `TxResult.code`.
3
+ *
4
+ * The Rust enum lives at `exchange-wire/src/types.rs::ExecError`. Codes
5
+ * are stable wire-format identifiers — adding a new variant goes at the
6
+ * end with the next free integer. **Keep this map in sync with that
7
+ * `code()` impl** (CI flags drift in the audit `api-drift` lane).
8
+ *
9
+ * Use `decodeExecError(code, log)` to translate a `TxResult.code` into a
10
+ * structured `{ name, description }`. UI can render `name` directly
11
+ * (machine-readable) or `description` (human-readable). Code `0` is
12
+ * success and returns `null` from this decoder — call sites should
13
+ * branch on `code === 0` first.
14
+ */
15
+ /**
16
+ * Named engine `ExecError` codes — the machine-readable half of the {@link TABLE}
17
+ * below, so callers can branch on `code === ExecErrorCode.InsufficientMargin`
18
+ * instead of a bare `12`. Values are the stable wire codes; names mirror the
19
+ * Rust `ExecError` variants. `errors.test.ts` asserts this enum and `TABLE`
20
+ * stay in agreement.
21
+ */
22
+ export var ExecErrorCode;
23
+ (function (ExecErrorCode) {
24
+ ExecErrorCode[ExecErrorCode["DecodeError"] = 1] = "DecodeError";
25
+ ExecErrorCode[ExecErrorCode["OrderNotFound"] = 2] = "OrderNotFound";
26
+ ExecErrorCode[ExecErrorCode["NotOwner"] = 3] = "NotOwner";
27
+ ExecErrorCode[ExecErrorCode["UnauthorizedOracle"] = 4] = "UnauthorizedOracle";
28
+ ExecErrorCode[ExecErrorCode["Overflow"] = 5] = "Overflow";
29
+ ExecErrorCode[ExecErrorCode["InvalidPrice"] = 6] = "InvalidPrice";
30
+ ExecErrorCode[ExecErrorCode["InvalidQuantity"] = 7] = "InvalidQuantity";
31
+ ExecErrorCode[ExecErrorCode["InvalidSide"] = 8] = "InvalidSide";
32
+ ExecErrorCode[ExecErrorCode["UnknownMarket"] = 9] = "UnknownMarket";
33
+ ExecErrorCode[ExecErrorCode["StateCorruption"] = 10] = "StateCorruption";
34
+ ExecErrorCode[ExecErrorCode["InsufficientBalance"] = 11] = "InsufficientBalance";
35
+ ExecErrorCode[ExecErrorCode["InsufficientMargin"] = 12] = "InsufficientMargin";
36
+ ExecErrorCode[ExecErrorCode["UnauthorizedRelayer"] = 13] = "UnauthorizedRelayer";
37
+ ExecErrorCode[ExecErrorCode["WithdrawalNotFound"] = 14] = "WithdrawalNotFound";
38
+ ExecErrorCode[ExecErrorCode["WithdrawalAlreadyProcessed"] = 15] = "WithdrawalAlreadyProcessed";
39
+ ExecErrorCode[ExecErrorCode["DuplicateDeposit"] = 16] = "DuplicateDeposit";
40
+ ExecErrorCode[ExecErrorCode["InvalidSignature"] = 17] = "InvalidSignature";
41
+ ExecErrorCode[ExecErrorCode["SignatureRequired"] = 18] = "SignatureRequired";
42
+ ExecErrorCode[ExecErrorCode["AgentNotAuthorized"] = 19] = "AgentNotAuthorized";
43
+ ExecErrorCode[ExecErrorCode["AgentCannotWithdraw"] = 20] = "AgentCannotWithdraw";
44
+ /** Timestamp nonce failed replay-window validation. Named `InvalidNonce` to
45
+ * match the engine `ExecError` variant and the Rust/Python bindings. */
46
+ ExecErrorCode[ExecErrorCode["InvalidNonce"] = 21] = "InvalidNonce";
47
+ ExecErrorCode[ExecErrorCode["MarketAlreadyExists"] = 22] = "MarketAlreadyExists";
48
+ ExecErrorCode[ExecErrorCode["InvalidMarketConfig"] = 23] = "InvalidMarketConfig";
49
+ ExecErrorCode[ExecErrorCode["ImpactMarketAlreadyExists"] = 24] = "ImpactMarketAlreadyExists";
50
+ ExecErrorCode[ExecErrorCode["ImpactMarketNotFound"] = 25] = "ImpactMarketNotFound";
51
+ ExecErrorCode[ExecErrorCode["MarketClosedForTrading"] = 26] = "MarketClosedForTrading";
52
+ ExecErrorCode[ExecErrorCode["BinaryPriceOutOfRange"] = 27] = "BinaryPriceOutOfRange";
53
+ ExecErrorCode[ExecErrorCode["InvalidResolution"] = 28] = "InvalidResolution";
54
+ ExecErrorCode[ExecErrorCode["PositionLimitExceeded"] = 29] = "PositionLimitExceeded";
55
+ ExecErrorCode[ExecErrorCode["OracleTimestampNotMonotonic"] = 30] = "OracleTimestampNotMonotonic";
56
+ ExecErrorCode[ExecErrorCode["TooManyActiveImpactMarkets"] = 31] = "TooManyActiveImpactMarkets";
57
+ ExecErrorCode[ExecErrorCode["SettlementPriceMismatch"] = 32] = "SettlementPriceMismatch";
58
+ ExecErrorCode[ExecErrorCode["OracleNotApplicable"] = 33] = "OracleNotApplicable";
59
+ ExecErrorCode[ExecErrorCode["PostOnlyWouldCross"] = 34] = "PostOnlyWouldCross";
60
+ ExecErrorCode[ExecErrorCode["ReduceOnlyWouldIncrease"] = 35] = "ReduceOnlyWouldIncrease";
61
+ ExecErrorCode[ExecErrorCode["TestActionRejected"] = 36] = "TestActionRejected";
62
+ ExecErrorCode[ExecErrorCode["StaleOracle"] = 37] = "StaleOracle";
63
+ ExecErrorCode[ExecErrorCode["UserLeverageBelowMarketIm"] = 38] = "UserLeverageBelowMarketIm";
64
+ ExecErrorCode[ExecErrorCode["TickSizeViolation"] = 39] = "TickSizeViolation";
65
+ ExecErrorCode[ExecErrorCode["LotSizeViolation"] = 40] = "LotSizeViolation";
66
+ ExecErrorCode[ExecErrorCode["OracleStaleNotElapsed"] = 41] = "OracleStaleNotElapsed";
67
+ ExecErrorCode[ExecErrorCode["FeeBpsOutOfRange"] = 42] = "FeeBpsOutOfRange";
68
+ ExecErrorCode[ExecErrorCode["FeeOverrideStaleSeq"] = 43] = "FeeOverrideStaleSeq";
69
+ ExecErrorCode[ExecErrorCode["ClientOrderIdNotFound"] = 44] = "ClientOrderIdNotFound";
70
+ ExecErrorCode[ExecErrorCode["DuplicateClientOrderId"] = 45] = "DuplicateClientOrderId";
71
+ ExecErrorCode[ExecErrorCode["InvalidClientOrderId"] = 46] = "InvalidClientOrderId";
72
+ ExecErrorCode[ExecErrorCode["FillOrKillWouldNotFill"] = 47] = "FillOrKillWouldNotFill";
73
+ ExecErrorCode[ExecErrorCode["InvalidCancelReplaceTarget"] = 48] = "InvalidCancelReplaceTarget";
74
+ ExecErrorCode[ExecErrorCode["AmendBelowFilled"] = 49] = "AmendBelowFilled";
75
+ /**
76
+ * New engines use code 50 for AtomicBasketOrder `SlippageExceeded`. During
77
+ * the rolling upgrade, legacy engines may still emit code 50 for
78
+ * `OpenInterestLimitExceeded`, so pass the canonical DeliverTx log to
79
+ * {@link decodeExecError}. Without a recognized log the decoder returns
80
+ * `AmbiguousCode50`, never a guessed classification.
81
+ */
82
+ ExecErrorCode[ExecErrorCode["SlippageExceeded"] = 50] = "SlippageExceeded";
83
+ /** Distinct open-interest-cap rejection emitted by upgraded engines. */
84
+ ExecErrorCode[ExecErrorCode["OpenInterestLimitExceeded"] = 51] = "OpenInterestLimitExceeded";
85
+ /** Admin governance action submitted while no signer registry exists. */
86
+ ExecErrorCode[ExecErrorCode["AdminGovernanceInactive"] = 52] = "AdminGovernanceInactive";
87
+ /** Signer is not the declared admin actor / not in the signer registry. */
88
+ ExecErrorCode[ExecErrorCode["NotAdminSigner"] = 53] = "NotAdminSigner";
89
+ // Proposal-lifecycle family (multisig governance), mirrored from the engine
90
+ // ExecError codes 54-71. Decode-only: emitted by the propose/approve/reject
91
+ // and emergency admin paths.
92
+ ExecErrorCode[ExecErrorCode["ProposalNotFound"] = 54] = "ProposalNotFound";
93
+ ExecErrorCode[ExecErrorCode["ProposalNotPending"] = 55] = "ProposalNotPending";
94
+ ExecErrorCode[ExecErrorCode["ProposalExpired"] = 56] = "ProposalExpired";
95
+ ExecErrorCode[ExecErrorCode["DuplicateApproval"] = 57] = "DuplicateApproval";
96
+ ExecErrorCode[ExecErrorCode["DuplicateRejection"] = 58] = "DuplicateRejection";
97
+ ExecErrorCode[ExecErrorCode["ProposalRegistryVersionMismatch"] = 59] = "ProposalRegistryVersionMismatch";
98
+ ExecErrorCode[ExecErrorCode["ProposalContentMismatch"] = 60] = "ProposalContentMismatch";
99
+ ExecErrorCode[ExecErrorCode["InvalidAdminAction"] = 61] = "InvalidAdminAction";
100
+ ExecErrorCode[ExecErrorCode["AdminActionTooLarge"] = 62] = "AdminActionTooLarge";
101
+ ExecErrorCode[ExecErrorCode["TooManyPendingProposals"] = 63] = "TooManyPendingProposals";
102
+ ExecErrorCode[ExecErrorCode["ProposalIdExhausted"] = 64] = "ProposalIdExhausted";
103
+ ExecErrorCode[ExecErrorCode["ConflictingVote"] = 65] = "ConflictingVote";
104
+ ExecErrorCode[ExecErrorCode["MarketIdOutOfRange"] = 66] = "MarketIdOutOfRange";
105
+ ExecErrorCode[ExecErrorCode["EmergencyRateLimited"] = 67] = "EmergencyRateLimited";
106
+ ExecErrorCode[ExecErrorCode["EmergencyGlobalRateLimited"] = 68] = "EmergencyGlobalRateLimited";
107
+ ExecErrorCode[ExecErrorCode["EmergencyActionRetired"] = 69] = "EmergencyActionRetired";
108
+ ExecErrorCode[ExecErrorCode["AdminActionRequiresProposal"] = 70] = "AdminActionRequiresProposal";
109
+ ExecErrorCode[ExecErrorCode["InvalidAdminRegistry"] = 71] = "InvalidAdminRegistry";
110
+ ExecErrorCode[ExecErrorCode["InternalError"] = 255] = "InternalError";
111
+ })(ExecErrorCode || (ExecErrorCode = {}));
112
+ const OPEN_INTEREST_LIMIT_EXCEEDED = {
113
+ name: "OpenInterestLimitExceeded",
114
+ description: "fill would push aggregate market open interest past MarketConfig.maxOpenInterest",
115
+ };
116
+ const SLIPPAGE_EXCEEDED = {
117
+ name: "SlippageExceeded",
118
+ description: "atomic basket aggregate slippage exceeded the submitted maxSlippageBps budget",
119
+ };
120
+ const TABLE = {
121
+ 1: { name: "DecodeError", description: "transaction decode error" },
122
+ 2: { name: "OrderNotFound", description: "order not found" },
123
+ 3: { name: "NotOwner", description: "not the owner of the order" },
124
+ 4: { name: "UnauthorizedOracle", description: "unauthorized oracle signer" },
125
+ 5: { name: "Overflow", description: "arithmetic overflow" },
126
+ 6: { name: "InvalidPrice", description: "invalid price" },
127
+ 7: { name: "InvalidQuantity", description: "invalid quantity" },
128
+ 8: { name: "InvalidSide", description: "invalid side" },
129
+ 9: { name: "UnknownMarket", description: "unknown market" },
130
+ 10: { name: "StateCorruption", description: "engine state corruption" },
131
+ 11: { name: "InsufficientBalance", description: "insufficient balance" },
132
+ 12: {
133
+ name: "InsufficientMargin",
134
+ description: "post-trade equity below initial margin requirement",
135
+ },
136
+ 13: {
137
+ name: "UnauthorizedRelayer",
138
+ description: "unauthorized relayer signer",
139
+ },
140
+ 14: { name: "WithdrawalNotFound", description: "withdrawal not found" },
141
+ 15: {
142
+ name: "WithdrawalAlreadyProcessed",
143
+ description: "withdrawal already processed",
144
+ },
145
+ 16: {
146
+ name: "DuplicateDeposit",
147
+ description: "duplicate deposit signature (replay protection)",
148
+ },
149
+ 17: { name: "InvalidSignature", description: "invalid Ed25519 signature" },
150
+ 18: {
151
+ name: "SignatureRequired",
152
+ description: "signed (V2) envelope required",
153
+ },
154
+ 19: {
155
+ name: "AgentNotAuthorized",
156
+ description: "signer is not the owner or an authorized agent",
157
+ },
158
+ 20: {
159
+ name: "AgentCannotWithdraw",
160
+ description: "agent wallets cannot perform withdrawals",
161
+ },
162
+ 21: {
163
+ name: "InvalidNonce",
164
+ description: "timestamp nonce failed replay-window validation — sign a fresh envelope",
165
+ },
166
+ 22: { name: "MarketAlreadyExists", description: "market already exists" },
167
+ 23: {
168
+ name: "InvalidMarketConfig",
169
+ description: "invalid market configuration",
170
+ },
171
+ 24: {
172
+ name: "ImpactMarketAlreadyExists",
173
+ description: "impact market already exists",
174
+ },
175
+ 25: { name: "ImpactMarketNotFound", description: "impact market not found" },
176
+ 26: {
177
+ name: "MarketClosedForTrading",
178
+ description: "order on a CP/binary book whose parent impact market is resolved or voided",
179
+ },
180
+ 27: {
181
+ name: "BinaryPriceOutOfRange",
182
+ description: "prediction-binary order price outside the [0, 1_000_000] (= $1) range",
183
+ },
184
+ 28: {
185
+ name: "InvalidResolution",
186
+ description: "ResolveEvent rejected — invalid outcome for current state",
187
+ },
188
+ 29: {
189
+ name: "PositionLimitExceeded",
190
+ description: "fill would push the taker's net position past MarketConfig.max_position_size",
191
+ },
192
+ 30: {
193
+ name: "OracleTimestampNotMonotonic",
194
+ description: "OracleUpdate publish_time_ms must be strictly greater than the last accepted update (audit B3)",
195
+ },
196
+ 31: {
197
+ name: "TooManyActiveImpactMarkets",
198
+ description: "account would touch more impact markets than the scenario margin engine can enumerate (cap = 4)",
199
+ },
200
+ 32: {
201
+ name: "SettlementPriceMismatch",
202
+ description: "net-delta margin grouping found legs of the same group with disagreeing settle prices (upstream data corruption)",
203
+ },
204
+ 33: {
205
+ name: "OracleNotApplicable",
206
+ description: "OracleUpdate targets a market kind that doesn't take oracle prices (impact-family children mark off the book)",
207
+ },
208
+ 34: {
209
+ name: "PostOnlyWouldCross",
210
+ description: "post-only order would have crossed the book — rejected to preserve maker semantics",
211
+ },
212
+ 35: {
213
+ name: "ReduceOnlyWouldIncrease",
214
+ description: "reduce-only order would have increased the position rather than reducing it",
215
+ },
216
+ 36: {
217
+ name: "TestActionRejected",
218
+ description: "test/admin action rejected (unauthorized signer or engine not configured to accept them)",
219
+ },
220
+ 37: {
221
+ name: "StaleOracle",
222
+ description: "oracle for this market is older than MarketConfig.mark_price_max_oracle_age_ms; order placement, margin, and liquidation refuse to use a stale oracle (BE-33)",
223
+ },
224
+ 38: {
225
+ name: "UserLeverageBelowMarketIm",
226
+ description: "SetUserMarketLeverage rejected: user_im_bps below market.im_bps. The engine only allows users to deleverage (more margin), never the other direction (BE-16)",
227
+ },
228
+ 39: {
229
+ name: "TickSizeViolation",
230
+ description: "PlaceOrder price is not a multiple of MarketConfig.tickSize (BE-48)",
231
+ },
232
+ 40: {
233
+ name: "LotSizeViolation",
234
+ description: "PlaceOrder/MarketOrder quantity is not a multiple of MarketConfig.lotSize (BE-48)",
235
+ },
236
+ 41: {
237
+ name: "OracleStaleNotElapsed",
238
+ description: "fallback oracle signer published before the primary's staleness window elapsed (BE-50)",
239
+ },
240
+ 42: {
241
+ name: "FeeBpsOutOfRange",
242
+ description: "fee bps value outside the [0, 10_000] basis-point range",
243
+ },
244
+ 43: {
245
+ name: "FeeOverrideStaleSeq",
246
+ description: "fee override rejected — seq not strictly greater than last accepted",
247
+ },
248
+ 44: {
249
+ name: "ClientOrderIdNotFound",
250
+ description: "cancel-by-client-order-id rejected because no active resting order exists for that owner/clientOrderId pair",
251
+ },
252
+ 45: {
253
+ name: "DuplicateClientOrderId",
254
+ description: "place order rejected because an active resting order already uses that owner/clientOrderId pair",
255
+ },
256
+ 46: {
257
+ name: "InvalidClientOrderId",
258
+ description: "clientOrderId 0 is reserved for absent IDs in exchange events; submit a positive 64-bit value",
259
+ },
260
+ 47: {
261
+ name: "FillOrKillWouldNotFill",
262
+ description: "FOK place order rejected because visible crossing liquidity could not fill the whole order immediately",
263
+ },
264
+ 48: {
265
+ name: "InvalidCancelReplaceTarget",
266
+ description: "cancel-replace rejected because exactly one of cancelOrderId or cancelClientOrderId must be supplied",
267
+ },
268
+ 49: {
269
+ name: "AmendBelowFilled",
270
+ description: "amended total quantity is below the quantity already filled while the order rested",
271
+ },
272
+ 51: OPEN_INTEREST_LIMIT_EXCEEDED,
273
+ 52: {
274
+ name: "AdminGovernanceInactive",
275
+ description: "admin governance action submitted while no admin signer registry exists on this chain; multisig administration is inactive and every governance path fails closed",
276
+ },
277
+ 53: {
278
+ name: "NotAdminSigner",
279
+ description: "tx signer does not match the action's declared proposer/approver/rejecter/signer field, or is not a member of the current admin signer registry",
280
+ },
281
+ 54: {
282
+ name: "ProposalNotFound",
283
+ description: "no admin proposal exists under this id (never created, or pruned from terminal retention)",
284
+ },
285
+ 55: {
286
+ name: "ProposalNotPending",
287
+ description: "the admin proposal is already terminal — votes are only accepted while pending",
288
+ },
289
+ 56: {
290
+ name: "ProposalExpired",
291
+ description: "the admin proposal passed its TTL — re-propose and collect fresh approvals",
292
+ },
293
+ 57: {
294
+ name: "DuplicateApproval",
295
+ description: "this signer already approved the proposal (the proposer approves at creation)",
296
+ },
297
+ 58: {
298
+ name: "DuplicateRejection",
299
+ description: "this signer already rejected the proposal",
300
+ },
301
+ 59: {
302
+ name: "ProposalRegistryVersionMismatch",
303
+ description: "registry version differs from the current signer registry — re-read and re-sign",
304
+ },
305
+ 60: {
306
+ name: "ProposalContentMismatch",
307
+ description: "approval context does not byte-match the stored proposal — rebuild from the proposals query",
308
+ },
309
+ 61: {
310
+ name: "InvalidAdminAction",
311
+ description: "inner admin/emergency action is invalid: unknown or not-admitted arm, non-zero inner signer, or out-of-bounds field",
312
+ },
313
+ 62: {
314
+ name: "AdminActionTooLarge",
315
+ description: "canonical inner action bytes exceed MAX_ADMIN_ACTION_BYTES",
316
+ },
317
+ 63: {
318
+ name: "TooManyPendingProposals",
319
+ description: "MAX_PENDING_PROPOSALS admin proposals are already pending",
320
+ },
321
+ 64: {
322
+ name: "ProposalIdExhausted",
323
+ description: "a governance id counter is exhausted; ids never wrap",
324
+ },
325
+ 65: {
326
+ name: "ConflictingVote",
327
+ description: "the opposite vote already exists — votes are immutable and disjoint",
328
+ },
329
+ 66: {
330
+ name: "MarketIdOutOfRange",
331
+ description: "market id exceeds the signed-32-bit identity bound (i32::MAX)",
332
+ },
333
+ 67: {
334
+ name: "EmergencyRateLimited",
335
+ description: "per-signer emergency action bound reached within the rolling window",
336
+ },
337
+ 68: {
338
+ name: "EmergencyGlobalRateLimited",
339
+ description: "chain-wide emergency action bound reached within the rolling window",
340
+ },
341
+ 69: {
342
+ name: "EmergencyActionRetired",
343
+ description: "this emergency arm was retired; new submissions fail closed",
344
+ },
345
+ 70: {
346
+ name: "AdminActionRequiresProposal",
347
+ description: "the signer registry exists — this admin action is proposal-only, even for an authorized relayer",
348
+ },
349
+ 71: {
350
+ name: "InvalidAdminRegistry",
351
+ description: "proposed signer roster violates the registry invariants (threshold bounds, sorted unique members, roster size, version headroom)",
352
+ },
353
+ 255: { name: "InternalError", description: "unexpected runtime failure" },
354
+ };
355
+ /**
356
+ * Translate a `TxResult.code` to the corresponding `ExecError` variant
357
+ * info. Returns `null` for code 0 (success) or codes that have no entry
358
+ * in the table (treat as unknown).
359
+ *
360
+ * Example:
361
+ * const r = await client.placeOrder(...);
362
+ * if (r.code !== 0) {
363
+ * const err = decodeExecError(r.code, r.log);
364
+ * console.error(`${err?.name ?? "Unknown"} (code ${r.code}): ${err?.description ?? r.log}`);
365
+ * }
366
+ */
367
+ const OPEN_INTEREST_LOG_PREFIX = "open interest limit exceeded on market ";
368
+ const SLIPPAGE_LOG_PREFIX = "atomic basket aggregate slippage ";
369
+ const AMBIGUOUS_CODE_50 = {
370
+ name: "AmbiguousCode50",
371
+ description: "during the rolling upgrade, engine code 50 may mean legacy OpenInterestLimitExceeded or current SlippageExceeded; a canonical non-empty DeliverTx log is required to classify it safely",
372
+ };
373
+ export function decodeExecError(code, log) {
374
+ if (code === 0)
375
+ return null;
376
+ if (code === 50) {
377
+ if (log?.startsWith(OPEN_INTEREST_LOG_PREFIX)) {
378
+ return OPEN_INTEREST_LIMIT_EXCEEDED;
379
+ }
380
+ if (log?.startsWith(SLIPPAGE_LOG_PREFIX)) {
381
+ return SLIPPAGE_EXCEEDED;
382
+ }
383
+ return AMBIGUOUS_CODE_50;
384
+ }
385
+ return TABLE[code] ?? null;
386
+ }
387
+ /**
388
+ * Returns just the variant name for a code, or `"UnknownError"` if the
389
+ * code isn't in the table. Useful when you want to log a stable error
390
+ * tag without rendering the full description.
391
+ */
392
+ export function execErrorName(code, log) {
393
+ if (code === 0)
394
+ return "Ok";
395
+ return decodeExecError(code, log)?.name ?? "UnknownError";
396
+ }
397
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAwFX;AAxFD,WAAY,aAAa;IACvB,+DAAe,CAAA;IACf,mEAAiB,CAAA;IACjB,yDAAY,CAAA;IACZ,6EAAsB,CAAA;IACtB,yDAAY,CAAA;IACZ,iEAAgB,CAAA;IAChB,uEAAmB,CAAA;IACnB,+DAAe,CAAA;IACf,mEAAiB,CAAA;IACjB,wEAAoB,CAAA;IACpB,gFAAwB,CAAA;IACxB,8EAAuB,CAAA;IACvB,gFAAwB,CAAA;IACxB,8EAAuB,CAAA;IACvB,8FAA+B,CAAA;IAC/B,0EAAqB,CAAA;IACrB,0EAAqB,CAAA;IACrB,4EAAsB,CAAA;IACtB,8EAAuB,CAAA;IACvB,gFAAwB,CAAA;IACxB;6EACyE;IACzE,kEAAiB,CAAA;IACjB,gFAAwB,CAAA;IACxB,gFAAwB,CAAA;IACxB,4FAA8B,CAAA;IAC9B,kFAAyB,CAAA;IACzB,sFAA2B,CAAA;IAC3B,oFAA0B,CAAA;IAC1B,4EAAsB,CAAA;IACtB,oFAA0B,CAAA;IAC1B,gGAAgC,CAAA;IAChC,8FAA+B,CAAA;IAC/B,wFAA4B,CAAA;IAC5B,gFAAwB,CAAA;IACxB,8EAAuB,CAAA;IACvB,wFAA4B,CAAA;IAC5B,8EAAuB,CAAA;IACvB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KAC3E;IACD,EAAE,EAAE;QACF,IAAI,EAAE,6BAA6B;QACnC,WAAW,EACT,iGAAiG;KACpG;IACD,EAAE,EAAE;QACF,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,kIAAkI;KACrI;IACD,GAAG,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,4BAA4B,EAAE;CAC1E,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,wBAAwB,GAAG,yCAAyC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,mCAAmC,CAAC;AAEhE,MAAM,iBAAiB,GAAkB;IACvC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,yLAAyL;CAC5L,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,GAAY;IAEZ,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,IAAI,GAAG,EAAE,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAC9C,OAAO,4BAA4B,CAAC;QACtC,CAAC;QACD,IAAI,GAAG,EAAE,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACzC,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,GAAY;IACtD,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,IAAI,cAAc,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { AdminAction, AdminSignerRegistry, EventOracleSource, ImpactMarketInfo, ProposalPage, ProposalDisplayInfo, ProposalStatus } from "./types.js";
2
+ /** `Option<EventOracleSource>`: `None` is nil (fact 4), the unit variant is a
3
+ * bare string (fact 2), the struct variants are single-entry maps with
4
+ * positional payloads (fact 3). Fails closed on an unknown variant — a
5
+ * resolution mode this build cannot name must never render as one it can.
6
+ * Exported for the client's impact-market read, which carries the same
7
+ * enum in the same compact-rmp form. */
8
+ export declare function decodeOracleSource(value: unknown, field: string): EventOracleSource | undefined;
9
+ /**
10
+ * One `ImpactMarketDisplayInfo` row from `GET /v1/impact_markets` /
11
+ * `/v1/impact_market/{id}` (exchange-core/src/query.rs), as the engine's
12
+ * positional array: 12 required slots, plus trailers shipped incrementally —
13
+ * [12] `oracleSource` (BE-54), [13] `description` and [14] `rules`
14
+ * (admin-actions v2). Older gateways serve shorter tuples; missing trailers
15
+ * stay `undefined` so callers can tell "not served" from "empty". Anything
16
+ * outside the supported 12–15 shapes — including trailing fields — is a
17
+ * refusal, same fail-closed posture as every decoder in this file.
18
+ */
19
+ export declare function decodeImpactMarketInfo(value: unknown, index?: number): ImpactMarketInfo;
20
+ /** The typed inner operation a proposal carries. Fails closed on an unknown
21
+ * variant: an SDK build that does not know an operation must never let a
22
+ * caller render or approve it as though it did. */
23
+ export declare function decodeAdminAction(value: unknown, field?: string): AdminAction;
24
+ /** Proposal status. Unit variants are strings, payload variants are
25
+ * single-entry maps whose payload is a positional array (facts 2 and 3). */
26
+ export declare function decodeProposalStatus(value: unknown, field?: string): ProposalStatus;
27
+ /**
28
+ * One proposal, as the engine shapes it for display and offline
29
+ * verification (`ProposalDisplayInfo`). `actionCanonicalBytes` is the EXACT
30
+ * stored payload the content hash covers — an approving signer rebuilds
31
+ * their approval from these fields rather than trusting anything a UI
32
+ * rendered, so every field is decoded, none are skipped.
33
+ */
34
+ export declare function decodeProposalDisplayInfo(raw: unknown[], index?: number): ProposalDisplayInfo;
35
+ /**
36
+ * The installed signer registry, or `null` when none is seeded.
37
+ *
38
+ * `null` means admin multisig is INACTIVE (fail-closed), which is not the
39
+ * same as an empty roster — callers must treat the two differently, so this
40
+ * takes the already-unwrapped `Option` payload from the client.
41
+ */
42
+ export declare function decodeAdminSignerRegistry(raw: unknown): AdminSignerRegistry | null;
43
+ /** Decode the engine's one-field `AdminSignerRegistryInfo` envelope. */
44
+ export declare function decodeAdminSignerRegistryInfo(raw: unknown): AdminSignerRegistry | null;
45
+ /** Decode and validate the engine's two-field proposal-page envelope. */
46
+ export declare function decodeProposalPage(raw: unknown): ProposalPage;
47
+ //# sourceMappingURL=governance-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance-query.d.ts","sourceRoot":"","sources":["../src/governance-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAGX,mBAAmB,EAGnB,iBAAiB,EAEjB,gBAAgB,EAGhB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EAGf,MAAM,YAAY,CAAC;AA4NpB;;;;;yCAKyC;AACzC,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,iBAAiB,GAAG,SAAS,CA2B/B;AAqCD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,KAAK,CAAC,EAAE,MAAM,GACb,gBAAgB,CAwBlB;AA4HD;;oDAEoD;AACpD,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,KAAK,SAAW,GACf,WAAW,CA4Cb;AAED;6EAC6E;AAC7E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,KAAK,SAAW,GACf,cAAc,CAuChB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EAAE,EACd,KAAK,CAAC,EAAE,MAAM,GACb,mBAAmB,CAuCrB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,GACX,mBAAmB,GAAG,IAAI,CAU5B;AAED,wEAAwE;AACxE,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,OAAO,GACX,mBAAmB,GAAG,IAAI,CAG5B;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAc7D"}