@defisaver/automation-sdk 3.0.3 → 3.0.5

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.
Files changed (143) hide show
  1. package/.babelrc +3 -3
  2. package/.editorconfig +9 -9
  3. package/.env.dev +4 -4
  4. package/.eslintignore +6 -6
  5. package/.eslintrc.js +41 -41
  6. package/.tests.sh +2 -2
  7. package/README.md +41 -41
  8. package/esm/abis/Erc20.json +223 -223
  9. package/esm/abis/SubStorage.json +17 -17
  10. package/esm/abis/UniMulticall.json +14 -14
  11. package/esm/abis/index.d.ts +9 -9
  12. package/esm/abis/index.js +30 -30
  13. package/esm/abis/legacy_AaveV2Subscriptions.json +8 -8
  14. package/esm/abis/legacy_AuthCheck.json +8 -8
  15. package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -9
  16. package/esm/abis/legacy_MakerSubscriptions.json +9 -9
  17. package/esm/automation/private/Automation.d.ts +12 -12
  18. package/esm/automation/private/Automation.js +42 -42
  19. package/esm/automation/private/LegacyAutomation.d.ts +25 -25
  20. package/esm/automation/private/LegacyAutomation.js +118 -118
  21. package/esm/automation/private/LegacyProtocol.d.ts +22 -22
  22. package/esm/automation/private/LegacyProtocol.js +41 -41
  23. package/esm/automation/private/LegacyProtocol.test.d.ts +1 -1
  24. package/esm/automation/private/LegacyProtocol.test.js +25 -25
  25. package/esm/automation/private/Protocol.d.ts +22 -22
  26. package/esm/automation/private/Protocol.js +41 -41
  27. package/esm/automation/private/Protocol.test.d.ts +1 -1
  28. package/esm/automation/private/Protocol.test.js +25 -25
  29. package/esm/automation/private/StrategiesAutomation.d.ts +33 -33
  30. package/esm/automation/private/StrategiesAutomation.js +181 -181
  31. package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
  32. package/esm/automation/private/StrategiesAutomation.test.js +671 -671
  33. package/esm/automation/public/ArbitrumStrategies.d.ts +5 -5
  34. package/esm/automation/public/ArbitrumStrategies.js +13 -13
  35. package/esm/automation/public/EthereumStrategies.d.ts +5 -5
  36. package/esm/automation/public/EthereumStrategies.js +13 -13
  37. package/esm/automation/public/OptimismStrategies.d.ts +5 -5
  38. package/esm/automation/public/OptimismStrategies.js +13 -13
  39. package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
  40. package/esm/automation/public/legacy/LegacyAaveAutomation.js +20 -20
  41. package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
  42. package/esm/automation/public/legacy/LegacyCompoundAutomation.js +20 -20
  43. package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
  44. package/esm/automation/public/legacy/LegacyMakerAutomation.js +20 -20
  45. package/esm/configuration.d.ts +1 -1
  46. package/esm/configuration.js +12 -12
  47. package/esm/constants/index.d.ts +45 -45
  48. package/esm/constants/index.js +395 -365
  49. package/esm/index.d.ts +22 -22
  50. package/esm/index.js +63 -63
  51. package/esm/services/contractService.d.ts +12 -12
  52. package/esm/services/contractService.js +54 -54
  53. package/esm/services/ethereumService.d.ts +7 -7
  54. package/esm/services/ethereumService.js +49 -49
  55. package/esm/services/ethereumService.test.d.ts +1 -1
  56. package/esm/services/ethereumService.test.js +242 -242
  57. package/esm/services/strategiesService.d.ts +2 -2
  58. package/esm/services/strategiesService.js +701 -698
  59. package/esm/services/strategiesService.test.d.ts +1 -1
  60. package/esm/services/strategiesService.test.js +110 -110
  61. package/esm/services/strategySubService.d.ts +87 -87
  62. package/esm/services/strategySubService.js +257 -252
  63. package/esm/services/strategySubService.test.d.ts +1 -1
  64. package/esm/services/strategySubService.test.js +892 -890
  65. package/esm/services/subDataService.d.ts +181 -181
  66. package/esm/services/subDataService.js +442 -442
  67. package/esm/services/subDataService.test.d.ts +1 -1
  68. package/esm/services/subDataService.test.js +1223 -1223
  69. package/esm/services/triggerService.d.ts +191 -191
  70. package/esm/services/triggerService.js +367 -367
  71. package/esm/services/triggerService.test.d.ts +1 -1
  72. package/esm/services/triggerService.test.js +926 -926
  73. package/esm/services/utils.d.ts +25 -25
  74. package/esm/services/utils.js +131 -131
  75. package/esm/services/utils.test.d.ts +1 -1
  76. package/esm/services/utils.test.js +376 -376
  77. package/esm/types/contracts/generated/Erc20.d.ts +53 -53
  78. package/esm/types/contracts/generated/Erc20.js +5 -5
  79. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
  80. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +5 -5
  81. package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
  82. package/esm/types/contracts/generated/Legacy_AuthCheck.js +5 -5
  83. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
  84. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +5 -5
  85. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
  86. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +5 -5
  87. package/esm/types/contracts/generated/SubStorage.d.ts +114 -114
  88. package/esm/types/contracts/generated/SubStorage.js +5 -5
  89. package/esm/types/contracts/generated/UniMulticall.d.ts +55 -55
  90. package/esm/types/contracts/generated/UniMulticall.js +5 -5
  91. package/esm/types/contracts/generated/index.d.ts +7 -7
  92. package/esm/types/contracts/generated/index.js +2 -2
  93. package/esm/types/contracts/generated/types.d.ts +54 -54
  94. package/esm/types/contracts/generated/types.js +2 -2
  95. package/esm/types/enums.d.ts +160 -154
  96. package/esm/types/enums.js +180 -174
  97. package/esm/types/index.d.ts +217 -217
  98. package/esm/types/index.js +2 -2
  99. package/package.json +71 -71
  100. package/scripts/generateContractTypes.js +39 -39
  101. package/src/abis/Erc20.json +222 -222
  102. package/src/abis/SubStorage.json +17 -17
  103. package/src/abis/UniMulticall.json +14 -14
  104. package/src/abis/index.ts +28 -28
  105. package/src/abis/legacy_AaveV2Subscriptions.json +7 -7
  106. package/src/abis/legacy_AuthCheck.json +7 -7
  107. package/src/abis/legacy_CompoundV2Subscriptions.json +8 -8
  108. package/src/abis/legacy_MakerSubscriptions.json +8 -8
  109. package/src/automation/private/Automation.ts +44 -44
  110. package/src/automation/private/LegacyAutomation.ts +135 -135
  111. package/src/automation/private/LegacyProtocol.test.ts +23 -23
  112. package/src/automation/private/LegacyProtocol.ts +51 -51
  113. package/src/automation/private/Protocol.test.ts +23 -23
  114. package/src/automation/private/Protocol.ts +51 -51
  115. package/src/automation/private/StrategiesAutomation.test.ts +663 -663
  116. package/src/automation/private/StrategiesAutomation.ts +242 -242
  117. package/src/automation/public/ArbitrumStrategies.ts +10 -10
  118. package/src/automation/public/EthereumStrategies.ts +10 -10
  119. package/src/automation/public/OptimismStrategies.ts +10 -10
  120. package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -20
  121. package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -20
  122. package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -20
  123. package/src/configuration.ts +8 -8
  124. package/src/constants/index.ts +409 -379
  125. package/src/index.ts +38 -38
  126. package/src/services/contractService.ts +77 -77
  127. package/src/services/ethereumService.test.ts +257 -257
  128. package/src/services/ethereumService.ts +69 -69
  129. package/src/services/strategiesService.test.ts +105 -105
  130. package/src/services/strategiesService.ts +905 -901
  131. package/src/services/strategySubService.test.ts +1063 -1060
  132. package/src/services/strategySubService.ts +496 -492
  133. package/src/services/subDataService.test.ts +1324 -1324
  134. package/src/services/subDataService.ts +594 -593
  135. package/src/services/triggerService.test.ts +1004 -1004
  136. package/src/services/triggerService.ts +449 -449
  137. package/src/services/utils.test.ts +430 -430
  138. package/src/services/utils.ts +103 -103
  139. package/src/types/enums.ts +174 -168
  140. package/src/types/index.ts +262 -262
  141. package/tsconfig.json +79 -79
  142. package/umd/index.js +65 -24
  143. package/webpack.umd.js +52 -52
