logiqical 0.1.0 → 0.1.2
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/README.md +185 -0
- package/dist/index.d.mts +316 -2
- package/dist/index.d.ts +316 -2
- package/dist/index.js +308 -1
- package/dist/index.mjs +306 -1
- package/package.json +14 -4
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
|
});
|
|
@@ -327,6 +329,53 @@ var LaunchpadModule = class {
|
|
|
327
329
|
await this.auth();
|
|
328
330
|
return this.http.get("/launchpad/trades", { count, offset });
|
|
329
331
|
}
|
|
332
|
+
// ── Token Launch ──
|
|
333
|
+
/**
|
|
334
|
+
* Launch a new token on Arena — uploads image, creates community, and returns the unsigned createToken transaction.
|
|
335
|
+
*
|
|
336
|
+
* @param wallet - Creator wallet address
|
|
337
|
+
* @param name - Token name (also used as community name)
|
|
338
|
+
* @param symbol - Token ticker symbol
|
|
339
|
+
* @param imageBase64 - Token image as base64 string (optional)
|
|
340
|
+
* @param paymentToken - "avax" or "arena" (default: "arena")
|
|
341
|
+
* @param initialBuyAvax - AVAX amount for initial buy at creation (default: "0")
|
|
342
|
+
*/
|
|
343
|
+
async launch(wallet, name, symbol, imageBase64, paymentToken = "arena", initialBuyAvax = "0") {
|
|
344
|
+
await this.auth();
|
|
345
|
+
return this.http.post("/launchpad/launch", {
|
|
346
|
+
wallet,
|
|
347
|
+
name,
|
|
348
|
+
symbol,
|
|
349
|
+
imageBase64,
|
|
350
|
+
paymentToken,
|
|
351
|
+
initialBuyAvax
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Upload a token image to Arena's CDN and get the hosted URL.
|
|
356
|
+
* Use this before launch() if you want to preview the image URL first.
|
|
357
|
+
*
|
|
358
|
+
* @param imageBase64 - Image as base64 string
|
|
359
|
+
* @param fileType - MIME type (default: "image/jpeg")
|
|
360
|
+
*/
|
|
361
|
+
async uploadImage(imageBase64, fileType = "image/jpeg") {
|
|
362
|
+
await this.auth();
|
|
363
|
+
return this.http.post("/launchpad/upload-image", { imageBase64, fileType });
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Build only the createToken transaction (no image or community creation).
|
|
367
|
+
* Useful if you want to handle image upload and community creation separately.
|
|
368
|
+
*
|
|
369
|
+
* @param wallet - Creator wallet address
|
|
370
|
+
* @param name - Token name
|
|
371
|
+
* @param symbol - Token ticker symbol
|
|
372
|
+
* @param paymentToken - "avax" or "arena" (default: "arena")
|
|
373
|
+
* @param initialBuyAvax - AVAX for initial buy (default: "0")
|
|
374
|
+
*/
|
|
375
|
+
async buildCreate(wallet, name, symbol, paymentToken = "arena", initialBuyAvax = "0") {
|
|
376
|
+
await this.auth();
|
|
377
|
+
return this.http.get("/launchpad/build/create", { wallet, name, symbol, paymentToken, initialBuyAvax });
|
|
378
|
+
}
|
|
330
379
|
// ── Trading ──
|
|
331
380
|
/**
|
|
332
381
|
* Build unsigned transaction to buy a launchpad token with AVAX.
|
|
@@ -420,6 +469,256 @@ var DexModule = class {
|
|
|
420
469
|
}
|
|
421
470
|
};
|
|
422
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
|
+
|
|
423
722
|
// src/client.ts
|
|
424
723
|
var DEFAULT_BASE_URL = "https://brave-alignment-production-1706.up.railway.app";
|
|
425
724
|
var LogiqicalClient = class {
|
|
@@ -429,8 +728,12 @@ var LogiqicalClient = class {
|
|
|
429
728
|
staking;
|
|
430
729
|
/** Discover, research, and trade launchpad tokens on bonding curves */
|
|
431
730
|
launchpad;
|
|
432
|
-
/** Swap any Avalanche token via LFJ +
|
|
731
|
+
/** Swap any Avalanche token via LFJ + Arena DEX */
|
|
433
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;
|
|
434
737
|
http;
|
|
435
738
|
wallet;
|
|
436
739
|
agentName;
|
|
@@ -444,6 +747,8 @@ var LogiqicalClient = class {
|
|
|
444
747
|
this.staking = new StakingModule(this.http, auth);
|
|
445
748
|
this.launchpad = new LaunchpadModule(this.http, auth);
|
|
446
749
|
this.dex = new DexModule(this.http, auth);
|
|
750
|
+
this.perps = new PerpsModule(this.http, auth);
|
|
751
|
+
this.bridge = new BridgeModule(this.http, auth);
|
|
447
752
|
}
|
|
448
753
|
/** The API key (available after first call or if provided in config) */
|
|
449
754
|
get apiKey() {
|
|
@@ -498,11 +803,13 @@ var LogiqicalClient = class {
|
|
|
498
803
|
};
|
|
499
804
|
// Annotate the CommonJS export names for ESM import in node:
|
|
500
805
|
0 && (module.exports = {
|
|
806
|
+
BridgeModule,
|
|
501
807
|
DexModule,
|
|
502
808
|
LaunchpadModule,
|
|
503
809
|
LogiqicalAuthError,
|
|
504
810
|
LogiqicalClient,
|
|
505
811
|
LogiqicalError,
|
|
812
|
+
PerpsModule,
|
|
506
813
|
StakingModule,
|
|
507
814
|
SwapModule
|
|
508
815
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -295,6 +295,53 @@ var LaunchpadModule = class {
|
|
|
295
295
|
await this.auth();
|
|
296
296
|
return this.http.get("/launchpad/trades", { count, offset });
|
|
297
297
|
}
|
|
298
|
+
// ── Token Launch ──
|
|
299
|
+
/**
|
|
300
|
+
* Launch a new token on Arena — uploads image, creates community, and returns the unsigned createToken transaction.
|
|
301
|
+
*
|
|
302
|
+
* @param wallet - Creator wallet address
|
|
303
|
+
* @param name - Token name (also used as community name)
|
|
304
|
+
* @param symbol - Token ticker symbol
|
|
305
|
+
* @param imageBase64 - Token image as base64 string (optional)
|
|
306
|
+
* @param paymentToken - "avax" or "arena" (default: "arena")
|
|
307
|
+
* @param initialBuyAvax - AVAX amount for initial buy at creation (default: "0")
|
|
308
|
+
*/
|
|
309
|
+
async launch(wallet, name, symbol, imageBase64, paymentToken = "arena", initialBuyAvax = "0") {
|
|
310
|
+
await this.auth();
|
|
311
|
+
return this.http.post("/launchpad/launch", {
|
|
312
|
+
wallet,
|
|
313
|
+
name,
|
|
314
|
+
symbol,
|
|
315
|
+
imageBase64,
|
|
316
|
+
paymentToken,
|
|
317
|
+
initialBuyAvax
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Upload a token image to Arena's CDN and get the hosted URL.
|
|
322
|
+
* Use this before launch() if you want to preview the image URL first.
|
|
323
|
+
*
|
|
324
|
+
* @param imageBase64 - Image as base64 string
|
|
325
|
+
* @param fileType - MIME type (default: "image/jpeg")
|
|
326
|
+
*/
|
|
327
|
+
async uploadImage(imageBase64, fileType = "image/jpeg") {
|
|
328
|
+
await this.auth();
|
|
329
|
+
return this.http.post("/launchpad/upload-image", { imageBase64, fileType });
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Build only the createToken transaction (no image or community creation).
|
|
333
|
+
* Useful if you want to handle image upload and community creation separately.
|
|
334
|
+
*
|
|
335
|
+
* @param wallet - Creator wallet address
|
|
336
|
+
* @param name - Token name
|
|
337
|
+
* @param symbol - Token ticker symbol
|
|
338
|
+
* @param paymentToken - "avax" or "arena" (default: "arena")
|
|
339
|
+
* @param initialBuyAvax - AVAX for initial buy (default: "0")
|
|
340
|
+
*/
|
|
341
|
+
async buildCreate(wallet, name, symbol, paymentToken = "arena", initialBuyAvax = "0") {
|
|
342
|
+
await this.auth();
|
|
343
|
+
return this.http.get("/launchpad/build/create", { wallet, name, symbol, paymentToken, initialBuyAvax });
|
|
344
|
+
}
|
|
298
345
|
// ── Trading ──
|
|
299
346
|
/**
|
|
300
347
|
* Build unsigned transaction to buy a launchpad token with AVAX.
|
|
@@ -388,6 +435,256 @@ var DexModule = class {
|
|
|
388
435
|
}
|
|
389
436
|
};
|
|
390
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
|
+
|
|
391
688
|
// src/client.ts
|
|
392
689
|
var DEFAULT_BASE_URL = "https://brave-alignment-production-1706.up.railway.app";
|
|
393
690
|
var LogiqicalClient = class {
|
|
@@ -397,8 +694,12 @@ var LogiqicalClient = class {
|
|
|
397
694
|
staking;
|
|
398
695
|
/** Discover, research, and trade launchpad tokens on bonding curves */
|
|
399
696
|
launchpad;
|
|
400
|
-
/** Swap any Avalanche token via LFJ +
|
|
697
|
+
/** Swap any Avalanche token via LFJ + Arena DEX */
|
|
401
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;
|
|
402
703
|
http;
|
|
403
704
|
wallet;
|
|
404
705
|
agentName;
|
|
@@ -412,6 +713,8 @@ var LogiqicalClient = class {
|
|
|
412
713
|
this.staking = new StakingModule(this.http, auth);
|
|
413
714
|
this.launchpad = new LaunchpadModule(this.http, auth);
|
|
414
715
|
this.dex = new DexModule(this.http, auth);
|
|
716
|
+
this.perps = new PerpsModule(this.http, auth);
|
|
717
|
+
this.bridge = new BridgeModule(this.http, auth);
|
|
415
718
|
}
|
|
416
719
|
/** The API key (available after first call or if provided in config) */
|
|
417
720
|
get apiKey() {
|
|
@@ -465,11 +768,13 @@ var LogiqicalClient = class {
|
|
|
465
768
|
}
|
|
466
769
|
};
|
|
467
770
|
export {
|
|
771
|
+
BridgeModule,
|
|
468
772
|
DexModule,
|
|
469
773
|
LaunchpadModule,
|
|
470
774
|
LogiqicalAuthError,
|
|
471
775
|
LogiqicalClient,
|
|
472
776
|
LogiqicalError,
|
|
777
|
+
PerpsModule,
|
|
473
778
|
StakingModule,
|
|
474
779
|
SwapModule
|
|
475
780
|
};
|