Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c25427e
feat(perps-controller): add stop/take-profit placement types, reduce-…
abretonc7s Jul 27, 2026
d6ea2c5
fix: address self-review feedback (TAT-3511)
abretonc7s Jul 28, 2026
3dfeabd
chore(perps-controller): rewrite the advanced-orders recipe in Recipe v1
abretonc7s Jul 28, 2026
0e4fe10
feat(perps-controller): add provider-agnostic tpslLinkage order option
abretonc7s Jul 28, 2026
f16e6d9
feat(perps-controller): prove advanced order types natively in the re…
abretonc7s Jul 28, 2026
63f0116
fix(perps-controller): honour timeInForce for limit orders
abretonc7s Jul 28, 2026
1c3ff0d
refactor(perps-controller): use a typed error code for unsupported ti…
abretonc7s Jul 28, 2026
df4f8cb
fix: address self-review feedback (TAT-3511)
abretonc7s Jul 28, 2026
5b4a84e
fix: address self-review feedback (TAT-3511)
abretonc7s Jul 28, 2026
c6ab60e
fix: address self-review feedback (TAT-3511)
abretonc7s Jul 28, 2026
71e44c1
fix(perps-controller): repair the build broken by the rev4 fixes
abretonc7s Jul 28, 2026
449059f
fix(perps-controller): clear standalone trigger leftovers on whole-po…
abretonc7s Jul 28, 2026
bb929be
test(perps-controller): guard streamed TP/SL counts against the trigg…
abretonc7s Jul 28, 2026
029871e
refactor(perps-controller): move e2e proof tooling out of the package
abretonc7s Jul 28, 2026
b013534
fix(perps-controller): repair CI after the standalone-trigger sweep
abretonc7s Jul 28, 2026
f6878fb
fix(perps-controller): close four advanced-order placement holes
abretonc7s Jul 28, 2026
f48a559
fix(perps-controller): reject unusable TP/SL sizes before any side ef…
abretonc7s Jul 28, 2026
03df555
fix(perps-controller): refuse orphan TP/SL and defer trading setup
abretonc7s Jul 28, 2026
8736d50
fix(perps-controller): refuse position linkage and hash trigger types
abretonc7s Jul 28, 2026
093ea06
fix(perps-controller): reject prices that round away at asset precision
abretonc7s Jul 29, 2026
944131d
fix(perps-controller): resolve position-bound trigger sizes from the …
abretonc7s Jul 29, 2026
b7c915a
fix(perps-controller): keep unnamed triggers in the position state
abretonc7s Jul 29, 2026
05fa31f
test(perps-controller): prove the advanced-order contract against the…
abretonc7s Jul 29, 2026
0914a53
fix(perps-controller): break the equal-price trigger tie the same way…
abretonc7s Jul 29, 2026
3d3e28d
chore(perps-controller): declare the e2e script to the dependency checks
abretonc7s Jul 29, 2026
2575697
fix(perps-controller): stop reporting the replaced order id after an …
abretonc7s Jul 31, 2026
90d9cf2
fix(perps-controller): address bugbot comments
abretonc7s Jul 31, 2026
a97462b
docs(perps-controller): declare the positionTpsl rejection as breaking
abretonc7s Jul 31, 2026
771ddc2
Merge remote-tracking branch 'origin/main' into TAT-3511-feat-add-per…
abretonc7s Jul 31, 2026
544e0b2
Merge remote-tracking branch 'origin/main' into TAT-3511-feat-add-per…
abretonc7s Jul 31, 2026
5a4d007
fix(perps-controller): refuse an unverifiable edit before trading setup
abretonc7s Jul 31, 2026
10d24dd
Merge remote-tracking branch 'origin/main' into TAT-3511-feat-add-per…
abretonc7s Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions knip.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ const config: KnipConfig = {
ignoreDependencies: ['bats'],
},
'packages/perps-controller': {
// Run directly (`npx tsx tests/e2e/...`) rather than imported, so knip
// needs telling it is an entry point — otherwise the dependencies only
// it uses look unused.
entry: ['tests/e2e/*.ts'],
ignoreDependencies: ['@metamask/accounts-controller'],
// The mobile client provides `core/Engine`; tests mock it via a
// relative path that doesn't resolve inside this monorepo.
ignoreUnresolved: [/^\.\.\/\.\.\/\.\.\/core\/Engine$/u],
},

