@nadohq/trigger-client 0.1.0-alpha.1 → 0.1.0-alpha.11

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 (64) hide show
  1. package/dist/TriggerClient.cjs +41 -17
  2. package/dist/TriggerClient.cjs.map +1 -1
  3. package/dist/TriggerClient.d.cts +5 -3
  4. package/dist/TriggerClient.d.ts +5 -3
  5. package/dist/TriggerClient.js +39 -10
  6. package/dist/TriggerClient.js.map +1 -1
  7. package/dist/dataMappers.cjs +170 -67
  8. package/dist/dataMappers.cjs.map +1 -1
  9. package/dist/dataMappers.d.cts +22 -8
  10. package/dist/dataMappers.d.ts +22 -8
  11. package/dist/dataMappers.js +169 -65
  12. package/dist/dataMappers.js.map +1 -1
  13. package/dist/endpoints.cjs +2 -2
  14. package/dist/endpoints.cjs.map +1 -1
  15. package/dist/endpoints.d.cts +1 -1
  16. package/dist/endpoints.d.ts +1 -1
  17. package/dist/endpoints.js +2 -2
  18. package/dist/endpoints.js.map +1 -1
  19. package/dist/index.d.cts +6 -5
  20. package/dist/index.d.ts +6 -5
  21. package/dist/types/TriggerServerFailureError.cjs +1 -1
  22. package/dist/types/TriggerServerFailureError.cjs.map +1 -1
  23. package/dist/types/TriggerServerFailureError.d.cts +3 -2
  24. package/dist/types/TriggerServerFailureError.d.ts +3 -2
  25. package/dist/types/TriggerServerFailureError.js +1 -1
  26. package/dist/types/TriggerServerFailureError.js.map +1 -1
  27. package/dist/types/clientModelTypes.cjs +19 -0
  28. package/dist/types/clientModelTypes.cjs.map +1 -0
  29. package/dist/types/clientModelTypes.d.cts +67 -0
  30. package/dist/types/clientModelTypes.d.ts +67 -0
  31. package/dist/types/clientModelTypes.js +1 -0
  32. package/dist/types/clientModelTypes.js.map +1 -0
  33. package/dist/types/clientTypes.cjs.map +1 -1
  34. package/dist/types/clientTypes.d.cts +41 -24
  35. package/dist/types/clientTypes.d.ts +41 -24
  36. package/dist/types/index.cjs +4 -0
  37. package/dist/types/index.cjs.map +1 -1
  38. package/dist/types/index.d.cts +6 -5
  39. package/dist/types/index.d.ts +6 -5
  40. package/dist/types/index.js +2 -0
  41. package/dist/types/index.js.map +1 -1
  42. package/dist/types/serverExecuteTypes.cjs.map +1 -1
  43. package/dist/types/serverExecuteTypes.d.cts +4 -15
  44. package/dist/types/serverExecuteTypes.d.ts +4 -15
  45. package/dist/types/serverModelTypes.cjs +19 -0
  46. package/dist/types/serverModelTypes.cjs.map +1 -0
  47. package/dist/types/serverModelTypes.d.cts +42 -0
  48. package/dist/types/serverModelTypes.d.ts +42 -0
  49. package/dist/types/serverModelTypes.js +1 -0
  50. package/dist/types/serverModelTypes.js.map +1 -0
  51. package/dist/types/serverQueryTypes.cjs.map +1 -1
  52. package/dist/types/serverQueryTypes.d.cts +47 -7
  53. package/dist/types/serverQueryTypes.d.ts +47 -7
  54. package/package.json +4 -5
  55. package/src/TriggerClient.ts +48 -9
  56. package/src/dataMappers.ts +224 -71
  57. package/src/endpoints.ts +2 -2
  58. package/src/types/TriggerServerFailureError.ts +2 -2
  59. package/src/types/clientModelTypes.ts +95 -0
  60. package/src/types/clientTypes.ts +60 -41
  61. package/src/types/index.ts +2 -0
  62. package/src/types/serverExecuteTypes.ts +3 -24
  63. package/src/types/serverModelTypes.ts +55 -0
  64. package/src/types/serverQueryTypes.ts +74 -9
@@ -1,111 +1,215 @@
1
1
  // src/dataMappers.ts
