@dhedge/backend-flatcoin-core 0.2.31 → 0.2.33
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/entity/order-execution.d.ts +7 -0
- package/dist/entity/order-execution.js +40 -0
- package/dist/repository/order-execution.repository.d.ts +9 -0
- package/dist/repository/order-execution.repository.js +39 -0
- package/dist/service/graph-query.service.d.ts +13 -1
- package/dist/service/graph-query.service.js +144 -3
- package/dist/utils/shared-types.d.ts +24 -0
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrderExecution = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
let OrderExecution = class OrderExecution {
|
|
16
|
+
};
|
|
17
|
+
exports.OrderExecution = OrderExecution;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], OrderExecution.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'tx_hash' }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], OrderExecution.prototype, "txHash", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'executor_address' }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], OrderExecution.prototype, "executorAddress", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'type', nullable: false }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], OrderExecution.prototype, "type", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'executed_at', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], OrderExecution.prototype, "executedAt", void 0);
|
|
38
|
+
exports.OrderExecution = OrderExecution = __decorate([
|
|
39
|
+
(0, typeorm_1.Entity)({ name: 'order-executions' })
|
|
40
|
+
], OrderExecution);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { OrderExecution } from '../entity/order-execution';
|
|
3
|
+
export declare class OrderExecutionRepository {
|
|
4
|
+
private repository;
|
|
5
|
+
constructor(repository: Repository<OrderExecution>);
|
|
6
|
+
save(orderExecution: OrderExecution): Promise<OrderExecution>;
|
|
7
|
+
saveAll(orderExecutions: OrderExecution[]): Promise<OrderExecution[]>;
|
|
8
|
+
getLatestRecord(): Promise<OrderExecution | null>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OrderExecutionRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const order_execution_1 = require("../entity/order-execution");
|
|
20
|
+
let OrderExecutionRepository = class OrderExecutionRepository {
|
|
21
|
+
constructor(repository) {
|
|
22
|
+
this.repository = repository;
|
|
23
|
+
}
|
|
24
|
+
async save(orderExecution) {
|
|
25
|
+
return this.repository.save(orderExecution);
|
|
26
|
+
}
|
|
27
|
+
async saveAll(orderExecutions) {
|
|
28
|
+
return this.repository.save(orderExecutions);
|
|
29
|
+
}
|
|
30
|
+
async getLatestRecord() {
|
|
31
|
+
return this.repository.createQueryBuilder().orderBy('executedAt', 'DESC').limit(1).getOne();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.OrderExecutionRepository = OrderExecutionRepository;
|
|
35
|
+
exports.OrderExecutionRepository = OrderExecutionRepository = __decorate([
|
|
36
|
+
(0, common_1.Injectable)(),
|
|
37
|
+
__param(0, (0, typeorm_1.InjectRepository)(order_execution_1.OrderExecution)),
|
|
38
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
39
|
+
], OrderExecutionRepository);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
|
-
import { AnnouncedLimitOrder, AnnouncedOrder, DepositEvent, LeveragePositionEvent, Position, WithdrawEvent } from '../utils';
|
|
2
|
+
import { AnnouncedLimitOrder, AnnouncedOrder, DepositEvent, LeverageAdjust, LeveragePositionEvent, Position, WithdrawEvent } from '../utils';
|
|
3
3
|
import { GraphQLClient } from 'graphql-request';
|
|
4
4
|
export declare class GraphQueryService {
|
|
5
5
|
private readonly graphQLClient;
|
|
@@ -7,25 +7,37 @@ export declare class GraphQueryService {
|
|
|
7
7
|
constructor(graphQLClient: GraphQLClient, logger: Logger);
|
|
8
8
|
getAnnouncedOrders(timestampFrom: number): Promise<AnnouncedOrder[]>;
|
|
9
9
|
getLeverageOpens(blockFrom: number): Promise<LeveragePositionEvent[]>;
|
|
10
|
+
getLeverageOpensByTimestampFrom(timestampFrom: number): Promise<LeveragePositionEvent[]>;
|
|
10
11
|
getLeverageCloses(blockFrom: number): Promise<LeveragePositionEvent[]>;
|
|
12
|
+
getLeverageClosesByTimestampFrom(timestampFrom: number): Promise<LeveragePositionEvent[]>;
|
|
13
|
+
getLeverageAdjustsByTimestampFrom(timestampFrom: number): Promise<LeverageAdjust[]>;
|
|
11
14
|
getPositionLiquidateds(blockFrom: number): Promise<LeveragePositionEvent[]>;
|
|
12
15
|
getDeposits(blockFrom: number): Promise<DepositEvent[]>;
|
|
16
|
+
getDepositsByTimestampFrom(timestampFrom: number): Promise<DepositEvent[]>;
|
|
13
17
|
getDepositsByDepositorAddress(account: string, blockFrom: number): Promise<DepositEvent[]>;
|
|
14
18
|
getWithdraws(blockFrom: number): Promise<WithdrawEvent[]>;
|
|
19
|
+
getWithdrawsByTimestampFrom(timestampFrom: number): Promise<WithdrawEvent[]>;
|
|
15
20
|
getWithdrawsByWithdrawerAddress(account: string, blockFrom: number): Promise<WithdrawEvent[]>;
|
|
16
21
|
getLimitOrderAnnounceds(blockNumberFrom: number): Promise<AnnouncedLimitOrder[]>;
|
|
22
|
+
getLimitOrderExecutedsByTimestampFrom(timestampFrom: number): Promise<LeverageAdjust[]>;
|
|
17
23
|
getAllOpenPositions(): Promise<Position[]>;
|
|
18
24
|
getOpenPositions(skip: number, first: number): Promise<Position[]>;
|
|
19
25
|
getClosedPositions(closeTimestampVar: number): Promise<Position[]>;
|
|
20
26
|
}
|
|
21
27
|
export declare const getAnnouncedOrdersQuery: string;
|
|
22
28
|
export declare const getLeverageOpensQuery: string;
|
|
29
|
+
export declare const getLeverageOpensByTimestampFromQuery: string;
|
|
23
30
|
export declare const getLeverageClosesQuery: string;
|
|
31
|
+
export declare const getLeverageClosesByTimestampFromQuery: string;
|
|
32
|
+
export declare const getLeverageAdjustsByTimestampFromQuery: string;
|
|
24
33
|
export declare const getPositionLiquidatedsQuery: string;
|
|
25
34
|
export declare const getDepositsQuery: string;
|
|
35
|
+
export declare const getDepositsByTimestampFromQuery: string;
|
|
26
36
|
export declare const getDepositsByDepositorAddressQuery: string;
|
|
27
37
|
export declare const getWithdrawsQuery: string;
|
|
38
|
+
export declare const getWithdrawsByTimestampFromQuery: string;
|
|
28
39
|
export declare const getWithdrawsByWithdrawerAddressQuery: string;
|
|
29
40
|
export declare const getLimitOrderAnnouncedsQuery: string;
|
|
41
|
+
export declare const getLimitOrderExecutedsByTimestampFromQuery: string;
|
|
30
42
|
export declare const getOpenPositionsQuery: string;
|
|
31
43
|
export declare const getClosedPositionsQuery: string;
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getClosedPositionsQuery = exports.getOpenPositionsQuery = exports.getLimitOrderAnnouncedsQuery = exports.getWithdrawsByWithdrawerAddressQuery = exports.getWithdrawsQuery = exports.getDepositsByDepositorAddressQuery = exports.getDepositsQuery = exports.getPositionLiquidatedsQuery = exports.getLeverageClosesQuery = exports.getLeverageOpensQuery = exports.getAnnouncedOrdersQuery = exports.GraphQueryService = void 0;
|
|
12
|
+
exports.getClosedPositionsQuery = exports.getOpenPositionsQuery = exports.getLimitOrderExecutedsByTimestampFromQuery = exports.getLimitOrderAnnouncedsQuery = exports.getWithdrawsByWithdrawerAddressQuery = exports.getWithdrawsByTimestampFromQuery = exports.getWithdrawsQuery = exports.getDepositsByDepositorAddressQuery = exports.getDepositsByTimestampFromQuery = exports.getDepositsQuery = exports.getPositionLiquidatedsQuery = exports.getLeverageAdjustsByTimestampFromQuery = exports.getLeverageClosesByTimestampFromQuery = exports.getLeverageClosesQuery = exports.getLeverageOpensByTimestampFromQuery = exports.getLeverageOpensQuery = exports.getAnnouncedOrdersQuery = exports.GraphQueryService = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const graphql_request_1 = require("graphql-request");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
@@ -22,11 +22,11 @@ let GraphQueryService = class GraphQueryService {
|
|
|
22
22
|
const variables = { timestamp: timestampFrom.toString() };
|
|
23
23
|
try {
|
|
24
24
|
const response = await this.graphQLClient.request(exports.getAnnouncedOrdersQuery, variables);
|
|
25
|
-
this.logger.log(`Fetched ${response.orderAnnounceds.length} orderAnnounceds events from the graph`);
|
|
25
|
+
this.logger.log(`Fetched ${response.orderAnnounceds.length} orderAnnounceds events from the graph from timestamp: ${timestampFrom}`);
|
|
26
26
|
return response.orderAnnounceds;
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
this.logger.error('Error fetching announced orders from the graph:', error);
|
|
29
|
+
this.logger.error('Error fetching announced orders from the graph by timestamp from:', error);
|
|
30
30
|
throw error;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -43,6 +43,19 @@ let GraphQueryService = class GraphQueryService {
|
|
|
43
43
|
throw error;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
async getLeverageOpensByTimestampFrom(timestampFrom) {
|
|
47
|
+
const variables = { blockTimestamp: timestampFrom };
|
|
48
|
+
try {
|
|
49
|
+
const response = await this.graphQLClient.request(exports.getLeverageOpensByTimestampFromQuery, variables);
|
|
50
|
+
this.logger.log(`Fetched ${response.leverageOpens.length} leverageOpens events from the graph from timestamp: ${timestampFrom}`);
|
|
51
|
+
response.leverageOpens.forEach((events) => (events.eventType = constants_1.LeveragePositionStatus.OPEN));
|
|
52
|
+
return response.leverageOpens;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.logger.error('Error fetching leverageOpens events from the graph by timestamp from:', error);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
46
59
|
async getLeverageCloses(blockFrom) {
|
|
47
60
|
const variables = { fromBlock: blockFrom };
|
|
48
61
|
try {
|
|
@@ -56,6 +69,31 @@ let GraphQueryService = class GraphQueryService {
|
|
|
56
69
|
throw error;
|
|
57
70
|
}
|
|
58
71
|
}
|
|
72
|
+
async getLeverageClosesByTimestampFrom(timestampFrom) {
|
|
73
|
+
const variables = { blockTimestamp: timestampFrom };
|
|
74
|
+
try {
|
|
75
|
+
const response = await this.graphQLClient.request(exports.getLeverageClosesByTimestampFromQuery, variables);
|
|
76
|
+
this.logger.log(`Fetched ${response.leverageCloses.length} leverageCloses events from the graph from timestamp: ${timestampFrom}`);
|
|
77
|
+
response.leverageCloses.forEach((events) => (events.eventType = constants_1.LeveragePositionStatus.CLOSED));
|
|
78
|
+
return response.leverageCloses;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
this.logger.error('Error fetching leverageCloses events from the graph by timestamp from:', error);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async getLeverageAdjustsByTimestampFrom(timestampFrom) {
|
|
86
|
+
const variables = { blockTimestamp: timestampFrom };
|
|
87
|
+
try {
|
|
88
|
+
const response = await this.graphQLClient.request(exports.getLeverageAdjustsByTimestampFromQuery, variables);
|
|
89
|
+
this.logger.log(`Fetched ${response.leverageAdjusts.length} leverageAdjusts events from the graph from timestamp: ${timestampFrom}`);
|
|
90
|
+
return response.leverageAdjusts;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.logger.error('Error fetching leverageAdjusts events from the graph by timestamp from:', error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
59
97
|
async getPositionLiquidateds(blockFrom) {
|
|
60
98
|
const variables = { fromBlock: blockFrom };
|
|
61
99
|
try {
|
|
@@ -81,6 +119,18 @@ let GraphQueryService = class GraphQueryService {
|
|
|
81
119
|
throw error;
|
|
82
120
|
}
|
|
83
121
|
}
|
|
122
|
+
async getDepositsByTimestampFrom(timestampFrom) {
|
|
123
|
+
const variables = { blockTimestamp: timestampFrom };
|
|
124
|
+
try {
|
|
125
|
+
const response = await this.graphQLClient.request(exports.getDepositsByTimestampFromQuery, variables);
|
|
126
|
+
this.logger.log(`Fetched ${response.deposits.length} deposits events from the graph from timestamp: ${timestampFrom}`);
|
|
127
|
+
return response.deposits;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.logger.error('Error fetching deposits events from the graph by timestamp from:', error);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
84
134
|
async getDepositsByDepositorAddress(account, blockFrom) {
|
|
85
135
|
const variables = { account: account, fromBlock: blockFrom };
|
|
86
136
|
try {
|
|
@@ -105,6 +155,18 @@ let GraphQueryService = class GraphQueryService {
|
|
|
105
155
|
throw error;
|
|
106
156
|
}
|
|
107
157
|
}
|
|
158
|
+
async getWithdrawsByTimestampFrom(timestampFrom) {
|
|
159
|
+
const variables = { blockTimestamp: timestampFrom };
|
|
160
|
+
try {
|
|
161
|
+
const response = await this.graphQLClient.request(exports.getWithdrawsByTimestampFromQuery, variables);
|
|
162
|
+
this.logger.log(`Fetched ${response.withdraws.length} withdraws events from the graph from timestamp: ${timestampFrom}`);
|
|
163
|
+
return response.withdraws;
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
this.logger.error('Error fetching withdraws events from the graph by timestamp from:', error);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
108
170
|
async getWithdrawsByWithdrawerAddress(account, blockFrom) {
|
|
109
171
|
const variables = { account: account, fromBlock: blockFrom };
|
|
110
172
|
try {
|
|
@@ -129,6 +191,18 @@ let GraphQueryService = class GraphQueryService {
|
|
|
129
191
|
throw error;
|
|
130
192
|
}
|
|
131
193
|
}
|
|
194
|
+
async getLimitOrderExecutedsByTimestampFrom(timestampFrom) {
|
|
195
|
+
const variables = { blockTimestamp: timestampFrom };
|
|
196
|
+
try {
|
|
197
|
+
const response = await this.graphQLClient.request(exports.getLimitOrderExecutedsByTimestampFromQuery, variables);
|
|
198
|
+
this.logger.log(`Fetched ${response.limitOrderExecuteds.length} limitOrderExecuteds events from the graph from timestamp: ${timestampFrom}`);
|
|
199
|
+
return response.limitOrderExecuteds;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
this.logger.error('Error fetching limitOrderExecuteds events from the graph by timestamp from:', error);
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
132
206
|
async getAllOpenPositions() {
|
|
133
207
|
const allPositions = [];
|
|
134
208
|
const first = 999;
|
|
@@ -195,6 +269,18 @@ exports.getLeverageOpensQuery = (0, graphql_request_1.gql) `
|
|
|
195
269
|
}
|
|
196
270
|
}
|
|
197
271
|
`;
|
|
272
|
+
exports.getLeverageOpensByTimestampFromQuery = (0, graphql_request_1.gql) `
|
|
273
|
+
query GetLeverageOpens($timestampFrom: Int) {
|
|
274
|
+
leverageOpens(where: { blockTimestamp_gt: $timestampFrom }) {
|
|
275
|
+
blockNumber
|
|
276
|
+
blockTimestamp
|
|
277
|
+
tokenId
|
|
278
|
+
account
|
|
279
|
+
transactionHash
|
|
280
|
+
executedBy
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
`;
|
|
198
284
|
exports.getLeverageClosesQuery = (0, graphql_request_1.gql) `
|
|
199
285
|
query GetLeverageCloses($fromBlock: Int) {
|
|
200
286
|
leverageCloses(where: { blockNumber_gt: $fromBlock }) {
|
|
@@ -204,6 +290,26 @@ exports.getLeverageClosesQuery = (0, graphql_request_1.gql) `
|
|
|
204
290
|
}
|
|
205
291
|
}
|
|
206
292
|
`;
|
|
293
|
+
exports.getLeverageClosesByTimestampFromQuery = (0, graphql_request_1.gql) `
|
|
294
|
+
query GetLeverageCloses($timestampFrom: Int) {
|
|
295
|
+
leverageCloses(where: { blockTimestamp_gt: $timestampFrom }) {
|
|
296
|
+
blockNumber
|
|
297
|
+
blockTimestamp
|
|
298
|
+
tokenId
|
|
299
|
+
transactionHash
|
|
300
|
+
executedBy
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
`;
|
|
304
|
+
exports.getLeverageAdjustsByTimestampFromQuery = (0, graphql_request_1.gql) `
|
|
305
|
+
query GetLeverageAdhusts($timestampFrom: Int) {
|
|
306
|
+
leverageAdjusts(where: { blockTimestamp_gt: $timestampFrom }) {
|
|
307
|
+
blockTimestamp
|
|
308
|
+
transactionHash
|
|
309
|
+
executedBy
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
207
313
|
exports.getPositionLiquidatedsQuery = (0, graphql_request_1.gql) `
|
|
208
314
|
query GetPositionLiquidateds($fromBlock: Int) {
|
|
209
315
|
positionLiquidateds(where: { blockNumber_gt: $fromBlock }) {
|
|
@@ -225,6 +331,19 @@ exports.getDepositsQuery = (0, graphql_request_1.gql) `
|
|
|
225
331
|
}
|
|
226
332
|
}
|
|
227
333
|
`;
|
|
334
|
+
exports.getDepositsByTimestampFromQuery = (0, graphql_request_1.gql) `
|
|
335
|
+
query GetDeposits($timestampFrom: Int) {
|
|
336
|
+
deposits(where: { blockTimestamp_gt: $timestampFrom }) {
|
|
337
|
+
depositor
|
|
338
|
+
depositAmount
|
|
339
|
+
mintedAmount
|
|
340
|
+
blockNumber
|
|
341
|
+
blockTimestamp
|
|
342
|
+
transactionHash
|
|
343
|
+
executedBy
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
`;
|
|
228
347
|
exports.getDepositsByDepositorAddressQuery = (0, graphql_request_1.gql) `
|
|
229
348
|
query GetDeposits($account: String, $fromBlock: Int) {
|
|
230
349
|
deposits(
|
|
@@ -250,6 +369,19 @@ exports.getWithdrawsQuery = (0, graphql_request_1.gql) `
|
|
|
250
369
|
}
|
|
251
370
|
}
|
|
252
371
|
`;
|
|
372
|
+
exports.getWithdrawsByTimestampFromQuery = (0, graphql_request_1.gql) `
|
|
373
|
+
query GetWithdraws($timestampFrom: Int) {
|
|
374
|
+
withdraws(where: { blockTimestamp_gt: $timestampFrom }, orderBy: blockTimestamp, orderDirection: asc, first: 1000) {
|
|
375
|
+
blockNumber
|
|
376
|
+
withdrawer
|
|
377
|
+
withdrawAmount
|
|
378
|
+
burnedAmount
|
|
379
|
+
blockTimestamp
|
|
380
|
+
transactionHash
|
|
381
|
+
executedBy
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
`;
|
|
253
385
|
exports.getWithdrawsByWithdrawerAddressQuery = (0, graphql_request_1.gql) `
|
|
254
386
|
query GetWithdraws($account: String, $fromBlock: Int) {
|
|
255
387
|
withdraws(
|
|
@@ -279,6 +411,15 @@ exports.getLimitOrderAnnouncedsQuery = (0, graphql_request_1.gql) `
|
|
|
279
411
|
}
|
|
280
412
|
}
|
|
281
413
|
`;
|
|
414
|
+
exports.getLimitOrderExecutedsByTimestampFromQuery = (0, graphql_request_1.gql) `
|
|
415
|
+
query GetLimitOrderExecuteds($timestampFrom: Int) {
|
|
416
|
+
limitOrderExecuteds(where: { blockTimestamp_gt: $timestampFrom }) {
|
|
417
|
+
blockTimestamp
|
|
418
|
+
transactionHash
|
|
419
|
+
executedBy
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
`;
|
|
282
423
|
exports.getOpenPositionsQuery = (0, graphql_request_1.gql) `
|
|
283
424
|
query GetOpenPositions($skip: Int, $first: Int) {
|
|
284
425
|
positions(where: { status: 0 }, skip: $skip, first: $first) {
|
|
@@ -4,12 +4,18 @@ export interface DepositEvent {
|
|
|
4
4
|
depositor: string;
|
|
5
5
|
depositAmount: string;
|
|
6
6
|
mintedAmount: string;
|
|
7
|
+
blockTimestamp: number;
|
|
8
|
+
executeInTime: number;
|
|
9
|
+
expirationTime: number;
|
|
7
10
|
}
|
|
8
11
|
export interface WithdrawEvent {
|
|
9
12
|
blockNumber: string;
|
|
10
13
|
withdrawer: string;
|
|
11
14
|
withdrawAmount: string;
|
|
12
15
|
burnedAmount: string;
|
|
16
|
+
blockTimestamp: number;
|
|
17
|
+
executeInTime: number;
|
|
18
|
+
expirationTime: number;
|
|
13
19
|
}
|
|
14
20
|
export declare class DepositWithdrawAction {
|
|
15
21
|
isDeposit: boolean;
|
|
@@ -33,6 +39,13 @@ export interface LeveragePositionEvent {
|
|
|
33
39
|
liquidator: string;
|
|
34
40
|
closePrice: string;
|
|
35
41
|
eventType: string;
|
|
42
|
+
transactionHash: string;
|
|
43
|
+
executedBy: string;
|
|
44
|
+
}
|
|
45
|
+
export interface LeverageAdjust {
|
|
46
|
+
blockTimestamp: number;
|
|
47
|
+
transactionHash: string;
|
|
48
|
+
executedBy: string;
|
|
36
49
|
}
|
|
37
50
|
export interface AnnouncedLimitOrder {
|
|
38
51
|
id: string;
|
|
@@ -44,6 +57,11 @@ export interface AnnouncedLimitOrder {
|
|
|
44
57
|
priceUpperThreshold: number;
|
|
45
58
|
transactionHash: string;
|
|
46
59
|
}
|
|
60
|
+
export interface LimitOrderExecuted {
|
|
61
|
+
blockTimestamp: number;
|
|
62
|
+
transactionHash: string;
|
|
63
|
+
executedBy: string;
|
|
64
|
+
}
|
|
47
65
|
export interface Position {
|
|
48
66
|
tokenId: number;
|
|
49
67
|
account: string;
|
|
@@ -66,12 +84,18 @@ export interface LeverageOpensData {
|
|
|
66
84
|
export interface PositionLiquidatedsData {
|
|
67
85
|
positionLiquidateds: LeveragePositionEvent[];
|
|
68
86
|
}
|
|
87
|
+
export interface LeverageAdjustsData {
|
|
88
|
+
leverageAdjusts: LeverageAdjust[];
|
|
89
|
+
}
|
|
69
90
|
export interface AnnouncedOrderData {
|
|
70
91
|
orderAnnounceds: AnnouncedOrder[];
|
|
71
92
|
}
|
|
72
93
|
export interface AnnouncedLimitOrderData {
|
|
73
94
|
limitOrderAnnounceds: AnnouncedLimitOrder[];
|
|
74
95
|
}
|
|
96
|
+
export interface LimitOrderExecutedsData {
|
|
97
|
+
limitOrderExecuteds: LimitOrderExecuted[];
|
|
98
|
+
}
|
|
75
99
|
export interface PositionData {
|
|
76
100
|
positions: Position[];
|
|
77
101
|
}
|