logiqical 0.0.11 → 0.1.1
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/index.d.mts +260 -2
- package/dist/index.d.ts +260 -2
- package/dist/index.js +261 -1
- package/dist/index.mjs +259 -1
- package/package.json +13 -3
package/dist/index.d.mts
CHANGED
|
@@ -256,6 +256,115 @@ interface DexSwapResponse {
|
|
|
256
256
|
transactions: UnsignedTx[];
|
|
257
257
|
summary: string;
|
|
258
258
|
}
|
|
259
|
+
interface PerpsSetupResponse {
|
|
260
|
+
success: boolean;
|
|
261
|
+
message: string;
|
|
262
|
+
}
|
|
263
|
+
interface PerpsTradingPair {
|
|
264
|
+
provider: string;
|
|
265
|
+
dex: string;
|
|
266
|
+
name: string;
|
|
267
|
+
symbol: string;
|
|
268
|
+
icon: string;
|
|
269
|
+
baseAssetId: number;
|
|
270
|
+
baseAsset: string;
|
|
271
|
+
quoteAsset: string;
|
|
272
|
+
sizePrecision: number;
|
|
273
|
+
pricePrecision: number;
|
|
274
|
+
maxLeverage: number;
|
|
275
|
+
isDelisted: boolean;
|
|
276
|
+
isOnlyIsolated: boolean;
|
|
277
|
+
marginMode: string;
|
|
278
|
+
}
|
|
279
|
+
interface PerpsTradingPairsResponse {
|
|
280
|
+
pairs: PerpsTradingPair[];
|
|
281
|
+
cachedAt: string;
|
|
282
|
+
count: number;
|
|
283
|
+
}
|
|
284
|
+
interface PerpsOrderResponse {
|
|
285
|
+
[key: string]: any;
|
|
286
|
+
}
|
|
287
|
+
interface PerpsPositionsResponse {
|
|
288
|
+
assetPositions?: any[];
|
|
289
|
+
marginSummary?: {
|
|
290
|
+
accountValue: string;
|
|
291
|
+
totalMarginUsed: string;
|
|
292
|
+
totalNtlPos: string;
|
|
293
|
+
totalRawUsd: string;
|
|
294
|
+
};
|
|
295
|
+
[key: string]: any;
|
|
296
|
+
}
|
|
297
|
+
interface BridgeTransaction {
|
|
298
|
+
to: string;
|
|
299
|
+
data: string;
|
|
300
|
+
value: string;
|
|
301
|
+
gasLimit?: string;
|
|
302
|
+
chainId: number;
|
|
303
|
+
}
|
|
304
|
+
interface BridgeQuoteResponse {
|
|
305
|
+
id: string;
|
|
306
|
+
fromChainId: number;
|
|
307
|
+
toChainId: number;
|
|
308
|
+
fromToken: string;
|
|
309
|
+
toToken: string;
|
|
310
|
+
fromAmount: string;
|
|
311
|
+
toAmount: string;
|
|
312
|
+
estimatedGas: string;
|
|
313
|
+
estimatedTime: number;
|
|
314
|
+
tool: string;
|
|
315
|
+
transaction?: BridgeTransaction;
|
|
316
|
+
}
|
|
317
|
+
interface BridgeRoutesResponse {
|
|
318
|
+
routes: BridgeQuoteResponse[];
|
|
319
|
+
count: number;
|
|
320
|
+
}
|
|
321
|
+
interface BridgeStatusResponse {
|
|
322
|
+
status: "NOT_FOUND" | "PENDING" | "DONE" | "FAILED";
|
|
323
|
+
substatus?: string;
|
|
324
|
+
receiving?: {
|
|
325
|
+
txHash: string;
|
|
326
|
+
amount: string;
|
|
327
|
+
token: string;
|
|
328
|
+
chainId: number;
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
interface BridgeLiFiToken {
|
|
332
|
+
address: string;
|
|
333
|
+
symbol: string;
|
|
334
|
+
decimals: number;
|
|
335
|
+
name: string;
|
|
336
|
+
priceUSD?: string;
|
|
337
|
+
chainId: number;
|
|
338
|
+
}
|
|
339
|
+
interface BridgeLiFiChain {
|
|
340
|
+
id: number;
|
|
341
|
+
key: string;
|
|
342
|
+
name: string;
|
|
343
|
+
chainType: string;
|
|
344
|
+
nativeToken?: {
|
|
345
|
+
symbol: string;
|
|
346
|
+
decimals: number;
|
|
347
|
+
address: string;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
interface BridgeTokensResponse {
|
|
351
|
+
tokens: Record<string, BridgeLiFiToken[]>;
|
|
352
|
+
}
|
|
353
|
+
interface BridgeTokenResponse extends BridgeLiFiToken {
|
|
354
|
+
}
|
|
355
|
+
interface BridgeChainsResponse {
|
|
356
|
+
chains: BridgeLiFiChain[];
|
|
357
|
+
count: number;
|
|
358
|
+
}
|
|
359
|
+
interface BridgeConnectionsResponse {
|
|
360
|
+
connections: any[];
|
|
361
|
+
}
|
|
362
|
+
interface BridgeInfoResponse {
|
|
363
|
+
chains: Record<string, number>;
|
|
364
|
+
usdc: Record<string, string>;
|
|
365
|
+
nativeToken: string;
|
|
366
|
+
tip: string;
|
|
367
|
+
}
|
|
259
368
|
interface RegisterResponse {
|
|
260
369
|
apiKey: string;
|
|
261
370
|
wallet: string;
|
|
@@ -532,6 +641,151 @@ declare class DexModule {
|
|
|
532
641
|
buildSwap(wallet: string, from: string, to: string, amount: string, slippage?: number): Promise<DexSwapResponse>;
|
|
533
642
|
}
|
|
534
643
|
|
|
644
|
+
declare class PerpsModule {
|
|
645
|
+
private http;
|
|
646
|
+
private auth;
|
|
647
|
+
constructor(http: HttpClient, auth: () => Promise<void>);
|
|
648
|
+
/**
|
|
649
|
+
* Link your Arena API key to enable perps trading.
|
|
650
|
+
* One-time setup — after this, all /perp endpoints work automatically.
|
|
651
|
+
* @param arenaApiKey - Your Arena API key (from arena.social)
|
|
652
|
+
*/
|
|
653
|
+
setup(arenaApiKey: string): Promise<PerpsSetupResponse>;
|
|
654
|
+
/** Register for perps trading on Hyperliquid */
|
|
655
|
+
register(): Promise<any>;
|
|
656
|
+
/** Check perps registration status */
|
|
657
|
+
getRegistrationStatus(): Promise<any>;
|
|
658
|
+
/** Get your Hyperliquid API wallet address */
|
|
659
|
+
getWalletAddress(): Promise<any>;
|
|
660
|
+
/** Check which auth steps are completed */
|
|
661
|
+
getAuthStatus(): Promise<any>;
|
|
662
|
+
/**
|
|
663
|
+
* Get EIP-712 payload for an auth step.
|
|
664
|
+
* @param step - Auth step: "accept-terms", "approve-agent", "set-referrer", "approve-builder-fee"
|
|
665
|
+
* @param body - Optional body (accept-terms requires mainWalletAddress)
|
|
666
|
+
*/
|
|
667
|
+
getAuthPayload(step: string, body?: any): Promise<any>;
|
|
668
|
+
/**
|
|
669
|
+
* Submit signed EIP-712 payload for an auth step.
|
|
670
|
+
* @param step - Auth step
|
|
671
|
+
* @param body - Signed payload with signature and metadata
|
|
672
|
+
*/
|
|
673
|
+
submitAuthSignature(step: string, body: any): Promise<any>;
|
|
674
|
+
/** Enable HIP-3 abstraction (automated, no signature needed) */
|
|
675
|
+
enableHip3(): Promise<any>;
|
|
676
|
+
/** Get all available perpetual trading pairs (250+ markets) */
|
|
677
|
+
getTradingPairs(): Promise<PerpsTradingPairsResponse>;
|
|
678
|
+
/**
|
|
679
|
+
* Update leverage for a market. Must be called before first order.
|
|
680
|
+
* @param symbol - Market symbol (e.g. "BTC", "ETH")
|
|
681
|
+
* @param leverage - Leverage multiplier (1-50 depending on market)
|
|
682
|
+
* @param leverageType - "cross" or "isolated"
|
|
683
|
+
*/
|
|
684
|
+
updateLeverage(symbol: string, leverage: number, leverageType?: "cross" | "isolated"): Promise<any>;
|
|
685
|
+
/**
|
|
686
|
+
* Place one or more perpetual orders.
|
|
687
|
+
* @param orders - Array of order objects (see docs for BaseOrderParams)
|
|
688
|
+
*/
|
|
689
|
+
placeOrder(orders: any[]): Promise<PerpsOrderResponse>;
|
|
690
|
+
/**
|
|
691
|
+
* Cancel one or more open orders.
|
|
692
|
+
* @param cancels - Array of { assetIndex, oid }
|
|
693
|
+
*/
|
|
694
|
+
cancelOrders(cancels: {
|
|
695
|
+
assetIndex: number;
|
|
696
|
+
oid: number;
|
|
697
|
+
}[]): Promise<any>;
|
|
698
|
+
/**
|
|
699
|
+
* Modify an existing order.
|
|
700
|
+
* @param oid - Order ID to modify
|
|
701
|
+
* @param order - New order parameters
|
|
702
|
+
*/
|
|
703
|
+
modifyOrder(oid: number, order: any): Promise<any>;
|
|
704
|
+
/**
|
|
705
|
+
* Close a position (convenience — creates reduce-only IOC with 10% slippage).
|
|
706
|
+
* @param symbol - Market symbol
|
|
707
|
+
* @param positionSide - "long" or "short"
|
|
708
|
+
* @param size - Position size to close
|
|
709
|
+
* @param currentPrice - Current market price
|
|
710
|
+
* @param closePercent - Percentage to close (default: 100)
|
|
711
|
+
*/
|
|
712
|
+
closePosition(symbol: string, positionSide: "long" | "short", size: number, currentPrice: number, closePercent?: number): Promise<any>;
|
|
713
|
+
/** Get open orders */
|
|
714
|
+
getOrders(): Promise<any>;
|
|
715
|
+
/** Get trade execution history */
|
|
716
|
+
getTradeExecutions(): Promise<any>;
|
|
717
|
+
/**
|
|
718
|
+
* Get positions and margin summary (queries Hyperliquid directly).
|
|
719
|
+
* @param wallet - Your Hyperliquid wallet address (from getWalletAddress)
|
|
720
|
+
*/
|
|
721
|
+
getPositions(wallet: string): Promise<PerpsPositionsResponse>;
|
|
722
|
+
/**
|
|
723
|
+
* Get open orders from Hyperliquid directly.
|
|
724
|
+
* @param wallet - Your Hyperliquid wallet address
|
|
725
|
+
*/
|
|
726
|
+
getOpenOrders(wallet: string): Promise<any>;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare class BridgeModule {
|
|
730
|
+
private http;
|
|
731
|
+
private auth;
|
|
732
|
+
constructor(http: HttpClient, auth: () => Promise<void>);
|
|
733
|
+
/**
|
|
734
|
+
* Get all supported chains for cross-chain bridging.
|
|
735
|
+
*/
|
|
736
|
+
getChains(): Promise<BridgeChainsResponse>;
|
|
737
|
+
/**
|
|
738
|
+
* Get tokens available on specified chains.
|
|
739
|
+
* @param chains - Comma-separated chain IDs (e.g. "43114,42161")
|
|
740
|
+
*/
|
|
741
|
+
getTokens(chains: string): Promise<BridgeTokensResponse>;
|
|
742
|
+
/**
|
|
743
|
+
* Get info for a specific token on a chain.
|
|
744
|
+
* @param chainId - Chain ID
|
|
745
|
+
* @param address - Token contract address
|
|
746
|
+
*/
|
|
747
|
+
getToken(chainId: number, address: string): Promise<BridgeTokenResponse>;
|
|
748
|
+
/**
|
|
749
|
+
* Get available bridge connections between two chains.
|
|
750
|
+
* @param fromChainId - Source chain ID
|
|
751
|
+
* @param toChainId - Destination chain ID
|
|
752
|
+
* @param fromToken - Optional source token address
|
|
753
|
+
* @param toToken - Optional destination token address
|
|
754
|
+
*/
|
|
755
|
+
getConnections(fromChainId: number, toChainId: number, fromToken?: string, toToken?: string): Promise<BridgeConnectionsResponse>;
|
|
756
|
+
/**
|
|
757
|
+
* Get a bridge quote with unsigned transaction data.
|
|
758
|
+
* The agent signs the returned tx on the source chain.
|
|
759
|
+
*
|
|
760
|
+
* @param fromChainId - Source chain ID
|
|
761
|
+
* @param toChainId - Destination chain ID
|
|
762
|
+
* @param fromToken - Source token address (use 0x0000...0000 for native tokens)
|
|
763
|
+
* @param toToken - Destination token address
|
|
764
|
+
* @param fromAmount - Human-readable amount (e.g. "0.1")
|
|
765
|
+
* @param fromAddress - Sender wallet address
|
|
766
|
+
* @param toAddress - Optional receiver address (defaults to fromAddress)
|
|
767
|
+
* @param slippage - Slippage tolerance as decimal (default 0.03 = 3%)
|
|
768
|
+
* @param fromDecimals - Token decimals (default 18)
|
|
769
|
+
*/
|
|
770
|
+
getQuote(fromChainId: number, toChainId: number, fromToken: string, toToken: string, fromAmount: string, fromAddress: string, toAddress?: string, slippage?: number, fromDecimals?: number): Promise<BridgeQuoteResponse>;
|
|
771
|
+
/**
|
|
772
|
+
* Get multiple bridge route options.
|
|
773
|
+
*/
|
|
774
|
+
getRoutes(fromChainId: number, toChainId: number, fromToken: string, toToken: string, fromAmount: string, fromAddress: string, toAddress?: string, slippage?: number, fromDecimals?: number): Promise<BridgeRoutesResponse>;
|
|
775
|
+
/**
|
|
776
|
+
* Check bridge transfer status.
|
|
777
|
+
* @param txHash - Source chain transaction hash
|
|
778
|
+
* @param fromChainId - Source chain ID
|
|
779
|
+
* @param toChainId - Destination chain ID
|
|
780
|
+
* @param bridge - Optional bridge tool name
|
|
781
|
+
*/
|
|
782
|
+
getStatus(txHash: string, fromChainId: number, toChainId: number, bridge?: string): Promise<BridgeStatusResponse>;
|
|
783
|
+
/**
|
|
784
|
+
* Get reference info — common chain IDs, USDC addresses, native token constant.
|
|
785
|
+
*/
|
|
786
|
+
getInfo(): Promise<BridgeInfoResponse>;
|
|
787
|
+
}
|
|
788
|
+
|
|
535
789
|
interface LogiqicalConfig {
|
|
536
790
|
/** Your wallet address — used for auto-registration */
|
|
537
791
|
wallet: string;
|
|
@@ -563,8 +817,12 @@ declare class LogiqicalClient {
|
|
|
563
817
|
readonly staking: StakingModule;
|
|
564
818
|
/** Discover, research, and trade launchpad tokens on bonding curves */
|
|
565
819
|
readonly launchpad: LaunchpadModule;
|
|
566
|
-
/** Swap any Avalanche token via LFJ +
|
|
820
|
+
/** Swap any Avalanche token via LFJ + Arena DEX */
|
|
567
821
|
readonly dex: DexModule;
|
|
822
|
+
/** Trade perpetual futures on Hyperliquid via Arena */
|
|
823
|
+
readonly perps: PerpsModule;
|
|
824
|
+
/** Cross-chain token bridging via Li.Fi — any token, any chain */
|
|
825
|
+
readonly bridge: BridgeModule;
|
|
568
826
|
private http;
|
|
569
827
|
private wallet;
|
|
570
828
|
private agentName;
|
|
@@ -605,4 +863,4 @@ declare class LogiqicalAuthError extends LogiqicalError {
|
|
|
605
863
|
constructor(endpoint: string);
|
|
606
864
|
}
|
|
607
865
|
|
|
608
|
-
export { type ArenaCommunity, type BalancesResponse, type BroadcastResponse, type BuildCreateResponse, type BuyQuoteResponse, type DexBalanceResponse, DexModule, type DexQuoteResponse, type DexSwapResponse, type DexTokenEntry, type DexTokenInfoResponse, type DexTokensResponse, type GlobalTradeEntry, type GlobalTradesResponse, type HealthResponse, type HolderEntry, type LaunchTokenResponse, type LaunchpadBuyResponse, type LaunchpadListResponse, LaunchpadModule, type LaunchpadQuoteResponse, type LaunchpadSellResponse, type LaunchpadToken, LogiqicalAuthError, LogiqicalClient, type LogiqicalConfig, LogiqicalError, type RegisterResponse, type SellQuoteResponse, type StakeBuildResponse, type StakeInfoResponse, StakingModule, type SwapBuyResponse, SwapModule, type SwapSellResponse, type TokenActivityResponse, type TokenCreator, type TokenDetailResponse, type TokenHoldersResponse, type TokenStatsTimeframes, type TradeEntry, type UnsignedTx, type UploadImageResponse };
|
|
866
|
+
export { type ArenaCommunity, type BalancesResponse, type BridgeChainsResponse, type BridgeConnectionsResponse, type BridgeInfoResponse, type BridgeLiFiChain, type BridgeLiFiToken, BridgeModule, type BridgeQuoteResponse, type BridgeRoutesResponse, type BridgeStatusResponse, type BridgeTokenResponse, type BridgeTokensResponse, type BridgeTransaction, type BroadcastResponse, type BuildCreateResponse, type BuyQuoteResponse, type DexBalanceResponse, DexModule, type DexQuoteResponse, type DexSwapResponse, type DexTokenEntry, type DexTokenInfoResponse, type DexTokensResponse, type GlobalTradeEntry, type GlobalTradesResponse, type HealthResponse, type HolderEntry, type LaunchTokenResponse, type LaunchpadBuyResponse, type LaunchpadListResponse, LaunchpadModule, type LaunchpadQuoteResponse, type LaunchpadSellResponse, type LaunchpadToken, LogiqicalAuthError, LogiqicalClient, type LogiqicalConfig, LogiqicalError, PerpsModule, type PerpsOrderResponse, type PerpsPositionsResponse, type PerpsSetupResponse, type PerpsTradingPair, type PerpsTradingPairsResponse, type RegisterResponse, type SellQuoteResponse, type StakeBuildResponse, type StakeInfoResponse, StakingModule, type SwapBuyResponse, SwapModule, type SwapSellResponse, type TokenActivityResponse, type TokenCreator, type TokenDetailResponse, type TokenHoldersResponse, type TokenStatsTimeframes, type TradeEntry, type UnsignedTx, type UploadImageResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -256,6 +256,115 @@ interface DexSwapResponse {
|
|
|
256
256
|
transactions: UnsignedTx[];
|
|
257
257
|
summary: string;
|
|
258
258
|
}
|
|
259
|
+
interface PerpsSetupResponse {
|
|
260
|
+
success: boolean;
|
|
261
|
+
message: string;
|
|
262
|
+
}
|
|
263
|
+
interface PerpsTradingPair {
|
|
264
|
+
provider: string;
|
|
265
|
+
dex: string;
|
|
266
|
+
name: string;
|
|
267
|
+
symbol: string;
|
|
268
|
+
icon: string;
|
|
269
|
+
baseAssetId: number;
|
|
270
|
+
baseAsset: string;
|
|
271
|
+
quoteAsset: string;
|
|
272
|
+
sizePrecision: number;
|
|
273
|
+
pricePrecision: number;
|
|
274
|
+
maxLeverage: number;
|
|
275
|
+
isDelisted: boolean;
|
|
276
|
+
isOnlyIsolated: boolean;
|
|
277
|
+
marginMode: string;
|
|
278
|
+
}
|
|
279
|
+
interface PerpsTradingPairsResponse {
|
|
280
|
+
pairs: PerpsTradingPair[];
|
|
281
|
+
cachedAt: string;
|
|
282
|
+
count: number;
|
|
283
|
+
}
|
|
284
|
+
interface PerpsOrderResponse {
|
|
285
|
+
[key: string]: any;
|
|
286
|
+
}
|
|
287
|
+
interface PerpsPositionsResponse {
|
|
288
|
+
assetPositions?: any[];
|
|
289
|
+
marginSummary?: {
|
|
290
|
+
accountValue: string;
|
|
291
|
+
totalMarginUsed: string;
|
|
292
|
+
totalNtlPos: string;
|
|
293
|
+
totalRawUsd: string;
|
|
294
|
+
};
|
|
295
|
+
[key: string]: any;
|
|
296
|
+
}
|
|
297
|
+
interface BridgeTransaction {
|
|
298
|
+
to: string;
|
|
299
|
+
data: string;
|
|
300
|
+
value: string;
|
|
301
|
+
gasLimit?: string;
|
|
302
|
+
chainId: number;
|
|
303
|
+
}
|
|
304
|
+
interface BridgeQuoteResponse {
|
|
305
|
+
id: string;
|
|
306
|
+
fromChainId: number;
|
|
307
|
+
toChainId: number;
|
|
308
|
+
fromToken: string;
|
|
309
|
+
toToken: string;
|
|
310
|
+
fromAmount: string;
|
|
311
|
+
toAmount: string;
|
|
312
|
+
estimatedGas: string;
|
|
313
|
+
estimatedTime: number;
|
|
314
|
+
tool: string;
|
|
315
|
+
transaction?: BridgeTransaction;
|
|
316
|
+
}
|
|
317
|
+
interface BridgeRoutesResponse {
|
|
318
|
+
routes: BridgeQuoteResponse[];
|
|
319
|
+
count: number;
|
|
320
|
+
}
|
|
321
|
+
interface BridgeStatusResponse {
|
|
322
|
+
status: "NOT_FOUND" | "PENDING" | "DONE" | "FAILED";
|
|
323
|
+
substatus?: string;
|
|
324
|
+
receiving?: {
|
|
325
|
+
txHash: string;
|
|
326
|
+
amount: string;
|
|
327
|
+
token: string;
|
|
328
|
+
chainId: number;
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
interface BridgeLiFiToken {
|
|
332
|
+
address: string;
|
|
333
|
+
symbol: string;
|
|
334
|
+
decimals: number;
|
|
335
|
+
name: string;
|
|
336
|
+
priceUSD?: string;
|
|
337
|
+
chainId: number;
|
|
338
|
+
}
|
|
339
|
+
interface BridgeLiFiChain {
|
|
340
|
+
id: number;
|
|
341
|
+
key: string;
|
|
342
|
+
name: string;
|
|
343
|
+
chainType: string;
|
|
344
|
+
nativeToken?: {
|
|
345
|
+
symbol: string;
|
|
346
|
+
decimals: number;
|
|
347
|
+
address: string;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
interface BridgeTokensResponse {
|
|
351
|
+
tokens: Record<string, BridgeLiFiToken[]>;
|
|
352
|
+
}
|
|
353
|
+
interface BridgeTokenResponse extends BridgeLiFiToken {
|
|
354
|
+
}
|
|
355
|
+
interface BridgeChainsResponse {
|
|
356
|
+
chains: BridgeLiFiChain[];
|
|
357
|
+
count: number;
|
|
358
|
+
}
|
|
359
|
+
interface BridgeConnectionsResponse {
|
|
360
|
+
connections: any[];
|
|
361
|
+
}
|
|
362
|
+
interface BridgeInfoResponse {
|
|
363
|
+
chains: Record<string, number>;
|
|
364
|
+
usdc: Record<string, string>;
|
|
365
|
+
nativeToken: string;
|
|
366
|
+
tip: string;
|
|
367
|
+
}
|
|
259
368
|
interface RegisterResponse {
|
|
260
369
|
apiKey: string;
|
|
261
370
|
wallet: string;
|
|
@@ -532,6 +641,151 @@ declare class DexModule {
|
|
|
532
641
|
buildSwap(wallet: string, from: string, to: string, amount: string, slippage?: number): Promise<DexSwapResponse>;
|
|
533
642
|
}
|
|
534
643
|
|
|
644
|
+
declare class PerpsModule {
|
|
645
|
+
private http;
|
|
646
|
+
private auth;
|
|
647
|
+
constructor(http: HttpClient, auth: () => Promise<void>);
|
|
648
|
+
/**
|
|
649
|
+
* Link your Arena API key to enable perps trading.
|
|
650
|
+
* One-time setup — after this, all /perp endpoints work automatically.
|
|
651
|
+
* @param arenaApiKey - Your Arena API key (from arena.social)
|
|
652
|
+
*/
|
|
653
|
+
setup(arenaApiKey: string): Promise<PerpsSetupResponse>;
|
|
654
|
+
/** Register for perps trading on Hyperliquid */
|
|
655
|
+
register(): Promise<any>;
|
|
656
|
+
/** Check perps registration status */
|
|
657
|
+
getRegistrationStatus(): Promise<any>;
|
|
658
|
+
/** Get your Hyperliquid API wallet address */
|
|
659
|
+
getWalletAddress(): Promise<any>;
|
|
660
|
+
/** Check which auth steps are completed */
|
|
661
|
+
getAuthStatus(): Promise<any>;
|
|
662
|
+
/**
|
|
663
|
+
* Get EIP-712 payload for an auth step.
|
|
664
|
+
* @param step - Auth step: "accept-terms", "approve-agent", "set-referrer", "approve-builder-fee"
|
|
665
|
+
* @param body - Optional body (accept-terms requires mainWalletAddress)
|
|
666
|
+
*/
|
|
667
|
+
getAuthPayload(step: string, body?: any): Promise<any>;
|
|
668
|
+
/**
|
|
669
|
+
* Submit signed EIP-712 payload for an auth step.
|
|
670
|
+
* @param step - Auth step
|
|
671
|
+
* @param body - Signed payload with signature and metadata
|
|
672
|
+
*/
|
|
673
|
+
submitAuthSignature(step: string, body: any): Promise<any>;
|
|
674
|
+
/** Enable HIP-3 abstraction (automated, no signature needed) */
|
|
675
|
+
enableHip3(): Promise<any>;
|
|
676
|
+
/** Get all available perpetual trading pairs (250+ markets) */
|
|
677
|
+
getTradingPairs(): Promise<PerpsTradingPairsResponse>;
|
|
678
|
+
/**
|
|
679
|
+
* Update leverage for a market. Must be called before first order.
|
|
680
|
+
* @param symbol - Market symbol (e.g. "BTC", "ETH")
|
|
681
|
+
* @param leverage - Leverage multiplier (1-50 depending on market)
|
|
682
|
+
* @param leverageType - "cross" or "isolated"
|
|
683
|
+
*/
|
|
684
|
+
updateLeverage(symbol: string, leverage: number, leverageType?: "cross" | "isolated"): Promise<any>;
|
|
685
|
+
/**
|
|
686
|
+
* Place one or more perpetual orders.
|
|
687
|
+
* @param orders - Array of order objects (see docs for BaseOrderParams)
|
|
688
|
+
*/
|
|
689
|
+
placeOrder(orders: any[]): Promise<PerpsOrderResponse>;
|
|
690
|
+
/**
|
|
691
|
+
* Cancel one or more open orders.
|
|
692
|
+
* @param cancels - Array of { assetIndex, oid }
|
|
693
|
+
*/
|
|
694
|
+
cancelOrders(cancels: {
|
|
695
|
+
assetIndex: number;
|
|
696
|
+
oid: number;
|
|
697
|
+
}[]): Promise<any>;
|
|
698
|
+
/**
|
|
699
|
+
* Modify an existing order.
|
|
700
|
+
* @param oid - Order ID to modify
|
|
701
|
+
* @param order - New order parameters
|
|
702
|
+
*/
|
|
703
|
+
modifyOrder(oid: number, order: any): Promise<any>;
|
|
704
|
+
/**
|
|
705
|
+
* Close a position (convenience — creates reduce-only IOC with 10% slippage).
|
|
706
|
+
* @param symbol - Market symbol
|
|
707
|
+
* @param positionSide - "long" or "short"
|
|
708
|
+
* @param size - Position size to close
|
|
709
|
+
* @param currentPrice - Current market price
|
|
710
|
+
* @param closePercent - Percentage to close (default: 100)
|
|
711
|
+
*/
|
|
712
|
+
closePosition(symbol: string, positionSide: "long" | "short", size: number, currentPrice: number, closePercent?: number): Promise<any>;
|
|
713
|
+
/** Get open orders */
|
|
714
|
+
getOrders(): Promise<any>;
|
|
715
|
+
/** Get trade execution history */
|
|
716
|
+
getTradeExecutions(): Promise<any>;
|
|
717
|
+
/**
|
|
718
|
+
* Get positions and margin summary (queries Hyperliquid directly).
|
|
719
|
+
* @param wallet - Your Hyperliquid wallet address (from getWalletAddress)
|
|
720
|
+
*/
|
|
721
|
+
getPositions(wallet: string): Promise<PerpsPositionsResponse>;
|
|
722
|
+
/**
|
|
723
|
+
* Get open orders from Hyperliquid directly.
|
|
724
|
+
* @param wallet - Your Hyperliquid wallet address
|
|
725
|
+
*/
|
|
726
|
+
getOpenOrders(wallet: string): Promise<any>;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare class BridgeModule {
|
|
730
|
+
private http;
|
|
731
|
+
private auth;
|
|
732
|
+
constructor(http: HttpClient, auth: () => Promise<void>);
|
|
733
|
+
/**
|
|
734
|
+
* Get all supported chains for cross-chain bridging.
|
|
735
|
+
*/
|
|
736
|
+
getChains(): Promise<BridgeChainsResponse>;
|
|
737
|
+
/**
|
|
738
|
+
* Get tokens available on specified chains.
|
|
739
|
+
* @param chains - Comma-separated chain IDs (e.g. "43114,42161")
|
|
740
|
+
*/
|
|
741
|
+
getTokens(chains: string): Promise<BridgeTokensResponse>;
|
|
742
|
+
/**
|
|
743
|
+
* Get info for a specific token on a chain.
|
|
744
|
+
* @param chainId - Chain ID
|
|
745
|
+
* @param address - Token contract address
|
|
746
|
+
*/
|
|
747
|
+
getToken(chainId: number, address: string): Promise<BridgeTokenResponse>;
|
|
748
|
+
/**
|
|
749
|
+
* Get available bridge connections between two chains.
|
|
750
|
+
* @param fromChainId - Source chain ID
|
|
751
|
+
* @param toChainId - Destination chain ID
|
|
752
|
+
* @param fromToken - Optional source token address
|
|
753
|
+
* @param toToken - Optional destination token address
|
|
754
|
+
*/
|
|
755
|
+
getConnections(fromChainId: number, toChainId: number, fromToken?: string, toToken?: string): Promise<BridgeConnectionsResponse>;
|
|
756
|
+
/**
|
|
757
|
+
* Get a bridge quote with unsigned transaction data.
|
|
758
|
+
* The agent signs the returned tx on the source chain.
|
|
759
|
+
*
|
|
760
|
+
* @param fromChainId - Source chain ID
|
|
761
|
+
* @param toChainId - Destination chain ID
|
|
762
|
+
* @param fromToken - Source token address (use 0x0000...0000 for native tokens)
|
|
763
|
+
* @param toToken - Destination token address
|
|
764
|
+
* @param fromAmount - Human-readable amount (e.g. "0.1")
|
|
765
|
+
* @param fromAddress - Sender wallet address
|
|
766
|
+
* @param toAddress - Optional receiver address (defaults to fromAddress)
|
|
767
|
+
* @param slippage - Slippage tolerance as decimal (default 0.03 = 3%)
|
|
768
|
+
* @param fromDecimals - Token decimals (default 18)
|
|
769
|
+
*/
|
|
770
|
+
getQuote(fromChainId: number, toChainId: number, fromToken: string, toToken: string, fromAmount: string, fromAddress: string, toAddress?: string, slippage?: number, fromDecimals?: number): Promise<BridgeQuoteResponse>;
|
|
771
|
+
/**
|
|
772
|
+
* Get multiple bridge route options.
|
|
773
|
+
*/
|
|
774
|
+
getRoutes(fromChainId: number, toChainId: number, fromToken: string, toToken: string, fromAmount: string, fromAddress: string, toAddress?: string, slippage?: number, fromDecimals?: number): Promise<BridgeRoutesResponse>;
|
|
775
|
+
/**
|
|
776
|
+
* Check bridge transfer status.
|
|
777
|
+
* @param txHash - Source chain transaction hash
|
|
778
|
+
* @param fromChainId - Source chain ID
|
|
779
|
+
* @param toChainId - Destination chain ID
|
|
780
|
+
* @param bridge - Optional bridge tool name
|
|
781
|
+
*/
|
|
782
|
+
getStatus(txHash: string, fromChainId: number, toChainId: number, bridge?: string): Promise<BridgeStatusResponse>;
|
|
783
|
+
/**
|
|
784
|
+
* Get reference info — common chain IDs, USDC addresses, native token constant.
|
|
785
|
+
*/
|
|
786
|
+
getInfo(): Promise<BridgeInfoResponse>;
|
|
787
|
+
}
|
|
788
|
+
|
|
535
789
|
interface LogiqicalConfig {
|
|
536
790
|
/** Your wallet address — used for auto-registration */
|
|
537
791
|
wallet: string;
|
|
@@ -563,8 +817,12 @@ declare class LogiqicalClient {
|
|
|
563
817
|
readonly staking: StakingModule;
|
|
564
818
|
/** Discover, research, and trade launchpad tokens on bonding curves */
|
|
565
819
|
readonly launchpad: LaunchpadModule;
|
|
566
|
-
/** Swap any Avalanche token via LFJ +
|
|
820
|
+
/** Swap any Avalanche token via LFJ + Arena DEX */
|
|
567
821
|
readonly dex: DexModule;
|
|
822
|
+
/** Trade perpetual futures on Hyperliquid via Arena */
|
|
823
|
+
readonly perps: PerpsModule;
|
|
824
|
+
/** Cross-chain token bridging via Li.Fi — any token, any chain */
|
|
825
|
+
readonly bridge: BridgeModule;
|
|
568
826
|
private http;
|
|
569
827
|
private wallet;
|
|
570
828
|
private agentName;
|
|
@@ -605,4 +863,4 @@ declare class LogiqicalAuthError extends LogiqicalError {
|
|
|
605
863
|
constructor(endpoint: string);
|
|
606
864
|
}
|
|
607
865
|
|
|
608
|
-
export { type ArenaCommunity, type BalancesResponse, type BroadcastResponse, type BuildCreateResponse, type BuyQuoteResponse, type DexBalanceResponse, DexModule, type DexQuoteResponse, type DexSwapResponse, type DexTokenEntry, type DexTokenInfoResponse, type DexTokensResponse, type GlobalTradeEntry, type GlobalTradesResponse, type HealthResponse, type HolderEntry, type LaunchTokenResponse, type LaunchpadBuyResponse, type LaunchpadListResponse, LaunchpadModule, type LaunchpadQuoteResponse, type LaunchpadSellResponse, type LaunchpadToken, LogiqicalAuthError, LogiqicalClient, type LogiqicalConfig, LogiqicalError, type RegisterResponse, type SellQuoteResponse, type StakeBuildResponse, type StakeInfoResponse, StakingModule, type SwapBuyResponse, SwapModule, type SwapSellResponse, type TokenActivityResponse, type TokenCreator, type TokenDetailResponse, type TokenHoldersResponse, type TokenStatsTimeframes, type TradeEntry, type UnsignedTx, type UploadImageResponse };
|
|
866
|
+
export { type ArenaCommunity, type BalancesResponse, type BridgeChainsResponse, type BridgeConnectionsResponse, type BridgeInfoResponse, type BridgeLiFiChain, type BridgeLiFiToken, BridgeModule, type BridgeQuoteResponse, type BridgeRoutesResponse, type BridgeStatusResponse, type BridgeTokenResponse, type BridgeTokensResponse, type BridgeTransaction, type BroadcastResponse, type BuildCreateResponse, type BuyQuoteResponse, type DexBalanceResponse, DexModule, type DexQuoteResponse, type DexSwapResponse, type DexTokenEntry, type DexTokenInfoResponse, type DexTokensResponse, type GlobalTradeEntry, type GlobalTradesResponse, type HealthResponse, type HolderEntry, type LaunchTokenResponse, type LaunchpadBuyResponse, type LaunchpadListResponse, LaunchpadModule, type LaunchpadQuoteResponse, type LaunchpadSellResponse, type LaunchpadToken, LogiqicalAuthError, LogiqicalClient, type LogiqicalConfig, LogiqicalError, PerpsModule, type PerpsOrderResponse, type PerpsPositionsResponse, type PerpsSetupResponse, type PerpsTradingPair, type PerpsTradingPairsResponse, type RegisterResponse, type SellQuoteResponse, type StakeBuildResponse, type StakeInfoResponse, StakingModule, type SwapBuyResponse, SwapModule, type SwapSellResponse, type TokenActivityResponse, type TokenCreator, type TokenDetailResponse, type TokenHoldersResponse, type TokenStatsTimeframes, type TradeEntry, type UnsignedTx, type UploadImageResponse };
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
BridgeModule: () => BridgeModule,
|
|
23
24
|
DexModule: () => DexModule,
|
|
24
25
|
LaunchpadModule: () => LaunchpadModule,
|
|
25
26
|
LogiqicalAuthError: () => LogiqicalAuthError,
|
|
26
27
|
LogiqicalClient: () => LogiqicalClient,
|
|
27
28
|
LogiqicalError: () => LogiqicalError,
|
|
29
|
+
PerpsModule: () => PerpsModule,
|
|
28
30
|
StakingModule: () => StakingModule,
|
|
29
31
|
SwapModule: () => SwapModule
|
|
30
32
|
});
|
|
@@ -467,6 +469,256 @@ var DexModule = class {
|
|
|
467
469
|
}
|
|
468
470
|
};
|
|
469
471
|
|
|
472
|
+
// src/modules/perps.ts
|
|
473
|
+
var PerpsModule = class {
|
|
474
|
+
constructor(http, auth) {
|
|
475
|
+
this.http = http;
|
|
476
|
+
this.auth = auth;
|
|
477
|
+
}
|
|
478
|
+
// ── Setup ──
|
|
479
|
+
/**
|
|
480
|
+
* Link your Arena API key to enable perps trading.
|
|
481
|
+
* One-time setup — after this, all /perp endpoints work automatically.
|
|
482
|
+
* @param arenaApiKey - Your Arena API key (from arena.social)
|
|
483
|
+
*/
|
|
484
|
+
async setup(arenaApiKey) {
|
|
485
|
+
await this.auth();
|
|
486
|
+
return this.http.post("/perp/setup", { arenaApiKey });
|
|
487
|
+
}
|
|
488
|
+
// ── Registration ──
|
|
489
|
+
/** Register for perps trading on Hyperliquid */
|
|
490
|
+
async register() {
|
|
491
|
+
await this.auth();
|
|
492
|
+
return this.http.post("/perp/register", {});
|
|
493
|
+
}
|
|
494
|
+
/** Check perps registration status */
|
|
495
|
+
async getRegistrationStatus() {
|
|
496
|
+
await this.auth();
|
|
497
|
+
return this.http.get("/perp/registration-status");
|
|
498
|
+
}
|
|
499
|
+
/** Get your Hyperliquid API wallet address */
|
|
500
|
+
async getWalletAddress() {
|
|
501
|
+
await this.auth();
|
|
502
|
+
return this.http.get("/perp/wallet-address");
|
|
503
|
+
}
|
|
504
|
+
// ── Auth Flow ──
|
|
505
|
+
/** Check which auth steps are completed */
|
|
506
|
+
async getAuthStatus() {
|
|
507
|
+
await this.auth();
|
|
508
|
+
return this.http.post("/perp/auth/status", {});
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Get EIP-712 payload for an auth step.
|
|
512
|
+
* @param step - Auth step: "accept-terms", "approve-agent", "set-referrer", "approve-builder-fee"
|
|
513
|
+
* @param body - Optional body (accept-terms requires mainWalletAddress)
|
|
514
|
+
*/
|
|
515
|
+
async getAuthPayload(step, body) {
|
|
516
|
+
await this.auth();
|
|
517
|
+
return this.http.post(`/perp/auth/${step}/payload`, body || {});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Submit signed EIP-712 payload for an auth step.
|
|
521
|
+
* @param step - Auth step
|
|
522
|
+
* @param body - Signed payload with signature and metadata
|
|
523
|
+
*/
|
|
524
|
+
async submitAuthSignature(step, body) {
|
|
525
|
+
await this.auth();
|
|
526
|
+
return this.http.post(`/perp/auth/${step}/submit`, body);
|
|
527
|
+
}
|
|
528
|
+
/** Enable HIP-3 abstraction (automated, no signature needed) */
|
|
529
|
+
async enableHip3() {
|
|
530
|
+
await this.auth();
|
|
531
|
+
return this.http.post("/perp/auth/enable-hip3", {});
|
|
532
|
+
}
|
|
533
|
+
// ── Market Data ──
|
|
534
|
+
/** Get all available perpetual trading pairs (250+ markets) */
|
|
535
|
+
async getTradingPairs() {
|
|
536
|
+
await this.auth();
|
|
537
|
+
return this.http.get("/perp/trading-pairs");
|
|
538
|
+
}
|
|
539
|
+
// ── Leverage ──
|
|
540
|
+
/**
|
|
541
|
+
* Update leverage for a market. Must be called before first order.
|
|
542
|
+
* @param symbol - Market symbol (e.g. "BTC", "ETH")
|
|
543
|
+
* @param leverage - Leverage multiplier (1-50 depending on market)
|
|
544
|
+
* @param leverageType - "cross" or "isolated"
|
|
545
|
+
*/
|
|
546
|
+
async updateLeverage(symbol, leverage, leverageType = "cross") {
|
|
547
|
+
await this.auth();
|
|
548
|
+
return this.http.post("/perp/leverage/update", { symbol, leverage, leverageType });
|
|
549
|
+
}
|
|
550
|
+
// ── Trading ──
|
|
551
|
+
/**
|
|
552
|
+
* Place one or more perpetual orders.
|
|
553
|
+
* @param orders - Array of order objects (see docs for BaseOrderParams)
|
|
554
|
+
*/
|
|
555
|
+
async placeOrder(orders) {
|
|
556
|
+
await this.auth();
|
|
557
|
+
return this.http.post("/perp/orders/place", { orders });
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Cancel one or more open orders.
|
|
561
|
+
* @param cancels - Array of { assetIndex, oid }
|
|
562
|
+
*/
|
|
563
|
+
async cancelOrders(cancels) {
|
|
564
|
+
await this.auth();
|
|
565
|
+
return this.http.post("/perp/orders/cancel", { cancels });
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Modify an existing order.
|
|
569
|
+
* @param oid - Order ID to modify
|
|
570
|
+
* @param order - New order parameters
|
|
571
|
+
*/
|
|
572
|
+
async modifyOrder(oid, order) {
|
|
573
|
+
await this.auth();
|
|
574
|
+
return this.http.post("/perp/orders/modify", { oid, order });
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Close a position (convenience — creates reduce-only IOC with 10% slippage).
|
|
578
|
+
* @param symbol - Market symbol
|
|
579
|
+
* @param positionSide - "long" or "short"
|
|
580
|
+
* @param size - Position size to close
|
|
581
|
+
* @param currentPrice - Current market price
|
|
582
|
+
* @param closePercent - Percentage to close (default: 100)
|
|
583
|
+
*/
|
|
584
|
+
async closePosition(symbol, positionSide, size, currentPrice, closePercent = 100) {
|
|
585
|
+
await this.auth();
|
|
586
|
+
return this.http.post("/perp/orders/close-position", {
|
|
587
|
+
symbol,
|
|
588
|
+
positionSide,
|
|
589
|
+
size,
|
|
590
|
+
currentPrice,
|
|
591
|
+
closePercent
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
// ── Account Data ──
|
|
595
|
+
/** Get open orders */
|
|
596
|
+
async getOrders() {
|
|
597
|
+
await this.auth();
|
|
598
|
+
return this.http.get("/perp/orders");
|
|
599
|
+
}
|
|
600
|
+
/** Get trade execution history */
|
|
601
|
+
async getTradeExecutions() {
|
|
602
|
+
await this.auth();
|
|
603
|
+
return this.http.get("/perp/trade-executions");
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Get positions and margin summary (queries Hyperliquid directly).
|
|
607
|
+
* @param wallet - Your Hyperliquid wallet address (from getWalletAddress)
|
|
608
|
+
*/
|
|
609
|
+
async getPositions(wallet) {
|
|
610
|
+
await this.auth();
|
|
611
|
+
return this.http.get("/perp/positions", { wallet });
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Get open orders from Hyperliquid directly.
|
|
615
|
+
* @param wallet - Your Hyperliquid wallet address
|
|
616
|
+
*/
|
|
617
|
+
async getOpenOrders(wallet) {
|
|
618
|
+
await this.auth();
|
|
619
|
+
return this.http.get("/perp/open-orders", { wallet });
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
// src/modules/bridge.ts
|
|
624
|
+
var BridgeModule = class {
|
|
625
|
+
constructor(http, auth) {
|
|
626
|
+
this.http = http;
|
|
627
|
+
this.auth = auth;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Get all supported chains for cross-chain bridging.
|
|
631
|
+
*/
|
|
632
|
+
async getChains() {
|
|
633
|
+
await this.auth();
|
|
634
|
+
return this.http.get("/bridge/chains");
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Get tokens available on specified chains.
|
|
638
|
+
* @param chains - Comma-separated chain IDs (e.g. "43114,42161")
|
|
639
|
+
*/
|
|
640
|
+
async getTokens(chains) {
|
|
641
|
+
await this.auth();
|
|
642
|
+
return this.http.get("/bridge/tokens", { chains });
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Get info for a specific token on a chain.
|
|
646
|
+
* @param chainId - Chain ID
|
|
647
|
+
* @param address - Token contract address
|
|
648
|
+
*/
|
|
649
|
+
async getToken(chainId, address) {
|
|
650
|
+
await this.auth();
|
|
651
|
+
return this.http.get("/bridge/token", { chainId, address });
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Get available bridge connections between two chains.
|
|
655
|
+
* @param fromChainId - Source chain ID
|
|
656
|
+
* @param toChainId - Destination chain ID
|
|
657
|
+
* @param fromToken - Optional source token address
|
|
658
|
+
* @param toToken - Optional destination token address
|
|
659
|
+
*/
|
|
660
|
+
async getConnections(fromChainId, toChainId, fromToken, toToken) {
|
|
661
|
+
await this.auth();
|
|
662
|
+
const params = { fromChainId, toChainId };
|
|
663
|
+
if (fromToken) params.fromToken = fromToken;
|
|
664
|
+
if (toToken) params.toToken = toToken;
|
|
665
|
+
return this.http.get("/bridge/connections", params);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Get a bridge quote with unsigned transaction data.
|
|
669
|
+
* The agent signs the returned tx on the source chain.
|
|
670
|
+
*
|
|
671
|
+
* @param fromChainId - Source chain ID
|
|
672
|
+
* @param toChainId - Destination chain ID
|
|
673
|
+
* @param fromToken - Source token address (use 0x0000...0000 for native tokens)
|
|
674
|
+
* @param toToken - Destination token address
|
|
675
|
+
* @param fromAmount - Human-readable amount (e.g. "0.1")
|
|
676
|
+
* @param fromAddress - Sender wallet address
|
|
677
|
+
* @param toAddress - Optional receiver address (defaults to fromAddress)
|
|
678
|
+
* @param slippage - Slippage tolerance as decimal (default 0.03 = 3%)
|
|
679
|
+
* @param fromDecimals - Token decimals (default 18)
|
|
680
|
+
*/
|
|
681
|
+
async getQuote(fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress, toAddress, slippage, fromDecimals) {
|
|
682
|
+
await this.auth();
|
|
683
|
+
const params = { fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress };
|
|
684
|
+
if (toAddress) params.toAddress = toAddress;
|
|
685
|
+
if (slippage !== void 0) params.slippage = slippage;
|
|
686
|
+
if (fromDecimals !== void 0) params.fromDecimals = fromDecimals;
|
|
687
|
+
return this.http.get("/bridge/quote", params);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Get multiple bridge route options.
|
|
691
|
+
*/
|
|
692
|
+
async getRoutes(fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress, toAddress, slippage, fromDecimals) {
|
|
693
|
+
await this.auth();
|
|
694
|
+
const params = { fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress };
|
|
695
|
+
if (toAddress) params.toAddress = toAddress;
|
|
696
|
+
if (slippage !== void 0) params.slippage = slippage;
|
|
697
|
+
if (fromDecimals !== void 0) params.fromDecimals = fromDecimals;
|
|
698
|
+
return this.http.get("/bridge/routes", params);
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Check bridge transfer status.
|
|
702
|
+
* @param txHash - Source chain transaction hash
|
|
703
|
+
* @param fromChainId - Source chain ID
|
|
704
|
+
* @param toChainId - Destination chain ID
|
|
705
|
+
* @param bridge - Optional bridge tool name
|
|
706
|
+
*/
|
|
707
|
+
async getStatus(txHash, fromChainId, toChainId, bridge) {
|
|
708
|
+
await this.auth();
|
|
709
|
+
const params = { txHash, fromChainId, toChainId };
|
|
710
|
+
if (bridge) params.bridge = bridge;
|
|
711
|
+
return this.http.get("/bridge/status", params);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Get reference info — common chain IDs, USDC addresses, native token constant.
|
|
715
|
+
*/
|
|
716
|
+
async getInfo() {
|
|
717
|
+
await this.auth();
|
|
718
|
+
return this.http.get("/bridge/info");
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
|
|
470
722
|
// src/client.ts
|
|
471
723
|
var DEFAULT_BASE_URL = "https://brave-alignment-production-1706.up.railway.app";
|
|
472
724
|
var LogiqicalClient = class {
|
|
@@ -476,8 +728,12 @@ var LogiqicalClient = class {
|
|
|
476
728
|
staking;
|
|
477
729
|
/** Discover, research, and trade launchpad tokens on bonding curves */
|
|
478
730
|
launchpad;
|
|
479
|
-
/** Swap any Avalanche token via LFJ +
|
|
731
|
+
/** Swap any Avalanche token via LFJ + Arena DEX */
|
|
480
732
|
dex;
|
|
733
|
+
/** Trade perpetual futures on Hyperliquid via Arena */
|
|
734
|
+
perps;
|
|
735
|
+
/** Cross-chain token bridging via Li.Fi — any token, any chain */
|
|
736
|
+
bridge;
|
|
481
737
|
http;
|
|
482
738
|
wallet;
|
|
483
739
|
agentName;
|
|
@@ -491,6 +747,8 @@ var LogiqicalClient = class {
|
|
|
491
747
|
this.staking = new StakingModule(this.http, auth);
|
|
492
748
|
this.launchpad = new LaunchpadModule(this.http, auth);
|
|
493
749
|
this.dex = new DexModule(this.http, auth);
|
|
750
|
+
this.perps = new PerpsModule(this.http, auth);
|
|
751
|
+
this.bridge = new BridgeModule(this.http, auth);
|
|
494
752
|
}
|
|
495
753
|
/** The API key (available after first call or if provided in config) */
|
|
496
754
|
get apiKey() {
|
|
@@ -545,11 +803,13 @@ var LogiqicalClient = class {
|
|
|
545
803
|
};
|
|
546
804
|
// Annotate the CommonJS export names for ESM import in node:
|
|
547
805
|
0 && (module.exports = {
|
|
806
|
+
BridgeModule,
|
|
548
807
|
DexModule,
|
|
549
808
|
LaunchpadModule,
|
|
550
809
|
LogiqicalAuthError,
|
|
551
810
|
LogiqicalClient,
|
|
552
811
|
LogiqicalError,
|
|
812
|
+
PerpsModule,
|
|
553
813
|
StakingModule,
|
|
554
814
|
SwapModule
|
|
555
815
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -435,6 +435,256 @@ var DexModule = class {
|
|
|
435
435
|
}
|
|
436
436
|
};
|
|
437
437
|
|
|
438
|
+
// src/modules/perps.ts
|
|
439
|
+
var PerpsModule = class {
|
|
440
|
+
constructor(http, auth) {
|
|
441
|
+
this.http = http;
|
|
442
|
+
this.auth = auth;
|
|
443
|
+
}
|
|
444
|
+
// ── Setup ──
|
|
445
|
+
/**
|
|
446
|
+
* Link your Arena API key to enable perps trading.
|
|
447
|
+
* One-time setup — after this, all /perp endpoints work automatically.
|
|
448
|
+
* @param arenaApiKey - Your Arena API key (from arena.social)
|
|
449
|
+
*/
|
|
450
|
+
async setup(arenaApiKey) {
|
|
451
|
+
await this.auth();
|
|
452
|
+
return this.http.post("/perp/setup", { arenaApiKey });
|
|
453
|
+
}
|
|
454
|
+
// ── Registration ──
|
|
455
|
+
/** Register for perps trading on Hyperliquid */
|
|
456
|
+
async register() {
|
|
457
|
+
await this.auth();
|
|
458
|
+
return this.http.post("/perp/register", {});
|
|
459
|
+
}
|
|
460
|
+
/** Check perps registration status */
|
|
461
|
+
async getRegistrationStatus() {
|
|
462
|
+
await this.auth();
|
|
463
|
+
return this.http.get("/perp/registration-status");
|
|
464
|
+
}
|
|
465
|
+
/** Get your Hyperliquid API wallet address */
|
|
466
|
+
async getWalletAddress() {
|
|
467
|
+
await this.auth();
|
|
468
|
+
return this.http.get("/perp/wallet-address");
|
|
469
|
+
}
|
|
470
|
+
// ── Auth Flow ──
|
|
471
|
+
/** Check which auth steps are completed */
|
|
472
|
+
async getAuthStatus() {
|
|
473
|
+
await this.auth();
|
|
474
|
+
return this.http.post("/perp/auth/status", {});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Get EIP-712 payload for an auth step.
|
|
478
|
+
* @param step - Auth step: "accept-terms", "approve-agent", "set-referrer", "approve-builder-fee"
|
|
479
|
+
* @param body - Optional body (accept-terms requires mainWalletAddress)
|
|
480
|
+
*/
|
|
481
|
+
async getAuthPayload(step, body) {
|
|
482
|
+
await this.auth();
|
|
483
|
+
return this.http.post(`/perp/auth/${step}/payload`, body || {});
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Submit signed EIP-712 payload for an auth step.
|
|
487
|
+
* @param step - Auth step
|
|
488
|
+
* @param body - Signed payload with signature and metadata
|
|
489
|
+
*/
|
|
490
|
+
async submitAuthSignature(step, body) {
|
|
491
|
+
await this.auth();
|
|
492
|
+
return this.http.post(`/perp/auth/${step}/submit`, body);
|
|
493
|
+
}
|
|
494
|
+
/** Enable HIP-3 abstraction (automated, no signature needed) */
|
|
495
|
+
async enableHip3() {
|
|
496
|
+
await this.auth();
|
|
497
|
+
return this.http.post("/perp/auth/enable-hip3", {});
|
|
498
|
+
}
|
|
499
|
+
// ── Market Data ──
|
|
500
|
+
/** Get all available perpetual trading pairs (250+ markets) */
|
|
501
|
+
async getTradingPairs() {
|
|
502
|
+
await this.auth();
|
|
503
|
+
return this.http.get("/perp/trading-pairs");
|
|
504
|
+
}
|
|
505
|
+
// ── Leverage ──
|
|
506
|
+
/**
|
|
507
|
+
* Update leverage for a market. Must be called before first order.
|
|
508
|
+
* @param symbol - Market symbol (e.g. "BTC", "ETH")
|
|
509
|
+
* @param leverage - Leverage multiplier (1-50 depending on market)
|
|
510
|
+
* @param leverageType - "cross" or "isolated"
|
|
511
|
+
*/
|
|
512
|
+
async updateLeverage(symbol, leverage, leverageType = "cross") {
|
|
513
|
+
await this.auth();
|
|
514
|
+
return this.http.post("/perp/leverage/update", { symbol, leverage, leverageType });
|
|
515
|
+
}
|
|
516
|
+
// ── Trading ──
|
|
517
|
+
/**
|
|
518
|
+
* Place one or more perpetual orders.
|
|
519
|
+
* @param orders - Array of order objects (see docs for BaseOrderParams)
|
|
520
|
+
*/
|
|
521
|
+
async placeOrder(orders) {
|
|
522
|
+
await this.auth();
|
|
523
|
+
return this.http.post("/perp/orders/place", { orders });
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Cancel one or more open orders.
|
|
527
|
+
* @param cancels - Array of { assetIndex, oid }
|
|
528
|
+
*/
|
|
529
|
+
async cancelOrders(cancels) {
|
|
530
|
+
await this.auth();
|
|
531
|
+
return this.http.post("/perp/orders/cancel", { cancels });
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Modify an existing order.
|
|
535
|
+
* @param oid - Order ID to modify
|
|
536
|
+
* @param order - New order parameters
|
|
537
|
+
*/
|
|
538
|
+
async modifyOrder(oid, order) {
|
|
539
|
+
await this.auth();
|
|
540
|
+
return this.http.post("/perp/orders/modify", { oid, order });
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Close a position (convenience — creates reduce-only IOC with 10% slippage).
|
|
544
|
+
* @param symbol - Market symbol
|
|
545
|
+
* @param positionSide - "long" or "short"
|
|
546
|
+
* @param size - Position size to close
|
|
547
|
+
* @param currentPrice - Current market price
|
|
548
|
+
* @param closePercent - Percentage to close (default: 100)
|
|
549
|
+
*/
|
|
550
|
+
async closePosition(symbol, positionSide, size, currentPrice, closePercent = 100) {
|
|
551
|
+
await this.auth();
|
|
552
|
+
return this.http.post("/perp/orders/close-position", {
|
|
553
|
+
symbol,
|
|
554
|
+
positionSide,
|
|
555
|
+
size,
|
|
556
|
+
currentPrice,
|
|
557
|
+
closePercent
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
// ── Account Data ──
|
|
561
|
+
/** Get open orders */
|
|
562
|
+
async getOrders() {
|
|
563
|
+
await this.auth();
|
|
564
|
+
return this.http.get("/perp/orders");
|
|
565
|
+
}
|
|
566
|
+
/** Get trade execution history */
|
|
567
|
+
async getTradeExecutions() {
|
|
568
|
+
await this.auth();
|
|
569
|
+
return this.http.get("/perp/trade-executions");
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Get positions and margin summary (queries Hyperliquid directly).
|
|
573
|
+
* @param wallet - Your Hyperliquid wallet address (from getWalletAddress)
|
|
574
|
+
*/
|
|
575
|
+
async getPositions(wallet) {
|
|
576
|
+
await this.auth();
|
|
577
|
+
return this.http.get("/perp/positions", { wallet });
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Get open orders from Hyperliquid directly.
|
|
581
|
+
* @param wallet - Your Hyperliquid wallet address
|
|
582
|
+
*/
|
|
583
|
+
async getOpenOrders(wallet) {
|
|
584
|
+
await this.auth();
|
|
585
|
+
return this.http.get("/perp/open-orders", { wallet });
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
// src/modules/bridge.ts
|
|
590
|
+
var BridgeModule = class {
|
|
591
|
+
constructor(http, auth) {
|
|
592
|
+
this.http = http;
|
|
593
|
+
this.auth = auth;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Get all supported chains for cross-chain bridging.
|
|
597
|
+
*/
|
|
598
|
+
async getChains() {
|
|
599
|
+
await this.auth();
|
|
600
|
+
return this.http.get("/bridge/chains");
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Get tokens available on specified chains.
|
|
604
|
+
* @param chains - Comma-separated chain IDs (e.g. "43114,42161")
|
|
605
|
+
*/
|
|
606
|
+
async getTokens(chains) {
|
|
607
|
+
await this.auth();
|
|
608
|
+
return this.http.get("/bridge/tokens", { chains });
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Get info for a specific token on a chain.
|
|
612
|
+
* @param chainId - Chain ID
|
|
613
|
+
* @param address - Token contract address
|
|
614
|
+
*/
|
|
615
|
+
async getToken(chainId, address) {
|
|
616
|
+
await this.auth();
|
|
617
|
+
return this.http.get("/bridge/token", { chainId, address });
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Get available bridge connections between two chains.
|
|
621
|
+
* @param fromChainId - Source chain ID
|
|
622
|
+
* @param toChainId - Destination chain ID
|
|
623
|
+
* @param fromToken - Optional source token address
|
|
624
|
+
* @param toToken - Optional destination token address
|
|
625
|
+
*/
|
|
626
|
+
async getConnections(fromChainId, toChainId, fromToken, toToken) {
|
|
627
|
+
await this.auth();
|
|
628
|
+
const params = { fromChainId, toChainId };
|
|
629
|
+
if (fromToken) params.fromToken = fromToken;
|
|
630
|
+
if (toToken) params.toToken = toToken;
|
|
631
|
+
return this.http.get("/bridge/connections", params);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Get a bridge quote with unsigned transaction data.
|
|
635
|
+
* The agent signs the returned tx on the source chain.
|
|
636
|
+
*
|
|
637
|
+
* @param fromChainId - Source chain ID
|
|
638
|
+
* @param toChainId - Destination chain ID
|
|
639
|
+
* @param fromToken - Source token address (use 0x0000...0000 for native tokens)
|
|
640
|
+
* @param toToken - Destination token address
|
|
641
|
+
* @param fromAmount - Human-readable amount (e.g. "0.1")
|
|
642
|
+
* @param fromAddress - Sender wallet address
|
|
643
|
+
* @param toAddress - Optional receiver address (defaults to fromAddress)
|
|
644
|
+
* @param slippage - Slippage tolerance as decimal (default 0.03 = 3%)
|
|
645
|
+
* @param fromDecimals - Token decimals (default 18)
|
|
646
|
+
*/
|
|
647
|
+
async getQuote(fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress, toAddress, slippage, fromDecimals) {
|
|
648
|
+
await this.auth();
|
|
649
|
+
const params = { fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress };
|
|
650
|
+
if (toAddress) params.toAddress = toAddress;
|
|
651
|
+
if (slippage !== void 0) params.slippage = slippage;
|
|
652
|
+
if (fromDecimals !== void 0) params.fromDecimals = fromDecimals;
|
|
653
|
+
return this.http.get("/bridge/quote", params);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Get multiple bridge route options.
|
|
657
|
+
*/
|
|
658
|
+
async getRoutes(fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress, toAddress, slippage, fromDecimals) {
|
|
659
|
+
await this.auth();
|
|
660
|
+
const params = { fromChainId, toChainId, fromToken, toToken, fromAmount, fromAddress };
|
|
661
|
+
if (toAddress) params.toAddress = toAddress;
|
|
662
|
+
if (slippage !== void 0) params.slippage = slippage;
|
|
663
|
+
if (fromDecimals !== void 0) params.fromDecimals = fromDecimals;
|
|
664
|
+
return this.http.get("/bridge/routes", params);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Check bridge transfer status.
|
|
668
|
+
* @param txHash - Source chain transaction hash
|
|
669
|
+
* @param fromChainId - Source chain ID
|
|
670
|
+
* @param toChainId - Destination chain ID
|
|
671
|
+
* @param bridge - Optional bridge tool name
|
|
672
|
+
*/
|
|
673
|
+
async getStatus(txHash, fromChainId, toChainId, bridge) {
|
|
674
|
+
await this.auth();
|
|
675
|
+
const params = { txHash, fromChainId, toChainId };
|
|
676
|
+
if (bridge) params.bridge = bridge;
|
|
677
|
+
return this.http.get("/bridge/status", params);
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Get reference info — common chain IDs, USDC addresses, native token constant.
|
|
681
|
+
*/
|
|
682
|
+
async getInfo() {
|
|
683
|
+
await this.auth();
|
|
684
|
+
return this.http.get("/bridge/info");
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
438
688
|
// src/client.ts
|
|
439
689
|
var DEFAULT_BASE_URL = "https://brave-alignment-production-1706.up.railway.app";
|
|
440
690
|
var LogiqicalClient = class {
|
|
@@ -444,8 +694,12 @@ var LogiqicalClient = class {
|
|
|
444
694
|
staking;
|
|
445
695
|
/** Discover, research, and trade launchpad tokens on bonding curves */
|
|
446
696
|
launchpad;
|
|
447
|
-
/** Swap any Avalanche token via LFJ +
|
|
697
|
+
/** Swap any Avalanche token via LFJ + Arena DEX */
|
|
448
698
|
dex;
|
|
699
|
+
/** Trade perpetual futures on Hyperliquid via Arena */
|
|
700
|
+
perps;
|
|
701
|
+
/** Cross-chain token bridging via Li.Fi — any token, any chain */
|
|
702
|
+
bridge;
|
|
449
703
|
http;
|
|
450
704
|
wallet;
|
|
451
705
|
agentName;
|
|
@@ -459,6 +713,8 @@ var LogiqicalClient = class {
|
|
|
459
713
|
this.staking = new StakingModule(this.http, auth);
|
|
460
714
|
this.launchpad = new LaunchpadModule(this.http, auth);
|
|
461
715
|
this.dex = new DexModule(this.http, auth);
|
|
716
|
+
this.perps = new PerpsModule(this.http, auth);
|
|
717
|
+
this.bridge = new BridgeModule(this.http, auth);
|
|
462
718
|
}
|
|
463
719
|
/** The API key (available after first call or if provided in config) */
|
|
464
720
|
get apiKey() {
|
|
@@ -512,11 +768,13 @@ var LogiqicalClient = class {
|
|
|
512
768
|
}
|
|
513
769
|
};
|
|
514
770
|
export {
|
|
771
|
+
BridgeModule,
|
|
515
772
|
DexModule,
|
|
516
773
|
LaunchpadModule,
|
|
517
774
|
LogiqicalAuthError,
|
|
518
775
|
LogiqicalClient,
|
|
519
776
|
LogiqicalError,
|
|
777
|
+
PerpsModule,
|
|
520
778
|
StakingModule,
|
|
521
779
|
SwapModule
|
|
522
780
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "logiqical",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript SDK for AI agents to trade on Avalanche — swaps, staking, launchpad, DEX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -12,13 +12,23 @@
|
|
|
12
12
|
"import": "./dist/index.mjs"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
16
18
|
"scripts": {
|
|
17
19
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
18
20
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
19
21
|
"prepublishOnly": "npm run build"
|
|
20
22
|
},
|
|
21
|
-
"keywords": [
|
|
23
|
+
"keywords": [
|
|
24
|
+
"avalanche",
|
|
25
|
+
"arena",
|
|
26
|
+
"defi",
|
|
27
|
+
"sdk",
|
|
28
|
+
"ai-agent",
|
|
29
|
+
"trading",
|
|
30
|
+
"logiqical"
|
|
31
|
+
],
|
|
22
32
|
"license": "MIT",
|
|
23
33
|
"repository": {
|
|
24
34
|
"type": "git",
|