@lifi/perps-sdk-provider-lighter 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 +176 -0
- package/dist/cjs/LighterProvider.d.ts +20 -0
- package/dist/cjs/LighterProvider.d.ts.map +1 -0
- package/dist/cjs/LighterProvider.js +592 -0
- package/dist/cjs/LighterProvider.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 +69 -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 +8 -0
- package/dist/cjs/accountSummary.js.map +1 -0
- package/dist/cjs/constants.d.ts +14 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +18 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/signers/LighterKeyStore.d.ts +18 -0
- package/dist/cjs/signers/LighterKeyStore.d.ts.map +1 -0
- package/dist/cjs/signers/LighterKeyStore.js +54 -0
- package/dist/cjs/signers/LighterKeyStore.js.map +1 -0
- package/dist/cjs/signers/LighterReadOnlyTokenManager.d.ts +56 -0
- package/dist/cjs/signers/LighterReadOnlyTokenManager.d.ts.map +1 -0
- package/dist/cjs/signers/LighterReadOnlyTokenManager.js +127 -0
- package/dist/cjs/signers/LighterReadOnlyTokenManager.js.map +1 -0
- package/dist/cjs/signers/LighterSigner.d.ts +41 -0
- package/dist/cjs/signers/LighterSigner.d.ts.map +1 -0
- package/dist/cjs/signers/LighterSigner.js +175 -0
- package/dist/cjs/signers/LighterSigner.js.map +1 -0
- package/dist/cjs/signers/createAuthToken.d.ts +12 -0
- package/dist/cjs/signers/createAuthToken.d.ts.map +1 -0
- package/dist/cjs/signers/createAuthToken.js +28 -0
- package/dist/cjs/signers/createAuthToken.js.map +1 -0
- package/dist/cjs/signers/index.d.ts +11 -0
- package/dist/cjs/signers/index.d.ts.map +1 -0
- package/dist/cjs/signers/index.js +19 -0
- package/dist/cjs/signers/index.js.map +1 -0
- package/dist/cjs/signers/signActions.d.ts +15 -0
- package/dist/cjs/signers/signActions.d.ts.map +1 -0
- package/dist/cjs/signers/signActions.js +142 -0
- package/dist/cjs/signers/signActions.js.map +1 -0
- package/dist/cjs/signers/wasmLoader.d.ts +42 -0
- package/dist/cjs/signers/wasmLoader.d.ts.map +1 -0
- package/dist/cjs/signers/wasmLoader.js +166 -0
- package/dist/cjs/signers/wasmLoader.js.map +1 -0
- package/dist/cjs/types/account.d.ts +97 -0
- package/dist/cjs/types/account.d.ts.map +1 -0
- package/dist/cjs/types/account.js +3 -0
- package/dist/cjs/types/account.js.map +1 -0
- package/dist/cjs/types/action.d.ts +72 -0
- package/dist/cjs/types/action.d.ts.map +1 -0
- package/dist/cjs/types/action.js +23 -0
- package/dist/cjs/types/action.js.map +1 -0
- package/dist/cjs/types/activity.d.ts +73 -0
- package/dist/cjs/types/activity.d.ts.map +1 -0
- package/dist/cjs/types/activity.js +3 -0
- package/dist/cjs/types/activity.js.map +1 -0
- package/dist/cjs/types/asset.d.ts +122 -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 +29 -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 +9 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +25 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/order.d.ts +57 -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/submit.d.ts +39 -0
- package/dist/cjs/types/submit.d.ts.map +1 -0
- package/dist/cjs/types/submit.js +3 -0
- package/dist/cjs/types/submit.js.map +1 -0
- package/dist/cjs/types/ws.d.ts +84 -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/activityCursor.d.ts +12 -0
- package/dist/cjs/utils/activityCursor.d.ts.map +1 -0
- package/dist/cjs/utils/activityCursor.js +85 -0
- package/dist/cjs/utils/activityCursor.js.map +1 -0
- package/dist/cjs/utils/apiClient.d.ts +26 -0
- package/dist/cjs/utils/apiClient.d.ts.map +1 -0
- package/dist/cjs/utils/apiClient.js +94 -0
- package/dist/cjs/utils/apiClient.js.map +1 -0
- package/dist/cjs/utils/fetchDetailedAccount.d.ts +5 -0
- package/dist/cjs/utils/fetchDetailedAccount.d.ts.map +1 -0
- package/dist/cjs/utils/fetchDetailedAccount.js +22 -0
- package/dist/cjs/utils/fetchDetailedAccount.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +16 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +45 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/lighterAsset.d.ts +3 -0
- package/dist/cjs/utils/lighterAsset.d.ts.map +1 -0
- package/dist/cjs/utils/lighterAsset.js +12 -0
- package/dist/cjs/utils/lighterAsset.js.map +1 -0
- package/dist/cjs/utils/liquidation.d.ts +4 -0
- package/dist/cjs/utils/liquidation.d.ts.map +1 -0
- package/dist/cjs/utils/liquidation.js +16 -0
- package/dist/cjs/utils/liquidation.js.map +1 -0
- package/dist/cjs/utils/mapFill.d.ts +4 -0
- package/dist/cjs/utils/mapFill.d.ts.map +1 -0
- package/dist/cjs/utils/mapFill.js +61 -0
- package/dist/cjs/utils/mapFill.js.map +1 -0
- package/dist/cjs/utils/mapOpenPositions.d.ts +4 -0
- package/dist/cjs/utils/mapOpenPositions.d.ts.map +1 -0
- package/dist/cjs/utils/mapOpenPositions.js +9 -0
- package/dist/cjs/utils/mapOpenPositions.js.map +1 -0
- package/dist/cjs/utils/mapOrder.d.ts +15 -0
- package/dist/cjs/utils/mapOrder.d.ts.map +1 -0
- package/dist/cjs/utils/mapOrder.js +164 -0
- package/dist/cjs/utils/mapOrder.js.map +1 -0
- package/dist/cjs/utils/mapPosition.d.ts +4 -0
- package/dist/cjs/utils/mapPosition.d.ts.map +1 -0
- package/dist/cjs/utils/mapPosition.js +30 -0
- package/dist/cjs/utils/mapPosition.js.map +1 -0
- package/dist/cjs/utils/ohlcvInterval.d.ts +2 -0
- package/dist/cjs/utils/ohlcvInterval.d.ts.map +1 -0
- package/dist/cjs/utils/ohlcvInterval.js +26 -0
- package/dist/cjs/utils/ohlcvInterval.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 +23 -0
- package/dist/cjs/utils/orderFormatting.js.map +1 -0
- package/dist/cjs/utils/time.d.ts +3 -0
- package/dist/cjs/utils/time.d.ts.map +1 -0
- package/dist/cjs/utils/time.js +8 -0
- package/dist/cjs/utils/time.js.map +1 -0
- package/dist/cjs/utils/wireEncoding.d.ts +9 -0
- package/dist/cjs/utils/wireEncoding.d.ts.map +1 -0
- package/dist/cjs/utils/wireEncoding.js +87 -0
- package/dist/cjs/utils/wireEncoding.js.map +1 -0
- package/dist/cjs/websocket/LighterWsProvider.d.ts +45 -0
- package/dist/cjs/websocket/LighterWsProvider.d.ts.map +1 -0
- package/dist/cjs/websocket/LighterWsProvider.js +396 -0
- package/dist/cjs/websocket/LighterWsProvider.js.map +1 -0
- package/dist/esm/LighterProvider.d.ts +105 -0
- package/dist/esm/LighterProvider.d.ts.map +1 -0
- package/dist/esm/LighterProvider.js +684 -0
- package/dist/esm/LighterProvider.js.map +1 -0
- package/dist/esm/accountConfig.d.ts +14 -0
- package/dist/esm/accountConfig.d.ts.map +1 -0
- package/dist/esm/accountConfig.js +135 -0
- package/dist/esm/accountConfig.js.map +1 -0
- package/dist/esm/accountSummary.d.ts +12 -0
- package/dist/esm/accountSummary.d.ts.map +1 -0
- package/dist/esm/accountSummary.js +14 -0
- package/dist/esm/accountSummary.js.map +1 -0
- package/dist/esm/constants.d.ts +74 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +73 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/signers/LighterKeyStore.d.ts +24 -0
- package/dist/esm/signers/LighterKeyStore.d.ts.map +1 -0
- package/dist/esm/signers/LighterKeyStore.js +55 -0
- package/dist/esm/signers/LighterKeyStore.js.map +1 -0
- package/dist/esm/signers/LighterReadOnlyTokenManager.d.ts +157 -0
- package/dist/esm/signers/LighterReadOnlyTokenManager.d.ts.map +1 -0
- package/dist/esm/signers/LighterReadOnlyTokenManager.js +194 -0
- package/dist/esm/signers/LighterReadOnlyTokenManager.js.map +1 -0
- package/dist/esm/signers/LighterSigner.d.ts +94 -0
- package/dist/esm/signers/LighterSigner.d.ts.map +1 -0
- package/dist/esm/signers/LighterSigner.js +228 -0
- package/dist/esm/signers/LighterSigner.js.map +1 -0
- package/dist/esm/signers/createAuthToken.d.ts +36 -0
- package/dist/esm/signers/createAuthToken.d.ts.map +1 -0
- package/dist/esm/signers/createAuthToken.js +42 -0
- package/dist/esm/signers/createAuthToken.js.map +1 -0
- package/dist/esm/signers/index.d.ts +11 -0
- package/dist/esm/signers/index.d.ts.map +1 -0
- package/dist/esm/signers/index.js +7 -0
- package/dist/esm/signers/index.js.map +1 -0
- package/dist/esm/signers/signActions.d.ts +54 -0
- package/dist/esm/signers/signActions.d.ts.map +1 -0
- package/dist/esm/signers/signActions.js +193 -0
- package/dist/esm/signers/signActions.js.map +1 -0
- package/dist/esm/signers/wasmLoader.d.ts +79 -0
- package/dist/esm/signers/wasmLoader.d.ts.map +1 -0
- package/dist/esm/signers/wasmLoader.js +180 -0
- package/dist/esm/signers/wasmLoader.js.map +1 -0
- package/dist/esm/types/account.d.ts +113 -0
- package/dist/esm/types/account.d.ts.map +1 -0
- package/dist/esm/types/account.js +4 -0
- package/dist/esm/types/account.js.map +1 -0
- package/dist/esm/types/action.d.ts +146 -0
- package/dist/esm/types/action.d.ts.map +1 -0
- package/dist/esm/types/action.js +50 -0
- package/dist/esm/types/action.js.map +1 -0
- package/dist/esm/types/activity.d.ts +83 -0
- package/dist/esm/types/activity.d.ts.map +1 -0
- package/dist/esm/types/activity.js +4 -0
- package/dist/esm/types/activity.js.map +1 -0
- package/dist/esm/types/asset.d.ts +134 -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 +31 -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 +9 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +12 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/order.d.ts +61 -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/submit.d.ts +76 -0
- package/dist/esm/types/submit.d.ts.map +1 -0
- package/dist/esm/types/submit.js +3 -0
- package/dist/esm/types/submit.js.map +1 -0
- package/dist/esm/types/ws.d.ts +124 -0
- package/dist/esm/types/ws.d.ts.map +1 -0
- package/dist/esm/types/ws.js +11 -0
- package/dist/esm/types/ws.js.map +1 -0
- package/dist/esm/utils/activityCursor.d.ts +51 -0
- package/dist/esm/utils/activityCursor.d.ts.map +1 -0
- package/dist/esm/utils/activityCursor.js +99 -0
- package/dist/esm/utils/activityCursor.js.map +1 -0
- package/dist/esm/utils/apiClient.d.ts +65 -0
- package/dist/esm/utils/apiClient.d.ts.map +1 -0
- package/dist/esm/utils/apiClient.js +131 -0
- package/dist/esm/utils/apiClient.js.map +1 -0
- package/dist/esm/utils/fetchDetailedAccount.d.ts +11 -0
- package/dist/esm/utils/fetchDetailedAccount.d.ts.map +1 -0
- package/dist/esm/utils/fetchDetailedAccount.js +24 -0
- package/dist/esm/utils/fetchDetailedAccount.js.map +1 -0
- package/dist/esm/utils/index.d.ts +16 -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/lighterAsset.d.ts +4 -0
- package/dist/esm/utils/lighterAsset.d.ts.map +1 -0
- package/dist/esm/utils/lighterAsset.js +9 -0
- package/dist/esm/utils/lighterAsset.js.map +1 -0
- package/dist/esm/utils/liquidation.d.ts +22 -0
- package/dist/esm/utils/liquidation.d.ts.map +1 -0
- package/dist/esm/utils/liquidation.js +31 -0
- package/dist/esm/utils/liquidation.js.map +1 -0
- package/dist/esm/utils/mapFill.d.ts +10 -0
- package/dist/esm/utils/mapFill.d.ts.map +1 -0
- package/dist/esm/utils/mapFill.js +72 -0
- package/dist/esm/utils/mapFill.js.map +1 -0
- package/dist/esm/utils/mapOpenPositions.d.ts +11 -0
- package/dist/esm/utils/mapOpenPositions.d.ts.map +1 -0
- package/dist/esm/utils/mapOpenPositions.js +12 -0
- package/dist/esm/utils/mapOpenPositions.js.map +1 -0
- package/dist/esm/utils/mapOrder.d.ts +72 -0
- package/dist/esm/utils/mapOrder.d.ts.map +1 -0
- package/dist/esm/utils/mapOrder.js +219 -0
- package/dist/esm/utils/mapOrder.js.map +1 -0
- package/dist/esm/utils/mapPosition.d.ts +9 -0
- package/dist/esm/utils/mapPosition.d.ts.map +1 -0
- package/dist/esm/utils/mapPosition.js +34 -0
- package/dist/esm/utils/mapPosition.js.map +1 -0
- package/dist/esm/utils/ohlcvInterval.d.ts +3 -0
- package/dist/esm/utils/ohlcvInterval.d.ts.map +1 -0
- package/dist/esm/utils/ohlcvInterval.js +30 -0
- package/dist/esm/utils/ohlcvInterval.js.map +1 -0
- package/dist/esm/utils/orderFormatting.d.ts +29 -0
- package/dist/esm/utils/orderFormatting.d.ts.map +1 -0
- package/dist/esm/utils/orderFormatting.js +41 -0
- package/dist/esm/utils/orderFormatting.js.map +1 -0
- package/dist/esm/utils/time.d.ts +5 -0
- package/dist/esm/utils/time.d.ts.map +1 -0
- package/dist/esm/utils/time.js +5 -0
- package/dist/esm/utils/time.js.map +1 -0
- package/dist/esm/utils/wireEncoding.d.ts +72 -0
- package/dist/esm/utils/wireEncoding.d.ts.map +1 -0
- package/dist/esm/utils/wireEncoding.js +129 -0
- package/dist/esm/utils/wireEncoding.js.map +1 -0
- package/dist/esm/websocket/LighterWsProvider.d.ts +97 -0
- package/dist/esm/websocket/LighterWsProvider.d.ts.map +1 -0
- package/dist/esm/websocket/LighterWsProvider.js +489 -0
- package/dist/esm/websocket/LighterWsProvider.js.map +1 -0
- package/dist/types/LighterProvider.d.ts +105 -0
- package/dist/types/LighterProvider.d.ts.map +1 -0
- package/dist/types/accountConfig.d.ts +14 -0
- package/dist/types/accountConfig.d.ts.map +1 -0
- package/dist/types/accountSummary.d.ts +12 -0
- package/dist/types/accountSummary.d.ts.map +1 -0
- package/dist/types/constants.d.ts +74 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/signers/LighterKeyStore.d.ts +24 -0
- package/dist/types/signers/LighterKeyStore.d.ts.map +1 -0
- package/dist/types/signers/LighterReadOnlyTokenManager.d.ts +157 -0
- package/dist/types/signers/LighterReadOnlyTokenManager.d.ts.map +1 -0
- package/dist/types/signers/LighterSigner.d.ts +94 -0
- package/dist/types/signers/LighterSigner.d.ts.map +1 -0
- package/dist/types/signers/createAuthToken.d.ts +36 -0
- package/dist/types/signers/createAuthToken.d.ts.map +1 -0
- package/dist/types/signers/index.d.ts +11 -0
- package/dist/types/signers/index.d.ts.map +1 -0
- package/dist/types/signers/signActions.d.ts +54 -0
- package/dist/types/signers/signActions.d.ts.map +1 -0
- package/dist/types/signers/wasmLoader.d.ts +79 -0
- package/dist/types/signers/wasmLoader.d.ts.map +1 -0
- package/dist/types/types/account.d.ts +113 -0
- package/dist/types/types/account.d.ts.map +1 -0
- package/dist/types/types/action.d.ts +146 -0
- package/dist/types/types/action.d.ts.map +1 -0
- package/dist/types/types/activity.d.ts +83 -0
- package/dist/types/types/activity.d.ts.map +1 -0
- package/dist/types/types/asset.d.ts +134 -0
- package/dist/types/types/asset.d.ts.map +1 -0
- package/dist/types/types/fill.d.ts +31 -0
- package/dist/types/types/fill.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +9 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/order.d.ts +61 -0
- package/dist/types/types/order.d.ts.map +1 -0
- package/dist/types/types/submit.d.ts +76 -0
- package/dist/types/types/submit.d.ts.map +1 -0
- package/dist/types/types/ws.d.ts +124 -0
- package/dist/types/types/ws.d.ts.map +1 -0
- package/dist/types/utils/activityCursor.d.ts +51 -0
- package/dist/types/utils/activityCursor.d.ts.map +1 -0
- package/dist/types/utils/apiClient.d.ts +65 -0
- package/dist/types/utils/apiClient.d.ts.map +1 -0
- package/dist/types/utils/fetchDetailedAccount.d.ts +11 -0
- package/dist/types/utils/fetchDetailedAccount.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +16 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/lighterAsset.d.ts +4 -0
- package/dist/types/utils/lighterAsset.d.ts.map +1 -0
- package/dist/types/utils/liquidation.d.ts +22 -0
- package/dist/types/utils/liquidation.d.ts.map +1 -0
- package/dist/types/utils/mapFill.d.ts +10 -0
- package/dist/types/utils/mapFill.d.ts.map +1 -0
- package/dist/types/utils/mapOpenPositions.d.ts +11 -0
- package/dist/types/utils/mapOpenPositions.d.ts.map +1 -0
- package/dist/types/utils/mapOrder.d.ts +72 -0
- package/dist/types/utils/mapOrder.d.ts.map +1 -0
- package/dist/types/utils/mapPosition.d.ts +9 -0
- package/dist/types/utils/mapPosition.d.ts.map +1 -0
- package/dist/types/utils/ohlcvInterval.d.ts +3 -0
- package/dist/types/utils/ohlcvInterval.d.ts.map +1 -0
- package/dist/types/utils/orderFormatting.d.ts +29 -0
- package/dist/types/utils/orderFormatting.d.ts.map +1 -0
- package/dist/types/utils/time.d.ts +5 -0
- package/dist/types/utils/time.d.ts.map +1 -0
- package/dist/types/utils/wireEncoding.d.ts +72 -0
- package/dist/types/utils/wireEncoding.d.ts.map +1 -0
- package/dist/types/websocket/LighterWsProvider.d.ts +97 -0
- package/dist/types/websocket/LighterWsProvider.d.ts.map +1 -0
- package/dist/wasm/lighter-signer.wasm +0 -0
- package/dist/wasm/wasm_exec.js +575 -0
- package/package.json +67 -0
- package/src/LighterProvider.ts +1167 -0
- package/src/accountConfig.ts +162 -0
- package/src/accountSummary.ts +22 -0
- package/src/constants.ts +89 -0
- package/src/index.ts +37 -0
- package/src/signers/LighterKeyStore.ts +79 -0
- package/src/signers/LighterReadOnlyTokenManager.ts +340 -0
- package/src/signers/LighterSigner.ts +400 -0
- package/src/signers/createAuthToken.ts +69 -0
- package/src/signers/index.ts +36 -0
- package/src/signers/signActions.ts +311 -0
- package/src/signers/wasmLoader.ts +293 -0
- package/src/types/account.ts +123 -0
- package/src/types/action.ts +163 -0
- package/src/types/activity.ts +94 -0
- package/src/types/asset.ts +146 -0
- package/src/types/fill.ts +42 -0
- package/src/types/index.ts +12 -0
- package/src/types/order.ts +65 -0
- package/src/types/submit.ts +83 -0
- package/src/types/ws.ts +136 -0
- package/src/utils/activityCursor.ts +150 -0
- package/src/utils/apiClient.ts +185 -0
- package/src/utils/fetchDetailedAccount.ts +46 -0
- package/src/utils/index.ts +38 -0
- package/src/utils/lighterAsset.ts +10 -0
- package/src/utils/liquidation.ts +39 -0
- package/src/utils/mapFill.ts +108 -0
- package/src/utils/mapOpenPositions.ts +18 -0
- package/src/utils/mapOrder.ts +258 -0
- package/src/utils/mapPosition.ts +42 -0
- package/src/utils/ohlcvInterval.ts +34 -0
- package/src/utils/orderFormatting.ts +46 -0
- package/src/utils/time.ts +6 -0
- package/src/utils/wireEncoding.ts +179 -0
- package/src/websocket/LighterWsProvider.ts +725 -0
- package/wasm/lighter-signer.wasm +0 -0
- package/wasm/wasm_exec.js +575 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { PerpsError } from '@lifi/perps-sdk'
|
|
2
|
+
import type {
|
|
3
|
+
AccountConfigSetting,
|
|
4
|
+
LighterAccountConfig,
|
|
5
|
+
ProviderAction,
|
|
6
|
+
} from '@lifi/perps-types'
|
|
7
|
+
import { ActionType, PerpsErrorCode } from '@lifi/perps-types'
|
|
8
|
+
|
|
9
|
+
function assertNever(value: never): never {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Unreachable: exhaustiveness check failed for value ${JSON.stringify(value)}`
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `account_type` on Lighter's `DetailedAccount` is a `StrictInt` in the
|
|
17
|
+
* public OpenAPI schema (`lighter-python/lighter/models/detailed_account.py`)
|
|
18
|
+
* with no documented integer ↔ name mapping in the Python or Go SDKs.
|
|
19
|
+
*
|
|
20
|
+
* The empirical mapping below follows the public docs' tier ordering
|
|
21
|
+
* (apidocs.lighter.xyz/docs/account-types lists Standard → Premium → Plus)
|
|
22
|
+
* and the Python paper client's `AccountTier` enum ordering (STANDARD
|
|
23
|
+
* first, PREMIUM next). The write side of `/changeAccountTier` accepts the
|
|
24
|
+
* lowercase strings `'standard' | 'premium'` — these are what the
|
|
25
|
+
* descriptor's `ParamOption.value` declarations carry, so this mapping
|
|
26
|
+
* round-trips cleanly with the OptionsModal selection.
|
|
27
|
+
*
|
|
28
|
+
* Lighter publishes a third "Plus" tier (likely integer `2`), but it is
|
|
29
|
+
* not currently settable via the public API, so we deliberately do not
|
|
30
|
+
* map it — a Plus account surfaces as "tier not detected" in the widget
|
|
31
|
+
* rather than offering an option that would 400 on submit. Add
|
|
32
|
+
* `LIGHTER_ACCOUNT_TYPE_PLUS` here (and to the backend descriptor) if
|
|
33
|
+
* Lighter exposes it later.
|
|
34
|
+
*
|
|
35
|
+
* Each integer is a named constant so a correction (e.g. Lighter publishing
|
|
36
|
+
* an authoritative table) is a one-line edit. An unmapped integer projects
|
|
37
|
+
* to `null` and surfaces as "tier not detected" in the widget, so drift is
|
|
38
|
+
* observable rather than silent.
|
|
39
|
+
*/
|
|
40
|
+
const LIGHTER_ACCOUNT_TYPE_STANDARD = 0
|
|
41
|
+
const LIGHTER_ACCOUNT_TYPE_PREMIUM = 1
|
|
42
|
+
|
|
43
|
+
const ACCOUNT_TYPE_INT_TO_WIRE: Readonly<Record<number, string>> = {
|
|
44
|
+
[LIGHTER_ACCOUNT_TYPE_STANDARD]: 'standard',
|
|
45
|
+
[LIGHTER_ACCOUNT_TYPE_PREMIUM]: 'premium',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Project a single Lighter descriptor against the typed
|
|
50
|
+
* `LighterAccountConfig` into an `AccountConfigSetting`.
|
|
51
|
+
*
|
|
52
|
+
* Mapping table:
|
|
53
|
+
*
|
|
54
|
+
* | descriptor.type | projected values
|
|
55
|
+
* |---------------------------|--------------------------------------------------
|
|
56
|
+
* | REGISTER_API_KEY | [] (no parameters)
|
|
57
|
+
* | APPROVE_READ_ONLY_TOKEN | [] (no parameters)
|
|
58
|
+
* | ACCOUNT_MODE | [{ name: 'mode', value: null }] (Lighter has no
|
|
59
|
+
* | | abstraction-mode equivalent; read-only here)
|
|
60
|
+
* | ACCOUNT_TYPE | [{ name: 'tier', value: config.accountType }]
|
|
61
|
+
*
|
|
62
|
+
* The switch is exhaustive over `ActionType` so enum additions force a
|
|
63
|
+
* compile error in the `default` arm. ActionTypes that are not valid on
|
|
64
|
+
* `Provider.setup` / `Provider.options` throw at runtime.
|
|
65
|
+
*/
|
|
66
|
+
function projectLighterDescriptor(
|
|
67
|
+
descriptor: ProviderAction,
|
|
68
|
+
config: LighterAccountConfig
|
|
69
|
+
): AccountConfigSetting {
|
|
70
|
+
switch (descriptor.type) {
|
|
71
|
+
// `REGISTER_API_KEY` is satisfied only when the locally-held keypair
|
|
72
|
+
// matches the key registered on-chain at this slot — computed client-side
|
|
73
|
+
// in `getAccount` (the SDK owns account reads + the keystore). Backend
|
|
74
|
+
// staging is mutation-only; it never decides satisfaction.
|
|
75
|
+
case ActionType.REGISTER_API_KEY:
|
|
76
|
+
return {
|
|
77
|
+
type: descriptor.type,
|
|
78
|
+
values: [],
|
|
79
|
+
satisfied: config.apiKeyRegistered,
|
|
80
|
+
}
|
|
81
|
+
// `APPROVE_READ_ONLY_TOKEN` is a client-only flow that never reaches
|
|
82
|
+
// the backend, so its satisfaction state lives entirely in the typed
|
|
83
|
+
// `LighterAccountConfig` projection.
|
|
84
|
+
case ActionType.APPROVE_READ_ONLY_TOKEN:
|
|
85
|
+
return {
|
|
86
|
+
type: descriptor.type,
|
|
87
|
+
values: [],
|
|
88
|
+
satisfied: config.readOnlyTokenApproved,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Lighter exposes no abstraction-mode equivalent; if a backend descriptor
|
|
92
|
+
// surfaces ACCOUNT_MODE on Lighter it always projects `null` and callers
|
|
93
|
+
// fall back to the descriptor's `default` ParamOption.
|
|
94
|
+
case ActionType.ACCOUNT_MODE:
|
|
95
|
+
return {
|
|
96
|
+
type: descriptor.type,
|
|
97
|
+
values: [{ name: 'mode', value: null }],
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// `tier` is the wire string `/changeAccountTier` accepts; we decode the
|
|
101
|
+
// raw integer `config.accountType` Lighter publishes via the mapping
|
|
102
|
+
// above so the projection matches the descriptor's enumerated values.
|
|
103
|
+
// Unrecognised integers project to `null` (surfaces as "tier not
|
|
104
|
+
// detected" — the widget still lets the user pick a value).
|
|
105
|
+
case ActionType.ACCOUNT_TYPE:
|
|
106
|
+
return {
|
|
107
|
+
type: descriptor.type,
|
|
108
|
+
values: [
|
|
109
|
+
{
|
|
110
|
+
name: 'tier',
|
|
111
|
+
value: ACCOUNT_TYPE_INT_TO_WIRE[config.accountType] ?? null,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
case ActionType.APPROVE_AGENT:
|
|
117
|
+
case ActionType.APPROVE_BUILDER_FEE:
|
|
118
|
+
case ActionType.SEND_ASSET:
|
|
119
|
+
case ActionType.WITHDRAWAL:
|
|
120
|
+
case ActionType.TRANSFER:
|
|
121
|
+
case ActionType.PLACE_ORDER:
|
|
122
|
+
case ActionType.PLACE_TRIGGER_ORDER:
|
|
123
|
+
case ActionType.CANCEL_ORDER:
|
|
124
|
+
case ActionType.CANCEL_ALL_ORDERS:
|
|
125
|
+
case ActionType.MODIFY_ORDER:
|
|
126
|
+
case ActionType.UPDATE_LEVERAGE:
|
|
127
|
+
case ActionType.UPDATE_POSITION_MARGIN:
|
|
128
|
+
case ActionType.DEPOSIT:
|
|
129
|
+
case ActionType.META_VOTE:
|
|
130
|
+
case ActionType.META_ACCEPT_TERMS:
|
|
131
|
+
throw new PerpsError(
|
|
132
|
+
PerpsErrorCode.SDKError,
|
|
133
|
+
`Lighter account-config mapper has no projection for ` +
|
|
134
|
+
`descriptor type '${descriptor.type}' — this ActionType is not ` +
|
|
135
|
+
`valid on Provider.setup / Provider.options for Lighter.`
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
default:
|
|
139
|
+
return assertNever(descriptor.type)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Project the union of Lighter setup + options descriptors against the typed
|
|
145
|
+
* `LighterAccountConfig`. Produces exactly one `AccountConfigSetting` per
|
|
146
|
+
* descriptor, in `setup`-then-`options` order (preserving the order in which
|
|
147
|
+
* the backend emits them).
|
|
148
|
+
*
|
|
149
|
+
* @param config Typed account state for the Lighter account.
|
|
150
|
+
* @param setup `Provider.setup` array as emitted by `/providers`.
|
|
151
|
+
* @param options `Provider.options` array as emitted by `/providers`.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export function projectLighterConfigSettings(
|
|
155
|
+
config: LighterAccountConfig,
|
|
156
|
+
setup: ProviderAction[],
|
|
157
|
+
options: ProviderAction[]
|
|
158
|
+
): AccountConfigSetting[] {
|
|
159
|
+
return [...setup, ...options].map((descriptor) =>
|
|
160
|
+
projectLighterDescriptor(descriptor, config)
|
|
161
|
+
)
|
|
162
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { summarizeAccount } from '@lifi/perps-sdk'
|
|
2
|
+
import type {
|
|
3
|
+
AccountResponse,
|
|
4
|
+
AccountSummary,
|
|
5
|
+
Position,
|
|
6
|
+
} from '@lifi/perps-types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Roll a Lighter {@link AccountResponse} up into an {@link AccountSummary}.
|
|
10
|
+
* Lighter has a single flat collateral model with no abstraction modes: the
|
|
11
|
+
* collateral rows hold `available_balance` (free margin), so available margin
|
|
12
|
+
* is the collateral as-is and the locked margin (carried by the positions'
|
|
13
|
+
* `marginUsed`) is added back for the gross portfolio value.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export function summarizeLighterAccount(
|
|
18
|
+
account: AccountResponse,
|
|
19
|
+
positions: Position[]
|
|
20
|
+
): AccountSummary {
|
|
21
|
+
return summarizeAccount(account, positions, false)
|
|
22
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { FeeTier } from '@lifi/perps-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lighter provider key as it appears on `Provider.key` from the backend.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export const LIGHTER_PROVIDER_KEY = 'lighter'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Default mainnet REST base URL for Lighter.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_LIGHTER_REST_URL = 'https://mainnet.zklighter.elliot.ai'
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const DEFAULT_TRADES_LIMIT = 50
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Lighter pairs each maker/taker fee with a 1e6 integer tick:
|
|
22
|
+
* fee_fraction = current_*_fee_tick / 1_000_000
|
|
23
|
+
*
|
|
24
|
+
* See lighter-python `paper_client/types.py:_FEE_TICK` for the canonical scale.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export const LIGHTER_FEE_TICK_SCALE = 1_000_000
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Lighter's public base fee tier (Standard Account): 0% maker / 0% taker on all
|
|
32
|
+
* perps markets. Per-account Premium tiers exist but require auth to resolve;
|
|
33
|
+
* unauthenticated quotes use this public base. Fractions, not basis points.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export const LIGHTER_BASE_FEE_TIER: FeeTier = { maker: '0', taker: '0' }
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Wildcard `market_id` accepted by Lighter's per-market account endpoints to
|
|
41
|
+
* indicate "every market". Used on `accountInactiveOrders`, `positionFunding`,
|
|
42
|
+
* `liquidations`.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export const LIGHTER_ALL_MARKETS_WILDCARD = 255
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Lighter caps `limit` at 100 on positionFunding/liquidations endpoints.
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export const LIGHTER_HISTORY_PAGE_SIZE = 100
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Default API key slot — reused per account. Lighter's docs reserve indexes
|
|
57
|
+
* `{0,1,2,3}` for its own desktop/mobile interfaces; user keys start at 4
|
|
58
|
+
* (max 254, with 255 reserved as `NilApiKeyIndex`). 42 is the LI.FI-wide
|
|
59
|
+
* identifier so a user running both the Lighter app and the widget never
|
|
60
|
+
* collides with the app's session key.
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export const DEFAULT_API_KEY_INDEX = 42
|
|
65
|
+
|
|
66
|
+
/** @internal */
|
|
67
|
+
const LIGHTER_CODE_ACCOUNT_NOT_FOUND = 21100
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Lighter body `code` for a rejected/invalid auth token ("invalid auth string").
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
const LIGHTER_INVALID_AUTH_CODE = 20013
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Lighter body `code` values that mean success. Lighter is inconsistent per
|
|
78
|
+
* endpoint: `/api/v1/account` returns `code: 200`, most others return `code: 0`.
|
|
79
|
+
* A body with no `code` field is also success (no error channel present).
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
const LIGHTER_SUCCESS_CODES = new Set([0, 200])
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
LIGHTER_CODE_ACCOUNT_NOT_FOUND,
|
|
87
|
+
LIGHTER_INVALID_AUTH_CODE,
|
|
88
|
+
LIGHTER_SUCCESS_CODES,
|
|
89
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// biome-ignore-all lint/performance/noBarrelFile: package public entry point.
|
|
2
|
+
// biome-ignore-all lint/performance/noReExportAll: package public entry point.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Lighter provider plugin for `@lifi/perps-sdk`. Serves `PerpsProvider` reads
|
|
6
|
+
* directly from Lighter's REST API (no LI.FI backend hop); auth-gated reads
|
|
7
|
+
* use the user's Lighter read-only token. Also owns `signActions` (the
|
|
8
|
+
* `WASM_BLOB` / `EVM_TX` arms of `PerpsClient.execute`) — `LighterSigner`,
|
|
9
|
+
* `LighterKeyStore`, `LighterReadOnlyTokenManager`, and the WASM blob ship
|
|
10
|
+
* with this package.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export { projectLighterConfigSettings } from './accountConfig.js'
|
|
17
|
+
export { summarizeLighterAccount } from './accountSummary.js'
|
|
18
|
+
export {
|
|
19
|
+
DEFAULT_API_KEY_INDEX,
|
|
20
|
+
DEFAULT_LIGHTER_REST_URL,
|
|
21
|
+
LIGHTER_PROVIDER_KEY,
|
|
22
|
+
} from './constants.js'
|
|
23
|
+
export type {
|
|
24
|
+
LighterPerpsProvider,
|
|
25
|
+
LighterProviderOptions,
|
|
26
|
+
} from './LighterProvider.js'
|
|
27
|
+
export { Lighter, lighterProvider } from './LighterProvider.js'
|
|
28
|
+
|
|
29
|
+
export * from './signers/index.js'
|
|
30
|
+
export * from './types/index.js'
|
|
31
|
+
export * from './utils/index.js'
|
|
32
|
+
export type { LighterAuthProvider } from './websocket/LighterWsProvider.js'
|
|
33
|
+
export {
|
|
34
|
+
LighterWsProvider,
|
|
35
|
+
type LighterWsProviderOptions,
|
|
36
|
+
lighterWsProvider,
|
|
37
|
+
} from './websocket/LighterWsProvider.js'
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { readValidatedRecord, type StorageAdapter } from '@lifi/perps-sdk'
|
|
2
|
+
import type { Address } from 'viem'
|
|
3
|
+
|
|
4
|
+
// The private key here is a Lighter custom keypair — generated via WASM
|
|
5
|
+
// GenerateAPIKey — not an Ethereum private key. The storage key is namespaced
|
|
6
|
+
// by provider (`lighter`) so the same user can hold credentials for other
|
|
7
|
+
// WASM-blob providers without collision.
|
|
8
|
+
|
|
9
|
+
const STORAGE_PREFIX = 'lifi-perps-lighter-key'
|
|
10
|
+
|
|
11
|
+
/** @public */
|
|
12
|
+
export interface LighterApiKey {
|
|
13
|
+
/** Lighter account index, looked up once via accountsByL1Address. */
|
|
14
|
+
accountIndex: number
|
|
15
|
+
/** API key slot (0-255). Defaults to {@link DEFAULT_API_KEY_INDEX}. */
|
|
16
|
+
apiKeyIndex: number
|
|
17
|
+
/** Lighter-native private key (0x-prefixed hex). */
|
|
18
|
+
apiKeyPrivateKey: string
|
|
19
|
+
/** Corresponding public key, registered via ChangePubKey. */
|
|
20
|
+
apiKeyPublicKey: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const isLighterApiKey = (value: unknown): value is LighterApiKey => {
|
|
24
|
+
if (typeof value !== 'object' || value === null) {
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
27
|
+
const { accountIndex, apiKeyIndex, apiKeyPrivateKey, apiKeyPublicKey } =
|
|
28
|
+
value as Record<string, unknown>
|
|
29
|
+
return (
|
|
30
|
+
typeof accountIndex === 'number' &&
|
|
31
|
+
Number.isFinite(accountIndex) &&
|
|
32
|
+
typeof apiKeyIndex === 'number' &&
|
|
33
|
+
Number.isFinite(apiKeyIndex) &&
|
|
34
|
+
typeof apiKeyPrivateKey === 'string' &&
|
|
35
|
+
apiKeyPrivateKey.length > 0 &&
|
|
36
|
+
typeof apiKeyPublicKey === 'string' &&
|
|
37
|
+
apiKeyPublicKey.length > 0
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @public */
|
|
42
|
+
export class LighterKeyStore {
|
|
43
|
+
private readonly storage: StorageAdapter
|
|
44
|
+
private readonly cache = new Map<string, LighterApiKey>()
|
|
45
|
+
|
|
46
|
+
constructor(storage: StorageAdapter) {
|
|
47
|
+
this.storage = storage
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private storageKey(address: Address): string {
|
|
51
|
+
return `${STORAGE_PREFIX}:${address.toLowerCase()}`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async get(address: Address): Promise<LighterApiKey | null> {
|
|
55
|
+
const key = this.storageKey(address)
|
|
56
|
+
const cached = this.cache.get(key)
|
|
57
|
+
if (cached) {
|
|
58
|
+
return cached
|
|
59
|
+
}
|
|
60
|
+
const parsed = await readValidatedRecord(this.storage, key, isLighterApiKey)
|
|
61
|
+
if (!parsed) {
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
this.cache.set(key, parsed)
|
|
65
|
+
return parsed
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async set(address: Address, value: LighterApiKey): Promise<void> {
|
|
69
|
+
const key = this.storageKey(address)
|
|
70
|
+
this.cache.set(key, value)
|
|
71
|
+
await this.storage.set(key, JSON.stringify(value))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async remove(address: Address): Promise<void> {
|
|
75
|
+
const key = this.storageKey(address)
|
|
76
|
+
this.cache.delete(key)
|
|
77
|
+
await this.storage.remove(key)
|
|
78
|
+
}
|
|
79
|
+
}
|