@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 +147 -25
- package/dist/index.d.ts +147 -25
- package/dist/index.js +204 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +203 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +741 -0
- package/dist/react/index.d.ts +741 -0
- package/dist/react/index.js +25998 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +25968 -0
- package/dist/react/index.mjs.map +1 -0
- package/package.json +30 -3
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as viem from 'viem';
|
|
3
|
+
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
4
|
+
import * as _pear_protocol_symm_core from '@pear-protocol/symm-core';
|
|
5
|
+
import { SymmSDK, OpenBasketPositionRequest, ClosePositionRequest, CancelOpenRequest, UpdatePositionRequest, SetTpslRequest, CancelTpslRequest } from '@pear-protocol/symm-core';
|
|
6
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
8
|
+
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
9
|
+
import * as _pear_protocol_symm_shared from '@pear-protocol/symm-shared';
|
|
10
|
+
|
|
11
|
+
type ChainId = number;
|
|
12
|
+
type SymmioSDKConfig = {
|
|
13
|
+
chainId: ChainId;
|
|
14
|
+
multiAccountAddress?: Address;
|
|
15
|
+
symmioDiamondAddress?: Address;
|
|
16
|
+
collateralAddress?: Address;
|
|
17
|
+
clearingHouseAddress?: Address;
|
|
18
|
+
signatureStoreAddress?: Address;
|
|
19
|
+
muonBaseUrls?: string[];
|
|
20
|
+
muonAppName?: string;
|
|
21
|
+
};
|
|
22
|
+
declare enum PositionType {
|
|
23
|
+
LONG = 0,
|
|
24
|
+
SHORT = 1
|
|
25
|
+
}
|
|
26
|
+
declare enum OrderType {
|
|
27
|
+
LIMIT = 0,
|
|
28
|
+
MARKET = 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type SymmProviderProps = {
|
|
32
|
+
chainId?: number;
|
|
33
|
+
symmCoreConfig: {
|
|
34
|
+
apiUrl: string;
|
|
35
|
+
wsUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
symmioConfig?: Partial<SymmioSDKConfig>;
|
|
38
|
+
siweDomain?: string;
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
};
|
|
41
|
+
declare function SymmProvider({ chainId: configChainId, symmCoreConfig, symmioConfig, siweDomain, children, }: SymmProviderProps): react_jsx_runtime.JSX.Element;
|
|
42
|
+
|
|
43
|
+
type Account = {
|
|
44
|
+
accountAddress: Address;
|
|
45
|
+
name: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type SchnorrSign = {
|
|
49
|
+
signature: bigint;
|
|
50
|
+
owner: Address;
|
|
51
|
+
nonce: Address;
|
|
52
|
+
};
|
|
53
|
+
type MuonSingleUpnlSig = {
|
|
54
|
+
reqId: Hex;
|
|
55
|
+
timestamp: bigint;
|
|
56
|
+
upnl: bigint;
|
|
57
|
+
gatewaySignature: Hex;
|
|
58
|
+
sigs: SchnorrSign;
|
|
59
|
+
};
|
|
60
|
+
type MuonSingleUpnlAndPriceSig = {
|
|
61
|
+
reqId: Hex;
|
|
62
|
+
timestamp: bigint;
|
|
63
|
+
upnl: bigint;
|
|
64
|
+
price: bigint;
|
|
65
|
+
gatewaySignature: Hex;
|
|
66
|
+
sigs: SchnorrSign;
|
|
67
|
+
};
|
|
68
|
+
type MuonBatchSig = {
|
|
69
|
+
reqId: Hex;
|
|
70
|
+
timestamp: bigint;
|
|
71
|
+
upnl: bigint;
|
|
72
|
+
prices: bigint[];
|
|
73
|
+
symbolIds: bigint[];
|
|
74
|
+
gatewaySignature: Hex;
|
|
75
|
+
sigs: SchnorrSign;
|
|
76
|
+
};
|
|
77
|
+
type MuonClientConfig = {
|
|
78
|
+
baseUrls: string[];
|
|
79
|
+
appName: string;
|
|
80
|
+
timeout?: number;
|
|
81
|
+
};
|
|
82
|
+
type MuonQuoteParams = {
|
|
83
|
+
partyA: Address;
|
|
84
|
+
chainId: number;
|
|
85
|
+
symmioAddress: Address;
|
|
86
|
+
symbolId: number;
|
|
87
|
+
};
|
|
88
|
+
type MuonDeallocateParams = {
|
|
89
|
+
partyA: Address;
|
|
90
|
+
chainId: number;
|
|
91
|
+
symmioAddress: Address;
|
|
92
|
+
};
|
|
93
|
+
type MuonBatchParams = {
|
|
94
|
+
partyA: Address;
|
|
95
|
+
chainId: number;
|
|
96
|
+
symmioAddress: Address;
|
|
97
|
+
symbolIds: number[];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type DepositParams = {
|
|
101
|
+
account: Address;
|
|
102
|
+
amount: bigint;
|
|
103
|
+
};
|
|
104
|
+
type DepositAndAllocateParams = {
|
|
105
|
+
account: Address;
|
|
106
|
+
amount: bigint;
|
|
107
|
+
};
|
|
108
|
+
type WithdrawParams = {
|
|
109
|
+
account: Address;
|
|
110
|
+
amount: bigint;
|
|
111
|
+
};
|
|
112
|
+
type AllocateParams = {
|
|
113
|
+
amount: bigint;
|
|
114
|
+
};
|
|
115
|
+
type DeallocateParams = {
|
|
116
|
+
amount: bigint;
|
|
117
|
+
upnlSig: MuonSingleUpnlSig;
|
|
118
|
+
};
|
|
119
|
+
type InternalTransferParams = {
|
|
120
|
+
recipient: Address;
|
|
121
|
+
amount: bigint;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
type SendQuoteParams = {
|
|
125
|
+
partyBsWhiteList: Address[];
|
|
126
|
+
symbolId: number;
|
|
127
|
+
positionType: PositionType;
|
|
128
|
+
orderType: OrderType;
|
|
129
|
+
price: bigint;
|
|
130
|
+
quantity: bigint;
|
|
131
|
+
cva: bigint;
|
|
132
|
+
lf: bigint;
|
|
133
|
+
partyAmm: bigint;
|
|
134
|
+
partyBmm: bigint;
|
|
135
|
+
maxFundingRate: bigint;
|
|
136
|
+
deadline: bigint;
|
|
137
|
+
affiliate: Address;
|
|
138
|
+
upnlSig: MuonSingleUpnlAndPriceSig;
|
|
139
|
+
};
|
|
140
|
+
type ClosePositionParams = {
|
|
141
|
+
quoteId: bigint;
|
|
142
|
+
closePrice: bigint;
|
|
143
|
+
quantityToClose: bigint;
|
|
144
|
+
orderType: OrderType;
|
|
145
|
+
deadline: bigint;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
type CreateSiweMessageParams = {
|
|
149
|
+
address: Address;
|
|
150
|
+
statement: string;
|
|
151
|
+
chainId: number;
|
|
152
|
+
nonce: string;
|
|
153
|
+
domain: string;
|
|
154
|
+
uri: string;
|
|
155
|
+
version?: string;
|
|
156
|
+
};
|
|
157
|
+
type SiweMessageResult = {
|
|
158
|
+
message: string;
|
|
159
|
+
issuedAt: string;
|
|
160
|
+
expirationTime: string;
|
|
161
|
+
};
|
|
162
|
+
type InstantLoginParams = {
|
|
163
|
+
accountAddress: Address;
|
|
164
|
+
signature: string;
|
|
165
|
+
expirationTime: string;
|
|
166
|
+
issuedAt: string;
|
|
167
|
+
nonce: string;
|
|
168
|
+
};
|
|
169
|
+
type InstantAuthToken = {
|
|
170
|
+
accessToken: string;
|
|
171
|
+
expirationTime: string;
|
|
172
|
+
issuedAt: string;
|
|
173
|
+
};
|
|
174
|
+
type InstantOpenParams = {
|
|
175
|
+
symbolId: number;
|
|
176
|
+
positionType: number;
|
|
177
|
+
orderType: number;
|
|
178
|
+
price: string;
|
|
179
|
+
quantity: string;
|
|
180
|
+
cva: string;
|
|
181
|
+
lf: string;
|
|
182
|
+
partyAmm: string;
|
|
183
|
+
partyBmm: string;
|
|
184
|
+
maxFundingRate: string;
|
|
185
|
+
deadline: number;
|
|
186
|
+
};
|
|
187
|
+
type InstantOpenResponse = {
|
|
188
|
+
successful: string;
|
|
189
|
+
message: string;
|
|
190
|
+
};
|
|
191
|
+
type InstantCloseParams = {
|
|
192
|
+
quoteId: string;
|
|
193
|
+
quantityToClose: string;
|
|
194
|
+
closePrice: string;
|
|
195
|
+
};
|
|
196
|
+
type InstantCloseResponse = {
|
|
197
|
+
successful: string;
|
|
198
|
+
message: string;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
declare class MuonClient {
|
|
202
|
+
private baseUrls;
|
|
203
|
+
private appName;
|
|
204
|
+
private timeout;
|
|
205
|
+
constructor(config?: Partial<MuonClientConfig>);
|
|
206
|
+
/**
|
|
207
|
+
* Sends a request to Muon, trying each base URL in order until one succeeds.
|
|
208
|
+
*/
|
|
209
|
+
private sendRequest;
|
|
210
|
+
/**
|
|
211
|
+
* Gets a UPnL + Price signature for opening a position (sendQuote).
|
|
212
|
+
*/
|
|
213
|
+
getQuoteSig(params: MuonQuoteParams): Promise<MuonSingleUpnlAndPriceSig>;
|
|
214
|
+
/**
|
|
215
|
+
* Gets a UPnL signature for deallocating funds.
|
|
216
|
+
* v0.8.5: Now includes pendingBalance for safe deallocate.
|
|
217
|
+
*/
|
|
218
|
+
getDeallocateSig(params: MuonDeallocateParams): Promise<MuonSingleUpnlSig>;
|
|
219
|
+
/**
|
|
220
|
+
* Gets a batch signature for multiple positions (v0.8.5).
|
|
221
|
+
* Single signature covers multiple symbol prices for batch open/close.
|
|
222
|
+
*/
|
|
223
|
+
getBatchSig(params: MuonBatchParams): Promise<MuonBatchSig>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare enum ApprovalState {
|
|
227
|
+
UNKNOWN = "UNKNOWN",
|
|
228
|
+
NOT_APPROVED = "NOT_APPROVED",
|
|
229
|
+
PENDING = "PENDING",
|
|
230
|
+
APPROVED = "APPROVED"
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
type DelegateAccessParams = {
|
|
234
|
+
account: Address;
|
|
235
|
+
target: Address;
|
|
236
|
+
selectors: Hex[];
|
|
237
|
+
activate: boolean;
|
|
238
|
+
};
|
|
239
|
+
type ProposeRevokeParams = {
|
|
240
|
+
account: Address;
|
|
241
|
+
target: Address;
|
|
242
|
+
selectors: Hex[];
|
|
243
|
+
};
|
|
244
|
+
type RevokeAccessParams = {
|
|
245
|
+
account: Address;
|
|
246
|
+
target: Address;
|
|
247
|
+
selectors: Hex[];
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* SymmioSDK — Main client for Symmio protocol.
|
|
252
|
+
*
|
|
253
|
+
* Provides a unified, ergonomic API over all protocol actions:
|
|
254
|
+
* account management (via MultiAccount), deposits/withdrawals,
|
|
255
|
+
* allocation/deallocation, trading, delegation, and administrative operations.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { SymmioSDK } from '@pear-protocol/symmio-client';
|
|
260
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
261
|
+
* import { arbitrum } from 'viem/chains';
|
|
262
|
+
*
|
|
263
|
+
* const sdk = new SymmioSDK({
|
|
264
|
+
* chainId: 42161,
|
|
265
|
+
* publicClient: createPublicClient({ chain: arbitrum, transport: http() }),
|
|
266
|
+
* walletClient: myWalletClient,
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* // Create an account
|
|
270
|
+
* const hash = await sdk.account.addAccount('Main Trading');
|
|
271
|
+
*
|
|
272
|
+
* // Deposit and allocate
|
|
273
|
+
* await sdk.deposit.depositAndAllocate({ account: '0x...', amount: 100000000n });
|
|
274
|
+
*
|
|
275
|
+
* // Open a position
|
|
276
|
+
* await sdk.trade.sendQuote('0x...account', { ... });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare class SymmioSDK {
|
|
280
|
+
readonly chainId: number;
|
|
281
|
+
readonly muon: MuonClient;
|
|
282
|
+
private _publicClient;
|
|
283
|
+
private _walletClient;
|
|
284
|
+
private _multiAccount;
|
|
285
|
+
private _symmioDiamond;
|
|
286
|
+
private _collateral;
|
|
287
|
+
private _clearingHouse?;
|
|
288
|
+
private _signatureStore?;
|
|
289
|
+
constructor(options: {
|
|
290
|
+
chainId: number;
|
|
291
|
+
publicClient: PublicClient;
|
|
292
|
+
walletClient: WalletClient;
|
|
293
|
+
config?: Partial<SymmioSDKConfig>;
|
|
294
|
+
});
|
|
295
|
+
get addresses(): {
|
|
296
|
+
multiAccount: `0x${string}`;
|
|
297
|
+
symmioDiamond: `0x${string}`;
|
|
298
|
+
collateral: `0x${string}`;
|
|
299
|
+
clearingHouse: `0x${string}` | undefined;
|
|
300
|
+
signatureStore: `0x${string}` | undefined;
|
|
301
|
+
};
|
|
302
|
+
get account(): {
|
|
303
|
+
/** Creates a new account. */
|
|
304
|
+
addAccount: (name: string) => Promise<`0x${string}`>;
|
|
305
|
+
/** Edits an account's name. */
|
|
306
|
+
editName: (accountAddress: Address, name: string) => Promise<`0x${string}`>;
|
|
307
|
+
/** Gets all accounts for a user (paginated). */
|
|
308
|
+
getAll: (user: Address, start?: number, size?: number) => Promise<Account[]>;
|
|
309
|
+
/** Gets the number of accounts for a user. */
|
|
310
|
+
getCount: (user: Address) => Promise<number>;
|
|
311
|
+
/** Gets the owner of an account. */
|
|
312
|
+
getOwner: (accountAddress: Address) => Promise<`0x${string}`>;
|
|
313
|
+
};
|
|
314
|
+
get deposit(): {
|
|
315
|
+
/** Standard deposit to an account. */
|
|
316
|
+
standard: (params: DepositParams) => Promise<`0x${string}`>;
|
|
317
|
+
/** Deposit and allocate in a single transaction. */
|
|
318
|
+
depositAndAllocate: (params: DepositAndAllocateParams) => Promise<`0x${string}`>;
|
|
319
|
+
};
|
|
320
|
+
get withdraw(): {
|
|
321
|
+
/** Withdraws collateral from an account. */
|
|
322
|
+
withdraw: (params: WithdrawParams) => Promise<`0x${string}`>;
|
|
323
|
+
};
|
|
324
|
+
get collateral(): {
|
|
325
|
+
/** Allocate collateral to a trading account. */
|
|
326
|
+
allocate: (subAccount: Address, params: AllocateParams) => Promise<`0x${string}`>;
|
|
327
|
+
/** Deallocate collateral (requires Muon signature). */
|
|
328
|
+
deallocate: (subAccount: Address, params: DeallocateParams) => Promise<`0x${string}`>;
|
|
329
|
+
/** Transfer funds to recipient's allocated balance. */
|
|
330
|
+
internalTransfer: (subAccount: Address, params: InternalTransferParams) => Promise<`0x${string}`>;
|
|
331
|
+
};
|
|
332
|
+
get trade(): {
|
|
333
|
+
/** Opens a position via sendQuoteWithAffiliate. */
|
|
334
|
+
sendQuote: (subAccount: Address, params: SendQuoteParams) => Promise<`0x${string}`>;
|
|
335
|
+
/** Close a position. */
|
|
336
|
+
closePosition: (subAccount: Address, params: ClosePositionParams) => Promise<`0x${string}`>;
|
|
337
|
+
/** Cancel a pending quote. */
|
|
338
|
+
cancelQuote: (subAccount: Address, quoteId: bigint) => Promise<`0x${string}`>;
|
|
339
|
+
/** Cancel a pending close request. */
|
|
340
|
+
cancelCloseRequest: (subAccount: Address, quoteId: bigint) => Promise<`0x${string}`>;
|
|
341
|
+
/** Force cancel a quote. */
|
|
342
|
+
forceCancelQuote: (subAccount: Address, quoteId: bigint) => Promise<`0x${string}`>;
|
|
343
|
+
/** Force cancel a close request. */
|
|
344
|
+
forceCancelCloseRequest: (subAccount: Address, quoteId: bigint) => Promise<`0x${string}`>;
|
|
345
|
+
};
|
|
346
|
+
get approval(): {
|
|
347
|
+
/** Approve the MultiAccount contract to spend collateral. */
|
|
348
|
+
approveCollateral: (amount: bigint) => Promise<`0x${string}`>;
|
|
349
|
+
/** Approve any spender for any token. */
|
|
350
|
+
approve: (token: Address, spender: Address, amount: bigint) => Promise<`0x${string}`>;
|
|
351
|
+
/** Get current allowance. */
|
|
352
|
+
getAllowance: (token: Address, owner: Address, spender: Address) => Promise<bigint>;
|
|
353
|
+
/** Get token balance. */
|
|
354
|
+
getBalance: (token: Address, account: Address) => Promise<bigint>;
|
|
355
|
+
/** Get approval state for a required amount. */
|
|
356
|
+
getState: (token: Address, owner: Address, spender: Address, requiredAmount: bigint) => Promise<ApprovalState>;
|
|
357
|
+
};
|
|
358
|
+
get delegation(): {
|
|
359
|
+
/** Delegate access to selectors. */
|
|
360
|
+
delegateAccess: (params: DelegateAccessParams) => Promise<`0x${string}`>;
|
|
361
|
+
/** Propose to revoke delegated access (starts cooldown). */
|
|
362
|
+
proposeRevoke: (params: ProposeRevokeParams) => Promise<`0x${string}`>;
|
|
363
|
+
/** Revoke delegated access (after cooldown). */
|
|
364
|
+
revokeAccess: (params: RevokeAccessParams) => Promise<`0x${string}`>;
|
|
365
|
+
};
|
|
366
|
+
get signature(): {
|
|
367
|
+
signTerms: () => Promise<`0x${string}`>;
|
|
368
|
+
storeSignature: (sig: Hex) => Promise<`0x${string}`>;
|
|
369
|
+
hasSigned: (user: Address) => Promise<boolean>;
|
|
370
|
+
getMessage: () => Promise<string>;
|
|
371
|
+
};
|
|
372
|
+
get admin(): {
|
|
373
|
+
grantRole: (role: Hex, grantee: Address) => Promise<`0x${string}`>;
|
|
374
|
+
revokeRole: (role: Hex, revokee: Address) => Promise<`0x${string}`>;
|
|
375
|
+
};
|
|
376
|
+
get instant(): {
|
|
377
|
+
/** Creates a SIWE message for instant trading authentication. */
|
|
378
|
+
createSiweMessage: (params: CreateSiweMessageParams) => SiweMessageResult;
|
|
379
|
+
/** Fetches a nonce from the hedger for SIWE authentication. */
|
|
380
|
+
getNonce: (subAccount: Address) => Promise<string>;
|
|
381
|
+
/** Exchanges a signed SIWE message for an access token. */
|
|
382
|
+
login: (params: InstantLoginParams) => Promise<InstantAuthToken>;
|
|
383
|
+
/** Opens a position instantly via the hedger (off-chain). */
|
|
384
|
+
open: (params: InstantOpenParams, accessToken: string) => Promise<InstantOpenResponse>;
|
|
385
|
+
/** Closes a position instantly via the hedger (off-chain). */
|
|
386
|
+
close: (params: InstantCloseParams, accessToken: string) => Promise<InstantCloseResponse>;
|
|
387
|
+
/** Cancels a pending instant close request. */
|
|
388
|
+
cancelClose: (quoteId: string, accessToken: string) => Promise<void>;
|
|
389
|
+
/** Fetches the list of open instant close requests for an account. */
|
|
390
|
+
getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
|
|
391
|
+
};
|
|
392
|
+
getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
|
|
393
|
+
getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
type SymmContextValue = {
|
|
397
|
+
symmioClient: SymmioSDK | null;
|
|
398
|
+
symmCoreClient: SymmSDK | null;
|
|
399
|
+
chainId: number;
|
|
400
|
+
address?: `0x${string}`;
|
|
401
|
+
accessToken: string | null;
|
|
402
|
+
authToken: string | null;
|
|
403
|
+
isReady: boolean;
|
|
404
|
+
refreshAuth: (accountAddress?: Address) => Promise<string | null>;
|
|
405
|
+
};
|
|
406
|
+
declare function useSymmContext(): SymmContextValue;
|
|
407
|
+
|
|
408
|
+
declare function useSymmioClient(): SymmioSDK | null;
|
|
409
|
+
|
|
410
|
+
declare function useSymmCoreClient(): SymmSDK | null;
|
|
411
|
+
|
|
412
|
+
declare function useSymmAuth(): {
|
|
413
|
+
accessToken: string | null;
|
|
414
|
+
authToken: string | null;
|
|
415
|
+
isAuthenticated: boolean;
|
|
416
|
+
refresh: (accountAddress?: viem.Address) => Promise<string | null>;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
declare function useSymmAccounts(userAddress?: Address): {
|
|
420
|
+
accounts: Account[];
|
|
421
|
+
count: number;
|
|
422
|
+
isLoading: boolean;
|
|
423
|
+
error: Error | null;
|
|
424
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<Account[], Error>>;
|
|
425
|
+
createAccount: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
426
|
+
name: string;
|
|
427
|
+
}, unknown>;
|
|
428
|
+
editName: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
429
|
+
accountAddress: Address;
|
|
430
|
+
name: string;
|
|
431
|
+
}, unknown>;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
declare function useSymmApproval(params: {
|
|
435
|
+
owner?: Address;
|
|
436
|
+
amount: bigint;
|
|
437
|
+
spender?: Address;
|
|
438
|
+
collateralToken?: Address;
|
|
439
|
+
}): {
|
|
440
|
+
approvalState: ApprovalState | null;
|
|
441
|
+
allowance: bigint;
|
|
442
|
+
balance: bigint;
|
|
443
|
+
isLoading: boolean;
|
|
444
|
+
approve: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, bigint, unknown>;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
declare function useSymmDeposit(): {
|
|
448
|
+
deposit: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
449
|
+
account: Address;
|
|
450
|
+
amount: bigint;
|
|
451
|
+
}, unknown>;
|
|
452
|
+
depositAndAllocate: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
453
|
+
account: Address;
|
|
454
|
+
amount: bigint;
|
|
455
|
+
}, unknown>;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
declare function useSymmWithdraw(): {
|
|
459
|
+
withdraw: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
460
|
+
account: Address;
|
|
461
|
+
amount: bigint;
|
|
462
|
+
}, unknown>;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
declare function useSymmCollateral(): {
|
|
466
|
+
allocate: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
467
|
+
subAccount: Address;
|
|
468
|
+
amount: bigint;
|
|
469
|
+
}, unknown>;
|
|
470
|
+
deallocate: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
471
|
+
subAccount: Address;
|
|
472
|
+
amount: bigint;
|
|
473
|
+
}, unknown>;
|
|
474
|
+
internalTransfer: _tanstack_react_query.UseMutationResult<`0x${string}`, Error, {
|
|
475
|
+
subAccount: Address;
|
|
476
|
+
params: InternalTransferParams;
|
|
477
|
+
}, unknown>;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
declare function useSymmSignature(userAddress?: Address): {
|
|
481
|
+
hasSigned: boolean;
|
|
482
|
+
isLoading: boolean;
|
|
483
|
+
signTerms: _tanstack_react_query.UseMutationResult<void, Error, void, unknown>;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
declare function useSymmBalances(params: {
|
|
487
|
+
userAddress?: Address;
|
|
488
|
+
chainId?: number;
|
|
489
|
+
multiAccountAddress?: Address;
|
|
490
|
+
}): {
|
|
491
|
+
balanceInfo: node_modules__pear_protocol_symm_core_dist_types.BalanceInfoResponse | null;
|
|
492
|
+
isLoading: boolean;
|
|
493
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.BalanceInfoResponse, Error>>;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
declare function useSymmTrade(): {
|
|
497
|
+
openBasket: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.BasketOpenResponse | _pear_protocol_symm_core.OpenBasketCommandResult, Error, OpenBasketPositionRequest, unknown>;
|
|
498
|
+
closePosition: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.ClosePositionResponse | _pear_protocol_symm_core.CloseCommandResult, Error, ClosePositionRequest, unknown>;
|
|
499
|
+
closeAll: _tanstack_react_query.UseMutationResult<node_modules__pear_protocol_symm_core_dist_types.CloseAllPositionsResponse, Error, Omit<node_modules__pear_protocol_symm_core_dist_types.CloseAllPositionsRequest, "chainId"> & {
|
|
500
|
+
chainId?: number;
|
|
501
|
+
}, unknown>;
|
|
502
|
+
cancelOpen: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, CancelOpenRequest, unknown>;
|
|
503
|
+
updatePosition: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.UpdatePositionResponse, Error, {
|
|
504
|
+
positionId: string;
|
|
505
|
+
request: UpdatePositionRequest;
|
|
506
|
+
}, unknown>;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
declare function useSymmPositions(params: {
|
|
510
|
+
accountAddress?: Address;
|
|
511
|
+
mainAddress?: Address;
|
|
512
|
+
chainId?: number;
|
|
513
|
+
}): {
|
|
514
|
+
positions: _pear_protocol_symm_core.OpenPositionDto[];
|
|
515
|
+
isLoading: boolean;
|
|
516
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_pear_protocol_symm_core.OpenPositionsListResponse, Error>>;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
declare function useSymmOpenOrders(params: {
|
|
520
|
+
accountAddress?: Address;
|
|
521
|
+
mainAddress?: Address;
|
|
522
|
+
chainId?: number;
|
|
523
|
+
}): {
|
|
524
|
+
orders: _pear_protocol_symm_core.UnifiedOrderItem[];
|
|
525
|
+
isLoading: boolean;
|
|
526
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_pear_protocol_symm_core.UnifiedOrdersListResponse, Error>>;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
declare function useSymmTradeHistory(params: {
|
|
530
|
+
accountAddress?: Address;
|
|
531
|
+
mainAddress?: Address;
|
|
532
|
+
chainId?: number;
|
|
533
|
+
}): {
|
|
534
|
+
trades: _pear_protocol_symm_shared.ApiResponse<unknown> | null;
|
|
535
|
+
isLoading: boolean;
|
|
536
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error>>;
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
declare function useSymmTpsl(): {
|
|
540
|
+
setTpsl: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.TpslUpdateResponse, Error, SetTpslRequest, unknown>;
|
|
541
|
+
cancelTpsl: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, CancelTpslRequest, unknown>;
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
declare function useSymmTwap(params: {
|
|
545
|
+
accountAddress?: Address;
|
|
546
|
+
mainAddress?: Address;
|
|
547
|
+
chainId?: number;
|
|
548
|
+
}): {
|
|
549
|
+
twapOrders: node_modules__pear_protocol_symm_core_dist_types.TwapOrder[];
|
|
550
|
+
isLoading: boolean;
|
|
551
|
+
cancelTwap: _tanstack_react_query.UseMutationResult<node_modules__pear_protocol_symm_core_dist_types.TwapOrderResponse, Error, string, unknown>;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
declare function useSymmMarkets(params?: {
|
|
555
|
+
chainId?: number;
|
|
556
|
+
searchText?: string;
|
|
557
|
+
}): {
|
|
558
|
+
markets: _pear_protocol_symm_core.MarketGroupItem[];
|
|
559
|
+
isLoading: boolean;
|
|
560
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_pear_protocol_symm_core.MarketsResponse, Error>>;
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
declare function useSymmFunding(params?: {
|
|
564
|
+
chainId?: number;
|
|
565
|
+
}): {
|
|
566
|
+
rates: node_modules__pear_protocol_symm_core_dist_types.FundingRate[];
|
|
567
|
+
isLoading: boolean;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
declare function useSymmPortfolio(params: {
|
|
571
|
+
accountAddress?: Address;
|
|
572
|
+
mainAddress?: Address;
|
|
573
|
+
chainId?: number;
|
|
574
|
+
}): {
|
|
575
|
+
metrics: _pear_protocol_symm_core.PortfolioResponse | null;
|
|
576
|
+
isLoading: boolean;
|
|
577
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_pear_protocol_symm_core.PortfolioResponse, Error>>;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
declare function useSymmNotifications(params: {
|
|
581
|
+
userAddress?: Address;
|
|
582
|
+
chainId?: number;
|
|
583
|
+
}): {
|
|
584
|
+
notifications: _pear_protocol_symm_core.Notification[];
|
|
585
|
+
unreadCount: number;
|
|
586
|
+
isLoading: boolean;
|
|
587
|
+
markRead: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.MarkReadResponse, Error, {
|
|
588
|
+
id?: string;
|
|
589
|
+
timestamp?: number;
|
|
590
|
+
}, unknown>;
|
|
591
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_pear_protocol_symm_core.NotificationsResponse, Error>>;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
declare function useSymmWs(params: {
|
|
595
|
+
accountAddress?: Address;
|
|
596
|
+
chainId?: number;
|
|
597
|
+
}): {
|
|
598
|
+
isConnected: boolean;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
interface SymmChartSelectionInput {
|
|
602
|
+
longSymbol: string | null;
|
|
603
|
+
shortSymbol: string | null;
|
|
604
|
+
longWeight?: number;
|
|
605
|
+
shortWeight?: number;
|
|
606
|
+
longTokens?: SymmChartTokenSelection[];
|
|
607
|
+
shortTokens?: SymmChartTokenSelection[];
|
|
608
|
+
}
|
|
609
|
+
interface SymmChartTokenSelection {
|
|
610
|
+
symbol: string;
|
|
611
|
+
weight: number;
|
|
612
|
+
}
|
|
613
|
+
interface SymmChartSelection {
|
|
614
|
+
longTokens: SymmChartTokenSelection[];
|
|
615
|
+
shortTokens: SymmChartTokenSelection[];
|
|
616
|
+
isSingleSided: boolean;
|
|
617
|
+
activeSide: 'long' | 'short' | null;
|
|
618
|
+
activeTokenSymbol?: string;
|
|
619
|
+
pairLabel: string;
|
|
620
|
+
selectedSymbols: string[];
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* SYMM chart selection hook. Accepts selection input as parameters
|
|
624
|
+
* rather than importing app store state, keeping the SDK app-agnostic.
|
|
625
|
+
*/
|
|
626
|
+
declare function useSymmChartSelection(input: SymmChartSelectionInput): SymmChartSelection;
|
|
627
|
+
|
|
628
|
+
interface SymmTokenMetadata {
|
|
629
|
+
currentPrice: number;
|
|
630
|
+
prevDayPrice: number;
|
|
631
|
+
priceChange24h: number;
|
|
632
|
+
priceChange24hPercent: number;
|
|
633
|
+
netFunding: number;
|
|
634
|
+
markPrice: number;
|
|
635
|
+
}
|
|
636
|
+
interface UseSymmTokenSelectionMetadataReturn {
|
|
637
|
+
isLoading: boolean;
|
|
638
|
+
isPriceDataReady: boolean;
|
|
639
|
+
isUnsupported: boolean;
|
|
640
|
+
unsupportedSymbols: string[];
|
|
641
|
+
unavailableReason: string | null;
|
|
642
|
+
longTokensMetadata: Record<string, SymmTokenMetadata | null>;
|
|
643
|
+
shortTokensMetadata: Record<string, SymmTokenMetadata | null>;
|
|
644
|
+
weightedRatio: number;
|
|
645
|
+
weightedRatio24h: number;
|
|
646
|
+
priceRatio: number;
|
|
647
|
+
priceRatio24h: number;
|
|
648
|
+
sumNetFunding: number;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Fetches Binance market data for selected SYMM chart tokens and derives
|
|
652
|
+
* chart header metrics (price ratio, weighted ratio, etc.).
|
|
653
|
+
*/
|
|
654
|
+
declare function useSymmTokenSelectionMetadata(selection: SymmChartSelection): UseSymmTokenSelectionMetadataReturn;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Candle interval type matching the chart system.
|
|
658
|
+
* Binance USD-M Futures uses the same string format.
|
|
659
|
+
*/
|
|
660
|
+
type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
|
|
661
|
+
|
|
662
|
+
interface ChartCandleData {
|
|
663
|
+
s?: string;
|
|
664
|
+
t: number;
|
|
665
|
+
T: number;
|
|
666
|
+
o: number;
|
|
667
|
+
c: number;
|
|
668
|
+
h: number;
|
|
669
|
+
l: number;
|
|
670
|
+
}
|
|
671
|
+
type RealtimeBar = {
|
|
672
|
+
time: number;
|
|
673
|
+
open: number;
|
|
674
|
+
high: number;
|
|
675
|
+
low: number;
|
|
676
|
+
close: number;
|
|
677
|
+
volume?: number;
|
|
678
|
+
};
|
|
679
|
+
type RealtimeBarsCallback = (bar: RealtimeBar) => void;
|
|
680
|
+
interface UseSymmChartCandlesReturn {
|
|
681
|
+
fetchBasketCandles: (start: number, end: number, interval: CandleInterval) => Promise<ChartCandleData[]>;
|
|
682
|
+
fetchPerformanceCandles: (start: number, end: number, interval: CandleInterval, symbol: string) => Promise<ChartCandleData[]>;
|
|
683
|
+
fetchOverallPerformanceCandles: (start: number, end: number, interval: CandleInterval) => Promise<ChartCandleData[]>;
|
|
684
|
+
addRealtimeListener: (cb: RealtimeBarsCallback) => string;
|
|
685
|
+
removeRealtimeListener: (id: string) => void;
|
|
686
|
+
getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
|
|
687
|
+
isLoading: boolean;
|
|
688
|
+
isUnsupported: boolean;
|
|
689
|
+
unsupportedSymbols: string[];
|
|
690
|
+
unavailableReason: string | null;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* SYMM chart candles hook backed by Binance mark-price klines.
|
|
694
|
+
* Returns the same interface as the Hyperliquid useBasketCandles hook.
|
|
695
|
+
*
|
|
696
|
+
* Realtime updates are provided via Binance kline WebSocket streams.
|
|
697
|
+
* When listeners are registered, the hook subscribes to kline streams
|
|
698
|
+
* for all selected symbols and emits computed basket bars.
|
|
699
|
+
*/
|
|
700
|
+
declare function useSymmChartCandles(selection: SymmChartSelection): UseSymmChartCandlesReturn;
|
|
701
|
+
|
|
702
|
+
interface SymmPerformanceOverlay {
|
|
703
|
+
id: string;
|
|
704
|
+
symbol: string;
|
|
705
|
+
label: string;
|
|
706
|
+
color: string;
|
|
707
|
+
enabled: boolean;
|
|
708
|
+
type: 'asset' | 'portfolio';
|
|
709
|
+
weight?: number;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* SYMM performance overlay hook. Generates overlay definitions
|
|
713
|
+
* for each selected SYMM leg, matching the Hyperliquid overlay contract.
|
|
714
|
+
*/
|
|
715
|
+
declare function useSymmPerformanceOverlays(selection: SymmChartSelection): {
|
|
716
|
+
overlays: SymmPerformanceOverlay[];
|
|
717
|
+
generateOverlaySymbols: () => string[];
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
declare const symmKeys: {
|
|
721
|
+
all: readonly ["symm"];
|
|
722
|
+
accounts: (address?: Address) => readonly ["symm", "accounts", `0x${string}` | undefined];
|
|
723
|
+
accountSummary: (address?: Address, chainId?: number) => readonly ["symm", "accountSummary", `0x${string}` | undefined, number | undefined];
|
|
724
|
+
signature: (address?: Address) => readonly ["symm", "signature", `0x${string}` | undefined];
|
|
725
|
+
approval: (owner?: Address, spender?: Address) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined];
|
|
726
|
+
balances: (address?: Address, chainId?: number) => readonly ["symm", "balances", `0x${string}` | undefined, number | undefined];
|
|
727
|
+
positions: (address?: Address, chainId?: number) => readonly ["symm", "positions", `0x${string}` | undefined, number | undefined];
|
|
728
|
+
openOrders: (address?: Address, chainId?: number) => readonly ["symm", "openOrders", `0x${string}` | undefined, number | undefined];
|
|
729
|
+
tradeHistory: (address?: Address, chainId?: number) => readonly ["symm", "tradeHistory", `0x${string}` | undefined, number | undefined];
|
|
730
|
+
tpslOrders: (address?: Address, chainId?: number) => readonly ["symm", "tpslOrders", `0x${string}` | undefined, number | undefined];
|
|
731
|
+
twapOrders: (address?: Address, chainId?: number) => readonly ["symm", "twapOrders", `0x${string}` | undefined, number | undefined];
|
|
732
|
+
markets: (chainId?: number, search?: string) => readonly ["symm", "markets", number | undefined, string | undefined];
|
|
733
|
+
fundingRates: (chainId?: number) => readonly ["symm", "fundingRates", number | undefined];
|
|
734
|
+
portfolio: (address?: Address, chainId?: number) => readonly ["symm", "portfolio", `0x${string}` | undefined, number | undefined];
|
|
735
|
+
notifications: (address?: Address, chainId?: number) => readonly ["symm", "notifications", `0x${string}` | undefined, number | undefined];
|
|
736
|
+
unreadCount: (address?: Address, chainId?: number) => readonly ["symm", "unreadCount", `0x${string}` | undefined, number | undefined];
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
declare function getSymmErrorMessage(error: unknown): string;
|
|
740
|
+
|
|
741
|
+
export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDeposit, useSymmFunding, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
|