@drift-labs/common 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/lib/EnvironmentConstants.js +2 -2
  2. package/lib/EnvironmentConstants.js.map +1 -1
  3. package/lib/clients/DlobWebsocketClient.d.ts +6 -0
  4. package/lib/clients/DlobWebsocketClient.js +24 -4
  5. package/lib/clients/DlobWebsocketClient.js.map +1 -1
  6. package/lib/clients/candleClient.js +12 -0
  7. package/lib/clients/candleClient.js.map +1 -1
  8. package/lib/clients/swiftClient.d.ts +1 -0
  9. package/lib/clients/swiftClient.js +79 -25
  10. package/lib/clients/swiftClient.js.map +1 -1
  11. package/lib/clients/tvFeed.d.ts +5 -1
  12. package/lib/clients/tvFeed.js +32 -5
  13. package/lib/clients/tvFeed.js.map +1 -1
  14. package/lib/common-ui-utils/commonUiUtils.d.ts +1 -2
  15. package/lib/common-ui-utils/commonUiUtils.js +38 -3
  16. package/lib/common-ui-utils/commonUiUtils.js.map +1 -1
  17. package/lib/common-ui-utils/order.d.ts +1 -2
  18. package/lib/common-ui-utils/order.js +9 -10
  19. package/lib/common-ui-utils/order.js.map +1 -1
  20. package/lib/common-ui-utils/user.js +23 -20
  21. package/lib/common-ui-utils/user.js.map +1 -1
  22. package/lib/constants/autogenerated/driftErrors.json +5 -1
  23. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.d.ts +1 -1
  24. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js +20 -5
  25. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js.map +1 -1
  26. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.d.ts +9 -1
  27. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.js.map +1 -1
  28. package/lib/drift/Drift/clients/AuthorityDrift/index.d.ts +1 -1
  29. package/lib/drift/Drift/clients/AuthorityDrift/index.js.map +1 -1
  30. package/lib/drift/Drift/clients/CentralServerDrift/index.d.ts +18 -2
  31. package/lib/drift/Drift/clients/CentralServerDrift/index.js +54 -19
  32. package/lib/drift/Drift/clients/CentralServerDrift/index.js.map +1 -1
  33. package/lib/drift/base/actions/perp/settlePnl.d.ts +4 -3
  34. package/lib/drift/base/actions/perp/settlePnl.js +6 -3
  35. package/lib/drift/base/actions/perp/settlePnl.js.map +1 -1
  36. package/lib/drift/base/actions/spot/deposit.d.ts +10 -3
  37. package/lib/drift/base/actions/spot/deposit.js +22 -7
  38. package/lib/drift/base/actions/spot/deposit.js.map +1 -1
  39. package/lib/drift/base/actions/trade/editOrder.d.ts +2 -0
  40. package/lib/drift/base/actions/trade/editOrder.js +1 -0
  41. package/lib/drift/base/actions/trade/editOrder.js.map +1 -1
  42. package/lib/drift/base/actions/trade/openPerpOrder/auction.d.ts +4 -1
  43. package/lib/drift/base/actions/trade/openPerpOrder/auction.js +4 -4
  44. package/lib/drift/base/actions/trade/openPerpOrder/auction.js.map +1 -1
  45. package/lib/drift/base/actions/trade/openPerpOrder/dlobServer/index.d.ts +6 -4
  46. package/lib/drift/base/actions/trade/openPerpOrder/dlobServer/index.js +6 -5
  47. package/lib/drift/base/actions/trade/openPerpOrder/dlobServer/index.js.map +1 -1
  48. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.d.ts +13 -6
  49. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js +26 -16
  50. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js.map +1 -1
  51. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.d.ts +1 -4
  52. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js +12 -15
  53. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js.map +1 -1
  54. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.d.ts +48 -11
  55. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js +54 -18
  56. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js.map +1 -1
  57. package/lib/drift/base/actions/trade/openPerpOrder/positionMaxLeverage.d.ts +2 -2
  58. package/lib/drift/base/actions/trade/openPerpOrder/positionMaxLeverage.js +6 -2
  59. package/lib/drift/base/actions/trade/openPerpOrder/positionMaxLeverage.js.map +1 -1
  60. package/lib/drift/base/actions/trade/openPerpOrder/types.d.ts +5 -3
  61. package/lib/drift/base/actions/trade/openPerpOrder/types.js.map +1 -1
  62. package/lib/drift/base/actions/trade/swap.d.ts +6 -13
  63. package/lib/drift/base/actions/trade/swap.js +11 -36
  64. package/lib/drift/base/actions/trade/swap.js.map +1 -1
  65. package/lib/drift/base/actions/user/create.d.ts +3 -1
  66. package/lib/drift/base/actions/user/create.js +27 -8
  67. package/lib/drift/base/actions/user/create.js.map +1 -1
  68. package/lib/drift/cli.js +16 -2
  69. package/lib/drift/cli.js.map +1 -1
  70. package/lib/drift/utils/auctionParamsResponseMapper.d.ts +2 -1
  71. package/lib/drift/utils/auctionParamsResponseMapper.js +1 -1
  72. package/lib/drift/utils/auctionParamsResponseMapper.js.map +1 -1
  73. package/lib/drift/utils/orderParams.js +1 -1
  74. package/lib/drift/utils/orderParams.js.map +1 -1
  75. package/lib/serializableTypes.d.ts +1 -0
  76. package/lib/serializableTypes.js +4 -0
  77. package/lib/serializableTypes.js.map +1 -1
  78. package/lib/utils/driftEvents.js +18 -2
  79. package/lib/utils/driftEvents.js.map +1 -1
  80. package/lib/utils/logger.js +34 -3
  81. package/lib/utils/logger.js.map +1 -1
  82. package/lib/utils/signedMsgs.d.ts +1 -1
  83. package/lib/utils/signedMsgs.js +2 -2
  84. package/lib/utils/signedMsgs.js.map +1 -1
  85. package/lib/utils/token.d.ts +2 -1
  86. package/lib/utils/token.js +3 -2
  87. package/lib/utils/token.js.map +1 -1
  88. package/package.json +16 -4
