@defisaver/automation-sdk 3.2.4-dev-1 → 3.2.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 (39) hide show
  1. package/cjs/constants/index.js +0 -90
  2. package/cjs/services/strategiesService.js +1 -48
  3. package/cjs/services/strategySubService.d.ts +1 -2
  4. package/cjs/services/strategySubService.js +6 -13
  5. package/cjs/services/strategySubService.test.js +0 -108
  6. package/cjs/services/subDataService.d.ts +7 -18
  7. package/cjs/services/subDataService.js +15 -48
  8. package/cjs/services/subDataService.test.js +48 -124
  9. package/cjs/services/triggerService.d.ts +0 -18
  10. package/cjs/services/triggerService.js +1 -36
  11. package/cjs/services/triggerService.test.js +0 -92
  12. package/cjs/types/enums.d.ts +5 -28
  13. package/cjs/types/enums.js +0 -23
  14. package/cjs/types/index.d.ts +1 -17
  15. package/esm/constants/index.js +0 -90
  16. package/esm/services/strategiesService.js +1 -48
  17. package/esm/services/strategySubService.d.ts +1 -2
  18. package/esm/services/strategySubService.js +6 -13
  19. package/esm/services/strategySubService.test.js +1 -109
  20. package/esm/services/subDataService.d.ts +7 -18
  21. package/esm/services/subDataService.js +14 -47
  22. package/esm/services/subDataService.test.js +48 -124
  23. package/esm/services/triggerService.d.ts +0 -18
  24. package/esm/services/triggerService.js +0 -35
  25. package/esm/services/triggerService.test.js +1 -93
  26. package/esm/types/enums.d.ts +5 -28
  27. package/esm/types/enums.js +0 -23
  28. package/esm/types/index.d.ts +1 -17
  29. package/package.json +2 -2
  30. package/src/constants/index.ts +1 -90
  31. package/src/services/strategiesService.ts +1 -62
  32. package/src/services/strategySubService.test.ts +1 -115
  33. package/src/services/strategySubService.ts +14 -33
  34. package/src/services/subDataService.test.ts +73 -128
  35. package/src/services/subDataService.ts +20 -73
  36. package/src/services/triggerService.test.ts +0 -102
  37. package/src/services/triggerService.ts +0 -55
  38. package/src/types/enums.ts +0 -23
  39. package/src/types/index.ts +1 -22
@@ -15,7 +15,6 @@ import {
15
15
  chainlinkPriceTrigger,
16
16
  compoundV2RatioTrigger,
17
17
  compoundV3RatioTrigger,
18
- compoundV3PriceTrigger,
19
18
  curveUsdBorrowRateTrigger,
20
19
  curveUsdSoftLiquidationTrigger,
21
20
  exchangeOffchainPriceTrigger,
@@ -30,7 +29,6 @@ import {
30
29
  crvUSDRatioTrigger,
31
30
  morphoBlueRatioTrigger,
32
31
  crvUsdHealthRatioTrigger, liquityV2DebtInFrontTrigger, liquityV2AdjustTimeTrigger,
33
- compoundV3PriceRangeTrigger,
34
32
  } from './triggerService';
35
33
 
36
34
  describe('Feature: triggerService.ts', () => {
@@ -1129,104 +1127,4 @@ describe('Feature: triggerService.ts', () => {
1129
1127
  });
1130
1128
  });
1131
1129
  });
