@defisaver/automation-sdk 1.0.1

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 (123) hide show
  1. package/.babelrc +3 -0
  2. package/.editorconfig +9 -0
  3. package/.eslintignore +7 -0
  4. package/.eslintrc.js +104 -0
  5. package/esm/abis/Erc20.json +223 -0
  6. package/esm/abis/SubStorage.json +17 -0
  7. package/esm/abis/UniMulticall.json +14 -0
  8. package/esm/abis/index.d.ts +9 -0
  9. package/esm/abis/index.js +18 -0
  10. package/esm/abis/legacy_AaveV2Subscriptions.json +8 -0
  11. package/esm/abis/legacy_AuthCheck.json +8 -0
  12. package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -0
  13. package/esm/abis/legacy_MakerSubscriptions.json +9 -0
  14. package/esm/automation/private/Automation.d.ts +12 -0
  15. package/esm/automation/private/Automation.js +39 -0
  16. package/esm/automation/private/LegacyAutomation.d.ts +25 -0
  17. package/esm/automation/private/LegacyAutomation.js +102 -0
  18. package/esm/automation/private/LegacyProtocol.d.ts +20 -0
  19. package/esm/automation/private/LegacyProtocol.js +34 -0
  20. package/esm/automation/private/Protocol.d.ts +20 -0
  21. package/esm/automation/private/Protocol.js +34 -0
  22. package/esm/automation/private/StrategiesAutomation.d.ts +24 -0
  23. package/esm/automation/private/StrategiesAutomation.js +111 -0
  24. package/esm/automation/public/ArbitrumStrategies.d.ts +5 -0
  25. package/esm/automation/public/ArbitrumStrategies.js +7 -0
  26. package/esm/automation/public/EthereumStrategies.d.ts +5 -0
  27. package/esm/automation/public/EthereumStrategies.js +7 -0
  28. package/esm/automation/public/OptimismStrategies.d.ts +5 -0
  29. package/esm/automation/public/OptimismStrategies.js +7 -0
  30. package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -0
  31. package/esm/automation/public/legacy/LegacyAaveAutomation.js +14 -0
  32. package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -0
  33. package/esm/automation/public/legacy/LegacyCompoundAutomation.js +14 -0
  34. package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -0
  35. package/esm/automation/public/legacy/LegacyMakerAutomation.js +14 -0
  36. package/esm/configuration.d.ts +1 -0
  37. package/esm/configuration.js +9 -0
  38. package/esm/constants/index.d.ts +23 -0
  39. package/esm/constants/index.js +153 -0
  40. package/esm/index.d.ts +20 -0
  41. package/esm/index.js +22 -0
  42. package/esm/services/contractService.d.ts +11 -0
  43. package/esm/services/contractService.js +40 -0
  44. package/esm/services/ethereumService.d.ts +7 -0
  45. package/esm/services/ethereumService.js +34 -0
  46. package/esm/services/strategiesService.d.ts +2 -0
  47. package/esm/services/strategiesService.js +244 -0
  48. package/esm/services/strategySubService.d.ts +32 -0
  49. package/esm/services/strategySubService.js +91 -0
  50. package/esm/services/subDataService.d.ts +62 -0
  51. package/esm/services/subDataService.js +148 -0
  52. package/esm/services/triggerService.d.ts +89 -0
  53. package/esm/services/triggerService.js +141 -0
  54. package/esm/services/utils.d.ts +24 -0
  55. package/esm/services/utils.js +78 -0
  56. package/esm/types/contracts/generated/Erc20.d.ts +53 -0
  57. package/esm/types/contracts/generated/Erc20.js +4 -0
  58. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -0
  59. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +4 -0
  60. package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -0
  61. package/esm/types/contracts/generated/Legacy_AuthCheck.js +4 -0
  62. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -0
  63. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +4 -0
  64. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -0
  65. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +4 -0
  66. package/esm/types/contracts/generated/SubStorage.d.ts +114 -0
  67. package/esm/types/contracts/generated/SubStorage.js +4 -0
  68. package/esm/types/contracts/generated/UniMulticall.d.ts +55 -0
  69. package/esm/types/contracts/generated/UniMulticall.js +4 -0
  70. package/esm/types/contracts/generated/index.d.ts +7 -0
  71. package/esm/types/contracts/generated/index.js +1 -0
  72. package/esm/types/contracts/generated/types.d.ts +54 -0
  73. package/esm/types/contracts/generated/types.js +1 -0
  74. package/esm/types/enums.d.ts +97 -0
  75. package/esm/types/enums.js +113 -0
  76. package/esm/types/index.d.ts +180 -0
  77. package/esm/types/index.js +1 -0
  78. package/package.json +66 -0
  79. package/scripts/generateContractTypes.js +39 -0
  80. package/src/abis/Erc20.json +223 -0
  81. package/src/abis/SubStorage.json +17 -0
  82. package/src/abis/UniMulticall.json +14 -0
  83. package/src/abis/index.ts +28 -0
  84. package/src/abis/legacy_AaveV2Subscriptions.json +8 -0
  85. package/src/abis/legacy_AuthCheck.json +8 -0
  86. package/src/abis/legacy_CompoundV2Subscriptions.json +9 -0
  87. package/src/abis/legacy_MakerSubscriptions.json +9 -0
  88. package/src/automation/private/Automation.ts +44 -0
  89. package/src/automation/private/LegacyAutomation.ts +124 -0
  90. package/src/automation/private/LegacyProtocol.ts +45 -0
  91. package/src/automation/private/Protocol.ts +45 -0
  92. package/src/automation/private/StrategiesAutomation.ts +157 -0
  93. package/src/automation/public/ArbitrumStrategies.ts +10 -0
  94. package/src/automation/public/EthereumStrategies.ts +10 -0
  95. package/src/automation/public/OptimismStrategies.ts +10 -0
  96. package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -0
  97. package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -0
  98. package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -0
  99. package/src/configuration.ts +11 -0
  100. package/src/constants/index.ts +173 -0
  101. package/src/index.ts +38 -0
  102. package/src/services/contractService.ts +65 -0
  103. package/src/services/ethereumService.ts +55 -0
  104. package/src/services/strategiesService.ts +336 -0
  105. package/src/services/strategySubService.ts +202 -0
  106. package/src/services/subDataService.ts +212 -0
  107. package/src/services/triggerService.ts +173 -0
  108. package/src/services/utils.ts +101 -0
  109. package/src/types/contracts/generated/Erc20.ts +95 -0
  110. package/src/types/contracts/generated/Legacy_AaveV2Subscriptions.ts +207 -0
  111. package/src/types/contracts/generated/Legacy_AuthCheck.ts +41 -0
  112. package/src/types/contracts/generated/Legacy_CompoundV2Subscriptions.ts +205 -0
  113. package/src/types/contracts/generated/Legacy_MakerSubscriptions.ts +338 -0
  114. package/src/types/contracts/generated/SubStorage.ts +196 -0
  115. package/src/types/contracts/generated/UniMulticall.ts +83 -0
  116. package/src/types/contracts/generated/index.ts +10 -0
  117. package/src/types/contracts/generated/types.ts +73 -0
  118. package/src/types/enums.ts +108 -0
  119. package/src/types/index.ts +217 -0
  120. package/src/types/typings/process.d.ts +9 -0
  121. package/tsconfig.json +79 -0
  122. package/umd/web3.d.ts +28961 -0
  123. package/webpack.umd.js +52 -0
