hyperliquid 0.5.0 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4e2d29336f0e921d82f0f7a154676a102a228fd5aa4811b85db890802330865
4
- data.tar.gz: ff28b26c30bd14549def4e1f5adb3193ab812cc4527da50109dd17d5bc333816
3
+ metadata.gz: 67b19ec4599a62be35288947fdc8ce2a98c6a0f012f4bdb055a58bd9e4a37849
4
+ data.tar.gz: 58470f99ebf59a1ba95936816c887210d5937240c55ea1b6e85f7d68b0d82a37
5
5
  SHA512:
6
- metadata.gz: d19f8ddf0b9d7cb16a7791a2d7117725929e956c05a46a27b11cc9b27bb051f0c4d7b1cfc1053e3683a9577ceaacbd96ebd3b06a3541d527f9c0437e5de067b1
7
- data.tar.gz: 8a590a96b1e14b8178e3d628cb8e498d718e0a41963dad0671ead93c06df3d389e2fe2c3082d2a27965eb0adf46370e1508f8a9b0cb2e002444c225e39d8aa79
6
+ metadata.gz: fe341138c6085166b2ddd6e87fd7458554e178c4361e9ad16ed7ab1d239333c821dc0556d7f86d9080ec2002c3c36f26b3f32282acc2b6ccc010b85f83c83abe
7
+ data.tar.gz: caaefe028d2a4727c01daeea7241290af00c8676d73c2371ce360279f4dc0c18337c1daa398ab968416ee2516f02d08882b0556d91b5e5e78d318bfbd2d7531f
data/.rubocop.yml CHANGED
@@ -4,6 +4,7 @@ AllCops:
4
4
  SuggestExtensions: false
5
5
  Exclude:
6
6
  - 'test_*.rb' # Exclude ad-hoc integration test scripts
7
+ - 'scripts/**/*' # Exclude integration test scripts
7
8
  - 'vendor/**/*' # Exclude vendored gems (CI bundles here)
8
9
 
9
10
  # Allow longer methods for complex logic
data/CHANGELOG.md CHANGED
@@ -1,8 +1,30 @@
1
1
  ## [Ruby Hyperliquid SDK Changelog]
2
2
 
3
+ ## [0.7.0] - 2026-01-30
4
+
5
+ - Add agent, builder & delegation actions to Exchange API
6
+ - `approve_agent` — authorize an agent wallet to trade on behalf of the account
7
+ - `approve_builder_fee` — approve a builder fee rate for a builder address
8
+ - `token_delegate` — delegate or undelegate HYPE tokens to a validator
9
+ - Add builder fee support on order placement
10
+ - Optional `builder:` parameter on `order`, `bulk_orders`, `market_order`, `market_close`
11
+ - Add EIP-712 type definitions for `ApproveAgent`, `ApproveBuilderFee`, and `TokenDelegate`
12
+
13
+ ## [0.6.0] - 2026-01-28
14
+
15
+ - Add transfers and account management to Exchange API
16
+ - USD transfers: `usd_send`, `usd_class_transfer`, `withdraw_from_bridge`
17
+ - Spot transfers: `spot_send`, `send_asset`
18
+ - Sub-accounts: `create_sub_account`, `sub_account_transfer`, `sub_account_spot_transfer`
19
+ - Vaults: `vault_transfer`
20
+ - Referrals: `set_referrer`
21
+ - Add user-signed action signing (`sign_user_signed_action`) for EIP-712 typed data with `HyperliquidSignTransaction` domain
22
+ - Add Python SDK parity test vectors for `usd_send`, `withdraw_from_bridge`, `create_sub_account`, and `sub_account_transfer`
23
+ - Reorganize integration tests into individual scripts under `scripts/` for easier debugging
24
+
3
25
  ## [0.5.0] - 2026-01-28
4
26
 
5
- - Add core trading features to Exchange API (Tier 1 parity with Python SDK)
27
+ - Add core trading features to Exchange API
6
28
  - Order modification: `modify_order`, `batch_modify`
7
29
  - Position management: `update_leverage`, `update_isolated_margin`, `market_close`
8
30
  - Dead man's switch: `schedule_cancel`