// -- Per-workspace `ignoreDependencies` snapshots --
Expand Down
62 changes: 58 additions & 4 deletions packages/perps-controller/CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/perps-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
"tsx": "^4.20.5",
"typedoc": "^0.25.13",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.3.3"
"typescript": "~5.3.3",
"viem": "^2.55.8"
},
"optionalDependencies": {
"@myx-trade/sdk": "^0.1.265"
Expand Down
6 changes: 6 additions & 0 deletions packages/perps-controller/src/constants/eventNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ export const PERPS_EVENT_VALUE = {
ORDER_TYPE: {
MARKET: 'market',
LIMIT: 'limit',
// Trigger placements are emitted verbatim by TradingService, so the enum has
// to list them for dashboards keyed on `order_type`.
STOP_MARKET: 'stop_market',
STOP_LIMIT: 'stop_limit',
TAKE_PROFIT_MARKET: 'take_profit_market',
TAKE_PROFIT_LIMIT: 'take_profit_limit',
},
ORDER_TYPE_CAPITALIZED: {
MARKET: 'market',
Expand Down
19 changes: 19 additions & 0 deletions packages/perps-controller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ export type {
GetUserHistoryParams,
TradeConfiguration,
OrderType,
TriggerOrderType,
OrderExecution,
TriggerDirection,
TpslLinkage,
PositionTriggerOrder,
MarketType,
MarketTypeFilter,
InputMethod,
Expand Down Expand Up @@ -475,6 +480,20 @@ export {
validateOrderParams,
validateCoinExists,
} from './utils/index.js';
export {
TRIGGER_ORDER_TYPES,
isTriggerOrderType,
isLimitExecutionOrderType,
getTriggerExecution,
getTriggerDirection,
buildTriggerOrderType,
buildPositionTriggerOrderFromOrder,
} from './utils/index.js';
export {
adaptTriggerOrderTypeFromSDK,
adaptPositionTriggerOrderFromSDK,
adaptTpslLinkageToGrouping,
} from './utils/index.js';
export {
generatePerpsId,
generateDepositId,
Expand Down
13 changes: 13 additions & 0 deletions packages/perps-controller/src/perpsErrorCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ export const PERPS_ERROR_CODES = {
ORDER_LEVERAGE_INVALID: 'ORDER_LEVERAGE_INVALID',
ORDER_LEVERAGE_BELOW_POSITION: 'ORDER_LEVERAGE_BELOW_POSITION',
ORDER_MAX_VALUE_EXCEEDED: 'ORDER_MAX_VALUE_EXCEEDED',
// Validation errors - trigger placement (stop / take profit) and partial TP/SL
ORDER_TRIGGER_PRICE_REQUIRED: 'ORDER_TRIGGER_PRICE_REQUIRED', // stop_*/take_profit_* placed without a trigger price
ORDER_TRIGGER_PRICE_POSITIVE: 'ORDER_TRIGGER_PRICE_POSITIVE',
ORDER_TRIGGER_PRICE_NOT_SUPPORTED: 'ORDER_TRIGGER_PRICE_NOT_SUPPORTED', // Trigger price supplied for a market/limit order
ORDER_TRIGGER_TPSL_UNSUPPORTED: 'ORDER_TRIGGER_TPSL_UNSUPPORTED', // Attached TP/SL on a trigger placement
ORDER_TPSL_SIZE_INVALID: 'ORDER_TPSL_SIZE_INVALID', // Partial TP/SL size non-positive, larger than the order, or missing its price
ORDER_EDIT_TRIGGER_UNSUPPORTED: 'ORDER_EDIT_TRIGGER_UNSUPPORTED', // editOrder cannot turn a resting order into a trigger placement
ORDER_TPSL_LINKAGE_CONFLICT: 'ORDER_TPSL_LINKAGE_CONFLICT', // tpslLinkage and the deprecated grouping disagree
ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED:
'ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED', // Position-linked TP/SL requested on an order placement; use updatePositionTPSL
ORDER_TPSL_LINKAGE_REQUIRED: 'ORDER_TPSL_LINKAGE_REQUIRED', // Attached TP/SL requested with no linkage to parent or position
ORDER_EDIT_ORDER_UNVERIFIABLE: 'ORDER_EDIT_ORDER_UNVERIFIABLE', // editOrder cannot confirm the resting order's placement type
ORDER_TIME_IN_FORCE_NOT_SUPPORTED: 'ORDER_TIME_IN_FORCE_NOT_SUPPORTED', // Time in force supplied for an order shape that cannot carry one
// HyperLiquid client/service errors
EXCHANGE_CLIENT_NOT_AVAILABLE: 'EXCHANGE_CLIENT_NOT_AVAILABLE',
INFO_CLIENT_NOT_AVAILABLE: 'INFO_CLIENT_NOT_AVAILABLE',
Expand Down
Loading
Loading