2
+ import { unpackOrderAppendix } from "@nadohq/shared";
2
3
  import {
3
4
  addDecimals,
4
5
  removeDecimals,
5
6
  toBigDecimal,
6
7
  toIntegerString
7
- } from "@nadohq/utils";
8
+ } from "@nadohq/shared";
9
+ function mapTriggerCriteria(criteria) {
10
+ switch (criteria.type) {
11
+ case "price":
12
+ return {
13
+ price_trigger: mapPriceTriggerCriteria(criteria.criteria)
14
+ };
15
+ case "time":
16
+ return {
17
+ time_trigger: mapTimeTriggerCriteria(criteria.criteria)
18
+ };
19
+ }
20
+ }
21
+ function mapPriceTriggerCriteria(criteria) {
22
+ const priceValue = toIntegerString(addDecimals(criteria.triggerPrice));
23
+ const price_requirement = (() => {
24
+ switch (criteria.type) {
25
+ case "oracle_price_above":
26
+ return { oracle_price_above: priceValue };
27
+ case "oracle_price_below":
28
+ return { oracle_price_below: priceValue };
29
+ case "last_price_above":
30
+ return { last_price_above: priceValue };
31
+ case "last_price_below":
32
+ return { last_price_below: priceValue };
33
+ case "mid_price_above":
34
+ return { mid_price_above: priceValue };
35
+ case "mid_price_below":
36
+ return { mid_price_below: priceValue };
37
+ }
38
+ })();
39
+ return {
40
+ price_requirement,
41
+ dependency: criteria.dependency ? {
42
+ digest: criteria.dependency.digest,
43
+ on_partial_fill: criteria.dependency.onPartialFill
44
+ } : void 0
45
+ };
46
+ }
47
+ function mapTimeTriggerCriteria(criteria) {
48
+ return {
49
+ interval: Number(criteria.interval),
50
+ amounts: criteria.amounts?.map((amount) => toIntegerString(amount))
51
+ };
52
+ }
53
+ function mapServerOrderInfo(info) {
54
+ const { order: serverOrder, status, updated_at } = info;
55
+ const order = {
56
+ amount: toBigDecimal(serverOrder.order.amount),
57
+ expiration: Number(serverOrder.order.expiration),
58
+ nonce: serverOrder.order.nonce,
59
+ price: removeDecimals(toBigDecimal(serverOrder.order.priceX18)),
60
+ digest: serverOrder.digest,
61
+ productId: serverOrder.product_id,
62
+ triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger),
63
+ appendix: unpackOrderAppendix(serverOrder.order.appendix)
64
+ };
65
+ return {
66
+ serverOrder,
67
+ order,
68
+ status: mapTriggerServerOrderStatus(status),
69
+ updatedAt: updated_at
70
+ };
71
+ }
8
72
  function mapTriggerServerOrderStatus(status) {
9
- if (status === "pending") {
73
+ if (status === "triggering") {
10
74
  return {
11
- type: "pending"
75
+ type: "triggering"
76
+ };
77
+ } else if (status === "waiting_price") {
78
+ return {
79
+ type: "waiting_price"
80
+ };
81
+ } else if (status === "waiting_dependency") {
82
+ return {
83
+ type: "waiting_dependency"
12
84
  };
13
85
  } else if ("cancelled" in status) {
14
86
  return {
15
87
  type: "cancelled",
16
88
  reason: status.cancelled
17
89
  };
90
+ } else if ("triggered" in status) {
91
+ return {
92
+ type: "triggered",
93
+ result: status.triggered
94
+ };
18
95
  } else if ("internal_error" in status) {
19
96
  return {
20
97
  type: "internal_error",
21
98
  error: status.internal_error
22
99
  };
23
- } else if ("triggered" in status) {
100
+ } else if ("twap_executing" in status) {
24
101
  return {
25
- type: "triggered",
26
- result: status.triggered
102
+ type: "twap_executing",
103
+ currentExecution: status.twap_executing.current_execution,
104
+ totalExecutions: status.twap_executing.total_executions
105
+ };
106
+ } else if ("twap_completed" in status) {
107
+ return {
108
+ type: "twap_completed",
109
+ executed: status.twap_completed.executed,
110
+ total: status.twap_completed.total
27
111
  };
28
112
  }
29
113
  throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);
30
114
  }
31
- function mapTriggerCriteria(criteria) {
32
- const priceValue = toIntegerString(addDecimals(criteria.triggerPrice));
33
- switch (criteria.type) {
34
- case "oracle_price_above":
35
- return { price_above: priceValue };
36
- case "oracle_price_below":
37
- return { price_below: priceValue };
38
- case "last_price_above":
39
- return { last_price_above: priceValue };
40
- case "last_price_below":
41
- return { last_price_below: priceValue };
42
- case "mid_price_above":
43
- return { mid_price_above: priceValue };
44
- case "mid_price_below":
45
- return { mid_price_below: priceValue };
46
- }
47
- }
48
115
  function mapServerTriggerCriteria(criteria) {
49
- if ("price_above" in criteria) {
116
+ if ("price_trigger" in criteria) {
50
117
  return {
51
- type: "oracle_price_above",
52
- triggerPrice: removeDecimals(criteria.price_above)
118
+ type: "price",
119
+ criteria: mapServerPriceTriggerCriteria(criteria.price_trigger)
53
120
  };
54
121
  }
55
- if ("price_below" in criteria) {
122
+ if ("time_trigger" in criteria) {
56
123
  return {
57
- type: "oracle_price_below",
58
- triggerPrice: removeDecimals(criteria.price_below)
124
+ type: "time",
125
+ criteria: mapServerTimeTriggerCriteria(criteria.time_trigger)
59
126
  };
60
127
  }
61
- if ("last_price_above" in criteria) {
128
+ throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);
129
+ }
130
+ function mapServerPriceTriggerCriteria(serverCriteria) {
131
+ const { price_requirement, dependency } = serverCriteria;
132
+ const { type, triggerPrice } = (() => {
133
+ if ("oracle_price_above" in price_requirement) {
134
+ return {
135
+ type: "oracle_price_above",
136
+ triggerPrice: price_requirement.oracle_price_above
137
+ };
138
+ } else if ("oracle_price_below" in price_requirement) {
139
+ return {
140
+ type: "oracle_price_below",
141
+ triggerPrice: price_requirement.oracle_price_below
142
+ };
143
+ } else if ("last_price_above" in price_requirement) {
144
+ return {
145
+ type: "last_price_above",
146
+ triggerPrice: price_requirement.last_price_above
147
+ };
148
+ } else if ("last_price_below" in price_requirement) {
149
+ return {
150
+ type: "last_price_below",
151
+ triggerPrice: price_requirement.last_price_below
152
+ };
153
+ } else if ("mid_price_above" in price_requirement) {
154
+ return {
155
+ type: "mid_price_above",
156
+ triggerPrice: price_requirement.mid_price_above
157
+ };
158
+ } else if ("mid_price_below" in price_requirement) {
159
+ return {
160
+ type: "mid_price_below",
161
+ triggerPrice: price_requirement.mid_price_below
162
+ };
163
+ } else {
164
+ throw new Error(
165
+ `Unknown price requirement: ${JSON.stringify(price_requirement)}`
166
+ );
167
+ }
168
+ })();
169
+ return {
170
+ type,
171
+ triggerPrice: removeDecimals(triggerPrice),
172
+ dependency: dependency ? {
173
+ digest: dependency.digest,
174
+ onPartialFill: dependency.on_partial_fill
175
+ } : void 0
176
+ };
177
+ }
178
+ function mapServerTimeTriggerCriteria(serverCriteria) {
179
+ return {
180
+ interval: toBigDecimal(serverCriteria.interval),
181
+ amounts: serverCriteria.amounts?.map(
182
+ (amount) => toBigDecimal(amount)
183
+ )
184
+ };
185
+ }
186
+ function mapTwapExecutionStatus(status) {
187
+ if (status === "pending") {
62
188
  return {
63
- type: "last_price_above",
64
- triggerPrice: removeDecimals(criteria.last_price_above)
189
+ type: "pending"
65
190
  };
66
- }
67
- if ("last_price_below" in criteria) {
191
+ } else if ("executed" in status) {
68
192
  return {
69
- type: "last_price_below",
70
- triggerPrice: removeDecimals(criteria.last_price_below)
193
+ type: "executed",
194
+ executedTime: status.executed.executed_time,
195
+ executeResponse: status.executed.execute_response
71
196
  };
72
- }
73
- if ("mid_price_above" in criteria) {
197
+ } else if ("failed" in status) {
74
198
  return {
75
- type: "mid_price_above",
76
- triggerPrice: removeDecimals(criteria.mid_price_above)
199
+ type: "failed",
200
+ error: status.failed
77
201
  };
78
- }
79
- if ("mid_price_below" in criteria) {
202
+ } else if ("cancelled" in status) {
80
203
  return {
81
- type: "mid_price_below",
82
- triggerPrice: removeDecimals(criteria.mid_price_below)
204
+ type: "cancelled",
205
+ reason: status.cancelled
83
206
  };
84
207
  }
85
- throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);
86
- }
87
- function mapServerOrderInfo(info) {
88
- const { order: serverOrder, status, updated_at } = info;
89
- const order = {
90
- amount: toBigDecimal(serverOrder.order.amount),
91
- expiration: toBigDecimal(serverOrder.order.expiration),
92
- nonce: serverOrder.order.nonce,
93
- price: removeDecimals(toBigDecimal(serverOrder.order.priceX18)),
94
- digest: serverOrder.digest,
95
- productId: serverOrder.product_id,
96
- triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger)
97
- };
98
- return {
99
- serverOrder,
100
- order,
101
- status: mapTriggerServerOrderStatus(status),
102
- updatedAt: updated_at
103
- };
208
+ throw Error(`Unknown TWAP execution status: ${JSON.stringify(status)}`);
104
209
  }
