fix(api/twapOrder): raise the max TWAP duration to 7 days - #198
Open
JulienKervarrec wants to merge 2 commits into
Open
JulienKervarrec wants to merge 2 commits into
JulienKervarrec wants to merge 2 commits into
Conversation
twap.m was capped at 1440 minutes (24 hours), but Hyperliquid allows a TWAP running time of 5 minutes to 7 days, so any duration above 24 hours was rejected client-side before the request was sent. Part of nktkas#194 Signed-off-by: Julien Kervarrec <114134889+JulienKervarrec@users.noreply.github.com>
Author
|
I checked the new bounds against the schema itself: |
Offline schema test: m = 5, 1440, 1441 and 10080 are accepted, 4 and 10081 rejected. It fails on main (m=1441) and passes with the new bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Julien Kervarrec <114134889+JulienKervarrec@users.noreply.github.com>
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TwapOrderRequestcapstwap.mat 1440 minutes:That is 24 hours, but the venue allows a TWAP running time of 5 minutes to 7 days (Hyperliquid docs, Trading → Order types → TWAP). Every duration between 24 hours and 7 days is therefore rejected by valibot before the request leaves the client, even though the exchange would accept it.
#194 mentions patching this exact value locally for that reason.
Change
10080 = 7 × 24 × 60. The minimum stays at 5, which already matched the documented range. One numeric literal and a trailing comment; no type or runtime behaviour changes beyond the widened bound.
Checks
tests/api/exchange/twapOrder.test.ts("twapOrder: duration bounds"): thetwapschema acceptsm= 5, 1440, 1441 and 10080 and rejects 4 and 10081. It fails onmain(m=1441 should be accepted) and passes with this change.deno test -A tests/api/exchange/twapOrder.test.ts -- --offlinepasses;deno fmt --checkanddeno lintpass on both files.jsr.iois unreachable from my machine, so for that run the JSR imports were mapped to local equivalents; CI remains the reference.Part of #194.