@dhedge/backend-flatcoin-core 0.1.32 → 0.1.34

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.
@@ -23,5 +23,11 @@ export declare enum OrderType {
23
23
  STABLE_WITHDRAW = 2,
24
24
  LEVERAGE_OPEN = 3,
25
25
  LEVERAGE_CLOSE = 4,
26
- LEVERAGE_ADJUST = 5
26
+ LEVERAGE_ADJUST = 5,
27
+ LIMIT_CLOSE = 6
28
+ }
29
+ export declare enum LimitOrderExecutionType {
30
+ NONE = 0,
31
+ STOP_LOSS = 1,
32
+ PROFIT_TAKE = 2
27
33
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrderType = exports.LeveragePositionStatus = exports.getChartPeriod = exports.HistoricalPeriod = exports.PERIOD_IN_SECONDS = void 0;
3
+ exports.LimitOrderExecutionType = exports.OrderType = exports.LeveragePositionStatus = exports.getChartPeriod = exports.HistoricalPeriod = exports.PERIOD_IN_SECONDS = void 0;
4
4
  var HistoricalPeriod;
5
5
  (function (HistoricalPeriod) {
6
6
  HistoricalPeriod["ONE_DAY"] = "1d";
@@ -38,4 +38,11 @@ var OrderType;
38
38
  OrderType[OrderType["LEVERAGE_OPEN"] = 3] = "LEVERAGE_OPEN";
39
39
  OrderType[OrderType["LEVERAGE_CLOSE"] = 4] = "LEVERAGE_CLOSE";
40
40
  OrderType[OrderType["LEVERAGE_ADJUST"] = 5] = "LEVERAGE_ADJUST";
41
+ OrderType[OrderType["LIMIT_CLOSE"] = 6] = "LIMIT_CLOSE";
41
42
  })(OrderType || (exports.OrderType = OrderType = {}));
43
+ var LimitOrderExecutionType;
44
+ (function (LimitOrderExecutionType) {
45
+ LimitOrderExecutionType[LimitOrderExecutionType["NONE"] = 0] = "NONE";
46
+ LimitOrderExecutionType[LimitOrderExecutionType["STOP_LOSS"] = 1] = "STOP_LOSS";
47
+ LimitOrderExecutionType[LimitOrderExecutionType["PROFIT_TAKE"] = 2] = "PROFIT_TAKE";
48
+ })(LimitOrderExecutionType || (exports.LimitOrderExecutionType = LimitOrderExecutionType = {}));
@@ -45,4 +45,15 @@ export declare const LimitOrder: ({
45
45
  stateMutability: string;
46
46
  type: string;
47
47
  anonymous?: undefined;
48
+ } | {
49
+ inputs: {
50
+ internalType: string;
51
+ name: string;
52
+ type: string;
53
+ }[];
54
+ name: string;
55
+ type: string;
56
+ anonymous?: undefined;
57
+ outputs?: undefined;
58
+ stateMutability?: undefined;
48
59
  })[];
@@ -181,4 +181,46 @@ exports.LimitOrder = [
181
181
  stateMutability: 'view',
182
182
  type: 'function',
183
183
  },
184
+ {
185
+ inputs: [
186
+ {
187
+ internalType: 'uint256',
188
+ name: 'tokenId',
189
+ type: 'uint256',
190
+ },
191
+ {
192
+ internalType: 'uint256',
193
+ name: 'priceLowerThreshold',
194
+ type: 'uint256',
195
+ },
196
+ {
197
+ internalType: 'uint256',
198
+ name: 'priceUpperThreshold',
199
+ type: 'uint256',
200
+ },
201
+ ],
202
+ name: 'LimitOrderAnnounced',
203
+ type: 'event',
204
+ },
205
+ {
206
+ inputs: [
207
+ {
208
+ internalType: 'uint256',
209
+ name: 'tokenId',
210
+ type: 'uint256',
211
+ },
212
+ {
213
+ internalType: 'uint256',
214
+ name: 'price',
215
+ type: 'uint256',
216
+ },
217
+ {
218
+ internalType: 'enum FlatcoinStructs.LimitOrderExecutionType',
219
+ name: 'limitOrderType',
220
+ type: 'uint8',
221
+ },
222
+ ],
223
+ name: 'LimitOrderExecuted',
224
+ type: 'event',
225
+ },
184
226
  ];