105
210
  export {
106
211
  mapServerOrderInfo,
107
- mapServerTriggerCriteria,
108
212
  mapTriggerCriteria,
109
- mapTriggerServerOrderStatus
213
+ mapTwapExecutionStatus
110
214
  };
111
215
  //# sourceMappingURL=dataMappers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n addDecimals,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/utils';\nimport {\n TriggerCriteria,\n TriggerOrder,\n TriggerOrderInfo,\n TriggerOrderStatus,\n TriggerServerOrderInfo,\n TriggerServerOrderStatus,\n TriggerServerTriggerCriteria,\n} from './types';\n\nexport function mapTriggerServerOrderStatus(\n status: TriggerServerOrderStatus,\n): TriggerOrderStatus {\n if (status === 'pending') {\n return {\n type: 'pending',\n };\n } else if ('cancelled' in status) {\n return {\n type: 'cancelled',\n reason: status.cancelled,\n };\n } else if ('internal_error' in status) {\n return {\n type: 'internal_error',\n error: status.internal_error,\n };\n } else if ('triggered' in status) {\n return {\n type: 'triggered',\n result: status.triggered,\n };\n }\n throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);\n}\n\nexport function mapTriggerCriteria(\n criteria: TriggerCriteria,\n): TriggerServerTriggerCriteria {\n const priceValue = toIntegerString(addDecimals(criteria.triggerPrice));\n switch (criteria.type) {\n case 'oracle_price_above':\n return { price_above: priceValue };\n case 'oracle_price_below':\n return { price_below: priceValue };\n case 'last_price_above':\n return { last_price_above: priceValue };\n case 'last_price_below':\n return { last_price_below: priceValue };\n case 'mid_price_above':\n return { mid_price_above: priceValue };\n case 'mid_price_below':\n return { mid_price_below: priceValue };\n }\n}\n\nexport function mapServerTriggerCriteria(\n criteria: TriggerServerTriggerCriteria,\n): TriggerCriteria {\n if ('price_above' in criteria) {\n return {\n type: 'oracle_price_above',\n triggerPrice: removeDecimals(criteria.price_above),\n };\n }\n if ('price_below' in criteria) {\n return {\n type: 'oracle_price_below',\n triggerPrice: removeDecimals(criteria.price_below),\n };\n }\n if ('last_price_above' in criteria) {\n return {\n type: 'last_price_above',\n triggerPrice: removeDecimals(criteria.last_price_above),\n };\n }\n if ('last_price_below' in criteria) {\n return {\n type: 'last_price_below',\n triggerPrice: removeDecimals(criteria.last_price_below),\n };\n }\n if ('mid_price_above' in criteria) {\n return {\n type: 'mid_price_above',\n triggerPrice: removeDecimals(criteria.mid_price_above),\n };\n }\n if ('mid_price_below' in criteria) {\n return {\n type: 'mid_price_below',\n triggerPrice: removeDecimals(criteria.mid_price_below),\n };\n }\n throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);\n}\n\nexport function mapServerOrderInfo(\n info: TriggerServerOrderInfo,\n): TriggerOrderInfo {\n const { order: serverOrder, status, updated_at } = info;\n const order: TriggerOrder = {\n amount: toBigDecimal(serverOrder.order.amount),\n expiration: toBigDecimal(serverOrder.order.expiration),\n nonce: serverOrder.order.nonce,\n price: removeDecimals(toBigDecimal(serverOrder.order.priceX18)),\n digest: serverOrder.digest,\n productId: serverOrder.product_id,\n triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger),\n };\n return {\n serverOrder,\n order,\n status: mapTriggerServerOrderStatus(status),\n updatedAt: updated_at,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,SAAS,4BACd,QACoB;AACpB,MAAI,WAAW,WAAW;AACxB,WAAO;AAAA,MACL,MAAM;AAAA,IACR;AAAA,EACF,WAAW,eAAe,QAAQ;AAChC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF,WAAW,oBAAoB,QAAQ;AACrC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,OAAO,OAAO;AAAA,IAChB;AAAA,EACF,WAAW,eAAe,QAAQ;AAChC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AACA,QAAM,MAAM,iCAAiC,KAAK,UAAU,MAAM,CAAC,EAAE;AACvE;AAEO,SAAS,mBACd,UAC8B;AAC9B,QAAM,aAAa,gBAAgB,YAAY,SAAS,YAAY,CAAC;AACrE,UAAQ,SAAS,MAAM;AAAA,IACrB,KAAK;AACH,aAAO,EAAE,aAAa,WAAW;AAAA,IACnC,KAAK;AACH,aAAO,EAAE,aAAa,WAAW;AAAA,IACnC,KAAK;AACH,aAAO,EAAE,kBAAkB,WAAW;AAAA,IACxC,KAAK;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AY;AAAA,IACvB,iBAAiB,yBAAyB,YAAY,OAAO;AAAA,EAC/D;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,QAAQ,4BAA4B,MAAM;AAAA,IAC1C,WAAW;AAAA,EACb;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import { unpackOrderAppendix } from '@nadohq/shared';\nimport {\n addDecimals,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\nimport {\n PriceTriggerCriteria,\n PriceTriggerRequirementType,\n TimeTriggerCriteria,\n TriggerCriteria,\n TriggerOrder,\n TriggerOrderInfo,\n TriggerOrderStatus,\n TriggerServerOrderInfo,\n TriggerServerOrderStatus,\n TriggerServerPriceRequirement,\n TriggerServerPriceTriggerCriteria,\n TriggerServerTimeTriggerCriteria,\n TriggerServerTriggerCriteria,\n TriggerServerTwapExecutionStatus,\n TwapExecutionStatus,\n} from './types';\n\n/**\n * Maps client-side trigger criteria to server-side trigger criteria format.\n * Converts price and time triggers to their respective server representations\n * with proper decimal scaling and field name transformations.\n *\n * @param criteria - The client-side trigger criteria (price or time based)\n * @returns The server-formatted trigger criteria ready for API transmission\n */\nexport function mapTriggerCriteria(\n criteria: TriggerCriteria,\n): TriggerServerTriggerCriteria {\n switch (criteria.type) {\n case 'price':\n return {\n price_trigger: mapPriceTriggerCriteria(criteria.criteria),\n };\n case 'time':\n return {\n time_trigger: mapTimeTriggerCriteria(criteria.criteria),\n };\n }\n}\n\nfunction mapPriceTriggerCriteria(\n criteria: PriceTriggerCriteria,\n): TriggerServerPriceTriggerCriteria {\n const priceValue = toIntegerString(addDecimals(criteria.triggerPrice));\n\n const price_requirement = ((): TriggerServerPriceRequirement => {\n switch (criteria.type) {\n case 'oracle_price_above':\n return { oracle_price_above: priceValue };\n case 'oracle_price_below':\n return { oracle_price_below: priceValue };\n case 'last_price_above':\n return { last_price_above: priceValue };\n case 'last_price_below':\n return { last_price_below: priceValue };\n case 'mid_price_above':\n return { mid_price_above: priceValue };\n case 'mid_price_below':\n return { mid_price_below: priceValue };\n }\n })();\n\n return {\n price_requirement,\n dependency: criteria.dependency\n ? {\n digest: criteria.dependency.digest,\n on_partial_fill: criteria.dependency.onPartialFill,\n }\n : undefined,\n };\n}\n\nfunction mapTimeTriggerCriteria(\n criteria: TimeTriggerCriteria,\n): TriggerServerTimeTriggerCriteria {\n return {\n interval: Number(criteria.interval),\n amounts: criteria.amounts?.map((amount) => toIntegerString(amount)),\n };\n}\n\n/**\n * Maps complete server-side trigger order information to client-side format.\n *\n * @param info - The complete server-side trigger order information including order, status, and timestamps\n * @returns The client-side trigger order information with converted values and normalized structure\n */\nexport function mapServerOrderInfo(\n info: TriggerServerOrderInfo,\n): TriggerOrderInfo {\n const { order: serverOrder, status, updated_at } = info;\n const order: TriggerOrder = {\n amount: toBigDecimal(serverOrder.order.amount),\n expiration: Number(serverOrder.order.expiration),\n nonce: serverOrder.order.nonce,\n price: removeDecimals(toBigDecimal(serverOrder.order.priceX18)),\n digest: serverOrder.digest,\n productId: serverOrder.product_id,\n triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger),\n appendix: unpackOrderAppendix(serverOrder.order.appendix),\n };\n return {\n serverOrder,\n order,\n status: mapTriggerServerOrderStatus(status),\n updatedAt: updated_at,\n };\n}\n\nfunction mapTriggerServerOrderStatus(\n status: TriggerServerOrderStatus,\n): TriggerOrderStatus {\n if (status === 'triggering') {\n return {\n type: 'triggering',\n };\n } else if (status === 'waiting_price') {\n return {\n type: 'waiting_price',\n };\n } else if (status === 'waiting_dependency') {\n return {\n type: 'waiting_dependency',\n };\n } else if ('cancelled' in status) {\n return {\n type: 'cancelled',\n reason: status.cancelled,\n };\n } else if ('triggered' in status) {\n return {\n type: 'triggered',\n result: status.triggered,\n };\n } else if ('internal_error' in status) {\n return {\n type: 'internal_error',\n error: status.internal_error,\n };\n } else if ('twap_executing' in status) {\n return {\n type: 'twap_executing',\n currentExecution: status.twap_executing.current_execution,\n totalExecutions: status.twap_executing.total_executions,\n };\n } else if ('twap_completed' in status) {\n return {\n type: 'twap_completed',\n executed: status.twap_completed.executed,\n total: status.twap_completed.total,\n };\n }\n throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);\n}\n\nfunction mapServerTriggerCriteria(\n criteria: TriggerServerTriggerCriteria,\n): TriggerCriteria {\n if ('price_trigger' in criteria) {\n return {\n type: 'price',\n criteria: mapServerPriceTriggerCriteria(criteria.price_trigger),\n };\n }\n if ('time_trigger' in criteria) {\n return {\n type: 'time',\n criteria: mapServerTimeTriggerCriteria(criteria.time_trigger),\n };\n }\n throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);\n}\n\nfunction mapServerPriceTriggerCriteria(\n serverCriteria: TriggerServerPriceTriggerCriteria,\n): PriceTriggerCriteria {\n const { price_requirement, dependency } = serverCriteria;\n\n const { type, triggerPrice } = ((): {\n type: PriceTriggerRequirementType;\n triggerPrice: string;\n } => {\n if ('oracle_price_above' in price_requirement) {\n return {\n type: 'oracle_price_above',\n triggerPrice: price_requirement.oracle_price_above,\n };\n } else if ('oracle_price_below' in price_requirement) {\n return {\n type: 'oracle_price_below',\n triggerPrice: price_requirement.oracle_price_below,\n };\n } else if ('last_price_above' in price_requirement) {\n return {\n type: 'last_price_above',\n triggerPrice: price_requirement.last_price_above,\n };\n } else if ('last_price_below' in price_requirement) {\n return {\n type: 'last_price_below',\n triggerPrice: price_requirement.last_price_below,\n };\n } else if ('mid_price_above' in price_requirement) {\n return {\n type: 'mid_price_above',\n triggerPrice: price_requirement.mid_price_above,\n };\n } else if ('mid_price_below' in price_requirement) {\n return {\n type: 'mid_price_below',\n triggerPrice: price_requirement.mid_price_below,\n };\n } else {\n throw new Error(\n `Unknown price requirement: ${JSON.stringify(price_requirement)}`,\n );\n }\n })();\n\n return {\n type,\n triggerPrice: removeDecimals(triggerPrice),\n dependency: dependency\n ? {\n digest: dependency.digest,\n onPartialFill: dependency.on_partial_fill,\n }\n : undefined,\n };\n}\n\nfunction mapServerTimeTriggerCriteria(\n serverCriteria: TriggerServerTimeTriggerCriteria,\n): TimeTriggerCriteria {\n return {\n interval: toBigDecimal(serverCriteria.interval),\n amounts: serverCriteria.amounts?.map((amount: string) =>\n toBigDecimal(amount),\n ),\n };\n}\n\nexport function mapTwapExecutionStatus(\n status: TriggerServerTwapExecutionStatus,\n): TwapExecutionStatus {\n if (status === 'pending') {\n return {\n type: 'pending',\n };\n } else if ('executed' in status) {\n return {\n type: 'executed',\n executedTime: status.executed.executed_time,\n executeResponse: status.executed.execute_response,\n };\n } else if ('failed' in status) {\n return {\n type: 'failed',\n error: status.failed,\n };\n } else if ('cancelled' in status) {\n return {\n type: 'cancelled',\n reason: status.cancelled,\n };\n }\n throw Error(`Unknown TWAP execution status: ${JSON.stringify(status)}`);\n}\n"],"mappings":";AAAA,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA2BA,SAAS,mBACd,UAC8B;AAC9B,UAAQ,SAAS,MAAM;AAAA,IACrB,KAAK;AACH,aAAO;AAAA,QACL,eAAe,wBAAwB,SAAS,QAAQ;AAAA,MAC1D;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,cAAc,uBAAuB,SAAS,QAAQ;AAAA,MACxD;AAAA,EACJ;AACF;AAEA,SAAS,wBACP,UACmC;AACnC,QAAM,aAAa,gBAAgB,YAAY,SAAS,YAAY,CAAC;AAErE,QAAM,qBAAqB,MAAqC;AAC9D,YAAQ,SAAS,MAAM;AAAA,MACrB,KAAK;AACH,eAAO,EAAE,oBAAoB,WAAW;AAAA,MAC1C,KAAK;AACH,eAAO,EAAE,oBAAoB,WAAW;AAAA,MAC1C,KAAK;AACH,eAAO,EAAE,kBAAkB,WAAW;AAAA,MACxC,KAAK;AACH,eAAO,EAAE,kBAAkB,WAAW;AAAA,MACxC,KAAK;AACH,eAAO,EAAE,iBAAiB,WAAW;AAAA,MACvC,KAAK;AACH,eA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","names":[]}