1132
-
1133
- describe('When testing triggerService.compoundV3PriceTrigger', () => {
1134
- describe('encode()', () => {
1135
- const examples: Array<[[string], [market: EthereumAddress, collToken: EthereumAddress, price: number, priceState: RatioState]]> = [
1136
- [
1137
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
1138
- [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 2000, RatioState.UNDER]
1139
- ],
1140
- [
1141
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
1142
- [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 3000, RatioState.OVER]
1143
- ],
1144
- ];
1145
-
1146
- examples.forEach(([expected, actual]) => {
1147
- it(`Given ${actual} should return expected value: ${expected}`, () => {
1148
- expect(compoundV3PriceTrigger.encode(...actual)).to.eql(expected);
1149
- });
1150
- });
1151
- });
1152
-
1153
- describe('decode()', () => {
1154
- const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, price: string, priceState: RatioState }, TriggerData]> = [
1155
- [
1156
- {
1157
- market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1158
- collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1159
- price: '2000',
1160
- priceState: RatioState.UNDER,
1161
- },
1162
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
1163
- ],
1164
- [
1165
- {
1166
- market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1167
- collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1168
- price: '3000',
1169
- priceState: RatioState.OVER,
1170
- },
1171
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
1172
- ],
1173
- ];
1174
-
1175
- examples.forEach(([expected, actual]) => {
1176
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1177
- expect(compoundV3PriceTrigger.decode(actual)).to.eql(expected);
1178
- });
1179
- });
1180
- });
1181
- });
1182
-
1183
- describe('When testing triggerService.compoundV3PriceRangeTrigger', () => {
1184
- describe('encode()', () => {
1185
- const examples: Array<[[string], [market: EthereumAddress, collToken: EthereumAddress, lowerPrice: number, upperPrice: number]]> = [
1186
- [
1187
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1188
- [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
1189
- ],
1190
- [
1191
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1192
- [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
1193
- ],
1194
- ];
1195
-
1196
- examples.forEach(([expected, actual]) => {
1197
- it(`Given ${actual} should return expected value: ${expected}`, () => {
1198
- expect(compoundV3PriceRangeTrigger.encode(...actual)).to.eql(expected);
1199
- });
1200
- });
1201
- });
1202
-
1203
- describe('decode()', () => {
1204
- const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, lowerPrice: string, upperPrice: string }, TriggerData]> = [
1205
- [
1206
- {
1207
- market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1208
- collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1209
- lowerPrice: '1500',
1210
- upperPrice: '4000',
1211
- },
1212
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1213
- ],
1214
- [
1215
- {
1216
- market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1217
- collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1218
- lowerPrice: '0',
1219
- upperPrice: '5000',
1220
- },
1221
- ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1222
- ],
1223
- ];
1224
-
1225
- examples.forEach(([expected, actual]) => {
1226
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1227
- expect(compoundV3PriceRangeTrigger.decode(actual)).to.eql(expected);
1228
- });
1229
- });
1230
- });
1231
- });
1232
1130
  });
@@ -600,58 +600,3 @@ export const fluidRatioTrigger = {
600
600
  };
601
601
  },
602
602
  };
