@basedone/core 0.0.1 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4UEJOM6W.mjs +9 -0
- package/dist/index.d.mts +462 -0
- package/dist/index.d.ts +462 -2
- package/dist/index.js +37465 -2
- package/dist/index.mjs +1027 -0
- package/dist/lib/cloid.d.ts.map +1 -1
- package/dist/lib/cloid.js +11 -1
- package/dist/lib/cloid.js.map +1 -1
- package/dist/meta-52Q5UUQ4.mjs +1474 -0
- package/dist/meta-FTWJX4LV.mjs +1445 -0
- package/dist/meta-IKWYLG3Q.mjs +1316 -0
- package/dist/meta-UUXKK7IB.mjs +1355 -0
- package/dist/perpDexs-PSE3LEVV.mjs +9 -0
- package/dist/perpDexs-S3TK25EU.mjs +17 -0
- package/dist/perpDexs-TZIQ57IW.mjs +537 -0
- package/dist/perpDexs-YNEAJ3R5.mjs +7 -0
- package/dist/perpDexs-YS3QQSHW.mjs +338 -0
- package/dist/spotMeta-7IJT3W6H.mjs +6442 -0
- package/dist/spotMeta-LEO5QFNS.mjs +26392 -0
- package/dist/spotMeta-MC5UYLQ7.mjs +6335 -0
- package/dist/spotMeta-TXJWYTKI.mjs +26403 -0
- package/dist/spotMeta-VAANYV77.mjs +6346 -0
- package/dist/spotMeta-ZVBZNUUE.mjs +26559 -0
- package/index.ts +6 -0
- package/lib/cloid/README.md +233 -0
- package/lib/cloid/cloid.ts +368 -0
- package/lib/cloid/encoder.ts +60 -0
- package/lib/constants/fee.ts +2 -0
- package/lib/constants/tokens.ts +28 -0
- package/lib/fee.ts +105 -0
- package/lib/hip3/market-info.ts +25 -0
- package/lib/hip3/utils.ts +9 -0
- package/lib/meta/README.md +471 -0
- package/lib/meta/data/mainnet/meta.json +1462 -0
- package/lib/meta/data/mainnet/perpDexs.json +11 -0
- package/lib/meta/data/mainnet/spotMeta.json +6432 -0
- package/lib/meta/data/testnet/dexs/rrrrr.json +33 -0
- package/lib/meta/data/testnet/meta.json +1343 -0
- package/lib/meta/data/testnet/perpDexs.json +531 -0
- package/lib/meta/data/testnet/spotMeta.json +26547 -0
- package/lib/meta/metadata.ts +600 -0
- package/lib/pup/calculator.ts +221 -0
- package/lib/pup/index.ts +9 -0
- package/lib/pup/types.ts +94 -0
- package/lib/utils/formatter.ts +97 -0
- package/package.json +21 -17
- package/readme.md +0 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, PerpDex } from '@nktkas/hyperliquid';
|
|
2
|
+
|
|
3
|
+
declare function encodeSlug(slug: string): bigint;
|
|
4
|
+
declare function decodeSlug(value: bigint): string;
|
|
5
|
+
declare function buildCloid(version: number, slug: string, clientId: number, oid: bigint | string, // bitint for oid, string for encoded string slug (12 characters max)
|
|
6
|
+
options?: {
|
|
7
|
+
isMiniApp?: boolean;
|
|
8
|
+
miniAppTriggered?: boolean;
|
|
9
|
+
widgetType?: WidgetType | number;
|
|
10
|
+
}): `0x${string}`;
|
|
11
|
+
declare function parseCloid(cloidHex: `0x${string}`): {
|
|
12
|
+
prefix: string;
|
|
13
|
+
version: number;
|
|
14
|
+
slug: string;
|
|
15
|
+
clientId: number;
|
|
16
|
+
isMiniApp: boolean;
|
|
17
|
+
miniAppTriggered: boolean;
|
|
18
|
+
widgetTypeId: number;
|
|
19
|
+
oid: bigint;
|
|
20
|
+
decodedOid: string;
|
|
21
|
+
clientName: string;
|
|
22
|
+
widgetTypeName: string;
|
|
23
|
+
} | null;
|
|
24
|
+
type CloidData = ReturnType<typeof parseCloid>;
|
|
25
|
+
declare function isBasedCloid(cloidHex?: `0x${string}` | null): boolean;
|
|
26
|
+
declare function isTenantCloid(tenantTrackingSlug: string, cloidHex?: `0x${string}` | null): boolean;
|
|
27
|
+
declare function isTrackingIdCloid(trackingId: bigint | string, cloidHex?: `0x${string}` | null): boolean;
|
|
28
|
+
declare function normaliseSlug(slug: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Normalise a tracking id to 12 characters
|
|
31
|
+
* @param trackingId - The tracking id to normalise
|
|
32
|
+
* @returns The normalised tracking id
|
|
33
|
+
*/
|
|
34
|
+
declare function normaliseTrackingId(trackingId: string): string;
|
|
35
|
+
type ClientCode = string;
|
|
36
|
+
declare const CloidClientCode: {
|
|
37
|
+
readonly Unset: 0;
|
|
38
|
+
readonly Web: 1;
|
|
39
|
+
readonly App: 2;
|
|
40
|
+
readonly TgBot: 3;
|
|
41
|
+
readonly TSL: 4;
|
|
42
|
+
readonly Grid: 5;
|
|
43
|
+
readonly Chase: 6;
|
|
44
|
+
readonly Desktop: 7;
|
|
45
|
+
readonly API: 8;
|
|
46
|
+
};
|
|
47
|
+
type ClientCodeType = keyof typeof CloidClientCode;
|
|
48
|
+
type CloidClientCodeId = (typeof CloidClientCode)[ClientCodeType];
|
|
49
|
+
declare const CloidClientCodeNameById: Record<number, ClientCodeType>;
|
|
50
|
+
declare function getClientCodeNameById(id: number): string;
|
|
51
|
+
declare const WidgetType: {
|
|
52
|
+
readonly Unset: 0;
|
|
53
|
+
readonly SidePanel: 1;
|
|
54
|
+
readonly Widget: 2;
|
|
55
|
+
readonly FloatingWidget: 3;
|
|
56
|
+
};
|
|
57
|
+
type WidgetType = keyof typeof WidgetType;
|
|
58
|
+
type WidgetTypeId = (typeof WidgetType)[WidgetType];
|
|
59
|
+
declare const WidgetTypeById: Record<number, WidgetType>;
|
|
60
|
+
declare function getWidgetTypeById(id: number): string;
|
|
61
|
+
/**
|
|
62
|
+
* @param tenantCode - The tenant code (max 5 characters, truncated if longer) default: "BASED"
|
|
63
|
+
* @param clientCode CloidClientCode - The client code (max 5 characters, truncated if longer) default: "Unset"
|
|
64
|
+
* @param oid - The oid (64 bits) used for identifying unique orders, default: 0xBA5ED10000BA5ED1 or string for encoded string slug (12 characters max)
|
|
65
|
+
* @param attribution - Mini-app and component options
|
|
66
|
+
* @returns The cloid
|
|
67
|
+
*/
|
|
68
|
+
declare function getCloid(tenantCode?: ClientCode | null, clientCode?: ClientCodeType | number, oid?: bigint | string, attribution?: {
|
|
69
|
+
isMiniApp?: boolean;
|
|
70
|
+
miniAppTriggered?: boolean;
|
|
71
|
+
widgetType?: WidgetType | number;
|
|
72
|
+
}): `0x${string}`;
|
|
73
|
+
declare function isClientCode(clientCode: ClientCodeType | number, cloidHex: `0x${string}`): boolean;
|
|
74
|
+
declare function isWidgetType(widgetType: WidgetType | number, cloidHex: `0x${string}`): boolean;
|
|
75
|
+
declare function isMiniAppCloid(cloidHex: `0x${string}`): boolean;
|
|
76
|
+
declare function isMiniAppTriggeredCloid(cloidHex: `0x${string}`): boolean;
|
|
77
|
+
|
|
78
|
+
declare const TARGET_APPROVED_MAX_BUILDER_FEE: number;
|
|
79
|
+
declare const TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT = "0.1%";
|
|
80
|
+
/**
|
|
81
|
+
* Get the amount of builder fee to approve for
|
|
82
|
+
* @param perpetualTradingFee - Perp fee in percentage
|
|
83
|
+
* @param spotTradingFee - Spot fee in percentage
|
|
84
|
+
* @returns {
|
|
85
|
+
* amount: number; - The amount of builder fee to approve in 1/10 of a basis point
|
|
86
|
+
* percent: string; - eg. String input to approve fee, "0.1%"
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
declare const getApprovalAmount: ({ customFeeEnabled, perpetualTradingFee, spotTradingFee, }: {
|
|
90
|
+
customFeeEnabled: boolean;
|
|
91
|
+
perpetualTradingFee?: number;
|
|
92
|
+
spotTradingFee?: number;
|
|
93
|
+
}) => {
|
|
94
|
+
approvalAmount: number;
|
|
95
|
+
approvalPercent: `${string}%`;
|
|
96
|
+
perpFee: number;
|
|
97
|
+
spotFee: number;
|
|
98
|
+
builder: `0x${string}`;
|
|
99
|
+
referralCode: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* PUP Token Eligibility Types and Constants
|
|
104
|
+
*/
|
|
105
|
+
interface V3LPTokenInfo {
|
|
106
|
+
token0: {
|
|
107
|
+
price: number;
|
|
108
|
+
value: number;
|
|
109
|
+
amount: number;
|
|
110
|
+
symbol: string;
|
|
111
|
+
address: string;
|
|
112
|
+
};
|
|
113
|
+
token1: {
|
|
114
|
+
price: number;
|
|
115
|
+
value: number;
|
|
116
|
+
amount: number;
|
|
117
|
+
symbol: string;
|
|
118
|
+
address: string;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
interface UpheavalPosition {
|
|
122
|
+
pair: string;
|
|
123
|
+
pool: string;
|
|
124
|
+
value: number;
|
|
125
|
+
amount: string;
|
|
126
|
+
version: 'erc20' | 'v3' | 'v2';
|
|
127
|
+
v3LPTokenInfo?: V3LPTokenInfo;
|
|
128
|
+
}
|
|
129
|
+
interface UpheavalSnapshot {
|
|
130
|
+
id: string;
|
|
131
|
+
user_address: string;
|
|
132
|
+
total_lp_value: number;
|
|
133
|
+
position_count: number;
|
|
134
|
+
metadata: {
|
|
135
|
+
positions: UpheavalPosition[];
|
|
136
|
+
snapshot_date: string;
|
|
137
|
+
};
|
|
138
|
+
created_at: string;
|
|
139
|
+
userId: string | null;
|
|
140
|
+
}
|
|
141
|
+
interface UpheavalApiResponse {
|
|
142
|
+
success: boolean;
|
|
143
|
+
snapshot: {
|
|
144
|
+
timestamp: string;
|
|
145
|
+
user_count: number;
|
|
146
|
+
};
|
|
147
|
+
data: UpheavalSnapshot[];
|
|
148
|
+
cached_at: string;
|
|
149
|
+
filtered_by: string;
|
|
150
|
+
}
|
|
151
|
+
interface PupEligibilityResult {
|
|
152
|
+
isEligible: boolean;
|
|
153
|
+
boostPct: number;
|
|
154
|
+
isAirdropRecipient: boolean;
|
|
155
|
+
pupTokenAmount?: number;
|
|
156
|
+
totalLpValue?: number;
|
|
157
|
+
currentTier?: number;
|
|
158
|
+
currentBoost?: number;
|
|
159
|
+
nextTier?: number | null;
|
|
160
|
+
nextBoost?: number | null;
|
|
161
|
+
amountToNextTier?: number | null;
|
|
162
|
+
nextTierThreshold?: number | null;
|
|
163
|
+
progressPercentage?: number;
|
|
164
|
+
}
|
|
165
|
+
interface AirdropAllocationData {
|
|
166
|
+
amount: bigint | {
|
|
167
|
+
div: (divisor: number) => {
|
|
168
|
+
toNumber: () => number;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
walletAddress: string;
|
|
172
|
+
}
|
|
173
|
+
declare const PUP_TOKEN_ADDRESS = "0x876e7f2f30935118a654fc0e1f807afc49efe500";
|
|
174
|
+
declare const PUP_TOKEN_THRESHOLDS: {
|
|
175
|
+
readonly AIRDROP_70_PERCENT: 0.7;
|
|
176
|
+
readonly AIRDROP_35_PERCENT: 0.35;
|
|
177
|
+
readonly AIRDROP_110_PERCENT: 1.1;
|
|
178
|
+
readonly NON_AIRDROP_TOKENS: 2000000;
|
|
179
|
+
};
|
|
180
|
+
declare const XP_BOOST_PERCENTAGES: {
|
|
181
|
+
readonly NO_BOOST: 0;
|
|
182
|
+
readonly TIER_1: 25;
|
|
183
|
+
readonly TIER_2: 50;
|
|
184
|
+
readonly TIER_3: 60;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* PUP Token Calculation Logic
|
|
189
|
+
* Pure functions for calculating PUP amounts and boost percentages
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Calculate total PUP amount from all positions
|
|
194
|
+
* @param positions Array of Upheaval positions
|
|
195
|
+
* @returns Total PUP token amount
|
|
196
|
+
*/
|
|
197
|
+
declare function calculateTotalPupAmount(positions: UpheavalPosition[]): number;
|
|
198
|
+
/**
|
|
199
|
+
* Calculate XP boost percentage based on PUP holdings
|
|
200
|
+
* @param pupTokenAmount Current PUP token holdings
|
|
201
|
+
* @param normalizedAirDropAmount Normalized airdrop amount (divided by 1e18)
|
|
202
|
+
* @param isAirdropRecipient Whether user received an airdrop
|
|
203
|
+
* @returns Boost percentage (0, 25, 50, or 60)
|
|
204
|
+
*/
|
|
205
|
+
declare function calculateBoostPercentage(pupTokenAmount: number, normalizedAirDropAmount: number, isAirdropRecipient: boolean): number;
|
|
206
|
+
/**
|
|
207
|
+
* Normalize airdrop amount from BigInt or Prisma Decimal
|
|
208
|
+
* @param amount Airdrop amount from database
|
|
209
|
+
* @returns Normalized amount as number
|
|
210
|
+
*/
|
|
211
|
+
declare function normalizeAirdropAmount(amount: bigint | {
|
|
212
|
+
div: (divisor: number) => {
|
|
213
|
+
toNumber: () => number;
|
|
214
|
+
};
|
|
215
|
+
} | null | undefined): number;
|
|
216
|
+
/**
|
|
217
|
+
* Get information about the next tier and amount needed to reach it
|
|
218
|
+
* @param pupTokenAmount Current PUP token holdings
|
|
219
|
+
* @param normalizedAirDropAmount Normalized airdrop amount (divided by 1e18)
|
|
220
|
+
* @param isAirdropRecipient Whether user received an airdrop
|
|
221
|
+
* @returns Information about current tier and progression to next tier
|
|
222
|
+
*/
|
|
223
|
+
declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount: number, isAirdropRecipient: boolean): {
|
|
224
|
+
currentTier: number;
|
|
225
|
+
currentBoost: number;
|
|
226
|
+
nextTier: number | null;
|
|
227
|
+
nextBoost: number | null;
|
|
228
|
+
amountToNextTier: number | null;
|
|
229
|
+
nextTierThreshold: number | null;
|
|
230
|
+
progressPercentage: number;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
declare const USDC_SPOT_TOKEN: SpotToken;
|
|
234
|
+
declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Market information for trading operations
|
|
238
|
+
*/
|
|
239
|
+
interface MarketInfo {
|
|
240
|
+
symbol: string;
|
|
241
|
+
assetId: number;
|
|
242
|
+
szDecimals: number;
|
|
243
|
+
type: "perps" | "spot" | "hip3";
|
|
244
|
+
coin: string;
|
|
245
|
+
maxLeverage?: number;
|
|
246
|
+
baseToken?: SpotToken;
|
|
247
|
+
quoteToken?: SpotToken;
|
|
248
|
+
dexName?: string;
|
|
249
|
+
dexIndex?: number;
|
|
250
|
+
}
|
|
251
|
+
interface DexInfo {
|
|
252
|
+
meta: PerpsMeta;
|
|
253
|
+
assetContext: PerpsAssetCtx[];
|
|
254
|
+
dexFullName: string;
|
|
255
|
+
dexName: string;
|
|
256
|
+
dexIndex: number;
|
|
257
|
+
collateralTokenSymbol: string;
|
|
258
|
+
}
|
|
259
|
+
type ExtendedPerpsMeta = PerpsMeta & {
|
|
260
|
+
collateralToken?: number;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Spot token information
|
|
264
|
+
*/
|
|
265
|
+
interface TokenInfo {
|
|
266
|
+
name: string;
|
|
267
|
+
index: number;
|
|
268
|
+
szDecimals: number;
|
|
269
|
+
weiDecimals: number;
|
|
270
|
+
tokenId: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Configuration for MetadataClient
|
|
274
|
+
*/
|
|
275
|
+
interface MetadataClientConfig {
|
|
276
|
+
/** List of HIP-3 DEX names to load metadata for */
|
|
277
|
+
hip3Dexs?: string[];
|
|
278
|
+
/** Whether to lazily initialize (fetch metadata on first use) */
|
|
279
|
+
lazyInit?: boolean;
|
|
280
|
+
/** Whether to use testnet (default: false for mainnet) */
|
|
281
|
+
isTestnet?: boolean;
|
|
282
|
+
/** Use static fallback data only, no API fetch */
|
|
283
|
+
onlyUseStaticFallback?: boolean;
|
|
284
|
+
/** Whether to use static fallback data if API fetch fails (default: true) */
|
|
285
|
+
useStaticFallback?: boolean;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* MetadataClient - Handles Hyperliquid metadata for trading operations
|
|
289
|
+
*
|
|
290
|
+
* Provides a clean interface to:
|
|
291
|
+
* - Convert symbols to asset IDs and decimals
|
|
292
|
+
* - Handle spot markets with multiple quote assets (USDC, USDT0, USDH)
|
|
293
|
+
* - Support perpetuals and HIP-3 deployed DEXs
|
|
294
|
+
* - Calculate correct asset IDs per Hyperliquid spec
|
|
295
|
+
*
|
|
296
|
+
* Asset ID Calculation:
|
|
297
|
+
* - Perps: index in meta universe
|
|
298
|
+
* - Spot: 10000 + index
|
|
299
|
+
* - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
|
|
300
|
+
*/
|
|
301
|
+
declare class MetadataClient {
|
|
302
|
+
private infoClient;
|
|
303
|
+
private config;
|
|
304
|
+
private isTestnet;
|
|
305
|
+
private spotMeta;
|
|
306
|
+
private perpsMeta;
|
|
307
|
+
private perpDexs;
|
|
308
|
+
private hip3DexsMeta;
|
|
309
|
+
private perpsSymbolToIndex;
|
|
310
|
+
private spotTokenNameToIndex;
|
|
311
|
+
private spotPairToMarket;
|
|
312
|
+
private baseTokenToMarkets;
|
|
313
|
+
private quoteAssets;
|
|
314
|
+
private coinToMarket;
|
|
315
|
+
private hip3SymbolToMarket;
|
|
316
|
+
private dexNameToIndex;
|
|
317
|
+
private initialized;
|
|
318
|
+
constructor(config?: MetadataClientConfig);
|
|
319
|
+
/**
|
|
320
|
+
* Initialize metadata by fetching from Hyperliquid
|
|
321
|
+
*/
|
|
322
|
+
initialize(): Promise<void>;
|
|
323
|
+
/**
|
|
324
|
+
* Load static metadata from bundled JSON files
|
|
325
|
+
*/
|
|
326
|
+
private loadStaticMetadata;
|
|
327
|
+
/**
|
|
328
|
+
* Build optimized lookup maps from raw metadata
|
|
329
|
+
* Called after metadata is loaded (from API or static files)
|
|
330
|
+
*/
|
|
331
|
+
private buildLookupMaps;
|
|
332
|
+
/**
|
|
333
|
+
* Load metadata for a specific HIP-3 DEX
|
|
334
|
+
* Also builds optimized lookups for this DEX's markets
|
|
335
|
+
*/
|
|
336
|
+
loadHip3Metadata(dexName: string): Promise<DexInfo>;
|
|
337
|
+
/**
|
|
338
|
+
* Build optimized lookups for HIP-3 markets of a specific DEX
|
|
339
|
+
*/
|
|
340
|
+
private buildHip3MarketsForDex;
|
|
341
|
+
/**
|
|
342
|
+
* Ensure metadata is loaded (for lazy init)
|
|
343
|
+
*/
|
|
344
|
+
private ensureInitialized;
|
|
345
|
+
/**
|
|
346
|
+
* Get market information by symbol
|
|
347
|
+
* Optimized: O(1) direct map lookup for most cases
|
|
348
|
+
* Lazily initialize hip-3 metadata if not already initialized
|
|
349
|
+
*
|
|
350
|
+
* @param symbol - Market symbol (e.g., "BTC", "PURR/USDC", "vntls:ABC")
|
|
351
|
+
* @param quoteAsset - Quote asset for spot markets (default: "USDC")
|
|
352
|
+
* @returns Market information or null if not found
|
|
353
|
+
*/
|
|
354
|
+
getMarketBySymbolAsync(symbol: string, quoteAsset?: string): Promise<MarketInfo | null>;
|
|
355
|
+
getMarketByCoin(coin: string): MarketInfo | null;
|
|
356
|
+
/**
|
|
357
|
+
* Get perpetuals market information
|
|
358
|
+
* Optimized: O(1) map lookup instead of O(n) array search
|
|
359
|
+
*/
|
|
360
|
+
getPerpsMarket(symbol: string): MarketInfo | null;
|
|
361
|
+
/**
|
|
362
|
+
* Get spot market information
|
|
363
|
+
* Optimized: O(1) map lookup instead of O(n) array searches
|
|
364
|
+
*
|
|
365
|
+
* @param baseSymbol - Base token symbol (e.g., "PURR", "UHYPE")
|
|
366
|
+
* @param quoteSymbol - Quote token symbol (default: "USDC")
|
|
367
|
+
*/
|
|
368
|
+
getSpotMarket(baseSymbol: string, quoteSymbol?: string): MarketInfo | null;
|
|
369
|
+
/**
|
|
370
|
+
* Get HIP-3 market information
|
|
371
|
+
* Optimized: O(1) map lookup after DEX metadata is loaded
|
|
372
|
+
*
|
|
373
|
+
* @param symbol - HIP-3 market symbol (format: "dex:coin")
|
|
374
|
+
*/
|
|
375
|
+
getHip3Market(symbol: string): Promise<MarketInfo | null>;
|
|
376
|
+
getHip3Dex(dexName: string): Promise<DexInfo | null>;
|
|
377
|
+
/**
|
|
378
|
+
* Get all available markets for a base token
|
|
379
|
+
* Optimized: O(1) map lookup instead of O(n) filter + map
|
|
380
|
+
* Useful for showing all quote asset options
|
|
381
|
+
*/
|
|
382
|
+
getAllMarketsForBase(baseSymbol: string): MarketInfo[];
|
|
383
|
+
/**
|
|
384
|
+
* Get spot token information
|
|
385
|
+
* Optimized: O(1) map lookup instead of O(n) array search
|
|
386
|
+
*/
|
|
387
|
+
getSpotTokenInfo(tokenSymbol: string): TokenInfo | null;
|
|
388
|
+
/**
|
|
389
|
+
* Get all available quote assets
|
|
390
|
+
* Optimized: O(1) pre-computed array instead of O(n) computation
|
|
391
|
+
*/
|
|
392
|
+
getAvailableQuoteAssets(): string[];
|
|
393
|
+
/**
|
|
394
|
+
* Get raw metadata (for advanced use cases)
|
|
395
|
+
*/
|
|
396
|
+
getRawMetadata(): {
|
|
397
|
+
spotMeta: SpotMeta | null;
|
|
398
|
+
perpsMeta: PerpsMeta | null;
|
|
399
|
+
perpDexs: (PerpDex | null)[];
|
|
400
|
+
hip3DexsMeta: {
|
|
401
|
+
[k: string]: DexInfo;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Get network configuration
|
|
406
|
+
*/
|
|
407
|
+
getNetworkInfo(): {
|
|
408
|
+
isTestnet: boolean;
|
|
409
|
+
useStaticFallback: boolean | undefined;
|
|
410
|
+
initialized: boolean;
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
declare const formatPriceAndSize: ({ px, sz, szDecimals, isSpot, }: {
|
|
415
|
+
px: number;
|
|
416
|
+
sz: number;
|
|
417
|
+
szDecimals: number;
|
|
418
|
+
isSpot: boolean;
|
|
419
|
+
}) => {
|
|
420
|
+
price: number;
|
|
421
|
+
size: number;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* Formats price for order placement following Hyperliquid rules
|
|
425
|
+
* - Rounded to priceDecimals of the asset
|
|
426
|
+
* @param px - The price to format
|
|
427
|
+
* @param priceDecimals - Price decimals for the asset
|
|
428
|
+
* @returns Formatted price as number (rounded to priceDecimals if exceeds)
|
|
429
|
+
*/
|
|
430
|
+
declare const formatPriceForOrder: ({ px, szDecimals, isSpot, }: {
|
|
431
|
+
px: number;
|
|
432
|
+
szDecimals: number;
|
|
433
|
+
isSpot: boolean;
|
|
434
|
+
}) => number;
|
|
435
|
+
/**
|
|
436
|
+
* Formats size for order placement following Hyperliquid rules
|
|
437
|
+
* - Rounded to szDecimals of the asset
|
|
438
|
+
* @param sz - The size to format
|
|
439
|
+
* @param szDecimals - Size decimals for the asset
|
|
440
|
+
* @returns Formatted size as number (rounded down to szDecimals if exceeds)
|
|
441
|
+
*/
|
|
442
|
+
declare const formatSizeForOrder: ({ sz, szDecimals, }: {
|
|
443
|
+
sz: number;
|
|
444
|
+
szDecimals: number;
|
|
445
|
+
}) => number;
|
|
446
|
+
/**
|
|
447
|
+
* Get minimum price decimals for tick size calculations
|
|
448
|
+
* Uses the same logic as internal price formatting
|
|
449
|
+
*
|
|
450
|
+
* @param price - The current price
|
|
451
|
+
* @param szDecimals - Size decimals for the asset
|
|
452
|
+
* @param isSpot - Whether this is a spot market (true) or perp market (false)
|
|
453
|
+
* @returns Minimum decimal places for price display
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* getPriceDecimals(1234.5, 0, false) // 1 (PERP market)
|
|
457
|
+
* getPriceDecimals(0.00123, 0, true) // 6 (SPOT market)
|
|
458
|
+
* getPriceDecimals(100000, 0, false) // 0 (large prices)
|
|
459
|
+
*/
|
|
460
|
+
declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
|
|
461
|
+
|
|
462
|
+
export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PupEligibilityResult, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid };
|