@@ -1,217 +1,217 @@
1
- import type Web3 from 'web3';
2
- import type { AbiItem } from 'web3-utils';
3
- import type { BaseContract, BlockType } from './contracts/generated/types';
4
- import type { Subscribe, StrategyModel } from './contracts/generated/SubStorage';
5
- import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState } from './enums';
6
- export type PlaceholderType = any;
7
- export type EthereumAddress = string;
8
- export type BlockNumber = BlockType;
9
- export declare namespace Utils {
10
- type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
11
- type WithRequired<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>;
12
- type ValuesOf<E> = E[keyof E];
13
- type EnumUnion<T> = {
14
- [k in keyof T]: ValuesOf<T[k]>;
15
- }[keyof T];
16
- }
17
- export declare namespace Contract {
18
- interface Json {
19
- abi: AbiItem[];
20
- networks?: {
21
- [key in ChainId as string]: {
22
- createdBlock?: number;
23
- address: EthereumAddress;
24
- };
25
- };
26
- }
27
- interface WithMeta<T> {
28
- abi: AbiItem[];
29
- address: EthereumAddress;
30
- createdBlock: BlockNumber;
31
- contract: T;
32
- }
33
- }
34
- export declare namespace Multicall {
35
- interface Calls {
36
- abiItem: AbiItem;
37
- target: EthereumAddress;
38
- gasLimit?: number;
39
- params: any[];
40
- }
41
- interface FormattedCalls {
42
- callData: string;
43
- target: EthereumAddress;
44
- gasLimit: number;
45
- }
46
- type Payload = any[];
47
- }
48
- interface _SubscriptionOptions {
49
- toBlock: BlockNumber;
50
- fromBlock: BlockNumber;
51
- mergeSubs: boolean;
52
- enabledOnly: boolean;
53
- unexpiredOnly: boolean;
54
- }
55
- export type SubscriptionOptions = Partial<_SubscriptionOptions>;
56
- export declare namespace Interfaces {
57
- interface ProtocolBase {
58
- id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation;
59
- name: string;
60
- slug: string;
61
- fullName: string;
62
- version: string;
63
- }
64
- interface Protocol extends ProtocolBase {
65
- id: ProtocolIdentifiers.StrategiesAutomation;
66
- }
67
- interface LegacyProtocol extends ProtocolBase {
68
- id: ProtocolIdentifiers.LegacyAutomation;
69
- }
70
- interface Automation {
71
- provider: Web3;
72
- providerFork: Web3;
73
- }
74
- interface LegacyAutomation<T extends BaseContract> {
75
- provider: Web3;
76
- monitorAddress: EthereumAddress;
77
- protocol: Interfaces.LegacyProtocol;
78
- subscriptionsJson: Contract.WithMeta<T>;
79
- }
80
- }
81
- export interface Strategy<T = StrategyOrBundleIds> {
82
- strategyOrBundleId: T;
83
- strategyId: Strategies.Identifiers | Strategies.IdOverrides;
84
- protocol: Interfaces.Protocol;
85
- isBundle?: boolean;
86
- }
87
- export interface BundleOrStrategy<T = StrategyOrBundleIds> extends Strategy<T> {
88
- bundleId?: string;
89
- bundleName?: string;
90
- }
91
- export type TriggerData = StrategyModel.StrategySubStructOutputStruct['triggerData'];
92
- export type SubData = StrategyModel.StrategySubStructOutputStruct['subData'];
93
- export declare namespace Position {
94
- namespace Specific {
95
- interface Base {
96
- subId1?: number;
97
- subId2?: number;
98
- mergeWithId?: Strategies.Identifiers;
99
- mergeId?: Strategies.Identifiers;
100
- }
101
- interface RatioProtection extends Base {
102
- triggerRepayRatio?: number;
103
- targetRepayRatio?: number;
104
- repayEnabled?: boolean;
105
- triggerBoostRatio?: number;
106
- targetBoostRatio?: number;
107
- boostEnabled?: boolean;
108
- }
109
- interface CloseOnPrice extends Base {
110
- price: string;
111
- closeToAssetAddr: EthereumAddress;
112
- }
113
- interface CloseOnPriceAave extends Base {
114
- collAsset: EthereumAddress;
115
- collAssetId: number;
116
- debtAsset: EthereumAddress;
117
- debtAssetId: number;
118
- baseToken: EthereumAddress;
119
- quoteToken: EthereumAddress;
120
- price: string;
121
- ratioState: RatioState;
122
- }
123
- interface CloseOnPriceWithMaximumGasPriceAave extends Base {
124
- collAsset: EthereumAddress;
125
- collAssetId: number;
126
- debtAsset: EthereumAddress;
127
- debtAssetId: number;
128
- baseToken: EthereumAddress;
129
- quoteToken: EthereumAddress;
130
- price: string;
131
- maximumGasPrice: string;
132
- ratioState: RatioState;
133
- }
134
- interface TrailingStop extends Base {
135
- roundId: number;
136
- triggerPercentage: number;
137
- closeToAssetAddr: EthereumAddress;
138
- }
139
- interface DebtInFrontRepay extends Base {
140
- debtInFrontMin: string;
141
- targetRepayRatioIncrease: number;
142
- }
143
- interface LeverageManagementCrvUSD extends Base {
144
- subHashBoost?: string;
145
- subHashRepay?: string;
146
- }
147
- }
148
- type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD;
149
- interface Automated {
150
- chainId: ChainId;
151
- positionId: string;
152
- owner: EthereumAddress;
153
- subId: number;
154
- subIds?: number[];
155
- isEnabled?: boolean;
156
- subHash: string;
157
- blockNumber: BlockNumber;
158
- protocol: Interfaces.Protocol;
159
- strategy: BundleOrStrategy;
160
- strategyData: {
161
- encoded: {
162
- triggerData: TriggerData;
163
- subData: SubData;
164
- };
165
- decoded: {
166
- triggerData: PlaceholderType;
167
- subData: PlaceholderType;
168
- };
169
- };
170
- specific: SpecificAny;
171
- }
172
- interface LegacyAutomated {
173
- chainId: ChainId;
174
- owner: EthereumAddress;
175
- isEnabled: boolean;
176
- protocol: Interfaces.LegacyProtocol;
177
- strategy: {
178
- strategyId: string;
179
- protocol: Interfaces.Protocol;
180
- };
181
- specific: any;
182
- }
183
- }
184
- type StrategyInfo<T extends number> = Record<T, Strategy<T>>;
185
- export type MainnetStrategiesInfo = StrategyInfo<Strategies.MainnetIds>;
186
- export type OptimismStrategiesInfo = StrategyInfo<Strategies.OptimismIds>;
187
- export type ArbitrumStrategiesInfo = StrategyInfo<Strategies.ArbitrumIds>;
188
- export type StrategyInfoUnion = MainnetStrategiesInfo | OptimismStrategiesInfo | ArbitrumStrategiesInfo;
189
- type BundleInfo<T extends number> = Record<T, BundleOrStrategy<T>>;
190
- export type MainnetBundleInfo = BundleInfo<Bundles.MainnetIds>;
191
- export type OptimismBundleInfo = BundleInfo<Bundles.OptimismIds>;
192
- export type ArbitrumBundleInfo = BundleInfo<Bundles.ArbitrumIds>;
193
- export type BundleInfoUnion = MainnetBundleInfo | OptimismBundleInfo | ArbitrumBundleInfo;
194
- export interface StrategiesInfo {
195
- [ChainId.Ethereum]: MainnetStrategiesInfo;
196
- [ChainId.Optimism]: OptimismStrategiesInfo;
197
- [ChainId.Arbitrum]: ArbitrumStrategiesInfo;
198
- }
199
- export interface BundlesInfo {
200
- [ChainId.Ethereum]: MainnetBundleInfo;
201
- [ChainId.Optimism]: OptimismBundleInfo;
202
- [ChainId.Arbitrum]: ArbitrumBundleInfo;
203
- }
204
- export type StrategyOrBundleIds = typeof Strategies.MainnetIds[keyof typeof Strategies.MainnetIds] | typeof Strategies.OptimismIds[keyof typeof Strategies.OptimismIds] | typeof Strategies.ArbitrumIds[keyof typeof Strategies.ArbitrumIds] | typeof Bundles.MainnetIds[keyof typeof Bundles.MainnetIds] | typeof Bundles.OptimismIds[keyof typeof Bundles.OptimismIds] | typeof Bundles.ArbitrumIds[keyof typeof Bundles.ArbitrumIds];
205
- export interface ParseData {
206
- chainId: ChainId;
207
- blockNumber: BlockNumber;
208
- subscriptionEventData: Subscribe['returnValues'];
209
- strategiesSubsData: StrategyModel.StoredSubDataStructOutputStruct;
210
- }
211
- type MapToProtocolVersion<T> = {
212
- [i in ProtocolIdentifiers.StrategiesAutomation]: {
213
- [key in Strategies.Identifiers as string]: T;
214
- };
215
- };
216
- export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData, chainId: ChainId) => Position.Automated>;
217
- export {};
1
+ import type Web3 from 'web3';
2
+ import type { AbiItem } from 'web3-utils';
3
+ import type { BaseContract, BlockType } from './contracts/generated/types';
4
+ import type { Subscribe, StrategyModel } from './contracts/generated/SubStorage';
5
+ import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState } from './enums';
6
+ export type PlaceholderType = any;
7
+ export type EthereumAddress = string;
8
+ export type BlockNumber = BlockType;
9
+ export declare namespace Utils {
10
+ type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
11
+ type WithRequired<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>;
12
+ type ValuesOf<E> = E[keyof E];
13
+ type EnumUnion<T> = {
14
+ [k in keyof T]: ValuesOf<T[k]>;
15
+ }[keyof T];
16
+ }
17
+ export declare namespace Contract {
18
+ interface Json {
19
+ abi: AbiItem[];
20
+ networks?: {
21
+ [key in ChainId as string]: {
22
+ createdBlock?: number;
23
+ address: EthereumAddress;
24
+ };
25
+ };
26
+ }
27
+ interface WithMeta<T> {
28
+ abi: AbiItem[];
29
+ address: EthereumAddress;
30
+ createdBlock: BlockNumber;
31
+ contract: T;
32
+ }
33
+ }
34
+ export declare namespace Multicall {
35
+ interface Calls {
36
+ abiItem: AbiItem;
37
+ target: EthereumAddress;
38
+ gasLimit?: number;
39
+ params: any[];
40
+ }
41
+ interface FormattedCalls {
42
+ callData: string;
43
+ target: EthereumAddress;
44
+ gasLimit: number;
45
+ }
46
+ type Payload = any[];
47
+ }
48
+ interface _SubscriptionOptions {
49
+ toBlock: BlockNumber;
50
+ fromBlock: BlockNumber;
51
+ mergeSubs: boolean;
52
+ enabledOnly: boolean;
53
+ unexpiredOnly: boolean;
54
+ }
55
+ export type SubscriptionOptions = Partial<_SubscriptionOptions>;
56
+ export declare namespace Interfaces {
57
+ interface ProtocolBase {
58
+ id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation;
59
+ name: string;
60
+ slug: string;
61
+ fullName: string;
62
+ version: string;
63
+ }
64
+ interface Protocol extends ProtocolBase {
65
+ id: ProtocolIdentifiers.StrategiesAutomation;
66
+ }
67
+ interface LegacyProtocol extends ProtocolBase {
68
+ id: ProtocolIdentifiers.LegacyAutomation;
69
+ }
70
+ interface Automation {
71
+ provider: Web3;
72
+ providerFork: Web3;
73
+ }
74
+ interface LegacyAutomation<T extends BaseContract> {
75
+ provider: Web3;
76
+ monitorAddress: EthereumAddress;
77
+ protocol: Interfaces.LegacyProtocol;
78
+ subscriptionsJson: Contract.WithMeta<T>;
79
+ }
80
+ }
81
+ export interface Strategy<T = StrategyOrBundleIds> {
82
+ strategyOrBundleId: T;
83
+ strategyId: Strategies.Identifiers | Strategies.IdOverrides;
84
+ protocol: Interfaces.Protocol;
85
+ isBundle?: boolean;
86
+ }
87
+ export interface BundleOrStrategy<T = StrategyOrBundleIds> extends Strategy<T> {
88
+ bundleId?: string;
89
+ bundleName?: string;
90
+ }
91
+ export type TriggerData = StrategyModel.StrategySubStructOutputStruct['triggerData'];
92
+ export type SubData = StrategyModel.StrategySubStructOutputStruct['subData'];
93
+ export declare namespace Position {
94
+ namespace Specific {
95
+ interface Base {
96
+ subId1?: number;
97
+ subId2?: number;
98
+ mergeWithId?: Strategies.Identifiers;
99
+ mergeId?: Strategies.Identifiers;
100
+ }
101
+ interface RatioProtection extends Base {
102
+ triggerRepayRatio?: number;
103
+ targetRepayRatio?: number;
104
+ repayEnabled?: boolean;
105
+ triggerBoostRatio?: number;
106
+ targetBoostRatio?: number;
107
+ boostEnabled?: boolean;
108
+ }
109
+ interface CloseOnPrice extends Base {
110
+ price: string;
111
+ closeToAssetAddr: EthereumAddress;
112
+ }
113
+ interface CloseOnPriceAave extends Base {
114
+ collAsset: EthereumAddress;
115
+ collAssetId: number;
116
+ debtAsset: EthereumAddress;
117
+ debtAssetId: number;
118
+ baseToken: EthereumAddress;
119
+ quoteToken: EthereumAddress;
120
+ price: string;
121
+ ratioState: RatioState;
122
+ }
123
+ interface CloseOnPriceWithMaximumGasPriceAave extends Base {
124
+ collAsset: EthereumAddress;
125
+ collAssetId: number;
126
+ debtAsset: EthereumAddress;
127
+ debtAssetId: number;
128
+ baseToken: EthereumAddress;
129
+ quoteToken: EthereumAddress;
130
+ price: string;
131
+ maximumGasPrice: string;
132
+ ratioState: RatioState;
133
+ }
134
+ interface TrailingStop extends Base {
135
+ roundId: number;
136
+ triggerPercentage: number;
137
+ closeToAssetAddr: EthereumAddress;
138
+ }
139
+ interface DebtInFrontRepay extends Base {
140
+ debtInFrontMin: string;
141
+ targetRepayRatioIncrease: number;
142
+ }
143
+ interface LeverageManagementCrvUSD extends Base {
144
+ subHashBoost?: string;
145
+ subHashRepay?: string;
146
+ }
147
+ }
148
+ type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD;
149
+ interface Automated {
150
+ chainId: ChainId;
151
+ positionId: string;
152
+ owner: EthereumAddress;
153
+ subId: number;
154
+ subIds?: number[];
155
+ isEnabled?: boolean;
156
+ subHash: string;
157
+ blockNumber: BlockNumber;
158
+ protocol: Interfaces.Protocol;
159
+ strategy: BundleOrStrategy;
160
+ strategyData: {
161
+ encoded: {
162
+ triggerData: TriggerData;
163
+ subData: SubData;
164
+ };
165
+ decoded: {
166
+ triggerData: PlaceholderType;
167
+ subData: PlaceholderType;
168
+ };
169
+ };
170
+ specific: SpecificAny;
171
+ }
172
+ interface LegacyAutomated {
173
+ chainId: ChainId;
174
+ owner: EthereumAddress;
175
+ isEnabled: boolean;
176
+ protocol: Interfaces.LegacyProtocol;
177
+ strategy: {
178
+ strategyId: string;
179
+ protocol: Interfaces.Protocol;
180
+ };
181
+ specific: any;
182
+ }
183
+ }
184
+ type StrategyInfo<T extends number> = Record<T, Strategy<T>>;
185
+ export type MainnetStrategiesInfo = StrategyInfo<Strategies.MainnetIds>;
186
+ export type OptimismStrategiesInfo = StrategyInfo<Strategies.OptimismIds>;
187
+ export type ArbitrumStrategiesInfo = StrategyInfo<Strategies.ArbitrumIds>;
188
+ export type StrategyInfoUnion = MainnetStrategiesInfo | OptimismStrategiesInfo | ArbitrumStrategiesInfo;
189
+ type BundleInfo<T extends number> = Record<T, BundleOrStrategy<T>>;
190
+ export type MainnetBundleInfo = BundleInfo<Bundles.MainnetIds>;
191
+ export type OptimismBundleInfo = BundleInfo<Bundles.OptimismIds>;
192
+ export type ArbitrumBundleInfo = BundleInfo<Bundles.ArbitrumIds>;
193
+ export type BundleInfoUnion = MainnetBundleInfo | OptimismBundleInfo | ArbitrumBundleInfo;
194
+ export interface StrategiesInfo {
195
+ [ChainId.Ethereum]: MainnetStrategiesInfo;
196
+ [ChainId.Optimism]: OptimismStrategiesInfo;
197
+ [ChainId.Arbitrum]: ArbitrumStrategiesInfo;
198
+ }
199
+ export interface BundlesInfo {
200
+ [ChainId.Ethereum]: MainnetBundleInfo;
201
+ [ChainId.Optimism]: OptimismBundleInfo;
202
+ [ChainId.Arbitrum]: ArbitrumBundleInfo;
203
+ }
204
+ export type StrategyOrBundleIds = typeof Strategies.MainnetIds[keyof typeof Strategies.MainnetIds] | typeof Strategies.OptimismIds[keyof typeof Strategies.OptimismIds] | typeof Strategies.ArbitrumIds[keyof typeof Strategies.ArbitrumIds] | typeof Bundles.MainnetIds[keyof typeof Bundles.MainnetIds] | typeof Bundles.OptimismIds[keyof typeof Bundles.OptimismIds] | typeof Bundles.ArbitrumIds[keyof typeof Bundles.ArbitrumIds];
205
+ export interface ParseData {
206
+ chainId: ChainId;
207
+ blockNumber: BlockNumber;
208
+ subscriptionEventData: Subscribe['returnValues'];
209
+ strategiesSubsData: StrategyModel.StoredSubDataStructOutputStruct;
210
+ }
211
+ type MapToProtocolVersion<T> = {
212
+ [i in ProtocolIdentifiers.StrategiesAutomation]: {
213
+ [key in Strategies.Identifiers as string]: T;
214
+ };
215
+ };
216
+ export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData, chainId: ChainId) => Position.Automated>;
217
+ export {};
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
- {
2
- "name": "@defisaver/automation-sdk",
3
- "version": "3.0.3",
4
- "description": "",
5
- "main": "./umd/index.js",
6
- "module": "./esm/index.js",
7
- "types": "./esm/index.d.ts",
8
- "scripts": {
9
- "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\"",
10
- "build:esm": "rm -rf esm && tsc -b",
11
- "build:umd": "rm -rf umd && webpack --config=webpack.umd.js",
12
- "build": "npm run lint && npm run build:umd && npm run build:esm",
13
- "documentMD": "npx typedoc --plugin typedoc-plugin-markdown --out docs/md",
14
- "document": "npx typedoc --out docs/default",
15
- "lint": "node_modules/.bin/eslint ./src",
16
- "gtc": "node scripts/generateContractTypes.js",
17
- "prepare": "husky install && npm run gtc",
18
- "test": "./.tests.sh"
19
- },
20
- "author": "DeFi Saver",
21
- "repository": "https://github.com/defisaver/automation-sdk",
22
- "license": "ISC",
23
- "dependencies": {
24
- "@defisaver/eslint-config": "^1.0.1",
25
- "@defisaver/sdk": "^1.0.61",
26
- "@defisaver/tokens": "^1.5.3",
27
- "@ethersproject/address": "^5.0.10",
28
- "@ethersproject/solidity": "^5.0.9",
29
- "decimal.js": "^10.4.3",
30
- "lodash": "^4.17.21",
31
- "web3-eth-abi": "^1.10.2",
32
- "web3-utils": "^1.10.2"
33
- },
34
- "devDependencies": {
35
- "@babel/core": "^7.12.10",
36
- "@babel/eslint-parser": "^7.12.17",
37
- "@babel/preset-env": "^7.12.11",
38
- "@babel/preset-typescript": "^7.12.7",
39
- "typechain-target-web3-v1-3mihai3": "^6.0.1",
40
- "@types/chai": "^4.3.6",
41
- "@types/lodash": "^4.14.191",
42
- "@types/mocha": "^10.0.1",
43
- "@types/node": "^18.11.15",
44
- "@typescript-eslint/eslint-plugin": "^5.42.0",
45
- "@typescript-eslint/parser": "^5.42.0",
46
- "babel-loader": "^8.2.2",
47
- "chai": "^4.3.8",
48
- "dotenv": "^16.3.1",
49
- "eslint": "8.22.0",
50
- "eslint-config-airbnb": "^18.0.2",
51
- "eslint-config-airbnb-typescript": "^17.0.0",
52
- "eslint-import-resolver-typescript": "^3.5.1",
53
- "eslint-plugin-import": "^2.22.0",
54
- "eslint-plugin-jsx-a11y": "^6.6.1",
55
- "eslint-plugin-react": "^7.31.11",
56
- "husky": "^8.0.0",
57
- "jsdoc-to-markdown": "^6.0.1",
58
- "mocha": "^10.2.0",
59
- "react": "^18.2.0",
60
- "ts-node": "^10.9.1",
61
- "typechain": "^8.1.0",
62
- "typedoc": "^0.23.20",
63
- "typedoc-plugin-markdown": "^3.13.6",
64
- "typescript": "^4.8.4",
65
- "web3": "^1.10.2",
66
- "web3-eth-contract": "^1.8.1",
67
- "web3-types": "^1.1.1",
68
- "webpack": "^5.76.0",
69
- "webpack-cli": "^4.10.0"
70
- }
71
- }
1
+ {
2
+ "name": "@defisaver/automation-sdk",
3
+ "version": "3.0.5",
4
+ "description": "",
5
+ "main": "./umd/index.js",
6
+ "module": "./esm/index.js",
7
+ "types": "./esm/index.d.ts",
8
+ "scripts": {
9
+ "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\"",
10
+ "build:esm": "rm -rf esm && tsc -b",
11
+ "build:umd": "rm -rf umd && webpack --config=webpack.umd.js",
12
+ "build": "npm run lint && npm run build:umd && npm run build:esm",
13
+ "documentMD": "npx typedoc --plugin typedoc-plugin-markdown --out docs/md",
14
+ "document": "npx typedoc --out docs/default",
15
+ "lint": "eslint ./src",
16
+ "gtc": "node scripts/generateContractTypes.js",
17
+ "prepare": "husky install && npm run gtc",
18
+ "test": "./.tests.sh"
19
+ },
20
+ "author": "DeFi Saver",
21
+ "repository": "https://github.com/defisaver/automation-sdk",
22
+ "license": "ISC",
23
+ "dependencies": {
24
+ "@defisaver/eslint-config": "^1.0.1",
25
+ "@defisaver/sdk": "^1.0.61",
26
+ "@defisaver/tokens": "^1.5.3",
27
+ "@ethersproject/address": "^5.0.10",
28
+ "@ethersproject/solidity": "^5.0.9",
29
+ "decimal.js": "^10.4.3",
30
+ "lodash": "^4.17.21",
31
+ "web3-eth-abi": "^1.10.2",
32
+ "web3-utils": "^1.10.2"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/core": "^7.12.10",
36
+ "@babel/eslint-parser": "^7.12.17",
37
+ "@babel/preset-env": "^7.12.11",
38
+ "@babel/preset-typescript": "^7.12.7",
39
+ "typechain-target-web3-v1-3mihai3": "^6.0.1",
40
+ "@types/chai": "^4.3.6",
41
+ "@types/lodash": "^4.14.191",
42
+ "@types/mocha": "^10.0.1",
43
+ "@types/node": "^18.11.15",
44
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
45
+ "@typescript-eslint/parser": "^5.42.0",
46
+ "babel-loader": "^8.2.2",
47
+ "chai": "^4.3.8",
48
+ "dotenv": "^16.3.1",
49
+ "eslint": "8.22.0",
50
+ "eslint-config-airbnb": "^18.0.2",
51
+ "eslint-config-airbnb-typescript": "^17.0.0",
52
+ "eslint-import-resolver-typescript": "^3.5.1",
53
+ "eslint-plugin-import": "^2.22.0",
54
+ "eslint-plugin-jsx-a11y": "^6.6.1",
55
+ "eslint-plugin-react": "^7.31.11",
56
+ "husky": "^8.0.0",
57
+ "jsdoc-to-markdown": "^6.0.1",
58
+ "mocha": "^10.2.0",
59
+ "react": "^18.2.0",
60
+ "ts-node": "^10.9.1",
61
+ "typechain": "^8.1.0",
62
+ "typedoc": "^0.23.20",
63
+ "typedoc-plugin-markdown": "^3.13.6",
64
+ "typescript": "^4.8.4",
65
+ "web3": "^1.10.2",
66
+ "web3-eth-contract": "^1.8.1",
67
+ "web3-types": "^1.1.1",
68
+ "webpack": "^5.76.0",
69
+ "webpack-cli": "^4.10.0"
70
+ }
71
+ }
@@ -1,39 +1,39 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- const { runTypeChain, glob } = require('typechain');
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- const abisFolder = path.resolve(__dirname, '../src/abis/');
7
-
8
- async function main() {
9
- const abiDir = path.join(__dirname, 'temp');
10
- const contractDir = path.join(__dirname, '..', 'src', 'types', 'contracts', 'generated');
11
- try {
12
- fs.mkdirSync(abiDir);
13
-
14
- fs.readdirSync(abisFolder).forEach(file => {
15
- if (file === 'index.ts') return;
16
- // eslint-disable-next-line import/no-dynamic-require
17
- const json = require(`${abisFolder}/${file}`);
18
- if (json.abi !== undefined) {
19
- fs.writeFileSync(path.join(abiDir, file), JSON.stringify(json.abi), 'utf8');
20
- }
21
- });
22
-
23
- const allFiles = glob(path.join(abiDir), ['*.json']);
24
- fs.rmSync(contractDir, { recursive: true, force: true });
25
-
26
- await runTypeChain({
27
- cwd: contractDir,
28
- filesToProcess: allFiles,
29
- allFiles,
30
- outDir: '.',
31
- target: 'web3-v1-3mihai3',
32
- });
33
- } catch (err) {
34
- console.error(err);
35
- }
36
- fs.rmSync(abiDir, { recursive: true, force: true });
37
- }
38
-
39
- main().catch(console.error);
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ const { runTypeChain, glob } = require('typechain');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const abisFolder = path.resolve(__dirname, '../src/abis/');
7
+
8
+ async function main() {
9
+ const abiDir = path.join(__dirname, 'temp');
10
+ const contractDir = path.join(__dirname, '..', 'src', 'types', 'contracts', 'generated');
11
+ try {
12
+ fs.mkdirSync(abiDir);
13
+
14
+ fs.readdirSync(abisFolder).forEach(file => {
15
+ if (file === 'index.ts') return;
16
+ // eslint-disable-next-line import/no-dynamic-require
17
+ const json = require(`${abisFolder}/${file}`);
18
+ if (json.abi !== undefined) {
19
+ fs.writeFileSync(path.join(abiDir, file), JSON.stringify(json.abi), 'utf8');
20
+ }
21
+ });
22
+
23
+ const allFiles = glob(path.join(abiDir), ['*.json']);
24
+ fs.rmSync(contractDir, { recursive: true, force: true });
25
+
26
+ await runTypeChain({
27
+ cwd: contractDir,
28
+ filesToProcess: allFiles,
29
+ allFiles,
30
+ outDir: '.',
31
+ target: 'web3-v1-3mihai3',
32
+ });
33
+ } catch (err) {
34
+ console.error(err);
35
+ }
36
+ fs.rmSync(abiDir, { recursive: true, force: true });
37
+ }
38
+
39
+ main().catch(console.error);