Skip to content

Commit e18564f

Browse files
shankars99shankar
andauthored
hlp/secondary-spot-markets (#1904)
Signed-off-by: shankar <shankar@layerzero.org> Co-authored-by: shankar <shankar@layerzero.org>
1 parent 20ff1d5 commit e18564f

8 files changed

Lines changed: 348 additions & 35 deletions

File tree

.changeset/sixty-readers-talk.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@layerzerolabs/hyperliquid-composer": patch
3+
"@layerzerolabs/oft-hyperliquid-example": patch
4+
---
5+
6+
improved cli and docs on expansion spot market pairs

examples/oft-hyperliquid/HYPERLIQUID.README.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ npx @layerzerolabs/hyperliquid-composer set-genesis \
9090

9191
### 4. Register Trading Spot
9292

93+
Registers a trading pair between your token and a quote asset (USDC, HYPE, or custom quote token).
94+
9395
```bash
9496
npx @layerzerolabs/hyperliquid-composer register-spot \
9597
--token-index <coreIndex> \
@@ -98,16 +100,54 @@ npx @layerzerolabs/hyperliquid-composer register-spot \
98100
[--log-level {info | verbose}]
99101
```
100102

103+
On success, this command outputs the allocated **spot index** and the exact command to run for finalization:
104+
105+
```
106+
============================================================
107+
SPOT REGISTRATION SUCCESSFUL
108+
============================================================
109+
Allocated Spot Index: 1421
110+
Base Token: 1502
111+
Quote Token: USDC (0)
112+
113+
NEXT STEP: Finalize the spot pair with:
114+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
115+
--token-index 1502 \
116+
--network testnet \
117+
--spot-index 1421 \
118+
--private-key $PRIVATE_KEY
119+
============================================================
120+
```
121+
122+
**Note:** For additional spot pairs (beyond the first), this command participates in the spot pair deployment Dutch auction.
123+
101124
### 5. Create Spot Deployment
102125

126+
Finalizes a spot pair by setting hyperliquidity parameters. Required after `register-spot` to make the trading pair live.
127+
103128
```bash
104129
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
105130
--token-index <coreIndex> \
106131
--network {testnet | mainnet} \
107132
--private-key $PRIVATE_KEY_HYPERLIQUID \
133+
[--spot-index <spotIndex>] \
108134
[--log-level {info | verbose}]
109135
```
110136

137+
**Options:**
138+
139+
- `--spot-index <id>`: Directly specify the spot index to finalize (recommended). Use the spot index from the `register-spot` output.
140+
141+
**Example:**
142+
143+
```bash
144+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
145+
--token-index 1502 \
146+
--network testnet \
147+
--spot-index 1421 \
148+
--private-key $PRIVATE_KEY
149+
```
150+
111151
### 6. Set Trading Fee Share (Optional)
112152

113153
Can be done at any time after deployment. **Note:** If you plan to enable quote token capability, read the [Permissionless Spot Quote Assets](https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/permissionless-spot-quote-assets) documentation before setting this value.
@@ -469,7 +509,7 @@ npx @layerzerolabs/hyperliquid-composer set-genesis \
469509

470510
### Step 4/7 `registerSpot`
471511

472-
This is the step that registers the Core Spot on `HyperCore` and creates a base-quote pair. You can now choose between USDC, USDT0, or custom quote tokens.
512+
This is the step that registers the Core Spot on `HyperCore` and creates a base-quote pair. You can choose between USDC, USDT0, HYPE, or custom quote tokens.
473513

474514
```bash
475515
npx @layerzerolabs/hyperliquid-composer register-spot \
@@ -479,9 +519,32 @@ npx @layerzerolabs/hyperliquid-composer register-spot \
479519
[--log-level {info | verbose}]
480520
```
481521

522+
On success, this command outputs the allocated **spot index** and the exact command for finalization:
523+
524+
```
525+
============================================================
526+
SPOT REGISTRATION SUCCESSFUL
527+
============================================================
528+
Allocated Spot Index: 1421
529+
Base Token: 1502
530+
Quote Token: USDC (0)
531+
532+
NEXT STEP: Finalize the spot pair with:
533+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
534+
--token-index 1502 \
535+
--network testnet \
536+
--spot-index 1421 \
537+
--private-key $PRIVATE_KEY
538+
============================================================
539+
```
540+
541+
**Note:** For additional spot pairs (beyond the first), this command participates in the spot pair deployment Dutch auction.
542+
482543
### Step 5/7 `createSpotDeployment`
483544

484-
This is the step that creates a spot deployment without hyperliquidity. This step is meant for tokens deployed with Hyperliquidity but is also required for tokens deployed without Hyperliquidity to be listed on Spot trading, as such the values for `startPx` and `orderSz` are not required as they are set by the market and the value set does not matter. The value for `nOrders` however MUST be 0 as we do not support Hyperliquidity - <https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/examples/spot_deploy.py#L97-L104>
545+
This step finalizes a spot deployment by setting hyperliquidity parameters. Required after `register-spot` to make the trading pair live on HyperCore.
546+
547+
For tokens deployed without Hyperliquidity, the values for `startPx` and `orderSz` are not significant as they are set by the market. The value for `nOrders` MUST be 0 as we do not support Hyperliquidity - <https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/examples/spot_deploy.py#L97-L104>
485548

486549
You will NOT be prompted for the following and instead the values will be set to 0:
487550

@@ -497,9 +560,24 @@ npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
497560
--token-index <coreIndex> \
498561
--network {testnet | mainnet} \
499562
--private-key $PRIVATE_KEY_HYPERLIQUID \
563+
[--spot-index <spotIndex>] \
500564
[--log-level {info | verbose}]
501565
```
502566

567+
**Options:**
568+
569+
- `--spot-index <id>`: Directly specify the spot index to finalize. Use the spot index from `register-spot` output. This is the recommended approach.
570+
571+
**Example:**
572+
573+
```bash
574+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
575+
--token-index 1502 \
576+
--network testnet \
577+
--spot-index 1421 \
578+
--private-key $PRIVATE_KEY
579+
```
580+
503581
> ⚠️ Note: `spot-deploy-state` should fail after completing this step.
504582
505583
Your Core Spot (that does not use Hyperliquidity) has now been deployed and registered on `HyperCore`.

packages/hyperliquid-composer/HYPERLIQUID.README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ npx @layerzerolabs/hyperliquid-composer set-genesis \
490490

491491
### 4. Register Trading Spot
492492

493+
Registers a trading pair between your token and a quote asset (USDC, HYPE, or custom quote token).
494+
493495
```bash
494496
npx @layerzerolabs/hyperliquid-composer register-spot \
495497
--token-index <coreIndex> \
@@ -498,16 +500,53 @@ npx @layerzerolabs/hyperliquid-composer register-spot \
498500
[--log-level {info | verbose}]
499501
```
500502

503+
On success, this command outputs the allocated **spot index** and the exact command to run for finalization:
504+
505+
```
506+
============================================================
507+
SPOT REGISTRATION SUCCESSFUL
508+
============================================================
509+
Allocated Spot Index: 1421
510+
Base Token: 1502
511+
Quote Token: USDC (0)
512+
513+
NEXT STEP: Finalize the spot pair with:
514+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
515+
--token-index 1502 \
516+
--network testnet \
517+
--spot-index 1421 \
518+
--private-key $PRIVATE_KEY
519+
============================================================
520+
```
521+
522+
**Note:** For additional spot pairs (beyond the first), this command participates in the spot pair deployment Dutch auction. Check the current auction status with `spot-auction-status`.
523+
501524
### 5. Create Spot Deployment
502525

526+
Finalizes a spot pair by setting hyperliquidity parameters. This step is required after `register-spot` to make the trading pair live.
527+
503528
```bash
504529
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
505530
--token-index <coreIndex> \
506531
--network {testnet | mainnet} \
507532
--private-key $PRIVATE_KEY_HYPERLIQUID \
533+
[--spot-index <spotIndex>] \
508534
[--log-level {info | verbose}]
509535
```
510536

537+
**Options:**
538+
- `--spot-index <id>`: Directly specify the spot index to finalize (recommended). This skips discovery and uses the spot index provided by `register-spot`.
539+
540+
**Example (using spot index from register-spot output):**
541+
542+
```bash
543+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
544+
--token-index 1502 \
545+
--network testnet \
546+
--spot-index 1421 \
547+
--private-key $PRIVATE_KEY
548+
```
549+
511550
### 6. Set Trading Fee Share (Optional)
512551

513552
Can be done at any time after deployment. **Note:** If you plan to enable quote token capability, read the [Permissionless Spot Quote Assets](https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/permissionless-spot-quote-assets) documentation before setting this value.
@@ -917,7 +956,9 @@ npx @layerzerolabs/hyperliquid-composer register-spot \
917956

918957
### Step 5/7 `createSpotDeployment`
919958

920-
This is the step that creates a spot deployment without hyperliquidity. This step is meant for tokens deployed with Hyperliquidity but is also required for tokens deployed without Hyperliquidity to be listed on Spot trading, as such the values for `startPx` and `orderSz` are not required as they are set by the market and the value set does not matter. The value for `nOrders` however MUST be 0 as we do not support Hyperliquidity - <https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/examples/spot_deploy.py#L97-L104>
959+
This step finalizes a spot deployment by setting hyperliquidity parameters. It is required after `register-spot` to make the trading pair live on HyperCore.
960+
961+
For tokens deployed without Hyperliquidity, the values for `startPx` and `orderSz` are not significant as they are set by the market. The value for `nOrders` MUST be 0 as we do not support Hyperliquidity - <https://github.com/hyperliquid-dex/hyperliquid-python-sdk/blob/master/examples/spot_deploy.py#L97-L104>
921962

922963
You will NOT be prompted for the following and instead the values will be set to 0:
923964

@@ -933,9 +974,24 @@ npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
933974
--token-index <coreIndex> \
934975
--network {testnet | mainnet} \
935976
--private-key $PRIVATE_KEY_HYPERLIQUID \
977+
[--spot-index <spotIndex>] \
936978
[--log-level {info | verbose}]
937979
```
938980

981+
**Options:**
982+
- `--spot-index <id>`: Directly specify the spot index to finalize. Use the spot index output from the `register-spot` command. This is the recommended approach as it skips network-wide discovery.
983+
984+
**Example:**
985+
986+
```bash
987+
# Using the spot index from register-spot output
988+
npx @layerzerolabs/hyperliquid-composer create-spot-deployment \
989+
--token-index 1502 \
990+
--network testnet \
991+
--spot-index 1421 \
992+
--private-key $PRIVATE_KEY
993+
```
994+
939995
> ⚠️ Note: `spot-deploy-state` should fail after completing this step.
940996
941997
Your Core Spot (that does not use Hyperliquidity) has now been deployed and registered on `HyperCore`.

packages/hyperliquid-composer/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ optionGroups
170170
program
171171
.command(CLI_COMMANDS.CREATE_SPOT_DEPLOYMENT)
172172
.description('HIP-1 Deployment 4. Create spot deployment without hyperliquidity')
173+
.option('-s, --spot-index <spot-index>', 'Directly specify spot index to finalize (skips discovery)')
173174
)
174175
.action(withNormalizedNetwork(createSpotDeployment))
175176

packages/hyperliquid-composer/src/commands/spot-deploy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@ export async function createSpotDeployment(args: CreateSpotDeploymentArgs): Prom
9595
const signer = await getHyperliquidSigner(args.privateKey)
9696
const isTestnet = args.network === 'testnet'
9797
const tokenIndex: number = parseInt(args.tokenIndex)
98+
const spotIndex: number | undefined = args.spotIndex ? parseInt(args.spotIndex) : undefined
9899

99-
logger.info(`Setting no hyperliquidity for token ${tokenIndex}`)
100+
if (spotIndex !== undefined) {
101+
logger.info(`Finalizing spot ${spotIndex} for token ${tokenIndex}`)
102+
} else {
103+
logger.info(`Setting no hyperliquidity for token ${tokenIndex}`)
104+
}
100105

101-
await setNoHyperliquidity(signer, isTestnet, tokenIndex, args.logLevel)
106+
await setNoHyperliquidity(signer, isTestnet, tokenIndex, args.logLevel, spotIndex)
102107
}
103108

104109
export async function registerTradingSpot(args: RegisterTradingSpotArgs): Promise<void> {

0 commit comments

Comments
 (0)