@symmio/trading-core 0.2.0 → 1.0.1

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 (37) hide show
  1. package/README.md +2 -2
  2. package/dist/core/config/create-config.d.ts +47 -4
  3. package/dist/core/config/create-config.d.ts.map +1 -1
  4. package/dist/core/config/create-config.js +25 -22
  5. package/dist/core/config/create-config.js.map +1 -1
  6. package/dist/index.d.ts +3 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +142 -138
  9. package/dist/solvers/estimated-price/get-estimated-price.d.ts +58 -0
  10. package/dist/solvers/estimated-price/get-estimated-price.d.ts.map +1 -0
  11. package/dist/solvers/estimated-price/get-estimated-price.js +30 -0
  12. package/dist/solvers/estimated-price/get-estimated-price.js.map +1 -0
  13. package/dist/solvers/estimated-price/index.d.ts +5 -0
  14. package/dist/solvers/estimated-price/index.d.ts.map +1 -0
  15. package/dist/solvers/estimated-price/price-impact.d.ts +25 -0
  16. package/dist/solvers/estimated-price/price-impact.d.ts.map +1 -0
  17. package/dist/solvers/estimated-price/price-impact.js +9 -0
  18. package/dist/solvers/estimated-price/price-impact.js.map +1 -0
  19. package/dist/solvers/estimated-price/query.d.ts +26 -0
  20. package/dist/solvers/estimated-price/query.d.ts.map +1 -0
  21. package/dist/solvers/estimated-price/query.js +28 -0
  22. package/dist/solvers/estimated-price/query.js.map +1 -0
  23. package/dist/solvers/estimated-price/to-estimated-price.d.ts +9 -0
  24. package/dist/solvers/estimated-price/to-estimated-price.d.ts.map +1 -0
  25. package/dist/solvers/estimated-price/to-estimated-price.js +8 -0
  26. package/dist/solvers/estimated-price/to-estimated-price.js.map +1 -0
  27. package/dist/solvers/instant-open/shared/trade-math.d.ts +48 -0
  28. package/dist/solvers/instant-open/shared/trade-math.d.ts.map +1 -1
  29. package/dist/solvers/instant-open/shared/trade-math.js +5 -1
  30. package/dist/solvers/instant-open/shared/trade-math.js.map +1 -1
  31. package/dist/solvers/types/generated/enigma-solver.js +11 -5
  32. package/dist/solvers/types/generated/enigma-solver.js.map +1 -1
  33. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts-addresses.d.ts +1 -1
  34. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts-addresses.js.map +1 -1
  35. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts.d.ts +1 -1
  36. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts.js.map +1 -1
  37. package/package.json +7 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/estimated-price/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAE/B,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEhE,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,2BAA2B,GAAG,kBAAkB,CAAC,2DAE3G;AAED,oEAAoE;AACpE,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErF,iEAAiE;AACjE,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,2BAA2B,GACzB,cAAc,CAAC,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACjG,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,6BAA6B,GAAG,kBAAkB,CAC5D,qBAAqB,EACrB,KAAK,EACL,qBAAqB,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,GAChC,6BAA6B,CAkB/B"}