@@ -0,0 +1 @@
1
+ export * from './leverage-position-data';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./leverage-position-data"), exports);
@@ -0,0 +1,11 @@
1
+ import { BigNumber } from 'ethers';
2
+ export declare class LeveragePositionData {
3
+ tokenId: BigNumber;
4
+ entryPrice: BigNumber;
5
+ marginDeposited: BigNumber;
6
+ additionalSize: BigNumber;
7
+ marginAfterSettlement: BigNumber;
8
+ liquidationPrice: BigNumber;
9
+ limitOrderPriceLowerThreshold: BigNumber;
10
+ limitOrderPriceUpperThreshold: BigNumber;
11
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LeveragePositionData = void 0;
4
+ class LeveragePositionData {
5
+ }
6
+ exports.LeveragePositionData = LeveragePositionData;
@@ -10,11 +10,15 @@ export declare class GraphQueryService {
10
10
  getLeverageCloses(blockFrom: number): Promise<LeveragePositionEvent[]>;
11
11
  getPositionLiquidateds(blockFrom: number): Promise<LeveragePositionEvent[]>;
12
12
  getDeposits(blockFrom: number): Promise<DepositEvent[]>;
13
+ getDepositsByDepositorAddress(account: string, blockFrom: number): Promise<DepositEvent[]>;
13
14
  getWithdraws(blockFrom: number): Promise<WithdrawEvent[]>;
15
+ getWithdrawsByWithdrawerAddress(account: string, blockFrom: number): Promise<WithdrawEvent[]>;
14
16
  }
15
17
  export declare const getAnnouncedOrdersQuery: string;
16
18
  export declare const getLeverageOpensQuery: string;
17
19
  export declare const getLeverageClosesQuery: string;
18
20
  export declare const getPositionLiquidatedsQuery: string;
19
21
  export declare const getDepositsQuery: string;
22
+ export declare const getDepositsByDepositorAddressQuery: string;
20
23
  export declare const getWithdrawsQuery: string;
24
+ export declare const getWithdrawsByWithdrawerAddressQuery: 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.getWithdrawsQuery = exports.getDepositsQuery = exports.getPositionLiquidatedsQuery = exports.getLeverageClosesQuery = exports.getLeverageOpensQuery = exports.getAnnouncedOrdersQuery = exports.GraphQueryService = void 0;
12
+ exports.getWithdrawsByWithdrawerAddressQuery = exports.getWithdrawsQuery = exports.getDepositsByDepositorAddressQuery = 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");
@@ -81,6 +81,18 @@ let GraphQueryService = class GraphQueryService {
81
81
  throw error;
82
82
  }
83
83
  }
84
+ async getDepositsByDepositorAddress(account, blockFrom) {
85
+ const variables = { account: account, fromBlock: blockFrom };
86
+ try {
87
+ const response = await this.graphQLClient.request(exports.getDepositsByDepositorAddressQuery, variables);
88
+ this.logger.log(`Fetched ${response.deposits.length} deposits events from the graph`);
89
+ return response.deposits;
90
+ }
91
+ catch (error) {
92
+ this.logger.error('Error fetching deposits events from the graph:', error);
93
+ throw error;
94
+ }
95
+ }
84
96
  async getWithdraws(blockFrom) {
85
97
  const variables = { fromBlock: blockFrom };
86
98
  try {
@@ -93,6 +105,18 @@ let GraphQueryService = class GraphQueryService {
93
105
  throw error;
94
106
  }
95
107
  }
108
+ async getWithdrawsByWithdrawerAddress(account, blockFrom) {
109
+ const variables = { account: account, fromBlock: blockFrom };
110
+ try {
111
+ const response = await this.graphQLClient.request(exports.getWithdrawsByWithdrawerAddressQuery, variables);
112
+ this.logger.log(`Fetched ${response.withdraws.length} withdraws events from the graph`);
113
+ return response.withdraws;
114
+ }
115
+ catch (error) {
116
+ this.logger.error('Error fetching withdraws events from the graph:', error);
117
+ throw error;
118
+ }
119
+ }
96
120
  };
97
121
  exports.GraphQueryService = GraphQueryService;
98
122
  exports.GraphQueryService = GraphQueryService = __decorate([
@@ -149,6 +173,21 @@ exports.getDepositsQuery = (0, graphql_request_1.gql) `
149
173
  }
150
174
  }
151
175
  `;
176
+ exports.getDepositsByDepositorAddressQuery = (0, graphql_request_1.gql) `
177
+ query GetDeposits($account: String, $fromBlock: Int) {
178
+ deposits(
179
+ where: { depositor: $account, blockNumber_gt: $fromBlock }
180
+ orderBy: blockTimestamp
181
+ orderDirection: asc
182
+ first: 1000
183
+ ) {
184
+ depositor
185
+ depositAmount
186
+ mintedAmount
187
+ blockNumber
188
+ }
189
+ }
190
+ `;
152
191
  exports.getWithdrawsQuery = (0, graphql_request_1.gql) `
153
192
  query GetWithdraws($fromBlock: Int) {
154
193
  withdraws(where: { blockNumber_gt: $fromBlock }, orderBy: blockTimestamp, orderDirection: asc, first: 1000) {
@@ -159,3 +198,18 @@ exports.getWithdrawsQuery = (0, graphql_request_1.gql) `
159
198
  }
160
199
  }
161
200
  `;
201
+ exports.getWithdrawsByWithdrawerAddressQuery = (0, graphql_request_1.gql) `
202
+ query GetWithdraws($account: String, $fromBlock: Int) {
203
+ withdraws(
204
+ where: { withdrawer: $account, blockNumber_gt: $fromBlock }
205
+ orderBy: blockTimestamp
206
+ orderDirection: asc
207
+ first: 1000
208
+ ) {
209
+ blockNumber
210
+ withdrawer
211
+ withdrawAmount
212
+ burnedAmount
213
+ }
214
+ }
215
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/backend-flatcoin-core",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Backend Flatcoin Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",