data/CLAUDE.md CHANGED
@@ -45,16 +45,15 @@ ruby example.rb
45
45
 
46
46
  ### Integration Testing (Testnet)
47
47
  ```bash
48
- # Run the testnet integration test (requires private key)
48
+ # Run all integration tests (requires private key)
49
49
  # Get testnet funds from: https://app.hyperliquid-testnet.xyz
50
- HYPERLIQUID_PRIVATE_KEY=0x... ruby test_integration.rb
50
+ HYPERLIQUID_PRIVATE_KEY=0x... ruby scripts/test_all.rb
51
+
52
+ # Run a single integration test
53
+ HYPERLIQUID_PRIVATE_KEY=0x... ruby scripts/test_08_usd_class_transfer.rb
51
54
  ```
52
55
 
53
- The integration test executes real trades on testnet:
54
- 1. Spot market roundtrip (buy/sell PURR/USDC)
55
- 2. Spot limit order (place and cancel)
56
- 3. Perp market roundtrip (long/close BTC)
57
- 4. Perp limit order (place short, cancel)
56
+ Integration tests live in `scripts/` as individual files. Each can be run standalone for debugging. `test_integration.rb` at the project root is a convenience wrapper that runs them all.
58
57
 
59
58
  ### Setup
60
59
  ```bash
data/docs/API.md CHANGED
@@ -84,11 +84,32 @@ Read-only methods for querying market data and user information.
84
84
  - `update_leverage(coin:, leverage:, is_cross:, ...)` - Set cross or isolated leverage for a coin
85
85
  - `update_isolated_margin(coin:, amount:, ...)` - Add or remove isolated margin for a position
86
86
 
87
+ ### Transfers & Account Management
88
+
89
+ - `usd_send(amount:, destination:)` - Transfer USDC to another address
90
+ - `spot_send(amount:, destination:, token:)` - Transfer a spot token to another address
91
+ - `usd_class_transfer(amount:, to_perp:)` - Move USDC between perp and spot accounts
92
+ - `withdraw_from_bridge(amount:, destination:)` - Withdraw USDC via the bridge
93
+ - `send_asset(destination:, source_dex:, destination_dex:, token:, amount:)` - Move assets between DEX instances
94
+ - `create_sub_account(name:)` - Create a sub-account
95
+ - `sub_account_transfer(sub_account_user:, is_deposit:, usd:)` - Transfer USDC to/from a sub-account
96
+ - `sub_account_spot_transfer(sub_account_user:, is_deposit:, token:, amount:)` - Transfer spot tokens to/from a sub-account
97
+ - `vault_transfer(vault_address:, is_deposit:, usd:)` - Deposit or withdraw USDC to/from a vault
98
+ - `set_referrer(code:)` - Set referral code
99
+
100
+ ### Agent & Builder
101
+
102
+ - `approve_agent(agent_address:, agent_name:)` - Authorize an agent wallet to trade on behalf of this account
103
+ - `approve_builder_fee(builder:, max_fee_rate:)` - Approve a builder fee rate for a builder address
104
+ - `token_delegate(validator:, wei:, is_undelegate:)` - Delegate or undelegate HYPE tokens to a validator
105
+
87
106
  ### Other
88
107
 
89
108
  - `address` - Get the wallet address associated with the private key
90
109
 
91
- All exchange methods support an optional `vault_address:` parameter for vault trading.
110
+ Order placement and management methods support an optional `vault_address:` parameter for vault trading.
111
+
112
+ Order placement methods (`order`, `bulk_orders`, `market_order`, `market_close`) support an optional `builder:` parameter for builder fee integration. The builder is a Hash with `:b` (builder address) and `:f` (fee in tenths of a basis point).
92
113
 
93
114
  ### Order Types
94
115
 
data/docs/DEVELOPMENT.md CHANGED
@@ -11,13 +11,42 @@ bin/setup
11
11
  ## Running Tests
12
12
 
13
13
  ```bash
14
- # Run all tests
14
+ # Run all unit tests
15
15
  rake spec
16
16
 
17
- # Run tests and linting together (default)
17
+ # Run unit tests and linting together (default)
18
18
  rake
