@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":"use-quote-group-funding.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-group-funding.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,EAAE,eAAe;IAC/G,6CAA6C;IAC7C,KAAK,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gDAAgD;IAChD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,4FAA4F;IAC5F,IAAI,EAAE,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrC,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,8BAA8B,GAAG,8BAA8B,CAiB/G"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuotesFunding as e } from "./use-quotes-funding.js";
|
|
3
|
+
import { aggregateGroupFunding as t } from "@symmio/trading-core";
|
|
4
|
+
import { useMemo as n } from "react";
|
|
5
|
+
//#region src/quotes/use-quote-group-funding.ts
|
|
6
|
+
function r(r) {
|
|
7
|
+
let { group: i, ...a } = r, o = i.quotes, s = e({
|
|
8
|
+
quotes: o,
|
|
9
|
+
...a
|
|
10
|
+
}), c = s.rows, l = n(() => t(o, c.filter((e) => e !== null)), [o, c]);
|
|
11
|
+
return n(() => ({
|
|
12
|
+
funding: l,
|
|
13
|
+
rows: c,
|
|
14
|
+
isLoading: s.isLoading,
|
|
15
|
+
error: s.error
|
|
16
|
+
}), [
|
|
17
|
+
l,
|
|
18
|
+
c,
|
|
19
|
+
s.isLoading,
|
|
20
|
+
s.error
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as useQuoteGroupFunding };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=use-quote-group-funding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quote-group-funding.js","names":[],"sources":["../../src/quotes/use-quote-group-funding.ts"],"sourcesContent":["\"use client\";\n\nimport {\n aggregateGroupFunding,\n type ConfigParameter,\n type GetQuoteFundingOptions,\n type QuoteFundingData,\n type QuoteGroup,\n type QuoteGroupFunding,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useQuotesFunding } from \"./use-quotes-funding\";\n\n/**\n * Parameters for {@link useQuoteGroupFunding}.\n */\nexport interface UseQuoteGroupFundingParameters extends Omit<GetQuoteFundingOptions, \"quoteIds\">, ConfigParameter {\n /** The group to read settled funding for. */\n group: QuoteGroup;\n}\n\n/**\n * Return type of {@link useQuoteGroupFunding}.\n */\nexport interface UseQuoteGroupFundingReturnType {\n /** Aggregated settled funding for the group. */\n funding: QuoteGroupFunding;\n /** Funding row per child quote, aligned 1:1 with `group.quotes`; `null` when unresolved. */\n rows: Array<QuoteFundingData | null>;\n /** `true` while the underlying subgraph query is loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Read the settled funding of a whole {@link QuoteGroup} — the group-level\n * counterpart of `useQuoteFunding`.\n *\n * Every child quote's funding is fetched in one subgraph round-trip via\n * {@link useQuotesFunding}, then folded by core's pure `aggregateGroupFunding`.\n * All arithmetic lives in core; this hook only wires the read to the fold and\n * memoizes the result, so the returned object is referentially stable while the\n * group and its rows are unchanged.\n *\n * **Sign convention** — `funding.netReceived = received − paid`, so a **positive**\n * value means the group has **earned** funding and a negative one means it has\n * **paid** for it. This matches {@link QuoteFundingData} and the uPnL folds, so\n * \"green = income\" coloring renders it as-is; it is the inverse of the\n * cost-positive on-chain `int256`.\n *\n * **Check `funding.isComplete` before presenting the total as final.**\n * `netReceived` is always the sum over the children that resolved, i.e. a lower\n * bound while the subgraph is still indexing (`funding.missingQuoteIds`\n * non-empty). An all-optimistic or empty group reports `isComplete: false` with\n * `netReceived: 0n`, so treat `isComplete: false` as \"funding unknown\", not as\n * \"no funding\".\n *\n * **Settled to date only** — these totals cover funding the protocol has already\n * charged and the analytics subgraph has indexed. Funding accrued since a\n * quote's last funding charge is not indexed anywhere and is therefore not\n * included.\n *\n * @param parameters - The group to read, plus optional chain/query/config overrides.\n * @returns The aggregated group funding, the per-child rows, and query state.\n *\n * @example\n * ```tsx\n * function GroupedPositionCard({ group }: { group: QuoteGroup }) {\n * const { funding, isLoading } = useQuoteGroupFunding({ group });\n *\n * if (isLoading || !funding.isComplete) return <FundingSkeleton />;\n *\n * // Already income-positive: `netReceived > 0n` means the group EARNED funding.\n * return <Money amount={funding.netReceived} label=\"Funding\" />;\n * }\n * ```\n */\nexport function useQuoteGroupFunding(parameters: UseQuoteGroupFundingParameters): UseQuoteGroupFundingReturnType {\n const { group, ...rest } = parameters;\n const quotes = group.quotes;\n\n /** One batched round-trip for the whole group; de-duping and off-chain skipping live there. */\n const batch = useQuotesFunding({ quotes, ...rest });\n const rows = batch.rows;\n\n const funding = useMemo(() => {\n const resolvedRows = rows.filter((row): row is QuoteFundingData => row !== null);\n return aggregateGroupFunding(quotes, resolvedRows);\n }, [quotes, rows]);\n\n return useMemo(\n () => ({ funding, rows, isLoading: batch.isLoading, error: batch.error }),\n [funding, rows, batch.isLoading, batch.error],\n );\n}\n"],"mappings":";;;;;AA+EA,SAAgB,EAAqB,GAA4E;CAC/G,IAAM,EAAE,UAAO,GAAG,MAAS,GACrB,IAAS,EAAM,QAGf,IAAQ,EAAiB;EAAE;EAAQ,GAAG;CAAK,CAAC,GAC5C,IAAO,EAAM,MAEb,IAAU,QAEP,EAAsB,GADR,EAAK,QAAQ,MAAiC,MAAQ,IACtC,CAAY,GAChD,CAAC,GAAQ,CAAI,CAAC;CAEjB,OAAO,SACE;EAAE;EAAS;EAAM,WAAW,EAAM;EAAW,OAAO,EAAM;CAAM,IACvE;EAAC;EAAS;EAAM,EAAM;EAAW,EAAM;CAAK,CAC9C;AACF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ConfigParameter, MarginRiskMetrics, QuoteGroup, QuoteGroupUpnl } from '@symmio/trading-core';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useQuoteGroupMarginRisk}.
|
|
6
|
+
*/
|
|
7
|
+
export interface UseQuoteGroupMarginRiskParameters extends ConfigParameter {
|
|
8
|
+
/** The merged position to describe. */
|
|
9
|
+
group: QuoteGroup;
|
|
10
|
+
/**
|
|
11
|
+
* Mark price override, 18-decimal wei. Omit to subscribe to the group's
|
|
12
|
+
* market. Pass it when the surrounding screen already holds the price, so the
|
|
13
|
+
* two do not open separate subscriptions or disagree by a tick.
|
|
14
|
+
*/
|
|
15
|
+
markPrice?: bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Account override; defaults to the group's resolved Virtual Account. The uPnL
|
|
18
|
+
* fold narrows to this account's children too, so `equity` stays consistent.
|
|
19
|
+
*/
|
|
20
|
+
account?: Address;
|
|
21
|
+
/**
|
|
22
|
+
* Refetch the balance when an open/close settles on-chain.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
live?: boolean;
|
|
26
|
+
/** Optional override; defaults to the connected chain. */
|
|
27
|
+
chainId?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Run the underlying reads only when `true` — gate a panel that is collapsed.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Return type of {@link useQuoteGroupMarginRisk}.
|
|
36
|
+
*/
|
|
37
|
+
export interface UseQuoteGroupMarginRiskReturnType {
|
|
38
|
+
/**
|
|
39
|
+
* Margin & risk for the group's liquidation domain. `undefined` while the
|
|
40
|
+
* balance read is in flight, **or** whenever the group spans several accounts
|
|
41
|
+
* ({@link isMultiAccount}) — blending liquidation domains is never correct.
|
|
42
|
+
*/
|
|
43
|
+
metrics?: MarginRiskMetrics;
|
|
44
|
+
/**
|
|
45
|
+
* The group's aggregated unrealized PnL at {@link markPrice}. Check
|
|
46
|
+
* `upnl.isComplete` before presenting anything derived from it as final.
|
|
47
|
+
*/
|
|
48
|
+
upnl: QuoteGroupUpnl;
|
|
49
|
+
/** Liquidation price of the resolved account, wei. `0n` when unavailable. */
|
|
50
|
+
liquidationPrice: bigint;
|
|
51
|
+
/** The mark price actually used, wei; `undefined` before the first tick. */
|
|
52
|
+
markPrice?: bigint;
|
|
53
|
+
/** The account {@link metrics} and {@link liquidationPrice} describe. */
|
|
54
|
+
account?: Address;
|
|
55
|
+
/** Distinct liquidation domains among the group's children (`vaAddress ?? partyA`). */
|
|
56
|
+
accounts: Address[];
|
|
57
|
+
/**
|
|
58
|
+
* `true` when the group's children live in more than one account. Each is
|
|
59
|
+
* liquidated independently, so {@link metrics} is suppressed — fan out with
|
|
60
|
+
* `useAccountMarginRisk` over {@link accounts} instead.
|
|
61
|
+
*/
|
|
62
|
+
isMultiAccount: boolean;
|
|
63
|
+
/** `true` while the balance, positions, or price reads are loading. */
|
|
64
|
+
isLoading: boolean;
|
|
65
|
+
/** Normalized request error, when one occurred. */
|
|
66
|
+
error: SymmioRequestError | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Margin and liquidation-risk state of a merged position — the group-level
|
|
70
|
+
* counterpart of `useAccountMarginRisk`.
|
|
71
|
+
*
|
|
72
|
+
* Resolves the group's Virtual Account, folds its children's unrealized PnL
|
|
73
|
+
* against the mark price with core's `aggregateGroupUpnl`, and runs both through
|
|
74
|
+
* `calculateMarginRisk`. The account's liquidation price comes from the existing
|
|
75
|
+
* `useAccountLiquidationPrice`. All arithmetic lives in core; this hook only
|
|
76
|
+
* wires the reads to the folds.
|
|
77
|
+
*
|
|
78
|
+
* **Mark price**: injected wins. Pass `markPrice` (wei) and no price
|
|
79
|
+
* subscription is opened; omit it and the hook subscribes to the group's market.
|
|
80
|
+
*
|
|
81
|
+
* **One liquidation domain per result.** A group normally maps 1:1 to a Virtual
|
|
82
|
+
* Account, because the built-in grouping strategies mirror the sub-account's
|
|
83
|
+
* on-chain isolation type. When it does not — a custom `keyOf`, or grouping by
|
|
84
|
+
* `MARKET` an account isolated by `MARKET_DIRECTION` — `isMultiAccount` is `true`
|
|
85
|
+
* and `metrics` is withheld rather than blended: an account at 2% buffer averaged
|
|
86
|
+
* with one at 200% reads as safe while the first is about to be liquidated.
|
|
87
|
+
*
|
|
88
|
+
* **Equity is exact only when the group covers the account's whole book.**
|
|
89
|
+
* `equity = allocatedBalance + upnl` mixes an account-wide balance with the
|
|
90
|
+
* group's uPnL. That is the same figure the reference app shows, and it is exact
|
|
91
|
+
* whenever the grouping strategy matches the sub-account's isolation type. Group
|
|
92
|
+
* a `MARKET`-isolated account by `MARKET_DIRECTION` and each group is a *subset*
|
|
93
|
+
* of its account, which understates equity — the hook cannot detect that without
|
|
94
|
+
* a second read, so it is stated rather than guessed at.
|
|
95
|
+
*
|
|
96
|
+
* @param parameters - The group, plus optional price/account/chain/config overrides.
|
|
97
|
+
* @returns The group's metrics, uPnL, liquidation price, and query state.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx
|
|
101
|
+
* function GroupRisk({ group }: { group: QuoteGroup }) {
|
|
102
|
+
* const { metrics, upnl, liquidationPrice } = useQuoteGroupMarginRisk({ group });
|
|
103
|
+
* if (!metrics) return <Skeleton />;
|
|
104
|
+
* // The three margin rows are uPnL-independent — render them even while
|
|
105
|
+
* // `upnl.isComplete` is false; gate only equity and the buffer on it.
|
|
106
|
+
* return <MarginRows metrics={metrics} live={upnl.isComplete} liq={liquidationPrice} />;
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function useQuoteGroupMarginRisk(parameters: UseQuoteGroupMarginRiskParameters): UseQuoteGroupMarginRiskReturnType;
|
|
111
|
+
//# sourceMappingURL=use-quote-group-margin-risk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quote-group-margin-risk.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-group-margin-risk.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,eAAe;IACxE,uCAAuC;IACvC,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;OAIG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,IAAI,EAAE,cAAc,CAAC;IACrB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uFAAuF;IACvF,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iCAAiC,GAC5C,iCAAiC,CA8FnC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useAccountLiquidationPrice as e } from "./use-account-liquidation-price.js";
|
|
3
|
+
import { useAccountMarginRisk as t } from "../margin/use-account-margin-risk.js";
|
|
4
|
+
import { useEnigmaPriceByMarketId as n } from "../price-service/use-enigma-price-by-market-id.js";
|
|
5
|
+
import { aggregateGroupUpnl as r, decimalPriceToWei as i } from "@symmio/trading-core";
|
|
6
|
+
import { useMemo as a } from "react";
|
|
7
|
+
//#region src/quotes/use-quote-group-margin-risk.ts
|
|
8
|
+
function o(o) {
|
|
9
|
+
let { group: s, markPrice: c, live: l = !0, chainId: u, enabled: d = !0, config: f } = o, p = s.quotes, m = a(() => {
|
|
10
|
+
let e = /* @__PURE__ */ new Set(), t = [];
|
|
11
|
+
for (let n of p) {
|
|
12
|
+
let r = n.vaAddress ?? n.partyA, i = r.toLowerCase();
|
|
13
|
+
e.has(i) || (e.add(i), t.push(r));
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
}, [p]), h = m.length > 1, g = o.account ?? s.vaAddress ?? m[0], _ = a(() => {
|
|
17
|
+
if (g === void 0) return p;
|
|
18
|
+
let e = g.toLowerCase();
|
|
19
|
+
return p.filter((t) => (t.vaAddress ?? t.partyA).toLowerCase() === e);
|
|
20
|
+
}, [p, g]), v = s.by.symbolId ?? p[0]?.symbolId, y = n({
|
|
21
|
+
marketId: v ?? 0n,
|
|
22
|
+
enabled: d && c === void 0 && v !== void 0,
|
|
23
|
+
chainId: u,
|
|
24
|
+
config: f
|
|
25
|
+
}), b = c ?? i(y.markPrice ?? ""), x = a(() => r(_, b), [_, b]), S = t({
|
|
26
|
+
account: h ? void 0 : g,
|
|
27
|
+
upnl: x.upnl,
|
|
28
|
+
live: l,
|
|
29
|
+
chainId: u,
|
|
30
|
+
config: f
|
|
31
|
+
}), C = e({
|
|
32
|
+
account: g,
|
|
33
|
+
chainId: u,
|
|
34
|
+
config: f
|
|
35
|
+
}), w = c === void 0 && y.isLoading;
|
|
36
|
+
return a(() => ({
|
|
37
|
+
metrics: h ? void 0 : S.metrics,
|
|
38
|
+
upnl: x,
|
|
39
|
+
liquidationPrice: C.liquidationPrice,
|
|
40
|
+
markPrice: b,
|
|
41
|
+
account: g,
|
|
42
|
+
accounts: m,
|
|
43
|
+
isMultiAccount: h,
|
|
44
|
+
isLoading: S.isLoading || C.isLoading || w,
|
|
45
|
+
error: S.error
|
|
46
|
+
}), [
|
|
47
|
+
S.metrics,
|
|
48
|
+
S.isLoading,
|
|
49
|
+
S.error,
|
|
50
|
+
x,
|
|
51
|
+
C.liquidationPrice,
|
|
52
|
+
C.isLoading,
|
|
53
|
+
b,
|
|
54
|
+
g,
|
|
55
|
+
m,
|
|
56
|
+
h,
|
|
57
|
+
w
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { o as useQuoteGroupMarginRisk };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=use-quote-group-margin-risk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quote-group-margin-risk.js","names":[],"sources":["../../src/quotes/use-quote-group-margin-risk.ts"],"sourcesContent":["\"use client\";\n\nimport {\n aggregateGroupUpnl,\n decimalPriceToWei,\n type ConfigParameter,\n type MarginRiskMetrics,\n type QuoteGroup,\n type QuoteGroupUpnl,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Address } from \"viem\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useAccountMarginRisk } from \"../margin/use-account-margin-risk\";\nimport { useEnigmaPriceByMarketId } from \"../price-service/use-enigma-price-by-market-id\";\nimport { useAccountLiquidationPrice } from \"./use-account-liquidation-price\";\n\n/**\n * Parameters for {@link useQuoteGroupMarginRisk}.\n */\nexport interface UseQuoteGroupMarginRiskParameters extends ConfigParameter {\n /** The merged position to describe. */\n group: QuoteGroup;\n /**\n * Mark price override, 18-decimal wei. Omit to subscribe to the group's\n * market. Pass it when the surrounding screen already holds the price, so the\n * two do not open separate subscriptions or disagree by a tick.\n */\n markPrice?: bigint;\n /**\n * Account override; defaults to the group's resolved Virtual Account. The uPnL\n * fold narrows to this account's children too, so `equity` stays consistent.\n */\n account?: Address;\n /**\n * Refetch the balance when an open/close settles on-chain.\n * @default true\n */\n live?: boolean;\n /** Optional override; defaults to the connected chain. */\n chainId?: number;\n /**\n * Run the underlying reads only when `true` — gate a panel that is collapsed.\n * @default true\n */\n enabled?: boolean;\n}\n\n/**\n * Return type of {@link useQuoteGroupMarginRisk}.\n */\nexport interface UseQuoteGroupMarginRiskReturnType {\n /**\n * Margin & risk for the group's liquidation domain. `undefined` while the\n * balance read is in flight, **or** whenever the group spans several accounts\n * ({@link isMultiAccount}) — blending liquidation domains is never correct.\n */\n metrics?: MarginRiskMetrics;\n /**\n * The group's aggregated unrealized PnL at {@link markPrice}. Check\n * `upnl.isComplete` before presenting anything derived from it as final.\n */\n upnl: QuoteGroupUpnl;\n /** Liquidation price of the resolved account, wei. `0n` when unavailable. */\n liquidationPrice: bigint;\n /** The mark price actually used, wei; `undefined` before the first tick. */\n markPrice?: bigint;\n /** The account {@link metrics} and {@link liquidationPrice} describe. */\n account?: Address;\n /** Distinct liquidation domains among the group's children (`vaAddress ?? partyA`). */\n accounts: Address[];\n /**\n * `true` when the group's children live in more than one account. Each is\n * liquidated independently, so {@link metrics} is suppressed — fan out with\n * `useAccountMarginRisk` over {@link accounts} instead.\n */\n isMultiAccount: boolean;\n /** `true` while the balance, positions, or price reads are loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Margin and liquidation-risk state of a merged position — the group-level\n * counterpart of `useAccountMarginRisk`.\n *\n * Resolves the group's Virtual Account, folds its children's unrealized PnL\n * against the mark price with core's `aggregateGroupUpnl`, and runs both through\n * `calculateMarginRisk`. The account's liquidation price comes from the existing\n * `useAccountLiquidationPrice`. All arithmetic lives in core; this hook only\n * wires the reads to the folds.\n *\n * **Mark price**: injected wins. Pass `markPrice` (wei) and no price\n * subscription is opened; omit it and the hook subscribes to the group's market.\n *\n * **One liquidation domain per result.** A group normally maps 1:1 to a Virtual\n * Account, because the built-in grouping strategies mirror the sub-account's\n * on-chain isolation type. When it does not — a custom `keyOf`, or grouping by\n * `MARKET` an account isolated by `MARKET_DIRECTION` — `isMultiAccount` is `true`\n * and `metrics` is withheld rather than blended: an account at 2% buffer averaged\n * with one at 200% reads as safe while the first is about to be liquidated.\n *\n * **Equity is exact only when the group covers the account's whole book.**\n * `equity = allocatedBalance + upnl` mixes an account-wide balance with the\n * group's uPnL. That is the same figure the reference app shows, and it is exact\n * whenever the grouping strategy matches the sub-account's isolation type. Group\n * a `MARKET`-isolated account by `MARKET_DIRECTION` and each group is a *subset*\n * of its account, which understates equity — the hook cannot detect that without\n * a second read, so it is stated rather than guessed at.\n *\n * @param parameters - The group, plus optional price/account/chain/config overrides.\n * @returns The group's metrics, uPnL, liquidation price, and query state.\n *\n * @example\n * ```tsx\n * function GroupRisk({ group }: { group: QuoteGroup }) {\n * const { metrics, upnl, liquidationPrice } = useQuoteGroupMarginRisk({ group });\n * if (!metrics) return <Skeleton />;\n * // The three margin rows are uPnL-independent — render them even while\n * // `upnl.isComplete` is false; gate only equity and the buffer on it.\n * return <MarginRows metrics={metrics} live={upnl.isComplete} liq={liquidationPrice} />;\n * }\n * ```\n */\nexport function useQuoteGroupMarginRisk(\n parameters: UseQuoteGroupMarginRiskParameters,\n): UseQuoteGroupMarginRiskReturnType {\n const { group, markPrice: markPriceOverride, live = true, chainId, enabled = true, config } = parameters;\n const quotes = group.quotes;\n\n /** One entry per liquidation domain the children live in, in first-appearance order. */\n const accounts = useMemo(() => {\n const seen = new Set<string>();\n const result: Address[] = [];\n for (const quote of quotes) {\n const address = quote.vaAddress ?? quote.partyA;\n const key = address.toLowerCase();\n if (seen.has(key)) continue;\n seen.add(key);\n result.push(address);\n }\n return result;\n }, [quotes]);\n\n const isMultiAccount = accounts.length > 1;\n const account = parameters.account ?? group.vaAddress ?? accounts[0];\n\n /**\n * Narrowing to the resolved account is what keeps `equity` honest: without it\n * an `account` override would fold every child's uPnL against one account's\n * balance.\n */\n const children = useMemo(() => {\n if (account === undefined) return quotes;\n const target = account.toLowerCase();\n return quotes.filter((quote) => (quote.vaAddress ?? quote.partyA).toLowerCase() === target);\n }, [quotes, account]);\n\n /** `by.symbolId` is unset under a custom `keyOf`; the children still carry the market. */\n const symbolId = group.by.symbolId ?? quotes[0]?.symbolId;\n\n const priceQuery = useEnigmaPriceByMarketId({\n marketId: symbolId ?? 0n,\n enabled: enabled && markPriceOverride === undefined && symbolId !== undefined,\n chainId,\n config,\n });\n\n /**\n * `decimalPriceToWei` returns `undefined` rather than `0n` for a feed that has\n * not ticked — a fabricated `0n` would report a total loss.\n */\n const markPrice = markPriceOverride ?? decimalPriceToWei(priceQuery.markPrice ?? \"\");\n\n const upnl = useMemo(() => aggregateGroupUpnl(children, markPrice), [children, markPrice]);\n\n const risk = useAccountMarginRisk({\n /** A blended multi-account figure would be misleading, so do not even read for it. */\n account: isMultiAccount ? undefined : account,\n upnl: upnl.upnl,\n live,\n chainId,\n config,\n });\n\n const liquidation = useAccountLiquidationPrice({ account, chainId, config });\n\n const isPriceLoading = markPriceOverride === undefined && priceQuery.isLoading;\n\n return useMemo(\n () => ({\n /**\n * Withheld explicitly, not merely by leaving the read idle: suppressing a\n * blended cross-account figure is this hook's contract, so it must not\n * depend on how the account hook happens to behave without an account.\n */\n metrics: isMultiAccount ? undefined : risk.metrics,\n upnl,\n liquidationPrice: liquidation.liquidationPrice,\n markPrice,\n account,\n accounts,\n isMultiAccount,\n isLoading: risk.isLoading || liquidation.isLoading || isPriceLoading,\n error: risk.error,\n }),\n [\n risk.metrics,\n risk.isLoading,\n risk.error,\n upnl,\n liquidation.liquidationPrice,\n liquidation.isLoading,\n markPrice,\n account,\n accounts,\n isMultiAccount,\n isPriceLoading,\n ],\n );\n}\n"],"mappings":";;;;;;;AA6HA,SAAgB,EACd,GACmC;CACnC,IAAM,EAAE,UAAO,WAAW,GAAmB,UAAO,IAAM,YAAS,aAAU,IAAM,cAAW,GACxF,IAAS,EAAM,QAGf,IAAW,QAAc;EAC7B,IAAM,oBAAO,IAAI,IAAY,GACvB,IAAoB,CAAC;EAC3B,KAAK,IAAM,KAAS,GAAQ;GAC1B,IAAM,IAAU,EAAM,aAAa,EAAM,QACnC,IAAM,EAAQ,YAAY;GAC5B,EAAK,IAAI,CAAG,MAChB,EAAK,IAAI,CAAG,GACZ,EAAO,KAAK,CAAO;EACrB;EACA,OAAO;CACT,GAAG,CAAC,CAAM,CAAC,GAEL,IAAiB,EAAS,SAAS,GACnC,IAAU,EAAW,WAAW,EAAM,aAAa,EAAS,IAO5D,IAAW,QAAc;EAC7B,IAAI,MAAY,KAAA,GAAW,OAAO;EAClC,IAAM,IAAS,EAAQ,YAAY;EACnC,OAAO,EAAO,QAAQ,OAAW,EAAM,aAAa,EAAM,QAAQ,YAAY,MAAM,CAAM;CAC5F,GAAG,CAAC,GAAQ,CAAO,CAAC,GAGd,IAAW,EAAM,GAAG,YAAY,EAAO,IAAI,UAE3C,IAAa,EAAyB;EAC1C,UAAU,KAAY;EACtB,SAAS,KAAW,MAAsB,KAAA,KAAa,MAAa,KAAA;EACpE;EACA;CACF,CAAC,GAMK,IAAY,KAAqB,EAAkB,EAAW,aAAa,EAAE,GAE7E,IAAO,QAAc,EAAmB,GAAU,CAAS,GAAG,CAAC,GAAU,CAAS,CAAC,GAEnF,IAAO,EAAqB;EAEhC,SAAS,IAAiB,KAAA,IAAY;EACtC,MAAM,EAAK;EACX;EACA;EACA;CACF,CAAC,GAEK,IAAc,EAA2B;EAAE;EAAS;EAAS;CAAO,CAAC,GAErE,IAAiB,MAAsB,KAAA,KAAa,EAAW;CAErE,OAAO,SACE;EAML,SAAS,IAAiB,KAAA,IAAY,EAAK;EAC3C;EACA,kBAAkB,EAAY;EAC9B;EACA;EACA;EACA;EACA,WAAW,EAAK,aAAa,EAAY,aAAa;EACtD,OAAO,EAAK;CACd,IACA;EACE,EAAK;EACL,EAAK;EACL,EAAK;EACL;EACA,EAAY;EACZ,EAAY;EACZ;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
|
|
@@ -21,9 +21,10 @@ export interface UseQuoteUpnlAndPnlReturnType extends CalculateQuoteUpnlReturnTy
|
|
|
21
21
|
* Compute unrealized PNL (open size, vs mark) and realized PNL (closed size,
|
|
22
22
|
* vs the quote's recorded close price) for a single {@link UnifiedQuote}.
|
|
23
23
|
*
|
|
24
|
-
* Mark price is resolved live via {@link
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Mark price is resolved live via {@link usePriceByMarketId} on the quote's
|
|
25
|
+
* `symbolId` — from whichever price provider serves the chain's resolved solver
|
|
26
|
+
* (Enigma on lowcap chains, Binance on majors chains). UPNL stays `"0"` until
|
|
27
|
+
* the first tick for that market arrives.
|
|
27
28
|
*
|
|
28
29
|
* @example
|
|
29
30
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-quote-upnl-and-pnl.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,eAAe;IACnE,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,4BAA4B,EAAE,2BAA2B;IAC7G,gFAAgF;IAChF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;CACpB;AAYD
|
|
1
|
+
{"version":3,"file":"use-quote-upnl-and-pnl.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,eAAe;IACnE,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,4BAA4B,EAAE,2BAA2B;IAC7G,gFAAgF;IAChF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;CACpB;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,4BAA4B,GAAG,4BAA4B,CAmDzG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { usePriceByMarketId as e } from "../price-service/use-price-by-market-id.js";
|
|
3
3
|
import { calculateQuoteLeverage as t, calculateQuotePnl as n, calculateQuoteUpnl as r } from "@symmio/trading-core";
|
|
4
4
|
import { useMemo as i } from "react";
|
|
5
5
|
//#region src/quotes/use-quote-upnl-and-pnl.ts
|
|
@@ -22,6 +22,7 @@ function o(o) {
|
|
|
22
22
|
let e = s.initialLockedValues ?? s.lockedValues, i = t({
|
|
23
23
|
quantity: s.quantity,
|
|
24
24
|
requestedOpenPrice: s.requestedOpenPrice,
|
|
25
|
+
openedPrice: s.openedPrice,
|
|
25
26
|
lockedValues: e
|
|
26
27
|
}), o = s.closedAmount ?? 0n, l = c.markPrice, { upnl: u, upnlPercent: d } = l ? r({
|
|
27
28
|
markPrice: l,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-quote-upnl-and-pnl.js","names":[],"sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateQuoteLeverage,\n calculateQuotePnl,\n calculateQuoteUpnl,\n type CalculateQuotePnlReturnType,\n type CalculateQuoteUpnlReturnType,\n type ConfigParameter,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"use-quote-upnl-and-pnl.js","names":[],"sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateQuoteLeverage,\n calculateQuotePnl,\n calculateQuoteUpnl,\n type CalculateQuotePnlReturnType,\n type CalculateQuoteUpnlReturnType,\n type ConfigParameter,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { usePriceByMarketId } from \"../price-service/use-price-by-market-id\";\n\n/**\n * Parameters for {@link useQuoteUpnlAndPnl}.\n */\nexport interface UseQuoteUpnlAndPnlParameters extends ConfigParameter {\n /** Unified quote to compute UPNL + realized PNL for. */\n quote?: UnifiedQuote;\n}\n\n/**\n * Return type of {@link useQuoteUpnlAndPnl}.\n */\nexport interface UseQuoteUpnlAndPnlReturnType extends CalculateQuoteUpnlReturnType, CalculateQuotePnlReturnType {\n /** Mark price used in the calc, decimal string. `null` until the first tick. */\n markPrice: string | null;\n /** Leverage derived from the quote's locked-margin breakdown, decimal string. */\n leverage: string;\n /** `true` while markets or mark-price are resolving. */\n isLoading: boolean;\n}\n\nconst EMPTY: UseQuoteUpnlAndPnlReturnType = {\n upnl: \"0\",\n upnlPercent: \"0\",\n pnl: \"0\",\n pnlPercent: \"0\",\n markPrice: null,\n leverage: \"0\",\n isLoading: false,\n};\n\n/**\n * Compute unrealized PNL (open size, vs mark) and realized PNL (closed size,\n * vs the quote's recorded close price) for a single {@link UnifiedQuote}.\n *\n * Mark price is resolved live via {@link usePriceByMarketId} on the quote's\n * `symbolId` — from whichever price provider serves the chain's resolved solver\n * (Enigma on lowcap chains, Binance on majors chains). UPNL stays `\"0\"` until\n * the first tick for that market arrives.\n *\n * @example\n * ```tsx\n * const { upnl, upnlPercent, pnl, pnlPercent, markPrice } = useQuoteUpnlAndPnl({ quote });\n * ```\n */\nexport function useQuoteUpnlAndPnl(parameters: UseQuoteUpnlAndPnlParameters): UseQuoteUpnlAndPnlReturnType {\n const { quote } = parameters;\n\n const priceQuery = usePriceByMarketId({\n marketId: quote?.symbolId ?? 0n,\n enabled: quote !== undefined,\n });\n\n return useMemo(() => {\n if (!quote) return EMPTY;\n\n const lockedValuesForLeverage = quote.initialLockedValues ?? quote.lockedValues;\n const leverage = calculateQuoteLeverage({\n quantity: quote.quantity,\n requestedOpenPrice: quote.requestedOpenPrice,\n openedPrice: quote.openedPrice,\n lockedValues: lockedValuesForLeverage,\n });\n\n const closedAmount = quote.closedAmount ?? 0n;\n const markPrice = priceQuery.markPrice;\n\n const { upnl, upnlPercent } = markPrice\n ? calculateQuoteUpnl({\n markPrice,\n positionType: quote.positionType,\n quantity: quote.quantity,\n closedAmount,\n openedPrice: quote.openedPrice ?? 0n,\n leverage,\n })\n : { upnl: \"0\", upnlPercent: \"0\" };\n\n const { pnl, pnlPercent } = calculateQuotePnl({\n positionType: quote.positionType,\n closedAmount,\n closedPrice: quote.avgClosedPrice ?? 0n,\n openedPrice: quote.openedPrice ?? 0n,\n leverage,\n });\n\n return {\n upnl,\n upnlPercent,\n pnl,\n pnlPercent,\n markPrice,\n leverage,\n isLoading: priceQuery.isLoading,\n };\n }, [quote, priceQuery.markPrice, priceQuery.isLoading]);\n}\n"],"mappings":";;;;;AAkCA,IAAM,IAAsC;CAC1C,MAAM;CACN,aAAa;CACb,KAAK;CACL,YAAY;CACZ,WAAW;CACX,UAAU;CACV,WAAW;AACb;AAgBA,SAAgB,EAAmB,GAAwE;CACzG,IAAM,EAAE,aAAU,GAEZ,IAAa,EAAmB;EACpC,UAAU,GAAO,YAAY;EAC7B,SAAS,MAAU,KAAA;CACrB,CAAC;CAED,OAAO,QAAc;EACnB,IAAI,CAAC,GAAO,OAAO;EAEnB,IAAM,IAA0B,EAAM,uBAAuB,EAAM,cAC7D,IAAW,EAAuB;GACtC,UAAU,EAAM;GAChB,oBAAoB,EAAM;GAC1B,aAAa,EAAM;GACnB,cAAc;EAChB,CAAC,GAEK,IAAe,EAAM,gBAAgB,IACrC,IAAY,EAAW,WAEvB,EAAE,SAAM,mBAAgB,IAC1B,EAAmB;GACjB;GACA,cAAc,EAAM;GACpB,UAAU,EAAM;GAChB;GACA,aAAa,EAAM,eAAe;GAClC;EACF,CAAC,IACD;GAAE,MAAM;GAAK,aAAa;EAAI,GAE5B,EAAE,QAAK,kBAAe,EAAkB;GAC5C,cAAc,EAAM;GACpB;GACA,aAAa,EAAM,kBAAkB;GACrC,aAAa,EAAM,eAAe;GAClC;EACF,CAAC;EAED,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,EAAW;EACxB;CACF,GAAG;EAAC;EAAO,EAAW;EAAW,EAAW;CAAS,CAAC;AACxD"}
|
|
@@ -11,8 +11,9 @@ export interface QuotesFundingInputQuote {
|
|
|
11
11
|
export interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions, "quoteIds">, ConfigParameter {
|
|
12
12
|
/**
|
|
13
13
|
* Quotes (or quote-id-bearing rows) to read funding for. Off-chain rows
|
|
14
|
-
* (`quoteId === undefined`) are silently skipped.
|
|
15
|
-
*
|
|
14
|
+
* (`quoteId === undefined`) are silently skipped. The resolved on-chain ids are
|
|
15
|
+
* de-duplicated and fetched in a single subgraph round-trip, so listing the
|
|
16
|
+
* same quote twice costs one request and contributes to the sums once.
|
|
16
17
|
*/
|
|
17
18
|
quotes: readonly QuotesFundingInputQuote[];
|
|
18
19
|
}
|
|
@@ -20,15 +21,35 @@ export interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions,
|
|
|
20
21
|
* Return type of {@link useQuotesFunding}.
|
|
21
22
|
*/
|
|
22
23
|
export interface UseQuotesFundingReturnType {
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Funding row per input quote, aligned 1:1 with `quotes` and in input order —
|
|
26
|
+
* `rows.length === quotes.length` on every path, including while loading and
|
|
27
|
+
* when nothing on-chain was requested. An entry is `null` for an off-chain row
|
|
28
|
+
* (no `quoteId`) or for an id the subgraph has not surfaced yet.
|
|
29
|
+
*/
|
|
24
30
|
rows: Array<QuoteFundingData | null>;
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Σ funding paid across the resolved rows (wei). Summed over the **distinct**
|
|
33
|
+
* on-chain ids, so a quote listed twice contributes once.
|
|
34
|
+
*/
|
|
26
35
|
paid: bigint;
|
|
27
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Σ funding received across the resolved rows (wei). Summed over the
|
|
38
|
+
* **distinct** on-chain ids, so a quote listed twice contributes once.
|
|
39
|
+
*/
|
|
28
40
|
received: bigint;
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Σ `received − paid` across the resolved rows (wei). **Positive = the position
|
|
43
|
+
* earned funding**; negative = it paid for it. A lower bound while
|
|
44
|
+
* `missingQuoteIds` is non-empty.
|
|
45
|
+
*/
|
|
46
|
+
netReceived: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Requested on-chain ids that have no funding row yet. While the query is in
|
|
49
|
+
* flight — and if it fails — this is **every** requested id, since nothing has
|
|
50
|
+
* resolved; once it settles it is the subset the subgraph did not return
|
|
51
|
+
* (indexing lag). Always empty when no on-chain ids were requested.
|
|
52
|
+
*/
|
|
32
53
|
missingQuoteIds: bigint[];
|
|
33
54
|
/** `true` while the underlying subgraph query is loading. */
|
|
34
55
|
isLoading: boolean;
|
|
@@ -41,11 +62,26 @@ export interface UseQuotesFundingReturnType {
|
|
|
41
62
|
*
|
|
42
63
|
* The hook is the canonical entry point for both single-quote details panels
|
|
43
64
|
* ({@link useQuoteFunding} delegates here with a 1-element list) and grouped
|
|
44
|
-
* quote cards (which want `Σ
|
|
65
|
+
* quote cards (which want `Σ netReceived`). Off-chain rows are skipped silently,
|
|
66
|
+
* and duplicate ids are fetched — and summed — exactly once.
|
|
67
|
+
*
|
|
68
|
+
* **Sign convention** — `netReceived = received − paid`, the P&L perspective, so
|
|
69
|
+
* a **positive** value means the position **earned** funding. This matches
|
|
70
|
+
* `QuoteFundingData.netReceived` and the uPnL folds, and is the inverse of the
|
|
71
|
+
* cost-positive on-chain `int256`. A "green = income" UI renders it directly.
|
|
72
|
+
*
|
|
73
|
+
* **Settled to date only** — the totals cover funding the protocol has already
|
|
74
|
+
* charged and the analytics subgraph has indexed. Funding accrued since a
|
|
75
|
+
* quote's last funding charge is not indexed anywhere and is therefore not
|
|
76
|
+
* included.
|
|
77
|
+
*
|
|
78
|
+
* @param parameters - The quotes to read funding for, plus optional chain/config overrides.
|
|
79
|
+
* @returns Per-quote rows aligned with `quotes`, the aggregate sums, and query state.
|
|
45
80
|
*
|
|
46
81
|
* @example
|
|
47
82
|
* ```tsx
|
|
48
|
-
* const { rows,
|
|
83
|
+
* const { rows, netReceived, missingQuoteIds, isLoading } = useQuotesFunding({ quotes: group.quotes });
|
|
84
|
+
* // `netReceived > 0n` → the position earned funding across the resolved rows.
|
|
49
85
|
* ```
|
|
50
86
|
*/
|
|
51
87
|
export declare function useQuotesFunding(parameters: UseQuotesFundingParameters): UseQuotesFundingReturnType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-quotes-funding.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quotes-funding.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,0EAA0E;AAC1E,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,EAAE,eAAe;IAC3G
|
|
1
|
+
{"version":3,"file":"use-quotes-funding.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quotes-funding.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,0EAA0E;AAC1E,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,EAAE,eAAe;IAC3G;;;;;OAKG;IACH,MAAM,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,IAAI,EAAE,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,0BAA0B,CAgGnG"}
|
|
@@ -6,75 +6,77 @@ import { getQuoteFundingQueryOptions as r } from "@symmio/trading-core";
|
|
|
6
6
|
import { useMemo as i } from "react";
|
|
7
7
|
import { useQuery as a } from "@tanstack/react-query";
|
|
8
8
|
//#region src/quotes/use-quotes-funding.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
paid: 0n,
|
|
12
|
-
received: 0n,
|
|
13
|
-
net: 0n,
|
|
14
|
-
missingQuoteIds: [],
|
|
15
|
-
isLoading: !1,
|
|
16
|
-
error: null
|
|
17
|
-
};
|
|
18
|
-
function s(s) {
|
|
19
|
-
let { quotes: c, ...l } = s, u = t(s), d = e(), f = i(() => {
|
|
9
|
+
function o(o) {
|
|
10
|
+
let { quotes: s, ...c } = o, l = t(o), u = e(), d = i(() => {
|
|
20
11
|
let e = /* @__PURE__ */ new Set(), t = [];
|
|
21
|
-
for (let n of
|
|
12
|
+
for (let n of s) {
|
|
22
13
|
if (n.quoteId === void 0) continue;
|
|
23
14
|
let r = n.quoteId.toString();
|
|
24
15
|
e.has(r) || (e.add(r), t.push(n.quoteId));
|
|
25
16
|
}
|
|
26
17
|
return t;
|
|
27
|
-
}, [
|
|
28
|
-
...
|
|
29
|
-
chainId:
|
|
30
|
-
quoteIds:
|
|
31
|
-
}),
|
|
32
|
-
...
|
|
18
|
+
}, [s]), f = r(l, {
|
|
19
|
+
...c,
|
|
20
|
+
chainId: c.chainId ?? u,
|
|
21
|
+
quoteIds: d
|
|
22
|
+
}), p = a({
|
|
23
|
+
...f,
|
|
33
24
|
queryFn: async () => {
|
|
34
25
|
try {
|
|
35
|
-
return await
|
|
26
|
+
return await f.queryFn();
|
|
36
27
|
} catch (e) {
|
|
37
28
|
throw n(e);
|
|
38
29
|
}
|
|
39
30
|
}
|
|
40
31
|
});
|
|
41
32
|
return i(() => {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
if (!e) return {
|
|
45
|
-
rows: c.map(() => null),
|
|
33
|
+
if (d.length === 0) return {
|
|
34
|
+
rows: s.map(() => null),
|
|
46
35
|
paid: 0n,
|
|
47
36
|
received: 0n,
|
|
48
|
-
|
|
37
|
+
netReceived: 0n,
|
|
49
38
|
missingQuoteIds: [],
|
|
50
|
-
isLoading:
|
|
51
|
-
error:
|
|
39
|
+
isLoading: !1,
|
|
40
|
+
error: null
|
|
41
|
+
};
|
|
42
|
+
let e = p.data;
|
|
43
|
+
if (!e) return {
|
|
44
|
+
rows: s.map(() => null),
|
|
45
|
+
paid: 0n,
|
|
46
|
+
received: 0n,
|
|
47
|
+
netReceived: 0n,
|
|
48
|
+
missingQuoteIds: [...d],
|
|
49
|
+
isLoading: p.isLoading,
|
|
50
|
+
error: p.error ?? null
|
|
52
51
|
};
|
|
53
52
|
let t = /* @__PURE__ */ new Map();
|
|
54
|
-
for (let n of e.rows)
|
|
55
|
-
|
|
53
|
+
for (let n of e.rows) {
|
|
54
|
+
let e = n.quoteId.toString();
|
|
55
|
+
t.has(e) || t.set(e, n);
|
|
56
|
+
}
|
|
57
|
+
let n = 0n, r = 0n;
|
|
58
|
+
for (let e of d) {
|
|
59
|
+
let i = t.get(e.toString());
|
|
60
|
+
i !== void 0 && (n += i.paid, r += i.received);
|
|
61
|
+
}
|
|
56
62
|
return {
|
|
57
|
-
rows:
|
|
58
|
-
if (e.quoteId === void 0) return null;
|
|
59
|
-
let a = t.get(e.quoteId.toString()) ?? null;
|
|
60
|
-
return a && (n += a.paid, r += a.received, i += a.net), a;
|
|
61
|
-
}),
|
|
63
|
+
rows: s.map((e) => e.quoteId === void 0 ? null : t.get(e.quoteId.toString()) ?? null),
|
|
62
64
|
paid: n,
|
|
63
65
|
received: r,
|
|
64
|
-
|
|
66
|
+
netReceived: r - n,
|
|
65
67
|
missingQuoteIds: e.missingQuoteIds,
|
|
66
|
-
isLoading:
|
|
67
|
-
error:
|
|
68
|
+
isLoading: p.isLoading,
|
|
69
|
+
error: p.error ?? null
|
|
68
70
|
};
|
|
69
71
|
}, [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
d,
|
|
73
|
+
s,
|
|
74
|
+
p.data,
|
|
75
|
+
p.isLoading,
|
|
76
|
+
p.error
|
|
75
77
|
]);
|
|
76
78
|
}
|
|
77
79
|
//#endregion
|
|
78
|
-
export {
|
|
80
|
+
export { o as useQuotesFunding };
|
|
79
81
|
|
|
80
82
|
//# sourceMappingURL=use-quotes-funding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-quotes-funding.js","names":[],"sources":["../../src/quotes/use-quotes-funding.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteFundingQueryOptions,\n type ConfigParameter,\n type GetQuoteFundingOptions,\n type QuoteFundingData,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\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/** Minimum quote shape `useQuotesFunding` needs: just the on-chain id. */\nexport interface QuotesFundingInputQuote {\n /** On-chain quote id. Off-chain (pending) rows pass `undefined` and are skipped. */\n quoteId?: bigint;\n}\n\n/**\n * Parameters for {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions, \"quoteIds\">, ConfigParameter {\n /**\n * Quotes (or quote-id-bearing rows) to read funding for. Off-chain rows\n * (`quoteId === undefined`) are silently skipped.
|
|
1
|
+
{"version":3,"file":"use-quotes-funding.js","names":[],"sources":["../../src/quotes/use-quotes-funding.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteFundingQueryOptions,\n type ConfigParameter,\n type GetQuoteFundingOptions,\n type QuoteFundingData,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\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/** Minimum quote shape `useQuotesFunding` needs: just the on-chain id. */\nexport interface QuotesFundingInputQuote {\n /** On-chain quote id. Off-chain (pending) rows pass `undefined` and are skipped. */\n quoteId?: bigint;\n}\n\n/**\n * Parameters for {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions, \"quoteIds\">, ConfigParameter {\n /**\n * Quotes (or quote-id-bearing rows) to read funding for. Off-chain rows\n * (`quoteId === undefined`) are silently skipped. The resolved on-chain ids are\n * de-duplicated and fetched in a single subgraph round-trip, so listing the\n * same quote twice costs one request and contributes to the sums once.\n */\n quotes: readonly QuotesFundingInputQuote[];\n}\n\n/**\n * Return type of {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingReturnType {\n /**\n * Funding row per input quote, aligned 1:1 with `quotes` and in input order —\n * `rows.length === quotes.length` on every path, including while loading and\n * when nothing on-chain was requested. An entry is `null` for an off-chain row\n * (no `quoteId`) or for an id the subgraph has not surfaced yet.\n */\n rows: Array<QuoteFundingData | null>;\n /**\n * Σ funding paid across the resolved rows (wei). Summed over the **distinct**\n * on-chain ids, so a quote listed twice contributes once.\n */\n paid: bigint;\n /**\n * Σ funding received across the resolved rows (wei). Summed over the\n * **distinct** on-chain ids, so a quote listed twice contributes once.\n */\n received: bigint;\n /**\n * Σ `received − paid` across the resolved rows (wei). **Positive = the position\n * earned funding**; negative = it paid for it. A lower bound while\n * `missingQuoteIds` is non-empty.\n */\n netReceived: bigint;\n /**\n * Requested on-chain ids that have no funding row yet. While the query is in\n * flight — and if it fails — this is **every** requested id, since nothing has\n * resolved; once it settles it is the subset the subgraph did not return\n * (indexing lag). Always empty when no on-chain ids were requested.\n */\n missingQuoteIds: bigint[];\n /** `true` while the underlying subgraph query is loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Batch-read funding totals for a list of quotes from the analytics subgraph in\n * a single round-trip and aggregate them into running sums for the group.\n *\n * The hook is the canonical entry point for both single-quote details panels\n * ({@link useQuoteFunding} delegates here with a 1-element list) and grouped\n * quote cards (which want `Σ netReceived`). Off-chain rows are skipped silently,\n * and duplicate ids are fetched — and summed — exactly once.\n *\n * **Sign convention** — `netReceived = received − paid`, the P&L perspective, so\n * a **positive** value means the position **earned** funding. This matches\n * `QuoteFundingData.netReceived` and the uPnL folds, and is the inverse of the\n * cost-positive on-chain `int256`. A \"green = income\" UI renders it directly.\n *\n * **Settled to date only** — the totals cover funding the protocol has already\n * charged and the analytics subgraph has indexed. Funding accrued since a\n * quote's last funding charge is not indexed anywhere and is therefore not\n * included.\n *\n * @param parameters - The quotes to read funding for, plus optional chain/config overrides.\n * @returns Per-quote rows aligned with `quotes`, the aggregate sums, and query state.\n *\n * @example\n * ```tsx\n * const { rows, netReceived, missingQuoteIds, isLoading } = useQuotesFunding({ quotes: group.quotes });\n * // `netReceived > 0n` → the position earned funding across the resolved rows.\n * ```\n */\nexport function useQuotesFunding(parameters: UseQuotesFundingParameters): UseQuotesFundingReturnType {\n const { quotes, ...rest } = parameters;\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const onchainQuoteIds = useMemo(() => {\n const seen = new Set<string>();\n const ids: bigint[] = [];\n for (const quote of quotes) {\n if (quote.quoteId === undefined) continue;\n const key = quote.quoteId.toString();\n if (seen.has(key)) continue;\n seen.add(key);\n ids.push(quote.quoteId);\n }\n return ids;\n }, [quotes]);\n\n const options = getQuoteFundingQueryOptions(config, {\n ...rest,\n chainId: rest.chainId ?? chainId,\n quoteIds: onchainQuoteIds,\n });\n\n const query = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<{ rows: QuoteFundingData[]; missingQuoteIds: bigint[] }, SymmioRequestError>;\n\n return useMemo(() => {\n /** Nothing on-chain to read: the query is disabled, but `rows` still owes one entry per input quote. */\n if (onchainQuoteIds.length === 0) {\n return {\n rows: quotes.map(() => null),\n paid: 0n,\n received: 0n,\n netReceived: 0n,\n missingQuoteIds: [],\n isLoading: false,\n error: null,\n };\n }\n\n const data = query.data;\n if (!data) {\n return {\n rows: quotes.map(() => null),\n paid: 0n,\n received: 0n,\n netReceived: 0n,\n /** In flight (or failed): nothing resolved, so every requested id is still outstanding. */\n missingQuoteIds: [...onchainQuoteIds],\n isLoading: query.isLoading,\n error: query.error ?? null,\n };\n }\n\n /** First row wins per id — a repeated row for the same quote must not double-count. */\n const byQuoteId = new Map<string, QuoteFundingData>();\n for (const row of data.rows) {\n const key = row.quoteId.toString();\n if (!byQuoteId.has(key)) byQuoteId.set(key, row);\n }\n\n let paid = 0n;\n let received = 0n;\n /** Fold over the de-duped ids, never over `quotes` — the same id listed twice is fetched once and must sum once. */\n for (const quoteId of onchainQuoteIds) {\n const row = byQuoteId.get(quoteId.toString());\n if (row === undefined) continue;\n paid += row.paid;\n received += row.received;\n }\n\n /** Built by lookup afterwards, so the 1:1 alignment with `quotes` is independent of the fold. */\n const rows = quotes.map((quote) =>\n quote.quoteId === undefined ? null : (byQuoteId.get(quote.quoteId.toString()) ?? null),\n );\n\n return {\n rows,\n paid,\n received,\n /** Derived from the sums so the aggregate keeps the row-level `netReceived = received − paid` invariant. */\n netReceived: received - paid,\n missingQuoteIds: data.missingQuoteIds,\n isLoading: query.isLoading,\n error: query.error ?? null,\n };\n }, [onchainQuoteIds, quotes, query.data, query.isLoading, query.error]);\n}\n"],"mappings":";;;;;;;;AAsGA,SAAgB,EAAiB,GAAoE;CACnG,IAAM,EAAE,WAAQ,GAAG,MAAS,GACtB,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAkB,QAAc;EACpC,IAAM,oBAAO,IAAI,IAAY,GACvB,IAAgB,CAAC;EACvB,KAAK,IAAM,KAAS,GAAQ;GAC1B,IAAI,EAAM,YAAY,KAAA,GAAW;GACjC,IAAM,IAAM,EAAM,QAAQ,SAAS;GAC/B,EAAK,IAAI,CAAG,MAChB,EAAK,IAAI,CAAG,GACZ,EAAI,KAAK,EAAM,OAAO;EACxB;EACA,OAAO;CACT,GAAG,CAAC,CAAM,CAAC,GAEL,IAAU,EAA4B,GAAQ;EAClD,GAAG;EACH,SAAS,EAAK,WAAW;EACzB,UAAU;CACZ,CAAC,GAEK,IAAQ,EAAS;EACrB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAED,OAAO,QAAc;EAEnB,IAAI,EAAgB,WAAW,GAC7B,OAAO;GACL,MAAM,EAAO,UAAU,IAAI;GAC3B,MAAM;GACN,UAAU;GACV,aAAa;GACb,iBAAiB,CAAC;GAClB,WAAW;GACX,OAAO;EACT;EAGF,IAAM,IAAO,EAAM;EACnB,IAAI,CAAC,GACH,OAAO;GACL,MAAM,EAAO,UAAU,IAAI;GAC3B,MAAM;GACN,UAAU;GACV,aAAa;GAEb,iBAAiB,CAAC,GAAG,CAAe;GACpC,WAAW,EAAM;GACjB,OAAO,EAAM,SAAS;EACxB;EAIF,IAAM,oBAAY,IAAI,IAA8B;EACpD,KAAK,IAAM,KAAO,EAAK,MAAM;GAC3B,IAAM,IAAM,EAAI,QAAQ,SAAS;GACjC,AAAK,EAAU,IAAI,CAAG,KAAG,EAAU,IAAI,GAAK,CAAG;EACjD;EAEA,IAAI,IAAO,IACP,IAAW;EAEf,KAAK,IAAM,KAAW,GAAiB;GACrC,IAAM,IAAM,EAAU,IAAI,EAAQ,SAAS,CAAC;GACxC,MAAQ,KAAA,MACZ,KAAQ,EAAI,MACZ,KAAY,EAAI;EAClB;EAOA,OAAO;GACL,MALW,EAAO,KAAK,MACvB,EAAM,YAAY,KAAA,IAAY,OAAQ,EAAU,IAAI,EAAM,QAAQ,SAAS,CAAC,KAAK,IAIjF;GACA;GACA;GAEA,aAAa,IAAW;GACxB,iBAAiB,EAAK;GACtB,WAAW,EAAM;GACjB,OAAO,EAAM,SAAS;EACxB;CACF,GAAG;EAAC;EAAiB;EAAQ,EAAM;EAAM,EAAM;EAAW,EAAM;CAAK,CAAC;AACxE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RequestToCancelCloseRequestParameters } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
|
+
/** Parameters for {@link useRequestToCancelCloseRequest}. */
|
|
6
|
+
export type UseRequestToCancelCloseRequestParameters = WriteParameters;
|
|
7
|
+
/** Result returned by the {@link useRequestToCancelCloseRequest} mutation. */
|
|
8
|
+
export type RequestToCancelCloseRequestResult = WriteResult;
|
|
9
|
+
/** Return type of {@link useRequestToCancelCloseRequest}. */
|
|
10
|
+
export type UseRequestToCancelCloseRequestReturnType = UseMutationResult<RequestToCancelCloseRequestResult, SymmioRequestError, RequestToCancelCloseRequestParameters>;
|
|
11
|
+
/**
|
|
12
|
+
* Cancel a pending close (`requestToCancelCloseRequest`, routed through the
|
|
13
|
+
* AccountLayer `_call` proxy) — how a partyA backs out of a resting close (e.g.
|
|
14
|
+
* a limit close) while the quote is `CLOSE_PENDING`. If partyB accepts, the quote
|
|
15
|
+
* returns to `OPENED`; if partyB stalls it enters `CANCEL_CLOSE_PENDING`, which
|
|
16
|
+
* {@link useForceCancelCloseRequest} escalates once the cooldown passes. On
|
|
17
|
+
* success (after the receipt) the subaccount's open-positions read is invalidated
|
|
18
|
+
* so the row's status refreshes.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const { mutate } = useRequestToCancelCloseRequest();
|
|
23
|
+
* mutate({ account: "0xsub…", quoteId: 42n });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useRequestToCancelCloseRequest(parameters?: UseRequestToCancelCloseRequestParameters): UseRequestToCancelCloseRequestReturnType;
|
|
27
|
+
//# sourceMappingURL=use-request-to-cancel-close-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-request-to-cancel-close-request.d.ts","sourceRoot":"","sources":["../../src/quotes/use-request-to-cancel-close-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,qCAAqC,EAC3C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F,6DAA6D;AAC7D,MAAM,MAAM,wCAAwC,GAAG,eAAe,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,MAAM,iCAAiC,GAAG,WAAW,CAAC;AAE5D,6DAA6D;AAC7D,MAAM,MAAM,wCAAwC,GAAG,iBAAiB,CACtE,iCAAiC,EACjC,kBAAkB,EAClB,qCAAqC,CACtC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,GAAE,wCAA6C,GACxD,wCAAwC,CAmC1C"}
|