@nadohq/shared 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (37) hide show
  1. package/dist/index.d.cts +2 -2
  2. package/dist/index.d.ts +2 -2
  3. package/dist/types/index.d.cts +1 -1
  4. package/dist/types/index.d.ts +1 -1
  5. package/dist/types/orderAppendixTypes.cjs.map +1 -1
  6. package/dist/types/orderAppendixTypes.d.cts +3 -3
  7. package/dist/types/orderAppendixTypes.d.ts +3 -3
  8. package/dist/utils/index.d.cts +1 -1
  9. package/dist/utils/index.d.ts +1 -1
  10. package/dist/utils/orders/appendix/{appendixTWAPValue.cjs → appendixTwapValue.cjs} +11 -11
  11. package/dist/utils/orders/appendix/{appendixTWAPValue.cjs.map → appendixTwapValue.cjs.map} +1 -1
  12. package/dist/utils/orders/appendix/{appendixTWAPValue.d.cts → appendixTwapValue.d.cts} +4 -4
  13. package/dist/utils/orders/appendix/{appendixTWAPValue.d.ts → appendixTwapValue.d.ts} +4 -4
  14. package/dist/utils/orders/appendix/{appendixTWAPValue.js → appendixTwapValue.js} +6 -6
  15. package/dist/utils/orders/appendix/{appendixTWAPValue.js.map → appendixTwapValue.js.map} +1 -1
  16. package/dist/utils/orders/appendix/index.cjs +2 -2
  17. package/dist/utils/orders/appendix/index.cjs.map +1 -1
  18. package/dist/utils/orders/appendix/index.d.cts +1 -1
  19. package/dist/utils/orders/appendix/index.d.ts +1 -1
  20. package/dist/utils/orders/appendix/index.js +1 -1
  21. package/dist/utils/orders/appendix/index.js.map +1 -1
  22. package/dist/utils/orders/appendix/packOrderAppendix.cjs +2 -2
  23. package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -1
  24. package/dist/utils/orders/appendix/packOrderAppendix.js +2 -2
  25. package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -1
  26. package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +2 -2
  27. package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -1
  28. package/dist/utils/orders/appendix/unpackOrderAppendix.js +2 -2
  29. package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -1
  30. package/dist/utils/orders/index.d.cts +1 -1
  31. package/dist/utils/orders/index.d.ts +1 -1
  32. package/package.json +2 -2
  33. package/src/types/orderAppendixTypes.ts +2 -2
  34. package/src/utils/orders/appendix/{appendixTWAPValue.ts → appendixTwapValue.ts} +5 -5
  35. package/src/utils/orders/appendix/index.ts +1 -1
  36. package/src/utils/orders/appendix/packOrderAppendix.ts +2 -2
  37. package/src/utils/orders/appendix/unpackOrderAppendix.ts +2 -2
package/dist/index.d.cts CHANGED
@@ -33,10 +33,10 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './types/su
33
33
  export { NadoContracts, WithContract, WithContracts } from './types/nadoContractTypes.cjs';
34
34
  export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './types/viemTypes.cjs';
35
35
  export { OrderExecutionType } from './types/OrderExecutionType.cjs';
36
- export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTWAPFields, OrderAppendixTriggerType } from './types/orderAppendixTypes.cjs';
36
+ export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.cjs';
37
37
  export { getOrderNonce, getRecvTimeFromOrderNonce } from './utils/orders/orderNonce.cjs';
38
38
  export { getDefaultRecvTime } from './utils/orders/recvTime.cjs';
39
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './utils/orders/appendix/appendixTWAPValue.cjs';
39
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './utils/orders/appendix/appendixTwapValue.cjs';
40
40
  export { unpackOrderAppendix } from './utils/orders/appendix/unpackOrderAppendix.cjs';
41
41
  export { packOrderAppendix } from './utils/orders/appendix/packOrderAppendix.cjs';
42
42
  export { PackedOrderAppendixBits } from './utils/orders/appendix/types.cjs';
package/dist/index.d.ts CHANGED
@@ -33,10 +33,10 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './types/su
33
33
  export { NadoContracts, WithContract, WithContracts } from './types/nadoContractTypes.js';
34
34
  export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './types/viemTypes.js';
35
35
  export { OrderExecutionType } from './types/OrderExecutionType.js';
36
- export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTWAPFields, OrderAppendixTriggerType } from './types/orderAppendixTypes.js';
36
+ export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.js';
37
37
  export { getOrderNonce, getRecvTimeFromOrderNonce } from './utils/orders/orderNonce.js';
38
38
  export { getDefaultRecvTime } from './utils/orders/recvTime.js';
39
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './utils/orders/appendix/appendixTWAPValue.js';
39
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './utils/orders/appendix/appendixTwapValue.js';
40
40
  export { unpackOrderAppendix } from './utils/orders/appendix/unpackOrderAppendix.js';
41
41
  export { packOrderAppendix } from './utils/orders/appendix/packOrderAppendix.js';
42
42
  export { PackedOrderAppendixBits } from './utils/orders/appendix/types.js';
@@ -8,7 +8,7 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccou
8
8
  export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.cjs';
9
9
  export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './viemTypes.cjs';
10
10
  export { OrderExecutionType } from './OrderExecutionType.cjs';
11
- export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTWAPFields, OrderAppendixTriggerType } from './orderAppendixTypes.cjs';
11
+ export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.cjs';
12
12
  import 'bignumber.js';
13
13
  import '../abis/nadoAbis.cjs';
14
14
  import 'viem';
@@ -8,7 +8,7 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccou
8
8
  export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.js';
9
9
  export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './viemTypes.js';
10
10
  export { OrderExecutionType } from './OrderExecutionType.js';
11
- export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTWAPFields, OrderAppendixTriggerType } from './orderAppendixTypes.js';
11
+ export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.js';
12
12
  import 'bignumber.js';
