@pear-protocol/symmio-client 0.1.9 → 0.1.10
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.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +24 -1
- package/dist/react/index.d.ts +24 -1
- package/dist/react/index.js +121 -28
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +121 -30
- package/dist/react/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/react/index.d.mts
CHANGED
|
@@ -639,6 +639,28 @@ declare function useSymmAvailableMargin(params: {
|
|
|
639
639
|
}, Error>>;
|
|
640
640
|
};
|
|
641
641
|
|
|
642
|
+
declare function useSymmAccountSummary(params: {
|
|
643
|
+
userAddress?: Address;
|
|
644
|
+
chainId?: number;
|
|
645
|
+
query?: SymmQueryConfig;
|
|
646
|
+
}): {
|
|
647
|
+
accounts: node_modules__pear_protocol_symm_core_dist_types.AccountSummaryItem[];
|
|
648
|
+
total: number;
|
|
649
|
+
isLoading: boolean;
|
|
650
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.AccountSummaryResponse, Error>>;
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
declare function useSymmAccountData(params: {
|
|
654
|
+
address?: Address;
|
|
655
|
+
upnl?: string;
|
|
656
|
+
chainId?: number;
|
|
657
|
+
query?: SymmQueryConfig;
|
|
658
|
+
}): {
|
|
659
|
+
accountData: node_modules__pear_protocol_symm_core_dist_types.AccountDataInfo | null;
|
|
660
|
+
isLoading: boolean;
|
|
661
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.AccountDataResponse, Error>>;
|
|
662
|
+
};
|
|
663
|
+
|
|
642
664
|
declare function useSymmBalances(params: {
|
|
643
665
|
userAddress?: Address;
|
|
644
666
|
chainId?: number;
|
|
@@ -910,6 +932,7 @@ declare const symmKeys: {
|
|
|
910
932
|
all: readonly ["symm"];
|
|
911
933
|
accounts: (address?: Address) => readonly ["symm", "accounts", `0x${string}` | undefined];
|
|
912
934
|
accountSummary: (address?: Address, chainId?: number) => readonly ["symm", "accountSummary", `0x${string}` | undefined, number | undefined];
|
|
935
|
+
accountData: (address?: Address, chainId?: number) => readonly ["symm", "accountData", `0x${string}` | undefined, number | undefined];
|
|
913
936
|
signature: (address?: Address) => readonly ["symm", "signature", `0x${string}` | undefined];
|
|
914
937
|
approval: (owner?: Address, spender?: Address) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined];
|
|
915
938
|
balances: (address?: Address, chainId?: number) => readonly ["symm", "balances", `0x${string}` | undefined, number | undefined];
|
|
@@ -931,4 +954,4 @@ declare const symmKeys: {
|
|
|
931
954
|
|
|
932
955
|
declare function getSymmErrorMessage(error: unknown): string;
|
|
933
956
|
|
|
934
|
-
export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmDelegationState, type SymmInstantTradeActionArgs, type SymmInstantTradeRequest, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmQueryConfig, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmDelegationParams, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
|
|
957
|
+
export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmDelegationState, type SymmInstantTradeActionArgs, type SymmInstantTradeRequest, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmQueryConfig, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmDelegationParams, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccountData, useSymmAccountSummary, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -639,6 +639,28 @@ declare function useSymmAvailableMargin(params: {
|
|
|
639
639
|
}, Error>>;
|
|
640
640
|
};
|
|
641
641
|
|
|
642
|
+
declare function useSymmAccountSummary(params: {
|
|
643
|
+
userAddress?: Address;
|
|
644
|
+
chainId?: number;
|
|
645
|
+
query?: SymmQueryConfig;
|
|
646
|
+
}): {
|
|
647
|
+
accounts: node_modules__pear_protocol_symm_core_dist_types.AccountSummaryItem[];
|
|
648
|
+
total: number;
|
|
649
|
+
isLoading: boolean;
|
|
650
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.AccountSummaryResponse, Error>>;
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
declare function useSymmAccountData(params: {
|
|
654
|
+
address?: Address;
|
|
655
|
+
upnl?: string;
|
|
656
|
+
chainId?: number;
|
|
657
|
+
query?: SymmQueryConfig;
|
|
658
|
+
}): {
|
|
659
|
+
accountData: node_modules__pear_protocol_symm_core_dist_types.AccountDataInfo | null;
|
|
660
|
+
isLoading: boolean;
|
|
661
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.AccountDataResponse, Error>>;
|
|
662
|
+
};
|
|
663
|
+
|
|
642
664
|
declare function useSymmBalances(params: {
|
|
643
665
|
userAddress?: Address;
|
|
644
666
|
chainId?: number;
|
|
@@ -910,6 +932,7 @@ declare const symmKeys: {
|
|
|
910
932
|
all: readonly ["symm"];
|
|
911
933
|
accounts: (address?: Address) => readonly ["symm", "accounts", `0x${string}` | undefined];
|
|
912
934
|
accountSummary: (address?: Address, chainId?: number) => readonly ["symm", "accountSummary", `0x${string}` | undefined, number | undefined];
|
|
935
|
+
accountData: (address?: Address, chainId?: number) => readonly ["symm", "accountData", `0x${string}` | undefined, number | undefined];
|
|
913
936
|
signature: (address?: Address) => readonly ["symm", "signature", `0x${string}` | undefined];
|
|
914
937
|
approval: (owner?: Address, spender?: Address) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined];
|
|
915
938
|
balances: (address?: Address, chainId?: number) => readonly ["symm", "balances", `0x${string}` | undefined, number | undefined];
|
|
@@ -931,4 +954,4 @@ declare const symmKeys: {
|
|
|
931
954
|
|
|
932
955
|
declare function getSymmErrorMessage(error: unknown): string;
|
|
933
956
|
|
|
934
|
-
export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmDelegationState, type SymmInstantTradeActionArgs, type SymmInstantTradeRequest, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmQueryConfig, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmDelegationParams, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
|
|
957
|
+
export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmDelegationState, type SymmInstantTradeActionArgs, type SymmInstantTradeRequest, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmQueryConfig, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmDelegationParams, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccountData, useSymmAccountSummary, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
|
package/dist/react/index.js
CHANGED
|
@@ -23767,11 +23767,11 @@ function prepareGrantRole(symmioDiamond, account, role, grantee) {
|
|
|
23767
23767
|
const data = viem.encodeFunctionData({
|
|
23768
23768
|
abi: SymmioDiamondABI,
|
|
23769
23769
|
functionName: "grantRole",
|
|
23770
|
-
args: [
|
|
23770
|
+
args: [grantee, role]
|
|
23771
23771
|
});
|
|
23772
23772
|
return {
|
|
23773
23773
|
functionName: "grantRole",
|
|
23774
|
-
args: [
|
|
23774
|
+
args: [grantee, role],
|
|
23775
23775
|
config: { account, to: symmioDiamond, data, value: 0n }
|
|
23776
23776
|
};
|
|
23777
23777
|
}
|
|
@@ -23780,11 +23780,11 @@ function prepareRevokeRole(symmioDiamond, account, role, revokee) {
|
|
|
23780
23780
|
const data = viem.encodeFunctionData({
|
|
23781
23781
|
abi: SymmioDiamondABI,
|
|
23782
23782
|
functionName: "revokeRole",
|
|
23783
|
-
args: [
|
|
23783
|
+
args: [revokee, role]
|
|
23784
23784
|
});
|
|
23785
23785
|
return {
|
|
23786
23786
|
functionName: "revokeRole",
|
|
23787
|
-
args: [
|
|
23787
|
+
args: [revokee, role],
|
|
23788
23788
|
config: { account, to: symmioDiamond, data, value: 0n }
|
|
23789
23789
|
};
|
|
23790
23790
|
}
|
|
@@ -24362,6 +24362,16 @@ function SymmProvider({
|
|
|
24362
24362
|
const [accessToken, setAccessToken] = react.useState(null);
|
|
24363
24363
|
const prevAddressRef = react.useRef(address);
|
|
24364
24364
|
const prevChainRef = react.useRef(chainId);
|
|
24365
|
+
const {
|
|
24366
|
+
multiAccountAddress,
|
|
24367
|
+
symmioDiamondAddress,
|
|
24368
|
+
collateralAddress,
|
|
24369
|
+
clearingHouseAddress,
|
|
24370
|
+
signatureStoreAddress,
|
|
24371
|
+
muonBaseUrls,
|
|
24372
|
+
muonAppName
|
|
24373
|
+
} = symmioConfig ?? {};
|
|
24374
|
+
const muonBaseUrlsKey = muonBaseUrls?.join(",");
|
|
24365
24375
|
const symmioClient = react.useMemo(() => {
|
|
24366
24376
|
if (!publicClient || !walletClient || !address) return null;
|
|
24367
24377
|
return new SymmioSDK({
|
|
@@ -24370,30 +24380,65 @@ function SymmProvider({
|
|
|
24370
24380
|
walletClient,
|
|
24371
24381
|
config: symmioConfig
|
|
24372
24382
|
});
|
|
24373
|
-
}, [
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
|
|
24381
|
-
|
|
24382
|
-
|
|
24383
|
-
|
|
24384
|
-
|
|
24385
|
-
|
|
24386
|
-
|
|
24387
|
-
|
|
24388
|
-
|
|
24389
|
-
|
|
24390
|
-
|
|
24391
|
-
|
|
24392
|
-
|
|
24393
|
-
|
|
24394
|
-
|
|
24395
|
-
|
|
24396
|
-
|
|
24383
|
+
}, [
|
|
24384
|
+
publicClient,
|
|
24385
|
+
walletClient,
|
|
24386
|
+
address,
|
|
24387
|
+
chainId,
|
|
24388
|
+
multiAccountAddress,
|
|
24389
|
+
symmioDiamondAddress,
|
|
24390
|
+
collateralAddress,
|
|
24391
|
+
clearingHouseAddress,
|
|
24392
|
+
signatureStoreAddress,
|
|
24393
|
+
muonBaseUrlsKey,
|
|
24394
|
+
muonAppName
|
|
24395
|
+
]);
|
|
24396
|
+
react.useEffect(() => {
|
|
24397
|
+
console.log("[SymmProvider] symmioClient prerequisites", {
|
|
24398
|
+
address,
|
|
24399
|
+
walletChainId,
|
|
24400
|
+
configChainId,
|
|
24401
|
+
resolvedChainId: chainId,
|
|
24402
|
+
hasPublicClient: !!publicClient,
|
|
24403
|
+
hasWalletClient: !!walletClient,
|
|
24404
|
+
hasAddress: !!address,
|
|
24405
|
+
symmioClientBuilt: !!symmioClient
|
|
24406
|
+
});
|
|
24407
|
+
}, [
|
|
24408
|
+
address,
|
|
24409
|
+
walletChainId,
|
|
24410
|
+
configChainId,
|
|
24411
|
+
chainId,
|
|
24412
|
+
publicClient,
|
|
24413
|
+
walletClient,
|
|
24414
|
+
symmioClient
|
|
24415
|
+
]);
|
|
24416
|
+
const refreshAuth = react.useCallback(
|
|
24417
|
+
async (accountAddress) => {
|
|
24418
|
+
if (!walletClient || !address) return null;
|
|
24419
|
+
const resolvedAccountAddress = accountAddress ?? address;
|
|
24420
|
+
const cached = getCachedToken(resolvedAccountAddress, chainId);
|
|
24421
|
+
if (cached) {
|
|
24422
|
+
setAccessToken(cached);
|
|
24423
|
+
return cached;
|
|
24424
|
+
}
|
|
24425
|
+
try {
|
|
24426
|
+
const token = await fetchAccessToken(
|
|
24427
|
+
walletClient,
|
|
24428
|
+
address,
|
|
24429
|
+
resolvedAccountAddress,
|
|
24430
|
+
chainId,
|
|
24431
|
+
siweDomain
|
|
24432
|
+
);
|
|
24433
|
+
setAccessToken(token);
|
|
24434
|
+
return token;
|
|
24435
|
+
} catch {
|
|
24436
|
+
setAccessToken(null);
|
|
24437
|
+
return null;
|
|
24438
|
+
}
|
|
24439
|
+
},
|
|
24440
|
+
[walletClient, address, chainId, siweDomain]
|
|
24441
|
+
);
|
|
24397
24442
|
react.useEffect(() => {
|
|
24398
24443
|
const previousAddress = prevAddressRef.current;
|
|
24399
24444
|
const previousChainId = prevChainRef.current;
|
|
@@ -24474,6 +24519,7 @@ var symmKeys = {
|
|
|
24474
24519
|
all: ["symm"],
|
|
24475
24520
|
accounts: (address) => ["symm", "accounts", address],
|
|
24476
24521
|
accountSummary: (address, chainId) => ["symm", "accountSummary", address, chainId],
|
|
24522
|
+
accountData: (address, chainId) => ["symm", "accountData", address, chainId],
|
|
24477
24523
|
signature: (address) => ["symm", "signature", address],
|
|
24478
24524
|
approval: (owner, spender) => ["symm", "approval", owner, spender],
|
|
24479
24525
|
balances: (address, chainId) => ["symm", "balances", address, chainId],
|
|
@@ -24537,6 +24583,7 @@ function useSymmDelegation(params) {
|
|
|
24537
24583
|
function invalidateBalances(qc) {
|
|
24538
24584
|
qc.invalidateQueries({ queryKey: ["symm", "balances"] });
|
|
24539
24585
|
qc.invalidateQueries({ queryKey: ["symm", "accountSummary"] });
|
|
24586
|
+
qc.invalidateQueries({ queryKey: ["symm", "accountData"] });
|
|
24540
24587
|
qc.invalidateQueries({ queryKey: ["symm", "portfolio"] });
|
|
24541
24588
|
}
|
|
24542
24589
|
function invalidatePositions(qc) {
|
|
@@ -24876,6 +24923,50 @@ function useSymmAvailableMargin(params) {
|
|
|
24876
24923
|
refetch: query.refetch
|
|
24877
24924
|
};
|
|
24878
24925
|
}
|
|
24926
|
+
function useSymmAccountSummary(params) {
|
|
24927
|
+
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24928
|
+
const { userAddress } = params;
|
|
24929
|
+
const chainId = params.chainId ?? ctxChainId;
|
|
24930
|
+
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
24931
|
+
const query = reactQuery.useQuery({
|
|
24932
|
+
...params.query,
|
|
24933
|
+
queryKey: symmKeys.accountSummary(userAddress, chainId),
|
|
24934
|
+
queryFn: () => symmCoreClient.accounts.getSummary({
|
|
24935
|
+
userAddress,
|
|
24936
|
+
chainId
|
|
24937
|
+
}),
|
|
24938
|
+
enabled: internalEnabled && (params.query?.enabled ?? true),
|
|
24939
|
+
staleTime: params.query?.staleTime ?? 1e4
|
|
24940
|
+
});
|
|
24941
|
+
return {
|
|
24942
|
+
accounts: query.data?.data?.accounts ?? [],
|
|
24943
|
+
total: query.data?.data?.total ?? 0,
|
|
24944
|
+
isLoading: query.isLoading,
|
|
24945
|
+
refetch: query.refetch
|
|
24946
|
+
};
|
|
24947
|
+
}
|
|
24948
|
+
function useSymmAccountData(params) {
|
|
24949
|
+
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24950
|
+
const { address, upnl } = params;
|
|
24951
|
+
const chainId = params.chainId ?? ctxChainId;
|
|
24952
|
+
const internalEnabled = !!symmCoreClient && !!address;
|
|
24953
|
+
const query = reactQuery.useQuery({
|
|
24954
|
+
...params.query,
|
|
24955
|
+
queryKey: symmKeys.accountData(address, chainId),
|
|
24956
|
+
queryFn: () => symmCoreClient.accounts.getData({
|
|
24957
|
+
address,
|
|
24958
|
+
chainId,
|
|
24959
|
+
upnl
|
|
24960
|
+
}),
|
|
24961
|
+
enabled: internalEnabled && (params.query?.enabled ?? true),
|
|
24962
|
+
staleTime: params.query?.staleTime ?? 1e4
|
|
24963
|
+
});
|
|
24964
|
+
return {
|
|
24965
|
+
accountData: query.data?.data ?? null,
|
|
24966
|
+
isLoading: query.isLoading,
|
|
24967
|
+
refetch: query.refetch
|
|
24968
|
+
};
|
|
24969
|
+
}
|
|
24879
24970
|
function useSymmBalances(params) {
|
|
24880
24971
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24881
24972
|
const { userAddress, multiAccountAddress } = params;
|
|
@@ -26338,6 +26429,8 @@ function getSymmErrorMessage(error) {
|
|
|
26338
26429
|
exports.SymmProvider = SymmProvider;
|
|
26339
26430
|
exports.getSymmErrorMessage = getSymmErrorMessage;
|
|
26340
26431
|
exports.symmKeys = symmKeys;
|
|
26432
|
+
exports.useSymmAccountData = useSymmAccountData;
|
|
26433
|
+
exports.useSymmAccountSummary = useSymmAccountSummary;
|
|
26341
26434
|
exports.useSymmAccounts = useSymmAccounts;
|
|
26342
26435
|
exports.useSymmApproval = useSymmApproval;
|
|
26343
26436
|
exports.useSymmAuth = useSymmAuth;
|