@stryke-xyz/premarket-sdk 1.1.8 → 1.1.9
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/README.md +256 -83
- package/dist/cjs/abi/MarketsRegistry.abi.json +98 -0
- package/dist/cjs/abi/OptionMarketVault.abi.json +78 -5
- package/dist/cjs/api/README.md +296 -0
- package/dist/cjs/config/README.md +112 -0
- package/dist/cjs/config/index.js +7 -3
- package/dist/cjs/exchange/README.md +280 -0
- package/dist/cjs/registry/README.md +150 -0
- package/dist/cjs/registry/markets-registry-contract.js +4 -1
- package/dist/cjs/registry/types.js +6 -2
- package/dist/cjs/shared/README.md +235 -0
- package/dist/cjs/shared/types.js +1 -1
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/sync/README.md +215 -0
- package/dist/cjs/sync/clients/base-client.js +518 -0
- package/dist/cjs/sync/redis-ws-client.js +235 -0
- package/dist/cjs/utils/README.md +89 -0
- package/dist/cjs/vault/README.md +268 -0
- package/dist/cjs/vault/transactions.js +4 -3
- package/dist/esm/abi/MarketsRegistry.abi.json +98 -0
- package/dist/esm/abi/OptionMarketVault.abi.json +78 -5
- package/dist/esm/api/README.md +296 -0
- package/dist/esm/config/README.md +112 -0
- package/dist/esm/config/index.js +4 -3
- package/dist/esm/exchange/README.md +280 -0
- package/dist/esm/registry/README.md +150 -0
- package/dist/esm/registry/markets-registry-contract.js +4 -1
- package/dist/esm/registry/types.js +6 -2
- package/dist/esm/shared/README.md +235 -0
- package/dist/esm/shared/types.js +1 -1
- package/dist/esm/shared/utils.js +0 -0
- package/dist/esm/sync/README.md +215 -0
- package/dist/esm/sync/clients/base-client.js +508 -0
- package/dist/esm/sync/redis-ws-client.js +225 -0
- package/dist/esm/utils/README.md +89 -0
- package/dist/esm/vault/README.md +268 -0
- package/dist/esm/vault/transactions.js +4 -3
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/registry/types.d.ts +4 -0
- package/dist/types/shared/types.d.ts +8 -0
- package/dist/types/shared/utils.d.ts +0 -0
- package/dist/types/sync/clients/base-client.d.ts +56 -0
- package/dist/types/sync/redis-ws-client.d.ts +21 -0
- package/dist/types/vault/transactions.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -311,65 +311,102 @@ Constructor config:
|
|
|
311
311
|
- `baseUrl`
|
|
312
312
|
- `fetchFn?`
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
- `createOrder(params, bearerToken)`
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
- `
|
|
324
|
-
|
|
325
|
-
- `
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
- `
|
|
333
|
-
- `
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
314
|
+
#### Order methods
|
|
315
|
+
|
|
316
|
+
- `createOrder(params, bearerToken)` — submits a new order and synchronously
|
|
317
|
+
returns the engine's match outcome. The backend awaits the matching engine's
|
|
318
|
+
reply (up to ~2 s). If the engine does not reply in time,
|
|
319
|
+
`matchResult.message === "awaiting match"` and `matches` is empty — callers
|
|
320
|
+
should then poll `getOrder` or watch the user activity WebSocket.
|
|
321
|
+
- `getOrder(orderHash)` — fetches a single stored order by hash; returns
|
|
322
|
+
`null` on 404.
|
|
323
|
+
- `getOrders(marketId, maker?)` — active orders for a market, optionally
|
|
324
|
+
scoped to a maker.
|
|
325
|
+
- `getUserOrders(maker, marketId)` — convenience wrapper around `getOrders`.
|
|
326
|
+
- `getUserOrdersAllMarkets(maker, opts?)` — all open orders across **all**
|
|
327
|
+
markets for a maker, paginated. `opts` accepts `{ limit?, offset?, status? }`.
|
|
328
|
+
Returns `PaginatedOrdersResponse`.
|
|
329
|
+
|
|
330
|
+
#### Market methods
|
|
331
|
+
|
|
332
|
+
- `getMarkets()` — full market catalog.
|
|
333
|
+
- `getMarketRecentTrades(marketId, limit?)` — recent trade activity, newest
|
|
334
|
+
first.
|
|
335
|
+
- `getMarket(marketId)` — single market by id; returns `null` on 404.
|
|
336
|
+
|
|
337
|
+
#### Position and PnL methods
|
|
338
|
+
|
|
339
|
+
- `getUserPositions(userAddress)` — enriched positions including market name,
|
|
340
|
+
instrument name, logo, collateral info, PnL breakdown, role flags
|
|
341
|
+
(`isOPrm`, `isOpen`), expiry, token ids, and `hasFinalTick`. Also returns a
|
|
342
|
+
`grouped` array keyed by market. Returns `EnrichedPositionsResponse`.
|
|
343
|
+
- `getUserTradingPnL(userAddress)` — realized trading PnL for limit-order
|
|
344
|
+
activity.
|
|
345
|
+
- `getUserPnL(userAddress)` — aggregated PnL across positions and orderbook
|
|
346
|
+
trading.
|
|
347
|
+
- `getTokenPnL(userAddress, tokenId)` — PnL for a single ERC-6909 token id.
|
|
348
|
+
- `getErc20PnL(userAddress, tokenAddress)` — trading PnL for a single ERC-20
|
|
349
|
+
token.
|
|
350
|
+
|
|
351
|
+
#### History methods
|
|
352
|
+
|
|
353
|
+
`getUserHistories` accepts an optional `opts` object with `limit?`, `marketId?`,
|
|
354
|
+
and `tokenId?` filters.
|
|
355
|
+
|
|
356
|
+
- `getUserHistories(userAddress, opts?)` — grouped + enriched user history.
|
|
357
|
+
Every event carries `marketName`, `instrumentName`, `logoUri`,
|
|
358
|
+
`collateralDecimals`, `collateralToken`, and a `type` discriminator. The
|
|
359
|
+
`timeline` field is a flat chronological list of all event types.
|
|
338
360
|
- `getMintHistory(userAddress, limit?)`
|
|
339
361
|
- `getRedeemHistory(userAddress, limit?)`
|
|
340
362
|
- `getUnwindHistory(userAddress, limit?)`
|
|
341
363
|
- `getTransferHistory(userAddress, limit?)`
|
|
342
364
|
- `getFillHistory(userAddress, limit?)`
|
|
343
365
|
|
|
344
|
-
Auth
|
|
366
|
+
#### Auth methods
|
|
345
367
|
|
|
346
|
-
- `getChallenge({ address, chainId })`
|
|
347
|
-
|
|
368
|
+
- `getChallenge({ address, chainId })` — requests an EIP-712 login challenge.
|
|
369
|
+
Returns `AuthChallenge`.
|
|
370
|
+
- `verifyAuth({ account, nonce, signature, chainId, expiresAt })` — verifies
|
|
371
|
+
the signed challenge. Returns `{ access: string }` (bearer token).
|
|
348
372
|
|
|
349
|
-
Integration
|
|
373
|
+
Integration notes:
|
|
350
374
|
|
|
351
|
-
- `getOrders` and `getUserOrders` both require a `marketId`.
|
|
352
|
-
|
|
353
|
-
|
|
375
|
+
- `getOrders` and `getUserOrders` both require a `marketId`. Active and
|
|
376
|
+
partially-filled orders are returned; cancelled / fully-filled / expired
|
|
377
|
+
orders are filtered server-side.
|
|
378
|
+
- `getUserOrdersAllMarkets` operates in paginated mode and does not require a
|
|
379
|
+
`marketId`; it defaults to `limit: 1000, offset: 0`.
|
|
354
380
|
|
|
355
381
|
### Deserializers
|
|
356
382
|
|
|
357
383
|
The API returns string-heavy DTOs because JSON cannot safely transport
|
|
358
|
-
`bigint`. Public helpers convert those payloads into bigint-friendly objects
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
- `
|
|
363
|
-
- `
|
|
364
|
-
- `
|
|
365
|
-
- `
|
|
366
|
-
- `
|
|
367
|
-
- `
|
|
368
|
-
- `
|
|
369
|
-
- `
|
|
370
|
-
- `
|
|
371
|
-
- `
|
|
372
|
-
|
|
384
|
+
`bigint`. Public helpers convert those payloads into bigint-friendly objects.
|
|
385
|
+
|
|
386
|
+
Scalar deserializers:
|
|
387
|
+
|
|
388
|
+
- `marketInstrumentToBigInt(instrument)` → `BigIntMarketInstrument`
|
|
389
|
+
- `marketToBigInt(market)` → `BigIntMarket`
|
|
390
|
+
- `marketsToBigInt(data)` → `{ markets: BigIntMarket[]; total: number }`
|
|
391
|
+
- `positionToBigInt(position)` → bigint position fields
|
|
392
|
+
- `tradingPnLToBigInt(trading)` → bigint PnL fields
|
|
393
|
+
- `mintHistoryToBigInt(mint)` → bigint mint history fields
|
|
394
|
+
- `redeemHistoryToBigInt(redeem)` → bigint redeem history fields
|
|
395
|
+
- `unwindHistoryToBigInt(unwind)` → bigint unwind history fields
|
|
396
|
+
- `transferHistoryToBigInt(transfer)` → bigint transfer history fields
|
|
397
|
+
- `fillHistoryToBigInt(fill)` → bigint fill history fields
|
|
398
|
+
|
|
399
|
+
BigInt market types exported for use with deserialized data:
|
|
400
|
+
|
|
401
|
+
- `BigIntBaseMarketInstrument`
|
|
402
|
+
- `BigIntVanillaMarketInstrument`
|
|
403
|
+
- `BigIntSpreadMarketInstrument`
|
|
404
|
+
- `BigIntMarketInstrument` (union)
|
|
405
|
+
- `BigIntBaseMarket`
|
|
406
|
+
- `BigIntErc6909Market`
|
|
407
|
+
- `BigIntErc20Market`
|
|
408
|
+
- `BigIntErc20Submarket`
|
|
409
|
+
- `BigIntMarket` (union)
|
|
373
410
|
|
|
374
411
|
## Vault Module
|
|
375
412
|
|
|
@@ -477,26 +514,42 @@ export interface TransactionCall {
|
|
|
477
514
|
|
|
478
515
|
User-facing lifecycle builders:
|
|
479
516
|
|
|
480
|
-
- `buildMintTransaction(vaultAddress, instrument, amount)`
|
|
481
|
-
|
|
482
|
-
- `
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
- `
|
|
486
|
-
|
|
487
|
-
- `
|
|
517
|
+
- `buildMintTransaction(vaultAddress, instrument, amount)` — deposit collateral
|
|
518
|
+
to receive PRM + oPRM tokens.
|
|
519
|
+
- `buildWithdrawTransaction(vaultAddress, prmTokenId, amount, receiver)` —
|
|
520
|
+
before expiry burns PRM + oPRM to return collateral; after expiry settles and
|
|
521
|
+
returns collateral minus loss.
|
|
522
|
+
- `buildRedeemTransaction(vaultAddress, oPrmTokenId, receiver)` — option
|
|
523
|
+
holders redeem oPRM tokens to claim profit after expiry.
|
|
524
|
+
- `buildUnwindTransaction(vaultAddress, prmTokenId, amount, receiver)` — alias
|
|
525
|
+
for `buildWithdrawTransaction`; burns both PRM and oPRM to reclaim collateral
|
|
526
|
+
before expiry.
|
|
527
|
+
- `buildRolloverTransaction(vaultAddress, oldPrmTokenId)` — rolls an expired
|
|
528
|
+
PRM position into the next epoch.
|
|
529
|
+
- `buildApproveTransaction(tokenAddress, spender, amount?)` — ERC-20 approval
|
|
530
|
+
(defaults to `maxUint256`).
|
|
531
|
+
- `buildBatchedMintTransactions(collateralTokenAddress, vaultAddress, instrument, collateralAmount, prmAmount)` —
|
|
532
|
+
returns `[approve, mint]` as a `TransactionCall[]` for a single UserOp batch.
|
|
533
|
+
- `buildSetOperatorTransaction(vaultAddress, operator, approved)` — ERC-6909
|
|
534
|
+
operator approval for delegated transfers.
|
|
488
535
|
|
|
489
536
|
Restricted or role-gated builders:
|
|
490
537
|
|
|
491
|
-
- `buildDelegateRedeemTransaction`
|
|
492
|
-
|
|
493
|
-
- `
|
|
494
|
-
|
|
495
|
-
- `
|
|
496
|
-
|
|
497
|
-
- `
|
|
498
|
-
|
|
499
|
-
- `
|
|
538
|
+
- `buildDelegateRedeemTransaction(vaultAddress, oPrmTokenId, receiver)` —
|
|
539
|
+
callable only by RedeemKeeper role.
|
|
540
|
+
- `buildDelegateRolloverTransaction(vaultAddress, oldPrmTokenId, holder)` —
|
|
541
|
+
callable only by RolloverKeeper role.
|
|
542
|
+
- `buildDelegateWithdrawTransaction(vaultAddress, prmTokenId, amount, owner, receiver?)` —
|
|
543
|
+
callable only by WithdrawKeeper role.
|
|
544
|
+
- `buildFillMarketDeliveryTransaction(vaultAddress, marketId, amount)` —
|
|
545
|
+
physical settlement market funding.
|
|
546
|
+
- `buildSetRolloverEnabledTransaction(vaultAddress, enabled)`
|
|
547
|
+
- `buildSetRoleTransaction(vaultAddress, account, role, enabled)` — owner only.
|
|
548
|
+
- `buildUpdateFinalTickTransaction(vaultAddress, marketId, tick)` —
|
|
549
|
+
FinalTickKeeper role.
|
|
550
|
+
- `buildUpdateMarketExpiryTransaction(vaultAddress, marketId, expiry)` —
|
|
551
|
+
MarketFinalizer role.
|
|
552
|
+
- `buildUpdateMarketExpiryFromMarketTransaction(vaultAddress, marketId, expiry)`
|
|
500
553
|
|
|
501
554
|
## Registry Module
|
|
502
555
|
|
|
@@ -670,8 +723,8 @@ applications do not hardcode environment-specific values.
|
|
|
670
723
|
|
|
671
724
|
Exports from `src/config/chains.ts`:
|
|
672
725
|
|
|
673
|
-
- `megaETH`
|
|
674
|
-
- `SUPPORTED_CHAINS`
|
|
726
|
+
- `megaETH` — viem chain definition for MegaETH mainnet (chain id `4326`)
|
|
727
|
+
- `SUPPORTED_CHAINS` — union type of supported chain ids
|
|
675
728
|
|
|
676
729
|
Runtime lookup from `src/config/index.ts`:
|
|
677
730
|
|
|
@@ -700,9 +753,9 @@ Public token maps:
|
|
|
700
753
|
|
|
701
754
|
Important nuance:
|
|
702
755
|
|
|
703
|
-
- `USDM`, `USDT0`, `MARKETS_REGISTRY`, `
|
|
704
|
-
`ERC_TOKENS_RESTRICTION_MODULE` are partial maps because
|
|
705
|
-
not exist on every supported chain
|
|
756
|
+
- `USDM`, `USDT0`, `MARKETS_REGISTRY`, `COMMUNITY_MARKET_MANAGER`,
|
|
757
|
+
`FEE_REGISTRY`, and `ERC_TOKENS_RESTRICTION_MODULE` are partial maps because
|
|
758
|
+
those deployments do not exist on every supported chain
|
|
706
759
|
|
|
707
760
|
### Contract address maps
|
|
708
761
|
|
|
@@ -712,6 +765,7 @@ Public address maps:
|
|
|
712
765
|
- `OPTION_MARKET_VAULT`
|
|
713
766
|
- `EXCHANGE`
|
|
714
767
|
- `MARKETS_REGISTRY`
|
|
768
|
+
- `COMMUNITY_MARKET_MANAGER`
|
|
715
769
|
- `ENTRY_POINT`
|
|
716
770
|
- `SIMPLE_ACCOUNT_FACTORY`
|
|
717
771
|
- `FEE_REGISTRY`
|
|
@@ -733,9 +787,11 @@ safely over JSON.
|
|
|
733
787
|
Main exports:
|
|
734
788
|
|
|
735
789
|
- `Order`
|
|
736
|
-
- `OrderSignature`
|
|
790
|
+
- `OrderSignature` — `0x${string}` (65-byte concatenated hex)
|
|
791
|
+
- `SplitOrderSignature` — wire format `{ r: string; vs: string }` (EIP-2098
|
|
792
|
+
compact pair) expected by the orderbook backend
|
|
737
793
|
- `OrderStatus`
|
|
738
|
-
- `TimeInForce`
|
|
794
|
+
- `TimeInForce` — `"FOK" | "FAK" | "GTC" | "GTD"`
|
|
739
795
|
- `CreateOrderParams`
|
|
740
796
|
- `CreateOrderRequest`
|
|
741
797
|
- `StoredOrder`
|
|
@@ -746,6 +802,7 @@ Main exports:
|
|
|
746
802
|
- `CreateOrderResult`
|
|
747
803
|
- `OrderResponse`
|
|
748
804
|
- `OrdersSnapshot`
|
|
805
|
+
- `PaginatedOrdersResponse`
|
|
749
806
|
|
|
750
807
|
Main order write shape:
|
|
751
808
|
|
|
@@ -755,6 +812,8 @@ export interface CreateOrderParams {
|
|
|
755
812
|
order: Order;
|
|
756
813
|
signature: OrderSignature;
|
|
757
814
|
operator?: string;
|
|
815
|
+
/** Primary wallet address (depositor) — required for ERC1271 smart account maker validation */
|
|
816
|
+
depositor?: string;
|
|
758
817
|
timeInForce?: TimeInForce;
|
|
759
818
|
postOnly?: boolean;
|
|
760
819
|
}
|
|
@@ -775,31 +834,119 @@ export interface StoredOrder {
|
|
|
775
834
|
status: OrderStatus;
|
|
776
835
|
side: "bid" | "ask";
|
|
777
836
|
price: number;
|
|
837
|
+
// Enriched by the order-queue when returning user orders
|
|
838
|
+
marketName?: string;
|
|
839
|
+
instrumentName?: string;
|
|
840
|
+
logoUri?: string | null;
|
|
778
841
|
}
|
|
779
842
|
```
|
|
780
843
|
|
|
781
844
|
### Market DTOs
|
|
782
845
|
|
|
846
|
+
`Market` is a discriminated union (`ApiMarket = Erc6909Market | Erc20Market`).
|
|
847
|
+
The `type` field (`"erc6909"` | `"erc20"`) is the discriminant.
|
|
848
|
+
|
|
849
|
+
`MarketInstrument` is also a discriminated union:
|
|
850
|
+
|
|
851
|
+
```ts
|
|
852
|
+
export type MarketInstrument =
|
|
853
|
+
| VanillaMarketInstrument // isSpread: false, spreadType: "vanilla"
|
|
854
|
+
| SpreadMarketInstrument; // isSpread: true, spreadType: "standard" | "absolute"
|
|
855
|
+
```
|
|
856
|
+
|
|
783
857
|
Public exports:
|
|
784
858
|
|
|
785
|
-
- `
|
|
786
|
-
- `
|
|
859
|
+
- `SpreadType` — `"vanilla" | "standard" | "absolute"`
|
|
860
|
+
- `BaseMarket` — shared fields across all market types, including `hasFinalTick`
|
|
861
|
+
- `BaseMarketInstrument` — shared instrument fields including `prmTokenId`,
|
|
862
|
+
`oPrmTokenId`, `expiry`
|
|
863
|
+
- `VanillaMarketInstrument`
|
|
864
|
+
- `SpreadMarketInstrument` — adds `lower` and `upper` bound fields
|
|
865
|
+
- `MarketInstrument` (union)
|
|
866
|
+
- `Erc20Submarket` — ERC-20 sub-market/instrument entry
|
|
867
|
+
- `Erc6909Market` — full ERC-6909 market shape (vault-backed)
|
|
868
|
+
- `Erc20Market` — ERC-20 market shape with `instruments` array
|
|
869
|
+
- `ApiMarket` / `Market` (union)
|
|
787
870
|
- `MarketResponse`
|
|
788
871
|
- `MarketsResponse`
|
|
789
872
|
|
|
790
|
-
`
|
|
791
|
-
top-of-book values, recent prices, collateral totals, and supply.
|
|
873
|
+
Key `BaseMarket` fields:
|
|
792
874
|
|
|
793
|
-
|
|
794
|
-
|
|
875
|
+
```ts
|
|
876
|
+
export interface BaseMarket {
|
|
877
|
+
id: string;
|
|
878
|
+
groupId: string | null;
|
|
879
|
+
groupName: string | null; // populated for grouped ERC-20 markets
|
|
880
|
+
type: "erc6909" | "erc20";
|
|
881
|
+
name: string;
|
|
882
|
+
collateralToken: string;
|
|
883
|
+
collateralDecimals: number;
|
|
884
|
+
marketType: "ERC20xERC20" | "ERC20xERC6909";
|
|
885
|
+
logoUri: string | null;
|
|
886
|
+
/** True when the on-chain FinalTick event has been indexed for this market's current expiry. */
|
|
887
|
+
hasFinalTick: boolean;
|
|
888
|
+
// ... pricing / ordering fields
|
|
889
|
+
}
|
|
890
|
+
```
|
|
795
891
|
|
|
796
892
|
### Position and PnL DTOs
|
|
797
893
|
|
|
798
894
|
Public exports:
|
|
799
895
|
|
|
800
|
-
- `UserPosition`
|
|
896
|
+
- `UserPosition` — raw position fields (holding, cost, proceeds, PnL)
|
|
897
|
+
- `EventEnrichment` — optional market/instrument metadata attached to positions
|
|
898
|
+
and history events (`collateralSymbol`, `marketId`, `marketName`,
|
|
899
|
+
`instrumentName`, `logoUri`, `collateralDecimals`, `collateralToken`)
|
|
900
|
+
- `EnrichedPosition` — `UserPosition` + `EventEnrichment` + role flags and
|
|
901
|
+
additional instrument fields:
|
|
902
|
+
|
|
903
|
+
```ts
|
|
904
|
+
export interface EnrichedPosition extends UserPosition, EventEnrichment {
|
|
905
|
+
isOpen: boolean; // true when holding > 0
|
|
906
|
+
isOPrm: boolean; // true = oPRM (outcome), false = PRM (write/minted)
|
|
907
|
+
marketId: string;
|
|
908
|
+
marketName: string;
|
|
909
|
+
instrumentName: string;
|
|
910
|
+
logoUri: string | null;
|
|
911
|
+
collateralDecimals: number;
|
|
912
|
+
collateralToken: string;
|
|
913
|
+
/** Unix timestamp string for this instrument's epoch expiry (null for ERC20 markets). */
|
|
914
|
+
expiry?: string | null;
|
|
915
|
+
/** prmTokenId for this instrument (decimal string). */
|
|
916
|
+
prmTokenId?: string | null;
|
|
917
|
+
/** oPrmTokenId for this instrument (decimal string). */
|
|
918
|
+
oPrmTokenId?: string | null;
|
|
919
|
+
/** true when an on-chain FinalTick event has been indexed for this instrument epoch. */
|
|
920
|
+
hasFinalTick?: boolean;
|
|
921
|
+
/** PnL contribution from limit-order trades */
|
|
922
|
+
tradePnl: string;
|
|
923
|
+
/** PnL contribution from redemption / exercise settlements */
|
|
924
|
+
redeemExercisePnl: string;
|
|
925
|
+
}
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
- `EnrichedPositionsResponse`:
|
|
929
|
+
|
|
930
|
+
```ts
|
|
931
|
+
export interface EnrichedPositionsResponse {
|
|
932
|
+
/** Flat list sorted by updatedAt desc. */
|
|
933
|
+
positions: EnrichedPosition[];
|
|
934
|
+
/** Same positions grouped by market. */
|
|
935
|
+
grouped: Array<{
|
|
936
|
+
marketId: string;
|
|
937
|
+
marketName: string;
|
|
938
|
+
logoUri: string | null;
|
|
939
|
+
collateralDecimals: number;
|
|
940
|
+
collateralToken: string;
|
|
941
|
+
positions: EnrichedPosition[];
|
|
942
|
+
}>;
|
|
943
|
+
}
|
|
944
|
+
```
|
|
945
|
+
|
|
801
946
|
- `TradingPnL`
|
|
802
|
-
- `
|
|
947
|
+
- `SettlementPnL` — settlement-specific PnL (`tokenId`, `totalProceeds`,
|
|
948
|
+
`realizedPnL`, `updatedAt`)
|
|
949
|
+
- `UserPnL` — aggregated `tradePnl`, `redeemExercisePnl`, `totalPnl`
|
|
803
950
|
- `TokenPnL`
|
|
804
951
|
- `Erc20PnL`
|
|
805
952
|
|
|
@@ -808,15 +955,41 @@ Public exports:
|
|
|
808
955
|
Public exports:
|
|
809
956
|
|
|
810
957
|
- `MintHistoryItem`
|
|
811
|
-
- `RedeemHistoryItem`
|
|
958
|
+
- `RedeemHistoryItem` — includes `netProceeds` (profit minus fees)
|
|
812
959
|
- `UnwindHistoryItem`
|
|
960
|
+
- `WithdrawHistoryItem` — post-expiry withdraw events (includes `loss`,
|
|
961
|
+
`lossUsdc`, `finalTick`, `netProceeds`)
|
|
962
|
+
- `RolloverHistoryItem` — rollover events (includes `oldExpiry`, `newExpiry`,
|
|
963
|
+
`residualCollateral`, `rolloverFee`, `finalTick`)
|
|
813
964
|
- `TransferHistoryItem`
|
|
814
|
-
- `OrderFillHistoryItem`
|
|
815
|
-
- `
|
|
965
|
+
- `OrderFillHistoryItem` — includes `isAsk` and `role` (`"maker" | "taker"`)
|
|
966
|
+
- `OrderCancelHistoryItem`
|
|
967
|
+
- `MarketTradeItem` (alias for `OrderFillHistoryItem`)
|
|
968
|
+
- `AnyHistoryEvent` — discriminated union of all history event types
|
|
816
969
|
- `UserHistories`
|
|
817
970
|
|
|
818
|
-
`UserHistories` groups
|
|
819
|
-
`
|
|
971
|
+
`UserHistories` groups all history types. The `timeline` field (when present)
|
|
972
|
+
is a flat chronological list of all events with a `type` discriminator:
|
|
973
|
+
|
|
974
|
+
```ts
|
|
975
|
+
export interface UserHistories {
|
|
976
|
+
mints: MintHistoryItem[];
|
|
977
|
+
redeems: RedeemHistoryItem[];
|
|
978
|
+
unwinds: UnwindHistoryItem[];
|
|
979
|
+
withdraws: WithdrawHistoryItem[];
|
|
980
|
+
rollovers: RolloverHistoryItem[];
|
|
981
|
+
transfers: TransferHistoryItem[];
|
|
982
|
+
fills: OrderFillHistoryItem[];
|
|
983
|
+
cancels: OrderCancelHistoryItem[];
|
|
984
|
+
/** Flat chronological list (newest first). Each event has a `type` field. */
|
|
985
|
+
timeline?: AnyHistoryEvent[];
|
|
986
|
+
}
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
### Auth types
|
|
990
|
+
|
|
991
|
+
- `AuthChallenge` — EIP-712 typed-data challenge returned by `getChallenge`.
|
|
992
|
+
Contains `domain`, `types`, and `message` (with `nonce` and `expiresAt`).
|
|
820
993
|
|
|
821
994
|
## Root-Level Helpers
|
|
822
995
|
|
|
@@ -549,6 +549,19 @@
|
|
|
549
549
|
"outputs": [],
|
|
550
550
|
"stateMutability": "nonpayable"
|
|
551
551
|
},
|
|
552
|
+
{
|
|
553
|
+
"type": "function",
|
|
554
|
+
"name": "setVault",
|
|
555
|
+
"inputs": [
|
|
556
|
+
{
|
|
557
|
+
"name": "vault_",
|
|
558
|
+
"type": "address",
|
|
559
|
+
"internalType": "address"
|
|
560
|
+
}
|
|
561
|
+
],
|
|
562
|
+
"outputs": [],
|
|
563
|
+
"stateMutability": "nonpayable"
|
|
564
|
+
},
|
|
552
565
|
{
|
|
553
566
|
"type": "function",
|
|
554
567
|
"name": "transferOwnership",
|
|
@@ -562,6 +575,24 @@
|
|
|
562
575
|
"outputs": [],
|
|
563
576
|
"stateMutability": "nonpayable"
|
|
564
577
|
},
|
|
578
|
+
{
|
|
579
|
+
"type": "function",
|
|
580
|
+
"name": "updateFinalTick",
|
|
581
|
+
"inputs": [
|
|
582
|
+
{
|
|
583
|
+
"name": "marketId",
|
|
584
|
+
"type": "uint256",
|
|
585
|
+
"internalType": "uint256"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"name": "tick",
|
|
589
|
+
"type": "uint256",
|
|
590
|
+
"internalType": "uint256"
|
|
591
|
+
}
|
|
592
|
+
],
|
|
593
|
+
"outputs": [],
|
|
594
|
+
"stateMutability": "nonpayable"
|
|
595
|
+
},
|
|
565
596
|
{
|
|
566
597
|
"type": "function",
|
|
567
598
|
"name": "updateMarketExpiry",
|
|
@@ -631,6 +662,19 @@
|
|
|
631
662
|
"outputs": [],
|
|
632
663
|
"stateMutability": "nonpayable"
|
|
633
664
|
},
|
|
665
|
+
{
|
|
666
|
+
"type": "function",
|
|
667
|
+
"name": "updateNullOutcome",
|
|
668
|
+
"inputs": [
|
|
669
|
+
{
|
|
670
|
+
"name": "marketId",
|
|
671
|
+
"type": "uint256",
|
|
672
|
+
"internalType": "uint256"
|
|
673
|
+
}
|
|
674
|
+
],
|
|
675
|
+
"outputs": [],
|
|
676
|
+
"stateMutability": "nonpayable"
|
|
677
|
+
},
|
|
634
678
|
{
|
|
635
679
|
"type": "function",
|
|
636
680
|
"name": "updateToken",
|
|
@@ -654,6 +698,19 @@
|
|
|
654
698
|
"outputs": [],
|
|
655
699
|
"stateMutability": "nonpayable"
|
|
656
700
|
},
|
|
701
|
+
{
|
|
702
|
+
"type": "function",
|
|
703
|
+
"name": "vault",
|
|
704
|
+
"inputs": [],
|
|
705
|
+
"outputs": [
|
|
706
|
+
{
|
|
707
|
+
"name": "",
|
|
708
|
+
"type": "address",
|
|
709
|
+
"internalType": "address"
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
"stateMutability": "view"
|
|
713
|
+
},
|
|
657
714
|
{
|
|
658
715
|
"type": "event",
|
|
659
716
|
"name": "AddressFeesUpdated",
|
|
@@ -963,6 +1020,31 @@
|
|
|
963
1020
|
],
|
|
964
1021
|
"anonymous": false
|
|
965
1022
|
},
|
|
1023
|
+
{
|
|
1024
|
+
"type": "event",
|
|
1025
|
+
"name": "VaultUpdated",
|
|
1026
|
+
"inputs": [
|
|
1027
|
+
{
|
|
1028
|
+
"name": "previousVault",
|
|
1029
|
+
"type": "address",
|
|
1030
|
+
"indexed": true,
|
|
1031
|
+
"internalType": "address"
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
"name": "newVault",
|
|
1035
|
+
"type": "address",
|
|
1036
|
+
"indexed": true,
|
|
1037
|
+
"internalType": "address"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
"name": "sender",
|
|
1041
|
+
"type": "address",
|
|
1042
|
+
"indexed": true,
|
|
1043
|
+
"internalType": "address"
|
|
1044
|
+
}
|
|
1045
|
+
],
|
|
1046
|
+
"anonymous": false
|
|
1047
|
+
},
|
|
966
1048
|
{
|
|
967
1049
|
"type": "error",
|
|
968
1050
|
"name": "AddressEmptyCode",
|
|
@@ -979,6 +1061,22 @@
|
|
|
979
1061
|
"name": "FailedCall",
|
|
980
1062
|
"inputs": []
|
|
981
1063
|
},
|
|
1064
|
+
{
|
|
1065
|
+
"type": "error",
|
|
1066
|
+
"name": "FinalizedOutcomeRequired",
|
|
1067
|
+
"inputs": [
|
|
1068
|
+
{
|
|
1069
|
+
"name": "marketId",
|
|
1070
|
+
"type": "uint256",
|
|
1071
|
+
"internalType": "uint256"
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
"name": "expiry",
|
|
1075
|
+
"type": "uint256",
|
|
1076
|
+
"internalType": "uint256"
|
|
1077
|
+
}
|
|
1078
|
+
]
|
|
1079
|
+
},
|
|
982
1080
|
{
|
|
983
1081
|
"type": "error",
|
|
984
1082
|
"name": "InvalidFeeRate",
|