@nadohq/trigger-client 0.1.0-alpha.1
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/README.md +2 -0
- package/dist/TriggerClient.cjs +217 -0
- package/dist/TriggerClient.cjs.map +1 -0
- package/dist/TriggerClient.d.cts +45 -0
- package/dist/TriggerClient.d.ts +45 -0
- package/dist/TriggerClient.js +188 -0
- package/dist/TriggerClient.js.map +1 -0
- package/dist/dataMappers.cjs +134 -0
- package/dist/dataMappers.cjs.map +1 -0
- package/dist/dataMappers.d.cts +13 -0
- package/dist/dataMappers.d.ts +13 -0
- package/dist/dataMappers.js +111 -0
- package/dist/dataMappers.js.map +1 -0
- package/dist/endpoints.cjs +35 -0
- package/dist/endpoints.cjs.map +1 -0
- package/dist/endpoints.d.cts +5 -0
- package/dist/endpoints.d.ts +5 -0
- package/dist/endpoints.js +10 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types/TriggerServerFailureError.cjs +36 -0
- package/dist/types/TriggerServerFailureError.cjs.map +1 -0
- package/dist/types/TriggerServerFailureError.d.cts +11 -0
- package/dist/types/TriggerServerFailureError.d.ts +11 -0
- package/dist/types/TriggerServerFailureError.js +11 -0
- package/dist/types/TriggerServerFailureError.js.map +1 -0
- package/dist/types/clientTypes.cjs +19 -0
- package/dist/types/clientTypes.cjs.map +1 -0
- package/dist/types/clientTypes.d.cts +75 -0
- package/dist/types/clientTypes.d.ts +75 -0
- package/dist/types/clientTypes.js +1 -0
- package/dist/types/clientTypes.js.map +1 -0
- package/dist/types/index.cjs +31 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/serverExecuteTypes.cjs +19 -0
- package/dist/types/serverExecuteTypes.cjs.map +1 -0
- package/dist/types/serverExecuteTypes.d.cts +37 -0
- package/dist/types/serverExecuteTypes.d.ts +37 -0
- package/dist/types/serverExecuteTypes.js +1 -0
- package/dist/types/serverExecuteTypes.js.map +1 -0
- package/dist/types/serverQueryTypes.cjs +19 -0
- package/dist/types/serverQueryTypes.cjs.map +1 -0
- package/dist/types/serverQueryTypes.d.cts +54 -0
- package/dist/types/serverQueryTypes.d.ts +54 -0
- package/dist/types/serverQueryTypes.js +1 -0
- package/dist/types/serverQueryTypes.js.map +1 -0
- package/package.json +53 -0
- package/src/TriggerClient.ts +284 -0
- package/src/dataMappers.ts +124 -0
- package/src/endpoints.ts +7 -0
- package/src/index.ts +3 -0
- package/src/types/TriggerServerFailureError.ts +12 -0
- package/src/types/clientTypes.ts +109 -0
- package/src/types/index.ts +4 -0
- package/src/types/serverExecuteTypes.ts +63 -0
- package/src/types/serverQueryTypes.ts +83 -0
|
@@ -0,0 +1,134 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/dataMappers.ts
|
|
21
|
+
var dataMappers_exports = {};
|
|
22
|
+
__export(dataMappers_exports, {
|
|
23
|
+
mapServerOrderInfo: () => mapServerOrderInfo,
|
|
24
|
+
mapServerTriggerCriteria: () => mapServerTriggerCriteria,
|
|
25
|
+
mapTriggerCriteria: () => mapTriggerCriteria,
|
|
26
|
+
mapTriggerServerOrderStatus: () => mapTriggerServerOrderStatus
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(dataMappers_exports);
|
|
29
|
+
var import_utils = require("@nadohq/utils");
|
|
30
|
+
function mapTriggerServerOrderStatus(status) {
|
|
31
|
+
if (status === "pending") {
|
|
32
|
+
return {
|
|
33
|
+
type: "pending"
|
|
34
|
+
};
|
|
35
|
+
} else if ("cancelled" in status) {
|
|
36
|
+
return {
|
|
37
|
+
type: "cancelled",
|
|
38
|
+
reason: status.cancelled
|
|
39
|
+
};
|
|
40
|
+
} else if ("internal_error" in status) {
|
|
41
|
+
return {
|
|
42
|
+
type: "internal_error",
|
|
43
|
+
error: status.internal_error
|
|
44
|
+
};
|
|
45
|
+
} else if ("triggered" in status) {
|
|
46
|
+
return {
|
|
47
|
+
type: "triggered",
|
|
48
|
+
result: status.triggered
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);
|
|
52
|
+
}
|
|
53
|
+
function mapTriggerCriteria(criteria) {
|
|
54
|
+
const priceValue = (0, import_utils.toIntegerString)((0, import_utils.addDecimals)(criteria.triggerPrice));
|
|
55
|
+
switch (criteria.type) {
|
|
56
|
+
case "oracle_price_above":
|
|
57
|
+
return { price_above: priceValue };
|
|
58
|
+
case "oracle_price_below":
|
|
59
|
+
return { price_below: priceValue };
|
|
60
|
+
case "last_price_above":
|
|
61
|
+
return { last_price_above: priceValue };
|
|
62
|
+
case "last_price_below":
|
|
63
|
+
return { last_price_below: priceValue };
|
|
64
|
+
case "mid_price_above":
|
|
65
|
+
return { mid_price_above: priceValue };
|
|
66
|
+
case "mid_price_below":
|
|
67
|
+
return { mid_price_below: priceValue };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function mapServerTriggerCriteria(criteria) {
|
|
71
|
+
if ("price_above" in criteria) {
|
|
72
|
+
return {
|
|
73
|
+
type: "oracle_price_above",
|
|
74
|
+
triggerPrice: (0, import_utils.removeDecimals)(criteria.price_above)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if ("price_below" in criteria) {
|
|
78
|
+
return {
|
|
79
|
+
type: "oracle_price_below",
|
|
80
|
+
triggerPrice: (0, import_utils.removeDecimals)(criteria.price_below)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if ("last_price_above" in criteria) {
|
|
84
|
+
return {
|
|
85
|
+
type: "last_price_above",
|
|
86
|
+
triggerPrice: (0, import_utils.removeDecimals)(criteria.last_price_above)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if ("last_price_below" in criteria) {
|
|
90
|
+
return {
|
|
91
|
+
type: "last_price_below",
|
|
92
|
+
triggerPrice: (0, import_utils.removeDecimals)(criteria.last_price_below)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if ("mid_price_above" in criteria) {
|
|
96
|
+
return {
|
|
97
|
+
type: "mid_price_above",
|
|
98
|
+
triggerPrice: (0, import_utils.removeDecimals)(criteria.mid_price_above)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if ("mid_price_below" in criteria) {
|
|
102
|
+
return {
|
|
103
|
+
type: "mid_price_below",
|
|
104
|
+
triggerPrice: (0, import_utils.removeDecimals)(criteria.mid_price_below)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`Unknown trigger criteria: ${JSON.stringify(criteria)}`);
|
|
108
|
+
}
|
|
109
|
+
function mapServerOrderInfo(info) {
|
|
110
|
+
const { order: serverOrder, status, updated_at } = info;
|
|
111
|
+
const order = {
|
|
112
|
+
amount: (0, import_utils.toBigDecimal)(serverOrder.order.amount),
|
|
113
|
+
expiration: (0, import_utils.toBigDecimal)(serverOrder.order.expiration),
|
|
114
|
+
nonce: serverOrder.order.nonce,
|
|
115
|
+
price: (0, import_utils.removeDecimals)((0, import_utils.toBigDecimal)(serverOrder.order.priceX18)),
|
|
116
|
+
digest: serverOrder.digest,
|
|
117
|
+
productId: serverOrder.product_id,
|
|
118
|
+
triggerCriteria: mapServerTriggerCriteria(serverOrder.trigger)
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
serverOrder,
|
|
122
|
+
order,
|
|
123
|
+
status: mapTriggerServerOrderStatus(status),
|
|
124
|
+
updatedAt: updated_at
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
mapServerOrderInfo,
|
|
130
|
+
mapServerTriggerCriteria,
|
|
131
|
+
mapTriggerCriteria,
|
|
132
|
+
mapTriggerServerOrderStatus
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=dataMappers.cjs.map
|
|
@@ -0,0 +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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKO;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,iBAAa,kCAAgB,0BAAY,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;AACH,aAAO,EAAE,kBAAkB,WAAW;AAAA,IACxC,KAAK;AACH,aAAO,EAAE,iBAAiB,WAAW;AAAA,IACvC,KAAK;AACH,aAAO,EAAE,iBAAiB,WAAW;AAAA,EACzC;AACF;AAEO,SAAS,yBACd,UACiB;AACjB,MAAI,iBAAiB,UAAU;AAC7B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,kBAAc,6BAAe,SAAS,WAAW;AAAA,IACnD;AAAA,EACF;AACA,MAAI,iBAAiB,UAAU;AAC7B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,kBAAc,6BAAe,SAAS,WAAW;AAAA,IACnD;AAAA,EACF;AACA,MAAI,sBAAsB,UAAU;AAClC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,kBAAc,6BAAe,SAAS,gBAAgB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,sBAAsB,UAAU;AAClC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,kBAAc,6BAAe,SAAS,gBAAgB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,kBAAc,6BAAe,SAAS,eAAe;AAAA,IACvD;AAAA,EACF;AACA,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,kBAAc,6BAAe,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,YAAQ,2BAAa,YAAY,MAAM,MAAM;AAAA,IAC7C,gBAAY,2BAAa,YAAY,MAAM,UAAU;AAAA,IACrD,OAAO,YAAY,MAAM;AAAA,IACzB,WAAO,iCAAe,2BAAa,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":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TriggerOrderStatus, TriggerCriteria, TriggerOrderInfo } from './types/clientTypes.cjs';
|
|
2
|
+
import { TriggerServerTriggerCriteria } from './types/serverExecuteTypes.cjs';
|
|
3
|
+
import { TriggerServerOrderStatus, TriggerServerOrderInfo } from './types/serverQueryTypes.cjs';
|
|
4
|
+
import '@nadohq/contracts';
|
|
5
|
+
import '@nadohq/engine-client';
|
|
6
|
+
import '@nadohq/utils';
|
|
7
|
+
|
|
8
|
+
declare function mapTriggerServerOrderStatus(status: TriggerServerOrderStatus): TriggerOrderStatus;
|
|
9
|
+
declare function mapTriggerCriteria(criteria: TriggerCriteria): TriggerServerTriggerCriteria;
|
|
10
|
+
declare function mapServerTriggerCriteria(criteria: TriggerServerTriggerCriteria): TriggerCriteria;
|
|
11
|
+
declare function mapServerOrderInfo(info: TriggerServerOrderInfo): TriggerOrderInfo;
|
|
12
|
+
|
|
13
|
+
export { mapServerOrderInfo, mapServerTriggerCriteria, mapTriggerCriteria, mapTriggerServerOrderStatus };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TriggerOrderStatus, TriggerCriteria, TriggerOrderInfo } from './types/clientTypes.js';
|
|
2
|
+
import { TriggerServerTriggerCriteria } from './types/serverExecuteTypes.js';
|
|
3
|
+
import { TriggerServerOrderStatus, TriggerServerOrderInfo } from './types/serverQueryTypes.js';
|
|
4
|
+
import '@nadohq/contracts';
|
|
5
|
+
import '@nadohq/engine-client';
|
|
6
|
+
import '@nadohq/utils';
|
|
7
|
+
|
|
8
|
+
declare function mapTriggerServerOrderStatus(status: TriggerServerOrderStatus): TriggerOrderStatus;
|
|
9
|
+
declare function mapTriggerCriteria(criteria: TriggerCriteria): TriggerServerTriggerCriteria;
|
|
10
|
+
declare function mapServerTriggerCriteria(criteria: TriggerServerTriggerCriteria): TriggerCriteria;
|
|
11
|
+
declare function mapServerOrderInfo(info: TriggerServerOrderInfo): TriggerOrderInfo;
|
|
12
|
+
|
|
13
|
+
export { mapServerOrderInfo, mapServerTriggerCriteria, mapTriggerCriteria, mapTriggerServerOrderStatus };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/dataMappers.ts
|
|
2
|
+
import {
|
|
3
|
+
addDecimals,
|
|
4
|
+
removeDecimals,
|
|
5
|
+
toBigDecimal,
|
|
6
|
+
toIntegerString
|
|
7
|
+
} from "@nadohq/utils";
|
|
8
|
+
function mapTriggerServerOrderStatus(status) {
|
|
9
|
+
if (status === "pending") {
|
|
10
|
+
return {
|
|
11
|
+
type: "pending"
|
|
12
|
+
};
|
|
13
|
+
} else if ("cancelled" in status) {
|
|
14
|
+
return {
|
|
15
|
+
type: "cancelled",
|
|
16
|
+
reason: status.cancelled
|
|
17
|
+
};
|
|
18
|
+
} else if ("internal_error" in status) {
|
|
19
|
+
return {
|
|
20
|
+
type: "internal_error",
|
|
21
|
+
error: status.internal_error
|
|
22
|
+
};
|
|
23
|
+
} else if ("triggered" in status) {
|
|
24
|
+
return {
|
|
25
|
+
type: "triggered",
|
|
26
|
+
result: status.triggered
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);
|
|
30
|
+
}
|
|
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
|
+
function mapServerTriggerCriteria(criteria) {
|
|
49
|
+
if ("price_above" in criteria) {
|
|
50
|
+
return {
|
|
51
|
+
type: "oracle_price_above",
|
|
52
|
+
triggerPrice: removeDecimals(criteria.price_above)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if ("price_below" in criteria) {
|
|
56
|
+
return {
|
|
57
|
+
type: "oracle_price_below",
|
|
58
|
+
triggerPrice: removeDecimals(criteria.price_below)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if ("last_price_above" in criteria) {
|
|
62
|
+
return {
|
|
63
|
+
type: "last_price_above",
|
|
64
|
+
triggerPrice: removeDecimals(criteria.last_price_above)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if ("last_price_below" in criteria) {
|
|
68
|
+
return {
|
|
69
|
+
type: "last_price_below",
|
|
70
|
+
triggerPrice: removeDecimals(criteria.last_price_below)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if ("mid_price_above" in criteria) {
|
|
74
|
+
return {
|
|
75
|
+
type: "mid_price_above",
|
|
76
|
+
triggerPrice: removeDecimals(criteria.mid_price_above)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if ("mid_price_below" in criteria) {
|
|
80
|
+
return {
|
|
81
|
+
type: "mid_price_below",
|
|
82
|
+
triggerPrice: removeDecimals(criteria.mid_price_below)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
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
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
mapServerOrderInfo,
|
|
107
|
+
mapServerTriggerCriteria,
|
|
108
|
+
mapTriggerCriteria,
|
|
109
|
+
mapTriggerServerOrderStatus
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=dataMappers.js.map
|
|
@@ -0,0 +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;AACH,aAAO,EAAE,kBAAkB,WAAW;AAAA,IACxC,KAAK;AACH,aAAO,EAAE,iBAAiB,WAAW;AAAA,IACvC,KAAK;AACH,aAAO,EAAE,iBAAiB,WAAW;AAAA,EACzC;AACF;AAEO,SAAS,yBACd,UACiB;AACjB,MAAI,iBAAiB,UAAU;AAC7B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,eAAe,SAAS,WAAW;AAAA,IACnD;AAAA,EACF;AACA,MAAI,iBAAiB,UAAU;AAC7B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,eAAe,SAAS,WAAW;AAAA,IACnD;AAAA,EACF;AACA,MAAI,sBAAsB,UAAU;AAClC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,eAAe,SAAS,gBAAgB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,sBAAsB,UAAU;AAClC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,eAAe,SAAS,gBAAgB;AAAA,IACxD;AAAA,EACF;AACA,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,cAAc,eAAe,SAAS,eAAe;AAAA,IACvD;AAAA,EACF;AACA,MAAI,qBAAqB,UAAU;AACjC,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":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/endpoints.ts
|
|
21
|
+
var endpoints_exports = {};
|
|
22
|
+
__export(endpoints_exports, {
|
|
23
|
+
TRIGGER_CLIENT_ENDPOINTS: () => TRIGGER_CLIENT_ENDPOINTS
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(endpoints_exports);
|
|
26
|
+
var TRIGGER_CLIENT_ENDPOINTS = {
|
|
27
|
+
local: "http://localhost:80/trigger",
|
|
28
|
+
arbitrumTestnet: "https://trigger.sepolia-test.vertexprotocol.com/v1",
|
|
29
|
+
arbitrum: "https://trigger.prod.vertexprotocol.com/v1"
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
TRIGGER_CLIENT_ENDPOINTS
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=endpoints.cjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/endpoints.ts
|
|
2
|
+
var TRIGGER_CLIENT_ENDPOINTS = {
|
|
3
|
+
local: "http://localhost:80/trigger",
|
|
4
|
+
arbitrumTestnet: "https://trigger.sepolia-test.vertexprotocol.com/v1",
|
|
5
|
+
arbitrum: "https://trigger.prod.vertexprotocol.com/v1"
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
TRIGGER_CLIENT_ENDPOINTS
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +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":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/index.ts
|
|
18
|
+
var index_exports = {};
|
|
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
|
+
__reExport(index_exports, require("./endpoints.cjs"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./types/index.cjs"),
|
|
26
|
+
...require("./TriggerClient.cjs"),
|
|
27
|
+
...require("./endpoints.cjs")
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './types';\nexport * from './TriggerClient';\nexport * from './endpoints';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,8BAAd;AACA,0BAAc,gCADd;AAEA,0BAAc,4BAFd;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export { TRIGGER_CLIENT_ENDPOINTS } from './endpoints.cjs';
|
|
7
|
+
import '@nadohq/contracts';
|
|
8
|
+
import '@nadohq/engine-client';
|
|
9
|
+
import '@nadohq/utils';
|
|
10
|
+
import 'axios';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export { TRIGGER_CLIENT_ENDPOINTS } from './endpoints.js';
|
|
7
|
+
import '@nadohq/contracts';
|
|
8
|
+
import '@nadohq/engine-client';
|
|
9
|
+
import '@nadohq/utils';
|
|
10
|
+
import 'axios';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './types';\nexport * from './TriggerClient';\nexport * from './endpoints';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/types/TriggerServerFailureError.ts
|
|
21
|
+
var TriggerServerFailureError_exports = {};
|
|
22
|
+
__export(TriggerServerFailureError_exports, {
|
|
23
|
+
TriggerServerFailureError: () => TriggerServerFailureError
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(TriggerServerFailureError_exports);
|
|
26
|
+
var TriggerServerFailureError = class extends Error {
|
|
27
|
+
constructor(responseData) {
|
|
28
|
+
super();
|
|
29
|
+
this.responseData = responseData;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
TriggerServerFailureError
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=TriggerServerFailureError.cjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerServerQueryFailureResponse } from './serverQueryTypes.cjs';
|
|
2
|
+
import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';
|
|
3
|
+
import '@nadohq/contracts';
|
|
4
|
+
import './serverExecuteTypes.cjs';
|
|
5
|
+
|
|
6
|
+
declare class TriggerServerFailureError extends Error {
|
|
7
|
+
readonly responseData: TriggerServerQueryFailureResponse | EngineServerExecuteFailureResult;
|
|
8
|
+
constructor(responseData: TriggerServerQueryFailureResponse | EngineServerExecuteFailureResult);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { TriggerServerFailureError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerServerQueryFailureResponse } from './serverQueryTypes.js';
|
|
2
|
+
import { EngineServerExecuteFailureResult } from '@nadohq/engine-client';
|
|
3
|
+
import '@nadohq/contracts';
|
|
4
|
+
import './serverExecuteTypes.js';
|
|
5
|
+
|
|
6
|
+
declare class TriggerServerFailureError extends Error {
|
|
7
|
+
readonly responseData: TriggerServerQueryFailureResponse | EngineServerExecuteFailureResult;
|
|
8
|
+
constructor(responseData: TriggerServerQueryFailureResponse | EngineServerExecuteFailureResult);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { TriggerServerFailureError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/types/TriggerServerFailureError.ts
|
|
2
|
+
var TriggerServerFailureError = class extends Error {
|
|
3
|
+
constructor(responseData) {
|
|
4
|
+
super();
|
|
5
|
+
this.responseData = responseData;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
TriggerServerFailureError
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=TriggerServerFailureError.js.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -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/clientTypes.ts
|
|
17
|
+
var clientTypes_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(clientTypes_exports);
|
|
19
|
+
//# sourceMappingURL=clientTypes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n EIP712CancelOrdersParams,\n EIP712CancelProductOrdersParams,\n Subaccount,\n} from '@nadohq/contracts';\nimport {\n EngineOrderParams,\n EngineServerExecuteResult,\n} from '@nadohq/engine-client';\nimport { BigDecimal, BigDecimalish } from '@nadohq/utils';\nimport { TriggerServerOrder } from './serverQueryTypes';\n\ntype WithOptionalNonce<T> = Omit<T, 'nonce'> & { nonce?: string };\n\nexport type TriggerCriteriaType =\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 type TriggerCriteria = {\n type: TriggerCriteriaType;\n triggerPrice: BigDecimalish;\n};\n\nexport type TriggerOrderStatus =\n | {\n type: 'pending';\n }\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\ninterface SignatureParams {\n // Orderbook address for placement, endpoint address for cancellation & listing\n verifyingAddr: string;\n chainId: number;\n}\n\n/**\n * Executes\n */\n\nexport interface TriggerPlaceOrderParams extends SignatureParams {\n id?: number;\n productId: number;\n order: EngineOrderParams;\n triggerCriteria: TriggerCriteria;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spotLeverage?: boolean;\n digest?: string;\n nonce?: string;\n}\n\nexport type TriggerCancelOrdersParams = SignatureParams &\n WithOptionalNonce<EIP712CancelOrdersParams>;\n\nexport type TriggerCancelProductOrdersParams = SignatureParams &\n WithOptionalNonce<EIP712CancelProductOrdersParams>;\n\n/**\n * Queries\n */\n\nexport interface TriggerListOrdersParams extends Subaccount, SignatureParams {\n // In millis, defaults to 90s in the future\n recvTime?: BigDecimal;\n // If not given, defaults to all products\n productId?: number;\n // Pending trigger orders only, ignores cancelled & triggered orders\n pending: boolean;\n // In seconds\n maxUpdateTimeInclusive?: number;\n // When provided, the associated trigger orders are returned regardless of other filters\n digests?: string[];\n limit?: number;\n}\n\nexport interface TriggerOrder {\n productId: number;\n triggerCriteria: TriggerCriteria;\n price: BigDecimal;\n amount: BigDecimal;\n expiration: BigDecimal;\n nonce: string;\n digest: string;\n}\n\nexport interface TriggerOrderInfo {\n order: TriggerOrder;\n serverOrder: TriggerServerOrder;\n status: TriggerOrderStatus;\n updatedAt: number;\n}\n\nexport interface TriggerListOrdersResponse {\n orders: TriggerOrderInfo[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { EIP712CancelOrdersParams, EIP712CancelProductOrdersParams, Subaccount } from '@nadohq/contracts';
|
|
2
|
+
import { EngineOrderParams, EngineServerExecuteResult } from '@nadohq/engine-client';
|
|
3
|
+
import { BigDecimalish, BigDecimal } from '@nadohq/utils';
|
|
4
|
+
import { TriggerServerOrder } from './serverQueryTypes.cjs';
|
|
5
|
+
import './serverExecuteTypes.cjs';
|
|
6
|
+
|
|
7
|
+
type WithOptionalNonce<T> = Omit<T, 'nonce'> & {
|
|
8
|
+
nonce?: string;
|
|
9
|
+
};
|
|
10
|
+
type TriggerCriteriaType = 'oracle_price_above' | 'oracle_price_below' | 'last_price_above' | 'last_price_below' | 'mid_price_above' | 'mid_price_below';
|
|
11
|
+
type TriggerCriteria = {
|
|
12
|
+
type: TriggerCriteriaType;
|
|
13
|
+
triggerPrice: BigDecimalish;
|
|
14
|
+
};
|
|
15
|
+
type TriggerOrderStatus = {
|
|
16
|
+
type: 'pending';
|
|
17
|
+
} | {
|
|
18
|
+
type: 'cancelled';
|
|
19
|
+
reason: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'triggered';
|
|
22
|
+
result: EngineServerExecuteResult;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'internal_error';
|
|
25
|
+
error: string;
|
|
26
|
+
};
|
|
27
|
+
interface SignatureParams {
|
|
28
|
+
verifyingAddr: string;
|
|
29
|
+
chainId: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Executes
|
|
33
|
+
*/
|
|
34
|
+
interface TriggerPlaceOrderParams extends SignatureParams {
|
|
35
|
+
id?: number;
|
|
36
|
+
productId: number;
|
|
37
|
+
order: EngineOrderParams;
|
|
38
|
+
triggerCriteria: TriggerCriteria;
|
|
39
|
+
spotLeverage?: boolean;
|
|
40
|
+
digest?: string;
|
|
41
|
+
nonce?: string;
|
|
42
|
+
}
|
|
43
|
+
type TriggerCancelOrdersParams = SignatureParams & WithOptionalNonce<EIP712CancelOrdersParams>;
|
|
44
|
+
type TriggerCancelProductOrdersParams = SignatureParams & WithOptionalNonce<EIP712CancelProductOrdersParams>;
|
|
45
|
+
/**
|
|
46
|
+
* Queries
|
|
47
|
+
*/
|
|
48
|
+
interface TriggerListOrdersParams extends Subaccount, SignatureParams {
|
|
49
|
+
recvTime?: BigDecimal;
|
|
50
|
+
productId?: number;
|
|
51
|
+
pending: boolean;
|
|
52
|
+
maxUpdateTimeInclusive?: number;
|
|
53
|
+
digests?: string[];
|
|
54
|
+
limit?: number;
|
|
55
|
+
}
|
|
56
|
+
interface TriggerOrder {
|
|
57
|
+
productId: number;
|
|
58
|
+
triggerCriteria: TriggerCriteria;
|
|
59
|
+
price: BigDecimal;
|
|
60
|
+
amount: BigDecimal;
|
|
61
|
+
expiration: BigDecimal;
|
|
62
|
+
nonce: string;
|
|
63
|
+
digest: string;
|
|
64
|
+
}
|
|
65
|
+
interface TriggerOrderInfo {
|
|
66
|
+
order: TriggerOrder;
|
|
67
|
+
serverOrder: TriggerServerOrder;
|
|
68
|
+
status: TriggerOrderStatus;
|
|
69
|
+
updatedAt: number;
|
|
70
|
+
}
|
|
71
|
+
interface TriggerListOrdersResponse {
|
|
72
|
+
orders: TriggerOrderInfo[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerCriteria, TriggerCriteriaType, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerOrderStatus, TriggerPlaceOrderParams };
|