@symmio/trading-react 3.0.0 → 3.1.0

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.
Files changed (267) hide show
  1. package/dist/account-layer/use-account-balance-of.d.ts +5 -4
  2. package/dist/account-layer/use-account-balance-of.d.ts.map +1 -1
  3. package/dist/account-layer/use-account-balance-of.js.map +1 -1
  4. package/dist/account-layer/use-add-margin.d.ts.map +1 -1
  5. package/dist/account-layer/use-add-margin.js +1 -3
  6. package/dist/account-layer/use-add-margin.js.map +1 -1
  7. package/dist/account-layer/use-allocate.d.ts.map +1 -1
  8. package/dist/account-layer/use-allocate.js +1 -3
  9. package/dist/account-layer/use-allocate.js.map +1 -1
  10. package/dist/account-layer/use-cancel-registration.d.ts.map +1 -1
  11. package/dist/account-layer/use-cancel-registration.js +1 -2
  12. package/dist/account-layer/use-cancel-registration.js.map +1 -1
  13. package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
  14. package/dist/account-layer/use-create-sub-accounts.js +1 -3
  15. package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
  16. package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
  17. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +1 -6
  18. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
  19. package/dist/account-layer/use-deallocate.d.ts.map +1 -1
  20. package/dist/account-layer/use-deallocate.js +1 -3
  21. package/dist/account-layer/use-deallocate.js.map +1 -1
  22. package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
  23. package/dist/account-layer/use-delete-sub-account.js +1 -2
  24. package/dist/account-layer/use-delete-sub-account.js.map +1 -1
  25. package/dist/account-layer/use-deposit-and-allocate.d.ts.map +1 -1
  26. package/dist/account-layer/use-deposit-and-allocate.js +1 -3
  27. package/dist/account-layer/use-deposit-and-allocate.js.map +1 -1
  28. package/dist/account-layer/use-deposit.d.ts.map +1 -1
  29. package/dist/account-layer/use-deposit.js +1 -3
  30. package/dist/account-layer/use-deposit.js.map +1 -1
  31. package/dist/account-layer/use-edit-account-name.d.ts.map +1 -1
  32. package/dist/account-layer/use-edit-account-name.js +1 -3
  33. package/dist/account-layer/use-edit-account-name.js.map +1 -1
  34. package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
  35. package/dist/account-layer/use-remove-margin.js +1 -3
  36. package/dist/account-layer/use-remove-margin.js.map +1 -1
  37. package/dist/account-layer/use-request-to-register-affiliate.d.ts.map +1 -1
  38. package/dist/account-layer/use-request-to-register-affiliate.js +1 -2
  39. package/dist/account-layer/use-request-to-register-affiliate.js.map +1 -1
  40. package/dist/collateral/use-approve-collateral.d.ts.map +1 -1
  41. package/dist/collateral/use-approve-collateral.js +1 -2
  42. package/dist/collateral/use-approve-collateral.js.map +1 -1
  43. package/dist/errors/normalize-symm-error.d.ts.map +1 -1
  44. package/dist/errors/normalize-symm-error.js +1 -0
  45. package/dist/errors/normalize-symm-error.js.map +1 -1
  46. package/dist/errors/symmio-request-error.d.ts +19 -0
  47. package/dist/errors/symmio-request-error.d.ts.map +1 -1
  48. package/dist/errors/symmio-request-error.js +2 -1
  49. package/dist/errors/symmio-request-error.js.map +1 -1
  50. package/dist/gasless/gasless-relay-types.d.ts +115 -0
  51. package/dist/gasless/gasless-relay-types.d.ts.map +1 -0
  52. package/dist/gasless/gasless-relay-types.js +9 -0
  53. package/dist/gasless/gasless-relay-types.js.map +1 -0
  54. package/dist/gasless/index.d.ts +21 -0
  55. package/dist/gasless/index.d.ts.map +1 -0
  56. package/dist/gasless/index.js +21 -0
  57. package/dist/gasless/invalidate-relay-reads.d.ts +96 -0
  58. package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -0
  59. package/dist/gasless/invalidate-relay-reads.js +107 -0
  60. package/dist/gasless/invalidate-relay-reads.js.map +1 -0
  61. package/dist/gasless/use-approve-operational-fee.d.ts +38 -0
  62. package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -0
  63. package/dist/gasless/use-approve-operational-fee.js +37 -0
  64. package/dist/gasless/use-approve-operational-fee.js.map +1 -0
  65. package/dist/gasless/use-debounced-batch.d.ts +22 -0
  66. package/dist/gasless/use-debounced-batch.d.ts.map +1 -0
  67. package/dist/gasless/use-debounced-batch.js +27 -0
  68. package/dist/gasless/use-debounced-batch.js.map +1 -0
  69. package/dist/gasless/use-gasless-batch-fee-quote.d.ts +48 -0
  70. package/dist/gasless/use-gasless-batch-fee-quote.d.ts.map +1 -0
  71. package/dist/gasless/use-gasless-batch-fee-quote.js +33 -0
  72. package/dist/gasless/use-gasless-batch-fee-quote.js.map +1 -0
  73. package/dist/gasless/use-gasless-deposit-policy.d.ts +28 -0
  74. package/dist/gasless/use-gasless-deposit-policy.d.ts.map +1 -0
  75. package/dist/gasless/use-gasless-deposit-policy.js +27 -0
  76. package/dist/gasless/use-gasless-deposit-policy.js.map +1 -0
  77. package/dist/gasless/use-gasless-fee-quote.d.ts +25 -0
  78. package/dist/gasless/use-gasless-fee-quote.d.ts.map +1 -0
  79. package/dist/gasless/use-gasless-fee-quote.js +27 -0
  80. package/dist/gasless/use-gasless-fee-quote.js.map +1 -0
  81. package/dist/gasless/use-gasless-relay-confirmation.d.ts +72 -0
  82. package/dist/gasless/use-gasless-relay-confirmation.d.ts.map +1 -0
  83. package/dist/gasless/use-gasless-relay-confirmation.js +148 -0
  84. package/dist/gasless/use-gasless-relay-confirmation.js.map +1 -0
  85. package/dist/gasless/use-gasless-request-stream.d.ts +34 -0
  86. package/dist/gasless/use-gasless-request-stream.d.ts.map +1 -0
  87. package/dist/gasless/use-gasless-request-stream.js +86 -0
  88. package/dist/gasless/use-gasless-request-stream.js.map +1 -0
  89. package/dist/gasless/use-gasless-request-transactions.d.ts +42 -0
  90. package/dist/gasless/use-gasless-request-transactions.d.ts.map +1 -0
  91. package/dist/gasless/use-gasless-request-transactions.js +28 -0
  92. package/dist/gasless/use-gasless-request-transactions.js.map +1 -0
  93. package/dist/gasless/use-gasless-request.d.ts +56 -0
  94. package/dist/gasless/use-gasless-request.d.ts.map +1 -0
  95. package/dist/gasless/use-gasless-request.js +51 -0
  96. package/dist/gasless/use-gasless-request.js.map +1 -0
  97. package/dist/gasless/use-gasless-wallet-address.d.ts +24 -0
  98. package/dist/gasless/use-gasless-wallet-address.d.ts.map +1 -0
  99. package/dist/gasless/use-gasless-wallet-address.js +27 -0
  100. package/dist/gasless/use-gasless-wallet-address.js.map +1 -0
  101. package/dist/gasless/use-gasless-wallet-creation-fee.d.ts +29 -0
  102. package/dist/gasless/use-gasless-wallet-creation-fee.d.ts.map +1 -0
  103. package/dist/gasless/use-gasless-wallet-creation-fee.js +27 -0
  104. package/dist/gasless/use-gasless-wallet-creation-fee.js.map +1 -0
  105. package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts +44 -0
  106. package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts.map +1 -0
  107. package/dist/gasless/use-gasless-wallet-execute-selectors.js +19 -0
  108. package/dist/gasless/use-gasless-wallet-execute-selectors.js.map +1 -0
  109. package/dist/gasless/use-gasless-wallet-execute.d.ts +51 -0
  110. package/dist/gasless/use-gasless-wallet-execute.d.ts.map +1 -0
  111. package/dist/gasless/use-gasless-wallet-execute.js +44 -0
  112. package/dist/gasless/use-gasless-wallet-execute.js.map +1 -0
  113. package/dist/gasless/use-gasless-wallet-nonce.d.ts +27 -0
  114. package/dist/gasless/use-gasless-wallet-nonce.d.ts.map +1 -0
  115. package/dist/gasless/use-gasless-wallet-nonce.js +27 -0
  116. package/dist/gasless/use-gasless-wallet-nonce.js.map +1 -0
  117. package/dist/gasless/use-operational-fee-allowance.d.ts +23 -0
  118. package/dist/gasless/use-operational-fee-allowance.d.ts.map +1 -0
  119. package/dist/gasless/use-operational-fee-allowance.js +27 -0
  120. package/dist/gasless/use-operational-fee-allowance.js.map +1 -0
  121. package/dist/gasless/use-relay-gasless-batch.d.ts +48 -0
  122. package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -0
  123. package/dist/gasless/use-relay-gasless-batch.js +44 -0
  124. package/dist/gasless/use-relay-gasless-batch.js.map +1 -0
  125. package/dist/gasless/use-relay-instant-operations.d.ts +43 -0
  126. package/dist/gasless/use-relay-instant-operations.d.ts.map +1 -0
  127. package/dist/gasless/use-relay-instant-operations.js +44 -0
  128. package/dist/gasless/use-relay-instant-operations.js.map +1 -0
  129. package/dist/gasless/use-resubmit-gasless-request.d.ts +39 -0
  130. package/dist/gasless/use-resubmit-gasless-request.d.ts.map +1 -0
  131. package/dist/gasless/use-resubmit-gasless-request.js +56 -0
  132. package/dist/gasless/use-resubmit-gasless-request.js.map +1 -0
  133. package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts +41 -0
  134. package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts.map +1 -0
  135. package/dist/gasless/use-settle-gasless-deposit-existing-account.js +47 -0
  136. package/dist/gasless/use-settle-gasless-deposit-existing-account.js.map +1 -0
  137. package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts +48 -0
  138. package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts.map +1 -0
  139. package/dist/gasless/use-settle-gasless-deposit-new-account.js +48 -0
  140. package/dist/gasless/use-settle-gasless-deposit-new-account.js.map +1 -0
  141. package/dist/gasless/use-supports-gasless-service.d.ts +22 -0
  142. package/dist/gasless/use-supports-gasless-service.d.ts.map +1 -0
  143. package/dist/gasless/use-supports-gasless-service.js +13 -0
  144. package/dist/gasless/use-supports-gasless-service.js.map +1 -0
  145. package/dist/index.d.ts +29 -11
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +251 -221
  148. package/dist/instant-layer/index.d.ts +7 -0
  149. package/dist/instant-layer/index.d.ts.map +1 -1
  150. package/dist/instant-layer/index.js +26 -19
  151. package/dist/instant-layer/use-active-delegations.d.ts +31 -0
  152. package/dist/instant-layer/use-active-delegations.d.ts.map +1 -0
  153. package/dist/instant-layer/use-active-delegations.js +23 -0
  154. package/dist/instant-layer/use-active-delegations.js.map +1 -0
  155. package/dist/instant-layer/use-are-delegations-active.d.ts +100 -0
  156. package/dist/instant-layer/use-are-delegations-active.d.ts.map +1 -0
  157. package/dist/instant-layer/use-are-delegations-active.js +60 -0
  158. package/dist/instant-layer/use-are-delegations-active.js.map +1 -0
  159. package/dist/instant-layer/use-finalize-revoke-delegation.d.ts +32 -0
  160. package/dist/instant-layer/use-finalize-revoke-delegation.d.ts.map +1 -0
  161. package/dist/instant-layer/use-finalize-revoke-delegation.js +45 -0
  162. package/dist/instant-layer/use-finalize-revoke-delegation.js.map +1 -0
  163. package/dist/instant-layer/use-grant-delegation.d.ts +12 -2
  164. package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
  165. package/dist/instant-layer/use-grant-delegation.js +27 -20
  166. package/dist/instant-layer/use-grant-delegation.js.map +1 -1
  167. package/dist/instant-layer/use-initiate-revoke-delegation.d.ts +32 -0
  168. package/dist/instant-layer/use-initiate-revoke-delegation.d.ts.map +1 -0
  169. package/dist/instant-layer/use-initiate-revoke-delegation.js +45 -0
  170. package/dist/instant-layer/use-initiate-revoke-delegation.js.map +1 -0
  171. package/dist/instant-layer/use-pending-revocation.d.ts +119 -0
  172. package/dist/instant-layer/use-pending-revocation.d.ts.map +1 -0
  173. package/dist/instant-layer/use-pending-revocation.js +73 -0
  174. package/dist/instant-layer/use-pending-revocation.js.map +1 -0
  175. package/dist/instant-layer/use-revocation-cooldown.d.ts +24 -0
  176. package/dist/instant-layer/use-revocation-cooldown.d.ts.map +1 -0
  177. package/dist/instant-layer/use-revocation-cooldown.js +23 -0
  178. package/dist/instant-layer/use-revocation-cooldown.js.map +1 -0
  179. package/dist/instant-layer/use-session-key-selectors.d.ts +53 -0
  180. package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -0
  181. package/dist/instant-layer/use-session-key-selectors.js +25 -0
  182. package/dist/instant-layer/use-session-key-selectors.js.map +1 -0
  183. package/dist/margin/use-available-instant-open-margin.js +8 -8
  184. package/dist/markets/index.d.ts +1 -0
  185. package/dist/markets/index.d.ts.map +1 -1
  186. package/dist/markets/index.js +3 -2
  187. package/dist/markets/use-funding-fees-of-party-b.d.ts +47 -0
  188. package/dist/markets/use-funding-fees-of-party-b.d.ts.map +1 -0
  189. package/dist/markets/use-funding-fees-of-party-b.js +27 -0
  190. package/dist/markets/use-funding-fees-of-party-b.js.map +1 -0
  191. package/dist/provider/create-session-key-wallet-client-resolver.d.ts +68 -0
  192. package/dist/provider/create-session-key-wallet-client-resolver.d.ts.map +1 -0
  193. package/dist/provider/create-session-key-wallet-client-resolver.js +51 -0
  194. package/dist/provider/create-session-key-wallet-client-resolver.js.map +1 -0
  195. package/dist/provider/index.d.ts +1 -0
  196. package/dist/provider/index.d.ts.map +1 -1
  197. package/dist/provider/index.js +5 -4
  198. package/dist/provider/symmio-provider.d.ts +7 -2
  199. package/dist/provider/symmio-provider.d.ts.map +1 -1
  200. package/dist/provider/symmio-provider.js +10 -7
  201. package/dist/provider/symmio-provider.js.map +1 -1
  202. package/dist/quotes/index.d.ts +2 -0
  203. package/dist/quotes/index.d.ts.map +1 -1
  204. package/dist/quotes/use-account-upnl.js +9 -9
  205. package/dist/quotes/use-close-quote-group.js +13 -13
  206. package/dist/quotes/use-force-cancel-close-request.d.ts.map +1 -1
  207. package/dist/quotes/use-force-cancel-close-request.js +1 -4
  208. package/dist/quotes/use-force-cancel-close-request.js.map +1 -1
  209. package/dist/quotes/use-force-cancel-quote.d.ts.map +1 -1
  210. package/dist/quotes/use-force-cancel-quote.js +1 -4
  211. package/dist/quotes/use-force-cancel-quote.js.map +1 -1
  212. package/dist/quotes/use-force-close.d.ts +2 -1
  213. package/dist/quotes/use-force-close.d.ts.map +1 -1
  214. package/dist/quotes/use-force-close.js +14 -12
  215. package/dist/quotes/use-force-close.js.map +1 -1
  216. package/dist/quotes/use-limit-orders.js +9 -9
  217. package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
  218. package/dist/quotes/use-managed-quotes.js +103 -103
  219. package/dist/quotes/use-managed-quotes.js.map +1 -1
  220. package/dist/quotes/use-party-a-open-positions.js +5 -5
  221. package/dist/quotes/use-quote-group-funding-history.d.ts +10 -7
  222. package/dist/quotes/use-quote-group-funding-history.d.ts.map +1 -1
  223. package/dist/quotes/use-quote-group-funding-history.js.map +1 -1
  224. package/dist/quotes/use-quote-group-funding.d.ts +4 -2
  225. package/dist/quotes/use-quote-group-funding.d.ts.map +1 -1
  226. package/dist/quotes/use-quote-group-funding.js.map +1 -1
  227. package/dist/quotes/use-quote-pending-funding.d.ts +62 -0
  228. package/dist/quotes/use-quote-pending-funding.d.ts.map +1 -0
  229. package/dist/quotes/use-quote-pending-funding.js +31 -0
  230. package/dist/quotes/use-quote-pending-funding.js.map +1 -0
  231. package/dist/quotes/use-quotes-funding.d.ts +4 -2
  232. package/dist/quotes/use-quotes-funding.d.ts.map +1 -1
  233. package/dist/quotes/use-quotes-funding.js.map +1 -1
  234. package/dist/quotes/use-quotes-pending-funding.d.ts +92 -0
  235. package/dist/quotes/use-quotes-pending-funding.d.ts.map +1 -0
  236. package/dist/quotes/use-quotes-pending-funding.js +94 -0
  237. package/dist/quotes/use-quotes-pending-funding.js.map +1 -0
  238. package/dist/quotes/use-request-to-cancel-close-request.d.ts.map +1 -1
  239. package/dist/quotes/use-request-to-cancel-close-request.js +1 -4
  240. package/dist/quotes/use-request-to-cancel-close-request.js.map +1 -1
  241. package/dist/quotes/use-request-to-cancel-quote.d.ts.map +1 -1
  242. package/dist/quotes/use-request-to-cancel-quote.js +1 -4
  243. package/dist/quotes/use-request-to-cancel-quote.js.map +1 -1
  244. package/dist/transactions/index.js +3 -3
  245. package/dist/transactions/resolve-write-result.d.ts +53 -2
  246. package/dist/transactions/resolve-write-result.d.ts.map +1 -1
  247. package/dist/transactions/resolve-write-result.js +52 -9
  248. package/dist/transactions/resolve-write-result.js.map +1 -1
  249. package/dist/transactions/write-types.d.ts +19 -1
  250. package/dist/transactions/write-types.d.ts.map +1 -1
  251. package/dist/utils/predicate-match.d.ts +7 -4
  252. package/dist/utils/predicate-match.d.ts.map +1 -1
  253. package/dist/utils/predicate-match.js +5 -5
  254. package/dist/utils/predicate-match.js.map +1 -1
  255. package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
  256. package/dist/withdraw/use-finalize-withdraw-request.js +1 -3
  257. package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
  258. package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
  259. package/dist/withdraw/use-initiate-withdraw.js +1 -5
  260. package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
  261. package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
  262. package/dist/withdraw/use-request-cancel-withdraw.js +1 -3
  263. package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
  264. package/dist/withdraw/use-withdraw.d.ts.map +1 -1
  265. package/dist/withdraw/use-withdraw.js +2 -1
  266. package/dist/withdraw/use-withdraw.js.map +1 -1
  267. package/package.json +6 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-initiate-revoke-delegation.js","names":[],"sources":["../../src/instant-layer/use-initiate-revoke-delegation.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getActiveDelegationsQueryKey,\n getDelegationExpiryQueryKey,\n getIsDelegationActiveQueryKey,\n getPendingRevocationEtasQueryKey,\n initiateRevokeDelegationMutationOptions,\n type InitiateRevokeDelegationParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/** Parameters for {@link useInitiateRevokeDelegation}. */\nexport type UseInitiateRevokeDelegationParameters = WriteParameters;\n\n/** Result returned by the {@link useInitiateRevokeDelegation} mutation. */\nexport type InitiateRevokeDelegationResult = WriteResult;\n\n/** Return type of {@link useInitiateRevokeDelegation}. */\nexport type UseInitiateRevokeDelegationReturnType = UseMutationResult<\n InitiateRevokeDelegationResult,\n SymmioRequestError,\n InitiateRevokeDelegationParameters\n>;\n\n/**\n * Start revoking a session key's Instant Layer delegation.\n *\n * **Always a gas-paid wallet transaction — there is no gasless option.** The\n * relay signs InstantLayer *operations*, and the contract accepts a\n * self-targeted operation only as a delegation grant, so a relayed revocation\n * would revert. Budget native gas for this call.\n *\n * The contract accepts it from the account owner, from the delegate itself, or\n * from a `REVOKER_ROLE` holder, and it only *schedules* the revocation: the key\n * keeps its authority until the cooldown ETA passes (see\n * {@link useRevocationCooldown}), after which {@link useFinalizeRevokeDelegation}\n * clears the stored grant.\n *\n * @example\n * ```tsx\n * const { mutate } = useInitiateRevokeDelegation();\n * mutate({ account: { addr: subAccount, isPartyB: false }, delegate: sessionKey, selectors });\n * ```\n */\nexport function useInitiateRevokeDelegation(\n parameters: UseInitiateRevokeDelegationParameters = {},\n): UseInitiateRevokeDelegationReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = initiateRevokeDelegationMutationOptions(config);\n\n return useMutation<InitiateRevokeDelegationResult, SymmioRequestError, InitiateRevokeDelegationParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const hash = await base.mutationFn(variables);\n return resolveWriteResult(config, hash, {\n chainId: variables.chainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_data, variables) => {\n const configKey = config.getChainConfigKey(variables.chainId ?? chainId);\n const delegation = { configKey, account: variables.account.addr, delegate: variables.delegate };\n\n void queryClient.invalidateQueries({ predicate: predicateMatch(getDelegationExpiryQueryKey, delegation) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getIsDelegationActiveQueryKey, delegation) });\n /**\n * The canonicalizing read keys by `delegator`, not `account`, so it needs\n * its own predicate rather than reusing the pair above.\n */\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getActiveDelegationsQueryKey, { configKey, delegator: variables.account }),\n });\n /**\n * The one read whose answer this write actually changes — the others keep\n * reporting the delegation as active until the cooldown ETA passes.\n */\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getPendingRevocationEtasQueryKey, {\n configKey,\n delegator: variables.account,\n delegate: variables.delegate,\n }),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;AAmDA,SAAgB,EACd,IAAoD,CAAC,GACd;CACvC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAwC,CAAM;CAE3D,OAAO,EAAoG;EACzG,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IAEF,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW,CAAS,GACJ;KACtC,SAAS,EAAU;KACnB,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAO,MAAc;GAC/B,IAAM,IAAY,EAAO,kBAAkB,EAAU,WAAW,CAAO,GACjE,IAAa;IAAE;IAAW,SAAS,EAAU,QAAQ;IAAM,UAAU,EAAU;GAAS;GAe9F,AAbA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAU,EAAE,CAAC,GACzG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAU,EAAE,CAAC,GAK3G,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA8B;IAAE;IAAW,WAAW,EAAU;GAAQ,CAAC,EACrG,CAAC,GAKD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAkC;IAC1D;IACA,WAAW,EAAU;IACrB,UAAU,EAAU;GACtB,CAAC,EACH,CAAC;EACH;CACF,CAAC;AACH"}
