@dhedge/backend-flatcoin-core 0.1.30 → 0.1.32

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.
@@ -45,4 +45,4 @@ export declare const LimitOrder: ({
45
45
  stateMutability: string;
46
46
  type: string;
47
47
  anonymous?: undefined;
48
- })[][];
48
+ })[];
@@ -2,185 +2,183 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LimitOrder = void 0;
4
4
  exports.LimitOrder = [
5
- [
6
- {
7
- anonymous: false,
8
- inputs: [
9
- {
10
- indexed: false,
11
- internalType: 'uint8',
12
- name: 'version',
13
- type: 'uint8',
14
- },
15
- ],
16
- name: 'Initialized',
17
- type: 'event',
18
- },
19
- {
20
- inputs: [],
21
- name: 'MODULE_KEY',
22
- outputs: [
23
- {
24
- internalType: 'bytes32',
25
- name: '',
26
- type: 'bytes32',
27
- },
28
- ],
29
- stateMutability: 'view',
30
- type: 'function',
31
- },
32
- {
33
- inputs: [
34
- {
35
- internalType: 'uint256',
36
- name: 'tokenId',
37
- type: 'uint256',
38
- },
39
- {
40
- internalType: 'uint256',
41
- name: 'priceLowerThreshold',
42
- type: 'uint256',
43
- },
44
- {
45
- internalType: 'uint256',
46
- name: 'priceUpperThreshold',
47
- type: 'uint256',
48
- },
49
- ],
50
- name: 'announceLimitOrder',
51
- outputs: [],
52
- stateMutability: 'nonpayable',
53
- type: 'function',
54
- },
55
- {
56
- inputs: [
57
- {
58
- internalType: 'uint256',
59
- name: 'tokenId',
60
- type: 'uint256',
61
- },
62
- ],
63
- name: 'cancelExistingLimitOrder',
64
- outputs: [
65
- {
66
- internalType: 'bool',
67
- name: 'cancelled',
68
- type: 'bool',
69
- },
70
- ],
71
- stateMutability: 'nonpayable',
72
- type: 'function',
73
- },
74
- {
75
- inputs: [
76
- {
77
- internalType: 'uint256',
78
- name: 'tokenId',
79
- type: 'uint256',
80
- },
81
- ],
82
- name: 'cancelLimitOrder',
83
- outputs: [],
84
- stateMutability: 'nonpayable',
85
- type: 'function',
86
- },
87
- {
88
- inputs: [
89
- {
90
- internalType: 'uint256',
91
- name: 'tokenId',
92
- type: 'uint256',
93
- },
94
- {
95
- internalType: 'bytes[]',
96
- name: 'priceUpdateData',
97
- type: 'bytes[]',
98
- },
99
- ],
100
- name: 'executeLimitOrder',
101
- outputs: [],
102
- stateMutability: 'payable',
103
- type: 'function',
104
- },
105
- {
106
- inputs: [
107
- {
108
- internalType: 'uint256',
109
- name: 'tokenId',
110
- type: 'uint256',
111
- },
112
- ],
113
- name: 'getLimitOrder',
114
- outputs: [
115
- {
116
- components: [
117
- {
118
- internalType: 'enum FlatcoinStructs.OrderType',
119
- name: 'orderType',
120
- type: 'uint8',
121
- },
122
- {
123
- internalType: 'uint256',
124
- name: 'keeperFee',
125
- type: 'uint256',
126
- },
127
- {
128
- internalType: 'uint64',
129
- name: 'executableAtTime',
130
- type: 'uint64',
131
- },
132
- {
133
- internalType: 'bytes',
134
- name: 'orderData',
135
- type: 'bytes',
136
- },
137
- ],
138
- internalType: 'struct FlatcoinStructs.Order',
139
- name: 'order',
140
- type: 'tuple',
141
- },
142
- ],
143
- stateMutability: 'view',
144
- type: 'function',
145
- },
146
- {
147
- inputs: [
148
- {
149
- internalType: 'contract IFlatcoinVault',
150
- name: '_vault',
151
- type: 'address',
152
- },
153
- ],
154
- name: 'initialize',
155
- outputs: [],
156
- stateMutability: 'nonpayable',
157
- type: 'function',
158
- },
159
- {
160
- inputs: [
161
- {
162
- internalType: 'contract IFlatcoinVault',
163
- name: '_vault',
164
- type: 'address',
165
- },
166
- ],
167
- name: 'setVault',
168
- outputs: [],
169
- stateMutability: 'nonpayable',
170
- type: 'function',
171
- },
172
- {
173
- inputs: [],
174
- name: 'vault',
175
- outputs: [
176
- {
177
- internalType: 'contract IFlatcoinVault',
178
- name: '',
179
- type: 'address',
180
- },
181
- ],
182
- stateMutability: 'view',
183
- type: 'function',
184
- },
185
- ],
5
+ {
6
+ anonymous: false,
7
+ inputs: [
8
+ {
9
+ indexed: false,
10
+ internalType: 'uint8',
11
+ name: 'version',
12
+ type: 'uint8',
13
+ },
14
+ ],
15
+ name: 'Initialized',
16
+ type: 'event',
17
+ },
18
+ {
19
+ inputs: [],
20
+ name: 'MODULE_KEY',
21
+ outputs: [
22
+ {
23
+ internalType: 'bytes32',
24
+ name: '',
25
+ type: 'bytes32',
26
+ },
27
+ ],
28
+ stateMutability: 'view',
29
+ type: 'function',
30
+ },
31
+ {
32
+ inputs: [
33
+ {
34
+ internalType: 'uint256',
35
+ name: 'tokenId',
36
+ type: 'uint256',
37
+ },
38
+ {
39
+ internalType: 'uint256',
40
+ name: 'priceLowerThreshold',
41
+ type: 'uint256',
42
+ },
43
+ {
44
+ internalType: 'uint256',
45
+ name: 'priceUpperThreshold',
46
+ type: 'uint256',
47
+ },
48
+ ],
49
+ name: 'announceLimitOrder',
50
+ outputs: [],
51
+ stateMutability: 'nonpayable',
52
+ type: 'function',
53
+ },
54
+ {
55
+ inputs: [
56
+ {
57
+ internalType: 'uint256',
58
+ name: 'tokenId',
59
+ type: 'uint256',
60
+ },
61
+ ],
62
+ name: 'cancelExistingLimitOrder',
63
+ outputs: [
64
+ {
65
+ internalType: 'bool',
66
+ name: 'cancelled',
67
+ type: 'bool',
68
+ },
69
+ ],
70
+ stateMutability: 'nonpayable',
71
+ type: 'function',
72
+ },
73
+ {
74
+ inputs: [
75
+ {
76
+ internalType: 'uint256',
77
+ name: 'tokenId',
78
+ type: 'uint256',
79
+ },
80
+ ],
81
+ name: 'cancelLimitOrder',
82
+ outputs: [],
83
+ stateMutability: 'nonpayable',
84
+ type: 'function',
85
+ },
86
+ {
87
+ inputs: [
88
+ {
89
+ internalType: 'uint256',
90
+ name: 'tokenId',
91
+ type: 'uint256',
92
+ },
93
+ {
94
+ internalType: 'bytes[]',
95
+ name: 'priceUpdateData',
96
+ type: 'bytes[]',
97
+ },
98
+ ],
99
+ name: 'executeLimitOrder',
100
+ outputs: [],
101
+ stateMutability: 'payable',
102
+ type: 'function',
103
+ },
104
+ {
105
+ inputs: [
106
+ {
107
+ internalType: 'uint256',
108
+ name: 'tokenId',
109
+ type: 'uint256',
110
+ },
111
+ ],
112
+ name: 'getLimitOrder',
113
+ outputs: [
114
+ {
115
+ components: [
116
+ {
117
+ internalType: 'enum FlatcoinStructs.OrderType',
118
+ name: 'orderType',
119
+ type: 'uint8',
120
+ },
121
+ {
122
+ internalType: 'uint256',
123
+ name: 'keeperFee',
124
+ type: 'uint256',
125
+ },
126
+ {
127
+ internalType: 'uint64',
128
+ name: 'executableAtTime',
129
+ type: 'uint64',
130
+ },
131
+ {
132
+ internalType: 'bytes',
133
+ name: 'orderData',
134
+ type: 'bytes',
135
+ },
136
+ ],
137
+ internalType: 'struct FlatcoinStructs.Order',
138
+ name: 'order',
139
+ type: 'tuple',
140
+ },
141
+ ],
142
+ stateMutability: 'view',
143
+ type: 'function',
144
+ },
145
+ {
146
+ inputs: [
147
+ {
148
+ internalType: 'contract IFlatcoinVault',
149
+ name: '_vault',
150
+ type: 'address',
151
+ },
152
+ ],
153
+ name: 'initialize',
154
+ outputs: [],
155
+ stateMutability: 'nonpayable',
156
+ type: 'function',
157
+ },
158
+ {
159
+ inputs: [
160
+ {
161
+ internalType: 'contract IFlatcoinVault',
162
+ name: '_vault',
163
+ type: 'address',
164
+ },
165
+ ],
166
+ name: 'setVault',
167
+ outputs: [],
168
+ stateMutability: 'nonpayable',
169
+ type: 'function',
170
+ },
171
+ {
172
+ inputs: [],
173
+ name: 'vault',
174
+ outputs: [
175
+ {
176
+ internalType: 'contract IFlatcoinVault',
177
+ name: '',
178
+ type: 'address',
179
+ },
180
+ ],
181
+ stateMutability: 'view',
182
+ type: 'function',
183
+ },
186
184
  ];
