@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.
- package/dist/contracts/abi/limit-order.d.ts +1 -1
- package/dist/contracts/abi/limit-order.js +179 -181
- package/dist/service/graph-query.service.d.ts +5 -1
- package/dist/service/graph-query.service.js +45 -1
- package/dist/utils/shared-types.d.ts +2 -2
- package/dist/utils/shared-types.js +4 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
|
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
|
|
36
|
+
export interface DepositEventsData {
|
|
37
37
|
deposits: DepositEvent[];
|
|
38
38
|
}
|
|
39
39
|
export interface WithdrawEventsData {
|