@@ -0,0 +1,114 @@
1
+ /// <reference types="node" />
2
+ import type BN from "bn.js";
3
+ import type { ContractOptions } from "web3-eth-contract";
4
+ import type { EventLog } from "web3-core";
5
+ import type { EventEmitter } from "events";
6
+ import type { Callback, NonPayableTransactionObject, BlockType, ContractEventLog, BaseContract } from "./types";
7
+ export interface EventOptions {
8
+ filter?: object;
9
+ fromBlock?: BlockType;
10
+ topics?: string[];
11
+ }
12
+ export declare namespace StrategyModel {
13
+ type StrategySubStruct = [number | string | BN, boolean, string | number[][], string | number[][]] | {
14
+ strategyOrBundleId: number | string | BN;
15
+ isBundle: boolean;
16
+ triggerData: string | number[][];
17
+ subData: string | number[][];
18
+ };
19
+ type StrategySubStructOutputArray = [
20
+ string,
21
+ boolean,
22
+ string[],
23
+ string[]
24
+ ];
25
+ type StrategySubStructOutputStruct = {
26
+ strategyOrBundleId: string;
27
+ isBundle: boolean;
28
+ triggerData: string[];
29
+ subData: string[];
30
+ };
31
+ type StrategySubStructOutput = StrategySubStructOutputArray & StrategySubStructOutputStruct;
32
+ type StoredSubDataStruct = [string | number[], boolean, string | number[]] | {
33
+ userProxy: string | number[];
34
+ isEnabled: boolean;
35
+ strategySubHash: string | number[];
36
+ };
37
+ type StoredSubDataStructOutputArray = [string, boolean, string];
38
+ type StoredSubDataStructOutputStruct = {
39
+ userProxy: string;
40
+ isEnabled: boolean;
41
+ strategySubHash: string;
42
+ };
43
+ type StoredSubDataStructOutput = StoredSubDataStructOutputArray & StoredSubDataStructOutputStruct;
44
+ }
45
+ export type ActivateSub = ContractEventLog<{
46
+ subId: string;
47
+ 0: string;
48
+ }>;
49
+ export type DeactivateSub = ContractEventLog<{
50
+ subId: string;
51
+ 0: string;
52
+ }>;
53
+ export type Subscribe = ContractEventLog<{
54
+ subId: string;
55
+ proxy: string;
56
+ subHash: string;
57
+ subStruct: StrategyModel.StrategySubStructOutput;
58
+ 0: string;
59
+ 1: string;
60
+ 2: string;
61
+ 3: StrategyModel.StrategySubStructOutput;
62
+ }>;
63
+ export type UpdateData = ContractEventLog<{
64
+ subId: string;
65
+ subHash: string;
66
+ subStruct: StrategyModel.StrategySubStructOutput;
67
+ 0: string;
68
+ 1: string;
69
+ 2: StrategyModel.StrategySubStructOutput;
70
+ }>;
71
+ export interface SubStorage extends BaseContract {
72
+ constructor(jsonInterface: any[], address?: string, options?: ContractOptions): SubStorage;
73
+ clone(): SubStorage;
74
+ methods: {
75
+ activateSub(_subId: number | string | BN): NonPayableTransactionObject<void>;
76
+ adminVault(): NonPayableTransactionObject<string>;
77
+ deactivateSub(_subId: number | string | BN): NonPayableTransactionObject<void>;
78
+ getSub(_subId: number | string | BN): NonPayableTransactionObject<StrategyModel.StoredSubDataStructOutput>;
79
+ getSubsCount(): NonPayableTransactionObject<string>;
80
+ kill(): NonPayableTransactionObject<void>;
81
+ registry(): NonPayableTransactionObject<string>;
82
+ strategiesSubs(arg0: number | string | BN): NonPayableTransactionObject<[
83
+ string,
84
+ boolean,
85
+ string
86
+ ] & {
87
+ userProxy: string;
88
+ isEnabled: boolean;
89
+ strategySubHash: string;
90
+ }>;
91
+ subscribeToStrategy(_sub: StrategyModel.StrategySubStruct): NonPayableTransactionObject<string>;
92
+ updateSubData(_subId: number | string | BN, _sub: StrategyModel.StrategySubStruct): NonPayableTransactionObject<void>;
93
+ withdrawStuckFunds(_token: string, _receiver: string, _amount: number | string | BN): NonPayableTransactionObject<void>;
94
+ };
95
+ events: {
96
+ ActivateSub(cb?: Callback<ActivateSub>): EventEmitter;
97
+ ActivateSub(options?: EventOptions, cb?: Callback<ActivateSub>): EventEmitter;
98
+ DeactivateSub(cb?: Callback<DeactivateSub>): EventEmitter;
99
+ DeactivateSub(options?: EventOptions, cb?: Callback<DeactivateSub>): EventEmitter;
100
+ Subscribe(cb?: Callback<Subscribe>): EventEmitter;
101
+ Subscribe(options?: EventOptions, cb?: Callback<Subscribe>): EventEmitter;
102
+ UpdateData(cb?: Callback<UpdateData>): EventEmitter;
103
+ UpdateData(options?: EventOptions, cb?: Callback<UpdateData>): EventEmitter;
104
+ allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
105
+ };
106
+ once(event: "ActivateSub", cb: Callback<ActivateSub>): void;
107
+ once(event: "ActivateSub", options: EventOptions, cb: Callback<ActivateSub>): void;
108
+ once(event: "DeactivateSub", cb: Callback<DeactivateSub>): void;
109
+ once(event: "DeactivateSub", options: EventOptions, cb: Callback<DeactivateSub>): void;
110
+ once(event: "Subscribe", cb: Callback<Subscribe>): void;
111
+ once(event: "Subscribe", options: EventOptions, cb: Callback<Subscribe>): void;
112
+ once(event: "UpdateData", cb: Callback<UpdateData>): void;
113
+ once(event: "UpdateData", options: EventOptions, cb: Callback<UpdateData>): void;
114
+ }
@@ -0,0 +1,4 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export {};
@@ -0,0 +1,55 @@
1
+ /// <reference types="node" />
2
+ import type BN from "bn.js";
3
+ import type { ContractOptions } from "web3-eth-contract";
4
+ import type { EventLog } from "web3-core";
5
+ import type { EventEmitter } from "events";
6
+ import type { Callback, NonPayableTransactionObject, BlockType, BaseContract } from "./types";
7
+ export interface EventOptions {
8
+ filter?: object;
9
+ fromBlock?: BlockType;
10
+ topics?: string[];
11
+ }
12
+ export declare namespace UniswapInterfaceMulticall {
13
+ type CallStruct = [string, number | string | BN, string | number[]] | {
14
+ target: string;
15
+ gasLimit: number | string | BN;
16
+ callData: string | number[];
17
+ };
18
+ type CallStructOutputArray = [string, string, string];
19
+ type CallStructOutputStruct = {
20
+ target: string;
21
+ gasLimit: string;
22
+ callData: string;
23
+ };
24
+ type CallStructOutput = CallStructOutputArray & CallStructOutputStruct;
25
+ type ResultStruct = [boolean, number | string | BN, string | number[]] | {
26
+ success: boolean;
27
+ gasUsed: number | string | BN;
28
+ returnData: string | number[];
29
+ };
30
+ type ResultStructOutputArray = [boolean, string, string];
31
+ type ResultStructOutputStruct = {
32
+ success: boolean;
33
+ gasUsed: string;
34
+ returnData: string;
35
+ };
36
+ type ResultStructOutput = ResultStructOutputArray & ResultStructOutputStruct;
37
+ }
38
+ export interface UniMulticall extends BaseContract {
39
+ constructor(jsonInterface: any[], address?: string, options?: ContractOptions): UniMulticall;
40
+ clone(): UniMulticall;
41
+ methods: {
42
+ getCurrentBlockTimestamp(): NonPayableTransactionObject<string>;
43
+ getEthBalance(addr: string): NonPayableTransactionObject<string>;
44
+ multicall(calls: UniswapInterfaceMulticall.CallStruct[]): NonPayableTransactionObject<[
45
+ string,
46
+ UniswapInterfaceMulticall.ResultStructOutput[]
47
+ ] & {
48
+ blockNumber: string;
49
+ returnData: UniswapInterfaceMulticall.ResultStructOutput[];
50
+ }>;
51
+ };
52
+ events: {
53
+ allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
54
+ };
55
+ }
@@ -0,0 +1,4 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export {};
@@ -0,0 +1,7 @@
1
+ export type { Erc20 } from "./Erc20";
2
+ export type { SubStorage } from "./SubStorage";
3
+ export type { UniMulticall } from "./UniMulticall";
4
+ export type { Legacy_AaveV2Subscriptions } from "./Legacy_AaveV2Subscriptions";
5
+ export type { Legacy_AuthCheck } from "./Legacy_AuthCheck";
6
+ export type { Legacy_CompoundV2Subscriptions } from "./Legacy_CompoundV2Subscriptions";
7
+ export type { Legacy_MakerSubscriptions } from "./Legacy_MakerSubscriptions";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ /// <reference types="node" />
2
+ import type BN from "bn.js";
3
+ import type { EventEmitter } from "events";
4
+ import type { EventLog, PromiEvent, TransactionReceipt } from "web3-core/types";
5
+ import type { Contract } from "web3-eth-contract";
6
+ export interface EstimateGasOptions {
7
+ from?: string;
8
+ gas?: number;
9
+ value?: number | string | BN;
10
+ }
11
+ export interface EventOptions {
12
+ filter?: object;
13
+ fromBlock?: BlockType;
14
+ topics?: string[];
15
+ }
16
+ export type Callback<T> = (error: Error, result: T) => void;
17
+ export interface ContractEventLog<T> extends EventLog {
18
+ returnValues: T;
19
+ }
20
+ export interface ContractEventEmitter<T> extends EventEmitter {
21
+ on(event: "connected", listener: (subscriptionId: string) => void): this;
22
+ on(event: "data" | "changed", listener: (event: ContractEventLog<T>) => void): this;
23
+ on(event: "error", listener: (error: Error) => void): this;
24
+ }
25
+ export interface NonPayableTx {
26
+ nonce?: string | number | BN;
27
+ chainId?: string | number | BN;
28
+ from?: string;
29
+ to?: string;
30
+ data?: string;
31
+ gas?: string | number | BN;
32
+ maxPriorityFeePerGas?: string | number | BN;
33
+ maxFeePerGas?: string | number | BN;
34
+ gasPrice?: string | number | BN;
35
+ }
36
+ export interface PayableTx extends NonPayableTx {
37
+ value?: string | number | BN;
38
+ }
39
+ export interface NonPayableTransactionObject<T> {
40
+ arguments: any[];
41
+ call(tx?: NonPayableTx, block?: BlockType): Promise<T>;
42
+ send(tx?: NonPayableTx): PromiEvent<TransactionReceipt>;
43
+ estimateGas(tx?: NonPayableTx): Promise<number>;
44
+ encodeABI(): string;
45
+ }
46
+ export interface PayableTransactionObject<T> {
47
+ arguments: any[];
48
+ call(tx?: PayableTx, block?: BlockType): Promise<T>;
49
+ send(tx?: PayableTx): PromiEvent<TransactionReceipt>;
50
+ estimateGas(tx?: PayableTx): Promise<number>;
51
+ encodeABI(): string;
52
+ }
53
+ export type BlockType = "latest" | "pending" | "genesis" | "earliest" | number | BN;
54
+ export type BaseContract = Omit<Contract, "clone" | "once">;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ export declare enum ChainId {
2
+ Ethereum = 1,
3
+ Optimism = 10,
4
+ Arbitrum = 42161
5
+ }
6
+ export declare enum RatioState {
7
+ OVER = 0,
8
+ UNDER = 1
9
+ }
10
+ export declare enum BundleProtocols {
11
+ MStable = "mstable",
12
+ Yearn = "yearn",
13
+ Rari = "rari"
14
+ }
15
+ /**
16
+ * @dev Follow the naming convention:
17
+ * - Enum name consists of two parts, name and version
18
+ * - Name should be human-readable name of the protocol, it can include spaces or any characters needed
19
+ * - Version should be separated from the name with double underscores `__` (If there is no version leave it out)
20
+ * - Example `Name of ThePROTOCOL__v1` (Without version `Name of ThePROTOCOL`)
21
+ */
22
+ export declare namespace ProtocolIdentifiers {
23
+ enum StrategiesAutomation {
24
+ MakerDAO = "MakerDAO__MCD",
25
+ Liquity = "Liquity",
26
+ ChickenBonds = "ChickenBonds",
27
+ CompoundV3 = "Compound__V3",
28
+ AaveV3 = "Aave__V3"
29
+ }
30
+ enum LegacyAutomation {
31
+ MakerDAO = "MakerDAO__MCD",
32
+ CompoundV2 = "Compound__V2",
33
+ AaveV2 = "Aave__V2"
34
+ }
35
+ }
36
+ export declare namespace Strategies {
37
+ enum MainnetIds {
38
+ MAKER_CLOSE_ON_PRICE_TO_DAI = 7,
39
+ MAKER_CLOSE_ON_PRICE_TO_COLL = 9,
40
+ LIQUITY_CLOSE_ON_PRICE_TO_COLL_DEPRECATED = 10,
41
+ MAKER_TRAILING_STOP_LOSS_TO_COLL = 11,
42
+ MAKER_TRAILING_STOP_LOSS_TO_DAI = 12,
43
+ LIQUITY_TRAILING_STOP_LOSS_TO_COLL = 13,
44
+ LIQUITY_CLOSE_ON_PRICE_TO_COLL = 14,
45
+ CHICKEN_BONDS_REBOND = 31
46
+ }
47
+ enum OptimismIds {
48
+ }
49
+ enum ArbitrumIds {
50
+ }
51
+ enum Identifiers {
52
+ SavingsLiqProtection = "smart-savings-liquidation-protection",
53
+ Repay = "repay",
54
+ EoaRepay = "eoa-repay",
55
+ Boost = "boost",
56
+ EoaBoost = "eoa-boost",
57
+ CloseToDebt = "close-to-debt",
58
+ CloseToCollateral = "close-to-collateral",
59
+ CloseOnPriceToDebt = "close-on-price-to-debt",
60
+ CloseOnPriceToColl = "close-on-price-to-collateral",
61
+ TrailingStopToColl = "trailing-stop-to-collateral",
62
+ TrailingStopToDebt = "trailing-stop-to-debt",
63
+ Rebond = "rebond",
64
+ BondProtection = "bond-protection"
65
+ }
66
+ enum IdOverrides {
67
+ TakeProfit = "take-profit",
68
+ StopLoss = "stop-loss",
69
+ TrailingStop = "trailing-stop",
70
+ LeverageManagement = "leverage-management",
71
+ EoaLeverageManagement = "leverage-management-eoa"
72
+ }
73
+ }
74
+ export declare namespace Bundles {
75
+ enum MainnetIds {
76
+ MAKER_REPAY_FROM_SMART_SAVINGS_YEARN = 0,
77
+ MAKER_REPAY_FROM_SMART_SAVINGS_MSTABLE = 1,
78
+ MAKER_REPAY_FROM_SMART_SAVINGS_RARI = 2,
79
+ COMP_V3_SW_REPAY_BUNDLE = 3,
80
+ COMP_V3_SW_BOOST_BUNDLE = 4,
81
+ COMP_V3_EOA_REPAY_BUNDLE = 5,
82
+ COMP_V3_EOA_BOOST_BUNDLE = 6,
83
+ LIQUITY_PAYBACK_USING_CHICKEN_BOND = 7
84
+ }
85
+ enum OptimismIds {
86
+ AAVE_V3_REPAY = 0,
87
+ AAVE_V3_BOOST = 1,
88
+ AAVE_V3_CLOSE_TO_DEBT = 2,
89
+ AAVE_V3_CLOSE_TO_COLLATERAL = 3
90
+ }
91
+ enum ArbitrumIds {
92
+ AAVE_V3_REPAY = 0,
93
+ AAVE_V3_BOOST = 1,
94
+ AAVE_V3_CLOSE_TO_DEBT = 2,
95
+ AAVE_V3_CLOSE_TO_COLLATERAL = 3
96
+ }
97
+ }
@@ -0,0 +1,113 @@
1
+ export var ChainId;
2
+ (function (ChainId) {
3
+ ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
4
+ ChainId[ChainId["Optimism"] = 10] = "Optimism";
5
+ ChainId[ChainId["Arbitrum"] = 42161] = "Arbitrum";
6
+ })(ChainId || (ChainId = {}));
7
+ export var RatioState;
8
+ (function (RatioState) {
9
+ RatioState[RatioState["OVER"] = 0] = "OVER";
10
+ RatioState[RatioState["UNDER"] = 1] = "UNDER";
11
+ })(RatioState || (RatioState = {}));
12
+ export var BundleProtocols;
13
+ (function (BundleProtocols) {
14
+ BundleProtocols["MStable"] = "mstable";
15
+ BundleProtocols["Yearn"] = "yearn";
16
+ BundleProtocols["Rari"] = "rari";
17
+ })(BundleProtocols || (BundleProtocols = {}));
18
+ /**
19
+ * @dev Follow the naming convention:
20
+ * - Enum name consists of two parts, name and version
21
+ * - Name should be human-readable name of the protocol, it can include spaces or any characters needed
22
+ * - Version should be separated from the name with double underscores `__` (If there is no version leave it out)
23
+ * - Example `Name of ThePROTOCOL__v1` (Without version `Name of ThePROTOCOL`)
24
+ */
25
+ export var ProtocolIdentifiers;
26
+ (function (ProtocolIdentifiers) {
27
+ let StrategiesAutomation;
28
+ (function (StrategiesAutomation) {
29
+ StrategiesAutomation["MakerDAO"] = "MakerDAO__MCD";
30
+ StrategiesAutomation["Liquity"] = "Liquity";
31
+ StrategiesAutomation["ChickenBonds"] = "ChickenBonds";
32
+ StrategiesAutomation["CompoundV3"] = "Compound__V3";
33
+ StrategiesAutomation["AaveV3"] = "Aave__V3";
34
+ })(StrategiesAutomation = ProtocolIdentifiers.StrategiesAutomation || (ProtocolIdentifiers.StrategiesAutomation = {}));
35
+ let LegacyAutomation;
36
+ (function (LegacyAutomation) {
37
+ LegacyAutomation["MakerDAO"] = "MakerDAO__MCD";
38
+ LegacyAutomation["CompoundV2"] = "Compound__V2";
39
+ LegacyAutomation["AaveV2"] = "Aave__V2";
40
+ })(LegacyAutomation = ProtocolIdentifiers.LegacyAutomation || (ProtocolIdentifiers.LegacyAutomation = {}));
41
+ })(ProtocolIdentifiers || (ProtocolIdentifiers = {}));
42
+ export var Strategies;
43
+ (function (Strategies) {
44
+ let MainnetIds;
45
+ (function (MainnetIds) {
46
+ MainnetIds[MainnetIds["MAKER_CLOSE_ON_PRICE_TO_DAI"] = 7] = "MAKER_CLOSE_ON_PRICE_TO_DAI";
47
+ MainnetIds[MainnetIds["MAKER_CLOSE_ON_PRICE_TO_COLL"] = 9] = "MAKER_CLOSE_ON_PRICE_TO_COLL";
48
+ MainnetIds[MainnetIds["LIQUITY_CLOSE_ON_PRICE_TO_COLL_DEPRECATED"] = 10] = "LIQUITY_CLOSE_ON_PRICE_TO_COLL_DEPRECATED";
49
+ MainnetIds[MainnetIds["MAKER_TRAILING_STOP_LOSS_TO_COLL"] = 11] = "MAKER_TRAILING_STOP_LOSS_TO_COLL";
50
+ MainnetIds[MainnetIds["MAKER_TRAILING_STOP_LOSS_TO_DAI"] = 12] = "MAKER_TRAILING_STOP_LOSS_TO_DAI";
51
+ MainnetIds[MainnetIds["LIQUITY_TRAILING_STOP_LOSS_TO_COLL"] = 13] = "LIQUITY_TRAILING_STOP_LOSS_TO_COLL";
52
+ MainnetIds[MainnetIds["LIQUITY_CLOSE_ON_PRICE_TO_COLL"] = 14] = "LIQUITY_CLOSE_ON_PRICE_TO_COLL";
53
+ MainnetIds[MainnetIds["CHICKEN_BONDS_REBOND"] = 31] = "CHICKEN_BONDS_REBOND";
54
+ })(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
55
+ let OptimismIds;
56
+ (function (OptimismIds) {
57
+ })(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
58
+ let ArbitrumIds;
59
+ (function (ArbitrumIds) {
60
+ })(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
61
+ let Identifiers;
62
+ (function (Identifiers) {
63
+ Identifiers["SavingsLiqProtection"] = "smart-savings-liquidation-protection";
64
+ Identifiers["Repay"] = "repay";
65
+ Identifiers["EoaRepay"] = "eoa-repay";
66
+ Identifiers["Boost"] = "boost";
67
+ Identifiers["EoaBoost"] = "eoa-boost";
68
+ Identifiers["CloseToDebt"] = "close-to-debt";
69
+ Identifiers["CloseToCollateral"] = "close-to-collateral";
70
+ Identifiers["CloseOnPriceToDebt"] = "close-on-price-to-debt";
71
+ Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
72
+ Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
73
+ Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
74
+ Identifiers["Rebond"] = "rebond";
75
+ Identifiers["BondProtection"] = "bond-protection";
76
+ })(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
77
+ let IdOverrides;
78
+ (function (IdOverrides) {
79
+ IdOverrides["TakeProfit"] = "take-profit";
80
+ IdOverrides["StopLoss"] = "stop-loss";
81
+ IdOverrides["TrailingStop"] = "trailing-stop";
82
+ IdOverrides["LeverageManagement"] = "leverage-management";
83
+ IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
84
+ })(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
85
+ })(Strategies || (Strategies = {}));
86
+ export var Bundles;
87
+ (function (Bundles) {
88
+ let MainnetIds;
89
+ (function (MainnetIds) {
90
+ MainnetIds[MainnetIds["MAKER_REPAY_FROM_SMART_SAVINGS_YEARN"] = 0] = "MAKER_REPAY_FROM_SMART_SAVINGS_YEARN";
91
+ MainnetIds[MainnetIds["MAKER_REPAY_FROM_SMART_SAVINGS_MSTABLE"] = 1] = "MAKER_REPAY_FROM_SMART_SAVINGS_MSTABLE";
92
+ MainnetIds[MainnetIds["MAKER_REPAY_FROM_SMART_SAVINGS_RARI"] = 2] = "MAKER_REPAY_FROM_SMART_SAVINGS_RARI";
93
+ MainnetIds[MainnetIds["COMP_V3_SW_REPAY_BUNDLE"] = 3] = "COMP_V3_SW_REPAY_BUNDLE";
94
+ MainnetIds[MainnetIds["COMP_V3_SW_BOOST_BUNDLE"] = 4] = "COMP_V3_SW_BOOST_BUNDLE";
95
+ MainnetIds[MainnetIds["COMP_V3_EOA_REPAY_BUNDLE"] = 5] = "COMP_V3_EOA_REPAY_BUNDLE";
96
+ MainnetIds[MainnetIds["COMP_V3_EOA_BOOST_BUNDLE"] = 6] = "COMP_V3_EOA_BOOST_BUNDLE";
97
+ MainnetIds[MainnetIds["LIQUITY_PAYBACK_USING_CHICKEN_BOND"] = 7] = "LIQUITY_PAYBACK_USING_CHICKEN_BOND";
98
+ })(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
99
+ let OptimismIds;
100
+ (function (OptimismIds) {
101
+ OptimismIds[OptimismIds["AAVE_V3_REPAY"] = 0] = "AAVE_V3_REPAY";
102
+ OptimismIds[OptimismIds["AAVE_V3_BOOST"] = 1] = "AAVE_V3_BOOST";
103
+ OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_DEBT"] = 2] = "AAVE_V3_CLOSE_TO_DEBT";
104
+ OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
105
+ })(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
106
+ let ArbitrumIds;
107
+ (function (ArbitrumIds) {
108
+ ArbitrumIds[ArbitrumIds["AAVE_V3_REPAY"] = 0] = "AAVE_V3_REPAY";
109
+ ArbitrumIds[ArbitrumIds["AAVE_V3_BOOST"] = 1] = "AAVE_V3_BOOST";
110
+ ArbitrumIds[ArbitrumIds["AAVE_V3_CLOSE_TO_DEBT"] = 2] = "AAVE_V3_CLOSE_TO_DEBT";
111
+ ArbitrumIds[ArbitrumIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
112
+ })(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
113
+ })(Bundles || (Bundles = {}));
@@ -0,0 +1,180 @@
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
+ export interface SubscriptionOptions {
49
+ toBlock: BlockNumber;
50
+ fromBlock: BlockNumber;
51
+ mergeWithSameId?: boolean;
52
+ }
53
+ export declare namespace Interfaces {
54
+ interface ProtocolBase {
55
+ id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation;
56
+ name: string;
57
+ fullName: string;
58
+ version: string;
59
+ }
60
+ interface Protocol extends ProtocolBase {
61
+ id: ProtocolIdentifiers.StrategiesAutomation;
62
+ }
63
+ interface LegacyProtocol extends ProtocolBase {
64
+ id: ProtocolIdentifiers.LegacyAutomation;
65
+ }
66
+ interface Automation {
67
+ provider: Web3;
68
+ }
69
+ interface LegacyAutomation<T extends BaseContract> {
70
+ provider: Web3;
71
+ monitorAddress: EthereumAddress;
72
+ protocol: Interfaces.LegacyProtocol;
73
+ subscriptionsJson: Contract.WithMeta<T>;
74
+ }
75
+ }
76
+ export interface Strategy {
77
+ strategyId: Strategies.Identifiers | Strategies.IdOverrides;
78
+ protocol: Interfaces.Protocol;
79
+ isBundle?: boolean;
80
+ }
81
+ export interface BundleOrStrategy extends Strategy {
82
+ bundleId?: string;
83
+ bundleName?: string;
84
+ }
85
+ export type TriggerData = StrategyModel.StrategySubStructOutputStruct['triggerData'];
86
+ export type SubData = StrategyModel.StrategySubStructOutputStruct['subData'];
87
+ export declare namespace Position {
88
+ namespace Specific {
89
+ interface Base {
90
+ subId1?: number;
91
+ subId2?: number;
92
+ mergeWithSameId?: boolean;
93
+ }
94
+ interface RatioProtection extends Base {
95
+ minRatio?: number;
96
+ minOptimalRatio?: number;
97
+ repayEnabled?: boolean;
98
+ maxRatio?: number;
99
+ maxOptimalRatio?: number;
100
+ boostEnabled?: boolean;
101
+ }
102
+ interface CloseOnPrice extends Base {
103
+ price: string;
104
+ closeToAssetAddr: EthereumAddress;
105
+ }
106
+ interface CloseOnPriceAave extends Base {
107
+ collAsset: EthereumAddress;
108
+ collAssetId: number;
109
+ debtAsset: EthereumAddress;
110
+ debtAssetId: number;
111
+ baseToken: EthereumAddress;
112
+ quoteToken: EthereumAddress;
113
+ price: string;
114
+ ratioState: RatioState;
115
+ }
116
+ interface TrailingStop extends Base {
117
+ roundId: number;
118
+ triggerPercentage: number;
119
+ closeToAssetAddr: EthereumAddress;
120
+ }
121
+ }
122
+ interface Automated {
123
+ chainId: ChainId;
124
+ owner: EthereumAddress;
125
+ subId: number;
126
+ subIds?: number[];
127
+ isEnabled?: boolean;
128
+ protocol: Interfaces.Protocol;
129
+ strategy: BundleOrStrategy;
130
+ strategyData: {
131
+ encoded: {
132
+ triggerData: TriggerData;
133
+ subData: SubData;
134
+ };
135
+ decoded: {
136
+ triggerData: PlaceholderType;
137
+ subData: PlaceholderType;
138
+ };
139
+ };
140
+ specific: Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave;
141
+ }
142
+ interface LegacyAutomated {
143
+ chainId: ChainId;
144
+ owner: EthereumAddress;
145
+ isEnabled: boolean;
146
+ protocol: Interfaces.LegacyProtocol;
147
+ specific: any;
148
+ }
149
+ }
150
+ type StrategyInfo<T extends number> = Record<T, Strategy>;
151
+ export type MainnetStrategiesInfo = StrategyInfo<Strategies.MainnetIds>;
152
+ export type OptimismStrategiesInfo = StrategyInfo<Strategies.OptimismIds>;
153
+ export type ArbitrumStrategiesInfo = StrategyInfo<Strategies.ArbitrumIds>;
154
+ type BundleInfo<T extends number> = Record<T, BundleOrStrategy>;
155
+ export type MainnetBundleInfo = BundleInfo<Bundles.MainnetIds>;
156
+ export type OptimismBundleInfo = BundleInfo<Bundles.OptimismIds>;
157
+ export type ArbitrumBundleInfo = BundleInfo<Bundles.ArbitrumIds>;
158
+ export interface StrategiesInfo {
159
+ [ChainId.Ethereum]: MainnetStrategiesInfo;
160
+ [ChainId.Optimism]: OptimismStrategiesInfo;
161
+ [ChainId.Arbitrum]: ArbitrumStrategiesInfo;
162
+ }
163
+ export interface BundlesInfo {
164
+ [ChainId.Ethereum]: MainnetBundleInfo;
165
+ [ChainId.Optimism]: OptimismBundleInfo;
166
+ [ChainId.Arbitrum]: ArbitrumBundleInfo;
167
+ }
168
+ export type StrategyOrBundleIds = Strategies.MainnetIds & Strategies.OptimismIds & Strategies.ArbitrumIds & Bundles.MainnetIds & Bundles.OptimismIds & Bundles.ArbitrumIds;
169
+ export interface ParseData {
170
+ chainId: ChainId;
171
+ subscriptionEventData: Subscribe['returnValues'];
172
+ strategiesSubsData: StrategyModel.StoredSubDataStructOutputStruct;
173
+ }
174
+ type MapToProtocolVersion<T> = {
175
+ [i in ProtocolIdentifiers.StrategiesAutomation]: {
176
+ [key in Strategies.Identifiers as string]: T;
177
+ };
178
+ };
179
+ export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData) => Position.Automated>;
180
+ export {};
@@ -0,0 +1 @@
1
+ export {};