@@ -0,0 +1,28 @@
1
+ import { filterQueryOptions as e } from "../../shared/utils/query.js";
2
+ import { getEstimatedPrice as t } from "./get-estimated-price.js";
3
+ //#region src/solvers/estimated-price/query.ts
4
+ function n(t) {
5
+ return ["getEstimatedPrice", e(t)];
6
+ }
7
+ function r(e, r) {
8
+ return {
9
+ ...r.query,
10
+ queryKey: n({
11
+ ...r,
12
+ configKey: e.getChainConfigKey(r.chainId)
13
+ }),
14
+ enabled: (r.query?.enabled ?? !0) && r.quantity.length > 0 && r.price.length > 0,
15
+ queryFn: () => t(e, {
16
+ chainId: r.chainId,
17
+ symbolId: r.symbolId,
18
+ quantity: r.quantity,
19
+ positionType: r.positionType,
20
+ entry: r.entry,
21
+ price: r.price
22
+ })
23
+ };
24
+ }
25
+ //#endregion
26
+ export { n as getEstimatedPriceQueryKey, r as getEstimatedPriceQueryOptions };
27
+
28
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/estimated-price/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getEstimatedPrice,\n type GetEstimatedPriceParameters,\n type GetEstimatedPriceReturnType,\n} from \"./get-estimated-price\";\n\n/** Data resolved by the {@link getEstimatedPriceQueryOptions} query. */\nexport type GetEstimatedPriceData = GetEstimatedPriceReturnType;\n\n/** Build the TanStack Query key for {@link getEstimatedPriceQueryOptions}. */\nexport function getEstimatedPriceQueryKey(options: Compute<GetEstimatedPriceParameters & ConfigKeyParameter>) {\n return [\"getEstimatedPrice\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getEstimatedPriceQueryKey}. */\nexport type GetEstimatedPriceQueryKey = ReturnType<typeof getEstimatedPriceQueryKey>;\n\n/** Options accepted by {@link getEstimatedPriceQueryOptions}. */\nexport type GetEstimatedPriceOptions = Compute<\n GetEstimatedPriceParameters &\n QueryParameter<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getEstimatedPriceQueryOptions}. */\nexport type GetEstimatedPriceQueryOptions = SymmioQueryOptions<\n GetEstimatedPriceData,\n Error,\n GetEstimatedPriceData,\n GetEstimatedPriceQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getEstimatedPrice}. Disabled until\n * `quantity` and `price` are non-empty, so the estimate does not fire on partial\n * input.\n *\n * @example\n * ```ts\n * useQuery(getEstimatedPriceQueryOptions(config, { symbolId, quantity, positionType, entry: \"open\", price }));\n * ```\n */\nexport function getEstimatedPriceQueryOptions(\n config: Config,\n options: GetEstimatedPriceOptions,\n): GetEstimatedPriceQueryOptions {\n return {\n ...options.query,\n queryKey: getEstimatedPriceQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: (options.query?.enabled ?? true) && options.quantity.length > 0 && options.price.length > 0,\n queryFn: () =>\n getEstimatedPrice(config, {\n chainId: options.chainId,\n symbolId: options.symbolId,\n quantity: options.quantity,\n positionType: options.positionType,\n entry: options.entry,\n price: options.price,\n }),\n };\n}\n"],"mappings":";;;AAcA,SAAgB,EAA0B,GAAoE;CAC5G,OAAO,CAAC,qBAAqB,EAAmB,CAAO,CAAC;AAC1D;AA6BA,SAAgB,EACd,GACA,GAC+B;CAC/B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA0B;GAClC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,SAAS,SAAS,KAAK,EAAQ,MAAM,SAAS;EACnG,eACE,EAAkB,GAAQ;GACxB,SAAS,EAAQ;GACjB,UAAU,EAAQ;GAClB,UAAU,EAAQ;GAClB,cAAc,EAAQ;GACtB,OAAO,EAAQ;GACf,OAAO,EAAQ;EACjB,CAAC;CACL;AACF"}
@@ -0,0 +1,9 @@
1
+ import { ApiGetEstimatedPriceResponse } from '../types/generated/enigma-solver.js';
2
+ import { GetEstimatedPriceReturnType } from './get-estimated-price.js';
3
+ /**
4
+ * Map the generated `ApiGetEstimatedPriceResponse` into the SDK's
5
+ * {@link GetEstimatedPriceReturnType}. A missing / empty `price` defaults to
6
+ * `"0"`.
7
+ */
8
+ export declare function toEstimatedPrice(raw: ApiGetEstimatedPriceResponse): GetEstimatedPriceReturnType;
9
+ //# sourceMappingURL=to-estimated-price.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-estimated-price.d.ts","sourceRoot":"","sources":["../../../src/solvers/estimated-price/to-estimated-price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEzE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,4BAA4B,GAAG,2BAA2B,CAE/F"}
@@ -0,0 +1,8 @@
1
+ //#region src/solvers/estimated-price/to-estimated-price.ts
2
+ function e(e) {
3
+ return { estimatedPrice: typeof e.price == "string" && e.price.length > 0 ? e.price : "0" };
4
+ }
5
+ //#endregion
6
+ export { e as toEstimatedPrice };
7
+
8
+ //# sourceMappingURL=to-estimated-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-estimated-price.js","names":[],"sources":["../../../src/solvers/estimated-price/to-estimated-price.ts"],"sourcesContent":["import type { ApiGetEstimatedPriceResponse } from \"../types/generated/enigma-solver\";\nimport type { GetEstimatedPriceReturnType } from \"./get-estimated-price\";\n\n/**\n * Map the generated `ApiGetEstimatedPriceResponse` into the SDK's\n * {@link GetEstimatedPriceReturnType}. A missing / empty `price` defaults to\n * `\"0\"`.\n */\nexport function toEstimatedPrice(raw: ApiGetEstimatedPriceResponse): GetEstimatedPriceReturnType {\n return { estimatedPrice: typeof raw.price === \"string\" && raw.price.length > 0 ? raw.price : \"0\" };\n}\n"],"mappings":";AAQA,SAAgB,EAAiB,GAAgE;CAC/F,OAAO,EAAE,gBAAgB,OAAO,EAAI,SAAU,YAAY,EAAI,MAAM,SAAS,IAAI,EAAI,QAAQ,IAAI;AACnG"}
@@ -142,4 +142,52 @@ export declare function computePlatformFee(rates: ComputePlatformFeeRates, initi
142
142
  * the wei value as `bigint` (truncated, no rounding) suitable for contract calls.
143
143
  */
144
144
  export declare function toWeiBigInt(value: string): bigint;
145
+ /**
146
+ * Inputs for {@link calculateAvailableInstantOpenMargin}. All amounts are
147
+ * 18-decimal wei / fixed-point.
148
+ */
149
+ export interface CalculateAvailableInstantOpenMarginParameters {
150
+ /** SubAccount available (deallocated) balance from `getAccountBalanceOf`; 1e18-scaled. */
151
+ balance: bigint;
152
+ /** Open fee rate (18-decimal fixed-point) from `getFeeForUser`. */
153
+ openFee: bigint;
154
+ /** Close fee rate (18-decimal fixed-point) from `getFeeForUser`. */
155
+ closeFee: bigint;
156
+ /** Slippage as an 18-decimal fraction (5% → `5n * 10n ** 16n`). */
157
+ slippageFractionWei: bigint;
158
+ /** Requested leverage (integer ≥ 1). */
159
+ leverage: number;
160
+ /** LONG skips the slippage cap; SHORT applies it. */
161
+ positionType: PositionType;
162
+ }
163
+ /**
164
+ * Maximum initial margin an instant open can spend. Shaves the raw available
165
+ * balance for fees (both sides, charged on the leveraged notional) and — for
166
+ * SHORT only — a worst-case slippage-fill buffer. Pure `bigint`; clamps to `0n`.
167
+ *
168
+ * ```text
169
+ * available = balance
170
+ * × max(0, 1 − slippageFactor) // SHORT: slippage, LONG: 0
171
+ * × max(0, 1 − leverage × (openFee + closeFee))
172
+ * ```
173
+ *
174
+ * A SHORT sizes quantity off `requestOpenPrice = markPrice × (1 − s)` (below
175
+ * mark), so a worse fill inflates notional by up to `1 / (1 − s)`; capping usable
176
+ * balance at `balance × (1 − s)` covers it. A LONG sets the request above mark,
177
+ * so fills deflate notional and need no cap.
178
+ *
179
+ * @returns spendable margin in 18-decimal wei.
180
+ * @example
181
+ * ```ts
182
+ * const max = calculateAvailableInstantOpenMargin({
183
+ * balance,
184
+ * openFee,
185
+ * closeFee,
186
+ * slippageFractionWei: 5n * 10n ** 16n, // 5%
187
+ * leverage: 10,
188
+ * positionType: PositionType.SHORT,
189
+ * });
190
+ * ```
191
+ */
192
+ export declare function calculateAvailableInstantOpenMargin(parameters: CalculateAvailableInstantOpenMarginParameters): bigint;
145
193
  //# sourceMappingURL=trade-math.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trade-math.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/shared/trade-math.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"trade-math.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/shared/trade-math.ts"],"names":[],"mappings":"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"}
@@ -36,7 +36,11 @@ function c(e, t, n) {
36
36
  function l(e) {
37
37
  return BigInt(n(e).toFixed(0, t.ROUND_DOWN));
38
38
  }
39
+ function u(t) {
40
+ let { balance: n, openFee: r, closeFee: i, slippageFractionWei: a, leverage: o, positionType: s } = t, c = 10n ** 18n, l = s === e.SHORT ? a >= c ? 0n : c - a : c, u = BigInt(o) * (r + i), d = u >= c ? 0n : c - u;
41
+ return n * l / c * d / c;
42
+ }
39
43
  //#endregion
40
- export { i as MARKET_ORDER_DEADLINE_SECONDS, s as calculateMargin, o as calculateTradeParams, c as computePlatformFee, a as getMarketOrderDeadline, l as toWeiBigInt };
44
+ export { i as MARKET_ORDER_DEADLINE_SECONDS, u as calculateAvailableInstantOpenMargin, s as calculateMargin, o as calculateTradeParams, c as computePlatformFee, a as getMarketOrderDeadline, l as toWeiBigInt };
41
45
 
42
46
  //# sourceMappingURL=trade-math.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trade-math.js","names":[],"sources":["../../../../src/solvers/instant-open/shared/trade-math.ts"],"sourcesContent":["import { parseEther, RoundingMode, toDecimal } from \"@symmio/utils/decimal\";\nimport { PositionType } from \"./types\";\n\n/**\n * Unix-seconds remaining for a MARKET-order deadline (5 minutes).\n */\nexport const MARKET_ORDER_DEADLINE_SECONDS = 300n;\n\n/**\n * Compute a unix-seconds `deadline` for a MARKET order.\n *\n * @param now - Optional override for `Math.floor(Date.now() / 1000)`. Useful for tests.\n */\nexport function getMarketOrderDeadline(now?: bigint): bigint {\n const base = now ?? BigInt(Math.floor(Date.now() / 1000));\n return base + MARKET_ORDER_DEADLINE_SECONDS;\n}\n\n/**\n * Parameters for {@link calculateTradeParams}.\n */\nexport interface CalculateTradeParamsParameters {\n /** Mark price as decimal string (e.g. `\"50123.45\"`). */\n markPrice: string;\n /** Slippage percent (e.g. `5` for 5%). */\n slippage: number;\n /** Position side: `\"LONG\"` or `\"SHORT\"`. */\n positionType: PositionType;\n /** User input as decimal string. Interpreted as collateral when `inputField === \"PRICE\"`. */\n userInput: string;\n /** Input mode. `\"PRICE\"` = userInput is USD collateral; `\"TOKEN\"` = userInput is base token amount. */\n inputField: \"PRICE\" | \"TOKEN\";\n /** Position leverage (integer ≥ 1). */\n leverage: number;\n /** Price precision (decimals). */\n pricePrecision: number;\n /** Quantity precision (decimals). */\n quantityPrecision: number;\n /** Solver locked-param percentages (e.g. `\"0.02\"` for 2%). */\n cvaPercent?: string;\n /** Solver locked-param percentages (e.g. `\"0.01\"` for 1%). */\n lfPercent?: string;\n /** Solver locked-param percentages. */\n partyAmmPercent?: string;\n /** Solver locked-param percentages. */\n partyBmmPercent?: string;\n}\n\n/**\n * Return type of {@link calculateTradeParams}.\n *\n * All values are decimal strings. Convert to 18-decimal `bigint` with\n * `parseEther(...).toFixed(0)` (or {@link toWeiBigInt}) before passing to a\n * contract call.\n */\nexport interface CalculateTradeParamsReturnType {\n /** Open price with slippage applied, trimmed to `pricePrecision`. */\n requestedOpenPrice: string;\n /** Base quantity (no leverage), trimmed to `quantityPrecision`. */\n quantityBasic: string;\n /** Leveraged quantity (`quantityBasic × leverage`), trimmed to `quantityPrecision`. */\n quantity: string;\n /** Base notional (`quantityBasic × requestedOpenPrice`). */\n notionalBasic: string;\n /** Leveraged notional (`notionalBasic × leverage`). */\n notional: string;\n /** CVA locked margin (`notionalBasic × cvaPercent / 100`). */\n cva: string;\n /** LF locked margin (`notionalBasic × lfPercent / 100`). */\n lf: string;\n /** PartyA maintenance margin. */\n partyAmm: string;\n /** PartyB maintenance margin. */\n partyBmm: string;\n}\n\n/**\n * Pure trade-parameters calculator for lowcap MARKET orders.\n *\n * Steps:\n * 1. `requestedOpenPrice = markPrice × (1 ± slippage/100)` trimmed to `pricePrecision`.\n * 2. `quantityBasic = userInput / requestedOpenPrice` (when `inputField === \"PRICE\"`) or\n * `userInput` (when `inputField === \"TOKEN\"`) trimmed to `quantityPrecision`.\n * 3. `notionalBasic = quantityBasic × requestedOpenPrice`.\n * 4. `cva / lf / partyAmm / partyBmm = notionalBasic × percent / 100`.\n * 5. `quantity = quantityBasic × leverage` trimmed to `quantityPrecision`.\n * 6. `notional = notionalBasic × leverage`.\n *\n * @returns `null` when `markPrice` is zero/NaN or `userInput` is invalid.\n */\nexport function calculateTradeParams(\n parameters: CalculateTradeParamsParameters,\n): CalculateTradeParamsReturnType | null {\n const {\n markPrice,\n slippage,\n positionType,\n userInput,\n inputField,\n leverage,\n pricePrecision,\n quantityPrecision,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n partyBmmPercent,\n } = parameters;\n\n const markPriceDec = toDecimal(markPrice);\n if (markPriceDec.isZero() || markPriceDec.isNaN()) return null;\n const userInputDec = toDecimal(userInput);\n if (userInputDec.isZero() || userInputDec.isNaN()) return null;\n\n const signedSlippage = positionType === PositionType.SHORT ? slippage : -slippage;\n const slippageFactor = toDecimal(100 - signedSlippage).div(100);\n const requestedOpenPrice = markPriceDec.times(slippageFactor).toFixed(pricePrecision, RoundingMode.ROUND_DOWN);\n\n const quantityBasic =\n inputField === \"PRICE\"\n ? userInputDec.div(requestedOpenPrice).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN)\n : userInputDec.toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n\n const notionalBasic = toDecimal(quantityBasic).times(requestedOpenPrice).toString();\n const cva = toDecimal(notionalBasic).times(toDecimal(cvaPercent)).div(100).toString();\n const lf = toDecimal(notionalBasic).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmm = toDecimal(notionalBasic).times(toDecimal(partyAmmPercent)).div(100).toString();\n const partyBmm = toDecimal(notionalBasic).times(toDecimal(partyBmmPercent)).div(100).toString();\n\n const quantity = toDecimal(quantityBasic).times(leverage).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n const notional = toDecimal(notionalBasic).times(leverage).toString();\n\n return {\n requestedOpenPrice,\n quantityBasic,\n quantity,\n notionalBasic,\n notional,\n cva,\n lf,\n partyAmm,\n partyBmm,\n };\n}\n\n/**\n * Parameters for {@link calculateMargin}.\n */\nexport interface CalculateMarginParameters {\n /** Position side. */\n positionType: PositionType;\n /** Mark price (decimal string). */\n markPrice: string;\n /** Base quantity from {@link calculateTradeParams}. */\n quantityBasic: string;\n /** CVA from {@link calculateTradeParams}. */\n cva: string;\n /** LF from {@link calculateTradeParams}. */\n lf: string;\n /** PartyA maintenance margin from {@link calculateTradeParams}. */\n partyAmm: string;\n /** Solver locked-param percents (passed when recomputing for SHORT). */\n cvaPercent?: string;\n /** Solver locked-param percents. */\n lfPercent?: string;\n /** Solver locked-param percents. */\n partyAmmPercent?: string;\n /** On-chain platform fee as decimal string (from {@link computePlatformFee}). */\n platformFee: string;\n}\n\n/**\n * Compute the `addMargin` amount for lowcap isolation.\n *\n * - **LONG**: `margin = cva + lf + partyAmm + platformFee`.\n * - **SHORT**: recompute the locked values at `markPrice`,\n * then sum + `platformFee`.\n *\n * @returns Margin as decimal string.\n */\nexport function calculateMargin(parameters: CalculateMarginParameters): string {\n const {\n positionType,\n markPrice,\n quantityBasic,\n cva,\n lf,\n partyAmm,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n platformFee,\n } = parameters;\n\n if (positionType === PositionType.LONG) {\n return toDecimal(cva).plus(lf).plus(partyAmm).plus(platformFee).toString();\n }\n\n const marginPrice = toDecimal(markPrice);\n const notionalBasicMargin = toDecimal(quantityBasic).times(marginPrice).toString();\n const cvaMargin = toDecimal(notionalBasicMargin).times(toDecimal(cvaPercent)).div(100).toString();\n const lfMargin = toDecimal(notionalBasicMargin).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmmMargin = toDecimal(notionalBasicMargin).times(toDecimal(partyAmmPercent)).div(100).toString();\n\n return toDecimal(cvaMargin).plus(lfMargin).plus(partyAmmMargin).plus(platformFee).toString();\n}\n\n/**\n * On-chain `getFeeForUser` result, in 18-decimal fixed-point.\n */\nexport interface ComputePlatformFeeRates {\n /** Open fee rate as 18-decimal `bigint`. */\n openFee: bigint;\n /** Close fee rate as 18-decimal `bigint`. */\n closeFee: bigint;\n}\n\n/**\n * Compute the total platform fee for an open + close round trip.\n *\n * `(openFee × initialNotional + closeFee × closeNotional) / 1e18`.\n *\n * @param rates - Fee rates from `getFeeForUser`.\n * @param initialNotional - Notional at open, decimal string.\n * @param closeNotional - Notional at close, decimal string.\n * @returns Total fee as decimal string.\n */\nexport function computePlatformFee(\n rates: ComputePlatformFeeRates,\n initialNotional: string,\n closeNotional: string,\n): string {\n const open = toDecimal(rates.openFee.toString()).times(initialNotional);\n const close = toDecimal(rates.closeFee.toString()).times(closeNotional);\n return open.plus(close).div(toDecimal(\"1e18\")).toString();\n}\n\n/**\n * Convert a decimal string to an 18-decimal-fixed-point `bigint`.\n *\n * Wrapper over `parseEther` from `@symmio/utils/decimal` that returns\n * the wei value as `bigint` (truncated, no rounding) suitable for contract calls.\n */\nexport function toWeiBigInt(value: string): bigint {\n return BigInt(parseEther(value).toFixed(0, RoundingMode.ROUND_DOWN));\n}\n"],"mappings":";;;AAMA,IAAa,IAAgC;AAO7C,SAAgB,EAAuB,GAAsB;CAE3D,QADa,KAAO,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,CAAC,KAC1C;AAChB;AA0EA,SAAgB,EACd,GACuC;CACvC,IAAM,EACJ,cACA,aACA,iBACA,cACA,eACA,aACA,mBACA,sBACA,eACA,cACA,oBACA,uBACE,GAEE,IAAe,EAAU,CAAS;CACxC,IAAI,EAAa,OAAO,KAAK,EAAa,MAAM,GAAG,OAAO;CAC1D,IAAM,IAAe,EAAU,CAAS;CACxC,IAAI,EAAa,OAAO,KAAK,EAAa,MAAM,GAAG,OAAO;CAG1D,IAAM,IAAiB,EAAU,OADV,MAAiB,EAAa,QAAQ,IAAW,CAAC,EACpB,EAAE,IAAI,GAAG,GACxD,IAAqB,EAAa,MAAM,CAAc,EAAE,QAAQ,GAAgB,EAAa,UAAU,GAEvG,IACJ,MAAe,UACX,EAAa,IAAI,CAAkB,EAAE,QAAQ,GAAmB,EAAa,UAAU,IACvF,EAAa,QAAQ,GAAmB,EAAa,UAAU,GAE/D,IAAgB,EAAU,CAAa,EAAE,MAAM,CAAkB,EAAE,SAAS,GAC5E,IAAM,EAAU,CAAa,EAAE,MAAM,EAAU,CAAU,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS,GAC9E,IAAK,EAAU,CAAa,EAAE,MAAM,EAAU,CAAS,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS,GAC5E,IAAW,EAAU,CAAa,EAAE,MAAM,EAAU,CAAe,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS,GACxF,IAAW,EAAU,CAAa,EAAE,MAAM,EAAU,CAAe,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;CAK9F,OAAO;EACL;EACA;EACA,UANe,EAAU,CAAa,EAAE,MAAM,CAAQ,EAAE,QAAQ,GAAmB,EAAa,UAMhG;EACA;EACA,UAPe,EAAU,CAAa,EAAE,MAAM,CAAQ,EAAE,SAOxD;EACA;EACA;EACA;EACA;CACF;AACF;AAqCA,SAAgB,EAAgB,GAA+C;CAC7E,IAAM,EACJ,iBACA,cACA,kBACA,QACA,OACA,aACA,eACA,cACA,oBACA,mBACE;CAEJ,IAAI,MAAiB,EAAa,MAChC,OAAO,EAAU,CAAG,EAAE,KAAK,CAAE,EAAE,KAAK,CAAQ,EAAE,KAAK,CAAW,EAAE,SAAS;CAG3E,IAAM,IAAc,EAAU,CAAS,GACjC,IAAsB,EAAU,CAAa,EAAE,MAAM,CAAW,EAAE,SAAS,GAC3E,IAAY,EAAU,CAAmB,EAAE,MAAM,EAAU,CAAU,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS,GAC1F,IAAW,EAAU,CAAmB,EAAE,MAAM,EAAU,CAAS,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS,GACxF,IAAiB,EAAU,CAAmB,EAAE,MAAM,EAAU,CAAe,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;CAE1G,OAAO,EAAU,CAAS,EAAE,KAAK,CAAQ,EAAE,KAAK,CAAc,EAAE,KAAK,CAAW,EAAE,SAAS;AAC7F;AAsBA,SAAgB,EACd,GACA,GACA,GACQ;CACR,IAAM,IAAO,EAAU,EAAM,QAAQ,SAAS,CAAC,EAAE,MAAM,CAAe,GAChE,IAAQ,EAAU,EAAM,SAAS,SAAS,CAAC,EAAE,MAAM,CAAa;CACtE,OAAO,EAAK,KAAK,CAAK,EAAE,IAAI,EAAU,MAAM,CAAC,EAAE,SAAS;AAC1D;AAQA,SAAgB,EAAY,GAAuB;CACjD,OAAO,OAAO,EAAW,CAAK,EAAE,QAAQ,GAAG,EAAa,UAAU,CAAC;AACrE"}
1
+ {"version":3,"file":"trade-math.js","names":[],"sources":["../../../../src/solvers/instant-open/shared/trade-math.ts"],"sourcesContent":["import { parseEther, RoundingMode, toDecimal } from \"@symmio/utils/decimal\";\nimport { PositionType } from \"./types\";\n\n/**\n * Unix-seconds remaining for a MARKET-order deadline (5 minutes).\n */\nexport const MARKET_ORDER_DEADLINE_SECONDS = 300n;\n\n/**\n * Compute a unix-seconds `deadline` for a MARKET order.\n *\n * @param now - Optional override for `Math.floor(Date.now() / 1000)`. Useful for tests.\n */\nexport function getMarketOrderDeadline(now?: bigint): bigint {\n const base = now ?? BigInt(Math.floor(Date.now() / 1000));\n return base + MARKET_ORDER_DEADLINE_SECONDS;\n}\n\n/**\n * Parameters for {@link calculateTradeParams}.\n */\nexport interface CalculateTradeParamsParameters {\n /** Mark price as decimal string (e.g. `\"50123.45\"`). */\n markPrice: string;\n /** Slippage percent (e.g. `5` for 5%). */\n slippage: number;\n /** Position side: `\"LONG\"` or `\"SHORT\"`. */\n positionType: PositionType;\n /** User input as decimal string. Interpreted as collateral when `inputField === \"PRICE\"`. */\n userInput: string;\n /** Input mode. `\"PRICE\"` = userInput is USD collateral; `\"TOKEN\"` = userInput is base token amount. */\n inputField: \"PRICE\" | \"TOKEN\";\n /** Position leverage (integer ≥ 1). */\n leverage: number;\n /** Price precision (decimals). */\n pricePrecision: number;\n /** Quantity precision (decimals). */\n quantityPrecision: number;\n /** Solver locked-param percentages (e.g. `\"0.02\"` for 2%). */\n cvaPercent?: string;\n /** Solver locked-param percentages (e.g. `\"0.01\"` for 1%). */\n lfPercent?: string;\n /** Solver locked-param percentages. */\n partyAmmPercent?: string;\n /** Solver locked-param percentages. */\n partyBmmPercent?: string;\n}\n\n/**\n * Return type of {@link calculateTradeParams}.\n *\n * All values are decimal strings. Convert to 18-decimal `bigint` with\n * `parseEther(...).toFixed(0)` (or {@link toWeiBigInt}) before passing to a\n * contract call.\n */\nexport interface CalculateTradeParamsReturnType {\n /** Open price with slippage applied, trimmed to `pricePrecision`. */\n requestedOpenPrice: string;\n /** Base quantity (no leverage), trimmed to `quantityPrecision`. */\n quantityBasic: string;\n /** Leveraged quantity (`quantityBasic × leverage`), trimmed to `quantityPrecision`. */\n quantity: string;\n /** Base notional (`quantityBasic × requestedOpenPrice`). */\n notionalBasic: string;\n /** Leveraged notional (`notionalBasic × leverage`). */\n notional: string;\n /** CVA locked margin (`notionalBasic × cvaPercent / 100`). */\n cva: string;\n /** LF locked margin (`notionalBasic × lfPercent / 100`). */\n lf: string;\n /** PartyA maintenance margin. */\n partyAmm: string;\n /** PartyB maintenance margin. */\n partyBmm: string;\n}\n\n/**\n * Pure trade-parameters calculator for lowcap MARKET orders.\n *\n * Steps:\n * 1. `requestedOpenPrice = markPrice × (1 ± slippage/100)` trimmed to `pricePrecision`.\n * 2. `quantityBasic = userInput / requestedOpenPrice` (when `inputField === \"PRICE\"`) or\n * `userInput` (when `inputField === \"TOKEN\"`) trimmed to `quantityPrecision`.\n * 3. `notionalBasic = quantityBasic × requestedOpenPrice`.\n * 4. `cva / lf / partyAmm / partyBmm = notionalBasic × percent / 100`.\n * 5. `quantity = quantityBasic × leverage` trimmed to `quantityPrecision`.\n * 6. `notional = notionalBasic × leverage`.\n *\n * @returns `null` when `markPrice` is zero/NaN or `userInput` is invalid.\n */\nexport function calculateTradeParams(\n parameters: CalculateTradeParamsParameters,\n): CalculateTradeParamsReturnType | null {\n const {\n markPrice,\n slippage,\n positionType,\n userInput,\n inputField,\n leverage,\n pricePrecision,\n quantityPrecision,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n partyBmmPercent,\n } = parameters;\n\n const markPriceDec = toDecimal(markPrice);\n if (markPriceDec.isZero() || markPriceDec.isNaN()) return null;\n const userInputDec = toDecimal(userInput);\n if (userInputDec.isZero() || userInputDec.isNaN()) return null;\n\n const signedSlippage = positionType === PositionType.SHORT ? slippage : -slippage;\n const slippageFactor = toDecimal(100 - signedSlippage).div(100);\n const requestedOpenPrice = markPriceDec.times(slippageFactor).toFixed(pricePrecision, RoundingMode.ROUND_DOWN);\n\n const quantityBasic =\n inputField === \"PRICE\"\n ? userInputDec.div(requestedOpenPrice).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN)\n : userInputDec.toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n\n const notionalBasic = toDecimal(quantityBasic).times(requestedOpenPrice).toString();\n const cva = toDecimal(notionalBasic).times(toDecimal(cvaPercent)).div(100).toString();\n const lf = toDecimal(notionalBasic).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmm = toDecimal(notionalBasic).times(toDecimal(partyAmmPercent)).div(100).toString();\n const partyBmm = toDecimal(notionalBasic).times(toDecimal(partyBmmPercent)).div(100).toString();\n\n const quantity = toDecimal(quantityBasic).times(leverage).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n const notional = toDecimal(notionalBasic).times(leverage).toString();\n\n return {\n requestedOpenPrice,\n quantityBasic,\n quantity,\n notionalBasic,\n notional,\n cva,\n lf,\n partyAmm,\n partyBmm,\n };\n}\n\n/**\n * Parameters for {@link calculateMargin}.\n */\nexport interface CalculateMarginParameters {\n /** Position side. */\n positionType: PositionType;\n /** Mark price (decimal string). */\n markPrice: string;\n /** Base quantity from {@link calculateTradeParams}. */\n quantityBasic: string;\n /** CVA from {@link calculateTradeParams}. */\n cva: string;\n /** LF from {@link calculateTradeParams}. */\n lf: string;\n /** PartyA maintenance margin from {@link calculateTradeParams}. */\n partyAmm: string;\n /** Solver locked-param percents (passed when recomputing for SHORT). */\n cvaPercent?: string;\n /** Solver locked-param percents. */\n lfPercent?: string;\n /** Solver locked-param percents. */\n partyAmmPercent?: string;\n /** On-chain platform fee as decimal string (from {@link computePlatformFee}). */\n platformFee: string;\n}\n\n/**\n * Compute the `addMargin` amount for lowcap isolation.\n *\n * - **LONG**: `margin = cva + lf + partyAmm + platformFee`.\n * - **SHORT**: recompute the locked values at `markPrice`,\n * then sum + `platformFee`.\n *\n * @returns Margin as decimal string.\n */\nexport function calculateMargin(parameters: CalculateMarginParameters): string {\n const {\n positionType,\n markPrice,\n quantityBasic,\n cva,\n lf,\n partyAmm,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n platformFee,\n } = parameters;\n\n if (positionType === PositionType.LONG) {\n return toDecimal(cva).plus(lf).plus(partyAmm).plus(platformFee).toString();\n }\n\n const marginPrice = toDecimal(markPrice);\n const notionalBasicMargin = toDecimal(quantityBasic).times(marginPrice).toString();\n const cvaMargin = toDecimal(notionalBasicMargin).times(toDecimal(cvaPercent)).div(100).toString();\n const lfMargin = toDecimal(notionalBasicMargin).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmmMargin = toDecimal(notionalBasicMargin).times(toDecimal(partyAmmPercent)).div(100).toString();\n\n return toDecimal(cvaMargin).plus(lfMargin).plus(partyAmmMargin).plus(platformFee).toString();\n}\n\n/**\n * On-chain `getFeeForUser` result, in 18-decimal fixed-point.\n */\nexport interface ComputePlatformFeeRates {\n /** Open fee rate as 18-decimal `bigint`. */\n openFee: bigint;\n /** Close fee rate as 18-decimal `bigint`. */\n closeFee: bigint;\n}\n\n/**\n * Compute the total platform fee for an open + close round trip.\n *\n * `(openFee × initialNotional + closeFee × closeNotional) / 1e18`.\n *\n * @param rates - Fee rates from `getFeeForUser`.\n * @param initialNotional - Notional at open, decimal string.\n * @param closeNotional - Notional at close, decimal string.\n * @returns Total fee as decimal string.\n */\nexport function computePlatformFee(\n rates: ComputePlatformFeeRates,\n initialNotional: string,\n closeNotional: string,\n): string {\n const open = toDecimal(rates.openFee.toString()).times(initialNotional);\n const close = toDecimal(rates.closeFee.toString()).times(closeNotional);\n return open.plus(close).div(toDecimal(\"1e18\")).toString();\n}\n\n/**\n * Convert a decimal string to an 18-decimal-fixed-point `bigint`.\n *\n * Wrapper over `parseEther` from `@symmio/utils/decimal` that returns\n * the wei value as `bigint` (truncated, no rounding) suitable for contract calls.\n */\nexport function toWeiBigInt(value: string): bigint {\n return BigInt(parseEther(value).toFixed(0, RoundingMode.ROUND_DOWN));\n}\n\n/**\n * Inputs for {@link calculateAvailableInstantOpenMargin}. All amounts are\n * 18-decimal wei / fixed-point.\n */\nexport interface CalculateAvailableInstantOpenMarginParameters {\n /** SubAccount available (deallocated) balance from `getAccountBalanceOf`; 1e18-scaled. */\n balance: bigint;\n /** Open fee rate (18-decimal fixed-point) from `getFeeForUser`. */\n openFee: bigint;\n /** Close fee rate (18-decimal fixed-point) from `getFeeForUser`. */\n closeFee: bigint;\n /** Slippage as an 18-decimal fraction (5% → `5n * 10n ** 16n`). */\n slippageFractionWei: bigint;\n /** Requested leverage (integer ≥ 1). */\n leverage: number;\n /** LONG skips the slippage cap; SHORT applies it. */\n positionType: PositionType;\n}\n\n/**\n * Maximum initial margin an instant open can spend. Shaves the raw available\n * balance for fees (both sides, charged on the leveraged notional) and — for\n * SHORT only — a worst-case slippage-fill buffer. Pure `bigint`; clamps to `0n`.\n *\n * ```text\n * available = balance\n * × max(0, 1 − slippageFactor) // SHORT: slippage, LONG: 0\n * × max(0, 1 − leverage × (openFee + closeFee))\n * ```\n *\n * A SHORT sizes quantity off `requestOpenPrice = markPrice × (1 − s)` (below\n * mark), so a worse fill inflates notional by up to `1 / (1 − s)`; capping usable\n * balance at `balance × (1 − s)` covers it. A LONG sets the request above mark,\n * so fills deflate notional and need no cap.\n *\n * @returns spendable margin in 18-decimal wei.\n * @example\n * ```ts\n * const max = calculateAvailableInstantOpenMargin({\n * balance,\n * openFee,\n * closeFee,\n * slippageFractionWei: 5n * 10n ** 16n, // 5%\n * leverage: 10,\n * positionType: PositionType.SHORT,\n * });\n * ```\n */\nexport function calculateAvailableInstantOpenMargin(parameters: CalculateAvailableInstantOpenMarginParameters): bigint {\n const { balance, openFee, closeFee, slippageFractionWei, leverage, positionType } = parameters;\n const ONE_E18 = 10n ** 18n;\n\n const slippageMultiplier =\n positionType === PositionType.SHORT\n ? slippageFractionWei >= ONE_E18\n ? 0n\n : ONE_E18 - slippageFractionWei\n : ONE_E18;\n\n const leverageScaled = BigInt(leverage) * (openFee + closeFee);\n const feeMultiplier = leverageScaled >= ONE_E18 ? 0n : ONE_E18 - leverageScaled;\n\n const afterSlippage = (balance * slippageMultiplier) / ONE_E18;\n return (afterSlippage * feeMultiplier) / ONE_E18;\n}\n"],"mappings":"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"}
@@ -1,25 +1,31 @@
1
1
  import e from "axios";
2
2
  //#region src/solvers/types/generated/enigma-solver.ts
3
- var t = (t) => e.get("/contract-symbols", t), n = (t) => e.get("/error_codes", t), r = (t, n) => e.get("/get_funding_info", {
3
+ var t = (t) => e.get("/contract-symbols", t), n = (t) => e.get("/error_codes", t), r = (t, n) => e.get("/estimated-price", {
4
4
  ...n,
5
5
  params: {
6
6
  ...t,
7
7
  ...n?.params
8
8
  }
9
- }), i = (t, n, r) => e.get(`/get_locked_params/${t}`, {
9
+ }), i = (t, n) => e.get("/get_funding_info", {
10
+ ...n,
11
+ params: {
12
+ ...t,
13
+ ...n?.params
14
+ }
15
+ }), a = (t, n, r) => e.get(`/get_locked_params/${t}`, {
10
16
  ...r,
11
17
  params: {
12
18
  ...n,
13
19
  ...r?.params
14
20
  }
15
- }), a = (t) => e.get("/get_market_info", t), o = (t, n) => e.get(`/instant_close/${t}`, n), s = (t, n) => e.get(`/instant_open/${t}`, n), c = (t, n) => e.get(`/instant_quote_id/${t}`, n), l = (t, n) => e.post("/instant_trade/instant_close", t, n), u = (t, n) => e.post("/instant_trade/instant_open", t, n), d = (t, n) => e.get("/notional_cap", {
21
+ }), o = (t) => e.get("/get_market_info", t), s = (t, n) => e.get(`/instant_close/${t}`, n), c = (t, n) => e.get(`/instant_open/${t}`, n), l = (t, n) => e.get(`/instant_quote_id/${t}`, n), u = (t, n) => e.post("/instant_trade/instant_close", t, n), d = (t, n) => e.post("/instant_trade/instant_open", t, n), f = (t, n) => e.get("/notional_cap", {
16
22
  ...n,
17
23
  params: {
18
24
  ...t,
19
25
  ...n?.params
20
26
  }
21
- }), f = (t, n) => e.get(`/notional_cap/${t}`, n);
27
+ }), p = (t, n) => e.get(`/notional_cap/${t}`, n);
22
28
  //#endregion
23
- export { t as getContractSymbols, n as getErrorCodes, r as getGetFundingInfo, i as getGetLockedParamsSymbol, a as getGetMarketInfo, o as getInstantCloseAccountAddress, s as getInstantOpenAccountAddress, c as getInstantQuoteIdTempQuoteId, d as getNotionalCap, f as getNotionalCapSymbolId, l as postInstantTradeInstantClose, u as postInstantTradeInstantOpen };
29
+ export { t as getContractSymbols, n as getErrorCodes, r as getEstimatedPrice, i as getGetFundingInfo, a as getGetLockedParamsSymbol, o as getGetMarketInfo, s as getInstantCloseAccountAddress, c as getInstantOpenAccountAddress, l as getInstantQuoteIdTempQuoteId, f as getNotionalCap, p as getNotionalCapSymbolId, u as postInstantTradeInstantClose, d as postInstantTradeInstantOpen };
24
30
 
25
31
  //# sourceMappingURL=enigma-solver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enigma-solver.js","names":[],"sources":["../../../../src/solvers/types/generated/enigma-solver.ts"],"sourcesContent":["/**\n * Generated by orval v8.14.0 🍺\n * Do not edit manually.\n * Low Cap Solver API\n * API for Low Cap Solver trading system\n * OpenAPI spec version: 1.0\n */\nimport type { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport axios from \"axios\";\n\nexport interface SymbolContractSymbol {\n asset?: string;\n funding_rate_epoch_duration?: string;\n funding_rate_window_time?: string;\n hedger_fee_close?: string;\n hedger_fee_open?: string;\n is_valid?: boolean;\n lot_size?: string;\n max_funding_rate?: string;\n max_leverage?: string;\n max_notional_value?: number;\n max_quantity?: string;\n min_acceptable_portion_lf?: string;\n min_acceptable_quote_value?: string;\n min_notional_value?: string;\n name?: string;\n price_precision?: number;\n quantity_precision?: number;\n rfq_allowed?: boolean;\n /** \"all\", \"long\", or \"short\" */\n side?: string;\n /** 0: Disabled, 1: Close only, 2: Open only, 3: Fully enabled */\n state?: number;\n symbol?: string;\n symbol_id?: number;\n /** From price service GetSymbolsInfo */\n token_address?: string;\n trading_fee?: string;\n}\n\nexport interface ApiContractSymbolsResponse {\n count?: number;\n symbols?: SymbolContractSymbol[];\n}\n\nexport type ApiCustomTableDataItem = { [key: string]: unknown };\n\nexport interface ApiCustomTableHeader {\n key?: string;\n label?: string;\n}\n\nexport interface ApiCustomTable {\n data?: ApiCustomTableDataItem[];\n headers?: ApiCustomTableHeader[];\n title?: string;\n}\n\nexport interface ApiFundingInfoResponse {\n [key: string]: {\n funding_rate_epoch_duration?: number;\n next_funding_rate_long?: string;\n next_funding_rate_short?: string;\n next_funding_time?: number;\n };\n}\n\nexport enum ApiGaslessAction {\n GaslessActionAddMargin = \"add_margin\",\n GaslessActionRemoveMargin = \"remove_margin\",\n GaslessActionDelegate = \"delegate_access_for_session_key\",\n}\nexport enum ApiGaslessRequestAction {\n add_margin = \"add_margin\",\n remove_margin = \"remove_margin\",\n delegate_access_for_session_key = \"delegate_access_for_session_key\",\n}\nexport interface Eip712AccountJSON {\n addr: string;\n isPartyB?: boolean;\n}\n\nexport interface Eip712DelegationInfoJSON {\n account: Eip712AccountJSON;\n delegatedSigner: string;\n expiryTimestamp: number;\n /** @minItems 1 */\n selectors: string[];\n}\n\nexport interface Eip712ReplayHeaderJSON {\n deadline: number;\n nonce?: number;\n salt: string;\n}\n\nexport interface Eip712SignedDelegationJSON {\n delegationInfo: Eip712DelegationInfoJSON;\n replayAttackHeader: Eip712ReplayHeaderJSON;\n}\n\nexport interface Eip712DelegationWithSigJSON {\n signature: string;\n signedDelegation: Eip712SignedDelegationJSON;\n}\n\nexport interface Eip712FlexFieldJSON {\n authorizedFlexFiller?: string;\n length?: number;\n offset?: number;\n}\n\nexport interface Eip712SignedOperationJSON {\n callData: string;\n flexFields?: Eip712FlexFieldJSON[];\n maxUses?: number;\n replayAttackHeader: Eip712ReplayHeaderJSON;\n signer: string;\n signerAccount: Eip712AccountJSON;\n target: string;\n}\n\nexport interface Eip712OperationWithSigJSON {\n signature: string;\n signedOperation: Eip712SignedOperationJSON;\n}\n\nexport interface ApiGaslessRequest {\n action: ApiGaslessRequestAction;\n delegation?: Eip712DelegationWithSigJSON;\n operation?: Eip712OperationWithSigJSON;\n}\n\nexport interface ApiGaslessResponse {\n action?: ApiGaslessAction;\n blockHash?: string;\n blockNumber?: number;\n dailyRemaining?: number;\n gasUsed?: number;\n partyA?: string;\n transactionHash?: string;\n}\n\nexport interface ApiGetEstimatedPriceResponse {\n price?: string;\n}\n\nexport interface ApiGetInstantCloseResponse {\n close_price?: string;\n quantity_to_close?: string;\n quote_id?: number;\n}\n\nexport interface ApiGetInstantOpenResponse {\n cva?: string;\n lf?: string;\n order_type?: number;\n partyAmm?: string;\n partyBmm?: string;\n party_a_address?: string;\n position_type?: number;\n quantity?: string;\n requested_open_price?: string;\n symbol_id?: number;\n temp_quote_id?: number;\n /** UUID is the frontend-provided UUID from the V2 sendQuote metadata */\n uuid?: string;\n}\n\nexport interface ApiGetQuoteIdResponse {\n quote_id?: number;\n}\n\nexport interface ApiQuoteInfo {\n affiliate?: string;\n avg_closed_price?: string;\n block_number?: number;\n closed_amount?: string;\n create_timestamp?: string;\n cva?: string;\n deadline?: string;\n id?: string;\n initial_cva?: string;\n initial_lf?: string;\n initial_opened_price?: string;\n initial_party_amm?: string;\n initial_party_bmm?: string;\n last_funding_payment_timestamp?: string;\n lf?: string;\n market_price?: string;\n max_funding_rate?: string;\n opened_price?: string;\n order_type?: number;\n parent_id?: string;\n party_a?: string;\n party_amm?: string;\n party_b?: string;\n party_bmm?: string;\n position_type?: number;\n quantity?: string;\n quantity_to_close?: string;\n quote_status?: number;\n requested_close_price?: string;\n requested_open_price?: string;\n status_modify_timestamp?: string;\n symbol_id?: string;\n trading_fee?: string;\n}\n\nexport interface ApiGetQuotesResponse {\n count?: number;\n quotes?: ApiQuoteInfo[];\n}\n\nexport interface ApiPeriodStats {\n \"1h\"?: number;\n \"1w\"?: number;\n \"24h\"?: number;\n \"5m\"?: number;\n}\n\nexport interface ApiStatsMetrics {\n \"Completed Closes\"?: ApiPeriodStats;\n \"Completed Opens\"?: ApiPeriodStats;\n \"Instant Closes\"?: ApiPeriodStats;\n \"Instant Opens\"?: ApiPeriodStats;\n}\n\nexport interface ApiGetStatsResponse {\n custom_tables?: ApiCustomTable[];\n periodic_stats?: ApiStatsMetrics;\n}\n\nexport interface ApiGetTempQuoteStatusResponse {\n cva?: string;\n error_category?: string;\n /** Populated only when State is \"Failed\" or \"Cancelled\". ErrorCode mirrors\n * the synchronous /instant_trade contract; ErrorCategory is the stable\n * bucket the frontend maps to user-facing copy. See\n * docs/v2/INSTANT_TRADE_ERRORS.md. */\n error_code?: number;\n error_detail?: string;\n error_message?: string;\n lf?: string;\n margin?: string;\n max_funding_rate?: string;\n opened_price?: string;\n order_type?: number;\n party_a_account?: string;\n party_amm?: string;\n position_type?: number;\n price?: string;\n quantity?: string;\n quote_id?: number;\n state?: string;\n sub_account?: string;\n symbol_id?: number;\n}\n\nexport interface ApiLockedParamsBySymbolIdResponse {\n cva?: string;\n leverage?: string;\n lf?: string;\n partyAmm?: string;\n partyBmm?: string;\n}\n\nexport interface ApiNotionalCapBySymbolResponse {\n available_to_long?: number;\n available_to_short?: number;\n error?: string;\n open_interest?: number;\n price?: number;\n symbol?: string;\n symbol_id?: number;\n token_balance?: number;\n total_cap?: number;\n usdc_balance?: number;\n used?: number;\n used_tokens?: number;\n}\n\nexport interface ApiNotionalCapAllSymbolsResponse {\n count?: number;\n symbols?: ApiNotionalCapBySymbolResponse[];\n total_open_interest?: number;\n total_used?: number;\n}\n\nexport interface ApiPostInstantOpenResponse {\n partyBmm?: string;\n temp_quote_id?: number;\n}\n\nexport interface ApiRevenueBySymbolItem {\n funding_revenue?: string;\n hedger_fee_revenue?: string;\n record_count?: number;\n symbol?: string;\n symbol_id?: number;\n total_revenue?: string;\n}\n\nexport interface ApiRevenueBatchPerSymbolResponse {\n funding_revenue?: string;\n hedger_fee_revenue?: string;\n record_count?: number;\n symbols?: ApiRevenueBySymbolItem[];\n total_revenue?: string;\n}\n\nexport interface ApiRevenueResponse {\n funding_revenue?: string;\n hedger_fee_revenue?: string;\n record_count?: number;\n total_revenue?: string;\n}\n\nexport interface ApiV2InstantCloseRequest {\n /**\n * @minItems 1\n * @maxItems 100\n */\n operations: Eip712OperationWithSigJSON[];\n}\n\nexport interface ApiV2InstantOpenRequest {\n addMargin?: Eip712OperationWithSigJSON;\n sendQuote: Eip712OperationWithSigJSON;\n}\n\nexport enum ClientErrorCategory {\n CategoryValidation = \"validation\",\n CategoryAuthentication = \"authentication\",\n CategoryAuthorization = \"authorization\",\n CategorySlippage = \"slippage\",\n CategoryLiquidity = \"liquidity\",\n CategoryAccountState = \"account_state\",\n CategorySymbolState = \"symbol_state\",\n CategoryRateLimit = \"rate_limit\",\n CategoryTimeout = \"timeout\",\n CategoryInternal = \"internal\",\n CategoryUnavailable = \"unavailable\",\n}\nexport interface ClientErrorCodeInfo {\n category?: ClientErrorCategory;\n code?: number;\n http_status?: number;\n message?: string;\n}\n\nexport interface XfiberErrorResponse {\n code?: number;\n error_detail?: string;\n error_message?: string;\n}\n\nexport type GetErrorCodes200 = { [key: string]: string };\n\nexport type GetEstimatedPriceParams = {\n /**\n * Symbol ID\n */\n symbol_id: number;\n /**\n * Order quantity\n */\n quantity: string;\n /**\n * Position type (long/short)\n */\n position_type: string;\n /**\n * Entry type (open/close)\n */\n entry: string;\n /**\n * Price\n */\n price: string;\n};\n\nexport type GetGetFundingInfoParams = {\n /**\n * Symbol names (omit for all)\n */\n symbols?: string[];\n};\n\nexport type GetGetLockedParamsSymbolParams = {\n /**\n * Leverage\n */\n leverage: number;\n};\n\nexport type GetGetMarketInfo200 = { [key: string]: unknown };\n\nexport type GetInstantTradeEip712Config200 = { [key: string]: unknown };\n\nexport type GetNotionalCapParams = {\n /**\n * Limit results (max 500, default 100)\n */\n limit?: number;\n /**\n * Offset for pagination (default 0)\n */\n offset?: number;\n};\n\nexport type GetNotionalCapBatchParams = {\n /**\n * Symbol IDs (max 100)\n */\n symbol_ids: number[];\n};\n\nexport type GetQuotesParams = {\n /**\n * Symbol ID filter\n */\n symbol_id?: number;\n /**\n * Party A address filter\n */\n party_a?: string;\n /**\n * Quote status filter (1-7)\n */\n status?: number;\n /**\n * Limit results (max 500, default 100)\n */\n limit?: number;\n /**\n * Offset for pagination (default 0)\n */\n offset?: number;\n};\n\nexport type GetRevenueParams = {\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetRevenueBatchParams = {\n /**\n * Symbol IDs (max 100)\n */\n symbol_ids: number[];\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetRevenuePerSymbolParams = {\n /**\n * Symbol IDs (max 100)\n */\n symbol_ids: number[];\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetRevenueSymbolIdParams = {\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetStatsParams = {\n /**\n * Filter response to specific stat types (periodic_stats, single_metrics, custom_tables, alerts)\n */\n include?: string[];\n};\n\n/**\n * @summary Get contract symbols\n */\nexport const getContractSymbols = (\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiContractSymbolsResponse>> => {\n return axios.get(`/contract-symbols`, options);\n};\n\n/**\n * @summary Get API error codes\n */\nexport const getErrorCodes = (options?: AxiosRequestConfig): Promise<AxiosResponse<GetErrorCodes200>> => {\n return axios.get(`/error_codes`, options);\n};\n\n/**\n * Returns solver-registered error codes (>= 3000) with message, category, and http_status. Use the flat /error_codes endpoint for backward-compatible code→message lookups.\n * @summary Get detailed API error codes\n */\nexport const getErrorCodesDetailed = (options?: AxiosRequestConfig): Promise<AxiosResponse<ClientErrorCodeInfo[]>> => {\n return axios.get(`/error_codes/detailed`, options);\n};\n\n/**\n * Get estimated execution price from inventory service (dry-run mode)\n * @summary Get estimated price for order\n */\nexport const getEstimatedPrice = (\n params: GetEstimatedPriceParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetEstimatedPriceResponse>> => {\n return axios.get(`/estimated-price`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get funding info\n */\nexport const getGetFundingInfo = (\n params?: GetGetFundingInfoParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiFundingInfoResponse>> => {\n return axios.get(`/get_funding_info`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get locked params by symbol\n */\nexport const getGetLockedParamsSymbol = (\n symbol: string,\n params: GetGetLockedParamsSymbolParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiLockedParamsBySymbolIdResponse>> => {\n return axios.get(`/get_locked_params/${symbol}`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns a JSON object whose keys are symbol names (dynamic — sourced from contract-symbol data) mapping to {trading_volume, lifetime_value}, plus top-level aggregate fields total_value_24h and total_lifetime_value.\n * @summary Get 24h market info\n */\nexport const getGetMarketInfo = (options?: AxiosRequestConfig): Promise<AxiosResponse<GetGetMarketInfo200>> => {\n return axios.get(`/get_market_info`, options);\n};\n\n/**\n * Returns all pending instant close orders for a given SubAccount address.\n * @summary Get pending instant close orders\n */\nexport const getInstantCloseAccountAddress = (\n accountAddress: string,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetInstantCloseResponse[]>> => {\n return axios.get(`/instant_close/${accountAddress}`, options);\n};\n\n/**\n * Returns all pending instant open orders for a given SubAccount address.\n * @summary Get pending instant open orders\n */\nexport const getInstantOpenAccountAddress = (\n accountAddress: string,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetInstantOpenResponse[]>> => {\n return axios.get(`/instant_open/${accountAddress}`, options);\n};\n\n/**\n * @summary Get quote ID by temp ID\n */\nexport const getInstantQuoteIdTempQuoteId = (\n tempQuoteId: number,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetQuoteIdResponse>> => {\n return axios.get(`/instant_quote_id/${tempQuoteId}`, options);\n};\n\n/**\n * Returns the EIP-712 domain, domain separator, type hashes, and full type definitions that clients must use when constructing signatures for V2 instant open/close operations. No authentication required.\n * @summary Get V2 EIP-712 signing config\n */\nexport const getInstantTradeEip712Config = (\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<GetInstantTradeEip712Config200>> => {\n return axios.get(`/instant_trade/eip712-config`, options);\n};\n\n/**\n * Relay a single user-signed EIP-712 operation so the solver wallet executes it on-chain. The user pays no native gas. Identity is proven by EIP-712 signature recovery; no JWT required. Synchronous — returns the on-chain tx hash on success or a clear error on failure.\n *\n * **Supported actions** (set via the `action` field):\n * - `add_margin` — top up the allocated balance of an existing VirtualAccount via AccountLayer.addMargin. The signer must own the VA (its parent SubAccount must equal the signer's SubAccount). Requires `operation`.\n * - `remove_margin` — withdraw allocated margin from an existing VirtualAccount via AccountLayer.removeMargin. Requires `operation`.\n * - `delegate_access_for_session_key` — grant a delegate signer access for one or more allowlisted selectors via InstantLayer.grantBatchDelegationBySig. Requires `delegation`.\n *\n * Exactly one of `operation` or `delegation` must be present per request. Delegation selectors are restricted to: `sendQuoteWithAffiliateAndData`, `requestToClosePosition`, `addMarginToNextVA`, `addMargin`, `removeMargin`, `allocate`, `deallocate`, `safeDeallocate`, `initiateWithdraw`, `finalizeWithdrawRequest`, `requestCancelWithdraw`.\n *\n * Each PartyA is limited to `GASLESS_DAILY_MAX` accepted attempts per UTC day (default 5). The counter is consumed on every attempt past basic validation, regardless of downstream success or failure; the `dailyRemaining` field in the response reports the user's remaining quota.\n * @summary Submit a gasless operation\n */\nexport const postInstantTradeExecuteOperation = (\n apiGaslessRequest: ApiGaslessRequest,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGaslessResponse>> => {\n return axios.post(`/instant_trade/execute-operation`, apiGaslessRequest, options);\n};\n\n/**\n * Submit one or more V2 close operations (requestToClosePosition), one per quote. No JWT required — identity is proven by EIP-712 signature recovery. On any failure the whole request is rejected. Processing happens asynchronously.\n * @summary Submit V2 instant close\n */\nexport const postInstantTradeInstantClose = (\n apiV2InstantCloseRequest: ApiV2InstantCloseRequest,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<void>> => {\n return axios.post(`/instant_trade/instant_close`, apiV2InstantCloseRequest, options);\n};\n\n/**\n * Submit a V2 instant open request with pre-signed EIP-712 PartyA operations (addMargin + sendQuote). No JWT required — identity is proven by EIP-712 signature recovery. Processing (hedge, muon sigs, symmio-api call) happens asynchronously.\n * @summary Submit V2 instant open\n */\nexport const postInstantTradeInstantOpen = (\n apiV2InstantOpenRequest: ApiV2InstantOpenRequest,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiPostInstantOpenResponse>> => {\n return axios.post(`/instant_trade/instant_open`, apiV2InstantOpenRequest, options);\n};\n\n/**\n * @summary Get notional caps for all symbols\n */\nexport const getNotionalCap = (\n params?: GetNotionalCapParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiNotionalCapAllSymbolsResponse>> => {\n return axios.get(`/notional_cap`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get notional caps for multiple symbols\n */\nexport const getNotionalCapBatch = (\n params: GetNotionalCapBatchParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiNotionalCapAllSymbolsResponse>> => {\n return axios.get(`/notional_cap/batch`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get notional cap by symbol\n */\nexport const getNotionalCapSymbolId = (\n symbolId: number,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiNotionalCapBySymbolResponse>> => {\n return axios.get(`/notional_cap/${symbolId}`, options);\n};\n\n/**\n * Get quotes from the event listener database with optional filters\n * @summary Get quotes from event listener\n */\nexport const getQuotes = (\n params?: GetQuotesParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetQuotesResponse>> => {\n return axios.get(`/quotes`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns total, hedger-fee, and funding-rate revenue. Filterable by time_range or custom start/end timestamps.\n * @summary Get aggregated revenue for all symbols\n */\nexport const getRevenue = (\n params?: GetRevenueParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueResponse>> => {\n return axios.get(`/revenue`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns total, hedger-fee, and funding-rate revenue for a set of symbols. Pass symbol_ids as a comma-separated list or repeated query params (max 100).\n * @summary Get aggregated revenue for multiple symbols\n */\nexport const getRevenueBatch = (\n params: GetRevenueBatchParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueResponse>> => {\n return axios.get(`/revenue/batch`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns aggregated revenue totals AND a per-symbol breakdown for the requested symbol_ids. Each item in `symbols` carries symbol_id, symbol name, and the same revenue dimensions returned at the top level. Symbols with no rows in the filter window are omitted; entries follow the request's symbol_ids order. Pass symbol_ids as a comma-separated list or repeated query params (max 100).\n * @summary Get aggregated revenue plus per-symbol breakdown\n */\nexport const getRevenuePerSymbol = (\n params: GetRevenuePerSymbolParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueBatchPerSymbolResponse>> => {\n return axios.get(`/revenue/per-symbol`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns total, hedger-fee, and funding-rate revenue for one symbol. Filterable by time_range or custom timestamps.\n * @summary Get aggregated revenue for a specific symbol\n */\nexport const getRevenueSymbolId = (\n symbolId: number,\n params?: GetRevenueSymbolIdParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueResponse>> => {\n return axios.get(`/revenue/${symbolId}`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Get instant trading statistics for different time periods (5m, 1h, 24h, 1w) grouped by metric type\n * @summary Get trading statistics\n */\nexport const getStats = (\n params?: GetStatsParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetStatsResponse>> => {\n return axios.get(`/stats`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get temp quote status\n */\nexport const getTempQuoteStatusTempQuoteId = (\n tempQuoteId: number,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetTempQuoteStatusResponse>> => {\n return axios.get(`/temp_quote_status/${tempQuoteId}`, options);\n};\n\nexport type GetContractSymbolsResult = AxiosResponse<ApiContractSymbolsResponse>;\nexport type GetErrorCodesResult = AxiosResponse<GetErrorCodes200>;\nexport type GetErrorCodesDetailedResult = AxiosResponse<ClientErrorCodeInfo[]>;\nexport type GetEstimatedPriceResult = AxiosResponse<ApiGetEstimatedPriceResponse>;\nexport type GetGetFundingInfoResult = AxiosResponse<ApiFundingInfoResponse>;\nexport type GetGetLockedParamsSymbolResult = AxiosResponse<ApiLockedParamsBySymbolIdResponse>;\nexport type GetGetMarketInfoResult = AxiosResponse<GetGetMarketInfo200>;\nexport type GetInstantCloseAccountAddressResult = AxiosResponse<ApiGetInstantCloseResponse[]>;\nexport type GetInstantOpenAccountAddressResult = AxiosResponse<ApiGetInstantOpenResponse[]>;\nexport type GetInstantQuoteIdTempQuoteIdResult = AxiosResponse<ApiGetQuoteIdResponse>;\nexport type GetInstantTradeEip712ConfigResult = AxiosResponse<GetInstantTradeEip712Config200>;\nexport type PostInstantTradeExecuteOperationResult = AxiosResponse<ApiGaslessResponse>;\nexport type PostInstantTradeInstantCloseResult = AxiosResponse<void>;\nexport type PostInstantTradeInstantOpenResult = AxiosResponse<ApiPostInstantOpenResponse>;\nexport type GetNotionalCapResult = AxiosResponse<ApiNotionalCapAllSymbolsResponse>;\nexport type GetNotionalCapBatchResult = AxiosResponse<ApiNotionalCapAllSymbolsResponse>;\nexport type GetNotionalCapSymbolIdResult = AxiosResponse<ApiNotionalCapBySymbolResponse>;\nexport type GetQuotesResult = AxiosResponse<ApiGetQuotesResponse>;\nexport type GetRevenueResult = AxiosResponse<ApiRevenueResponse>;\nexport type GetRevenueBatchResult = AxiosResponse<ApiRevenueResponse>;\nexport type GetRevenuePerSymbolResult = AxiosResponse<ApiRevenueBatchPerSymbolResponse>;\nexport type GetRevenueSymbolIdResult = AxiosResponse<ApiRevenueResponse>;\nexport type GetStatsResult = AxiosResponse<ApiGetStatsResponse>;\nexport type GetTempQuoteStatusTempQuoteIdResult = AxiosResponse<ApiGetTempQuoteStatusResponse>;\n"],"mappings":";;AAuhBA,IAAa,KACX,MAEO,EAAM,IAAI,qBAAqB,CAAO,GAMlC,KAAiB,MACrB,EAAM,IAAI,gBAAgB,CAAO,GA4B7B,KACX,GACA,MAEO,EAAM,IAAI,qBAAqB;CACpC,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAMU,KACX,GACA,GACA,MAEO,EAAM,IAAI,sBAAsB,KAAU;CAC/C,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAOU,KAAoB,MACxB,EAAM,IAAI,oBAAoB,CAAO,GAOjC,KACX,GACA,MAEO,EAAM,IAAI,kBAAkB,KAAkB,CAAO,GAOjD,KACX,GACA,MAEO,EAAM,IAAI,iBAAiB,KAAkB,CAAO,GAMhD,KACX,GACA,MAEO,EAAM,IAAI,qBAAqB,KAAe,CAAO,GAqCjD,KACX,GACA,MAEO,EAAM,KAAK,gCAAgC,GAA0B,CAAO,GAOxE,KACX,GACA,MAEO,EAAM,KAAK,+BAA+B,GAAyB,CAAO,GAMtE,KACX,GACA,MAEO,EAAM,IAAI,iBAAiB;CAChC,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAmBU,KACX,GACA,MAEO,EAAM,IAAI,iBAAiB,KAAY,CAAO"}
1
+ {"version":3,"file":"enigma-solver.js","names":[],"sources":["../../../../src/solvers/types/generated/enigma-solver.ts"],"sourcesContent":["/**\n * Generated by orval v8.14.0 🍺\n * Do not edit manually.\n * Low Cap Solver API\n * API for Low Cap Solver trading system\n * OpenAPI spec version: 1.0\n */\nimport type { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport axios from \"axios\";\n\nexport interface SymbolContractSymbol {\n asset?: string;\n funding_rate_epoch_duration?: string;\n funding_rate_window_time?: string;\n hedger_fee_close?: string;\n hedger_fee_open?: string;\n is_valid?: boolean;\n lot_size?: string;\n max_funding_rate?: string;\n max_leverage?: string;\n max_notional_value?: number;\n max_quantity?: string;\n min_acceptable_portion_lf?: string;\n min_acceptable_quote_value?: string;\n min_notional_value?: string;\n name?: string;\n price_precision?: number;\n quantity_precision?: number;\n rfq_allowed?: boolean;\n /** \"all\", \"long\", or \"short\" */\n side?: string;\n /** 0: Disabled, 1: Close only, 2: Open only, 3: Fully enabled */\n state?: number;\n symbol?: string;\n symbol_id?: number;\n /** From price service GetSymbolsInfo */\n token_address?: string;\n trading_fee?: string;\n}\n\nexport interface ApiContractSymbolsResponse {\n count?: number;\n symbols?: SymbolContractSymbol[];\n}\n\nexport type ApiCustomTableDataItem = { [key: string]: unknown };\n\nexport interface ApiCustomTableHeader {\n key?: string;\n label?: string;\n}\n\nexport interface ApiCustomTable {\n data?: ApiCustomTableDataItem[];\n headers?: ApiCustomTableHeader[];\n title?: string;\n}\n\nexport interface ApiFundingInfoResponse {\n [key: string]: {\n funding_rate_epoch_duration?: number;\n next_funding_rate_long?: string;\n next_funding_rate_short?: string;\n next_funding_time?: number;\n };\n}\n\nexport enum ApiGaslessAction {\n GaslessActionAddMargin = \"add_margin\",\n GaslessActionRemoveMargin = \"remove_margin\",\n GaslessActionDelegate = \"delegate_access_for_session_key\",\n}\nexport enum ApiGaslessRequestAction {\n add_margin = \"add_margin\",\n remove_margin = \"remove_margin\",\n delegate_access_for_session_key = \"delegate_access_for_session_key\",\n}\nexport interface Eip712AccountJSON {\n addr: string;\n isPartyB?: boolean;\n}\n\nexport interface Eip712DelegationInfoJSON {\n account: Eip712AccountJSON;\n delegatedSigner: string;\n expiryTimestamp: number;\n /** @minItems 1 */\n selectors: string[];\n}\n\nexport interface Eip712ReplayHeaderJSON {\n deadline: number;\n nonce?: number;\n salt: string;\n}\n\nexport interface Eip712SignedDelegationJSON {\n delegationInfo: Eip712DelegationInfoJSON;\n replayAttackHeader: Eip712ReplayHeaderJSON;\n}\n\nexport interface Eip712DelegationWithSigJSON {\n signature: string;\n signedDelegation: Eip712SignedDelegationJSON;\n}\n\nexport interface Eip712FlexFieldJSON {\n authorizedFlexFiller?: string;\n length?: number;\n offset?: number;\n}\n\nexport interface Eip712SignedOperationJSON {\n callData: string;\n flexFields?: Eip712FlexFieldJSON[];\n maxUses?: number;\n replayAttackHeader: Eip712ReplayHeaderJSON;\n signer: string;\n signerAccount: Eip712AccountJSON;\n target: string;\n}\n\nexport interface Eip712OperationWithSigJSON {\n signature: string;\n signedOperation: Eip712SignedOperationJSON;\n}\n\nexport interface ApiGaslessRequest {\n action: ApiGaslessRequestAction;\n delegation?: Eip712DelegationWithSigJSON;\n operation?: Eip712OperationWithSigJSON;\n}\n\nexport interface ApiGaslessResponse {\n action?: ApiGaslessAction;\n blockHash?: string;\n blockNumber?: number;\n dailyRemaining?: number;\n gasUsed?: number;\n partyA?: string;\n transactionHash?: string;\n}\n\nexport interface ApiGetEstimatedPriceResponse {\n price?: string;\n}\n\nexport interface ApiGetInstantCloseResponse {\n close_price?: string;\n quantity_to_close?: string;\n quote_id?: number;\n}\n\nexport interface ApiGetInstantOpenResponse {\n cva?: string;\n lf?: string;\n order_type?: number;\n partyAmm?: string;\n partyBmm?: string;\n party_a_address?: string;\n position_type?: number;\n quantity?: string;\n requested_open_price?: string;\n symbol_id?: number;\n temp_quote_id?: number;\n /** UUID is the frontend-provided UUID from the V2 sendQuote metadata */\n uuid?: string;\n}\n\nexport interface ApiGetQuoteIdResponse {\n quote_id?: number;\n}\n\nexport interface ApiQuoteInfo {\n affiliate?: string;\n avg_closed_price?: string;\n block_number?: number;\n closed_amount?: string;\n create_timestamp?: string;\n cva?: string;\n deadline?: string;\n id?: string;\n initial_cva?: string;\n initial_lf?: string;\n initial_opened_price?: string;\n initial_party_amm?: string;\n initial_party_bmm?: string;\n last_funding_payment_timestamp?: string;\n lf?: string;\n market_price?: string;\n max_funding_rate?: string;\n opened_price?: string;\n order_type?: number;\n parent_id?: string;\n party_a?: string;\n party_amm?: string;\n party_b?: string;\n party_bmm?: string;\n position_type?: number;\n quantity?: string;\n quantity_to_close?: string;\n quote_status?: number;\n requested_close_price?: string;\n requested_open_price?: string;\n status_modify_timestamp?: string;\n symbol_id?: string;\n trading_fee?: string;\n}\n\nexport interface ApiGetQuotesResponse {\n count?: number;\n quotes?: ApiQuoteInfo[];\n}\n\nexport interface ApiPeriodStats {\n \"1h\"?: number;\n \"1w\"?: number;\n \"24h\"?: number;\n \"5m\"?: number;\n}\n\nexport interface ApiStatsMetrics {\n \"Completed Closes\"?: ApiPeriodStats;\n \"Completed Opens\"?: ApiPeriodStats;\n \"Instant Closes\"?: ApiPeriodStats;\n \"Instant Opens\"?: ApiPeriodStats;\n}\n\nexport interface ApiGetStatsResponse {\n custom_tables?: ApiCustomTable[];\n periodic_stats?: ApiStatsMetrics;\n}\n\nexport interface ApiGetTempQuoteStatusResponse {\n cva?: string;\n error_category?: string;\n /** Populated only when State is \"Failed\" or \"Cancelled\". ErrorCode mirrors\n * the synchronous /instant_trade contract; ErrorCategory is the stable\n * bucket the frontend maps to user-facing copy. See\n * docs/v2/INSTANT_TRADE_ERRORS.md. */\n error_code?: number;\n error_detail?: string;\n error_message?: string;\n lf?: string;\n margin?: string;\n max_funding_rate?: string;\n opened_price?: string;\n order_type?: number;\n party_a_account?: string;\n party_amm?: string;\n position_type?: number;\n price?: string;\n quantity?: string;\n quote_id?: number;\n state?: string;\n sub_account?: string;\n symbol_id?: number;\n}\n\nexport interface ApiLockedParamsBySymbolIdResponse {\n cva?: string;\n leverage?: string;\n lf?: string;\n partyAmm?: string;\n partyBmm?: string;\n}\n\nexport interface ApiNotionalCapBySymbolResponse {\n available_to_long?: number;\n available_to_short?: number;\n error?: string;\n open_interest?: number;\n price?: number;\n symbol?: string;\n symbol_id?: number;\n token_balance?: number;\n total_cap?: number;\n usdc_balance?: number;\n used?: number;\n used_tokens?: number;\n}\n\nexport interface ApiNotionalCapAllSymbolsResponse {\n count?: number;\n symbols?: ApiNotionalCapBySymbolResponse[];\n total_open_interest?: number;\n total_used?: number;\n}\n\nexport interface ApiPostInstantOpenResponse {\n partyBmm?: string;\n temp_quote_id?: number;\n}\n\nexport interface ApiRevenueBySymbolItem {\n funding_revenue?: string;\n hedger_fee_revenue?: string;\n record_count?: number;\n symbol?: string;\n symbol_id?: number;\n total_revenue?: string;\n}\n\nexport interface ApiRevenueBatchPerSymbolResponse {\n funding_revenue?: string;\n hedger_fee_revenue?: string;\n record_count?: number;\n symbols?: ApiRevenueBySymbolItem[];\n total_revenue?: string;\n}\n\nexport interface ApiRevenueResponse {\n funding_revenue?: string;\n hedger_fee_revenue?: string;\n record_count?: number;\n total_revenue?: string;\n}\n\nexport interface ApiV2InstantCloseRequest {\n /**\n * @minItems 1\n * @maxItems 100\n */\n operations: Eip712OperationWithSigJSON[];\n}\n\nexport interface ApiV2InstantOpenRequest {\n addMargin?: Eip712OperationWithSigJSON;\n sendQuote: Eip712OperationWithSigJSON;\n}\n\nexport enum ClientErrorCategory {\n CategoryValidation = \"validation\",\n CategoryAuthentication = \"authentication\",\n CategoryAuthorization = \"authorization\",\n CategorySlippage = \"slippage\",\n CategoryLiquidity = \"liquidity\",\n CategoryAccountState = \"account_state\",\n CategorySymbolState = \"symbol_state\",\n CategoryRateLimit = \"rate_limit\",\n CategoryTimeout = \"timeout\",\n CategoryInternal = \"internal\",\n CategoryUnavailable = \"unavailable\",\n}\nexport interface ClientErrorCodeInfo {\n category?: ClientErrorCategory;\n code?: number;\n http_status?: number;\n message?: string;\n}\n\nexport interface XfiberErrorResponse {\n code?: number;\n error_detail?: string;\n error_message?: string;\n}\n\nexport type GetErrorCodes200 = { [key: string]: string };\n\nexport type GetEstimatedPriceParams = {\n /**\n * Symbol ID\n */\n symbol_id: number;\n /**\n * Order quantity\n */\n quantity: string;\n /**\n * Position type (long/short)\n */\n position_type: string;\n /**\n * Entry type (open/close)\n */\n entry: string;\n /**\n * Price\n */\n price: string;\n};\n\nexport type GetGetFundingInfoParams = {\n /**\n * Symbol names (omit for all)\n */\n symbols?: string[];\n};\n\nexport type GetGetLockedParamsSymbolParams = {\n /**\n * Leverage\n */\n leverage: number;\n};\n\nexport type GetGetMarketInfo200 = { [key: string]: unknown };\n\nexport type GetInstantTradeEip712Config200 = { [key: string]: unknown };\n\nexport type GetNotionalCapParams = {\n /**\n * Limit results (max 500, default 100)\n */\n limit?: number;\n /**\n * Offset for pagination (default 0)\n */\n offset?: number;\n};\n\nexport type GetNotionalCapBatchParams = {\n /**\n * Symbol IDs (max 100)\n */\n symbol_ids: number[];\n};\n\nexport type GetQuotesParams = {\n /**\n * Symbol ID filter\n */\n symbol_id?: number;\n /**\n * Party A address filter\n */\n party_a?: string;\n /**\n * Quote status filter (1-7)\n */\n status?: number;\n /**\n * Limit results (max 500, default 100)\n */\n limit?: number;\n /**\n * Offset for pagination (default 0)\n */\n offset?: number;\n};\n\nexport type GetRevenueParams = {\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetRevenueBatchParams = {\n /**\n * Symbol IDs (max 100)\n */\n symbol_ids: number[];\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetRevenuePerSymbolParams = {\n /**\n * Symbol IDs (max 100)\n */\n symbol_ids: number[];\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetRevenueSymbolIdParams = {\n /**\n * Preset range (1h, 24h, 7d, 30d, lifetime)\n */\n time_range?: string;\n /**\n * Revenue type filter (HedgerFee, FundingRate)\n */\n type?: string;\n /**\n * Unix timestamp start (overrides time_range)\n */\n start_time?: number;\n /**\n * Unix timestamp end\n */\n end_time?: number;\n};\n\nexport type GetStatsParams = {\n /**\n * Filter response to specific stat types (periodic_stats, single_metrics, custom_tables, alerts)\n */\n include?: string[];\n};\n\n/**\n * @summary Get contract symbols\n */\nexport const getContractSymbols = (\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiContractSymbolsResponse>> => {\n return axios.get(`/contract-symbols`, options);\n};\n\n/**\n * @summary Get API error codes\n */\nexport const getErrorCodes = (options?: AxiosRequestConfig): Promise<AxiosResponse<GetErrorCodes200>> => {\n return axios.get(`/error_codes`, options);\n};\n\n/**\n * Returns solver-registered error codes (>= 3000) with message, category, and http_status. Use the flat /error_codes endpoint for backward-compatible code→message lookups.\n * @summary Get detailed API error codes\n */\nexport const getErrorCodesDetailed = (options?: AxiosRequestConfig): Promise<AxiosResponse<ClientErrorCodeInfo[]>> => {\n return axios.get(`/error_codes/detailed`, options);\n};\n\n/**\n * Get estimated execution price from inventory service (dry-run mode)\n * @summary Get estimated price for order\n */\nexport const getEstimatedPrice = (\n params: GetEstimatedPriceParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetEstimatedPriceResponse>> => {\n return axios.get(`/estimated-price`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get funding info\n */\nexport const getGetFundingInfo = (\n params?: GetGetFundingInfoParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiFundingInfoResponse>> => {\n return axios.get(`/get_funding_info`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get locked params by symbol\n */\nexport const getGetLockedParamsSymbol = (\n symbol: string,\n params: GetGetLockedParamsSymbolParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiLockedParamsBySymbolIdResponse>> => {\n return axios.get(`/get_locked_params/${symbol}`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns a JSON object whose keys are symbol names (dynamic — sourced from contract-symbol data) mapping to {trading_volume, lifetime_value}, plus top-level aggregate fields total_value_24h and total_lifetime_value.\n * @summary Get 24h market info\n */\nexport const getGetMarketInfo = (options?: AxiosRequestConfig): Promise<AxiosResponse<GetGetMarketInfo200>> => {\n return axios.get(`/get_market_info`, options);\n};\n\n/**\n * Returns all pending instant close orders for a given SubAccount address.\n * @summary Get pending instant close orders\n */\nexport const getInstantCloseAccountAddress = (\n accountAddress: string,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetInstantCloseResponse[]>> => {\n return axios.get(`/instant_close/${accountAddress}`, options);\n};\n\n/**\n * Returns all pending instant open orders for a given SubAccount address.\n * @summary Get pending instant open orders\n */\nexport const getInstantOpenAccountAddress = (\n accountAddress: string,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetInstantOpenResponse[]>> => {\n return axios.get(`/instant_open/${accountAddress}`, options);\n};\n\n/**\n * @summary Get quote ID by temp ID\n */\nexport const getInstantQuoteIdTempQuoteId = (\n tempQuoteId: number,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetQuoteIdResponse>> => {\n return axios.get(`/instant_quote_id/${tempQuoteId}`, options);\n};\n\n/**\n * Returns the EIP-712 domain, domain separator, type hashes, and full type definitions that clients must use when constructing signatures for V2 instant open/close operations. No authentication required.\n * @summary Get V2 EIP-712 signing config\n */\nexport const getInstantTradeEip712Config = (\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<GetInstantTradeEip712Config200>> => {\n return axios.get(`/instant_trade/eip712-config`, options);\n};\n\n/**\n * Relay a single user-signed EIP-712 operation so the solver wallet executes it on-chain. The user pays no native gas. Identity is proven by EIP-712 signature recovery; no JWT required. Synchronous — returns the on-chain tx hash on success or a clear error on failure.\n *\n * **Supported actions** (set via the `action` field):\n * - `add_margin` — top up the allocated balance of an existing VirtualAccount via AccountLayer.addMargin. The signer must own the VA (its parent SubAccount must equal the signer's SubAccount). Requires `operation`.\n * - `remove_margin` — withdraw allocated margin from an existing VirtualAccount via AccountLayer.removeMargin. Requires `operation`.\n * - `delegate_access_for_session_key` — grant a delegate signer access for one or more allowlisted selectors via InstantLayer.grantBatchDelegationBySig. Requires `delegation`.\n *\n * Exactly one of `operation` or `delegation` must be present per request. Delegation selectors are restricted to: `sendQuoteWithAffiliateAndData`, `requestToClosePosition`, `addMarginToNextVA`, `addMargin`, `removeMargin`, `allocate`, `deallocate`, `safeDeallocate`, `initiateWithdraw`, `finalizeWithdrawRequest`, `requestCancelWithdraw`.\n *\n * Each PartyA is limited to `GASLESS_DAILY_MAX` accepted attempts per UTC day (default 5). The counter is consumed on every attempt past basic validation, regardless of downstream success or failure; the `dailyRemaining` field in the response reports the user's remaining quota.\n * @summary Submit a gasless operation\n */\nexport const postInstantTradeExecuteOperation = (\n apiGaslessRequest: ApiGaslessRequest,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGaslessResponse>> => {\n return axios.post(`/instant_trade/execute-operation`, apiGaslessRequest, options);\n};\n\n/**\n * Submit one or more V2 close operations (requestToClosePosition), one per quote. No JWT required — identity is proven by EIP-712 signature recovery. On any failure the whole request is rejected. Processing happens asynchronously.\n * @summary Submit V2 instant close\n */\nexport const postInstantTradeInstantClose = (\n apiV2InstantCloseRequest: ApiV2InstantCloseRequest,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<void>> => {\n return axios.post(`/instant_trade/instant_close`, apiV2InstantCloseRequest, options);\n};\n\n/**\n * Submit a V2 instant open request with pre-signed EIP-712 PartyA operations (addMargin + sendQuote). No JWT required — identity is proven by EIP-712 signature recovery. Processing (hedge, muon sigs, symmio-api call) happens asynchronously.\n * @summary Submit V2 instant open\n */\nexport const postInstantTradeInstantOpen = (\n apiV2InstantOpenRequest: ApiV2InstantOpenRequest,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiPostInstantOpenResponse>> => {\n return axios.post(`/instant_trade/instant_open`, apiV2InstantOpenRequest, options);\n};\n\n/**\n * @summary Get notional caps for all symbols\n */\nexport const getNotionalCap = (\n params?: GetNotionalCapParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiNotionalCapAllSymbolsResponse>> => {\n return axios.get(`/notional_cap`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get notional caps for multiple symbols\n */\nexport const getNotionalCapBatch = (\n params: GetNotionalCapBatchParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiNotionalCapAllSymbolsResponse>> => {\n return axios.get(`/notional_cap/batch`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get notional cap by symbol\n */\nexport const getNotionalCapSymbolId = (\n symbolId: number,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiNotionalCapBySymbolResponse>> => {\n return axios.get(`/notional_cap/${symbolId}`, options);\n};\n\n/**\n * Get quotes from the event listener database with optional filters\n * @summary Get quotes from event listener\n */\nexport const getQuotes = (\n params?: GetQuotesParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetQuotesResponse>> => {\n return axios.get(`/quotes`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns total, hedger-fee, and funding-rate revenue. Filterable by time_range or custom start/end timestamps.\n * @summary Get aggregated revenue for all symbols\n */\nexport const getRevenue = (\n params?: GetRevenueParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueResponse>> => {\n return axios.get(`/revenue`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns total, hedger-fee, and funding-rate revenue for a set of symbols. Pass symbol_ids as a comma-separated list or repeated query params (max 100).\n * @summary Get aggregated revenue for multiple symbols\n */\nexport const getRevenueBatch = (\n params: GetRevenueBatchParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueResponse>> => {\n return axios.get(`/revenue/batch`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns aggregated revenue totals AND a per-symbol breakdown for the requested symbol_ids. Each item in `symbols` carries symbol_id, symbol name, and the same revenue dimensions returned at the top level. Symbols with no rows in the filter window are omitted; entries follow the request's symbol_ids order. Pass symbol_ids as a comma-separated list or repeated query params (max 100).\n * @summary Get aggregated revenue plus per-symbol breakdown\n */\nexport const getRevenuePerSymbol = (\n params: GetRevenuePerSymbolParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueBatchPerSymbolResponse>> => {\n return axios.get(`/revenue/per-symbol`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Returns total, hedger-fee, and funding-rate revenue for one symbol. Filterable by time_range or custom timestamps.\n * @summary Get aggregated revenue for a specific symbol\n */\nexport const getRevenueSymbolId = (\n symbolId: number,\n params?: GetRevenueSymbolIdParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiRevenueResponse>> => {\n return axios.get(`/revenue/${symbolId}`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * Get instant trading statistics for different time periods (5m, 1h, 24h, 1w) grouped by metric type\n * @summary Get trading statistics\n */\nexport const getStats = (\n params?: GetStatsParams,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetStatsResponse>> => {\n return axios.get(`/stats`, {\n ...options,\n params: { ...params, ...options?.params },\n });\n};\n\n/**\n * @summary Get temp quote status\n */\nexport const getTempQuoteStatusTempQuoteId = (\n tempQuoteId: number,\n options?: AxiosRequestConfig,\n): Promise<AxiosResponse<ApiGetTempQuoteStatusResponse>> => {\n return axios.get(`/temp_quote_status/${tempQuoteId}`, options);\n};\n\nexport type GetContractSymbolsResult = AxiosResponse<ApiContractSymbolsResponse>;\nexport type GetErrorCodesResult = AxiosResponse<GetErrorCodes200>;\nexport type GetErrorCodesDetailedResult = AxiosResponse<ClientErrorCodeInfo[]>;\nexport type GetEstimatedPriceResult = AxiosResponse<ApiGetEstimatedPriceResponse>;\nexport type GetGetFundingInfoResult = AxiosResponse<ApiFundingInfoResponse>;\nexport type GetGetLockedParamsSymbolResult = AxiosResponse<ApiLockedParamsBySymbolIdResponse>;\nexport type GetGetMarketInfoResult = AxiosResponse<GetGetMarketInfo200>;\nexport type GetInstantCloseAccountAddressResult = AxiosResponse<ApiGetInstantCloseResponse[]>;\nexport type GetInstantOpenAccountAddressResult = AxiosResponse<ApiGetInstantOpenResponse[]>;\nexport type GetInstantQuoteIdTempQuoteIdResult = AxiosResponse<ApiGetQuoteIdResponse>;\nexport type GetInstantTradeEip712ConfigResult = AxiosResponse<GetInstantTradeEip712Config200>;\nexport type PostInstantTradeExecuteOperationResult = AxiosResponse<ApiGaslessResponse>;\nexport type PostInstantTradeInstantCloseResult = AxiosResponse<void>;\nexport type PostInstantTradeInstantOpenResult = AxiosResponse<ApiPostInstantOpenResponse>;\nexport type GetNotionalCapResult = AxiosResponse<ApiNotionalCapAllSymbolsResponse>;\nexport type GetNotionalCapBatchResult = AxiosResponse<ApiNotionalCapAllSymbolsResponse>;\nexport type GetNotionalCapSymbolIdResult = AxiosResponse<ApiNotionalCapBySymbolResponse>;\nexport type GetQuotesResult = AxiosResponse<ApiGetQuotesResponse>;\nexport type GetRevenueResult = AxiosResponse<ApiRevenueResponse>;\nexport type GetRevenueBatchResult = AxiosResponse<ApiRevenueResponse>;\nexport type GetRevenuePerSymbolResult = AxiosResponse<ApiRevenueBatchPerSymbolResponse>;\nexport type GetRevenueSymbolIdResult = AxiosResponse<ApiRevenueResponse>;\nexport type GetStatsResult = AxiosResponse<ApiGetStatsResponse>;\nexport type GetTempQuoteStatusTempQuoteIdResult = AxiosResponse<ApiGetTempQuoteStatusResponse>;\n"],"mappings":";;AAuhBA,IAAa,KACX,MAEO,EAAM,IAAI,qBAAqB,CAAO,GAMlC,KAAiB,MACrB,EAAM,IAAI,gBAAgB,CAAO,GAe7B,KACX,GACA,MAEO,EAAM,IAAI,oBAAoB;CACnC,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAMU,KACX,GACA,MAEO,EAAM,IAAI,qBAAqB;CACpC,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAMU,KACX,GACA,GACA,MAEO,EAAM,IAAI,sBAAsB,KAAU;CAC/C,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAOU,KAAoB,MACxB,EAAM,IAAI,oBAAoB,CAAO,GAOjC,KACX,GACA,MAEO,EAAM,IAAI,kBAAkB,KAAkB,CAAO,GAOjD,KACX,GACA,MAEO,EAAM,IAAI,iBAAiB,KAAkB,CAAO,GAMhD,KACX,GACA,MAEO,EAAM,IAAI,qBAAqB,KAAe,CAAO,GAqCjD,KACX,GACA,MAEO,EAAM,KAAK,gCAAgC,GAA0B,CAAO,GAOxE,KACX,GACA,MAEO,EAAM,KAAK,+BAA+B,GAAyB,CAAO,GAMtE,KACX,GACA,MAEO,EAAM,IAAI,iBAAiB;CAChC,GAAG;CACH,QAAQ;EAAE,GAAG;EAAQ,GAAG,GAAS;CAAO;AAC1C,CAAC,GAmBU,KACX,GACA,MAEO,EAAM,IAAI,iBAAiB,KAAY,CAAO"}
@@ -13,7 +13,7 @@ export type GetUserSubAccountsAddressesParameters = Compute<ChainIdParameter & {
13
13
  */
14
14
  offset?: bigint;
15
15
  /**
16
- * Pagination limit, in subaccounts. The default matches the value the SYMM
16
+ * Pagination limit, in subaccounts. The default matches the value the SYMMIO
17
17
  * Explorer Inspector page uses.
18
18
  * @default 200n
19
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"get-user-sub-accounts-addresses.js","names":[],"sources":["../../../../src/symmio-contracts/account-layer/actions/get-user-sub-accounts-addresses.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../../shared/types/properties\";\nimport { accountLayerAbi } from \"../../abi/v0.8.5/account-layer\";\n\n/**\n * Parameters for {@link getUserSubAccountsAddresses}.\n */\nexport type GetUserSubAccountsAddressesParameters = Compute<\n ChainIdParameter & {\n /** EOA whose subaccount addresses to list. */\n user: Address;\n /**\n * Pagination offset, in subaccounts.\n * @default 0n\n */\n offset?: bigint;\n /**\n * Pagination limit, in subaccounts. The default matches the value the SYMM\n * Explorer Inspector page uses.\n * @default 200n\n */\n limit?: bigint;\n }\n>;\n\n/** Return type of {@link getUserSubAccountsAddresses}. */\nexport type GetUserSubAccountsAddressesReturnType = readonly Address[];\n\n/**\n * Read the addresses of all SYMMIO subaccounts owned by `user`. A lighter\n * alternative to {@link getUserSubAccounts} when only the addresses are needed.\n *\n * Resolves the viem client and `AccountLayer` address from `config` for the\n * given chain (or the config's default chain when `chainId` is omitted).\n *\n * @param config - The SDK config.\n * @param parameters - User address, optional pagination, optional chain id.\n * @returns The user's subaccount addresses.\n * @throws {SymmError} when the chain is not supported.\n * @throws Viem's `ContractFunctionExecutionError` and friends for on-chain failures.\n *\n * @example\n * ```ts\n * const addresses = await getUserSubAccountsAddresses(config, { user: \"0xabc…\", limit: 100n });\n * ```\n */\nexport async function getUserSubAccountsAddresses(\n config: Config,\n parameters: GetUserSubAccountsAddressesParameters,\n): Promise<GetUserSubAccountsAddressesReturnType> {\n const { chainId, user, offset = 0n, limit = 200n } = parameters;\n\n const { addresses } = config.getChainConfig(chainId);\n const client = config.getClient({ chainId });\n\n return client.readContract({\n address: addresses.accountLayerAddress,\n abi: accountLayerAbi,\n functionName: \"getUserSubAccountsAddresses\",\n args: [user, offset, limit],\n });\n}\n"],"mappings":";;AA+CA,eAAsB,EACpB,GACA,GACgD;CAChD,IAAM,EAAE,YAAS,SAAM,YAAS,IAAI,WAAQ,SAAS,GAE/C,EAAE,iBAAc,EAAO,eAAe,CAAO;CAGnD,OAFe,EAAO,UAAU,EAAE,WAAQ,CAEnC,EAAO,aAAa;EACzB,SAAS,EAAU;EACnB,KAAK;EACL,cAAc;EACd,MAAM;GAAC;GAAM;GAAQ;EAAK;CAC5B,CAAC;AACH"}
1
+ {"version":3,"file":"get-user-sub-accounts-addresses.js","names":[],"sources":["../../../../src/symmio-contracts/account-layer/actions/get-user-sub-accounts-addresses.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../../shared/types/properties\";\nimport { accountLayerAbi } from \"../../abi/v0.8.5/account-layer\";\n\n/**\n * Parameters for {@link getUserSubAccountsAddresses}.\n */\nexport type GetUserSubAccountsAddressesParameters = Compute<\n ChainIdParameter & {\n /** EOA whose subaccount addresses to list. */\n user: Address;\n /**\n * Pagination offset, in subaccounts.\n * @default 0n\n */\n offset?: bigint;\n /**\n * Pagination limit, in subaccounts. The default matches the value the SYMMIO\n * Explorer Inspector page uses.\n * @default 200n\n */\n limit?: bigint;\n }\n>;\n\n/** Return type of {@link getUserSubAccountsAddresses}. */\nexport type GetUserSubAccountsAddressesReturnType = readonly Address[];\n\n/**\n * Read the addresses of all SYMMIO subaccounts owned by `user`. A lighter\n * alternative to {@link getUserSubAccounts} when only the addresses are needed.\n *\n * Resolves the viem client and `AccountLayer` address from `config` for the\n * given chain (or the config's default chain when `chainId` is omitted).\n *\n * @param config - The SDK config.\n * @param parameters - User address, optional pagination, optional chain id.\n * @returns The user's subaccount addresses.\n * @throws {SymmError} when the chain is not supported.\n * @throws Viem's `ContractFunctionExecutionError` and friends for on-chain failures.\n *\n * @example\n * ```ts\n * const addresses = await getUserSubAccountsAddresses(config, { user: \"0xabc…\", limit: 100n });\n * ```\n */\nexport async function getUserSubAccountsAddresses(\n config: Config,\n parameters: GetUserSubAccountsAddressesParameters,\n): Promise<GetUserSubAccountsAddressesReturnType> {\n const { chainId, user, offset = 0n, limit = 200n } = parameters;\n\n const { addresses } = config.getChainConfig(chainId);\n const client = config.getClient({ chainId });\n\n return client.readContract({\n address: addresses.accountLayerAddress,\n abi: accountLayerAbi,\n functionName: \"getUserSubAccountsAddresses\",\n args: [user, offset, limit],\n });\n}\n"],"mappings":";;AA+CA,eAAsB,EACpB,GACA,GACgD;CAChD,IAAM,EAAE,YAAS,SAAM,YAAS,IAAI,WAAQ,SAAS,GAE/C,EAAE,iBAAc,EAAO,eAAe,CAAO;CAGnD,OAFe,EAAO,UAAU,EAAE,WAAQ,CAEnC,EAAO,aAAa;EACzB,SAAS,EAAU;EACnB,KAAK;EACL,cAAc;EACd,MAAM;GAAC;GAAM;GAAQ;EAAK;CAC5B,CAAC;AACH"}
@@ -14,7 +14,7 @@ export type GetUserSubAccountsParameters = Compute<ChainIdParameter & {
14
14
  */
15
15
  offset?: bigint;
16
16
  /**
17
- * Pagination limit, in subaccounts. The default matches the value the SYMM
17
+ * Pagination limit, in subaccounts. The default matches the value the SYMMIO
18
18
  * Explorer Inspector page uses.
19
19
  * @default 200n
20
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"get-user-sub-accounts.js","names":[],"sources":["../../../../src/symmio-contracts/account-layer/actions/get-user-sub-accounts.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../../shared/types/properties\";\nimport { accountLayerAbi } from \"../../abi/v0.8.5/account-layer\";\nimport type { SubAccountDetail } from \"../types\";\n\n/**\n * Parameters for {@link getUserSubAccounts}.\n */\nexport type GetUserSubAccountsParameters = Compute<\n ChainIdParameter & {\n /** EOA whose subaccounts to list. */\n user: Address;\n /**\n * Pagination offset, in subaccounts.\n * @default 0n\n */\n offset?: bigint;\n /**\n * Pagination limit, in subaccounts. The default matches the value the SYMM\n * Explorer Inspector page uses.\n * @default 200n\n */\n limit?: bigint;\n }\n>;\n\n/** Return type of {@link getUserSubAccounts}. */\nexport type GetUserSubAccountsReturnType = readonly SubAccountDetail[];\n\n/**\n * Read all SYMMIO subaccounts owned by `user`.\n *\n * Resolves the viem client and `AccountLayer` address from `config` for the\n * given chain (or the config's default chain when `chainId` is omitted).\n *\n * @param config - The SDK config.\n * @param parameters - User address, optional pagination, optional chain id.\n * @returns The user's subaccounts.\n * @throws {SymmError} when the chain is not supported.\n * @throws Viem's `ContractFunctionExecutionError` and friends for on-chain failures.\n *\n * @example\n * ```ts\n * const subs = await getUserSubAccounts(config, { user: \"0xabc…\", limit: 100n });\n * ```\n */\nexport async function getUserSubAccounts(\n config: Config,\n parameters: GetUserSubAccountsParameters,\n): Promise<GetUserSubAccountsReturnType> {\n const { chainId, user, offset = 0n, limit = 200n } = parameters;\n\n const { addresses } = config.getChainConfig(chainId);\n const client = config.getClient({ chainId });\n\n const result = await client.readContract({\n address: addresses.accountLayerAddress,\n abi: accountLayerAbi,\n functionName: \"getUserSubAccounts\",\n args: [user, offset, limit],\n });\n\n return result;\n}\n"],"mappings":";;AA+CA,eAAsB,EACpB,GACA,GACuC;CACvC,IAAM,EAAE,YAAS,SAAM,YAAS,IAAI,WAAQ,SAAS,GAE/C,EAAE,iBAAc,EAAO,eAAe,CAAO;CAUnD,OAAO,MATQ,EAAO,UAAU,EAAE,WAAQ,CAErB,EAAO,aAAa;EACvC,SAAS,EAAU;EACnB,KAAK;EACL,cAAc;EACd,MAAM;GAAC;GAAM;GAAQ;EAAK;CAC5B,CAAC;AAGH"}
1
+ {"version":3,"file":"get-user-sub-accounts.js","names":[],"sources":["../../../../src/symmio-contracts/account-layer/actions/get-user-sub-accounts.ts"],"sourcesContent":["import type { Address } from \"viem\";\nimport type { Config } from \"../../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../../shared/types/properties\";\nimport { accountLayerAbi } from \"../../abi/v0.8.5/account-layer\";\nimport type { SubAccountDetail } from \"../types\";\n\n/**\n * Parameters for {@link getUserSubAccounts}.\n */\nexport type GetUserSubAccountsParameters = Compute<\n ChainIdParameter & {\n /** EOA whose subaccounts to list. */\n user: Address;\n /**\n * Pagination offset, in subaccounts.\n * @default 0n\n */\n offset?: bigint;\n /**\n * Pagination limit, in subaccounts. The default matches the value the SYMMIO\n * Explorer Inspector page uses.\n * @default 200n\n */\n limit?: bigint;\n }\n>;\n\n/** Return type of {@link getUserSubAccounts}. */\nexport type GetUserSubAccountsReturnType = readonly SubAccountDetail[];\n\n/**\n * Read all SYMMIO subaccounts owned by `user`.\n *\n * Resolves the viem client and `AccountLayer` address from `config` for the\n * given chain (or the config's default chain when `chainId` is omitted).\n *\n * @param config - The SDK config.\n * @param parameters - User address, optional pagination, optional chain id.\n * @returns The user's subaccounts.\n * @throws {SymmError} when the chain is not supported.\n * @throws Viem's `ContractFunctionExecutionError` and friends for on-chain failures.\n *\n * @example\n * ```ts\n * const subs = await getUserSubAccounts(config, { user: \"0xabc…\", limit: 100n });\n * ```\n */\nexport async function getUserSubAccounts(\n config: Config,\n parameters: GetUserSubAccountsParameters,\n): Promise<GetUserSubAccountsReturnType> {\n const { chainId, user, offset = 0n, limit = 200n } = parameters;\n\n const { addresses } = config.getChainConfig(chainId);\n const client = config.getClient({ chainId });\n\n const result = await client.readContract({\n address: addresses.accountLayerAddress,\n abi: accountLayerAbi,\n functionName: \"getUserSubAccounts\",\n args: [user, offset, limit],\n });\n\n return result;\n}\n"],"mappings":";;AA+CA,eAAsB,EACpB,GACA,GACuC;CACvC,IAAM,EAAE,YAAS,SAAM,YAAS,IAAI,WAAQ,SAAS,GAE/C,EAAE,iBAAc,EAAO,eAAe,CAAO;CAUnD,OAAO,MATQ,EAAO,UAAU,EAAE,WAAQ,CAErB,EAAO,aAAa;EACvC,SAAS,EAAU;EACnB,KAAK;EACL,cAAc;EACd,MAAM;GAAC;GAAM;GAAQ;EAAK;CAC5B,CAAC;AAGH"}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@symmio/trading-core",
3
- "version": "0.2.0",
3
+ "version": "1.0.1",
4
4
  "description": "Framework-agnostic SYMMIO SDK. Contract calls, calculations, and transformations with no framework assumptions.",
5
5
  "license": "MIT",
6
- "homepage": "https://github.com/SYMM-IO/SYMM-Frontier/tree/main/packages/trading-core#readme",
6
+ "homepage": "https://github.com/SYMM-IO/Trading-SDK/tree/main/packages/trading-core#readme",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/SYMM-IO/SYMM-Frontier.git",
9
+ "url": "git+https://github.com/SYMM-IO/Trading-SDK.git",
10
10
  "directory": "packages/trading-core"
11
11
  },
12
- "bugs": "https://github.com/SYMM-IO/SYMM-Frontier/issues",
12
+ "bugs": "https://github.com/SYMM-IO/Trading-SDK/issues",
13
13
  "type": "module",
14
14
  "sideEffects": false,
15
15
  "main": "./dist/index.js",
@@ -48,14 +48,14 @@
48
48
  "vite": "^8.0.13",
49
49
  "vite-plugin-dts": "^5.0.0",
50
50
  "vitest": "^4.1.10",
51
- "@symmio/eslint-config": "^0.1.2",
52
- "@symmio/typescript-config": "^0.1.1"
51
+ "@symmio/eslint-config": "^1.0.0",
52
+ "@symmio/typescript-config": "^1.0.0"
53
53
  },
54
54
  "dependencies": {
55
55
  "@tanstack/query-core": "^5.90.5",
56
56
  "axios": "^1.16.1",
57
57
  "ohash": "^2.0.11",
58
- "@symmio/utils": "^0.2.0"
58
+ "@symmio/utils": "^1.0.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "vite build && node ../../scripts/fix-dts-extensions.mjs dist",