@circuitorg/agent-sdk 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +114 -0
  2. package/index.d.ts +1116 -44
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -24,6 +24,11 @@ A simplified TypeScript SDK for building automated agents to deploy on Circuit.
24
24
  - [📈 Polymarket Prediction Markets](#-polymarket-prediction-markets)
25
25
  - [Place Market Orders](#place-market-orders)
26
26
  - [Redeem Positions](#redeem-positions)
27
+ - [Hyperliquid Trading](#hyperliquid-trading)
28
+ - [Account Information](#account-information)
29
+ - [Place Orders](#place-orders)
30
+ - [Order Management](#order-management)
31
+ - [Transfer Between Accounts](#transfer-between-accounts)
27
32
  - [📊 Transaction History](#-transaction-history)
28
33
  - [🚀 Sign \& Send Transactions](#-sign--send-transactions)
29
34
  - [Ethereum (any EVM chain)](#ethereum-any-evm-chain)
@@ -328,6 +333,115 @@ async function stop(agent: AgentContext): Promise<void> {
328
333
  }
329
334
  ```
330
335
 
336
+ ## Hyperliquid Trading
337
+
338
+ Trade perpetual futures (with leverage) and spot markets on Hyperliquid DEX.
339
+
340
+ **Market Types:**
341
+ - **Perp**: Perpetual futures trading with leverage (use `market: "perp"` in order parameters)
342
+ - **Spot**: Spot trading (use `market: "spot"` in order parameters)
343
+
344
+ **Asset Naming for Spot:**
345
+ - Non-Hypercore-native assets use "Unit" prefix: `UBTC` (Unit BTC), `UETH` (Unit ETH)
346
+ - Example: To trade BTC spot, use symbol `UBTC-USDC`
347
+
348
+ ### Account Information
349
+
350
+ ```typescript
351
+ async function run(agent: AgentContext): Promise<void> {
352
+ // Check balances
353
+ const balances = await agent.platforms.hyperliquid.balances();
354
+ if (balances.success && balances.data) {
355
+ await agent.log(`Account value: $${balances.data.perp.accountValue}`);
356
+ await agent.log(`Withdrawable: $${balances.data.perp.withdrawable}`);
357
+ }
358
+
359
+ // View open positions
360
+ const positions = await agent.platforms.hyperliquid.positions();
361
+ if (positions.success && positions.data) {
362
+ for (const pos of positions.data) {
363
+ await agent.log(`${pos.symbol}: ${pos.side} ${pos.size} @ ${pos.entryPrice}`);
364
+ await agent.log(`Unrealized PnL: $${pos.unrealizedPnl}`);
365
+ }
366
+ }
367
+ }
368
+ ```
369
+
370
+ ### Place Orders
371
+
372
+ ```typescript
373
+ async function run(agent: AgentContext): Promise<void> {
374
+ // Perp market order
375
+ const perpOrder = await agent.platforms.hyperliquid.placeOrder({
376
+ symbol: "BTC-USD",
377
+ side: "buy",
378
+ size: 0.0001,
379
+ price: 110000, // Acts as slippage limit for market orders
380
+ market: "perp",
381
+ type: "market"
382
+ });
383
+
384
+ if (perpOrder.success && perpOrder.data) {
385
+ await agent.log(`Perp Order ${perpOrder.data.orderId}: ${perpOrder.data.status}`);
386
+ } else {
387
+ await agent.log(perpOrder.error, { error: true });
388
+ }
389
+
390
+ // Spot market order (for non-Hypercore-native assets like BTC)
391
+ const spotOrder = await agent.platforms.hyperliquid.placeOrder({
392
+ symbol: "UBTC-USDC", // Unit BTC
393
+ side: "buy",
394
+ size: 0.0001,
395
+ price: 110000,
396
+ market: "spot", // Changed to spot
397
+ type: "market"
398
+ });
399
+
400
+ if (spotOrder.success && spotOrder.data) {
401
+ await agent.log(`Spot Order ${spotOrder.data.orderId}: ${spotOrder.data.status}`);
402
+ } else {
403
+ await agent.log(spotOrder.error, { error: true });
404
+ }
405
+ }
406
+ ```
407
+
408
+ ### Order Management
409
+
410
+ ```typescript
411
+ async function run(agent: AgentContext): Promise<void> {
412
+ // Get open orders
413
+ const openOrders = await agent.platforms.hyperliquid.openOrders();
414
+
415
+ // Get specific order details
416
+ const order = await agent.platforms.hyperliquid.order("12345");
417
+
418
+ // Cancel an order
419
+ const result = await agent.platforms.hyperliquid.deleteOrder("12345", "BTC-USD");
420
+
421
+ // View historical orders
422
+ const history = await agent.platforms.hyperliquid.orders();
423
+
424
+ // Check order fills
425
+ const fills = await agent.platforms.hyperliquid.orderFills();
426
+ }
427
+ ```
428
+
429
+ ### Transfer Between Accounts
430
+
431
+ ```typescript
432
+ async function run(agent: AgentContext): Promise<void> {
433
+ // Transfer USDC from spot to perp account
434
+ const transfer = await agent.platforms.hyperliquid.transfer({
435
+ amount: 1000.0,
436
+ toPerp: true
437
+ });
438
+
439
+ if (transfer.success) {
440
+ await agent.log("Transfer completed");
441
+ }
442
+ }
443
+ ```
444
+
331
445
  ## 📊 Transaction History
332
446
 
333
447
  Get a list of asset changes for all confirmed transactions during your session. This is useful for tracking what assets have moved in and out of the agent's wallet.