@@ -0,0 +1,119 @@
1
+ import { ConfigParameter, GetPendingRevocationEtasOptions, GetPendingRevocationEtasReturnType, InstantLayerAccount } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { Address, Hex } from 'viem';
4
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
5
+ /** Parameters for {@link usePendingRevocation}. */
6
+ export interface UsePendingRevocationParameters extends ConfigParameter {
7
+ /**
8
+ * Account the delegation is enforced under — pass the same account that was
9
+ * handed to `useInitiateRevokeDelegation`. Unlike {@link useAreDelegationsActive},
10
+ * the underlying read does **not** canonicalize a virtual account to its
11
+ * parent, because neither does the mapping it reads.
12
+ */
13
+ account: InstantLayerAccount;
14
+ /** Delegated signer being checked, typically the session key's address. */
15
+ delegate: Address;
16
+ /**
17
+ * Selectors to probe. Pass the **granted** set — the same one handed to
18
+ * `useSessionKeySelectors` / `useAreDelegationsActive` — not that hook's
19
+ * `activeSelectors`. Enforcement stops the moment the ETA passes, so
20
+ * `activeSelectors` empties out exactly when the revocation becomes
21
+ * finalizable, and probing it would hide the scheduled revocation at the one
22
+ * moment a UI needs it.
23
+ */
24
+ selectors: readonly Hex[];
25
+ /** Optional chain override; defaults to the config's chain. */
26
+ chainId?: number;
27
+ /** TanStack Query overrides for the underlying read. */
28
+ query?: GetPendingRevocationEtasOptions["query"];
29
+ }
30
+ /** Return type of {@link usePendingRevocation}. */
31
+ export interface UsePendingRevocationReturnType {
32
+ /**
33
+ * `true` while at least one probed selector has a scheduled revocation whose
34
+ * ETA has **not** passed — the key is still signing, but on its way out.
35
+ */
36
+ isRevoking: boolean;
37
+ /**
38
+ * The **latest** ETA across the scheduled selectors, as a Unix timestamp in
39
+ * seconds — the moment the key stops being able to sign anything at all.
40
+ * `undefined` when no revocation is scheduled.
41
+ */
42
+ etaTimestamp?: bigint;
43
+ /**
44
+ * Whole seconds left until {@link UsePendingRevocationReturnType.etaTimestamp},
45
+ * recomputed every second while the revocation counts down and clamped at `0`
46
+ * once it lands. `undefined` when no revocation is scheduled.
47
+ *
48
+ * This is the value to render as a live countdown: `etaTimestamp` alone is a
49
+ * fixed instant, so formatting it relatively (`"in 9m"`) looks frozen for a
50
+ * minute at a time.
51
+ */
52
+ secondsRemaining?: number;
53
+ /**
54
+ * Probed selectors with a scheduled revocation, in the order they were
55
+ * requested. A selector stays in this list after its ETA passes, until
56
+ * someone finalizes — it is scheduled either way, only no longer enforced.
57
+ */
58
+ revokingSelectors: readonly Hex[];
59
+ /**
60
+ * `true` when a revocation is scheduled and **every** scheduled ETA has
61
+ * passed, so `useFinalizeRevokeDelegation` will go through. Finalizing while
62
+ * any ETA is still in the future reverts with `RevocationCooldownNotOver`.
63
+ */
64
+ isFinalizable: boolean;
65
+ /** `true` while the underlying read is in flight. */
66
+ isLoading: boolean;
67
+ /** `true` when the underlying read failed. */
68
+ isError: boolean;
69
+ /** The read's error, if any. */
70
+ error: SymmioRequestError | null;
71
+ /** Refetch the underlying read — call it after an initiate or finalize settles. */
72
+ refetch: UseQueryResult<GetPendingRevocationEtasReturnType, SymmioRequestError>["refetch"];
73
+ /** The full underlying query result, for states this hook does not surface. */
74
+ query: UseQueryResult<GetPendingRevocationEtasReturnType, SymmioRequestError>;
75
+ }
76
+ /**
77
+ * "Is this key being revoked, and until when is it still live?" — the pending
78
+ * side of the two-step revocation, against a clock that ticks.
79
+ *
80
+ * **This is the only way to see a revocation in flight.** `initiateRevokeDelegation`
81
+ * does not clear the grant; it schedules one, and the contract keeps enforcing
82
+ * the delegation until the ETA passes. {@link useAreDelegationsActive} therefore
83
+ * keeps reporting the key as active for the whole cooldown — correctly, because
84
+ * it is. Pair the two: that hook answers "can it sign?", this one answers "is it
85
+ * on its way out, and when does that land?".
86
+ *
87
+ * The comparison runs against a 1-second clock that starts only while something
88
+ * is actually counting down and stops itself once the last ETA passes, so
89
+ * `isRevoking` flips to `false` and `isFinalizable` to `true` on their own —
90
+ * a finalize button gated on them enables itself without a refresh. That same
91
+ * clock drives `secondsRemaining`, so a live countdown needs no timer of its
92
+ * own.
93
+ *
94
+ * **Probe the granted selector set, not the active one.** A delegation stops
95
+ * being enforced at its ETA but stays scheduled until someone finalizes, so
96
+ * `useAreDelegationsActive`'s `activeSelectors` goes empty precisely when
97
+ * `isFinalizable` should turn `true`. Feeding that shrinking list back in here
98
+ * would disable a finalize button at the moment it becomes callable.
99
+ *
100
+ * The read is skipped entirely for an empty `selectors` list — there is nothing
101
+ * to probe — unless `query.enabled` says otherwise.
102
+ *
103
+ * @param parameters - Account, delegate, probed selectors, optional chain and query overrides.
104
+ * @returns Whether a revocation is pending, its ETA, the scheduled selectors, and the read's state.
105
+ *
106
+ * @example
107
+ * ```tsx
108
+ * const { isRevoking, etaTimestamp, isFinalizable } = usePendingRevocation({
109
+ * account: { addr: subAccount, isPartyB: false },
110
+ * delegate: sessionKeyAddress,
111
+ * selectors: grantedSelectors,
112
+ * });
113
+ *
114
+ * if (isRevoking) return <p>Revoking — still live until {formatTime(etaTimestamp)}</p>;
115
+ * return <button disabled={!isFinalizable}>Finalize revoke</button>;
116
+ * ```
117
+ */
118
+ export declare function usePendingRevocation(parameters: UsePendingRevocationParameters): UsePendingRevocationReturnType;
119
+ //# sourceMappingURL=use-pending-revocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pending-revocation.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-pending-revocation.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,mBAAmB,EACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,mDAAmD;AACnD,MAAM,WAAW,8BAA+B,SAAQ,eAAe;IACrE;;;;;OAKG;IACH,OAAO,EAAE,mBAAmB,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;;;OAOG;IACH,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC;IAC1B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,KAAK,CAAC,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;CAClD;AAED,mDAAmD;AACnD,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,EAAE,SAAS,GAAG,EAAE,CAAC;IAClC;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB,qDAAqD;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,mFAAmF;IACnF,OAAO,EAAE,cAAc,CAAC,kCAAkC,EAAE,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3F,+EAA+E;IAC/E,KAAK,EAAE,cAAc,CAAC,kCAAkC,EAAE,kBAAkB,CAAC,CAAC;CAC/E;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,8BAA8B,GAAG,8BAA8B,CA6E/G"}
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import { useSymmioConfig as e } from "../provider/use-symmio-config.js";
3
+ import { normalizeSymmError as t } from "../errors/normalize-symm-error.js";
4
+ import { getPendingRevocationEtasQueryOptions as n } from "@symmio/trading-core";
5
+ import { useEffect as r, useMemo as i, useState as a } from "react";
6
+ import { useQuery as o } from "@tanstack/react-query";
7
+ //#region src/instant-layer/use-pending-revocation.ts
8
+ var s = /* @__PURE__ */ new Map();
9
+ function c() {
10
+ return BigInt(Math.floor(Date.now() / 1e3));
11
+ }
12
+ function l(l) {
13
+ let u = e(l), { account: d, delegate: f, selectors: p, chainId: m, query: h } = l, g = n(u, {
14
+ delegator: d,
15
+ delegate: f,
16
+ selectors: p,
17
+ chainId: m,
18
+ query: {
19
+ ...h,
20
+ enabled: h?.enabled ?? p.length > 0
21
+ }
22
+ }), _ = o({
23
+ ...g,
24
+ queryFn: async () => {
25
+ try {
26
+ return await g.queryFn();
27
+ } catch (e) {
28
+ throw t(e);
29
+ }
30
+ }
31
+ }), { data: v, isLoading: y, isError: b, error: x, refetch: S } = _, C = v ?? s, w = i(() => p.filter((e) => C.has(e)), [p, C]), T = i(() => {
32
+ let e;
33
+ for (let t of C.values()) (e === void 0 || t > e) && (e = t);
34
+ return e;
35
+ }, [C]), [E, D] = a(c);
36
+ return r(() => {
37
+ if (T === void 0 || (D(c()), T <= c())) return;
38
+ let e = setInterval(() => {
39
+ let t = c();
40
+ D(t), t >= T && clearInterval(e);
41
+ }, 1e3);
42
+ return () => clearInterval(e);
43
+ }, [T]), i(() => {
44
+ let e = !1, t = C.size > 0;
45
+ for (let n of C.values()) n > E && (e = !0, t = !1);
46
+ return {
47
+ isRevoking: e,
48
+ etaTimestamp: T,
49
+ secondsRemaining: T === void 0 ? void 0 : Number(T > E ? T - E : 0n),
50
+ revokingSelectors: w,
51
+ isFinalizable: t,
52
+ isLoading: y,
53
+ isError: b,
54
+ error: x ?? null,
55
+ refetch: S,
56
+ query: _
57
+ };
58
+ }, [
59
+ C,
60
+ E,
61
+ T,
62
+ w,
63
+ y,
64
+ b,
65
+ x,
66
+ S,
67
+ _
68
+ ]);
69
+ }
70
+ //#endregion
71
+ export { l as usePendingRevocation };
72
+
73
+ //# sourceMappingURL=use-pending-revocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pending-revocation.js","names":[],"sources":["../../src/instant-layer/use-pending-revocation.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getPendingRevocationEtasQueryOptions,\n type ConfigParameter,\n type GetPendingRevocationEtasOptions,\n type GetPendingRevocationEtasReturnType,\n type InstantLayerAccount,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport type { Address, Hex } from \"viem\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link usePendingRevocation}. */\nexport interface UsePendingRevocationParameters extends ConfigParameter {\n /**\n * Account the delegation is enforced under — pass the same account that was\n * handed to `useInitiateRevokeDelegation`. Unlike {@link useAreDelegationsActive},\n * the underlying read does **not** canonicalize a virtual account to its\n * parent, because neither does the mapping it reads.\n */\n account: InstantLayerAccount;\n /** Delegated signer being checked, typically the session key's address. */\n delegate: Address;\n /**\n * Selectors to probe. Pass the **granted** set — the same one handed to\n * `useSessionKeySelectors` / `useAreDelegationsActive` — not that hook's\n * `activeSelectors`. Enforcement stops the moment the ETA passes, so\n * `activeSelectors` empties out exactly when the revocation becomes\n * finalizable, and probing it would hide the scheduled revocation at the one\n * moment a UI needs it.\n */\n selectors: readonly Hex[];\n /** Optional chain override; defaults to the config's chain. */\n chainId?: number;\n /** TanStack Query overrides for the underlying read. */\n query?: GetPendingRevocationEtasOptions[\"query\"];\n}\n\n/** Return type of {@link usePendingRevocation}. */\nexport interface UsePendingRevocationReturnType {\n /**\n * `true` while at least one probed selector has a scheduled revocation whose\n * ETA has **not** passed — the key is still signing, but on its way out.\n */\n isRevoking: boolean;\n /**\n * The **latest** ETA across the scheduled selectors, as a Unix timestamp in\n * seconds — the moment the key stops being able to sign anything at all.\n * `undefined` when no revocation is scheduled.\n */\n etaTimestamp?: bigint;\n /**\n * Whole seconds left until {@link UsePendingRevocationReturnType.etaTimestamp},\n * recomputed every second while the revocation counts down and clamped at `0`\n * once it lands. `undefined` when no revocation is scheduled.\n *\n * This is the value to render as a live countdown: `etaTimestamp` alone is a\n * fixed instant, so formatting it relatively (`\"in 9m\"`) looks frozen for a\n * minute at a time.\n */\n secondsRemaining?: number;\n /**\n * Probed selectors with a scheduled revocation, in the order they were\n * requested. A selector stays in this list after its ETA passes, until\n * someone finalizes — it is scheduled either way, only no longer enforced.\n */\n revokingSelectors: readonly Hex[];\n /**\n * `true` when a revocation is scheduled and **every** scheduled ETA has\n * passed, so `useFinalizeRevokeDelegation` will go through. Finalizing while\n * any ETA is still in the future reverts with `RevocationCooldownNotOver`.\n */\n isFinalizable: boolean;\n /** `true` while the underlying read is in flight. */\n isLoading: boolean;\n /** `true` when the underlying read failed. */\n isError: boolean;\n /** The read's error, if any. */\n error: SymmioRequestError | null;\n /** Refetch the underlying read — call it after an initiate or finalize settles. */\n refetch: UseQueryResult<GetPendingRevocationEtasReturnType, SymmioRequestError>[\"refetch\"];\n /** The full underlying query result, for states this hook does not surface. */\n query: UseQueryResult<GetPendingRevocationEtasReturnType, SymmioRequestError>;\n}\n\n/** Stable empty result so a pending read does not churn the memo's identity. */\nconst NO_ETAS: GetPendingRevocationEtasReturnType = new Map<Hex, bigint>();\n\n/** Current Unix time in seconds, the unit every on-chain timestamp uses. */\nfunction nowSeconds(): bigint {\n return BigInt(Math.floor(Date.now() / 1000));\n}\n\n/**\n * \"Is this key being revoked, and until when is it still live?\" — the pending\n * side of the two-step revocation, against a clock that ticks.\n *\n * **This is the only way to see a revocation in flight.** `initiateRevokeDelegation`\n * does not clear the grant; it schedules one, and the contract keeps enforcing\n * the delegation until the ETA passes. {@link useAreDelegationsActive} therefore\n * keeps reporting the key as active for the whole cooldown — correctly, because\n * it is. Pair the two: that hook answers \"can it sign?\", this one answers \"is it\n * on its way out, and when does that land?\".\n *\n * The comparison runs against a 1-second clock that starts only while something\n * is actually counting down and stops itself once the last ETA passes, so\n * `isRevoking` flips to `false` and `isFinalizable` to `true` on their own —\n * a finalize button gated on them enables itself without a refresh. That same\n * clock drives `secondsRemaining`, so a live countdown needs no timer of its\n * own.\n *\n * **Probe the granted selector set, not the active one.** A delegation stops\n * being enforced at its ETA but stays scheduled until someone finalizes, so\n * `useAreDelegationsActive`'s `activeSelectors` goes empty precisely when\n * `isFinalizable` should turn `true`. Feeding that shrinking list back in here\n * would disable a finalize button at the moment it becomes callable.\n *\n * The read is skipped entirely for an empty `selectors` list — there is nothing\n * to probe — unless `query.enabled` says otherwise.\n *\n * @param parameters - Account, delegate, probed selectors, optional chain and query overrides.\n * @returns Whether a revocation is pending, its ETA, the scheduled selectors, and the read's state.\n *\n * @example\n * ```tsx\n * const { isRevoking, etaTimestamp, isFinalizable } = usePendingRevocation({\n * account: { addr: subAccount, isPartyB: false },\n * delegate: sessionKeyAddress,\n * selectors: grantedSelectors,\n * });\n *\n * if (isRevoking) return <p>Revoking — still live until {formatTime(etaTimestamp)}</p>;\n * return <button disabled={!isFinalizable}>Finalize revoke</button>;\n * ```\n */\nexport function usePendingRevocation(parameters: UsePendingRevocationParameters): UsePendingRevocationReturnType {\n const config = useSymmioConfig(parameters);\n const { account, delegate, selectors, chainId, query } = parameters;\n\n const options = getPendingRevocationEtasQueryOptions(config, {\n delegator: account,\n delegate,\n selectors,\n chainId,\n query: { ...query, enabled: query?.enabled ?? selectors.length > 0 },\n });\n\n const result = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<GetPendingRevocationEtasReturnType, SymmioRequestError>;\n\n const { data, isLoading, isError, error, refetch } = result;\n const etas = data ?? NO_ETAS;\n\n const revokingSelectors = useMemo(() => selectors.filter((selector) => etas.has(selector)), [selectors, etas]);\n const etaTimestamp = useMemo(() => {\n let latest: bigint | undefined;\n for (const eta of etas.values()) if (latest === undefined || eta > latest) latest = eta;\n return latest;\n }, [etas]);\n\n const [now, setNow] = useState(nowSeconds);\n\n /**\n * Re-key the clock on the deadline itself: it resyncs the moment a new ETA\n * arrives (the read can resolve long after mount, leaving `now` stale), ticks\n * only while that deadline is in the future, and clears itself once it\n * passes — a scheduled-but-elapsed revocation never leaves a timer running.\n */\n useEffect(() => {\n if (etaTimestamp === undefined) return;\n setNow(nowSeconds());\n if (etaTimestamp <= nowSeconds()) return;\n\n const id = setInterval(() => {\n const current = nowSeconds();\n setNow(current);\n if (current >= etaTimestamp) clearInterval(id);\n }, 1000);\n return () => clearInterval(id);\n }, [etaTimestamp]);\n\n return useMemo<UsePendingRevocationReturnType>(() => {\n let isRevoking = false;\n let allElapsed = etas.size > 0;\n for (const eta of etas.values()) {\n if (eta > now) {\n isRevoking = true;\n allElapsed = false;\n }\n }\n\n return {\n isRevoking,\n etaTimestamp,\n secondsRemaining: etaTimestamp === undefined ? undefined : Number(etaTimestamp > now ? etaTimestamp - now : 0n),\n revokingSelectors,\n isFinalizable: allElapsed,\n isLoading,\n isError,\n error: error ?? null,\n refetch,\n query: result,\n };\n }, [etas, now, etaTimestamp, revokingSelectors, isLoading, isError, error, refetch, result]);\n}\n"],"mappings":";;;;;;;AA0FA,IAAM,oBAA8C,IAAI,IAAiB;AAGzE,SAAS,IAAqB;CAC5B,OAAO,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,CAAC;AAC7C;AA4CA,SAAgB,EAAqB,GAA4E;CAC/G,IAAM,IAAS,EAAgB,CAAU,GACnC,EAAE,YAAS,aAAU,cAAW,YAAS,aAAU,GAEnD,IAAU,EAAqC,GAAQ;EAC3D,WAAW;EACX;EACA;EACA;EACA,OAAO;GAAE,GAAG;GAAO,SAAS,GAAO,WAAW,EAAU,SAAS;EAAE;CACrE,CAAC,GAEK,IAAS,EAAS;EACtB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC,GAEK,EAAE,SAAM,cAAW,YAAS,UAAO,eAAY,GAC/C,IAAO,KAAQ,GAEf,IAAoB,QAAc,EAAU,QAAQ,MAAa,EAAK,IAAI,CAAQ,CAAC,GAAG,CAAC,GAAW,CAAI,CAAC,GACvG,IAAe,QAAc;EACjC,IAAI;EACJ,KAAK,IAAM,KAAO,EAAK,OAAO,GAAG,CAAI,MAAW,KAAA,KAAa,IAAM,OAAQ,IAAS;EACpF,OAAO;CACT,GAAG,CAAC,CAAI,CAAC,GAEH,CAAC,GAAK,KAAU,EAAS,CAAU;CAqBzC,OAbA,QAAgB;EAGd,IAFI,MAAiB,KAAA,MACrB,EAAO,EAAW,CAAC,GACf,KAAgB,EAAW,IAAG;EAElC,IAAM,IAAK,kBAAkB;GAC3B,IAAM,IAAU,EAAW;GAE3B,AADA,EAAO,CAAO,GACV,KAAW,KAAc,cAAc,CAAE;EAC/C,GAAG,GAAI;EACP,aAAa,cAAc,CAAE;CAC/B,GAAG,CAAC,CAAY,CAAC,GAEV,QAA8C;EACnD,IAAI,IAAa,IACb,IAAa,EAAK,OAAO;EAC7B,KAAK,IAAM,KAAO,EAAK,OAAO,GAC5B,AAAI,IAAM,MACR,IAAa,IACb,IAAa;EAIjB,OAAO;GACL;GACA;GACA,kBAAkB,MAAiB,KAAA,IAAY,KAAA,IAAY,OAAO,IAAe,IAAM,IAAe,IAAM,EAAE;GAC9G;GACA,eAAe;GACf;GACA;GACA,OAAO,KAAS;GAChB;GACA,OAAO;EACT;CACF,GAAG;EAAC;EAAM;EAAK;EAAc;EAAmB;EAAW;EAAS;EAAO;EAAS;CAAM,CAAC;AAC7F"}
@@ -0,0 +1,24 @@
1
+ import { ConfigParameter, GetRevocationCooldownOptions, GetRevocationCooldownReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Parameters for {@link useRevocationCooldown}: an optional chain id and
6
+ * TanStack `query` overrides, plus an optional `config`.
7
+ */
8
+ export type UseRevocationCooldownParameters = GetRevocationCooldownOptions & ConfigParameter;
9
+ /** Return type of {@link useRevocationCooldown}. */
10
+ export type UseRevocationCooldownReturnType = UseQueryResult<GetRevocationCooldownReturnType, SymmioRequestError>;
11
+ /**
12
+ * Read the Instant Layer's delegation revocation cooldown, in seconds.
13
+ *
14
+ * This is the delay between {@link useInitiateRevokeDelegation} and the moment
15
+ * the delegation stops being enforced — surface it so a UI can tell the user
16
+ * how long a revoked key stays live.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const { data: cooldownSeconds } = useRevocationCooldown();
21
+ * ```
22
+ */
23
+ export declare function useRevocationCooldown(parameters?: UseRevocationCooldownParameters): UseRevocationCooldownReturnType;
24
+ //# sourceMappingURL=use-revocation-cooldown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-revocation-cooldown.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-revocation-cooldown.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,4BAA4B,GAAG,eAAe,CAAC;AAE7F,oDAAoD;AACpD,MAAM,MAAM,+BAA+B,GAAG,cAAc,CAAC,+BAA+B,EAAE,kBAAkB,CAAC,CAAC;AAElH;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,GAAE,+BAAoC,GAC/C,+BAA+B,CAcjC"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useSymmioConfig as e } from "../provider/use-symmio-config.js";
3
+ import { normalizeSymmError as t } from "../errors/normalize-symm-error.js";
4
+ import { getRevocationCooldownQueryOptions as n } from "@symmio/trading-core";
5
+ import { useQuery as r } from "@tanstack/react-query";
6
+ //#region src/instant-layer/use-revocation-cooldown.ts
7
+ function i(i = {}) {
8
+ let a = n(e(i), i);
9
+ return r({
10
+ ...a,
11
+ queryFn: async () => {
12
+ try {
13
+ return await a.queryFn();
14
+ } catch (e) {
15
+ throw t(e);
16
+ }
17
+ }
18
+ });
19
+ }
20
+ //#endregion
21
+ export { i as useRevocationCooldown };
22
+
23
+ //# sourceMappingURL=use-revocation-cooldown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-revocation-cooldown.js","names":[],"sources":["../../src/instant-layer/use-revocation-cooldown.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getRevocationCooldownQueryOptions,\n type ConfigParameter,\n type GetRevocationCooldownOptions,\n type GetRevocationCooldownReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useRevocationCooldown}: an optional chain id and\n * TanStack `query` overrides, plus an optional `config`.\n */\nexport type UseRevocationCooldownParameters = GetRevocationCooldownOptions & ConfigParameter;\n\n/** Return type of {@link useRevocationCooldown}. */\nexport type UseRevocationCooldownReturnType = UseQueryResult<GetRevocationCooldownReturnType, SymmioRequestError>;\n\n/**\n * Read the Instant Layer's delegation revocation cooldown, in seconds.\n *\n * This is the delay between {@link useInitiateRevokeDelegation} and the moment\n * the delegation stops being enforced — surface it so a UI can tell the user\n * how long a revoked key stays live.\n *\n * @example\n * ```tsx\n * const { data: cooldownSeconds } = useRevocationCooldown();\n * ```\n */\nexport function useRevocationCooldown(\n parameters: UseRevocationCooldownParameters = {},\n): UseRevocationCooldownReturnType {\n const config = useSymmioConfig(parameters);\n const options = getRevocationCooldownQueryOptions(config, parameters);\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseRevocationCooldownReturnType;\n}\n"],"mappings":";;;;;;AAkCA,SAAgB,EACd,IAA8C,CAAC,GACd;CAEjC,IAAM,IAAU,EADD,EAAgB,CACmB,GAAQ,CAAU;CAEpE,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,53 @@
1
+ import { ConfigParameter, SessionKeySelectorScope } from '@symmio/trading-core';
2
+ import { Hex } from 'viem';
3
+ /** Parameters for {@link useSessionKeySelectors}: the target chain plus the authority scope. */
4
+ export interface UseSessionKeySelectorsParameters extends ConfigParameter, SessionKeySelectorScope {
5
+ /** Chain to resolve the selector set for; defaults to the connected chain. */
6
+ chainId?: number;
7
+ }
8
+ /** Return type of {@link useSessionKeySelectors}: the de-duplicated selector set to grant. */
9
+ export type UseSessionKeySelectorsReturnType = readonly Hex[];
10
+ /**
11
+ * **The** selector set to hand a session key — the set to pass to
12
+ * `useGrantDelegation` (and to `useAreDelegationsActive` when checking whether
13
+ * that key is still usable). It resolves the chain's contracts generation, so a
14
+ * multi-chain app never grants the other generation's open-leg selector.
15
+ *
16
+ * The default scope is the onboarding grant: the instant trade lifecycle plus
17
+ * gasless account management. Because the contract enforces that
18
+ * `grantDelegation` is owner-only, that single grant is the *only* wallet
19
+ * prompt a session key ever costs — every write it covers afterwards is
20
+ * promptless and gas-free.
21
+ *
22
+ * `initiateWithdraw` is **opt-out by default** (`withdraw` defaults to
23
+ * `false`): its calldata carries a caller-supplied `receiver`, so a key holding
24
+ * it can send the sub-account's collateral to an address of its own choosing.
25
+ * Pass `withdraw: true` only for a key that must run withdrawals unattended,
26
+ * and treat it as a materially larger grant.
27
+ *
28
+ * The result is referentially stable across renders while the chain and scope
29
+ * flags do not change, so it is safe to pass straight into a mutation's
30
+ * variables or another hook's parameters.
31
+ *
32
+ * @param parameters - Optional chain override, scope flags, and `config`.
33
+ * @returns The lowercase, de-duplicated selector set for the requested scope.
34
+ * @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.
35
+ * @throws {SymmError} `GASLESS_UNSUPPORTED_CONTRACTS_VERSION` when the `account`
36
+ * or `withdraw` scope is requested on a chain whose contracts are not
37
+ * `"0.8.6"`. Render a trade-only key there with `{ account: false }`.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * const selectors = useSessionKeySelectors();
42
+ * const { mutate } = useGrantDelegation();
43
+ * mutate({ account: { addr: subAccount, isPartyB: false }, delegatedSigner, selectors, expiryTimestamp });
44
+ * ```
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * // A key that also withdraws unattended — it can move the collateral out.
49
+ * const selectors = useSessionKeySelectors({ withdraw: true });
50
+ * ```
51
+ */
52
+ export declare function useSessionKeySelectors(parameters?: UseSessionKeySelectorsParameters): UseSessionKeySelectorsReturnType;
53
+ //# sourceMappingURL=use-session-key-selectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-session-key-selectors.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-session-key-selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIhC,gGAAgG;AAChG,MAAM,WAAW,gCAAiC,SAAQ,eAAe,EAAE,uBAAuB;IAChG,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8FAA8F;AAC9F,MAAM,MAAM,gCAAgC,GAAG,SAAS,GAAG,EAAE,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,gCAAqC,GAChD,gCAAgC,CAUlC"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { getSessionKeySelectors as n } from "@symmio/trading-core";
5
+ import { useMemo as r } from "react";
6
+ //#region src/instant-layer/use-session-key-selectors.ts
7
+ function i(i = {}) {
8
+ let a = t(i), o = e(), { trade: s, account: c, withdraw: l } = i, u = i.chainId ?? o;
9
+ return r(() => n(a, {
10
+ chainId: u,
11
+ trade: s,
12
+ account: c,
13
+ withdraw: l
14
+ }), [
15
+ a,
16
+ u,
17
+ s,
18
+ c,
19
+ l
20
+ ]);
21
+ }
22
+ //#endregion
23
+ export { i as useSessionKeySelectors };
24
+
25
+ //# sourceMappingURL=use-session-key-selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-session-key-selectors.js","names":[],"sources":["../../src/instant-layer/use-session-key-selectors.ts"],"sourcesContent":["\"use client\";\n\nimport { getSessionKeySelectors, type ConfigParameter, type SessionKeySelectorScope } from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Hex } from \"viem\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSessionKeySelectors}: the target chain plus the authority scope. */\nexport interface UseSessionKeySelectorsParameters extends ConfigParameter, SessionKeySelectorScope {\n /** Chain to resolve the selector set for; defaults to the connected chain. */\n chainId?: number;\n}\n\n/** Return type of {@link useSessionKeySelectors}: the de-duplicated selector set to grant. */\nexport type UseSessionKeySelectorsReturnType = readonly Hex[];\n\n/**\n * **The** selector set to hand a session key — the set to pass to\n * `useGrantDelegation` (and to `useAreDelegationsActive` when checking whether\n * that key is still usable). It resolves the chain's contracts generation, so a\n * multi-chain app never grants the other generation's open-leg selector.\n *\n * The default scope is the onboarding grant: the instant trade lifecycle plus\n * gasless account management. Because the contract enforces that\n * `grantDelegation` is owner-only, that single grant is the *only* wallet\n * prompt a session key ever costs — every write it covers afterwards is\n * promptless and gas-free.\n *\n * `initiateWithdraw` is **opt-out by default** (`withdraw` defaults to\n * `false`): its calldata carries a caller-supplied `receiver`, so a key holding\n * it can send the sub-account's collateral to an address of its own choosing.\n * Pass `withdraw: true` only for a key that must run withdrawals unattended,\n * and treat it as a materially larger grant.\n *\n * The result is referentially stable across renders while the chain and scope\n * flags do not change, so it is safe to pass straight into a mutation's\n * variables or another hook's parameters.\n *\n * @param parameters - Optional chain override, scope flags, and `config`.\n * @returns The lowercase, de-duplicated selector set for the requested scope.\n * @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.\n * @throws {SymmError} `GASLESS_UNSUPPORTED_CONTRACTS_VERSION` when the `account`\n * or `withdraw` scope is requested on a chain whose contracts are not\n * `\"0.8.6\"`. Render a trade-only key there with `{ account: false }`.\n *\n * @example\n * ```tsx\n * const selectors = useSessionKeySelectors();\n * const { mutate } = useGrantDelegation();\n * mutate({ account: { addr: subAccount, isPartyB: false }, delegatedSigner, selectors, expiryTimestamp });\n * ```\n *\n * @example\n * ```tsx\n * // A key that also withdraws unattended — it can move the collateral out.\n * const selectors = useSessionKeySelectors({ withdraw: true });\n * ```\n */\nexport function useSessionKeySelectors(\n parameters: UseSessionKeySelectorsParameters = {},\n): UseSessionKeySelectorsReturnType {\n const config = useSymmioConfig(parameters);\n const connectedChainId = useSymmioChainId();\n const { trade, account, withdraw } = parameters;\n const chainId = parameters.chainId ?? connectedChainId;\n\n return useMemo(\n () => getSessionKeySelectors(config, { chainId, trade, account, withdraw }),\n [config, chainId, trade, account, withdraw],\n );\n}\n"],"mappings":";;;;;;AA2DA,SAAgB,EACd,IAA+C,CAAC,GACd;CAClC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAmB,EAAiB,GACpC,EAAE,UAAO,YAAS,gBAAa,GAC/B,IAAU,EAAW,WAAW;CAEtC,OAAO,QACC,EAAuB,GAAQ;EAAE;EAAS;EAAO;EAAS;CAAS,CAAC,GAC1E;EAAC;EAAQ;EAAS;EAAO;EAAS;CAAQ,CAC5C;AACF"}
@@ -6,8 +6,8 @@ import { useSubAccount as r } from "../account-layer/use-sub-account.js";
6
6
  import { useFeeForUser as i } from "../fees/use-fee-for-user.js";
7
7
  import { useAccountUpnl as a } from "../quotes/use-account-upnl.js";
8
8
  import { SubAccountIsolationType as o, calculateAvailableForOrder as s, calculateAvailableInstantOpenMargin as c } from "@symmio/trading-core";
9
- import { useCallback as l, useMemo as u } from "react";
10
- import { formatUnits as d, zeroAddress as f } from "viem";
9
+ import { formatUnits as l, zeroAddress as u } from "viem";
10
+ import { useCallback as d, useMemo as f } from "react";
11
11
  //#region src/margin/use-available-instant-open-margin.ts
12
12
  function p(e) {
13
13
  return BigInt(Math.round(e * 0x2386f26fc10000));
@@ -18,7 +18,7 @@ function h(h) {
18
18
  chainId: S,
19
19
  solverId: x
20
20
  }).id === "rasa", T = r({
21
- account: g ?? f,
21
+ account: g ?? u,
22
22
  chainId: S,
23
23
  config: C,
24
24
  query: {
@@ -32,7 +32,7 @@ function h(h) {
32
32
  live: !0,
33
33
  query: { enabled: D && !O }
34
34
  }), A = i({
35
- user: g ?? f,
35
+ user: g ?? u,
36
36
  symbolId: _ ?? 0,
37
37
  chainId: S,
38
38
  config: C,
@@ -50,7 +50,7 @@ function h(h) {
50
50
  config: C,
51
51
  enabled: O,
52
52
  live: !0
53
- }), { data: N, isLoading: P, error: F, refetch: I } = k, { data: L, isLoading: R, error: z, refetch: B } = A, { data: V, isLoading: H, error: U, refetch: W } = j, { upnl: G, isLoading: K, refetch: q } = M, J = l(async () => {
53
+ }), { data: N, isLoading: P, error: F, refetch: I } = k, { data: L, isLoading: R, error: z, refetch: B } = A, { data: V, isLoading: H, error: U, refetch: W } = j, { upnl: G, isLoading: K, refetch: q } = M, J = d(async () => {
54
54
  if (O) {
55
55
  await Promise.all([W(), q()]);
56
56
  return;
@@ -63,7 +63,7 @@ function h(h) {
63
63
  W,
64
64
  q
65
65
  ]);
66
- return u(() => {
66
+ return f(() => {
67
67
  let e = !!g && !D;
68
68
  if (O) {
69
69
  let e = H || K, t = U ?? null;
@@ -80,7 +80,7 @@ function h(h) {
80
80
  }), r = n > 0n ? n : 0n, i = w ? r * m / 10000n : r;
81
81
  return {
82
82
  availableMarginWei: i,
83
- availableMargin: d(i, 18),
83
+ availableMargin: l(i, 18),
84
84
  isLoading: e,
85
85
  error: t,
86
86
  refetch: J
@@ -104,7 +104,7 @@ function h(h) {
104
104
  });
105
105
  return {
106
106
  availableMarginWei: r,
107
- availableMargin: d(r, 18),
107
+ availableMargin: l(r, 18),
108
108
  isLoading: t,
109
109
  error: n,
110
110
  refetch: J
@@ -1,3 +1,4 @@
1
+ export * from './use-funding-fees-of-party-b.js';
1
2
  export * from './use-markets.js';
2
3
  export * from './use-onchain-contract-markets.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markets/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markets/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,gCAAgC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import { useMarkets as e } from "./use-markets.js";
2
- import { useOnchainContractMarkets as t } from "./use-onchain-contract-markets.js";
3
- export { e as useMarkets, t as useOnchainContractMarkets };
2
+ import { useFundingFeesOfPartyB as t } from "./use-funding-fees-of-party-b.js";
3
+ import { useOnchainContractMarkets as n } from "./use-onchain-contract-markets.js";
4
+ export { t as useFundingFeesOfPartyB, e as useMarkets, n as useOnchainContractMarkets };
@@ -0,0 +1,47 @@
1
+ import { ConfigParameter, GetFundingFeesOfPartyBOptions, GetFundingFeesOfPartyBReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Parameters for {@link useFundingFeesOfPartyB}: the core query options (symbol
6
+ * id, partyB, chain id, TanStack `query` overrides) plus an optional `config`.
7
+ */
8
+ export type UseFundingFeesOfPartyBParameters = GetFundingFeesOfPartyBOptions & ConfigParameter;
9
+ /** Return type of {@link useFundingFeesOfPartyB}. */
10
+ export type UseFundingFeesOfPartyBReturnType = UseQueryResult<GetFundingFeesOfPartyBReturnType, SymmioRequestError>;
11
+ /**
12
+ * Read the accumulated-funding state a solver (partyB) keeps for one symbol —
13
+ * the SYMMIO core diamond's `FundingFee` struct: current and weighted-average
14
+ * rates, epoch tracking and carried-over fee snapshots.
15
+ *
16
+ * Values are the raw contract values: rates are **cost-positive** (a positive
17
+ * long/short value means that side pays), the opposite of the SDK's
18
+ * income-positive funding amounts. `epochDuration === 0n` means accumulated
19
+ * funding is not configured for the pair; `startEpoch === 0n` and
20
+ * `startEpochTimeStamp === 0n` with a duration set mean it is configured but has
21
+ * not started; otherwise the pair accrues — read the per-quote amount with
22
+ * {@link useQuotesPendingFunding}.
23
+ *
24
+ * Delegates to core's `getFundingFeesOfPartyB`. Does not poll by default; pass
25
+ * `query.refetchInterval` to keep it fresh. `chainId` defaults to the connected
26
+ * chain. Errors are normalized to {@link SymmioRequestError}.
27
+ *
28
+ * @param parameters - Symbol id, partyB, optional chain id, TanStack `query` overrides and `config`.
29
+ * @returns A TanStack query result holding the pair's `FundingFee` state.
30
+ *
31
+ * A quote only has a `partyB` once a solver has locked it, so read the pair off
32
+ * an on-chain quote (or the solver you target) and gate the query while it is
33
+ * still missing.
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * const { data: quote } = useQuote({ quoteId: 7334n });
38
+ * const { data: fee } = useFundingFeesOfPartyB({
39
+ * symbolId: quote?.symbolId ?? 0n,
40
+ * partyB: quote?.partyB ?? zeroAddress,
41
+ * query: { enabled: quote !== undefined && quote !== null },
42
+ * });
43
+ * const accruing = fee !== undefined && fee.epochDuration > 0n && (fee.startEpoch !== 0n || fee.startEpochTimeStamp !== 0n);
44
+ * ```
45
+ */
46
+ export declare function useFundingFeesOfPartyB(parameters: UseFundingFeesOfPartyBParameters): UseFundingFeesOfPartyBReturnType;
47
+ //# sourceMappingURL=use-funding-fees-of-party-b.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-funding-fees-of-party-b.d.ts","sourceRoot":"","sources":["../../src/markets/use-funding-fees-of-party-b.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACtC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,gCAAgC,GAAG,6BAA6B,GAAG,eAAe,CAAC;AAE/F,qDAAqD;AACrD,MAAM,MAAM,gCAAgC,GAAG,cAAc,CAAC,gCAAgC,EAAE,kBAAkB,CAAC,CAAC;AAEpH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,gCAAgC,GAAG,gCAAgC,CAkBrH"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { getFundingFeesOfPartyBQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/markets/use-funding-fees-of-party-b.ts
8
+ function a(a) {
9
+ let o = t(a), s = e(), c = r(o, {
10
+ ...a,
11
+ chainId: a.chainId ?? s
12
+ });
13
+ return i({
14
+ ...c,
15
+ queryFn: async () => {
16
+ try {
17
+ return await c.queryFn();
18
+ } catch (e) {
19
+ throw n(e);
20
+ }
21
+ }
22
+ });
23
+ }
24
+ //#endregion
25
+ export { a as useFundingFeesOfPartyB };
26
+
27
+ //# sourceMappingURL=use-funding-fees-of-party-b.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-funding-fees-of-party-b.js","names":[],"sources":["../../src/markets/use-funding-fees-of-party-b.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getFundingFeesOfPartyBQueryOptions,\n type ConfigParameter,\n type GetFundingFeesOfPartyBOptions,\n type GetFundingFeesOfPartyBReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useFundingFeesOfPartyB}: the core query options (symbol\n * id, partyB, chain id, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseFundingFeesOfPartyBParameters = GetFundingFeesOfPartyBOptions & ConfigParameter;\n\n/** Return type of {@link useFundingFeesOfPartyB}. */\nexport type UseFundingFeesOfPartyBReturnType = UseQueryResult<GetFundingFeesOfPartyBReturnType, SymmioRequestError>;\n\n/**\n * Read the accumulated-funding state a solver (partyB) keeps for one symbol —\n * the SYMMIO core diamond's `FundingFee` struct: current and weighted-average\n * rates, epoch tracking and carried-over fee snapshots.\n *\n * Values are the raw contract values: rates are **cost-positive** (a positive\n * long/short value means that side pays), the opposite of the SDK's\n * income-positive funding amounts. `epochDuration === 0n` means accumulated\n * funding is not configured for the pair; `startEpoch === 0n` and\n * `startEpochTimeStamp === 0n` with a duration set mean it is configured but has\n * not started; otherwise the pair accrues — read the per-quote amount with\n * {@link useQuotesPendingFunding}.\n *\n * Delegates to core's `getFundingFeesOfPartyB`. Does not poll by default; pass\n * `query.refetchInterval` to keep it fresh. `chainId` defaults to the connected\n * chain. Errors are normalized to {@link SymmioRequestError}.\n *\n * @param parameters - Symbol id, partyB, optional chain id, TanStack `query` overrides and `config`.\n * @returns A TanStack query result holding the pair's `FundingFee` state.\n *\n * A quote only has a `partyB` once a solver has locked it, so read the pair off\n * an on-chain quote (or the solver you target) and gate the query while it is\n * still missing.\n *\n * @example\n * ```tsx\n * const { data: quote } = useQuote({ quoteId: 7334n });\n * const { data: fee } = useFundingFeesOfPartyB({\n * symbolId: quote?.symbolId ?? 0n,\n * partyB: quote?.partyB ?? zeroAddress,\n * query: { enabled: quote !== undefined && quote !== null },\n * });\n * const accruing = fee !== undefined && fee.epochDuration > 0n && (fee.startEpoch !== 0n || fee.startEpochTimeStamp !== 0n);\n * ```\n */\nexport function useFundingFeesOfPartyB(parameters: UseFundingFeesOfPartyBParameters): UseFundingFeesOfPartyBReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getFundingFeesOfPartyBQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseFundingFeesOfPartyBReturnType;\n}\n"],"mappings":";;;;;;;AA0DA,SAAgB,EAAuB,GAAgF;CACrH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAmC,GAAQ;EACzD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,68 @@
1
+ import { GetWalletClientFn } from '@symmio/trading-core';
2
+ import { Account, Transport } from 'viem';
3
+ import { Config as WagmiConfig } from 'wagmi';
4
+ /**
5
+ * Parameters for {@link createSessionKeyWalletClientResolver}.
6
+ */
7
+ export interface CreateSessionKeyWalletClientResolverParameters {
8
+ /** Returns the session-key account to sign with, or null when no key is loaded. */
9
+ getSessionAccount: () => Account | null;
10
+ /** The wagmi config used to resolve the connected wallet and the target chain. */
11
+ wagmiConfig: WagmiConfig;
12
+ /** Optional per-chain transport override for the session-key client. Defaults to wagmi's transport for that chain. */
13
+ transport?: (chainId: number) => Transport;
14
+ }
15
+ /**
16
+ * Build a {@link GetWalletClientFn} that routes the SDK's `from` hint to a
17
+ * session-key signer, falling back to the wagmi-connected wallet.
18
+ *
19
+ * Pass the result as `SymmioProvider`'s `getWalletClient` prop. Every SDK write
20
+ * that can be relayed gaslessly asks the resolver for a signer and passes the
21
+ * `from` address it wants; with this resolver installed, a `from` that matches
22
+ * the loaded session key is signed in-memory with **no wallet prompt**, while
23
+ * any other `from` (typically the account owner) keeps using the connected
24
+ * wallet.
25
+ *
26
+ * The session-key client is bound to the transport the host configured in wagmi
27
+ * for that chain, so it uses the app's RPCs rather than viem's public defaults.
28
+ *
29
+ * Unlike the provider's default resolver, an unresolvable `from` is a loud
30
+ * error: it never falls back to prompting the connected wallet, because the
31
+ * owner is also authorized on-chain and the write would silently succeed with
32
+ * the wrong signer.
33
+ *
34
+ * The factory takes a `getSessionAccount` callback rather than a session-key
35
+ * manager on purpose — `@symmio/trading-react` must not depend on
36
+ * `@symmio/session-key`, and the callback is read fresh on every call so
37
+ * loading, rotating, or clearing the key needs no new resolver.
38
+ *
39
+ * @param parameters - See {@link CreateSessionKeyWalletClientResolverParameters}.
40
+ * @returns A resolver suitable for `SymmioProvider`'s `getWalletClient` prop.
41
+ * @throws {SymmError} `UNSUPPORTED_CHAIN` when the requested chain is not in the
42
+ * wagmi config, `SESSION_SIGNER_UNAVAILABLE` when `from` matches neither the
43
+ * loaded session key nor the connected wallet, and `NO_WALLET_CONNECTED` when
44
+ * the fallback path finds no connected wallet.
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * function Providers({ children }: { children: ReactNode }) {
49
+ * const wagmiConfig = useConfig();
50
+ * const getWalletClient = useMemo(
51
+ * () =>
52
+ * createSessionKeyWalletClientResolver({
53
+ * wagmiConfig,
54
+ * getSessionAccount: () => sessionKeyManager.getAccount(),
55
+ * }),
56
+ * [wagmiConfig],
57
+ * );
58
+ *
59
+ * return (
60
+ * <SymmioProvider symmioConfig={symmioConfig} getWalletClient={getWalletClient}>
61
+ * {children}
62
+ * </SymmioProvider>
63
+ * );
64
+ * }
65
+ * ```
66
+ */
67
+ export declare function createSessionKeyWalletClientResolver(parameters: CreateSessionKeyWalletClientResolverParameters): GetWalletClientFn;
68
+ //# sourceMappingURL=create-session-key-wallet-client-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-session-key-wallet-client-resolver.d.ts","sourceRoot":"","sources":["../../src/provider/create-session-key-wallet-client-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,iBAAiB,EAA2B,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAoC,KAAK,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAChH,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,8CAA8C;IAC7D,mFAAmF;IACnF,iBAAiB,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IACxC,kFAAkF;IAClF,WAAW,EAAE,WAAW,CAAC;IACzB,sHAAsH;IACtH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,CAAC;CAC5C;AA6FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,oCAAoC,CAClD,UAAU,EAAE,8CAA8C,GACzD,iBAAiB,CAyBnB"}