13
13
  import '../abis/nadoAbis.js';
14
14
  import 'viem';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/orderAppendixTypes.ts"],"sourcesContent":["import { BigDecimalish } from '../utils/math';\nimport { OrderExecutionType } from './OrderExecutionType';\n\n/**\n * Encodes whether the order will be sent to the trigger service\n */\nexport type OrderAppendixTriggerType =\n | 'price'\n | 'twap'\n // TWAP with specified order amounts, which will be specified in the Trigger Order itself\n | 'twap_custom_amounts';\n\n/**\n * Fields associated with a TWAP trigger order.\n */\nexport interface OrderAppendixTWAPFields {\n /**\n * Number of TWAP orders to be placed.\n */\n numOrders: number;\n /**\n * Maximum slippage on each TWAP order, based on the oracle price at time of order execution.\n * Ex: 0.01 means 1% slippage.\n */\n slippageFrac: number;\n}\n\n/**\n * Fields associated with an isolated order\n */\nexport interface OrderAppendixIsolatedFields {\n /**\n * Amount of margin to transfer into the isolated position.\n */\n margin: BigDecimalish;\n}\n\n/**\n * All the fields encoded by the order appendix\n */\nexport interface OrderAppendix {\n reduceOnly?: boolean;\n orderExecutionType: OrderExecutionType;\n /**\n * Specify the type of trigger that will be used for the order if the order will be sent to the trigger service.\n */\n triggerType?: OrderAppendixTriggerType;\n /**\n * Specify if the order is for an isolated position\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n isolated?: OrderAppendixIsolatedFields;\n /**\n * Specify if the order is a TWAP order\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n twap?: OrderAppendixTWAPFields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/orderAppendixTypes.ts"],"sourcesContent":["import { BigDecimalish } from '../utils/math';\nimport { OrderExecutionType } from './OrderExecutionType';\n\n/**\n * Encodes whether the order will be sent to the trigger service\n */\nexport type OrderAppendixTriggerType =\n | 'price'\n | 'twap'\n // TWAP with specified order amounts, which will be specified in the Trigger Order itself\n | 'twap_custom_amounts';\n\n/**\n * Fields associated with a TWAP trigger order.\n */\nexport interface OrderAppendixTwapFields {\n /**\n * Number of TWAP orders to be placed.\n */\n numOrders: number;\n /**\n * Maximum slippage on each TWAP order, based on the oracle price at time of order execution.\n * Ex: 0.01 means 1% slippage.\n */\n slippageFrac: number;\n}\n\n/**\n * Fields associated with an isolated order\n */\nexport interface OrderAppendixIsolatedFields {\n /**\n * Amount of margin to transfer into the isolated position.\n */\n margin: BigDecimalish;\n}\n\n/**\n * All the fields encoded by the order appendix\n */\nexport interface OrderAppendix {\n reduceOnly?: boolean;\n orderExecutionType: OrderExecutionType;\n /**\n * Specify the type of trigger that will be used for the order if the order will be sent to the trigger service.\n */\n triggerType?: OrderAppendixTriggerType;\n /**\n * Specify if the order is for an isolated position\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n isolated?: OrderAppendixIsolatedFields;\n /**\n * Specify if the order is a TWAP order\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n twap?: OrderAppendixTwapFields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -9,7 +9,7 @@ type OrderAppendixTriggerType = 'price' | 'twap' | 'twap_custom_amounts';
9
9
  /**
10
10
  * Fields associated with a TWAP trigger order.
11
11
  */
