@lifi/perps-sdk-provider-ondo 0.0.0-preview-7ff840c
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 +38 -0
- package/dist/cjs/OndoProvider.d.ts +8 -0
- package/dist/cjs/OndoProvider.d.ts.map +1 -0
- package/dist/cjs/OndoProvider.js +338 -0
- package/dist/cjs/OndoProvider.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 +59 -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/auth/OndoTokenStore.d.ts +13 -0
- package/dist/cjs/auth/OndoTokenStore.d.ts.map +1 -0
- package/dist/cjs/auth/OndoTokenStore.js +53 -0
- package/dist/cjs/auth/OndoTokenStore.js.map +1 -0
- package/dist/cjs/auth/completeSiweLogin.d.ts +13 -0
- package/dist/cjs/auth/completeSiweLogin.d.ts.map +1 -0
- package/dist/cjs/auth/completeSiweLogin.js +15 -0
- package/dist/cjs/auth/completeSiweLogin.js.map +1 -0
- package/dist/cjs/auth/index.d.ts +4 -0
- package/dist/cjs/auth/index.d.ts.map +1 -0
- package/dist/cjs/auth/index.js +11 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/signActions.d.ts +13 -0
- package/dist/cjs/auth/signActions.d.ts.map +1 -0
- package/dist/cjs/auth/signActions.js +86 -0
- package/dist/cjs/auth/signActions.js.map +1 -0
- package/dist/cjs/constants.d.ts +9 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +12 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types/auth.d.ts +16 -0
- package/dist/cjs/types/auth.d.ts.map +1 -0
- package/dist/cjs/types/auth.js +3 -0
- package/dist/cjs/types/auth.js.map +1 -0
- package/dist/cjs/types/index.d.ts +4 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/wire.d.ts +154 -0
- package/dist/cjs/types/wire.d.ts.map +1 -0
- package/dist/cjs/types/wire.js +3 -0
- package/dist/cjs/types/wire.js.map +1 -0
- package/dist/cjs/types/ws.d.ts +92 -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 +9 -0
- package/dist/cjs/utils/activityCursor.d.ts.map +1 -0
- package/dist/cjs/utils/activityCursor.js +79 -0
- package/dist/cjs/utils/activityCursor.js.map +1 -0
- package/dist/cjs/utils/apiClient.d.ts +43 -0
- package/dist/cjs/utils/apiClient.d.ts.map +1 -0
- package/dist/cjs/utils/apiClient.js +134 -0
- package/dist/cjs/utils/apiClient.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +11 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +39 -0
- package/dist/cjs/utils/index.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/mapActivity.d.ts +5 -0
- package/dist/cjs/utils/mapActivity.d.ts.map +1 -0
- package/dist/cjs/utils/mapActivity.js +34 -0
- package/dist/cjs/utils/mapActivity.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 +36 -0
- package/dist/cjs/utils/mapFill.js.map +1 -0
- package/dist/cjs/utils/mapOrder.d.ts +16 -0
- package/dist/cjs/utils/mapOrder.d.ts.map +1 -0
- package/dist/cjs/utils/mapOrder.js +135 -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 +26 -0
- package/dist/cjs/utils/mapPosition.js.map +1 -0
- package/dist/cjs/utils/ohlcvInterval.d.ts +4 -0
- package/dist/cjs/utils/ohlcvInterval.d.ts.map +1 -0
- package/dist/cjs/utils/ohlcvInterval.js +49 -0
- package/dist/cjs/utils/ohlcvInterval.js.map +1 -0
- package/dist/cjs/utils/ondoAsset.d.ts +3 -0
- package/dist/cjs/utils/ondoAsset.d.ts.map +1 -0
- package/dist/cjs/utils/ondoAsset.js +12 -0
- package/dist/cjs/utils/ondoAsset.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 +40 -0
- package/dist/cjs/utils/orderFormatting.js.map +1 -0
- package/dist/cjs/websocket/OndoWsProvider.d.ts +56 -0
- package/dist/cjs/websocket/OndoWsProvider.d.ts.map +1 -0
- package/dist/cjs/websocket/OndoWsProvider.js +515 -0
- package/dist/cjs/websocket/OndoWsProvider.js.map +1 -0
- package/dist/esm/OndoProvider.d.ts +39 -0
- package/dist/esm/OndoProvider.d.ts.map +1 -0
- package/dist/esm/OndoProvider.js +366 -0
- package/dist/esm/OndoProvider.js.map +1 -0
- package/dist/esm/accountConfig.d.ts +13 -0
- package/dist/esm/accountConfig.d.ts.map +1 -0
- package/dist/esm/accountConfig.js +77 -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/auth/OndoTokenStore.d.ts +20 -0
- package/dist/esm/auth/OndoTokenStore.d.ts.map +1 -0
- package/dist/esm/auth/OndoTokenStore.js +61 -0
- package/dist/esm/auth/OndoTokenStore.js.map +1 -0
- package/dist/esm/auth/completeSiweLogin.d.ts +28 -0
- package/dist/esm/auth/completeSiweLogin.d.ts.map +1 -0
- package/dist/esm/auth/completeSiweLogin.js +21 -0
- package/dist/esm/auth/completeSiweLogin.js.map +1 -0
- package/dist/esm/auth/index.d.ts +4 -0
- package/dist/esm/auth/index.d.ts.map +1 -0
- package/dist/esm/auth/index.js +5 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/signActions.d.ts +35 -0
- package/dist/esm/auth/signActions.d.ts.map +1 -0
- package/dist/esm/auth/signActions.js +103 -0
- package/dist/esm/auth/signActions.js.map +1 -0
- package/dist/esm/constants.d.ts +35 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +35 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types/auth.d.ts +32 -0
- package/dist/esm/types/auth.d.ts.map +1 -0
- package/dist/esm/types/auth.js +2 -0
- package/dist/esm/types/auth.js.map +1 -0
- package/dist/esm/types/index.d.ts +4 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/wire.d.ts +195 -0
- package/dist/esm/types/wire.d.ts.map +1 -0
- package/dist/esm/types/wire.js +7 -0
- package/dist/esm/types/wire.js.map +1 -0
- package/dist/esm/types/ws.d.ts +108 -0
- package/dist/esm/types/ws.d.ts.map +1 -0
- package/dist/esm/types/ws.js +7 -0
- package/dist/esm/types/ws.js.map +1 -0
- package/dist/esm/utils/activityCursor.d.ts +47 -0
- package/dist/esm/utils/activityCursor.d.ts.map +1 -0
- package/dist/esm/utils/activityCursor.js +93 -0
- package/dist/esm/utils/activityCursor.js.map +1 -0
- package/dist/esm/utils/apiClient.d.ts +90 -0
- package/dist/esm/utils/apiClient.d.ts.map +1 -0
- package/dist/esm/utils/apiClient.js +169 -0
- package/dist/esm/utils/apiClient.js.map +1 -0
- package/dist/esm/utils/index.d.ts +11 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +12 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/liquidation.d.ts +20 -0
- package/dist/esm/utils/liquidation.d.ts.map +1 -0
- package/dist/esm/utils/liquidation.js +29 -0
- package/dist/esm/utils/liquidation.js.map +1 -0
- package/dist/esm/utils/mapActivity.d.ts +21 -0
- package/dist/esm/utils/mapActivity.d.ts.map +1 -0
- package/dist/esm/utils/mapActivity.js +45 -0
- package/dist/esm/utils/mapActivity.js.map +1 -0
- package/dist/esm/utils/mapFill.d.ts +12 -0
- package/dist/esm/utils/mapFill.d.ts.map +1 -0
- package/dist/esm/utils/mapFill.js +37 -0
- package/dist/esm/utils/mapFill.js.map +1 -0
- package/dist/esm/utils/mapOrder.d.ts +50 -0
- package/dist/esm/utils/mapOrder.d.ts.map +1 -0
- package/dist/esm/utils/mapOrder.js +155 -0
- package/dist/esm/utils/mapOrder.js.map +1 -0
- package/dist/esm/utils/mapPosition.d.ts +19 -0
- package/dist/esm/utils/mapPosition.d.ts.map +1 -0
- package/dist/esm/utils/mapPosition.js +32 -0
- package/dist/esm/utils/mapPosition.js.map +1 -0
- package/dist/esm/utils/ohlcvInterval.d.ts +11 -0
- package/dist/esm/utils/ohlcvInterval.d.ts.map +1 -0
- package/dist/esm/utils/ohlcvInterval.js +59 -0
- package/dist/esm/utils/ohlcvInterval.js.map +1 -0
- package/dist/esm/utils/ondoAsset.d.ts +4 -0
- package/dist/esm/utils/ondoAsset.d.ts.map +1 -0
- package/dist/esm/utils/ondoAsset.js +9 -0
- package/dist/esm/utils/ondoAsset.js.map +1 -0
- package/dist/esm/utils/orderFormatting.d.ts +33 -0
- package/dist/esm/utils/orderFormatting.d.ts.map +1 -0
- package/dist/esm/utils/orderFormatting.js +62 -0
- package/dist/esm/utils/orderFormatting.js.map +1 -0
- package/dist/esm/websocket/OndoWsProvider.d.ts +122 -0
- package/dist/esm/websocket/OndoWsProvider.d.ts.map +1 -0
- package/dist/esm/websocket/OndoWsProvider.js +591 -0
- package/dist/esm/websocket/OndoWsProvider.js.map +1 -0
- package/dist/types/OndoProvider.d.ts +39 -0
- package/dist/types/OndoProvider.d.ts.map +1 -0
- package/dist/types/accountConfig.d.ts +13 -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/auth/OndoTokenStore.d.ts +20 -0
- package/dist/types/auth/OndoTokenStore.d.ts.map +1 -0
- package/dist/types/auth/completeSiweLogin.d.ts +28 -0
- package/dist/types/auth/completeSiweLogin.d.ts.map +1 -0
- package/dist/types/auth/index.d.ts +4 -0
- package/dist/types/auth/index.d.ts.map +1 -0
- package/dist/types/auth/signActions.d.ts +35 -0
- package/dist/types/auth/signActions.d.ts.map +1 -0
- package/dist/types/constants.d.ts +35 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/auth.d.ts +32 -0
- package/dist/types/types/auth.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/wire.d.ts +195 -0
- package/dist/types/types/wire.d.ts.map +1 -0
- package/dist/types/types/ws.d.ts +108 -0
- package/dist/types/types/ws.d.ts.map +1 -0
- package/dist/types/utils/activityCursor.d.ts +47 -0
- package/dist/types/utils/activityCursor.d.ts.map +1 -0
- package/dist/types/utils/apiClient.d.ts +90 -0
- package/dist/types/utils/apiClient.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +11 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/liquidation.d.ts +20 -0
- package/dist/types/utils/liquidation.d.ts.map +1 -0
- package/dist/types/utils/mapActivity.d.ts +21 -0
- package/dist/types/utils/mapActivity.d.ts.map +1 -0
- package/dist/types/utils/mapFill.d.ts +12 -0
- package/dist/types/utils/mapFill.d.ts.map +1 -0
- package/dist/types/utils/mapOrder.d.ts +50 -0
- package/dist/types/utils/mapOrder.d.ts.map +1 -0
- package/dist/types/utils/mapPosition.d.ts +19 -0
- package/dist/types/utils/mapPosition.d.ts.map +1 -0
- package/dist/types/utils/ohlcvInterval.d.ts +11 -0
- package/dist/types/utils/ohlcvInterval.d.ts.map +1 -0
- package/dist/types/utils/ondoAsset.d.ts +4 -0
- package/dist/types/utils/ondoAsset.d.ts.map +1 -0
- package/dist/types/utils/orderFormatting.d.ts +33 -0
- package/dist/types/utils/orderFormatting.d.ts.map +1 -0
- package/dist/types/websocket/OndoWsProvider.d.ts +122 -0
- package/dist/types/websocket/OndoWsProvider.d.ts.map +1 -0
- package/package.json +64 -0
- package/src/OndoProvider.ts +635 -0
- package/src/accountConfig.ts +105 -0
- package/src/accountSummary.ts +22 -0
- package/src/auth/OndoTokenStore.ts +83 -0
- package/src/auth/completeSiweLogin.ts +43 -0
- package/src/auth/index.ts +12 -0
- package/src/auth/signActions.ts +160 -0
- package/src/constants.ts +38 -0
- package/src/index.ts +36 -0
- package/src/types/auth.ts +32 -0
- package/src/types/index.ts +5 -0
- package/src/types/wire.ts +228 -0
- package/src/types/ws.ts +79 -0
- package/src/utils/activityCursor.ts +140 -0
- package/src/utils/apiClient.ts +257 -0
- package/src/utils/index.ts +35 -0
- package/src/utils/liquidation.ts +37 -0
- package/src/utils/mapActivity.ts +61 -0
- package/src/utils/mapFill.ts +47 -0
- package/src/utils/mapOrder.ts +201 -0
- package/src/utils/mapPosition.ts +44 -0
- package/src/utils/ohlcvInterval.ts +69 -0
- package/src/utils/ondoAsset.ts +10 -0
- package/src/utils/orderFormatting.ts +70 -0
- package/src/websocket/OndoWsProvider.ts +752 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AccountConfig, AccountConfigSetting, ProviderAction } from '@lifi/perps-types';
|
|
2
|
+
/**
|
|
3
|
+
* Project the union of Ondo setup + options descriptors against the typed
|
|
4
|
+
* `OndoAccountConfig`. Produces exactly one `AccountConfigSetting` per
|
|
5
|
+
* descriptor, in `setup`-then-`options` order.
|
|
6
|
+
*
|
|
7
|
+
* @param config Typed account state; a non-`ondo` config throws `SDKError`.
|
|
8
|
+
* @param setup `Provider.setup` array as emitted by `/providers`.
|
|
9
|
+
* @param options `Provider.options` array as emitted by `/providers`.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function projectOndoConfigSettings(config: AccountConfig, setup: ProviderAction[], options: ProviderAction[]): AccountConfigSetting[];
|
|
13
|
+
//# 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,aAAa,EACb,oBAAoB,EAEpB,cAAc,EACf,MAAM,mBAAmB,CAAA;AA0E1B;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,cAAc,EAAE,GACxB,oBAAoB,EAAE,CAUxB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AccountResponse, AccountSummary, Position } from '@lifi/perps-types';
|
|
2
|
+
/**
|
|
3
|
+
* Roll an Ondo {@link AccountResponse} up into an {@link AccountSummary}.
|
|
4
|
+
* Ondo's collateral row holds `walletBalance`, which includes locked margin
|
|
5
|
+
* but not unrealized PnL (the positions carry it) — gross semantics: the
|
|
6
|
+
* venue counts unrealized PnL toward buying power
|
|
7
|
+
* (`availableMargin = marginBalance − usedMargin`).
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAccountSummary(account: AccountResponse, positions: Position[]): AccountSummary;
|
|
12
|
+
//# sourceMappingURL=accountSummary.d.ts.map
|
|
@@ -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;AAE1B;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EACxB,SAAS,EAAE,QAAQ,EAAE,GACpB,cAAc,CAEhB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type StorageAdapter } from '@lifi/perps-sdk';
|
|
2
|
+
import type { Address } from 'viem';
|
|
3
|
+
import type { OndoAuthToken } from '../types/auth.js';
|
|
4
|
+
/**
|
|
5
|
+
* Persists the Ondo session token per wallet address and environment via a
|
|
6
|
+
* `StorageAdapter`. An expired token reads back as absent (and is evicted),
|
|
7
|
+
* so callers can treat `null` uniformly as "run the SIWE login".
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare class OndoTokenStore {
|
|
12
|
+
private readonly storage;
|
|
13
|
+
private readonly host;
|
|
14
|
+
constructor(storage: StorageAdapter, baseUrl: string);
|
|
15
|
+
private storageKey;
|
|
16
|
+
get(address: Address): Promise<OndoAuthToken | null>;
|
|
17
|
+
set(address: Address, token: OndoAuthToken): Promise<void>;
|
|
18
|
+
remove(address: Address): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=OndoTokenStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OndoTokenStore.d.ts","sourceRoot":"","sources":["../../../src/auth/OndoTokenStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAsCrD;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;gBAEjB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;IAKpD,OAAO,CAAC,UAAU;IAMZ,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAapD,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PerpsClientSigner } from '@lifi/perps-sdk';
|
|
2
|
+
import type { Hex } from 'viem';
|
|
3
|
+
import type { OndoAuthToken } from '../types/auth.js';
|
|
4
|
+
import type { OndoApiClient } from '../utils/apiClient.js';
|
|
5
|
+
/**
|
|
6
|
+
* SIWE challenge to sign, as issued by Ondo's `get_challenge`.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface OndoSiweChallenge {
|
|
11
|
+
id: string;
|
|
12
|
+
/** Plain-text ERC-4361 message; signed as-is via `personal_sign`. */
|
|
13
|
+
message: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sign a SIWE challenge with the user's wallet and exchange it for an Ondo
|
|
17
|
+
* session token, directly against Ondo — the returned JWT never transits the
|
|
18
|
+
* LI.FI backend. viem's `signMessage` performs the EIP-191 `personal_sign`
|
|
19
|
+
* encoding Ondo verifies against. The signature is returned alongside the
|
|
20
|
+
* token so callers can hand it back as a `SiweSignedActionStep`.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare function completeSiweLogin(client: OndoApiClient, signer: PerpsClientSigner, challenge: OndoSiweChallenge): Promise<{
|
|
25
|
+
token: OndoAuthToken;
|
|
26
|
+
signature: Hex;
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=completeSiweLogin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completeSiweLogin.d.ts","sourceRoot":"","sources":["../../../src/auth/completeSiweLogin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,GAAG,CAAA;CAAE,CAAC,CAanD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { completeSiweLogin, type OndoSiweChallenge, } from './completeSiweLogin.js';
|
|
2
|
+
export { OndoTokenStore } from './OndoTokenStore.js';
|
|
3
|
+
export { executeOndoRestCallActions, type OndoSignActionsDeps, ondoSignActions, } from './signActions.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,GACvB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EACL,0BAA0B,EAC1B,KAAK,mBAAmB,EACxB,eAAe,GAChB,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type SignActionsContext } from '@lifi/perps-sdk';
|
|
2
|
+
import type { ActionResult, ActionStep, RestCallSignedActionStep, SignedActionStep } from '@lifi/perps-types';
|
|
3
|
+
import { SigningMethod } from '@lifi/perps-types';
|
|
4
|
+
import type { Address } from 'viem';
|
|
5
|
+
import { type OndoApiClient } from '../utils/apiClient.js';
|
|
6
|
+
import type { OndoTokenStore } from './OndoTokenStore.js';
|
|
7
|
+
/** @internal */
|
|
8
|
+
export interface OndoSignActionsDeps {
|
|
9
|
+
client: OndoApiClient;
|
|
10
|
+
tokenStore: OndoTokenStore;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ondo's `signActions` arms.
|
|
14
|
+
*
|
|
15
|
+
* `SIWE` signs the backend-built ERC-4361 challenge with the user's wallet
|
|
16
|
+
* and completes the login directly against Ondo — the returned session JWT is
|
|
17
|
+
* persisted in the token store and never transits the LI.FI backend.
|
|
18
|
+
*
|
|
19
|
+
* `AUTH_TOKEN` attaches the stored session JWT as an `Authorization: Bearer`
|
|
20
|
+
* header on each REST-call step; an absent or expired token throws
|
|
21
|
+
* {@link OndoSessionExpiredError} so callers re-run the SIWE login.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function ondoSignActions(deps: OndoSignActionsDeps, method: SigningMethod, steps: ActionStep[], address: Address, ctx?: SignActionsContext): Promise<SignedActionStep[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Execute credential-bearing REST-call steps directly against Ondo,
|
|
28
|
+
* sequentially — later steps in a batch may depend on earlier ones (e.g.
|
|
29
|
+
* leverage update before order placement), so after the first failure the
|
|
30
|
+
* remainder is skipped rather than executed out of order.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function executeOndoRestCallActions(client: OndoApiClient, steps: RestCallSignedActionStep[]): Promise<ActionResult[]>;
|
|
35
|
+
//# sourceMappingURL=signActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signActions.d.ts","sourceRoot":"","sources":["../../../src/auth/signActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,wBAAwB,EACxB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAkB,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAA;IACrB,UAAU,EAAE,cAAc,CAAA;CAC3B;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,mBAAmB,EACzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA0D7B;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,wBAAwB,EAAE,GAChC,OAAO,CAAC,YAAY,EAAE,CAAC,CAuCzB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ondo provider key as it appears on `Provider.key` from the backend.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare const ONDO_PROVIDER_KEY = "ondo";
|
|
7
|
+
/**
|
|
8
|
+
* Default (production) REST base URL for Ondo Perps.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_ONDO_API_URL = "https://api.ondoperps.xyz";
|
|
13
|
+
/**
|
|
14
|
+
* Sandbox REST base URL for Ondo Perps.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const ONDO_SANDBOX_API_URL = "https://api.ondoperps-sandbox.xyz";
|
|
19
|
+
/**
|
|
20
|
+
* Default (production) WebSocket URL for Ondo Perps.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_ONDO_WS_URL = "wss://api.ondoperps.xyz/ws";
|
|
25
|
+
/**
|
|
26
|
+
* Ondo's public base fee schedule (2 bps maker / 5 bps taker). Ondo exposes no
|
|
27
|
+
* per-account fee endpoint, so quotes and account snapshots use this schedule.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const ONDO_BASE_FEE_TIER: {
|
|
32
|
+
maker: string;
|
|
33
|
+
taker: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,SAAS,CAAA;AAEvC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,8BAA8B,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,sCAAsC,CAAA;AAEvE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,+BAA+B,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ondo Perps provider plugin for `@lifi/perps-sdk`. Ondo authenticates with a
|
|
3
|
+
* client-held session JWT obtained through a SIWE (ERC-4361) login — this
|
|
4
|
+
* package owns the venue HTTP boundary (`OndoApiClient`), the login completion
|
|
5
|
+
* (`completeSiweLogin`), and browser-side persistence of the session token
|
|
6
|
+
* (`OndoTokenStore`). The JWT never transits the LI.FI backend.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export { projectOndoConfigSettings } from './accountConfig.js';
|
|
12
|
+
export { getAccountSummary } from './accountSummary.js';
|
|
13
|
+
export * from './auth/index.js';
|
|
14
|
+
export { DEFAULT_ONDO_API_URL, DEFAULT_ONDO_WS_URL, ONDO_BASE_FEE_TIER, ONDO_PROVIDER_KEY, ONDO_SANDBOX_API_URL, } from './constants.js';
|
|
15
|
+
export { Ondo, type OndoProviderOptions, ondoProvider, } from './OndoProvider.js';
|
|
16
|
+
export * from './types/index.js';
|
|
17
|
+
export * from './utils/index.js';
|
|
18
|
+
export { OndoWsProvider, type OndoWsProviderOptions, ondoWsProvider, } from './websocket/OndoWsProvider.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,IAAI,EACJ,KAAK,mBAAmB,EACxB,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,cAAc,GACf,MAAM,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Envelope wrapping every Ondo REST response: `result` is present on
|
|
3
|
+
* success, `error`/`error_code` on failure.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface OndoGenericResponse<T> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
/** Machine-readable failure discriminator (per-endpoint enum). */
|
|
11
|
+
error_code?: string;
|
|
12
|
+
result?: T;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Ondo session credential returned by `complete_challenge`. `token` is the
|
|
16
|
+
* JWT presented as `Authorization: Bearer` on subsequent calls.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface OndoAuthToken {
|
|
21
|
+
identifier: string;
|
|
22
|
+
authType: string;
|
|
23
|
+
accountId: string;
|
|
24
|
+
/** Absolute unix timestamp (seconds). */
|
|
25
|
+
issuedAtSecs: number;
|
|
26
|
+
/** Absolute unix timestamp (seconds) — not a duration. */
|
|
27
|
+
expirationSecs: number;
|
|
28
|
+
token: string;
|
|
29
|
+
/** True when this login created the Ondo account. */
|
|
30
|
+
newAccount: boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/types/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,CAAC,CAAA;CACX;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACnE,mBAAmB,WAAW,CAAA;AAC9B,mBAAmB,SAAS,CAAA"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ondo REST wire types (`Ondo*`), mirroring the Ondo Perps OpenAPI schemas.
|
|
3
|
+
* All numeric quantities arrive as strings; timestamps are ISO 8601 strings
|
|
4
|
+
* unless a field says otherwise.
|
|
5
|
+
*/
|
|
6
|
+
/** Cursor pair Ondo returns as a sibling of `result` on paginated endpoints. */
|
|
7
|
+
export interface OndoPageInfo {
|
|
8
|
+
prevCursor?: string;
|
|
9
|
+
nextCursor?: string;
|
|
10
|
+
}
|
|
11
|
+
/** @public */
|
|
12
|
+
export type OndoPositionDirection = 'long' | 'short' | 'neutral';
|
|
13
|
+
/** Mirrors Ondo's `ApiPosition`. @public */
|
|
14
|
+
export interface OndoPosition {
|
|
15
|
+
market: string;
|
|
16
|
+
direction: OndoPositionDirection;
|
|
17
|
+
/** Position size in base currency (unsigned magnitude). */
|
|
18
|
+
netQuantity: string;
|
|
19
|
+
averageEntryPrice: string;
|
|
20
|
+
usedMargin: string;
|
|
21
|
+
unrealizedPnl: string;
|
|
22
|
+
markPrice: string;
|
|
23
|
+
liquidationPrice: string;
|
|
24
|
+
bankruptcyPrice: string;
|
|
25
|
+
maintenanceMargin: string;
|
|
26
|
+
notionalValue: string;
|
|
27
|
+
leverage: string;
|
|
28
|
+
netFundingSinceNeutral: string;
|
|
29
|
+
returnOnEquity: string;
|
|
30
|
+
stopLossTriggerPrice?: string;
|
|
31
|
+
takeProfitTriggerPrice?: string;
|
|
32
|
+
}
|
|
33
|
+
/** @public */
|
|
34
|
+
export type OndoOrderSide = 'buy' | 'sell';
|
|
35
|
+
/** @public */
|
|
36
|
+
export type OndoOrderStatus = 'open' | 'fullyfilled' | 'canceled' | 'pending' | 'untriggered';
|
|
37
|
+
/** @public */
|
|
38
|
+
export type OndoOrderType = 'limit' | 'market' | 'stopMarket' | 'takeProfitMarket';
|
|
39
|
+
/** @public */
|
|
40
|
+
export type OndoTimeInForce = 'GTC' | 'IOC';
|
|
41
|
+
/** @public */
|
|
42
|
+
export type OndoStopOrderType = 'stopLoss' | 'takeProfit';
|
|
43
|
+
/** Mirrors Ondo's `ApiOrder`. @public */
|
|
44
|
+
export interface OndoOrder {
|
|
45
|
+
orderId: string;
|
|
46
|
+
side: OndoOrderSide;
|
|
47
|
+
price: string;
|
|
48
|
+
size: string;
|
|
49
|
+
market: string;
|
|
50
|
+
filledSize: string;
|
|
51
|
+
lastFillSize: string;
|
|
52
|
+
filledCost: string;
|
|
53
|
+
fee: string;
|
|
54
|
+
status: OndoOrderStatus;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
type: OndoOrderType;
|
|
57
|
+
clientOrderId?: string;
|
|
58
|
+
parentOrderId?: string;
|
|
59
|
+
realizedPnl?: string;
|
|
60
|
+
feeRebate?: string;
|
|
61
|
+
filledAt?: string;
|
|
62
|
+
canceledAt?: string;
|
|
63
|
+
cancelReason?: string;
|
|
64
|
+
/** Not returned for market orders. */
|
|
65
|
+
timeInForce?: OndoTimeInForce;
|
|
66
|
+
reduceOnly?: boolean;
|
|
67
|
+
liquidationId?: string;
|
|
68
|
+
/** Position-level TP/SL flag. */
|
|
69
|
+
closePosition?: boolean;
|
|
70
|
+
stopOrderType?: OndoStopOrderType;
|
|
71
|
+
triggerPrice?: string;
|
|
72
|
+
}
|
|
73
|
+
/** @public */
|
|
74
|
+
export type OndoFillDirection = 'openLong' | 'openShort' | 'closeLong' | 'closeShort' | 'flipLongToShort' | 'flipShortToLong';
|
|
75
|
+
/** Mirrors Ondo's `ApiFill`. @public */
|
|
76
|
+
export interface OndoFill {
|
|
77
|
+
id: string;
|
|
78
|
+
orderId: string;
|
|
79
|
+
market: string;
|
|
80
|
+
price: string;
|
|
81
|
+
size: string;
|
|
82
|
+
side: OndoOrderSide;
|
|
83
|
+
filledCost: string;
|
|
84
|
+
fee: string;
|
|
85
|
+
time: string;
|
|
86
|
+
isMaker: boolean;
|
|
87
|
+
clientOrderId?: string;
|
|
88
|
+
parentOrderID?: string;
|
|
89
|
+
direction?: OndoFillDirection;
|
|
90
|
+
feeRebate?: string;
|
|
91
|
+
pnl?: string;
|
|
92
|
+
isADL?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Mirrors Ondo's `MarginAccountBalanceSummary`. Invariants per the docs:
|
|
96
|
+
* `marginBalance = walletBalance + unrealizedPnl`,
|
|
97
|
+
* `availableMargin = marginBalance − usedMargin`.
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export interface OndoBalanceSummary {
|
|
101
|
+
walletBalance: string;
|
|
102
|
+
realizedPnl: string;
|
|
103
|
+
unrealizedPnl: string;
|
|
104
|
+
marginBalance: string;
|
|
105
|
+
usedMargin: string;
|
|
106
|
+
availableMargin: string;
|
|
107
|
+
withdrawableMargin: string;
|
|
108
|
+
maintenanceMarginRequirement: string;
|
|
109
|
+
totalMaintenanceMargin: string;
|
|
110
|
+
marginRatio: string;
|
|
111
|
+
leverage: string;
|
|
112
|
+
underLiquidation: boolean;
|
|
113
|
+
totalFundingPayments: string;
|
|
114
|
+
totalTradingFees: string;
|
|
115
|
+
totalPnL: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* `GET /v1/account/referral` result: the referral applied to the account.
|
|
119
|
+
* The endpoint is absent from Ondo's published OpenAPI spec; shape mirrors the
|
|
120
|
+
* venue web app. `result` is `null` when no referral is applied.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export interface OndoAccountReferral {
|
|
124
|
+
/** The referrer's code applied to this account. */
|
|
125
|
+
code: string;
|
|
126
|
+
/** Rebate share of trading fees returned to the referred account. */
|
|
127
|
+
rebate?: number;
|
|
128
|
+
}
|
|
129
|
+
/** Mirrors Ondo's `Contract` (perps contract ticker row). @public */
|
|
130
|
+
export interface OndoContract {
|
|
131
|
+
market: string;
|
|
132
|
+
productType: string;
|
|
133
|
+
contractType: string;
|
|
134
|
+
baseCurrency: string;
|
|
135
|
+
quoteCurrency: string;
|
|
136
|
+
disabled: boolean;
|
|
137
|
+
displayName?: string;
|
|
138
|
+
lastPrice?: string;
|
|
139
|
+
indexPrice?: string;
|
|
140
|
+
fundingRate?: string;
|
|
141
|
+
nextFundingRate?: string;
|
|
142
|
+
nextFundingRateTimestamp?: string;
|
|
143
|
+
makerFee?: string;
|
|
144
|
+
takerFee?: string;
|
|
145
|
+
openInterest?: string;
|
|
146
|
+
openInterestUsd?: string;
|
|
147
|
+
priceChangePercent?: string;
|
|
148
|
+
isClosed?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** Mirrors Ondo's `FundingFeeTransfer`. Carries no id — callers synthesize one. @public */
|
|
151
|
+
export interface OndoFundingFeeTransfer {
|
|
152
|
+
market: string;
|
|
153
|
+
time: string;
|
|
154
|
+
markPrice: string;
|
|
155
|
+
positionSize: string;
|
|
156
|
+
positionDirection: OndoPositionDirection;
|
|
157
|
+
rate: string;
|
|
158
|
+
/** Which side paid this interval. */
|
|
159
|
+
payer: OndoPositionDirection;
|
|
160
|
+
/** Signed: positive = earned, negative = paid. */
|
|
161
|
+
amount: string;
|
|
162
|
+
}
|
|
163
|
+
/** @public */
|
|
164
|
+
export type OndoLiquidationStatus = 'queued' | 'start' | 'retry' | 'stop';
|
|
165
|
+
/** Mirrors Ondo's `LiquidationEvent`. @public */
|
|
166
|
+
export interface OndoLiquidationEvent {
|
|
167
|
+
id: string;
|
|
168
|
+
time: string;
|
|
169
|
+
initiatedAt: string;
|
|
170
|
+
accountId: string;
|
|
171
|
+
status: OndoLiquidationStatus;
|
|
172
|
+
insuranceFundUsed: string;
|
|
173
|
+
adl: boolean;
|
|
174
|
+
retryCount: number;
|
|
175
|
+
triggeringPositions?: OndoPosition[];
|
|
176
|
+
filledQuoteSize?: string;
|
|
177
|
+
filledQuantity?: string;
|
|
178
|
+
reclaimOrderMargin?: boolean;
|
|
179
|
+
}
|
|
180
|
+
/** @public */
|
|
181
|
+
export type OndoAccountState = 'open' | 'disabled' | 'offboarding' | 'closed';
|
|
182
|
+
/** Mirrors Ondo's `AccountInfo` (the `/v1/account` result). @public */
|
|
183
|
+
export interface OndoAccountInfo {
|
|
184
|
+
accountID: string;
|
|
185
|
+
identifier: string;
|
|
186
|
+
authType: string;
|
|
187
|
+
accountState: OndoAccountState;
|
|
188
|
+
withdrawalFeeUSD: string;
|
|
189
|
+
termsVersion: number;
|
|
190
|
+
termsUnixSecs: number;
|
|
191
|
+
privacyVersion: number;
|
|
192
|
+
privacyUnixSecs: number;
|
|
193
|
+
marketingConsent: string;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=wire.d.ts.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E,CAAA;IACpC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,cAAc;AACd,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAA;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,gBAAgB,CAAA;IAC9B,gBAAgB,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ondo WebSocket wire types. Client ops are `{op, ...args}` envelopes (only
|
|
3
|
+
* `login` nests its arguments); server data frames are
|
|
4
|
+
* `{type: 'update', channel, data}`.
|
|
5
|
+
*/
|
|
6
|
+
import type { OndoFill, OndoOrder, OndoPosition } from './wire.js';
|
|
7
|
+
/** Level tuple as streamed: `[price, size]`, both decimal strings. @public */
|
|
8
|
+
export type OndoBookLevel = [string, string];
|
|
9
|
+
/** Streamed order-book snapshot (`depthBooksPerps`/`topOfBooksPerps`). @public */
|
|
10
|
+
export interface OndoBookSnapshot {
|
|
11
|
+
market: string;
|
|
12
|
+
time: string;
|
|
13
|
+
asks: OndoBookLevel[];
|
|
14
|
+
bids: OndoBookLevel[];
|
|
15
|
+
depthLevels?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Streamed public trade (`tradesPerps`). @public */
|
|
18
|
+
export interface OndoWsTrade {
|
|
19
|
+
market: string;
|
|
20
|
+
price: string;
|
|
21
|
+
size: string;
|
|
22
|
+
cost: string;
|
|
23
|
+
aggressor_side: 'buy' | 'sell';
|
|
24
|
+
time: string;
|
|
25
|
+
id: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Streamed candlestick (`kLinePerps`). Prices and volume arrive as numbers,
|
|
29
|
+
* unlike the string-typed REST shapes; `s`/`e`/`t` are Unix seconds.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export interface OndoKline {
|
|
33
|
+
m: string;
|
|
34
|
+
t: number;
|
|
35
|
+
s: number;
|
|
36
|
+
e: number;
|
|
37
|
+
o: number;
|
|
38
|
+
h: number;
|
|
39
|
+
l: number;
|
|
40
|
+
c: number;
|
|
41
|
+
v: number;
|
|
42
|
+
x: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** Streamed mark price (`markPricesPerps`). @public */
|
|
45
|
+
export interface OndoMarkPrice {
|
|
46
|
+
market: string;
|
|
47
|
+
markPrice: string;
|
|
48
|
+
}
|
|
49
|
+
/** Streamed funding rate (`fundingRatesPerps`). @public */
|
|
50
|
+
export interface OndoFundingRate {
|
|
51
|
+
market: string;
|
|
52
|
+
rate: string;
|
|
53
|
+
intervalEnds: string;
|
|
54
|
+
premiums?: unknown[];
|
|
55
|
+
}
|
|
56
|
+
/** Server frame envelope. Non-`update` types are acks or errors. @public */
|
|
57
|
+
export type OndoWsMessage = {
|
|
58
|
+
type: 'update';
|
|
59
|
+
channel: 'depthBooksPerps';
|
|
60
|
+
data: OndoBookSnapshot[];
|
|
61
|
+
} | {
|
|
62
|
+
type: 'update';
|
|
63
|
+
channel: 'tradesPerps';
|
|
64
|
+
data: OndoWsTrade[];
|
|
65
|
+
} | {
|
|
66
|
+
type: 'update';
|
|
67
|
+
channel: 'kLinePerps';
|
|
68
|
+
data: OndoKline;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'update';
|
|
71
|
+
channel: 'markPricesPerps';
|
|
72
|
+
data: OndoMarkPrice[];
|
|
73
|
+
} | {
|
|
74
|
+
type: 'update';
|
|
75
|
+
channel: 'fundingRatesPerps';
|
|
76
|
+
data: OndoFundingRate[];
|
|
77
|
+
} | {
|
|
78
|
+
type: 'update';
|
|
79
|
+
channel: 'ordersPerps';
|
|
80
|
+
data: OndoOrder[];
|
|
81
|
+
} | {
|
|
82
|
+
type: 'update';
|
|
83
|
+
channel: 'fillsPerps';
|
|
84
|
+
data: OndoFill[];
|
|
85
|
+
} | {
|
|
86
|
+
type: 'update';
|
|
87
|
+
channel: 'positionsPerps';
|
|
88
|
+
data: OndoPosition[];
|
|
89
|
+
} | {
|
|
90
|
+
type: 'update';
|
|
91
|
+
channel: string;
|
|
92
|
+
data: unknown;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'pong';
|
|
95
|
+
} | {
|
|
96
|
+
type: 'loggedIn';
|
|
97
|
+
msg?: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: 'subscribed';
|
|
100
|
+
channel?: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: 'unsubscribed';
|
|
103
|
+
channel?: string;
|
|
104
|
+
} | {
|
|
105
|
+
type: 'error';
|
|
106
|
+
msg?: string;
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=ws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/types/ws.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAElE,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE5C,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,WAAW,CAAC,EAAE,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or` returned by that endpoint on the
|
|
6
|
+
* previous call. When a key is **present** with a non-empty string the
|
|
7
|
+
* corresponding endpoint will be re-fetched at that cursor on the next call;
|
|
8
|
+
* when a key is **absent** the endpoint is treated as exhausted (or never
|
|
9
|
+
* paged because the type filter excluded it) and skipped.
|
|
10
|
+
*
|
|
11
|
+
* The envelope is round-tripped through `cursor` as base64url JSON so callers
|
|
12
|
+
* don't need to know the per-endpoint shape.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface OndoActivityCursor {
|
|
16
|
+
fundings?: string;
|
|
17
|
+
liquidations?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Already-fetched, merged-and-sorted rows that did not fit under the page
|
|
20
|
+
* `limit`. The upstream cursors above have advanced past these rows, so they
|
|
21
|
+
* are replayed (prepended) on the next page before any fresh fetch — without
|
|
22
|
+
* them the tail would be lost forever.
|
|
23
|
+
*/
|
|
24
|
+
overflow?: ActivityItem[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Encode an `OndoActivityCursor` as the base64url-of-JSON cursor string
|
|
28
|
+
* persisted between activity pages. Returns `undefined` when every
|
|
29
|
+
* per-endpoint key is empty and no `overflow` rows remain — the caller
|
|
30
|
+
* should report `hasMore: false` and omit `cursor` from `Pagination` then.
|
|
31
|
+
*
|
|
32
|
+
* Browser-direct: `Buffer` is Node-only. We use `btoa` over a Latin-1
|
|
33
|
+
* encoding of the UTF-8 bytes and then rewrite `+/=` to base64url. This is
|
|
34
|
+
* the same byte sequence Node's `Buffer.from(json, 'utf8').toString('base64url')`
|
|
35
|
+
* produces, so cursors round-trip across environments.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare const encodeActivityCursor: (env: OndoActivityCursor) => string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Decode a previously-encoded activity cursor. Returns `undefined` for an
|
|
41
|
+
* absent cursor (first page) and throws {@link PerpsError} with
|
|
42
|
+
* `ValidationError` if the string is malformed — we'd rather fail loudly than
|
|
43
|
+
* silently re-page from page 1 and re-deliver already-paginated rows.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare const decodeActivityCursor: (cursor: string | undefined) => OndoActivityCursor | undefined;
|
|
47
|
+
//# sourceMappingURL=activityCursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activityCursor.d.ts","sourceRoot":"","sources":["../../../src/utils/activityCursor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,mBAAmB,CAAA;AAErE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;CAC1B;AAOD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,kBAAkB,KACtB,MAAM,GAAG,SAcX,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,GAAG,SAAS,KACzB,kBAAkB,GAAG,SA6CvB,CAAA"}
|