@lifi/perps-sdk-provider-hyperliquid 0.2.0-alpha.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/LICENSE +201 -0
- package/README.md +174 -0
- package/dist/cjs/HyperliquidProvider.d.ts +15 -0
- package/dist/cjs/HyperliquidProvider.d.ts.map +1 -0
- package/dist/cjs/HyperliquidProvider.js +135 -0
- package/dist/cjs/HyperliquidProvider.js.map +1 -0
- package/dist/cjs/accountConfig.d.ts +3 -0
- package/dist/cjs/accountConfig.d.ts.map +1 -0
- package/dist/cjs/accountConfig.js +45 -0
- package/dist/cjs/accountConfig.js.map +1 -0
- package/dist/cjs/accountSummary.d.ts +3 -0
- package/dist/cjs/accountSummary.d.ts.map +1 -0
- package/dist/cjs/accountSummary.js +12 -0
- package/dist/cjs/accountSummary.js.map +1 -0
- package/dist/cjs/constants.d.ts +11 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +16 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/context.d.ts +13 -0
- package/dist/cjs/context.d.ts.map +1 -0
- package/dist/cjs/context.js +24 -0
- package/dist/cjs/context.js.map +1 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/services/getAccount.d.ts +6 -0
- package/dist/cjs/services/getAccount.d.ts.map +1 -0
- package/dist/cjs/services/getAccount.js +109 -0
- package/dist/cjs/services/getAccount.js.map +1 -0
- package/dist/cjs/services/getActivity.d.ts +15 -0
- package/dist/cjs/services/getActivity.d.ts.map +1 -0
- package/dist/cjs/services/getActivity.js +65 -0
- package/dist/cjs/services/getActivity.js.map +1 -0
- package/dist/cjs/services/getFills.d.ts +13 -0
- package/dist/cjs/services/getFills.d.ts.map +1 -0
- package/dist/cjs/services/getFills.js +40 -0
- package/dist/cjs/services/getFills.js.map +1 -0
- package/dist/cjs/services/getOrder.d.ts +6 -0
- package/dist/cjs/services/getOrder.d.ts.map +1 -0
- package/dist/cjs/services/getOrder.js +27 -0
- package/dist/cjs/services/getOrder.js.map +1 -0
- package/dist/cjs/services/getOrders.d.ts +11 -0
- package/dist/cjs/services/getOrders.d.ts.map +1 -0
- package/dist/cjs/services/getOrders.js +51 -0
- package/dist/cjs/services/getOrders.js.map +1 -0
- package/dist/cjs/services/getPositions.d.ts +11 -0
- package/dist/cjs/services/getPositions.d.ts.map +1 -0
- package/dist/cjs/services/getPositions.js +33 -0
- package/dist/cjs/services/getPositions.js.map +1 -0
- package/dist/cjs/signers/HyperliquidAgentStore.d.ts +19 -0
- package/dist/cjs/signers/HyperliquidAgentStore.d.ts.map +1 -0
- package/dist/cjs/signers/HyperliquidAgentStore.js +110 -0
- package/dist/cjs/signers/HyperliquidAgentStore.js.map +1 -0
- package/dist/cjs/signers/index.d.ts +4 -0
- package/dist/cjs/signers/index.d.ts.map +1 -0
- package/dist/cjs/signers/index.js +8 -0
- package/dist/cjs/signers/index.js.map +1 -0
- package/dist/cjs/signers/signActions.d.ts +7 -0
- package/dist/cjs/signers/signActions.d.ts.map +1 -0
- package/dist/cjs/signers/signActions.js +33 -0
- package/dist/cjs/signers/signActions.js.map +1 -0
- package/dist/cjs/types/account.d.ts +51 -0
- package/dist/cjs/types/account.d.ts.map +1 -0
- package/dist/cjs/types/account.js +10 -0
- package/dist/cjs/types/account.js.map +1 -0
- package/dist/cjs/types/action.d.ts +51 -0
- package/dist/cjs/types/action.d.ts.map +1 -0
- package/dist/cjs/types/action.js +11 -0
- package/dist/cjs/types/action.js.map +1 -0
- package/dist/cjs/types/asset.d.ts +66 -0
- package/dist/cjs/types/asset.d.ts.map +1 -0
- package/dist/cjs/types/asset.js +3 -0
- package/dist/cjs/types/asset.js.map +1 -0
- package/dist/cjs/types/fill.d.ts +18 -0
- package/dist/cjs/types/fill.d.ts.map +1 -0
- package/dist/cjs/types/fill.js +3 -0
- package/dist/cjs/types/fill.js.map +1 -0
- package/dist/cjs/types/index.d.ts +8 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +24 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/ledger.d.ts +53 -0
- package/dist/cjs/types/ledger.d.ts.map +1 -0
- package/dist/cjs/types/ledger.js +8 -0
- package/dist/cjs/types/ledger.js.map +1 -0
- package/dist/cjs/types/order.d.ts +46 -0
- package/dist/cjs/types/order.d.ts.map +1 -0
- package/dist/cjs/types/order.js +3 -0
- package/dist/cjs/types/order.js.map +1 -0
- package/dist/cjs/types/ws.d.ts +36 -0
- package/dist/cjs/types/ws.d.ts.map +1 -0
- package/dist/cjs/types/ws.js +3 -0
- package/dist/cjs/types/ws.js.map +1 -0
- package/dist/cjs/utils/assetId.d.ts +4 -0
- package/dist/cjs/utils/assetId.d.ts.map +1 -0
- package/dist/cjs/utils/assetId.js +21 -0
- package/dist/cjs/utils/assetId.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +15 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +49 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/infoClient.d.ts +10 -0
- package/dist/cjs/utils/infoClient.d.ts.map +1 -0
- package/dist/cjs/utils/infoClient.js +58 -0
- package/dist/cjs/utils/infoClient.js.map +1 -0
- package/dist/cjs/utils/liquidation.d.ts +3 -0
- package/dist/cjs/utils/liquidation.d.ts.map +1 -0
- package/dist/cjs/utils/liquidation.js +24 -0
- package/dist/cjs/utils/liquidation.js.map +1 -0
- package/dist/cjs/utils/mapActivity.d.ts +5 -0
- package/dist/cjs/utils/mapActivity.d.ts.map +1 -0
- package/dist/cjs/utils/mapActivity.js +133 -0
- package/dist/cjs/utils/mapActivity.js.map +1 -0
- package/dist/cjs/utils/mapFill.d.ts +6 -0
- package/dist/cjs/utils/mapFill.d.ts.map +1 -0
- package/dist/cjs/utils/mapFill.js +33 -0
- package/dist/cjs/utils/mapFill.js.map +1 -0
- package/dist/cjs/utils/mapMarket.d.ts +4 -0
- package/dist/cjs/utils/mapMarket.d.ts.map +1 -0
- package/dist/cjs/utils/mapMarket.js +22 -0
- package/dist/cjs/utils/mapMarket.js.map +1 -0
- package/dist/cjs/utils/mapMarketPrice.d.ts +4 -0
- package/dist/cjs/utils/mapMarketPrice.d.ts.map +1 -0
- package/dist/cjs/utils/mapMarketPrice.js +22 -0
- package/dist/cjs/utils/mapMarketPrice.js.map +1 -0
- package/dist/cjs/utils/mapOrder.d.ts +12 -0
- package/dist/cjs/utils/mapOrder.d.ts.map +1 -0
- package/dist/cjs/utils/mapOrder.js +156 -0
- package/dist/cjs/utils/mapOrder.js.map +1 -0
- package/dist/cjs/utils/mapPosition.d.ts +5 -0
- package/dist/cjs/utils/mapPosition.d.ts.map +1 -0
- package/dist/cjs/utils/mapPosition.js +28 -0
- package/dist/cjs/utils/mapPosition.js.map +1 -0
- package/dist/cjs/utils/marketDisplay.d.ts +4 -0
- package/dist/cjs/utils/marketDisplay.d.ts.map +1 -0
- package/dist/cjs/utils/marketDisplay.js +23 -0
- package/dist/cjs/utils/marketDisplay.js.map +1 -0
- package/dist/cjs/utils/orderFormatting.d.ts +4 -0
- package/dist/cjs/utils/orderFormatting.d.ts.map +1 -0
- package/dist/cjs/utils/orderFormatting.js +30 -0
- package/dist/cjs/utils/orderFormatting.js.map +1 -0
- package/dist/cjs/utils/priceStepToAggregation.d.ts +5 -0
- package/dist/cjs/utils/priceStepToAggregation.d.ts.map +1 -0
- package/dist/cjs/utils/priceStepToAggregation.js +36 -0
- package/dist/cjs/utils/priceStepToAggregation.js.map +1 -0
- package/dist/cjs/utils/spotBalance.d.ts +6 -0
- package/dist/cjs/utils/spotBalance.d.ts.map +1 -0
- package/dist/cjs/utils/spotBalance.js +34 -0
- package/dist/cjs/utils/spotBalance.js.map +1 -0
- package/dist/cjs/websocket/HyperliquidWsProvider.d.ts +29 -0
- package/dist/cjs/websocket/HyperliquidWsProvider.d.ts.map +1 -0
- package/dist/cjs/websocket/HyperliquidWsProvider.js +359 -0
- package/dist/cjs/websocket/HyperliquidWsProvider.js.map +1 -0
- package/dist/cjs/websocket/index.d.ts +2 -0
- package/dist/cjs/websocket/index.d.ts.map +1 -0
- package/dist/cjs/websocket/index.js +6 -0
- package/dist/cjs/websocket/index.js.map +1 -0
- package/dist/esm/HyperliquidProvider.d.ts +64 -0
- package/dist/esm/HyperliquidProvider.d.ts.map +1 -0
- package/dist/esm/HyperliquidProvider.js +162 -0
- package/dist/esm/HyperliquidProvider.js.map +1 -0
- package/dist/esm/accountConfig.d.ts +10 -0
- package/dist/esm/accountConfig.d.ts.map +1 -0
- package/dist/esm/accountConfig.js +65 -0
- package/dist/esm/accountConfig.js.map +1 -0
- package/dist/esm/accountSummary.d.ts +10 -0
- package/dist/esm/accountSummary.d.ts.map +1 -0
- package/dist/esm/accountSummary.js +22 -0
- package/dist/esm/accountSummary.js.map +1 -0
- package/dist/esm/constants.d.ts +40 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +42 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/context.d.ts +26 -0
- package/dist/esm/context.d.ts.map +1 -0
- package/dist/esm/context.js +25 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/index.d.ts +31 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/services/getAccount.d.ts +28 -0
- package/dist/esm/services/getAccount.d.ts.map +1 -0
- package/dist/esm/services/getAccount.js +134 -0
- package/dist/esm/services/getAccount.js.map +1 -0
- package/dist/esm/services/getActivity.d.ts +33 -0
- package/dist/esm/services/getActivity.d.ts.map +1 -0
- package/dist/esm/services/getActivity.js +75 -0
- package/dist/esm/services/getActivity.js.map +1 -0
- package/dist/esm/services/getFills.d.ts +34 -0
- package/dist/esm/services/getFills.d.ts.map +1 -0
- package/dist/esm/services/getFills.js +49 -0
- package/dist/esm/services/getFills.js.map +1 -0
- package/dist/esm/services/getOrder.d.ts +17 -0
- package/dist/esm/services/getOrder.d.ts.map +1 -0
- package/dist/esm/services/getOrder.js +29 -0
- package/dist/esm/services/getOrder.js.map +1 -0
- package/dist/esm/services/getOrders.d.ts +27 -0
- package/dist/esm/services/getOrders.d.ts.map +1 -0
- package/dist/esm/services/getOrders.js +57 -0
- package/dist/esm/services/getOrders.js.map +1 -0
- package/dist/esm/services/getPositions.d.ts +26 -0
- package/dist/esm/services/getPositions.d.ts.map +1 -0
- package/dist/esm/services/getPositions.js +37 -0
- package/dist/esm/services/getPositions.js.map +1 -0
- package/dist/esm/signers/HyperliquidAgentStore.d.ts +54 -0
- package/dist/esm/signers/HyperliquidAgentStore.d.ts.map +1 -0
- package/dist/esm/signers/HyperliquidAgentStore.js +134 -0
- package/dist/esm/signers/HyperliquidAgentStore.js.map +1 -0
- package/dist/esm/signers/index.d.ts +4 -0
- package/dist/esm/signers/index.d.ts.map +1 -0
- package/dist/esm/signers/index.js +4 -0
- package/dist/esm/signers/index.js.map +1 -0
- package/dist/esm/signers/signActions.d.ts +15 -0
- package/dist/esm/signers/signActions.d.ts.map +1 -0
- package/dist/esm/signers/signActions.js +38 -0
- package/dist/esm/signers/signActions.js.map +1 -0
- package/dist/esm/types/account.d.ts +64 -0
- package/dist/esm/types/account.d.ts.map +1 -0
- package/dist/esm/types/account.js +13 -0
- package/dist/esm/types/account.js.map +1 -0
- package/dist/esm/types/action.d.ts +61 -0
- package/dist/esm/types/action.d.ts.map +1 -0
- package/dist/esm/types/action.js +16 -0
- package/dist/esm/types/action.js.map +1 -0
- package/dist/esm/types/asset.d.ts +82 -0
- package/dist/esm/types/asset.d.ts.map +1 -0
- package/dist/esm/types/asset.js +3 -0
- package/dist/esm/types/asset.js.map +1 -0
- package/dist/esm/types/fill.d.ts +21 -0
- package/dist/esm/types/fill.d.ts.map +1 -0
- package/dist/esm/types/fill.js +3 -0
- package/dist/esm/types/fill.js.map +1 -0
- package/dist/esm/types/index.d.ts +8 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/ledger.d.ts +93 -0
- package/dist/esm/types/ledger.d.ts.map +1 -0
- package/dist/esm/types/ledger.js +16 -0
- package/dist/esm/types/ledger.js.map +1 -0
- package/dist/esm/types/order.d.ts +51 -0
- package/dist/esm/types/order.d.ts.map +1 -0
- package/dist/esm/types/order.js +3 -0
- package/dist/esm/types/order.js.map +1 -0
- package/dist/esm/types/ws.d.ts +43 -0
- package/dist/esm/types/ws.d.ts.map +1 -0
- package/dist/esm/types/ws.js +3 -0
- package/dist/esm/types/ws.js.map +1 -0
- package/dist/esm/utils/assetId.d.ts +20 -0
- package/dist/esm/utils/assetId.d.ts.map +1 -0
- package/dist/esm/utils/assetId.js +31 -0
- package/dist/esm/utils/assetId.js.map +1 -0
- package/dist/esm/utils/index.d.ts +15 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +17 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/infoClient.d.ts +28 -0
- package/dist/esm/utils/infoClient.d.ts.map +1 -0
- package/dist/esm/utils/infoClient.js +70 -0
- package/dist/esm/utils/infoClient.js.map +1 -0
- package/dist/esm/utils/liquidation.d.ts +48 -0
- package/dist/esm/utils/liquidation.d.ts.map +1 -0
- package/dist/esm/utils/liquidation.js +65 -0
- package/dist/esm/utils/liquidation.js.map +1 -0
- package/dist/esm/utils/mapActivity.d.ts +15 -0
- package/dist/esm/utils/mapActivity.d.ts.map +1 -0
- package/dist/esm/utils/mapActivity.js +148 -0
- package/dist/esm/utils/mapActivity.js.map +1 -0
- package/dist/esm/utils/mapFill.d.ts +11 -0
- package/dist/esm/utils/mapFill.d.ts.map +1 -0
- package/dist/esm/utils/mapFill.js +34 -0
- package/dist/esm/utils/mapFill.js.map +1 -0
- package/dist/esm/utils/mapMarket.d.ts +12 -0
- package/dist/esm/utils/mapMarket.d.ts.map +1 -0
- package/dist/esm/utils/mapMarket.js +27 -0
- package/dist/esm/utils/mapMarket.js.map +1 -0
- package/dist/esm/utils/mapMarketPrice.d.ts +10 -0
- package/dist/esm/utils/mapMarketPrice.d.ts.map +1 -0
- package/dist/esm/utils/mapMarketPrice.js +24 -0
- package/dist/esm/utils/mapMarketPrice.js.map +1 -0
- package/dist/esm/utils/mapOrder.d.ts +49 -0
- package/dist/esm/utils/mapOrder.d.ts.map +1 -0
- package/dist/esm/utils/mapOrder.js +182 -0
- package/dist/esm/utils/mapOrder.js.map +1 -0
- package/dist/esm/utils/mapPosition.d.ts +12 -0
- package/dist/esm/utils/mapPosition.d.ts.map +1 -0
- package/dist/esm/utils/mapPosition.js +30 -0
- package/dist/esm/utils/mapPosition.js.map +1 -0
- package/dist/esm/utils/marketDisplay.d.ts +17 -0
- package/dist/esm/utils/marketDisplay.d.ts.map +1 -0
- package/dist/esm/utils/marketDisplay.js +31 -0
- package/dist/esm/utils/marketDisplay.js.map +1 -0
- package/dist/esm/utils/orderFormatting.d.ts +50 -0
- package/dist/esm/utils/orderFormatting.d.ts.map +1 -0
- package/dist/esm/utils/orderFormatting.js +78 -0
- package/dist/esm/utils/orderFormatting.js.map +1 -0
- package/dist/esm/utils/priceStepToAggregation.d.ts +20 -0
- package/dist/esm/utils/priceStepToAggregation.d.ts.map +1 -0
- package/dist/esm/utils/priceStepToAggregation.js +51 -0
- package/dist/esm/utils/priceStepToAggregation.js.map +1 -0
- package/dist/esm/utils/spotBalance.d.ts +18 -0
- package/dist/esm/utils/spotBalance.d.ts.map +1 -0
- package/dist/esm/utils/spotBalance.js +40 -0
- package/dist/esm/utils/spotBalance.js.map +1 -0
- package/dist/esm/websocket/HyperliquidWsProvider.d.ts +61 -0
- package/dist/esm/websocket/HyperliquidWsProvider.d.ts.map +1 -0
- package/dist/esm/websocket/HyperliquidWsProvider.js +406 -0
- package/dist/esm/websocket/HyperliquidWsProvider.js.map +1 -0
- package/dist/esm/websocket/index.d.ts +2 -0
- package/dist/esm/websocket/index.d.ts.map +1 -0
- package/dist/esm/websocket/index.js +3 -0
- package/dist/esm/websocket/index.js.map +1 -0
- package/dist/types/HyperliquidProvider.d.ts +64 -0
- package/dist/types/HyperliquidProvider.d.ts.map +1 -0
- package/dist/types/accountConfig.d.ts +10 -0
- package/dist/types/accountConfig.d.ts.map +1 -0
- package/dist/types/accountSummary.d.ts +10 -0
- package/dist/types/accountSummary.d.ts.map +1 -0
- package/dist/types/constants.d.ts +40 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/context.d.ts +26 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/services/getAccount.d.ts +28 -0
- package/dist/types/services/getAccount.d.ts.map +1 -0
- package/dist/types/services/getActivity.d.ts +33 -0
- package/dist/types/services/getActivity.d.ts.map +1 -0
- package/dist/types/services/getFills.d.ts +34 -0
- package/dist/types/services/getFills.d.ts.map +1 -0
- package/dist/types/services/getOrder.d.ts +17 -0
- package/dist/types/services/getOrder.d.ts.map +1 -0
- package/dist/types/services/getOrders.d.ts +27 -0
- package/dist/types/services/getOrders.d.ts.map +1 -0
- package/dist/types/services/getPositions.d.ts +26 -0
- package/dist/types/services/getPositions.d.ts.map +1 -0
- package/dist/types/signers/HyperliquidAgentStore.d.ts +54 -0
- package/dist/types/signers/HyperliquidAgentStore.d.ts.map +1 -0
- package/dist/types/signers/index.d.ts +4 -0
- package/dist/types/signers/index.d.ts.map +1 -0
- package/dist/types/signers/signActions.d.ts +15 -0
- package/dist/types/signers/signActions.d.ts.map +1 -0
- package/dist/types/types/account.d.ts +64 -0
- package/dist/types/types/account.d.ts.map +1 -0
- package/dist/types/types/action.d.ts +61 -0
- package/dist/types/types/action.d.ts.map +1 -0
- package/dist/types/types/asset.d.ts +82 -0
- package/dist/types/types/asset.d.ts.map +1 -0
- package/dist/types/types/fill.d.ts +21 -0
- package/dist/types/types/fill.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/ledger.d.ts +93 -0
- package/dist/types/types/ledger.d.ts.map +1 -0
- package/dist/types/types/order.d.ts +51 -0
- package/dist/types/types/order.d.ts.map +1 -0
- package/dist/types/types/ws.d.ts +43 -0
- package/dist/types/types/ws.d.ts.map +1 -0
- package/dist/types/utils/assetId.d.ts +20 -0
- package/dist/types/utils/assetId.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +15 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/infoClient.d.ts +28 -0
- package/dist/types/utils/infoClient.d.ts.map +1 -0
- package/dist/types/utils/liquidation.d.ts +48 -0
- package/dist/types/utils/liquidation.d.ts.map +1 -0
- package/dist/types/utils/mapActivity.d.ts +15 -0
- package/dist/types/utils/mapActivity.d.ts.map +1 -0
- package/dist/types/utils/mapFill.d.ts +11 -0
- package/dist/types/utils/mapFill.d.ts.map +1 -0
- package/dist/types/utils/mapMarket.d.ts +12 -0
- package/dist/types/utils/mapMarket.d.ts.map +1 -0
- package/dist/types/utils/mapMarketPrice.d.ts +10 -0
- package/dist/types/utils/mapMarketPrice.d.ts.map +1 -0
- package/dist/types/utils/mapOrder.d.ts +49 -0
- package/dist/types/utils/mapOrder.d.ts.map +1 -0
- package/dist/types/utils/mapPosition.d.ts +12 -0
- package/dist/types/utils/mapPosition.d.ts.map +1 -0
- package/dist/types/utils/marketDisplay.d.ts +17 -0
- package/dist/types/utils/marketDisplay.d.ts.map +1 -0
- package/dist/types/utils/orderFormatting.d.ts +50 -0
- package/dist/types/utils/orderFormatting.d.ts.map +1 -0
- package/dist/types/utils/priceStepToAggregation.d.ts +20 -0
- package/dist/types/utils/priceStepToAggregation.d.ts.map +1 -0
- package/dist/types/utils/spotBalance.d.ts +18 -0
- package/dist/types/utils/spotBalance.d.ts.map +1 -0
- package/dist/types/websocket/HyperliquidWsProvider.d.ts +61 -0
- package/dist/types/websocket/HyperliquidWsProvider.d.ts.map +1 -0
- package/dist/types/websocket/index.d.ts +2 -0
- package/dist/types/websocket/index.d.ts.map +1 -0
- package/package.json +73 -0
- package/src/HyperliquidProvider.ts +381 -0
- package/src/accountConfig.ts +89 -0
- package/src/accountSummary.ts +32 -0
- package/src/constants.ts +47 -0
- package/src/context.ts +41 -0
- package/src/index.ts +45 -0
- package/src/services/getAccount.ts +263 -0
- package/src/services/getActivity.ts +162 -0
- package/src/services/getFills.ts +96 -0
- package/src/services/getOrder.ts +61 -0
- package/src/services/getOrders.ts +101 -0
- package/src/services/getPositions.ts +76 -0
- package/src/signers/HyperliquidAgentStore.ts +176 -0
- package/src/signers/index.ts +5 -0
- package/src/signers/signActions.ts +78 -0
- package/src/types/account.ts +74 -0
- package/src/types/action.ts +66 -0
- package/src/types/asset.ts +96 -0
- package/src/types/fill.ts +24 -0
- package/src/types/index.ts +11 -0
- package/src/types/ledger.ts +111 -0
- package/src/types/order.ts +56 -0
- package/src/types/ws.ts +47 -0
- package/src/utils/assetId.ts +38 -0
- package/src/utils/index.ts +38 -0
- package/src/utils/infoClient.ts +111 -0
- package/src/utils/liquidation.ts +74 -0
- package/src/utils/mapActivity.ts +182 -0
- package/src/utils/mapFill.ts +48 -0
- package/src/utils/mapMarket.ts +33 -0
- package/src/utils/mapMarketPrice.ts +33 -0
- package/src/utils/mapOrder.ts +218 -0
- package/src/utils/mapPosition.ts +40 -0
- package/src/utils/marketDisplay.ts +38 -0
- package/src/utils/orderFormatting.ts +93 -0
- package/src/utils/priceStepToAggregation.ts +58 -0
- package/src/utils/spotBalance.ts +51 -0
- package/src/websocket/HyperliquidWsProvider.ts +533 -0
- package/src/websocket/index.ts +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright LI.FI
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# `@lifi/perps-sdk-provider-hyperliquid`
|
|
2
|
+
|
|
3
|
+
Hyperliquid provider plugin for the [LI.FI Perps SDK](../../README.md).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @lifi/perps-sdk @lifi/perps-sdk-provider-hyperliquid
|
|
9
|
+
# or
|
|
10
|
+
npm install @lifi/perps-sdk @lifi/perps-sdk-provider-hyperliquid
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Registration
|
|
14
|
+
|
|
15
|
+
Pass `hyperliquidProvider()` to `createPerpsClient` (or `PerpsClient`):
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createPerpsClient } from '@lifi/perps-sdk'
|
|
19
|
+
import { hyperliquidProvider } from '@lifi/perps-sdk-provider-hyperliquid'
|
|
20
|
+
|
|
21
|
+
const client = createPerpsClient({
|
|
22
|
+
integrator: 'my-app',
|
|
23
|
+
apiKey: 'your-api-key',
|
|
24
|
+
providers: [hyperliquidProvider()],
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Agent keypair concept
|
|
29
|
+
|
|
30
|
+
Hyperliquid requires every trading action to be signed by a designated **agent wallet** — a fresh EVM keypair the user authorises once. The provider generates this keypair client-side, stores it locally via `HyperliquidAgentStore`, and presents only its address to the backend during setup. The user's own wallet signs a single `APPROVE_AGENT` EIP-712 message; from that point all orders sign with the agent key with no further wallet prompts.
|
|
31
|
+
|
|
32
|
+
The agent private key never leaves the client and is never sent to the LI.FI backend. It is a session-level signing credential, not a custody key — the user's funds always remain under their L1 address.
|
|
33
|
+
|
|
34
|
+
## Setup flow
|
|
35
|
+
|
|
36
|
+
Call `checkSetup` before trading. It reports any unsatisfied setup steps and an `isReady` flag. For a fresh address the only required step is `APPROVE_AGENT`, which is signed by the user's wallet (`PerpsSigner.USER`). After that step is executed, all subsequent orders sign automatically with the agent key (`PerpsSigner.AGENT`) and require no wallet interaction.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { PerpsClient } from '@lifi/perps-sdk'
|
|
40
|
+
import { hyperliquidProvider } from '@lifi/perps-sdk-provider-hyperliquid'
|
|
41
|
+
import type { Account, Chain, Transport, WalletClient } from 'viem'
|
|
42
|
+
|
|
43
|
+
const perps = new PerpsClient({
|
|
44
|
+
integrator: 'my-app',
|
|
45
|
+
apiKey: 'your-api-key',
|
|
46
|
+
providers: [hyperliquidProvider()],
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// Provide the user's wallet for the one USER-signed step.
|
|
50
|
+
perps.setUserWallet(walletClient)
|
|
51
|
+
|
|
52
|
+
const setup = await perps.checkSetup({ provider: 'hyperliquid', address })
|
|
53
|
+
|
|
54
|
+
if (!setup.isReady) {
|
|
55
|
+
const signedActions = await Promise.all(
|
|
56
|
+
setup.setup.map((step) =>
|
|
57
|
+
perps.signProviderSetupAction('hyperliquid', address, step)
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
await perps.executeProviderSetup({
|
|
61
|
+
provider: 'hyperliquid',
|
|
62
|
+
address,
|
|
63
|
+
setup: setup.setup,
|
|
64
|
+
signedActions,
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// All orders now sign with the agent key automatically.
|
|
69
|
+
await perps.placeOrder({ provider: 'hyperliquid', address, ... })
|
|
70
|
+
|
|
71
|
+
declare const walletClient: WalletClient<Transport, Chain, Account>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
See [`examples/agent-trading.ts`](../../examples/agent-trading.ts) for the full flow, including market resolution and order placement.
|
|
75
|
+
|
|
76
|
+
### Sequence diagram
|
|
77
|
+
|
|
78
|
+
```mermaid
|
|
79
|
+
sequenceDiagram
|
|
80
|
+
participant App
|
|
81
|
+
participant PC as PerpsClient
|
|
82
|
+
participant AS as HyperliquidAgentStore
|
|
83
|
+
participant W as User wallet
|
|
84
|
+
participant BE as LI.FI backend
|
|
85
|
+
Note over App,BE: one-time setup
|
|
86
|
+
App->>PC: checkSetup(address)
|
|
87
|
+
PC->>AS: getOrCreate(address)
|
|
88
|
+
AS-->>PC: agent keypair (storage)
|
|
89
|
+
PC->>BE: createAction(APPROVE_AGENT)
|
|
90
|
+
BE-->>PC: EIP-712 typed data
|
|
91
|
+
PC->>W: user signs once
|
|
92
|
+
PC->>BE: executeAction(signed)
|
|
93
|
+
Note over App,BE: steady state — every order
|
|
94
|
+
App->>PC: placeOrder(...)
|
|
95
|
+
PC->>PC: sign with agent key (no wallet popup)
|
|
96
|
+
PC->>BE: createAction → executeAction
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Storage
|
|
100
|
+
|
|
101
|
+
By default the agent keypair is persisted in browser `localStorage` under the key:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
lifi-perps-agent:<userAddress (lowercased)>:hyperliquid
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
If storage is cleared or the app moves to a new browser or device, the keypair is gone and `checkSetup` will report setup as required again. Re-running the setup flow issues a new keypair and `APPROVE_AGENT` signature — no funds are at risk; the previous agent key simply loses its authorisation.
|
|
108
|
+
|
|
109
|
+
To use a different storage backend (SSR, encrypted storage, in-memory testing), pass a custom [`StorageAdapter`](../../examples/custom-storage.ts) to `hyperliquidProvider`:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
hyperliquidProvider({
|
|
113
|
+
storage: {
|
|
114
|
+
get: async (key) => myStore.get(key) ?? null,
|
|
115
|
+
set: async (key, value) => { myStore.set(key, value) },
|
|
116
|
+
remove: async (key) => { myStore.delete(key) },
|
|
117
|
+
},
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
See [`examples/custom-storage.ts`](../../examples/custom-storage.ts) for a complete example.
|
|
122
|
+
|
|
123
|
+
## Signing
|
|
124
|
+
|
|
125
|
+
| Action class | Signed by | Examples |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| Trading actions (orders, cancels, leverage) | `PerpsSigner.AGENT` — agent key, no wallet prompt | `placeOrder`, `cancelOrders`, `updateLeverage` |
|
|
128
|
+
| Setup / account actions | `PerpsSigner.USER` — user wallet | `APPROVE_AGENT`, withdrawals |
|
|
129
|
+
|
|
130
|
+
The provider handles signer dispatch internally. Applications do not call signing functions directly.
|
|
131
|
+
|
|
132
|
+
## Agent expiry
|
|
133
|
+
|
|
134
|
+
Hyperliquid agents carry an optional TTL (`agentTtlMs` on `ApproveAgentParams`). When an agent expires, the provider's signing will fail and `checkSetup` will report setup as required for that address again. Completing the setup flow issues and approves a new agent keypair. No funds are affected; only trading authorisation lapses.
|
|
135
|
+
|
|
136
|
+
## Exported surface
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import {
|
|
140
|
+
// Factory and provider types
|
|
141
|
+
hyperliquidProvider, // (): HyperliquidPerpsProvider
|
|
142
|
+
type HyperliquidPerpsProvider, // extends PerpsProviderPlugin; agent lifecycle methods
|
|
143
|
+
type HyperliquidProviderOptions,
|
|
144
|
+
|
|
145
|
+
// Agent store (direct use is optional — the provider manages it automatically)
|
|
146
|
+
HyperliquidAgentStore,
|
|
147
|
+
type HyperliquidAgent, // { address: Address; privateKey: Hex }
|
|
148
|
+
|
|
149
|
+
// WebSocket provider
|
|
150
|
+
HyperliquidWsProvider,
|
|
151
|
+
hyperliquidWsProvider,
|
|
152
|
+
|
|
153
|
+
// Service functions (low-level, provider-agnostic callers)
|
|
154
|
+
getAccount,
|
|
155
|
+
getPositions,
|
|
156
|
+
getOrders,
|
|
157
|
+
getOrder,
|
|
158
|
+
getFills,
|
|
159
|
+
getActivity,
|
|
160
|
+
|
|
161
|
+
// Account utilities
|
|
162
|
+
projectHyperliquidConfigSettings,
|
|
163
|
+
summarizeHyperliquidAccount,
|
|
164
|
+
|
|
165
|
+
// Constants
|
|
166
|
+
DEFAULT_HYPERLIQUID_API_URL,
|
|
167
|
+
HYPERLIQUID_FEE_TIER_FALLBACK,
|
|
168
|
+
HYPERLIQUID_PROVIDER_KEY,
|
|
169
|
+
} from '@lifi/perps-sdk-provider-hyperliquid'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`HyperliquidPerpsProvider` adds three agent-lifecycle methods on top of the base `PerpsProviderPlugin` contract: `getAgentAddress`, `hasAgent`, and `removeAgent`. Use them to surface a "revoke agent" affordance or to inspect agent state; routine trading does not need them.
|
|
173
|
+
|
|
174
|
+
For the generic `create → sign → execute` action lifecycle, see the [root README](../../README.md).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PerpsProviderPlugin, type StorageAdapter } from '@lifi/perps-sdk';
|
|
2
|
+
import { type Address, type Hex } from 'viem';
|
|
3
|
+
import { type HyperliquidAgent } from './signers/HyperliquidAgentStore.js';
|
|
4
|
+
export interface HyperliquidProviderOptions {
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
storage?: StorageAdapter;
|
|
7
|
+
}
|
|
8
|
+
export interface HyperliquidPerpsProvider extends PerpsProviderPlugin {
|
|
9
|
+
getAgentAddress(address: Address): Promise<Address>;
|
|
10
|
+
hasAgent(address: Address): Promise<boolean>;
|
|
11
|
+
removeAgent(address: Address): Promise<void>;
|
|
12
|
+
importAgent(address: Address, privateKey: Hex): Promise<HyperliquidAgent>;
|
|
13
|
+
}
|
|
14
|
+
export declare function hyperliquidProvider(options?: HyperliquidProviderOptions): HyperliquidPerpsProvider;
|
|
15
|
+
//# sourceMappingURL=HyperliquidProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HyperliquidProvider.d.ts","sourceRoot":"","sources":["../../src/HyperliquidProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,mBAAmB,EAYxB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAA;AAuBxB,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAa,MAAM,MAAM,CAAA;AAgBxD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,oCAAoC,CAAA;AAY3C,MAAM,WAAW,0BAA0B;IAOzC,MAAM,CAAC,EAAE,MAAM,CAAA;IAMf,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAUD,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IAEnE,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEnD,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE5C,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5C,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC1E;AAuBD,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,wBAAwB,CA0P1B"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hyperliquidProvider = hyperliquidProvider;
|
|
4
|
+
const perps_sdk_1 = require("@lifi/perps-sdk");
|
|
5
|
+
const perps_types_1 = require("@lifi/perps-types");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const accountConfig_js_1 = require("./accountConfig.js");
|
|
8
|
+
const accountSummary_js_1 = require("./accountSummary.js");
|
|
9
|
+
const constants_js_1 = require("./constants.js");
|
|
10
|
+
const context_js_1 = require("./context.js");
|
|
11
|
+
const getAccount_js_1 = require("./services/getAccount.js");
|
|
12
|
+
const getActivity_js_1 = require("./services/getActivity.js");
|
|
13
|
+
const getFills_js_1 = require("./services/getFills.js");
|
|
14
|
+
const getOrder_js_1 = require("./services/getOrder.js");
|
|
15
|
+
const getOrders_js_1 = require("./services/getOrders.js");
|
|
16
|
+
const getPositions_js_1 = require("./services/getPositions.js");
|
|
17
|
+
const HyperliquidAgentStore_js_1 = require("./signers/HyperliquidAgentStore.js");
|
|
18
|
+
const signActions_js_1 = require("./signers/signActions.js");
|
|
19
|
+
const infoClient_js_1 = require("./utils/infoClient.js");
|
|
20
|
+
const liquidation_js_1 = require("./utils/liquidation.js");
|
|
21
|
+
const orderFormatting_js_1 = require("./utils/orderFormatting.js");
|
|
22
|
+
function hyperliquidProvider(options = {}) {
|
|
23
|
+
const apiUrl = options.apiUrl ?? constants_js_1.DEFAULT_HYPERLIQUID_API_URL;
|
|
24
|
+
const agentStore = new HyperliquidAgentStore_js_1.HyperliquidAgentStore(options.storage);
|
|
25
|
+
const contextRef = new context_js_1.HyperliquidContextRef(apiUrl);
|
|
26
|
+
const toLowerAddress = (value) => typeof value === 'string' && (0, viem_1.isAddress)(value) ? value.toLowerCase() : null;
|
|
27
|
+
const toValidUntilMs = (value) => {
|
|
28
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === 'string') {
|
|
32
|
+
const parsed = Number(value);
|
|
33
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
const isKnownExpiredRemoteAgent = async (address, localAgentAddress) => {
|
|
38
|
+
let context = null;
|
|
39
|
+
try {
|
|
40
|
+
context = contextRef.require();
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const agents = await (0, infoClient_js_1.infoRequest)(apiUrl, { type: 'extraAgents', user: address }, (0, infoClient_js_1.hlInfoOptions)(context.client));
|
|
46
|
+
const local = localAgentAddress.toLowerCase();
|
|
47
|
+
const match = agents.find((agent) => toLowerAddress(agent.address) === local);
|
|
48
|
+
if (!match) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const validUntilMs = toValidUntilMs(match.validUntil);
|
|
52
|
+
return validUntilMs !== null && validUntilMs <= Date.now();
|
|
53
|
+
};
|
|
54
|
+
const resolveApproveAgentAddress = async (address) => {
|
|
55
|
+
try {
|
|
56
|
+
const localAgent = await agentStore.get(address);
|
|
57
|
+
try {
|
|
58
|
+
if (await isKnownExpiredRemoteAgent(address, localAgent.address)) {
|
|
59
|
+
await agentStore.remove(address);
|
|
60
|
+
return (await agentStore.getOrCreate(address)).address;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
}
|
|
65
|
+
return localAgent.address;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof perps_sdk_1.PerpsError &&
|
|
69
|
+
error.message === perps_sdk_1.PerpsErrorMessage.AgentNotFound) {
|
|
70
|
+
return (await agentStore.getOrCreate(address)).address;
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
type: constants_js_1.PROVIDER_KEY,
|
|
77
|
+
bind: (client) => contextRef.bind(client),
|
|
78
|
+
getAgentAddress: async (address) => (await agentStore.get(address)).address,
|
|
79
|
+
hasAgent: (address) => agentStore.has(address),
|
|
80
|
+
removeAgent: (address) => agentStore.remove(address),
|
|
81
|
+
importAgent: (address, privateKey) => agentStore.import(address, privateKey),
|
|
82
|
+
resolveActionRequest: async (action, address, signers) => {
|
|
83
|
+
if (action === perps_types_1.ActionType.APPROVE_AGENT) {
|
|
84
|
+
const agentAddress = await resolveApproveAgentAddress(address);
|
|
85
|
+
return { params: { agentAddress } };
|
|
86
|
+
}
|
|
87
|
+
if (signers.includes(perps_types_1.PerpsSigner.AGENT)) {
|
|
88
|
+
const agent = await agentStore.get(address);
|
|
89
|
+
return { signerAddress: agent.address };
|
|
90
|
+
}
|
|
91
|
+
return {};
|
|
92
|
+
},
|
|
93
|
+
signActions: (method, steps, address, ctx) => (0, signActions_js_1.hyperliquidSignActions)(agentStore, method, steps, address, ctx),
|
|
94
|
+
getAccount: (params, opts) => (0, getAccount_js_1.getAccount)(contextRef.require(), { address: params.address }, opts),
|
|
95
|
+
getPositions: (params, opts) => (0, getPositions_js_1.getPositions)(contextRef.require(), {
|
|
96
|
+
address: params.address,
|
|
97
|
+
marketId: params.marketId,
|
|
98
|
+
limit: params.limit,
|
|
99
|
+
}, opts),
|
|
100
|
+
getOrders: (params, opts) => (0, getOrders_js_1.getOrders)(contextRef.require(), {
|
|
101
|
+
address: params.address,
|
|
102
|
+
marketId: params.marketId,
|
|
103
|
+
limit: params.limit,
|
|
104
|
+
}, opts),
|
|
105
|
+
getOrder: (params, opts) => (0, getOrder_js_1.getOrder)(contextRef.require(), { address: params.address, id: params.id }, opts),
|
|
106
|
+
getFills: (params, opts) => (0, getFills_js_1.getFills)(contextRef.require(), {
|
|
107
|
+
address: params.address,
|
|
108
|
+
limit: params.limit,
|
|
109
|
+
cursor: params.cursor,
|
|
110
|
+
startTime: params.startTime,
|
|
111
|
+
endTime: params.endTime,
|
|
112
|
+
}, opts),
|
|
113
|
+
getActivity: (params, opts) => (0, getActivity_js_1.getActivity)(contextRef.require(), {
|
|
114
|
+
address: params.address,
|
|
115
|
+
limit: params.limit,
|
|
116
|
+
cursor: params.cursor,
|
|
117
|
+
startTime: params.startTime,
|
|
118
|
+
endTime: params.endTime,
|
|
119
|
+
type: params.type,
|
|
120
|
+
}, opts),
|
|
121
|
+
getQuote: (params, opts) => (0, perps_sdk_1.resolveQuote)(contextRef.require().client, constants_js_1.PROVIDER_KEY, params, constants_js_1.HYPERLIQUID_FEE_TIER_FALLBACK, opts),
|
|
122
|
+
getPortfolioSummary: (account, positions) => (0, accountSummary_js_1.summarizeHyperliquidAccount)(account, positions),
|
|
123
|
+
formatOrderPrice: (market, price) => (0, orderFormatting_js_1.formatOrderPrice)(price, market.szDecimals, market.categoryId === constants_js_1.SPOT_MARKET_ID ? 'spot' : undefined),
|
|
124
|
+
formatOrderSize: (market, size) => (0, orderFormatting_js_1.formatOrderSize)(size, market.szDecimals),
|
|
125
|
+
estimateLiquidationPrice: (market, params) => (0, liquidation_js_1.calculateLiquidationPrice)(params.entryPrice, params.leverage, params.isLong, market.maxLeverage),
|
|
126
|
+
projectConfig: (config, setup, options) => {
|
|
127
|
+
if (config.provider !== constants_js_1.PROVIDER_KEY) {
|
|
128
|
+
throw new perps_sdk_1.PerpsError(perps_types_1.PerpsErrorCode.SDKError, `hyperliquidProvider.projectConfig received config for provider ` +
|
|
129
|
+
`'${config.provider}'.`);
|
|
130
|
+
}
|
|
131
|
+
return (0, accountConfig_js_1.projectHyperliquidConfigSettings)(config, setup, options);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=HyperliquidProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HyperliquidProvider.js","sourceRoot":"","sources":["../../src/HyperliquidProvider.ts"],"names":[],"mappings":";;AAgIA,kDA4PC;AA5XD,+CAkBwB;AACxB,mDAqB0B;AAC1B,+BAAwD;AACxD,yDAAqE;AACrE,2DAAiE;AACjE,iDAKuB;AACvB,6CAAoD;AACpD,4DAAqD;AACrD,8DAAuD;AACvD,wDAAiD;AACjD,wDAAiD;AACjD,0DAAmD;AACnD,gEAAyD;AACzD,iFAG2C;AAC3C,6DAAiE;AAEjE,yDAAkE;AAClE,2DAAkE;AAClE,mEAA8E;AA+D9E,SAAgB,mBAAmB,CACjC,UAAsC,EAAE;IAExC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,0CAA2B,CAAA;IAC5D,MAAM,UAAU,GAAG,IAAI,gDAAqB,CAAC,OA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K,EAAE,OAAO,CAAC,CAAA;QACjE,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AccountConfigSetting, HyperliquidAccountConfig, ProviderAction } from '@lifi/perps-types';
|
|
2
|
+
export declare function projectHyperliquidConfigSettings(config: HyperliquidAccountConfig, setup: ProviderAction[], options: ProviderAction[]): AccountConfigSetting[];
|
|
3
|
+
//# sourceMappingURL=accountConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountConfig.d.ts","sourceRoot":"","sources":["../../src/accountConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,cAAc,EACf,MAAM,mBAAmB,CAAA;AA2E1B,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,cAAc,EAAE,GACxB,oBAAoB,EAAE,CAIxB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectHyperliquidConfigSettings = projectHyperliquidConfigSettings;
|
|
4
|
+
const perps_sdk_1 = require("@lifi/perps-sdk");
|
|
5
|
+
const perps_types_1 = require("@lifi/perps-types");
|
|
6
|
+
function assertNever(value) {
|
|
7
|
+
throw new Error(`Unreachable: exhaustiveness check failed for value ${JSON.stringify(value)}`);
|
|
8
|
+
}
|
|
9
|
+
function projectHyperliquidDescriptor(descriptor, config) {
|
|
10
|
+
switch (descriptor.type) {
|
|
11
|
+
case perps_types_1.ActionType.APPROVE_AGENT:
|
|
12
|
+
case perps_types_1.ActionType.APPROVE_BUILDER_FEE:
|
|
13
|
+
return { type: descriptor.type, values: [] };
|
|
14
|
+
case perps_types_1.ActionType.ACCOUNT_MODE:
|
|
15
|
+
return {
|
|
16
|
+
type: descriptor.type,
|
|
17
|
+
values: [{ name: 'mode', value: config.abstractionMode }],
|
|
18
|
+
};
|
|
19
|
+
case perps_types_1.ActionType.ACCOUNT_TYPE:
|
|
20
|
+
case perps_types_1.ActionType.SEND_ASSET:
|
|
21
|
+
case perps_types_1.ActionType.WITHDRAWAL:
|
|
22
|
+
case perps_types_1.ActionType.TRANSFER:
|
|
23
|
+
case perps_types_1.ActionType.PLACE_ORDER:
|
|
24
|
+
case perps_types_1.ActionType.PLACE_TRIGGER_ORDER:
|
|
25
|
+
case perps_types_1.ActionType.CANCEL_ORDER:
|
|
26
|
+
case perps_types_1.ActionType.CANCEL_ALL_ORDERS:
|
|
27
|
+
case perps_types_1.ActionType.MODIFY_ORDER:
|
|
28
|
+
case perps_types_1.ActionType.UPDATE_LEVERAGE:
|
|
29
|
+
case perps_types_1.ActionType.UPDATE_POSITION_MARGIN:
|
|
30
|
+
case perps_types_1.ActionType.REGISTER_API_KEY:
|
|
31
|
+
case perps_types_1.ActionType.APPROVE_READ_ONLY_TOKEN:
|
|
32
|
+
case perps_types_1.ActionType.DEPOSIT:
|
|
33
|
+
case perps_types_1.ActionType.META_VOTE:
|
|
34
|
+
case perps_types_1.ActionType.META_ACCEPT_TERMS:
|
|
35
|
+
throw new perps_sdk_1.PerpsError(perps_types_1.PerpsErrorCode.SDKError, `Hyperliquid account-config mapper has no projection for ` +
|
|
36
|
+
`descriptor type '${descriptor.type}' — this ActionType is not ` +
|
|
37
|
+
`valid on Provider.setup / Provider.options for Hyperliquid.`);
|
|
38
|
+
default:
|
|
39
|
+
return assertNever(descriptor.type);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function projectHyperliquidConfigSettings(config, setup, options) {
|
|
43
|
+
return [...setup, ...options].map((descriptor) => projectHyperliquidDescriptor(descriptor, config));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=accountConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountConfig.js","sourceRoot":"","sources":["../../src/accountConfig.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AAK,wBAAU,CAAC,iBAAiB;YAC/B,MAAM,IAAI,sBAAU,CAClB,4BAAc,CAAC,QAAQ,EACvB,0DAA0D;gBACxD,oBAAoB,UAAU,CAAC,IAAI,6BAA6B;gBAChE,6DAA6D,CAChE,CAAA;QAEH;YACE,OAAO,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;AACH,CAAC;AASD,SAAgB,gCAAgC,CAC9C,MAAgC,EAChC,KAAuB,EACvB,OAAyB;IAEzB,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/C,4BAA4B,CAAC,UAAU,EAAE,MAAM,CAAC,CACjD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountSummary.d.ts","sourceRoot":"","sources":["../../src/accountSummary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAqB1B,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,eAAe,EACxB,SAAS,EAAE,QAAQ,EAAE,GACpB,cAAc,CAEhB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.summarizeHyperliquidAccount = summarizeHyperliquidAccount;
|
|
4
|
+
const perps_sdk_1 = require("@lifi/perps-sdk");
|
|
5
|
+
const index_js_1 = require("./types/index.js");
|
|
6
|
+
const isUnifiedMode = (account) => account.config.provider === 'hyperliquid' &&
|
|
7
|
+
(account.config.abstractionMode === index_js_1.HlAbstractionMode.UNIFIED_ACCOUNT ||
|
|
8
|
+
account.config.abstractionMode === index_js_1.HlAbstractionMode.PORTFOLIO_MARGIN);
|
|
9
|
+
function summarizeHyperliquidAccount(account, positions) {
|
|
10
|
+
return (0, perps_sdk_1.summarizeAccount)(account, positions, isUnifiedMode(account));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=accountSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountSummary.js","sourceRoot":"","sources":["../../src/accountSummary.ts"],"names":[],"mappings":";;AA0BA,kEAKC;AA/BD,+CAAkD;AAMlD,+CAAoD;AAQpD,MAAM,aAAa,GAAG,CAAC,OAAwB,EAAW,EAAE,CAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,aAAa;IACzC,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,KAAK,4BAAiB,CAAC,eAAe;QACnE,OAAO,CAAC,MAAM,CAAC,eAAe,KAAK,4BAAiB,CAAC,gBAAgB,CAAC,CAAA;AAS1E,SAAgB,2BAA2B,CACzC,OAAwB,EACxB,SAAqB;IAErB,OAAO,IAAA,4BAAgB,EAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FeeTier } from '@lifi/perps-types';
|
|
2
|
+
export declare const PROVIDER_KEY = "hyperliquid";
|
|
3
|
+
export declare const DEFAULT_HYPERLIQUID_API_URL = "https://api.hyperliquid.xyz";
|
|
4
|
+
export declare const HYPERLIQUID_FEE_TIER_FALLBACK: FeeTier;
|
|
5
|
+
export declare const DEFAULT_HISTORY_LIMIT = 50;
|
|
6
|
+
export declare const MAX_HISTORY_LIMIT = 200;
|
|
7
|
+
export declare const NINETY_DAYS_MS: number;
|
|
8
|
+
export declare const MAIN_DEX_NAME = "";
|
|
9
|
+
export declare const MAIN_MARKET_ID = "hyperliquid";
|
|
10
|
+
export declare const SPOT_MARKET_ID = "spot";
|
|
11
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAQhD,eAAO,MAAM,YAAY,gBAAgB,CAAA;AAOzC,eAAO,MAAM,2BAA2B,gCAAgC,CAAA;AASxE,eAAO,MAAM,6BAA6B,EAAE,OAG3C,CAAA;AAGD,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAEvC,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,cAAc,QAA2B,CAAA;AAQtD,eAAO,MAAM,aAAa,KAAK,CAAA;AAE/B,eAAO,MAAM,cAAc,gBAAgB,CAAA;AAE3C,eAAO,MAAM,cAAc,SAAS,CAAA"}
|