@symmio/trading-react 4.3.0 → 4.5.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/account-layer/automatic-timelock-attempt.d.ts +11 -0
- package/dist/account-layer/automatic-timelock-attempt.d.ts.map +1 -0
- package/dist/account-layer/automatic-timelock-attempt.js +41 -0
- package/dist/account-layer/automatic-timelock-attempt.js.map +1 -0
- package/dist/account-layer/index.d.ts +9 -0
- package/dist/account-layer/index.d.ts.map +1 -1
- package/dist/account-layer/index.js +41 -32
- package/dist/account-layer/use-active-virtual-account-by-key.d.ts +33 -0
- package/dist/account-layer/use-active-virtual-account-by-key.d.ts.map +1 -0
- package/dist/account-layer/use-active-virtual-account-by-key.js +27 -0
- package/dist/account-layer/use-active-virtual-account-by-key.js.map +1 -0
- package/dist/account-layer/use-add-margin.d.ts +2 -2
- package/dist/account-layer/use-add-margin.d.ts.map +1 -1
- package/dist/account-layer/use-add-margin.js +28 -17
- package/dist/account-layer/use-add-margin.js.map +1 -1
- package/dist/account-layer/use-allocate.d.ts +2 -2
- package/dist/account-layer/use-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-allocate.js +28 -17
- package/dist/account-layer/use-allocate.js.map +1 -1
- package/dist/account-layer/use-automatic-timelock-recovery.d.ts +25 -0
- package/dist/account-layer/use-automatic-timelock-recovery.d.ts.map +1 -0
- package/dist/account-layer/use-automatic-timelock-recovery.js +26 -0
- package/dist/account-layer/use-automatic-timelock-recovery.js.map +1 -0
- package/dist/account-layer/use-automatic-timelock.d.ts +48 -0
- package/dist/account-layer/use-automatic-timelock.d.ts.map +1 -0
- package/dist/account-layer/use-automatic-timelock.js +189 -0
- package/dist/account-layer/use-automatic-timelock.js.map +1 -0
- package/dist/account-layer/use-create-sub-accounts.d.ts +9 -4
- package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.js +11 -13
- package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts +3 -3
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +32 -21
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
- package/dist/account-layer/use-deallocate.d.ts +6 -5
- package/dist/account-layer/use-deallocate.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate.js +33 -20
- package/dist/account-layer/use-deallocate.js.map +1 -1
- package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
- package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
- package/dist/account-layer/use-delete-sub-account.js +30 -19
- package/dist/account-layer/use-delete-sub-account.js.map +1 -1
- package/dist/account-layer/use-execute-account-calls.d.ts +7 -0
- package/dist/account-layer/use-execute-account-calls.d.ts.map +1 -0
- package/dist/account-layer/use-execute-account-calls.js +54 -0
- package/dist/account-layer/use-execute-account-calls.js.map +1 -0
- package/dist/account-layer/use-protected-function.d.ts +22 -0
- package/dist/account-layer/use-protected-function.d.ts.map +1 -0
- package/dist/account-layer/use-protected-function.js +68 -0
- package/dist/account-layer/use-protected-function.js.map +1 -0
- package/dist/account-layer/use-remove-margin.d.ts +2 -2
- package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
- package/dist/account-layer/use-remove-margin.js +31 -20
- package/dist/account-layer/use-remove-margin.js.map +1 -1
- package/dist/account-layer/use-timelock-policy.d.ts +21 -0
- package/dist/account-layer/use-timelock-policy.d.ts.map +1 -0
- package/dist/account-layer/use-timelock-policy.js +112 -0
- package/dist/account-layer/use-timelock-policy.js.map +1 -0
- package/dist/account-layer/use-timelock-route.d.ts +75 -0
- package/dist/account-layer/use-timelock-route.d.ts.map +1 -0
- package/dist/account-layer/use-timelock-route.js +177 -0
- package/dist/account-layer/use-timelock-route.js.map +1 -0
- package/dist/account-layer/use-timelock.d.ts +102 -0
- package/dist/account-layer/use-timelock.d.ts.map +1 -0
- package/dist/account-layer/use-timelock.js +177 -0
- package/dist/account-layer/use-timelock.js.map +1 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts +24 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js +27 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js.map +1 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts +25 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts.map +1 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.js +27 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.js.map +1 -0
- package/dist/errors/normalize-protected-write-error.d.ts +5 -0
- package/dist/errors/normalize-protected-write-error.d.ts.map +1 -0
- package/dist/errors/normalize-protected-write-error.js +43 -0
- package/dist/errors/normalize-protected-write-error.js.map +1 -0
- package/dist/errors/normalize-symm-error.d.ts.map +1 -1
- package/dist/errors/normalize-symm-error.js +56 -43
- package/dist/errors/normalize-symm-error.js.map +1 -1
- package/dist/errors/symmio-request-error.d.ts +5 -0
- package/dist/errors/symmio-request-error.d.ts.map +1 -1
- package/dist/errors/symmio-request-error.js +2 -1
- package/dist/errors/symmio-request-error.js.map +1 -1
- package/dist/gasless/index.d.ts +1 -0
- package/dist/gasless/index.d.ts.map +1 -1
- package/dist/gasless/index.js +20 -19
- package/dist/gasless/invalidate-relay-reads.d.ts +3 -1
- package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -1
- package/dist/gasless/invalidate-relay-reads.js +115 -60
- package/dist/gasless/invalidate-relay-reads.js.map +1 -1
- package/dist/gasless/use-approve-operational-fee-allowance.d.ts +37 -0
- package/dist/gasless/use-approve-operational-fee-allowance.d.ts.map +1 -0
- package/dist/gasless/use-approve-operational-fee-allowance.js +48 -0
- package/dist/gasless/use-approve-operational-fee-allowance.js.map +1 -0
- package/dist/gasless/use-approve-operational-fee.d.ts +2 -2
- package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -1
- package/dist/gasless/use-approve-operational-fee.js +28 -17
- package/dist/gasless/use-approve-operational-fee.js.map +1 -1
- package/dist/gasless/use-relay-gasless-batch.d.ts +5 -4
- package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -1
- package/dist/gasless/use-relay-gasless-batch.js.map +1 -1
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -256
- package/dist/instant-layer/index.d.ts +2 -0
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +25 -23
- package/dist/instant-layer/invalidate-delegation-grant.d.ts +17 -0
- package/dist/instant-layer/invalidate-delegation-grant.d.ts.map +1 -0
- package/dist/instant-layer/invalidate-delegation-grant.js +26 -0
- package/dist/instant-layer/invalidate-delegation-grant.js.map +1 -0
- package/dist/instant-layer/use-grant-delegation.d.ts +3 -1
- package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
- package/dist/instant-layer/use-grant-delegation.js +19 -28
- package/dist/instant-layer/use-grant-delegation.js.map +1 -1
- package/dist/instant-layer/use-grant-delegations.d.ts +44 -0
- package/dist/instant-layer/use-grant-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-grant-delegations.js +36 -0
- package/dist/instant-layer/use-grant-delegations.js.map +1 -0
- package/dist/instant-layer/use-instant-close-fees.js +8 -8
- package/dist/instant-layer/use-instant-open-inputs.d.ts +1 -0
- package/dist/instant-layer/use-instant-open-inputs.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-open-inputs.js +81 -80
- package/dist/instant-layer/use-instant-open-inputs.js.map +1 -1
- package/dist/instant-layer/use-prepare-instant-open-params.d.ts +6 -0
- package/dist/instant-layer/use-prepare-instant-open-params.d.ts.map +1 -1
- package/dist/instant-layer/use-prepare-instant-open-params.js +1 -0
- package/dist/instant-layer/use-prepare-instant-open-params.js.map +1 -1
- package/dist/instant-layer/use-session-key-selectors.d.ts +5 -2
- package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -1
- package/dist/instant-layer/use-session-key-selectors.js +9 -5
- package/dist/instant-layer/use-session-key-selectors.js.map +1 -1
- package/dist/instant-layer/use-simulate-grant-delegations.d.ts +25 -0
- package/dist/instant-layer/use-simulate-grant-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-simulate-grant-delegations.js +29 -0
- package/dist/instant-layer/use-simulate-grant-delegations.js.map +1 -0
- package/dist/price-service/use-enigma-prices.d.ts +4 -0
- package/dist/price-service/use-enigma-prices.d.ts.map +1 -1
- package/dist/price-service/use-enigma-prices.js +60 -24
- package/dist/price-service/use-enigma-prices.js.map +1 -1
- package/dist/provider/symmio-provider.d.ts +31 -4
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +12 -11
- package/dist/provider/symmio-provider.js.map +1 -1
- package/dist/solvers/timelock-capability-cache.d.ts +9 -0
- package/dist/solvers/timelock-capability-cache.d.ts.map +1 -0
- package/dist/solvers/timelock-capability-cache.js +79 -0
- package/dist/solvers/timelock-capability-cache.js.map +1 -0
- package/dist/solvers/use-solver-info.d.ts +5 -2
- package/dist/solvers/use-solver-info.d.ts.map +1 -1
- package/dist/solvers/use-solver-info.js +35 -11
- package/dist/solvers/use-solver-info.js.map +1 -1
- package/dist/transactions/write-types.d.ts +13 -1
- package/dist/transactions/write-types.d.ts.map +1 -1
- package/dist/withdraw/index.d.ts +3 -0
- package/dist/withdraw/index.d.ts.map +1 -1
- package/dist/withdraw/use-deallocate-debounce-time.d.ts +29 -0
- package/dist/withdraw/use-deallocate-debounce-time.d.ts.map +1 -0
- package/dist/withdraw/use-deallocate-debounce-time.js +27 -0
- package/dist/withdraw/use-deallocate-debounce-time.js.map +1 -0
- package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.js +13 -12
- package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
- package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.js +29 -17
- package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
- package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts +19 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts.map +1 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.js +27 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.js.map +1 -0
- package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.js +14 -13
- package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
- package/dist/withdraw/use-withdraw-cooldown-of.d.ts +33 -0
- package/dist/withdraw/use-withdraw-cooldown-of.d.ts.map +1 -0
- package/dist/withdraw/use-withdraw-cooldown-of.js +27 -0
- package/dist/withdraw/use-withdraw-cooldown-of.js.map +1 -0
- package/dist/withdraw/use-withdraw.d.ts +3 -3
- package/dist/withdraw/use-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-withdraw.js +57 -31
- package/dist/withdraw/use-withdraw.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
3
|
import { useSymmioConfig as ee } from "../provider/use-symmio-config.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { useSolverInfo as te } from "../solvers/use-solver-info.js";
|
|
5
|
+
import { useFeeForUser as ne } from "../fees/use-fee-for-user.js";
|
|
6
|
+
import { useMarkets as re } from "../markets/use-markets.js";
|
|
7
|
+
import { usePriceByName as ie } from "../price-service/use-price-by-name.js";
|
|
8
8
|
import { useEstimatedPrice as t } from "../estimated-price/use-estimated-price.js";
|
|
9
9
|
import { useLockedParams as n } from "../locked-params/use-locked-params.js";
|
|
10
10
|
import { getInstantOpenFundingError as r } from "./get-instant-open-funding-error.js";
|
|
@@ -12,121 +12,122 @@ import { PositionType as i, calculateTradeParams as a } from "@symmio/trading-co
|
|
|
12
12
|
import { useMemo as ae } from "react";
|
|
13
13
|
//#region src/instant-layer/use-instant-open-inputs.ts
|
|
14
14
|
function o(o, s, c = !0) {
|
|
15
|
-
let l = ee(o), u = e(), d = o.chainId ?? u, { subAccountAddress:
|
|
15
|
+
let l = ee(o), u = e(), d = o.chainId ?? u, { subAccountAddress: oe, market: f, positionType: p, initialMargin: se, fund: m, leverage: h, solverId: g } = o, _ = m !== void 0, v = _ || o.availableBalance !== void 0, y = s === "prepare" || v, ce = s === "prepare" && l.getChainConfig(d).contractsVersion === "0.8.6", b = _ ? m.balance : se ?? "", x = c && b.length > 0, S = l.getSolver({
|
|
16
16
|
chainId: d,
|
|
17
|
-
solverId:
|
|
18
|
-
}).id === "enigma",
|
|
17
|
+
solverId: g
|
|
18
|
+
}).id === "enigma", C = x ? r({
|
|
19
19
|
...o,
|
|
20
|
-
isLowcap:
|
|
21
|
-
}) : void 0,
|
|
20
|
+
isLowcap: S
|
|
21
|
+
}) : void 0, w = x && C === void 0, T = re({
|
|
22
22
|
config: o.config,
|
|
23
23
|
chainId: d,
|
|
24
|
-
solverId:
|
|
24
|
+
solverId: g,
|
|
25
25
|
query: {
|
|
26
|
-
enabled:
|
|
26
|
+
enabled: w,
|
|
27
27
|
staleTime: 3e5
|
|
28
28
|
}
|
|
29
|
-
}).data?.find((e) => e.symbolId ===
|
|
29
|
+
}).data?.find((e) => e.symbolId === f.id), E = f.name ?? T?.name, D = f.pricePrecision ?? T?.pricePrecision, O = f.quantityPrecision ?? T?.quantityPrecision, k = f.hedgerFeeOpen ?? T?.hedgerFeeOpen, A = f.hedgerFeeClose ?? T?.hedgerFeeClose, j = f.minOpenSolverFeeCap ?? (T ? T.kind === "enigma" ? T.minOpenSolverFeeCap : "0" : void 0), M = f.minCloseSolverFeeCap ?? (T ? T.kind === "enigma" ? T.minCloseSolverFeeCap : "0" : void 0), le = !ce || j !== void 0 && M !== void 0, N = T?.kind === "enigma" ? T : void 0, ue = f.hedgerFeeCloseEarlyRate ?? N?.hedgerFeeCloseEarlyRate ?? A, de = f.hedgerFeeCloseEarlyThreshold ?? N?.hedgerFeeCloseEarlyThreshold ?? 0, fe = f.hedgerFeeCloseStandardThreshold ?? N?.hedgerFeeCloseStandardThreshold ?? 0, P = f.minAcceptablePortionLf ?? T?.minAcceptablePortionLf, F = f.minAcceptableQuoteValue ?? T?.minAcceptableQuoteValue, I = f.maxNotionalValue ?? T?.maxNotionalValue, L = f.minNotionalValue ?? T?.minNotionalValue, R = f.maxQuantity ?? T?.maxQuantity, z = f.lotSize ?? T?.lotSize, B = !v || P !== void 0 && F !== void 0 && I !== void 0 && L !== void 0 && R !== void 0 && z !== void 0, V = o.lockedParamPercent?.cva !== void 0 && o.lockedParamPercent.lf !== void 0 && o.lockedParamPercent.partyAmm !== void 0 && o.lockedParamPercent.partyBmm !== void 0, H = n({
|
|
30
30
|
config: o.config,
|
|
31
31
|
chainId: d,
|
|
32
|
-
solverId:
|
|
33
|
-
symbol:
|
|
34
|
-
leverage:
|
|
32
|
+
solverId: g,
|
|
33
|
+
symbol: E ?? "",
|
|
34
|
+
leverage: h,
|
|
35
35
|
query: {
|
|
36
|
-
enabled:
|
|
36
|
+
enabled: w && y && !V && E !== void 0,
|
|
37
37
|
staleTime: 3e5
|
|
38
38
|
}
|
|
39
|
-
}),
|
|
40
|
-
cva:
|
|
41
|
-
lf:
|
|
42
|
-
partyAmm:
|
|
43
|
-
partyBmm:
|
|
44
|
-
} : void 0,
|
|
39
|
+
}), U = V ? o.lockedParamPercent : H.data ? {
|
|
40
|
+
cva: H.data.cva ?? "0",
|
|
41
|
+
lf: H.data.lf ?? "0",
|
|
42
|
+
partyAmm: H.data.partyAmm ?? "0",
|
|
43
|
+
partyBmm: H.data.partyBmm ?? "0"
|
|
44
|
+
} : void 0, pe = !y || U !== void 0, W = te({
|
|
45
45
|
config: o.config,
|
|
46
46
|
chainId: d,
|
|
47
|
-
solverId:
|
|
47
|
+
solverId: g,
|
|
48
48
|
query: {
|
|
49
|
-
enabled:
|
|
49
|
+
enabled: w && S && o.solverInfo === void 0,
|
|
50
50
|
staleTime: 3e5,
|
|
51
51
|
retry: !1
|
|
52
52
|
}
|
|
53
|
-
}),
|
|
53
|
+
}), G = o.solverInfo ?? W.data ?? (W.isError ? {} : void 0), me = !S || G !== void 0, he = ne({
|
|
54
54
|
config: o.config,
|
|
55
55
|
chainId: d,
|
|
56
|
-
user:
|
|
57
|
-
symbolId: BigInt(
|
|
56
|
+
user: oe,
|
|
57
|
+
symbolId: BigInt(f.id),
|
|
58
58
|
query: {
|
|
59
|
-
enabled:
|
|
59
|
+
enabled: w && o.feeRates === void 0,
|
|
60
60
|
staleTime: 3e5
|
|
61
61
|
}
|
|
62
|
-
}),
|
|
63
|
-
name:
|
|
64
|
-
solverId:
|
|
65
|
-
enabled:
|
|
66
|
-
}),
|
|
67
|
-
markPrice:
|
|
62
|
+
}), K = o.feeRates ?? he.data, ge = ie({
|
|
63
|
+
name: E,
|
|
64
|
+
solverId: g,
|
|
65
|
+
enabled: w && o.markPrice === void 0
|
|
66
|
+
}), q = o.markPrice ?? ge.markPrice ?? void 0, J = ae(() => !w || !S || q === void 0 || D === void 0 || O === void 0 ? "" : a({
|
|
67
|
+
markPrice: q,
|
|
68
68
|
slippage: 0,
|
|
69
|
-
positionType:
|
|
70
|
-
userInput:
|
|
69
|
+
positionType: p,
|
|
70
|
+
userInput: b,
|
|
71
71
|
inputField: "PRICE",
|
|
72
|
-
leverage:
|
|
73
|
-
pricePrecision:
|
|
74
|
-
quantityPrecision:
|
|
72
|
+
leverage: h,
|
|
73
|
+
pricePrecision: D,
|
|
74
|
+
quantityPrecision: O
|
|
75
75
|
})?.quantity ?? "", [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
w,
|
|
77
|
+
S,
|
|
78
|
+
q,
|
|
79
|
+
D,
|
|
79
80
|
O,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
]), he = Y === void 0 ? "" : String(Number(Y) * (m === i.SHORT ? .5 : 1.5)), Z = t({
|
|
81
|
+
p,
|
|
82
|
+
b,
|
|
83
|
+
h
|
|
84
|
+
]), _e = q === void 0 ? "" : String(Number(q) * (p === i.SHORT ? .5 : 1.5)), Y = t({
|
|
85
85
|
config: o.config,
|
|
86
86
|
chainId: d,
|
|
87
|
-
solverId:
|
|
88
|
-
symbolId:
|
|
89
|
-
quantity:
|
|
90
|
-
positionType:
|
|
87
|
+
solverId: g,
|
|
88
|
+
symbolId: f.id,
|
|
89
|
+
quantity: J,
|
|
90
|
+
positionType: p,
|
|
91
91
|
entry: "open",
|
|
92
|
-
price:
|
|
92
|
+
price: _e,
|
|
93
93
|
query: {
|
|
94
|
-
enabled:
|
|
94
|
+
enabled: w && S && o.estimatedOpenPrice === void 0 && J.length > 0,
|
|
95
95
|
staleTime: 3e4
|
|
96
96
|
}
|
|
97
|
-
}),
|
|
97
|
+
}), X = S && o.estimatedOpenPrice === void 0 && (Y.isDebouncing || Y.isFetching), Z = !S || o.estimatedOpenPrice !== void 0 || !X && (Y.isFetched || Y.isError), Q = o.estimatedOpenPrice === void 0 ? Y.data?.estimatedPrice : o.estimatedOpenPrice, $ = !S || !Z ? void 0 : Q && Q !== "0" ? Q : null, ve = w && S && o.estimatedOpenPrice === void 0 && $ != null && !X && !Y.isPlaceholderData && !Y.isError ? Y.data?.estimatedPriceWithoutShadow : void 0;
|
|
98
98
|
return {
|
|
99
99
|
config: l,
|
|
100
|
-
validationError:
|
|
101
|
-
ready:
|
|
102
|
-
refetchEstimatedPrice:
|
|
103
|
-
|
|
100
|
+
validationError: C,
|
|
101
|
+
ready: w && E !== void 0 && D !== void 0 && O !== void 0 && K !== void 0 && q !== void 0 && pe && (!S || k !== void 0 && A !== void 0) && B && le && me && Z,
|
|
102
|
+
refetchEstimatedPrice: Y.refetch,
|
|
103
|
+
estimatedOpenPriceWithoutShadow: ve,
|
|
104
|
+
estimatedOpenPriceTimestamp: Y.isPlaceholderData ? void 0 : Y.dataUpdatedAt || void 0,
|
|
104
105
|
prefills: {
|
|
105
106
|
chainId: d,
|
|
106
107
|
market: {
|
|
107
|
-
id:
|
|
108
|
-
name:
|
|
109
|
-
pricePrecision:
|
|
110
|
-
quantityPrecision:
|
|
111
|
-
minOpenSolverFeeCap:
|
|
112
|
-
minCloseSolverFeeCap:
|
|
113
|
-
hedgerFeeOpen:
|
|
114
|
-
hedgerFeeClose:
|
|
115
|
-
hedgerFeeCloseEarlyRate:
|
|
116
|
-
hedgerFeeCloseEarlyThreshold:
|
|
117
|
-
hedgerFeeCloseStandardThreshold:
|
|
118
|
-
minAcceptablePortionLf:
|
|
119
|
-
minAcceptableQuoteValue:
|
|
120
|
-
maxNotionalValue:
|
|
121
|
-
minNotionalValue:
|
|
122
|
-
maxQuantity:
|
|
123
|
-
lotSize:
|
|
108
|
+
id: f.id,
|
|
109
|
+
name: E,
|
|
110
|
+
pricePrecision: D,
|
|
111
|
+
quantityPrecision: O,
|
|
112
|
+
minOpenSolverFeeCap: j,
|
|
113
|
+
minCloseSolverFeeCap: M,
|
|
114
|
+
hedgerFeeOpen: k,
|
|
115
|
+
hedgerFeeClose: A,
|
|
116
|
+
hedgerFeeCloseEarlyRate: ue,
|
|
117
|
+
hedgerFeeCloseEarlyThreshold: de,
|
|
118
|
+
hedgerFeeCloseStandardThreshold: fe,
|
|
119
|
+
minAcceptablePortionLf: P,
|
|
120
|
+
minAcceptableQuoteValue: F,
|
|
121
|
+
maxNotionalValue: I,
|
|
122
|
+
minNotionalValue: L,
|
|
123
|
+
maxQuantity: R,
|
|
124
|
+
lotSize: z
|
|
124
125
|
},
|
|
125
|
-
markPrice:
|
|
126
|
-
feeRates:
|
|
127
|
-
lockedParamPercent:
|
|
128
|
-
solverInfo:
|
|
129
|
-
estimatedOpenPrice:
|
|
126
|
+
markPrice: q,
|
|
127
|
+
feeRates: K,
|
|
128
|
+
lockedParamPercent: U,
|
|
129
|
+
solverInfo: G,
|
|
130
|
+
estimatedOpenPrice: $
|
|
130
131
|
}
|
|
131
132
|
};
|
|
132
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-instant-open-inputs.js","names":[],"sources":["../../src/instant-layer/use-instant-open-inputs.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateTradeParams,\n PositionType,\n type ConfigParameter,\n type GetInstantOpenFeesParameters,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { useEstimatedPrice } from \"../estimated-price/use-estimated-price\";\nimport { useFeeForUser } from \"../fees/use-fee-for-user\";\nimport { useLockedParams } from \"../locked-params/use-locked-params\";\nimport { useMarkets } from \"../markets/use-markets\";\nimport { usePriceByName } from \"../price-service/use-price-by-name\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useSolverInfo } from \"../solvers/use-solver-info\";\nimport { getInstantOpenFundingError } from \"./get-instant-open-funding-error\";\n\n/** Shared input orchestration for preparation and fee previews; calculations stay in core. */\nexport function useInstantOpenInputs(\n parameters: GetInstantOpenFeesParameters & ConfigParameter,\n purpose: \"prepare\" | \"fees\",\n queryEnabled = true,\n) {\n const config = useSymmioConfig(parameters);\n const contextChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? contextChainId;\n const { subAccountAddress, market, positionType, initialMargin, fund, leverage, solverId } = parameters;\n const isFullBalance = fund !== undefined;\n const canSizeFullBalance = isFullBalance || parameters.availableBalance !== undefined;\n const needsLockedParams = purpose === \"prepare\" || canSizeFullBalance;\n const needsSolverFeeCaps = purpose === \"prepare\" && config.getChainConfig(chainId).contractsVersion === \"0.8.6\";\n /** The amount driving the sizing math — the typed margin, or the whole balance in full-balance mode. */\n const sizingInput = isFullBalance ? fund.balance : (initialMargin ?? \"\");\n const requested = queryEnabled && sizingInput.length > 0;\n\n /** The dry-run estimate exists only on lowcap (Enigma) solvers. */\n const isLowcap = config.getSolver({ chainId, solverId }).id === \"enigma\";\n const validationError = requested ? getInstantOpenFundingError({ ...parameters, isLowcap }) : undefined;\n const enabled = requested && validationError === undefined;\n\n // Market metadata — slow-moving; dedupes with any other useMarkets on the page.\n const marketsQuery = useMarkets({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled, staleTime: 300_000 },\n });\n const resolvedMarket = marketsQuery.data?.find((entry) => entry.symbolId === market.id);\n const marketName = market.name ?? resolvedMarket?.name;\n const pricePrecision = market.pricePrecision ?? resolvedMarket?.pricePrecision;\n const quantityPrecision = market.quantityPrecision ?? resolvedMarket?.quantityPrecision;\n const hedgerFeeOpen = market.hedgerFeeOpen ?? resolvedMarket?.hedgerFeeOpen;\n const hedgerFeeClose = market.hedgerFeeClose ?? resolvedMarket?.hedgerFeeClose;\n\n const minOpenSolverFeeCap =\n market.minOpenSolverFeeCap ??\n (resolvedMarket ? (resolvedMarket.kind === \"enigma\" ? resolvedMarket.minOpenSolverFeeCap : \"0\") : undefined);\n const minCloseSolverFeeCap =\n market.minCloseSolverFeeCap ??\n (resolvedMarket ? (resolvedMarket.kind === \"enigma\" ? resolvedMarket.minCloseSolverFeeCap : \"0\") : undefined);\n const capsReady = !needsSolverFeeCaps || (minOpenSolverFeeCap !== undefined && minCloseSolverFeeCap !== undefined);\n\n // Time-decaying close-fee rates ride the same `useMarkets` read — Enigma-only\n // fields on `EnigmaMarket`, so narrow on `kind` before reading.\n const resolvedEnigmaMarket = resolvedMarket?.kind === \"enigma\" ? resolvedMarket : undefined;\n const hedgerFeeCloseEarlyRate =\n market.hedgerFeeCloseEarlyRate ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyRate ?? hedgerFeeClose;\n const hedgerFeeCloseEarlyThreshold =\n market.hedgerFeeCloseEarlyThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyThreshold ?? 0;\n const hedgerFeeCloseStandardThreshold =\n market.hedgerFeeCloseStandardThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseStandardThreshold ?? 0;\n\n // Quote constraints — explicit or automatic full-balance sizing snaps to the lot grid and checks the\n // published floors; they ride the same `useMarkets` read.\n const minAcceptablePortionLf = market.minAcceptablePortionLf ?? resolvedMarket?.minAcceptablePortionLf;\n const minAcceptableQuoteValue = market.minAcceptableQuoteValue ?? resolvedMarket?.minAcceptableQuoteValue;\n const maxNotionalValue = market.maxNotionalValue ?? resolvedMarket?.maxNotionalValue;\n const minNotionalValue = market.minNotionalValue ?? resolvedMarket?.minNotionalValue;\n const maxQuantity = market.maxQuantity ?? resolvedMarket?.maxQuantity;\n const lotSize = market.lotSize ?? resolvedMarket?.lotSize;\n const constraintsReady =\n !canSizeFullBalance ||\n (minAcceptablePortionLf !== undefined &&\n minAcceptableQuoteValue !== undefined &&\n maxNotionalValue !== undefined &&\n minNotionalValue !== undefined &&\n maxQuantity !== undefined &&\n lotSize !== undefined);\n\n // Preparation always needs locks; the fee preview needs them only for balance sizing.\n const locksPrefilled =\n parameters.lockedParamPercent?.cva !== undefined &&\n parameters.lockedParamPercent.lf !== undefined &&\n parameters.lockedParamPercent.partyAmm !== undefined &&\n parameters.lockedParamPercent.partyBmm !== undefined;\n const lockedParamsQuery = useLockedParams({\n config: parameters.config,\n chainId,\n solverId,\n symbol: marketName ?? \"\",\n leverage,\n query: {\n enabled: enabled && needsLockedParams && !locksPrefilled && marketName !== undefined,\n staleTime: 300_000,\n },\n });\n const lockedParamPercent = locksPrefilled\n ? parameters.lockedParamPercent\n : lockedParamsQuery.data\n ? {\n // The resolver skips its fetch only when all four fields are present —\n // mirror its `\"0\"` defaults for fields the solver omits.\n cva: lockedParamsQuery.data.cva ?? \"0\",\n lf: lockedParamsQuery.data.lf ?? \"0\",\n partyAmm: lockedParamsQuery.data.partyAmm ?? \"0\",\n partyBmm: lockedParamsQuery.data.partyBmm ?? \"0\",\n }\n : undefined;\n const lockedParamsReady = !needsLockedParams || lockedParamPercent !== undefined;\n\n // Static solver fees follow the same cached input path as the other prefills.\n // A failed optional /info read keeps core's existing zero-static-fee fallback.\n const solverInfoQuery = useSolverInfo({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled: enabled && isLowcap && parameters.solverInfo === undefined, staleTime: 300_000, retry: false },\n });\n const solverInfo = parameters.solverInfo ?? solverInfoQuery.data ?? (solverInfoQuery.isError ? {} : undefined);\n const solverInfoReady = !isLowcap || solverInfo !== undefined;\n\n // On-chain platform fee rates — contract state, changes rarely; cached hard.\n const feeQuery = useFeeForUser({\n config: parameters.config,\n chainId,\n user: subAccountAddress,\n symbolId: BigInt(market.id),\n query: { enabled: enabled && parameters.feeRates === undefined, staleTime: 300_000 },\n });\n const feeRates = parameters.feeRates ?? feeQuery.data;\n\n // Mark price — caller's cache-hot value wins; otherwise the shared stream.\n const priceQuery = usePriceByName({\n name: marketName,\n solverId,\n enabled: enabled && parameters.markPrice === undefined,\n });\n const markPrice = parameters.markPrice ?? priceQuery.markPrice ?? undefined;\n\n // Lowcap dry-run estimate: mark-sized quantity, wide fixed request bound so the\n // solver's price gate never rejects the question. Debounced internally.\n const estimateQuantity = useMemo(() => {\n if (!enabled || !isLowcap || markPrice === undefined) return \"\";\n if (pricePrecision === undefined || quantityPrecision === undefined) return \"\";\n const sized = calculateTradeParams({\n markPrice,\n slippage: 0,\n positionType,\n userInput: sizingInput,\n inputField: \"PRICE\",\n leverage,\n pricePrecision,\n quantityPrecision,\n });\n return sized?.quantity ?? \"\";\n }, [enabled, isLowcap, markPrice, pricePrecision, quantityPrecision, positionType, sizingInput, leverage]);\n const estimateRequestPrice =\n markPrice !== undefined ? String(Number(markPrice) * (positionType === PositionType.SHORT ? 0.5 : 1.5)) : \"\";\n const estimateQuery = useEstimatedPrice({\n config: parameters.config,\n chainId,\n solverId,\n symbolId: market.id,\n quantity: estimateQuantity,\n positionType,\n entry: \"open\",\n price: estimateRequestPrice,\n query: {\n enabled: enabled && isLowcap && parameters.estimatedOpenPrice === undefined && estimateQuantity.length > 0,\n staleTime: 30_000,\n },\n });\n // undefined = pending, string = available, null = settled but unavailable.\n // Pass null through to core so a failed cached request is not fetched again.\n const estimateUpdating =\n isLowcap && parameters.estimatedOpenPrice === undefined && (estimateQuery.isDebouncing || estimateQuery.isFetching);\n const estimateSettled =\n !isLowcap ||\n parameters.estimatedOpenPrice !== undefined ||\n (!estimateUpdating && (estimateQuery.isFetched || estimateQuery.isError));\n const resolvedEstimate =\n parameters.estimatedOpenPrice !== undefined ? parameters.estimatedOpenPrice : estimateQuery.data?.estimatedPrice;\n const estimatedOpenPrice =\n !isLowcap || !estimateSettled ? undefined : resolvedEstimate && resolvedEstimate !== \"0\" ? resolvedEstimate : null;\n\n // Every prefill present → the query function is pure, zero fetches.\n const ready =\n enabled &&\n marketName !== undefined &&\n pricePrecision !== undefined &&\n quantityPrecision !== undefined &&\n feeRates !== undefined &&\n markPrice !== undefined &&\n lockedParamsReady &&\n (!isLowcap || (hedgerFeeOpen !== undefined && hedgerFeeClose !== undefined)) &&\n constraintsReady &&\n capsReady &&\n solverInfoReady &&\n estimateSettled;\n\n return {\n config,\n validationError,\n ready,\n refetchEstimatedPrice: estimateQuery.refetch,\n estimatedOpenPriceTimestamp: estimateQuery.isPlaceholderData ? undefined : estimateQuery.dataUpdatedAt || undefined,\n prefills: {\n chainId,\n market: {\n id: market.id,\n name: marketName,\n pricePrecision,\n quantityPrecision,\n minOpenSolverFeeCap,\n minCloseSolverFeeCap,\n hedgerFeeOpen,\n hedgerFeeClose,\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold,\n hedgerFeeCloseStandardThreshold,\n minAcceptablePortionLf,\n minAcceptableQuoteValue,\n maxNotionalValue,\n minNotionalValue,\n maxQuantity,\n lotSize,\n },\n markPrice,\n feeRates,\n lockedParamPercent,\n solverInfo,\n estimatedOpenPrice,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,SAA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,OACC,CAAC,KAAa,MAAkB,KAAA,KAAa,MAAmB,KAAA,MACjE,KACA,MACA,MACA;EAMA,uBAAuB,EAAc;EACrC,6BAA6B,EAAc,oBAAoB,KAAA,IAAY,EAAc,iBAAiB,KAAA;EAC1G,UAAU;GACR;GACA,QAAQ;IACN,IAAI,EAAO;IACX,MAAM;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA;GACA;GACA;GACA;GACA;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-instant-open-inputs.js","names":[],"sources":["../../src/instant-layer/use-instant-open-inputs.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateTradeParams,\n PositionType,\n type ConfigParameter,\n type GetInstantOpenFeesParameters,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { useEstimatedPrice } from \"../estimated-price/use-estimated-price\";\nimport { useFeeForUser } from \"../fees/use-fee-for-user\";\nimport { useLockedParams } from \"../locked-params/use-locked-params\";\nimport { useMarkets } from \"../markets/use-markets\";\nimport { usePriceByName } from \"../price-service/use-price-by-name\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useSolverInfo } from \"../solvers/use-solver-info\";\nimport { getInstantOpenFundingError } from \"./get-instant-open-funding-error\";\n\n/** Shared input orchestration for preparation and fee previews; calculations stay in core. */\nexport function useInstantOpenInputs(\n parameters: GetInstantOpenFeesParameters & ConfigParameter,\n purpose: \"prepare\" | \"fees\",\n queryEnabled = true,\n) {\n const config = useSymmioConfig(parameters);\n const contextChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? contextChainId;\n const { subAccountAddress, market, positionType, initialMargin, fund, leverage, solverId } = parameters;\n const isFullBalance = fund !== undefined;\n const canSizeFullBalance = isFullBalance || parameters.availableBalance !== undefined;\n const needsLockedParams = purpose === \"prepare\" || canSizeFullBalance;\n const needsSolverFeeCaps = purpose === \"prepare\" && config.getChainConfig(chainId).contractsVersion === \"0.8.6\";\n /** The amount driving the sizing math — the typed margin, or the whole balance in full-balance mode. */\n const sizingInput = isFullBalance ? fund.balance : (initialMargin ?? \"\");\n const requested = queryEnabled && sizingInput.length > 0;\n\n /** The dry-run estimate exists only on lowcap (Enigma) solvers. */\n const isLowcap = config.getSolver({ chainId, solverId }).id === \"enigma\";\n const validationError = requested ? getInstantOpenFundingError({ ...parameters, isLowcap }) : undefined;\n const enabled = requested && validationError === undefined;\n\n // Market metadata — slow-moving; dedupes with any other useMarkets on the page.\n const marketsQuery = useMarkets({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled, staleTime: 300_000 },\n });\n const resolvedMarket = marketsQuery.data?.find((entry) => entry.symbolId === market.id);\n const marketName = market.name ?? resolvedMarket?.name;\n const pricePrecision = market.pricePrecision ?? resolvedMarket?.pricePrecision;\n const quantityPrecision = market.quantityPrecision ?? resolvedMarket?.quantityPrecision;\n const hedgerFeeOpen = market.hedgerFeeOpen ?? resolvedMarket?.hedgerFeeOpen;\n const hedgerFeeClose = market.hedgerFeeClose ?? resolvedMarket?.hedgerFeeClose;\n\n const minOpenSolverFeeCap =\n market.minOpenSolverFeeCap ??\n (resolvedMarket ? (resolvedMarket.kind === \"enigma\" ? resolvedMarket.minOpenSolverFeeCap : \"0\") : undefined);\n const minCloseSolverFeeCap =\n market.minCloseSolverFeeCap ??\n (resolvedMarket ? (resolvedMarket.kind === \"enigma\" ? resolvedMarket.minCloseSolverFeeCap : \"0\") : undefined);\n const capsReady = !needsSolverFeeCaps || (minOpenSolverFeeCap !== undefined && minCloseSolverFeeCap !== undefined);\n\n // Time-decaying close-fee rates ride the same `useMarkets` read — Enigma-only\n // fields on `EnigmaMarket`, so narrow on `kind` before reading.\n const resolvedEnigmaMarket = resolvedMarket?.kind === \"enigma\" ? resolvedMarket : undefined;\n const hedgerFeeCloseEarlyRate =\n market.hedgerFeeCloseEarlyRate ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyRate ?? hedgerFeeClose;\n const hedgerFeeCloseEarlyThreshold =\n market.hedgerFeeCloseEarlyThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyThreshold ?? 0;\n const hedgerFeeCloseStandardThreshold =\n market.hedgerFeeCloseStandardThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseStandardThreshold ?? 0;\n\n // Quote constraints — explicit or automatic full-balance sizing snaps to the lot grid and checks the\n // published floors; they ride the same `useMarkets` read.\n const minAcceptablePortionLf = market.minAcceptablePortionLf ?? resolvedMarket?.minAcceptablePortionLf;\n const minAcceptableQuoteValue = market.minAcceptableQuoteValue ?? resolvedMarket?.minAcceptableQuoteValue;\n const maxNotionalValue = market.maxNotionalValue ?? resolvedMarket?.maxNotionalValue;\n const minNotionalValue = market.minNotionalValue ?? resolvedMarket?.minNotionalValue;\n const maxQuantity = market.maxQuantity ?? resolvedMarket?.maxQuantity;\n const lotSize = market.lotSize ?? resolvedMarket?.lotSize;\n const constraintsReady =\n !canSizeFullBalance ||\n (minAcceptablePortionLf !== undefined &&\n minAcceptableQuoteValue !== undefined &&\n maxNotionalValue !== undefined &&\n minNotionalValue !== undefined &&\n maxQuantity !== undefined &&\n lotSize !== undefined);\n\n // Preparation always needs locks; the fee preview needs them only for balance sizing.\n const locksPrefilled =\n parameters.lockedParamPercent?.cva !== undefined &&\n parameters.lockedParamPercent.lf !== undefined &&\n parameters.lockedParamPercent.partyAmm !== undefined &&\n parameters.lockedParamPercent.partyBmm !== undefined;\n const lockedParamsQuery = useLockedParams({\n config: parameters.config,\n chainId,\n solverId,\n symbol: marketName ?? \"\",\n leverage,\n query: {\n enabled: enabled && needsLockedParams && !locksPrefilled && marketName !== undefined,\n staleTime: 300_000,\n },\n });\n const lockedParamPercent = locksPrefilled\n ? parameters.lockedParamPercent\n : lockedParamsQuery.data\n ? {\n // The resolver skips its fetch only when all four fields are present —\n // mirror its `\"0\"` defaults for fields the solver omits.\n cva: lockedParamsQuery.data.cva ?? \"0\",\n lf: lockedParamsQuery.data.lf ?? \"0\",\n partyAmm: lockedParamsQuery.data.partyAmm ?? \"0\",\n partyBmm: lockedParamsQuery.data.partyBmm ?? \"0\",\n }\n : undefined;\n const lockedParamsReady = !needsLockedParams || lockedParamPercent !== undefined;\n\n // Static solver fees follow the same cached input path as the other prefills.\n // A failed optional /info read keeps core's existing zero-static-fee fallback.\n const solverInfoQuery = useSolverInfo({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled: enabled && isLowcap && parameters.solverInfo === undefined, staleTime: 300_000, retry: false },\n });\n const solverInfo = parameters.solverInfo ?? solverInfoQuery.data ?? (solverInfoQuery.isError ? {} : undefined);\n const solverInfoReady = !isLowcap || solverInfo !== undefined;\n\n // On-chain platform fee rates — contract state, changes rarely; cached hard.\n const feeQuery = useFeeForUser({\n config: parameters.config,\n chainId,\n user: subAccountAddress,\n symbolId: BigInt(market.id),\n query: { enabled: enabled && parameters.feeRates === undefined, staleTime: 300_000 },\n });\n const feeRates = parameters.feeRates ?? feeQuery.data;\n\n // Mark price — caller's cache-hot value wins; otherwise the shared stream.\n const priceQuery = usePriceByName({\n name: marketName,\n solverId,\n enabled: enabled && parameters.markPrice === undefined,\n });\n const markPrice = parameters.markPrice ?? priceQuery.markPrice ?? undefined;\n\n // Lowcap dry-run estimate: mark-sized quantity, wide fixed request bound so the\n // solver's price gate never rejects the question. Debounced internally.\n const estimateQuantity = useMemo(() => {\n if (!enabled || !isLowcap || markPrice === undefined) return \"\";\n if (pricePrecision === undefined || quantityPrecision === undefined) return \"\";\n const sized = calculateTradeParams({\n markPrice,\n slippage: 0,\n positionType,\n userInput: sizingInput,\n inputField: \"PRICE\",\n leverage,\n pricePrecision,\n quantityPrecision,\n });\n return sized?.quantity ?? \"\";\n }, [enabled, isLowcap, markPrice, pricePrecision, quantityPrecision, positionType, sizingInput, leverage]);\n const estimateRequestPrice =\n markPrice !== undefined ? String(Number(markPrice) * (positionType === PositionType.SHORT ? 0.5 : 1.5)) : \"\";\n const estimateQuery = useEstimatedPrice({\n config: parameters.config,\n chainId,\n solverId,\n symbolId: market.id,\n quantity: estimateQuantity,\n positionType,\n entry: \"open\",\n price: estimateRequestPrice,\n query: {\n enabled: enabled && isLowcap && parameters.estimatedOpenPrice === undefined && estimateQuantity.length > 0,\n staleTime: 30_000,\n },\n });\n // undefined = pending, string = available, null = settled but unavailable.\n // Pass null through to core so a failed cached request is not fetched again.\n const estimateUpdating =\n isLowcap && parameters.estimatedOpenPrice === undefined && (estimateQuery.isDebouncing || estimateQuery.isFetching);\n const estimateSettled =\n !isLowcap ||\n parameters.estimatedOpenPrice !== undefined ||\n (!estimateUpdating && (estimateQuery.isFetched || estimateQuery.isError));\n const resolvedEstimate =\n parameters.estimatedOpenPrice !== undefined ? parameters.estimatedOpenPrice : estimateQuery.data?.estimatedPrice;\n const estimatedOpenPrice =\n !isLowcap || !estimateSettled ? undefined : resolvedEstimate && resolvedEstimate !== \"0\" ? resolvedEstimate : null;\n // Only pair diagnostics with the settled SDK-managed estimate, never a\n // caller override or a cached response for inputs that are still changing.\n const estimatedOpenPriceWithoutShadow =\n enabled &&\n isLowcap &&\n parameters.estimatedOpenPrice === undefined &&\n estimatedOpenPrice != null &&\n !estimateUpdating &&\n !estimateQuery.isPlaceholderData &&\n !estimateQuery.isError\n ? estimateQuery.data?.estimatedPriceWithoutShadow\n : undefined;\n\n // Every prefill present → the query function is pure, zero fetches.\n const ready =\n enabled &&\n marketName !== undefined &&\n pricePrecision !== undefined &&\n quantityPrecision !== undefined &&\n feeRates !== undefined &&\n markPrice !== undefined &&\n lockedParamsReady &&\n (!isLowcap || (hedgerFeeOpen !== undefined && hedgerFeeClose !== undefined)) &&\n constraintsReady &&\n capsReady &&\n solverInfoReady &&\n estimateSettled;\n\n return {\n config,\n validationError,\n ready,\n refetchEstimatedPrice: estimateQuery.refetch,\n estimatedOpenPriceWithoutShadow,\n estimatedOpenPriceTimestamp: estimateQuery.isPlaceholderData ? undefined : estimateQuery.dataUpdatedAt || undefined,\n prefills: {\n chainId,\n market: {\n id: market.id,\n name: marketName,\n pricePrecision,\n quantityPrecision,\n minOpenSolverFeeCap,\n minCloseSolverFeeCap,\n hedgerFeeOpen,\n hedgerFeeClose,\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold,\n hedgerFeeCloseStandardThreshold,\n minAcceptablePortionLf,\n minAcceptableQuoteValue,\n maxNotionalValue,\n minNotionalValue,\n maxQuantity,\n lotSize,\n },\n markPrice,\n feeRates,\n lockedParamPercent,\n solverInfo,\n estimatedOpenPrice,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,SAAgB,EACd,GACA,GACA,IAAe,IACf;CACA,IAAM,IAAS,GAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAChC,EAAE,uBAAmB,WAAQ,iBAAc,mBAAe,SAAM,aAAU,gBAAa,GACvF,IAAgB,MAAS,KAAA,GACzB,IAAqB,KAAiB,EAAW,qBAAqB,KAAA,GACtE,IAAoB,MAAY,aAAa,GAC7C,KAAqB,MAAY,aAAa,EAAO,eAAe,CAAO,EAAE,qBAAqB,SAElG,IAAc,IAAgB,EAAK,UAAW,MAAiB,IAC/D,IAAY,KAAgB,EAAY,SAAS,GAGjD,IAAW,EAAO,UAAU;EAAE;EAAS;CAAS,CAAC,EAAE,OAAO,UAC1D,IAAkB,IAAY,EAA2B;EAAE,GAAG;EAAY;CAAS,CAAC,IAAI,KAAA,GACxF,IAAU,KAAa,MAAoB,KAAA,GAS3C,IANe,GAAW;EAC9B,QAAQ,EAAW;EACnB;EACA;EACA,OAAO;GAAE;GAAS,WAAW;EAAQ;CACvC,CACuB,EAAa,MAAM,MAAM,MAAU,EAAM,aAAa,EAAO,EAAE,GAChF,IAAa,EAAO,QAAQ,GAAgB,MAC5C,IAAiB,EAAO,kBAAkB,GAAgB,gBAC1D,IAAoB,EAAO,qBAAqB,GAAgB,mBAChE,IAAgB,EAAO,i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J,KAAY,EAAW,uBAAuB,KAAA,MAAc,EAAc,gBAAgB,EAAc,aACpG,IACJ,CAAC,KACD,EAAW,uBAAuB,KAAA,KACjC,CAAC,MAAqB,EAAc,aAAa,EAAc,UAC5D,IACJ,EAAW,uBAAuB,KAAA,IAA4C,EAAc,MAAM,iBAApD,EAAW,oBACrD,IACJ,CAAC,KAAY,CAAC,IAAkB,KAAA,IAAY,KAAoB,MAAqB,MAAM,IAAmB,MAG1G,KACJ,KACA,KACA,EAAW,uBAAuB,KAAA,KAClC,KAAsB,QACtB,CAAC,KACD,CAAC,EAAc,qBACf,CAAC,EAAc,UACX,EAAc,MAAM,8BACpB,KAAA;CAiBN,OAAO;EACL;EACA;EACA,OAhBA,KACA,MAAe,KAAA,KACf,MAAmB,KAAA,KACnB,MAAsB,KAAA,KACtB,MAAa,KAAA,KACb,MAAc,KAAA,KACd,OACC,CAAC,KAAa,MAAkB,KAAA,KAAa,MAAmB,KAAA,MACjE,KACA,MACA,MACA;EAMA,uBAAuB,EAAc;EACrC;EACA,6BAA6B,EAAc,oBAAoB,KAAA,IAAY,EAAc,iBAAiB,KAAA;EAC1G,UAAU;GACR;GACA,QAAQ;IACN,IAAI,EAAO;IACX,MAAM;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA;GACA;GACA;GACA;GACA;EACF;CACF;AACF"}
|
|
@@ -23,6 +23,12 @@ export type UsePrepareInstantOpenParamsReturnType = UseQueryResult<PrepareInstan
|
|
|
23
23
|
* preview bit-for-bit.
|
|
24
24
|
*/
|
|
25
25
|
estimatedOpenPrice: string | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Diagnostic no-shadow price from the same settled SDK-managed estimate.
|
|
28
|
+
* Absent for older solvers, pending/failed estimates or caller-supplied
|
|
29
|
+
* estimatedOpenPrice. Never use it for preparation, fees or submission.
|
|
30
|
+
*/
|
|
31
|
+
estimatedOpenPriceWithoutShadow?: string;
|
|
26
32
|
/** Arrival time of the fetched estimate in epoch milliseconds. The frontend decides when to refresh or expire it. */
|
|
27
33
|
estimatedOpenPriceTimestamp: number | undefined;
|
|
28
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-prepare-instant-open-params.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-prepare-instant-open-params.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACxC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAG1F;;;;;;GAMG;AACH,MAAM,MAAM,qCAAqC,GAAG,+BAA+B,GAAG,eAAe,CAAC;AAEtG;;;;GAIG;AACH,MAAM,MAAM,qCAAqC,GAAG,cAAc,CAChE,kCAAkC,EAClC,kBAAkB,CACnB,GAAG;IACF;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,qHAAqH;IACrH,2BAA2B,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD;;;;OAIG;IACH,qBAAqB,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAC9D,4FAA4F;IAC5F,eAAe,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAChD,8FAA8F;IAC9F,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,qCAAqC,GAChD,qCAAqC,
|
|
1
|
+
{"version":3,"file":"use-prepare-instant-open-params.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-prepare-instant-open-params.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACxC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAG1F;;;;;;GAMG;AACH,MAAM,MAAM,qCAAqC,GAAG,+BAA+B,GAAG,eAAe,CAAC;AAEtG;;;;GAIG;AACH,MAAM,MAAM,qCAAqC,GAAG,cAAc,CAChE,kCAAkC,EAClC,kBAAkB,CACnB,GAAG;IACF;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,qHAAqH;IACrH,2BAA2B,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD;;;;OAIG;IACH,qBAAqB,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAC9D,4FAA4F;IAC5F,eAAe,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAChD,8FAA8F;IAC9F,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,qCAAqC,GAChD,qCAAqC,CA+BvC"}
|
|
@@ -28,6 +28,7 @@ function i(i) {
|
|
|
28
28
|
refetchEstimatedPrice: a.refetchEstimatedPrice,
|
|
29
29
|
validationError: a.validationError,
|
|
30
30
|
estimatedOpenPrice: a.prefills.estimatedOpenPrice,
|
|
31
|
+
estimatedOpenPriceWithoutShadow: a.estimatedOpenPriceWithoutShadow,
|
|
31
32
|
estimatedOpenPriceTimestamp: i.estimatedOpenPriceTimestamp ?? a.estimatedOpenPriceTimestamp,
|
|
32
33
|
isReady: a.ready && s.isSuccess && !s.isFetching && !s.isPlaceholderData
|
|
33
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-prepare-instant-open-params.js","names":[],"sources":["../../src/instant-layer/use-prepare-instant-open-params.ts"],"sourcesContent":["\"use client\";\n\nimport {\n prepareInstantOpenParamsQueryOptions,\n type ConfigParameter,\n type PrepareInstantOpenParamsOptions,\n type PrepareInstantOpenParamsReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport type { UseEstimatedPriceReturnType } from \"../estimated-price/use-estimated-price\";\nimport { useInstantOpenInputs } from \"./use-instant-open-inputs\";\n\n/**\n * Parameters for {@link usePrepareInstantOpenParams}: the same trade intent the\n * submit takes (`subAccountAddress`, `from`, `market`, `positionType`,\n * `initialMargin` **or** `fund`, optional `availableBalance` for automatic sizing,\n * `leverage`, optional `slippage` / pre-fetched\n * data, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UsePrepareInstantOpenParamsParameters = PrepareInstantOpenParamsOptions & ConfigParameter;\n\n/**\n * Return type of {@link usePrepareInstantOpenParams}: the query result carrying\n * the prepared {@link PrepareInstantOpenParamsReturnType}, plus the dry-run estimate the\n * params were built with.\n */\nexport type UsePrepareInstantOpenParamsReturnType = UseQueryResult<\n PrepareInstantOpenParamsReturnType,\n SymmioRequestError\n> & {\n /**\n * The dry-run estimate the preview was built with (`null` when unavailable;\n * `undefined` while pending or on a non-lowcap solver). Forward it as\n * `estimatedOpenPrice` to the submit so its `margin.amount` — whose settlement leg tracks the estimate — matches this\n * preview bit-for-bit.\n */\n estimatedOpenPrice: string | null | undefined;\n /** Arrival time of the fetched estimate in epoch milliseconds. The frontend decides when to refresh or expire it. */\n estimatedOpenPriceTimestamp: number | undefined;\n /**\n * Refetch the SDK-managed estimate on the frontend's schedule. Resolves when\n * the estimate request finishes; use isReady to await preparation. A supplied\n * estimatedOpenPrice still takes precedence over the fetched value.\n */\n refetchEstimatedPrice: UseEstimatedPriceReturnType[\"refetch\"];\n /** Synchronous input error. Display before query.error; dependent queries stay disabled. */\n validationError: SymmioRequestError | undefined;\n /** True when all inputs and the current preparation have settled; gate submission on this. */\n isReady: boolean;\n};\n\n/**\n * Live-preview the exact {@link PrepareInstantOpenParamsReturnType} an instant-open submit\n * will sign — `order` (price + quantity), `lockedParam`, `margin.amount`, and\n * `solverFeeCaps` — by running `prepareInstantOpenParams` as a read.\n * `prepareInstantOpenParams` neither signs nor submits, so this is safe to run\n * live; drive a \"quote preview\" from it and what the user sees is bit-for-bit\n * what `sendQuote` receives, with no separate local recomputation to drift.\n *\n * Like {@link useInstantOpenFees}, it **pre-fetches every input through its own\n * cached queries** (market metadata, mark price, locked params, on-chain fee\n * rates, solver info, and the lowcap dry-run estimate) and passes them in as\n * prefills, so the query function is pure and does no per-render network. Previous data is kept\n * while inputs move, so a mark-price tick updates the numbers in place.\n *\n * For bit-for-bit parity on `margin.amount`, forward {@link\n * UsePrepareInstantOpenParamsReturnType.estimatedOpenPrice} to the submit call\n * (`useInstantOpenAuto` / `useInstantOpenWithTpSl`) as `estimatedOpenPrice`, so\n * both the preview and the send provision settlement at the same estimate. The\n * full-balance sizing decision and quantity also depend on that estimate.\n * Gate submission on `isReady` while inputs or the estimate are settling.\n * Display `validationError ?? error`; input errors are synchronous, including offline.\n * A disabled hook or empty input remains idle without input validation.\n *\n * @example\n * ```tsx\n * const preview = usePrepareInstantOpenParams({\n * subAccountAddress,\n * from: sessionKey,\n * market: { id: symbolId },\n * positionType,\n * initialMargin,\n * leverage,\n * slippage,\n * });\n * // preview.data?.order.quantity — the exact leveraged quantity (wei) the send signs\n * // submit: mutate({ …, estimatedOpenPrice: preview.estimatedOpenPrice })\n * ```\n */\nexport function usePrepareInstantOpenParams(\n parameters: UsePrepareInstantOpenParamsParameters,\n): UsePrepareInstantOpenParamsReturnType {\n const inputs = useInstantOpenInputs(parameters, \"prepare\", parameters.query?.enabled !== false);\n const options = prepareInstantOpenParamsQueryOptions(inputs.config, {\n ...parameters,\n ...inputs.prefills,\n query: {\n ...parameters.query,\n enabled: inputs.ready,\n placeholderData: (previous) => (inputs.validationError === undefined ? previous : undefined),\n },\n });\n const query = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<PrepareInstantOpenParamsReturnType, SymmioRequestError>;\n\n return {\n ...query,\n refetchEstimatedPrice: inputs.refetchEstimatedPrice,\n validationError: inputs.validationError,\n estimatedOpenPrice: inputs.prefills.estimatedOpenPrice,\n estimatedOpenPriceTimestamp: parameters.estimatedOpenPriceTimestamp ?? inputs.estimatedOpenPriceTimestamp,\n isReady: inputs.ready && query.isSuccess && !query.isFetching && !query.isPlaceholderData,\n };\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"use-prepare-instant-open-params.js","names":[],"sources":["../../src/instant-layer/use-prepare-instant-open-params.ts"],"sourcesContent":["\"use client\";\n\nimport {\n prepareInstantOpenParamsQueryOptions,\n type ConfigParameter,\n type PrepareInstantOpenParamsOptions,\n type PrepareInstantOpenParamsReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport type { UseEstimatedPriceReturnType } from \"../estimated-price/use-estimated-price\";\nimport { useInstantOpenInputs } from \"./use-instant-open-inputs\";\n\n/**\n * Parameters for {@link usePrepareInstantOpenParams}: the same trade intent the\n * submit takes (`subAccountAddress`, `from`, `market`, `positionType`,\n * `initialMargin` **or** `fund`, optional `availableBalance` for automatic sizing,\n * `leverage`, optional `slippage` / pre-fetched\n * data, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UsePrepareInstantOpenParamsParameters = PrepareInstantOpenParamsOptions & ConfigParameter;\n\n/**\n * Return type of {@link usePrepareInstantOpenParams}: the query result carrying\n * the prepared {@link PrepareInstantOpenParamsReturnType}, plus the dry-run estimate the\n * params were built with.\n */\nexport type UsePrepareInstantOpenParamsReturnType = UseQueryResult<\n PrepareInstantOpenParamsReturnType,\n SymmioRequestError\n> & {\n /**\n * The dry-run estimate the preview was built with (`null` when unavailable;\n * `undefined` while pending or on a non-lowcap solver). Forward it as\n * `estimatedOpenPrice` to the submit so its `margin.amount` — whose settlement leg tracks the estimate — matches this\n * preview bit-for-bit.\n */\n estimatedOpenPrice: string | null | undefined;\n /**\n * Diagnostic no-shadow price from the same settled SDK-managed estimate.\n * Absent for older solvers, pending/failed estimates or caller-supplied\n * estimatedOpenPrice. Never use it for preparation, fees or submission.\n */\n estimatedOpenPriceWithoutShadow?: string;\n /** Arrival time of the fetched estimate in epoch milliseconds. The frontend decides when to refresh or expire it. */\n estimatedOpenPriceTimestamp: number | undefined;\n /**\n * Refetch the SDK-managed estimate on the frontend's schedule. Resolves when\n * the estimate request finishes; use isReady to await preparation. A supplied\n * estimatedOpenPrice still takes precedence over the fetched value.\n */\n refetchEstimatedPrice: UseEstimatedPriceReturnType[\"refetch\"];\n /** Synchronous input error. Display before query.error; dependent queries stay disabled. */\n validationError: SymmioRequestError | undefined;\n /** True when all inputs and the current preparation have settled; gate submission on this. */\n isReady: boolean;\n};\n\n/**\n * Live-preview the exact {@link PrepareInstantOpenParamsReturnType} an instant-open submit\n * will sign — `order` (price + quantity), `lockedParam`, `margin.amount`, and\n * `solverFeeCaps` — by running `prepareInstantOpenParams` as a read.\n * `prepareInstantOpenParams` neither signs nor submits, so this is safe to run\n * live; drive a \"quote preview\" from it and what the user sees is bit-for-bit\n * what `sendQuote` receives, with no separate local recomputation to drift.\n *\n * Like {@link useInstantOpenFees}, it **pre-fetches every input through its own\n * cached queries** (market metadata, mark price, locked params, on-chain fee\n * rates, solver info, and the lowcap dry-run estimate) and passes them in as\n * prefills, so the query function is pure and does no per-render network. Previous data is kept\n * while inputs move, so a mark-price tick updates the numbers in place.\n *\n * For bit-for-bit parity on `margin.amount`, forward {@link\n * UsePrepareInstantOpenParamsReturnType.estimatedOpenPrice} to the submit call\n * (`useInstantOpenAuto` / `useInstantOpenWithTpSl`) as `estimatedOpenPrice`, so\n * both the preview and the send provision settlement at the same estimate. The\n * full-balance sizing decision and quantity also depend on that estimate.\n * Gate submission on `isReady` while inputs or the estimate are settling.\n * Display `validationError ?? error`; input errors are synchronous, including offline.\n * A disabled hook or empty input remains idle without input validation.\n *\n * @example\n * ```tsx\n * const preview = usePrepareInstantOpenParams({\n * subAccountAddress,\n * from: sessionKey,\n * market: { id: symbolId },\n * positionType,\n * initialMargin,\n * leverage,\n * slippage,\n * });\n * // preview.data?.order.quantity — the exact leveraged quantity (wei) the send signs\n * // submit: mutate({ …, estimatedOpenPrice: preview.estimatedOpenPrice })\n * ```\n */\nexport function usePrepareInstantOpenParams(\n parameters: UsePrepareInstantOpenParamsParameters,\n): UsePrepareInstantOpenParamsReturnType {\n const inputs = useInstantOpenInputs(parameters, \"prepare\", parameters.query?.enabled !== false);\n const options = prepareInstantOpenParamsQueryOptions(inputs.config, {\n ...parameters,\n ...inputs.prefills,\n query: {\n ...parameters.query,\n enabled: inputs.ready,\n placeholderData: (previous) => (inputs.validationError === undefined ? previous : undefined),\n },\n });\n const query = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<PrepareInstantOpenParamsReturnType, SymmioRequestError>;\n\n return {\n ...query,\n refetchEstimatedPrice: inputs.refetchEstimatedPrice,\n validationError: inputs.validationError,\n estimatedOpenPrice: inputs.prefills.estimatedOpenPrice,\n estimatedOpenPriceWithoutShadow: inputs.estimatedOpenPriceWithoutShadow,\n estimatedOpenPriceTimestamp: parameters.estimatedOpenPriceTimestamp ?? inputs.estimatedOpenPriceTimestamp,\n isReady: inputs.ready && query.isSuccess && !query.isFetching && !query.isPlaceholderData,\n };\n}\n"],"mappings":";;;;;;AAiGA,SAAgB,EACd,GACuC;CACvC,IAAM,IAAS,EAAqB,GAAY,WAAW,EAAW,OAAO,YAAY,EAAK,GACxF,IAAU,EAAqC,EAAO,QAAQ;EAClE,GAAG;EACH,GAAG,EAAO;EACV,OAAO;GACL,GAAG,EAAW;GACd,SAAS,EAAO;GAChB,kBAAkB,MAAc,EAAO,oBAAoB,KAAA,IAAY,IAAW,KAAA;EACpF;CACF,CAAC,GACK,IAAQ,EAAS;EACrB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAED,OAAO;EACL,GAAG;EACH,uBAAuB,EAAO;EAC9B,iBAAiB,EAAO;EACxB,oBAAoB,EAAO,SAAS;EACpC,iCAAiC,EAAO;EACxC,6BAA6B,EAAW,+BAA+B,EAAO;EAC9E,SAAS,EAAO,SAAS,EAAM,aAAa,CAAC,EAAM,cAAc,CAAC,EAAM;CAC1E;AACF"}
|
|
@@ -24,6 +24,9 @@ export type UseSessionKeySelectorsReturnType = readonly Hex[];
|
|
|
24
24
|
* it can send the sub-account's collateral to an address of its own choosing.
|
|
25
25
|
* Pass `withdraw: true` only for a key that must run withdrawals unattended,
|
|
26
26
|
* and treat it as a materially larger grant.
|
|
27
|
+
* `coreCalls` and `timelockScheduling` also default to `false` and are separate
|
|
28
|
+
* opt-ins. The former grants broad AccountLayer `_call` authority (including
|
|
29
|
+
* delegated timelock approval requests); the latter grants scheduling authority.
|
|
27
30
|
*
|
|
28
31
|
* The result is referentially stable across renders while the chain and scope
|
|
29
32
|
* flags do not change, so it is safe to pass straight into a mutation's
|
|
@@ -32,8 +35,8 @@ export type UseSessionKeySelectorsReturnType = readonly Hex[];
|
|
|
32
35
|
* @param parameters - Optional chain override, scope flags, and `config`.
|
|
33
36
|
* @returns The lowercase, de-duplicated selector set for the requested scope.
|
|
34
37
|
* @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.
|
|
35
|
-
* @throws {SymmError} `
|
|
36
|
-
* or `
|
|
38
|
+
* @throws {SymmError} `SESSION_KEY_SELECTORS_UNSUPPORTED_CHAIN` when the `account`,
|
|
39
|
+
* `withdraw`, `coreCalls`, or `timelockScheduling` scope is requested on a chain whose contracts are not
|
|
37
40
|
* `"0.8.6"`. Render a trade-only key there with `{ account: false }`.
|
|
38
41
|
*
|
|
39
42
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-key-selectors.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-session-key-selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIhC,gGAAgG;AAChG,MAAM,WAAW,gCAAiC,SAAQ,eAAe,EAAE,uBAAuB;IAChG,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8FAA8F;AAC9F,MAAM,MAAM,gCAAgC,GAAG,SAAS,GAAG,EAAE,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"use-session-key-selectors.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-session-key-selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIhC,gGAAgG;AAChG,MAAM,WAAW,gCAAiC,SAAQ,eAAe,EAAE,uBAAuB;IAChG,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8FAA8F;AAC9F,MAAM,MAAM,gCAAgC,GAAG,SAAS,GAAG,EAAE,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,gCAAqC,GAChD,gCAAgC,CAUlC"}
|
|
@@ -5,18 +5,22 @@ import { getSessionKeySelectors as n } from "@symmio/trading-core";
|
|
|
5
5
|
import { useMemo as r } from "react";
|
|
6
6
|
//#region src/instant-layer/use-session-key-selectors.ts
|
|
7
7
|
function i(i = {}) {
|
|
8
|
-
let a = t(i), o = e(), { trade: s, account: c, withdraw: l } = i,
|
|
8
|
+
let a = t(i), o = e(), { trade: s, account: c, withdraw: l, coreCalls: u, timelockScheduling: d } = i, f = i.chainId ?? o;
|
|
9
9
|
return r(() => n(a, {
|
|
10
|
-
chainId:
|
|
10
|
+
chainId: f,
|
|
11
11
|
trade: s,
|
|
12
12
|
account: c,
|
|
13
|
-
withdraw: l
|
|
13
|
+
withdraw: l,
|
|
14
|
+
coreCalls: u,
|
|
15
|
+
timelockScheduling: d
|
|
14
16
|
}), [
|
|
15
17
|
a,
|
|
16
|
-
|
|
18
|
+
f,
|
|
17
19
|
s,
|
|
18
20
|
c,
|
|
19
|
-
l
|
|
21
|
+
l,
|
|
22
|
+
u,
|
|
23
|
+
d
|
|
20
24
|
]);
|
|
21
25
|
}
|
|
22
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-key-selectors.js","names":[],"sources":["../../src/instant-layer/use-session-key-selectors.ts"],"sourcesContent":["\"use client\";\n\nimport { getSessionKeySelectors, type ConfigParameter, type SessionKeySelectorScope } from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Hex } from \"viem\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSessionKeySelectors}: the target chain plus the authority scope. */\nexport interface UseSessionKeySelectorsParameters extends ConfigParameter, SessionKeySelectorScope {\n /** Chain to resolve the selector set for; defaults to the connected chain. */\n chainId?: number;\n}\n\n/** Return type of {@link useSessionKeySelectors}: the de-duplicated selector set to grant. */\nexport type UseSessionKeySelectorsReturnType = readonly Hex[];\n\n/**\n * **The** selector set to hand a session key — the set to pass to\n * `useGrantDelegation` (and to `useAreDelegationsActive` when checking whether\n * that key is still usable). It resolves the chain's contracts generation, so a\n * multi-chain app never grants the other generation's open-leg selector.\n *\n * The default scope is the onboarding grant: the instant trade lifecycle plus\n * gasless account management. Because the contract enforces that\n * `grantDelegation` is owner-only, that single grant is the *only* wallet\n * prompt a session key ever costs — every write it covers afterwards is\n * promptless and gas-free.\n *\n * `initiateWithdraw` is **opt-out by default** (`withdraw` defaults to\n * `false`): its calldata carries a caller-supplied `receiver`, so a key holding\n * it can send the sub-account's collateral to an address of its own choosing.\n * Pass `withdraw: true` only for a key that must run withdrawals unattended,\n * and treat it as a materially larger grant.\n *\n * The result is referentially stable across renders while the chain and scope\n * flags do not change, so it is safe to pass straight into a mutation's\n * variables or another hook's parameters.\n *\n * @param parameters - Optional chain override, scope flags, and `config`.\n * @returns The lowercase, de-duplicated selector set for the requested scope.\n * @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.\n * @throws {SymmError} `
|
|
1
|
+
{"version":3,"file":"use-session-key-selectors.js","names":[],"sources":["../../src/instant-layer/use-session-key-selectors.ts"],"sourcesContent":["\"use client\";\n\nimport { getSessionKeySelectors, type ConfigParameter, type SessionKeySelectorScope } from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Hex } from \"viem\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSessionKeySelectors}: the target chain plus the authority scope. */\nexport interface UseSessionKeySelectorsParameters extends ConfigParameter, SessionKeySelectorScope {\n /** Chain to resolve the selector set for; defaults to the connected chain. */\n chainId?: number;\n}\n\n/** Return type of {@link useSessionKeySelectors}: the de-duplicated selector set to grant. */\nexport type UseSessionKeySelectorsReturnType = readonly Hex[];\n\n/**\n * **The** selector set to hand a session key — the set to pass to\n * `useGrantDelegation` (and to `useAreDelegationsActive` when checking whether\n * that key is still usable). It resolves the chain's contracts generation, so a\n * multi-chain app never grants the other generation's open-leg selector.\n *\n * The default scope is the onboarding grant: the instant trade lifecycle plus\n * gasless account management. Because the contract enforces that\n * `grantDelegation` is owner-only, that single grant is the *only* wallet\n * prompt a session key ever costs — every write it covers afterwards is\n * promptless and gas-free.\n *\n * `initiateWithdraw` is **opt-out by default** (`withdraw` defaults to\n * `false`): its calldata carries a caller-supplied `receiver`, so a key holding\n * it can send the sub-account's collateral to an address of its own choosing.\n * Pass `withdraw: true` only for a key that must run withdrawals unattended,\n * and treat it as a materially larger grant.\n * `coreCalls` and `timelockScheduling` also default to `false` and are separate\n * opt-ins. The former grants broad AccountLayer `_call` authority (including\n * delegated timelock approval requests); the latter grants scheduling authority.\n *\n * The result is referentially stable across renders while the chain and scope\n * flags do not change, so it is safe to pass straight into a mutation's\n * variables or another hook's parameters.\n *\n * @param parameters - Optional chain override, scope flags, and `config`.\n * @returns The lowercase, de-duplicated selector set for the requested scope.\n * @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.\n * @throws {SymmError} `SESSION_KEY_SELECTORS_UNSUPPORTED_CHAIN` when the `account`,\n * `withdraw`, `coreCalls`, or `timelockScheduling` scope is requested on a chain whose contracts are not\n * `\"0.8.6\"`. Render a trade-only key there with `{ account: false }`.\n *\n * @example\n * ```tsx\n * const selectors = useSessionKeySelectors();\n * const { mutate } = useGrantDelegation();\n * mutate({ account: { addr: subAccount, isPartyB: false }, delegatedSigner, selectors, expiryTimestamp });\n * ```\n *\n * @example\n * ```tsx\n * // A key that also withdraws unattended — it can move the collateral out.\n * const selectors = useSessionKeySelectors({ withdraw: true });\n * ```\n */\nexport function useSessionKeySelectors(\n parameters: UseSessionKeySelectorsParameters = {},\n): UseSessionKeySelectorsReturnType {\n const config = useSymmioConfig(parameters);\n const connectedChainId = useSymmioChainId();\n const { trade, account, withdraw, coreCalls, timelockScheduling } = parameters;\n const chainId = parameters.chainId ?? connectedChainId;\n\n return useMemo(\n () => getSessionKeySelectors(config, { chainId, trade, account, withdraw, coreCalls, timelockScheduling }),\n [config, chainId, trade, account, withdraw, coreCalls, timelockScheduling],\n );\n}\n"],"mappings":";;;;;;AA8DA,SAAgB,EACd,IAA+C,CAAC,GACd;CAClC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAmB,EAAiB,GACpC,EAAE,UAAO,YAAS,aAAU,cAAW,0BAAuB,GAC9D,IAAU,EAAW,WAAW;CAEtC,OAAO,QACC,EAAuB,GAAQ;EAAE;EAAS;EAAO;EAAS;EAAU;EAAW;CAAmB,CAAC,GACzG;EAAC;EAAQ;EAAS;EAAO;EAAS;EAAU;EAAW;CAAkB,CAC3E;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ConfigParameter, SimulateGrantDelegationsParameters, SimulateGrantDelegationsReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useSimulateGrantDelegations}: an optional `config`
|
|
6
|
+
* override. The dry-run's inputs are passed as the mutation `variables`.
|
|
7
|
+
*/
|
|
8
|
+
export type UseSimulateGrantDelegationsParameters = ConfigParameter;
|
|
9
|
+
/** Return type of {@link useSimulateGrantDelegations}. */
|
|
10
|
+
export type UseSimulateGrantDelegationsReturnType = UseMutationResult<SimulateGrantDelegationsReturnType, SymmioRequestError, SimulateGrantDelegationsParameters>;
|
|
11
|
+
/**
|
|
12
|
+
* On-demand dry-run (`simulateContract`) of `grantDelegations`. Call
|
|
13
|
+
* `mutate(args)` to run it; `data` holds viem's `{ request, result }` (a would-be
|
|
14
|
+
* revert surfaces as a normalized {@link SymmioRequestError}). `from` defaults to
|
|
15
|
+
* the connected wallet and `chainId` to the connected chain.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const sim = useSimulateGrantDelegations();
|
|
20
|
+
* sim.mutate({ account, delegations });
|
|
21
|
+
* // sim.data?.result, sim.isPending, sim.error
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useSimulateGrantDelegations(parameters?: UseSimulateGrantDelegationsParameters): UseSimulateGrantDelegationsReturnType;
|
|
25
|
+
//# sourceMappingURL=use-simulate-grant-delegations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-simulate-grant-delegations.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-simulate-grant-delegations.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACxC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,qCAAqC,GAAG,eAAe,CAAC;AAEpE,0DAA0D;AAC1D,MAAM,MAAM,qCAAqC,GAAG,iBAAiB,CACnE,kCAAkC,EAClC,kBAAkB,EAClB,kCAAkC,CACnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,GAAE,qCAA0C,GACrD,qCAAqC,CAoBvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
|
+
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
|
+
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
+
import { simulateGrantDelegationsMutationOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useConnection as i } from "wagmi";
|
|
7
|
+
import { useMutation as a } from "@tanstack/react-query";
|
|
8
|
+
//#region src/instant-layer/use-simulate-grant-delegations.ts
|
|
9
|
+
function o(o = {}) {
|
|
10
|
+
let s = t(o), c = e(), { address: l } = i(), u = r(s);
|
|
11
|
+
return a({
|
|
12
|
+
mutationKey: u.mutationKey,
|
|
13
|
+
mutationFn: async (e) => {
|
|
14
|
+
try {
|
|
15
|
+
return await u.mutationFn({
|
|
16
|
+
...e,
|
|
17
|
+
chainId: e.chainId ?? c,
|
|
18
|
+
from: e.from ?? l
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
throw n(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { o as useSimulateGrantDelegations };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=use-simulate-grant-delegations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-simulate-grant-delegations.js","names":[],"sources":["../../src/instant-layer/use-simulate-grant-delegations.ts"],"sourcesContent":["\"use client\";\n\nimport {\n simulateGrantDelegationsMutationOptions,\n type ConfigParameter,\n type SimulateGrantDelegationsParameters,\n type SimulateGrantDelegationsReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useConnection } from \"wagmi\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useSimulateGrantDelegations}: an optional `config`\n * override. The dry-run's inputs are passed as the mutation `variables`.\n */\nexport type UseSimulateGrantDelegationsParameters = ConfigParameter;\n\n/** Return type of {@link useSimulateGrantDelegations}. */\nexport type UseSimulateGrantDelegationsReturnType = UseMutationResult<\n SimulateGrantDelegationsReturnType,\n SymmioRequestError,\n SimulateGrantDelegationsParameters\n>;\n\n/**\n * On-demand dry-run (`simulateContract`) of `grantDelegations`. Call\n * `mutate(args)` to run it; `data` holds viem's `{ request, result }` (a would-be\n * revert surfaces as a normalized {@link SymmioRequestError}). `from` defaults to\n * the connected wallet and `chainId` to the connected chain.\n *\n * @example\n * ```tsx\n * const sim = useSimulateGrantDelegations();\n * sim.mutate({ account, delegations });\n * // sim.data?.result, sim.isPending, sim.error\n * ```\n */\nexport function useSimulateGrantDelegations(\n parameters: UseSimulateGrantDelegationsParameters = {},\n): UseSimulateGrantDelegationsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const { address } = useConnection();\n const base = simulateGrantDelegationsMutationOptions(config);\n\n return useMutation<SimulateGrantDelegationsReturnType, SymmioRequestError, SimulateGrantDelegationsParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({\n ...variables,\n chainId: variables.chainId ?? chainId,\n from: variables.from ?? address,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n });\n}\n"],"mappings":";;;;;;;;AAyCA,SAAgB,EACd,IAAoD,CAAC,GACd;CACvC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,EAAE,eAAY,EAAc,GAC5B,IAAO,EAAwC,CAAM;CAE3D,OAAO,EAAwG;EAC7G,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAC3B,GAAG;KACH,SAAS,EAAU,WAAW;KAC9B,MAAM,EAAU,QAAQ;IAC1B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
|
@@ -30,6 +30,10 @@ export interface UseEnigmaPricesReturnType {
|
|
|
30
30
|
* non-stateful sink). The subscription is shared across hook instances via the
|
|
31
31
|
* SDK socket pool — multiple `useEnigmaPrices()` mounts cost one connection.
|
|
32
32
|
*
|
|
33
|
+
* Prices, status and errors reset when the Config instance or resolved chain
|
|
34
|
+
* changes. Reconnects and stopping/restarting the same target retain prices.
|
|
35
|
+
* Callbacks from a disposed subscription are ignored.
|
|
36
|
+
*
|
|
33
37
|
* @example
|
|
34
38
|
* ```tsx
|
|
35
39
|
* const { prices, status } = useEnigmaPrices();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-enigma-prices.d.ts","sourceRoot":"","sources":["../../src/price-service/use-enigma-prices.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-enigma-prices.d.ts","sourceRoot":"","sources":["../../src/price-service/use-enigma-prices.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,eAAe;IAChE,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,0BAA0B;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,yDAAyD;IACzD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAE,yBAA8B,GAAG,yBAAyB,CA+DrG"}
|