@dhedge/backend-flatcoin-core 0.3.18 → 0.3.20

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.
@@ -521,4 +521,48 @@ exports.FlatcoinErrors = [
521
521
  name: 'DelayedOrderInvalid',
522
522
  type: 'error',
523
523
  },
524
+ { inputs: [], name: 'NotInitializing', type: 'error' },
525
+ {
526
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
527
+ name: 'AddressInsufficientBalance',
528
+ type: 'error',
529
+ },
530
+ {
531
+ inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
532
+ name: 'LimitOrderInvalid',
533
+ type: 'error',
534
+ },
535
+ { inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' },
536
+ {
537
+ inputs: [{ internalType: 'address', name: 'token', type: 'address' }],
538
+ name: 'SafeERC20FailedOperation',
539
+ type: 'error',
540
+ },
541
+ { inputs: [{ internalType: 'address', name: 'target', type: 'address' }], name: 'AddressEmptyCode', type: 'error' },
542
+ {
543
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
544
+ name: 'AddressInsufficientBalance',
545
+ type: 'error',
546
+ },
547
+ { inputs: [], name: 'FailedInnerCall', type: 'error' },
548
+ { inputs: [], name: 'InvalidInitialization', type: 'error' },
549
+ {
550
+ inputs: [
551
+ { internalType: 'uint256', name: 'stopLossPrice', type: 'uint256' },
552
+ { internalType: 'uint256', name: 'profitTakePrice', type: 'uint256' },
553
+ ],
554
+ name: 'InvalidLimitOrderPrices',
555
+ type: 'error',
556
+ },
557
+ { inputs: [], name: 'MaxPositionsReached', type: 'error' },
558
+ {
559
+ inputs: [{ internalType: 'address', name: 'caller', type: 'address' }],
560
+ name: 'OnlyAuthorizedCaller',
561
+ type: 'error',
562
+ },
563
+ {
564
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
565
+ name: 'UnauthorizedReceiver',
566
+ type: 'error',
567
+ },
524
568
  ];
