@pear-protocol/symmio-client 0.1.4 → 0.1.6
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 +67 -26
- package/dist/index.d.ts +67 -26
- package/dist/index.js +77 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +138 -7
- package/dist/react/index.d.ts +138 -7
- package/dist/react/index.js +279 -30
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +278 -32
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -176,6 +176,30 @@ type CancelQuoteParams = {
|
|
|
176
176
|
quoteId: bigint;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
type Account = {
|
|
180
|
+
accountAddress: Address;
|
|
181
|
+
name: string;
|
|
182
|
+
};
|
|
183
|
+
type AccountBalance = {
|
|
184
|
+
collateralBalance: bigint;
|
|
185
|
+
allocatedBalance: bigint;
|
|
186
|
+
availableBalance: bigint;
|
|
187
|
+
lockedCVA: bigint;
|
|
188
|
+
lockedLF: bigint;
|
|
189
|
+
lockedPartyAMM: bigint;
|
|
190
|
+
lockedPartyBMM: bigint;
|
|
191
|
+
pendingLockedCVA: bigint;
|
|
192
|
+
pendingLockedLF: bigint;
|
|
193
|
+
pendingLockedPartyAMM: bigint;
|
|
194
|
+
pendingLockedPartyBMM: bigint;
|
|
195
|
+
positionsCount: number;
|
|
196
|
+
pendingCount: number;
|
|
197
|
+
nonces: number;
|
|
198
|
+
};
|
|
199
|
+
type AddAccountParams = {
|
|
200
|
+
name: string;
|
|
201
|
+
};
|
|
202
|
+
|
|
179
203
|
type CreateSiweMessageParams = {
|
|
180
204
|
address: Address;
|
|
181
205
|
statement: string;
|
|
@@ -324,6 +348,11 @@ type RevokeAccessParams = {
|
|
|
324
348
|
target: Address;
|
|
325
349
|
selectors: Hex[];
|
|
326
350
|
};
|
|
351
|
+
type DelegatedAccessParams = {
|
|
352
|
+
account: Address;
|
|
353
|
+
target: Address;
|
|
354
|
+
selector: Hex;
|
|
355
|
+
};
|
|
327
356
|
/**
|
|
328
357
|
* Prepares a delegateAccesses transaction.
|
|
329
358
|
*/
|
|
@@ -339,18 +368,21 @@ declare function prepareRevokeAccess(multiAccount: Address, account: Address, pa
|
|
|
339
368
|
declare function delegateAccess(walletClient: WalletClient, publicClient: PublicClient, multiAccount: Address, params: DelegateAccessParams): Promise<Hex>;
|
|
340
369
|
declare function proposeRevoke(walletClient: WalletClient, publicClient: PublicClient, multiAccount: Address, params: ProposeRevokeParams): Promise<Hex>;
|
|
341
370
|
declare function revokeAccess(walletClient: WalletClient, publicClient: PublicClient, multiAccount: Address, params: RevokeAccessParams): Promise<Hex>;
|
|
371
|
+
declare function hasDelegatedAccess(publicClient: PublicClient, multiAccount: Address, params: DelegatedAccessParams): Promise<boolean>;
|
|
342
372
|
|
|
343
373
|
type delegation_DelegateAccessParams = DelegateAccessParams;
|
|
374
|
+
type delegation_DelegatedAccessParams = DelegatedAccessParams;
|
|
344
375
|
type delegation_ProposeRevokeParams = ProposeRevokeParams;
|
|
345
376
|
type delegation_RevokeAccessParams = RevokeAccessParams;
|
|
346
377
|
declare const delegation_delegateAccess: typeof delegateAccess;
|
|
378
|
+
declare const delegation_hasDelegatedAccess: typeof hasDelegatedAccess;
|
|
347
379
|
declare const delegation_prepareDelegateAccess: typeof prepareDelegateAccess;
|
|
348
380
|
declare const delegation_prepareProposeRevoke: typeof prepareProposeRevoke;
|
|
349
381
|
declare const delegation_prepareRevokeAccess: typeof prepareRevokeAccess;
|
|
350
382
|
declare const delegation_proposeRevoke: typeof proposeRevoke;
|
|
351
383
|
declare const delegation_revokeAccess: typeof revokeAccess;
|
|
352
384
|
declare namespace delegation {
|
|
353
|
-
export { type delegation_DelegateAccessParams as DelegateAccessParams, type delegation_ProposeRevokeParams as ProposeRevokeParams, type delegation_RevokeAccessParams as RevokeAccessParams, delegation_delegateAccess as delegateAccess, delegation_prepareDelegateAccess as prepareDelegateAccess, delegation_prepareProposeRevoke as prepareProposeRevoke, delegation_prepareRevokeAccess as prepareRevokeAccess, delegation_proposeRevoke as proposeRevoke, delegation_revokeAccess as revokeAccess };
|
|
385
|
+
export { type delegation_DelegateAccessParams as DelegateAccessParams, type delegation_DelegatedAccessParams as DelegatedAccessParams, type delegation_ProposeRevokeParams as ProposeRevokeParams, type delegation_RevokeAccessParams as RevokeAccessParams, delegation_delegateAccess as delegateAccess, delegation_hasDelegatedAccess as hasDelegatedAccess, delegation_prepareDelegateAccess as prepareDelegateAccess, delegation_prepareProposeRevoke as prepareProposeRevoke, delegation_prepareRevokeAccess as prepareRevokeAccess, delegation_proposeRevoke as proposeRevoke, delegation_revokeAccess as revokeAccess };
|
|
354
386
|
}
|
|
355
387
|
|
|
356
388
|
/**
|
|
@@ -468,6 +500,8 @@ declare class SymmioSDK {
|
|
|
468
500
|
proposeRevoke: (params: ProposeRevokeParams) => Promise<`0x${string}`>;
|
|
469
501
|
/** Revoke delegated access (after cooldown). */
|
|
470
502
|
revokeAccess: (params: RevokeAccessParams) => Promise<`0x${string}`>;
|
|
503
|
+
/** Reads whether a selector is delegated to a target for a sub-account. */
|
|
504
|
+
hasAccess: (params: DelegatedAccessParams) => Promise<boolean>;
|
|
471
505
|
};
|
|
472
506
|
get signature(): {
|
|
473
507
|
signTerms: () => Promise<`0x${string}`>;
|
|
@@ -495,34 +529,16 @@ declare class SymmioSDK {
|
|
|
495
529
|
/** Fetches the list of open instant close requests for an account. */
|
|
496
530
|
getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
|
|
497
531
|
};
|
|
532
|
+
get stats(): {
|
|
533
|
+
/** Reads partyA statistics (balances, locks) from the Diamond contract. */
|
|
534
|
+
getPartyAStats: (partyA: Address) => Promise<AccountBalance>;
|
|
535
|
+
/** Calculates available margin for placing orders given uPNL. */
|
|
536
|
+
calculateAvailableForOrder: (stats: AccountBalance, upnl: bigint) => bigint;
|
|
537
|
+
};
|
|
498
538
|
getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
|
|
499
539
|
getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
|
|
500
540
|
}
|
|
501
541
|
|
|
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
|
-
|
|
526
542
|
type Quote = {
|
|
527
543
|
id: number;
|
|
528
544
|
partyBsWhiteList: Address[];
|
|
@@ -19890,6 +19906,31 @@ declare namespace instant {
|
|
|
19890
19906
|
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
19907
|
}
|
|
19892
19908
|
|
|
19909
|
+
/**
|
|
19910
|
+
* Reads partyA statistics from the SymmioDiamond contract.
|
|
19911
|
+
* Returns balances, locked amounts, and pending locked amounts.
|
|
19912
|
+
*/
|
|
19913
|
+
declare function getPartyAStats(publicClient: PublicClient, symmioDiamond: Address, partyA: Address): Promise<AccountBalance>;
|
|
19914
|
+
/**
|
|
19915
|
+
* Calculates available margin for placing orders.
|
|
19916
|
+
*
|
|
19917
|
+
* When uPNL >= 0:
|
|
19918
|
+
* availableForOrder = allocatedBalance + upnl - totalLocked - totalPendingLocked
|
|
19919
|
+
*
|
|
19920
|
+
* When uPNL < 0:
|
|
19921
|
+
* considering_mm = max(|upnl|, lockedPartyAMM)
|
|
19922
|
+
* availableForOrder = allocatedBalance - lockedCVA - lockedLF - totalPendingLocked - considering_mm
|
|
19923
|
+
*
|
|
19924
|
+
* The negative-uPNL path prevents double-counting losses against the MM lock.
|
|
19925
|
+
*/
|
|
19926
|
+
declare function calculateAvailableForOrder(stats: AccountBalance, upnl: bigint): bigint;
|
|
19927
|
+
|
|
19928
|
+
declare const stats_calculateAvailableForOrder: typeof calculateAvailableForOrder;
|
|
19929
|
+
declare const stats_getPartyAStats: typeof getPartyAStats;
|
|
19930
|
+
declare namespace stats {
|
|
19931
|
+
export { stats_calculateAvailableForOrder as calculateAvailableForOrder, stats_getPartyAStats as getPartyAStats };
|
|
19932
|
+
}
|
|
19933
|
+
|
|
19893
19934
|
/**
|
|
19894
19935
|
* Adds a gas margin buffer to the estimated gas.
|
|
19895
19936
|
* Default buffer is 20% above the estimation.
|
|
@@ -19954,4 +19995,4 @@ declare function formatPrice(price: bigint, decimals: number, precision?: number
|
|
|
19954
19995
|
*/
|
|
19955
19996
|
declare function applySlippage(price: bigint, slippagePercent: number, isLong: boolean): bigint;
|
|
19956
19997
|
|
|
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 };
|
|
19998
|
+
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, stats as statsActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,30 @@ type CancelQuoteParams = {
|
|
|
176
176
|
quoteId: bigint;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
type Account = {
|
|
180
|
+
accountAddress: Address;
|
|
181
|
+
name: string;
|
|
182
|
+
};
|
|
183
|
+
type AccountBalance = {
|
|
184
|
+
collateralBalance: bigint;
|
|
185
|
+
allocatedBalance: bigint;
|
|
186
|
+
availableBalance: bigint;
|
|
187
|
+
lockedCVA: bigint;
|
|
188
|
+
lockedLF: bigint;
|
|
189
|
+
lockedPartyAMM: bigint;
|
|
190
|
+
lockedPartyBMM: bigint;
|
|
191
|
+
pendingLockedCVA: bigint;
|
|
192
|
+
pendingLockedLF: bigint;
|
|
193
|
+
pendingLockedPartyAMM: bigint;
|
|
194
|
+
pendingLockedPartyBMM: bigint;
|
|
195
|
+
positionsCount: number;
|
|
196
|
+
pendingCount: number;
|
|
197
|
+
nonces: number;
|
|
198
|
+
};
|
|
199
|
+
type AddAccountParams = {
|
|
200
|
+
name: string;
|
|
201
|
+
};
|
|
202
|
+
|
|
179
203
|
type CreateSiweMessageParams = {
|
|
180
204
|
address: Address;
|
|
181
205
|
statement: string;
|
|
@@ -324,6 +348,11 @@ type RevokeAccessParams = {
|
|
|
324
348
|
target: Address;
|
|
325
349
|
selectors: Hex[];
|
|
326
350
|
};
|
|
351
|
+
type DelegatedAccessParams = {
|
|
352
|
+
account: Address;
|
|
353
|
+
target: Address;
|
|
354
|
+
selector: Hex;
|
|
355
|
+
};
|
|
327
356
|
/**
|
|
328
357
|
* Prepares a delegateAccesses transaction.
|
|
329
358
|
*/
|
|
@@ -339,18 +368,21 @@ declare function prepareRevokeAccess(multiAccount: Address, account: Address, pa
|
|
|
339
368
|
declare function delegateAccess(walletClient: WalletClient, publicClient: PublicClient, multiAccount: Address, params: DelegateAccessParams): Promise<Hex>;
|
|
340
369
|
declare function proposeRevoke(walletClient: WalletClient, publicClient: PublicClient, multiAccount: Address, params: ProposeRevokeParams): Promise<Hex>;
|
|
341
370
|
declare function revokeAccess(walletClient: WalletClient, publicClient: PublicClient, multiAccount: Address, params: RevokeAccessParams): Promise<Hex>;
|
|
371
|
+
declare function hasDelegatedAccess(publicClient: PublicClient, multiAccount: Address, params: DelegatedAccessParams): Promise<boolean>;
|
|
342
372
|
|
|
343
373
|
type delegation_DelegateAccessParams = DelegateAccessParams;
|
|
374
|
+
type delegation_DelegatedAccessParams = DelegatedAccessParams;
|
|
344
375
|
type delegation_ProposeRevokeParams = ProposeRevokeParams;
|
|
345
376
|
type delegation_RevokeAccessParams = RevokeAccessParams;
|
|
346
377
|
declare const delegation_delegateAccess: typeof delegateAccess;
|
|
378
|
+
declare const delegation_hasDelegatedAccess: typeof hasDelegatedAccess;
|
|
347
379
|
declare const delegation_prepareDelegateAccess: typeof prepareDelegateAccess;
|
|
348
380
|
declare const delegation_prepareProposeRevoke: typeof prepareProposeRevoke;
|
|
349
381
|
declare const delegation_prepareRevokeAccess: typeof prepareRevokeAccess;
|
|
350
382
|
declare const delegation_proposeRevoke: typeof proposeRevoke;
|
|
351
383
|
declare const delegation_revokeAccess: typeof revokeAccess;
|
|
352
384
|
declare namespace delegation {
|
|
353
|
-
export { type delegation_DelegateAccessParams as DelegateAccessParams, type delegation_ProposeRevokeParams as ProposeRevokeParams, type delegation_RevokeAccessParams as RevokeAccessParams, delegation_delegateAccess as delegateAccess, delegation_prepareDelegateAccess as prepareDelegateAccess, delegation_prepareProposeRevoke as prepareProposeRevoke, delegation_prepareRevokeAccess as prepareRevokeAccess, delegation_proposeRevoke as proposeRevoke, delegation_revokeAccess as revokeAccess };
|
|
385
|
+
export { type delegation_DelegateAccessParams as DelegateAccessParams, type delegation_DelegatedAccessParams as DelegatedAccessParams, type delegation_ProposeRevokeParams as ProposeRevokeParams, type delegation_RevokeAccessParams as RevokeAccessParams, delegation_delegateAccess as delegateAccess, delegation_hasDelegatedAccess as hasDelegatedAccess, delegation_prepareDelegateAccess as prepareDelegateAccess, delegation_prepareProposeRevoke as prepareProposeRevoke, delegation_prepareRevokeAccess as prepareRevokeAccess, delegation_proposeRevoke as proposeRevoke, delegation_revokeAccess as revokeAccess };
|
|
354
386
|
}
|
|
355
387
|
|
|
356
388
|
/**
|
|
@@ -468,6 +500,8 @@ declare class SymmioSDK {
|
|
|
468
500
|
proposeRevoke: (params: ProposeRevokeParams) => Promise<`0x${string}`>;
|
|
469
501
|
/** Revoke delegated access (after cooldown). */
|
|
470
502
|
revokeAccess: (params: RevokeAccessParams) => Promise<`0x${string}`>;
|
|
503
|
+
/** Reads whether a selector is delegated to a target for a sub-account. */
|
|
504
|
+
hasAccess: (params: DelegatedAccessParams) => Promise<boolean>;
|
|
471
505
|
};
|
|
472
506
|
get signature(): {
|
|
473
507
|
signTerms: () => Promise<`0x${string}`>;
|
|
@@ -495,34 +529,16 @@ declare class SymmioSDK {
|
|
|
495
529
|
/** Fetches the list of open instant close requests for an account. */
|
|
496
530
|
getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
|
|
497
531
|
};
|
|
532
|
+
get stats(): {
|
|
533
|
+
/** Reads partyA statistics (balances, locks) from the Diamond contract. */
|
|
534
|
+
getPartyAStats: (partyA: Address) => Promise<AccountBalance>;
|
|
535
|
+
/** Calculates available margin for placing orders given uPNL. */
|
|
536
|
+
calculateAvailableForOrder: (stats: AccountBalance, upnl: bigint) => bigint;
|
|
537
|
+
};
|
|
498
538
|
getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
|
|
499
539
|
getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
|
|
500
540
|
}
|
|
501
541
|
|
|
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
|
-
|
|
526
542
|
type Quote = {
|
|
527
543
|
id: number;
|
|
528
544
|
partyBsWhiteList: Address[];
|
|
@@ -19890,6 +19906,31 @@ declare namespace instant {
|
|
|
19890
19906
|
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
19907
|
}
|
|
19892
19908
|
|
|
19909
|
+
/**
|
|
19910
|
+
* Reads partyA statistics from the SymmioDiamond contract.
|
|
19911
|
+
* Returns balances, locked amounts, and pending locked amounts.
|
|
19912
|
+
*/
|
|
19913
|
+
declare function getPartyAStats(publicClient: PublicClient, symmioDiamond: Address, partyA: Address): Promise<AccountBalance>;
|
|
19914
|
+
/**
|
|
19915
|
+
* Calculates available margin for placing orders.
|
|
19916
|
+
*
|
|
19917
|
+
* When uPNL >= 0:
|
|
19918
|
+
* availableForOrder = allocatedBalance + upnl - totalLocked - totalPendingLocked
|
|
19919
|
+
*
|
|
19920
|
+
* When uPNL < 0:
|
|
19921
|
+
* considering_mm = max(|upnl|, lockedPartyAMM)
|
|
19922
|
+
* availableForOrder = allocatedBalance - lockedCVA - lockedLF - totalPendingLocked - considering_mm
|
|
19923
|
+
*
|
|
19924
|
+
* The negative-uPNL path prevents double-counting losses against the MM lock.
|
|
19925
|
+
*/
|
|
19926
|
+
declare function calculateAvailableForOrder(stats: AccountBalance, upnl: bigint): bigint;
|
|
19927
|
+
|
|
19928
|
+
declare const stats_calculateAvailableForOrder: typeof calculateAvailableForOrder;
|
|
19929
|
+
declare const stats_getPartyAStats: typeof getPartyAStats;
|
|
19930
|
+
declare namespace stats {
|
|
19931
|
+
export { stats_calculateAvailableForOrder as calculateAvailableForOrder, stats_getPartyAStats as getPartyAStats };
|
|
19932
|
+
}
|
|
19933
|
+
|
|
19893
19934
|
/**
|
|
19894
19935
|
* Adds a gas margin buffer to the estimated gas.
|
|
19895
19936
|
* Default buffer is 20% above the estimation.
|
|
@@ -19954,4 +19995,4 @@ declare function formatPrice(price: bigint, decimals: number, precision?: number
|
|
|
19954
19995
|
*/
|
|
19955
19996
|
declare function applySlippage(price: bigint, slippagePercent: number, isLong: boolean): bigint;
|
|
19956
19997
|
|
|
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 };
|
|
19998
|
+
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, stats as statsActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
|
package/dist/index.js
CHANGED
|
@@ -23861,6 +23861,7 @@ async function getApprovalState(publicClient, tokenAddress, owner, spender, requ
|
|
|
23861
23861
|
var delegation_exports = {};
|
|
23862
23862
|
__export(delegation_exports, {
|
|
23863
23863
|
delegateAccess: () => delegateAccess,
|
|
23864
|
+
hasDelegatedAccess: () => hasDelegatedAccess,
|
|
23864
23865
|
prepareDelegateAccess: () => prepareDelegateAccess,
|
|
23865
23866
|
prepareProposeRevoke: () => prepareProposeRevoke,
|
|
23866
23867
|
prepareRevokeAccess: () => prepareRevokeAccess,
|
|
@@ -23938,6 +23939,17 @@ async function revokeAccess(walletClient, publicClient, multiAccount, params) {
|
|
|
23938
23939
|
chain: walletClient.chain
|
|
23939
23940
|
});
|
|
23940
23941
|
}
|
|
23942
|
+
async function hasDelegatedAccess(publicClient, multiAccount, params) {
|
|
23943
|
+
validateAddress(params.account, "subAccount");
|
|
23944
|
+
validateAddress(params.target, "target");
|
|
23945
|
+
const result = await publicClient.readContract({
|
|
23946
|
+
address: multiAccount,
|
|
23947
|
+
abi: MultiAccountABI,
|
|
23948
|
+
functionName: "delegatedAccesses",
|
|
23949
|
+
args: [params.account, params.target, params.selector]
|
|
23950
|
+
});
|
|
23951
|
+
return Boolean(result);
|
|
23952
|
+
}
|
|
23941
23953
|
|
|
23942
23954
|
// src/actions/signature.ts
|
|
23943
23955
|
var signature_exports = {};
|
|
@@ -24271,6 +24283,56 @@ async function getOpenInstantCloses(chainId, account, accessToken) {
|
|
|
24271
24283
|
return response.json();
|
|
24272
24284
|
}
|
|
24273
24285
|
|
|
24286
|
+
// src/actions/stats.ts
|
|
24287
|
+
var stats_exports = {};
|
|
24288
|
+
__export(stats_exports, {
|
|
24289
|
+
calculateAvailableForOrder: () => calculateAvailableForOrder,
|
|
24290
|
+
getPartyAStats: () => getPartyAStats
|
|
24291
|
+
});
|
|
24292
|
+
async function getPartyAStats(publicClient, symmioDiamond, partyA) {
|
|
24293
|
+
const result = await publicClient.readContract({
|
|
24294
|
+
address: symmioDiamond,
|
|
24295
|
+
abi: SymmioDiamondABI,
|
|
24296
|
+
functionName: "partyAStats",
|
|
24297
|
+
args: [partyA]
|
|
24298
|
+
});
|
|
24299
|
+
return {
|
|
24300
|
+
collateralBalance: result[1],
|
|
24301
|
+
allocatedBalance: result[2],
|
|
24302
|
+
availableBalance: result[3],
|
|
24303
|
+
lockedCVA: result[4],
|
|
24304
|
+
lockedLF: result[5],
|
|
24305
|
+
lockedPartyAMM: result[6],
|
|
24306
|
+
lockedPartyBMM: result[7],
|
|
24307
|
+
pendingLockedCVA: result[8],
|
|
24308
|
+
pendingLockedLF: result[9],
|
|
24309
|
+
pendingLockedPartyAMM: result[10],
|
|
24310
|
+
pendingLockedPartyBMM: result[11],
|
|
24311
|
+
positionsCount: Number(result[12]),
|
|
24312
|
+
pendingCount: Number(result[13]),
|
|
24313
|
+
nonces: 0
|
|
24314
|
+
};
|
|
24315
|
+
}
|
|
24316
|
+
function calculateAvailableForOrder(stats, upnl) {
|
|
24317
|
+
const {
|
|
24318
|
+
allocatedBalance,
|
|
24319
|
+
lockedCVA,
|
|
24320
|
+
lockedLF,
|
|
24321
|
+
lockedPartyAMM,
|
|
24322
|
+
pendingLockedCVA,
|
|
24323
|
+
pendingLockedLF,
|
|
24324
|
+
pendingLockedPartyAMM
|
|
24325
|
+
} = stats;
|
|
24326
|
+
const totalPendingLocked = pendingLockedCVA + pendingLockedLF + pendingLockedPartyAMM;
|
|
24327
|
+
if (upnl >= 0n) {
|
|
24328
|
+
const totalLocked = lockedCVA + lockedLF + lockedPartyAMM;
|
|
24329
|
+
return allocatedBalance + upnl - totalLocked - totalPendingLocked;
|
|
24330
|
+
}
|
|
24331
|
+
const absUpnl = -upnl;
|
|
24332
|
+
const consideringMm = absUpnl > lockedPartyAMM ? absUpnl : lockedPartyAMM;
|
|
24333
|
+
return allocatedBalance - lockedCVA - lockedLF - totalPendingLocked - consideringMm;
|
|
24334
|
+
}
|
|
24335
|
+
|
|
24274
24336
|
// src/client.ts
|
|
24275
24337
|
var SymmioSDK = class {
|
|
24276
24338
|
chainId;
|
|
@@ -24417,7 +24479,9 @@ var SymmioSDK = class {
|
|
|
24417
24479
|
/** Propose to revoke delegated access (starts cooldown). */
|
|
24418
24480
|
proposeRevoke: (params) => proposeRevoke(wc, pc, ma, params),
|
|
24419
24481
|
/** Revoke delegated access (after cooldown). */
|
|
24420
|
-
revokeAccess: (params) => revokeAccess(wc, pc, ma, params)
|
|
24482
|
+
revokeAccess: (params) => revokeAccess(wc, pc, ma, params),
|
|
24483
|
+
/** Reads whether a selector is delegated to a target for a sub-account. */
|
|
24484
|
+
hasAccess: (params) => hasDelegatedAccess(pc, ma, params)
|
|
24421
24485
|
};
|
|
24422
24486
|
}
|
|
24423
24487
|
// ─── Signature Module ──────────────────────────────────────────
|
|
@@ -24473,6 +24537,17 @@ var SymmioSDK = class {
|
|
|
24473
24537
|
getOpenCloses: (account, accessToken) => getOpenInstantCloses(this.chainId, account, accessToken)
|
|
24474
24538
|
};
|
|
24475
24539
|
}
|
|
24540
|
+
// ─── Stats Module ───────────────────────────────────────────
|
|
24541
|
+
get stats() {
|
|
24542
|
+
const pc = this._publicClient;
|
|
24543
|
+
const sd = this._symmioDiamond;
|
|
24544
|
+
return {
|
|
24545
|
+
/** Reads partyA statistics (balances, locks) from the Diamond contract. */
|
|
24546
|
+
getPartyAStats: (partyA) => getPartyAStats(pc, sd, partyA),
|
|
24547
|
+
/** Calculates available margin for placing orders given uPNL. */
|
|
24548
|
+
calculateAvailableForOrder: (stats, upnl) => calculateAvailableForOrder(stats, upnl)
|
|
24549
|
+
};
|
|
24550
|
+
}
|
|
24476
24551
|
// ─── Muon Signatures ──────────────────────────────────────────
|
|
24477
24552
|
async getQuoteSig(partyA, symbolId) {
|
|
24478
24553
|
return this.muon.getQuoteSig({
|
|
@@ -24862,6 +24937,7 @@ exports.fromWei = fromWei;
|
|
|
24862
24937
|
exports.getAddress = getAddress;
|
|
24863
24938
|
exports.instantActions = instant_exports;
|
|
24864
24939
|
exports.signatureActions = signature_exports;
|
|
24940
|
+
exports.statsActions = stats_exports;
|
|
24865
24941
|
exports.toWei = toWei;
|
|
24866
24942
|
exports.tradeActions = trade_exports;
|
|
24867
24943
|
exports.validateAddress = validateAddress;
|