@@ -25,8 +25,8 @@ __export(endpoints_exports, {
25
25
  module.exports = __toCommonJS(endpoints_exports);
26
26
  var TRIGGER_CLIENT_ENDPOINTS = {
27
27
  local: "http://localhost:80/trigger",
28
- arbitrumTestnet: "https://trigger.sepolia-test.vertexprotocol.com/v1",
29
- arbitrum: "https://trigger.prod.vertexprotocol.com/v1"
28
+ arbitrum: "https://trigger.prod.vertexprotocol.com/v1",
29
+ inkTestnet: "https://trigger.test.nado-backend.xyz/v1"
30
30
  };
31
31
  // Annotate the CommonJS export names for ESM import in node:
32
32
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/contracts';\n\nexport const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:80/trigger',\n arbitrumTestnet: 'https://trigger.sepolia-test.vertexprotocol.com/v1',\n arbitrum: 'https://trigger.prod.vertexprotocol.com/v1',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,2BAAqD;AAAA,EAChE,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,UAAU;AACZ;","names":[]}
1
+ {"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\nexport const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:80/trigger',\n arbitrum: 'https://trigger.prod.vertexprotocol.com/v1',\n inkTestnet: 'https://trigger.test.nado-backend.xyz/v1',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,2BAAqD;AAAA,EAChE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;","names":[]}
@@ -1,4 +1,4 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  declare const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
4
4
 
@@ -1,4 +1,4 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  declare const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
4
4
 
package/dist/endpoints.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/endpoints.ts
2
2
  var TRIGGER_CLIENT_ENDPOINTS = {
3
3
  local: "http://localhost:80/trigger",
4
- arbitrumTestnet: "https://trigger.sepolia-test.vertexprotocol.com/v1",
5
- arbitrum: "https://trigger.prod.vertexprotocol.com/v1"
4
+ arbitrum: "https://trigger.prod.vertexprotocol.com/v1",
5
+ inkTestnet: "https://trigger.test.nado-backend.xyz/v1"
6
6
  };
7
7
  export {
8
8
  TRIGGER_CLIENT_ENDPOINTS
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/contracts';\n\nexport const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:80/trigger',\n arbitrumTestnet: 'https://trigger.sepolia-test.vertexprotocol.com/v1',\n arbitrum: 'https://trigger.prod.vertexprotocol.com/v1',\n};\n"],"mappings":";AAEO,IAAM,2BAAqD;AAAA,EAChE,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,UAAU;AACZ;","names":[]}
1
+ {"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\nexport const TRIGGER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:80/trigger',\n arbitrum: 'https://trigger.prod.vertexprotocol.com/v1',\n inkTestnet: 'https://trigger.test.nado-backend.xyz/v1',\n};\n"],"mappings":";AAEO,IAAM,2BAAqD;AAAA,EAChE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,10 +1,11 @@
1
- export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerCriteria, TriggerCriteriaType, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerOrderStatus, TriggerPlaceOrderParams } from './types/clientTypes.cjs';
2
- export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams, TriggerServerTriggerCriteria } from './types/serverExecuteTypes.cjs';
3
- export { TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse } from './types/serverQueryTypes.cjs';
1
+ export { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus } from './types/clientModelTypes.cjs';
2
+ export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TwapExecutionInfo, TwapExecutionStatus } from './types/clientTypes.cjs';
3
+ export { TriggerServerDependency, TriggerServerPriceRequirement, TriggerServerPriceTriggerCriteria, TriggerServerTimeTriggerCriteria, TriggerServerTriggerCriteria } from './types/serverModelTypes.cjs';
4
+ export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams } from './types/serverExecuteTypes.cjs';
5
+ export { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse } from './types/serverQueryTypes.cjs';
4
6
  export { TriggerServerFailureError } from './types/TriggerServerFailureError.cjs';
