Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add PerpDeployHaltTrading method#110

Merged
sonirico merged 1 commit intosonirico:masterfrom
ivaaaan:halt-trading-method
Dec 18, 2025
Merged

feat: add PerpDeployHaltTrading method#110
sonirico merged 1 commit intosonirico:masterfrom
ivaaaan:halt-trading-method

Conversation

@ivaaaan
Copy link
Contributor

@ivaaaan ivaaaan commented Dec 17, 2025

Not sure if Python SDK provides it but I needed that method today, so decided to add :)

From docs:

{
      type: "perpDeploy",
      haltTrading: { coin: string, isHalted: boolean },
    }

Copilot AI review requested due to automatic review settings December 17, 2025 20:10
@ivaaaan ivaaaan changed the title feat: add haltTrading method feat: add PerpDeployHaltTrading method Dec 17, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new PerpDeployHaltTrading method to enable halting or unhalting trading for builder-deployed perpetual DEXs. The method follows the established pattern for PerpDeploy operations, constructing a signed L1 action and posting it to the API.

  • Adds new PerpDeployHaltTrading method with coin and isHalted parameters
  • Implements standard PerpDeploy action signing and posting flow
  • Returns PerpDeployResponse consistent with other PerpDeploy methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1327 to +1331
func (e *Exchange) PerpDeployHaltTrading(
ctx context.Context,
coin string,
isHalted bool,
) (*PerpDeployResponse, error) {
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PerpDeployHaltTrading method is missing a dex parameter that appears to be required by other PerpDeploy methods. Looking at PerpDeployRegisterAsset (line 1258) and PerpDeploySetOracle (line 1374), both include a dex parameter to identify which builder-deployed DEX to operate on. The haltTrading action likely needs to specify which DEX's trading should be halted. Consider adding a dex string parameter to the function signature and including it in the action payload.

Copilot uses AI. Check for mistakes.
return &result, nil
}

// PerpHaltTrading halts or unhalts trading for a builder-deployed DEX
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function documentation is missing a reference to the Python SDK method that this corresponds to. Other PerpDeploy methods in this file include such references (e.g., "This matches the Python SDK's perp_deploy_register_asset method" on line 1255, "This matches the Python SDK's perp_deploy_set_oracle method" on line 1368). For consistency with the codebase's documented goal of maintaining feature parity with the Python SDK, add a similar comment indicating which Python SDK method this implements.

Suggested change
// PerpHaltTrading halts or unhalts trading for a builder-deployed DEX
// PerpHaltTrading halts or unhalts trading for a builder-deployed DEX. This matches the Python SDK's perp_deploy_halt_trading method.

Copilot uses AI. Check for mistakes.
@sonirico
Copy link
Owner

Hi @ivaaaan thank you so much for your contribution. Would you mind to introduce some tests as well? You can have a look at https://github.com/sonirico/go-hyperliquid/blob/master/info_test.go#L704 to see how it's done. Also, please kindly review if this is an "info" endpoint or an "exchange" endpoint to place this code on the appropriate file.

@ivaaaan
Copy link
Contributor Author

ivaaaan commented Dec 18, 2025

Added some basic tests

@sonirico
Copy link
Owner

Added some basic tests

Thanks!

Please change initRecorder(true...) to initRecorder(false...), otherwise the yaml will be overridden again.

Also please amend your commits to adhere to https://www.conventionalcommits.org/en/v1.0.0/

@ivaaaan ivaaaan force-pushed the halt-trading-method branch from 89cb387 to 2a2f1a6 Compare December 18, 2025 10:55
@ivaaaan
Copy link
Contributor Author

ivaaaan commented Dec 18, 2025

Added some basic tests

Thanks!

Please change initRecorder(true...) to initRecorder(false...), otherwise the yaml will be overridden again.

Also please amend your commits to adhere to https://www.conventionalcommits.org/en/v1.0.0/

Yep, all should be fixed now.

proto_minor: 1
content_length: 271
host: api.hyperliquid-testnet.xyz
body: '{"action":{"haltTrading":{"coin":"test:BTC","isHalted":true},"type":"perpDeploy"}}'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how could you get a success here with a mock coin test:BTC? Hope you didn't manually edit this yaml 🙃

@ivaaaan
Copy link
Contributor Author

ivaaaan commented Dec 18, 2025 via email

@sonirico sonirico merged commit 000e597 into sonirico:master Dec 18, 2025
2 checks passed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 20334602966

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 30 of 42 (71.43%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 18.241%

Changes Missing Coverage Covered Lines Changed/Added Lines %
exchange_others.go 25 31 80.65%
types_easyjson.go 5 11 45.45%
Totals Coverage Status
Change from base Build 20228176968: 0.4%
Covered Lines: 3354
Relevant Lines: 18387

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants