@nadohq/trigger-client 0.1.0-alpha.3 → 0.1.0-alpha.31
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.
- package/dist/TriggerClient.cjs +74 -34
- package/dist/TriggerClient.cjs.map +1 -1
- package/dist/TriggerClient.d.cts +8 -4
- package/dist/TriggerClient.d.ts +8 -4
- package/dist/TriggerClient.js +73 -28
- package/dist/TriggerClient.js.map +1 -1
- package/dist/dataMappers.cjs +170 -67
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +22 -8
- package/dist/dataMappers.d.ts +22 -8
- package/dist/dataMappers.js +171 -66
- package/dist/dataMappers.js.map +1 -1
- package/dist/endpoints.cjs +2 -2
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +1 -1
- package/dist/endpoints.d.ts +1 -1
- package/dist/endpoints.js +2 -2
- package/dist/endpoints.js.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/TriggerServerFailureError.cjs +1 -1
- package/dist/types/TriggerServerFailureError.cjs.map +1 -1
- package/dist/types/TriggerServerFailureError.d.cts +3 -2
- package/dist/types/TriggerServerFailureError.d.ts +3 -2
- package/dist/types/TriggerServerFailureError.js +1 -1
- package/dist/types/TriggerServerFailureError.js.map +1 -1
- package/dist/types/clientModelTypes.cjs +19 -0
- package/dist/types/clientModelTypes.cjs.map +1 -0
- package/dist/types/clientModelTypes.d.cts +67 -0
- package/dist/types/clientModelTypes.d.ts +67 -0
- package/dist/types/clientModelTypes.js +1 -0
- package/dist/types/clientModelTypes.js.map +1 -0
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +50 -24
- package/dist/types/clientTypes.d.ts +50 -24
- package/dist/types/index.cjs +4 -0
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +6 -5
- package/dist/types/index.d.ts +6 -5
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/serverExecuteTypes.cjs.map +1 -1
- package/dist/types/serverExecuteTypes.d.cts +9 -15
- package/dist/types/serverExecuteTypes.d.ts +9 -15
- package/dist/types/serverModelTypes.cjs +19 -0
- package/dist/types/serverModelTypes.cjs.map +1 -0
- package/dist/types/serverModelTypes.d.cts +42 -0
- package/dist/types/serverModelTypes.d.ts +42 -0
- package/dist/types/serverModelTypes.js +1 -0
- package/dist/types/serverModelTypes.js.map +1 -0
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +48 -7
- package/dist/types/serverQueryTypes.d.ts +48 -7
- package/package.json +4 -5
- package/src/TriggerClient.ts +90 -29
- package/src/dataMappers.ts +225 -71
- package/src/endpoints.ts +2 -2
- package/src/index.ts +2 -2
- package/src/types/TriggerServerFailureError.ts +2 -2
- package/src/types/clientModelTypes.ts +95 -0
- package/src/types/clientTypes.ts +70 -41
- package/src/types/index.ts +2 -0
- package/src/types/serverExecuteTypes.ts +9 -24
- package/src/types/serverModelTypes.ts +55 -0
- package/src/types/serverQueryTypes.ts +75 -9
package/dist/dataMappers.js
CHANGED
|
@@ -3,109 +3,214 @@ import {
|
|
|
3
3
|
addDecimals,
|
|
4
4
|
removeDecimals,
|
|
5
5
|
toBigDecimal,
|
|
6
|
-
toIntegerString
|
|
7
|
-
|
|
6
|
+
toIntegerString,
|
|
7
|
+
unpackOrderAppendix
|
|
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, placed_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
|
+
placementTime: placed_at
|
|
71
|
+
};
|
|
72
|
+
}
|
|
8
73
|
function mapTriggerServerOrderStatus(status) {
|
|
9
|
-
if (status === "
|
|
74
|
+
if (status === "triggering") {
|
|
10
75
|
return {
|
|
11
|
-
type: "
|
|
76
|
+
type: "triggering"
|
|
77
|
+
};
|
|
78
|
+
} else if (status === "waiting_price") {
|
|
79
|
+
return {
|
|
80
|
+
type: "waiting_price"
|
|
81
|
+
};
|
|
82
|
+
} else if (status === "waiting_dependency") {
|
|
83
|
+
return {
|
|
84
|
+
type: "waiting_dependency"
|
|
12
85
|
};
|
|
13
86
|
} else if ("cancelled" in status) {
|
|
14
87
|
return {
|
|
15
88
|
type: "cancelled",
|
|
16
89
|
reason: status.cancelled
|
|
17
90
|
};
|
|
91
|
+
} else if ("triggered" in status) {
|
|
92
|
+
return {
|
|
93
|
+
type: "triggered",
|
|
94
|
+
result: status.triggered
|
|
95
|
+
};
|
|
18
96
|
} else if ("internal_error" in status) {
|
|
19
97
|
return {
|
|
20
98
|
type: "internal_error",
|
|
21
99
|
error: status.internal_error
|
|
22
100
|
};
|
|
23
|
-
} else if ("
|
|
101
|
+
} else if ("twap_executing" in status) {
|
|
24
102
|
return {
|
|
25
|
-
type: "
|
|
26
|
-
|
|
103
|
+
type: "twap_executing",
|
|
104
|
+
currentExecution: status.twap_executing.current_execution,
|
|
105
|
+
totalExecutions: status.twap_executing.total_executions
|
|
106
|
+
};
|
|
107
|
+
} else if ("twap_completed" in status) {
|
|
108
|
+
return {
|
|
109
|
+
type: "twap_completed",
|
|
110
|
+
executed: status.twap_completed.executed,
|
|
111
|
+
total: status.twap_completed.total
|
|
27
112
|
};
|
|
28
113
|
}
|
|
29
114
|
throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);
|
|
30
115
|
}
|
|
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
116
|
function mapServerTriggerCriteria(criteria) {
|
|
49
|
-
if ("
|
|
117
|
+
if ("price_trigger" in criteria) {
|
|
50
118
|
return {
|
|
51
|
-
type: "
|
|
52
|
-
|
|
119
|
+
type: "price",
|
|
120
|
+
criteria: mapServerPriceTriggerCriteria(criteria.price_trigger)
|
|
53
121
|
};
|
|
54
122
|
}
|
|
55
|
-
if ("
|
|
123
|
+
if ("time_trigger" in criteria) {
|
|
56
124
|
return {
|
|
57
|
-
type: "
|
|
58
|
-
|
|
125
|
+
type: "time",
|
|
126
|
+
criteria: mapServerTimeTriggerCriteria(criteria.time_trigger)
|
|
59
127
|
};
|
|
60
128
|
}
|
|
61
|
-
|
|
129
|
+
throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);
|
|
130
|
+
}
|
|
131
|
+
function mapServerPriceTriggerCriteria(serverCriteria) {
|
|
132
|
+
const { price_requirement, dependency } = serverCriteria;
|
|
133
|
+
const { type, triggerPrice } = (() => {
|
|
134
|
+
if ("oracle_price_above" in price_requirement) {
|
|
135
|
+
return {
|
|
136
|
+
type: "oracle_price_above",
|
|
137
|
+
triggerPrice: price_requirement.oracle_price_above
|
|
138
|
+
};
|
|
139
|
+
} else if ("oracle_price_below" in price_requirement) {
|
|
140
|
+
return {
|
|
141
|
+
type: "oracle_price_below",
|
|
142
|
+
triggerPrice: price_requirement.oracle_price_below
|
|
143
|
+
};
|
|
144
|
+
} else if ("last_price_above" in price_requirement) {
|
|
145
|
+
return {
|
|
146
|
+
type: "last_price_above",
|
|
147
|
+
triggerPrice: price_requirement.last_price_above
|
|
148
|
+
};
|
|
149
|
+
} else if ("last_price_below" in price_requirement) {
|
|
150
|
+
return {
|
|
151
|
+
type: "last_price_below",
|
|
152
|
+
triggerPrice: price_requirement.last_price_below
|
|
153
|
+
};
|
|
154
|
+
} else if ("mid_price_above" in price_requirement) {
|
|
155
|
+
return {
|
|
156
|
+
type: "mid_price_above",
|
|
157
|
+
triggerPrice: price_requirement.mid_price_above
|
|
158
|
+
};
|
|
159
|
+
} else if ("mid_price_below" in price_requirement) {
|
|
160
|
+
return {
|
|
161
|
+
type: "mid_price_below",
|
|
162
|
+
triggerPrice: price_requirement.mid_price_below
|
|
163
|
+
};
|
|
164
|
+
} else {
|
|
165
|
+
throw new Error(
|
|
166
|
+
`Unknown price requirement: ${JSON.stringify(price_requirement)}`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
})();
|
|
170
|
+
return {
|
|
171
|
+
type,
|
|
172
|
+
triggerPrice: removeDecimals(triggerPrice),
|
|
173
|
+
dependency: dependency ? {
|
|
174
|
+
digest: dependency.digest,
|
|
175
|
+
onPartialFill: dependency.on_partial_fill
|
|
176
|
+
} : void 0
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function mapServerTimeTriggerCriteria(serverCriteria) {
|
|
180
|
+
return {
|
|
181
|
+
interval: toBigDecimal(serverCriteria.interval),
|
|
182
|
+
amounts: serverCriteria.amounts?.map(
|
|
183
|
+
(amount) => toBigDecimal(amount)
|
|
184
|
+
)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function mapTwapExecutionStatus(status) {
|
|
188
|
+
if (status === "pending") {
|
|
62
189
|
return {
|
|
63
|
-
type: "
|
|
64
|
-
triggerPrice: removeDecimals(criteria.last_price_above)
|
|
190
|
+
type: "pending"
|
|
65
191
|
};
|
|
66
|
-
}
|
|
67
|
-
if ("last_price_below" in criteria) {
|
|
192
|
+
} else if ("executed" in status) {
|
|
68
193
|
return {
|
|
69
|
-
type: "
|
|
70
|
-
|
|
194
|
+
type: "executed",
|
|
195
|
+
executedTime: status.executed.executed_time,
|
|
196
|
+
executeResponse: status.executed.execute_response
|
|
71
197
|
};
|
|
72
|
-
}
|
|
73
|
-
if ("mid_price_above" in criteria) {
|
|
198
|
+
} else if ("failed" in status) {
|
|
74
199
|
return {
|
|
75
|
-
type: "
|
|
76
|
-
|
|
200
|
+
type: "failed",
|
|
201
|
+
error: status.failed
|
|
77
202
|
};
|
|
78
|
-
}
|
|
79
|
-
if ("mid_price_below" in criteria) {
|
|
203
|
+
} else if ("cancelled" in status) {
|
|
80
204
|
return {
|
|
81
|
-
type: "
|
|
82
|
-
|
|
205
|
+
type: "cancelled",
|
|
206
|
+
reason: status.cancelled
|
|
83
207
|
};
|
|
84
208
|
}
|
|
85
|
-
throw
|
|
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
|
-
};
|
|
209
|
+
throw Error(`Unknown TWAP execution status: ${JSON.stringify(status)}`);
|
|
104
210
|
}
|
|
105
211
|
export {
|
|
106
212
|
mapServerOrderInfo,
|
|
107
|
-
mapServerTriggerCriteria,
|
|
108
213
|
mapTriggerCriteria,
|
|
109
|
-
|
|
214
|
+
mapTwapExecutionStatus
|
|
110
215
|
};
|
|
111
216
|
//# sourceMappingURL=dataMappers.js.map
|
package/dist/dataMappers.js.map
CHANGED
|
@@ -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;AA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,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,eAAe,SAAS,eAAe;AAAA,IACvD;AAAA,EACF;AACA,QAAM,IAAI,MAAM,6BAA6B,KAAK,UAAU,QAAQ,CAAC,EAAE;AACzE;AAEO,SAAS,mBACd,MACkB;AAClB,QAAM,EAAE,OAAO,aAAa,QAAQ,WAAW,IAAI;AACnD,QAAM,QAAsB;AAAA,IAC1B,QAAQ,aAAa,YAAY,MAAM,MAAM;AAAA,IAC7C,YAAY,aAAa,YAAY,MAAM,UAAU;AAAA,IACrD,OAAO,YAAY,MAAM;AAAA,IACzB,OAAO,eAAe,aAAa,YAAY,MAAM,QAAQ,CAAC;AAAA,IAC9D,QAAQ,YAAY;AAAA,IACpB,WAAW,YAAY;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 {\n addDecimals,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n unpackOrderAppendix,\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, placed_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 placementTime: placed_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;AAAA,EACE;AAAA,EACA;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,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AACF;AAEO,SAAS,uBACd,QACqB;AACrB,MAAI,WAAW,WAAW;AACxB,WAAO;AAAA,MACL,MAAM;AAAA,IACR;AAAA,EACF,WAAW,cAAc,QAAQ;AAC/B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,OAAO,SAAS;AAAA,MAC9B,iBAAiB,OAAO,SAAS;AAAA,IACnC;AAAA,EACF,WAAW,YAAY,QAAQ;AAC7B,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,kCAAkC,KAAK,UAAU,MAAM,CAAC,EAAE;AACxE;","names":[]}
|
package/dist/endpoints.cjs
CHANGED
|
@@ -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
|
-
|
|
29
|
-
|
|
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 = {
|
package/dist/endpoints.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/
|
|
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":[]}
|
package/dist/endpoints.d.cts
CHANGED
package/dist/endpoints.d.ts
CHANGED
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
|
-
|
|
5
|
-
|
|
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
|
package/dist/endpoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/
|
|
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.cjs
CHANGED
|
@@ -17,13 +17,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var index_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./types/index.cjs"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("./TriggerClient.cjs"), module.exports);
|
|
22
20
|
__reExport(index_exports, require("./endpoints.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./TriggerClient.cjs"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./types/index.cjs"), module.exports);
|
|
23
23
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
24
|
0 && (module.exports = {
|
|
25
|
-
...require("./
|
|
25
|
+
...require("./endpoints.cjs"),
|
|
26
26
|
...require("./TriggerClient.cjs"),
|
|
27
|
-
...require("./
|
|
27
|
+
...require("./types/index.cjs")
|
|
28
28
|
});
|
|
29
29
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './endpoints';\nexport * from './TriggerClient';\nexport * from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,4BAAd;AACA,0BAAc,gCADd;AAEA,0BAAc,8BAFd;","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';
|
|
4
|
-
export { TriggerServerFailureError } from './types/TriggerServerFailureError.cjs';
|
|
5
|
-
export { TriggerClient, TriggerClientOpts } from './TriggerClient.cjs';
|
|
6
1
|
export { TRIGGER_CLIENT_ENDPOINTS } from './endpoints.cjs';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export { TriggerClient, TriggerClientOpts } from './TriggerClient.cjs';
|
|
3
|
+
export { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus } from './types/clientModelTypes.cjs';
|
|
4
|
+
export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TriggerPlaceOrdersParams, TwapExecutionInfo, TwapExecutionStatus } from './types/clientTypes.cjs';
|
|
5
|
+
export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams, TriggerServerPlaceOrdersParams } from './types/serverExecuteTypes.cjs';
|
|
6
|
+
export { TriggerServerDependency, TriggerServerPriceRequirement, TriggerServerPriceTriggerCriteria, TriggerServerTimeTriggerCriteria, TriggerServerTriggerCriteria } from './types/serverModelTypes.cjs';
|
|
7
|
+
export { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse } from './types/serverQueryTypes.cjs';
|
|
8
|
+
export { TriggerServerFailureError } from './types/TriggerServerFailureError.cjs';
|
|
9
|
+
import '@nadohq/shared';
|
|
10
10
|
import 'axios';
|
|
11
|
+
import '@nadohq/engine-client';
|
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';
|
|
4
|
-
export { TriggerServerFailureError } from './types/TriggerServerFailureError.js';
|
|
5
|
-
export { TriggerClient, TriggerClientOpts } from './TriggerClient.js';
|
|
6
1
|
export { TRIGGER_CLIENT_ENDPOINTS } from './endpoints.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export { TriggerClient, TriggerClientOpts } from './TriggerClient.js';
|
|
3
|
+
export { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus } from './types/clientModelTypes.js';
|
|
4
|
+
export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TriggerPlaceOrdersParams, TwapExecutionInfo, TwapExecutionStatus } from './types/clientTypes.js';
|
|
5
|
+
export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams, TriggerServerPlaceOrdersParams } from './types/serverExecuteTypes.js';
|
|
6
|
+
export { TriggerServerDependency, TriggerServerPriceRequirement, TriggerServerPriceTriggerCriteria, TriggerServerTimeTriggerCriteria, TriggerServerTriggerCriteria } from './types/serverModelTypes.js';
|
|
7
|
+
export { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse } from './types/serverQueryTypes.js';
|
|
8
|
+
export { TriggerServerFailureError } from './types/TriggerServerFailureError.js';
|
|
9
|
+
import '@nadohq/shared';
|
|
10
10
|
import 'axios';
|
|
11
|
+
import '@nadohq/engine-client';
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './endpoints';\nexport * from './TriggerClient';\nexport * from './types';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -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 {
|
|
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 '
|
|
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 '
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/TriggerServerFailureError.ts"],"sourcesContent":["import {
|
|
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 };
|