19
19
  ```
20
20
 
21
+ ### Integration Testing (Testnet)
22
+
23
+ Integration tests live in `scripts/` and execute real trades on testnet. No real funds are at risk. Get testnet funds from https://app.hyperliquid-testnet.xyz.
24
+
25
+ ```bash
26
+ # Run all integration tests
27
+ HYPERLIQUID_PRIVATE_KEY=0x... ruby scripts/test_all.rb
28
+
29
+ # Run a single integration test
30
+ HYPERLIQUID_PRIVATE_KEY=0x... ruby scripts/test_08_usd_class_transfer.rb
31
+ ```
32
+
33
+ The convenience wrapper `ruby test_integration.rb` also runs all tests.
34
+
35
+ Available test scripts:
36
+
37
+ | Script | Description |
38
+ |--------|-------------|
39
+ | `test_01_spot_market_roundtrip.rb` | Buy/sell PURR/USDC at market |
40
+ | `test_02_spot_limit_order.rb` | Place and cancel a spot limit order |
41
+ | `test_03_perp_market_roundtrip.rb` | Long/close BTC at market |
42
+ | `test_04_perp_limit_order.rb` | Place and cancel a perp short |
43
+ | `test_05_update_leverage.rb` | Set cross, isolated, and reset leverage |
44
+ | `test_06_modify_order.rb` | Place, modify, and cancel an order |
45
+ | `test_07_market_close.rb` | Open a position and close via `market_close` |
46
+ | `test_08_usd_class_transfer.rb` | Transfer USDC between perp and spot |
47
+ | `test_09_sub_account_lifecycle.rb` | Create sub-account, deposit, withdraw |
48
+ | `test_10_vault_transfer.rb` | Deposit/withdraw to a vault |
49
+
21
50
  ## Linting
22
51
 
23
52
  ```bash
@@ -37,18 +66,3 @@ This opens an interactive prompt with the SDK loaded for experimentation.
37
66
  ```bash
38
67
  ruby example.rb
39
68
  ```
40
-
41
- ## Integration Testing (Testnet)
42
-
43
- For real trading tests on testnet:
44
-
45
- ```bash
46
- # Get testnet funds from: https://app.hyperliquid-testnet.xyz
47
- HYPERLIQUID_PRIVATE_KEY=0x... ruby test_integration.rb
48
- ```
49
-
50
- The integration test executes real trades on testnet:
51
- 1. Spot market roundtrip (buy/sell PURR/USDC)
52
- 2. Spot limit order (place and cancel)
53
- 3. Perp market roundtrip (long/close BTC)
54
- 4. Perp limit order (place short, cancel)
data/docs/EXAMPLES.md CHANGED
@@ -388,6 +388,153 @@ sdk.exchange.order(
388
388
  )