@@ -1,5 +1,5 @@
1
1
  import { Logger } from '@nestjs/common';
2
- import { AnnouncedOrder, LeveragePositionEvent } from '../utils';
2
+ import { AnnouncedOrder, DepositEvent, LeveragePositionEvent, WithdrawEvent } from '../utils';
3
3
  import { GraphQLClient } from 'graphql-request';
4
4
  export declare class GraphQueryService {
5
5
  private readonly graphQLClient;
@@ -9,8 +9,12 @@ export declare class GraphQueryService {
9
9
  getLeverageOpens(blockFrom: number): Promise<LeveragePositionEvent[]>;
10
10
  getLeverageCloses(blockFrom: number): Promise<LeveragePositionEvent[]>;
11
11
  getPositionLiquidateds(blockFrom: number): Promise<LeveragePositionEvent[]>;
12
+ getDeposits(blockFrom: number): Promise<DepositEvent[]>;
13
+ getWithdraws(blockFrom: number): Promise<WithdrawEvent[]>;
12
14
  }
13
15
  export declare const getAnnouncedOrdersQuery: string;
14
16
  export declare const getLeverageOpensQuery: string;
15
17
  export declare const getLeverageClosesQuery: string;
16
18
  export declare const getPositionLiquidatedsQuery: string;
19
+ export declare const getDepositsQuery: string;
20
+ export declare const getWithdrawsQuery: 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.getPositionLiquidatedsQuery = exports.getLeverageClosesQuery = exports.getLeverageOpensQuery = exports.getAnnouncedOrdersQuery = exports.GraphQueryService = void 0;
12
+ exports.getWithdrawsQuery = exports.getDepositsQuery = exports.getPositionLiquidatedsQuery = exports.getLeverageClosesQuery = 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");
@@ -69,6 +69,30 @@ let GraphQueryService = class GraphQueryService {
69
69
  throw error;
70
70
  }
71
71
  }