5
7
  export { TriggerClient, TriggerClientOpts } from './TriggerClient.cjs';
6
8
  export { TRIGGER_CLIENT_ENDPOINTS } from './endpoints.cjs';
7
- import '@nadohq/contracts';
8
9
  import '@nadohq/engine-client';
9
- import '@nadohq/utils';
10
+ import '@nadohq/shared';
10
11
  import 'axios';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerCriteria, TriggerCriteriaType, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerOrderStatus, TriggerPlaceOrderParams } from './types/clientTypes.js';
2
- export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams, TriggerServerTriggerCriteria } from './types/serverExecuteTypes.js';
3
- export { TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse } from './types/serverQueryTypes.js';
1
+ export { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus } from './types/clientModelTypes.js';
2
+ export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TwapExecutionInfo, TwapExecutionStatus } from './types/clientTypes.js';
3
+ export { TriggerServerDependency, TriggerServerPriceRequirement, TriggerServerPriceTriggerCriteria, TriggerServerTimeTriggerCriteria, TriggerServerTriggerCriteria } from './types/serverModelTypes.js';
4
+ export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams } from './types/serverExecuteTypes.js';
5
+ export { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse } from './types/serverQueryTypes.js';
4
6
  export { TriggerServerFailureError } from './types/TriggerServerFailureError.js';