@@ -0,0 +1,51 @@
1
+ export declare const OrderAnnouncementModule: ({
2
+ inputs: never[];
3
+ stateMutability: string;
4
+ type: string;
5
+ anonymous?: undefined;
6
+ name?: undefined;
7
+ outputs?: undefined;
8
+ } | {
9
+ anonymous: boolean;
10
+ inputs: {
11
+ indexed: boolean;
12
+ internalType: string;
13
+ name: string;
14
+ type: string;
15
+ }[];
16
+ name: string;
17
+ type: string;
18
+ stateMutability?: undefined;
19
+ outputs?: undefined;
20
+ } | {
21
+ inputs: {
22
+ internalType: string;
23
+ name: string;
24
+ type: string;
25
+ }[];
26
+ name: string;
27
+ outputs: {
28
+ components: {
29
+ internalType: string;
30
+ name: string;
31
+ type: string;
32
+ }[];
33
+ internalType: string;
34
+ name: string;
35
+ type: string;
36
+ }[];
37
+ stateMutability: string;
38
+ type: string;
39
+ anonymous?: undefined;
40
+ } | {
41
+ inputs: never[];
42
+ name: string;
43
+ outputs: {
44
+ internalType: string;
45
+ name: string;
46
+ type: string;
47
+ }[];
48
+ stateMutability: string;
49
+ type: string;
50
+ anonymous?: undefined;
51
+ })[];
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderAnnouncementModule = void 0;
4
+ exports.OrderAnnouncementModule = [
5
+ { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
6
+ {
7
+ anonymous: false,
8
+ inputs: [
9
+ { indexed: false, internalType: 'address', name: 'account', type: 'address' },
10
+ { indexed: false, internalType: 'uint256', name: 'tokenId', type: 'uint256' },
11
+ { indexed: false, internalType: 'uint256', name: 'stopLossPrice', type: 'uint256' },
12
+ { indexed: false, internalType: 'uint256', name: 'profitTakePrice', type: 'uint256' },
13
+ ],
14
+ name: 'LimitOrderAnnounced',
15
+ type: 'event',
16
+ },
17
+ {
18
+ anonymous: false,
19
+ inputs: [
20
+ { indexed: false, internalType: 'address', name: 'account', type: 'address' },
21
+ { indexed: false, internalType: 'uint256', name: 'tokenId', type: 'uint256' },
22
+ ],
23
+ name: 'LimitOrderCancelled',
24
+ type: 'event',
25
+ },
26
+ {
27
+ anonymous: false,
28
+ inputs: [
29
+ { indexed: false, internalType: 'address', name: 'account', type: 'address' },
30
+ { indexed: false, internalType: 'enum OrderType', name: 'orderType', type: 'uint8' },
31
+ { indexed: false, internalType: 'uint256', name: 'keeperFee', type: 'uint256' },
32
+ ],
33
+ name: 'OrderAnnounced',
34
+ type: 'event',
35
+ },
36
+ {
37
+ inputs: [
38
+ { internalType: 'uint256', name: 'tokenId_', type: 'uint256' },
39
+ { internalType: 'address', name: 'positionOwner_', type: 'address' },
40
+ { internalType: 'uint256', name: 'stopLossPrice_', type: 'uint256' },
41
+ { internalType: 'uint256', name: 'profitTakePrice_', type: 'uint256' },
42
+ ],
43
+ name: 'createLimitOrder',
44
+ outputs: [],
45
+ stateMutability: 'nonpayable',
46
+ type: 'function',
47
+ },
48
+ {
49
+ inputs: [{ internalType: 'uint256', name: 'tokenId_', type: 'uint256' }],
50
+ name: 'deleteLimitOrder',
51
+ outputs: [],
52
+ stateMutability: 'nonpayable',
53
+ type: 'function',
54
+ },
55
+ {
56
+ inputs: [{ internalType: 'address', name: 'account_', type: 'address' }],
57
+ name: 'deleteOrder',
58
+ outputs: [],
59
+ stateMutability: 'nonpayable',
60
+ type: 'function',
61
+ },
62
+ {
63
+ inputs: [{ internalType: 'address', name: 'account_', type: 'address' }],
64
+ name: 'getAnnouncedOrder',
65
+ outputs: [
66
+ {
67
+ components: [
68
+ { internalType: 'enum OrderType', name: 'orderType', type: 'uint8' },
69
+ { internalType: 'uint256', name: 'keeperFee', type: 'uint256' },
70
+ { internalType: 'uint64', name: 'executableAtTime', type: 'uint64' },
71
+ { internalType: 'bytes', name: 'orderData', type: 'bytes' },
72
+ ],
73
+ internalType: 'struct Order',
74
+ name: 'order_',
75
+ type: 'tuple',
76
+ },
77
+ ],
78
+ stateMutability: 'view',
79
+ type: 'function',
80
+ },
81
+ {
82
+ inputs: [{ internalType: 'uint256', name: 'tokenId_', type: 'uint256' }],
83
+ name: 'getLimitOrder',
84
+ outputs: [
85
+ {
86
+ components: [
87
+ { internalType: 'enum OrderType', name: 'orderType', type: 'uint8' },
88
+ { internalType: 'uint256', name: 'keeperFee', type: 'uint256' },
89
+ { internalType: 'uint64', name: 'executableAtTime', type: 'uint64' },
90
+ { internalType: 'bytes', name: 'orderData', type: 'bytes' },
91
+ ],
92
+ internalType: 'struct Order',
93
+ name: 'order_',
94
+ type: 'tuple',
95
+ },
96
+ ],
97
+ stateMutability: 'view',
98
+ type: 'function',
99
+ },
100
+ {
101
+ inputs: [],
102
+ name: 'minExecutabilityAge',
103
+ outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
104
+ stateMutability: 'view',
105
+ type: 'function',
106
+ },
107
+ ];
@@ -0,0 +1,35 @@
1
+ export declare const OrderExecutionModule: ({
2
+ inputs: never[];
3
+ stateMutability: string;
4
+ type: string;
5
+ anonymous?: undefined;
6
+ name?: undefined;
7
+ outputs?: undefined;
8
+ } | {
9
+ anonymous: boolean;
10
+ inputs: {
11
+ indexed: boolean;
12
+ internalType: string;
13
+ name: string;
14
+ type: string;
15
+ }[];
16
+ name: string;
17
+ type: string;
18
+ stateMutability?: undefined;
19
+ outputs?: undefined;
20
+ } | {
21
+ inputs: {
22
+ internalType: string;
23
+ name: string;
24
+ type: string;
25
+ }[];
26
+ name: string;
27
+ outputs: {
28
+ internalType: string;
29
+ name: string;
30
+ type: string;
31
+ }[];
32
+ stateMutability: string;
33
+ type: string;
34
+ anonymous?: undefined;
35
+ })[];
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderExecutionModule = void 0;
4
+ exports.OrderExecutionModule = [
5
+ { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
6
+ {
7
+ anonymous: false,
8
+ inputs: [
9
+ { indexed: false, internalType: 'uint256', name: 'tokenId', type: 'uint256' },
10
+ {
11
+ indexed: false,
12
+ internalType: 'enum OrderExecutionModule.LimitOrderExecutionType',
13
+ name: 'executionType',
14
+ type: 'uint8',
15
+ },
16
+ ],
17
+ name: 'LimitOrderExecuted',
18
+ type: 'event',
19
+ },
20
+ {
21
+ anonymous: false,
22
+ inputs: [
23
+ { indexed: false, internalType: 'address', name: 'account', type: 'address' },
24
+ { indexed: false, internalType: 'enum OrderType', name: 'orderType', type: 'uint8' },
25
+ ],
26
+ name: 'OrderCancelled',
27
+ type: 'event',
28
+ },
29
+ {
30
+ anonymous: false,
31
+ inputs: [
32
+ { indexed: false, internalType: 'address', name: 'account', type: 'address' },
33
+ { indexed: false, internalType: 'enum OrderType', name: 'orderType', type: 'uint8' },
34
+ { indexed: false, internalType: 'uint256', name: 'keeperFee', type: 'uint256' },
35
+ ],
36
+ name: 'OrderExecuted',
37
+ type: 'event',
38
+ },
39
+ {
40
+ inputs: [{ internalType: 'address', name: 'account_', type: 'address' }],
41
+ name: 'cancelExistingOrder',
42
+ outputs: [],
43
+ stateMutability: 'nonpayable',
44
+ type: 'function',
45
+ },
46
+ {
47
+ inputs: [{ internalType: 'address', name: 'account_', type: 'address' }],
48
+ name: 'cancelOrderByModule',
49
+ outputs: [],
50
+ stateMutability: 'nonpayable',
51
+ type: 'function',
52
+ },
53
+ {
54
+ inputs: [
55
+ { internalType: 'uint256', name: 'tokenId_', type: 'uint256' },
56
+ { internalType: 'bytes[]', name: 'priceUpdateData_', type: 'bytes[]' },
57
+ ],
58
+ name: 'executeLimitOrder',
59
+ outputs: [],
60
+ stateMutability: 'payable',
61
+ type: 'function',
62
+ },
63
+ {
64
+ inputs: [
65
+ { internalType: 'address', name: 'account_', type: 'address' },
66
+ { internalType: 'bytes[]', name: 'priceUpdateData_', type: 'bytes[]' },
67
+ ],
68
+ name: 'executeOrder',
69
+ outputs: [],
70
+ stateMutability: 'payable',
71
+ type: 'function',
72
+ },
73
+ {
74
+ inputs: [{ internalType: 'address', name: 'account_', type: 'address' }],
75
+ name: 'hasOrderExpired',
76
+ outputs: [{ internalType: 'bool', name: 'expired_', type: 'bool' }],
77
+ stateMutability: 'view',
78
+ type: 'function',
79
+ },
80
+ {
81
+ inputs: [],
82
+ name: 'maxExecutabilityAge',
83
+ outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
84
+ stateMutability: 'view',
85
+ type: 'function',
86
+ },
87
+ ];
@@ -4,5 +4,5 @@ export declare class MultichainConfigRepository {
4
4
  private repository;
5
5
  constructor(repository: Repository<MultichainConfig>);
6
6
  getById(id: number): Promise<MultichainConfig | null>;
7
- getByAppAndCode(appName: string, marketId: string): Promise<MultichainConfig | null>;
7
+ getByAppAndMarket(appName: string, marketId: string): Promise<MultichainConfig | null>;
8
8
  }
@@ -24,7 +24,7 @@ let MultichainConfigRepository = class MultichainConfigRepository {
24
24
  async getById(id) {
25
25
  return this.repository.createQueryBuilder().where('id = :id').setParameter('id', id).take(1).getOne();
26
26
  }
27
- async getByAppAndCode(appName, marketId) {
27
+ async getByAppAndMarket(appName, marketId) {
28
28
  return this.repository
29
29
  .createQueryBuilder()
30
30
  .where('app_name = :appName', { appName: appName })
@@ -6,7 +6,7 @@ export declare class MultichainConfigService {
6
6
  private readonly logger;
7
7
  private readonly configs;
8
8
  constructor(configRepository: MultichainConfigRepository, logger: Logger);
9
- loadConfigs(appName: string, blockChainCode: string): Promise<MultichainConfig | undefined>;
9
+ loadConfigs(appName: string, marketId: string): Promise<MultichainConfig | undefined>;
10
10
  private getConfigFromCache;
11
11
  private putConfigsToCache;
12
12
  }
@@ -18,30 +18,30 @@ let MultichainConfigService = class MultichainConfigService {
18
18
  this.logger = logger;
19
19
  this.configs = new Map();
20
20
  }
21
- async loadConfigs(appName, blockChainCode) {
22
- if (this.getConfigFromCache(appName, blockChainCode)) {
23
- return this.getConfigFromCache(appName, blockChainCode);
21
+ async loadConfigs(appName, marketId) {
22
+ if (this.getConfigFromCache(appName, marketId)) {
23
+ return this.getConfigFromCache(appName, marketId);
24
24
  }
25
25
  else {
26
- const result = await this.configRepository.getByAppAndCode(appName, blockChainCode);
26
+ const result = await this.configRepository.getByAppAndMarket(appName, marketId);
27
27
  if (!result) {
28
- throw new Error(`failed to load multichain config from db for ${appName} code ${blockChainCode}`);
28
+ throw new Error(`failed to load multichain config from db for ${appName} marketId ${marketId}`);
29
29
  }
30
30
  else {
31
- if (!this.getConfigFromCache(appName, blockChainCode)) {
32
- this.putConfigsToCache(appName, blockChainCode, result);
33
- this.logger.log(`multichain config loaded from database for ${appName} code ${blockChainCode}`);
31
+ if (!this.getConfigFromCache(appName, marketId)) {
32
+ this.putConfigsToCache(appName, marketId, result);
33
+ this.logger.log(`multichain config loaded from database for ${appName} marketId ${marketId}`);
34
34
  }
35
- return this.getConfigFromCache(appName, blockChainCode);
35
+ return this.getConfigFromCache(appName, marketId);
36
36
  }
37
37
  }
38
38
  }
39
- getConfigFromCache(appName, blockChainCode) {
40
- const key = appName.concat(blockChainCode);
39
+ getConfigFromCache(appName, marketId) {
40
+ const key = appName.concat(marketId);
41
41
  return this.configs.get(key);
42
42
  }
43
- putConfigsToCache(appName, blockChainCode, config) {
44
- const key = appName.concat(blockChainCode);
43
+ putConfigsToCache(appName, marketId, config) {
44
+ const key = appName.concat(marketId);
45
45
  this.configs.set(key, config);
46
46
  }
47
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/backend-flatcoin-core",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "Backend Flatcoin Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",