12
- interface OrderAppendixTWAPFields {
12
+ interface OrderAppendixTwapFields {
13
13
  /**
14
14
  * Number of TWAP orders to be placed.
15
15
  */
@@ -48,7 +48,7 @@ interface OrderAppendix {
48
48
  * Specify if the order is a TWAP order
49
49
  * An order CANNOT be both a TWAP order and an isolated order.
50
50
  */
51
- twap?: OrderAppendixTWAPFields;
51
+ twap?: OrderAppendixTwapFields;
52
52
  }
53
53
 
54
- export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTWAPFields, OrderAppendixTriggerType };
54
+ export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
@@ -9,7 +9,7 @@ type OrderAppendixTriggerType = 'price' | 'twap' | 'twap_custom_amounts';
9
9
  /**
10
10
  * Fields associated with a TWAP trigger order.
11
11
  */
12
- interface OrderAppendixTWAPFields {
12
+ interface OrderAppendixTwapFields {
13
13
  /**
14
14
  * Number of TWAP orders to be placed.
15
15
  */
@@ -48,7 +48,7 @@ interface OrderAppendix {
48
48
  * Specify if the order is a TWAP order
49
49
  * An order CANNOT be both a TWAP order and an isolated order.
50
50
  */
51
- twap?: OrderAppendixTWAPFields;
51
+ twap?: OrderAppendixTwapFields;
52
52
  }
53
53
 
54
- export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTWAPFields, OrderAppendixTriggerType };
54
+ export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
@@ -1,6 +1,6 @@
1
1
  export { getOrderNonce, getRecvTimeFromOrderNonce } from './orders/orderNonce.cjs';
2
2
  export { getDefaultRecvTime } from './orders/recvTime.cjs';
3
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './orders/appendix/appendixTWAPValue.cjs';
3
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.cjs';
4
4
  export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.cjs';
5
5
  export { packOrderAppendix } from './orders/appendix/packOrderAppendix.cjs';
6
6
  export { PackedOrderAppendixBits } from './orders/appendix/types.cjs';
@@ -1,6 +1,6 @@
1
1
  export { getOrderNonce, getRecvTimeFromOrderNonce } from './orders/orderNonce.js';
2
2
  export { getDefaultRecvTime } from './orders/recvTime.js';
3
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './orders/appendix/appendixTWAPValue.js';
3
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.js';
4
4
  export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.js';
5
5
  export { packOrderAppendix } from './orders/appendix/packOrderAppendix.js';
6
6
  export { PackedOrderAppendixBits } from './orders/appendix/types.js';
@@ -17,15 +17,15 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/utils/orders/appendix/appendixTWAPValue.ts
21
- var appendixTWAPValue_exports = {};
22
- __export(appendixTWAPValue_exports, {
23
- packTWAPOrderAppendixValue: () => packTWAPOrderAppendixValue,
24
- unpackTWAPOrderAppendixValue: () => unpackTWAPOrderAppendixValue
20
+ // src/utils/orders/appendix/appendixTwapValue.ts
21
+ var appendixTwapValue_exports = {};
22
+ __export(appendixTwapValue_exports, {
23
+ packTwapOrderAppendixValue: () => packTwapOrderAppendixValue,
24
+ unpackTwapOrderAppendixValue: () => unpackTwapOrderAppendixValue
25
25
  });
26
- module.exports = __toCommonJS(appendixTWAPValue_exports);
26
+ module.exports = __toCommonJS(appendixTwapValue_exports);
27
27
  var import_math = require("../../math/index.cjs");
28
- function packTWAPOrderAppendixValue({
28
+ function packTwapOrderAppendixValue({
29
29
  numOrders,
30
30
  slippageFrac
31
31
  }) {
@@ -34,7 +34,7 @@ function packTWAPOrderAppendixValue({
34
34
  return (numOrdersBigInt & 0xffffffffn) << 64n | (slippageX6BigInt & 0xffffffffn) << 32n | // The last reserved 32 bits are set to 0
35
35
  0n & 0xffffffffn;
36
36
  }
37
- function unpackTWAPOrderAppendixValue(value) {
37
+ function unpackTwapOrderAppendixValue(value) {
38
38
  const numOrders = value >> 64n & 0xffffffffn;
39
39
  const slippageX6 = value >> 32n & 0xffffffffn;
40
40
  return {
@@ -44,7 +44,7 @@ function unpackTWAPOrderAppendixValue(value) {
44
44
  }
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
47
- packTWAPOrderAppendixValue,
48
- unpackTWAPOrderAppendixValue
47
+ packTwapOrderAppendixValue,
48
+ unpackTwapOrderAppendixValue
49
49
  });
50
- //# sourceMappingURL=appendixTWAPValue.cjs.map
50
+ //# sourceMappingURL=appendixTwapValue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTWAPValue.ts"],"sourcesContent":["import { OrderAppendixTWAPFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTWAPOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTWAPFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTWAPOrderAppendixValue(\n value: bigint,\n): OrderAppendixTWAPFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsD;AAe/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,sBAAkB,sBAAS,SAAS;AAC1C,QAAM,uBAAmB,0BAAS,yBAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,kBAAc,4BAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsD;AAe/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,sBAAkB,sBAAS,SAAS;AAC1C,QAAM,uBAAmB,0BAAS,yBAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,kBAAc,4BAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { OrderAppendixTWAPFields } from '../../../types/orderAppendixTypes.cjs';
1
+ import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes.cjs';
2
2
  import '../../math/bigDecimal.cjs';
3
3
  import 'bignumber.js';
4
4
  import '../../../types/OrderExecutionType.cjs';
@@ -16,7 +16,7 @@ import '../../../types/OrderExecutionType.cjs';
16
16
  * - `slippage_x6` occupies bits 63..32 (middle 32 bits)
17
17
  * - `reserved` occupies bits 31..0 (least significant 32 bits)
18
18
  */
19
- declare function packTWAPOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTWAPFields): bigint;
19
+ declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
20
20
  /**
21
21
  * Unpacks a 96-bit bigint into its component fields for TWAP orders.
22
22
  *
@@ -26,6 +26,6 @@ declare function packTWAPOrderAppendixValue({ numOrders, slippageFrac, }: OrderA
26
26
  * - slippage_x6: number, from bits 63..32
27
27
  * - reserved: number, from bits 31..0
28
28
  */
29
- declare function unpackTWAPOrderAppendixValue(value: bigint): OrderAppendixTWAPFields;
29
+ declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
30
30
 
31
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue };
31
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue };
@@ -1,4 +1,4 @@
1
- import { OrderAppendixTWAPFields } from '../../../types/orderAppendixTypes.js';
1
+ import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes.js';
2
2
  import '../../math/bigDecimal.js';
3
3
  import 'bignumber.js';
4
4
  import '../../../types/OrderExecutionType.js';
@@ -16,7 +16,7 @@ import '../../../types/OrderExecutionType.js';
16
16
  * - `slippage_x6` occupies bits 63..32 (middle 32 bits)
17
17
  * - `reserved` occupies bits 31..0 (least significant 32 bits)
18
18
  */
19
- declare function packTWAPOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTWAPFields): bigint;
19
+ declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
20
20
  /**
21
21
  * Unpacks a 96-bit bigint into its component fields for TWAP orders.
22
22
  *
@@ -26,6 +26,6 @@ declare function packTWAPOrderAppendixValue({ numOrders, slippageFrac, }: OrderA
26
26
  * - slippage_x6: number, from bits 63..32
27
27
  * - reserved: number, from bits 31..0
28
28
  */
29
- declare function unpackTWAPOrderAppendixValue(value: bigint): OrderAppendixTWAPFields;
29
+ declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
30
30
 
31
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue };
31
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue };
@@ -1,8 +1,8 @@
1
1
  import "../../../chunk-5WRI5ZAA.js";
2
2
 
3
- // src/utils/orders/appendix/appendixTWAPValue.ts
3
+ // src/utils/orders/appendix/appendixTwapValue.ts
4
4
  import { addDecimals, removeDecimals, toBigInt } from "../../math/index.js";
5
- function packTWAPOrderAppendixValue({
5
+ function packTwapOrderAppendixValue({
6
6
  numOrders,
7
7
  slippageFrac
8
8
  }) {
@@ -11,7 +11,7 @@ function packTWAPOrderAppendixValue({
11
11
  return (numOrdersBigInt & 0xffffffffn) << 64n | (slippageX6BigInt & 0xffffffffn) << 32n | // The last reserved 32 bits are set to 0
12
12
  0n & 0xffffffffn;
13
13
  }
14
- function unpackTWAPOrderAppendixValue(value) {
14
+ function unpackTwapOrderAppendixValue(value) {
15
15
  const numOrders = value >> 64n & 0xffffffffn;
16
16
  const slippageX6 = value >> 32n & 0xffffffffn;
17
17
  return {
@@ -20,7 +20,7 @@ function unpackTWAPOrderAppendixValue(value) {
20
20
  };
21
21
  }
22
22
  export {
23
- packTWAPOrderAppendixValue,
24
- unpackTWAPOrderAppendixValue
23
+ packTwapOrderAppendixValue,
24
+ unpackTwapOrderAppendixValue
25
25
  };
26
- //# sourceMappingURL=appendixTWAPValue.js.map
26
+ //# sourceMappingURL=appendixTwapValue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTWAPValue.ts"],"sourcesContent":["import { OrderAppendixTWAPFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTWAPOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTWAPFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTWAPOrderAppendixValue(\n value: bigint,\n): OrderAppendixTWAPFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;AACA,SAAS,aAAa,gBAAgB,gBAAgB;AAe/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,kBAAkB,SAAS,SAAS;AAC1C,QAAM,mBAAmB,SAAS,YAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,cAAc,eAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;AACA,SAAS,aAAa,gBAAgB,gBAAgB;AAe/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,kBAAkB,SAAS,SAAS;AAC1C,QAAM,mBAAmB,SAAS,YAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,cAAc,eAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
@@ -17,14 +17,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
17
17
  // src/utils/orders/appendix/index.ts
18
18
  var appendix_exports = {};
19
19
  module.exports = __toCommonJS(appendix_exports);
20
- __reExport(appendix_exports, require("./appendixTWAPValue.cjs"), module.exports);
20
+ __reExport(appendix_exports, require("./appendixTwapValue.cjs"), module.exports);
21
21
  __reExport(appendix_exports, require("./unpackOrderAppendix.cjs"), module.exports);
22
22
  __reExport(appendix_exports, require("./packOrderAppendix.cjs"), module.exports);
23
23
  __reExport(appendix_exports, require("./types.cjs"), module.exports);
24
24
  __reExport(appendix_exports, require("./bitMaskValue.cjs"), module.exports);
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
- ...require("./appendixTWAPValue.cjs"),
27
+ ...require("./appendixTwapValue.cjs"),
28
28
  ...require("./unpackOrderAppendix.cjs"),
29
29
  ...require("./packOrderAppendix.cjs"),
30
30
  ...require("./types.cjs"),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTWAPValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,oCAAd;AACA,6BAAc,sCADd;AAEA,6BAAc,oCAFd;AAGA,6BAAc,wBAHd;AAIA,6BAAc,+BAJd;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,oCAAd;AACA,6BAAc,sCADd;AAEA,6BAAc,oCAFd;AAGA,6BAAc,wBAHd;AAIA,6BAAc,+BAJd;","names":[]}
@@ -1,4 +1,4 @@
1
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './appendixTWAPValue.cjs';
1
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendixTwapValue.cjs';
2
2
  export { unpackOrderAppendix } from './unpackOrderAppendix.cjs';
3
3
  export { packOrderAppendix } from './packOrderAppendix.cjs';
4
4
  export { PackedOrderAppendixBits } from './types.cjs';
@@ -1,4 +1,4 @@
1
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './appendixTWAPValue.js';
1
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendixTwapValue.js';
2
2
  export { unpackOrderAppendix } from './unpackOrderAppendix.js';
3
3
  export { packOrderAppendix } from './packOrderAppendix.js';
4
4
  export { PackedOrderAppendixBits } from './types.js';
@@ -1,5 +1,5 @@
1
1
  // src/utils/orders/appendix/index.ts
2
- export * from "./appendixTWAPValue.js";
2
+ export * from "./appendixTwapValue.js";
3
3
  export * from "./unpackOrderAppendix.js";
4
4
  export * from "./packOrderAppendix.js";
5
5
  export * from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTWAPValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -24,12 +24,12 @@ __export(packOrderAppendix_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(packOrderAppendix_exports);
26
26
  var import_toBigInt = require("../../math/toBigInt.cjs");
27
- var import_appendixTWAPValue = require("./appendixTWAPValue.cjs");
27
+ var import_appendixTwapValue = require("./appendixTwapValue.cjs");
28
28
  var import_bitMaskValue = require("./bitMaskValue.cjs");
29
29
  function mapOrderAppendixToBitValues(appendix) {
30
30
  const value = (() => {
31
31
  if (appendix.twap) {
32
- return (0, import_appendixTWAPValue.packTWAPOrderAppendixValue)(appendix.twap);
32
+ return (0, import_appendixTwapValue.packTwapOrderAppendixValue)(appendix.twap);
33
33
  }
34
34
  if (appendix.isolated) {
35
35
  return (0, import_toBigInt.toBigInt)(appendix.isolated.margin);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTWAPOrderAppendixValue } from './appendixTWAPValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTWAPOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAyB;AACzB,+BAA2C;AAC3C,0BAA6B;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,iBAAO,qDAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,iBAAO,0BAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,aAAS,kCAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,UAAO,kCAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,SAAM,kCAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,SAAM,kCAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTwapOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAyB;AACzB,+BAA2C;AAC3C,0BAA6B;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,iBAAO,qDAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,iBAAO,0BAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,aAAS,kCAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,UAAO,kCAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,SAAM,kCAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,SAAM,kCAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
@@ -2,12 +2,12 @@ import "../../../chunk-5WRI5ZAA.js";
2
2
 
3
3
  // src/utils/orders/appendix/packOrderAppendix.ts
4
4
  import { toBigInt } from "../../math/toBigInt.js";
5
- import { packTWAPOrderAppendixValue } from "./appendixTWAPValue.js";
5
+ import { packTwapOrderAppendixValue } from "./appendixTwapValue.js";
6
6
  import { bitMaskValue } from "./bitMaskValue.js";
7
7
  function mapOrderAppendixToBitValues(appendix) {
8
8
  const value = (() => {
9
9
  if (appendix.twap) {
10
- return packTWAPOrderAppendixValue(appendix.twap);
10
+ return packTwapOrderAppendixValue(appendix.twap);
11
11
  }
12
12
  if (appendix.isolated) {
13
13
  return toBigInt(appendix.isolated.margin);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTWAPOrderAppendixValue } from './appendixTWAPValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTWAPOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;AACA,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAC3C,SAAS,oBAAoB;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,aAAO,2BAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,aAAO,SAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,SAAS,aAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,MAAO,aAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,KAAM,aAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,KAAM,aAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTwapOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;AACA,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAC3C,SAAS,oBAAoB;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,aAAO,2BAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,aAAO,SAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,SAAS,aAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,MAAO,aAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,KAAM,aAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,KAAM,aAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
@@ -24,7 +24,7 @@ __export(unpackOrderAppendix_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(unpackOrderAppendix_exports);
26
26
  var import_math = require("../../math/index.cjs");
27
- var import_appendixTWAPValue = require("./appendixTWAPValue.cjs");
27
+ var import_appendixTwapValue = require("./appendixTwapValue.cjs");
28
28
  var import_bitMaskValue = require("./bitMaskValue.cjs");
29
29
  function mapBitValuesToAppendix(bits) {
30
30
  const triggerType = (() => {
@@ -63,7 +63,7 @@ function mapBitValuesToAppendix(bits) {
63
63
  })();
64
64
  const twapFields = (() => {
65
65
  if (triggerType === "twap" || triggerType === "twap_custom_amounts") {
66
- return (0, import_appendixTWAPValue.unpackTWAPOrderAppendixValue)(bits.value);
66
+ return (0, import_appendixTwapValue.unpackTwapOrderAppendixValue)(bits.value);
67
67
  }
68
68
  })();
69
69
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport { unpackTWAPOrderAppendixValue } from './appendixTWAPValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {\n const triggerType = (() => {\n switch (bits.trigger) {\n case 1:\n return 'price';\n case 2:\n return 'twap';\n case 3:\n return 'twap_custom_amounts';\n default:\n return undefined;\n }\n })();\n const orderExecutionType = (() => {\n switch (bits.orderType) {\n case 0:\n return 'default';\n case 1:\n return 'ioc';\n case 2:\n return 'fok';\n case 3:\n return 'post_only';\n default:\n throw new Error(\n `[mapBitValuesToAppendix] Unknown order type: ${bits.orderType}`,\n );\n }\n })();\n const isolatedFields = (() => {\n if (bits.isolated) {\n return { margin: bits.value };\n }\n return undefined;\n })();\n const twapFields = (() => {\n if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {\n return unpackTWAPOrderAppendixValue(bits.value);\n }\n })();\n\n return {\n reduceOnly: !!bits.reduceOnly,\n orderExecutionType,\n triggerType,\n isolated: isolatedFields,\n twap: twapFields,\n };\n}\n\n/**\n * Unpack the OrderAppendix fields from a packed bigint.\n * @param packed\n */\nexport function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {\n let temp = toBigInt(packed);\n // Bitmasks lowest 8 bits for version\n const version = Number(bitMaskValue(temp, 8));\n // Shift out the version bits\n temp >>= 8n;\n // Repeat for the rest of the fields\n const isolated = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const orderType = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reduceOnly = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const trigger = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reserved = Number(bitMaskValue(temp, 18));\n temp >>= 18n;\n // The remaining bits are the value, which should be 96 bits\n const value = bitMaskValue(temp, 96);\n\n return mapBitValuesToAppendix({\n value,\n reserved,\n trigger,\n reduceOnly,\n orderType,\n isolated,\n version,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAwC;AACxC,+BAA6C;AAC7C,0BAA6B;AAG7B,SAAS,uBAAuB,MAA8C;AAC5E,QAAM,eAAe,MAAM;AACzB,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,sBAAsB,MAAM;AAChC,YAAQ,KAAK,WAAW;AAAA,MACtB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,cAAM,IAAI;AAAA,UACR,gDAAgD,KAAK,SAAS;AAAA,QAChE;AAAA,IACJ;AAAA,EACF,GAAG;AACH,QAAM,kBAAkB,MAAM;AAC5B,QAAI,KAAK,UAAU;AACjB,aAAO,EAAE,QAAQ,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,cAAc,MAAM;AACxB,QAAI,gBAAgB,UAAU,gBAAgB,uBAAuB;AACnE,iBAAO,uDAA6B,KAAK,KAAK;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,KAAK;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;AAMO,SAAS,oBAAoB,QAAsC;AACxE,MAAI,WAAO,sBAAS,MAAM;AAE1B,QAAM,UAAU,WAAO,kCAAa,MAAM,CAAC,CAAC;AAE5C,WAAS;AAET,QAAM,WAAW,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC7C,WAAS;AACT,QAAM,YAAY,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC9C,WAAS;AACT,QAAM,aAAa,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC/C,WAAS;AACT,QAAM,UAAU,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC5C,WAAS;AACT,QAAM,WAAW,WAAO,kCAAa,MAAM,EAAE,CAAC;AAC9C,WAAS;AAET,QAAM,YAAQ,kCAAa,MAAM,EAAE;AAEnC,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport { unpackTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {\n const triggerType = (() => {\n switch (bits.trigger) {\n case 1:\n return 'price';\n case 2:\n return 'twap';\n case 3:\n return 'twap_custom_amounts';\n default:\n return undefined;\n }\n })();\n const orderExecutionType = (() => {\n switch (bits.orderType) {\n case 0:\n return 'default';\n case 1:\n return 'ioc';\n case 2:\n return 'fok';\n case 3:\n return 'post_only';\n default:\n throw new Error(\n `[mapBitValuesToAppendix] Unknown order type: ${bits.orderType}`,\n );\n }\n })();\n const isolatedFields = (() => {\n if (bits.isolated) {\n return { margin: bits.value };\n }\n return undefined;\n })();\n const twapFields = (() => {\n if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {\n return unpackTwapOrderAppendixValue(bits.value);\n }\n })();\n\n return {\n reduceOnly: !!bits.reduceOnly,\n orderExecutionType,\n triggerType,\n isolated: isolatedFields,\n twap: twapFields,\n };\n}\n\n/**\n * Unpack the OrderAppendix fields from a packed bigint.\n * @param packed\n */\nexport function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {\n let temp = toBigInt(packed);\n // Bitmasks lowest 8 bits for version\n const version = Number(bitMaskValue(temp, 8));\n // Shift out the version bits\n temp >>= 8n;\n // Repeat for the rest of the fields\n const isolated = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const orderType = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reduceOnly = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const trigger = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reserved = Number(bitMaskValue(temp, 18));\n temp >>= 18n;\n // The remaining bits are the value, which should be 96 bits\n const value = bitMaskValue(temp, 96);\n\n return mapBitValuesToAppendix({\n value,\n reserved,\n trigger,\n reduceOnly,\n orderType,\n isolated,\n version,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAwC;AACxC,+BAA6C;AAC7C,0BAA6B;AAG7B,SAAS,uBAAuB,MAA8C;AAC5E,QAAM,eAAe,MAAM;AACzB,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,sBAAsB,MAAM;AAChC,YAAQ,KAAK,WAAW;AAAA,MACtB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,cAAM,IAAI;AAAA,UACR,gDAAgD,KAAK,SAAS;AAAA,QAChE;AAAA,IACJ;AAAA,EACF,GAAG;AACH,QAAM,kBAAkB,MAAM;AAC5B,QAAI,KAAK,UAAU;AACjB,aAAO,EAAE,QAAQ,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,cAAc,MAAM;AACxB,QAAI,gBAAgB,UAAU,gBAAgB,uBAAuB;AACnE,iBAAO,uDAA6B,KAAK,KAAK;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,KAAK;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;AAMO,SAAS,oBAAoB,QAAsC;AACxE,MAAI,WAAO,sBAAS,MAAM;AAE1B,QAAM,UAAU,WAAO,kCAAa,MAAM,CAAC,CAAC;AAE5C,WAAS;AAET,QAAM,WAAW,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC7C,WAAS;AACT,QAAM,YAAY,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC9C,WAAS;AACT,QAAM,aAAa,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC/C,WAAS;AACT,QAAM,UAAU,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC5C,WAAS;AACT,QAAM,WAAW,WAAO,kCAAa,MAAM,EAAE,CAAC;AAC9C,WAAS;AAET,QAAM,YAAQ,kCAAa,MAAM,EAAE;AAEnC,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -2,7 +2,7 @@ import "../../../chunk-5WRI5ZAA.js";
2
2
 
3
3
  // src/utils/orders/appendix/unpackOrderAppendix.ts
4
4
  import { toBigInt } from "../../math/index.js";
5
- import { unpackTWAPOrderAppendixValue } from "./appendixTWAPValue.js";
5
+ import { unpackTwapOrderAppendixValue } from "./appendixTwapValue.js";
6
6
  import { bitMaskValue } from "./bitMaskValue.js";
7
7
  function mapBitValuesToAppendix(bits) {
8
8
  const triggerType = (() => {
@@ -41,7 +41,7 @@ function mapBitValuesToAppendix(bits) {
41
41
  })();
42
42
  const twapFields = (() => {
43
43
  if (triggerType === "twap" || triggerType === "twap_custom_amounts") {
44
- return unpackTWAPOrderAppendixValue(bits.value);
44
+ return unpackTwapOrderAppendixValue(bits.value);
45
45
  }
46
46
  })();
47
47
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport { unpackTWAPOrderAppendixValue } from './appendixTWAPValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {\n const triggerType = (() => {\n switch (bits.trigger) {\n case 1:\n return 'price';\n case 2:\n return 'twap';\n case 3:\n return 'twap_custom_amounts';\n default:\n return undefined;\n }\n })();\n const orderExecutionType = (() => {\n switch (bits.orderType) {\n case 0:\n return 'default';\n case 1:\n return 'ioc';\n case 2:\n return 'fok';\n case 3:\n return 'post_only';\n default:\n throw new Error(\n `[mapBitValuesToAppendix] Unknown order type: ${bits.orderType}`,\n );\n }\n })();\n const isolatedFields = (() => {\n if (bits.isolated) {\n return { margin: bits.value };\n }\n return undefined;\n })();\n const twapFields = (() => {\n if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {\n return unpackTWAPOrderAppendixValue(bits.value);\n }\n })();\n\n return {\n reduceOnly: !!bits.reduceOnly,\n orderExecutionType,\n triggerType,\n isolated: isolatedFields,\n twap: twapFields,\n };\n}\n\n/**\n * Unpack the OrderAppendix fields from a packed bigint.\n * @param packed\n */\nexport function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {\n let temp = toBigInt(packed);\n // Bitmasks lowest 8 bits for version\n const version = Number(bitMaskValue(temp, 8));\n // Shift out the version bits\n temp >>= 8n;\n // Repeat for the rest of the fields\n const isolated = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const orderType = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reduceOnly = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const trigger = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reserved = Number(bitMaskValue(temp, 18));\n temp >>= 18n;\n // The remaining bits are the value, which should be 96 bits\n const value = bitMaskValue(temp, 96);\n\n return mapBitValuesToAppendix({\n value,\n reserved,\n trigger,\n reduceOnly,\n orderType,\n isolated,\n version,\n });\n}\n"],"mappings":";;;AACA,SAAwB,gBAAgB;AACxC,SAAS,oCAAoC;AAC7C,SAAS,oBAAoB;AAG7B,SAAS,uBAAuB,MAA8C;AAC5E,QAAM,eAAe,MAAM;AACzB,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,sBAAsB,MAAM;AAChC,YAAQ,KAAK,WAAW;AAAA,MACtB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,cAAM,IAAI;AAAA,UACR,gDAAgD,KAAK,SAAS;AAAA,QAChE;AAAA,IACJ;AAAA,EACF,GAAG;AACH,QAAM,kBAAkB,MAAM;AAC5B,QAAI,KAAK,UAAU;AACjB,aAAO,EAAE,QAAQ,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,cAAc,MAAM;AACxB,QAAI,gBAAgB,UAAU,gBAAgB,uBAAuB;AACnE,aAAO,6BAA6B,KAAK,KAAK;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,KAAK;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;AAMO,SAAS,oBAAoB,QAAsC;AACxE,MAAI,OAAO,SAAS,MAAM;AAE1B,QAAM,UAAU,OAAO,aAAa,MAAM,CAAC,CAAC;AAE5C,WAAS;AAET,QAAM,WAAW,OAAO,aAAa,MAAM,CAAC,CAAC;AAC7C,WAAS;AACT,QAAM,YAAY,OAAO,aAAa,MAAM,CAAC,CAAC;AAC9C,WAAS;AACT,QAAM,aAAa,OAAO,aAAa,MAAM,CAAC,CAAC;AAC/C,WAAS;AACT,QAAM,UAAU,OAAO,aAAa,MAAM,CAAC,CAAC;AAC5C,WAAS;AACT,QAAM,WAAW,OAAO,aAAa,MAAM,EAAE,CAAC;AAC9C,WAAS;AAET,QAAM,QAAQ,aAAa,MAAM,EAAE;AAEnC,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport { unpackTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {\n const triggerType = (() => {\n switch (bits.trigger) {\n case 1:\n return 'price';\n case 2:\n return 'twap';\n case 3:\n return 'twap_custom_amounts';\n default:\n return undefined;\n }\n })();\n const orderExecutionType = (() => {\n switch (bits.orderType) {\n case 0:\n return 'default';\n case 1:\n return 'ioc';\n case 2:\n return 'fok';\n case 3:\n return 'post_only';\n default:\n throw new Error(\n `[mapBitValuesToAppendix] Unknown order type: ${bits.orderType}`,\n );\n }\n })();\n const isolatedFields = (() => {\n if (bits.isolated) {\n return { margin: bits.value };\n }\n return undefined;\n })();\n const twapFields = (() => {\n if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {\n return unpackTwapOrderAppendixValue(bits.value);\n }\n })();\n\n return {\n reduceOnly: !!bits.reduceOnly,\n orderExecutionType,\n triggerType,\n isolated: isolatedFields,\n twap: twapFields,\n };\n}\n\n/**\n * Unpack the OrderAppendix fields from a packed bigint.\n * @param packed\n */\nexport function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {\n let temp = toBigInt(packed);\n // Bitmasks lowest 8 bits for version\n const version = Number(bitMaskValue(temp, 8));\n // Shift out the version bits\n temp >>= 8n;\n // Repeat for the rest of the fields\n const isolated = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const orderType = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reduceOnly = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const trigger = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reserved = Number(bitMaskValue(temp, 18));\n temp >>= 18n;\n // The remaining bits are the value, which should be 96 bits\n const value = bitMaskValue(temp, 96);\n\n return mapBitValuesToAppendix({\n value,\n reserved,\n trigger,\n reduceOnly,\n orderType,\n isolated,\n version,\n });\n}\n"],"mappings":";;;AACA,SAAwB,gBAAgB;AACxC,SAAS,oCAAoC;AAC7C,SAAS,oBAAoB;AAG7B,SAAS,uBAAuB,MAA8C;AAC5E,QAAM,eAAe,MAAM;AACzB,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,sBAAsB,MAAM;AAChC,YAAQ,KAAK,WAAW;AAAA,MACtB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,cAAM,IAAI;AAAA,UACR,gDAAgD,KAAK,SAAS;AAAA,QAChE;AAAA,IACJ;AAAA,EACF,GAAG;AACH,QAAM,kBAAkB,MAAM;AAC5B,QAAI,KAAK,UAAU;AACjB,aAAO,EAAE,QAAQ,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,cAAc,MAAM;AACxB,QAAI,gBAAgB,UAAU,gBAAgB,uBAAuB;AACnE,aAAO,6BAA6B,KAAK,KAAK;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,KAAK;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;AAMO,SAAS,oBAAoB,QAAsC;AACxE,MAAI,OAAO,SAAS,MAAM;AAE1B,QAAM,UAAU,OAAO,aAAa,MAAM,CAAC,CAAC;AAE5C,WAAS;AAET,QAAM,WAAW,OAAO,aAAa,MAAM,CAAC,CAAC;AAC7C,WAAS;AACT,QAAM,YAAY,OAAO,aAAa,MAAM,CAAC,CAAC;AAC9C,WAAS;AACT,QAAM,aAAa,OAAO,aAAa,MAAM,CAAC,CAAC;AAC/C,WAAS;AACT,QAAM,UAAU,OAAO,aAAa,MAAM,CAAC,CAAC;AAC5C,WAAS;AACT,QAAM,WAAW,OAAO,aAAa,MAAM,EAAE,CAAC;AAC9C,WAAS;AAET,QAAM,QAAQ,aAAa,MAAM,EAAE;AAEnC,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,6 +1,6 @@
1
1
  export { getOrderNonce, getRecvTimeFromOrderNonce } from './orderNonce.cjs';
2
2
  export { getDefaultRecvTime } from './recvTime.cjs';
3
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './appendix/appendixTWAPValue.cjs';
3
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendix/appendixTwapValue.cjs';
4
4
  export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.cjs';
5
5
  export { packOrderAppendix } from './appendix/packOrderAppendix.cjs';
6
6
  export { PackedOrderAppendixBits } from './appendix/types.cjs';
@@ -1,6 +1,6 @@
1
1
  export { getOrderNonce, getRecvTimeFromOrderNonce } from './orderNonce.js';
2
2
  export { getDefaultRecvTime } from './recvTime.js';
3
- export { packTWAPOrderAppendixValue, unpackTWAPOrderAppendixValue } from './appendix/appendixTWAPValue.js';
3
+ export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendix/appendixTwapValue.js';
4
4
  export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.js';
5
5
  export { packOrderAppendix } from './appendix/packOrderAppendix.js';
6
6
  export { PackedOrderAppendixBits } from './appendix/types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/shared",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Shared utilities, types, and contract helpers for Nado SDK",
@@ -45,5 +45,5 @@
45
45
  "bignumber.js": "^9.3.0",
46
46
  "viem": "*"
47
47
  },
48
- "gitHead": "b852ce36b851303225d3f4b81739ac667c64cf8c"
48
+ "gitHead": "de119d61db2be44b2cab79b8d373b66eb0f8ffe6"
49
49
  }
@@ -13,7 +13,7 @@ export type OrderAppendixTriggerType =
13
13
  /**
14
14
  * Fields associated with a TWAP trigger order.
15
15
  */
16
- export interface OrderAppendixTWAPFields {
16
+ export interface OrderAppendixTwapFields {
17
17
  /**
18
18
  * Number of TWAP orders to be placed.
19
19
  */
@@ -54,5 +54,5 @@ export interface OrderAppendix {
54
54
  * Specify if the order is a TWAP order
55
55
  * An order CANNOT be both a TWAP order and an isolated order.
56
56
  */
57
- twap?: OrderAppendixTWAPFields;
57
+ twap?: OrderAppendixTwapFields;
58
58
  }
@@ -1,4 +1,4 @@
1
- import { OrderAppendixTWAPFields } from '../../../types/orderAppendixTypes';
1
+ import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';
2
2
  import { addDecimals, removeDecimals, toBigInt } from '../../math';
3
3
 
4
4
  /**
@@ -14,10 +14,10 @@ import { addDecimals, removeDecimals, toBigInt } from '../../math';
14
14
  * - `slippage_x6` occupies bits 63..32 (middle 32 bits)
15
15
  * - `reserved` occupies bits 31..0 (least significant 32 bits)
16
16
  */
17
- export function packTWAPOrderAppendixValue({
17
+ export function packTwapOrderAppendixValue({
18
18
  numOrders,
19
19
  slippageFrac,
20
- }: OrderAppendixTWAPFields): bigint {
20
+ }: OrderAppendixTwapFields): bigint {
21
21
  const numOrdersBigInt = toBigInt(numOrders);
22
22
  const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));
23
23
 
@@ -38,9 +38,9 @@ export function packTWAPOrderAppendixValue({
38
38
  * - slippage_x6: number, from bits 63..32
39
39
  * - reserved: number, from bits 31..0
40
40
  */
41
- export function unpackTWAPOrderAppendixValue(
41
+ export function unpackTwapOrderAppendixValue(
42
42
  value: bigint,
43
- ): OrderAppendixTWAPFields {
43
+ ): OrderAppendixTwapFields {
44
44
  const numOrders = (value >> 64n) & 0xffffffffn;
45
45
  const slippageX6 = (value >> 32n) & 0xffffffffn;
46
46
 
@@ -1,4 +1,4 @@
1
- export * from './appendixTWAPValue';
1
+ export * from './appendixTwapValue';
2
2
  export * from './unpackOrderAppendix';
3
3
  export * from './packOrderAppendix';
4
4
  export * from './types';
@@ -1,6 +1,6 @@
1
1
  import { OrderAppendix } from '../../../types/orderAppendixTypes';
2
2
  import { toBigInt } from '../../math/toBigInt';
3
- import { packTWAPOrderAppendixValue } from './appendixTWAPValue';
3
+ import { packTwapOrderAppendixValue } from './appendixTwapValue';
4
4
  import { bitMaskValue } from './bitMaskValue';
5
5
  import { PackedOrderAppendixBits } from './types';
6
6
 
@@ -9,7 +9,7 @@ function mapOrderAppendixToBitValues(
9
9
  ): PackedOrderAppendixBits {
10
10
  const value = (() => {
11
11
  if (appendix.twap) {
12
- return packTWAPOrderAppendixValue(appendix.twap);
12
+ return packTwapOrderAppendixValue(appendix.twap);
13
13
  }
14
14
  if (appendix.isolated) {
15
15
  return toBigInt(appendix.isolated.margin);
@@ -1,6 +1,6 @@
1
1
  import { OrderAppendix } from '../../../types/orderAppendixTypes';
2
2
  import { BigDecimalish, toBigInt } from '../../math';
3
- import { unpackTWAPOrderAppendixValue } from './appendixTWAPValue';
3
+ import { unpackTwapOrderAppendixValue } from './appendixTwapValue';
4
4
  import { bitMaskValue } from './bitMaskValue';
5
5
  import { PackedOrderAppendixBits } from './types';
6
6
 
@@ -41,7 +41,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
41
41
  })();
42
42
  const twapFields = (() => {
43
43
  if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {
44
- return unpackTWAPOrderAppendixValue(bits.value);
44
+ return unpackTwapOrderAppendixValue(bits.value);
45
45
  }
46
46
  })();
47
47