feat: add PerpDeployHaltTrading method#110
Conversation
There was a problem hiding this comment.
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
PerpDeployHaltTradingmethod withcoinandisHaltedparameters - Implements standard PerpDeploy action signing and posting flow
- Returns
PerpDeployResponseconsistent with other PerpDeploy methods
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func (e *Exchange) PerpDeployHaltTrading( | ||
| ctx context.Context, | ||
| coin string, | ||
| isHalted bool, | ||
| ) (*PerpDeployResponse, error) { |
There was a problem hiding this comment.
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.
| return &result, nil | ||
| } | ||
|
|
||
| // PerpHaltTrading halts or unhalts trading for a builder-deployed DEX |
There was a problem hiding this comment.
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.
| // 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. |
|
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. |
|
Added some basic tests |
Thanks! Please change Also please amend your commits to adhere to https://www.conventionalcommits.org/en/v1.0.0/ |
89cb387 to
2a2f1a6
Compare
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"}}' |
There was a problem hiding this comment.
how could you get a success here with a mock coin test:BTC? Hope you didn't manually edit this yaml 🙃
|
Yeah I edited it manually. I thought the goal of recorder is to mock HL responses. Otherwise those won’t he unit tests and we will need to deploy dex and symbol using the static private key.
On Thu, Dec 18, 2025, at 12:12 PM, Marquitos wrote:
***@***.**** commented on this pull request.
In testdata/PerpDeployHaltTrading_Success.yaml <#110 (comment)>:
> @@ -0,0 +1,52 @@
+---
+version: 2
+interactions:
+ - id: 0
+ request:
+ proto: HTTP/1.1
+ proto_major: 1
+ proto_minor: 1
+ content_length: 271
+ host: api.hyperliquid-testnet.xyz
+ body: '{"action":{"haltTrading":{"coin":"test:BTC","isHalted":true},"type":"perpDeploy"}}'
how could you get a success here with a mock coin `test:BTC`? Hope you didn't manually edit this yaml 🙃
—
Reply to this email directly, view it on GitHub <#110 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACPFCICFDFYTXMXVZMWO6LT4CKD27AVCNFSM6AAAAACPLJDILSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTKOJSGI2DQMRXGY>.
You are receiving this because you were assigned.Message ID: ***@***.***>
Thanks,
Ivan
|
Pull Request Test Coverage Report for Build 20334602966Warning: 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
💛 - Coveralls |
Not sure if Python SDK provides it but I needed that method today, so decided to add :)
From docs: