@pear-protocol/symmio-client 0.1.0 → 0.1.2

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/index.d.mts CHANGED
@@ -65,30 +65,6 @@ declare enum SoftLiquidationLevel {
65
65
  EMERGENCY = 3
66
66
  }
67
67
 
68
- type Account = {
69
- accountAddress: Address;
70
- name: string;
71
- };
72
- type AccountBalance = {
73
- collateralBalance: bigint;
74
- allocatedBalance: bigint;
75
- availableBalance: bigint;
76
- lockedCVA: bigint;
77
- lockedLF: bigint;
78
- lockedPartyAMM: bigint;
79
- lockedPartyBMM: bigint;
80
- pendingLockedCVA: bigint;
81
- pendingLockedLF: bigint;
82
- pendingLockedPartyAMM: bigint;
83
- pendingLockedPartyBMM: bigint;
84
- positionsCount: number;
85
- pendingCount: number;
86
- nonces: number;
87
- };
88
- type AddAccountParams = {
89
- name: string;
90
- };
91
-
92
68
  type SchnorrSign = {
93
69
  signature: bigint;
94
70
  owner: Address;
@@ -200,6 +176,70 @@ type CancelQuoteParams = {
200
176
  quoteId: bigint;
201
177
  };
202
178
 
179
+ type CreateSiweMessageParams = {
180
+ address: Address;
181
+ statement: string;
182
+ chainId: number;
183
+ nonce: string;
184
+ domain: string;
185
+ uri: string;
186
+ version?: string;
187
+ };
188
+ type SiweMessageResult = {
189
+ message: string;
190
+ issuedAt: string;
191
+ expirationTime: string;
192
+ };
193
+ type InstantLoginParams = {
194
+ accountAddress: Address;
195
+ signature: string;
196
+ expirationTime: string;
197
+ issuedAt: string;
198
+ nonce: string;
199
+ };
200
+ type InstantAuthToken = {
201
+ accessToken: string;
202
+ expirationTime: string;
203
+ issuedAt: string;
204
+ };
205
+ type InstantOpenParams = {
206
+ symbolId: number;
207
+ positionType: number;
208
+ orderType: number;
209
+ price: string;
210
+ quantity: string;
211
+ cva: string;
212
+ lf: string;
213
+ partyAmm: string;
214
+ partyBmm: string;
215
+ maxFundingRate: string;
216
+ deadline: number;
217
+ };
218
+ type InstantOpenResponse = {
219
+ successful: string;
220
+ message: string;
221
+ };
222
+ type InstantCloseParams = {
223
+ quoteId: string;
224
+ quantityToClose: string;
225
+ closePrice: string;
226
+ };
227
+ type InstantCloseResponse = {
228
+ successful: string;
229
+ message: string;
230
+ };
231
+ declare enum InstantCloseStatus {
232
+ STARTED = 0,
233
+ PROCESSING = 1,
234
+ FAILED = 2,
235
+ FINISHED = 3
236
+ }
237
+ type InstantErrorResponse = {
238
+ error_code: number;
239
+ error_message: string;
240
+ error_detail: string[];
241
+ };
242
+
203
243
  declare class MuonClient {
204
244
  private baseUrls;
205
245
  private appName;
@@ -439,10 +479,50 @@ declare class SymmioSDK {
439
479
  grantRole: (role: Hex, grantee: Address) => Promise<`0x${string}`>;
440
480
  revokeRole: (role: Hex, revokee: Address) => Promise<`0x${string}`>;
441
481
  };
482
+ get instant(): {
483
+ /** Creates a SIWE message for instant trading authentication. */
484
+ createSiweMessage: (params: CreateSiweMessageParams) => SiweMessageResult;
485
+ /** Fetches a nonce from the hedger for SIWE authentication. */
486
+ getNonce: (subAccount: Address) => Promise<string>;
487
+ /** Exchanges a signed SIWE message for an access token. */
488
+ login: (params: InstantLoginParams) => Promise<InstantAuthToken>;
489
+ /** Opens a position instantly via the hedger (off-chain). */
490
+ open: (params: InstantOpenParams, accessToken: string) => Promise<InstantOpenResponse>;
491
+ /** Closes a position instantly via the hedger (off-chain). */
492
+ close: (params: InstantCloseParams, accessToken: string) => Promise<InstantCloseResponse>;
493
+ /** Cancels a pending instant close request. */
494
+ cancelClose: (quoteId: string, accessToken: string) => Promise<void>;
495
+ /** Fetches the list of open instant close requests for an account. */
496
+ getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
497
+ };
442
498
  getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
443
499
  getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
444
500
  }
445
501
 
502
+ type Account = {
503
+ accountAddress: Address;
504
+ name: string;
505
+ };
506
+ type AccountBalance = {
507
+ collateralBalance: bigint;
508
+ allocatedBalance: bigint;
509
+ availableBalance: bigint;
510
+ lockedCVA: bigint;
511
+ lockedLF: bigint;
512
+ lockedPartyAMM: bigint;
513
+ lockedPartyBMM: bigint;
514
+ pendingLockedCVA: bigint;
515
+ pendingLockedLF: bigint;
516
+ pendingLockedPartyAMM: bigint;
517
+ pendingLockedPartyBMM: bigint;
518
+ positionsCount: number;
519
+ pendingCount: number;
520
+ nonces: number;
521
+ };
522
+ type AddAccountParams = {
523
+ name: string;
524
+ };
525
+
446
526
  type Quote = {
447
527
  id: number;
448
528
  partyBsWhiteList: Address[];
@@ -19507,6 +19587,7 @@ declare const ALL_TRADING_SELECTORS: Hex[];
19507
19587
  /**
19508
19588
  * Default configuration values for Symmio SDK.
19509
19589
  */
19590
+
19510
19591
  /** Market order deadline: 5 minutes */
19511
19592
  declare const MARKET_ORDER_DEADLINE = 300n;
19512
19593
  /** Limit order deadline: ~10 years */
@@ -19768,6 +19849,47 @@ declare namespace admin {
19768
19849
  export { admin_grantRole as grantRole, admin_prepareGrantRole as prepareGrantRole, admin_prepareRevokeRole as prepareRevokeRole, admin_revokeRole as revokeRole };
19769
19850
  }
19770
19851
 
19852
+ /**
19853
+ * Creates a SIWE (Sign-In with Ethereum) message for instant trading auth.
19854
+ * Follows EIP-4361 format. Token is valid for 30 days.
19855
+ */
19856
+ declare function createSiweMessage(params: CreateSiweMessageParams): SiweMessageResult;
19857
+ /**
19858
+ * Fetches a nonce from the hedger for SIWE authentication.
19859
+ */
19860
+ declare function getNonce(chainId: number, subAccount: Address): Promise<string>;
19861
+ /**
19862
+ * Exchanges a signed SIWE message for an access token from the hedger.
19863
+ */
19864
+ declare function login(chainId: number, params: InstantLoginParams): Promise<InstantAuthToken>;
19865
+ /**
19866
+ * Opens a position instantly via the hedger's off-chain endpoint.
19867
+ */
19868
+ declare function instantOpen(chainId: number, params: InstantOpenParams, accessToken: string): Promise<InstantOpenResponse>;
19869
+ /**
19870
+ * Closes a position instantly via the hedger's off-chain endpoint.
19871
+ */
19872
+ declare function instantClose(chainId: number, params: InstantCloseParams, accessToken: string): Promise<InstantCloseResponse>;
19873
+ /**
19874
+ * Cancels a pending instant close request.
19875
+ */
19876
+ declare function cancelInstantClose(chainId: number, quoteId: string, accessToken: string): Promise<void>;
19877
+ /**
19878
+ * Fetches the list of open (pending) instant close requests for an account.
19879
+ */
19880
+ declare function getOpenInstantCloses(chainId: number, account: Address, accessToken: string): Promise<unknown[]>;
19881
+
19882
+ declare const instant_cancelInstantClose: typeof cancelInstantClose;
19883
+ declare const instant_createSiweMessage: typeof createSiweMessage;
19884
+ declare const instant_getNonce: typeof getNonce;
19885
+ declare const instant_getOpenInstantCloses: typeof getOpenInstantCloses;
19886
+ declare const instant_instantClose: typeof instantClose;
19887
+ declare const instant_instantOpen: typeof instantOpen;
19888
+ declare const instant_login: typeof login;
19889
+ declare namespace instant {
19890
+ export { instant_cancelInstantClose as cancelInstantClose, instant_createSiweMessage as createSiweMessage, instant_getNonce as getNonce, instant_getOpenInstantCloses as getOpenInstantCloses, instant_instantClose as instantClose, instant_instantOpen as instantOpen, instant_login as login };
19891
+ }
19892
+
19771
19893
  /**
19772
19894
  * Adds a gas margin buffer to the estimated gas.
19773
19895
  * Default buffer is 20% above the estimation.
@@ -19832,4 +19954,4 @@ declare function formatPrice(price: bigint, decimals: number, precision?: number
19832
19954
  */
19833
19955
  declare function applySlippage(price: bigint, slippagePercent: number, isLong: boolean): bigint;
19834
19956
 
19835
- export { type ADLAssurance, ALL_TRADING_SELECTORS, type Account, type AccountBalance, type AccumulatedFundingRate, type AddAccountParams, type AffiliateFeeConfig, AffiliateFeeLevel, type AggregatedPosition, type AllocateParams, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, type CancelQuoteParams, type ChainId, ClearingHouseABI, type ClearingHouseLiquidation, ClearingHouseLiquidationStatus, type ClosePositionParams, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, type DeallocateParams, type DepositAndAllocateParams, type DepositParams, ERC20ABI, FALLBACK_CHAIN_ID, type InsuranceVaultConfig, type InternalTransferParams, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, type Market, MultiAccountABI, type MuonBatchParams, type MuonBatchSig, MuonClient, type MuonClientConfig, type MuonDeallocateParams, type MuonQuoteParams, type MuonSingleUpnlAndPriceSig, type MuonSingleUpnlSig, type MuonSingleUpnlWithPendingBalanceSig, MuonVerifierABI, OrderType, PositionType, type PreparedTransaction, type Quote, QuoteStatus, type RegisterAffiliateParams, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, type SchnorrSign, type SendQuoteParams, type SetAffiliateFeeParams, SignatureStoreABI, SoftLiquidationLevel, type SoftLiquidationThreshold, SupportedChainId, type SymbolCategory, type SymbolType, SymmioDiamondABI, SymmioSDK, type SymmioSDKConfig, SymmioSDKError, type TransactionConfig, type TransactionReceipt, type TransactionResult, V3_CHAIN_IDS, type WithdrawParams, account as accountActions, admin as adminActions, allocate$1 as allocateActions, applySlippage, approval as approvalActions, calculateGasMargin, cancel as cancelActions, close as closeActions, delegation as delegationActions, deposit$1 as depositActions, encodeCall, formatPrice, fromWei, getAddress, signature as signatureActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
19957
+ export { type ADLAssurance, ALL_TRADING_SELECTORS, type Account, type AccountBalance, type AccumulatedFundingRate, type AddAccountParams, type AffiliateFeeConfig, AffiliateFeeLevel, type AggregatedPosition, type AllocateParams, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, type CancelQuoteParams, type ChainId, ClearingHouseABI, type ClearingHouseLiquidation, ClearingHouseLiquidationStatus, type ClosePositionParams, type CreateSiweMessageParams, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, type DeallocateParams, type DepositAndAllocateParams, type DepositParams, ERC20ABI, FALLBACK_CHAIN_ID, type InstantAuthToken, type InstantCloseParams, type InstantCloseResponse, InstantCloseStatus, type InstantErrorResponse, type InstantLoginParams, type InstantOpenParams, type InstantOpenResponse, type InsuranceVaultConfig, type InternalTransferParams, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, type Market, MultiAccountABI, type MuonBatchParams, type MuonBatchSig, MuonClient, type MuonClientConfig, type MuonDeallocateParams, type MuonQuoteParams, type MuonSingleUpnlAndPriceSig, type MuonSingleUpnlSig, type MuonSingleUpnlWithPendingBalanceSig, MuonVerifierABI, OrderType, PositionType, type PreparedTransaction, type Quote, QuoteStatus, type RegisterAffiliateParams, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, type SchnorrSign, type SendQuoteParams, type SetAffiliateFeeParams, SignatureStoreABI, type SiweMessageResult, SoftLiquidationLevel, type SoftLiquidationThreshold, SupportedChainId, type SymbolCategory, type SymbolType, SymmioDiamondABI, SymmioSDK, type SymmioSDKConfig, SymmioSDKError, type TransactionConfig, type TransactionReceipt, type TransactionResult, V3_CHAIN_IDS, type WithdrawParams, account as accountActions, admin as adminActions, allocate$1 as allocateActions, applySlippage, approval as approvalActions, calculateGasMargin, cancel as cancelActions, close as closeActions, delegation as delegationActions, deposit$1 as depositActions, encodeCall, formatPrice, fromWei, getAddress, instant as instantActions, signature as signatureActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
package/dist/index.d.ts CHANGED
@@ -65,30 +65,6 @@ declare enum SoftLiquidationLevel {
65
65
  EMERGENCY = 3
66
66
  }
67
67
 
68
- type Account = {
69
- accountAddress: Address;
70
- name: string;
71
- };
72
- type AccountBalance = {
73
- collateralBalance: bigint;
74
- allocatedBalance: bigint;
75
- availableBalance: bigint;
76
- lockedCVA: bigint;
77
- lockedLF: bigint;
78
- lockedPartyAMM: bigint;
79
- lockedPartyBMM: bigint;
80
- pendingLockedCVA: bigint;
81
- pendingLockedLF: bigint;
82
- pendingLockedPartyAMM: bigint;
83
- pendingLockedPartyBMM: bigint;
84
- positionsCount: number;
85
- pendingCount: number;
86
- nonces: number;
87
- };
88
- type AddAccountParams = {
89
- name: string;
90
- };
91
-
92
68
  type SchnorrSign = {
93
69
  signature: bigint;
94
70
  owner: Address;
@@ -200,6 +176,70 @@ type CancelQuoteParams = {
200
176
  quoteId: bigint;
201
177
  };
202
178
 
179
+ type CreateSiweMessageParams = {
180
+ address: Address;
181
+ statement: string;
182
+ chainId: number;
183
+ nonce: string;
184
+ domain: string;
185
+ uri: string;
186
+ version?: string;
187
+ };
188
+ type SiweMessageResult = {
189
+ message: string;
190
+ issuedAt: string;
191
+ expirationTime: string;
192
+ };
193
+ type InstantLoginParams = {
194
+ accountAddress: Address;
195
+ signature: string;
196
+ expirationTime: string;
197
+ issuedAt: string;
198
+ nonce: string;
199
+ };
200
+ type InstantAuthToken = {
201
+ accessToken: string;
202
+ expirationTime: string;
203
+ issuedAt: string;
204
+ };
205
+ type InstantOpenParams = {
206
+ symbolId: number;
207
+ positionType: number;
208
+ orderType: number;
209
+ price: string;
210
+ quantity: string;
211
+ cva: string;
212
+ lf: string;
213
+ partyAmm: string;
214
+ partyBmm: string;
215
+ maxFundingRate: string;
216
+ deadline: number;
217
+ };
218
+ type InstantOpenResponse = {
219
+ successful: string;
220
+ message: string;
221
+ };
222
+ type InstantCloseParams = {
223
+ quoteId: string;
224
+ quantityToClose: string;
225
+ closePrice: string;
226
+ };
227
+ type InstantCloseResponse = {
228
+ successful: string;
229
+ message: string;
230
+ };
231
+ declare enum InstantCloseStatus {
232
+ STARTED = 0,
233
+ PROCESSING = 1,
234
+ FAILED = 2,
235
+ FINISHED = 3
236
+ }
237
+ type InstantErrorResponse = {
238
+ error_code: number;
239
+ error_message: string;
240
+ error_detail: string[];
241
+ };
242
+
203
243
  declare class MuonClient {
204
244
  private baseUrls;
205
245
  private appName;
@@ -439,10 +479,50 @@ declare class SymmioSDK {
439
479
  grantRole: (role: Hex, grantee: Address) => Promise<`0x${string}`>;
440
480
  revokeRole: (role: Hex, revokee: Address) => Promise<`0x${string}`>;
441
481
  };
482
+ get instant(): {
483
+ /** Creates a SIWE message for instant trading authentication. */
484
+ createSiweMessage: (params: CreateSiweMessageParams) => SiweMessageResult;
485
+ /** Fetches a nonce from the hedger for SIWE authentication. */
486
+ getNonce: (subAccount: Address) => Promise<string>;
487
+ /** Exchanges a signed SIWE message for an access token. */
488
+ login: (params: InstantLoginParams) => Promise<InstantAuthToken>;
489
+ /** Opens a position instantly via the hedger (off-chain). */
490
+ open: (params: InstantOpenParams, accessToken: string) => Promise<InstantOpenResponse>;
491
+ /** Closes a position instantly via the hedger (off-chain). */
492
+ close: (params: InstantCloseParams, accessToken: string) => Promise<InstantCloseResponse>;
493
+ /** Cancels a pending instant close request. */
494
+ cancelClose: (quoteId: string, accessToken: string) => Promise<void>;
495
+ /** Fetches the list of open instant close requests for an account. */
496
+ getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
497
+ };
442
498
  getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
443
499
  getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
444
500
  }
445
501
 
502
+ type Account = {
503
+ accountAddress: Address;
504
+ name: string;
505
+ };
506
+ type AccountBalance = {
507
+ collateralBalance: bigint;
508
+ allocatedBalance: bigint;
509
+ availableBalance: bigint;
510
+ lockedCVA: bigint;
511
+ lockedLF: bigint;
512
+ lockedPartyAMM: bigint;
513
+ lockedPartyBMM: bigint;
514
+ pendingLockedCVA: bigint;
515
+ pendingLockedLF: bigint;
516
+ pendingLockedPartyAMM: bigint;
517
+ pendingLockedPartyBMM: bigint;
518
+ positionsCount: number;
519
+ pendingCount: number;
520
+ nonces: number;
521
+ };
522
+ type AddAccountParams = {
523
+ name: string;
524
+ };
525
+
446
526
  type Quote = {
447
527
  id: number;
448
528
  partyBsWhiteList: Address[];
@@ -19507,6 +19587,7 @@ declare const ALL_TRADING_SELECTORS: Hex[];
19507
19587
  /**
19508
19588
  * Default configuration values for Symmio SDK.
19509
19589
  */
19590
+
19510
19591
  /** Market order deadline: 5 minutes */
19511
19592
  declare const MARKET_ORDER_DEADLINE = 300n;
19512
19593
  /** Limit order deadline: ~10 years */
@@ -19768,6 +19849,47 @@ declare namespace admin {
19768
19849
  export { admin_grantRole as grantRole, admin_prepareGrantRole as prepareGrantRole, admin_prepareRevokeRole as prepareRevokeRole, admin_revokeRole as revokeRole };
19769
19850
  }
19770
19851
 
19852
+ /**
19853
+ * Creates a SIWE (Sign-In with Ethereum) message for instant trading auth.
19854
+ * Follows EIP-4361 format. Token is valid for 30 days.
19855
+ */
19856
+ declare function createSiweMessage(params: CreateSiweMessageParams): SiweMessageResult;
19857
+ /**
19858
+ * Fetches a nonce from the hedger for SIWE authentication.
19859
+ */
19860
+ declare function getNonce(chainId: number, subAccount: Address): Promise<string>;
19861
+ /**
19862
+ * Exchanges a signed SIWE message for an access token from the hedger.
19863
+ */
19864
+ declare function login(chainId: number, params: InstantLoginParams): Promise<InstantAuthToken>;
19865
+ /**
19866
+ * Opens a position instantly via the hedger's off-chain endpoint.
19867
+ */
19868
+ declare function instantOpen(chainId: number, params: InstantOpenParams, accessToken: string): Promise<InstantOpenResponse>;
19869
+ /**
19870
+ * Closes a position instantly via the hedger's off-chain endpoint.
19871
+ */
19872
+ declare function instantClose(chainId: number, params: InstantCloseParams, accessToken: string): Promise<InstantCloseResponse>;
19873
+ /**
19874
+ * Cancels a pending instant close request.
19875
+ */
19876
+ declare function cancelInstantClose(chainId: number, quoteId: string, accessToken: string): Promise<void>;
19877
+ /**
19878
+ * Fetches the list of open (pending) instant close requests for an account.
19879
+ */
19880
+ declare function getOpenInstantCloses(chainId: number, account: Address, accessToken: string): Promise<unknown[]>;
19881
+
19882
+ declare const instant_cancelInstantClose: typeof cancelInstantClose;
19883
+ declare const instant_createSiweMessage: typeof createSiweMessage;
19884
+ declare const instant_getNonce: typeof getNonce;
19885
+ declare const instant_getOpenInstantCloses: typeof getOpenInstantCloses;
19886
+ declare const instant_instantClose: typeof instantClose;
19887
+ declare const instant_instantOpen: typeof instantOpen;
19888
+ declare const instant_login: typeof login;
19889
+ declare namespace instant {
19890
+ export { instant_cancelInstantClose as cancelInstantClose, instant_createSiweMessage as createSiweMessage, instant_getNonce as getNonce, instant_getOpenInstantCloses as getOpenInstantCloses, instant_instantClose as instantClose, instant_instantOpen as instantOpen, instant_login as login };
19891
+ }
19892
+
19771
19893
  /**
19772
19894
  * Adds a gas margin buffer to the estimated gas.
19773
19895
  * Default buffer is 20% above the estimation.
@@ -19832,4 +19954,4 @@ declare function formatPrice(price: bigint, decimals: number, precision?: number
19832
19954
  */
19833
19955
  declare function applySlippage(price: bigint, slippagePercent: number, isLong: boolean): bigint;
19834
19956
 
19835
- export { type ADLAssurance, ALL_TRADING_SELECTORS, type Account, type AccountBalance, type AccumulatedFundingRate, type AddAccountParams, type AffiliateFeeConfig, AffiliateFeeLevel, type AggregatedPosition, type AllocateParams, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, type CancelQuoteParams, type ChainId, ClearingHouseABI, type ClearingHouseLiquidation, ClearingHouseLiquidationStatus, type ClosePositionParams, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, type DeallocateParams, type DepositAndAllocateParams, type DepositParams, ERC20ABI, FALLBACK_CHAIN_ID, type InsuranceVaultConfig, type InternalTransferParams, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, type Market, MultiAccountABI, type MuonBatchParams, type MuonBatchSig, MuonClient, type MuonClientConfig, type MuonDeallocateParams, type MuonQuoteParams, type MuonSingleUpnlAndPriceSig, type MuonSingleUpnlSig, type MuonSingleUpnlWithPendingBalanceSig, MuonVerifierABI, OrderType, PositionType, type PreparedTransaction, type Quote, QuoteStatus, type RegisterAffiliateParams, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, type SchnorrSign, type SendQuoteParams, type SetAffiliateFeeParams, SignatureStoreABI, SoftLiquidationLevel, type SoftLiquidationThreshold, SupportedChainId, type SymbolCategory, type SymbolType, SymmioDiamondABI, SymmioSDK, type SymmioSDKConfig, SymmioSDKError, type TransactionConfig, type TransactionReceipt, type TransactionResult, V3_CHAIN_IDS, type WithdrawParams, account as accountActions, admin as adminActions, allocate$1 as allocateActions, applySlippage, approval as approvalActions, calculateGasMargin, cancel as cancelActions, close as closeActions, delegation as delegationActions, deposit$1 as depositActions, encodeCall, formatPrice, fromWei, getAddress, signature as signatureActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
19957
+ export { type ADLAssurance, ALL_TRADING_SELECTORS, type Account, type AccountBalance, type AccumulatedFundingRate, type AddAccountParams, type AffiliateFeeConfig, AffiliateFeeLevel, type AggregatedPosition, type AllocateParams, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, type CancelQuoteParams, type ChainId, ClearingHouseABI, type ClearingHouseLiquidation, ClearingHouseLiquidationStatus, type ClosePositionParams, type CreateSiweMessageParams, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, type DeallocateParams, type DepositAndAllocateParams, type DepositParams, ERC20ABI, FALLBACK_CHAIN_ID, type InstantAuthToken, type InstantCloseParams, type InstantCloseResponse, InstantCloseStatus, type InstantErrorResponse, type InstantLoginParams, type InstantOpenParams, type InstantOpenResponse, type InsuranceVaultConfig, type InternalTransferParams, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, type Market, MultiAccountABI, type MuonBatchParams, type MuonBatchSig, MuonClient, type MuonClientConfig, type MuonDeallocateParams, type MuonQuoteParams, type MuonSingleUpnlAndPriceSig, type MuonSingleUpnlSig, type MuonSingleUpnlWithPendingBalanceSig, MuonVerifierABI, OrderType, PositionType, type PreparedTransaction, type Quote, QuoteStatus, type RegisterAffiliateParams, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, type SchnorrSign, type SendQuoteParams, type SetAffiliateFeeParams, SignatureStoreABI, type SiweMessageResult, SoftLiquidationLevel, type SoftLiquidationThreshold, SupportedChainId, type SymbolCategory, type SymbolType, SymmioDiamondABI, SymmioSDK, type SymmioSDKConfig, SymmioSDKError, type TransactionConfig, type TransactionReceipt, type TransactionResult, V3_CHAIN_IDS, type WithdrawParams, account as accountActions, admin as adminActions, allocate$1 as allocateActions, applySlippage, approval as approvalActions, calculateGasMargin, cancel as cancelActions, close as closeActions, delegation as delegationActions, deposit$1 as depositActions, encodeCall, formatPrice, fromWei, getAddress, instant as instantActions, signature as signatureActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
package/dist/index.js CHANGED
@@ -82,6 +82,10 @@ var MUON_BASE_URLS = [
82
82
  ];
83
83
  var MUON_APP_NAME = "symmio";
84
84
  var MUON_REQUEST_TIMEOUT = 15e3;
85
+ var HEDGER_BASE_URLS = {
86
+ [42161 /* ARBITRUM */]: "https://www.perps-streaming.com/v1/42161a/0x6273242a7E88b3De90822b31648C212215caaFE4",
87
+ [8453 /* BASE */]: "https://www.perps-streaming.com/v1/8453a/0x6273242a7E88b3De90822b31648C212215caaFE4"
88
+ };
85
89
  var SymmioSDKError = class extends Error {
86
90
  constructor(message, code) {
87
91
  super(message);
@@ -24097,6 +24101,176 @@ async function revokeRole(walletClient, publicClient, symmioDiamond, role, revok
24097
24101
  });
24098
24102
  }
24099
24103
 
24104
+ // src/actions/instant.ts
24105
+ var instant_exports = {};
24106
+ __export(instant_exports, {
24107
+ cancelInstantClose: () => cancelInstantClose,
24108
+ createSiweMessage: () => createSiweMessage,
24109
+ getNonce: () => getNonce,
24110
+ getOpenInstantCloses: () => getOpenInstantCloses,
24111
+ instantClose: () => instantClose,
24112
+ instantOpen: () => instantOpen,
24113
+ login: () => login
24114
+ });
24115
+ function getHedgerBaseUrl(chainId) {
24116
+ const baseUrl = HEDGER_BASE_URLS[chainId];
24117
+ if (!baseUrl) {
24118
+ throw new Error(`No hedger base URL configured for chain ${chainId}.`);
24119
+ }
24120
+ return baseUrl;
24121
+ }
24122
+ function createSiweMessage(params) {
24123
+ const version = params.version ?? "1";
24124
+ const issuedAt = (/* @__PURE__ */ new Date()).toISOString();
24125
+ const expirationTime = new Date(
24126
+ Date.now() + 30 * 24 * 60 * 60 * 1e3
24127
+ ).toISOString();
24128
+ const message = [
24129
+ `${params.domain} wants you to sign in with your Ethereum account:`,
24130
+ params.address,
24131
+ "",
24132
+ params.statement,
24133
+ "",
24134
+ `URI: ${params.uri}`,
24135
+ `Version: ${version}`,
24136
+ `Chain ID: ${params.chainId}`,
24137
+ `Nonce: ${params.nonce}`,
24138
+ `Issued At: ${issuedAt}`,
24139
+ `Expiration Time: ${expirationTime}`
24140
+ ].join("\n");
24141
+ return { message, issuedAt, expirationTime };
24142
+ }
24143
+ async function getNonce(chainId, subAccount) {
24144
+ const hedgerBaseUrl = getHedgerBaseUrl(chainId);
24145
+ const url = new URL(`nonce/${subAccount}`, hedgerBaseUrl).href;
24146
+ const response = await fetch(url);
24147
+ if (!response.ok) {
24148
+ throw new Error(`Failed to fetch nonce: ${response.statusText}`);
24149
+ }
24150
+ const data = await response.json();
24151
+ return data.nonce;
24152
+ }
24153
+ async function login(chainId, params) {
24154
+ const hedgerBaseUrl = getHedgerBaseUrl(chainId);
24155
+ const url = new URL("login", hedgerBaseUrl).href;
24156
+ const body = {
24157
+ account_address: params.accountAddress,
24158
+ expiration_time: params.expirationTime,
24159
+ issued_at: params.issuedAt,
24160
+ signature: params.signature,
24161
+ nonce: params.nonce
24162
+ };
24163
+ const response = await fetch(url, {
24164
+ method: "POST",
24165
+ headers: { "Content-Type": "application/json" },
24166
+ body: JSON.stringify(body)
24167
+ });
24168
+ if (!response.ok) {
24169
+ const errorData = await response.json().catch(() => null);
24170
+ throw new Error(
24171
+ errorData?.error_message ?? `Login failed: ${response.statusText}`
24172
+ );
24173
+ }
24174
+ const data = await response.json();
24175
+ if (!data.access_token) {
24176
+ throw new Error("No access token received");
24177
+ }
24178
+ return {
24179
+ accessToken: data.access_token,
24180
+ expirationTime: params.expirationTime,
24181
+ issuedAt: params.issuedAt
24182
+ };
24183
+ }
24184
+ async function instantOpen(chainId, params, accessToken) {
24185
+ const hedgerBaseUrl = getHedgerBaseUrl(chainId);
24186
+ const url = new URL("instant_open", hedgerBaseUrl).href;
24187
+ const body = {
24188
+ symbolId: params.symbolId,
24189
+ positionType: params.positionType,
24190
+ orderType: params.orderType,
24191
+ price: params.price,
24192
+ quantity: params.quantity,
24193
+ cva: params.cva,
24194
+ lf: params.lf,
24195
+ partyAmm: params.partyAmm,
24196
+ partyBmm: params.partyBmm,
24197
+ maxFundingRate: params.maxFundingRate,
24198
+ deadline: params.deadline
24199
+ };
24200
+ const response = await fetch(url, {
24201
+ method: "POST",
24202
+ headers: {
24203
+ "Content-Type": "application/json",
24204
+ Authorization: `Bearer ${accessToken}`
24205
+ },
24206
+ body: JSON.stringify(body)
24207
+ });
24208
+ if (!response.ok) {
24209
+ const errorData = await response.json().catch(() => null);
24210
+ throw new Error(
24211
+ errorData?.error_message ?? `Instant open failed: ${response.statusText}`
24212
+ );
24213
+ }
24214
+ return response.json();
24215
+ }
24216
+ async function instantClose(chainId, params, accessToken) {
24217
+ const hedgerBaseUrl = getHedgerBaseUrl(chainId);
24218
+ const url = new URL("instant_close", hedgerBaseUrl).href;
24219
+ const body = {
24220
+ quote_id: params.quoteId,
24221
+ quantity_to_close: params.quantityToClose,
24222
+ close_price: params.closePrice
24223
+ };
24224
+ const response = await fetch(url, {
24225
+ method: "POST",
24226
+ headers: {
24227
+ "Content-Type": "application/json",
24228
+ Authorization: `Bearer ${accessToken}`
24229
+ },
24230
+ body: JSON.stringify(body)
24231
+ });
24232
+ if (!response.ok) {
24233
+ const errorData = await response.json().catch(() => null);
24234
+ throw new Error(
24235
+ errorData?.error_message ?? `Instant close failed: ${response.statusText}`
24236
+ );
24237
+ }
24238
+ return response.json();
24239
+ }
24240
+ async function cancelInstantClose(chainId, quoteId, accessToken) {
24241
+ const hedgerBaseUrl = getHedgerBaseUrl(chainId);
24242
+ const url = new URL(`instant_close/${quoteId}`, hedgerBaseUrl).href;
24243
+ const response = await fetch(url, {
24244
+ method: "DELETE",
24245
+ headers: {
24246
+ "Content-Type": "application/json",
24247
+ Authorization: `Bearer ${accessToken}`
24248
+ }
24249
+ });
24250
+ if (!response.ok) {
24251
+ const errorData = await response.json().catch(() => null);
24252
+ throw new Error(
24253
+ errorData?.error_message ?? `Cancel instant close failed: ${response.statusText}`
24254
+ );
24255
+ }
24256
+ }
24257
+ async function getOpenInstantCloses(chainId, account, accessToken) {
24258
+ const hedgerBaseUrl = getHedgerBaseUrl(chainId);
24259
+ const url = new URL(`instant_close/${account}`, hedgerBaseUrl).href;
24260
+ const response = await fetch(url, {
24261
+ headers: {
24262
+ Authorization: `Bearer ${accessToken}`
24263
+ }
24264
+ });
24265
+ if (!response.ok) {
24266
+ const errorData = await response.json().catch(() => null);
24267
+ throw new Error(
24268
+ errorData?.error_message ?? `Failed to fetch instant closes: ${response.statusText}`
24269
+ );
24270
+ }
24271
+ return response.json();
24272
+ }
24273
+
24100
24274
  // src/client.ts
24101
24275
  var SymmioSDK = class {
24102
24276
  chainId;
@@ -24280,6 +24454,25 @@ var SymmioSDK = class {
24280
24454
  revokeRole: (role, revokee) => revokeRole(wc, pc, sd, role, revokee)
24281
24455
  };
24282
24456
  }
24457
+ // ─── Instant Trading Module ──────────────────────────────────
24458
+ get instant() {
24459
+ return {
24460
+ /** Creates a SIWE message for instant trading authentication. */
24461
+ createSiweMessage: (params) => createSiweMessage(params),
24462
+ /** Fetches a nonce from the hedger for SIWE authentication. */
24463
+ getNonce: (subAccount) => getNonce(this.chainId, subAccount),
24464
+ /** Exchanges a signed SIWE message for an access token. */
24465
+ login: (params) => login(this.chainId, params),
24466
+ /** Opens a position instantly via the hedger (off-chain). */
24467
+ open: (params, accessToken) => instantOpen(this.chainId, params, accessToken),
24468
+ /** Closes a position instantly via the hedger (off-chain). */
24469
+ close: (params, accessToken) => instantClose(this.chainId, params, accessToken),
24470
+ /** Cancels a pending instant close request. */
24471
+ cancelClose: (quoteId, accessToken) => cancelInstantClose(this.chainId, quoteId, accessToken),
24472
+ /** Fetches the list of open instant close requests for an account. */
24473
+ getOpenCloses: (account, accessToken) => getOpenInstantCloses(this.chainId, account, accessToken)
24474
+ };
24475
+ }
24283
24476
  // ─── Muon Signatures ──────────────────────────────────────────
24284
24477
  async getQuoteSig(partyA, symbolId) {
24285
24478
  return this.muon.getQuoteSig({
@@ -24356,6 +24549,15 @@ var ClearingHouseLiquidationStatus = /* @__PURE__ */ ((ClearingHouseLiquidationS
24356
24549
  return ClearingHouseLiquidationStatus2;
24357
24550
  })(ClearingHouseLiquidationStatus || {});
24358
24551
 
24552
+ // src/types/instant.ts
24553
+ var InstantCloseStatus = /* @__PURE__ */ ((InstantCloseStatus2) => {
24554
+ InstantCloseStatus2[InstantCloseStatus2["STARTED"] = 0] = "STARTED";
24555
+ InstantCloseStatus2[InstantCloseStatus2["PROCESSING"] = 1] = "PROCESSING";
24556
+ InstantCloseStatus2[InstantCloseStatus2["FAILED"] = 2] = "FAILED";
24557
+ InstantCloseStatus2[InstantCloseStatus2["FINISHED"] = 3] = "FINISHED";
24558
+ return InstantCloseStatus2;
24559
+ })(InstantCloseStatus || {});
24560
+
24359
24561
  // src/abis/ClearingHouse.ts
24360
24562
  var ClearingHouseABI = [
24361
24563
  // ─── Liquidation Lifecycle ────────────────────────────────────
@@ -24618,6 +24820,7 @@ exports.DEFAULT_PARTY_B_ADDRESS = DEFAULT_PARTY_B_ADDRESS;
24618
24820
  exports.DEFAULT_PRECISION = DEFAULT_PRECISION;
24619
24821
  exports.ERC20ABI = ERC20ABI;
24620
24822
  exports.FALLBACK_CHAIN_ID = FALLBACK_CHAIN_ID;
24823
+ exports.InstantCloseStatus = InstantCloseStatus;
24621
24824
  exports.LIMIT_ORDER_DEADLINE = LIMIT_ORDER_DEADLINE;
24622
24825
  exports.LiquidationStatus = LiquidationStatus;
24623
24826
  exports.MARKET_ORDER_DEADLINE = MARKET_ORDER_DEADLINE;
@@ -24657,6 +24860,7 @@ exports.encodeCall = encodeCall;
24657
24860
  exports.formatPrice = formatPrice;
24658
24861
  exports.fromWei = fromWei;
24659
24862
  exports.getAddress = getAddress;
24863
+ exports.instantActions = instant_exports;
24660
24864
  exports.signatureActions = signature_exports;
24661
24865
  exports.toWei = toWei;
24662
24866
  exports.tradeActions = trade_exports;