@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 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-hold.js","names":[],"sources":["../../src/quotes/confirm-hold.ts"],"sourcesContent":["import { QuoteLifecycle, QuoteStatus, type UnifiedQuote } from \"@symmio/trading-core\";\n\n/**\n * Next interval (ms) for a confirm-hold backoff: double the current delay, capped\n * at `max`. After the immediate refetch the schedule is `first`, `first * 2`, … up to\n * `max`, then steady at `max` until the hold is released.\n *\n * @param current - the current backoff interval (ms).\n * @param max - the ceiling interval (ms).\n */\nexport function nextConfirmDelay(current: number, max: number): number {\n return Math.min(current * 2, max);\n}\n\n/**\n * One close-confirm hold entry: its deadline (ms epoch) plus the `closedAmount`\n * the position had **when the fill was seen**. The chase (and the row's\n * `WRITE_ONCHAIN_CLOSE` retention) releases the moment the on-chain `closedAmount`\n * advances past this baseline — a **partial** settle back to a live position —\n * the same as a full settle (row removed) or a `CLOSE_PENDING` status.\n */\nexport interface CloseConfirmEntry {\n deadline: number;\n baseClosed: bigint;\n}\n\n/**\n * Whether the chain has acknowledged a close for a quote that is **still present**\n * in the active set. Releases the close-confirm hold when the on-chain status\n * reflects the pending close (`quoteStatus` `CLOSE_PENDING` / `CANCEL_CLOSE_PENDING`),\n * the quote is terminally `CLOSED`, or `closedAmount` caught up to the full\n * `quantity`. A quote that dropped out of the active set entirely (a full close)\n * is handled by the caller, not here.\n */\nexport function isCloseConfirmedOnchain(quote: UnifiedQuote): boolean {\n if (quote.lifecycle === QuoteLifecycle.CLOSED) return true;\n if (quote.quoteStatus === QuoteStatus.CLOSE_PENDING || quote.quoteStatus === QuoteStatus.CANCEL_CLOSE_PENDING) {\n return true;\n }\n const closed = quote.closedAmount ?? 0n;\n return quote.quantity > 0n && closed >= quote.quantity;\n}\n\n/**\n * Prune the close-confirm hold **in place** against the current active quotes.\n *\n * The hold keeps the managed-quotes on-chain reads accelerated after a close\n * notification until the chain reflects the close — it exists because a rasa\n * instant-close reports `FillMarketOrderInstantClose` while the on-chain read\n * still shows the quote OPENED, and the stateless reconcile would otherwise revert\n * the row to `ONCHAIN` and stop the accelerated poll before the settle lands.\n *\n * Deletes an entry when the chain confirms the close — the row dropped from the\n * active set (full close), or {@link isCloseConfirmedOnchain} for a still-present\n * row — or when its deadline has passed. Returns the ids dropped **only** because\n * their deadline expired without confirmation (a close that never settled), so the\n * caller can surface them; confirmed and absent entries are not returned.\n *\n * @param pending - map of on-chain quoteId → deadline (ms epoch); mutated in place.\n * @param quotes - the current reconciled active quotes.\n * @param now - current time (ms epoch), e.g. `Date.now()`.\n * @returns the quoteIds dropped due to an expired deadline.\n */\nexport function pruneCloseConfirmHold(\n pending: Map<string, CloseConfirmEntry>,\n quotes: readonly UnifiedQuote[],\n now: number,\n): string[] {\n if (pending.size === 0) return [];\n const expired: string[] = [];\n for (const [quoteId, { deadline, baseClosed }] of pending) {\n const row = quotes.find((quote) => `${quote.quoteId}` === quoteId);\n /* Released once the chain reflects the close: the row dropped (full settle),\n the status/closed-amount confirms it, or `closedAmount` advanced past the\n baseline captured at the fill — a partial settle back to a live position. */\n if (!row || isCloseConfirmedOnchain(row) || (row.closedAmount ?? 0n) > baseClosed) {\n pending.delete(quoteId);\n continue;\n }\n if (now > deadline) {\n pending.delete(quoteId);\n expired.push(quoteId);\n }\n }\n return expired;\n}\n\n/**\n * Whether the on-chain read has caught up with an anchored open: the row carries\n * the polled struct (`raw.onchain`), so `getPartyAOpenPositions` /\n * `getPartyAPendingQuotes` have actually returned the quote. A row that exists only\n * because a notification anchored it (`WRITE_ONCHAIN`, or a retained anchor) is\n * **not** confirmed — that row is precisely what the hold is waiting to replace.\n */\nexport function isOpenConfirmedOnchain(quote: UnifiedQuote): boolean {\n return quote.raw.onchain !== undefined;\n}\n\n/**\n * Prune the open-confirm hold **in place** against the current active quotes.\n *\n * The hold chases the on-chain reads after an open-anchor notification\n * (`SendQuoteTransaction` / `SendQuote` / `FillLimitOrderOpen`) until the read\n * returns the quote. The solver emits that frame when it **broadcasts** the\n * transaction, so the single invalidation it triggers races the block and usually\n * loses; without the chase the position stays invisible until something else\n * happens to refetch, because with the notifications socket live there is no idle\n * poll and the accelerated retry only runs while a `WRITE_ONCHAIN` row exists —\n * which requires a pre-chain row from the hedger feed that may already be gone.\n *\n * Mirror of {@link pruneCloseConfirmHold} with one deliberate difference: for a\n * close, a row **absent** from the active set means the close landed; for an open,\n * absence is the very condition being chased, so it keeps the entry.\n *\n * @param pending - map of on-chain quoteId → deadline (ms epoch); mutated in place.\n * @param quotes - the current reconciled active quotes.\n * @param now - current time (ms epoch), e.g. `Date.now()`.\n * @returns the quoteIds dropped due to an expired deadline (an anchor the read never confirmed).\n */\nexport function pruneOpenConfirmHold(\n pending: Map<string, number>,\n quotes: readonly UnifiedQuote[],\n now: number,\n): string[] {\n if (pending.size === 0) return [];\n const expired: string[] = [];\n for (const [quoteId, deadline] of pending) {\n const row = quotes.find((quote) => `${quote.quoteId}` === quoteId);\n if (row && isOpenConfirmedOnchain(row)) {\n pending.delete(quoteId);\n continue;\n }\n if (now > deadline) {\n pending.delete(quoteId);\n expired.push(quoteId);\n }\n }\n return expired;\n}\n\n/**\n * Whether the chain has settled a cancel for a quote that is **still present** in the\n * active set — only the terminal `CLOSED` lifecycle counts (`CANCELED` / `EXPIRED` /\n * `CLOSED` on-chain). A quote that dropped out of the active set entirely is the\n * normal outcome and is handled by the caller.\n *\n * Deliberately **not** released on `quoteStatus !== CANCEL_PENDING`: the hold is\n * registered off the cancel-request notification, which the solver publishes around\n * the time the request transaction is broadcast, so the read at that moment usually\n * still says `LOCKED`. Releasing on \"not CANCEL_PENDING\" would end the chase on that\n * stale pre-request read and leave the row stuck exactly as before. Holding through\n * `LOCKED` → `CANCEL_PENDING` → gone is the point.\n */\nexport function isCancelConfirmedOnchain(quote: UnifiedQuote): boolean {\n return quote.lifecycle === QuoteLifecycle.CLOSED;\n}\n\n/**\n * Prune the cancel-confirm hold **in place** against the current active quotes.\n *\n * The hold chases the on-chain reads after a cancel notification until the chain\n * settles the cancel. It exists because cancelling a `LOCKED` order is a\n * **two-transaction** flow of which only the first is announced:\n * `requestToCancelQuote` moves the quote to `CANCEL_PENDING` and leaves it in\n * `partyAPendingQuotes`, and the solver's later `acceptCancelRequest` — the one that\n * sets `CANCELED` and removes it — publishes no notification frame at all. With the\n * event channel live there is no idle poll and a `CANCEL_PENDING` row does not\n * accelerate anything (its lifecycle is the generic `ONCHAIN`), so without this chase\n * a cancelled order stays on screen until something unrelated happens to refetch.\n *\n * Same shape as {@link pruneCloseConfirmHold}: an entry whose row is **absent** from\n * the active set is confirmed (the accept removed it from the pending array), as is\n * one whose row went terminal ({@link isCancelConfirmedOnchain}). Returns the ids\n * dropped **only** because their deadline passed — a cancel the solver never answered\n * — so the caller can surface them.\n *\n * @param pending - map of on-chain quoteId → deadline (ms epoch); mutated in place.\n * @param quotes - the current reconciled active quotes.\n * @param now - current time (ms epoch), e.g. `Date.now()`.\n * @returns the quoteIds dropped due to an expired deadline.\n */\nexport function pruneCancelConfirmHold(\n pending: Map<string, number>,\n quotes: readonly UnifiedQuote[],\n now: number,\n): string[] {\n if (pending.size === 0) return [];\n const expired: string[] = [];\n for (const [quoteId, deadline] of pending) {\n const row = quotes.find((quote) => `${quote.quoteId}` === quoteId);\n if (!row || isCancelConfirmedOnchain(row)) {\n pending.delete(quoteId);\n continue;\n }\n if (now > deadline) {\n pending.delete(quoteId);\n expired.push(quoteId);\n }\n }\n return expired;\n}\n"],"mappings":";;AAUA,SAAgB,EAAiB,GAAiB,GAAqB;CACrE,OAAO,KAAK,IAAI,IAAU,GAAG,CAAG;AAClC;AAsBA,SAAgB,EAAwB,GAA8B;CAEpE,IADI,EAAM,cAAc,EAAe,UACnC,EAAM,gBAAgB,EAAY,iBAAiB,EAAM,gBAAgB,EAAY,sBACvF,OAAO;CAET,IAAM,IAAS,EAAM,gBAAgB;CACrC,OAAO,EAAM,WAAW,MAAM,KAAU,EAAM;AAChD;AAsBA,SAAgB,EACd,GACA,GACA,GACU;CACV,IAAI,EAAQ,SAAS,GAAG,OAAO,CAAC;CAChC,IAAM,IAAoB,CAAC;CAC3B,KAAK,IAAM,CAAC,GAAS,EAAE,aAAU,oBAAiB,GAAS;EACzD,IAAM,IAAM,EAAO,MAAM,MAAU,GAAG,EAAM,cAAc,CAAO;EAIjE,IAAI,CAAC,KAAO,EAAwB,CAAG,MAAM,EAAI,gBAAgB,MAAM,GAAY;GACjF,EAAQ,OAAO,CAAO;GACtB;EACF;EACA,AAAI,IAAM,MACR,EAAQ,OAAO,CAAO,GACtB,EAAQ,KAAK,CAAO;CAExB;CACA,OAAO;AACT;AASA,SAAgB,EAAuB,GAA8B;CACnE,OAAO,EAAM,IAAI,YAAY,KAAA;AAC/B;AAuBA,SAAgB,EACd,GACA,GACA,GACU;CACV,IAAI,EAAQ,SAAS,GAAG,OAAO,CAAC;CAChC,IAAM,IAAoB,CAAC;CAC3B,KAAK,IAAM,CAAC,GAAS,MAAa,GAAS;EACzC,IAAM,IAAM,EAAO,MAAM,MAAU,GAAG,EAAM,cAAc,CAAO;EACjE,IAAI,KAAO,EAAuB,CAAG,GAAG;GACtC,EAAQ,OAAO,CAAO;GACtB;EACF;EACA,AAAI,IAAM,MACR,EAAQ,OAAO,CAAO,GACtB,EAAQ,KAAK,CAAO;CAExB;CACA,OAAO;AACT;AAeA,SAAgB,EAAyB,GAA8B;CACrE,OAAO,EAAM,cAAc,EAAe;AAC5C;AA0BA,SAAgB,EACd,GACA,GACA,GACU;CACV,IAAI,EAAQ,SAAS,GAAG,OAAO,CAAC;CAChC,IAAM,IAAoB,CAAC;CAC3B,KAAK,IAAM,CAAC,GAAS,MAAa,GAAS;EACzC,IAAM,IAAM,EAAO,MAAM,MAAU,GAAG,EAAM,cAAc,CAAO;EACjE,IAAI,CAAC,KAAO,EAAyB,CAAG,GAAG;GACzC,EAAQ,OAAO,CAAO;GACtB;EACF;EACA,AAAI,IAAM,MACR,EAAQ,OAAO,CAAO,GACtB,EAAQ,KAAK,CAAO;CAExB;CACA,OAAO;AACT"}
|
package/dist/quotes/index.d.ts
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
export * from './optimistic-quotes-store.js';
|
|
2
2
|
export * from './use-account-liquidation-price.js';
|
|
3
|
+
export * from './use-account-upnl.js';
|
|
4
|
+
export * from './use-close-quote-group.js';
|
|
5
|
+
export * from './use-cool-downs-of-ma.js';
|
|
6
|
+
export * from './use-force-cancel-close-request.js';
|
|
7
|
+
export * from './use-force-cancel-quote.js';
|
|
8
|
+
export * from './use-force-close.js';
|
|
9
|
+
export * from './use-force-close-eligibility.js';
|
|
10
|
+
export * from './use-force-close-params.js';
|
|
3
11
|
export * from './use-grouped-quotes.js';
|
|
12
|
+
export * from './use-limit-orders.js';
|
|
4
13
|
export * from './use-managed-quotes.js';
|
|
5
14
|
export * from './use-party-a-open-positions.js';
|
|
6
15
|
export * from './use-party-a-pending-quotes.js';
|
|
7
16
|
export * from './use-quote.js';
|
|
8
17
|
export * from './use-quote-events-by-type.js';
|
|
9
18
|
export * from './use-quote-funding.js';
|
|
19
|
+
export * from './use-quote-group-funding.js';
|
|
20
|
+
export * from './use-quote-group-funding-history.js';
|
|
21
|
+
export * from './use-quote-group-margin-risk.js';
|
|
10
22
|
export * from './use-quote-history.js';
|
|
11
23
|
export * from './use-quote-platform-fee.js';
|
|
12
24
|
export * from './use-quote-price-history.js';
|
|
13
25
|
export * from './use-quote-upnl-and-pnl.js';
|
|
14
26
|
export * from './use-quotes-funding.js';
|
|
27
|
+
export * from './use-request-to-cancel-close-request.js';
|
|
28
|
+
export * from './use-request-to-cancel-quote.js';
|
|
15
29
|
export * from './use-subgraph-query.js';
|
|
16
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quotes/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quotes/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ConfigParameter, SolverId } from '@symmio/trading-core';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for {@link useAccountUpnl}.
|
|
5
|
+
*/
|
|
6
|
+
export interface UseAccountUpnlParameters extends ConfigParameter {
|
|
7
|
+
/** The partyA whose open positions are summed. Disabled while undefined. */
|
|
8
|
+
account?: Address;
|
|
9
|
+
/** Target chain id. Defaults to the SDK's active chain. */
|
|
10
|
+
chainId?: number;
|
|
11
|
+
/** Solver whose markets + price provider value the positions. Defaults to the chain's default solver. */
|
|
12
|
+
solverId?: SolverId;
|
|
13
|
+
/** Compute only when `true`. Default `true`. */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to the account's live notifications so the position set tracks
|
|
17
|
+
* opens/closes (and off-chain quotes anchoring on-chain) without a manual
|
|
18
|
+
* refresh. Mark prices are always live via the price socket.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
live?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Value returned by {@link useAccountUpnl}.
|
|
25
|
+
*/
|
|
26
|
+
export interface UseAccountUpnlReturnType {
|
|
27
|
+
/**
|
|
28
|
+
* Σ unrealized PnL across the account's open positions — on-chain **and**
|
|
29
|
+
* off-chain (optimistic instant-opens) — signed wei. `undefined` until every
|
|
30
|
+
* priced position has a live mark price, so a half-priced sum is never
|
|
31
|
+
* mistaken for the real figure.
|
|
32
|
+
*/
|
|
33
|
+
upnl: bigint | undefined;
|
|
34
|
+
/** Number of open positions contributing to the sum (`0` ⇒ `upnl` is `0n`). */
|
|
35
|
+
openPositionCount: number;
|
|
36
|
+
/** True while positions or markets are still loading. */
|
|
37
|
+
isLoading: boolean;
|
|
38
|
+
/** Refetch the underlying position + market reads (prices are a live socket). */
|
|
39
|
+
refetch: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The account-level unrealized PnL, computed **inside the SDK** — no oracle
|
|
43
|
+
* round-trip: each open position's uPnL is `openQuantity × (mark − open)`
|
|
44
|
+
* (sign by side, via `calculateQuoteUpnlWei`) against the live mark price of
|
|
45
|
+
* whichever provider serves the resolved solver, and the account total is the
|
|
46
|
+
* sum. Positions come from the **managed (unified) pipeline**, so off-chain
|
|
47
|
+
* optimistic opens count from the moment they exist and hand over seamlessly
|
|
48
|
+
* once they anchor on-chain. Feed `upnl` to `calculateAvailableForOrder` for
|
|
49
|
+
* the spendable balance of a cross-margin account.
|
|
50
|
+
*
|
|
51
|
+
* A position without any price reference, with nothing left open, or whose
|
|
52
|
+
* market has no live tick yet keeps `upnl` at `undefined` until it is priced;
|
|
53
|
+
* an optimistic open is valued at its settled fill price when known, else its
|
|
54
|
+
* requested price.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* const { upnl } = useAccountUpnl({ account: subAccount, live: true });
|
|
59
|
+
* const available =
|
|
60
|
+
* balanceInfo && upnl !== undefined
|
|
61
|
+
* ? calculateAvailableForOrder({ balanceInfo, upnl })
|
|
62
|
+
* : undefined;
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useAccountUpnl(parameters?: UseAccountUpnlParameters): UseAccountUpnlReturnType;
|
|
66
|
+
//# sourceMappingURL=use-account-upnl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-account-upnl.d.ts","sourceRoot":"","sources":["../../src/quotes/use-account-upnl.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2C,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEpH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAMpC;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC/D,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yGAAyG;IACzG,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,UAAU,GAAE,wBAA6B,GAAG,wBAAwB,CAsFlG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMarkets as e } from "../markets/use-markets.js";
|
|
3
|
+
import { usePrices as t } from "../price-service/use-prices.js";
|
|
4
|
+
import { useManagedQuotes as n } from "./use-managed-quotes.js";
|
|
5
|
+
import { calculateQuoteUpnlWei as r, isActivePosition as i } from "@symmio/trading-core";
|
|
6
|
+
import { useCallback as a, useMemo as o } from "react";
|
|
7
|
+
import { parseUnits as s } from "viem";
|
|
8
|
+
//#region src/quotes/use-account-upnl.ts
|
|
9
|
+
function c(c = {}) {
|
|
10
|
+
let { account: l, chainId: u, solverId: d, enabled: f = !0, live: p = !1, ...m } = c, h = n({
|
|
11
|
+
partyA: l,
|
|
12
|
+
chainId: u,
|
|
13
|
+
live: p,
|
|
14
|
+
enabled: f && !!l
|
|
15
|
+
}), g = e({
|
|
16
|
+
...m,
|
|
17
|
+
chainId: u,
|
|
18
|
+
solverId: d
|
|
19
|
+
}), { refetch: _ } = h, { refetch: v } = g, y = a(async () => {
|
|
20
|
+
_(), await v();
|
|
21
|
+
}, [_, v]), b = o(() => h.quotes.filter((e) => i(e) && e.openQuantity > 0n && (e.openedPrice ?? e.requestedOpenPrice) > 0n), [h.quotes]), x = o(() => {
|
|
22
|
+
let e = /* @__PURE__ */ new Map();
|
|
23
|
+
for (let t of g.data ?? []) t.symbolId !== void 0 && t.name && e.set(String(t.symbolId), t.name);
|
|
24
|
+
return e;
|
|
25
|
+
}, [g.data]), S = o(() => {
|
|
26
|
+
let e = /* @__PURE__ */ new Set();
|
|
27
|
+
for (let t of b) {
|
|
28
|
+
let n = x.get(String(t.symbolId));
|
|
29
|
+
n && e.add(n);
|
|
30
|
+
}
|
|
31
|
+
return [...e];
|
|
32
|
+
}, [b, x]), { ticks: C } = t({
|
|
33
|
+
...m,
|
|
34
|
+
chainId: u,
|
|
35
|
+
solverId: d,
|
|
36
|
+
names: S,
|
|
37
|
+
enabled: f && S.length > 0
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
upnl: o(() => {
|
|
41
|
+
if (b.length === 0) return 0n;
|
|
42
|
+
let e = 0n;
|
|
43
|
+
for (let t of b) {
|
|
44
|
+
let n = x.get(String(t.symbolId)), i = n ? C[n]?.markPrice : void 0;
|
|
45
|
+
if (i === void 0) return;
|
|
46
|
+
let a;
|
|
47
|
+
try {
|
|
48
|
+
a = s(i, 18);
|
|
49
|
+
} catch {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
e += r({
|
|
53
|
+
positionType: t.positionType,
|
|
54
|
+
openQuantity: t.openQuantity,
|
|
55
|
+
openedPrice: t.openedPrice ?? t.requestedOpenPrice,
|
|
56
|
+
markPrice: a
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return e;
|
|
60
|
+
}, [
|
|
61
|
+
b,
|
|
62
|
+
x,
|
|
63
|
+
C
|
|
64
|
+
]),
|
|
65
|
+
openPositionCount: b.length,
|
|
66
|
+
isLoading: h.isLoading || g.isLoading,
|
|
67
|
+
refetch: y
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { c as useAccountUpnl };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=use-account-upnl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-account-upnl.js","names":[],"sources":["../../src/quotes/use-account-upnl.ts"],"sourcesContent":["\"use client\";\n\nimport { calculateQuoteUpnlWei, isActivePosition, type ConfigParameter, type SolverId } from \"@symmio/trading-core\";\nimport { useCallback, useMemo } from \"react\";\nimport type { Address } from \"viem\";\nimport { parseUnits } from \"viem\";\nimport { useMarkets } from \"../markets/use-markets\";\nimport { usePrices } from \"../price-service/use-prices\";\nimport { useManagedQuotes } from \"./use-managed-quotes\";\n\n/**\n * Parameters for {@link useAccountUpnl}.\n */\nexport interface UseAccountUpnlParameters extends ConfigParameter {\n /** The partyA whose open positions are summed. Disabled while undefined. */\n account?: Address;\n /** Target chain id. Defaults to the SDK's active chain. */\n chainId?: number;\n /** Solver whose markets + price provider value the positions. Defaults to the chain's default solver. */\n solverId?: SolverId;\n /** Compute only when `true`. Default `true`. */\n enabled?: boolean;\n /**\n * Subscribe to the account's live notifications so the position set tracks\n * opens/closes (and off-chain quotes anchoring on-chain) without a manual\n * refresh. Mark prices are always live via the price socket.\n * @default false\n */\n live?: boolean;\n}\n\n/**\n * Value returned by {@link useAccountUpnl}.\n */\nexport interface UseAccountUpnlReturnType {\n /**\n * Σ unrealized PnL across the account's open positions — on-chain **and**\n * off-chain (optimistic instant-opens) — signed wei. `undefined` until every\n * priced position has a live mark price, so a half-priced sum is never\n * mistaken for the real figure.\n */\n upnl: bigint | undefined;\n /** Number of open positions contributing to the sum (`0` ⇒ `upnl` is `0n`). */\n openPositionCount: number;\n /** True while positions or markets are still loading. */\n isLoading: boolean;\n /** Refetch the underlying position + market reads (prices are a live socket). */\n refetch: () => Promise<void>;\n}\n\n/**\n * The account-level unrealized PnL, computed **inside the SDK** — no oracle\n * round-trip: each open position's uPnL is `openQuantity × (mark − open)`\n * (sign by side, via `calculateQuoteUpnlWei`) against the live mark price of\n * whichever provider serves the resolved solver, and the account total is the\n * sum. Positions come from the **managed (unified) pipeline**, so off-chain\n * optimistic opens count from the moment they exist and hand over seamlessly\n * once they anchor on-chain. Feed `upnl` to `calculateAvailableForOrder` for\n * the spendable balance of a cross-margin account.\n *\n * A position without any price reference, with nothing left open, or whose\n * market has no live tick yet keeps `upnl` at `undefined` until it is priced;\n * an optimistic open is valued at its settled fill price when known, else its\n * requested price.\n *\n * @example\n * ```tsx\n * const { upnl } = useAccountUpnl({ account: subAccount, live: true });\n * const available =\n * balanceInfo && upnl !== undefined\n * ? calculateAvailableForOrder({ balanceInfo, upnl })\n * : undefined;\n * ```\n */\nexport function useAccountUpnl(parameters: UseAccountUpnlParameters = {}): UseAccountUpnlReturnType {\n const { account, chainId, solverId, enabled = true, live = false, ...rest } = parameters;\n\n // The unified pipeline: on-chain reads + off-chain instant-ops + live\n // notifications reconciled into one lifecycle-tagged list. It owns the\n // \"off-chain quote became on-chain\" transition this hook relies on.\n const managed = useManagedQuotes({\n partyA: account,\n chainId,\n live,\n enabled: enabled && Boolean(account),\n });\n const marketsQuery = useMarkets({ ...rest, chainId, solverId });\n\n const { refetch: refetchManaged } = managed;\n const { refetch: refetchMarkets } = marketsQuery;\n const refetch = useCallback(async () => {\n refetchManaged();\n await refetchMarkets();\n }, [refetchManaged, refetchMarkets]);\n\n /** Open positions (both origins) that can carry uPnL: open size + a price reference. */\n const openPositions = useMemo(\n () =>\n managed.quotes.filter(\n (quote) =>\n isActivePosition(quote) && quote.openQuantity > 0n && (quote.openedPrice ?? quote.requestedOpenPrice) > 0n,\n ),\n [managed.quotes],\n );\n\n const nameBySymbolId = useMemo(() => {\n const map = new Map<string, string>();\n for (const market of marketsQuery.data ?? []) {\n if (market.symbolId !== undefined && market.name) map.set(String(market.symbolId), market.name);\n }\n return map;\n }, [marketsQuery.data]);\n\n const names = useMemo(() => {\n const unique = new Set<string>();\n for (const position of openPositions) {\n const name = nameBySymbolId.get(String(position.symbolId));\n if (name) unique.add(name);\n }\n return [...unique];\n }, [openPositions, nameBySymbolId]);\n\n const { ticks } = usePrices({\n ...rest,\n chainId,\n solverId,\n names,\n enabled: enabled && names.length > 0,\n });\n\n const upnl = useMemo<bigint | undefined>(() => {\n if (openPositions.length === 0) return 0n;\n let total = 0n;\n for (const position of openPositions) {\n const name = nameBySymbolId.get(String(position.symbolId));\n const markPriceDecimal = name ? ticks[name]?.markPrice : undefined;\n if (markPriceDecimal === undefined) return undefined;\n let markPrice: bigint;\n try {\n markPrice = parseUnits(markPriceDecimal, 18);\n } catch {\n return undefined;\n }\n total += calculateQuoteUpnlWei({\n positionType: position.positionType,\n openQuantity: position.openQuantity,\n // Settled fill price when known; an unfilled optimistic open is valued at its requested price.\n openedPrice: position.openedPrice ?? position.requestedOpenPrice,\n markPrice,\n });\n }\n return total;\n }, [openPositions, nameBySymbolId, ticks]);\n\n return {\n upnl,\n openPositionCount: openPositions.length,\n isLoading: managed.isLoading || marketsQuery.isLoading,\n refetch,\n };\n}\n"],"mappings":";;;;;;;;AA0EA,SAAgB,EAAe,IAAuC,CAAC,GAA6B;CAClG,IAAM,EAAE,YAAS,YAAS,aAAU,aAAU,IAAM,UAAO,IAAO,GAAG,MAAS,GAKxE,IAAU,EAAiB;EAC/B,QAAQ;EACR;EACA;EACA,SAAS,KAAW,EAAQ;CAC9B,CAAC,GACK,IAAe,EAAW;EAAE,GAAG;EAAM;EAAS;CAAS,CAAC,GAExD,EAAE,SAAS,MAAmB,GAC9B,EAAE,SAAS,MAAmB,GAC9B,IAAU,EAAY,YAAY;EAEtC,AADA,EAAe,GACf,MAAM,EAAe;CACvB,GAAG,CAAC,GAAgB,CAAc,CAAC,GAG7B,IAAgB,QAElB,EAAQ,OAAO,QACZ,MACC,EAAiB,CAAK,KAAK,EAAM,eAAe,OAAO,EAAM,eAAe,EAAM,sBAAsB,EAC5G,GACF,CAAC,EAAQ,MAAM,CACjB,GAEM,IAAiB,QAAc;EACnC,IAAM,oBAAM,IAAI,IAAoB;EACpC,KAAK,IAAM,KAAU,EAAa,QAAQ,CAAC,GACzC,AAAI,EAAO,aAAa,KAAA,KAAa,EAAO,QAAM,EAAI,IAAI,OAAO,EAAO,QAAQ,GAAG,EAAO,IAAI;EAEhG,OAAO;CACT,GAAG,CAAC,EAAa,IAAI,CAAC,GAEhB,IAAQ,QAAc;EAC1B,IAAM,oBAAS,IAAI,IAAY;EAC/B,KAAK,IAAM,KAAY,GAAe;GACpC,IAAM,IAAO,EAAe,IAAI,OAAO,EAAS,QAAQ,CAAC;GACzD,AAAI,KAAM,EAAO,IAAI,CAAI;EAC3B;EACA,OAAO,CAAC,GAAG,CAAM;CACnB,GAAG,CAAC,GAAe,CAAc,CAAC,GAE5B,EAAE,aAAU,EAAU;EAC1B,GAAG;EACH;EACA;EACA;EACA,SAAS,KAAW,EAAM,SAAS;CACrC,CAAC;CA0BD,OAAO;EACL,MAzBW,QAAkC;GAC7C,IAAI,EAAc,WAAW,GAAG,OAAO;GACvC,IAAI,IAAQ;GACZ,KAAK,IAAM,KAAY,GAAe;IACpC,IAAM,IAAO,EAAe,IAAI,OAAO,EAAS,QAAQ,CAAC,GACnD,IAAmB,IAAO,EAAM,IAAO,YAAY,KAAA;IACzD,IAAI,MAAqB,KAAA,GAAW;IACpC,IAAI;IACJ,IAAI;KACF,IAAY,EAAW,GAAkB,EAAE;IAC7C,QAAQ;KACN;IACF;IACA,KAAS,EAAsB;KAC7B,cAAc,EAAS;KACvB,cAAc,EAAS;KAEvB,aAAa,EAAS,eAAe,EAAS;KAC9C;IACF,CAAC;GACH;GACA,OAAO;EACT,GAAG;GAAC;GAAe;GAAgB;EAAK,CAGtC;EACA,mBAAmB,EAAc;EACjC,WAAW,EAAQ,aAAa,EAAa;EAC7C;CACF;AACF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ConfigParameter, PlanGroupCloseFailure, QuoteGroup } from '@symmio/trading-core';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Lifecycle of one child close inside a group close:
|
|
6
|
+
* `queued` → `closing` (submitted in the bulk request, awaiting its close-fill
|
|
7
|
+
* notification) → `closed` (fill notification received), or `failed` (the bulk
|
|
8
|
+
* submit or the close itself errored).
|
|
9
|
+
*/
|
|
10
|
+
export type CloseQuoteGroupStepStatus = "queued" | "closing" | "closed" | "failed";
|
|
11
|
+
/** Live state of one child close inside a group close run. */
|
|
12
|
+
export interface CloseQuoteGroupStep {
|
|
13
|
+
/** Child identity (`UnifiedQuote.key`). */
|
|
14
|
+
key: string;
|
|
15
|
+
/** On-chain quote id of the child. */
|
|
16
|
+
quoteId: bigint;
|
|
17
|
+
/** Planned close amount, wei. */
|
|
18
|
+
closeQuantity: bigint;
|
|
19
|
+
/** `full` when the child closes entirely, `partial` otherwise. */
|
|
20
|
+
kind: "full" | "partial";
|
|
21
|
+
/** Current lifecycle stage of this child close. */
|
|
22
|
+
status: CloseQuoteGroupStepStatus;
|
|
23
|
+
/** Normalized error, when `status` is `failed`. */
|
|
24
|
+
error?: SymmioRequestError;
|
|
25
|
+
}
|
|
26
|
+
/** Overall lifecycle of a group close run. */
|
|
27
|
+
export type CloseQuoteGroupStatus = "idle" | "closing" | "success" | "failed";
|
|
28
|
+
/** Inputs for one {@link UseCloseQuoteGroupReturnType.close} run. */
|
|
29
|
+
export interface CloseQuoteGroupParameters {
|
|
30
|
+
/** The group whose children are being closed. */
|
|
31
|
+
group: QuoteGroup;
|
|
32
|
+
/** Exact total quantity to close across the group, wei. */
|
|
33
|
+
targetQuantity: bigint;
|
|
34
|
+
/**
|
|
35
|
+
* The symbol's `minAcceptableQuoteValue` (wei) — the dust floor a partially
|
|
36
|
+
* closed child must keep. Read it from the market info of the group's symbol.
|
|
37
|
+
*/
|
|
38
|
+
minAcceptableQuoteValue: bigint;
|
|
39
|
+
/** Slippage tolerance percent forwarded to every child close (e.g. `5`). */
|
|
40
|
+
slippage: number;
|
|
41
|
+
/** Pre-fetched mark price (decimal string) forwarded to every child close. */
|
|
42
|
+
markPrice?: string;
|
|
43
|
+
/** Delegated session key to submit the closes from, when delegation is active. */
|
|
44
|
+
from?: Address;
|
|
45
|
+
/**
|
|
46
|
+
* Account whose live notification stream reports the close fills — pass the
|
|
47
|
+
* **sub-account** when closing Virtual Account quotes (the VA frames arrive
|
|
48
|
+
* on its owning sub-account's stream). Defaults to the first child's
|
|
49
|
+
* `vaAddress ?? partyA`.
|
|
50
|
+
*/
|
|
51
|
+
notificationsAccount?: Address;
|
|
52
|
+
/** Chain override; defaults to the connected chain. */
|
|
53
|
+
chainId?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Submission outcome of one {@link UseCloseQuoteGroupReturnType.close} run.
|
|
57
|
+
* Resolves when the bulk request carrying every child close has been
|
|
58
|
+
* **submitted** — settlement is confirmed asynchronously per child (its
|
|
59
|
+
* close-fill notification), tracked via `status` / `steps` /
|
|
60
|
+
* `progressPercent` on the hook.
|
|
61
|
+
*/
|
|
62
|
+
export interface CloseQuoteGroupSummary {
|
|
63
|
+
/** `true` when every planned child close was submitted successfully. */
|
|
64
|
+
ok: boolean;
|
|
65
|
+
/** Σ quantity already confirmed closed at resolve time, wei. */
|
|
66
|
+
closedQuantity: bigint;
|
|
67
|
+
/** Per-child final states. Empty when planning already failed. */
|
|
68
|
+
steps: CloseQuoteGroupStep[];
|
|
69
|
+
/** Present when the plan itself was infeasible — nothing was closed. */
|
|
70
|
+
planFailure?: PlanGroupCloseFailure;
|
|
71
|
+
/** The error that stopped the run, when `ok` is `false` and a close failed. */
|
|
72
|
+
error?: SymmioRequestError;
|
|
73
|
+
}
|
|
74
|
+
/** Return type of {@link useCloseQuoteGroup}. */
|
|
75
|
+
export interface UseCloseQuoteGroupReturnType {
|
|
76
|
+
/** Plan and execute a group close. Resolves with the run's summary (never rejects). */
|
|
77
|
+
close: (parameters: CloseQuoteGroupParameters) => Promise<CloseQuoteGroupSummary>;
|
|
78
|
+
/** Clear the run state back to `idle`. No-op while a run is in flight. */
|
|
79
|
+
reset: () => void;
|
|
80
|
+
/** Overall run lifecycle. */
|
|
81
|
+
status: CloseQuoteGroupStatus;
|
|
82
|
+
/** `true` while a run is in flight. */
|
|
83
|
+
isClosing: boolean;
|
|
84
|
+
/** Quantity-weighted completion, `0`–`100` (2-decimal resolution). */
|
|
85
|
+
progressPercent: number;
|
|
86
|
+
/** Σ quantity closed so far in the current/last run, wei. */
|
|
87
|
+
closedQuantity: bigint;
|
|
88
|
+
/** The run's target, wei (`0` while idle). */
|
|
89
|
+
targetQuantity: bigint;
|
|
90
|
+
/** Per-child close states of the current/last run, in execution order. */
|
|
91
|
+
steps: CloseQuoteGroupStep[];
|
|
92
|
+
/** Planning failure of the last run, when the plan was infeasible. */
|
|
93
|
+
planFailure?: PlanGroupCloseFailure;
|
|
94
|
+
/** The error that stopped the last run, when a child close failed. */
|
|
95
|
+
error?: SymmioRequestError;
|
|
96
|
+
}
|
|
97
|
+
/** Parameters for {@link useCloseQuoteGroup}. */
|
|
98
|
+
export type UseCloseQuoteGroupParameters = ConfigParameter;
|
|
99
|
+
/**
|
|
100
|
+
* Close an exact quantity across a grouped position, child by child.
|
|
101
|
+
*
|
|
102
|
+
* The run first plans the allocation with `planGroupClose` (largest child
|
|
103
|
+
* first; every partially closed child keeps at least the symbol's
|
|
104
|
+
* `minAcceptableQuoteValue`; the plan sums to the target exactly or fails
|
|
105
|
+
* without closing anything). It then submits **every allocation in one bulk
|
|
106
|
+
* request** (`instantCloseBulkAuto` — n operations, one endpoint call). A
|
|
107
|
+
* submitted child stays `closing` until its close settles: the hook watches
|
|
108
|
+
* the account's live notifications and flips the child to `closed` — advancing
|
|
109
|
+
* `closedQuantity` / `progressPercent` — when its **close fill** frame arrives
|
|
110
|
+
* (`lastSeenAction: FillMarketOrderInstantClose` / `FillLimitOrderClose` with
|
|
111
|
+
* `success`); `status` becomes `success` once every child confirms, and a
|
|
112
|
+
* `failed` frame fails that step and the run. A rejected bulk submit fails the
|
|
113
|
+
* whole run at once.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* const { close, status, progressPercent, steps } = useCloseQuoteGroup();
|
|
118
|
+
* const summary = await close({
|
|
119
|
+
* group, targetQuantity: parseUnits("2.8", 18),
|
|
120
|
+
* minAcceptableQuoteValue: market.minAcceptableQuoteValue, slippage: 5,
|
|
121
|
+
* });
|
|
122
|
+
* if (!summary.ok) showError(summary.planFailure ?? summary.error);
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function useCloseQuoteGroup(parameters?: UseCloseQuoteGroupParameters): UseCloseQuoteGroupReturnType;
|
|
126
|
+
//# sourceMappingURL=use-close-quote-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-close-quote-group.d.ts","sourceRoot":"","sources":["../../src/quotes/use-close-quote-group.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,eAAe,EAEpB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAgBzE;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnF,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,mDAAmD;IACnD,MAAM,EAAE,yBAAyB,CAAC;IAClC,mDAAmD;IACnD,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9E,qEAAqE;AACrE,MAAM,WAAW,yBAAyB;IACxC,iDAAiD;IACjD,KAAK,EAAE,UAAU,CAAC;IAClB,2DAA2D;IAC3D,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,EAAE,EAAE,OAAO,CAAC;IACZ,gEAAgE;IAChE,cAAc,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,wEAAwE;IACxE,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,iDAAiD;AACjD,MAAM,WAAW,4BAA4B;IAC3C,uFAAuF;IACvF,KAAK,EAAE,CAAC,UAAU,EAAE,yBAAyB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAClF,0EAA0E;IAC1E,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,6BAA6B;IAC7B,MAAM,EAAE,qBAAqB,CAAC;IAC9B,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,eAAe,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,sEAAsE;IACtE,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,sEAAsE;IACtE,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAa3D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CA2L9G"}
|
|
@@ -0,0 +1,172 @@
|
|
|
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 { useNotifications as r } from "../websocket/use-notifications.js";
|
|
6
|
+
import { predicateMatch as i } from "../utils/predicate-match.js";
|
|
7
|
+
import { NotificationType as a, getInstantClosesQueryKey as o, instantCloseBulkAutoMutationOptions as s, planGroupClose as c, toGroupCloseCandidates as l } from "@symmio/trading-core";
|
|
8
|
+
import { useCallback as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
9
|
+
import { formatUnits as m } from "viem";
|
|
10
|
+
import { useQueryClient as h } from "@tanstack/react-query";
|
|
11
|
+
//#region src/quotes/use-close-quote-group.ts
|
|
12
|
+
var g = 18, _ = new Set(["FillMarketOrderInstantClose", "FillLimitOrderClose"]), v = {
|
|
13
|
+
status: "idle",
|
|
14
|
+
steps: [],
|
|
15
|
+
closedQuantity: 0n,
|
|
16
|
+
targetQuantity: 0n
|
|
17
|
+
};
|
|
18
|
+
function y(y = {}) {
|
|
19
|
+
let b = t(y), x = e(), S = h(), [C, w] = p(v), T = f(v), E = f(!1), [D, O] = p(), k = f(void 0), A = u((e) => {
|
|
20
|
+
T.current = e, w(e);
|
|
21
|
+
}, []), j = u((e) => {
|
|
22
|
+
let t = T.current, r = t.steps.findIndex((t) => t.status === "closing" && String(t.quoteId) === e.quoteId);
|
|
23
|
+
if (r < 0) return;
|
|
24
|
+
let i = e.type === a.SUCCESS && e.lastSeenAction !== null && _.has(e.lastSeenAction), o = e.type === a.FAILED;
|
|
25
|
+
if (!i && !o) return;
|
|
26
|
+
let s = [...t.steps], c = t.closedQuantity;
|
|
27
|
+
if (i) {
|
|
28
|
+
let e = {
|
|
29
|
+
...s[r],
|
|
30
|
+
status: "closed"
|
|
31
|
+
};
|
|
32
|
+
c += e.closeQuantity, s[r] = e;
|
|
33
|
+
let n = s.every((e) => e.status === "closed"), i = t.status === "closing" && n ? "success" : t.status;
|
|
34
|
+
A({
|
|
35
|
+
...t,
|
|
36
|
+
steps: s,
|
|
37
|
+
closedQuantity: c,
|
|
38
|
+
status: i
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let l = n(Error(e.failureMessage ?? "Close failed on the solver."));
|
|
43
|
+
s[r] = {
|
|
44
|
+
...s[r],
|
|
45
|
+
status: "failed",
|
|
46
|
+
error: l
|
|
47
|
+
}, A({
|
|
48
|
+
...t,
|
|
49
|
+
steps: s,
|
|
50
|
+
status: "failed",
|
|
51
|
+
error: l
|
|
52
|
+
});
|
|
53
|
+
}, [A]);
|
|
54
|
+
r({
|
|
55
|
+
account: D,
|
|
56
|
+
chainId: k.current,
|
|
57
|
+
config: y.config,
|
|
58
|
+
enabled: !!D && C.steps.some((e) => e.status === "closing"),
|
|
59
|
+
onNotification: j
|
|
60
|
+
});
|
|
61
|
+
let M = u(async (e) => {
|
|
62
|
+
if (E.current || T.current.steps.some((e) => e.status === "closing")) return {
|
|
63
|
+
ok: !1,
|
|
64
|
+
closedQuantity: 0n,
|
|
65
|
+
steps: [],
|
|
66
|
+
error: n(/* @__PURE__ */ Error("A group close is already in flight."))
|
|
67
|
+
};
|
|
68
|
+
let { group: t, targetQuantity: r, minAcceptableQuoteValue: a, slippage: u, markPrice: d, from: f, notificationsAccount: p } = e, h = e.chainId ?? x, _ = c(l(t.quotes, a), r);
|
|
69
|
+
if (!_.feasible) return A({
|
|
70
|
+
status: "failed",
|
|
71
|
+
steps: [],
|
|
72
|
+
closedQuantity: 0n,
|
|
73
|
+
targetQuantity: r,
|
|
74
|
+
planFailure: _
|
|
75
|
+
}), {
|
|
76
|
+
ok: !1,
|
|
77
|
+
closedQuantity: 0n,
|
|
78
|
+
steps: [],
|
|
79
|
+
planFailure: _
|
|
80
|
+
};
|
|
81
|
+
let v = new Map(t.quotes.map((e) => [e.key, e])), y = _.allocations.map((e) => ({
|
|
82
|
+
key: e.key,
|
|
83
|
+
quoteId: v.get(e.key).quoteId,
|
|
84
|
+
closeQuantity: e.closeQuantity,
|
|
85
|
+
kind: e.kind,
|
|
86
|
+
status: "queued"
|
|
87
|
+
}));
|
|
88
|
+
E.current = !0;
|
|
89
|
+
let C = v.get(y[0].key);
|
|
90
|
+
k.current = h, O(p ?? C.vaAddress ?? C.partyA), A({
|
|
91
|
+
status: "closing",
|
|
92
|
+
steps: y.map((e) => ({
|
|
93
|
+
...e,
|
|
94
|
+
status: "closing"
|
|
95
|
+
})),
|
|
96
|
+
closedQuantity: 0n,
|
|
97
|
+
targetQuantity: r
|
|
98
|
+
});
|
|
99
|
+
let w = s(b);
|
|
100
|
+
try {
|
|
101
|
+
await w.mutationFn({
|
|
102
|
+
orders: y.map((e) => {
|
|
103
|
+
let t = v.get(e.key);
|
|
104
|
+
return {
|
|
105
|
+
partyA: t.vaAddress ?? t.partyA,
|
|
106
|
+
market: { id: Number(t.symbolId) },
|
|
107
|
+
positionType: t.positionType,
|
|
108
|
+
quoteId: e.quoteId,
|
|
109
|
+
quantityToClose: m(e.closeQuantity, g),
|
|
110
|
+
slippage: u,
|
|
111
|
+
markPrice: d
|
|
112
|
+
};
|
|
113
|
+
}),
|
|
114
|
+
from: f,
|
|
115
|
+
chainId: h
|
|
116
|
+
});
|
|
117
|
+
} catch (e) {
|
|
118
|
+
let t = n(e), r = T.current;
|
|
119
|
+
return A({
|
|
120
|
+
...r,
|
|
121
|
+
status: "failed",
|
|
122
|
+
steps: r.steps.map((e) => e.status === "closing" ? {
|
|
123
|
+
...e,
|
|
124
|
+
status: "failed",
|
|
125
|
+
error: t
|
|
126
|
+
} : e),
|
|
127
|
+
error: t
|
|
128
|
+
}), {
|
|
129
|
+
ok: !1,
|
|
130
|
+
closedQuantity: T.current.closedQuantity,
|
|
131
|
+
steps: [...T.current.steps],
|
|
132
|
+
error: t
|
|
133
|
+
};
|
|
134
|
+
} finally {
|
|
135
|
+
E.current = !1;
|
|
136
|
+
}
|
|
137
|
+
let D = b.getChainConfigKey(h);
|
|
138
|
+
S.invalidateQueries({ predicate: i(o, { configKey: D }) });
|
|
139
|
+
let j = T.current;
|
|
140
|
+
return j.status === "closing" && j.steps.every((e) => e.status === "closed") && A({
|
|
141
|
+
...j,
|
|
142
|
+
status: "success"
|
|
143
|
+
}), {
|
|
144
|
+
ok: !0,
|
|
145
|
+
closedQuantity: T.current.closedQuantity,
|
|
146
|
+
steps: [...T.current.steps]
|
|
147
|
+
};
|
|
148
|
+
}, [
|
|
149
|
+
A,
|
|
150
|
+
b,
|
|
151
|
+
x,
|
|
152
|
+
S
|
|
153
|
+
]), N = u(() => {
|
|
154
|
+
E.current || (k.current = void 0, O(void 0), A(v));
|
|
155
|
+
}, [A]), P = d(() => C.targetQuantity <= 0n ? 0 : Number(C.closedQuantity * 10000n / C.targetQuantity) / 100, [C.closedQuantity, C.targetQuantity]);
|
|
156
|
+
return {
|
|
157
|
+
close: M,
|
|
158
|
+
reset: N,
|
|
159
|
+
status: C.status,
|
|
160
|
+
isClosing: C.status === "closing",
|
|
161
|
+
progressPercent: P,
|
|
162
|
+
closedQuantity: C.closedQuantity,
|
|
163
|
+
targetQuantity: C.targetQuantity,
|
|
164
|
+
steps: C.steps,
|
|
165
|
+
planFailure: C.planFailure,
|
|
166
|
+
error: C.error
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { y as useCloseQuoteGroup };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=use-close-quote-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-close-quote-group.js","names":[],"sources":["../../src/quotes/use-close-quote-group.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantClosesQueryKey,\n instantCloseBulkAutoMutationOptions,\n NotificationType,\n planGroupClose,\n toGroupCloseCandidates,\n type ConfigParameter,\n type Notification,\n type PlanGroupCloseFailure,\n type QuoteGroup,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { Address } from \"viem\";\nimport { formatUnits } 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 { predicateMatch } from \"../utils\";\nimport { useNotifications } from \"../websocket/use-notifications\";\n\n/** Decimal places of an 18-decimal-wei fixed-point value. */\nconst WEI_DECIMALS = 18;\n\n/**\n * Solver `lastSeenAction` values that report a close **fill** — the moment a\n * close is actually done (mirrors the core notification classifier's fill set;\n * the request-stage actions are deliberately not here).\n */\nconst CLOSE_FILL_ACTIONS = new Set([\"FillMarketOrderInstantClose\", \"FillLimitOrderClose\"]);\n\n/**\n * Lifecycle of one child close inside a group close:\n * `queued` → `closing` (submitted in the bulk request, awaiting its close-fill\n * notification) → `closed` (fill notification received), or `failed` (the bulk\n * submit or the close itself errored).\n */\nexport type CloseQuoteGroupStepStatus = \"queued\" | \"closing\" | \"closed\" | \"failed\";\n\n/** Live state of one child close inside a group close run. */\nexport interface CloseQuoteGroupStep {\n /** Child identity (`UnifiedQuote.key`). */\n key: string;\n /** On-chain quote id of the child. */\n quoteId: bigint;\n /** Planned close amount, wei. */\n closeQuantity: bigint;\n /** `full` when the child closes entirely, `partial` otherwise. */\n kind: \"full\" | \"partial\";\n /** Current lifecycle stage of this child close. */\n status: CloseQuoteGroupStepStatus;\n /** Normalized error, when `status` is `failed`. */\n error?: SymmioRequestError;\n}\n\n/** Overall lifecycle of a group close run. */\nexport type CloseQuoteGroupStatus = \"idle\" | \"closing\" | \"success\" | \"failed\";\n\n/** Inputs for one {@link UseCloseQuoteGroupReturnType.close} run. */\nexport interface CloseQuoteGroupParameters {\n /** The group whose children are being closed. */\n group: QuoteGroup;\n /** Exact total quantity to close across the group, wei. */\n targetQuantity: bigint;\n /**\n * The symbol's `minAcceptableQuoteValue` (wei) — the dust floor a partially\n * closed child must keep. Read it from the market info of the group's symbol.\n */\n minAcceptableQuoteValue: bigint;\n /** Slippage tolerance percent forwarded to every child close (e.g. `5`). */\n slippage: number;\n /** Pre-fetched mark price (decimal string) forwarded to every child close. */\n markPrice?: string;\n /** Delegated session key to submit the closes from, when delegation is active. */\n from?: Address;\n /**\n * Account whose live notification stream reports the close fills — pass the\n * **sub-account** when closing Virtual Account quotes (the VA frames arrive\n * on its owning sub-account's stream). Defaults to the first child's\n * `vaAddress ?? partyA`.\n */\n notificationsAccount?: Address;\n /** Chain override; defaults to the connected chain. */\n chainId?: number;\n}\n\n/**\n * Submission outcome of one {@link UseCloseQuoteGroupReturnType.close} run.\n * Resolves when the bulk request carrying every child close has been\n * **submitted** — settlement is confirmed asynchronously per child (its\n * close-fill notification), tracked via `status` / `steps` /\n * `progressPercent` on the hook.\n */\nexport interface CloseQuoteGroupSummary {\n /** `true` when every planned child close was submitted successfully. */\n ok: boolean;\n /** Σ quantity already confirmed closed at resolve time, wei. */\n closedQuantity: bigint;\n /** Per-child final states. Empty when planning already failed. */\n steps: CloseQuoteGroupStep[];\n /** Present when the plan itself was infeasible — nothing was closed. */\n planFailure?: PlanGroupCloseFailure;\n /** The error that stopped the run, when `ok` is `false` and a close failed. */\n error?: SymmioRequestError;\n}\n\n/** Return type of {@link useCloseQuoteGroup}. */\nexport interface UseCloseQuoteGroupReturnType {\n /** Plan and execute a group close. Resolves with the run's summary (never rejects). */\n close: (parameters: CloseQuoteGroupParameters) => Promise<CloseQuoteGroupSummary>;\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: CloseQuoteGroupStatus;\n /** `true` while a run is in flight. */\n isClosing: boolean;\n /** Quantity-weighted completion, `0`–`100` (2-decimal resolution). */\n progressPercent: number;\n /** Σ quantity closed so far in the current/last run, wei. */\n closedQuantity: bigint;\n /** The run's target, wei (`0` while idle). */\n targetQuantity: bigint;\n /** Per-child close states of the current/last run, in execution order. */\n steps: CloseQuoteGroupStep[];\n /** Planning failure of the last run, when the plan was infeasible. */\n planFailure?: PlanGroupCloseFailure;\n /** The error that stopped the last run, when a child close failed. */\n error?: SymmioRequestError;\n}\n\n/** Parameters for {@link useCloseQuoteGroup}. */\nexport type UseCloseQuoteGroupParameters = ConfigParameter;\n\ninterface RunState {\n status: CloseQuoteGroupStatus;\n steps: CloseQuoteGroupStep[];\n closedQuantity: bigint;\n targetQuantity: bigint;\n planFailure?: PlanGroupCloseFailure;\n error?: SymmioRequestError;\n}\n\nconst IDLE: RunState = { status: \"idle\", steps: [], closedQuantity: 0n, targetQuantity: 0n };\n\n/**\n * Close an exact quantity across a grouped position, child by child.\n *\n * The run first plans the allocation with `planGroupClose` (largest child\n * first; every partially closed child keeps at least the symbol's\n * `minAcceptableQuoteValue`; the plan sums to the target exactly or fails\n * without closing anything). It then submits **every allocation in one bulk\n * request** (`instantCloseBulkAuto` — n operations, one endpoint call). A\n * submitted child stays `closing` until its close settles: the hook watches\n * the account's live notifications and flips the child to `closed` — advancing\n * `closedQuantity` / `progressPercent` — when its **close fill** frame arrives\n * (`lastSeenAction: FillMarketOrderInstantClose` / `FillLimitOrderClose` with\n * `success`); `status` becomes `success` once every child confirms, and a\n * `failed` frame fails that step and the run. A rejected bulk submit fails the\n * whole run at once.\n *\n * @example\n * ```tsx\n * const { close, status, progressPercent, steps } = useCloseQuoteGroup();\n * const summary = await close({\n * group, targetQuantity: parseUnits(\"2.8\", 18),\n * minAcceptableQuoteValue: market.minAcceptableQuoteValue, slippage: 5,\n * });\n * if (!summary.ok) showError(summary.planFailure ?? summary.error);\n * ```\n */\nexport function useCloseQuoteGroup(parameters: UseCloseQuoteGroupParameters = {}): UseCloseQuoteGroupReturnType {\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 (single source). */\n const runRef = useRef<RunState>(IDLE);\n const inFlight = useRef(false);\n /** Account whose notification stream confirms the run's closes. */\n const [watchAccount, setWatchAccount] = 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 /**\n * Settlement tracking: a submitted child is finished when its close **fill**\n * notification arrives — `lastSeenAction` of `FillMarketOrderInstantClose`\n * (or `FillLimitOrderClose`) with a `success` status. That flips the step to\n * `closed` and advances progress; the run finishes (`success`) once every\n * step is closed. A `failed` frame for the quote marks the step (and run)\n * failed instead. Request-stage frames (`InstantRequestToClosePosition`, …)\n * are ignored.\n */\n const onNotification = useCallback(\n (notification: Notification) => {\n const run = runRef.current;\n const index = run.steps.findIndex(\n (step) => step.status === \"closing\" && String(step.quoteId) === notification.quoteId,\n );\n if (index < 0) return;\n\n const isCloseFill =\n notification.type === NotificationType.SUCCESS &&\n notification.lastSeenAction !== null &&\n CLOSE_FILL_ACTIONS.has(notification.lastSeenAction);\n const isFailure = notification.type === NotificationType.FAILED;\n if (!isCloseFill && !isFailure) return;\n\n const steps = [...run.steps];\n let closedQuantity = run.closedQuantity;\n if (isCloseFill) {\n const step = { ...steps[index]!, status: \"closed\" as const };\n closedQuantity += step.closeQuantity;\n steps[index] = step;\n const allClosed = steps.every((entry) => entry.status === \"closed\");\n const status = run.status === \"closing\" && allClosed ? \"success\" : run.status;\n commit({ ...run, steps, closedQuantity, status });\n return;\n }\n const error = normalizeSymmError(new Error(notification.failureMessage ?? \"Close failed on the solver.\"));\n steps[index] = { ...steps[index]!, status: \"failed\", error };\n commit({ ...run, steps, status: \"failed\", error });\n },\n [commit],\n );\n\n useNotifications({\n account: watchAccount,\n chainId: watchChainIdRef.current,\n config: parameters.config,\n // Listen while any submitted child still awaits its settle notifications —\n // even after a later submit failed, the earlier closes keep confirming.\n enabled: Boolean(watchAccount) && state.steps.some((step) => step.status === \"closing\"),\n onNotification,\n });\n\n const close = useCallback(\n async (runParameters: CloseQuoteGroupParameters): Promise<CloseQuoteGroupSummary> => {\n if (inFlight.current || runRef.current.steps.some((step) => step.status === \"closing\")) {\n return {\n ok: false,\n closedQuantity: 0n,\n steps: [],\n error: normalizeSymmError(new Error(\"A group close is already in flight.\")),\n };\n }\n\n const { group, targetQuantity, minAcceptableQuoteValue, slippage, markPrice, from, notificationsAccount } =\n runParameters;\n const chainId = runParameters.chainId ?? connectedChainId;\n\n const candidates = toGroupCloseCandidates(group.quotes, minAcceptableQuoteValue);\n const plan = planGroupClose(candidates, targetQuantity);\n if (!plan.feasible) {\n commit({ status: \"failed\", steps: [], closedQuantity: 0n, targetQuantity, planFailure: plan });\n return { ok: false, closedQuantity: 0n, steps: [], planFailure: plan };\n }\n\n const childByKey = new Map<string, UnifiedQuote>(group.quotes.map((quote) => [quote.key, quote]));\n const steps: CloseQuoteGroupStep[] = plan.allocations.map((allocation) => ({\n key: allocation.key,\n // The planner only emits candidates built from anchored children, so the id is present.\n quoteId: childByKey.get(allocation.key)!.quoteId!,\n closeQuantity: allocation.closeQuantity,\n kind: allocation.kind,\n status: \"queued\",\n }));\n\n inFlight.current = true;\n const firstChild = childByKey.get(steps[0]!.key)!;\n watchChainIdRef.current = chainId;\n setWatchAccount(notificationsAccount ?? firstChild.vaAddress ?? firstChild.partyA);\n\n // Every allocation submits in ONE bulk round-trip, so all steps go `closing` together.\n commit({\n status: \"closing\",\n steps: steps.map((step) => ({ ...step, status: \"closing\" as const })),\n closedQuantity: 0n,\n targetQuantity,\n });\n\n const base = instantCloseBulkAutoMutationOptions(config);\n try {\n await base.mutationFn({\n orders: steps.map((step) => {\n const child = childByKey.get(step.key)!;\n return {\n partyA: child.vaAddress ?? child.partyA,\n market: { id: Number(child.symbolId) },\n positionType: child.positionType,\n quoteId: step.quoteId,\n quantityToClose: formatUnits(step.closeQuantity, WEI_DECIMALS),\n slippage,\n markPrice,\n };\n }),\n from,\n chainId,\n });\n } catch (err) {\n const error = normalizeSymmError(err);\n const run = runRef.current;\n commit({\n ...run,\n status: \"failed\",\n steps: run.steps.map((step) =>\n step.status === \"closing\" ? { ...step, status: \"failed\" as const, error } : step,\n ),\n error,\n });\n return { ok: false, closedQuantity: runRef.current.closedQuantity, steps: [...runRef.current.steps], error };\n } finally {\n inFlight.current = false;\n }\n\n // Surface the fresh closing rows immediately, exactly like the single-close hook.\n const configKey = config.getChainConfigKey(chainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantClosesQueryKey, { configKey }) });\n\n // Submitted. Completion is notification-driven; fast fills may already have\n // finished the run while the request was in flight.\n const run = runRef.current;\n if (run.status === \"closing\" && run.steps.every((step) => step.status === \"closed\")) {\n commit({ ...run, status: \"success\" });\n }\n return { ok: true, closedQuantity: runRef.current.closedQuantity, steps: [...runRef.current.steps] };\n },\n [commit, config, connectedChainId, queryClient],\n );\n\n const reset = useCallback(() => {\n if (inFlight.current) return;\n watchChainIdRef.current = undefined;\n setWatchAccount(undefined);\n commit(IDLE);\n }, [commit]);\n\n const progressPercent = useMemo(() => {\n if (state.targetQuantity <= 0n) return 0;\n return Number((state.closedQuantity * 10_000n) / state.targetQuantity) / 100;\n }, [state.closedQuantity, state.targetQuantity]);\n\n return {\n close,\n reset,\n status: state.status,\n isClosing: state.status === \"closing\",\n progressPercent,\n closedQuantity: state.closedQuantity,\n targetQuantity: state.targetQuantity,\n steps: state.steps,\n planFailure: state.planFailure,\n error: state.error,\n };\n}\n"],"mappings":";;;;;;;;;;;AA0BA,IAAM,IAAe,IAOf,IAAqB,IAAI,IAAI,CAAC,+BAA+B,qBAAqB,CAAC,GAiHnF,IAAiB;CAAE,QAAQ;CAAQ,OAAO,CAAC;CAAG,gBAAgB;CAAI,gBAAgB;AAAG;AA4B3F,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,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,CAAC,GAAc,KAAmB,EAAkB,GACpD,IAAkB,EAA2B,KAAA,CAAS,GAEtD,IAAS,GAAa,MAAmB;EAE7C,AADA,EAAO,UAAU,GACjB,EAAS,CAAI;CACf,GAAG,CAAC,CAAC,GAWC,IAAiB,GACpB,MAA+B;EAC9B,IAAM,IAAM,EAAO,SACb,IAAQ,EAAI,MAAM,WACrB,MAAS,EAAK,WAAW,aAAa,OAAO,EAAK,OAAO,MAAM,EAAa,OAC/E;EACA,IAAI,IAAQ,GAAG;EAEf,IAAM,IACJ,EAAa,SAAS,EAAiB,WACvC,EAAa,mBAAmB,QAChC,EAAmB,IAAI,EAAa,cAAc,GAC9C,IAAY,EAAa,SAAS,EAAiB;EACzD,IAAI,CAAC,KAAe,CAAC,GAAW;EAEhC,IAAM,IAAQ,CAAC,GAAG,EAAI,KAAK,GACvB,IAAiB,EAAI;EACzB,IAAI,GAAa;GACf,IAAM,IAAO;IAAE,GAAG,EAAM;IAAS,QAAQ;GAAkB;GAE3D,AADA,KAAkB,EAAK,eACvB,EAAM,KAAS;GACf,IAAM,IAAY,EAAM,OAAO,MAAU,EAAM,WAAW,QAAQ,GAC5D,IAAS,EAAI,WAAW,aAAa,IAAY,YAAY,EAAI;GACvE,EAAO;IAAE,GAAG;IAAK;IAAO;IAAgB;GAAO,CAAC;GAChD;EACF;EACA,IAAM,IAAQ,EAAuB,MAAM,EAAa,kBAAkB,6BAA6B,CAAC;EAExG,AADA,EAAM,KAAS;GAAE,GAAG,EAAM;GAAS,QAAQ;GAAU;EAAM,GAC3D,EAAO;GAAE,GAAG;GAAK;GAAO,QAAQ;GAAU;EAAM,CAAC;CACnD,GACA,CAAC,CAAM,CACT;CAEA,EAAiB;EACf,SAAS;EACT,SAAS,EAAgB;EACzB,QAAQ,EAAW;EAGnB,SAAS,EAAQ,KAAiB,EAAM,MAAM,MAAM,MAAS,EAAK,WAAW,SAAS;EACtF;CACF,CAAC;CAED,IAAM,IAAQ,EACZ,OAAO,MAA8E;EACnF,IAAI,EAAS,WAAW,EAAO,QAAQ,MAAM,MAAM,MAAS,EAAK,WAAW,SAAS,GACnF,OAAO;GACL,IAAI;GACJ,gBAAgB;GAChB,OAAO,CAAC;GACR,OAAO,EAAmB,gBAAI,MAAM,qCAAqC,CAAC;EAC5E;EAGF,IAAM,EAAE,UAAO,mBAAgB,4BAAyB,aAAU,cAAW,SAAM,4BACjF,GACI,IAAU,EAAc,WAAW,GAGnC,IAAO,EADM,EAAuB,EAAM,QAAQ,CAC5B,GAAY,CAAc;EACtD,IAAI,CAAC,EAAK,UAER,OADA,EAAO;GAAE,QAAQ;GAAU,OAAO,CAAC;GAAG,gBAAgB;GAAI;GAAgB,aAAa;EAAK,CAAC,GACtF;GAAE,IAAI;GAAO,gBAAgB;GAAI,OAAO,CAAC;GAAG,aAAa;EAAK;EAGvE,IAAM,IAAa,IAAI,IAA0B,EAAM,OAAO,KAAK,MAAU,CAAC,EAAM,KAAK,CAAK,CAAC,CAAC,GAC1F,IAA+B,EAAK,YAAY,KAAK,OAAgB;GACzE,KAAK,EAAW;GAEhB,SAAS,EAAW,IAAI,EAAW,GAAG,EAAG;GACzC,eAAe,EAAW;GAC1B,MAAM,EAAW;GACjB,QAAQ;EACV,EAAE;EAEF,EAAS,UAAU;EACnB,IAAM,IAAa,EAAW,IAAI,EAAM,GAAI,GAAG;EAK/C,AAJA,EAAgB,UAAU,GAC1B,EAAgB,KAAwB,EAAW,aAAa,EAAW,MAAM,GAGjF,EAAO;GACL,QAAQ;GACR,OAAO,EAAM,KAAK,OAAU;IAAE,GAAG;IAAM,QAAQ;GAAmB,EAAE;GACpE,gBAAgB;GAChB;EACF,CAAC;EAED,IAAM,IAAO,EAAoC,CAAM;EACvD,IAAI;GACF,MAAM,EAAK,WAAW;IACpB,QAAQ,EAAM,KAAK,MAAS;KAC1B,IAAM,IAAQ,EAAW,IAAI,EAAK,GAAG;KACrC,OAAO;MACL,QAAQ,EAAM,aAAa,EAAM;MACjC,QAAQ,EAAE,IAAI,OAAO,EAAM,QAAQ,EAAE;MACrC,cAAc,EAAM;MACpB,SAAS,EAAK;MACd,iBAAiB,EAAY,EAAK,eAAe,CAAY;MAC7D;MACA;KACF;IACF,CAAC;IACD;IACA;GACF,CAAC;EACH,SAAS,GAAK;GACZ,IAAM,IAAQ,EAAmB,CAAG,GAC9B,IAAM,EAAO;GASnB,OARA,EAAO;IACL,GAAG;IACH,QAAQ;IACR,OAAO,EAAI,MAAM,KAAK,MACpB,EAAK,WAAW,YAAY;KAAE,GAAG;KAAM,QAAQ;KAAmB;IAAM,IAAI,CAC9E;IACA;GACF,CAAC,GACM;IAAE,IAAI;IAAO,gBAAgB,EAAO,QAAQ;IAAgB,OAAO,CAAC,GAAG,EAAO,QAAQ,KAAK;IAAG;GAAM;EAC7G,UAAU;GACR,EAAS,UAAU;EACrB;EAGA,IAAM,IAAY,EAAO,kBAAkB,CAAO;EAClD,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA0B,EAAE,aAAU,CAAC,EAAE,CAAC;EAIzG,IAAM,IAAM,EAAO;EAInB,OAHI,EAAI,WAAW,aAAa,EAAI,MAAM,OAAO,MAAS,EAAK,WAAW,QAAQ,KAChF,EAAO;GAAE,GAAG;GAAK,QAAQ;EAAU,CAAC,GAE/B;GAAE,IAAI;GAAM,gBAAgB,EAAO,QAAQ;GAAgB,OAAO,CAAC,GAAG,EAAO,QAAQ,KAAK;EAAE;CACrG,GACA;EAAC;EAAQ;EAAQ;EAAkB;CAAW,CAChD,GAEM,IAAQ,QAAkB;EAC1B,EAAS,YACb,EAAgB,UAAU,KAAA,GAC1B,EAAgB,KAAA,CAAS,GACzB,EAAO,CAAI;CACb,GAAG,CAAC,CAAM,CAAC,GAEL,IAAkB,QAClB,EAAM,kBAAkB,KAAW,IAChC,OAAQ,EAAM,iBAAiB,SAAW,EAAM,cAAc,IAAI,KACxE,CAAC,EAAM,gBAAgB,EAAM,cAAc,CAAC;CAE/C,OAAO;EACL;EACA;EACA,QAAQ,EAAM;EACd,WAAW,EAAM,WAAW;EAC5B;EACA,gBAAgB,EAAM;EACtB,gBAAgB,EAAM;EACtB,OAAO,EAAM;EACb,aAAa,EAAM;EACnB,OAAO,EAAM;CACf;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConfigParameter, GetCoolDownsOfMAOptions, GetCoolDownsOfMAReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useCoolDownsOfMA}: the core query options (chain id,
|
|
6
|
+
* TanStack `query` overrides) plus an optional `config`.
|
|
7
|
+
*/
|
|
8
|
+
export type UseCoolDownsOfMAParameters = GetCoolDownsOfMAOptions & ConfigParameter;
|
|
9
|
+
/** Return type of {@link useCoolDownsOfMA}. */
|
|
10
|
+
export type UseCoolDownsOfMAReturnType = UseQueryResult<GetCoolDownsOfMAReturnType, SymmioRequestError>;
|
|
11
|
+
/**
|
|
12
|
+
* Read the protocol cooldown periods (`coolDownsOfMA`) as a 4-tuple of seconds.
|
|
13
|
+
* **Index 1 is the force-cancel cooldown** — the delay after a quote enters
|
|
14
|
+
* `CANCEL_PENDING` before {@link useForceCancelQuote} becomes eligible
|
|
15
|
+
* (`now >= statusModifyTimestamp + coolDowns[1]`). These values rarely change,
|
|
16
|
+
* so a long `staleTime` is appropriate. Errors are normalized to
|
|
17
|
+
* {@link SymmioRequestError}.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { data: coolDowns } = useCoolDownsOfMA();
|
|
22
|
+
* const forceCancelCooldown = coolDowns?.[1];
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useCoolDownsOfMA(parameters?: UseCoolDownsOfMAParameters): UseCoolDownsOfMAReturnType;
|
|
26
|
+
//# sourceMappingURL=use-cool-downs-of-ma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-cool-downs-of-ma.d.ts","sourceRoot":"","sources":["../../src/quotes/use-cool-downs-of-ma.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;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,GAAG,eAAe,CAAC;AAEnF,+CAA+C;AAC/C,MAAM,MAAM,0BAA0B,GAAG,cAAc,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAExG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,0BAA+B,GAAG,0BAA0B,CAkBxG"}
|
|
@@ -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 { getCoolDownsOfMAQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/quotes/use-cool-downs-of-ma.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 useCoolDownsOfMA };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-cool-downs-of-ma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-cool-downs-of-ma.js","names":[],"sources":["../../src/quotes/use-cool-downs-of-ma.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getCoolDownsOfMAQueryOptions,\n type ConfigParameter,\n type GetCoolDownsOfMAOptions,\n type GetCoolDownsOfMAReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useCoolDownsOfMA}: the core query options (chain id,\n * TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseCoolDownsOfMAParameters = GetCoolDownsOfMAOptions & ConfigParameter;\n\n/** Return type of {@link useCoolDownsOfMA}. */\nexport type UseCoolDownsOfMAReturnType = UseQueryResult<GetCoolDownsOfMAReturnType, SymmioRequestError>;\n\n/**\n * Read the protocol cooldown periods (`coolDownsOfMA`) as a 4-tuple of seconds.\n * **Index 1 is the force-cancel cooldown** — the delay after a quote enters\n * `CANCEL_PENDING` before {@link useForceCancelQuote} becomes eligible\n * (`now >= statusModifyTimestamp + coolDowns[1]`). These values rarely change,\n * so a long `staleTime` is appropriate. Errors are normalized to\n * {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data: coolDowns } = useCoolDownsOfMA();\n * const forceCancelCooldown = coolDowns?.[1];\n * ```\n */\nexport function useCoolDownsOfMA(parameters: UseCoolDownsOfMAParameters = {}): UseCoolDownsOfMAReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getCoolDownsOfMAQueryOptions(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 UseCoolDownsOfMAReturnType;\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,EAAiB,IAAyC,CAAC,GAA+B;CACxG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA6B,GAAQ;EACnD,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"}
|