@symmio/trading-core 3.4.1 → 3.6.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.d.ts.map +1 -1
- package/dist/core/chains/registry.js +6 -0
- package/dist/core/chains/registry.js.map +1 -1
- package/dist/gasless/delegation-preflight.d.ts +22 -0
- package/dist/gasless/delegation-preflight.d.ts.map +1 -1
- package/dist/gasless/delegation-preflight.js +34 -19
- package/dist/gasless/delegation-preflight.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -79
- package/dist/pools/index.d.ts +1 -0
- package/dist/pools/index.d.ts.map +1 -1
- package/dist/pools/token-price/get-token-price.d.ts +71 -0
- package/dist/pools/token-price/get-token-price.d.ts.map +1 -0
- package/dist/pools/token-price/get-token-price.js +30 -0
- package/dist/pools/token-price/get-token-price.js.map +1 -0
- package/dist/pools/token-price/index.d.ts +4 -0
- package/dist/pools/token-price/index.d.ts.map +1 -0
- package/dist/pools/token-price/query.d.ts +52 -0
- package/dist/pools/token-price/query.d.ts.map +1 -0
- package/dist/pools/token-price/query.js +29 -0
- package/dist/pools/token-price/query.js.map +1 -0
- package/dist/pools/token-price/to-token-price.d.ts +14 -0
- package/dist/pools/token-price/to-token-price.d.ts.map +1 -0
- package/dist/pools/token-price/to-token-price.js +8 -0
- package/dist/pools/token-price/to-token-price.js.map +1 -0
- package/dist/pools/transactions/get-pool-transactions.d.ts +59 -17
- package/dist/pools/transactions/get-pool-transactions.d.ts.map +1 -1
- package/dist/pools/transactions/get-pool-transactions.js +7 -4
- package/dist/pools/transactions/get-pool-transactions.js.map +1 -1
- package/dist/pools/transactions/query.d.ts +6 -2
- package/dist/pools/transactions/query.d.ts.map +1 -1
- package/dist/pools/transactions/query.js +12 -13
- package/dist/pools/transactions/query.js.map +1 -1
- package/dist/pools/transactions/to-pool-transaction.d.ts +7 -0
- package/dist/pools/transactions/to-pool-transaction.d.ts.map +1 -1
- package/dist/pools/transactions/to-pool-transaction.js +3 -1
- package/dist/pools/transactions/to-pool-transaction.js.map +1 -1
- package/dist/pools/types/generated/listing-backend.js +8 -8
- package/dist/pools/types/generated/listing-backend.js.map +1 -1
- package/dist/pools/types.d.ts +53 -10
- package/dist/pools/types.d.ts.map +1 -1
- package/dist/pools/types.js +6 -4
- package/dist/pools/types.js.map +1 -1
- package/dist/solvers/instant-close/instant-close/instant-close.d.ts +8 -1
- package/dist/solvers/instant-close/instant-close/instant-close.d.ts.map +1 -1
- package/dist/solvers/instant-close/instant-close/instant-close.js +40 -32
- 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 +7 -1
- 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 +48 -40
- package/dist/solvers/instant-close/instant-close-bulk/instant-close-bulk.js.map +1 -1
- package/dist/solvers/instant-close/instant-close-bulk-auto/instant-close-bulk-auto.d.ts +4 -2
- package/dist/solvers/instant-close/instant-close-bulk-auto/instant-close-bulk-auto.d.ts.map +1 -1
- package/dist/solvers/instant-close/instant-close-bulk-auto/instant-close-bulk-auto.js +1 -0
- package/dist/solvers/instant-close/instant-close-bulk-auto/instant-close-bulk-auto.js.map +1 -1
- package/dist/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.d.ts +4 -2
- package/dist/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.d.ts.map +1 -1
- package/dist/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.js +2 -1
- package/dist/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.js.map +1 -1
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts +2 -0
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts.map +1 -1
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js +64 -56
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js.map +1 -1
- package/dist/solvers/instant-open/instant-open/adapters/rasa-instant-open.d.ts +2 -0
- package/dist/solvers/instant-open/instant-open/adapters/rasa-instant-open.d.ts.map +1 -1
- package/dist/solvers/instant-open/instant-open/adapters/rasa-instant-open.js +51 -43
- package/dist/solvers/instant-open/instant-open/adapters/rasa-instant-open.js.map +1 -1
- package/dist/solvers/instant-open/instant-open/instant-open.d.ts +6 -0
- package/dist/solvers/instant-open/instant-open/instant-open.d.ts.map +1 -1
- package/dist/solvers/instant-open/instant-open/instant-open.js.map +1 -1
- package/dist/solvers/instant-open/instant-open/types.d.ts +2 -1
- package/dist/solvers/instant-open/instant-open/types.d.ts.map +1 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts +3 -1
- 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 +2 -1
- package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.js.map +1 -1
- package/dist/solvers/shared/index.d.ts +1 -0
- package/dist/solvers/shared/index.d.ts.map +1 -1
- package/dist/solvers/shared/instant-delegation-preflight.d.ts +65 -0
- package/dist/solvers/shared/instant-delegation-preflight.d.ts.map +1 -0
- package/dist/solvers/shared/instant-delegation-preflight.js +34 -0
- package/dist/solvers/shared/instant-delegation-preflight.js.map +1 -0
- package/dist/symmio-contracts/abi/v0.8.6/gasless-layer.d.ts +6 -4
- package/dist/symmio-contracts/abi/v0.8.6/gasless-layer.d.ts.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/gasless-layer.js.map +1 -1
- package/package.json +3 -3
package/dist/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Address, Hex } from 'viem';
|
|
2
2
|
import { Config } from '../../../core/config/index.js';
|
|
3
3
|
import { Compute, WriteSolverParameter } from '../../../shared/types/properties.js';
|
|
4
|
+
import { InstantDelegationPreflightParameter } from '../../shared/instant-delegation-preflight.js';
|
|
4
5
|
import { InstantCloseParameters } from '../instant-close/instant-close.js';
|
|
5
6
|
import { InstantCloseMarketData, PositionType } from '../shared/types.js';
|
|
6
7
|
/**
|
|
@@ -8,9 +9,10 @@ import { InstantCloseMarketData, PositionType } from '../shared/types.js';
|
|
|
8
9
|
*
|
|
9
10
|
* Required = inputs only the caller can know (PartyA, quote id, trade
|
|
10
11
|
* intent). Optional = anything derivable from solver / price-service reads.
|
|
11
|
-
* Pre-fill an optional field to skip its fetch.
|
|
12
|
+
* Pre-fill an optional field to skip its fetch. `preflightDelegation` is
|
|
13
|
+
* forwarded to {@link InstantCloseParameters}.
|
|
12
14
|
*/
|
|
13
|
-
export type PrepareInstantCloseParameters = Compute<WriteSolverParameter & {
|
|
15
|
+
export type PrepareInstantCloseParameters = Compute<WriteSolverParameter & InstantDelegationPreflightParameter & {
|
|
14
16
|
/** PartyA — the VA address that owns the position. */
|
|
15
17
|
partyA: Address;
|
|
16
18
|
/** Market identification + optional pre-fetched precision metadata. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-instant-close-params.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"prepare-instant-close-params.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEtF,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2CAA2C,CAAC;AAErG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GAAG,OAAO,CACjD,oBAAoB,GAClB,mCAAmC,GAAG;IACpC,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,MAAM,EAAE,sBAAsB,CAAC;IAC/B,oEAAoE;IACpE,YAAY,EAAE,YAAY,CAAC;IAC3B,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,eAAe,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,6BAA6B,GACxC,OAAO,CAAC,sBAAsB,CAAC,CAqDjC"}
|
package/dist/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-instant-close-params.js","names":[],"sources":["../../../../src/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { Config } from \"../../../core/config\";\nimport { SymmError } from \"../../../shared/errors/symm-error\";\nimport type { Compute, WriteSolverParameter } from \"../../../shared/types/properties\";\nimport { toWeiBigInt } from \"../../instant-open/shared/trade-math\";\nimport { resolveMarket, resolveMarkPrice } from \"../../shared/resolvers\";\nimport type { InstantCloseParameters } from \"../instant-close/instant-close\";\nimport { calculateClosePrice, clampClosePrecision } from \"../shared/close-math\";\nimport { type InstantCloseMarketData, type PositionType } from \"../shared/types\";\n\n/**\n * Parameters for {@link prepareInstantCloseParams} and `instantCloseAuto`.\n *\n * Required = inputs only the caller can know (PartyA, quote id, trade\n * intent). Optional = anything derivable from solver / price-service reads.\n * Pre-fill an optional field to skip its fetch.\n */\nexport type PrepareInstantCloseParameters = Compute<\n WriteSolverParameter & {\n
|
|
1
|
+
{"version":3,"file":"prepare-instant-close-params.js","names":[],"sources":["../../../../src/solvers/instant-close/prepare-instant-close-params/prepare-instant-close-params.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { Config } from \"../../../core/config\";\nimport { SymmError } from \"../../../shared/errors/symm-error\";\nimport type { Compute, WriteSolverParameter } from \"../../../shared/types/properties\";\nimport { toWeiBigInt } from \"../../instant-open/shared/trade-math\";\nimport type { InstantDelegationPreflightParameter } from \"../../shared/instant-delegation-preflight\";\nimport { resolveMarket, resolveMarkPrice } from \"../../shared/resolvers\";\nimport type { InstantCloseParameters } from \"../instant-close/instant-close\";\nimport { calculateClosePrice, clampClosePrecision } from \"../shared/close-math\";\nimport { type InstantCloseMarketData, type PositionType } from \"../shared/types\";\n\n/**\n * Parameters for {@link prepareInstantCloseParams} and `instantCloseAuto`.\n *\n * Required = inputs only the caller can know (PartyA, quote id, trade\n * intent). Optional = anything derivable from solver / price-service reads.\n * Pre-fill an optional field to skip its fetch. `preflightDelegation` is\n * forwarded to {@link InstantCloseParameters}.\n */\nexport type PrepareInstantCloseParameters = Compute<\n WriteSolverParameter &\n InstantDelegationPreflightParameter & {\n /** PartyA — the VA address that owns the position. */\n partyA: Address;\n /** Market identification + optional pre-fetched precision metadata. */\n market: InstantCloseMarketData;\n /** Side of the position being closed (LONG = sell, SHORT = buy). */\n positionType: PositionType;\n /** Quote id of the position. */\n quoteId: bigint;\n /** Quantity to close as decimal string (base-token units). */\n quantityToClose: string;\n /** Slippage tolerance percent (e.g. `5` for 5%). */\n slippage: number;\n /** Pre-fetched mark price as decimal string. When omitted, fetched via Enigma price service. */\n markPrice?: string;\n /** Forwarded to {@link InstantCloseParameters}. */\n salt?: Hex;\n /** Forwarded to {@link InstantCloseParameters}. */\n deadline?: bigint;\n }\n>;\n\n/**\n * Resolve every input the {@link InstantCloseParameters} primitive needs from\n * a minimal parameter set.\n *\n * Steps:\n * 1. Resolve market metadata + mark price (caller-supplied values\n * short-circuit the fetches).\n * 2. Compute the slippage-adjusted close price via {@link calculateClosePrice}.\n * 3. Clamp `quantityToClose` to the market's `quantityPrecision`.\n * 4. Convert decimal strings to 18-decimal-wei `bigint`.\n *\n * @throws {SymmError} `INSTANT_CLOSE_INVALID_PARAMETERS` when the mark price\n * is zero/NaN or `quantityToClose` is non-positive.\n */\nexport async function prepareInstantCloseParams(\n config: Config,\n parameters: PrepareInstantCloseParameters,\n): Promise<InstantCloseParameters> {\n const market = await resolveMarket(config, {\n chainId: parameters.chainId,\n solverId: parameters.solverId,\n marketId: parameters.market.id,\n marketName: parameters.market.name,\n pricePrecision: parameters.market.pricePrecision,\n quantityPrecision: parameters.market.quantityPrecision,\n });\n const markPrice = await resolveMarkPrice(config, {\n chainId: parameters.chainId,\n solverId: parameters.solverId,\n marketName: market.name,\n markPrice: parameters.markPrice,\n });\n\n const closePrice = calculateClosePrice({\n markPrice,\n slippage: parameters.slippage,\n positionType: parameters.positionType,\n pricePrecision: market.pricePrecision,\n });\n const clampedQuantity = clampClosePrecision({\n quantityToClose: parameters.quantityToClose,\n quantityPrecision: market.quantityPrecision,\n });\n if (closePrice === null || clampedQuantity === null) {\n throw new SymmError(\n \"validation\",\n \"INSTANT_CLOSE_INVALID_PARAMETERS\",\n \"Invalid instant-close parameters: markPrice or quantityToClose is zero/NaN.\",\n );\n }\n\n return {\n chainId: parameters.chainId,\n /**\n * Carried through deliberately: `instantClose` resolves the solver from it to\n * pick the submit URL, so dropping it would send a quote priced for one\n * solver to another.\n */\n solverId: parameters.solverId,\n from: parameters.from,\n partyA: parameters.partyA,\n order: {\n quoteId: parameters.quoteId,\n closePrice: toWeiBigInt(closePrice),\n quantityToClose: toWeiBigInt(clampedQuantity),\n },\n salt: parameters.salt,\n deadline: parameters.deadline,\n preflightDelegation: parameters.preflightDelegation,\n };\n}\n"],"mappings":";;;;;;AAyDA,eAAsB,EACpB,GACA,GACiC;CACjC,IAAM,IAAS,MAAM,EAAc,GAAQ;EACzC,SAAS,EAAW;EACpB,UAAU,EAAW;EACrB,UAAU,EAAW,OAAO;EAC5B,YAAY,EAAW,OAAO;EAC9B,gBAAgB,EAAW,OAAO;EAClC,mBAAmB,EAAW,OAAO;CACvC,CAAC,GAQK,IAAa,EAAoB;EACrC,WAAA,MARsB,EAAiB,GAAQ;GAC/C,SAAS,EAAW;GACpB,UAAU,EAAW;GACrB,YAAY,EAAO;GACnB,WAAW,EAAW;EACxB,CAAC;EAIC,UAAU,EAAW;EACrB,cAAc,EAAW;EACzB,gBAAgB,EAAO;CACzB,CAAC,GACK,IAAkB,EAAoB;EAC1C,iBAAiB,EAAW;EAC5B,mBAAmB,EAAO;CAC5B,CAAC;CACD,IAAI,MAAe,QAAQ,MAAoB,MAC7C,MAAM,IAAI,EACR,cACA,oCACA,6EACF;CAGF,OAAO;EACL,SAAS,EAAW;EAMpB,UAAU,EAAW;EACrB,MAAM,EAAW;EACjB,QAAQ,EAAW;EACnB,OAAO;GACL,SAAS,EAAW;GACpB,YAAY,EAAY,CAAU;GAClC,iBAAiB,EAAY,CAAe;EAC9C;EACA,MAAM,EAAW;EACjB,UAAU,EAAW;EACrB,qBAAqB,EAAW;CAClC;AACF"}
|
|
@@ -15,6 +15,8 @@ import { InstantOpenAdapterContext } from './context.js';
|
|
|
15
15
|
* @throws {SymmError} `INSTANT_OPEN_MARGIN_REQUIRED` when `margin` is absent —
|
|
16
16
|
* reachable when the caller omitted `solverId` and the chain's default solver
|
|
17
17
|
* turned out to be Enigma.
|
|
18
|
+
* @throws {SymmError} `INSTANT_SIGNER_NOT_DELEGATED` when the signer lacks the
|
|
19
|
+
* delegation for either operation, before anything is signed.
|
|
18
20
|
* @throws {SymmApiError} when the hedger request fails.
|
|
19
21
|
* @internal
|
|
20
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enigma-instant-open.d.ts","sourceRoot":"","sources":["../../../../../src/solvers/instant-open/instant-open/adapters/enigma-instant-open.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enigma-instant-open.d.ts","sourceRoot":"","sources":["../../../../../src/solvers/instant-open/instant-open/adapters/enigma-instant-open.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,yBAAyB,EAClC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA8FlC"}
|
|
@@ -1,76 +1,84 @@
|
|
|
1
1
|
import { SymmError as e } from "../../../../shared/errors/symm-error.js";
|
|
2
2
|
import { buildSignedOperation as t, signAndFormatInstantOperation as n } from "../../shared/operations.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { assertInstantSignerDelegated as r } from "../../../shared/instant-delegation-preflight.js";
|
|
4
|
+
import { encodeAddMarginToNextVA as i, encodeSendQuote as a, encodeSendQuoteWithAffiliateAndData as o, getFakeSendQuoteMuonSignature as s, sendQuoteUpnlSigFlexRange as c } from "../../shared/calldata.js";
|
|
5
|
+
import { sendInstantOpen as l } from "../../shared/hedger-api.js";
|
|
6
|
+
import { isolationTypeForSide as u } from "../../shared/types.js";
|
|
6
7
|
//#region src/solvers/instant-open/instant-open/adapters/enigma-instant-open.ts
|
|
7
|
-
async function
|
|
8
|
-
if (!
|
|
9
|
-
let { config:
|
|
10
|
-
subAccount:
|
|
11
|
-
isolationType:
|
|
12
|
-
symbolId:
|
|
13
|
-
amount:
|
|
14
|
-
}),
|
|
15
|
-
partyBsWhiteList: [
|
|
16
|
-
symbolId:
|
|
17
|
-
positionType:
|
|
8
|
+
async function d(d, f) {
|
|
9
|
+
if (!f.margin) throw new e("validation", "INSTANT_OPEN_MARGIN_REQUIRED", "instantOpen: the Enigma (lowcap) flow funds a new virtual account, so `margin.amount` is required.");
|
|
10
|
+
let { config: p, solver: m, chainConfig: h, walletClient: g, signerAddress: _, deadline: v, symbolId: y, metadata: b } = d, { accountLayerAddress: x, symmioAddress: S, affiliatesAddress: C } = h.addresses, w = i({
|
|
11
|
+
subAccount: f.subAccountAddress,
|
|
12
|
+
isolationType: u(f.positionType),
|
|
13
|
+
symbolId: y,
|
|
14
|
+
amount: f.margin.amount
|
|
15
|
+
}), T = {
|
|
16
|
+
partyBsWhiteList: [m.address],
|
|
17
|
+
symbolId: y,
|
|
18
|
+
positionType: f.positionType,
|
|
18
19
|
orderType: 1,
|
|
19
|
-
price:
|
|
20
|
-
quantity:
|
|
21
|
-
cva:
|
|
22
|
-
lf:
|
|
23
|
-
partyAmm:
|
|
24
|
-
partyBmm:
|
|
25
|
-
deadline:
|
|
26
|
-
affiliate:
|
|
27
|
-
data:
|
|
28
|
-
upnlSig:
|
|
29
|
-
},
|
|
30
|
-
...
|
|
31
|
-
solverFeeCaps:
|
|
32
|
-
}), E = t({
|
|
33
|
-
signer: g,
|
|
34
|
-
target: b,
|
|
35
|
-
callData: C,
|
|
36
|
-
signerAccount: d.subAccountAddress,
|
|
37
|
-
deadline: d.operationDeadline ?? _,
|
|
38
|
-
salt: d.addMarginSalt
|
|
20
|
+
price: f.order.price,
|
|
21
|
+
quantity: f.order.quantity,
|
|
22
|
+
cva: f.lockedParam.cva,
|
|
23
|
+
lf: f.lockedParam.lf,
|
|
24
|
+
partyAmm: f.lockedParam.partyAmm,
|
|
25
|
+
partyBmm: f.lockedParam.partyBmm,
|
|
26
|
+
deadline: v,
|
|
27
|
+
affiliate: C,
|
|
28
|
+
data: b,
|
|
29
|
+
upnlSig: s(f.markPrice ?? f.order.price)
|
|
30
|
+
}, E = h.contractsVersion === "0.8.5" ? o(T) : a({
|
|
31
|
+
...T,
|
|
32
|
+
solverFeeCaps: f.solverFeeCaps
|
|
39
33
|
}), D = t({
|
|
40
|
-
signer:
|
|
34
|
+
signer: _,
|
|
41
35
|
target: x,
|
|
42
|
-
callData:
|
|
43
|
-
signerAccount:
|
|
44
|
-
deadline:
|
|
45
|
-
salt:
|
|
36
|
+
callData: w,
|
|
37
|
+
signerAccount: f.subAccountAddress,
|
|
38
|
+
deadline: f.operationDeadline ?? v,
|
|
39
|
+
salt: f.addMarginSalt
|
|
40
|
+
}), O = t({
|
|
41
|
+
signer: _,
|
|
42
|
+
target: S,
|
|
43
|
+
callData: E,
|
|
44
|
+
signerAccount: f.subAccountAddress,
|
|
45
|
+
deadline: f.operationDeadline ?? v,
|
|
46
|
+
salt: f.sendQuoteSalt,
|
|
46
47
|
flexFields: [{
|
|
47
|
-
...
|
|
48
|
-
authorizedFlexFiller:
|
|
48
|
+
...c(E),
|
|
49
|
+
authorizedFlexFiller: m.address
|
|
49
50
|
}]
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
chainId:
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
});
|
|
52
|
+
await r(p, {
|
|
53
|
+
chainId: d.chainId,
|
|
54
|
+
action: "instantOpen",
|
|
55
|
+
operations: [D, O],
|
|
56
|
+
enabled: f.preflightDelegation
|
|
57
|
+
});
|
|
58
|
+
let [k, A] = await Promise.all([n(p, {
|
|
55
59
|
operation: D,
|
|
56
|
-
chainId:
|
|
57
|
-
walletClient:
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
chainId: d.chainId,
|
|
61
|
+
walletClient: g
|
|
62
|
+
}), n(p, {
|
|
63
|
+
operation: O,
|
|
64
|
+
chainId: d.chainId,
|
|
65
|
+
walletClient: g
|
|
66
|
+
})]), j = await l(p, {
|
|
67
|
+
chainId: d.chainId,
|
|
68
|
+
solverId: m.id,
|
|
61
69
|
request: {
|
|
62
|
-
addMargin:
|
|
63
|
-
sendQuote:
|
|
70
|
+
addMargin: k,
|
|
71
|
+
sendQuote: A
|
|
64
72
|
}
|
|
65
73
|
});
|
|
66
74
|
return {
|
|
67
75
|
kind: "enigma",
|
|
68
76
|
success: !0,
|
|
69
|
-
tempQuoteId:
|
|
70
|
-
partyBmm:
|
|
77
|
+
tempQuoteId: j.temp_quote_id !== void 0 && j.temp_quote_id !== null ? String(j.temp_quote_id) : void 0,
|
|
78
|
+
partyBmm: j.partyBmm
|
|
71
79
|
};
|
|
72
80
|
}
|
|
73
81
|
//#endregion
|
|
74
|
-
export {
|
|
82
|
+
export { d as submitEnigmaInstantOpen };
|
|
75
83
|
|
|
76
84
|
//# sourceMappingURL=enigma-instant-open.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enigma-instant-open.js","names":[],"sources":["../../../../../src/solvers/instant-open/instant-open/adapters/enigma-instant-open.ts"],"sourcesContent":["import { SymmError } from \"../../../../shared/errors/symm-error\";\nimport {\n encodeAddMarginToNextVA,\n encodeSendQuote,\n encodeSendQuoteWithAffiliateAndData,\n getFakeSendQuoteMuonSignature,\n sendQuoteUpnlSigFlexRange,\n} from \"../../shared/calldata\";\nimport { sendInstantOpen } from \"../../shared/hedger-api\";\nimport { buildSignedOperation, signAndFormatInstantOperation } from \"../../shared/operations\";\nimport { ORDER_TYPE_MARKET, isolationTypeForSide } from \"../../shared/types\";\nimport type { EnigmaInstantOpenResult, InstantOpenParameters } from \"../types\";\nimport type { InstantOpenAdapterContext } from \"./context\";\n\n/**\n * Submit an instant open to an **Enigma** (lowcap) hedger.\n *\n * Signs two operations — `addMarginToNextVA` on the AccountLayer and\n * `sendQuote` on the diamond — and posts both to `/instant_trade/instant_open`.\n *\n * The quote carries a **placeholder** Muon signature: lowcap bypasses Muon\n * verification, but the contract still reads `upnlSig.price`, and the encoded\n * signature region is delegated to the solver via a `FlexField` so it can write a\n * live attestation at execution time. Only the `sendQuote` operation carries the\n * delegation; `addMargin` stays fully fixed.\n *\n * @throws {SymmError} `INSTANT_OPEN_MARGIN_REQUIRED` when `margin` is absent —\n * reachable when the caller omitted `solverId` and the chain's default solver\n * turned out to be Enigma.\n * @throws {SymmApiError} when the hedger request fails.\n * @internal\n */\nexport async function submitEnigmaInstantOpen(\n context: InstantOpenAdapterContext,\n parameters: InstantOpenParameters,\n): Promise<EnigmaInstantOpenResult> {\n if (!parameters.margin) {\n throw new SymmError(\n \"validation\",\n \"INSTANT_OPEN_MARGIN_REQUIRED\",\n \"instantOpen: the Enigma (lowcap) flow funds a new virtual account, so `margin.amount` is required.\",\n );\n }\n\n const { config, solver, chainConfig, walletClient, signerAddress, deadline, symbolId, metadata } = context;\n const { accountLayerAddress, symmioAddress, affiliatesAddress } = chainConfig.addresses;\n\n const addMarginCallData = encodeAddMarginToNextVA({\n subAccount: parameters.subAccountAddress,\n isolationType: isolationTypeForSide(parameters.positionType),\n symbolId,\n amount: parameters.margin.amount,\n });\n\n const quoteArgs = {\n partyBsWhiteList: [solver.address],\n symbolId,\n positionType: parameters.positionType,\n orderType: ORDER_TYPE_MARKET,\n price: parameters.order.price,\n quantity: parameters.order.quantity,\n cva: parameters.lockedParam.cva,\n lf: parameters.lockedParam.lf,\n partyAmm: parameters.lockedParam.partyAmm,\n partyBmm: parameters.lockedParam.partyBmm,\n deadline,\n affiliate: affiliatesAddress,\n data: metadata,\n upnlSig: getFakeSendQuoteMuonSignature(parameters.markPrice ?? parameters.order.price),\n };\n\n /**\n * Which quote-send call to sign is a chain-generation fact: a v0.8.5 diamond\n * has no capped `sendQuote` selector (the calldata would revert), and a\n * v0.8.6 solver rejects the legacy call's zero fee caps.\n */\n const sendQuoteCallData =\n chainConfig.contractsVersion === \"0.8.5\"\n ? encodeSendQuoteWithAffiliateAndData(quoteArgs)\n : encodeSendQuote({ ...quoteArgs, solverFeeCaps: parameters.solverFeeCaps });\n\n const addMarginOp = buildSignedOperation({\n signer: signerAddress,\n target: accountLayerAddress,\n callData: addMarginCallData,\n signerAccount: parameters.subAccountAddress,\n deadline: parameters.operationDeadline ?? deadline,\n salt: parameters.addMarginSalt,\n });\n\n const sendQuoteOp = buildSignedOperation({\n signer: signerAddress,\n target: symmioAddress,\n callData: sendQuoteCallData,\n signerAccount: parameters.subAccountAddress,\n deadline: parameters.operationDeadline ?? deadline,\n salt: parameters.sendQuoteSalt,\n flexFields: [{ ...sendQuoteUpnlSigFlexRange(sendQuoteCallData), authorizedFlexFiller: solver.address }],\n });\n\n const [addMargin, sendQuote] = await Promise.all([\n signAndFormatInstantOperation(config, { operation: addMarginOp, chainId: context.chainId, walletClient }),\n signAndFormatInstantOperation(config, { operation: sendQuoteOp, chainId: context.chainId, walletClient }),\n ]);\n\n const response = await sendInstantOpen(config, {\n chainId: context.chainId,\n // The resolved solver's own id — never a hardcoded kind, so a differently-id'd\n // solver of the same kind can never be re-resolved onto the wrong endpoint.\n solverId: solver.id,\n request: { addMargin, sendQuote },\n });\n\n return {\n kind: \"enigma\",\n success: true,\n tempQuoteId:\n response.temp_quote_id !== undefined && response.temp_quote_id !== null\n ? String(response.temp_quote_id)\n : undefined,\n partyBmm: response.partyBmm,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"enigma-instant-open.js","names":[],"sources":["../../../../../src/solvers/instant-open/instant-open/adapters/enigma-instant-open.ts"],"sourcesContent":["import { SymmError } from \"../../../../shared/errors/symm-error\";\nimport { assertInstantSignerDelegated } from \"../../../shared/instant-delegation-preflight\";\nimport {\n encodeAddMarginToNextVA,\n encodeSendQuote,\n encodeSendQuoteWithAffiliateAndData,\n getFakeSendQuoteMuonSignature,\n sendQuoteUpnlSigFlexRange,\n} from \"../../shared/calldata\";\nimport { sendInstantOpen } from \"../../shared/hedger-api\";\nimport { buildSignedOperation, signAndFormatInstantOperation } from \"../../shared/operations\";\nimport { ORDER_TYPE_MARKET, isolationTypeForSide } from \"../../shared/types\";\nimport type { EnigmaInstantOpenResult, InstantOpenParameters } from \"../types\";\nimport type { InstantOpenAdapterContext } from \"./context\";\n\n/**\n * Submit an instant open to an **Enigma** (lowcap) hedger.\n *\n * Signs two operations — `addMarginToNextVA` on the AccountLayer and\n * `sendQuote` on the diamond — and posts both to `/instant_trade/instant_open`.\n *\n * The quote carries a **placeholder** Muon signature: lowcap bypasses Muon\n * verification, but the contract still reads `upnlSig.price`, and the encoded\n * signature region is delegated to the solver via a `FlexField` so it can write a\n * live attestation at execution time. Only the `sendQuote` operation carries the\n * delegation; `addMargin` stays fully fixed.\n *\n * @throws {SymmError} `INSTANT_OPEN_MARGIN_REQUIRED` when `margin` is absent —\n * reachable when the caller omitted `solverId` and the chain's default solver\n * turned out to be Enigma.\n * @throws {SymmError} `INSTANT_SIGNER_NOT_DELEGATED` when the signer lacks the\n * delegation for either operation, before anything is signed.\n * @throws {SymmApiError} when the hedger request fails.\n * @internal\n */\nexport async function submitEnigmaInstantOpen(\n context: InstantOpenAdapterContext,\n parameters: InstantOpenParameters,\n): Promise<EnigmaInstantOpenResult> {\n if (!parameters.margin) {\n throw new SymmError(\n \"validation\",\n \"INSTANT_OPEN_MARGIN_REQUIRED\",\n \"instantOpen: the Enigma (lowcap) flow funds a new virtual account, so `margin.amount` is required.\",\n );\n }\n\n const { config, solver, chainConfig, walletClient, signerAddress, deadline, symbolId, metadata } = context;\n const { accountLayerAddress, symmioAddress, affiliatesAddress } = chainConfig.addresses;\n\n const addMarginCallData = encodeAddMarginToNextVA({\n subAccount: parameters.subAccountAddress,\n isolationType: isolationTypeForSide(parameters.positionType),\n symbolId,\n amount: parameters.margin.amount,\n });\n\n const quoteArgs = {\n partyBsWhiteList: [solver.address],\n symbolId,\n positionType: parameters.positionType,\n orderType: ORDER_TYPE_MARKET,\n price: parameters.order.price,\n quantity: parameters.order.quantity,\n cva: parameters.lockedParam.cva,\n lf: parameters.lockedParam.lf,\n partyAmm: parameters.lockedParam.partyAmm,\n partyBmm: parameters.lockedParam.partyBmm,\n deadline,\n affiliate: affiliatesAddress,\n data: metadata,\n upnlSig: getFakeSendQuoteMuonSignature(parameters.markPrice ?? parameters.order.price),\n };\n\n /**\n * Which quote-send call to sign is a chain-generation fact: a v0.8.5 diamond\n * has no capped `sendQuote` selector (the calldata would revert), and a\n * v0.8.6 solver rejects the legacy call's zero fee caps.\n */\n const sendQuoteCallData =\n chainConfig.contractsVersion === \"0.8.5\"\n ? encodeSendQuoteWithAffiliateAndData(quoteArgs)\n : encodeSendQuote({ ...quoteArgs, solverFeeCaps: parameters.solverFeeCaps });\n\n const addMarginOp = buildSignedOperation({\n signer: signerAddress,\n target: accountLayerAddress,\n callData: addMarginCallData,\n signerAccount: parameters.subAccountAddress,\n deadline: parameters.operationDeadline ?? deadline,\n salt: parameters.addMarginSalt,\n });\n\n const sendQuoteOp = buildSignedOperation({\n signer: signerAddress,\n target: symmioAddress,\n callData: sendQuoteCallData,\n signerAccount: parameters.subAccountAddress,\n deadline: parameters.operationDeadline ?? deadline,\n salt: parameters.sendQuoteSalt,\n flexFields: [{ ...sendQuoteUpnlSigFlexRange(sendQuoteCallData), authorizedFlexFiller: solver.address }],\n });\n\n await assertInstantSignerDelegated(config, {\n chainId: context.chainId,\n action: \"instantOpen\",\n operations: [addMarginOp, sendQuoteOp],\n enabled: parameters.preflightDelegation,\n });\n\n const [addMargin, sendQuote] = await Promise.all([\n signAndFormatInstantOperation(config, { operation: addMarginOp, chainId: context.chainId, walletClient }),\n signAndFormatInstantOperation(config, { operation: sendQuoteOp, chainId: context.chainId, walletClient }),\n ]);\n\n const response = await sendInstantOpen(config, {\n chainId: context.chainId,\n // The resolved solver's own id — never a hardcoded kind, so a differently-id'd\n // solver of the same kind can never be re-resolved onto the wrong endpoint.\n solverId: solver.id,\n request: { addMargin, sendQuote },\n });\n\n return {\n kind: \"enigma\",\n success: true,\n tempQuoteId:\n response.temp_quote_id !== undefined && response.temp_quote_id !== null\n ? String(response.temp_quote_id)\n : undefined,\n partyBmm: response.partyBmm,\n };\n}\n"],"mappings":";;;;;;;AAmCA,eAAsB,EACpB,GACA,GACkC;CAClC,IAAI,CAAC,EAAW,QACd,MAAM,IAAI,EACR,cACA,gCACA,oGACF;CAGF,IAAM,EAAE,WAAQ,WAAQ,gBAAa,iBAAc,kBAAe,aAAU,aAAU,gBAAa,GAC7F,EAAE,wBAAqB,kBAAe,yBAAsB,EAAY,WAExE,IAAoB,EAAwB;EAChD,YAAY,EAAW;EACvB,eAAe,EAAqB,EAAW,YAAY;EAC3D;EACA,QAAQ,EAAW,OAAO;CAC5B,CAAC,GAEK,IAAY;EAChB,kBAAkB,CAAC,EAAO,OAAO;EACjC;EACA,cAAc,EAAW;EACzB,WAAA;EACA,OAAO,EAAW,MAAM;EACxB,UAAU,EAAW,MAAM;EAC3B,KAAK,EAAW,YAAY;EAC5B,IAAI,EAAW,YAAY;EAC3B,UAAU,EAAW,YAAY;EACjC,UAAU,EAAW,YAAY;EACjC;EACA,WAAW;EACX,MAAM;EACN,SAAS,EAA8B,EAAW,aAAa,EAAW,MAAM,KAAK;CACvF,GAOM,IACJ,EAAY,qBAAqB,UAC7B,EAAoC,CAAS,IAC7C,EAAgB;EAAE,GAAG;EAAW,eAAe,EAAW;CAAc,CAAC,GAEzE,IAAc,EAAqB;EACvC,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,eAAe,EAAW;EAC1B,UAAU,EAAW,qBAAqB;EAC1C,MAAM,EAAW;CACnB,CAAC,GAEK,IAAc,EAAqB;EACvC,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,eAAe,EAAW;EAC1B,UAAU,EAAW,qBAAqB;EAC1C,MAAM,EAAW;EACjB,YAAY,CAAC;GAAE,GAAG,EAA0B,CAAiB;GAAG,sBAAsB,EAAO;EAAQ,CAAC;CACxG,CAAC;CAED,MAAM,EAA6B,GAAQ;EACzC,SAAS,EAAQ;EACjB,QAAQ;EACR,YAAY,CAAC,GAAa,CAAW;EACrC,SAAS,EAAW;CACtB,CAAC;CAED,IAAM,CAAC,GAAW,KAAa,MAAM,QAAQ,IAAI,CAC/C,EAA8B,GAAQ;EAAE,WAAW;EAAa,SAAS,EAAQ;EAAS;CAAa,CAAC,GACxG,EAA8B,GAAQ;EAAE,WAAW;EAAa,SAAS,EAAQ;EAAS;CAAa,CAAC,CAC1G,CAAC,GAEK,IAAW,MAAM,EAAgB,GAAQ;EAC7C,SAAS,EAAQ;EAGjB,UAAU,EAAO;EACjB,SAAS;GAAE;GAAW;EAAU;CAClC,CAAC;CAED,OAAO;EACL,MAAM;EACN,SAAS;EACT,aACE,EAAS,kBAAkB,KAAA,KAAa,EAAS,kBAAkB,OAC/D,OAAO,EAAS,aAAa,IAC7B,KAAA;EACN,UAAU,EAAS;CACrB;AACF"}
|
|
@@ -15,6 +15,8 @@ import { InstantOpenAdapterContext } from './context.js';
|
|
|
15
15
|
* nothing to delegate.
|
|
16
16
|
*
|
|
17
17
|
* @throws {SymmError} when the Muon attestation cannot be fetched.
|
|
18
|
+
* @throws {SymmError} `INSTANT_SIGNER_NOT_DELEGATED` when the signer lacks the
|
|
19
|
+
* delegation for the operation, before it is signed.
|
|
18
20
|
* @throws {SymmApiError} when the hedger request fails.
|
|
19
21
|
* @internal
|
|
20
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rasa-instant-open.d.ts","sourceRoot":"","sources":["../../../../../src/solvers/instant-open/instant-open/adapters/rasa-instant-open.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rasa-instant-open.d.ts","sourceRoot":"","sources":["../../../../../src/solvers/instant-open/instant-open/adapters/rasa-instant-open.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,yBAAyB,EAClC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAmEhC"}
|
|
@@ -1,55 +1,63 @@
|
|
|
1
1
|
import { buildSignedOperation as e, signAndFormatInstantOperation as t } from "../../shared/operations.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { assertInstantSignerDelegated as n } from "../../../shared/instant-delegation-preflight.js";
|
|
3
|
+
import { encodeSendQuoteWithAffiliateAndData as r } from "../../shared/calldata.js";
|
|
4
|
+
import { sendRasaInstantOpen as i } from "../../shared/hedger-api.js";
|
|
4
5
|
import "../../shared/types.js";
|
|
5
|
-
import { getSendQuoteUpnlSig as
|
|
6
|
-
import { toRasaInstantOpen as
|
|
6
|
+
import { getSendQuoteUpnlSig as a } from "../../../../muon/send-quote-upnl-sig/get-send-quote-upnl-sig.js";
|
|
7
|
+
import { toRasaInstantOpen as o } from "../../get-instant-opens/adapters/rasa-instant-opens.js";
|
|
7
8
|
//#region src/solvers/instant-open/instant-open/adapters/rasa-instant-open.ts
|
|
8
|
-
async function
|
|
9
|
-
let { config:
|
|
10
|
-
chainId:
|
|
11
|
-
partyA:
|
|
12
|
-
symbolId:
|
|
13
|
-
}),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
upnlSig: v
|
|
32
|
-
}),
|
|
33
|
-
signerAccount: s.subAccountAddress,
|
|
34
|
-
deadline: p,
|
|
35
|
-
salt: s.sendQuoteSalt
|
|
9
|
+
async function s(s, c) {
|
|
10
|
+
let { config: l, solver: u, chainConfig: d, walletClient: f, signerAddress: p, deadline: m, symbolId: h, metadata: g } = s, { symmioAddress: _, affiliatesAddress: v } = d.addresses, y = await a(l, {
|
|
11
|
+
chainId: s.chainId,
|
|
12
|
+
partyA: c.subAccountAddress,
|
|
13
|
+
symbolId: h
|
|
14
|
+
}), b = e({
|
|
15
|
+
signer: p,
|
|
16
|
+
target: _,
|
|
17
|
+
callData: r({
|
|
18
|
+
partyBsWhiteList: [u.address],
|
|
19
|
+
symbolId: h,
|
|
20
|
+
positionType: c.positionType,
|
|
21
|
+
orderType: c.orderType ?? 1,
|
|
22
|
+
price: c.order.price,
|
|
23
|
+
quantity: c.order.quantity,
|
|
24
|
+
cva: c.lockedParam.cva,
|
|
25
|
+
lf: c.lockedParam.lf,
|
|
26
|
+
partyAmm: c.lockedParam.partyAmm,
|
|
27
|
+
partyBmm: c.lockedParam.partyBmm,
|
|
28
|
+
deadline: m,
|
|
29
|
+
affiliate: v,
|
|
30
|
+
data: g,
|
|
31
|
+
upnlSig: y
|
|
36
32
|
}),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
signerAccount: c.subAccountAddress,
|
|
34
|
+
deadline: m,
|
|
35
|
+
salt: c.sendQuoteSalt
|
|
36
|
+
});
|
|
37
|
+
await n(l, {
|
|
38
|
+
chainId: s.chainId,
|
|
39
|
+
action: "instantOpen",
|
|
40
|
+
operations: [b],
|
|
41
|
+
enabled: c.preflightDelegation
|
|
42
|
+
});
|
|
43
|
+
let x = await t(l, {
|
|
44
|
+
operation: b,
|
|
45
|
+
chainId: s.chainId,
|
|
46
|
+
walletClient: f
|
|
47
|
+
}), S = await i(l, {
|
|
48
|
+
chainId: s.chainId,
|
|
49
|
+
solverId: u.id,
|
|
50
|
+
sendQuote: x
|
|
51
|
+
}), C = o(S);
|
|
44
52
|
return {
|
|
45
53
|
kind: "rasa",
|
|
46
54
|
success: !0,
|
|
47
|
-
tempQuoteId: String(
|
|
48
|
-
partyBmm:
|
|
49
|
-
rfq:
|
|
55
|
+
tempQuoteId: String(S.temp_quote_id),
|
|
56
|
+
partyBmm: S.partyBmm,
|
|
57
|
+
rfq: C
|
|
50
58
|
};
|
|
51
59
|
}
|
|
52
60
|
//#endregion
|
|
53
|
-
export {
|
|
61
|
+
export { s as submitRasaInstantOpen };
|
|
54
62
|
|
|
55
63
|
//# sourceMappingURL=rasa-instant-open.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rasa-instant-open.js","names":[],"sources":["../../../../../src/solvers/instant-open/instant-open/adapters/rasa-instant-open.ts"],"sourcesContent":["import { getSendQuoteUpnlSig } from \"../../../../muon/send-quote-upnl-sig\";\nimport { toRasaInstantOpen } from \"../../get-instant-opens/adapters/rasa-instant-opens\";\nimport { encodeSendQuoteWithAffiliateAndData } from \"../../shared/calldata\";\nimport { sendRasaInstantOpen } from \"../../shared/hedger-api\";\nimport { buildSignedOperation, signAndFormatInstantOperation } from \"../../shared/operations\";\nimport { ORDER_TYPE_MARKET } from \"../../shared/types\";\nimport type { InstantOpenParameters, RasaInstantOpenResult } from \"../types\";\nimport type { InstantOpenAdapterContext } from \"./context\";\n\n/**\n * Submit an instant open to a **Rasa** (majors) hedger.\n *\n * Signs a single `sendQuote` operation on the diamond, under the sub-account's\n * authority, and posts it to `/instant_trade/open`. Rasa is cross-margin: there\n * is no virtual account and no `addMargin` leg, so the request body carries only\n * `sendQuote`.\n *\n * Unlike the Enigma flow, Rasa enforces Muon verification — the quote must carry\n * a live `uPnl_A_withSymbolPrice` attestation. It is fetched here, immediately\n * before signing, because the signature is encoded *inside* the signed calldata\n * and cannot be filled in afterwards. That also means no `flexFields`: there is\n * nothing to delegate.\n *\n * @throws {SymmError} when the Muon attestation cannot be fetched.\n * @throws {SymmApiError} when the hedger request fails.\n * @internal\n */\nexport async function submitRasaInstantOpen(\n context: InstantOpenAdapterContext,\n parameters: InstantOpenParameters,\n): Promise<RasaInstantOpenResult> {\n const { config, solver, chainConfig, walletClient, signerAddress, deadline, symbolId, metadata } = context;\n const { symmioAddress, affiliatesAddress } = chainConfig.addresses;\n\n /** Fetch last: the attestation is short-lived and is signed into the calldata. */\n const upnlSig = await getSendQuoteUpnlSig(config, {\n chainId: context.chainId,\n partyA: parameters.subAccountAddress,\n symbolId,\n });\n\n const sendQuoteCallData = encodeSendQuoteWithAffiliateAndData({\n partyBsWhiteList: [solver.address],\n symbolId,\n positionType: parameters.positionType,\n orderType: parameters.orderType ?? ORDER_TYPE_MARKET,\n price: parameters.order.price,\n quantity: parameters.order.quantity,\n cva: parameters.lockedParam.cva,\n lf: parameters.lockedParam.lf,\n partyAmm: parameters.lockedParam.partyAmm,\n partyBmm: parameters.lockedParam.partyBmm,\n deadline,\n affiliate: affiliatesAddress,\n data: metadata,\n upnlSig,\n });\n\n const sendQuoteOp = buildSignedOperation({\n signer: signerAddress,\n target: symmioAddress,\n callData: sendQuoteCallData,\n signerAccount: parameters.subAccountAddress,\n deadline,\n salt: parameters.sendQuoteSalt,\n });\n\n const sendQuote = await signAndFormatInstantOperation(config, {\n operation: sendQuoteOp,\n chainId: context.chainId,\n walletClient,\n });\n\n const response = await sendRasaInstantOpen(config, {\n chainId: context.chainId,\n // The resolved solver's own id — never a hardcoded kind, so a differently-id'd\n // solver of the same kind can never be re-resolved onto the wrong endpoint.\n solverId: solver.id,\n sendQuote,\n });\n\n const rfq = toRasaInstantOpen(response);\n\n return {\n kind: \"rasa\",\n success: true,\n tempQuoteId: String(response.temp_quote_id),\n partyBmm: response.partyBmm,\n rfq,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rasa-instant-open.js","names":[],"sources":["../../../../../src/solvers/instant-open/instant-open/adapters/rasa-instant-open.ts"],"sourcesContent":["import { getSendQuoteUpnlSig } from \"../../../../muon/send-quote-upnl-sig\";\nimport { assertInstantSignerDelegated } from \"../../../shared/instant-delegation-preflight\";\nimport { toRasaInstantOpen } from \"../../get-instant-opens/adapters/rasa-instant-opens\";\nimport { encodeSendQuoteWithAffiliateAndData } from \"../../shared/calldata\";\nimport { sendRasaInstantOpen } from \"../../shared/hedger-api\";\nimport { buildSignedOperation, signAndFormatInstantOperation } from \"../../shared/operations\";\nimport { ORDER_TYPE_MARKET } from \"../../shared/types\";\nimport type { InstantOpenParameters, RasaInstantOpenResult } from \"../types\";\nimport type { InstantOpenAdapterContext } from \"./context\";\n\n/**\n * Submit an instant open to a **Rasa** (majors) hedger.\n *\n * Signs a single `sendQuote` operation on the diamond, under the sub-account's\n * authority, and posts it to `/instant_trade/open`. Rasa is cross-margin: there\n * is no virtual account and no `addMargin` leg, so the request body carries only\n * `sendQuote`.\n *\n * Unlike the Enigma flow, Rasa enforces Muon verification — the quote must carry\n * a live `uPnl_A_withSymbolPrice` attestation. It is fetched here, immediately\n * before signing, because the signature is encoded *inside* the signed calldata\n * and cannot be filled in afterwards. That also means no `flexFields`: there is\n * nothing to delegate.\n *\n * @throws {SymmError} when the Muon attestation cannot be fetched.\n * @throws {SymmError} `INSTANT_SIGNER_NOT_DELEGATED` when the signer lacks the\n * delegation for the operation, before it is signed.\n * @throws {SymmApiError} when the hedger request fails.\n * @internal\n */\nexport async function submitRasaInstantOpen(\n context: InstantOpenAdapterContext,\n parameters: InstantOpenParameters,\n): Promise<RasaInstantOpenResult> {\n const { config, solver, chainConfig, walletClient, signerAddress, deadline, symbolId, metadata } = context;\n const { symmioAddress, affiliatesAddress } = chainConfig.addresses;\n\n /** Fetch last: the attestation is short-lived and is signed into the calldata. */\n const upnlSig = await getSendQuoteUpnlSig(config, {\n chainId: context.chainId,\n partyA: parameters.subAccountAddress,\n symbolId,\n });\n\n const sendQuoteCallData = encodeSendQuoteWithAffiliateAndData({\n partyBsWhiteList: [solver.address],\n symbolId,\n positionType: parameters.positionType,\n orderType: parameters.orderType ?? ORDER_TYPE_MARKET,\n price: parameters.order.price,\n quantity: parameters.order.quantity,\n cva: parameters.lockedParam.cva,\n lf: parameters.lockedParam.lf,\n partyAmm: parameters.lockedParam.partyAmm,\n partyBmm: parameters.lockedParam.partyBmm,\n deadline,\n affiliate: affiliatesAddress,\n data: metadata,\n upnlSig,\n });\n\n const sendQuoteOp = buildSignedOperation({\n signer: signerAddress,\n target: symmioAddress,\n callData: sendQuoteCallData,\n signerAccount: parameters.subAccountAddress,\n deadline,\n salt: parameters.sendQuoteSalt,\n });\n\n await assertInstantSignerDelegated(config, {\n chainId: context.chainId,\n action: \"instantOpen\",\n operations: [sendQuoteOp],\n enabled: parameters.preflightDelegation,\n });\n\n const sendQuote = await signAndFormatInstantOperation(config, {\n operation: sendQuoteOp,\n chainId: context.chainId,\n walletClient,\n });\n\n const response = await sendRasaInstantOpen(config, {\n chainId: context.chainId,\n // The resolved solver's own id — never a hardcoded kind, so a differently-id'd\n // solver of the same kind can never be re-resolved onto the wrong endpoint.\n solverId: solver.id,\n sendQuote,\n });\n\n const rfq = toRasaInstantOpen(response);\n\n return {\n kind: \"rasa\",\n success: true,\n tempQuoteId: String(response.temp_quote_id),\n partyBmm: response.partyBmm,\n rfq,\n };\n}\n"],"mappings":";;;;;;;;AA8BA,eAAsB,EACpB,GACA,GACgC;CAChC,IAAM,EAAE,WAAQ,WAAQ,gBAAa,iBAAc,kBAAe,aAAU,aAAU,gBAAa,GAC7F,EAAE,kBAAe,yBAAsB,EAAY,WAGnD,IAAU,MAAM,EAAoB,GAAQ;EAChD,SAAS,EAAQ;EACjB,QAAQ,EAAW;EACnB;CACF,CAAC,GAmBK,IAAc,EAAqB;EACvC,QAAQ;EACR,QAAQ;EACR,UApBwB,EAAoC;GAC5D,kBAAkB,CAAC,EAAO,OAAO;GACjC;GACA,cAAc,EAAW;GACzB,WAAW,EAAW,aAAA;GACtB,OAAO,EAAW,MAAM;GACxB,UAAU,EAAW,MAAM;GAC3B,KAAK,EAAW,YAAY;GAC5B,IAAI,EAAW,YAAY;GAC3B,UAAU,EAAW,YAAY;GACjC,UAAU,EAAW,YAAY;GACjC;GACA,WAAW;GACX,MAAM;GACN;EACF,CAKY;EACV,eAAe,EAAW;EAC1B;EACA,MAAM,EAAW;CACnB,CAAC;CAED,MAAM,EAA6B,GAAQ;EACzC,SAAS,EAAQ;EACjB,QAAQ;EACR,YAAY,CAAC,CAAW;EACxB,SAAS,EAAW;CACtB,CAAC;CAED,IAAM,IAAY,MAAM,EAA8B,GAAQ;EAC5D,WAAW;EACX,SAAS,EAAQ;EACjB;CACF,CAAC,GAEK,IAAW,MAAM,EAAoB,GAAQ;EACjD,SAAS,EAAQ;EAGjB,UAAU,EAAO;EACjB;CACF,CAAC,GAEK,IAAM,EAAkB,CAAQ;CAEtC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa,OAAO,EAAS,aAAa;EAC1C,UAAU,EAAS;EACnB;CACF;AACF"}
|
|
@@ -25,11 +25,17 @@ import { InstantOpenParameters, InstantOpenReturnType } from './types.js';
|
|
|
25
25
|
* which case a missing `margin` on an Enigma chain throws
|
|
26
26
|
* `INSTANT_OPEN_MARGIN_REQUIRED` rather than silently under-funding the trade.
|
|
27
27
|
*
|
|
28
|
+
* Before signing, it checks that the signer holds the InstantLayer delegation
|
|
29
|
+
* for every operation it is about to sign (skip it with
|
|
30
|
+
* `preflightDelegation: false`). The sub-account's owner needs none.
|
|
31
|
+
*
|
|
28
32
|
* @param config - The SDK config.
|
|
29
33
|
* @param parameters - Final-wei order, locked params, and the target sub-account.
|
|
30
34
|
* @returns The hedger's acknowledgement, discriminated on `kind`.
|
|
31
35
|
* @throws {SymmError} when the chain or solver is unsupported, or a kind's
|
|
32
36
|
* required inputs are missing.
|
|
37
|
+
* @throws {SymmError} `INSTANT_SIGNER_NOT_DELEGATED` when the signer lacks the
|
|
38
|
+
* delegation, before anything is signed.
|
|
33
39
|
* @throws {SymmApiError} when the hedger request fails.
|
|
34
40
|
*
|
|
35
41
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instant-open.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/instant-open/instant-open.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E
|
|
1
|
+
{"version":3,"file":"instant-open.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/instant-open/instant-open.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAC7E,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAkCnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instant-open.js","names":[],"sources":["../../../../src/solvers/instant-open/instant-open/instant-open.ts"],"sourcesContent":["import type { SymmioSolverKind } from \"../../../core/chains/types\";\nimport type { Config } from \"../../../core/config\";\nimport { SymmError } from \"../../../shared/errors/symm-error\";\nimport { buildQuoteMetadata } from \"../shared/calldata\";\nimport { getMarketOrderDeadline } from \"../shared/trade-math\";\nimport { submitEnigmaInstantOpen, submitRasaInstantOpen, type InstantOpenAdapterContext } from \"./adapters\";\nimport type { InstantOpenParameters, InstantOpenReturnType } from \"./types\";\n\n/**\n * Open an instant position through the solver's InstantLayer v2 flow.\n *\n * Pure primitive — every domain value is already final wei. It builds calldata,\n * signs the operations, and submits them. It does no math and no market\n * fetching; use `prepareInstantOpenParams` to derive this shape from UI inputs,\n * or `instantOpenAuto` for the combined convenience.\n *\n * **The two solver kinds open positions differently, and this dispatches on that:**\n *\n * - **Enigma (lowcap)** signs *two* operations — `addMarginToNextVA` on the\n * AccountLayer plus `sendQuote` on the diamond — funding a fresh virtual\n * account in the same batch. `margin.amount` is required. The quote carries a\n * placeholder Muon signature whose byte range is delegated to the solver.\n * - **Rasa (majors)** signs *one* operation — `sendQuote` on the diamond, under\n * the sub-account. It is cross-margin, so there is no virtual account, no\n * `addMargin`, and no `margin` parameter. The quote carries a **live** Muon\n * attestation fetched immediately before signing.\n *\n * Pass a literal `solverId` to narrow both the parameters and the return type to\n * one kind. Omit it and the chain's `defaultSolverId` decides at runtime — in\n * which case a missing `margin` on an Enigma chain throws\n * `INSTANT_OPEN_MARGIN_REQUIRED` rather than silently under-funding the trade.\n *\n * @param config - The SDK config.\n * @param parameters - Final-wei order, locked params, and the target sub-account.\n * @returns The hedger's acknowledgement, discriminated on `kind`.\n * @throws {SymmError} when the chain or solver is unsupported, or a kind's\n * required inputs are missing.\n * @throws {SymmApiError} when the hedger request fails.\n *\n * @example\n * ```ts\n * // Rasa (majors) — one operation, live Muon sig, no margin.\n * const { tempQuoteId, rfq } = await instantOpen(config, {\n * solverId: \"rasa\",\n * subAccountAddress,\n * marketId: 1,\n * positionType: PositionType.LONG,\n * order: { price: 50_000000000000000000n, quantity: 1_000000000000000000n },\n * lockedParam: { cva: 1_000000000000000000n, lf: 500000000000000000n, partyAmm: 1_500000000000000000n, partyBmm: 1_500000000000000000n },\n * });\n * ```\n */\nexport async function instantOpen<K extends SymmioSolverKind = SymmioSolverKind>(\n config: Config,\n parameters: InstantOpenParameters<K>,\n): Promise<InstantOpenReturnType<K>> {\n const chainConfig = config.getChainConfig(parameters.chainId);\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n\n /** Resolved once: this can prompt the user, so it must not run per adapter. */\n const walletClient = await config.getWalletClient({ chainId: parameters.chainId, from: parameters.from });\n\n const context: InstantOpenAdapterContext = {\n config,\n solver,\n chainConfig,\n walletClient,\n signerAddress: walletClient.account.address,\n chainId: parameters.chainId,\n deadline: parameters.deadline ?? getMarketOrderDeadline(),\n symbolId: BigInt(parameters.marketId),\n metadata: buildQuoteMetadata(parameters.uuid ?? globalThis.crypto.randomUUID()),\n };\n\n switch (solver.id) {\n case \"enigma\":\n return (await submitEnigmaInstantOpen(context, parameters)) as InstantOpenReturnType<K>;\n case \"rasa\":\n return (await submitRasaInstantOpen(context, parameters)) as InstantOpenReturnType<K>;\n default: {\n /** A new solver kind fails to compile here until its adapter is wired in. */\n const unreachable: never = solver.id;\n throw new SymmError(\n \"api\",\n \"UNSUPPORTED_BY_SOLVER\",\n `instantOpen: solver kind \"${String(unreachable)}\" has no instant-open adapter.`,\n );\n }\n }\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"instant-open.js","names":[],"sources":["../../../../src/solvers/instant-open/instant-open/instant-open.ts"],"sourcesContent":["import type { SymmioSolverKind } from \"../../../core/chains/types\";\nimport type { Config } from \"../../../core/config\";\nimport { SymmError } from \"../../../shared/errors/symm-error\";\nimport { buildQuoteMetadata } from \"../shared/calldata\";\nimport { getMarketOrderDeadline } from \"../shared/trade-math\";\nimport { submitEnigmaInstantOpen, submitRasaInstantOpen, type InstantOpenAdapterContext } from \"./adapters\";\nimport type { InstantOpenParameters, InstantOpenReturnType } from \"./types\";\n\n/**\n * Open an instant position through the solver's InstantLayer v2 flow.\n *\n * Pure primitive — every domain value is already final wei. It builds calldata,\n * signs the operations, and submits them. It does no math and no market\n * fetching; use `prepareInstantOpenParams` to derive this shape from UI inputs,\n * or `instantOpenAuto` for the combined convenience.\n *\n * **The two solver kinds open positions differently, and this dispatches on that:**\n *\n * - **Enigma (lowcap)** signs *two* operations — `addMarginToNextVA` on the\n * AccountLayer plus `sendQuote` on the diamond — funding a fresh virtual\n * account in the same batch. `margin.amount` is required. The quote carries a\n * placeholder Muon signature whose byte range is delegated to the solver.\n * - **Rasa (majors)** signs *one* operation — `sendQuote` on the diamond, under\n * the sub-account. It is cross-margin, so there is no virtual account, no\n * `addMargin`, and no `margin` parameter. The quote carries a **live** Muon\n * attestation fetched immediately before signing.\n *\n * Pass a literal `solverId` to narrow both the parameters and the return type to\n * one kind. Omit it and the chain's `defaultSolverId` decides at runtime — in\n * which case a missing `margin` on an Enigma chain throws\n * `INSTANT_OPEN_MARGIN_REQUIRED` rather than silently under-funding the trade.\n *\n * Before signing, it checks that the signer holds the InstantLayer delegation\n * for every operation it is about to sign (skip it with\n * `preflightDelegation: false`). The sub-account's owner needs none.\n *\n * @param config - The SDK config.\n * @param parameters - Final-wei order, locked params, and the target sub-account.\n * @returns The hedger's acknowledgement, discriminated on `kind`.\n * @throws {SymmError} when the chain or solver is unsupported, or a kind's\n * required inputs are missing.\n * @throws {SymmError} `INSTANT_SIGNER_NOT_DELEGATED` when the signer lacks the\n * delegation, before anything is signed.\n * @throws {SymmApiError} when the hedger request fails.\n *\n * @example\n * ```ts\n * // Rasa (majors) — one operation, live Muon sig, no margin.\n * const { tempQuoteId, rfq } = await instantOpen(config, {\n * solverId: \"rasa\",\n * subAccountAddress,\n * marketId: 1,\n * positionType: PositionType.LONG,\n * order: { price: 50_000000000000000000n, quantity: 1_000000000000000000n },\n * lockedParam: { cva: 1_000000000000000000n, lf: 500000000000000000n, partyAmm: 1_500000000000000000n, partyBmm: 1_500000000000000000n },\n * });\n * ```\n */\nexport async function instantOpen<K extends SymmioSolverKind = SymmioSolverKind>(\n config: Config,\n parameters: InstantOpenParameters<K>,\n): Promise<InstantOpenReturnType<K>> {\n const chainConfig = config.getChainConfig(parameters.chainId);\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n\n /** Resolved once: this can prompt the user, so it must not run per adapter. */\n const walletClient = await config.getWalletClient({ chainId: parameters.chainId, from: parameters.from });\n\n const context: InstantOpenAdapterContext = {\n config,\n solver,\n chainConfig,\n walletClient,\n signerAddress: walletClient.account.address,\n chainId: parameters.chainId,\n deadline: parameters.deadline ?? getMarketOrderDeadline(),\n symbolId: BigInt(parameters.marketId),\n metadata: buildQuoteMetadata(parameters.uuid ?? globalThis.crypto.randomUUID()),\n };\n\n switch (solver.id) {\n case \"enigma\":\n return (await submitEnigmaInstantOpen(context, parameters)) as InstantOpenReturnType<K>;\n case \"rasa\":\n return (await submitRasaInstantOpen(context, parameters)) as InstantOpenReturnType<K>;\n default: {\n /** A new solver kind fails to compile here until its adapter is wired in. */\n const unreachable: never = solver.id;\n throw new SymmError(\n \"api\",\n \"UNSUPPORTED_BY_SOLVER\",\n `instantOpen: solver kind \"${String(unreachable)}\" has no instant-open adapter.`,\n );\n }\n }\n}\n"],"mappings":";;;;;;AA0DA,eAAsB,EACpB,GACA,GACmC;CACnC,IAAM,IAAc,EAAO,eAAe,EAAW,OAAO,GACtD,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC,GAGxF,IAAe,MAAM,EAAO,gBAAgB;EAAE,SAAS,EAAW;EAAS,MAAM,EAAW;CAAK,CAAC,GAElG,IAAqC;EACzC;EACA;EACA;EACA;EACA,eAAe,EAAa,QAAQ;EACpC,SAAS,EAAW;EACpB,UAAU,EAAW,YAAY,EAAuB;EACxD,UAAU,OAAO,EAAW,QAAQ;EACpC,UAAU,EAAmB,EAAW,QAAQ,WAAW,OAAO,WAAW,CAAC;CAChF;CAEA,QAAQ,EAAO,IAAf;EACE,KAAK,UACH,OAAQ,MAAM,EAAwB,GAAS,CAAU;EAC3D,KAAK,QACH,OAAQ,MAAM,EAAsB,GAAS,CAAU;EACzD,SAAS;GAEP,IAAM,IAAqB,EAAO;GAClC,MAAM,IAAI,EACR,OACA,yBACA,6BAA6B,OAAO,CAAW,EAAE,+BACnD;EACF;CACF;AACF"}
|
|
@@ -2,6 +2,7 @@ import { Address, Hex } from 'viem';
|
|
|
2
2
|
import { SymmioSolverKind } from '../../../core/chains/types.js';
|
|
3
3
|
import { ChainIdParameter, Compute, FromParameter } from '../../../shared/types/properties.js';
|
|
4
4
|
import { PositionType } from '../../../symmio-contracts/symmio/types.js';
|
|
5
|
+
import { InstantDelegationPreflightParameter } from '../../shared/instant-delegation-preflight.js';
|
|
5
6
|
import { RasaInstantOpen } from '../get-instant-opens/types.js';
|
|
6
7
|
import { InstantOpenLockedParams, InstantOpenMargin, InstantOpenOrder, SolverFeeCaps, SolverOrderType } from '../shared/types.js';
|
|
7
8
|
/**
|
|
@@ -14,7 +15,7 @@ import { InstantOpenLockedParams, InstantOpenMargin, InstantOpenOrder, SolverFee
|
|
|
14
15
|
* Passing a literal `solverId` binds `K`, which narrows the **return** type to
|
|
15
16
|
* that solver's result variant.
|
|
16
17
|
*/
|
|
17
|
-
export type InstantOpenParameters<K extends SymmioSolverKind = SymmioSolverKind> = Compute<ChainIdParameter & FromParameter & {
|
|
18
|
+
export type InstantOpenParameters<K extends SymmioSolverKind = SymmioSolverKind> = Compute<ChainIdParameter & FromParameter & InstantDelegationPreflightParameter & {
|
|
18
19
|
/** Which solver to open against. Omit to use the chain's default solver. */
|
|
19
20
|
solverId?: K;
|
|
20
21
|
/** Sub-account / partyA address — the `signerAccount.addr` the operation runs under. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/instant-open/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,OAAO,CACxF,gBAAgB,GACd,aAAa,GAAG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/instant-open/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2CAA2C,CAAC;AACrG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,OAAO,CACxF,gBAAgB,GACd,aAAa,GACb,mCAAmC,GAAG;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,wFAAwF;IACxF,iBAAiB,EAAE,OAAO,CAAC;IAC3B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,8EAA8E;IAC9E,KAAK,EAAE,gBAAgB,CAAC;IACxB,8FAA8F;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mGAAmG;IACnG,WAAW,EAAE,uBAAuB,CAAC;IACrC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,sEAAsE;IACtE,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CACJ,CAAC;AAEF,sEAAsE;AACtE,UAAU,qBAAqB;IAC7B,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,mEAAmE;AACnE,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,mDAAmD;IACnD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,gEAAgE;AAChE,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,EAAE,eAAe,CAAC;CACtB;AAED,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,uBAAuB,CAAC;IAChC,IAAI,EAAE,qBAAqB,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Config } from '../../../core/config/index.js';
|
|
|
3
3
|
import { Compute, WriteSolverParameter } from '../../../shared/types/properties.js';
|
|
4
4
|
import { FeeForUser } from '../../../symmio-contracts/symmio/actions/get-fee-for-user.js';
|
|
5
5
|
import { EnigmaSolverInfo } from '../../get-solver-info/index.js';
|
|
6
|
+
import { InstantDelegationPreflightParameter } from '../../shared/instant-delegation-preflight.js';
|
|
6
7
|
import { ApiLockedParamsBySymbolIdResponse } from '../../types/generated/enigma-solver.js';
|
|
7
8
|
import { InstantOpenParameters } from '../instant-open/types.js';
|
|
8
9
|
import { InstantOpenMarketData, PositionType } from '../shared/types.js';
|
|
@@ -37,8 +38,9 @@ export interface FullBalanceFunding {
|
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Fields shared by every {@link PrepareInstantOpenParameters} funding mode.
|
|
41
|
+
* `preflightDelegation` is forwarded to {@link InstantOpenParameters}.
|
|
40
42
|
*/
|
|
41
|
-
type PrepareInstantOpenBaseParameters = WriteSolverParameter & {
|
|
43
|
+
type PrepareInstantOpenBaseParameters = WriteSolverParameter & InstantDelegationPreflightParameter & {
|
|
42
44
|
/** Sub-account / partyA address. */
|
|
43
45
|
subAccountAddress: Address;
|
|
44
46
|
/** Market identification + optional pre-fetched precision metadata. */
|
package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-instant-open-params.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AASnE,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA+BhF;;;;;;GAMG;AACH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,IAAI,EAAE,cAAc,CAAC;IACrB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED
|
|
1
|
+
{"version":3,"file":"prepare-instant-open-params.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2CAA2C,CAAC;AACrG,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AASnE,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA+BhF;;;;;;GAMG;AACH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,IAAI,EAAE,cAAc,CAAC;IACrB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,KAAK,gCAAgC,GAAG,oBAAoB,GAC1D,mCAAmC,GAAG;IACpC,oCAAoC;IACpC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,uEAAuE;IACvE,MAAM,EAAE,qBAAqB,CAAC;IAC9B,kBAAkB;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,8GAA8G;IAC9G,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,iCAAiC,CAAC;IACvD;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,kDAAkD;IAClD,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEJ;;;;;;;;GAQG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAChD,gCAAgC,GAAG;IACjC,sGAAsG;IACtG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC3B,CACF,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,kCAAkC,GAAG,qBAAqB,GAAG;IACvE,uFAAuF;IACvF,WAAW,EAAE,gBAAgB,GAAG,cAAc,CAAC;CAChD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,4BAA4B,GACvC,OAAO,CAAC,kCAAkC,CAAC,CAkR7C"}
|
package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.js
CHANGED
|
@@ -188,7 +188,8 @@ async function b(r, v) {
|
|
|
188
188
|
addMarginSalt: v.addMarginSalt,
|
|
189
189
|
sendQuoteSalt: v.sendQuoteSalt,
|
|
190
190
|
deadline: v.deadline,
|
|
191
|
-
operationDeadline: v.operationDeadline
|
|
191
|
+
operationDeadline: v.operationDeadline,
|
|
192
|
+
preflightDelegation: v.preflightDelegation
|
|
192
193
|
};
|
|
193
194
|
}
|
|
194
195
|
//#endregion
|