@nadohq/trigger-client 0.1.0-alpha.7 → 0.1.0-alpha.9
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 +18 -1
- package/dist/TriggerClient.cjs.map +1 -1
- package/dist/TriggerClient.d.cts +2 -1
- package/dist/TriggerClient.d.ts +2 -1
- package/dist/TriggerClient.js +23 -2
- package/dist/TriggerClient.js.map +1 -1
- package/dist/dataMappers.cjs +54 -8
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +4 -3
- package/dist/dataMappers.d.ts +4 -3
- package/dist/dataMappers.js +52 -7
- package/dist/dataMappers.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types/clientModelTypes.cjs.map +1 -1
- package/dist/types/clientModelTypes.d.cts +14 -2
- package/dist/types/clientModelTypes.d.ts +14 -2
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +29 -4
- package/dist/types/clientTypes.d.ts +29 -4
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +1 -1
- package/dist/types/serverModelTypes.d.ts +1 -1
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +43 -7
- package/dist/types/serverQueryTypes.d.ts +43 -7
- package/package.json +4 -4
- package/src/TriggerClient.ts +33 -2
- package/src/dataMappers.ts +55 -6
- package/src/types/clientModelTypes.ts +19 -3
- package/src/types/clientTypes.ts +41 -4
- package/src/types/serverModelTypes.ts +1 -1
- package/src/types/serverQueryTypes.ts +70 -9
|
@@ -1 +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: '
|
|
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":[]}
|
|
@@ -40,8 +40,6 @@ type TriggerCriteria = {
|
|
|
40
40
|
};
|
|
41
41
|
type TriggerCriteriaType = TriggerCriteria['type'];
|
|
42
42
|
type TriggerOrderStatus = {
|
|
43
|
-
type: 'pending';
|
|
44
|
-
} | {
|
|
45
43
|
type: 'cancelled';
|
|
46
44
|
reason: string;
|
|
47
45
|
} | {
|
|
@@ -50,6 +48,20 @@ type TriggerOrderStatus = {
|
|
|
50
48
|
} | {
|
|
51
49
|
type: 'internal_error';
|
|
52
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;
|
|
53
65
|
};
|
|
54
66
|
|
|
55
67
|
export type { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus };
|
|
@@ -40,8 +40,6 @@ type TriggerCriteria = {
|
|
|
40
40
|
};
|
|
41
41
|
type TriggerCriteriaType = TriggerCriteria['type'];
|
|
42
42
|
type TriggerOrderStatus = {
|
|
43
|
-
type: 'pending';
|
|
44
|
-
} | {
|
|
45
43
|
type: 'cancelled';
|
|
46
44
|
reason: string;
|
|
47
45
|
} | {
|
|
@@ -50,6 +48,20 @@ type TriggerOrderStatus = {
|
|
|
50
48
|
} | {
|
|
51
49
|
type: 'internal_error';
|
|
52
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;
|
|
53
65
|
};
|
|
54
66
|
|
|
55
67
|
export type { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"sources":["../../src/types/clientTypes.ts"],"sourcesContent":["import {\n EngineOrderParams,\n EngineServerExecuteResult,\n} from '@nadohq/engine-client';\nimport {\n BigDecimal,\n EIP712CancelOrdersParams,\n EIP712CancelProductOrdersParams,\n OrderAppendix,\n Subaccount,\n} from '@nadohq/shared';\nimport { TriggerCriteria, TriggerOrderStatus } from './clientModelTypes';\nimport {\n TriggerServerOrder,\n TriggerServerStatusTypeFilter,\n TriggerServerTriggerTypeFilter,\n} from './serverQueryTypes';\n\ntype WithOptionalNonce<T> = Omit<T, 'nonce'> & { nonce?: string };\n\ninterface SignatureParams {\n /**\n * Address derived from productId for placement (see getOrderVerifyingAddr)\n * endpoint address for cancellation & listing\n */\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 // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)\n borrowMargin?: 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 // 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 // Filter by status types\n statusTypes?: TriggerServerStatusTypeFilter[];\n // Filter by trigger types\n triggerTypes?: TriggerServerTriggerTypeFilter[];\n // Filter by reduce-only orders\n reduceOnly?: boolean;\n}\n\nexport interface TriggerOrder {\n productId: number;\n triggerCriteria: TriggerCriteria;\n price: BigDecimal;\n amount: BigDecimal;\n expiration: number;\n nonce: string;\n digest: string;\n appendix: OrderAppendix;\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\nexport interface TriggerListTwapExecutionsParams {\n digest: string;\n}\n\nexport type TwapExecutionStatus =\n | {\n type: 'pending';\n }\n | {\n type: 'executed';\n executedTime: number;\n executeResponse: EngineServerExecuteResult;\n }\n | {\n type: 'failed';\n error: string;\n }\n | {\n type: 'cancelled';\n reason: string;\n };\n\nexport interface TwapExecutionInfo {\n executionId: number;\n scheduledTime: number;\n status: TwapExecutionStatus;\n updatedAt: number;\n}\n\nexport interface TriggerListTwapExecutionsResponse {\n executions: TwapExecutionInfo[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { EngineOrderParams, EngineServerExecuteResult } from '@nadohq/engine-client';
|
|
1
2
|
import { EIP712CancelOrdersParams, EIP712CancelProductOrdersParams, Subaccount, BigDecimal, OrderAppendix } from '@nadohq/shared';
|
|
2
|
-
import { EngineOrderParams } from '@nadohq/engine-client';
|
|
3
3
|
import { TriggerCriteria, TriggerOrderStatus } from './clientModelTypes.cjs';
|
|
4
|
-
import { TriggerServerTriggerTypeFilter, TriggerServerOrder } from './serverQueryTypes.cjs';
|
|
4
|
+
import { TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerOrder } from './serverQueryTypes.cjs';
|
|
5
5
|
import './serverExecuteTypes.cjs';
|
|
6
6
|
import './serverModelTypes.cjs';
|
|
7
7
|
|
|
@@ -37,10 +37,10 @@ type TriggerCancelProductOrdersParams = SignatureParams & WithOptionalNonce<EIP7
|
|
|
37
37
|
interface TriggerListOrdersParams extends Subaccount, SignatureParams {
|
|
38
38
|
recvTime?: BigDecimal;
|
|
39
39
|
productId?: number;
|
|
40
|
-
pending: boolean;
|
|
41
40
|
maxUpdateTimeInclusive?: number;
|
|
42
41
|
digests?: string[];
|
|
43
42
|
limit?: number;
|
|
43
|
+
statusTypes?: TriggerServerStatusTypeFilter[];
|
|
44
44
|
triggerTypes?: TriggerServerTriggerTypeFilter[];
|
|
45
45
|
reduceOnly?: boolean;
|
|
46
46
|
}
|
|
@@ -63,5 +63,30 @@ interface TriggerOrderInfo {
|
|
|
63
63
|
interface TriggerListOrdersResponse {
|
|
64
64
|
orders: TriggerOrderInfo[];
|
|
65
65
|
}
|
|
66
|
+
interface TriggerListTwapExecutionsParams {
|
|
67
|
+
digest: string;
|
|
68
|
+
}
|
|
69
|
+
type TwapExecutionStatus = {
|
|
70
|
+
type: 'pending';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'executed';
|
|
73
|
+
executedTime: number;
|
|
74
|
+
executeResponse: EngineServerExecuteResult;
|
|
75
|
+
} | {
|
|
76
|
+
type: 'failed';
|
|
77
|
+
error: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'cancelled';
|
|
80
|
+
reason: string;
|
|
81
|
+
};
|
|
82
|
+
interface TwapExecutionInfo {
|
|
83
|
+
executionId: number;
|
|
84
|
+
scheduledTime: number;
|
|
85
|
+
status: TwapExecutionStatus;
|
|
86
|
+
updatedAt: number;
|
|
87
|
+
}
|
|
88
|
+
interface TriggerListTwapExecutionsResponse {
|
|
89
|
+
executions: TwapExecutionInfo[];
|
|
90
|
+
}
|
|
66
91
|
|
|
67
|
-
export type { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams };
|
|
92
|
+
export type { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TwapExecutionInfo, TwapExecutionStatus };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { EngineOrderParams, EngineServerExecuteResult } from '@nadohq/engine-client';
|
|
1
2
|
import { EIP712CancelOrdersParams, EIP712CancelProductOrdersParams, Subaccount, BigDecimal, OrderAppendix } from '@nadohq/shared';
|
|
2
|
-
import { EngineOrderParams } from '@nadohq/engine-client';
|
|
3
3
|
import { TriggerCriteria, TriggerOrderStatus } from './clientModelTypes.js';
|
|
4
|
-
import { TriggerServerTriggerTypeFilter, TriggerServerOrder } from './serverQueryTypes.js';
|
|
4
|
+
import { TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerOrder } from './serverQueryTypes.js';
|
|
5
5
|
import './serverExecuteTypes.js';
|
|
6
6
|
import './serverModelTypes.js';
|
|
7
7
|
|
|
@@ -37,10 +37,10 @@ type TriggerCancelProductOrdersParams = SignatureParams & WithOptionalNonce<EIP7
|
|
|
37
37
|
interface TriggerListOrdersParams extends Subaccount, SignatureParams {
|
|
38
38
|
recvTime?: BigDecimal;
|
|
39
39
|
productId?: number;
|
|
40
|
-
pending: boolean;
|
|
41
40
|
maxUpdateTimeInclusive?: number;
|
|
42
41
|
digests?: string[];
|
|
43
42
|
limit?: number;
|
|
43
|
+
statusTypes?: TriggerServerStatusTypeFilter[];
|
|
44
44
|
triggerTypes?: TriggerServerTriggerTypeFilter[];
|
|
45
45
|
reduceOnly?: boolean;
|
|
46
46
|
}
|
|
@@ -63,5 +63,30 @@ interface TriggerOrderInfo {
|
|
|
63
63
|
interface TriggerListOrdersResponse {
|
|
64
64
|
orders: TriggerOrderInfo[];
|
|
65
65
|
}
|
|
66
|
+
interface TriggerListTwapExecutionsParams {
|
|
67
|
+
digest: string;
|
|
68
|
+
}
|
|
69
|
+
type TwapExecutionStatus = {
|
|
70
|
+
type: 'pending';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'executed';
|
|
73
|
+
executedTime: number;
|
|
74
|
+
executeResponse: EngineServerExecuteResult;
|
|
75
|
+
} | {
|
|
76
|
+
type: 'failed';
|
|
77
|
+
error: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'cancelled';
|
|
80
|
+
reason: string;
|
|
81
|
+
};
|
|
82
|
+
interface TwapExecutionInfo {
|
|
83
|
+
executionId: number;
|
|
84
|
+
scheduledTime: number;
|
|
85
|
+
status: TwapExecutionStatus;
|
|
86
|
+
updatedAt: number;
|
|
87
|
+
}
|
|
88
|
+
interface TriggerListTwapExecutionsResponse {
|
|
89
|
+
executions: TwapExecutionInfo[];
|
|
90
|
+
}
|
|
66
91
|
|
|
67
|
-
export type { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams };
|
|
92
|
+
export type { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TwapExecutionInfo, TwapExecutionStatus };
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus } from './clientModelTypes.cjs';
|
|
2
|
-
export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams } from './clientTypes.cjs';
|
|
2
|
+
export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TwapExecutionInfo, TwapExecutionStatus } from './clientTypes.cjs';
|
|
3
3
|
export { TriggerServerDependency, TriggerServerPriceRequirement, TriggerServerPriceTriggerCriteria, TriggerServerTimeTriggerCriteria, TriggerServerTriggerCriteria } from './serverModelTypes.cjs';
|
|
4
4
|
export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams } from './serverExecuteTypes.cjs';
|
|
5
|
-
export { TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerTriggerTypeFilter } from './serverQueryTypes.cjs';
|
|
5
|
+
export { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse } from './serverQueryTypes.cjs';
|
|
6
6
|
export { TriggerServerFailureError } from './TriggerServerFailureError.cjs';
|
|
7
7
|
import '@nadohq/engine-client';
|
|
8
8
|
import '@nadohq/shared';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { PriceTriggerCriteria, PriceTriggerDependency, PriceTriggerRequirementType, TimeTriggerCriteria, TriggerCriteria, TriggerCriteriaType, TriggerOrderStatus } from './clientModelTypes.js';
|
|
2
|
-
export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams } from './clientTypes.js';
|
|
2
|
+
export { TriggerCancelOrdersParams, TriggerCancelProductOrdersParams, TriggerListOrdersParams, TriggerListOrdersResponse, TriggerListTwapExecutionsParams, TriggerListTwapExecutionsResponse, TriggerOrder, TriggerOrderInfo, TriggerPlaceOrderParams, TwapExecutionInfo, TwapExecutionStatus } from './clientTypes.js';
|
|
3
3
|
export { TriggerServerDependency, TriggerServerPriceRequirement, TriggerServerPriceTriggerCriteria, TriggerServerTimeTriggerCriteria, TriggerServerTriggerCriteria } from './serverModelTypes.js';
|
|
4
4
|
export { TriggerServerCancelOrdersParams, TriggerServerCancelProductOrdersParams, TriggerServerExecuteRequestByType, TriggerServerExecuteRequestType, TriggerServerExecuteResult, TriggerServerExecuteSuccessResult, TriggerServerPlaceOrderParams } from './serverExecuteTypes.js';
|
|
5
|
-
export { TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerTriggerTypeFilter } from './serverQueryTypes.js';
|
|
5
|
+
export { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse } from './serverQueryTypes.js';
|
|
6
6
|
export { TriggerServerFailureError } from './TriggerServerFailureError.js';
|
|
7
7
|
import '@nadohq/engine-client';
|
|
8
8
|
import '@nadohq/shared';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["export interface TriggerServerDependency {\n digest: string;\n /**\n * Whether to trigger on partial fills.\n */\n on_partial_fill: boolean;\n}\n\nexport type TriggerServerPriceRequirement =\n // These trigger on fast oracle price\n | {\n oracle_price_above: string;\n }\n | {\n oracle_price_below: string;\n }\n // These trigger on last trade price\n | {\n last_price_above: string;\n }\n | {\n last_price_below: string;\n }\n // These trigger on mid-book price\n | {\n mid_price_above: string;\n }\n | {\n mid_price_below: string;\n };\n\nexport interface TriggerServerPriceTriggerCriteria {\n price_requirement: TriggerServerPriceRequirement;\n dependency?: TriggerServerDependency;\n}\n\nexport interface TriggerServerTimeTriggerCriteria {\n /**\n * Trigger interval in seconds\n */\n interval:
|
|
1
|
+
{"version":3,"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["export interface TriggerServerDependency {\n digest: string;\n /**\n * Whether to trigger on partial fills.\n */\n on_partial_fill: boolean;\n}\n\nexport type TriggerServerPriceRequirement =\n // These trigger on fast oracle price\n | {\n oracle_price_above: string;\n }\n | {\n oracle_price_below: string;\n }\n // These trigger on last trade price\n | {\n last_price_above: string;\n }\n | {\n last_price_below: string;\n }\n // These trigger on mid-book price\n | {\n mid_price_above: string;\n }\n | {\n mid_price_below: string;\n };\n\nexport interface TriggerServerPriceTriggerCriteria {\n price_requirement: TriggerServerPriceRequirement;\n dependency?: TriggerServerDependency;\n}\n\nexport interface TriggerServerTimeTriggerCriteria {\n /**\n * Trigger interval in seconds\n */\n interval: number;\n /**\n * 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?: string[];\n}\n\nexport type TriggerServerTriggerCriteria =\n | {\n price_trigger: TriggerServerPriceTriggerCriteria;\n }\n | {\n time_trigger: TriggerServerTimeTriggerCriteria;\n };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -26,7 +26,7 @@ interface TriggerServerTimeTriggerCriteria {
|
|
|
26
26
|
/**
|
|
27
27
|
* Trigger interval in seconds
|
|
28
28
|
*/
|
|
29
|
-
interval:
|
|
29
|
+
interval: number;
|
|
30
30
|
/**
|
|
31
31
|
* By default, trigger service will split up orders as per total amount / interval
|
|
32
32
|
* If you want to specify the amounts for each interval, you can provide them here.
|
|
@@ -26,7 +26,7 @@ interface TriggerServerTimeTriggerCriteria {
|
|
|
26
26
|
/**
|
|
27
27
|
* Trigger interval in seconds
|
|
28
28
|
*/
|
|
29
|
-
interval:
|
|
29
|
+
interval: number;
|
|
30
30
|
/**
|
|
31
31
|
* By default, trigger service will split up orders as per total amount / interval
|
|
32
32
|
* If you want to specify the amounts for each interval, you can provide them here.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { EngineServerExecuteResult } from '@nadohq/engine-client';\nimport { EIP712ListTriggerOrdersValues, SignedTx } from '@nadohq/shared';\nimport { TriggerServerPlaceOrderParams } from './serverExecuteTypes';\n\nexport type TriggerServerOrderStatus =\n | {\n cancelled: TriggerServerCancelReason;\n }\n | {\n triggered: EngineServerExecuteResult;\n }\n | {\n internal_error: string;\n }\n | 'triggering'\n | 'waiting_price'\n | 'waiting_dependency'\n | {\n twap_executing: {\n current_execution: number;\n total_executions: number;\n };\n }\n | {\n twap_completed: {\n executed: number;\n total: number;\n };\n };\n\n/**\n * Request types\n */\n\nexport type TriggerServerTriggerTypeFilter = 'price_trigger' | 'time_trigger';\n\nexport type TriggerServerStatusTypeFilter =\n | 'cancelled'\n | 'triggered'\n | 'internal_error'\n | 'triggering'\n | 'waiting_price'\n | 'waiting_dependency'\n | 'twap_executing'\n | 'twap_completed';\n\nexport interface TriggerServerListTriggerOrdersParams\n extends SignedTx<EIP712ListTriggerOrdersValues> {\n // If not given, defaults to all products\n product_id?: number;\n max_update_time?: number;\n digests?: string[];\n limit?: number;\n trigger_types?: TriggerServerTriggerTypeFilter[];\n status_types?: TriggerServerStatusTypeFilter[];\n reduce_only?: boolean;\n}\n\nexport interface TriggerServerListTwapExecutionsParams {\n digest: string;\n}\n\nexport interface TriggerServerQueryRequestByType {\n list_trigger_orders: TriggerServerListTriggerOrdersParams;\n list_twap_executions: TriggerServerListTwapExecutionsParams;\n}\n\nexport type TriggerServerQueryRequestType =\n keyof TriggerServerQueryRequestByType;\n\n/**\n * Response types\n */\n\nexport type TriggerServerOrder = TriggerServerPlaceOrderParams & {\n // Digest is always populated here\n digest: string;\n};\n\nexport interface TriggerServerOrderInfo {\n order: TriggerServerOrder;\n status: TriggerServerOrderStatus;\n updated_at: number;\n}\n\nexport interface TriggerServerListTriggerOrdersResponse {\n orders: TriggerServerOrderInfo[];\n}\n\nexport type TriggerServerCancelReason =\n | 'user_requested'\n | 'linked_signer_changed'\n | 'expired'\n | 'account_health'\n | 'isolated_subaccount_closed'\n | 'dependent_order_cancelled';\n\nexport type TriggerServerTwapExecutionStatus =\n | 'pending'\n | {\n executed: {\n executed_time: number;\n execute_response: EngineServerExecuteResult;\n };\n }\n | {\n failed: string;\n }\n | {\n cancelled: TriggerServerCancelReason;\n };\n\nexport interface TriggerServerTwapExecutionInfo {\n execution_id: number;\n scheduled_time: number;\n status: TriggerServerTwapExecutionStatus;\n updated_at: number;\n}\n\nexport interface TriggerServerTwapExecutionsResponse {\n executions: TriggerServerTwapExecutionInfo[];\n}\n\nexport interface TriggerServerQueryResponseByType {\n list_trigger_orders: TriggerServerListTriggerOrdersResponse;\n list_twap_executions: TriggerServerTwapExecutionsResponse;\n}\n\nexport interface TriggerServerQuerySuccessResponse<\n TQueryType extends\n keyof TriggerServerQueryResponseByType = TriggerServerQueryRequestType,\n> {\n status: 'success';\n data: TriggerServerQueryResponseByType[TQueryType];\n}\n\nexport interface TriggerServerQueryFailureResponse {\n status: 'failure';\n error: string;\n error_code: number;\n}\n\nexport type TriggerServerQueryResponse<\n TQueryType extends\n keyof TriggerServerQueryResponseByType = TriggerServerQueryRequestType,\n> =\n | TriggerServerQuerySuccessResponse<TQueryType>\n | TriggerServerQueryFailureResponse;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
import { SignedTx, EIP712ListTriggerOrdersValues } from '@nadohq/shared';
|
|
2
1
|
import { EngineServerExecuteResult } from '@nadohq/engine-client';
|
|
2
|
+
import { SignedTx, EIP712ListTriggerOrdersValues } from '@nadohq/shared';
|
|
3
3
|
import { TriggerServerPlaceOrderParams } from './serverExecuteTypes.cjs';
|
|
4
4
|
import './serverModelTypes.cjs';
|
|
5
5
|
|
|
6
|
-
type TriggerServerOrderStatus =
|
|
7
|
-
|
|
6
|
+
type TriggerServerOrderStatus = {
|
|
7
|
+
cancelled: TriggerServerCancelReason;
|
|
8
8
|
} | {
|
|
9
|
-
|
|
9
|
+
triggered: EngineServerExecuteResult;
|
|
10
10
|
} | {
|
|
11
11
|
internal_error: string;
|
|
12
|
+
} | 'triggering' | 'waiting_price' | 'waiting_dependency' | {
|
|
13
|
+
twap_executing: {
|
|
14
|
+
current_execution: number;
|
|
15
|
+
total_executions: number;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
twap_completed: {
|
|
19
|
+
executed: number;
|
|
20
|
+
total: number;
|
|
21
|
+
};
|
|
12
22
|
};
|
|
13
23
|
/**
|
|
14
24
|
* Request types
|
|
15
25
|
*/
|
|
16
|
-
type TriggerServerTriggerTypeFilter = 'price_trigger' | '
|
|
26
|
+
type TriggerServerTriggerTypeFilter = 'price_trigger' | 'time_trigger';
|
|
27
|
+
type TriggerServerStatusTypeFilter = 'cancelled' | 'triggered' | 'internal_error' | 'triggering' | 'waiting_price' | 'waiting_dependency' | 'twap_executing' | 'twap_completed';
|
|
17
28
|
interface TriggerServerListTriggerOrdersParams extends SignedTx<EIP712ListTriggerOrdersValues> {
|
|
18
|
-
pending: boolean;
|
|
19
29
|
product_id?: number;
|
|
20
30
|
max_update_time?: number;
|
|
21
31
|
digests?: string[];
|
|
22
32
|
limit?: number;
|
|
23
33
|
trigger_types?: TriggerServerTriggerTypeFilter[];
|
|
34
|
+
status_types?: TriggerServerStatusTypeFilter[];
|
|
24
35
|
reduce_only?: boolean;
|
|
25
36
|
}
|
|
37
|
+
interface TriggerServerListTwapExecutionsParams {
|
|
38
|
+
digest: string;
|
|
39
|
+
}
|
|
26
40
|
interface TriggerServerQueryRequestByType {
|
|
27
41
|
list_trigger_orders: TriggerServerListTriggerOrdersParams;
|
|
42
|
+
list_twap_executions: TriggerServerListTwapExecutionsParams;
|
|
28
43
|
}
|
|
29
44
|
type TriggerServerQueryRequestType = keyof TriggerServerQueryRequestByType;
|
|
30
45
|
/**
|
|
@@ -41,8 +56,29 @@ interface TriggerServerOrderInfo {
|
|
|
41
56
|
interface TriggerServerListTriggerOrdersResponse {
|
|
42
57
|
orders: TriggerServerOrderInfo[];
|
|
43
58
|
}
|
|
59
|
+
type TriggerServerCancelReason = 'user_requested' | 'linked_signer_changed' | 'expired' | 'account_health' | 'isolated_subaccount_closed' | 'dependent_order_cancelled';
|
|
60
|
+
type TriggerServerTwapExecutionStatus = 'pending' | {
|
|
61
|
+
executed: {
|
|
62
|
+
executed_time: number;
|
|
63
|
+
execute_response: EngineServerExecuteResult;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
failed: string;
|
|
67
|
+
} | {
|
|
68
|
+
cancelled: TriggerServerCancelReason;
|
|
69
|
+
};
|
|
70
|
+
interface TriggerServerTwapExecutionInfo {
|
|
71
|
+
execution_id: number;
|
|
72
|
+
scheduled_time: number;
|
|
73
|
+
status: TriggerServerTwapExecutionStatus;
|
|
74
|
+
updated_at: number;
|
|
75
|
+
}
|
|
76
|
+
interface TriggerServerTwapExecutionsResponse {
|
|
77
|
+
executions: TriggerServerTwapExecutionInfo[];
|
|
78
|
+
}
|
|
44
79
|
interface TriggerServerQueryResponseByType {
|
|
45
80
|
list_trigger_orders: TriggerServerListTriggerOrdersResponse;
|
|
81
|
+
list_twap_executions: TriggerServerTwapExecutionsResponse;
|
|
46
82
|
}
|
|
47
83
|
interface TriggerServerQuerySuccessResponse<TQueryType extends keyof TriggerServerQueryResponseByType = TriggerServerQueryRequestType> {
|
|
48
84
|
status: 'success';
|
|
@@ -55,4 +91,4 @@ interface TriggerServerQueryFailureResponse {
|
|
|
55
91
|
}
|
|
56
92
|
type TriggerServerQueryResponse<TQueryType extends keyof TriggerServerQueryResponseByType = TriggerServerQueryRequestType> = TriggerServerQuerySuccessResponse<TQueryType> | TriggerServerQueryFailureResponse;
|
|
57
93
|
|
|
58
|
-
export type { TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerTriggerTypeFilter };
|
|
94
|
+
export type { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse };
|
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
import { SignedTx, EIP712ListTriggerOrdersValues } from '@nadohq/shared';
|
|
2
1
|
import { EngineServerExecuteResult } from '@nadohq/engine-client';
|
|
2
|
+
import { SignedTx, EIP712ListTriggerOrdersValues } from '@nadohq/shared';
|
|
3
3
|
import { TriggerServerPlaceOrderParams } from './serverExecuteTypes.js';
|
|
4
4
|
import './serverModelTypes.js';
|
|
5
5
|
|
|
6
|
-
type TriggerServerOrderStatus =
|
|
7
|
-
|
|
6
|
+
type TriggerServerOrderStatus = {
|
|
7
|
+
cancelled: TriggerServerCancelReason;
|
|
8
8
|
} | {
|
|
9
|
-
|
|
9
|
+
triggered: EngineServerExecuteResult;
|
|
10
10
|
} | {
|
|
11
11
|
internal_error: string;
|
|
12
|
+
} | 'triggering' | 'waiting_price' | 'waiting_dependency' | {
|
|
13
|
+
twap_executing: {
|
|
14
|
+
current_execution: number;
|
|
15
|
+
total_executions: number;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
twap_completed: {
|
|
19
|
+
executed: number;
|
|
20
|
+
total: number;
|
|
21
|
+
};
|
|
12
22
|
};
|
|
13
23
|
/**
|
|
14
24
|
* Request types
|
|
15
25
|
*/
|
|
16
|
-
type TriggerServerTriggerTypeFilter = 'price_trigger' | '
|
|
26
|
+
type TriggerServerTriggerTypeFilter = 'price_trigger' | 'time_trigger';
|
|
27
|
+
type TriggerServerStatusTypeFilter = 'cancelled' | 'triggered' | 'internal_error' | 'triggering' | 'waiting_price' | 'waiting_dependency' | 'twap_executing' | 'twap_completed';
|
|
17
28
|
interface TriggerServerListTriggerOrdersParams extends SignedTx<EIP712ListTriggerOrdersValues> {
|
|
18
|
-
pending: boolean;
|
|
19
29
|
product_id?: number;
|
|
20
30
|
max_update_time?: number;
|
|
21
31
|
digests?: string[];
|
|
22
32
|
limit?: number;
|
|
23
33
|
trigger_types?: TriggerServerTriggerTypeFilter[];
|
|
34
|
+
status_types?: TriggerServerStatusTypeFilter[];
|
|
24
35
|
reduce_only?: boolean;
|
|
25
36
|
}
|
|
37
|
+
interface TriggerServerListTwapExecutionsParams {
|
|
38
|
+
digest: string;
|
|
39
|
+
}
|
|
26
40
|
interface TriggerServerQueryRequestByType {
|
|
27
41
|
list_trigger_orders: TriggerServerListTriggerOrdersParams;
|
|
42
|
+
list_twap_executions: TriggerServerListTwapExecutionsParams;
|
|
28
43
|
}
|
|
29
44
|
type TriggerServerQueryRequestType = keyof TriggerServerQueryRequestByType;
|
|
30
45
|
/**
|
|
@@ -41,8 +56,29 @@ interface TriggerServerOrderInfo {
|
|
|
41
56
|
interface TriggerServerListTriggerOrdersResponse {
|
|
42
57
|
orders: TriggerServerOrderInfo[];
|
|
43
58
|
}
|
|
59
|
+
type TriggerServerCancelReason = 'user_requested' | 'linked_signer_changed' | 'expired' | 'account_health' | 'isolated_subaccount_closed' | 'dependent_order_cancelled';
|
|
60
|
+
type TriggerServerTwapExecutionStatus = 'pending' | {
|
|
61
|
+
executed: {
|
|
62
|
+
executed_time: number;
|
|
63
|
+
execute_response: EngineServerExecuteResult;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
failed: string;
|
|
67
|
+
} | {
|
|
68
|
+
cancelled: TriggerServerCancelReason;
|
|
69
|
+
};
|
|
70
|
+
interface TriggerServerTwapExecutionInfo {
|
|
71
|
+
execution_id: number;
|
|
72
|
+
scheduled_time: number;
|
|
73
|
+
status: TriggerServerTwapExecutionStatus;
|
|
74
|
+
updated_at: number;
|
|
75
|
+
}
|
|
76
|
+
interface TriggerServerTwapExecutionsResponse {
|
|
77
|
+
executions: TriggerServerTwapExecutionInfo[];
|
|
78
|
+
}
|
|
44
79
|
interface TriggerServerQueryResponseByType {
|
|
45
80
|
list_trigger_orders: TriggerServerListTriggerOrdersResponse;
|
|
81
|
+
list_twap_executions: TriggerServerTwapExecutionsResponse;
|
|
46
82
|
}
|
|
47
83
|
interface TriggerServerQuerySuccessResponse<TQueryType extends keyof TriggerServerQueryResponseByType = TriggerServerQueryRequestType> {
|
|
48
84
|
status: 'success';
|
|
@@ -55,4 +91,4 @@ interface TriggerServerQueryFailureResponse {
|
|
|
55
91
|
}
|
|
56
92
|
type TriggerServerQueryResponse<TQueryType extends keyof TriggerServerQueryResponseByType = TriggerServerQueryRequestType> = TriggerServerQuerySuccessResponse<TQueryType> | TriggerServerQueryFailureResponse;
|
|
57
93
|
|
|
58
|
-
export type { TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerTriggerTypeFilter };
|
|
94
|
+
export type { TriggerServerCancelReason, TriggerServerListTriggerOrdersParams, TriggerServerListTriggerOrdersResponse, TriggerServerListTwapExecutionsParams, TriggerServerOrder, TriggerServerOrderInfo, TriggerServerOrderStatus, TriggerServerQueryFailureResponse, TriggerServerQueryRequestByType, TriggerServerQueryRequestType, TriggerServerQueryResponse, TriggerServerQueryResponseByType, TriggerServerQuerySuccessResponse, TriggerServerStatusTypeFilter, TriggerServerTriggerTypeFilter, TriggerServerTwapExecutionInfo, TriggerServerTwapExecutionStatus, TriggerServerTwapExecutionsResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/trigger-client",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "> TODO: description",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nadohq/engine-client": "^0.1.0-alpha.
|
|
41
|
-
"@nadohq/shared": "^0.1.0-alpha.
|
|
40
|
+
"@nadohq/engine-client": "^0.1.0-alpha.9",
|
|
41
|
+
"@nadohq/shared": "^0.1.0-alpha.9",
|
|
42
42
|
"axios": "*",
|
|
43
43
|
"ts-mixer": "*"
|
|
44
44
|
},
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"viem": "*"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "aa99daac81aaf29696ecdbdb45276145823e0ac7"
|
|
52
52
|
}
|
package/src/TriggerClient.ts
CHANGED
|
@@ -14,12 +14,18 @@ import {
|
|
|
14
14
|
WalletNotProvidedError,
|
|
15
15
|
} from '@nadohq/shared';
|
|
16
16
|
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
mapServerOrderInfo,
|
|
19
|
+
mapTriggerCriteria,
|
|
20
|
+
mapTwapExecutionStatus,
|
|
21
|
+
} from './dataMappers';
|
|
18
22
|
import {
|
|
19
23
|
TriggerCancelOrdersParams,
|
|
20
24
|
TriggerCancelProductOrdersParams,
|
|
21
25
|
TriggerListOrdersParams,
|
|
22
26
|
TriggerListOrdersResponse,
|
|
27
|
+
TriggerListTwapExecutionsParams,
|
|
28
|
+
TriggerListTwapExecutionsResponse,
|
|
23
29
|
TriggerOrderInfo,
|
|
24
30
|
TriggerPlaceOrderParams,
|
|
25
31
|
TriggerServerExecuteRequestByType,
|
|
@@ -31,6 +37,7 @@ import {
|
|
|
31
37
|
TriggerServerQueryResponse,
|
|
32
38
|
TriggerServerQueryResponseByType,
|
|
33
39
|
TriggerServerQuerySuccessResponse,
|
|
40
|
+
TwapExecutionInfo,
|
|
34
41
|
} from './types';
|
|
35
42
|
import { TriggerServerFailureError } from './types/TriggerServerFailureError';
|
|
36
43
|
|
|
@@ -179,7 +186,7 @@ export class TriggerClient {
|
|
|
179
186
|
{
|
|
180
187
|
limit: params.limit,
|
|
181
188
|
max_update_time: params.maxUpdateTimeInclusive,
|
|
182
|
-
|
|
189
|
+
status_types: params.statusTypes,
|
|
183
190
|
product_id: params.productId,
|
|
184
191
|
digests: params.digests,
|
|
185
192
|
trigger_types: params.triggerTypes,
|
|
@@ -198,6 +205,30 @@ export class TriggerClient {
|
|
|
198
205
|
};
|
|
199
206
|
}
|
|
200
207
|
|
|
208
|
+
async listTwapExecutions(
|
|
209
|
+
params: TriggerListTwapExecutionsParams,
|
|
210
|
+
): Promise<TriggerListTwapExecutionsResponse> {
|
|
211
|
+
const queryParams: TriggerServerQueryRequestByType['list_twap_executions'] =
|
|
212
|
+
{
|
|
213
|
+
digest: params.digest,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const baseResponse = await this.query('list_twap_executions', queryParams);
|
|
217
|
+
|
|
218
|
+
const executions: TwapExecutionInfo[] = baseResponse.executions.map(
|
|
219
|
+
(execution) => ({
|
|
220
|
+
executionId: execution.execution_id,
|
|
221
|
+
scheduledTime: execution.scheduled_time,
|
|
222
|
+
status: mapTwapExecutionStatus(execution.status),
|
|
223
|
+
updatedAt: execution.updated_at,
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
executions,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
201
232
|
/*
|
|
202
233
|
Base Fns
|
|
203
234
|
*/
|
package/src/dataMappers.ts
CHANGED
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
TriggerServerPriceTriggerCriteria,
|
|
20
20
|
TriggerServerTimeTriggerCriteria,
|
|
21
21
|
TriggerServerTriggerCriteria,
|
|
22
|
+
TriggerServerTwapExecutionStatus,
|
|
23
|
+
TwapExecutionStatus,
|
|
22
24
|
} from './types';
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -81,7 +83,7 @@ function mapTimeTriggerCriteria(
|
|
|
81
83
|
criteria: TimeTriggerCriteria,
|
|
82
84
|
): TriggerServerTimeTriggerCriteria {
|
|
83
85
|
return {
|
|
84
|
-
interval:
|
|
86
|
+
interval: Number(criteria.interval),
|
|
85
87
|
amounts: criteria.amounts?.map((amount) => toIntegerString(amount)),
|
|
86
88
|
};
|
|
87
89
|
}
|
|
@@ -117,24 +119,44 @@ export function mapServerOrderInfo(
|
|
|
117
119
|
function mapTriggerServerOrderStatus(
|
|
118
120
|
status: TriggerServerOrderStatus,
|
|
119
121
|
): TriggerOrderStatus {
|
|
120
|
-
if (status === '
|
|
122
|
+
if (status === 'triggering') {
|
|
121
123
|
return {
|
|
122
|
-
type: '
|
|
124
|
+
type: 'triggering',
|
|
125
|
+
};
|
|
126
|
+
} else if (status === 'waiting_price') {
|
|
127
|
+
return {
|
|
128
|
+
type: 'waiting_price',
|
|
129
|
+
};
|
|
130
|
+
} else if (status === 'waiting_dependency') {
|
|
131
|
+
return {
|
|
132
|
+
type: 'waiting_dependency',
|
|
123
133
|
};
|
|
124
134
|
} else if ('cancelled' in status) {
|
|
125
135
|
return {
|
|
126
136
|
type: 'cancelled',
|
|
127
137
|
reason: status.cancelled,
|
|
128
138
|
};
|
|
139
|
+
} else if ('triggered' in status) {
|
|
140
|
+
return {
|
|
141
|
+
type: 'triggered',
|
|
142
|
+
result: status.triggered,
|
|
143
|
+
};
|
|
129
144
|
} else if ('internal_error' in status) {
|
|
130
145
|
return {
|
|
131
146
|
type: 'internal_error',
|
|
132
147
|
error: status.internal_error,
|
|
133
148
|
};
|
|
134
|
-
} else if ('
|
|
149
|
+
} else if ('twap_executing' in status) {
|
|
135
150
|
return {
|
|
136
|
-
type: '
|
|
137
|
-
|
|
151
|
+
type: 'twap_executing',
|
|
152
|
+
currentExecution: status.twap_executing.current_execution,
|
|
153
|
+
totalExecutions: status.twap_executing.total_executions,
|
|
154
|
+
};
|
|
155
|
+
} else if ('twap_completed' in status) {
|
|
156
|
+
return {
|
|
157
|
+
type: 'twap_completed',
|
|
158
|
+
executed: status.twap_completed.executed,
|
|
159
|
+
total: status.twap_completed.total,
|
|
138
160
|
};
|
|
139
161
|
}
|
|
140
162
|
throw Error(`Unknown trigger order status: ${JSON.stringify(status)}`);
|
|
@@ -226,3 +248,30 @@ function mapServerTimeTriggerCriteria(
|
|
|
226
248
|
),
|
|
227
249
|
};
|
|
228
250
|
}
|
|
251
|
+
|
|
252
|
+
export function mapTwapExecutionStatus(
|
|
253
|
+
status: TriggerServerTwapExecutionStatus,
|
|
254
|
+
): TwapExecutionStatus {
|
|
255
|
+
if (status === 'pending') {
|
|
256
|
+
return {
|
|
257
|
+
type: 'pending',
|
|
258
|
+
};
|
|
259
|
+
} else if ('executed' in status) {
|
|
260
|
+
return {
|
|
261
|
+
type: 'executed',
|
|
262
|
+
executedTime: status.executed.executed_time,
|
|
263
|
+
executeResponse: status.executed.execute_response,
|
|
264
|
+
};
|
|
265
|
+
} else if ('failed' in status) {
|
|
266
|
+
return {
|
|
267
|
+
type: 'failed',
|
|
268
|
+
error: status.failed,
|
|
269
|
+
};
|
|
270
|
+
} else if ('cancelled' in status) {
|
|
271
|
+
return {
|
|
272
|
+
type: 'cancelled',
|
|
273
|
+
reason: status.cancelled,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
throw Error(`Unknown TWAP execution status: ${JSON.stringify(status)}`);
|
|
277
|
+
}
|