@@ -11,7 +11,7 @@ export interface MappedAuctionParams {
11
11
  immediateOrCancel?: boolean;
12
12
  triggerPrice?: BN | null;
13
13
  triggerCondition?: OrderTriggerCondition;
14
- oraclePriceOffset?: BN;
14
+ oraclePriceOffset?: number | null;
15
15
  auctionDuration: number | undefined;
16
16
  maxTs?: BN | null;
17
17
  auctionStartPrice: BN | undefined;
@@ -40,6 +40,7 @@ export interface ServerAuctionParamsResponse {
40
40
  params: ServerAuctionParams;
41
41
  };
42
42
  }
43
+ export type AuctionParamsFetchedCallback = (urlSearchParams: URLSearchParams, response: ServerAuctionParamsResponse) => void;
43
44
  /**
44
45
  * Maps the server response from getOrderParams back to proper client-side types
45
46
  */
@@ -14,6 +14,7 @@ const FIELD_MAPPING = {
14
14
  userOrderId: { type: 'number' },
15
15
  marketIndex: { type: 'number' },
16
16
  auctionDuration: { type: 'number' },
17
+ oraclePriceOffset: { type: 'number' },
17
18
  // Booleans
18
19
  reduceOnly: { type: 'boolean' },
19
20
  immediateOrCancel: { type: 'boolean' },
@@ -22,7 +23,6 @@ const FIELD_MAPPING = {
22
23
  auctionStartPrice: { type: 'bn' },
23
24
  auctionEndPrice: { type: 'bn' },
24
25
  // Nullable BNs
25
- oraclePriceOffset: { type: 'bn_nullable' },
26
26
  triggerPrice: { type: 'bn_nullable' },
27
27
  maxTs: { type: 'bn_nullable' },
28
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"auctionParamsResponseMapper.js","sourceRoot":"","sources":["../../../src/drift/utils/auctionParamsResponseMapper.ts"],"names":[],"mappings":";;;AAAA,yCAOyB;AACzB,uCAAyC;AAuDzC,MAAM,aAAa,GAAmD;IACrE,gCAAgC;IAChC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC1B,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAElC,4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oBAC9B,MAAM,EAAE,WAAW,KAAK,IAAI;oBAC5B,WAAW,EAAE,WAAW,KAAK,SAAS;oBACtC,kBAAkB,EAAE,mBAAmB;iBACvC,CAAC,CAAC;gBACH,MAAM,IAAI,KAAK,CACd,4BAA4B,SAAS,aAAa,WAAW,WAC5D,MAAM,CAAC,IACR,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CACtD,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,MAA6B,CAAC;AACtC,CAAC;AAtCD,4DAsCC","sourcesContent":["import {\n\tBN,\n\tOrderType,\n\tMarketType,\n\tPositionDirection,\n\tPostOnlyParams,\n\tOrderTriggerCondition,\n} from '@drift-labs/sdk';\nimport { ENUM_UTILS } from '../../utils';\n\nexport interface MappedAuctionParams {\n\torderType: OrderType;\n\tmarketType: MarketType;\n\tuserOrderId?: number;\n\tdirection: PositionDirection;\n\tbaseAssetAmount: BN;\n\tmarketIndex: number;\n\treduceOnly?: boolean;\n\tpostOnly?: PostOnlyParams;\n\timmediateOrCancel?: boolean;\n\ttriggerPrice?: BN | null;\n\ttriggerCondition?: OrderTriggerCondition;\n\toraclePriceOffset?: BN;\n\tauctionDuration: number | undefined;\n\tmaxTs?: BN | null;\n\tauctionStartPrice: BN | undefined;\n\tauctionEndPrice: BN | undefined;\n}\n\n// Field mapping configuration\ntype FieldType = 'enum' | 'bn' | 'number' | 'boolean' | 'bn_nullable';\n\ninterface FieldConfig {\n\ttype: FieldType;\n}\n\n// Define the type for the actual params object\ninterface ServerAuctionParams {\n\torderType?: string;\n\tmarketType?: string;\n\tuserOrderId?: number;\n\tdirection?: string;\n\tbaseAssetAmount?: string | number;\n\tmarketIndex?: number;\n\treduceOnly?: boolean;\n\tpostOnly?: string;\n\timmediateOrCancel?: boolean;\n\ttriggerPrice?: string | number | null;\n\ttriggerCondition?: string;\n\toraclePriceOffset?: string | number;\n\tauctionDuration?: number;\n\tmaxTs?: string | number | null;\n\tauctionStartPrice?: string | number;\n\tauctionEndPrice?: string | number;\n}\n\nexport interface ServerAuctionParamsResponse {\n\tdata: {\n\t\tparams: ServerAuctionParams;\n\t\t// Additional fields like entryPrice, bestPrice, etc. are ignored for now\n\t};\n}\n\nconst FIELD_MAPPING: Record<keyof ServerAuctionParams, FieldConfig> = {\n\t// Enums (string -> enum object)\n\torderType: { type: 'enum' },\n\tmarketType: { type: 'enum' },\n\tdirection: { type: 'enum' },\n\tpostOnly: { type: 'enum' },\n\ttriggerCondition: { type: 'enum' },\n\n\t// Numbers (keep as numbers)\n\tuserOrderId: { type: 'number' },\n\tmarketIndex: { type: 'number' },\n\tauctionDuration: { type: 'number' },\n\n\t// Booleans\n\treduceOnly: { type: 'boolean' },\n\timmediateOrCancel: { type: 'boolean' },\n\n\t// BNs (string/number -> BN)\n\tbaseAssetAmount: { type: 'bn' },\n\tauctionStartPrice: { type: 'bn' },\n\tauctionEndPrice: { type: 'bn' },\n\n\t// Nullable BNs\n\toraclePriceOffset: { type: 'bn_nullable' },\n\ttriggerPrice: { type: 'bn_nullable' },\n\tmaxTs: { type: 'bn_nullable' },\n};\n\n// Type conversion functions\nconst convertValue = (value: any, type: FieldType): any => {\n\tswitch (type) {\n\t\tcase 'enum':\n\t\t\ttry {\n\t\t\t\t// Convert string values to proper SDK enums\n\t\t\t\tlet enumResult;\n\t\t\t\tswitch (value) {\n\t\t\t\t\tcase 'oracle':\n\t\t\t\t\t\tenumResult = OrderType.ORACLE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'market':\n\t\t\t\t\t\tenumResult = OrderType.MARKET;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'limit':\n\t\t\t\t\t\tenumResult = OrderType.LIMIT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'trigger_market':\n\t\t\t\t\t\tenumResult = OrderType.TRIGGER_MARKET;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'trigger_limit':\n\t\t\t\t\t\tenumResult = OrderType.TRIGGER_LIMIT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'perp':\n\t\t\t\t\t\tenumResult = MarketType.PERP;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'spot':\n\t\t\t\t\t\tenumResult = MarketType.SPOT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'long':\n\t\t\t\t\t\tenumResult = PositionDirection.LONG;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'short':\n\t\t\t\t\t\tenumResult = PositionDirection.SHORT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'none':\n\t\t\t\t\t\tenumResult = PostOnlyParams.NONE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'must_post_only':\n\t\t\t\t\t\tenumResult = PostOnlyParams.MUST_POST_ONLY;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'try_post_only':\n\t\t\t\t\t\tenumResult = PostOnlyParams.TRY_POST_ONLY;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'above':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.ABOVE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'below':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.BELOW;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'triggered_above':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.TRIGGERED_ABOVE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'triggered_below':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.TRIGGERED_BELOW;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`⚠️ [Converter] Unknown enum value: ${value}, using ENUM_UTILS.toObj as fallback`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tenumResult = ENUM_UTILS.toObj(value);\n\t\t\t\t}\n\t\t\t\treturn enumResult;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`❌ [Converter] Enum conversion failed for ${value}:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\tcase 'bn':\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\t// Server returned null for a required BN field, this should cause fallback to client-side calculation\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Server returned ${\n\t\t\t\t\t\tvalue === null ? 'null' : 'undefined'\n\t\t\t\t\t} for required BN field, expected non-null value`\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn new BN(value.toString());\n\t\tcase 'bn_nullable':\n\t\t\treturn value === null || value === undefined\n\t\t\t\t? null\n\t\t\t\t: new BN(value.toString());\n\t\tcase 'number':\n\t\t\treturn value;\n\t\tcase 'boolean':\n\t\t\treturn value;\n\t\tdefault:\n\t\t\treturn value;\n\t}\n};\n\n/**\n * Maps the server response from getOrderParams back to proper client-side types\n */\nexport function mapAuctionParamsResponse(\n\tserverAuctionParams: ServerAuctionParams\n): MappedAuctionParams {\n\tconst mapped: Partial<MappedAuctionParams> = {};\n\n\t// Extract the actual params from the nested structure\n\tif (!serverAuctionParams) {\n\t\tthrow new Error('Invalid server response: missing data.params');\n\t}\n\n\t// Process each field based on its configuration\n\tObject.entries(FIELD_MAPPING).forEach(([fieldName, config]) => {\n\t\tconst serverValue =\n\t\t\tserverAuctionParams[fieldName as keyof ServerAuctionParams];\n\n\t\tif (serverValue !== undefined) {\n\t\t\ttry {\n\t\t\t\t(mapped as any)[fieldName] = convertValue(serverValue, config.type);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`🔴 [Mapper] Field conversion error:`, {\n\t\t\t\t\tfieldName,\n\t\t\t\t\tserverValue,\n\t\t\t\t\texpectedType: config.type,\n\t\t\t\t\tactualType: typeof serverValue,\n\t\t\t\t\tisNull: serverValue === null,\n\t\t\t\t\tisUndefined: serverValue === undefined,\n\t\t\t\t\tfullServerResponse: serverAuctionParams,\n\t\t\t\t});\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to convert field '${fieldName}' (value: ${serverValue}, type: ${\n\t\t\t\t\t\tconfig.type\n\t\t\t\t\t}): ${error instanceof Error ? error.message : error}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\treturn mapped as MappedAuctionParams;\n}\n"]}
1
+ {"version":3,"file":"auctionParamsResponseMapper.js","sourceRoot":"","sources":["../../../src/drift/utils/auctionParamsResponseMapper.ts"],"names":[],"mappings":";;;AAAA,yCAOyB;AACzB,uCAAyC;AA4DzC,MAAM,aAAa,GAAmD;IACrE,gCAAgC;IAChC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC1B,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAElC,4BAA4B;IAC5B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/B,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAErC,WAAW;IACX,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC/B,iBAAiB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAEtC,4BAA4B;IAC5B,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IAC/B,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IACjC,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IAE/B,eAAe;IACf,YAAY,EAAE,EAAE,IAAI,EAA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SAAgB,wBAAwB,CACvC,mBAAwC;IAExC,MAAM,MAAM,GAAiC,EAAE,CAAC;IAEhD,sDAAsD;IACtD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACjE,CAAC;IAED,gDAAgD;IAChD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE;QAC7D,MAAM,WAAW,GAChB,mBAAmB,CAAC,SAAsC,CAAC,CAAC;QAE7D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,MAAc,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE;oBACpD,SAAS;oBACT,WAAW;oBACX,YAAY,EAAE,MAAM,CAAC,IAAI;oBACzB,UAAU,EAAE,OAAO,WAAW;oBAC9B,MAAM,EAAE,WAAW,KAAK,IAAI;oBAC5B,WAAW,EAAE,WAAW,KAAK,SAAS;oBACtC,kBAAkB,EAAE,mBAAmB;iBACvC,CAAC,CAAC;gBACH,MAAM,IAAI,KAAK,CACd,4BAA4B,SAAS,aAAa,WAAW,WAC5D,MAAM,CAAC,IACR,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CACtD,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,MAA6B,CAAC;AACtC,CAAC;AAtCD,4DAsCC","sourcesContent":["import {\n\tBN,\n\tOrderType,\n\tMarketType,\n\tPositionDirection,\n\tPostOnlyParams,\n\tOrderTriggerCondition,\n} from '@drift-labs/sdk';\nimport { ENUM_UTILS } from '../../utils';\n\nexport interface MappedAuctionParams {\n\torderType: OrderType;\n\tmarketType: MarketType;\n\tuserOrderId?: number;\n\tdirection: PositionDirection;\n\tbaseAssetAmount: BN;\n\tmarketIndex: number;\n\treduceOnly?: boolean;\n\tpostOnly?: PostOnlyParams;\n\timmediateOrCancel?: boolean;\n\ttriggerPrice?: BN | null;\n\ttriggerCondition?: OrderTriggerCondition;\n\toraclePriceOffset?: number | null;\n\tauctionDuration: number | undefined;\n\tmaxTs?: BN | null;\n\tauctionStartPrice: BN | undefined;\n\tauctionEndPrice: BN | undefined;\n}\n\n// Field mapping configuration\ntype FieldType = 'enum' | 'bn' | 'number' | 'boolean' | 'bn_nullable';\n\ninterface FieldConfig {\n\ttype: FieldType;\n}\n\n// Define the type for the actual params object\ninterface ServerAuctionParams {\n\torderType?: string;\n\tmarketType?: string;\n\tuserOrderId?: number;\n\tdirection?: string;\n\tbaseAssetAmount?: string | number;\n\tmarketIndex?: number;\n\treduceOnly?: boolean;\n\tpostOnly?: string;\n\timmediateOrCancel?: boolean;\n\ttriggerPrice?: string | number | null;\n\ttriggerCondition?: string;\n\toraclePriceOffset?: string | number;\n\tauctionDuration?: number;\n\tmaxTs?: string | number | null;\n\tauctionStartPrice?: string | number;\n\tauctionEndPrice?: string | number;\n}\n\nexport interface ServerAuctionParamsResponse {\n\tdata: {\n\t\tparams: ServerAuctionParams;\n\t\t// Additional fields like entryPrice, bestPrice, etc. are ignored for now\n\t};\n}\n\nexport type AuctionParamsFetchedCallback = (\n\turlSearchParams: URLSearchParams,\n\tresponse: ServerAuctionParamsResponse\n) => void;\n\nconst FIELD_MAPPING: Record<keyof ServerAuctionParams, FieldConfig> = {\n\t// Enums (string -> enum object)\n\torderType: { type: 'enum' },\n\tmarketType: { type: 'enum' },\n\tdirection: { type: 'enum' },\n\tpostOnly: { type: 'enum' },\n\ttriggerCondition: { type: 'enum' },\n\n\t// Numbers (keep as numbers)\n\tuserOrderId: { type: 'number' },\n\tmarketIndex: { type: 'number' },\n\tauctionDuration: { type: 'number' },\n\toraclePriceOffset: { type: 'number' },\n\n\t// Booleans\n\treduceOnly: { type: 'boolean' },\n\timmediateOrCancel: { type: 'boolean' },\n\n\t// BNs (string/number -> BN)\n\tbaseAssetAmount: { type: 'bn' },\n\tauctionStartPrice: { type: 'bn' },\n\tauctionEndPrice: { type: 'bn' },\n\n\t// Nullable BNs\n\ttriggerPrice: { type: 'bn_nullable' },\n\tmaxTs: { type: 'bn_nullable' },\n};\n\n// Type conversion functions\nconst convertValue = (value: any, type: FieldType): any => {\n\tswitch (type) {\n\t\tcase 'enum':\n\t\t\ttry {\n\t\t\t\t// Convert string values to proper SDK enums\n\t\t\t\tlet enumResult;\n\t\t\t\tswitch (value) {\n\t\t\t\t\tcase 'oracle':\n\t\t\t\t\t\tenumResult = OrderType.ORACLE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'market':\n\t\t\t\t\t\tenumResult = OrderType.MARKET;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'limit':\n\t\t\t\t\t\tenumResult = OrderType.LIMIT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'trigger_market':\n\t\t\t\t\t\tenumResult = OrderType.TRIGGER_MARKET;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'trigger_limit':\n\t\t\t\t\t\tenumResult = OrderType.TRIGGER_LIMIT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'perp':\n\t\t\t\t\t\tenumResult = MarketType.PERP;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'spot':\n\t\t\t\t\t\tenumResult = MarketType.SPOT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'long':\n\t\t\t\t\t\tenumResult = PositionDirection.LONG;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'short':\n\t\t\t\t\t\tenumResult = PositionDirection.SHORT;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'none':\n\t\t\t\t\t\tenumResult = PostOnlyParams.NONE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'must_post_only':\n\t\t\t\t\t\tenumResult = PostOnlyParams.MUST_POST_ONLY;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'try_post_only':\n\t\t\t\t\t\tenumResult = PostOnlyParams.TRY_POST_ONLY;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'above':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.ABOVE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'below':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.BELOW;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'triggered_above':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.TRIGGERED_ABOVE;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'triggered_below':\n\t\t\t\t\t\tenumResult = OrderTriggerCondition.TRIGGERED_BELOW;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`⚠️ [Converter] Unknown enum value: ${value}, using ENUM_UTILS.toObj as fallback`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tenumResult = ENUM_UTILS.toObj(value);\n\t\t\t\t}\n\t\t\t\treturn enumResult;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`❌ [Converter] Enum conversion failed for ${value}:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\tcase 'bn':\n\t\t\tif (value === null || value === undefined) {\n\t\t\t\t// Server returned null for a required BN field, this should cause fallback to client-side calculation\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Server returned ${\n\t\t\t\t\t\tvalue === null ? 'null' : 'undefined'\n\t\t\t\t\t} for required BN field, expected non-null value`\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn new BN(value.toString());\n\t\tcase 'bn_nullable':\n\t\t\treturn value === null || value === undefined\n\t\t\t\t? null\n\t\t\t\t: new BN(value.toString());\n\t\tcase 'number':\n\t\t\treturn value;\n\t\tcase 'boolean':\n\t\t\treturn value;\n\t\tdefault:\n\t\t\treturn value;\n\t}\n};\n\n/**\n * Maps the server response from getOrderParams back to proper client-side types\n */\nexport function mapAuctionParamsResponse(\n\tserverAuctionParams: ServerAuctionParams\n): MappedAuctionParams {\n\tconst mapped: Partial<MappedAuctionParams> = {};\n\n\t// Extract the actual params from the nested structure\n\tif (!serverAuctionParams) {\n\t\tthrow new Error('Invalid server response: missing data.params');\n\t}\n\n\t// Process each field based on its configuration\n\tObject.entries(FIELD_MAPPING).forEach(([fieldName, config]) => {\n\t\tconst serverValue =\n\t\t\tserverAuctionParams[fieldName as keyof ServerAuctionParams];\n\n\t\tif (serverValue !== undefined) {\n\t\t\ttry {\n\t\t\t\t(mapped as any)[fieldName] = convertValue(serverValue, config.type);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`🔴 [Mapper] Field conversion error:`, {\n\t\t\t\t\tfieldName,\n\t\t\t\t\tserverValue,\n\t\t\t\t\texpectedType: config.type,\n\t\t\t\t\tactualType: typeof serverValue,\n\t\t\t\t\tisNull: serverValue === null,\n\t\t\t\t\tisUndefined: serverValue === undefined,\n\t\t\t\t\tfullServerResponse: serverAuctionParams,\n\t\t\t\t});\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to convert field '${fieldName}' (value: ${serverValue}, type: ${\n\t\t\t\t\t\tconfig.type\n\t\t\t\t\t}): ${error instanceof Error ? error.message : error}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\treturn mapped as MappedAuctionParams;\n}\n"]}
@@ -96,7 +96,7 @@ function buildNonMarketOrderParams({ marketIndex, marketType, direction, baseAss
96
96
  throw new Error('TRIGGER_MARKET orders require triggerPrice');
97
97
  }
98
98
  const triggerCondition = getTriggerCondition(direction, orderType);
99
- const hasLimitPrice = !!orderConfig.limitPrice;
99
+ const hasLimitPrice = !!orderConfig.limitPrice && !orderConfig.limitPrice.isZero();
100
100
  if (hasLimitPrice) {
101
101
  return (0, sdk_1.getTriggerLimitOrderParams)({
102
102
  marketIndex,
@@ -1 +1 @@
1
- {"version":3,"file":"orderParams.js","sourceRoot":"","sources":["../../../src/drift/utils/orderParams.ts"],"names":[],"mappings":";;;AAAA,yCAUyB;AACzB,uCAAyC;AAGzC;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACvC,MAAU,EACV,SAA2B,EAC3B,UAAe;IAEf,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACd,mFAAmF,CACnF,CAAC;QACH,CAAC;QACD,wEAAwE;QACxE,iEAAiE;QACjE,MAAM,eAAe,GAAG,IAAI,QAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,QAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACP,4BAA4B;QAC5B,OAAO,MAAM,CAAC;IACf,CAAC;AACF,CAAC;AAnBD,4DAmBC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,MAKtC;IACA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAElE,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;QACzB,kCAAkC;QAClC,OAAO,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;SAAM,IAAI,eAAe,EAAE,CAAC;QAC5B,kBAAkB;QAClB,OAAO,eAAe,CAAC;IACxB,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACd,iEAAiE,CACjE,CAAC;IACH,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2BAA2B,SAAS,EAAE,CAAC,CAAC;AACzD,CAAC;AAtFD,8DAsFC","sourcesContent":["import {\n\tBN,\n\tPositionDirection,\n\tPostOnlyParams,\n\tOptionalOrderParams,\n\tgetLimitOrderParams,\n\tgetTriggerMarketOrderParams,\n\tgetTriggerLimitOrderParams,\n\tOrderTriggerCondition,\n\tZERO,\n} from '@drift-labs/sdk';\nimport { ENUM_UTILS } from '../../utils';\nimport { NonMarketOrderParamsConfig } from '../base/actions/trade/openPerpOrder/types';\n\n/**\n * Converts amount and assetType to base asset amount\n * @param amount - The amount to convert\n * @param assetType - 'base' or 'quote'\n * @param limitPrice - Required when assetType is 'quote' for conversion\n * @returns Base asset amount\n */\nexport function convertToBaseAssetAmount(\n\tamount: BN,\n\tassetType: 'base' | 'quote',\n\tlimitPrice?: BN\n): BN {\n\tif (assetType === 'quote') {\n\t\tif (!limitPrice || limitPrice.isZero()) {\n\t\t\tthrow new Error(\n\t\t\t\t'When using quote asset type, limitPrice is required for conversion to base amount'\n\t\t\t);\n\t\t}\n\t\t// Convert quote amount to base amount: quoteAmount / price = baseAmount\n\t\t// Using PRICE_PRECISION as the limit price is in price precision\n\t\tconst PRICE_PRECISION = new BN(10).pow(new BN(6));\n\t\treturn amount.mul(PRICE_PRECISION).div(limitPrice);\n\t} else {\n\t\t// Base amount, use directly\n\t\treturn amount;\n\t}\n}\n\n/**\n * Resolves amount parameters from either new (amount + assetType) or legacy (baseAssetAmount) approach\n */\nexport function resolveBaseAssetAmount(params: {\n\tamount?: BN;\n\tassetType?: 'base' | 'quote';\n\tbaseAssetAmount?: BN;\n\tlimitPrice?: BN;\n}): BN {\n\tconst { amount, assetType, baseAssetAmount, limitPrice } = params;\n\n\tif (amount && assetType) {\n\t\t// New approach: convert if needed\n\t\treturn convertToBaseAssetAmount(amount, assetType, limitPrice);\n\t} else if (baseAssetAmount) {\n\t\t// Legacy approach\n\t\treturn baseAssetAmount;\n\t} else {\n\t\tthrow new Error(\n\t\t\t'Either (amount + assetType) or baseAssetAmount must be provided'\n\t\t);\n\t}\n}\n\n/**\n * Determine trigger condition based on direction\n * For stop orders: ABOVE when long, BELOW when short\n * For take profit orders: BELOW when long, ABOVE when short\n */\nconst getTriggerCondition = (\n\tdirection: PositionDirection,\n\ttpOrSl: 'takeProfit' | 'stopLoss'\n) => {\n\tconst isTakeProfit = tpOrSl === 'takeProfit';\n\tconst isLong = ENUM_UTILS.match(direction, PositionDirection.LONG);\n\n\tif (isTakeProfit) {\n\t\tif (isLong) {\n\t\t\treturn OrderTriggerCondition.BELOW;\n\t\t} else {\n\t\t\treturn OrderTriggerCondition.ABOVE;\n\t\t}\n\t} else {\n\t\t// Stop loss\n\t\tif (isLong) {\n\t\t\treturn OrderTriggerCondition.ABOVE;\n\t\t} else {\n\t\t\treturn OrderTriggerCondition.BELOW;\n\t\t}\n\t}\n};\n\n/**\n * Builds proper order parameters for non-market orders using the same logic as the UI\n */\nexport function buildNonMarketOrderParams({\n\tmarketIndex,\n\tmarketType,\n\tdirection,\n\tbaseAssetAmount,\n\torderConfig,\n\treduceOnly = false,\n\tpostOnly = PostOnlyParams.NONE,\n\tuserOrderId = 0,\n}: NonMarketOrderParamsConfig): OptionalOrderParams {\n\tconst orderType = orderConfig.orderType;\n\n\t// Build order params based on order type using SDK functions\n\tif (orderType === 'limit') {\n\t\tif (!orderConfig.limitPrice) {\n\t\t\tthrow new Error('LIMIT orders require limitPrice');\n\t\t}\n\n\t\treturn getLimitOrderParams({\n\t\t\tmarketIndex,\n\t\t\tmarketType,\n\t\t\tdirection,\n\t\t\tbaseAssetAmount,\n\t\t\tprice: orderConfig.limitPrice,\n\t\t\treduceOnly,\n\t\t\tpostOnly,\n\t\t\tuserOrderId,\n\t\t});\n\t}\n\n\tif (orderType === 'takeProfit' || orderType === 'stopLoss') {\n\t\tif (!orderConfig.triggerPrice) {\n\t\t\tthrow new Error('TRIGGER_MARKET orders require triggerPrice');\n\t\t}\n\n\t\tconst triggerCondition = getTriggerCondition(direction, orderType);\n\t\tconst hasLimitPrice = !!orderConfig.limitPrice;\n\n\t\tif (hasLimitPrice) {\n\t\t\treturn getTriggerLimitOrderParams({\n\t\t\t\tmarketIndex,\n\t\t\t\tmarketType,\n\t\t\t\tdirection,\n\t\t\t\tbaseAssetAmount,\n\t\t\t\ttriggerPrice: orderConfig.triggerPrice,\n\t\t\t\tprice: orderConfig.limitPrice!,\n\t\t\t\ttriggerCondition,\n\t\t\t\treduceOnly,\n\t\t\t\tpostOnly,\n\t\t\t\tuserOrderId,\n\t\t\t});\n\t\t} else {\n\t\t\treturn getTriggerMarketOrderParams({\n\t\t\t\tmarketIndex,\n\t\t\t\tmarketType,\n\t\t\t\tdirection,\n\t\t\t\tbaseAssetAmount,\n\t\t\t\ttriggerPrice: orderConfig.triggerPrice,\n\t\t\t\tprice: orderConfig.limitPrice,\n\t\t\t\ttriggerCondition,\n\t\t\t\treduceOnly,\n\t\t\t\tpostOnly,\n\t\t\t\tuserOrderId,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (orderType === 'oracleLimit') {\n\t\tif (!orderConfig.oraclePriceOffset) {\n\t\t\tthrow new Error('ORACLE orders require oraclePriceOffset');\n\t\t}\n\n\t\treturn getLimitOrderParams({\n\t\t\tmarketIndex,\n\t\t\tmarketType,\n\t\t\tdirection,\n\t\t\tbaseAssetAmount,\n\t\t\tprice: ZERO,\n\t\t\toraclePriceOffset: orderConfig.oraclePriceOffset.toNumber(),\n\t\t\tuserOrderId,\n\t\t\tpostOnly,\n\t\t\treduceOnly,\n\t\t});\n\t}\n\n\tthrow new Error(`Unsupported order type: ${orderType}`);\n}\n"]}
1
+ {"version":3,"file":"orderParams.js","sourceRoot":"","sources":["../../../src/drift/utils/orderParams.ts"],"names":[],"mappings":";;;AAAA,yCAUyB;AACzB,uCAAyC;AAGzC;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACvC,MAAU,EACV,SAA2B,EAC3B,UAAe;IAEf,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;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CAAC;YACnB,OAAO,IAAA,gCAA0B,EAAC;gBACjC,WAAW;gBACX,UAAU;gBACV,SAAS;gBACT,eAAe;gBACf,YAAY,EAAE,WAAW,CAAC,YAAY;gBACtC,KAAK,EAAE,WAAW,CAAC,UAAW;gBAC9B,gBAAgB;gBAChB,UAAU;gBACV,QAAQ;gBACR,WAAW;aACX,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACP,OAAO,IAAA,iCAA2B,EAAC;gBAClC,WAAW;gBACX,UAAU;gBACV,SAAS;gBACT,eAAe;gBACf,YAAY,EAAE,WAAW,CAAC,YAAY;gBACtC,KAAK,EAAE,WAAW,CAAC,UAAU;gBAC7B,gBAAgB;gBAChB,UAAU;gBACV,QAAQ;gBACR,WAAW;aACX,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,IAAA,yBAAmB,EAAC;YAC1B,WAAW;YACX,UAAU;YACV,SAAS;YACT,eAAe;YACf,KAAK,EAAE,UAAI;YACX,iBAAiB,EAAE,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE;YAC3D,WAAW;YACX,QAAQ;YACR,UAAU;SACV,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;AACzD,CAAC;AAvFD,8DAuFC","sourcesContent":["import {\n\tBN,\n\tPositionDirection,\n\tPostOnlyParams,\n\tOptionalOrderParams,\n\tgetLimitOrderParams,\n\tgetTriggerMarketOrderParams,\n\tgetTriggerLimitOrderParams,\n\tOrderTriggerCondition,\n\tZERO,\n} from '@drift-labs/sdk';\nimport { ENUM_UTILS } from '../../utils';\nimport { NonMarketOrderParamsConfig } from '../base/actions/trade/openPerpOrder/types';\n\n/**\n * Converts amount and assetType to base asset amount\n * @param amount - The amount to convert\n * @param assetType - 'base' or 'quote'\n * @param limitPrice - Required when assetType is 'quote' for conversion\n * @returns Base asset amount\n */\nexport function convertToBaseAssetAmount(\n\tamount: BN,\n\tassetType: 'base' | 'quote',\n\tlimitPrice?: BN\n): BN {\n\tif (assetType === 'quote') {\n\t\tif (!limitPrice || limitPrice.isZero()) {\n\t\t\tthrow new Error(\n\t\t\t\t'When using quote asset type, limitPrice is required for conversion to base amount'\n\t\t\t);\n\t\t}\n\t\t// Convert quote amount to base amount: quoteAmount / price = baseAmount\n\t\t// Using PRICE_PRECISION as the limit price is in price precision\n\t\tconst PRICE_PRECISION = new BN(10).pow(new BN(6));\n\t\treturn amount.mul(PRICE_PRECISION).div(limitPrice);\n\t} else {\n\t\t// Base amount, use directly\n\t\treturn amount;\n\t}\n}\n\n/**\n * Resolves amount parameters from either new (amount + assetType) or legacy (baseAssetAmount) approach\n */\nexport function resolveBaseAssetAmount(params: {\n\tamount?: BN;\n\tassetType?: 'base' | 'quote';\n\tbaseAssetAmount?: BN;\n\tlimitPrice?: BN;\n}): BN {\n\tconst { amount, assetType, baseAssetAmount, limitPrice } = params;\n\n\tif (amount && assetType) {\n\t\t// New approach: convert if needed\n\t\treturn convertToBaseAssetAmount(amount, assetType, limitPrice);\n\t} else if (baseAssetAmount) {\n\t\t// Legacy approach\n\t\treturn baseAssetAmount;\n\t} else {\n\t\tthrow new Error(\n\t\t\t'Either (amount + assetType) or baseAssetAmount must be provided'\n\t\t);\n\t}\n}\n\n/**\n * Determine trigger condition based on direction\n * For stop orders: ABOVE when long, BELOW when short\n * For take profit orders: BELOW when long, ABOVE when short\n */\nconst getTriggerCondition = (\n\tdirection: PositionDirection,\n\ttpOrSl: 'takeProfit' | 'stopLoss'\n) => {\n\tconst isTakeProfit = tpOrSl === 'takeProfit';\n\tconst isLong = ENUM_UTILS.match(direction, PositionDirection.LONG);\n\n\tif (isTakeProfit) {\n\t\tif (isLong) {\n\t\t\treturn OrderTriggerCondition.BELOW;\n\t\t} else {\n\t\t\treturn OrderTriggerCondition.ABOVE;\n\t\t}\n\t} else {\n\t\t// Stop loss\n\t\tif (isLong) {\n\t\t\treturn OrderTriggerCondition.ABOVE;\n\t\t} else {\n\t\t\treturn OrderTriggerCondition.BELOW;\n\t\t}\n\t}\n};\n\n/**\n * Builds proper order parameters for non-market orders using the same logic as the UI\n */\nexport function buildNonMarketOrderParams({\n\tmarketIndex,\n\tmarketType,\n\tdirection,\n\tbaseAssetAmount,\n\torderConfig,\n\treduceOnly = false,\n\tpostOnly = PostOnlyParams.NONE,\n\tuserOrderId = 0,\n}: NonMarketOrderParamsConfig): OptionalOrderParams {\n\tconst orderType = orderConfig.orderType;\n\n\t// Build order params based on order type using SDK functions\n\tif (orderType === 'limit') {\n\t\tif (!orderConfig.limitPrice) {\n\t\t\tthrow new Error('LIMIT orders require limitPrice');\n\t\t}\n\n\t\treturn getLimitOrderParams({\n\t\t\tmarketIndex,\n\t\t\tmarketType,\n\t\t\tdirection,\n\t\t\tbaseAssetAmount,\n\t\t\tprice: orderConfig.limitPrice,\n\t\t\treduceOnly,\n\t\t\tpostOnly,\n\t\t\tuserOrderId,\n\t\t});\n\t}\n\n\tif (orderType === 'takeProfit' || orderType === 'stopLoss') {\n\t\tif (!orderConfig.triggerPrice) {\n\t\t\tthrow new Error('TRIGGER_MARKET orders require triggerPrice');\n\t\t}\n\n\t\tconst triggerCondition = getTriggerCondition(direction, orderType);\n\t\tconst hasLimitPrice =\n\t\t\t!!orderConfig.limitPrice && !orderConfig.limitPrice.isZero();\n\n\t\tif (hasLimitPrice) {\n\t\t\treturn getTriggerLimitOrderParams({\n\t\t\t\tmarketIndex,\n\t\t\t\tmarketType,\n\t\t\t\tdirection,\n\t\t\t\tbaseAssetAmount,\n\t\t\t\ttriggerPrice: orderConfig.triggerPrice,\n\t\t\t\tprice: orderConfig.limitPrice!,\n\t\t\t\ttriggerCondition,\n\t\t\t\treduceOnly,\n\t\t\t\tpostOnly,\n\t\t\t\tuserOrderId,\n\t\t\t});\n\t\t} else {\n\t\t\treturn getTriggerMarketOrderParams({\n\t\t\t\tmarketIndex,\n\t\t\t\tmarketType,\n\t\t\t\tdirection,\n\t\t\t\tbaseAssetAmount,\n\t\t\t\ttriggerPrice: orderConfig.triggerPrice,\n\t\t\t\tprice: orderConfig.limitPrice,\n\t\t\t\ttriggerCondition,\n\t\t\t\treduceOnly,\n\t\t\t\tpostOnly,\n\t\t\t\tuserOrderId,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (orderType === 'oracleLimit') {\n\t\tif (!orderConfig.oraclePriceOffset) {\n\t\t\tthrow new Error('ORACLE orders require oraclePriceOffset');\n\t\t}\n\n\t\treturn getLimitOrderParams({\n\t\t\tmarketIndex,\n\t\t\tmarketType,\n\t\t\tdirection,\n\t\t\tbaseAssetAmount,\n\t\t\tprice: ZERO,\n\t\t\toraclePriceOffset: orderConfig.oraclePriceOffset.toNumber(),\n\t\t\tuserOrderId,\n\t\t\tpostOnly,\n\t\t\treduceOnly,\n\t\t});\n\t}\n\n\tthrow new Error(`Unsupported order type: ${orderType}`);\n}\n"]}
@@ -158,6 +158,7 @@ export declare class UISerializableOrderRecordV2 {
158
158
  lastActionExplanation: OrderActionExplanation;
159
159
  lastActionStatus: string;
160
160
  status: string;
161
+ cumulativeFee: BigNum | null;
161
162
  static onDeserialized(data: JsonObject, instance: UISerializableOrderRecordV2): void;
162
163
  }
163
164
  export declare class UISerializableOrderActionRecordBase {
@@ -894,6 +894,10 @@ __decorate([
894
894
  (0, cerializr_1.autoserializeAs)(String),
895
895
  __metadata("design:type", String)
896
896
  ], UISerializableOrderRecordV2.prototype, "status", void 0);
897
+ __decorate([
898
+ (0, cerializr_1.autoserializeUsing)(NullableQuoteBigNumSerializeAndDeserializeFns),
899
+ __metadata("design:type", sdk_1.BigNum)
900
+ ], UISerializableOrderRecordV2.prototype, "cumulativeFee", void 0);
897
901
  class UISerializableOrderActionRecordBase {
898
902
  }
899
903
  exports.UISerializableOrderActionRecordBase = UISerializableOrderActionRecordBase;