389
389
  ```
390
390
 
391
+ ### Transfers & Account Management
392
+
393
+ ```ruby
394
+ # Transfer USDC to another address
395
+ sdk.exchange.usd_send(
396
+ amount: '100',
397
+ destination: '0x...'
398
+ )
399
+
400
+ # Transfer a spot token to another address
401
+ sdk.exchange.spot_send(
402
+ amount: '50',
403
+ destination: '0x...',
404
+ token: 'PURR'
405
+ )
406
+
407
+ # Move USDC between perp and spot accounts
408
+ sdk.exchange.usd_class_transfer(amount: '100', to_perp: false) # perp -> spot
409
+ sdk.exchange.usd_class_transfer(amount: '100', to_perp: true) # spot -> perp
410
+
411
+ # Withdraw USDC via the bridge
412
+ sdk.exchange.withdraw_from_bridge(
413
+ amount: '100',
414
+ destination: '0x...'
415
+ )
416
+
417
+ # Move assets between DEX instances
418
+ sdk.exchange.send_asset(
419
+ destination: '0x...',
420
+ source_dex: 'dex1',
421
+ destination_dex: 'dex2',
422
+ token: 'USDC',
423
+ amount: '100'
424
+ )
425
+ ```
426
+
427
+ ### Sub-Account Management
428
+
429
+ ```ruby
430
+ # Create a sub-account
431
+ result = sdk.exchange.create_sub_account(name: 'my-sub-account')
432
+ sub_address = result.dig('response', 'data', 'subAccountUser')
433
+
434
+ # Deposit USDC into a sub-account
435
+ sdk.exchange.sub_account_transfer(
436
+ sub_account_user: sub_address,
437
+ is_deposit: true,
438
+ usd: 100
439
+ )
440
+
441
+ # Withdraw USDC from a sub-account
442
+ sdk.exchange.sub_account_transfer(
443
+ sub_account_user: sub_address,
444
+ is_deposit: false,
445
+ usd: 50
446
+ )
447
+
448
+ # Transfer spot tokens to a sub-account
449
+ sdk.exchange.sub_account_spot_transfer(
450
+ sub_account_user: sub_address,
451
+ is_deposit: true,
452
+ token: 'PURR',
453
+ amount: '10'
454
+ )
455
+ ```
456
+
457
+ ### Vault Operations
458
+
459
+ ```ruby
460
+ # Deposit USDC into a vault
461
+ sdk.exchange.vault_transfer(
462
+ vault_address: '0x...',
463
+ is_deposit: true,
464
+ usd: 100
465
+ )
466
+
467
+ # Withdraw USDC from a vault
468
+ sdk.exchange.vault_transfer(
469
+ vault_address: '0x...',
470
+ is_deposit: false,
471
+ usd: 50
472
+ )
473
+ ```
474
+
475
+ ### Referral
476
+
477
+ ```ruby
478
+ # Set a referral code
479
+ sdk.exchange.set_referrer(code: 'MY_REFERRAL_CODE')
480
+ ```
481
+
482
+ ### Agent, Builder & Delegation
483
+
484
+ ```ruby
485
+ # Authorize an agent wallet to trade on your behalf
486
+ agent_key = Eth::Key.new
487
+ result = sdk.exchange.approve_agent(
488
+ agent_address: agent_key.address.to_s,
489
+ agent_name: 'my-trading-bot' # optional
490
+ )
491
+
492
+ # Approve a builder fee (required before placing orders with that builder)
493
+ sdk.exchange.approve_builder_fee(
494
+ builder: '0x250F311Ae04D3CEA03443C76340069eD26C47D7D',
495
+ max_fee_rate: '0.01%' # 1 basis point
496
+ )
497
+
498
+ # Place an order with a builder fee
499
+ sdk.exchange.order(
500
+ coin: 'BTC',
501
+ is_buy: true,
502
+ size: '0.01',
503
+ limit_px: '95000',
504
+ builder: { b: '0x250F311Ae04D3CEA03443C76340069eD26C47D7D', f: 10 } # f=10 means 1bp
505
+ )
506
+
507
+ # Builder works with all order methods
508
+ sdk.exchange.bulk_orders(
509
+ orders: [
510
+ { coin: 'BTC', is_buy: true, size: '0.01', limit_px: '94000' },
511
+ { coin: 'BTC', is_buy: false, size: '0.01', limit_px: '96000' }
512
+ ],
513
+ builder: { b: '0x250F311Ae04D3CEA03443C76340069eD26C47D7D', f: 10 }
514
+ )
515
+
516
+ sdk.exchange.market_order(
517
+ coin: 'BTC',
518
+ is_buy: true,
519
+ size: '0.01',
520
+ builder: { b: '0x250F311Ae04D3CEA03443C76340069eD26C47D7D', f: 10 }
521
+ )
522
+
523
+ # Delegate HYPE tokens to a validator (wei = float * 1e8)
524
+ sdk.exchange.token_delegate(
525
+ validator: '0x...',
526
+ wei: 100_000_000, # 1 HYPE
527
+ is_undelegate: false
528
+ )
529
+
530
+ # Undelegate HYPE tokens
531
+ sdk.exchange.token_delegate(
532
+ validator: '0x...',
533
+ wei: 10_000_000, # 0.1 HYPE
534
+ is_undelegate: true
535
+ )
536
+ ```
537
+
391
538
  ### Client Order IDs (Cloid)
392
539
 
393
540
  ```ruby