@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,27 @@
|
|
|
1
|
+
import { ForceCancelCloseRequestParameters } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
|
+
/** Parameters for {@link useForceCancelCloseRequest}. */
|
|
6
|
+
export type UseForceCancelCloseRequestParameters = WriteParameters;
|
|
7
|
+
/** Result returned by the {@link useForceCancelCloseRequest} mutation. */
|
|
8
|
+
export type ForceCancelCloseRequestResult = WriteResult;
|
|
9
|
+
/** Return type of {@link useForceCancelCloseRequest}. */
|
|
10
|
+
export type UseForceCancelCloseRequestReturnType = UseMutationResult<ForceCancelCloseRequestResult, SymmioRequestError, ForceCancelCloseRequestParameters>;
|
|
11
|
+
/**
|
|
12
|
+
* Force-cancel a stalled pending close (`forceCancelCloseRequest`, routed through
|
|
13
|
+
* the AccountLayer `_call` proxy). Only valid once the quote is
|
|
14
|
+
* `CANCEL_CLOSE_PENDING` (partyA already called `requestToCancelCloseRequest` and
|
|
15
|
+
* partyB never acted) **and** the force-cancel-close cooldown has elapsed — see
|
|
16
|
+
* {@link useCoolDownsOfMA} (index 2) plus the quote's `statusModifyTimestamp`. The
|
|
17
|
+
* quote returns to `OPENED`. On success (after the receipt) the subaccount's
|
|
18
|
+
* open-positions read is invalidated.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const { mutate } = useForceCancelCloseRequest();
|
|
23
|
+
* mutate({ account: "0xsub…", quoteId: 42n });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useForceCancelCloseRequest(parameters?: UseForceCancelCloseRequestParameters): UseForceCancelCloseRequestReturnType;
|
|
27
|
+
//# sourceMappingURL=use-force-cancel-close-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-cancel-close-request.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-cancel-close-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,iCAAiC,EACvC,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,yDAAyD;AACzD,MAAM,MAAM,oCAAoC,GAAG,eAAe,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,MAAM,6BAA6B,GAAG,WAAW,CAAC;AAExD,yDAAyD;AACzD,MAAM,MAAM,oCAAoC,GAAG,iBAAiB,CAClE,6BAA6B,EAC7B,kBAAkB,EAClB,iCAAiC,CAClC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,oCAAyC,GACpD,oCAAoC,CAmCtC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { forceCancelCloseRequestMutationOptions as a, getPartyAOpenPositionsQueryKey as o } from "@symmio/trading-core";
|
|
8
|
+
import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
|
|
9
|
+
//#region src/quotes/use-force-cancel-close-request.ts
|
|
10
|
+
function l(l = {}) {
|
|
11
|
+
let u = t(l), d = e(), f = c(), p = a(u);
|
|
12
|
+
return s({
|
|
13
|
+
mutationKey: p.mutationKey,
|
|
14
|
+
mutationFn: async (e) => {
|
|
15
|
+
try {
|
|
16
|
+
let t = e.chainId ?? d;
|
|
17
|
+
return r(u, await p.mutationFn({
|
|
18
|
+
account: e.account,
|
|
19
|
+
quoteId: e.quoteId,
|
|
20
|
+
from: e.from,
|
|
21
|
+
simulateBeforeWrite: e.simulateBeforeWrite,
|
|
22
|
+
chainId: t
|
|
23
|
+
}), {
|
|
24
|
+
chainId: t,
|
|
25
|
+
waitForReceipt: l.waitForReceipt,
|
|
26
|
+
confirmations: l.confirmations
|
|
27
|
+
});
|
|
28
|
+
} catch (e) {
|
|
29
|
+
throw n(e);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
onSuccess: (e, t) => {
|
|
33
|
+
let n = { partyA: t.account };
|
|
34
|
+
f.invalidateQueries({ predicate: i(o, n) });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { l as useForceCancelCloseRequest };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=use-force-cancel-close-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-cancel-close-request.js","names":[],"sources":["../../src/quotes/use-force-cancel-close-request.ts"],"sourcesContent":["\"use client\";\n\nimport {\n forceCancelCloseRequestMutationOptions,\n getPartyAOpenPositionsQueryKey,\n type ForceCancelCloseRequestParameters,\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 useForceCancelCloseRequest}. */\nexport type UseForceCancelCloseRequestParameters = WriteParameters;\n\n/** Result returned by the {@link useForceCancelCloseRequest} mutation. */\nexport type ForceCancelCloseRequestResult = WriteResult;\n\n/** Return type of {@link useForceCancelCloseRequest}. */\nexport type UseForceCancelCloseRequestReturnType = UseMutationResult<\n ForceCancelCloseRequestResult,\n SymmioRequestError,\n ForceCancelCloseRequestParameters\n>;\n\n/**\n * Force-cancel a stalled pending close (`forceCancelCloseRequest`, routed through\n * the AccountLayer `_call` proxy). Only valid once the quote is\n * `CANCEL_CLOSE_PENDING` (partyA already called `requestToCancelCloseRequest` and\n * partyB never acted) **and** the force-cancel-close cooldown has elapsed — see\n * {@link useCoolDownsOfMA} (index 2) plus the quote's `statusModifyTimestamp`. The\n * quote returns to `OPENED`. On success (after the receipt) the subaccount's\n * open-positions read is invalidated.\n *\n * @example\n * ```tsx\n * const { mutate } = useForceCancelCloseRequest();\n * mutate({ account: \"0xsub…\", quoteId: 42n });\n * ```\n */\nexport function useForceCancelCloseRequest(\n parameters: UseForceCancelCloseRequestParameters = {},\n): UseForceCancelCloseRequestReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = forceCancelCloseRequestMutationOptions(config);\n\n return useMutation<ForceCancelCloseRequestResult, SymmioRequestError, ForceCancelCloseRequestParameters>({\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 quoteId: variables.quoteId,\n from: variables.from,\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 // The force-cancel returns the position to OPENED — refetch the owning\n // partyA's open positions so the status updates.\n const partial = { partyA: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAOpenPositionsQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA2CA,SAAgB,EACd,IAAmD,CAAC,GACd;CACtC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAuC,CAAM;CAE1D,OAAO,EAAkG;EACvG,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAQ7C,OAAO,EAAmB,GAAQ,MAPf,EAAK,WAAW;KACjC,SAAS,EAAU;KACnB,SAAS,EAAU;KACnB,MAAM,EAAU;KAChB,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,IAAU,EAAE,QAAQ,EAAU,QAAQ;GAC5C,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC;EAC3G;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ForceCancelQuoteParameters } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
|
+
/** Parameters for {@link useForceCancelQuote}. */
|
|
6
|
+
export type UseForceCancelQuoteParameters = WriteParameters;
|
|
7
|
+
/** Result returned by the {@link useForceCancelQuote} mutation. */
|
|
8
|
+
export type ForceCancelQuoteResult = WriteResult;
|
|
9
|
+
/** Return type of {@link useForceCancelQuote}. */
|
|
10
|
+
export type UseForceCancelQuoteReturnType = UseMutationResult<ForceCancelQuoteResult, SymmioRequestError, ForceCancelQuoteParameters>;
|
|
11
|
+
/**
|
|
12
|
+
* Force-cancel a stalled quote (`forceCancelQuote`, routed through the
|
|
13
|
+
* AccountLayer `_call` proxy). Only valid once the quote is `CANCEL_PENDING`
|
|
14
|
+
* (partyA already called `requestToCancelQuote` on a `LOCKED` order) **and** the
|
|
15
|
+
* force-cancel cooldown has elapsed — see {@link useCoolDownsOfMA} (index 1) plus
|
|
16
|
+
* the quote's `statusModifyTimestamp`. On success (after the receipt) the
|
|
17
|
+
* subaccount's pending-quotes reads are invalidated so the order drops out.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { mutate } = useForceCancelQuote();
|
|
22
|
+
* mutate({ account: "0xsub…", quoteId: 42n });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useForceCancelQuote(parameters?: UseForceCancelQuoteParameters): UseForceCancelQuoteReturnType;
|
|
26
|
+
//# sourceMappingURL=use-force-cancel-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-cancel-quote.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-cancel-quote.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,0BAA0B,EAChC,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,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC;AAE5D,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAEjD,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,iBAAiB,CAC3D,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,CAC3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,6BAAkC,GAAG,6BAA6B,CAkDjH"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { invalidateAccountBalances as a } from "../utils/invalidate-account-balances.js";
|
|
8
|
+
import { forceCancelQuoteMutationOptions as o, getPartyAOpenPositionsQueryKey as s, getPartyAPendingQuotesQueryKey as c, getPendingQuotesQueryKey as l, getQuoteQueryKey as u } from "@symmio/trading-core";
|
|
9
|
+
import { useMutation as d, useQueryClient as f } from "@tanstack/react-query";
|
|
10
|
+
//#region src/quotes/use-force-cancel-quote.ts
|
|
11
|
+
function p(p = {}) {
|
|
12
|
+
let m = t(p), h = e(), g = f(), _ = o(m);
|
|
13
|
+
return d({
|
|
14
|
+
mutationKey: _.mutationKey,
|
|
15
|
+
mutationFn: async (e) => {
|
|
16
|
+
try {
|
|
17
|
+
let t = e.chainId ?? h;
|
|
18
|
+
return r(m, await _.mutationFn({
|
|
19
|
+
account: e.account,
|
|
20
|
+
quoteId: e.quoteId,
|
|
21
|
+
from: e.from,
|
|
22
|
+
simulateBeforeWrite: e.simulateBeforeWrite,
|
|
23
|
+
chainId: t
|
|
24
|
+
}), {
|
|
25
|
+
chainId: t,
|
|
26
|
+
waitForReceipt: p.waitForReceipt,
|
|
27
|
+
confirmations: p.confirmations
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
throw n(e);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
onSuccess: (e, t) => {
|
|
34
|
+
let n = { partyA: t.account };
|
|
35
|
+
g.invalidateQueries({ predicate: i(l, n) }), g.invalidateQueries({ predicate: i(c, n) }), g.invalidateQueries({ predicate: i(s, n) }), g.invalidateQueries({ predicate: i(u, { quoteId: t.quoteId }) }), a(g, { configKey: m.getChainConfigKey(t.chainId ?? h) });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { p as useForceCancelQuote };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=use-force-cancel-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-cancel-quote.js","names":[],"sources":["../../src/quotes/use-force-cancel-quote.ts"],"sourcesContent":["\"use client\";\n\nimport {\n forceCancelQuoteMutationOptions,\n getPartyAOpenPositionsQueryKey,\n getPartyAPendingQuotesQueryKey,\n getPendingQuotesQueryKey,\n getQuoteQueryKey,\n type ForceCancelQuoteParameters,\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 { invalidateAccountBalances, predicateMatch } from \"../utils\";\n\n/** Parameters for {@link useForceCancelQuote}. */\nexport type UseForceCancelQuoteParameters = WriteParameters;\n\n/** Result returned by the {@link useForceCancelQuote} mutation. */\nexport type ForceCancelQuoteResult = WriteResult;\n\n/** Return type of {@link useForceCancelQuote}. */\nexport type UseForceCancelQuoteReturnType = UseMutationResult<\n ForceCancelQuoteResult,\n SymmioRequestError,\n ForceCancelQuoteParameters\n>;\n\n/**\n * Force-cancel a stalled quote (`forceCancelQuote`, routed through the\n * AccountLayer `_call` proxy). Only valid once the quote is `CANCEL_PENDING`\n * (partyA already called `requestToCancelQuote` on a `LOCKED` order) **and** the\n * force-cancel cooldown has elapsed — see {@link useCoolDownsOfMA} (index 1) plus\n * the quote's `statusModifyTimestamp`. On success (after the receipt) the\n * subaccount's pending-quotes reads are invalidated so the order drops out.\n *\n * @example\n * ```tsx\n * const { mutate } = useForceCancelQuote();\n * mutate({ account: \"0xsub…\", quoteId: 42n });\n * ```\n */\nexport function useForceCancelQuote(parameters: UseForceCancelQuoteParameters = {}): UseForceCancelQuoteReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = forceCancelQuoteMutationOptions(config);\n\n return useMutation<ForceCancelQuoteResult, SymmioRequestError, ForceCancelQuoteParameters>({\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 quoteId: variables.quoteId,\n from: variables.from,\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 // The force-cancelled quote leaves the pending set — refetch the pending\n // reads (full quotes + ids), the open positions for this partyA, and the\n // quote's own `getQuote` hydration (the read carrying `quoteStatus`) after the\n // receipt, so managed-quotes drops the now-terminal quote.\n const partial = { partyA: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingQuotesQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAPendingQuotesQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAOpenPositionsQueryKey, partial) });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getQuoteQueryKey, { quoteId: variables.quoteId }),\n });\n /**\n * A force-cancel refunds the open trading fee and releases both parties'\n * pending locked balances in the same transaction, so every balance read is now\n * stale.\n */\n invalidateAccountBalances(queryClient, {\n configKey: config.getChainConfigKey(variables.chainId ?? chainId),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;;AA6CA,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;IAQ7C,OAAO,EAAmB,GAAQ,MAPf,EAAK,WAAW;KACjC,SAAS,EAAU;KACnB,SAAS,EAAU;KACnB,MAAM,EAAU;KAChB,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;GAKjC,IAAM,IAAU,EAAE,QAAQ,EAAU,QAAQ;GAY5C,AAXA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA0B,CAAO,EAAE,CAAC,GACnG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC,GACzG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC,GACzG,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAkB,EAAE,SAAS,EAAU,QAAQ,CAAC,EAC5E,CAAC,GAMD,EAA0B,GAAa,EACrC,WAAW,EAAO,kBAAkB,EAAU,WAAW,CAAO,EAClE,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ConfigParameter, ForceCloseEligibility, Quote } from '@symmio/trading-core';
|
|
2
|
+
/** The quote fields {@link useForceCloseEligibility} needs. */
|
|
3
|
+
export type ForceCloseEligibilityQuote = Pick<Quote, "quoteStatus" | "orderType" | "statusModifyTimestamp" | "deadline" | "symbolId">;
|
|
4
|
+
/** Parameters for {@link useForceCloseEligibility}. */
|
|
5
|
+
export type UseForceCloseEligibilityParameters = ConfigParameter & {
|
|
6
|
+
/** The quote (or a subset with the needed fields) to gate. */
|
|
7
|
+
quote?: ForceCloseEligibilityQuote;
|
|
8
|
+
};
|
|
9
|
+
/** Return type of {@link useForceCloseEligibility}. */
|
|
10
|
+
export type UseForceCloseEligibilityReturnType = ForceCloseEligibility & {
|
|
11
|
+
/** `true` while the force-close params are loading (eligibility not yet known). */
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Live force-close eligibility for a quote — the button gate + cooldown
|
|
16
|
+
* countdown. Reads the market's force-close params ({@link useForceCloseParams})
|
|
17
|
+
* and runs the pure `checkForceCloseEligibility` against a 1-second clock, so
|
|
18
|
+
* `cooldownRemaining` ticks down and `eligible` flips on the moment the cooldown
|
|
19
|
+
* elapses, without a manual refresh. Send with {@link useForceClose}.
|
|
20
|
+
*
|
|
21
|
+
* Force close is a limit-order feature (majors / rasa), so it is never eligible
|
|
22
|
+
* on a solver that does not support limit orders.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const { eligible, reason, cooldownRemaining } = useForceCloseEligibility({ quote });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useForceCloseEligibility(parameters?: UseForceCloseEligibilityParameters): UseForceCloseEligibilityReturnType;
|
|
30
|
+
//# sourceMappingURL=use-force-close-eligibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-close-eligibility.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-close-eligibility.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,KAAK,EACX,MAAM,sBAAsB,CAAC;AAK9B,+DAA+D;AAC/D,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,KAAK,EACL,aAAa,GAAG,WAAW,GAAG,uBAAuB,GAAG,UAAU,GAAG,UAAU,CAChF,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAAG;IACjE,8DAA8D;IAC9D,KAAK,CAAC,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,qBAAqB,GAAG;IACvE,mFAAmF;IACnF,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAIF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,kCAAuC,GAClD,kCAAkC,CA8BpC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSupportsLimitOrder as e } from "../solvers/use-solver-capabilities.js";
|
|
3
|
+
import { useForceCloseParams as t } from "./use-force-close-params.js";
|
|
4
|
+
import { checkForceCloseEligibility as n } from "@symmio/trading-core";
|
|
5
|
+
import { useEffect as r, useMemo as i, useState as a } from "react";
|
|
6
|
+
//#region src/quotes/use-force-close-eligibility.ts
|
|
7
|
+
var o = {
|
|
8
|
+
eligible: !1,
|
|
9
|
+
cooldownRemaining: 0n
|
|
10
|
+
};
|
|
11
|
+
function s(s = {}) {
|
|
12
|
+
let { quote: c, config: l } = s, u = e({ config: l }), d = t({
|
|
13
|
+
symbolId: c?.symbolId ?? 0n,
|
|
14
|
+
config: l,
|
|
15
|
+
query: { enabled: c !== void 0 }
|
|
16
|
+
}), f = d.data, [p, m] = a(() => BigInt(Math.floor(Date.now() / 1e3)));
|
|
17
|
+
return r(() => {
|
|
18
|
+
let e = setInterval(() => m(BigInt(Math.floor(Date.now() / 1e3))), 1e3);
|
|
19
|
+
return () => clearInterval(e);
|
|
20
|
+
}, []), {
|
|
21
|
+
...i(() => !u || !c || !f ? o : n({
|
|
22
|
+
quote: c,
|
|
23
|
+
firstCooldown: f.firstCooldown,
|
|
24
|
+
secondCooldown: f.secondCooldown,
|
|
25
|
+
minSigPeriod: f.minSigPeriod,
|
|
26
|
+
now: p
|
|
27
|
+
}), [
|
|
28
|
+
u,
|
|
29
|
+
c,
|
|
30
|
+
f,
|
|
31
|
+
p
|
|
32
|
+
]),
|
|
33
|
+
isLoading: d.isLoading
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { s as useForceCloseEligibility };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=use-force-close-eligibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-close-eligibility.js","names":[],"sources":["../../src/quotes/use-force-close-eligibility.ts"],"sourcesContent":["\"use client\";\n\nimport {\n checkForceCloseEligibility,\n type ConfigParameter,\n type ForceCloseEligibility,\n type Quote,\n} from \"@symmio/trading-core\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useSupportsLimitOrder } from \"../solvers/use-solver-capabilities\";\nimport { useForceCloseParams } from \"./use-force-close-params\";\n\n/** The quote fields {@link useForceCloseEligibility} needs. */\nexport type ForceCloseEligibilityQuote = Pick<\n Quote,\n \"quoteStatus\" | \"orderType\" | \"statusModifyTimestamp\" | \"deadline\" | \"symbolId\"\n>;\n\n/** Parameters for {@link useForceCloseEligibility}. */\nexport type UseForceCloseEligibilityParameters = ConfigParameter & {\n /** The quote (or a subset with the needed fields) to gate. */\n quote?: ForceCloseEligibilityQuote;\n};\n\n/** Return type of {@link useForceCloseEligibility}. */\nexport type UseForceCloseEligibilityReturnType = ForceCloseEligibility & {\n /** `true` while the force-close params are loading (eligibility not yet known). */\n isLoading: boolean;\n};\n\nconst NOT_ELIGIBLE: ForceCloseEligibility = { eligible: false, cooldownRemaining: 0n };\n\n/**\n * Live force-close eligibility for a quote — the button gate + cooldown\n * countdown. Reads the market's force-close params ({@link useForceCloseParams})\n * and runs the pure `checkForceCloseEligibility` against a 1-second clock, so\n * `cooldownRemaining` ticks down and `eligible` flips on the moment the cooldown\n * elapses, without a manual refresh. Send with {@link useForceClose}.\n *\n * Force close is a limit-order feature (majors / rasa), so it is never eligible\n * on a solver that does not support limit orders.\n *\n * @example\n * ```tsx\n * const { eligible, reason, cooldownRemaining } = useForceCloseEligibility({ quote });\n * ```\n */\nexport function useForceCloseEligibility(\n parameters: UseForceCloseEligibilityParameters = {},\n): UseForceCloseEligibilityReturnType {\n const { quote, config } = parameters;\n const supportsLimit = useSupportsLimitOrder({ config });\n /** `0n` is a placeholder that is never fetched — the query stays disabled until a quote is present. */\n const paramsQuery = useForceCloseParams({\n symbolId: quote?.symbolId ?? 0n,\n config,\n query: { enabled: quote !== undefined },\n });\n const params = paramsQuery.data;\n\n const [nowSec, setNowSec] = useState(() => BigInt(Math.floor(Date.now() / 1000)));\n useEffect(() => {\n const id = setInterval(() => setNowSec(BigInt(Math.floor(Date.now() / 1000))), 1000);\n return () => clearInterval(id);\n }, []);\n\n const eligibility = useMemo<ForceCloseEligibility>(() => {\n // Force close only exists on limit-supporting solvers — never eligible otherwise.\n if (!supportsLimit || !quote || !params) return NOT_ELIGIBLE;\n return checkForceCloseEligibility({\n quote,\n firstCooldown: params.firstCooldown,\n secondCooldown: params.secondCooldown,\n minSigPeriod: params.minSigPeriod,\n now: nowSec,\n });\n }, [supportsLimit, quote, params, nowSec]);\n\n return { ...eligibility, isLoading: paramsQuery.isLoading };\n}\n"],"mappings":";;;;;;AA8BA,IAAM,IAAsC;CAAE,UAAU;CAAO,mBAAmB;AAAG;AAiBrF,SAAgB,EACd,IAAiD,CAAC,GACd;CACpC,IAAM,EAAE,UAAO,cAAW,GACpB,IAAgB,EAAsB,EAAE,UAAO,CAAC,GAEhD,IAAc,EAAoB;EACtC,UAAU,GAAO,YAAY;EAC7B;EACA,OAAO,EAAE,SAAS,MAAU,KAAA,EAAU;CACxC,CAAC,GACK,IAAS,EAAY,MAErB,CAAC,GAAQ,KAAa,QAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,CAAC,CAAC;CAkBhF,OAjBA,QAAgB;EACd,IAAM,IAAK,kBAAkB,EAAU,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,CAAC,CAAC,GAAG,GAAI;EACnF,aAAa,cAAc,CAAE;CAC/B,GAAG,CAAC,CAAC,GAcE;EAAE,GAZW,QAEd,CAAC,KAAiB,CAAC,KAAS,CAAC,IAAe,IACzC,EAA2B;GAChC;GACA,eAAe,EAAO;GACtB,gBAAgB,EAAO;GACvB,cAAc,EAAO;GACrB,KAAK;EACP,CAAC,GACA;GAAC;GAAe;GAAO;GAAQ;EAAM,CAE5B;EAAa,WAAW,EAAY;CAAU;AAC5D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConfigParameter, GetForceCloseParamsData, GetForceCloseParamsOptions } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useForceCloseParams}: the core options (`symbolId`, chain id) plus an optional `config`. */
|
|
5
|
+
export type UseForceCloseParamsParameters = GetForceCloseParamsOptions & ConfigParameter;
|
|
6
|
+
/** Return type of {@link useForceCloseParams}. */
|
|
7
|
+
export type UseForceCloseParamsReturnType = UseQueryResult<GetForceCloseParamsData, SymmioRequestError>;
|
|
8
|
+
/**
|
|
9
|
+
* Read the protocol force-close params (cooldowns, price penalty, min signature
|
|
10
|
+
* period, and the symbol's gap ratio) for a market — the inputs to the
|
|
11
|
+
* force-close eligibility gate and price checks. These change rarely, so a long
|
|
12
|
+
* `staleTime` fits. `symbolId` is required; while it is still loading, pass a
|
|
13
|
+
* placeholder and gate with `query.enabled`. Errors are normalized to
|
|
14
|
+
* {@link SymmioRequestError}.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const { data: params } = useForceCloseParams({ symbolId: 1n });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function useForceCloseParams(parameters: UseForceCloseParamsParameters): UseForceCloseParamsReturnType;
|
|
22
|
+
//# sourceMappingURL=use-force-close-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-close-params.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-close-params.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,qHAAqH;AACrH,MAAM,MAAM,6BAA6B,GAAG,0BAA0B,GAAG,eAAe,CAAC;AAEzF,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,cAAc,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;AAExG;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,6BAA6B,GAAG,6BAA6B,CAkB5G"}
|
|
@@ -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 { getForceCloseParamsQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/quotes/use-force-close-params.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 useForceCloseParams };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-force-close-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-close-params.js","names":[],"sources":["../../src/quotes/use-force-close-params.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getForceCloseParamsQueryOptions,\n type ConfigParameter,\n type GetForceCloseParamsData,\n type GetForceCloseParamsOptions,\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/** Parameters for {@link useForceCloseParams}: the core options (`symbolId`, chain id) plus an optional `config`. */\nexport type UseForceCloseParamsParameters = GetForceCloseParamsOptions & ConfigParameter;\n\n/** Return type of {@link useForceCloseParams}. */\nexport type UseForceCloseParamsReturnType = UseQueryResult<GetForceCloseParamsData, SymmioRequestError>;\n\n/**\n * Read the protocol force-close params (cooldowns, price penalty, min signature\n * period, and the symbol's gap ratio) for a market — the inputs to the\n * force-close eligibility gate and price checks. These change rarely, so a long\n * `staleTime` fits. `symbolId` is required; while it is still loading, pass a\n * placeholder and gate with `query.enabled`. Errors are normalized to\n * {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data: params } = useForceCloseParams({ symbolId: 1n });\n * ```\n */\nexport function useForceCloseParams(parameters: UseForceCloseParamsParameters): UseForceCloseParamsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getForceCloseParamsQueryOptions(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 UseForceCloseParamsReturnType;\n}\n"],"mappings":";;;;;;;AAiCA,SAAgB,EAAoB,GAA0E;CAC5G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAgC,GAAQ;EACtD,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,30 @@
|
|
|
1
|
+
import { ForceCloseAutoParameters } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
|
+
/** Parameters for {@link useForceClose}. */
|
|
6
|
+
export type UseForceCloseParameters = WriteParameters;
|
|
7
|
+
/** Result returned by the {@link useForceClose} mutation. */
|
|
8
|
+
export type ForceCloseResult = WriteResult;
|
|
9
|
+
/** Return type of {@link useForceClose}. */
|
|
10
|
+
export type UseForceCloseReturnType = UseMutationResult<ForceCloseResult, SymmioRequestError, ForceCloseAutoParameters>;
|
|
11
|
+
/**
|
|
12
|
+
* Force-close a stalled `CLOSE_PENDING` **limit** position end-to-end from just a
|
|
13
|
+
* `quoteId` (`forceCloseAuto`): read the quote + force-close params, gate on
|
|
14
|
+
* eligibility, find a price window from reference candles, fetch the Muon
|
|
15
|
+
* `HighLowPriceSig`, preflight the gap, and send `forceClosePosition` through the
|
|
16
|
+
* AccountLayer `_call` proxy. On success (after the receipt) the subaccount's
|
|
17
|
+
* open-positions read is invalidated so the row updates.
|
|
18
|
+
*
|
|
19
|
+
* Throws (normalized) on ineligibility (`FORCE_CLOSE_NOT_ELIGIBLE`), the market
|
|
20
|
+
* not having hit the price (`FORCE_CLOSE_PRICE_NOT_REACHED`), or a contract
|
|
21
|
+
* revert. Gate the button first with {@link useForceCloseEligibility}.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const forceClose = useForceClose();
|
|
26
|
+
* forceClose.mutate({ account: "0xsub…", quoteId: 42n });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useForceClose(parameters?: UseForceCloseParameters): UseForceCloseReturnType;
|
|
30
|
+
//# sourceMappingURL=use-force-close.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-close.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-close.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,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,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAEtD,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAE3C,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,wBAAwB,CAAC,CAAC;AAExH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,UAAU,GAAE,uBAA4B,GAAG,uBAAuB,CA6B/F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { forceCloseAutoMutationOptions as a, getPartyAOpenPositionsQueryKey as o } from "@symmio/trading-core";
|
|
8
|
+
import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
|
|
9
|
+
//#region src/quotes/use-force-close.ts
|
|
10
|
+
function l(l = {}) {
|
|
11
|
+
let u = t(l), d = e(), f = c(), p = a(u);
|
|
12
|
+
return s({
|
|
13
|
+
mutationKey: p.mutationKey,
|
|
14
|
+
mutationFn: async (e) => {
|
|
15
|
+
try {
|
|
16
|
+
let t = e.chainId ?? d;
|
|
17
|
+
return r(u, await p.mutationFn({
|
|
18
|
+
...e,
|
|
19
|
+
chainId: t
|
|
20
|
+
}), {
|
|
21
|
+
chainId: t,
|
|
22
|
+
waitForReceipt: l.waitForReceipt,
|
|
23
|
+
confirmations: l.confirmations
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
throw n(e);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
onSuccess: (e, t) => {
|
|
30
|
+
let n = { partyA: t.account };
|
|
31
|
+
f.invalidateQueries({ predicate: i(o, n) });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { l as useForceClose };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=use-force-close.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-close.js","names":[],"sources":["../../src/quotes/use-force-close.ts"],"sourcesContent":["\"use client\";\n\nimport {\n forceCloseAutoMutationOptions,\n getPartyAOpenPositionsQueryKey,\n type ForceCloseAutoParameters,\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 useForceClose}. */\nexport type UseForceCloseParameters = WriteParameters;\n\n/** Result returned by the {@link useForceClose} mutation. */\nexport type ForceCloseResult = WriteResult;\n\n/** Return type of {@link useForceClose}. */\nexport type UseForceCloseReturnType = UseMutationResult<ForceCloseResult, SymmioRequestError, ForceCloseAutoParameters>;\n\n/**\n * Force-close a stalled `CLOSE_PENDING` **limit** position end-to-end from just a\n * `quoteId` (`forceCloseAuto`): read the quote + force-close params, gate on\n * eligibility, find a price window from reference candles, fetch the Muon\n * `HighLowPriceSig`, preflight the gap, and send `forceClosePosition` through the\n * AccountLayer `_call` proxy. On success (after the receipt) the subaccount's\n * open-positions read is invalidated so the row updates.\n *\n * Throws (normalized) on ineligibility (`FORCE_CLOSE_NOT_ELIGIBLE`), the market\n * not having hit the price (`FORCE_CLOSE_PRICE_NOT_REACHED`), or a contract\n * revert. Gate the button first with {@link useForceCloseEligibility}.\n *\n * @example\n * ```tsx\n * const forceClose = useForceClose();\n * forceClose.mutate({ account: \"0xsub…\", quoteId: 42n });\n * ```\n */\nexport function useForceClose(parameters: UseForceCloseParameters = {}): UseForceCloseReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = forceCloseAutoMutationOptions(config);\n\n return useMutation<ForceCloseResult, SymmioRequestError, ForceCloseAutoParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\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 // The force-close transitions the position — refetch the owning partyA's\n // open positions so the status updates.\n const partial = { partyA: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAOpenPositionsQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA0CA,SAAgB,EAAc,IAAsC,CAAC,GAA4B;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAA8B,CAAM;CAEjD,OAAO,EAA4E;EACjF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;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,IAAU,EAAE,QAAQ,EAAU,QAAQ;GAC5C,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC;EAC3G;CACF,CAAC;AACH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GroupQuotesOptions, QuoteGroup, QuoteGroupingStrategy, UnifiedQuote } from '@symmio/trading-core';
|
|
1
|
+
import { SubAccountIsolationType, GroupQuotesOptions, QuoteGroup, QuoteGroupingStrategy, UnifiedQuote } from '@symmio/trading-core';
|
|
2
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
2
3
|
import { UseManagedQuotesParameters, UseManagedQuotesResult } from './use-managed-quotes.js';
|
|
3
4
|
/**
|
|
4
5
|
* Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}
|
|
@@ -6,10 +7,14 @@ import { UseManagedQuotesParameters, UseManagedQuotesResult } from './use-manage
|
|
|
6
7
|
*/
|
|
7
8
|
export interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {
|
|
8
9
|
/**
|
|
9
|
-
* How to fold active positions into groups
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* How to fold active positions into groups. The only
|
|
11
|
+
* {@link SubAccountIsolationType} accepted is `MARKET_DIRECTION` (one group per
|
|
12
|
+
* market + side), which is also the default — grouped positions are defined for
|
|
13
|
+
* that isolation alone. Passing any other isolation type throws
|
|
14
|
+
* `UNSUPPORTED_GROUPING_ISOLATION`; pass a custom `{ keyOf }` to fold on another
|
|
15
|
+
* dimension (`keyQuoteByMarket` / `keyQuotePerQuote` cover the common cases).
|
|
12
16
|
*
|
|
17
|
+
* A custom `{ keyOf }` also opts out of the sub-account isolation check below.
|
|
13
18
|
* Passing a fresh `{ keyOf }` object every render recomputes the groups every
|
|
14
19
|
* render; memoize a custom strategy if that matters.
|
|
15
20
|
*/
|
|
@@ -19,13 +24,32 @@ export interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {
|
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* Value returned by {@link useGroupedQuotes} — the full {@link useManagedQuotes}
|
|
22
|
-
* result, plus the grouped positions
|
|
27
|
+
* result, plus the grouped positions, the flat pending orders, and the
|
|
28
|
+
* isolation check that decides whether grouping applies at all.
|
|
23
29
|
*/
|
|
24
30
|
export interface UseGroupedQuotesResult extends UseManagedQuotesResult {
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Active positions folded into {@link QuoteGroup}s under `strategy`,
|
|
33
|
+
* newest-first. Always empty while {@link isGroupingSupported} is `false`.
|
|
34
|
+
*/
|
|
26
35
|
groups: QuoteGroup[];
|
|
27
36
|
/** Resting/pending limit orders, kept flat (never grouped). */
|
|
28
37
|
pending: UnifiedQuote[];
|
|
38
|
+
/**
|
|
39
|
+
* Isolation type of the sub-account owning `partyA` (resolved through the
|
|
40
|
+
* Virtual Account's parent when `partyA` is a VA). `undefined` while the read
|
|
41
|
+
* is in flight, when `partyA` is neither a sub-account nor a VA, and when a
|
|
42
|
+
* custom `{ keyOf }` strategy skipped the lookup.
|
|
43
|
+
*/
|
|
44
|
+
isolationType?: SubAccountIsolationType;
|
|
45
|
+
/**
|
|
46
|
+
* `false` only when the owning sub-account's isolation is **known** and is not
|
|
47
|
+
* `MARKET_DIRECTION`. `true` while the isolation is unresolved, so a consumer
|
|
48
|
+
* gating on it never flashes an error state during the read.
|
|
49
|
+
*/
|
|
50
|
+
isGroupingSupported: boolean;
|
|
51
|
+
/** The rejection behind `isGroupingSupported: false`; `null` otherwise. */
|
|
52
|
+
groupingError: SymmioRequestError | null;
|
|
29
53
|
}
|
|
30
54
|
/**
|
|
31
55
|
* Managed quotes for one sub-account, folded into grouped positions.
|
|
@@ -36,19 +60,35 @@ export interface UseGroupedQuotesResult extends UseManagedQuotesResult {
|
|
|
36
60
|
* Pending limit orders are returned flat in `pending` — the grouped-positions vs
|
|
37
61
|
* open-orders split. The full flat list stays available on `quotes`.
|
|
38
62
|
*
|
|
63
|
+
* **Grouping is a `MARKET_DIRECTION`-only feature.** It is the one isolation
|
|
64
|
+
* where a market + side cohort is a real on-chain unit (the AccountLayer
|
|
65
|
+
* allocates one Virtual Account per market + direction), so folding that cohort
|
|
66
|
+
* into a single row aggregates values that belong together — and group-level
|
|
67
|
+
* actions (group close, group TP/SL) act on quotes that really share a VA. This
|
|
68
|
+
* hook therefore resolves the isolation of the sub-account owning `partyA`
|
|
69
|
+
* (walking up from a Virtual Account to its parent when needed) and, when that
|
|
70
|
+
* isolation is anything else, returns **no groups** together with
|
|
71
|
+
* `isGroupingSupported: false` and a `groupingError` instead of silently folding
|
|
72
|
+
* unrelated positions. `quotes` and `pending` are untouched, so a consumer can
|
|
73
|
+
* still render flat rows for those accounts. The lookup is skipped for a custom
|
|
74
|
+
* `{ keyOf }` strategy — that caller has opted out of isolation-based grouping.
|
|
75
|
+
*
|
|
39
76
|
* All grouping is pure and runs in a `useMemo`, so the heavy work is the
|
|
40
77
|
* underlying reads, not the fold.
|
|
41
78
|
*
|
|
42
79
|
* @param parameters - Managed-quotes parameters plus `strategy` / `groupSort`.
|
|
43
|
-
* @returns The managed-quotes result extended with `groups` and
|
|
80
|
+
* @returns The managed-quotes result extended with `groups`, `pending`, and the isolation check.
|
|
81
|
+
* @throws {SymmError} `UNSUPPORTED_GROUPING_ISOLATION` when `strategy` is an
|
|
82
|
+
* isolation type other than `MARKET_DIRECTION`.
|
|
44
83
|
*
|
|
45
84
|
* @example
|
|
46
85
|
* ```tsx
|
|
47
|
-
* const { groups, pending,
|
|
86
|
+
* const { groups, pending, isGroupingSupported, groupingError } = useGroupedQuotes({ partyA });
|
|
87
|
+
* if (!isGroupingSupported) return <FlatPositions rows={pending} note={groupingError?.message} />;
|
|
48
88
|
* // groups[0].metrics.openQuantity, groups[0].metrics.weightedOpenPrice, …
|
|
49
89
|
*
|
|
50
|
-
* //
|
|
51
|
-
* useGroupedQuotes({ partyA, strategy:
|
|
90
|
+
* // fold on another dimension — opts out of the isolation check:
|
|
91
|
+
* useGroupedQuotes({ partyA, strategy: { keyOf: keyQuoteByMarket } });
|
|
52
92
|
* ```
|
|
53
93
|
*/
|
|
54
94
|
export declare function useGroupedQuotes(parameters: UseGroupedQuotesParameters): UseGroupedQuotesResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grouped-quotes.d.ts","sourceRoot":"","sources":["../../src/quotes/use-grouped-quotes.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-grouped-quotes.d.ts","sourceRoot":"","sources":["../../src/quotes/use-grouped-quotes.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,uBAAuB,EAEvB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAoB,KAAK,0BAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAKtH;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,0BAA0B;IAC5E;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,0FAA0F;IAC1F,SAAS,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IACpE;;;OAGG;IACH,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,+DAA+D;IAC/D,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;;OAIG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAC7B,2EAA2E;IAC3E,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,sBAAsB,CAwD/F"}
|
|
@@ -1,21 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { normalizeSymmError as e } from "../errors/normalize-symm-error.js";
|
|
3
|
+
import { useManagedQuotes as t } from "./use-managed-quotes.js";
|
|
4
|
+
import { useGroupingIsolation as n } from "./use-grouping-isolation.js";
|
|
5
|
+
import { SubAccountIsolationType as r, assertQuoteGroupingSupported as i, groupQuotes as a, partitionQuotes as o, supportsQuoteGrouping as s } from "@symmio/trading-core";
|
|
6
|
+
import { useEffect as c, useMemo as l, useRef as u } from "react";
|
|
5
7
|
//#region src/quotes/use-grouped-quotes.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
var d = [];
|
|
9
|
+
function f(f) {
|
|
10
|
+
let { strategy: p = r.MARKET_DIRECTION, groupSort: m, ...h } = f, g = t(h), _ = typeof p != "object", v = n({
|
|
11
|
+
account: f.partyA,
|
|
12
|
+
chainId: f.chainId,
|
|
13
|
+
enabled: _ && (f.enabled ?? !0)
|
|
14
|
+
}), y = !_ || v === void 0 || s(v), b = l(() => {
|
|
15
|
+
if (v === void 0 || y) return null;
|
|
16
|
+
try {
|
|
17
|
+
return i(v), null;
|
|
18
|
+
} catch (t) {
|
|
19
|
+
return e(t);
|
|
20
|
+
}
|
|
21
|
+
}, [v, y]), { positions: x, pending: S } = l(() => o(g.quotes), [g.quotes]), C = l(() => (typeof p != "object" && i(p), y ? a(x, p, m ? { sort: m } : void 0) : d), [
|
|
22
|
+
x,
|
|
23
|
+
p,
|
|
24
|
+
m,
|
|
25
|
+
y
|
|
26
|
+
]), w = u(void 0);
|
|
27
|
+
return c(() => {
|
|
28
|
+
if (!b || process.env.NODE_ENV === "production") return;
|
|
29
|
+
let e = `${f.partyA}:${v}`;
|
|
30
|
+
w.current !== e && (w.current = e, console.warn(`[useGroupedQuotes] ${b.message} No groups are returned; read \`quotes\` instead.`));
|
|
31
|
+
}, [
|
|
32
|
+
b,
|
|
33
|
+
v,
|
|
34
|
+
f.partyA
|
|
35
|
+
]), {
|
|
36
|
+
...g,
|
|
37
|
+
groups: C,
|
|
38
|
+
pending: S,
|
|
39
|
+
isolationType: v,
|
|
40
|
+
isGroupingSupported: y,
|
|
41
|
+
groupingError: b
|
|
16
42
|
};
|
|
17
43
|
}
|
|
18
44
|
//#endregion
|
|
19
|
-
export {
|
|
45
|
+
export { f as useGroupedQuotes };
|
|
20
46
|
|
|
21
47
|
//# sourceMappingURL=use-grouped-quotes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grouped-quotes.js","names":[],"sources":["../../src/quotes/use-grouped-quotes.ts"],"sourcesContent":["\"use client\";\n\nimport {\n groupQuotes,\n partitionQuotes,\n SubAccountIsolationType,\n type GroupQuotesOptions,\n type QuoteGroup,\n type QuoteGroupingStrategy,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { useManagedQuotes, type UseManagedQuotesParameters, type UseManagedQuotesResult } from \"./use-managed-quotes\";\n\n/**\n * Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}\n * accepts, plus how to fold the resulting positions into groups.\n */\nexport interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {\n /**\n * How to fold active positions into groups
|
|
1
|
+
{"version":3,"file":"use-grouped-quotes.js","names":[],"sources":["../../src/quotes/use-grouped-quotes.ts"],"sourcesContent":["\"use client\";\n\nimport {\n assertQuoteGroupingSupported,\n groupQuotes,\n partitionQuotes,\n SubAccountIsolationType,\n supportsQuoteGrouping,\n type GroupQuotesOptions,\n type QuoteGroup,\n type QuoteGroupingStrategy,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useGroupingIsolation } from \"./use-grouping-isolation\";\nimport { useManagedQuotes, type UseManagedQuotesParameters, type UseManagedQuotesResult } from \"./use-managed-quotes\";\n\n/** Stable empty result for the guarded case, so `groups` keeps its identity across renders. */\nconst NO_GROUPS: QuoteGroup[] = [];\n\n/**\n * Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}\n * accepts, plus how to fold the resulting positions into groups.\n */\nexport interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {\n /**\n * How to fold active positions into groups. The only\n * {@link SubAccountIsolationType} accepted is `MARKET_DIRECTION` (one group per\n * market + side), which is also the default — grouped positions are defined for\n * that isolation alone. Passing any other isolation type throws\n * `UNSUPPORTED_GROUPING_ISOLATION`; pass a custom `{ keyOf }` to fold on another\n * dimension (`keyQuoteByMarket` / `keyQuotePerQuote` cover the common cases).\n *\n * A custom `{ keyOf }` also opts out of the sub-account isolation check below.\n * Passing a fresh `{ keyOf }` object every render recomputes the groups every\n * render; memoize a custom strategy if that matters.\n */\n strategy?: QuoteGroupingStrategy;\n /** Optional group-ordering override forwarded to `groupQuotes` (default newest-first). */\n groupSort?: GroupQuotesOptions[\"sort\"];\n}\n\n/**\n * Value returned by {@link useGroupedQuotes} — the full {@link useManagedQuotes}\n * result, plus the grouped positions, the flat pending orders, and the\n * isolation check that decides whether grouping applies at all.\n */\nexport interface UseGroupedQuotesResult extends UseManagedQuotesResult {\n /**\n * Active positions folded into {@link QuoteGroup}s under `strategy`,\n * newest-first. Always empty while {@link isGroupingSupported} is `false`.\n */\n groups: QuoteGroup[];\n /** Resting/pending limit orders, kept flat (never grouped). */\n pending: UnifiedQuote[];\n /**\n * Isolation type of the sub-account owning `partyA` (resolved through the\n * Virtual Account's parent when `partyA` is a VA). `undefined` while the read\n * is in flight, when `partyA` is neither a sub-account nor a VA, and when a\n * custom `{ keyOf }` strategy skipped the lookup.\n */\n isolationType?: SubAccountIsolationType;\n /**\n * `false` only when the owning sub-account's isolation is **known** and is not\n * `MARKET_DIRECTION`. `true` while the isolation is unresolved, so a consumer\n * gating on it never flashes an error state during the read.\n */\n isGroupingSupported: boolean;\n /** The rejection behind `isGroupingSupported: false`; `null` otherwise. */\n groupingError: SymmioRequestError | null;\n}\n\n/**\n * Managed quotes for one sub-account, folded into grouped positions.\n *\n * Reads every quote source via {@link useManagedQuotes}, splits the merged list\n * into active positions and pending orders (`partitionQuotes`), then folds the\n * positions into {@link QuoteGroup}s under the chosen `strategy` (`groupQuotes`).\n * Pending limit orders are returned flat in `pending` — the grouped-positions vs\n * open-orders split. The full flat list stays available on `quotes`.\n *\n * **Grouping is a `MARKET_DIRECTION`-only feature.** It is the one isolation\n * where a market + side cohort is a real on-chain unit (the AccountLayer\n * allocates one Virtual Account per market + direction), so folding that cohort\n * into a single row aggregates values that belong together — and group-level\n * actions (group close, group TP/SL) act on quotes that really share a VA. This\n * hook therefore resolves the isolation of the sub-account owning `partyA`\n * (walking up from a Virtual Account to its parent when needed) and, when that\n * isolation is anything else, returns **no groups** together with\n * `isGroupingSupported: false` and a `groupingError` instead of silently folding\n * unrelated positions. `quotes` and `pending` are untouched, so a consumer can\n * still render flat rows for those accounts. The lookup is skipped for a custom\n * `{ keyOf }` strategy — that caller has opted out of isolation-based grouping.\n *\n * All grouping is pure and runs in a `useMemo`, so the heavy work is the\n * underlying reads, not the fold.\n *\n * @param parameters - Managed-quotes parameters plus `strategy` / `groupSort`.\n * @returns The managed-quotes result extended with `groups`, `pending`, and the isolation check.\n * @throws {SymmError} `UNSUPPORTED_GROUPING_ISOLATION` when `strategy` is an\n * isolation type other than `MARKET_DIRECTION`.\n *\n * @example\n * ```tsx\n * const { groups, pending, isGroupingSupported, groupingError } = useGroupedQuotes({ partyA });\n * if (!isGroupingSupported) return <FlatPositions rows={pending} note={groupingError?.message} />;\n * // groups[0].metrics.openQuantity, groups[0].metrics.weightedOpenPrice, …\n *\n * // fold on another dimension — opts out of the isolation check:\n * useGroupedQuotes({ partyA, strategy: { keyOf: keyQuoteByMarket } });\n * ```\n */\nexport function useGroupedQuotes(parameters: UseGroupedQuotesParameters): UseGroupedQuotesResult {\n const { strategy = SubAccountIsolationType.MARKET_DIRECTION, groupSort, ...managedParameters } = parameters;\n const managed = useManagedQuotes(managedParameters);\n\n /**\n * The sub-account check only applies to isolation-backed grouping; a custom\n * `{ keyOf }` groups on the consumer's own dimension, so no on-chain isolation\n * can contradict it and no read is worth firing.\n */\n const isIsolationStrategy = typeof strategy !== \"object\";\n const isolationType = useGroupingIsolation({\n account: parameters.partyA,\n chainId: parameters.chainId,\n enabled: isIsolationStrategy && (parameters.enabled ?? true),\n });\n\n /**\n * Unresolved isolation reads as supported — never flash a failure while loading.\n * A custom `{ keyOf }` strategy opted out of the isolation gate entirely, so it\n * is always supported regardless of any isolation the lookup might surface.\n */\n const isGroupingSupported =\n !isIsolationStrategy || isolationType === undefined || supportsQuoteGrouping(isolationType);\n\n const groupingError = useMemo<SymmioRequestError | null>(() => {\n if (isolationType === undefined || isGroupingSupported) return null;\n try {\n assertQuoteGroupingSupported(isolationType);\n return null;\n } catch (err) {\n return normalizeSymmError(err);\n }\n }, [isolationType, isGroupingSupported]);\n\n const { positions, pending } = useMemo(() => partitionQuotes(managed.quotes), [managed.quotes]);\n const groups = useMemo(() => {\n /** An unsupported `strategy` is a caller bug — throw even when the guard already blanked the groups. */\n if (typeof strategy !== \"object\") assertQuoteGroupingSupported(strategy);\n if (!isGroupingSupported) return NO_GROUPS;\n return groupQuotes(positions, strategy, groupSort ? { sort: groupSort } : undefined);\n }, [positions, strategy, groupSort, isGroupingSupported]);\n\n /**\n * Blanked groups are easy to misread as \"no positions\", so say why once per\n * account — in development only, and keyed so a re-render never re-logs.\n */\n const warnedRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!groupingError || process.env.NODE_ENV === \"production\") return;\n const key = `${parameters.partyA}:${isolationType}`;\n if (warnedRef.current === key) return;\n warnedRef.current = key;\n console.warn(`[useGroupedQuotes] ${groupingError.message} No groups are returned; read \\`quotes\\` instead.`);\n }, [groupingError, isolationType, parameters.partyA]);\n\n return { ...managed, groups, pending, isolationType, isGroupingSupported, groupingError };\n}\n"],"mappings":";;;;;;;AAoBA,IAAM,IAA0B,CAAC;AA8FjC,SAAgB,EAAiB,GAAgE;CAC/F,IAAM,EAAE,cAAW,EAAwB,kBAAkB,cAAW,GAAG,MAAsB,GAC3F,IAAU,EAAiB,CAAiB,GAO5C,IAAsB,OAAO,KAAa,UAC1C,IAAgB,EAAqB;EACzC,SAAS,EAAW;EACpB,SAAS,EAAW;EACpB,SAAS,MAAwB,EAAW,WAAW;CACzD,CAAC,GAOK,IACJ,CAAC,KAAuB,MAAkB,KAAA,KAAa,EAAsB,CAAa,GAEtF,IAAgB,QAAyC;EAC7D,IAAI,MAAkB,KAAA,KAAa,GAAqB,OAAO;EAC/D,IAAI;GAEF,OADA,EAA6B,CAAa,GACnC;EACT,SAAS,GAAK;GACZ,OAAO,EAAmB,CAAG;EAC/B;CACF,GAAG,CAAC,GAAe,CAAmB,CAAC,GAEjC,EAAE,cAAW,eAAY,QAAc,EAAgB,EAAQ,MAAM,GAAG,CAAC,EAAQ,MAAM,CAAC,GACxF,IAAS,SAET,OAAO,KAAa,YAAU,EAA6B,CAAQ,GAClE,IACE,EAAY,GAAW,GAAU,IAAY,EAAE,MAAM,EAAU,IAAI,KAAA,CAAS,IADlD,IAEhC;EAAC;EAAW;EAAU;EAAW;CAAmB,CAAC,GAMlD,IAAY,EAA2B,KAAA,CAAS;CAStD,OARA,QAAgB;EACd,IAAI,CAAC,KAAA,QAAA,IAAA,aAA0C,cAAc;EAC7D,IAAM,IAAM,GAAG,EAAW,OAAO,GAAG;EAChC,EAAU,YAAY,MAC1B,EAAU,UAAU,GACpB,QAAQ,KAAK,sBAAsB,EAAc,QAAQ,kDAAkD;CAC7G,GAAG;EAAC;EAAe;EAAe,EAAW;CAAM,CAAC,GAE7C;EAAE,GAAG;EAAS;EAAQ;EAAS;EAAe;EAAqB;CAAc;AAC1F"}
|