@symmio/trading-core 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/chains/registry.js +1 -1
- package/dist/core/chains/registry.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +304 -298
- package/dist/quotes/get-quote-history/solver-fees.d.ts +39 -0
- package/dist/quotes/get-quote-history/solver-fees.d.ts.map +1 -0
- package/dist/quotes/get-quote-history/solver-fees.js +36 -0
- package/dist/quotes/get-quote-history/solver-fees.js.map +1 -0
- package/dist/quotes/get-quote-history/to-history-row.d.ts.map +1 -1
- package/dist/quotes/get-quote-history/to-history-row.js +34 -30
- package/dist/quotes/get-quote-history/to-history-row.js.map +1 -1
- package/dist/quotes/get-quote-history/types.d.ts +20 -0
- package/dist/quotes/get-quote-history/types.d.ts.map +1 -1
- package/dist/quotes/get-quote-history/types.js.map +1 -1
- package/dist/solvers/get-solver-info/get-solver-info.d.ts +36 -0
- package/dist/solvers/get-solver-info/get-solver-info.d.ts.map +1 -0
- package/dist/solvers/get-solver-info/get-solver-info.js +28 -0
- package/dist/solvers/get-solver-info/get-solver-info.js.map +1 -0
- package/dist/solvers/get-solver-info/index.d.ts +3 -0
- package/dist/solvers/get-solver-info/index.d.ts.map +1 -0
- package/dist/solvers/get-solver-info/query.d.ts +29 -0
- package/dist/solvers/get-solver-info/query.d.ts.map +1 -0
- package/dist/solvers/get-solver-info/query.js +24 -0
- package/dist/solvers/get-solver-info/query.js.map +1 -0
- package/dist/solvers/instant-close/get-instant-close-fees/get-instant-close-fees.d.ts +152 -0
- package/dist/solvers/instant-close/get-instant-close-fees/get-instant-close-fees.d.ts.map +1 -0
- package/dist/solvers/instant-close/get-instant-close-fees/get-instant-close-fees.js +82 -0
- package/dist/solvers/instant-close/get-instant-close-fees/get-instant-close-fees.js.map +1 -0
- package/dist/solvers/instant-close/get-instant-close-fees/index.d.ts +3 -0
- package/dist/solvers/instant-close/get-instant-close-fees/index.d.ts.map +1 -0
- package/dist/solvers/instant-close/get-instant-close-fees/query.d.ts +37 -0
- package/dist/solvers/instant-close/get-instant-close-fees/query.d.ts.map +1 -0
- package/dist/solvers/instant-close/get-instant-close-fees/query.js +32 -0
- package/dist/solvers/instant-close/get-instant-close-fees/query.js.map +1 -0
- package/dist/solvers/instant-close/index.d.ts +1 -0
- package/dist/solvers/instant-close/index.d.ts.map +1 -1
- package/dist/solvers/instant-close/instant-close/instant-close.d.ts +4 -3
- package/dist/solvers/instant-close/instant-close/instant-close.d.ts.map +1 -1
- package/dist/solvers/instant-close/instant-close/instant-close.js +26 -22
- package/dist/solvers/instant-close/instant-close/instant-close.js.map +1 -1
- package/dist/solvers/instant-close/instant-close-bulk/instant-close-bulk.d.ts +2 -0
- package/dist/solvers/instant-close/instant-close-bulk/instant-close-bulk.d.ts.map +1 -1
- package/dist/solvers/instant-close/instant-close-bulk/instant-close-bulk.js +26 -22
- package/dist/solvers/instant-close/instant-close-bulk/instant-close-bulk.js.map +1 -1
- package/dist/solvers/instant-close/shared/calldata.d.ts +1 -1
- package/dist/solvers/instant-close/shared/calldata.d.ts.map +1 -1
- package/dist/solvers/instant-close/shared/calldata.js.map +1 -1
- package/dist/solvers/instant-close/shared/resolve-close-order-type.d.ts +13 -0
- package/dist/solvers/instant-close/shared/resolve-close-order-type.d.ts.map +1 -0
- package/dist/solvers/instant-close/shared/resolve-close-order-type.js +9 -0
- package/dist/solvers/instant-close/shared/resolve-close-order-type.js.map +1 -0
- package/dist/solvers/instant-close/shared/types.d.ts +3 -3
- package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.d.ts +111 -35
- package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.d.ts.map +1 -1
- package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.js +168 -91
- package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.js.map +1 -1
- package/dist/solvers/instant-open/get-instant-open-fees/query.d.ts +3 -2
- package/dist/solvers/instant-open/get-instant-open-fees/query.d.ts.map +1 -1
- package/dist/solvers/instant-open/get-instant-open-fees/query.js +4 -15
- package/dist/solvers/instant-open/get-instant-open-fees/query.js.map +1 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/index.d.ts +1 -0
- package/dist/solvers/instant-open/prepare-instant-open-params/index.d.ts.map +1 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts +108 -12
- package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts.map +1 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.js +169 -149
- package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.js.map +1 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/query.d.ts +49 -0
- package/dist/solvers/instant-open/prepare-instant-open-params/query.d.ts.map +1 -0
- package/dist/solvers/instant-open/prepare-instant-open-params/query.js +24 -0
- package/dist/solvers/instant-open/prepare-instant-open-params/query.js.map +1 -0
- package/dist/solvers/instant-open/prepare-instant-open-params/resolvers/index.d.ts +0 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/resolvers/index.d.ts.map +1 -1
- package/dist/solvers/instant-open/shared/full-balance-sizing.d.ts +164 -0
- package/dist/solvers/instant-open/shared/full-balance-sizing.d.ts.map +1 -0
- package/dist/solvers/instant-open/shared/full-balance-sizing.js +138 -0
- package/dist/solvers/instant-open/shared/full-balance-sizing.js.map +1 -0
- package/dist/solvers/instant-open/shared/index.d.ts +1 -0
- package/dist/solvers/instant-open/shared/index.d.ts.map +1 -1
- package/dist/solvers/instant-open/shared/resolve-instant-open-sizing.d.ts +46 -0
- package/dist/solvers/instant-open/shared/resolve-instant-open-sizing.d.ts.map +1 -0
- package/dist/solvers/instant-open/shared/resolve-instant-open-sizing.js +50 -0
- package/dist/solvers/instant-open/shared/resolve-instant-open-sizing.js.map +1 -0
- package/dist/solvers/instant-open/shared/trade-math.d.ts +73 -26
- package/dist/solvers/instant-open/shared/trade-math.d.ts.map +1 -1
- package/dist/solvers/instant-open/shared/trade-math.js +18 -13
- package/dist/solvers/instant-open/shared/trade-math.js.map +1 -1
- package/dist/solvers/instant-open/shared/types.d.ts +18 -1
- package/dist/solvers/instant-open/shared/types.d.ts.map +1 -1
- package/dist/solvers/instant-open/shared/types.js.map +1 -1
- package/dist/solvers/limit-open/prepare-limit-open-params.d.ts +3 -1
- package/dist/solvers/limit-open/prepare-limit-open-params.d.ts.map +1 -1
- package/dist/solvers/limit-open/prepare-limit-open-params.js.map +1 -1
- package/dist/solvers/shared/resolvers/index.d.ts +2 -0
- package/dist/solvers/shared/resolvers/index.d.ts.map +1 -1
- package/dist/solvers/{instant-open/prepare-instant-open-params → shared}/resolvers/resolve-fee-rates.d.ts +3 -3
- package/dist/solvers/shared/resolvers/resolve-fee-rates.d.ts.map +1 -0
- package/dist/solvers/{instant-open/prepare-instant-open-params → shared}/resolvers/resolve-fee-rates.js +2 -2
- package/dist/solvers/shared/resolvers/resolve-fee-rates.js.map +1 -0
- package/dist/solvers/shared/resolvers/resolve-market.d.ts +21 -0
- package/dist/solvers/shared/resolvers/resolve-market.d.ts.map +1 -1
- package/dist/solvers/shared/resolvers/resolve-market.js +34 -18
- package/dist/solvers/shared/resolvers/resolve-market.js.map +1 -1
- package/dist/solvers/shared/resolvers/resolve-solver-info.d.ts +29 -0
- package/dist/solvers/shared/resolvers/resolve-solver-info.d.ts.map +1 -0
- package/dist/solvers/shared/resolvers/resolve-solver-info.js +21 -0
- package/dist/solvers/shared/resolvers/resolve-solver-info.js.map +1 -0
- package/dist/solvers/shared/resolvers/types.d.ts +12 -0
- package/dist/solvers/shared/resolvers/types.d.ts.map +1 -1
- package/dist/solvers/types/generated/enigma-solver.d.ts +43 -82
- package/dist/solvers/types/generated/enigma-solver.d.ts.map +1 -1
- package/dist/solvers/types/generated/enigma-solver.js +6 -6
- package/dist/solvers/types/generated/enigma-solver.js.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/account-layer.d.ts +696 -85
- package/dist/symmio-contracts/abi/v0.8.6/account-layer.d.ts.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/account-layer.js +815 -116
- package/dist/symmio-contracts/abi/v0.8.6/account-layer.js.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/symmio.d.ts +1044 -467
- package/dist/symmio-contracts/abi/v0.8.6/symmio.d.ts.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/symmio.js +1183 -496
- package/dist/symmio-contracts/abi/v0.8.6/symmio.js.map +1 -1
- package/dist/symmio-contracts/symmio/types.d.ts +3 -1
- package/dist/symmio-contracts/symmio/types.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/types.js +1 -1
- package/dist/symmio-contracts/symmio/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/resolvers/resolve-fee-rates.d.ts.map +0 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/resolvers/resolve-fee-rates.js.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The solver fees a single `QuoteEvent` charged, decoded from its `metadata`
|
|
3
|
+
* `solverFees` list. All amounts are 18-decimal wei of collateral.
|
|
4
|
+
*/
|
|
5
|
+
export interface QuoteSolverFees {
|
|
6
|
+
/** The `SOLVER_FEE` entry, or `null` when the event carried none. */
|
|
7
|
+
solverFee: bigint | null;
|
|
8
|
+
/** The `STATIC_SOLVER_FEE` entry, or `null` when the event carried none. */
|
|
9
|
+
staticSolverFee: bigint | null;
|
|
10
|
+
/**
|
|
11
|
+
* Sum of every entry in the list — including tags this version does not name
|
|
12
|
+
* individually — or `null` when the event recorded no `solverFees` at all.
|
|
13
|
+
*/
|
|
14
|
+
totalSolverFee: bigint | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Decode the `solverFees` value of a `QuoteEvent`'s `metadata` snapshot.
|
|
18
|
+
*
|
|
19
|
+
* The subgraph records the contract's `SolverFeeEntry[]` as a list of
|
|
20
|
+
* `[tag, amount]` tuples, e.g.
|
|
21
|
+
* `[["SOLVER_FEE", "659102399999999"], ["STATIC_SOLVER_FEE", "100000000000000000"]]`.
|
|
22
|
+
* Only the fill-close and open-position events carry it; liquidation and ADL
|
|
23
|
+
* events, and deployments indexed before the fee was recorded, omit it entirely.
|
|
24
|
+
*
|
|
25
|
+
* `totalSolverFee` sums **every** well-formed entry, so a tag added by a future
|
|
26
|
+
* contract release still lands in the total even though it has no named field
|
|
27
|
+
* here. Entries whose amount is missing, unparsable, or negative are skipped.
|
|
28
|
+
*
|
|
29
|
+
* @param solverFees - The `solverFees` value off the already-parsed metadata object.
|
|
30
|
+
* @returns The named fees plus their total, each `null` when the list is absent or not a list.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const metadata = JSON.parse(event.metadata);
|
|
35
|
+
* const { solverFee, staticSolverFee, totalSolverFee } = parseSolverFees(metadata.solverFees);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseSolverFees(solverFees: unknown): QuoteSolverFees;
|
|
39
|
+
//# sourceMappingURL=solver-fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solver-fees.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/solver-fees.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAyBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAmBpE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/quotes/get-quote-history/solver-fees.ts
|
|
2
|
+
var e = "SOLVER_FEE", t = "STATIC_SOLVER_FEE", n = {
|
|
3
|
+
solverFee: null,
|
|
4
|
+
staticSolverFee: null,
|
|
5
|
+
totalSolverFee: null
|
|
6
|
+
};
|
|
7
|
+
function r(e) {
|
|
8
|
+
if (e == null) return null;
|
|
9
|
+
let t = String(e).trim();
|
|
10
|
+
if (t === "") return null;
|
|
11
|
+
let n;
|
|
12
|
+
try {
|
|
13
|
+
n = BigInt(t);
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return n >= 0n ? n : null;
|
|
18
|
+
}
|
|
19
|
+
function i(i) {
|
|
20
|
+
if (!Array.isArray(i)) return n;
|
|
21
|
+
let a = null, o = null, s = 0n;
|
|
22
|
+
for (let n of i) {
|
|
23
|
+
if (!Array.isArray(n)) continue;
|
|
24
|
+
let i = r(n[1]);
|
|
25
|
+
i !== null && (s += i, n[0] === e ? a = i : n[0] === t && (o = i));
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
solverFee: a,
|
|
29
|
+
staticSolverFee: o,
|
|
30
|
+
totalSolverFee: s
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { i as parseSolverFees };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=solver-fees.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solver-fees.js","names":[],"sources":["../../../src/quotes/get-quote-history/solver-fees.ts"],"sourcesContent":["/**\n * Metadata tag of the rate-based solver fee — `notional × rate`, so it scales\n * with the size the event settled.\n */\nconst SOLVER_FEE_TAG = \"SOLVER_FEE\";\n\n/**\n * Metadata tag of the flat solver fee — a fixed per-event charge, independent of\n * the settled size.\n */\nconst STATIC_SOLVER_FEE_TAG = \"STATIC_SOLVER_FEE\";\n\n/**\n * The solver fees a single `QuoteEvent` charged, decoded from its `metadata`\n * `solverFees` list. All amounts are 18-decimal wei of collateral.\n */\nexport interface QuoteSolverFees {\n /** The `SOLVER_FEE` entry, or `null` when the event carried none. */\n solverFee: bigint | null;\n /** The `STATIC_SOLVER_FEE` entry, or `null` when the event carried none. */\n staticSolverFee: bigint | null;\n /**\n * Sum of every entry in the list — including tags this version does not name\n * individually — or `null` when the event recorded no `solverFees` at all.\n */\n totalSolverFee: bigint | null;\n}\n\n/** The decoded shape for an event that recorded no `solverFees` list. */\nconst NO_SOLVER_FEES: QuoteSolverFees = { solverFee: null, staticSolverFee: null, totalSolverFee: null };\n\n/**\n * Read one entry's amount as a non-negative `bigint`, or `null` when it is\n * absent, unparsable, or negative (a fee is never negative, so a negative value\n * is malformed and must not skew the total).\n */\nfunction toFeeAmount(value: unknown): bigint | null {\n if (value === undefined || value === null) return null;\n\n const text = String(value).trim();\n if (text === \"\") return null;\n\n let parsed: bigint;\n try {\n parsed = BigInt(text);\n } catch {\n return null;\n }\n return parsed >= 0n ? parsed : null;\n}\n\n/**\n * Decode the `solverFees` value of a `QuoteEvent`'s `metadata` snapshot.\n *\n * The subgraph records the contract's `SolverFeeEntry[]` as a list of\n * `[tag, amount]` tuples, e.g.\n * `[[\"SOLVER_FEE\", \"659102399999999\"], [\"STATIC_SOLVER_FEE\", \"100000000000000000\"]]`.\n * Only the fill-close and open-position events carry it; liquidation and ADL\n * events, and deployments indexed before the fee was recorded, omit it entirely.\n *\n * `totalSolverFee` sums **every** well-formed entry, so a tag added by a future\n * contract release still lands in the total even though it has no named field\n * here. Entries whose amount is missing, unparsable, or negative are skipped.\n *\n * @param solverFees - The `solverFees` value off the already-parsed metadata object.\n * @returns The named fees plus their total, each `null` when the list is absent or not a list.\n *\n * @example\n * ```ts\n * const metadata = JSON.parse(event.metadata);\n * const { solverFee, staticSolverFee, totalSolverFee } = parseSolverFees(metadata.solverFees);\n * ```\n */\nexport function parseSolverFees(solverFees: unknown): QuoteSolverFees {\n if (!Array.isArray(solverFees)) return NO_SOLVER_FEES;\n\n let solverFee: bigint | null = null;\n let staticSolverFee: bigint | null = null;\n let totalSolverFee = 0n;\n\n for (const entry of solverFees) {\n if (!Array.isArray(entry)) continue;\n\n const amount = toFeeAmount(entry[1]);\n if (amount === null) continue;\n\n totalSolverFee += amount;\n if (entry[0] === SOLVER_FEE_TAG) solverFee = amount;\n else if (entry[0] === STATIC_SOLVER_FEE_TAG) staticSolverFee = amount;\n }\n\n return { solverFee, staticSolverFee, totalSolverFee };\n}\n"],"mappings":";AAIA,IAAM,IAAiB,cAMjB,IAAwB,qBAmBxB,IAAkC;CAAE,WAAW;CAAM,iBAAiB;CAAM,gBAAgB;AAAK;AAOvG,SAAS,EAAY,GAA+B;CAClD,IAAI,KAAiC,MAAM,OAAO;CAElD,IAAM,IAAO,OAAO,CAAK,EAAE,KAAK;CAChC,IAAI,MAAS,IAAI,OAAO;CAExB,IAAI;CACJ,IAAI;EACF,IAAS,OAAO,CAAI;CACtB,QAAQ;EACN,OAAO;CACT;CACA,OAAO,KAAU,KAAK,IAAS;AACjC;AAwBA,SAAgB,EAAgB,GAAsC;CACpE,IAAI,CAAC,MAAM,QAAQ,CAAU,GAAG,OAAO;CAEvC,IAAI,IAA2B,MAC3B,IAAiC,MACjC,IAAiB;CAErB,KAAK,IAAM,KAAS,GAAY;EAC9B,IAAI,CAAC,MAAM,QAAQ,CAAK,GAAG;EAE3B,IAAM,IAAS,EAAY,EAAM,EAAE;EAC/B,MAAW,SAEf,KAAkB,GACd,EAAM,OAAO,IAAgB,IAAY,IACpC,EAAM,OAAO,MAAuB,IAAkB;CACjE;CAEA,OAAO;EAAE;EAAW;EAAiB;CAAe;AACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-history-row.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/to-history-row.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;
|
|
1
|
+
{"version":3,"file":"to-history-row.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/to-history-row.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAC;AAG1G,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpE,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAqCjF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,eAAe,CAqDxE"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { LIQUIDATION_EVENT_TYPES as e, eventTypeToQuoteStatus as t } from "./close-type.js";
|
|
2
|
-
import {
|
|
2
|
+
import { parseSolverFees as n } from "./solver-fees.js";
|
|
3
|
+
import { getAddress as r } from "viem";
|
|
3
4
|
//#region src/quotes/get-quote-history/to-history-row.ts
|
|
4
|
-
function
|
|
5
|
+
function i(e) {
|
|
5
6
|
return e ? BigInt(e) : 0n;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
+
function a(e) {
|
|
8
9
|
if (!e) return null;
|
|
9
10
|
try {
|
|
10
11
|
return JSON.parse(e);
|
|
@@ -12,7 +13,7 @@ function i(e) {
|
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function o(e) {
|
|
16
17
|
if (e == null) return null;
|
|
17
18
|
let t = String(e).trim();
|
|
18
19
|
if (t === "") return null;
|
|
@@ -24,35 +25,38 @@ function a(e) {
|
|
|
24
25
|
}
|
|
25
26
|
return n > 0n ? n : null;
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
let
|
|
28
|
+
function s(s) {
|
|
29
|
+
let c = s.type, l = s.quote, u = e.has(c), d = a(s.metadata), f = d ? o(d.amount) : null, p = d ? o(d.closePrice) : null, m = d ? o(d.openedPrice) : null, h = n(d?.solverFees), g = f ?? i(l.closedAmount), _ = f ?? i(l.quantityToClose), v = p ?? i(l.averageClosedPrice), y = m ?? i(l.openedPrice), b = u ? f ?? i(l.liquidateAmount) : i(l.liquidateAmount), x = u ? p ?? i(l.liquidatePrice) : i(l.liquidatePrice);
|
|
29
30
|
return {
|
|
30
|
-
eventId:
|
|
31
|
-
closeEventType:
|
|
32
|
-
closedAt: Number(
|
|
33
|
-
quoteId:
|
|
34
|
-
marketId:
|
|
35
|
-
symbol:
|
|
36
|
-
positionType:
|
|
37
|
-
orderType:
|
|
38
|
-
quoteStatus: t[
|
|
39
|
-
quantity:
|
|
40
|
-
openedPrice:
|
|
41
|
-
requestedOpenPrice:
|
|
42
|
-
avgClosedPrice:
|
|
43
|
-
closedAmount:
|
|
44
|
-
quantityToClose:
|
|
45
|
-
liquidateAmount:
|
|
46
|
-
liquidatePrice:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
eventId: s.id,
|
|
32
|
+
closeEventType: c,
|
|
33
|
+
closedAt: Number(s.timestamp),
|
|
34
|
+
quoteId: i(s.quoteId),
|
|
35
|
+
marketId: l.symbolId ? Number(l.symbolId) : 0,
|
|
36
|
+
symbol: l.symbol ?? null,
|
|
37
|
+
positionType: l.positionType ?? 0,
|
|
38
|
+
orderType: l.orderTypeOpen ?? 0,
|
|
39
|
+
quoteStatus: t[c] ?? l.quoteStatus ?? 0,
|
|
40
|
+
quantity: i(l.quantity),
|
|
41
|
+
openedPrice: y,
|
|
42
|
+
requestedOpenPrice: i(l.requestedOpenPrice),
|
|
43
|
+
avgClosedPrice: v,
|
|
44
|
+
closedAmount: g,
|
|
45
|
+
quantityToClose: _,
|
|
46
|
+
liquidateAmount: b,
|
|
47
|
+
liquidatePrice: x,
|
|
48
|
+
solverFee: h.solverFee,
|
|
49
|
+
staticSolverFee: h.staticSolverFee,
|
|
50
|
+
totalSolverFee: h.totalSolverFee,
|
|
51
|
+
partyA: r(l.partyA),
|
|
52
|
+
partyB: l.partyB ? r(l.partyB) : null,
|
|
53
|
+
subAccount: l.subAccount ? r(l.subAccount.id) : null,
|
|
54
|
+
blockNumber: s.blockNumber ? BigInt(s.blockNumber) : void 0,
|
|
55
|
+
transaction: s.transaction ? s.transaction : void 0,
|
|
56
|
+
rawMetadata: s.metadata
|
|
53
57
|
};
|
|
54
58
|
}
|
|
55
59
|
//#endregion
|
|
56
|
-
export {
|
|
60
|
+
export { s as toQuoteHistoryRow };
|
|
57
61
|
|
|
58
62
|
//# sourceMappingURL=to-history-row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-history-row.js","names":[],"sources":["../../../src/quotes/get-quote-history/to-history-row.ts"],"sourcesContent":["import { getAddress, type Hex } from \"viem\";\nimport type { OrderType, PositionType, QuoteStatus } from \"../../symmio-contracts/symmio/types\";\nimport type { QuoteEventsForHistoryQuery } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport { eventTypeToQuoteStatus, LIQUIDATION_EVENT_TYPES } from \"./close-type\";\nimport { QuoteCloseEventType, type QuoteHistoryRow } from \"./types\";\n\n/** A single `quoteEvents` row as returned by the history query. */\nexport type RawQuoteEventRow = QuoteEventsForHistoryQuery[\"quoteEvents\"][number];\n\n/** Parse a wei string to `bigint`, defaulting null/undefined to `0n`. */\nfunction toBigInt(value: string | null | undefined): bigint {\n return value ? BigInt(value) : 0n;\n}\n\n/** Parse the event `metadata` JSON, returning `null` on absence or malformed input. */\nfunction parseMetadata(raw: string | null): Record<string, unknown> | null {\n if (!raw) return null;\n try {\n return JSON.parse(raw) as Record<string, unknown>;\n } catch {\n return null;\n }\n}\n\n/**\n * Read a wei field from the metadata snapshot as a positive `bigint`, or `null`\n * when it is absent, malformed, or non-positive (so a missing snapshot field\n * falls back to the quote's mutable value rather than overwriting it with zero).\n */\nfunction positiveWei(value: unknown): bigint | null {\n if (value === undefined || value === null) return null;\n\n const text = String(value).trim();\n if (text === \"\") return null;\n\n let parsed: bigint;\n try {\n parsed = BigInt(text);\n } catch {\n return null;\n }\n return parsed > 0n ? parsed : null;\n}\n\n/**\n * Build a {@link QuoteHistoryRow} from one immutable `quoteEvents` row, overlaying\n * the event's frozen `metadata` snapshot (amount, close price, open price) onto\n * the otherwise-mutable quote. Without this overlay, every partial-close row of a\n * quote would show its final mutable state instead of the amount/price of that\n * individual close.\n *\n * @param row - One `quoteEvents` row from {@link \"QuoteEventsForHistoryDocument\"}.\n * @returns The decoded, snapshot-applied history row.\n */\nexport function toQuoteHistoryRow(row: RawQuoteEventRow): QuoteHistoryRow {\n const eventType = row.type as QuoteCloseEventType;\n const quote = row.quote;\n const isLiquidation = LIQUIDATION_EVENT_TYPES.has(eventType);\n\n const metadata = parseMetadata(row.metadata);\n const snapshotAmount = metadata ? positiveWei(metadata.amount) : null;\n const snapshotClosePrice = metadata ? positiveWei(metadata.closePrice) : null;\n const snapshotOpenedPrice = metadata ? positiveWei(metadata.openedPrice) : null;\n\n // Overlay the immutable per-event snapshot over the mutable quote values. The\n // snapshot `amount` is this event's settled size — it drives both the closed\n // amount and the close-request quantity (mirrors the reference frontend's applyHistoryCloseEventMetadata).\n const closedAmount = snapshotAmount ?? toBigInt(quote.closedAmount);\n const quantityToClose = snapshotAmount ?? toBigInt(quote.quantityToClose);\n const avgClosedPrice = snapshotClosePrice ?? toBigInt(quote.averageClosedPrice);\n const openedPrice = snapshotOpenedPrice ?? toBigInt(quote.openedPrice);\n const liquidateAmount = isLiquidation\n ? (snapshotAmount ?? toBigInt(quote.liquidateAmount))\n : toBigInt(quote.liquidateAmount);\n const liquidatePrice = isLiquidation\n ? (snapshotClosePrice ?? toBigInt(quote.liquidatePrice))\n : toBigInt(quote.liquidatePrice);\n\n return {\n eventId: row.id,\n closeEventType: eventType,\n closedAt: Number(row.timestamp),\n quoteId: toBigInt(row.quoteId),\n marketId: quote.symbolId ? Number(quote.symbolId) : 0,\n symbol: quote.symbol ?? null,\n positionType: (quote.positionType ?? 0) as PositionType,\n orderType: (quote.orderTypeOpen ?? 0) as OrderType,\n quoteStatus: eventTypeToQuoteStatus[eventType] ?? ((quote.quoteStatus ?? 0) as QuoteStatus),\n quantity: toBigInt(quote.quantity),\n openedPrice,\n requestedOpenPrice: toBigInt(quote.requestedOpenPrice),\n avgClosedPrice,\n closedAmount,\n quantityToClose,\n liquidateAmount,\n liquidatePrice,\n partyA: getAddress(quote.partyA),\n partyB: quote.partyB ? getAddress(quote.partyB) : null,\n subAccount: quote.subAccount ? getAddress(quote.subAccount.id) : null,\n blockNumber: row.blockNumber ? BigInt(row.blockNumber) : undefined,\n transaction: row.transaction ? (row.transaction as Hex) : undefined,\n rawMetadata: row.metadata,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"to-history-row.js","names":[],"sources":["../../../src/quotes/get-quote-history/to-history-row.ts"],"sourcesContent":["import { getAddress, type Hex } from \"viem\";\nimport type { OrderType, PositionType, QuoteStatus } from \"../../symmio-contracts/symmio/types\";\nimport type { QuoteEventsForHistoryQuery } from \"../../symmio-subgraph/types/generated/analytics/graphql\";\nimport { eventTypeToQuoteStatus, LIQUIDATION_EVENT_TYPES } from \"./close-type\";\nimport { parseSolverFees } from \"./solver-fees\";\nimport { QuoteCloseEventType, type QuoteHistoryRow } from \"./types\";\n\n/** A single `quoteEvents` row as returned by the history query. */\nexport type RawQuoteEventRow = QuoteEventsForHistoryQuery[\"quoteEvents\"][number];\n\n/** Parse a wei string to `bigint`, defaulting null/undefined to `0n`. */\nfunction toBigInt(value: string | null | undefined): bigint {\n return value ? BigInt(value) : 0n;\n}\n\n/** Parse the event `metadata` JSON, returning `null` on absence or malformed input. */\nfunction parseMetadata(raw: string | null): Record<string, unknown> | null {\n if (!raw) return null;\n try {\n return JSON.parse(raw) as Record<string, unknown>;\n } catch {\n return null;\n }\n}\n\n/**\n * Read a wei field from the metadata snapshot as a positive `bigint`, or `null`\n * when it is absent, malformed, or non-positive (so a missing snapshot field\n * falls back to the quote's mutable value rather than overwriting it with zero).\n */\nfunction positiveWei(value: unknown): bigint | null {\n if (value === undefined || value === null) return null;\n\n const text = String(value).trim();\n if (text === \"\") return null;\n\n let parsed: bigint;\n try {\n parsed = BigInt(text);\n } catch {\n return null;\n }\n return parsed > 0n ? parsed : null;\n}\n\n/**\n * Build a {@link QuoteHistoryRow} from one immutable `quoteEvents` row, overlaying\n * the event's frozen `metadata` snapshot (amount, close price, open price) onto\n * the otherwise-mutable quote. Without this overlay, every partial-close row of a\n * quote would show its final mutable state instead of the amount/price of that\n * individual close.\n *\n * @param row - One `quoteEvents` row from {@link \"QuoteEventsForHistoryDocument\"}.\n * @returns The decoded, snapshot-applied history row.\n */\nexport function toQuoteHistoryRow(row: RawQuoteEventRow): QuoteHistoryRow {\n const eventType = row.type as QuoteCloseEventType;\n const quote = row.quote;\n const isLiquidation = LIQUIDATION_EVENT_TYPES.has(eventType);\n\n const metadata = parseMetadata(row.metadata);\n const snapshotAmount = metadata ? positiveWei(metadata.amount) : null;\n const snapshotClosePrice = metadata ? positiveWei(metadata.closePrice) : null;\n const snapshotOpenedPrice = metadata ? positiveWei(metadata.openedPrice) : null;\n const solverFees = parseSolverFees(metadata?.solverFees);\n\n // Overlay the immutable per-event snapshot over the mutable quote values. The\n // snapshot `amount` is this event's settled size — it drives both the closed\n // amount and the close-request quantity (mirrors the reference frontend's applyHistoryCloseEventMetadata).\n const closedAmount = snapshotAmount ?? toBigInt(quote.closedAmount);\n const quantityToClose = snapshotAmount ?? toBigInt(quote.quantityToClose);\n const avgClosedPrice = snapshotClosePrice ?? toBigInt(quote.averageClosedPrice);\n const openedPrice = snapshotOpenedPrice ?? toBigInt(quote.openedPrice);\n const liquidateAmount = isLiquidation\n ? (snapshotAmount ?? toBigInt(quote.liquidateAmount))\n : toBigInt(quote.liquidateAmount);\n const liquidatePrice = isLiquidation\n ? (snapshotClosePrice ?? toBigInt(quote.liquidatePrice))\n : toBigInt(quote.liquidatePrice);\n\n return {\n eventId: row.id,\n closeEventType: eventType,\n closedAt: Number(row.timestamp),\n quoteId: toBigInt(row.quoteId),\n marketId: quote.symbolId ? Number(quote.symbolId) : 0,\n symbol: quote.symbol ?? null,\n positionType: (quote.positionType ?? 0) as PositionType,\n orderType: (quote.orderTypeOpen ?? 0) as OrderType,\n quoteStatus: eventTypeToQuoteStatus[eventType] ?? ((quote.quoteStatus ?? 0) as QuoteStatus),\n quantity: toBigInt(quote.quantity),\n openedPrice,\n requestedOpenPrice: toBigInt(quote.requestedOpenPrice),\n avgClosedPrice,\n closedAmount,\n quantityToClose,\n liquidateAmount,\n liquidatePrice,\n solverFee: solverFees.solverFee,\n staticSolverFee: solverFees.staticSolverFee,\n totalSolverFee: solverFees.totalSolverFee,\n partyA: getAddress(quote.partyA),\n partyB: quote.partyB ? getAddress(quote.partyB) : null,\n subAccount: quote.subAccount ? getAddress(quote.subAccount.id) : null,\n blockNumber: row.blockNumber ? BigInt(row.blockNumber) : undefined,\n transaction: row.transaction ? (row.transaction as Hex) : undefined,\n rawMetadata: row.metadata,\n };\n}\n"],"mappings":";;;;AAWA,SAAS,EAAS,GAA0C;CAC1D,OAAO,IAAQ,OAAO,CAAK,IAAI;AACjC;AAGA,SAAS,EAAc,GAAoD;CACzE,IAAI,CAAC,GAAK,OAAO;CACjB,IAAI;EACF,OAAO,KAAK,MAAM,CAAG;CACvB,QAAQ;EACN,OAAO;CACT;AACF;AAOA,SAAS,EAAY,GAA+B;CAClD,IAAI,KAAiC,MAAM,OAAO;CAElD,IAAM,IAAO,OAAO,CAAK,EAAE,KAAK;CAChC,IAAI,MAAS,IAAI,OAAO;CAExB,IAAI;CACJ,IAAI;EACF,IAAS,OAAO,CAAI;CACtB,QAAQ;EACN,OAAO;CACT;CACA,OAAO,IAAS,KAAK,IAAS;AAChC;AAYA,SAAgB,EAAkB,GAAwC;CACxE,IAAM,IAAY,EAAI,MAChB,IAAQ,EAAI,OACZ,IAAgB,EAAwB,IAAI,CAAS,GAErD,IAAW,EAAc,E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igint;
|
|
93
93
|
/** Liquidation price (set only for liquidation rows). */
|
|
94
94
|
liquidatePrice: bigint;
|
|
95
|
+
/**
|
|
96
|
+
* Rate-based solver fee charged by this event (`SOLVER_FEE`), or `null` when
|
|
97
|
+
* the event carried none.
|
|
98
|
+
*/
|
|
99
|
+
solverFee: bigint | null;
|
|
100
|
+
/**
|
|
101
|
+
* Flat solver fee charged by this event (`STATIC_SOLVER_FEE`), or `null` when
|
|
102
|
+
* the event carried none.
|
|
103
|
+
*/
|
|
104
|
+
staticSolverFee: bigint | null;
|
|
105
|
+
/**
|
|
106
|
+
* Sum of every solver fee on the event — including tags this version does not
|
|
107
|
+
* name individually — or `null` when the event recorded none at all.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Only fill-close events carry solver fees: liquidation and ADL rows, and
|
|
111
|
+
* deployments indexed before the fee was recorded, read `null` on all three
|
|
112
|
+
* fee fields. The untruncated list stays on {@link QuoteHistoryRow.rawMetadata}.
|
|
113
|
+
*/
|
|
114
|
+
totalSolverFee: bigint | null;
|
|
95
115
|
/** PartyA (the SubAccount or Virtual Account that owns the quote). */
|
|
96
116
|
partyA: Address;
|
|
97
117
|
/** PartyB (the hedger/solver), or `null` when absent. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/quotes/get-quote-history/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAEhG;;;;;GAKG;AACH,oBAAY,cAAc;IACxB,yCAAyC;IACzC,GAAG,QAAQ;IACX,mCAAmC;IACnC,MAAM,WAAW;IACjB,mCAAmC;IACnC,WAAW,gBAAgB;IAC3B,2CAA2C;IAC3C,eAAe,oBAAoB;IACnC,6CAA6C;IAC7C,SAAS,cAAc;IAC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cesContent":["import type { Address, Hex } from \"viem\";\nimport type { OrderType, PositionType, QuoteStatus } from \"../../symmio-contracts/symmio/types\";\n\n/**\n * Close-type filter for quote history.\n *\n * Selects which terminal events a history read returns. Maps to the subgraph's\n * `QuoteEvent.type` values via {@link \"closeTypeToEventTypes\"}.\n */\nexport enum QuoteCloseType {\n /** Every close and liquidation event. */\n All = \"All\",\n /** Normal close (`FILL_CLOSE`). */\n Closed = \"Closed\",\n /** Force close (`FORCE_CLOSE`). */\n ForceClosed = \"ForceClosed\",\n /** Emergency close (`EMERGENCY_CLOSE`). */\n EmergencyClosed = \"EmergencyClosed\",\n /** Auto-deleveraging close (`ADL_CLOSE`). */\n AdlClosed = \"AdlClosed\",\n /** Liquidation (`LIQUIDATE_PARTY_A` / `_PARTY_B` / `_CLEARING_HOUSE`). */\n Liquidated = \"Liquidated\",\n}\n\n/**\n * Subgraph `QuoteEvent.type` values that terminate a (partial) position and\n * therefore appear in history. Each carries an immutable `metadata` snapshot.\n *\n * @remarks\n * Mirrors the event-type strings emitted by the SYMMIO subgraphs (v0.8.6+);\n * see the subgraphs `0.8.6_migration` doc — QuoteEvent metadata.\n */\nexport enum QuoteCloseEventType {\n /** A normal (partial or full) close. */\n FillClose = \"FILL_CLOSE\",\n /** A force close. */\n ForceClose = \"FORCE_CLOSE\",\n /** An emergency close. */\n EmergencyClose = \"EMERGENCY_CLOSE\",\n /** An auto-deleveraging close. */\n AdlClose = \"ADL_CLOSE\",\n /** Liquidation initiated against partyA. */\n LiquidatePartyA = \"LIQUIDATE_PARTY_A\",\n /** Liquidation initiated against partyB. */\n LiquidatePartyB = \"LIQUIDATE_PARTY_B\",\n /** Liquidation initiated by the clearing house. */\n LiquidateClearingHouse = \"LIQUIDATE_CLEARING_HOUSE\",\n}\n\n/**\n * One row of quote history — a single immutable `QuoteEvent` with its per-event\n * `metadata` snapshot overlaid onto the (otherwise mutable) quote it belongs to.\n *\n * Because the underlying `Quote` entity is mutable, a quote closed across several\n * partial closes produces several history rows that would otherwise show the same\n * final state. The snapshot overlay restores each event's own amount/price, so\n * every partial-close row is distinct.\n *\n * @remarks\n * Amounts and prices are raw `bigint` (18-decimal fixed point, no scaling),\n * matching the SDK's on-chain {@link \"Quote\"} reads. Enum fields are decoded.\n */\nexport interface QuoteHistoryRow {\n /** Stable id of the underlying immutable `QuoteEvent` (use as a row key). */\n eventId: string;\n /** The close / liquidation event that produced this row. */\n closeEventType: QuoteCloseEventType;\n /** Event block timestamp in seconds (the row's \"close time\"). */\n closedAt: number;\n /** Protocol quote id. */\n quoteId: bigint;\n /** Market identifier (`symbolId`). */\n marketId: number;\n /** Market ticker resolved by the subgraph, when known. */\n symbol: string | null;\n /** Long or short. */\n positionType: PositionType;\n /** Limit or market order (open side). */\n orderType: OrderType;\n /** Lifecycle status, forced to `CLOSED` / `LIQUIDATED` from the event type. */\n quoteStatus: QuoteStatus;\n /** Total quote quantity. */\n quantity: bigint;\n /** Open price (snapshot-overlaid when the event carried one). */\n openedPrice: bigint;\n /** Price partyA originally requested to open at. */\n requestedOpenPrice: bigint;\n /** Average close price (snapshot-overlaid with this event's close price). */\n avgClosedPrice: bigint;\n /** Amount closed by this event (snapshot `amount`). */\n closedAmount: bigint;\n /** Quantity of the close request this event settled. */\n quantityToClose: bigint;\n /** Liquidated amount (set only for liquidation rows). */\n liquidateAmount: bigint;\n /** Liquidation price (set only for liquidation rows). */\n liquidatePrice: bigint;\n /** PartyA (the SubAccount or Virtual Account that owns the quote). */\n partyA: Address;\n /** PartyB (the hedger/solver), or `null` when absent. */\n partyB: Address | null;\n /** The account-layer SubAccount address, or `null` when absent. */\n subAccount: Address | null;\n /** Block number of the event, when available. */\n blockNumber?: bigint;\n /** Transaction hash of the event, when available. */\n transaction?: Hex;\n /** Raw event `metadata` JSON string, preserved for power users. */\n rawMetadata: string | null;\n}\n"],"mappings":";AASA,IAAY,IAAL,yBAAA,GAAA;QAEL,EAAA,MAAA,OAEA,EAAA,SAAA,UAEA,EAAA,cAAA,eAEA,EAAA,kBAAA,mBAEA,EAAA,YAAA,aAEA,EAAA,aAAA;AACF,EAAA,CAAA,CAAA,GAUY,IAAL,yBAAA,GAAA;QAEL,EAAA,YAAA,cAEA,EAAA,aAAA,eAEA,EAAA,iBAAA,mBAEA,EAAA,WAAA,aAEA,EAAA,kBAAA,qBAEA,EAAA,kBAAA,qBAEA,EAAA,yBAAA;AACF,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/quotes/get-quote-history/types.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { OrderType, PositionType, QuoteStatus } from \"../../symmio-contracts/symmio/types\";\n\n/**\n * Close-type filter for quote history.\n *\n * Selects which terminal events a history read returns. Maps to the subgraph's\n * `QuoteEvent.type` values via {@link \"closeTypeToEventTypes\"}.\n */\nexport enum QuoteCloseType {\n /** Every close and liquidation event. */\n All = \"All\",\n /** Normal close (`FILL_CLOSE`). */\n Closed = \"Closed\",\n /** Force close (`FORCE_CLOSE`). */\n ForceClosed = \"ForceClosed\",\n /** Emergency close (`EMERGENCY_CLOSE`). */\n EmergencyClosed = \"EmergencyClosed\",\n /** Auto-deleveraging close (`ADL_CLOSE`). */\n AdlClosed = \"AdlClosed\",\n /** Liquidation (`LIQUIDATE_PARTY_A` / `_PARTY_B` / `_CLEARING_HOUSE`). */\n Liquidated = \"Liquidated\",\n}\n\n/**\n * Subgraph `QuoteEvent.type` values that terminate a (partial) position and\n * therefore appear in history. Each carries an immutable `metadata` snapshot.\n *\n * @remarks\n * Mirrors the event-type strings emitted by the SYMMIO subgraphs (v0.8.6+);\n * see the subgraphs `0.8.6_migration` doc — QuoteEvent metadata.\n */\nexport enum QuoteCloseEventType {\n /** A normal (partial or full) close. */\n FillClose = \"FILL_CLOSE\",\n /** A force close. */\n ForceClose = \"FORCE_CLOSE\",\n /** An emergency close. */\n EmergencyClose = \"EMERGENCY_CLOSE\",\n /** An auto-deleveraging close. */\n AdlClose = \"ADL_CLOSE\",\n /** Liquidation initiated against partyA. */\n LiquidatePartyA = \"LIQUIDATE_PARTY_A\",\n /** Liquidation initiated against partyB. */\n LiquidatePartyB = \"LIQUIDATE_PARTY_B\",\n /** Liquidation initiated by the clearing house. */\n LiquidateClearingHouse = \"LIQUIDATE_CLEARING_HOUSE\",\n}\n\n/**\n * One row of quote history — a single immutable `QuoteEvent` with its per-event\n * `metadata` snapshot overlaid onto the (otherwise mutable) quote it belongs to.\n *\n * Because the underlying `Quote` entity is mutable, a quote closed across several\n * partial closes produces several history rows that would otherwise show the same\n * final state. The snapshot overlay restores each event's own amount/price, so\n * every partial-close row is distinct.\n *\n * @remarks\n * Amounts and prices are raw `bigint` (18-decimal fixed point, no scaling),\n * matching the SDK's on-chain {@link \"Quote\"} reads. Enum fields are decoded.\n */\nexport interface QuoteHistoryRow {\n /** Stable id of the underlying immutable `QuoteEvent` (use as a row key). */\n eventId: string;\n /** The close / liquidation event that produced this row. */\n closeEventType: QuoteCloseEventType;\n /** Event block timestamp in seconds (the row's \"close time\"). */\n closedAt: number;\n /** Protocol quote id. */\n quoteId: bigint;\n /** Market identifier (`symbolId`). */\n marketId: number;\n /** Market ticker resolved by the subgraph, when known. */\n symbol: string | null;\n /** Long or short. */\n positionType: PositionType;\n /** Limit or market order (open side). */\n orderType: OrderType;\n /** Lifecycle status, forced to `CLOSED` / `LIQUIDATED` from the event type. */\n quoteStatus: QuoteStatus;\n /** Total quote quantity. */\n quantity: bigint;\n /** Open price (snapshot-overlaid when the event carried one). */\n openedPrice: bigint;\n /** Price partyA originally requested to open at. */\n requestedOpenPrice: bigint;\n /** Average close price (snapshot-overlaid with this event's close price). */\n avgClosedPrice: bigint;\n /** Amount closed by this event (snapshot `amount`). */\n closedAmount: bigint;\n /** Quantity of the close request this event settled. */\n quantityToClose: bigint;\n /** Liquidated amount (set only for liquidation rows). */\n liquidateAmount: bigint;\n /** Liquidation price (set only for liquidation rows). */\n liquidatePrice: bigint;\n /**\n * Rate-based solver fee charged by this event (`SOLVER_FEE`), or `null` when\n * the event carried none.\n */\n solverFee: bigint | null;\n /**\n * Flat solver fee charged by this event (`STATIC_SOLVER_FEE`), or `null` when\n * the event carried none.\n */\n staticSolverFee: bigint | null;\n /**\n * Sum of every solver fee on the event — including tags this version does not\n * name individually — or `null` when the event recorded none at all.\n *\n * @remarks\n * Only fill-close events carry solver fees: liquidation and ADL rows, and\n * deployments indexed before the fee was recorded, read `null` on all three\n * fee fields. The untruncated list stays on {@link QuoteHistoryRow.rawMetadata}.\n */\n totalSolverFee: bigint | null;\n /** PartyA (the SubAccount or Virtual Account that owns the quote). */\n partyA: Address;\n /** PartyB (the hedger/solver), or `null` when absent. */\n partyB: Address | null;\n /** The account-layer SubAccount address, or `null` when absent. */\n subAccount: Address | null;\n /** Block number of the event, when available. */\n blockNumber?: bigint;\n /** Transaction hash of the event, when available. */\n transaction?: Hex;\n /** Raw event `metadata` JSON string, preserved for power users. */\n rawMetadata: string | null;\n}\n"],"mappings":";AASA,IAAY,IAAL,yBAAA,GAAA;QAEL,EAAA,MAAA,OAEA,EAAA,SAAA,UAEA,EAAA,cAAA,eAEA,EAAA,kBAAA,mBAEA,EAAA,YAAA,aAEA,EAAA,aAAA;AACF,EAAA,CAAA,CAAA,GAUY,IAAL,yBAAA,GAAA;QAEL,EAAA,YAAA,cAEA,EAAA,aAAA,eAEA,EAAA,iBAAA,mBAEA,EAAA,WAAA,aAEA,EAAA,kBAAA,qBAEA,EAAA,kBAAA,qBAEA,EAAA,yBAAA;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Config } from '../../core/config/index.js';
|
|
2
|
+
import { Compute, ReadSolverParameter } from '../../shared/types/properties.js';
|
|
3
|
+
/**
|
|
4
|
+
* Static solver-fee configuration from the Enigma-only `GET /info` endpoint.
|
|
5
|
+
*
|
|
6
|
+
* A flat camelCase mirror of the wire shape; amounts are USD decimal strings
|
|
7
|
+
* exactly as the solver reports them.
|
|
8
|
+
*/
|
|
9
|
+
export interface EnigmaSolverInfo {
|
|
10
|
+
/**
|
|
11
|
+
* Configured USD amount charged per instant open, before signed fee-cap
|
|
12
|
+
* adjustments. `undefined` when the solver omits it.
|
|
13
|
+
*/
|
|
14
|
+
staticSolverFeeOpen?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Configured USD amount charged per instant close (including each partial
|
|
17
|
+
* close), before signed fee-cap adjustments. `undefined` when the solver
|
|
18
|
+
* omits it.
|
|
19
|
+
*/
|
|
20
|
+
staticSolverFeeClose?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Parameters for {@link getSolverInfo}. */
|
|
23
|
+
export type GetSolverInfoParameters = Compute<ReadSolverParameter>;
|
|
24
|
+
/** Return type of {@link getSolverInfo}. */
|
|
25
|
+
export type GetSolverInfoReturnType = EnigmaSolverInfo;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch the solver's general information via the Enigma-only `/info` endpoint.
|
|
28
|
+
*
|
|
29
|
+
* @param config - The SDK config.
|
|
30
|
+
* @param parameters - Optional chain/solver.
|
|
31
|
+
* @returns The solver's static fee configuration ({@link EnigmaSolverInfo}).
|
|
32
|
+
* @throws {SymmError} `UNSUPPORTED_BY_SOLVER` when the resolved solver is not an `enigma` solver.
|
|
33
|
+
* @throws {SymmApiError} when the API request fails.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getSolverInfo(config: Config, parameters?: GetSolverInfoParameters): Promise<GetSolverInfoReturnType>;
|
|
36
|
+
//# sourceMappingURL=get-solver-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-solver-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/get-solver-info/get-solver-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIlF;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEnE,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,uBAA4B,GACvC,OAAO,CAAC,uBAAuB,CAAC,CAqBlC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
|
|
2
|
+
import { getInfo as n } from "../types/generated/enigma-solver.js";
|
|
3
|
+
import { assertSolverKind as r } from "../assert-solver-kind.js";
|
|
4
|
+
import { isAxiosError as i } from "axios";
|
|
5
|
+
//#region src/solvers/get-solver-info/get-solver-info.ts
|
|
6
|
+
async function a(a, o = {}) {
|
|
7
|
+
let s = a.getSolver({
|
|
8
|
+
chainId: o.chainId,
|
|
9
|
+
solverId: o.solverId
|
|
10
|
+
});
|
|
11
|
+
r(s, "enigma", "getSolverInfo");
|
|
12
|
+
try {
|
|
13
|
+
let e = await n({ baseURL: s.url });
|
|
14
|
+
return {
|
|
15
|
+
staticSolverFeeOpen: e.data.static_solver_fee_open,
|
|
16
|
+
staticSolverFeeClose: e.data.static_solver_fee_close
|
|
17
|
+
};
|
|
18
|
+
} catch (n) {
|
|
19
|
+
throw n instanceof t ? n : i(n) ? e.fromAxios(n, {
|
|
20
|
+
code: "FETCH_SOLVER_INFO_FAILED",
|
|
21
|
+
baseURL: s.url
|
|
22
|
+
}) : new t("api", "FETCH_SOLVER_INFO_FAILED", `Failed to fetch solver info: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { a as getSolverInfo };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=get-solver-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-solver-info.js","names":[],"sources":["../../../src/solvers/get-solver-info/get-solver-info.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { assertSolverKind } from \"../assert-solver-kind\";\nimport { getInfo } from \"../types/generated/enigma-solver\";\n\n/**\n * Static solver-fee configuration from the Enigma-only `GET /info` endpoint.\n *\n * A flat camelCase mirror of the wire shape; amounts are USD decimal strings\n * exactly as the solver reports them.\n */\nexport interface EnigmaSolverInfo {\n /**\n * Configured USD amount charged per instant open, before signed fee-cap\n * adjustments. `undefined` when the solver omits it.\n */\n staticSolverFeeOpen?: string;\n /**\n * Configured USD amount charged per instant close (including each partial\n * close), before signed fee-cap adjustments. `undefined` when the solver\n * omits it.\n */\n staticSolverFeeClose?: string;\n}\n\n/** Parameters for {@link getSolverInfo}. */\nexport type GetSolverInfoParameters = Compute<ReadSolverParameter>;\n\n/** Return type of {@link getSolverInfo}. */\nexport type GetSolverInfoReturnType = EnigmaSolverInfo;\n\n/**\n * Fetch the solver's general information via the Enigma-only `/info` endpoint.\n *\n * @param config - The SDK config.\n * @param parameters - Optional chain/solver.\n * @returns The solver's static fee configuration ({@link EnigmaSolverInfo}).\n * @throws {SymmError} `UNSUPPORTED_BY_SOLVER` when the resolved solver is not an `enigma` solver.\n * @throws {SymmApiError} when the API request fails.\n */\nexport async function getSolverInfo(\n config: Config,\n parameters: GetSolverInfoParameters = {},\n): Promise<GetSolverInfoReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n assertSolverKind(solver, \"enigma\", \"getSolverInfo\");\n try {\n const response = await getInfo({ baseURL: solver.url });\n return {\n staticSolverFeeOpen: response.data.static_solver_fee_open,\n staticSolverFeeClose: response.data.static_solver_fee_close,\n };\n } catch (err) {\n if (err instanceof SymmError) throw err;\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_SOLVER_INFO_FAILED\", baseURL: solver.url });\n }\n throw new SymmError(\n \"api\",\n \"FETCH_SOLVER_INFO_FAILED\",\n `Failed to fetch solver info: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;AA0CA,eAAsB,EACpB,GACA,IAAsC,CAAC,GACL;CAClC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,EAAiB,GAAQ,UAAU,eAAe;CAClD,IAAI;EACF,IAAM,IAAW,MAAM,EAAQ,EAAE,SAAS,EAAO,IAAI,CAAC;EACtD,OAAO;GACL,qBAAqB,EAAS,KAAK;GACnC,sBAAsB,EAAS,KAAK;EACtC;CACF,SAAS,GAAK;EAKZ,MAJI,aAAe,IAAiB,IAChC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAA4B,SAAS,EAAO;EAAI,CAAC,IAEvF,IAAI,EACR,OACA,4BACA,gCAAgC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAC/E,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solvers/get-solver-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Config } from '../../core/config/index.js';
|
|
2
|
+
import { Compute, ConfigKeyParameter } from '../../shared/types/properties.js';
|
|
3
|
+
import { QueryParameter, SymmioQueryOptions } from '../../shared/types/query.js';
|
|
4
|
+
import { GetSolverInfoParameters, GetSolverInfoReturnType } from './get-solver-info.js';
|
|
5
|
+
/** Data resolved by the {@link getSolverInfoQueryOptions} query. */
|
|
6
|
+
export type GetSolverInfoData = GetSolverInfoReturnType;
|
|
7
|
+
/**
|
|
8
|
+
* Build the TanStack Query key for {@link getSolverInfoQueryOptions}.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Partial query parameters (chain id, solver).
|
|
11
|
+
* @returns A stable, hashable query key.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getSolverInfoQueryKey(options?: Compute<GetSolverInfoParameters & ConfigKeyParameter>): readonly ["getSolverInfo", Record<string, unknown>];
|
|
14
|
+
/** Query-key type produced by {@link getSolverInfoQueryKey}. */
|
|
15
|
+
export type GetSolverInfoQueryKey = ReturnType<typeof getSolverInfoQueryKey>;
|
|
16
|
+
/** Options accepted by {@link getSolverInfoQueryOptions}. */
|
|
17
|
+
export type GetSolverInfoOptions = Compute<GetSolverInfoParameters & QueryParameter<GetSolverInfoData, Error, GetSolverInfoData, GetSolverInfoQueryKey>>;
|
|
18
|
+
/** TanStack Query options returned by {@link getSolverInfoQueryOptions}. */
|
|
19
|
+
export type GetSolverInfoQueryOptions = SymmioQueryOptions<GetSolverInfoData, Error, GetSolverInfoData, GetSolverInfoQueryKey>;
|
|
20
|
+
/**
|
|
21
|
+
* Build TanStack Query options for {@link getSolverInfo}. A non-enigma solver
|
|
22
|
+
* surfaces `UNSUPPORTED_BY_SOLVER` from the query function.
|
|
23
|
+
*
|
|
24
|
+
* @param config - The SDK config.
|
|
25
|
+
* @param options - Query parameters and TanStack overrides.
|
|
26
|
+
* @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getSolverInfoQueryOptions(config: Config, options?: GetSolverInfoOptions): GetSolverInfoQueryOptions;
|
|
29
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/get-solver-info/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,EAAiB,KAAK,uBAAuB,EAAE,KAAK,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE9G,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,OAAO,CAAC,uBAAuB,GAAG,kBAAkB,CAAM,uDAExG;AAED,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,MAAM,oBAAoB,GAAG,OAAO,CACxC,uBAAuB,GAAG,cAAc,CAAC,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,CAAC,CAC7G,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,CACxD,iBAAiB,EACjB,KAAK,EACL,iBAAiB,EACjB,qBAAqB,CACtB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,oBAAyB,GACjC,yBAAyB,CAU3B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { filterQueryOptions as e } from "../../shared/utils/query.js";
|
|
2
|
+
import { getSolverInfo as t } from "./get-solver-info.js";
|
|
3
|
+
//#region src/solvers/get-solver-info/query.ts
|
|
4
|
+
function n(t = {}) {
|
|
5
|
+
return ["getSolverInfo", 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,
|
|
15
|
+
queryFn: () => t(e, {
|
|
16
|
+
chainId: r.chainId,
|
|
17
|
+
solverId: r.solverId
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { n as getSolverInfoQueryKey, r as getSolverInfoQueryOptions };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/get-solver-info/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 { getSolverInfo, type GetSolverInfoParameters, type GetSolverInfoReturnType } from \"./get-solver-info\";\n\n/** Data resolved by the {@link getSolverInfoQueryOptions} query. */\nexport type GetSolverInfoData = GetSolverInfoReturnType;\n\n/**\n * Build the TanStack Query key for {@link getSolverInfoQueryOptions}.\n *\n * @param options - Partial query parameters (chain id, solver).\n * @returns A stable, hashable query key.\n */\nexport function getSolverInfoQueryKey(options: Compute<GetSolverInfoParameters & ConfigKeyParameter> = {}) {\n return [\"getSolverInfo\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getSolverInfoQueryKey}. */\nexport type GetSolverInfoQueryKey = ReturnType<typeof getSolverInfoQueryKey>;\n\n/** Options accepted by {@link getSolverInfoQueryOptions}. */\nexport type GetSolverInfoOptions = Compute<\n GetSolverInfoParameters & QueryParameter<GetSolverInfoData, Error, GetSolverInfoData, GetSolverInfoQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getSolverInfoQueryOptions}. */\nexport type GetSolverInfoQueryOptions = SymmioQueryOptions<\n GetSolverInfoData,\n Error,\n GetSolverInfoData,\n GetSolverInfoQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getSolverInfo}. A non-enigma solver\n * surfaces `UNSUPPORTED_BY_SOLVER` from the query function.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n */\nexport function getSolverInfoQueryOptions(\n config: Config,\n options: GetSolverInfoOptions = {},\n): GetSolverInfoQueryOptions {\n return {\n ...options.query,\n queryKey: getSolverInfoQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () => getSolverInfo(config, { chainId: options.chainId, solverId: options.solverId }),\n };\n}\n"],"mappings":";;;AAeA,SAAgB,EAAsB,IAAiE,CAAC,GAAG;CACzG,OAAO,CAAC,iBAAiB,EAAmB,CAAO,CAAC;AACtD;AA0BA,SAAgB,EACd,GACA,IAAgC,CAAC,GACN;CAC3B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAsB;GAC9B,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eAAe,EAAc,GAAQ;GAAE,SAAS,EAAQ;GAAS,UAAU,EAAQ;EAAS,CAAC;CAC/F;AACF"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { Config } from '../../../core/config/index.js';
|
|
3
|
+
import { Compute, ReadSolverParameter } from '../../../shared/types/properties.js';
|
|
4
|
+
import { FeeForUser } from '../../../symmio-contracts/symmio/actions/get-fee-for-user.js';
|
|
5
|
+
import { EnigmaSolverInfo } from '../../get-solver-info/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Market identification for {@link getInstantCloseFees} — the id plus optional
|
|
8
|
+
* pre-fetched metadata; every pre-filled field skips part of the market fetch.
|
|
9
|
+
*/
|
|
10
|
+
export interface InstantCloseFeesMarketData {
|
|
11
|
+
/** Market / symbol id. */
|
|
12
|
+
id: number;
|
|
13
|
+
/** Pre-fetched market name. */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Pre-fetched price precision (decimals). */
|
|
16
|
+
pricePrecision?: number;
|
|
17
|
+
/** Pre-fetched quantity precision (decimals). */
|
|
18
|
+
quantityPrecision?: number;
|
|
19
|
+
/** Pre-fetched solver open-fee rate — only consulted for the resolver short-circuit. */
|
|
20
|
+
hedgerFeeOpen?: string;
|
|
21
|
+
/** Pre-fetched solver standard (floor) close-fee rate (decimal fraction string). */
|
|
22
|
+
hedgerFeeClose?: string;
|
|
23
|
+
/** Pre-fetched early (peak) close-fee rate (decimal fraction string). */
|
|
24
|
+
hedgerFeeCloseEarlyRate?: string;
|
|
25
|
+
/** Pre-fetched early-window length in seconds. */
|
|
26
|
+
hedgerFeeCloseEarlyThreshold?: number;
|
|
27
|
+
/** Pre-fetched standard-rate threshold in seconds. */
|
|
28
|
+
hedgerFeeCloseStandardThreshold?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parameters for {@link getInstantCloseFees}.
|
|
32
|
+
*/
|
|
33
|
+
export type GetInstantCloseFeesParameters = Compute<ReadSolverParameter & {
|
|
34
|
+
/** PartyA the platform close-fee rate is read for (`getFeeForUser`). */
|
|
35
|
+
subAccountAddress: Address;
|
|
36
|
+
/** Market identification + optional pre-fetched metadata. */
|
|
37
|
+
market: InstantCloseFeesMarketData;
|
|
38
|
+
/** Leveraged base-asset quantity being closed (decimal string). */
|
|
39
|
+
quantity: string;
|
|
40
|
+
/**
|
|
41
|
+
* When the position opened, in unix seconds — the holding time the solver
|
|
42
|
+
* close-fee schedule is priced at is `now − openedAt`. When omitted on a
|
|
43
|
+
* lowcap solver the schedule is priced at holding time `0` (the early-rate
|
|
44
|
+
* worst case) — the conservative default for an unknown age.
|
|
45
|
+
*/
|
|
46
|
+
openedAt?: bigint | number;
|
|
47
|
+
/**
|
|
48
|
+
* Override for "now" in unix seconds. Defaults to the current clock at
|
|
49
|
+
* call time; pass a fixed value for deterministic previews and tests.
|
|
50
|
+
*/
|
|
51
|
+
now?: number;
|
|
52
|
+
/** Pre-fetched mark price as decimal string. When omitted, fetched via the price service. */
|
|
53
|
+
markPrice?: string;
|
|
54
|
+
/** Pre-fetched on-chain fee rates (matches `getFeeForUser` return). When omitted, fetched. */
|
|
55
|
+
feeRates?: FeeForUser;
|
|
56
|
+
/**
|
|
57
|
+
* Pre-fetched solver static fees (matches `getSolverInfo` return) —
|
|
58
|
+
* **lowcap/Enigma only**; ignored on any other solver kind. When omitted on
|
|
59
|
+
* a lowcap solver, fetched via `getSolverInfo` (fail-soft: an unreachable
|
|
60
|
+
* `/info` prices the static close leg at `"0"`).
|
|
61
|
+
*/
|
|
62
|
+
solverInfo?: EnigmaSolverInfo;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Fee legs every solver kind charges **at close**.
|
|
66
|
+
*/
|
|
67
|
+
export interface BaseInstantCloseFees {
|
|
68
|
+
/**
|
|
69
|
+
* Platform close fee: `getFeeForUser.closeFee × notional / 1e18` (decimal
|
|
70
|
+
* string). Charged on-chain from the allocated balance after PnL settlement.
|
|
71
|
+
*/
|
|
72
|
+
platformCloseFee: string;
|
|
73
|
+
/** Close notional the rates were applied to: `quantity × markPrice` (decimal string). */
|
|
74
|
+
notional: string;
|
|
75
|
+
/** Sum of every close leg this kind charges (decimal string). */
|
|
76
|
+
totalFee: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Fee breakdown for a **lowcap (Enigma)** instant close. Extends the platform
|
|
80
|
+
* leg with the solver legs charged at close execution.
|
|
81
|
+
*/
|
|
82
|
+
export interface EnigmaInstantCloseFees extends BaseInstantCloseFees {
|
|
83
|
+
/** Discriminant: these fees were priced for an Enigma (lowcap) solver. */
|
|
84
|
+
kind: "enigma";
|
|
85
|
+
/**
|
|
86
|
+
* Solver close fee at the priced holding time (decimal string) — the
|
|
87
|
+
* schedule decays from the early (peak) rate to the standard rate as the
|
|
88
|
+
* position ages. Capped on-chain by the `closeRateCap` the open signed.
|
|
89
|
+
*/
|
|
90
|
+
closeSolverFee: string;
|
|
91
|
+
/** The close-fee rate the leg was priced at (decimal fraction string) — for rate displays. */
|
|
92
|
+
closeSolverFeeRate: string;
|
|
93
|
+
/** Holding time the schedule was evaluated at, in seconds. */
|
|
94
|
+
holdingSeconds: number;
|
|
95
|
+
/**
|
|
96
|
+
* Static solver close fee — a flat USD amount from the solver's `/info`
|
|
97
|
+
* config, independent of the notional (decimal string). `"0"` when the
|
|
98
|
+
* solver publishes none.
|
|
99
|
+
*/
|
|
100
|
+
staticSolverFeeClose: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Fee breakdown for a **majors (Rasa)** instant close — the platform close leg
|
|
104
|
+
* only.
|
|
105
|
+
*/
|
|
106
|
+
export interface RasaInstantCloseFees extends BaseInstantCloseFees {
|
|
107
|
+
/** Discriminant: these fees were priced for a Rasa (majors) solver. */
|
|
108
|
+
kind: "rasa";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Return type of {@link getInstantCloseFees}. Narrow on `kind` to reach the
|
|
112
|
+
* lowcap-only legs.
|
|
113
|
+
*/
|
|
114
|
+
export type GetInstantCloseFeesReturnType = EnigmaInstantCloseFees | RasaInstantCloseFees;
|
|
115
|
+
/**
|
|
116
|
+
* Preview every fee closing a position pays **right now** — priced from the
|
|
117
|
+
* current mark price and the position's real holding time, without signing or
|
|
118
|
+
* submitting anything. The open flow deliberately does not preview these legs
|
|
119
|
+
* (`getInstantOpenFees` is open-side only): at open the close notional and the
|
|
120
|
+
* holding-time rate are unknown, so the honest number only exists here.
|
|
121
|
+
*
|
|
122
|
+
* - **Both kinds**: `platformCloseFee` (on-chain `getFeeForUser.closeFee` ×
|
|
123
|
+
* close notional) — the contract charges it from the allocated balance after
|
|
124
|
+
* PnL settlement.
|
|
125
|
+
* - **Lowcap (Enigma) only**: `closeSolverFee` — the close-fee schedule
|
|
126
|
+
* (early → standard decay) evaluated at `now − openedAt` seconds, capped
|
|
127
|
+
* on-chain by the `closeRateCap` the open signed — plus the flat
|
|
128
|
+
* `staticSolverFeeClose` from the solver's `/info` config.
|
|
129
|
+
*
|
|
130
|
+
* The holding time is stamped at call time: `now` defaults to the current
|
|
131
|
+
* clock; pass it explicitly for deterministic previews. An omitted `openedAt`
|
|
132
|
+
* prices the worst case (holding time `0`, the peak rate).
|
|
133
|
+
*
|
|
134
|
+
* @throws {SymmError} `INVALID_TRADE_PARAMETERS` when `quantity` is not a
|
|
135
|
+
* positive number or the mark price resolves to zero/NaN;
|
|
136
|
+
* `RESOLVE_MARKET_NOT_FOUND` / `RESOLVE_MARK_PRICE_NOT_FOUND` for
|
|
137
|
+
* unresolvable inputs.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const fees = await getInstantCloseFees(config, {
|
|
142
|
+
* subAccountAddress,
|
|
143
|
+
* market: { id: 1 },
|
|
144
|
+
* quantity: "2.5",
|
|
145
|
+
* openedAt: position.createTimestamp,
|
|
146
|
+
* });
|
|
147
|
+
* if (fees.kind === "enigma") console.log(fees.closeSolverFee, fees.holdingSeconds);
|
|
148
|
+
* console.log(fees.totalFee);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function getInstantCloseFees(config: Config, parameters: GetInstantCloseFeesParameters): Promise<GetInstantCloseFeesReturnType>;
|
|
152
|
+
//# sourceMappingURL=get-instant-close-fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-instant-close-fees.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-close/get-instant-close-fees/get-instant-close-fees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO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