603
-
604
- export const compoundV3PriceTrigger = {
605
- encode(
606
- market: EthereumAddress,
607
- collToken: EthereumAddress,
608
- price: number,
609
- priceState: RatioState,
610
- ) {
611
- const _price = new Dec(price.toString()).mul(1e8).floor().toString();
612
- return [
613
- AbiCoder.encodeParameters(
614
- ['address', 'address', 'uint256', 'uint8'],
615
- [market, collToken, _price, priceState]),
616
- ];
617
- },
618
- decode(
619
- triggerData: TriggerData,
620
- ) {
621
- const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
622
- return {
623
- market: decodedData[0] as EthereumAddress,
624
- collToken: decodedData[1] as EthereumAddress,
625
- price: new Dec(decodedData[2] as string).div(1e8).toString(),
626
- priceState: Number(decodedData[3]),
627
- };
628
- },
629
- };
630
-
631
- export const compoundV3PriceRangeTrigger = {
632
- encode(
633
- market: EthereumAddress,
634
- collToken: EthereumAddress,
635
- lowerPrice: number,
636
- upperPrice: number,
637
- ) {
638
- const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
639
- const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
640
- return [
641
- AbiCoder.encodeParameters(
642
- ['address', 'address', 'uint256', 'uint256'],
643
- [market, collToken, lowerPriceFormatted, upperPriceFormatted]),
644
- ];
645
- },
646
- decode(
647
- triggerData: TriggerData,
648
- ) {
649
- const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint256'], triggerData[0]);
650
- return {
651
- market: decodedData[0] as EthereumAddress,
652
- collToken: decodedData[1] as EthereumAddress,
653
- lowerPrice: new Dec(decodedData[2] as string).div(1e8).toString(),
654
- upperPrice: new Dec(decodedData[3] as string).div(1e8).toString(),
655
- };
656
- },
657
- };
@@ -128,7 +128,6 @@ export namespace Strategies {
128
128
  CloseOnPriceToDebt = 'close-on-price-to-debt',
129
129
  CloseOnPriceToColl = 'close-on-price-to-collateral',
130
130
  CloseOnPrice = 'close-on-price',
131
- EoaCloseOnPrice = 'eoa-close-on-price',
132
131
  TrailingStopToColl = 'trailing-stop-to-collateral',
133
132
  TrailingStopToDebt = 'trailing-stop-to-debt',
134
133
  Rebond = 'rebond',
@@ -141,8 +140,6 @@ export namespace Strategies {
141
140
  OpenOrderFromDebt = 'open-order-from-debt',
142
141
  BoostOnPrice = 'boost-on-price',
143
142
  RepayOnPrice = 'repay-on-price',
144
- EoaBoostOnPrice = 'eoa-boost-on-price',
145
- EoaRepayOnPrice = 'eoa-repay-on-price',
146
143
  }
147
144
  export enum IdOverrides {
148
145
  TakeProfit = 'take-profit',
@@ -152,8 +149,6 @@ export namespace Strategies {
152
149
  TrailingStop = 'trailing-stop',
153
150
  LeverageManagement = 'leverage-management',
154
151
  EoaLeverageManagement = 'leverage-management-eoa',
155
- LeverageManagementOnPrice = 'leverage-management-on-price',
156
- EoaLeverageManagementOnPrice = 'leverage-management-on-price-eoa',
157
152
  }
158
153
  }
159
154
 
@@ -207,12 +202,6 @@ export namespace Bundles {
207
202
  LIQUITY_V2_BOOST_ON_PRICE = 43,
208
203
  FLUID_T1_REPAY = 44,
209
204
  FLUID_T1_BOOST = 45,
210
- COMP_V3_SW_REPAY_ON_PRICE = 46,
211
- COMP_V3_SW_BOOST_ON_PRICE = 47,
212
- COMP_V3_SW_CLOSE = 48,
213
- COMP_V3_EOA_REPAY_ON_PRICE = 49,
214
- COMP_V3_EOA_BOOST_ON_PRICE = 50,
215
- COMP_V3_EOA_CLOSE = 51,
216
205
  }
217
206
 
218
207
  export enum OptimismIds {
@@ -238,12 +227,6 @@ export namespace Bundles {
238
227
  MORPHO_BLUE_BOOST_ON_PRICE = 12,
239
228
  FLUID_T1_REPAY = 13,
240
229
  FLUID_T1_BOOST = 14,
241
- COMP_V3_SW_REPAY_ON_PRICE = 15,
242
- COMP_V3_SW_BOOST_ON_PRICE = 16,
243
- COMP_V3_SW_CLOSE = 17,
244
- COMP_V3_EOA_REPAY_ON_PRICE = 18,
245
- COMP_V3_EOA_BOOST_ON_PRICE = 19,
246
- COMP_V3_EOA_CLOSE = 20,
247
230
  }
248
231
 
249
232
  export enum ArbitrumIds {
@@ -257,12 +240,6 @@ export namespace Bundles {
257
240
  AAVE_V3_REPAY_ON_PRICE = 7,
258
241
  FLUID_T1_REPAY = 8,
259
242
  FLUID_T1_BOOST = 9,
260
- COMP_V3_SW_REPAY_ON_PRICE = 10,
261
- COMP_V3_SW_BOOST_ON_PRICE = 11,
262
- COMP_V3_SW_CLOSE = 12,
263
- COMP_V3_EOA_REPAY_ON_PRICE = 13,
264
- COMP_V3_EOA_BOOST_ON_PRICE = 14,
265
- COMP_V3_EOA_CLOSE = 15,
266
243
  }
267
244
  }
268
245
 
@@ -205,25 +205,6 @@ export declare namespace Position {
205
205
  subHashBoost?: string,
206
206
  subHashRepay?: string,
207
207
  }
208
-
209
- interface CompoundV3Base extends Base {
210
- market: EthereumAddress,
211
- collToken: EthereumAddress,
212
- baseToken: EthereumAddress,
213
- }
214
-
215
- interface CompoundV3LeverageManagementOnPrice extends CompoundV3Base {
216
- ratio: number,
217
- price: string,
218
- priceState: RatioState,
219
- }
220
-
221
- interface CompoundV3CloseOnPrice extends CompoundV3Base {
222
- stopLossPrice: string,
223
- takeProfitPrice: string,
224
- stopLossType: CloseToAssetType | undefined,
225
- takeProfitType: CloseToAssetType | undefined,
226
- }
227
208
  }
228
209
 
229
210
  type SpecificAny =
@@ -238,9 +219,7 @@ export declare namespace Position {
238
219
  | Specific.CloseOnPriceLiquityV2
239
220
  | Specific.BoostOnPriceMorpho
240
221
  | Specific.BoostOnPriceLiquityV2
241
- | Specific.PaybackLiquityV2
242
- | Specific.CompoundV3LeverageManagementOnPrice
243
- | Specific.CompoundV3CloseOnPrice;
222
+ | Specific.PaybackLiquityV2;
244
223
 
245
224
  export interface Automated {
246
225
  chainId: ChainId,