@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,358 @@
|
|
|
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 { useTpSlRecords as r, useTpSlStore as i } from "./tpsl-store.js";
|
|
6
|
+
import { TPSL_CONFIRMATION_TIMEOUT_CODE as a, awaitTpSlConfirmation as o, tpslConfirmationTimeoutError as s } from "./await-tpsl-confirmation.js";
|
|
7
|
+
import { invalidateTpSlReads as c } from "./invalidate-tpsl.js";
|
|
8
|
+
import { startTpSlFallbackPoll as l } from "./tpsl-fallback-poll.js";
|
|
9
|
+
import { runWithConcurrency as u } from "./run-with-concurrency.js";
|
|
10
|
+
import { isCancelSideSettled as d, isWriteSideSettled as f } from "./settled-side.js";
|
|
11
|
+
import { dedupeAddresses as p, useWatchTpSlAccounts as m } from "./use-watch-tpsl-accounts.js";
|
|
12
|
+
import { deleteQuoteTpSlMutationOptions as h, planGroupTpSl as g, setQuoteTpSlMutationOptions as _ } from "@symmio/trading-core";
|
|
13
|
+
import { useCallback as v, useEffect as y, useMemo as b, useRef as x, useState as S } from "react";
|
|
14
|
+
import { useQueryClient as C } from "@tanstack/react-query";
|
|
15
|
+
//#region src/tpsl/use-set-quote-group-tpsl.ts
|
|
16
|
+
var w = {
|
|
17
|
+
status: "idle",
|
|
18
|
+
steps: []
|
|
19
|
+
}, T = {
|
|
20
|
+
actions: [],
|
|
21
|
+
sets: [],
|
|
22
|
+
deletes: [],
|
|
23
|
+
skips: [],
|
|
24
|
+
hasInvalid: !1,
|
|
25
|
+
isNoop: !0
|
|
26
|
+
};
|
|
27
|
+
function E(d = {}) {
|
|
28
|
+
let f = t(d), p = e(), E = C(), [N, P] = S(w), F = x(w), I = x(!1), L = x(void 0), [R, z] = S([]), B = x(void 0), V = v((e) => {
|
|
29
|
+
F.current = e, P(e);
|
|
30
|
+
}, []), H = b(() => Array.from(new Set(N.steps.filter((e) => e.status === "confirming").map((e) => e.quoteId))), [N.steps]);
|
|
31
|
+
m({
|
|
32
|
+
accounts: R,
|
|
33
|
+
ids: H,
|
|
34
|
+
chainId: B.current,
|
|
35
|
+
config: d.config,
|
|
36
|
+
enabled: R.length > 0 && H.length > 0
|
|
37
|
+
});
|
|
38
|
+
let U = v(() => {
|
|
39
|
+
let e = F.current;
|
|
40
|
+
if (!e.steps.some((e) => e.status === "confirming")) return;
|
|
41
|
+
let t = D(e.steps);
|
|
42
|
+
t && V({
|
|
43
|
+
...e,
|
|
44
|
+
steps: t,
|
|
45
|
+
status: M(t)
|
|
46
|
+
});
|
|
47
|
+
}, [V]);
|
|
48
|
+
y(() => {
|
|
49
|
+
U();
|
|
50
|
+
}, [r(H), U]);
|
|
51
|
+
let W = v(async (e, t = []) => {
|
|
52
|
+
if (I.current) return {
|
|
53
|
+
ok: !1,
|
|
54
|
+
submittedCount: 0,
|
|
55
|
+
confirmedCount: 0,
|
|
56
|
+
failedCount: 0,
|
|
57
|
+
skippedCount: 0,
|
|
58
|
+
steps: [],
|
|
59
|
+
plan: T,
|
|
60
|
+
stoppedByUser: !1,
|
|
61
|
+
error: n(/* @__PURE__ */ Error("A grouped TP/SL run is already in flight."))
|
|
62
|
+
};
|
|
63
|
+
let r = e.chainId ?? p, d = g({
|
|
64
|
+
children: e.children,
|
|
65
|
+
desired: e.desired,
|
|
66
|
+
pricePrecision: e.pricePrecision,
|
|
67
|
+
referencePrice: e.referencePrice,
|
|
68
|
+
config: e.config,
|
|
69
|
+
only: e.only
|
|
70
|
+
}), m = d.actions.filter((e) => e.action !== "skip"), v = /* @__PURE__ */ new Map();
|
|
71
|
+
for (let e of d.actions) e.action !== "skip" && v.set(e.quoteId, e.virtualAccount);
|
|
72
|
+
let y = [...t, ...d.actions.map((e) => j(e))];
|
|
73
|
+
if (L.current = e, B.current = r, z(k(e, d)), V({
|
|
74
|
+
status: m.length > 0 ? "submitting" : M(y),
|
|
75
|
+
steps: y,
|
|
76
|
+
plan: d
|
|
77
|
+
}), m.length === 0) return {
|
|
78
|
+
ok: !0,
|
|
79
|
+
submittedCount: 0,
|
|
80
|
+
confirmedCount: 0,
|
|
81
|
+
failedCount: 0,
|
|
82
|
+
skippedCount: d.skips.length,
|
|
83
|
+
steps: y,
|
|
84
|
+
plan: d,
|
|
85
|
+
stoppedByUser: !1
|
|
86
|
+
};
|
|
87
|
+
I.current = !0;
|
|
88
|
+
let b = _(f), x = h(f), S = i.getState().markConfirming, C = !1;
|
|
89
|
+
function w(e, t) {
|
|
90
|
+
let n = F.current, r = n.steps.findIndex((t) => t.id === e);
|
|
91
|
+
if (r < 0) return;
|
|
92
|
+
let i = [...n.steps];
|
|
93
|
+
i[r] = t(i[r]), V({
|
|
94
|
+
...n,
|
|
95
|
+
steps: i,
|
|
96
|
+
status: M(i)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function D(e, t) {
|
|
100
|
+
let r = n(t);
|
|
101
|
+
r.kind === "user-rejected" && (C = !0), w(e, (e) => ({
|
|
102
|
+
...e,
|
|
103
|
+
status: "failed",
|
|
104
|
+
error: r
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
function N() {
|
|
108
|
+
let e = i.getState(), t = [];
|
|
109
|
+
for (let n of F.current.steps) if (n.status === "confirming") {
|
|
110
|
+
for (let t of n.sides) e.clearConfirming(n.quoteId, t === "take_profit" ? "tp" : "sl");
|
|
111
|
+
t.push(n.quoteId);
|
|
112
|
+
}
|
|
113
|
+
if (t.length === 0) return;
|
|
114
|
+
let n = s(), r = F.current, a = r.steps.map((e) => e.status === "confirming" ? {
|
|
115
|
+
...e,
|
|
116
|
+
status: "failed",
|
|
117
|
+
error: n
|
|
118
|
+
} : e);
|
|
119
|
+
V({
|
|
120
|
+
...r,
|
|
121
|
+
steps: a,
|
|
122
|
+
status: M(a),
|
|
123
|
+
error: r.error ?? n
|
|
124
|
+
}), c(E, t);
|
|
125
|
+
}
|
|
126
|
+
let P = async (t) => {
|
|
127
|
+
let n = A(t);
|
|
128
|
+
if (w(n, (e) => ({
|
|
129
|
+
...e,
|
|
130
|
+
status: "submitting"
|
|
131
|
+
})), t.action === "delete") {
|
|
132
|
+
try {
|
|
133
|
+
await x.mutationFn({
|
|
134
|
+
quoteId: t.quoteId,
|
|
135
|
+
virtualAccount: t.virtualAccount,
|
|
136
|
+
cohQuoteId: t.cohQuoteId,
|
|
137
|
+
conditionalOrderType: t.conditionalOrderType,
|
|
138
|
+
from: e.from,
|
|
139
|
+
chainId: r
|
|
140
|
+
}), S(t.quoteId, t.conditionalOrderType === "take_profit" ? "tp" : "sl", { intent: "cancel" }), w(n, (e) => ({
|
|
141
|
+
...e,
|
|
142
|
+
status: "confirming"
|
|
143
|
+
}));
|
|
144
|
+
} catch (e) {
|
|
145
|
+
D(n, e);
|
|
146
|
+
}
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (t.action === "set") try {
|
|
150
|
+
let i = await b.mutationFn({
|
|
151
|
+
quoteId: t.quoteId,
|
|
152
|
+
virtualAccount: t.virtualAccount,
|
|
153
|
+
subAccount: e.subAccount,
|
|
154
|
+
symbolId: t.symbolId,
|
|
155
|
+
positionType: t.positionType,
|
|
156
|
+
quantity: t.quantity,
|
|
157
|
+
pricePrecision: e.pricePrecision,
|
|
158
|
+
affiliate: e.affiliate,
|
|
159
|
+
slippage: e.slippage,
|
|
160
|
+
tp: t.tp,
|
|
161
|
+
sl: t.sl,
|
|
162
|
+
from: e.from,
|
|
163
|
+
chainId: r
|
|
164
|
+
});
|
|
165
|
+
t.tp && S(t.quoteId, "tp", {
|
|
166
|
+
price: t.tp.triggerPrice,
|
|
167
|
+
pricePrecision: e.pricePrecision,
|
|
168
|
+
priceType: t.tp.priceType,
|
|
169
|
+
cohQuoteId: i.cohQuoteId
|
|
170
|
+
}), t.sl && S(t.quoteId, "sl", {
|
|
171
|
+
price: t.sl.triggerPrice,
|
|
172
|
+
pricePrecision: e.pricePrecision,
|
|
173
|
+
priceType: t.sl.priceType,
|
|
174
|
+
cohQuoteId: i.cohQuoteId
|
|
175
|
+
}), w(n, (e) => ({
|
|
176
|
+
...e,
|
|
177
|
+
status: "confirming",
|
|
178
|
+
cohQuoteId: i.cohQuoteId
|
|
179
|
+
}));
|
|
180
|
+
} catch (e) {
|
|
181
|
+
D(n, e);
|
|
182
|
+
}
|
|
183
|
+
}, R = e.stopOnUserRejection ?? !0;
|
|
184
|
+
try {
|
|
185
|
+
if (await u(m, e.concurrency ?? 1, P, () => R ? C : !1), C) {
|
|
186
|
+
let e = F.current, t = n(/* @__PURE__ */ Error("Signature rejected — the remaining legs were not submitted.")), r = e.steps.map((e) => e.status === "queued" ? {
|
|
187
|
+
...e,
|
|
188
|
+
status: "failed",
|
|
189
|
+
error: t
|
|
190
|
+
} : e);
|
|
191
|
+
V({
|
|
192
|
+
...e,
|
|
193
|
+
steps: r,
|
|
194
|
+
status: M(r)
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
let t = F.current;
|
|
198
|
+
V({
|
|
199
|
+
...t,
|
|
200
|
+
error: t.steps.find((e) => e.status === "failed")?.error
|
|
201
|
+
}), await o({
|
|
202
|
+
settle: U,
|
|
203
|
+
hasPending: () => F.current.steps.some((e) => e.status === "confirming"),
|
|
204
|
+
onTimeout: () => void c(E, F.current.steps.filter((e) => e.status === "confirming").map((e) => e.quoteId)),
|
|
205
|
+
onExpire: N,
|
|
206
|
+
onWait: () => l(f, {
|
|
207
|
+
chainId: r,
|
|
208
|
+
delayMs: e.fallbackPollDelayMs,
|
|
209
|
+
intervalMs: e.fallbackPollIntervalMs,
|
|
210
|
+
getWaiting: () => O(F.current.steps, v)
|
|
211
|
+
}).stop,
|
|
212
|
+
timeoutMs: e.confirmationTimeoutMs ?? 6e4
|
|
213
|
+
});
|
|
214
|
+
} finally {
|
|
215
|
+
I.current = !1;
|
|
216
|
+
}
|
|
217
|
+
let H = F.current.steps, W = H.filter((e) => e.status === "failed"), G = H.filter((e) => e.status === "done"), K = W.filter((e) => e.error?.code === a);
|
|
218
|
+
return V({
|
|
219
|
+
...F.current,
|
|
220
|
+
status: M(H),
|
|
221
|
+
error: W[0]?.error
|
|
222
|
+
}), c(E, G.map((e) => e.quoteId)), {
|
|
223
|
+
ok: W.length === 0,
|
|
224
|
+
submittedCount: G.length + K.length,
|
|
225
|
+
confirmedCount: G.length,
|
|
226
|
+
failedCount: W.length,
|
|
227
|
+
skippedCount: d.skips.length,
|
|
228
|
+
steps: [...H],
|
|
229
|
+
plan: d,
|
|
230
|
+
stoppedByUser: C,
|
|
231
|
+
error: W[0]?.error
|
|
232
|
+
};
|
|
233
|
+
}, [
|
|
234
|
+
V,
|
|
235
|
+
f,
|
|
236
|
+
p,
|
|
237
|
+
E,
|
|
238
|
+
U
|
|
239
|
+
]), G = v((e) => W(e), [W]), K = v(async (e) => {
|
|
240
|
+
let t = L.current, n = F.current.steps, r = [...new Set(n.filter((e) => e.status === "failed").map((e) => e.key))];
|
|
241
|
+
if (!t || r.length === 0) return {
|
|
242
|
+
ok: !0,
|
|
243
|
+
submittedCount: 0,
|
|
244
|
+
confirmedCount: 0,
|
|
245
|
+
failedCount: 0,
|
|
246
|
+
skippedCount: 0,
|
|
247
|
+
steps: [...n],
|
|
248
|
+
plan: F.current.plan ?? T,
|
|
249
|
+
stoppedByUser: !1
|
|
250
|
+
};
|
|
251
|
+
let i = n.filter((e) => !r.includes(e.key));
|
|
252
|
+
return W({
|
|
253
|
+
...t,
|
|
254
|
+
children: e ?? t.children,
|
|
255
|
+
only: r
|
|
256
|
+
}, i);
|
|
257
|
+
}, [W]), q = v(() => {
|
|
258
|
+
I.current || (B.current = void 0, z([]), L.current = void 0, V(w));
|
|
259
|
+
}, [V]), J = b(() => {
|
|
260
|
+
let e = N.steps.filter((e) => e.status !== "skipped"), t = e.filter((e) => e.status === "confirming" || e.status === "done").length, n = e.filter((e) => e.status === "done").length, r = e.filter((e) => e.status === "failed").length, i = n + r;
|
|
261
|
+
return {
|
|
262
|
+
acceptedCount: t,
|
|
263
|
+
confirmedCount: n,
|
|
264
|
+
failedCount: r,
|
|
265
|
+
totalCount: e.length,
|
|
266
|
+
progressPercent: e.length === 0 ? 0 : Math.round(i / e.length * 1e4) / 100
|
|
267
|
+
};
|
|
268
|
+
}, [N.steps]);
|
|
269
|
+
return {
|
|
270
|
+
set: G,
|
|
271
|
+
retryFailed: K,
|
|
272
|
+
reset: q,
|
|
273
|
+
status: N.status,
|
|
274
|
+
isSubmitting: N.status === "submitting",
|
|
275
|
+
isConfirming: N.status === "confirming",
|
|
276
|
+
...J,
|
|
277
|
+
steps: N.steps,
|
|
278
|
+
plan: N.plan,
|
|
279
|
+
error: N.error
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function D(e) {
|
|
283
|
+
let t = i.getState(), n = !1, r = e.map((e) => {
|
|
284
|
+
if (e.status !== "confirming") return e;
|
|
285
|
+
let r = t.get(e.quoteId);
|
|
286
|
+
if (!r) return e;
|
|
287
|
+
let i = e.sides.filter((t) => e.kind === "cancel" ? !d(r, t) : !f(r, t));
|
|
288
|
+
return i.length === e.sides.length ? e : (n = !0, i.length > 0 ? {
|
|
289
|
+
...e,
|
|
290
|
+
sides: i
|
|
291
|
+
} : {
|
|
292
|
+
...e,
|
|
293
|
+
sides: [],
|
|
294
|
+
status: "done"
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
return n ? r : void 0;
|
|
298
|
+
}
|
|
299
|
+
function O(e, t) {
|
|
300
|
+
let n = [];
|
|
301
|
+
for (let r of e) {
|
|
302
|
+
if (r.status !== "confirming") continue;
|
|
303
|
+
let e = t.get(r.quoteId);
|
|
304
|
+
if (e) for (let t of r.sides) n.push({
|
|
305
|
+
quoteId: r.quoteId,
|
|
306
|
+
side: t,
|
|
307
|
+
intent: r.kind === "cancel" ? "cancel" : "write",
|
|
308
|
+
cohQuoteId: r.cohQuoteId,
|
|
309
|
+
account: e
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return n;
|
|
313
|
+
}
|
|
314
|
+
function k(e, t) {
|
|
315
|
+
return e.notificationsAccounts ? p(e.notificationsAccounts) : p([e.notificationsAccount ?? e.subAccount, ...t.actions.map((e) => e.action === "skip" ? void 0 : e.virtualAccount)]);
|
|
316
|
+
}
|
|
317
|
+
function A(e) {
|
|
318
|
+
return e.action === "delete" ? `${e.key}:cancel:${e.conditionalOrderType}` : e.action === "set" ? `${e.key}:write` : `${e.key}:skip`;
|
|
319
|
+
}
|
|
320
|
+
function j(e) {
|
|
321
|
+
return e.action === "delete" ? {
|
|
322
|
+
id: A(e),
|
|
323
|
+
key: e.key,
|
|
324
|
+
kind: "cancel",
|
|
325
|
+
quoteId: e.quoteId,
|
|
326
|
+
sides: [e.conditionalOrderType],
|
|
327
|
+
status: "queued",
|
|
328
|
+
cohQuoteId: e.cohQuoteId
|
|
329
|
+
} : e.action === "set" ? {
|
|
330
|
+
id: A(e),
|
|
331
|
+
key: e.key,
|
|
332
|
+
kind: "write",
|
|
333
|
+
quoteId: e.quoteId,
|
|
334
|
+
sides: [...e.tp ? ["take_profit"] : [], ...e.sl ? ["stop_loss"] : []],
|
|
335
|
+
status: "queued"
|
|
336
|
+
} : {
|
|
337
|
+
id: A(e),
|
|
338
|
+
key: e.key,
|
|
339
|
+
kind: "skip",
|
|
340
|
+
quoteId: 0n,
|
|
341
|
+
sides: [],
|
|
342
|
+
status: "skipped",
|
|
343
|
+
skipReason: e.reason,
|
|
344
|
+
validation: e.validation
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function M(e) {
|
|
348
|
+
let t = e.filter((e) => e.status !== "skipped");
|
|
349
|
+
if (t.length === 0) return "success";
|
|
350
|
+
if (t.some((e) => e.status === "queued" || e.status === "submitting")) return "submitting";
|
|
351
|
+
if (t.some((e) => e.status === "confirming")) return "confirming";
|
|
352
|
+
let n = t.filter((e) => e.status === "failed").length;
|
|
353
|
+
return n === t.length ? "failed" : n > 0 ? "partial" : "success";
|
|
354
|
+
}
|
|
355
|
+
//#endregion
|
|
356
|
+
export { E as useSetQuoteGroupTpSl };
|
|
357
|
+
|
|
358
|
+
//# sourceMappingURL=use-set-quote-group-tpsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-set-quote-group-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-group-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n deleteQuoteTpSlMutationOptions,\n planGroupTpSl,\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type GroupTpSlAction,\n type GroupTpSlChild,\n type GroupTpSlDesiredMap,\n type GroupTpSlSkipReason,\n type PlanGroupTpSlResult,\n type TpSlConditionalOrderType,\n type TpSlConfig,\n type TpSlValidation,\n} from \"@symmio/trading-core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useMemo, 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\";\nimport {\n awaitTpSlConfirmation,\n DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS,\n TPSL_CONFIRMATION_TIMEOUT_CODE,\n tpslConfirmationTimeoutError,\n} from \"./await-tpsl-confirmation\";\nimport { invalidateTpSlReads } from \"./invalidate-tpsl\";\nimport { runWithConcurrency } from \"./run-with-concurrency\";\nimport { isCancelSideSettled, isWriteSideSettled } from \"./settled-side\";\nimport { startTpSlFallbackPoll, type TpSlPollWaitingSide } from \"./tpsl-fallback-poll\";\nimport { useTpSlRecords, useTpSlStore } from \"./tpsl-store\";\nimport { dedupeAddresses, useWatchTpSlAccounts } from \"./use-watch-tpsl-accounts\";\n\n/**\n * Lifecycle of one step inside a grouped TP/SL run:\n * `queued` → `submitting` (request in flight) → `confirming` (handler returned\n * 200) → `done` (the WebSocket reported the order live, or gone for a cancel),\n * or `failed`, or `skipped` (the plan decided the leg needs no write).\n */\nexport type SetQuoteGroupTpSlStepStatus = \"queued\" | \"submitting\" | \"confirming\" | \"done\" | \"failed\" | \"skipped\";\n\n/** What a step does. A leg can produce a `cancel` **and** a `write` in one run. */\nexport type SetQuoteGroupTpSlStepKind = \"write\" | \"cancel\" | \"skip\";\n\n/** Live state of one step. */\nexport interface SetQuoteGroupTpSlStep {\n /**\n * Stable step identity, unique within a run. A leg may yield several steps\n * (cancel one side, write the other), so this — not `key` — is what a\n * consumer should use as a list key.\n */\n id: string;\n /** Leg identity (`GroupTpSlChild.key`). Several steps can share it. */\n key: string;\n /** What this step does. */\n kind: SetQuoteGroupTpSlStepKind;\n /** On-chain quote id. `0n` for a leg the plan skipped before it anchored. */\n quoteId: bigint;\n /**\n * Sides this step still awaits confirmation for. A write starts with the\n * sides it wrote and empties as reports land; a cancel carries exactly one.\n */\n sides: TpSlConditionalOrderType[];\n /** Current stage. */\n status: SetQuoteGroupTpSlStepStatus;\n /** Why the leg was skipped, when `status` is `\"skipped\"`. */\n skipReason?: GroupTpSlSkipReason;\n /** Per-side validation errors, when `skipReason` is `\"invalid\"`. */\n validation?: TpSlValidation;\n /** Handler-issued conditional-order id — reported by a write, targeted by a cancel. */\n cohQuoteId?: string;\n /** Normalized error, when `status` is `\"failed\"`. */\n error?: SymmioRequestError;\n}\n\n/** Overall lifecycle of a grouped TP/SL run. */\nexport type SetQuoteGroupTpSlStatus =\n | \"idle\"\n /** At least one request is in flight. */\n | \"submitting\"\n /** Every request settled; at least one step still awaits its handler report. */\n | \"confirming\"\n /** Every written and cancelled step is confirmed. */\n | \"success\"\n /** Some steps were accepted, some failed. */\n | \"partial\"\n /** Every step failed. */\n | \"failed\";\n\n/** Inputs for one {@link UseSetQuoteGroupTpSlReturnType.set} run. */\nexport interface SetQuoteGroupTpSlParameters {\n /** Legs with their confirmed snapshots — from {@link useQuoteGroupTpSl}. */\n children: readonly GroupTpSlChild[];\n /** Desired per-leg state, keyed by `GroupTpSlChild.key`. */\n desired: GroupTpSlDesiredMap;\n /** SubAccount that owns every leg's Virtual Account — required in the signed message. */\n subAccount: Address;\n /** Market price precision. One value per run — a grouped position is one market. */\n pricePrecision: number;\n /** Live handler `/configs/` rules; with `referencePrice`, invalid legs are skipped, not submitted. */\n config?: TpSlConfig;\n /** Reference price for validation (decimal string) — pass the live mark price. */\n referencePrice?: string;\n /** Slippage percent forwarded to every write. Defaults to the SDK's TP/SL default. */\n slippage?: number;\n /** Affiliate override forwarded to every write. */\n affiliate?: Address;\n /** Delegated session key to sign from, when delegation is active. */\n from?: Address;\n /**\n * How many requests may be in flight at once. Default `1` — every leg needs\n * its own EIP-712 signature from the same wallet client, and serializing\n * avoids signature races and simultaneous wallet prompts. Raise it only when\n * signing with a session key.\n */\n concurrency?: number;\n /**\n * Stop the run when the wallet rejects a signature, instead of prompting for\n * every remaining leg. Default `true` — a trader who dismisses one prompt did\n * not consent to five more.\n */\n stopOnUserRejection?: boolean;\n /**\n * Accounts whose live streams confirm the run. Defaults to the deduped\n * Virtual Account of every leg the plan touches — the channel the handler\n * reports these orders on, and the reason a group spanning several VAs is\n * fully covered.\n */\n notificationsAccounts?: readonly Address[];\n /**\n * Single-account form of {@link SetQuoteGroupTpSlParameters.notificationsAccounts}.\n *\n * @deprecated Pass `notificationsAccounts`. A grouped position can span\n * Virtual Accounts, so one address rarely covers the whole run.\n */\n notificationsAccount?: Address;\n /**\n * How long a step may wait for its report before the run refetches the\n * handler's rows and, failing that, gives up on it. Defaults to\n * {@link DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS}.\n */\n confirmationTimeoutMs?: number;\n /**\n * How long the WebSocket report gets on its own before the fallback sweep\n * starts, in milliseconds. Defaults to {@link TPSL_FALLBACK_POLL_DELAY_MS}.\n *\n * The sweep exists for reports that never come; while one can still\n * plausibly arrive, reading the handler adds load and answers nothing.\n */\n fallbackPollDelayMs?: number;\n /**\n * Cadence of the fallback sweep once it has started, in milliseconds.\n * Defaults to {@link TPSL_FALLBACK_POLL_INTERVAL_MS}; `0` disables the sweep\n * and leaves the WebSocket report as the only confirmation signal.\n */\n fallbackPollIntervalMs?: number;\n /** Chain override; defaults to the connected chain. */\n chainId?: number;\n /** Restrict the run to these leg keys — the retry-failed-only path. */\n only?: readonly string[];\n}\n\n/**\n * Outcome of one run, reported once every step has been confirmed by the\n * handler's report — or given up on. Nothing about the run is still in flight\n * when this resolves.\n */\nexport interface SetQuoteGroupTpSlSummary {\n /** `true` when every planned step was accepted **and** confirmed. */\n ok: boolean;\n /** Steps the handler accepted (writes and cancels). */\n submittedCount: number;\n /** Steps the handler's report confirmed. */\n confirmedCount: number;\n /** Steps that failed. */\n failedCount: number;\n /** Legs the plan skipped. */\n skippedCount: number;\n /** Per-step final states at resolve time. */\n steps: SetQuoteGroupTpSlStep[];\n /** The plan the run executed — inspect `skips` for why a leg was left out. */\n plan: PlanGroupTpSlResult;\n /** `true` when the run stopped early because the wallet rejected a signature. */\n stoppedByUser: boolean;\n /** First error, when any step failed. */\n error?: SymmioRequestError;\n}\n\n/** Return type of {@link useSetQuoteGroupTpSl}. */\nexport interface UseSetQuoteGroupTpSlReturnType {\n /**\n * Plan and apply. Resolves once every step has been confirmed by the\n * handler's report or given up on (never rejects).\n */\n set: (parameters: SetQuoteGroupTpSlParameters) => Promise<SetQuoteGroupTpSlSummary>;\n /**\n * Re-run only the steps that failed, against fresh children when supplied\n * (so a leg that confirmed via a race is diffed away). Steps that already\n * succeeded are preserved, not reset. Never rejects.\n */\n retryFailed: (children?: readonly GroupTpSlChild[]) => Promise<SetQuoteGroupTpSlSummary>;\n /** Clear the run state back to `idle`. No-op while a run is in flight. */\n reset: () => void;\n /** Overall run lifecycle. */\n status: SetQuoteGroupTpSlStatus;\n /** `true` while a request is in flight. */\n isSubmitting: boolean;\n /** `true` while every request has settled but some step still awaits its handler report. */\n isConfirming: boolean;\n /**\n * Share of steps that reached a terminal state — confirmed or failed — as\n * `0`–`100` (2-decimal resolution). A step the handler accepted but has not\n * reported on yet does **not** count.\n */\n progressPercent: number;\n /** Steps the handler accepted so far — **excludes** failures. */\n acceptedCount: number;\n /** Steps the handler's report has confirmed so far. */\n confirmedCount: number;\n /** Steps that failed so far. */\n failedCount: number;\n /** Steps the current/last run intends to execute (writes + cancels). */\n totalCount: number;\n /** Per-step states of the current/last run, in execution order. */\n steps: SetQuoteGroupTpSlStep[];\n /** The last run's plan, for UI gating. */\n plan?: PlanGroupTpSlResult;\n /** First error of the last run, when a step failed. */\n error?: SymmioRequestError;\n}\n\n/** Parameters for {@link useSetQuoteGroupTpSl}. */\nexport type UseSetQuoteGroupTpSlParameters = ConfigParameter;\n\ninterface RunState {\n status: SetQuoteGroupTpSlStatus;\n steps: SetQuoteGroupTpSlStep[];\n plan?: PlanGroupTpSlResult;\n error?: SymmioRequestError;\n}\n\nconst IDLE: RunState = { status: \"idle\", steps: [] };\n\n/** A plan that decided nothing — returned when a run never got off the ground. */\nconst EMPTY_PLAN: PlanGroupTpSlResult = {\n actions: [],\n sets: [],\n deletes: [],\n skips: [],\n hasInvalid: false,\n isNoop: true,\n};\n\n/**\n * Apply a desired take-profit / stop-loss state across a grouped position.\n *\n * The run first diffs the desired state with `planGroupTpSl`, so a leg whose\n * trigger price and price type already match the handler is never re-submitted\n * and a side that did not change is dropped from its request. It then executes\n * the plan — **one signed request per leg, sequentially by default**, because\n * the conditional-order handler has no bulk endpoint and every request needs\n * its own EIP-712 signature.\n *\n * Both halves of the plan run: a side the caller cleared becomes a cancel\n * (`deleteQuoteTpSl`), a side with a new value becomes a write\n * (`setQuoteTpSl`). One leg can do both in the same run.\n *\n * A step goes `confirming` as soon as the handler returns 200 (the shared TP/SL\n * store is marked so the UI can show the target price straight away) and `done`\n * once the WebSocket reports the matching transition — live for a write, gone\n * for a cancel. **`set()` waits for those reports**: it resolves only when every\n * step is confirmed, so a caller that awaits it can trust the exits are real.\n * A step whose report never arrives falls back to the handler's REST rows after\n * `confirmationTimeoutMs` and fails if those do not show it either.\n *\n * A failed step fails only itself and the run ends as `\"partial\"`, except when\n * the wallet rejects a signature, which stops the run rather than prompting\n * again.\n *\n * @param parameters - Optional config override.\n * @returns The run controls and its live per-step state.\n *\n * @example\n * ```tsx\n * const { set, steps, isConfirming } = useSetQuoteGroupTpSl();\n * // Resolves once the handler has reported every leg live.\n * const summary = await set({ children, desired: editor.desired, subAccount, pricePrecision });\n * if (!summary.ok) showError(summary.error);\n * ```\n */\nexport function useSetQuoteGroupTpSl(parameters: UseSetQuoteGroupTpSlParameters = {}): UseSetQuoteGroupTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const connectedChainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const [state, setState] = useState<RunState>(IDLE);\n /** Mirror of `state` for the notification callback and the submit loop. */\n const runRef = useRef<RunState>(IDLE);\n const inFlight = useRef(false);\n /** Inputs of the last run, so `retryFailed` can replay them. */\n const lastRunRef = useRef<SetQuoteGroupTpSlParameters | undefined>(undefined);\n const [watchAccounts, setWatchAccounts] = useState<Address[]>([]);\n const watchChainIdRef = useRef<number | undefined>(undefined);\n\n const commit = useCallback((next: RunState) => {\n runRef.current = next;\n setState(next);\n }, []);\n\n /** Confirming steps' quote ids — the frames this run is listening for. */\n const confirmingIds = useMemo(\n () => Array.from(new Set(state.steps.filter((step) => step.status === \"confirming\").map((step) => step.quoteId))),\n [state.steps],\n );\n\n /**\n * Watch every Virtual Account the run touches. The frames land in the shared\n * store rather than here, and step resolution reads that store — so a step\n * advances no matter which subscription delivered the update, including a\n * co-mounted read hook's.\n */\n useWatchTpSlAccounts({\n accounts: watchAccounts,\n ids: confirmingIds,\n chainId: watchChainIdRef.current,\n config: parameters.config,\n enabled: watchAccounts.length > 0 && confirmingIds.length > 0,\n });\n\n /** Reconcile confirming steps against the store. Safe to call at any time. */\n const settle = useCallback(() => {\n const run = runRef.current;\n if (!run.steps.some((step) => step.status === \"confirming\")) return;\n const next = settleSteps(run.steps);\n if (next) commit({ ...run, steps: next, status: resolveStatus(next) });\n }, [commit]);\n\n // Keep the rendered state in step with the store for as long as this hook is\n // mounted. The run's own waiter drives the same reconcile off its store\n // subscription, so a run still resolves after the component unmounts.\n const confirmingRecords = useTpSlRecords(confirmingIds);\n useEffect(() => {\n settle();\n // `confirmingRecords` is the store subscription that drives this; `runRef`\n // and the store are read live.\n }, [confirmingRecords, settle]);\n\n const run = useCallback(\n async (\n runParameters: SetQuoteGroupTpSlParameters,\n /** Steps from an earlier run to preserve (the retry path). */\n carryOver: SetQuoteGroupTpSlStep[] = [],\n ): Promise<SetQuoteGroupTpSlSummary> => {\n if (inFlight.current) {\n return {\n ok: false,\n submittedCount: 0,\n confirmedCount: 0,\n failedCount: 0,\n skippedCount: 0,\n steps: [],\n plan: EMPTY_PLAN,\n stoppedByUser: false,\n error: normalizeSymmError(new Error(\"A grouped TP/SL run is already in flight.\")),\n };\n }\n\n const chainId = runParameters.chainId ?? connectedChainId;\n const plan = planGroupTpSl({\n children: runParameters.children,\n desired: runParameters.desired,\n pricePrecision: runParameters.pricePrecision,\n referencePrice: runParameters.referencePrice,\n config: runParameters.config,\n only: runParameters.only,\n });\n\n /** Walk `plan.actions` so a leg's cancel keeps its planned place before its write. */\n const work = plan.actions.filter((action) => action.action !== \"skip\");\n /** Which Virtual Account each leg lives under — the account its orders are filed under. */\n const virtualAccountByQuoteId = new Map<bigint, Address>();\n for (const action of plan.actions) {\n if (action.action !== \"skip\") virtualAccountByQuoteId.set(action.quoteId, action.virtualAccount);\n }\n const steps: SetQuoteGroupTpSlStep[] = [\n ...carryOver,\n ...plan.actions.map<SetQuoteGroupTpSlStep>((action) => toStep(action)),\n ];\n\n lastRunRef.current = runParameters;\n watchChainIdRef.current = chainId;\n setWatchAccounts(watchAccountsOf(runParameters, plan));\n commit({ status: work.length > 0 ? \"submitting\" : resolveStatus(steps), steps, plan });\n if (work.length === 0) {\n return {\n ok: true,\n submittedCount: 0,\n confirmedCount: 0,\n failedCount: 0,\n skippedCount: plan.skips.length,\n steps,\n plan,\n stoppedByUser: false,\n };\n }\n\n inFlight.current = true;\n const setBase = setQuoteTpSlMutationOptions(config);\n const deleteBase = deleteQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore.getState().markConfirming;\n let stoppedByUser = false;\n\n /** Update one step by id and recompute the run status from the whole list. */\n function patchStep(id: string, mutate: (step: SetQuoteGroupTpSlStep) => SetQuoteGroupTpSlStep): void {\n const current = runRef.current;\n const index = current.steps.findIndex((step) => step.id === id);\n if (index < 0) return;\n const next = [...current.steps];\n next[index] = mutate(next[index]!);\n commit({ ...current, steps: next, status: resolveStatus(next) });\n }\n\n function fail(id: string, err: unknown): void {\n const error = normalizeSymmError(err);\n if (error.kind === \"user-rejected\") stoppedByUser = true;\n patchStep(id, (step) => ({ ...step, status: \"failed\", error }));\n }\n\n /**\n * Stop waiting on the steps the handler never reported. Their store-side\n * guard is dropped first, so the refetch that follows writes the\n * handler's real rows through instead of being held off by a\n * confirmation that is not coming.\n */\n function expirePending(): void {\n const store = useTpSlStore.getState();\n const expired: bigint[] = [];\n for (const step of runRef.current.steps) {\n if (step.status !== \"confirming\") continue;\n for (const side of step.sides) store.clearConfirming(step.quoteId, side === \"take_profit\" ? \"tp\" : \"sl\");\n expired.push(step.quoteId);\n }\n if (expired.length === 0) return;\n const error = tpslConfirmationTimeoutError();\n const current = runRef.current;\n const next = current.steps.map((step) =>\n step.status === \"confirming\" ? { ...step, status: \"failed\" as const, error } : step,\n );\n commit({ ...current, steps: next, status: resolveStatus(next), error: current.error ?? error });\n void invalidateTpSlReads(queryClient, expired);\n }\n\n const execute = async (action: GroupTpSlAction) => {\n const id = stepIdOf(action);\n patchStep(id, (step) => ({ ...step, status: \"submitting\" }));\n\n if (action.action === \"delete\") {\n try {\n await deleteBase.mutationFn({\n quoteId: action.quoteId,\n virtualAccount: action.virtualAccount,\n cohQuoteId: action.cohQuoteId,\n conditionalOrderType: action.conditionalOrderType,\n from: runParameters.from,\n chainId,\n });\n // `intent: \"cancel\"` — this side is waiting to disappear, so an\n // empty refetch confirms it rather than being held as a write.\n markConfirming(action.quoteId, action.conditionalOrderType === \"take_profit\" ? \"tp\" : \"sl\", {\n intent: \"cancel\",\n });\n patchStep(id, (step) => ({ ...step, status: \"confirming\" }));\n } catch (err) {\n fail(id, err);\n }\n return;\n }\n if (action.action !== \"set\") return;\n\n try {\n const result = await setBase.mutationFn({\n quoteId: action.quoteId,\n virtualAccount: action.virtualAccount,\n subAccount: runParameters.subAccount,\n symbolId: action.symbolId,\n positionType: action.positionType,\n quantity: action.quantity,\n pricePrecision: runParameters.pricePrecision,\n affiliate: runParameters.affiliate,\n slippage: runParameters.slippage,\n tp: action.tp,\n sl: action.sl,\n from: runParameters.from,\n chainId,\n });\n if (action.tp) {\n markConfirming(action.quoteId, \"tp\", {\n price: action.tp.triggerPrice,\n pricePrecision: runParameters.pricePrecision,\n priceType: action.tp.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n if (action.sl) {\n markConfirming(action.quoteId, \"sl\", {\n price: action.sl.triggerPrice,\n pricePrecision: runParameters.pricePrecision,\n priceType: action.sl.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n patchStep(id, (step) => ({ ...step, status: \"confirming\", cohQuoteId: result.cohQuoteId }));\n } catch (err) {\n fail(id, err);\n }\n };\n\n const stopOnUserRejection = runParameters.stopOnUserRejection ?? true;\n try {\n await runWithConcurrency(work, runParameters.concurrency ?? 1, execute, () =>\n stopOnUserRejection ? stoppedByUser : false,\n );\n\n /** Anything the abort left `queued` never reached the handler — say so. */\n if (stoppedByUser) {\n const current = runRef.current;\n const cancelled = normalizeSymmError(\n new Error(\"Signature rejected — the remaining legs were not submitted.\"),\n );\n const next = current.steps.map((step) =>\n step.status === \"queued\" ? { ...step, status: \"failed\" as const, error: cancelled } : step,\n );\n commit({ ...current, steps: next, status: resolveStatus(next) });\n }\n\n /** Surface the first failure while the rest of the run is still confirming. */\n const submitted = runRef.current;\n commit({ ...submitted, error: submitted.steps.find((step) => step.status === \"failed\")?.error });\n\n // Every request has been answered; now wait for the handler to report\n // each accepted step — live for a write, gone for a cancel. Refetching\n // is the fallback, not the signal, so it fires only once a report is\n // overdue.\n await awaitTpSlConfirmation({\n settle,\n hasPending: () => runRef.current.steps.some((step) => step.status === \"confirming\"),\n onTimeout: () =>\n void invalidateTpSlReads(\n queryClient,\n runRef.current.steps.filter((step) => step.status === \"confirming\").map((step) => step.quoteId),\n ),\n onExpire: expirePending,\n onWait: () =>\n startTpSlFallbackPoll(config, {\n chainId,\n delayMs: runParameters.fallbackPollDelayMs,\n intervalMs: runParameters.fallbackPollIntervalMs,\n getWaiting: () => waitingSidesOf(runRef.current.steps, virtualAccountByQuoteId),\n }).stop,\n timeoutMs: runParameters.confirmationTimeoutMs ?? DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS,\n });\n } finally {\n inFlight.current = false;\n }\n\n const finalSteps = runRef.current.steps;\n const failed = finalSteps.filter((step) => step.status === \"failed\");\n const confirmed = finalSteps.filter((step) => step.status === \"done\");\n /** Accepted but never reported — the handler took it, the confirmation never came. */\n const unconfirmed = failed.filter((step) => step.error?.code === TPSL_CONFIRMATION_TIMEOUT_CODE);\n commit({ ...runRef.current, status: resolveStatus(finalSteps), error: failed[0]?.error });\n\n // Reconcile against the handler's rows now that the run is over: the\n // reports carried the state, this makes sure the resting snapshot agrees.\n void invalidateTpSlReads(\n queryClient,\n confirmed.map((step) => step.quoteId),\n );\n\n return {\n ok: failed.length === 0,\n submittedCount: confirmed.length + unconfirmed.length,\n confirmedCount: confirmed.length,\n failedCount: failed.length,\n skippedCount: plan.skips.length,\n steps: [...finalSteps],\n plan,\n stoppedByUser,\n error: failed[0]?.error,\n };\n },\n [commit, config, connectedChainId, queryClient, settle],\n );\n\n const set = useCallback((runParameters: SetQuoteGroupTpSlParameters) => run(runParameters), [run]);\n\n const retryFailed = useCallback(\n async (children?: readonly GroupTpSlChild[]): Promise<SetQuoteGroupTpSlSummary> => {\n const last = lastRunRef.current;\n const previous = runRef.current.steps;\n const failedKeys = [...new Set(previous.filter((step) => step.status === \"failed\").map((step) => step.key))];\n if (!last || failedKeys.length === 0) {\n return {\n ok: true,\n submittedCount: 0,\n confirmedCount: 0,\n failedCount: 0,\n skippedCount: 0,\n steps: [...previous],\n plan: runRef.current.plan ?? EMPTY_PLAN,\n stoppedByUser: false,\n };\n }\n // Keep every step that already succeeded or is still confirming, so a\n // retry never regresses progress or tears down a live subscription.\n const carryOver = previous.filter((step) => !failedKeys.includes(step.key));\n return run({ ...last, children: children ?? last.children, only: failedKeys }, carryOver);\n },\n [run],\n );\n\n const reset = useCallback(() => {\n if (inFlight.current) return;\n watchChainIdRef.current = undefined;\n setWatchAccounts([]);\n lastRunRef.current = undefined;\n commit(IDLE);\n }, [commit]);\n\n const counts = useMemo(() => {\n const executed = state.steps.filter((step) => step.status !== \"skipped\");\n const accepted = executed.filter((step) => step.status === \"confirming\" || step.status === \"done\").length;\n const confirmed = executed.filter((step) => step.status === \"done\").length;\n const failed = executed.filter((step) => step.status === \"failed\").length;\n /** A step the handler accepted but has not reported on is not progress yet. */\n const settled = confirmed + failed;\n return {\n acceptedCount: accepted,\n confirmedCount: confirmed,\n failedCount: failed,\n totalCount: executed.length,\n progressPercent: executed.length === 0 ? 0 : Math.round((settled / executed.length) * 10_000) / 100,\n };\n }, [state.steps]);\n\n return {\n set,\n retryFailed,\n reset,\n status: state.status,\n isSubmitting: state.status === \"submitting\",\n isConfirming: state.status === \"confirming\",\n ...counts,\n steps: state.steps,\n plan: state.plan,\n error: state.error,\n };\n}\n\n/**\n * Reconcile confirming steps against the shared store: drop each side the\n * handler has reported on and mark the step `done` once none are left.\n *\n * @param steps - The run's current steps.\n * @returns The updated list, or `undefined` when nothing moved.\n */\nfunction settleSteps(steps: SetQuoteGroupTpSlStep[]): SetQuoteGroupTpSlStep[] | undefined {\n const store = useTpSlStore.getState();\n let changed = false;\n const next = steps.map((step) => {\n if (step.status !== \"confirming\") return step;\n const record = store.get(step.quoteId);\n if (!record) return step;\n const remaining = step.sides.filter((side) =>\n step.kind === \"cancel\" ? !isCancelSideSettled(record, side) : !isWriteSideSettled(record, side),\n );\n if (remaining.length === step.sides.length) return step;\n changed = true;\n return remaining.length > 0 ? { ...step, sides: remaining } : { ...step, sides: [], status: \"done\" as const };\n });\n return changed ? next : undefined;\n}\n\n/**\n * The sides this run is still waiting on, in the shape the fallback sweep\n * needs: one entry per `(quote, side)` still `confirming`, tagged with the\n * account whose orders it will be found among and with what it is waiting for.\n *\n * Read live on every tick, so a side settled by a WebSocket frame between two\n * ticks drops out on its own.\n */\nfunction waitingSidesOf(\n steps: readonly SetQuoteGroupTpSlStep[],\n accounts: ReadonlyMap<bigint, Address>,\n): TpSlPollWaitingSide[] {\n const waiting: TpSlPollWaitingSide[] = [];\n for (const step of steps) {\n if (step.status !== \"confirming\") continue;\n const account = accounts.get(step.quoteId);\n if (!account) continue;\n for (const side of step.sides) {\n waiting.push({\n quoteId: step.quoteId,\n side,\n intent: step.kind === \"cancel\" ? \"cancel\" : \"write\",\n cohQuoteId: step.cohQuoteId,\n account,\n });\n }\n }\n return waiting;\n}\n\n/**\n * The accounts whose streams report on this run.\n *\n * The SubAccount comes first because that is where the handler actually\n * publishes: a report's `address` is the subscribing account, not the Virtual\n * Account that owns the order — two quotes under different VAs arrive on the\n * same channel. The VAs are watched as well, since they are what the orders are\n * filed under and a deployment that reports there costs us one pooled\n * subscription to cover.\n */\nfunction watchAccountsOf(parameters: SetQuoteGroupTpSlParameters, plan: PlanGroupTpSlResult): Address[] {\n if (parameters.notificationsAccounts) return dedupeAddresses(parameters.notificationsAccounts);\n return dedupeAddresses([\n parameters.notificationsAccount ?? parameters.subAccount,\n ...plan.actions.map((action) => (action.action === \"skip\" ? undefined : action.virtualAccount)),\n ]);\n}\n\n/** Stable, unique step identity. A cancel is per-side; a write covers both sides of one leg. */\nfunction stepIdOf(action: GroupTpSlAction): string {\n if (action.action === \"delete\") return `${action.key}:cancel:${action.conditionalOrderType}`;\n if (action.action === \"set\") return `${action.key}:write`;\n return `${action.key}:skip`;\n}\n\n/** Map one planner decision onto its initial step. */\nfunction toStep(action: GroupTpSlAction): SetQuoteGroupTpSlStep {\n if (action.action === \"delete\") {\n return {\n id: stepIdOf(action),\n key: action.key,\n kind: \"cancel\",\n quoteId: action.quoteId,\n sides: [action.conditionalOrderType],\n status: \"queued\",\n cohQuoteId: action.cohQuoteId,\n };\n }\n if (action.action === \"set\") {\n return {\n id: stepIdOf(action),\n key: action.key,\n kind: \"write\",\n quoteId: action.quoteId,\n sides: [...(action.tp ? ([\"take_profit\"] as const) : []), ...(action.sl ? ([\"stop_loss\"] as const) : [])],\n status: \"queued\",\n };\n }\n return {\n id: stepIdOf(action),\n key: action.key,\n kind: \"skip\",\n quoteId: 0n,\n sides: [],\n status: \"skipped\",\n skipReason: action.reason,\n validation: action.validation,\n };\n}\n\n/**\n * Derive the run status from the current step list. Skipped legs never\n * influence it — a run whose plan skipped everything is a success. `confirming`\n * outranks `partial` so a failure elsewhere cannot make the status terminal\n * while other steps still await their reports.\n */\nfunction resolveStatus(steps: SetQuoteGroupTpSlStep[]): SetQuoteGroupTpSlStatus {\n const executed = steps.filter((step) => step.status !== \"skipped\");\n if (executed.length === 0) return \"success\";\n if (executed.some((step) => step.status === \"queued\" || step.status === \"submitting\")) return \"submitting\";\n if (executed.some((step) => step.status === \"confirming\")) return \"confirming\";\n const failed = executed.filter((step) => step.status === \"failed\").length;\n if (failed === executed.length) return \"failed\";\n if (failed > 0) return \"partial\";\n return \"success\";\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoPA,IAAM,IAAiB;CAAE,QAAQ;CAAQ,OAAO,CAAC;AAAE,GAG7C,IAAkC;CACtC,SAAS,CAAC;CACV,MAAM,CAAC;CACP,SAAS,CAAC;CACV,OAAO,CAAC;CACR,YAAY;CACZ,QAAQ;AACV;AAuCA,SAAgB,EAAqB,IAA6C,CAAC,GAAmC;CACpH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAmB,EAAiB,GACpC,IAAc,EAAe,GAC7B,CAAC,GAAO,KAAY,EAAmB,CAAI,GAE3C,IAAS,EAAiB,CAAI,GAC9B,IAAW,EAAO,EAAK,GAEvB,IAAa,EAAgD,KAAA,CAAS,GACtE,CAAC,GAAe,KAAoB,EAAoB,CAAC,CAAC,GAC1D,IAAkB,EAA2B,KAAA,CAAS,GAEtD,IAAS,GAAa,MAAmB;EAE7C,AADA,EAAO,UAAU,GACjB,EAAS,CAAI;CACf,GAAG,CAAC,CAAC,GAGC,IAAgB,QACd,MAAM,KAAK,IAAI,IAAI,EAAM,MAAM,QAAQ,MAAS,EAAK,WAAW,YAAY,EAAE,KAAK,MAAS,EAAK,OAAO,CAAC,CAAC,GAChH,CAAC,EAAM,KAAK,CACd;CAQA,EAAqB;EACnB,UAAU;EACV,KAAK;EACL,SAAS,EAAgB;EACzB,QAAQ,EAAW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Ac,GAAyD;CAC9E,IAAM,IAAW,EAAM,QAAQ,MAAS,EAAK,WAAW,SAAS;CACjE,IAAI,EAAS,WAAW,GAAG,OAAO;CAClC,IAAI,EAAS,MAAM,MAAS,EAAK,WAAW,YAAY,EAAK,WAAW,YAAY,GAAG,OAAO;CAC9F,IAAI,EAAS,MAAM,MAAS,EAAK,WAAW,YAAY,GAAG,OAAO;CAClE,IAAM,IAAS,EAAS,QAAQ,MAAS,EAAK,WAAW,QAAQ,EAAE;CAGnE,OAFI,MAAW,EAAS,SAAe,WACnC,IAAS,IAAU,YAChB;AACT"}
|
|
@@ -14,10 +14,10 @@ export type UseSetQuoteTpSlReturnType = UseMutationResult<SetQuoteTpSlReturnType
|
|
|
14
14
|
* 2. `confirming` — POST returned 200; the store's `markConfirming` sets
|
|
15
15
|
* `tp/slState` to `"confirming"` and seeds the target trigger price so
|
|
16
16
|
* the UI can render it immediately.
|
|
17
|
-
* 3. `new` —
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* 3. `new` — Confirmed. The handler's live `report` (`applyNotification`)
|
|
18
|
+
* resolves the side first when the socket is connected; a refetch of the
|
|
19
|
+
* quote's TP/SL read on success is the authoritative backstop, so the box
|
|
20
|
+
* resolves out of `confirming` even when that frame is missed.
|
|
21
21
|
*/
|
|
22
22
|
export declare function useSetQuoteTpSl(parameters?: UseSetQuoteTpSlParameters): UseSetQuoteTpSlReturnType;
|
|
23
23
|
//# sourceMappingURL=use-set-quote-tpsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-set-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"use-set-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAMzE,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAExD,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CACvD,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAE,yBAA8B,GAAG,yBAAyB,CAoCrG"}
|
|
@@ -3,37 +3,40 @@ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
|
3
3
|
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 { useTpSlStore as r } from "./tpsl-store.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { invalidateTpSlReads as i } from "./invalidate-tpsl.js";
|
|
7
|
+
import { setQuoteTpSlMutationOptions as a } from "@symmio/trading-core";
|
|
8
|
+
import { useMutation as o, useQueryClient as s } from "@tanstack/react-query";
|
|
8
9
|
//#region src/tpsl/use-set-quote-tpsl.ts
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
return
|
|
12
|
-
mutationKey:
|
|
10
|
+
function c(c = {}) {
|
|
11
|
+
let l = t(c), u = e(), d = s(), f = a(l), p = r((e) => e.markConfirming);
|
|
12
|
+
return o({
|
|
13
|
+
mutationKey: f.mutationKey,
|
|
13
14
|
mutationFn: async (e) => {
|
|
14
15
|
try {
|
|
15
|
-
return await
|
|
16
|
+
return await f.mutationFn({
|
|
16
17
|
...e,
|
|
17
|
-
chainId: e.chainId ??
|
|
18
|
+
chainId: e.chainId ?? u
|
|
18
19
|
});
|
|
19
20
|
} catch (e) {
|
|
20
21
|
throw n(e);
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
onSuccess: (e, t) => {
|
|
24
|
-
t.tp &&
|
|
25
|
+
t.tp && p(t.quoteId, "tp", {
|
|
25
26
|
price: t.tp.triggerPrice,
|
|
27
|
+
pricePrecision: t.pricePrecision,
|
|
26
28
|
priceType: t.tp.priceType,
|
|
27
29
|
cohQuoteId: e.cohQuoteId
|
|
28
|
-
}), t.sl &&
|
|
30
|
+
}), t.sl && p(t.quoteId, "sl", {
|
|
29
31
|
price: t.sl.triggerPrice,
|
|
32
|
+
pricePrecision: t.pricePrecision,
|
|
30
33
|
priceType: t.sl.priceType,
|
|
31
34
|
cohQuoteId: e.cohQuoteId
|
|
32
|
-
});
|
|
35
|
+
}), i(d, [t.quoteId]);
|
|
33
36
|
}
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
//#endregion
|
|
37
|
-
export {
|
|
40
|
+
export { c as useSetQuoteTpSl };
|
|
38
41
|
|
|
39
42
|
//# sourceMappingURL=use-set-quote-tpsl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-set-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, 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 { useTpSlStore } from \"./tpsl-store\";\n\n/** Parameters for {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlReturnType = UseMutationResult<\n SetQuoteTpSlReturnType,\n SymmioRequestError,\n SetQuoteTpSlParameters\n>;\n\n/**\n * Submit a TP/SL order for one quote. Signs an EIP-712 message with the\n * session-key wallet and POSTs to the handler.\n *\n * State machine (per side):\n * 1. `pending` — POST in flight (`mutation.isPending`).\n * 2. `confirming` — POST returned 200; the store's `markConfirming` sets\n * `tp/slState` to `\"confirming\"` and seeds the target trigger price so\n * the UI can render it immediately.\n * 3. `new` —
|
|
1
|
+
{"version":3,"file":"use-set-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\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 { invalidateTpSlReads } from \"./invalidate-tpsl\";\nimport { useTpSlStore } from \"./tpsl-store\";\n\n/** Parameters for {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlReturnType = UseMutationResult<\n SetQuoteTpSlReturnType,\n SymmioRequestError,\n SetQuoteTpSlParameters\n>;\n\n/**\n * Submit a TP/SL order for one quote. Signs an EIP-712 message with the\n * session-key wallet and POSTs to the handler.\n *\n * State machine (per side):\n * 1. `pending` — POST in flight (`mutation.isPending`).\n * 2. `confirming` — POST returned 200; the store's `markConfirming` sets\n * `tp/slState` to `\"confirming\"` and seeds the target trigger price so\n * the UI can render it immediately.\n * 3. `new` — Confirmed. The handler's live `report` (`applyNotification`)\n * resolves the side first when the socket is connected; a refetch of the\n * quote's TP/SL read on success is the authoritative backstop, so the box\n * resolves out of `confirming` even when that frame is missed.\n */\nexport function useSetQuoteTpSl(parameters: UseSetQuoteTpSlParameters = {}): UseSetQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const base = setQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore((state) => state.markConfirming);\n\n return useMutation<SetQuoteTpSlReturnType, SymmioRequestError, SetQuoteTpSlParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({ ...variables, chainId: variables.chainId ?? chainId });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (result, variables) => {\n if (variables.tp) {\n markConfirming(variables.quoteId, \"tp\", {\n price: variables.tp.triggerPrice,\n pricePrecision: variables.pricePrecision,\n priceType: variables.tp.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n if (variables.sl) {\n markConfirming(variables.quoteId, \"sl\", {\n price: variables.sl.triggerPrice,\n pricePrecision: variables.pricePrecision,\n priceType: variables.sl.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n void invalidateTpSlReads(queryClient, [variables.quoteId]);\n },\n });\n}\n"],"mappings":";;;;;;;;;AAwCA,SAAgB,EAAgB,IAAwC,CAAC,GAA8B;CACrG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAO,EAA4B,CAAM,GACzC,IAAiB,GAAc,MAAU,EAAM,cAAc;CAEnE,OAAO,EAAgF;EACrF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS,EAAU,WAAW;IAAQ,CAAC;GACtF,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAQ,MAAc;GAiBhC,AAhBI,EAAU,MACZ,EAAe,EAAU,SAAS,MAAM;IACtC,OAAO,EAAU,GAAG;IACpB,gBAAgB,EAAU;IAC1B,WAAW,EAAU,GAAG;IACxB,YAAY,EAAO;GACrB,CAAC,GAEC,EAAU,MACZ,EAAe,EAAU,SAAS,MAAM;IACtC,OAAO,EAAU,GAAG;IACpB,gBAAgB,EAAU;IAC1B,WAAW,EAAU,GAAG;IACxB,YAAY,EAAO;GACrB,CAAC,GAEH,EAAyB,GAAa,CAAC,EAAU,OAAO,CAAC;EAC3D;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConfigParameter, SolverId } from '@symmio/trading-core';
|
|
2
|
+
/** Parameters for {@link useTpSlSupported}. */
|
|
3
|
+
export interface UseTpSlSupportedParameters extends ConfigParameter {
|
|
4
|
+
/** Chain to check; defaults to the connected chain. */
|
|
5
|
+
chainId?: number;
|
|
6
|
+
/** Solver to check; defaults to the chain's default solver. */
|
|
7
|
+
solverId?: SolverId;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Whether TP/SL is available on the target chain/solver — i.e. the resolved
|
|
11
|
+
* solver declares a conditional-order handler. Use it to hide or disable TP/SL
|
|
12
|
+
* UI (cells, modals, the TP/SL flow) so a solver without a handler (e.g. a rasa
|
|
13
|
+
* solver on Base) degrades gracefully instead of erroring.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const tpslSupported = useTpSlSupported();
|
|
18
|
+
* if (!tpslSupported) return null; // hide the TP/SL cell
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function useTpSlSupported(parameters?: UseTpSlSupportedParameters): boolean;
|
|
22
|
+
//# sourceMappingURL=use-tpsl-supported.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tpsl-supported.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-tpsl-supported.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIzF,+CAA+C;AAC/C,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,0BAA+B,GAAG,OAAO,CAIrF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { supportsTpSl as n } from "@symmio/trading-core";
|
|
5
|
+
//#region src/tpsl/use-tpsl-supported.ts
|
|
6
|
+
function r(r = {}) {
|
|
7
|
+
let i = t(r), a = e();
|
|
8
|
+
return n(i, {
|
|
9
|
+
chainId: r.chainId ?? a,
|
|
10
|
+
solverId: r.solverId
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { r as useTpSlSupported };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=use-tpsl-supported.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tpsl-supported.js","names":[],"sources":["../../src/tpsl/use-tpsl-supported.ts"],"sourcesContent":["\"use client\";\n\nimport { supportsTpSl, type ConfigParameter, type SolverId } from \"@symmio/trading-core\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useTpSlSupported}. */\nexport interface UseTpSlSupportedParameters extends ConfigParameter {\n /** Chain to check; defaults to the connected chain. */\n chainId?: number;\n /** Solver to check; defaults to the chain's default solver. */\n solverId?: SolverId;\n}\n\n/**\n * Whether TP/SL is available on the target chain/solver — i.e. the resolved\n * solver declares a conditional-order handler. Use it to hide or disable TP/SL\n * UI (cells, modals, the TP/SL flow) so a solver without a handler (e.g. a rasa\n * solver on Base) degrades gracefully instead of erroring.\n *\n * @example\n * ```tsx\n * const tpslSupported = useTpSlSupported();\n * if (!tpslSupported) return null; // hide the TP/SL cell\n * ```\n */\nexport function useTpSlSupported(parameters: UseTpSlSupportedParameters = {}): boolean {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n return supportsTpSl(config, { chainId: parameters.chainId ?? chainId, solverId: parameters.solverId });\n}\n"],"mappings":";;;;;AA0BA,SAAgB,EAAiB,IAAyC,CAAC,GAAY;CACrF,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB;CACjC,OAAO,EAAa,GAAQ;EAAE,SAAS,EAAW,WAAW;EAAS,UAAU,EAAW;CAAS,CAAC;AACvG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConfigParameter } from '@symmio/trading-core';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
/** Parameters for {@link useWatchTpSlAccounts}. */
|
|
4
|
+
export interface UseWatchTpSlAccountsParameters extends ConfigParameter {
|
|
5
|
+
/** Accounts to subscribe to. A grouped position can span Virtual Accounts. */
|
|
6
|
+
accounts: readonly Address[];
|
|
7
|
+
/** Quote ids an incoming frame may belong to; read live inside the handler. */
|
|
8
|
+
ids: readonly (bigint | undefined)[];
|
|
9
|
+
/** Target chain id. Defaults to the config's default chain. */
|
|
10
|
+
chainId?: number;
|
|
11
|
+
/** Subscribe only when `true`. Default `true`. */
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Subscribe to the TP/SL stream of several accounts at once and fold every
|
|
16
|
+
* matching frame into the shared TP/SL store.
|
|
17
|
+
*
|
|
18
|
+
* `useWatchTpSlNotifications` cannot cover this: the account count changes as a
|
|
19
|
+
* group grows, and a hook cannot be called in a loop. So this drives the core
|
|
20
|
+
* watcher directly from one effect. The SDK's socket pool keys on
|
|
21
|
+
* `(wsUrl, appName, account)`, so subscribing here adds handlers to sockets
|
|
22
|
+
* other hooks already opened rather than new connections.
|
|
23
|
+
*
|
|
24
|
+
* Frames land in the store rather than in a caller-supplied callback, because
|
|
25
|
+
* the store is what every consumer — read hooks, run hooks, cells — reconciles
|
|
26
|
+
* against. That way a step confirms no matter which subscription received it.
|
|
27
|
+
*
|
|
28
|
+
* @param parameters - The accounts to watch, the candidate quote ids, and the enable switch.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useWatchTpSlAccounts(parameters: UseWatchTpSlAccountsParameters): void;
|
|
31
|
+
/** Case-insensitive address dedupe that preserves first-seen order. */
|
|
32
|
+
export declare function dedupeAddresses(addresses: readonly (Address | undefined)[]): Address[];
|
|
33
|
+
//# sourceMappingURL=use-watch-tpsl-accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-watch-tpsl-accounts.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-watch-tpsl-accounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAKpC,mDAAmD;AACnD,MAAM,WAAW,8BAA+B,SAAQ,eAAe;IACrE,8EAA8E;IAC9E,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,+EAA+E;IAC/E,GAAG,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IACrC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,8BAA8B,GAAG,IAAI,CAgCrF;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,CAWtF"}
|