72
+ async getDeposits(blockFrom) {
73
+ const variables = { fromBlock: blockFrom };
74
+ try {
75
+ const response = await this.graphQLClient.request(exports.getDepositsQuery, variables);
76
+ this.logger.log(`Fetched ${response.deposits.length} deposits events from the graph`);
77
+ return response.deposits;
78
+ }
79
+ catch (error) {
80
+ this.logger.error('Error fetching deposits events from the graph:', error);
81
+ throw error;
82
+ }
83
+ }
84
+ async getWithdraws(blockFrom) {
85
+ const variables = { fromBlock: blockFrom };
86
+ try {
87
+ const response = await this.graphQLClient.request(exports.getWithdrawsQuery, variables);
88
+ this.logger.log(`Fetched ${response.withdraws.length} withdraws events from the graph`);
89
+ return response.withdraws;
90
+ }
91
+ catch (error) {
92
+ this.logger.error('Error fetching withdraws events from the graph:', error);
93
+ throw error;
94
+ }
95
+ }
72
96
  };
73
97
  exports.GraphQueryService = GraphQueryService;
74
98
  exports.GraphQueryService = GraphQueryService = __decorate([
@@ -115,3 +139,23 @@ exports.getPositionLiquidatedsQuery = (0, graphql_request_1.gql) `
115
139
  }
116
140
  }
117
141
  `;
142
+ exports.getDepositsQuery = (0, graphql_request_1.gql) `
143
+ query GetDeposits($fromBlock: Int) {
144
+ deposits(where: { blockNumber_gt: $fromBlock }, orderBy: blockTimestamp, orderDirection: asc, first: 1000) {
145
+ depositor
146
+ depositAmount
147
+ mintedAmount
148
+ blockNumber
149
+ }
150
+ }
151
+ `;
152
+ exports.getWithdrawsQuery = (0, graphql_request_1.gql) `
153
+ query GetWithdraws($fromBlock: Int) {
154
+ withdraws(where: { blockNumber_gt: $fromBlock }, orderBy: blockTimestamp, orderDirection: asc, first: 1000) {
155
+ blockNumber
156
+ withdrawer
157
+ withdrawAmount
158
+ burnedAmount
159
+ }
160
+ }
161
+ `;
@@ -11,7 +11,7 @@ export interface WithdrawEvent {
11
11
  withdrawAmount: string;
12
12
  burnedAmount: string;
13
13
  }
14
- export interface DepositWithdrawAction {
14
+ export declare class DepositWithdrawAction {
15
15
  isDeposit: boolean;
16
16
  blockNumber: number;
17
17
  unitAmount: BigNumber;
@@ -33,7 +33,7 @@ export interface LeveragePositionEvent {
33
33
  liquidator: string;
34
34
  eventType: string;
35
35
  }
36
- export interface DepositsEventsData {
36
+ export interface DepositEventsData {
37
37
  deposits: DepositEvent[];
38
38
  }
39
39
  export interface WithdrawEventsData {
@@ -1,2 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DepositWithdrawAction = void 0;
4
+ class DepositWithdrawAction {
5
+ }
6
+ exports.DepositWithdrawAction = DepositWithdrawAction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/backend-flatcoin-core",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "Backend Flatcoin Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",