5
7
  export { TriggerClient, TriggerClientOpts } from './TriggerClient.js';
6
8
  export { TRIGGER_CLIENT_ENDPOINTS } from './endpoints.js';
7
- import '@nadohq/contracts';
8
9
  import '@nadohq/engine-client';
9
- import '@nadohq/utils';
10
+ import '@nadohq/shared';
10
11
  import 'axios';
@@ -25,7 +25,7 @@ __export(TriggerServerFailureError_exports, {
25
25
  module.exports = __toCommonJS(TriggerServerFailureError_exports);
26
26
  var TriggerServerFailureError = class extends Error {
27
27
  constructor(responseData) {
28
- super();
28
+ super(`${responseData.error_code}: ${responseData.error}`);
29
29
  this.responseData = responseData;
30
30
  }
31
31
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/TriggerServerFailureError.ts"],"sourcesContent":["import { TriggerServerQueryFailureResponse } from './serverQueryTypes';\nimport { EngineServerExecuteFailureResult } from '@nadohq/engine-client';\n\nexport class TriggerServerFailureError extends Error {\n constructor(\n readonly responseData:\n | TriggerServerQueryFailureResponse\n | EngineServerExecuteFailureResult,\n ) {\n super();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EACnD,YACW,cAGT;AACA,UAAM;AAJG;AAAA,EAKX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/types/TriggerServerFailureError.ts"],"sourcesContent":["import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';\nimport { TriggerServerQueryFailureResponse } from './serverQueryTypes';\n\nexport class TriggerServerFailureError extends Error {\n constructor(\n readonly responseData:\n | TriggerServerQueryFailureResponse\n | EngineServerExecuteFailureResult,\n ) {\n super(`${responseData.error_code}: ${responseData.error}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EACnD,YACW,cAGT;AACA,UAAM,GAAG,aAAa,UAAU,KAAK,aAAa,KAAK,EAAE;AAJhD;AAAA,EAKX;AACF;","names":[]}
@@ -1,7 +1,8 @@
1
- import { TriggerServerQueryFailureResponse } from './serverQueryTypes.cjs';
2
1
  import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';
3
- import '@nadohq/contracts';
2
+ import { TriggerServerQueryFailureResponse } from './serverQueryTypes.cjs';
3
+ import '@nadohq/shared';
4
4
  import './serverExecuteTypes.cjs';
5
+ import './serverModelTypes.cjs';
5
6
 
6
7
  declare class TriggerServerFailureError extends Error {
7
8
  readonly responseData: TriggerServerQueryFailureResponse | EngineServerExecuteFailureResult;
@@ -1,7 +1,8 @@
1
- import { TriggerServerQueryFailureResponse } from './serverQueryTypes.js';
2
1
  import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';
3
- import '@nadohq/contracts';
2
+ import { TriggerServerQueryFailureResponse } from './serverQueryTypes.js';
3
+ import '@nadohq/shared';
4
4
  import './serverExecuteTypes.js';
5
+ import './serverModelTypes.js';
5
6
 
6
7
  declare class TriggerServerFailureError extends Error {
7
8
  readonly responseData: TriggerServerQueryFailureResponse | EngineServerExecuteFailureResult;
@@ -1,7 +1,7 @@
1
1
  // src/types/TriggerServerFailureError.ts
2
2
  var TriggerServerFailureError = class extends Error {
3
3
  constructor(responseData) {
4
- super();
4
+ super(`${responseData.error_code}: ${responseData.error}`);
5
5
  this.responseData = responseData;
6
6
  }
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/TriggerServerFailureError.ts"],"sourcesContent":["import { TriggerServerQueryFailureResponse } from './serverQueryTypes';\nimport { EngineServerExecuteFailureResult } from '@nadohq/engine-client';\n\nexport class TriggerServerFailureError extends Error {\n constructor(\n readonly responseData:\n | TriggerServerQueryFailureResponse\n | EngineServerExecuteFailureResult,\n ) {\n super();\n }\n}\n"],"mappings":";AAGO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EACnD,YACW,cAGT;AACA,UAAM;AAJG;AAAA,EAKX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/types/TriggerServerFailureError.ts"],"sourcesContent":["import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';\nimport { TriggerServerQueryFailureResponse } from './serverQueryTypes';\n\nexport class TriggerServerFailureError extends Error {\n constructor(\n readonly responseData:\n | TriggerServerQueryFailureResponse\n | EngineServerExecuteFailureResult,\n ) {\n super(`${responseData.error_code}: ${responseData.error}`);\n }\n}\n"],"mappings":";AAGO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EACnD,YACW,cAGT;AACA,UAAM,GAAG,aAAa,UAAU,KAAK,aAAa,KAAK,EAAE;AAJhD;AAAA,EAKX;AACF;","names":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types/clientModelTypes.ts
17
+ var clientModelTypes_exports = {};
18
+ module.exports = __toCommonJS(clientModelTypes_exports);
19
+ //# sourceMappingURL=clientModelTypes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/clientModelTypes.ts"],"sourcesContent":["import { EngineServerExecuteResult } from '@nadohq/engine-client';\nimport { BigDecimalish } from '@nadohq/shared';\n\n/*\nPrice trigger\n */\n\nexport type PriceTriggerRequirementType =\n | 'oracle_price_above'\n | 'oracle_price_below'\n | 'last_price_above'\n | 'last_price_below'\n | 'mid_price_above'\n | 'mid_price_below';\n\nexport interface PriceTriggerDependency {\n /**\n * Digest of the order that this trigger depends on.\n */\n digest: string;\n /**\n * Whether to trigger on partial fills.\n */\n onPartialFill: boolean;\n}\n\nexport interface PriceTriggerCriteria {\n type: PriceTriggerRequirementType;\n triggerPrice: BigDecimalish;\n dependency?: PriceTriggerDependency;\n}\n\n/*\nTime trigger (for TWAP)\n */\n\nexport interface TimeTriggerCriteria {\n /**\n * For TWAP: Trigger interval in seconds\n */\n interval: BigDecimalish;\n /**\n * For TWAP: By default, trigger service will split up orders as per total amount / interval\n * If you want to specify the amounts for each interval, you can provide them here.\n */\n amounts?: BigDecimalish[];\n}\n\n/**\n * All possible trigger conditions that can be used to place a trigger order.\n */\nexport type TriggerCriteria =\n | {\n type: 'price';\n criteria: PriceTriggerCriteria;\n }\n | {\n type: 'time';\n criteria: TimeTriggerCriteria;\n };\n\nexport type TriggerCriteriaType = TriggerCriteria['type'];\n\nexport type TriggerOrderStatus =\n | {\n type: 'cancelled';\n reason: string;\n }\n | {\n type: 'triggered';\n result: EngineServerExecuteResult;\n }\n | {\n type: 'internal_error';\n error: string;\n }\n | {\n type: 'triggering';\n }\n | {\n type: 'waiting_price';\n }\n | {\n type: 'waiting_dependency';\n }\n | {\n type: 'twap_executing';\n currentExecution: number;\n totalExecutions: number;\n }\n | {\n type: 'twap_completed';\n executed: number;\n total: number;\n };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,67 @@
1
+ import { EngineServerExecuteResult } from '@nadohq/engine-client';
2
+ import { BigDecimalish } from '@nadohq/shared';
3
+
4
+ type PriceTriggerRequirementType = 'oracle_price_above' | 'oracle_price_below' | 'last_price_above' | 'last_price_below' | 'mid_price_above' | 'mid_price_below';
5
+ interface PriceTriggerDependency {
6
+ /**
7
+ * Digest of the order that this trigger depends on.
8
+ */
9
+ digest: string;
10
+ /**
11
+ * Whether to trigger on partial fills.
12
+ */
13
+ onPartialFill: boolean;
14
+ }
15
+ interface PriceTriggerCriteria {
16
+ type: PriceTriggerRequirementType;
17
+ triggerPrice: BigDecimalish;
18
+ dependency?: PriceTriggerDependency;
19
+ }
20
+ interface TimeTriggerCriteria {
21
+ /**
22
+ * For TWAP: Trigger interval in seconds
23
+ */
24
+ interval: BigDecimalish;
25
+ /**
26
+ * For TWAP: By default, trigger service will split up orders as per total amount / interval
27
+ * If you want to specify the amounts for each interval, you can provide them here.
28
+ */
29
+ amounts?: BigDecimalish[];
30
+ }
31
+ /**
32
+ * All possible trigger conditions that can be used to place a trigger order.
33
+ */
34
+ type TriggerCriteria = {
35
+ type: 'price';
36
+ criteria: PriceTriggerCriteria;
37
+ } | {
38
+ type: 'time';
39
+ criteria: TimeTriggerCriteria;
40
+ };
41
+ type TriggerCriteriaType = TriggerCriteria['type'];
42
+ type TriggerOrderStatus = {
43
+ type: 'cancelled';
44
+ reason: string;
45
+ } | {
46
+ type: 'triggered';
47
+ result: EngineServerExecuteResult;
48
+ } | {
49
+ type: 'internal_error';
50
+ error: string;
51
+ } | {
52
+ type: 'triggering';
53
+ } | {
54
+ type: 'waiting_price';
55
+ } | {
56
+ type: 'waiting_dependency';
57
+ } | {
58
+ type: 'twap_executing';
59
+ currentExecution: number;
60
+ totalExecutions: number;
61
+ } | {
62
+ type: 'twap_completed';
63
+ executed: number;
64
+ total: number;
65
+ };
66
+
67
+ export type { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus };
@@ -0,0 +1,67 @@
1
+ import { EngineServerExecuteResult } from '@nadohq/engine-client';
2
+ import { BigDecimalish } from '@nadohq/shared';
3
+
4
+ type PriceTriggerRequirementType = 'oracle_price_above' | 'oracle_price_below' | 'last_price_above' | 'last_price_below' | 'mid_price_above' | 'mid_price_below';
5
+ interface PriceTriggerDependency {
6
+ /**
7
+ * Digest of the order that this trigger depends on.
8
+ */
9
+ digest: string;
10
+ /**
11
+ * Whether to trigger on partial fills.
12
+ */
13
+ onPartialFill: boolean;
14
+ }
15
+ interface PriceTriggerCriteria {
16
+ type: PriceTriggerRequirementType;
17
+ triggerPrice: BigDecimalish;
18
+ dependency?: PriceTriggerDependency;
19
+ }
20
+ interface TimeTriggerCriteria {
21
+ /**
22
+ * For TWAP: Trigger interval in seconds
23
+ */
24
+ interval: BigDecimalish;
25
+ /**
26
+ * For TWAP: By default, trigger service will split up orders as per total amount / interval
27
+ * If you want to specify the amounts for each interval, you can provide them here.
28
+ */
29
+ amounts?: BigDecimalish[];
30
+ }
31
+ /**
32
+ * All possible trigger conditions that can be used to place a trigger order.
33
+ */
34
+ type TriggerCriteria = {
35
+ type: 'price';
36
+ criteria: PriceTriggerCriteria;
37
+ } | {
38
+ type: 'time';
39
+ criteria: TimeTriggerCriteria;
40
+ };
41
+ type TriggerCriteriaType = TriggerCriteria['type'];
42
+ type TriggerOrderStatus = {
43
+ type: 'cancelled';
44
+ reason: string;
45
+ } | {
46
+ type: 'triggered';
47
+ result: EngineServerExecuteResult;
48
+ } | {
49
+ type: 'internal_error';
50
+ error: string;
51
+ } | {
52
+ type: 'triggering';
53
+ } | {
54
+ type: 'waiting_price';
55
+ } | {
56
+ type: 'waiting_dependency';
57
+ } | {
58
+ type: 'twap_executing';
59
+ currentExecution: number;
60
+ totalExecutions: number;
61
+ } | {
62
+ type: 'twap_completed';
63
+ executed: number;
64
+ total: number;
65
+ };
66
+
67
+ export type { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=clientModelTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}