@symmio/trading-react 1.1.0 → 3.0.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.
- package/dist/account-layer/index.d.ts +1 -0
- package/dist/account-layer/index.d.ts.map +1 -1
- package/dist/account-layer/index.js +26 -25
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts +53 -0
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -0
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +49 -0
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -0
- package/dist/account-layer/use-deposit-and-allocate.d.ts +4 -2
- package/dist/account-layer/use-deposit-and-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-deposit-and-allocate.js +17 -15
- package/dist/account-layer/use-deposit-and-allocate.js.map +1 -1
- package/dist/account-layer/use-edit-account-name.d.ts.map +1 -1
- package/dist/account-layer/use-edit-account-name.js +14 -14
- package/dist/account-layer/use-edit-account-name.js.map +1 -1
- package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.d.ts +1 -1
- package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.js.map +1 -1
- package/dist/candles/index.d.ts +5 -0
- package/dist/candles/index.d.ts.map +1 -0
- package/dist/candles/index.js +5 -0
- package/dist/candles/use-binance-candle-source.d.ts +27 -0
- package/dist/candles/use-binance-candle-source.d.ts.map +1 -0
- package/dist/candles/use-binance-candle-source.js +24 -0
- package/dist/candles/use-binance-candle-source.js.map +1 -0
- package/dist/candles/use-candle-stream.d.ts +65 -0
- package/dist/candles/use-candle-stream.d.ts.map +1 -0
- package/dist/candles/use-candle-stream.js +44 -0
- package/dist/candles/use-candle-stream.js.map +1 -0
- package/dist/candles/use-candles.d.ts +40 -0
- package/dist/candles/use-candles.d.ts.map +1 -0
- package/dist/candles/use-candles.js +22 -0
- package/dist/candles/use-candles.js.map +1 -0
- package/dist/candles/use-tradingview-datafeed.d.ts +31 -0
- package/dist/candles/use-tradingview-datafeed.d.ts.map +1 -0
- package/dist/candles/use-tradingview-datafeed.js +21 -0
- package/dist/candles/use-tradingview-datafeed.js.map +1 -0
- package/dist/index.d.ts +125 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +201 -113
- package/dist/instant-layer/index.d.ts +4 -0
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +10 -6
- package/dist/instant-layer/use-instant-close-auto.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-close-auto.js +12 -11
- package/dist/instant-layer/use-instant-close-auto.js.map +1 -1
- package/dist/instant-layer/use-instant-close-bulk-auto.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-close-bulk-auto.js +12 -11
- package/dist/instant-layer/use-instant-close-bulk-auto.js.map +1 -1
- package/dist/instant-layer/use-instant-close-bulk.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-close-bulk.js +12 -11
- package/dist/instant-layer/use-instant-close-bulk.js.map +1 -1
- package/dist/instant-layer/use-instant-close.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-close.js +12 -11
- package/dist/instant-layer/use-instant-close.js.map +1 -1
- package/dist/instant-layer/use-instant-open-auto.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-open-auto.js +12 -11
- package/dist/instant-layer/use-instant-open-auto.js.map +1 -1
- package/dist/instant-layer/use-instant-open-fees.d.ts +43 -0
- package/dist/instant-layer/use-instant-open-fees.d.ts.map +1 -0
- package/dist/instant-layer/use-instant-open-fees.js +111 -0
- package/dist/instant-layer/use-instant-open-fees.js.map +1 -0
- package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-open-with-tpsl.js +34 -31
- package/dist/instant-layer/use-instant-open-with-tpsl.js.map +1 -1
- package/dist/instant-layer/use-instant-open.d.ts +23 -18
- package/dist/instant-layer/use-instant-open.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-open.js +12 -11
- package/dist/instant-layer/use-instant-open.js.map +1 -1
- package/dist/instant-layer/use-instant-opens.d.ts +6 -6
- package/dist/instant-layer/use-instant-opens.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-opens.js.map +1 -1
- package/dist/instant-layer/use-instant-trade-required-selectors.d.ts +25 -0
- package/dist/instant-layer/use-instant-trade-required-selectors.d.ts.map +1 -0
- package/dist/instant-layer/use-instant-trade-required-selectors.js +13 -0
- package/dist/instant-layer/use-instant-trade-required-selectors.js.map +1 -0
- package/dist/instant-layer/use-limit-close-auto.d.ts +30 -0
- package/dist/instant-layer/use-limit-close-auto.d.ts.map +1 -0
- package/dist/instant-layer/use-limit-close-auto.js +33 -0
- package/dist/instant-layer/use-limit-close-auto.js.map +1 -0
- package/dist/instant-layer/use-limit-open-auto.d.ts +30 -0
- package/dist/instant-layer/use-limit-open-auto.d.ts.map +1 -0
- package/dist/instant-layer/use-limit-open-auto.js +33 -0
- package/dist/instant-layer/use-limit-open-auto.js.map +1 -0
- package/dist/inventory/index.d.ts +3 -0
- package/dist/inventory/index.d.ts.map +1 -0
- package/dist/inventory/index.js +3 -0
- package/dist/inventory/use-inventory-tvl-history.d.ts +27 -0
- package/dist/inventory/use-inventory-tvl-history.d.ts.map +1 -0
- package/dist/inventory/use-inventory-tvl-history.js +28 -0
- package/dist/inventory/use-inventory-tvl-history.js.map +1 -0
- package/dist/inventory/use-inventory-tvl.d.ts +23 -0
- package/dist/inventory/use-inventory-tvl.d.ts.map +1 -0
- package/dist/inventory/use-inventory-tvl.js +27 -0
- package/dist/inventory/use-inventory-tvl.js.map +1 -0
- package/dist/margin/index.d.ts +1 -0
- package/dist/margin/index.d.ts.map +1 -1
- package/dist/margin/use-account-margin-risk.d.ts +68 -0
- package/dist/margin/use-account-margin-risk.d.ts.map +1 -0
- package/dist/margin/use-account-margin-risk.js +31 -0
- package/dist/margin/use-account-margin-risk.js.map +1 -0
- package/dist/margin/use-available-instant-open-margin.d.ts +27 -7
- package/dist/margin/use-available-instant-open-margin.d.ts.map +1 -1
- package/dist/margin/use-available-instant-open-margin.js +117 -46
- package/dist/margin/use-available-instant-open-margin.js.map +1 -1
- package/dist/market-info/use-market-info.d.ts +13 -13
- package/dist/market-info/use-market-info.d.ts.map +1 -1
- package/dist/market-info/use-market-info.js.map +1 -1
- package/dist/markets/use-markets.d.ts +14 -8
- package/dist/markets/use-markets.d.ts.map +1 -1
- package/dist/markets/use-markets.js.map +1 -1
- package/dist/muon/index.d.ts +2 -0
- package/dist/muon/index.d.ts.map +1 -1
- package/dist/muon/use-force-close-price-sig.d.ts +34 -0
- package/dist/muon/use-force-close-price-sig.d.ts.map +1 -0
- package/dist/muon/use-force-close-price-sig.js +31 -0
- package/dist/muon/use-force-close-price-sig.js.map +1 -0
- package/dist/muon/use-send-quote-upnl-sig.d.ts +30 -0
- package/dist/muon/use-send-quote-upnl-sig.d.ts.map +1 -0
- package/dist/muon/use-send-quote-upnl-sig.js +28 -0
- package/dist/muon/use-send-quote-upnl-sig.js.map +1 -0
- package/dist/notifications/use-search-notifications.d.ts +12 -12
- package/dist/notifications/use-search-notifications.d.ts.map +1 -1
- package/dist/notifications/use-search-notifications.js.map +1 -1
- package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts +7 -7
- package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts.map +1 -1
- package/dist/notional-cap/use-notional-cap-by-symbol-id.js.map +1 -1
- package/dist/orderbook/index.d.ts +5 -0
- package/dist/orderbook/index.d.ts.map +1 -0
- package/dist/orderbook/index.js +5 -0
- package/dist/orderbook/use-binance-orderbook-source.d.ts +28 -0
- package/dist/orderbook/use-binance-orderbook-source.d.ts.map +1 -0
- package/dist/orderbook/use-binance-orderbook-source.js +26 -0
- package/dist/orderbook/use-binance-orderbook-source.js.map +1 -0
- package/dist/orderbook/use-live-orderbook.d.ts +104 -0
- package/dist/orderbook/use-live-orderbook.d.ts.map +1 -0
- package/dist/orderbook/use-live-orderbook.js +77 -0
- package/dist/orderbook/use-live-orderbook.js.map +1 -0
- package/dist/orderbook/use-orderbook-stream.d.ts +73 -0
- package/dist/orderbook/use-orderbook-stream.d.ts.map +1 -0
- package/dist/orderbook/use-orderbook-stream.js +49 -0
- package/dist/orderbook/use-orderbook-stream.js.map +1 -0
- package/dist/orderbook/use-orderbook.d.ts +35 -0
- package/dist/orderbook/use-orderbook.d.ts.map +1 -0
- package/dist/orderbook/use-orderbook.js +22 -0
- package/dist/orderbook/use-orderbook.js.map +1 -0
- package/dist/pools/index.d.ts +30 -0
- package/dist/pools/index.d.ts.map +1 -0
- package/dist/pools/index.js +30 -0
- package/dist/pools/use-add-market.d.ts +57 -0
- package/dist/pools/use-add-market.d.ts.map +1 -0
- package/dist/pools/use-add-market.js +30 -0
- package/dist/pools/use-add-market.js.map +1 -0
- package/dist/pools/use-authenticate-listing.d.ts +45 -0
- package/dist/pools/use-authenticate-listing.d.ts.map +1 -0
- package/dist/pools/use-authenticate-listing.js +30 -0
- package/dist/pools/use-authenticate-listing.js.map +1 -0
- package/dist/pools/use-cancel-withdraw.d.ts +47 -0
- package/dist/pools/use-cancel-withdraw.d.ts.map +1 -0
- package/dist/pools/use-cancel-withdraw.js +30 -0
- package/dist/pools/use-cancel-withdraw.js.map +1 -0
- package/dist/pools/use-claim-history.d.ts +25 -0
- package/dist/pools/use-claim-history.d.ts.map +1 -0
- package/dist/pools/use-claim-history.js +27 -0
- package/dist/pools/use-claim-history.js.map +1 -0
- package/dist/pools/use-claim-profit.d.ts +53 -0
- package/dist/pools/use-claim-profit.d.ts.map +1 -0
- package/dist/pools/use-claim-profit.js +30 -0
- package/dist/pools/use-claim-profit.js.map +1 -0
- package/dist/pools/use-deposit-address.d.ts +43 -0
- package/dist/pools/use-deposit-address.d.ts.map +1 -0
- package/dist/pools/use-deposit-address.js +28 -0
- package/dist/pools/use-deposit-address.js.map +1 -0
- package/dist/pools/use-listing-config.d.ts +28 -0
- package/dist/pools/use-listing-config.d.ts.map +1 -0
- package/dist/pools/use-listing-config.js +27 -0
- package/dist/pools/use-listing-config.js.map +1 -0
- package/dist/pools/use-listing-market-config-projection.d.ts +66 -0
- package/dist/pools/use-listing-market-config-projection.d.ts.map +1 -0
- package/dist/pools/use-listing-market-config-projection.js +57 -0
- package/dist/pools/use-listing-market-config-projection.js.map +1 -0
- package/dist/pools/use-listing-market-config.d.ts +49 -0
- package/dist/pools/use-listing-market-config.d.ts.map +1 -0
- package/dist/pools/use-listing-market-config.js +28 -0
- package/dist/pools/use-listing-market-config.js.map +1 -0
- package/dist/pools/use-listing-market-detail.d.ts +29 -0
- package/dist/pools/use-listing-market-detail.d.ts.map +1 -0
- package/dist/pools/use-listing-market-detail.js +27 -0
- package/dist/pools/use-listing-market-detail.js.map +1 -0
- package/dist/pools/use-listing-markets.d.ts +32 -0
- package/dist/pools/use-listing-markets.d.ts.map +1 -0
- package/dist/pools/use-listing-markets.js +27 -0
- package/dist/pools/use-listing-markets.js.map +1 -0
- package/dist/pools/use-listing-status.d.ts +29 -0
- package/dist/pools/use-listing-status.d.ts.map +1 -0
- package/dist/pools/use-listing-status.js +28 -0
- package/dist/pools/use-listing-status.js.map +1 -0
- package/dist/pools/use-pool-quotes.d.ts +26 -0
- package/dist/pools/use-pool-quotes.d.ts.map +1 -0
- package/dist/pools/use-pool-quotes.js +27 -0
- package/dist/pools/use-pool-quotes.js.map +1 -0
- package/dist/pools/use-pool-reward-chart.d.ts +32 -0
- package/dist/pools/use-pool-reward-chart.d.ts.map +1 -0
- package/dist/pools/use-pool-reward-chart.js +28 -0
- package/dist/pools/use-pool-reward-chart.js.map +1 -0
- package/dist/pools/use-pool-total-reward.d.ts +27 -0
- package/dist/pools/use-pool-total-reward.d.ts.map +1 -0
- package/dist/pools/use-pool-total-reward.js +28 -0
- package/dist/pools/use-pool-total-reward.js.map +1 -0
- package/dist/pools/use-pool-trade-history.d.ts +26 -0
- package/dist/pools/use-pool-trade-history.d.ts.map +1 -0
- package/dist/pools/use-pool-trade-history.js +27 -0
- package/dist/pools/use-pool-trade-history.js.map +1 -0
- package/dist/pools/use-pool-transactions.d.ts +23 -0
- package/dist/pools/use-pool-transactions.d.ts.map +1 -0
- package/dist/pools/use-pool-transactions.js +27 -0
- package/dist/pools/use-pool-transactions.js.map +1 -0
- package/dist/pools/use-refund-market.d.ts +51 -0
- package/dist/pools/use-refund-market.d.ts.map +1 -0
- package/dist/pools/use-refund-market.js +30 -0
- package/dist/pools/use-refund-market.js.map +1 -0
- package/dist/pools/use-retry-listing-info.d.ts +23 -0
- package/dist/pools/use-retry-listing-info.d.ts.map +1 -0
- package/dist/pools/use-retry-listing-info.js +27 -0
- package/dist/pools/use-retry-listing-info.js.map +1 -0
- package/dist/pools/use-retry-listing.d.ts +46 -0
- package/dist/pools/use-retry-listing.d.ts.map +1 -0
- package/dist/pools/use-retry-listing.js +30 -0
- package/dist/pools/use-retry-listing.js.map +1 -0
- package/dist/pools/use-supports-listing-service.d.ts +21 -0
- package/dist/pools/use-supports-listing-service.d.ts.map +1 -0
- package/dist/pools/use-supports-listing-service.js +13 -0
- package/dist/pools/use-supports-listing-service.js.map +1 -0
- package/dist/pools/use-update-listing-market-config.d.ts +60 -0
- package/dist/pools/use-update-listing-market-config.d.ts.map +1 -0
- package/dist/pools/use-update-listing-market-config.js +30 -0
- package/dist/pools/use-update-listing-market-config.js.map +1 -0
- package/dist/pools/use-user-listing-markets.d.ts +40 -0
- package/dist/pools/use-user-listing-markets.d.ts.map +1 -0
- package/dist/pools/use-user-listing-markets.js +28 -0
- package/dist/pools/use-user-listing-markets.js.map +1 -0
- package/dist/pools/use-user-profit.d.ts +39 -0
- package/dist/pools/use-user-profit.d.ts.map +1 -0
- package/dist/pools/use-user-profit.js +28 -0
- package/dist/pools/use-user-profit.js.map +1 -0
- package/dist/pools/use-user-reward-chart.d.ts +28 -0
- package/dist/pools/use-user-reward-chart.d.ts.map +1 -0
- package/dist/pools/use-user-reward-chart.js +28 -0
- package/dist/pools/use-user-reward-chart.js.map +1 -0
- package/dist/pools/use-user-total-reward.d.ts +30 -0
- package/dist/pools/use-user-total-reward.d.ts.map +1 -0
- package/dist/pools/use-user-total-reward.js +28 -0
- package/dist/pools/use-user-total-reward.js.map +1 -0
- package/dist/pools/use-user-transactions.d.ts +24 -0
- package/dist/pools/use-user-transactions.d.ts.map +1 -0
- package/dist/pools/use-user-transactions.js +27 -0
- package/dist/pools/use-user-transactions.js.map +1 -0
- package/dist/pools/use-weekly-listing-limit.d.ts +28 -0
- package/dist/pools/use-weekly-listing-limit.d.ts.map +1 -0
- package/dist/pools/use-weekly-listing-limit.js +28 -0
- package/dist/pools/use-weekly-listing-limit.js.map +1 -0
- package/dist/pools/use-withdraw-lp.d.ts +52 -0
- package/dist/pools/use-withdraw-lp.d.ts.map +1 -0
- package/dist/pools/use-withdraw-lp.js +30 -0
- package/dist/pools/use-withdraw-lp.js.map +1 -0
- package/dist/price-service/index.d.ts +8 -0
- package/dist/price-service/index.d.ts.map +1 -1
- package/dist/price-service/index.js +17 -9
- package/dist/price-service/use-binance-health.d.ts +16 -0
- package/dist/price-service/use-binance-health.d.ts.map +1 -0
- package/dist/price-service/use-binance-health.js +27 -0
- package/dist/price-service/use-binance-health.js.map +1 -0
- package/dist/price-service/use-binance-premium-index.d.ts +24 -0
- package/dist/price-service/use-binance-premium-index.d.ts.map +1 -0
- package/dist/price-service/use-binance-premium-index.js +27 -0
- package/dist/price-service/use-binance-premium-index.js.map +1 -0
- package/dist/price-service/use-binance-prices.d.ts +54 -0
- package/dist/price-service/use-binance-prices.d.ts.map +1 -0
- package/dist/price-service/use-binance-prices.js +57 -0
- package/dist/price-service/use-binance-prices.js.map +1 -0
- package/dist/price-service/use-binance-symbols-info.d.ts +18 -0
- package/dist/price-service/use-binance-symbols-info.d.ts.map +1 -0
- package/dist/price-service/use-binance-symbols-info.js +27 -0
- package/dist/price-service/use-binance-symbols-info.js.map +1 -0
- package/dist/price-service/use-enigma-price-by-market-id.d.ts +7 -1
- package/dist/price-service/use-enigma-price-by-market-id.d.ts.map +1 -1
- package/dist/price-service/use-enigma-price-by-market-id.js +1 -1
- package/dist/price-service/use-enigma-price-by-market-id.js.map +1 -1
- package/dist/price-service/use-mark-prices.d.ts +25 -0
- package/dist/price-service/use-mark-prices.d.ts.map +1 -0
- package/dist/price-service/use-mark-prices.js +27 -0
- package/dist/price-service/use-mark-prices.js.map +1 -0
- package/dist/price-service/use-price-by-market-id.d.ts +53 -0
- package/dist/price-service/use-price-by-market-id.d.ts.map +1 -0
- package/dist/price-service/use-price-by-market-id.js +33 -0
- package/dist/price-service/use-price-by-market-id.js.map +1 -0
- package/dist/price-service/use-price-by-name.d.ts +48 -0
- package/dist/price-service/use-price-by-name.d.ts.map +1 -0
- package/dist/price-service/use-price-by-name.js +23 -0
- package/dist/price-service/use-price-by-name.js.map +1 -0
- package/dist/price-service/use-prices.d.ts +87 -0
- package/dist/price-service/use-prices.d.ts.map +1 -0
- package/dist/price-service/use-prices.js +77 -0
- package/dist/price-service/use-prices.js.map +1 -0
- package/dist/provider/symmio-provider.d.ts +8 -2
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +19 -19
- package/dist/provider/symmio-provider.js.map +1 -1
- package/dist/quotes/confirm-hold.d.ts +121 -0
- package/dist/quotes/confirm-hold.d.ts.map +1 -0
- package/dist/quotes/confirm-hold.js +59 -0
- package/dist/quotes/confirm-hold.js.map +1 -0
- package/dist/quotes/index.d.ts +14 -0
- package/dist/quotes/index.d.ts.map +1 -1
- package/dist/quotes/use-account-upnl.d.ts +66 -0
- package/dist/quotes/use-account-upnl.d.ts.map +1 -0
- package/dist/quotes/use-account-upnl.js +73 -0
- package/dist/quotes/use-account-upnl.js.map +1 -0
- package/dist/quotes/use-close-quote-group.d.ts +126 -0
- package/dist/quotes/use-close-quote-group.d.ts.map +1 -0
- package/dist/quotes/use-close-quote-group.js +172 -0
- package/dist/quotes/use-close-quote-group.js.map +1 -0
- package/dist/quotes/use-cool-downs-of-ma.d.ts +26 -0
- package/dist/quotes/use-cool-downs-of-ma.d.ts.map +1 -0
- package/dist/quotes/use-cool-downs-of-ma.js +27 -0
- package/dist/quotes/use-cool-downs-of-ma.js.map +1 -0
- package/dist/quotes/use-force-cancel-close-request.d.ts +27 -0
- package/dist/quotes/use-force-cancel-close-request.d.ts.map +1 -0
- package/dist/quotes/use-force-cancel-close-request.js +41 -0
- package/dist/quotes/use-force-cancel-close-request.js.map +1 -0
- package/dist/quotes/use-force-cancel-quote.d.ts +26 -0
- package/dist/quotes/use-force-cancel-quote.d.ts.map +1 -0
- package/dist/quotes/use-force-cancel-quote.js +42 -0
- package/dist/quotes/use-force-cancel-quote.js.map +1 -0
- package/dist/quotes/use-force-close-eligibility.d.ts +30 -0
- package/dist/quotes/use-force-close-eligibility.d.ts.map +1 -0
- package/dist/quotes/use-force-close-eligibility.js +39 -0
- package/dist/quotes/use-force-close-eligibility.js.map +1 -0
- package/dist/quotes/use-force-close-params.d.ts +22 -0
- package/dist/quotes/use-force-close-params.d.ts.map +1 -0
- package/dist/quotes/use-force-close-params.js +27 -0
- package/dist/quotes/use-force-close-params.js.map +1 -0
- package/dist/quotes/use-force-close.d.ts +30 -0
- package/dist/quotes/use-force-close.d.ts.map +1 -0
- package/dist/quotes/use-force-close.js +38 -0
- package/dist/quotes/use-force-close.js.map +1 -0
- package/dist/quotes/use-grouped-quotes.d.ts +50 -10
- package/dist/quotes/use-grouped-quotes.d.ts.map +1 -1
- package/dist/quotes/use-grouped-quotes.js +40 -14
- package/dist/quotes/use-grouped-quotes.js.map +1 -1
- package/dist/quotes/use-grouping-isolation.d.ts +35 -0
- package/dist/quotes/use-grouping-isolation.d.ts.map +1 -0
- package/dist/quotes/use-grouping-isolation.js +39 -0
- package/dist/quotes/use-grouping-isolation.js.map +1 -0
- package/dist/quotes/use-limit-orders.d.ts +62 -0
- package/dist/quotes/use-limit-orders.d.ts.map +1 -0
- package/dist/quotes/use-limit-orders.js +82 -0
- package/dist/quotes/use-limit-orders.js.map +1 -0
- package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
- package/dist/quotes/use-managed-quotes.js +198 -166
- package/dist/quotes/use-managed-quotes.js.map +1 -1
- package/dist/quotes/use-party-a-open-positions.d.ts +26 -6
- package/dist/quotes/use-party-a-open-positions.d.ts.map +1 -1
- package/dist/quotes/use-party-a-open-positions.js +32 -12
- package/dist/quotes/use-party-a-open-positions.js.map +1 -1
- package/dist/quotes/use-quote-funding.d.ts +2 -2
- package/dist/quotes/use-quote-funding.js.map +1 -1
- package/dist/quotes/use-quote-group-funding-history.d.ts +70 -0
- package/dist/quotes/use-quote-group-funding-history.d.ts.map +1 -0
- package/dist/quotes/use-quote-group-funding-history.js +38 -0
- package/dist/quotes/use-quote-group-funding-history.js.map +1 -0
- package/dist/quotes/use-quote-group-funding.d.ts +67 -0
- package/dist/quotes/use-quote-group-funding.d.ts.map +1 -0
- package/dist/quotes/use-quote-group-funding.js +26 -0
- package/dist/quotes/use-quote-group-funding.js.map +1 -0
- package/dist/quotes/use-quote-group-margin-risk.d.ts +111 -0
- package/dist/quotes/use-quote-group-margin-risk.d.ts.map +1 -0
- package/dist/quotes/use-quote-group-margin-risk.js +63 -0
- package/dist/quotes/use-quote-group-margin-risk.js.map +1 -0
- package/dist/quotes/use-quote-upnl-and-pnl.d.ts +4 -3
- package/dist/quotes/use-quote-upnl-and-pnl.d.ts.map +1 -1
- package/dist/quotes/use-quote-upnl-and-pnl.js +2 -1
- package/dist/quotes/use-quote-upnl-and-pnl.js.map +1 -1
- package/dist/quotes/use-quotes-funding.d.ts +46 -10
- package/dist/quotes/use-quotes-funding.d.ts.map +1 -1
- package/dist/quotes/use-quotes-funding.js +44 -42
- package/dist/quotes/use-quotes-funding.js.map +1 -1
- package/dist/quotes/use-request-to-cancel-close-request.d.ts +27 -0
- package/dist/quotes/use-request-to-cancel-close-request.d.ts.map +1 -0
- package/dist/quotes/use-request-to-cancel-close-request.js +41 -0
- package/dist/quotes/use-request-to-cancel-close-request.js.map +1 -0
- package/dist/quotes/use-request-to-cancel-quote.d.ts +32 -0
- package/dist/quotes/use-request-to-cancel-quote.d.ts.map +1 -0
- package/dist/quotes/use-request-to-cancel-quote.js +42 -0
- package/dist/quotes/use-request-to-cancel-quote.js.map +1 -0
- package/dist/rasa-solver/index.d.ts +7 -0
- package/dist/rasa-solver/index.d.ts.map +1 -0
- package/dist/rasa-solver/use-error-message.d.ts +14 -0
- package/dist/rasa-solver/use-error-message.d.ts.map +1 -0
- package/dist/rasa-solver/use-error-message.js +27 -0
- package/dist/rasa-solver/use-error-message.js.map +1 -0
- package/dist/rasa-solver/use-party-a-upnl.d.ts +14 -0
- package/dist/rasa-solver/use-party-a-upnl.d.ts.map +1 -0
- package/dist/rasa-solver/use-party-a-upnl.js +27 -0
- package/dist/rasa-solver/use-party-a-upnl.js.map +1 -0
- package/dist/rasa-solver/use-solver-balance-info.d.ts +14 -0
- package/dist/rasa-solver/use-solver-balance-info.d.ts.map +1 -0
- package/dist/rasa-solver/use-solver-balance-info.js +27 -0
- package/dist/rasa-solver/use-solver-balance-info.js.map +1 -0
- package/dist/rasa-solver/use-solver-open-interest.d.ts +14 -0
- package/dist/rasa-solver/use-solver-open-interest.d.ts.map +1 -0
- package/dist/rasa-solver/use-solver-open-interest.js +27 -0
- package/dist/rasa-solver/use-solver-open-interest.js.map +1 -0
- package/dist/rasa-solver/use-solver-price-range.d.ts +14 -0
- package/dist/rasa-solver/use-solver-price-range.d.ts.map +1 -0
- package/dist/rasa-solver/use-solver-price-range.js +27 -0
- package/dist/rasa-solver/use-solver-price-range.js.map +1 -0
- package/dist/rasa-solver/use-solver-readiness.d.ts +13 -0
- package/dist/rasa-solver/use-solver-readiness.d.ts.map +1 -0
- package/dist/rasa-solver/use-solver-readiness.js +27 -0
- package/dist/rasa-solver/use-solver-readiness.js.map +1 -0
- package/dist/revenue-records/index.d.ts +2 -0
- package/dist/revenue-records/index.d.ts.map +1 -0
- package/dist/revenue-records/use-revenue-records.d.ts +25 -0
- package/dist/revenue-records/use-revenue-records.d.ts.map +1 -0
- package/dist/revenue-records/use-revenue-records.js +27 -0
- package/dist/revenue-records/use-revenue-records.js.map +1 -0
- package/dist/solvers/index.d.ts +3 -0
- package/dist/solvers/index.d.ts.map +1 -0
- package/dist/solvers/use-solver-capabilities.d.ts +31 -0
- package/dist/solvers/use-solver-capabilities.d.ts.map +1 -0
- package/dist/solvers/use-solver-capabilities.js +30 -0
- package/dist/solvers/use-solver-capabilities.js.map +1 -0
- package/dist/solvers/use-solver-revenue.d.ts +28 -0
- package/dist/solvers/use-solver-revenue.d.ts.map +1 -0
- package/dist/solvers/use-solver-revenue.js +27 -0
- package/dist/solvers/use-solver-revenue.js.map +1 -0
- package/dist/symbols/index.d.ts +2 -0
- package/dist/symbols/index.d.ts.map +1 -0
- package/dist/symbols/use-symbols.d.ts +25 -0
- package/dist/symbols/use-symbols.d.ts.map +1 -0
- package/dist/symbols/use-symbols.js +27 -0
- package/dist/symbols/use-symbols.js.map +1 -0
- package/dist/tpsl/apply-tpsl-search-snapshot.d.ts +33 -0
- package/dist/tpsl/apply-tpsl-search-snapshot.d.ts.map +1 -0
- package/dist/tpsl/apply-tpsl-search-snapshot.js +51 -0
- package/dist/tpsl/apply-tpsl-search-snapshot.js.map +1 -0
- package/dist/tpsl/await-tpsl-confirmation.d.ts +77 -0
- package/dist/tpsl/await-tpsl-confirmation.d.ts.map +1 -0
- package/dist/tpsl/await-tpsl-confirmation.js +42 -0
- package/dist/tpsl/await-tpsl-confirmation.js.map +1 -0
- package/dist/tpsl/index.d.ts +11 -0
- package/dist/tpsl/index.d.ts.map +1 -1
- package/dist/tpsl/invalidate-tpsl.d.ts +23 -0
- package/dist/tpsl/invalidate-tpsl.d.ts.map +1 -0
- package/dist/tpsl/invalidate-tpsl.js +14 -0
- package/dist/tpsl/invalidate-tpsl.js.map +1 -0
- package/dist/tpsl/match-tpsl-notification.d.ts +27 -0
- package/dist/tpsl/match-tpsl-notification.d.ts.map +1 -0
- package/dist/tpsl/match-tpsl-notification.js +22 -0
- package/dist/tpsl/match-tpsl-notification.js.map +1 -0
- package/dist/tpsl/run-with-concurrency.d.ts +20 -0
- package/dist/tpsl/run-with-concurrency.d.ts.map +1 -0
- package/dist/tpsl/run-with-concurrency.js +15 -0
- package/dist/tpsl/run-with-concurrency.js.map +1 -0
- package/dist/tpsl/settled-side.d.ts +31 -0
- package/dist/tpsl/settled-side.d.ts.map +1 -0
- package/dist/tpsl/settled-side.js +21 -0
- package/dist/tpsl/settled-side.js.map +1 -0
- package/dist/tpsl/tpsl-fallback-poll.d.ts +74 -0
- package/dist/tpsl/tpsl-fallback-poll.d.ts.map +1 -0
- package/dist/tpsl/tpsl-fallback-poll.js +101 -0
- package/dist/tpsl/tpsl-fallback-poll.js.map +1 -0
- package/dist/tpsl/tpsl-store.d.ts +98 -2
- package/dist/tpsl/tpsl-store.d.ts.map +1 -1
- package/dist/tpsl/tpsl-store.js +111 -63
- package/dist/tpsl/tpsl-store.js.map +1 -1
- package/dist/tpsl/use-delete-quote-group-tpsl.d.ts +165 -0
- package/dist/tpsl/use-delete-quote-group-tpsl.d.ts.map +1 -0
- package/dist/tpsl/use-delete-quote-group-tpsl.js +247 -0
- package/dist/tpsl/use-delete-quote-group-tpsl.js.map +1 -0
- package/dist/tpsl/use-delete-quote-tpsl.d.ts.map +1 -1
- package/dist/tpsl/use-delete-quote-tpsl.js +11 -10
- package/dist/tpsl/use-delete-quote-tpsl.js.map +1 -1
- package/dist/tpsl/use-quote-group-tpsl-editor.d.ts +66 -0
- package/dist/tpsl/use-quote-group-tpsl-editor.d.ts.map +1 -0
- package/dist/tpsl/use-quote-group-tpsl-editor.js +78 -0
- package/dist/tpsl/use-quote-group-tpsl-editor.js.map +1 -0
- package/dist/tpsl/use-quote-group-tpsl.d.ts +74 -0
- package/dist/tpsl/use-quote-group-tpsl.d.ts.map +1 -0
- package/dist/tpsl/use-quote-group-tpsl.js +67 -0
- package/dist/tpsl/use-quote-group-tpsl.js.map +1 -0
- package/dist/tpsl/use-quote-tpsl.d.ts +18 -2
- package/dist/tpsl/use-quote-tpsl.d.ts.map +1 -1
- package/dist/tpsl/use-quote-tpsl.js +32 -24
- package/dist/tpsl/use-quote-tpsl.js.map +1 -1
- package/dist/tpsl/use-search-tpsl-orders.d.ts +30 -0
- package/dist/tpsl/use-search-tpsl-orders.d.ts.map +1 -0
- package/dist/tpsl/use-search-tpsl-orders.js +27 -0
- package/dist/tpsl/use-search-tpsl-orders.js.map +1 -0
- package/dist/tpsl/use-set-quote-group-tpsl.d.ts +234 -0
- package/dist/tpsl/use-set-quote-group-tpsl.d.ts.map +1 -0
- package/dist/tpsl/use-set-quote-group-tpsl.js +358 -0
- package/dist/tpsl/use-set-quote-group-tpsl.js.map +1 -0
- package/dist/tpsl/use-set-quote-tpsl.d.ts +4 -4
- package/dist/tpsl/use-set-quote-tpsl.d.ts.map +1 -1
- package/dist/tpsl/use-set-quote-tpsl.js +15 -12
- package/dist/tpsl/use-set-quote-tpsl.js.map +1 -1
- package/dist/tpsl/use-tpsl-supported.d.ts +22 -0
- package/dist/tpsl/use-tpsl-supported.d.ts.map +1 -0
- package/dist/tpsl/use-tpsl-supported.js +16 -0
- package/dist/tpsl/use-tpsl-supported.js.map +1 -0
- package/dist/tpsl/use-watch-tpsl-accounts.d.ts +33 -0
- package/dist/tpsl/use-watch-tpsl-accounts.d.ts.map +1 -0
- package/dist/tpsl/use-watch-tpsl-accounts.js +44 -0
- package/dist/tpsl/use-watch-tpsl-accounts.js.map +1 -0
- package/dist/trade-volume/index.d.ts +2 -0
- package/dist/trade-volume/index.d.ts.map +1 -0
- package/dist/trade-volume/use-trade-volume.d.ts +26 -0
- package/dist/trade-volume/use-trade-volume.d.ts.map +1 -0
- package/dist/trade-volume/use-trade-volume.js +27 -0
- package/dist/trade-volume/use-trade-volume.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/invalidate-account-balances.d.ts +36 -0
- package/dist/utils/invalidate-account-balances.d.ts.map +1 -0
- package/dist/utils/invalidate-account-balances.js +10 -0
- package/dist/utils/invalidate-account-balances.js.map +1 -0
- package/dist/websocket/use-notifications.d.ts +3 -1
- package/dist/websocket/use-notifications.d.ts.map +1 -1
- package/dist/websocket/use-notifications.js +22 -20
- package/dist/websocket/use-notifications.js.map +1 -1
- package/dist/withdraw/index.d.ts +1 -0
- package/dist/withdraw/index.d.ts.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.d.ts +1 -1
- package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.d.ts +4 -2
- package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.js +15 -13
- package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
- package/dist/withdraw/use-withdraw.d.ts +67 -0
- package/dist/withdraw/use-withdraw.d.ts.map +1 -0
- package/dist/withdraw/use-withdraw.js +49 -0
- package/dist/withdraw/use-withdraw.js.map +1 -0
- package/package.json +18 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioConfig as e } from "../provider/use-symmio-config.js";
|
|
3
|
+
import { useTpSlStore as t } from "./tpsl-store.js";
|
|
4
|
+
import { linkTpSlNotificationIds as n, matchTpSlNotification as r } from "./match-tpsl-notification.js";
|
|
5
|
+
import { supportsTpSl as i, watchTpSlNotifications as a } from "@symmio/trading-core";
|
|
6
|
+
import { useEffect as o, useRef as s } from "react";
|
|
7
|
+
//#region src/tpsl/use-watch-tpsl-accounts.ts
|
|
8
|
+
function c(c) {
|
|
9
|
+
let { accounts: l, ids: u, chainId: d, enabled: f = !0 } = c, p = e(c), m = i(p, { chainId: d }), h = s(u);
|
|
10
|
+
h.current = u, o(() => {
|
|
11
|
+
if (!f || !m || l.length === 0) return;
|
|
12
|
+
let e = (e) => {
|
|
13
|
+
n(e);
|
|
14
|
+
let i = r(e, h.current);
|
|
15
|
+
i !== void 0 && t.getState().applyNotification(i, e);
|
|
16
|
+
}, i = l.map((t) => a(p, {
|
|
17
|
+
account: t,
|
|
18
|
+
chainId: d,
|
|
19
|
+
onNotification: e
|
|
20
|
+
}));
|
|
21
|
+
return () => {
|
|
22
|
+
for (let e of i) e();
|
|
23
|
+
};
|
|
24
|
+
}, [
|
|
25
|
+
l.map((e) => e.toLowerCase()).join(","),
|
|
26
|
+
d,
|
|
27
|
+
p,
|
|
28
|
+
f,
|
|
29
|
+
m
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
function l(e) {
|
|
33
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
34
|
+
for (let r of e) {
|
|
35
|
+
if (!r) continue;
|
|
36
|
+
let e = r.toLowerCase();
|
|
37
|
+
t.has(e) || (t.add(e), n.push(r));
|
|
38
|
+
}
|
|
39
|
+
return n;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { l as dedupeAddresses, c as useWatchTpSlAccounts };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=use-watch-tpsl-accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-watch-tpsl-accounts.js","names":[],"sources":["../../src/tpsl/use-watch-tpsl-accounts.ts"],"sourcesContent":["\"use client\";\n\nimport {\n supportsTpSl,\n watchTpSlNotifications,\n type ConfigParameter,\n type TpSlNotification,\n} from \"@symmio/trading-core\";\nimport { useEffect, useRef } from \"react\";\nimport type { Address } from \"viem\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { linkTpSlNotificationIds, matchTpSlNotification } from \"./match-tpsl-notification\";\nimport { useTpSlStore } from \"./tpsl-store\";\n\n/** Parameters for {@link useWatchTpSlAccounts}. */\nexport interface UseWatchTpSlAccountsParameters extends ConfigParameter {\n /** Accounts to subscribe to. A grouped position can span Virtual Accounts. */\n accounts: readonly Address[];\n /** Quote ids an incoming frame may belong to; read live inside the handler. */\n ids: readonly (bigint | undefined)[];\n /** Target chain id. Defaults to the config's default chain. */\n chainId?: number;\n /** Subscribe only when `true`. Default `true`. */\n enabled?: boolean;\n}\n\n/**\n * Subscribe to the TP/SL stream of several accounts at once and fold every\n * matching frame into the shared TP/SL store.\n *\n * `useWatchTpSlNotifications` cannot cover this: the account count changes as a\n * group grows, and a hook cannot be called in a loop. So this drives the core\n * watcher directly from one effect. The SDK's socket pool keys on\n * `(wsUrl, appName, account)`, so subscribing here adds handlers to sockets\n * other hooks already opened rather than new connections.\n *\n * Frames land in the store rather than in a caller-supplied callback, because\n * the store is what every consumer — read hooks, run hooks, cells — reconciles\n * against. That way a step confirms no matter which subscription received it.\n *\n * @param parameters - The accounts to watch, the candidate quote ids, and the enable switch.\n */\nexport function useWatchTpSlAccounts(parameters: UseWatchTpSlAccountsParameters): void {\n const { accounts, ids, chainId, enabled = true } = parameters;\n const config = useSymmioConfig(parameters);\n // The resolved solver may have no TP/SL handler (e.g. a rasa solver on Base);\n // subscribing would throw `TPSL_NOT_CONFIGURED`. Skip when unsupported.\n const supported = supportsTpSl(config, { chainId });\n\n /** Read the live id list from inside the long-lived socket handler. */\n const idsRef = useRef(ids);\n idsRef.current = ids;\n\n /** Re-subscribe only when the account set genuinely changes. */\n const accountsKey = accounts.map((account) => account.toLowerCase()).join(\",\");\n\n useEffect(() => {\n if (!enabled || !supported || accounts.length === 0) return;\n\n const onNotification = (notification: TpSlNotification) => {\n linkTpSlNotificationIds(notification);\n const target = matchTpSlNotification(notification, idsRef.current);\n if (target === undefined) return;\n useTpSlStore.getState().applyNotification(target, notification);\n };\n\n const unwatchers = accounts.map((account) => watchTpSlNotifications(config, { account, chainId, onNotification }));\n return () => {\n for (const unwatch of unwatchers) unwatch();\n };\n // `accountsKey` stands in for `accounts` — a fresh array with the same\n // members must not tear down and rebuild the subscriptions.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [accountsKey, chainId, config, enabled, supported]);\n}\n\n/** Case-insensitive address dedupe that preserves first-seen order. */\nexport function dedupeAddresses(addresses: readonly (Address | undefined)[]): Address[] {\n const seen = new Set<string>();\n const unique: Address[] = [];\n for (const address of addresses) {\n if (!address) continue;\n const normalized = address.toLowerCase();\n if (seen.has(normalized)) continue;\n seen.add(normalized);\n unique.push(address);\n }\n return unique;\n}\n"],"mappings":";;;;;;;AA0CA,SAAgB,EAAqB,GAAkD;CACrF,IAAM,EAAE,aAAU,QAAK,YAAS,aAAU,OAAS,GAC7C,IAAS,EAAgB,CAAU,GAGnC,IAAY,EAAa,GAAQ,EAAE,WAAQ,CAAC,GAG5C,IAAS,EAAO,CAAG;CAMzB,AALA,EAAO,UAAU,GAKjB,QAAgB;EACd,IAAI,CAAC,KAAW,CAAC,KAAa,EAAS,WAAW,GAAG;EAErD,IAAM,KAAkB,MAAmC;GACzD,EAAwB,CAAY;GACpC,IAAM,IAAS,EAAsB,GAAc,EAAO,OAAO;GAC7D,MAAW,KAAA,KACf,EAAa,SAAS,EAAE,kBAAkB,GAAQ,CAAY;EAChE,GAEM,IAAa,EAAS,KAAK,MAAY,EAAuB,GAAQ;GAAE;GAAS;GAAS;EAAe,CAAC,CAAC;EACjH,aAAa;GACX,KAAK,IAAM,KAAW,GAAY,EAAQ;EAC5C;CAIF,GAAG;EAnBiB,EAAS,KAAK,MAAY,EAAQ,YAAY,CAAC,EAAE,KAAK,GAmBtE;EAAa;EAAS;EAAQ;EAAS;CAAS,CAAC;AACvD;AAGA,SAAgB,EAAgB,GAAwD;CACtF,IAAM,oBAAO,IAAI,IAAY,GACvB,IAAoB,CAAC;CAC3B,KAAK,IAAM,KAAW,GAAW;EAC/B,IAAI,CAAC,GAAS;EACd,IAAM,IAAa,EAAQ,YAAY;EACnC,EAAK,IAAI,CAAU,MACvB,EAAK,IAAI,CAAU,GACnB,EAAO,KAAK,CAAO;CACrB;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trade-volume/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConfigParameter, GetTradeVolumeOptions, GetTradeVolumeReturnType } 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 useTradeVolume}: the core query options (required
|
|
6
|
+
* `symbolId`, chain id, TanStack `query` overrides) plus an optional `config`.
|
|
7
|
+
*/
|
|
8
|
+
export type UseTradeVolumeParameters = GetTradeVolumeOptions & ConfigParameter;
|
|
9
|
+
/** Return type of {@link useTradeVolume}. */
|
|
10
|
+
export type UseTradeVolumeReturnType = UseQueryResult<GetTradeVolumeReturnType, SymmioRequestError>;
|
|
11
|
+
/**
|
|
12
|
+
* Read the last N daily trade-volume rows for one market from the active chain's
|
|
13
|
+
* enigma solver. Rows are ascending by day. The query is disabled until a
|
|
14
|
+
* positive `symbolId` is supplied.
|
|
15
|
+
*
|
|
16
|
+
* Does not poll by default; pass `query.refetchInterval` to opt into polling.
|
|
17
|
+
* Errors are normalized to {@link SymmioRequestError}.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { data } = useTradeVolume({ symbolId: 1 });
|
|
22
|
+
* const latest = data?.at(-1);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useTradeVolume(parameters: UseTradeVolumeParameters): UseTradeVolumeReturnType;
|
|
26
|
+
//# sourceMappingURL=use-trade-volume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trade-volume.d.ts","sourceRoot":"","sources":["../../src/trade-volume/use-trade-volume.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC9B,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,wBAAwB,GAAG,qBAAqB,GAAG,eAAe,CAAC;AAE/E,6CAA6C;AAC7C,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC,wBAAwB,EAAE,kBAAkB,CAAC,CAAC;AAEpG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,wBAAwB,GAAG,wBAAwB,CAkB7F"}
|
|
@@ -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 { getTradeVolumeQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/trade-volume/use-trade-volume.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 useTradeVolume };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-trade-volume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trade-volume.js","names":[],"sources":["../../src/trade-volume/use-trade-volume.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getTradeVolumeQueryOptions,\n type ConfigParameter,\n type GetTradeVolumeOptions,\n type GetTradeVolumeReturnType,\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 useTradeVolume}: the core query options (required\n * `symbolId`, chain id, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseTradeVolumeParameters = GetTradeVolumeOptions & ConfigParameter;\n\n/** Return type of {@link useTradeVolume}. */\nexport type UseTradeVolumeReturnType = UseQueryResult<GetTradeVolumeReturnType, SymmioRequestError>;\n\n/**\n * Read the last N daily trade-volume rows for one market from the active chain's\n * enigma solver. Rows are ascending by day. The query is disabled until a\n * positive `symbolId` is supplied.\n *\n * Does not poll by default; pass `query.refetchInterval` to opt into polling.\n * Errors are normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data } = useTradeVolume({ symbolId: 1 });\n * const latest = data?.at(-1);\n * ```\n */\nexport function useTradeVolume(parameters: UseTradeVolumeParameters): UseTradeVolumeReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getTradeVolumeQueryOptions(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 UseTradeVolumeReturnType;\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,EAAe,GAAgE;CAC7F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA2B,GAAQ;EACjD,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"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
/**
|
|
3
|
+
* Invalidate every cached sub-account balance read — `balanceOf` and
|
|
4
|
+
* `balanceInfoOfPartyA` — on one chain config.
|
|
5
|
+
*
|
|
6
|
+
* Call this from any mutation that moves collateral: an open locks margin and
|
|
7
|
+
* charges a fee, a close releases margin and realizes PnL, a cancel unlocks a
|
|
8
|
+
* pending quote's reserved margin. Without it those reads keep serving the
|
|
9
|
+
* pre-trade value for as long as the consumer's `staleTime` allows, because a
|
|
10
|
+
* mount only refetches when the entry is already stale.
|
|
11
|
+
*
|
|
12
|
+
* Invalidating also covers consumers that are not mounted at the time of the
|
|
13
|
+
* write. An unmounted query cannot refetch, but it is flagged
|
|
14
|
+
* `isInvalidated`, and TanStack checks that flag ahead of `staleTime` — so the
|
|
15
|
+
* next mount refetches no matter how fresh the cached value looks.
|
|
16
|
+
*
|
|
17
|
+
* Scoped by `configKey`, not by account, on purpose: a position write can move
|
|
18
|
+
* both a Virtual Account's balance and its parent sub-account's, while the
|
|
19
|
+
* mutation variables carry only `partyA` — the VA for isolated positions, the
|
|
20
|
+
* sub-account for cross-margin, never both.
|
|
21
|
+
*
|
|
22
|
+
* @param queryClient - The active TanStack query client.
|
|
23
|
+
* @param scope - The chain-config fingerprint from `config.getChainConfigKey()`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* onSuccess: (_result, variables) => {
|
|
28
|
+
* const configKey = config.getChainConfigKey(variables.chainId ?? chainId);
|
|
29
|
+
* invalidateAccountBalances(queryClient, { configKey });
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function invalidateAccountBalances(queryClient: QueryClient, scope: {
|
|
34
|
+
configKey?: string;
|
|
35
|
+
}): void;
|
|
36
|
+
//# sourceMappingURL=invalidate-account-balances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate-account-balances.d.ts","sourceRoot":"","sources":["../../src/utils/invalidate-account-balances.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGvG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { predicateMatch as e } from "./predicate-match.js";
|
|
2
|
+
import { getAccountBalanceInfoQueryKey as t, getAccountBalanceOfQueryKey as n } from "@symmio/trading-core";
|
|
3
|
+
//#region src/utils/invalidate-account-balances.ts
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
r.invalidateQueries({ predicate: e(n, i) }), r.invalidateQueries({ predicate: e(t, i) });
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { r as invalidateAccountBalances };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=invalidate-account-balances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate-account-balances.js","names":[],"sources":["../../src/utils/invalidate-account-balances.ts"],"sourcesContent":["import { getAccountBalanceInfoQueryKey, getAccountBalanceOfQueryKey } from \"@symmio/trading-core\";\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport { predicateMatch } from \"./predicate-match\";\n\n/**\n * Invalidate every cached sub-account balance read — `balanceOf` and\n * `balanceInfoOfPartyA` — on one chain config.\n *\n * Call this from any mutation that moves collateral: an open locks margin and\n * charges a fee, a close releases margin and realizes PnL, a cancel unlocks a\n * pending quote's reserved margin. Without it those reads keep serving the\n * pre-trade value for as long as the consumer's `staleTime` allows, because a\n * mount only refetches when the entry is already stale.\n *\n * Invalidating also covers consumers that are not mounted at the time of the\n * write. An unmounted query cannot refetch, but it is flagged\n * `isInvalidated`, and TanStack checks that flag ahead of `staleTime` — so the\n * next mount refetches no matter how fresh the cached value looks.\n *\n * Scoped by `configKey`, not by account, on purpose: a position write can move\n * both a Virtual Account's balance and its parent sub-account's, while the\n * mutation variables carry only `partyA` — the VA for isolated positions, the\n * sub-account for cross-margin, never both.\n *\n * @param queryClient - The active TanStack query client.\n * @param scope - The chain-config fingerprint from `config.getChainConfigKey()`.\n *\n * @example\n * ```ts\n * onSuccess: (_result, variables) => {\n * const configKey = config.getChainConfigKey(variables.chainId ?? chainId);\n * invalidateAccountBalances(queryClient, { configKey });\n * };\n * ```\n */\nexport function invalidateAccountBalances(queryClient: QueryClient, scope: { configKey?: string }): void {\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceOfQueryKey, scope) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceInfoQueryKey, scope) });\n}\n"],"mappings":";;;AAmCA,SAAgB,EAA0B,GAA0B,GAAqC;CAEvG,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAK,EAAE,CAAC,GACpG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAK,EAAE,CAAC;AACxG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigParameter, Notification, SocketStatus } from '@symmio/trading-core';
|
|
1
|
+
import { ConfigParameter, Notification, SocketStatus, SolverId } from '@symmio/trading-core';
|
|
2
2
|
import { Address } from 'viem';
|
|
3
3
|
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
@@ -9,6 +9,8 @@ export interface UseNotificationsParameters extends ConfigParameter {
|
|
|
9
9
|
account?: Address;
|
|
10
10
|
/** Target chain id. Defaults to the SDK's active chain. */
|
|
11
11
|
chainId?: number;
|
|
12
|
+
/** Target solver. Defaults to the chain's default solver; selects the notifications endpoint + protocol. */
|
|
13
|
+
solverId?: SolverId;
|
|
12
14
|
/** Optional per-message callback, invoked in addition to buffering. */
|
|
13
15
|
onNotification?: (notification: Notification) => void;
|
|
14
16
|
/** Max notifications retained in `notifications` (newest-first). Default 50. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-notifications.d.ts","sourceRoot":"","sources":["../../src/websocket/use-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-notifications.d.ts","sourceRoot":"","sources":["../../src/websocket/use-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAOzE;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,uEAAuE;IACvE,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IACtD,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,+CAA+C;IAC/C,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,uDAAuD;IACvD,MAAM,EAAE,YAAY,CAAC;IACrB,6DAA6D;IAC7D,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,0BAA+B,GAAG,0BAA0B,CAsDxG"}
|
|
@@ -7,42 +7,44 @@ import { useEffect as i, useRef as a, useState as o } from "react";
|
|
|
7
7
|
//#region src/websocket/use-notifications.ts
|
|
8
8
|
var s = 50;
|
|
9
9
|
function c(c = {}) {
|
|
10
|
-
let { account: l, chainId: u,
|
|
11
|
-
C.current = d;
|
|
12
|
-
let w = a(f);
|
|
10
|
+
let { account: l, chainId: u, solverId: d, onNotification: f, limit: p = s, enabled: m = !0 } = c, h = t(c), g = e(), _ = u ?? g, [v, y] = o([]), [b, x] = o("closed"), [S, C] = o(null), w = a(f);
|
|
13
11
|
w.current = f;
|
|
14
|
-
let T = p
|
|
12
|
+
let T = a(p);
|
|
13
|
+
T.current = p;
|
|
14
|
+
let E = m && !!l;
|
|
15
15
|
return i(() => {
|
|
16
|
-
if (!
|
|
17
|
-
|
|
16
|
+
if (!E || !l) {
|
|
17
|
+
x("closed");
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
y([]), C(null);
|
|
21
21
|
let e;
|
|
22
22
|
try {
|
|
23
|
-
e = r(
|
|
23
|
+
e = r(h, {
|
|
24
24
|
account: l,
|
|
25
|
-
chainId:
|
|
25
|
+
chainId: _,
|
|
26
|
+
solverId: d,
|
|
26
27
|
onNotification: (e) => {
|
|
27
|
-
|
|
28
|
+
y((t) => [e, ...t].slice(0, T.current)), w.current?.(e);
|
|
28
29
|
},
|
|
29
|
-
onStatusChange:
|
|
30
|
-
onError: (e) =>
|
|
30
|
+
onStatusChange: x,
|
|
31
|
+
onError: (e) => C(n(e))
|
|
31
32
|
});
|
|
32
33
|
} catch (e) {
|
|
33
|
-
|
|
34
|
+
C(n(e)), x("closed");
|
|
34
35
|
}
|
|
35
36
|
return () => e?.();
|
|
36
37
|
}, [
|
|
37
|
-
|
|
38
|
+
E,
|
|
38
39
|
l,
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
h,
|
|
41
|
+
_,
|
|
42
|
+
d
|
|
41
43
|
]), {
|
|
42
|
-
notifications:
|
|
43
|
-
latest:
|
|
44
|
-
status:
|
|
45
|
-
error:
|
|
44
|
+
notifications: v,
|
|
45
|
+
latest: v[0] ?? null,
|
|
46
|
+
status: b,
|
|
47
|
+
error: S
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-notifications.js","names":[],"sources":["../../src/websocket/use-notifications.ts"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"use-notifications.js","names":[],"sources":["../../src/websocket/use-notifications.ts"],"sourcesContent":["\"use client\";\n\nimport {\n watchNotifications,\n type ConfigParameter,\n type Notification,\n type SocketStatus,\n type SolverId,\n} from \"@symmio/trading-core\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Address } from \"viem\";\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/** Default number of notifications retained in the buffer. */\nconst DEFAULT_LIMIT = 50;\n\n/**\n * Parameters for {@link useNotifications}.\n */\nexport interface UseNotificationsParameters extends ConfigParameter {\n /** SubAccount address to subscribe for. The hook is idle until this is set. */\n account?: Address;\n /** Target chain id. Defaults to the SDK's active chain. */\n chainId?: number;\n /** Target solver. Defaults to the chain's default solver; selects the notifications endpoint + protocol. */\n solverId?: SolverId;\n /** Optional per-message callback, invoked in addition to buffering. */\n onNotification?: (notification: Notification) => void;\n /** Max notifications retained in `notifications` (newest-first). Default 50. */\n limit?: number;\n /** Subscribe only when `true` (and an account is set). Default `true`. */\n enabled?: boolean;\n}\n\n/**\n * Value returned by {@link useNotifications}.\n */\nexport interface UseNotificationsReturnType {\n /** Buffered notifications, newest first, capped at `limit`. */\n notifications: Notification[];\n /** The most recent notification, or `null`. */\n latest: Notification | null;\n /** Live connection status of the underlying socket. */\n status: SocketStatus;\n /** The last transport/parse error, normalized, or `null`. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Subscribe to live SYMMIO position/quote notifications for an account.\n *\n * Opens a reconnecting subscription via the SDK's `watchNotifications`, buffers\n * incoming messages newest-first (capped at `limit`), and surfaces the live\n * connection `status`. Pass `onNotification` to also react to each message\n * imperatively. The subscription is torn down on unmount or when `account` /\n * `chainId` / `enabled` change.\n *\n * @example\n * ```tsx\n * const { notifications, status } = useNotifications({ account });\n * return <Badge status={status} count={notifications.length} />;\n * ```\n */\nexport function useNotifications(parameters: UseNotificationsParameters = {}): UseNotificationsReturnType {\n const { account, chainId, solverId, onNotification, limit = DEFAULT_LIMIT, enabled = true } = parameters;\n const config = useSymmioConfig(parameters);\n const defaultChainId = useSymmioChainId();\n const resolvedChainId = chainId ?? defaultChainId;\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [status, setStatus] = useState<SocketStatus>(\"closed\");\n const [error, setError] = useState<SymmioRequestError | null>(null);\n\n // Keep the latest callback/limit without forcing the subscription to re-open.\n const onNotificationRef = useRef(onNotification);\n onNotificationRef.current = onNotification;\n const limitRef = useRef(limit);\n limitRef.current = limit;\n\n const active = enabled && Boolean(account);\n\n useEffect(() => {\n if (!active || !account) {\n setStatus(\"closed\");\n return;\n }\n\n setNotifications([]);\n setError(null);\n\n let unwatch: (() => void) | undefined;\n try {\n unwatch = watchNotifications(config, {\n account,\n chainId: resolvedChainId,\n solverId,\n onNotification: (notification) => {\n setNotifications((prev) => [notification, ...prev].slice(0, limitRef.current));\n onNotificationRef.current?.(notification);\n },\n onStatusChange: setStatus,\n onError: (err) => setError(normalizeSymmError(err)),\n });\n } catch (err) {\n setError(normalizeSymmError(err));\n setStatus(\"closed\");\n }\n\n return () => unwatch?.();\n }, [active, account, config, resolvedChainId, solverId]);\n\n return {\n notifications,\n latest: notifications[0] ?? null,\n status,\n error,\n };\n}\n"],"mappings":";;;;;;;AAiBA,IAAM,IAAgB;AAiDtB,SAAgB,EAAiB,IAAyC,CAAC,GAA+B;CACxG,IAAM,EAAE,YAAS,YAAS,aAAU,mBAAgB,WAAQ,GAAe,aAAU,OAAS,GACxF,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAkB,KAAW,GAE7B,CAAC,GAAe,KAAoB,EAAyB,CAAC,CAAC,GAC/D,CAAC,GAAQ,KAAa,EAAuB,QAAQ,GACrD,CAAC,GAAO,KAAY,EAAoC,IAAI,GAG5D,IAAoB,EAAO,CAAc;CAC/C,EAAkB,UAAU;CAC5B,IAAM,IAAW,EAAO,CAAK;CAC7B,EAAS,UAAU;CAEnB,IAAM,IAAS,KAAW,EAAQ;CAgClC,OA9BA,QAAgB;EACd,IAAI,CAAC,KAAU,CAAC,GAAS;GACvB,EAAU,QAAQ;GAClB;EACF;EAGA,AADA,EAAiB,CAAC,CAAC,GACnB,EAAS,IAAI;EAEb,IAAI;EACJ,IAAI;GACF,IAAU,EAAmB,GAAQ;IACnC;IACA,SAAS;IACT;IACA,iBAAiB,MAAiB;KAEhC,AADA,GAAkB,MAAS,CAAC,GAAc,GAAG,CAAI,EAAE,MAAM,GAAG,EAAS,OAAO,CAAC,GAC7E,EAAkB,UAAU,CAAY;IAC1C;IACA,gBAAgB;IAChB,UAAU,MAAQ,EAAS,EAAmB,CAAG,CAAC;GACpD,CAAC;EACH,SAAS,GAAK;GAEZ,AADA,EAAS,EAAmB,CAAG,CAAC,GAChC,EAAU,QAAQ;EACpB;EAEA,aAAa,IAAU;CACzB,GAAG;EAAC;EAAQ;EAAS;EAAQ;EAAiB;CAAQ,CAAC,GAEhD;EACL;EACA,QAAQ,EAAc,MAAM;EAC5B;EACA;CACF;AACF"}
|
package/dist/withdraw/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './use-request-cancel-withdraw.js';
|
|
|
6
6
|
export * from './use-simulate-finalize-withdraw-request.js';
|
|
7
7
|
export * from './use-simulate-initiate-withdraw.js';
|
|
8
8
|
export * from './use-simulate-request-cancel-withdraw.js';
|
|
9
|
+
export * from './use-withdraw.js';
|
|
9
10
|
export * from './use-withdraw-requests.js';
|
|
10
11
|
export * from './use-withdrawable-time.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withdraw/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withdraw/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
@@ -21,7 +21,7 @@ export type UseInitiateWithdrawReturnType = UseMutationResult<InitiateWithdrawRe
|
|
|
21
21
|
* ```tsx
|
|
22
22
|
* import { createClassicWithdrawPart } from "@symmio/trading-core";
|
|
23
23
|
* const { mutate } = useInitiateWithdraw();
|
|
24
|
-
* mutate({ account: "0xsub…", parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId:
|
|
24
|
+
* mutate({ account: "0xsub…", parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId: 42161n })] });
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export declare function useInitiateWithdraw(parameters?: UseInitiateWithdrawParameters): UseInitiateWithdrawReturnType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-initiate-withdraw.js","names":[],"sources":["../../src/withdraw/use-initiate-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getLastWithdrawRequestIdQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n initiateWithdrawMutationOptions,\n type InitiateWithdrawParameters,\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/**\n * Parameters for {@link useInitiateWithdraw}.\n */\nexport type UseInitiateWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useInitiateWithdraw} mutation. */\nexport type InitiateWithdrawResult = WriteResult;\n\n/** Return type of {@link useInitiateWithdraw}. */\nexport type UseInitiateWithdrawReturnType = UseMutationResult<\n InitiateWithdrawResult,\n SymmioRequestError,\n InitiateWithdrawParameters\n>;\n\n/**\n * Open a withdraw request for a subaccount (the SDK routes it through the\n * AccountLayer `_call` proxy). The full input surface is exposed via the mutation\n * variables — `parts`, `speedUp`, `providerData`. On success, the subaccount's\n * pending-requests, last-request-id, and withdrawable-time queries are\n * invalidated.\n *\n * @example\n * ```tsx\n * import { createClassicWithdrawPart } from \"@symmio/trading-core\";\n * const { mutate } = useInitiateWithdraw();\n * mutate({ account: \"0xsub…\", parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId:
|
|
1
|
+
{"version":3,"file":"use-initiate-withdraw.js","names":[],"sources":["../../src/withdraw/use-initiate-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getLastWithdrawRequestIdQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n initiateWithdrawMutationOptions,\n type InitiateWithdrawParameters,\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/**\n * Parameters for {@link useInitiateWithdraw}.\n */\nexport type UseInitiateWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useInitiateWithdraw} mutation. */\nexport type InitiateWithdrawResult = WriteResult;\n\n/** Return type of {@link useInitiateWithdraw}. */\nexport type UseInitiateWithdrawReturnType = UseMutationResult<\n InitiateWithdrawResult,\n SymmioRequestError,\n InitiateWithdrawParameters\n>;\n\n/**\n * Open a withdraw request for a subaccount (the SDK routes it through the\n * AccountLayer `_call` proxy). The full input surface is exposed via the mutation\n * variables — `parts`, `speedUp`, `providerData`. On success, the subaccount's\n * pending-requests, last-request-id, and withdrawable-time queries are\n * invalidated.\n *\n * @example\n * ```tsx\n * import { createClassicWithdrawPart } from \"@symmio/trading-core\";\n * const { mutate } = useInitiateWithdraw();\n * mutate({ account: \"0xsub…\", parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId: 42161n })] });\n * ```\n */\nexport function useInitiateWithdraw(parameters: UseInitiateWithdrawParameters = {}): UseInitiateWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = initiateWithdrawMutationOptions(config);\n\n return useMutation<InitiateWithdrawResult, SymmioRequestError, InitiateWithdrawParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({\n account: variables.account,\n parts: variables.parts,\n speedUp: variables.speedUp,\n providerData: variables.providerData,\n simulateBeforeWrite: variables.simulateBeforeWrite,\n chainId: resolvedChainId,\n });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n const partial = { user: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getLastWithdrawRequestIdQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawableTimeQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAgB,EAAoB,IAA4C,CAAC,GAAkC;CACjH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAgC,CAAM;CAEnD,OAAO,EAAoF;EACzF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAS7C,OAAO,EAAmB,GAAQ,MARf,EAAK,WAAW;KACjC,SAAS,EAAU;KACnB,OAAO,EAAU;KACjB,SAAS,EAAU;KACnB,cAAc,EAAU;KACxB,qBAAqB,EAAU;KAC/B,SAAS;IACX,CAAC,GACuC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GACjC,IAAM,IAAU,EAAE,MAAM,EAAU,QAAQ;GAG1C,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAoC,CAAO,EAAE,CAAC,GAC7G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAkC,CAAO,EAAE,CAAC,GAC3G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC;EACxG;CACF,CAAC;AACH"}
|
|
@@ -12,8 +12,10 @@ export type RequestCancelWithdrawResult = WriteResult;
|
|
|
12
12
|
export type UseRequestCancelWithdrawReturnType = UseMutationResult<RequestCancelWithdrawResult, SymmioRequestError, RequestCancelWithdrawParameters>;
|
|
13
13
|
/**
|
|
14
14
|
* Request cancellation of a pending withdraw request (routed through the
|
|
15
|
-
* AccountLayer `_call` proxy). On success, the subaccount's
|
|
16
|
-
*
|
|
15
|
+
* AccountLayer `_call` proxy). On success (after the receipt), the subaccount's
|
|
16
|
+
* balance reads (`balanceInfo`, `balanceOf`) and its pending-requests / requests
|
|
17
|
+
* queries are invalidated — cancel returns the reserved funds to the available
|
|
18
|
+
* balance.
|
|
17
19
|
*
|
|
18
20
|
* @example
|
|
19
21
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-request-cancel-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-request-cancel-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,eAAe,CAAC;AAEjE,wEAAwE;AACxE,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC;AAEtD,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,iBAAiB,CAChE,2BAA2B,EAC3B,kBAAkB,EAClB,+BAA+B,CAChC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,kCAAuC,GAClD,kCAAkC,CAyCpC"}
|
|
@@ -4,37 +4,39 @@ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
|
4
4
|
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
5
|
import { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
|
|
6
6
|
import { predicateMatch as i } from "../utils/predicate-match.js";
|
|
7
|
-
import {
|
|
8
|
-
import { useMutation as
|
|
7
|
+
import { getAccountBalanceInfoQueryKey as a, getAccountBalanceOfQueryKey as o, getPendingWithdrawRequestsQueryKey as s, getWithdrawRequestsQueryKey as c, requestCancelWithdrawMutationOptions as l } from "@symmio/trading-core";
|
|
8
|
+
import { useMutation as u, useQueryClient as d } from "@tanstack/react-query";
|
|
9
9
|
//#region src/withdraw/use-request-cancel-withdraw.ts
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
return
|
|
13
|
-
mutationKey:
|
|
10
|
+
function f(f = {}) {
|
|
11
|
+
let p = t(f), m = e(), h = d(), g = l(p);
|
|
12
|
+
return u({
|
|
13
|
+
mutationKey: g.mutationKey,
|
|
14
14
|
mutationFn: async (e) => {
|
|
15
15
|
try {
|
|
16
|
-
let t = e.chainId ??
|
|
17
|
-
return r(
|
|
16
|
+
let t = e.chainId ?? m;
|
|
17
|
+
return r(p, await g.mutationFn({
|
|
18
18
|
account: e.account,
|
|
19
19
|
requestId: e.requestId,
|
|
20
20
|
simulateBeforeWrite: e.simulateBeforeWrite,
|
|
21
21
|
chainId: t
|
|
22
22
|
}), {
|
|
23
23
|
chainId: t,
|
|
24
|
-
waitForReceipt:
|
|
25
|
-
confirmations:
|
|
24
|
+
waitForReceipt: f.waitForReceipt,
|
|
25
|
+
confirmations: f.confirmations
|
|
26
26
|
});
|
|
27
27
|
} catch (e) {
|
|
28
28
|
throw n(e);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
onSuccess: (e, t) => {
|
|
32
|
-
let n = {
|
|
33
|
-
|
|
32
|
+
let n = { account: t.account };
|
|
33
|
+
h.invalidateQueries({ predicate: i(a, n) }), h.invalidateQueries({ predicate: i(o, n) });
|
|
34
|
+
let r = { user: t.account };
|
|
35
|
+
h.invalidateQueries({ predicate: i(s, r) }), h.invalidateQueries({ predicate: i(c, r) });
|
|
34
36
|
}
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
//#endregion
|
|
38
|
-
export {
|
|
40
|
+
export { f as useRequestCancelWithdraw };
|
|
39
41
|
|
|
40
42
|
//# sourceMappingURL=use-request-cancel-withdraw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-request-cancel-withdraw.js","names":[],"sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getPendingWithdrawRequestsQueryKey,\n getWithdrawRequestsQueryKey,\n requestCancelWithdrawMutationOptions,\n type RequestCancelWithdrawParameters,\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/**\n * Parameters for {@link useRequestCancelWithdraw}.\n */\nexport type UseRequestCancelWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useRequestCancelWithdraw} mutation. */\nexport type RequestCancelWithdrawResult = WriteResult;\n\n/** Return type of {@link useRequestCancelWithdraw}. */\nexport type UseRequestCancelWithdrawReturnType = UseMutationResult<\n RequestCancelWithdrawResult,\n SymmioRequestError,\n RequestCancelWithdrawParameters\n>;\n\n/**\n * Request cancellation of a pending withdraw request (routed through the\n * AccountLayer `_call` proxy). On success, the subaccount's pending-requests
|
|
1
|
+
{"version":3,"file":"use-request-cancel-withdraw.js","names":[],"sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getAccountBalanceInfoQueryKey,\n getAccountBalanceOfQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawRequestsQueryKey,\n requestCancelWithdrawMutationOptions,\n type RequestCancelWithdrawParameters,\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/**\n * Parameters for {@link useRequestCancelWithdraw}.\n */\nexport type UseRequestCancelWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useRequestCancelWithdraw} mutation. */\nexport type RequestCancelWithdrawResult = WriteResult;\n\n/** Return type of {@link useRequestCancelWithdraw}. */\nexport type UseRequestCancelWithdrawReturnType = UseMutationResult<\n RequestCancelWithdrawResult,\n SymmioRequestError,\n RequestCancelWithdrawParameters\n>;\n\n/**\n * Request cancellation of a pending withdraw request (routed through the\n * AccountLayer `_call` proxy). On success (after the receipt), the subaccount's\n * balance reads (`balanceInfo`, `balanceOf`) and its pending-requests / requests\n * queries are invalidated — cancel returns the reserved funds to the available\n * balance.\n *\n * @example\n * ```tsx\n * const { mutate } = useRequestCancelWithdraw();\n * mutate({ account: \"0xsub…\", requestId: 1n });\n * ```\n */\nexport function useRequestCancelWithdraw(\n parameters: UseRequestCancelWithdrawParameters = {},\n): UseRequestCancelWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = requestCancelWithdrawMutationOptions(config);\n\n return useMutation<RequestCancelWithdrawResult, SymmioRequestError, RequestCancelWithdrawParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({\n account: variables.account,\n requestId: variables.requestId,\n simulateBeforeWrite: variables.simulateBeforeWrite,\n chainId: resolvedChainId,\n });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n // Cancel returns the reserved funds to the subaccount's available balance and\n // removes the request — refetch balances + the withdraw lists (after the receipt).\n const balancePartial = { account: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceInfoQueryKey, balancePartial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceOfQueryKey, balancePartial) });\n\n const withdrawPartial = { user: variables.account };\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, withdrawPartial),\n });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawRequestsQueryKey, withdrawPartial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAgB,EACd,IAAiD,CAAC,GACd;CACpC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAqC,CAAM;CAExD,OAAO,EAA8F;EACnG,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAO7C,OAAO,EAAmB,GAAQ,MANf,EAAK,WAAW;KACjC,SAAS,EAAU;KACnB,WAAW,EAAU;KACrB,qBAAqB,EAAU;KAC/B,SAAS;IACX,CAAC,GACuC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAGjC,IAAM,IAAiB,EAAE,SAAS,EAAU,QAAQ;GAEpD,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAc,EAAE,CAAC,GAC/G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAc,EAAE,CAAC;GAE7G,IAAM,IAAkB,EAAE,MAAM,EAAU,QAAQ;GAIlD,AAHA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC,CAAe,EAC/E,CAAC,GACD,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAe,EAAE,CAAC;EAChH;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { WithdrawAutoParameters } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { Address } from 'viem';
|
|
4
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
5
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Parameters for {@link useWithdraw}. `account` (the subaccount) and `chainId` are
|
|
8
|
+
* read at hook time so the hook can resolve the subaccount's isolation type via
|
|
9
|
+
* {@link useSubAccount}; the per-withdraw inputs (`amount`, `receiver`, …) are the
|
|
10
|
+
* mutation variables.
|
|
11
|
+
*/
|
|
12
|
+
export type UseWithdrawParameters = WriteParameters & {
|
|
13
|
+
/** The subaccount to withdraw from. The connected wallet must be its on-chain owner. */
|
|
14
|
+
account?: Address;
|
|
15
|
+
/** Target chain id. Defaults to the connected chain. */
|
|
16
|
+
chainId?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Variables for the {@link useWithdraw} mutation — the per-withdraw inputs, with
|
|
20
|
+
* `amount` in the **collateral token's decimals**. `account`, `chainId`, and
|
|
21
|
+
* `isolationType` are supplied by the hook, so the caller never passes them (nor
|
|
22
|
+
* `parts`). `upnlSig` is optional; on the `CUSTOM` path a fresh Muon uPnL signature
|
|
23
|
+
* is fetched for the deallocate leg when omitted.
|
|
24
|
+
*/
|
|
25
|
+
export type UseWithdrawVariables = Omit<WithdrawAutoParameters, "account" | "isolationType" | "chainId">;
|
|
26
|
+
/** Result returned by the {@link useWithdraw} mutation. */
|
|
27
|
+
export type WithdrawResult = WriteResult;
|
|
28
|
+
/** Return type of {@link useWithdraw}. */
|
|
29
|
+
export type UseWithdrawReturnType = UseMutationResult<WithdrawResult, SymmioRequestError, UseWithdrawVariables>;
|
|
30
|
+
/**
|
|
31
|
+
* Withdraw from a subaccount from a **minimal, collateral-decimals input** — the
|
|
32
|
+
* high-level entry point that hides isolation, parts, and amount scaling.
|
|
33
|
+
*
|
|
34
|
+
* Pass the `account` (and optional `chainId`) to the hook; call `mutate` with just
|
|
35
|
+
* `{ amount, receiver }`. The hook reads the subaccount's `isolationType` with
|
|
36
|
+
* {@link useSubAccount} (deduped with any other `useSubAccount` on the same key —
|
|
37
|
+
* e.g. one already driving a balance display) and hands it to the SDK, so the core
|
|
38
|
+
* action skips a redundant on-chain read and picks the path: a `CUSTOM`
|
|
39
|
+
* (cross-margin) subaccount deallocates then initiates in one atomic transaction; a
|
|
40
|
+
* `MARKET` / `MARKET_DIRECTION` (VA / lowcap) subaccount only initiates the withdraw
|
|
41
|
+
* request. On a cache miss the core action resolves `isolationType` itself.
|
|
42
|
+
*
|
|
43
|
+
* `amount` is in the **collateral token's decimals** (e.g. 6 for USDC). The hook
|
|
44
|
+
* builds the classic same-chain withdraw part from it and, on the `CUSTOM` path,
|
|
45
|
+
* scales it to the 18-decimal amount the deallocate leg needs — the caller does not
|
|
46
|
+
* scale anything.
|
|
47
|
+
*
|
|
48
|
+
* On success, the subaccount's balance reads (`balanceInfo`, `balanceOf`) and its
|
|
49
|
+
* pending-requests / withdrawable-time reads are invalidated.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* On the `CUSTOM` path the SDK fetches a fresh Muon uPnL signature for the
|
|
53
|
+
* deallocate leg unless you pass one as `upnlSig`; that leg is subject to the
|
|
54
|
+
* on-chain deallocate debounce. Failures surface as a normalized
|
|
55
|
+
* {@link SymmioRequestError}. Reach for `useDeallocateAndInitiateWithdraw` /
|
|
56
|
+
* `useInitiateWithdraw` when you already know the isolation and want to drive one
|
|
57
|
+
* specific path, or need custom (multi-part / cross-chain) withdraw parts.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* const { mutate } = useWithdraw({ account: "0xsub…" });
|
|
62
|
+
* // amount in the collateral token's decimals (6-dec USDC → 1 USDC):
|
|
63
|
+
* mutate({ amount: 1_000000n, receiver: "0xabc…" });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function useWithdraw(parameters?: UseWithdrawParameters): UseWithdrawReturnType;
|
|
67
|
+
//# sourceMappingURL=use-withdraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG;IACpD,wFAAwF;IACxF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,CAAC,CAAC;AAEzG,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AAEzC,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AAEhH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,WAAW,CAAC,UAAU,GAAE,qBAA0B,GAAG,qBAAqB,CAiDzF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
|
|
6
|
+
import { predicateMatch as i } from "../utils/predicate-match.js";
|
|
7
|
+
import { useSubAccount as a } from "../account-layer/use-sub-account.js";
|
|
8
|
+
import { SymmError as o, getAccountBalanceInfoQueryKey as s, getAccountBalanceOfQueryKey as c, getPendingWithdrawRequestsQueryKey as l, getWithdrawableTimeQueryKey as u, withdrawAutoMutationOptions as d } from "@symmio/trading-core";
|
|
9
|
+
import { useMutation as f, useQueryClient as p } from "@tanstack/react-query";
|
|
10
|
+
//#region src/withdraw/use-withdraw.ts
|
|
11
|
+
function m(m = {}) {
|
|
12
|
+
let h = t(m), g = e(), _ = p(), v = m.chainId ?? g, { data: y } = a({
|
|
13
|
+
account: m.account,
|
|
14
|
+
chainId: m.chainId
|
|
15
|
+
}), b = y?.isolationType, x = d(h);
|
|
16
|
+
return f({
|
|
17
|
+
mutationKey: x.mutationKey,
|
|
18
|
+
mutationFn: async (e) => {
|
|
19
|
+
try {
|
|
20
|
+
let t = m.account;
|
|
21
|
+
if (!t) throw new o("validation", "MISSING_ACCOUNT", "useWithdraw: `account` must be set on the hook.");
|
|
22
|
+
return r(h, await x.mutationFn({
|
|
23
|
+
...e,
|
|
24
|
+
account: t,
|
|
25
|
+
chainId: v,
|
|
26
|
+
isolationType: b
|
|
27
|
+
}), {
|
|
28
|
+
chainId: v,
|
|
29
|
+
waitForReceipt: m.waitForReceipt,
|
|
30
|
+
confirmations: m.confirmations
|
|
31
|
+
});
|
|
32
|
+
} catch (e) {
|
|
33
|
+
throw n(e);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
let e = m.account;
|
|
38
|
+
if (!e) return;
|
|
39
|
+
let t = { account: e };
|
|
40
|
+
_.invalidateQueries({ predicate: i(s, t) }), _.invalidateQueries({ predicate: i(c, t) });
|
|
41
|
+
let n = { user: e };
|
|
42
|
+
_.invalidateQueries({ predicate: i(l, n) }), _.invalidateQueries({ predicate: i(u, n) });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { m as useWithdraw };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=use-withdraw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-withdraw.js","names":[],"sources":["../../src/withdraw/use-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getAccountBalanceInfoQueryKey,\n getAccountBalanceOfQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n SymmError,\n withdrawAutoMutationOptions,\n type WithdrawAutoParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport type { Address } from \"viem\";\nimport { useSubAccount } from \"../account-layer/use-sub-account\";\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/**\n * Parameters for {@link useWithdraw}. `account` (the subaccount) and `chainId` are\n * read at hook time so the hook can resolve the subaccount's isolation type via\n * {@link useSubAccount}; the per-withdraw inputs (`amount`, `receiver`, …) are the\n * mutation variables.\n */\nexport type UseWithdrawParameters = WriteParameters & {\n /** The subaccount to withdraw from. The connected wallet must be its on-chain owner. */\n account?: Address;\n /** Target chain id. Defaults to the connected chain. */\n chainId?: number;\n};\n\n/**\n * Variables for the {@link useWithdraw} mutation — the per-withdraw inputs, with\n * `amount` in the **collateral token's decimals**. `account`, `chainId`, and\n * `isolationType` are supplied by the hook, so the caller never passes them (nor\n * `parts`). `upnlSig` is optional; on the `CUSTOM` path a fresh Muon uPnL signature\n * is fetched for the deallocate leg when omitted.\n */\nexport type UseWithdrawVariables = Omit<WithdrawAutoParameters, \"account\" | \"isolationType\" | \"chainId\">;\n\n/** Result returned by the {@link useWithdraw} mutation. */\nexport type WithdrawResult = WriteResult;\n\n/** Return type of {@link useWithdraw}. */\nexport type UseWithdrawReturnType = UseMutationResult<WithdrawResult, SymmioRequestError, UseWithdrawVariables>;\n\n/**\n * Withdraw from a subaccount from a **minimal, collateral-decimals input** — the\n * high-level entry point that hides isolation, parts, and amount scaling.\n *\n * Pass the `account` (and optional `chainId`) to the hook; call `mutate` with just\n * `{ amount, receiver }`. The hook reads the subaccount's `isolationType` with\n * {@link useSubAccount} (deduped with any other `useSubAccount` on the same key —\n * e.g. one already driving a balance display) and hands it to the SDK, so the core\n * action skips a redundant on-chain read and picks the path: a `CUSTOM`\n * (cross-margin) subaccount deallocates then initiates in one atomic transaction; a\n * `MARKET` / `MARKET_DIRECTION` (VA / lowcap) subaccount only initiates the withdraw\n * request. On a cache miss the core action resolves `isolationType` itself.\n *\n * `amount` is in the **collateral token's decimals** (e.g. 6 for USDC). The hook\n * builds the classic same-chain withdraw part from it and, on the `CUSTOM` path,\n * scales it to the 18-decimal amount the deallocate leg needs — the caller does not\n * scale anything.\n *\n * On success, the subaccount's balance reads (`balanceInfo`, `balanceOf`) and its\n * pending-requests / withdrawable-time reads are invalidated.\n *\n * @remarks\n * On the `CUSTOM` path the SDK fetches a fresh Muon uPnL signature for the\n * deallocate leg unless you pass one as `upnlSig`; that leg is subject to the\n * on-chain deallocate debounce. Failures surface as a normalized\n * {@link SymmioRequestError}. Reach for `useDeallocateAndInitiateWithdraw` /\n * `useInitiateWithdraw` when you already know the isolation and want to drive one\n * specific path, or need custom (multi-part / cross-chain) withdraw parts.\n *\n * @example\n * ```tsx\n * const { mutate } = useWithdraw({ account: \"0xsub…\" });\n * // amount in the collateral token's decimals (6-dec USDC → 1 USDC):\n * mutate({ amount: 1_000000n, receiver: \"0xabc…\" });\n * ```\n */\nexport function useWithdraw(parameters: UseWithdrawParameters = {}): UseWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const resolvedChainId = parameters.chainId ?? chainId;\n\n // Resolve the subaccount's isolation type via the standard hook (deduped by\n // react-query with any other useSubAccount on the same key), so the core action\n // skips a redundant getSubAccount RPC.\n const { data: subAccount } = useSubAccount({ account: parameters.account, chainId: parameters.chainId });\n const isolationType = subAccount?.isolationType;\n\n const base = withdrawAutoMutationOptions(config);\n\n return useMutation<WithdrawResult, SymmioRequestError, UseWithdrawVariables>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const account = parameters.account;\n if (!account) {\n throw new SymmError(\"validation\", \"MISSING_ACCOUNT\", \"useWithdraw: `account` must be set on the hook.\");\n }\n const hash = await base.mutationFn({ ...variables, account, chainId: resolvedChainId, isolationType });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n const account = parameters.account;\n if (!account) return;\n\n const balancePartial = { account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceInfoQueryKey, balancePartial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceOfQueryKey, balancePartial) });\n\n const withdrawPartial = { user: account };\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, withdrawPartial),\n });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getWithdrawableTimeQueryKey, withdrawPartial),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAqFA,SAAgB,EAAY,IAAoC,CAAC,GAA0B;CACzF,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAkB,EAAW,WAAW,GAKxC,EAAE,MAAM,MAAe,EAAc;EAAE,SAAS,EAAW;EAAS,SAAS,EAAW;CAAQ,CAAC,GACjG,IAAgB,GAAY,eAE5B,IAAO,EAA4B,CAAM;CAE/C,OAAO,EAAsE;EAC3E,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAU,EAAW;IAC3B,IAAI,CAAC,GACH,MAAM,IAAI,EAAU,cAAc,mBAAmB,iDAAiD;IAGxG,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW;KAAS,SAAS;KAAiB;IAAc,CAAC,GAC7D;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GACf,IAAM,IAAU,EAAW;GAC3B,IAAI,CAAC,GAAS;GAEd,IAAM,IAAiB,EAAE,WAAQ;GAEjC,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAc,EAAE,CAAC,GAC/G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAc,EAAE,CAAC;GAE7G,IAAM,IAAkB,EAAE,MAAM,EAAQ;GAIxC,AAHA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC,CAAe,EAC/E,CAAC,GACD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA6B,CAAe,EACxE,CAAC;EACH;CACF,CAAC;AACH"}
|