@defisaver/automation-sdk 3.1.1 → 3.1.3

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.
@@ -422,6 +422,21 @@ exports.BASE_BUNDLES_INFO = {
422
422
  strategyId: enums_1.Strategies.Identifiers.Repay,
423
423
  protocol: exports.PROTOCOLS.CompoundV3,
424
424
  },
425
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY]: {
426
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY,
427
+ strategyId: enums_1.Strategies.Identifiers.Repay,
428
+ protocol: exports.PROTOCOLS.MorphoBlue,
429
+ },
430
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_BOOST]: {
431
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_BOOST,
432
+ strategyId: enums_1.Strategies.Identifiers.Boost,
433
+ protocol: exports.PROTOCOLS.MorphoBlue,
434
+ },
435
+ [enums_1.Bundles.BaseIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL]: {
436
+ strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
437
+ strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
438
+ protocol: exports.PROTOCOLS.AaveV3,
439
+ },
425
440
  };
426
441
  exports.ARBITRUM_BUNDLES_INFO = {
427
442
  [enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
@@ -96,5 +96,5 @@ export declare const crvUSDEncode: {
96
96
  payback(proxyAddress: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress, controllerAddr: EthereumAddress, minHealthRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
97
97
  };
98
98
  export declare const morphoBlueEncode: {
99
- leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean): (boolean | string[] | Bundles.MainnetIds)[];
99
+ leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (boolean | string[] | Bundles.MainnetIds)[] | (boolean | string[] | Bundles.BaseIds)[];
100
100
  };
@@ -248,12 +248,15 @@ exports.crvUSDEncode = {
248
248
  },
249
249
  };
250
250
  exports.morphoBlueEncode = {
251
- leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA) {
251
+ leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
252
252
  const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
253
253
  const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
254
254
  // over is boost, under is repay
255
255
  const isBoost = ratioState === enums_1.RatioState.OVER;
256
256
  let strategyOrBundleId;
257
+ if (network === enums_1.ChainId.Base) {
258
+ return [isBoost ? enums_1.Bundles.BaseIds.MORPHO_BLUE_BOOST : enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY, true, triggerData, subData];
259
+ }
257
260
  if (isBoost)
258
261
  strategyOrBundleId = isEOA ? enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST : enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST;
259
262
  else
@@ -859,6 +859,7 @@ describe('Feature: strategySubService.ts', () => {
859
859
  120,
860
860
  web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
861
861
  false,
862
+ enums_1.ChainId.Ethereum,
862
863
  ]
863
864
  ],
864
865
  [
@@ -892,6 +893,7 @@ describe('Feature: strategySubService.ts', () => {
892
893
  200,
893
894
  web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
894
895
  false,
896
+ enums_1.ChainId.Ethereum,
895
897
  ]
896
898
  ],
897
899
  ];
@@ -167,7 +167,10 @@ export declare namespace Bundles {
167
167
  AAVE_V3_CLOSE_TO_DEBT = 2,
168
168
  AAVE_V3_CLOSE_TO_COLLATERAL = 3,
169
169
  COMP_V3_SW_REPAY_BUNDLE = 4,
170
- COMP_V3_SW_BOOST_BUNDLE = 5
170
+ COMP_V3_SW_BOOST_BUNDLE = 5,
171
+ MORPHO_BLUE_REPAY = 8,
172
+ MORPHO_BLUE_BOOST = 9,
173
+ AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10
171
174
  }
172
175
  enum ArbitrumIds {
173
176
  AAVE_V3_REPAY = 0,
@@ -189,6 +189,9 @@ var Bundles;
189
189
  BaseIds[BaseIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
190
190
  BaseIds[BaseIds["COMP_V3_SW_REPAY_BUNDLE"] = 4] = "COMP_V3_SW_REPAY_BUNDLE";
191
191
  BaseIds[BaseIds["COMP_V3_SW_BOOST_BUNDLE"] = 5] = "COMP_V3_SW_BOOST_BUNDLE";
192
+ BaseIds[BaseIds["MORPHO_BLUE_REPAY"] = 8] = "MORPHO_BLUE_REPAY";
193
+ BaseIds[BaseIds["MORPHO_BLUE_BOOST"] = 9] = "MORPHO_BLUE_BOOST";
194
+ BaseIds[BaseIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 10] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
192
195
  })(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
193
196
  let ArbitrumIds;
194
197
  (function (ArbitrumIds) {
@@ -416,6 +416,21 @@ export const BASE_BUNDLES_INFO = {
416
416
  strategyId: Strategies.Identifiers.Repay,
417
417
  protocol: PROTOCOLS.CompoundV3,
418
418
  },
419
+ [Bundles.BaseIds.MORPHO_BLUE_REPAY]: {
420
+ strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_REPAY,
421
+ strategyId: Strategies.Identifiers.Repay,
422
+ protocol: PROTOCOLS.MorphoBlue,
423
+ },
424
+ [Bundles.BaseIds.MORPHO_BLUE_BOOST]: {
425
+ strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_BOOST,
426
+ strategyId: Strategies.Identifiers.Boost,
427
+ protocol: PROTOCOLS.MorphoBlue,
428
+ },
429
+ [Bundles.BaseIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL]: {
430
+ strategyOrBundleId: Bundles.BaseIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
431
+ strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
432
+ protocol: PROTOCOLS.AaveV3,
433
+ },
419
434
  };
420
435
  export const ARBITRUM_BUNDLES_INFO = {
421
436
  [Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
@@ -96,5 +96,5 @@ export declare const crvUSDEncode: {
96
96
  payback(proxyAddress: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress, controllerAddr: EthereumAddress, minHealthRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
97
97
  };
98
98
  export declare const morphoBlueEncode: {
99
- leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean): (boolean | string[] | Bundles.MainnetIds)[];
99
+ leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (boolean | string[] | Bundles.MainnetIds)[] | (boolean | string[] | Bundles.BaseIds)[];
100
100
  };
@@ -219,12 +219,15 @@ export const crvUSDEncode = {
219
219
  },
220
220
  };
221
221
  export const morphoBlueEncode = {
222
- leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA) {
222
+ leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
223
223
  const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
224
224
  const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
225
225
  // over is boost, under is repay
226
226
  const isBoost = ratioState === RatioState.OVER;
227
227
  let strategyOrBundleId;
228
+ if (network === ChainId.Base) {
229
+ return [isBoost ? Bundles.BaseIds.MORPHO_BLUE_BOOST : Bundles.BaseIds.MORPHO_BLUE_REPAY, true, triggerData, subData];
230
+ }
228
231
  if (isBoost)
229
232
  strategyOrBundleId = isEOA ? Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST : Bundles.MainnetIds.MORPHO_BLUE_BOOST;
230
233
  else
@@ -831,6 +831,7 @@ describe('Feature: strategySubService.ts', () => {
831
831
  120,
832
832
  web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
833
833
  false,
834
+ ChainId.Ethereum,
834
835
  ]
835
836
  ],
836
837
  [
@@ -864,6 +865,7 @@ describe('Feature: strategySubService.ts', () => {
864
865
  200,
865
866
  web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
866
867
  false,
868
+ ChainId.Ethereum,
867
869
  ]
868
870
  ],
869
871
  ];
@@ -167,7 +167,10 @@ export declare namespace Bundles {
167
167
  AAVE_V3_CLOSE_TO_DEBT = 2,
168
168
  AAVE_V3_CLOSE_TO_COLLATERAL = 3,
169
169
  COMP_V3_SW_REPAY_BUNDLE = 4,
170
- COMP_V3_SW_BOOST_BUNDLE = 5
170
+ COMP_V3_SW_BOOST_BUNDLE = 5,
171
+ MORPHO_BLUE_REPAY = 8,
172
+ MORPHO_BLUE_BOOST = 9,
173
+ AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10
171
174
  }
172
175
  enum ArbitrumIds {
173
176
  AAVE_V3_REPAY = 0,
@@ -186,6 +186,9 @@ export var Bundles;
186
186
  BaseIds[BaseIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
187
187
  BaseIds[BaseIds["COMP_V3_SW_REPAY_BUNDLE"] = 4] = "COMP_V3_SW_REPAY_BUNDLE";
188
188
  BaseIds[BaseIds["COMP_V3_SW_BOOST_BUNDLE"] = 5] = "COMP_V3_SW_BOOST_BUNDLE";
189
+ BaseIds[BaseIds["MORPHO_BLUE_REPAY"] = 8] = "MORPHO_BLUE_REPAY";
190
+ BaseIds[BaseIds["MORPHO_BLUE_BOOST"] = 9] = "MORPHO_BLUE_BOOST";
191
+ BaseIds[BaseIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 10] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
189
192
  })(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
190
193
  let ArbitrumIds;
191
194
  (function (ArbitrumIds) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@defisaver/eslint-config": "^1.0.1",
27
27
  "@defisaver/sdk": "^1.0.61",
28
- "@defisaver/tokens": "^1.5.3",
28
+ "@defisaver/tokens": "^1.5.50",
29
29
  "@ethersproject/address": "^5.0.10",
30
30
  "@ethersproject/solidity": "^5.0.9",
31
31
  "decimal.js": "^10.4.3",
@@ -35,7 +35,6 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@defisaver/eslint-config": "^1.0.1",
38
- "typechain-target-web3-v1-3mihai3": "^6.0.1",
39
38
  "@types/chai": "^4.3.6",
40
39
  "@types/lodash": "^4.14.191",
41
40
  "@types/mocha": "^10.0.1",
@@ -50,6 +49,7 @@
50
49
  "react": "^18.2.0",
51
50
  "ts-node": "^10.9.1",
52
51
  "typechain": "^8.1.0",
52
+ "typechain-target-web3-v1-3mihai3": "^6.0.1",
53
53
  "typedoc": "^0.23.20",
54
54
  "typedoc-plugin-markdown": "^3.13.6",
55
55
  "typescript": "^4.8.4"
@@ -436,6 +436,21 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
436
436
  strategyId: Strategies.Identifiers.Repay,
437
437
  protocol: PROTOCOLS.CompoundV3,
438
438
  },
439
+ [Bundles.BaseIds.MORPHO_BLUE_REPAY]: {
440
+ strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_REPAY,
441
+ strategyId: Strategies.Identifiers.Repay,
442
+ protocol: PROTOCOLS.MorphoBlue,
443
+ },
444
+ [Bundles.BaseIds.MORPHO_BLUE_BOOST]: {
445
+ strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_BOOST,
446
+ strategyId: Strategies.Identifiers.Boost,
447
+ protocol: PROTOCOLS.MorphoBlue,
448
+ },
449
+ [Bundles.BaseIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL]: {
450
+ strategyOrBundleId: Bundles.BaseIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
451
+ strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
452
+ protocol: PROTOCOLS.AaveV3,
453
+ },
439
454
  };
440
455
 
441
456
  export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
@@ -1008,6 +1008,7 @@ describe('Feature: strategySubService.ts', () => {
1008
1008
  triggerRatio: number,
1009
1009
  user: EthereumAddress,
1010
1010
  isEoa: boolean,
1011
+ network: ChainId
1011
1012
  ],
1012
1013
  ]> = [
1013
1014
  [
@@ -1041,6 +1042,7 @@ describe('Feature: strategySubService.ts', () => {
1041
1042
  120,
1042
1043
  web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1043
1044
  false,
1045
+ ChainId.Ethereum,
1044
1046
  ]
1045
1047
  ],
1046
1048
  [
@@ -1074,6 +1076,7 @@ describe('Feature: strategySubService.ts', () => {
1074
1076
  200,
1075
1077
  web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1076
1078
  false,
1079
+ ChainId.Ethereum,
1077
1080
  ]
1078
1081
  ],
1079
1082
  ];
@@ -501,6 +501,7 @@ export const morphoBlueEncode = {
501
501
  triggerRatio: number,
502
502
  user: EthereumAddress,
503
503
  isEOA: boolean,
504
+ network: ChainId,
504
505
  ) {
505
506
  const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
506
507
 
@@ -509,6 +510,11 @@ export const morphoBlueEncode = {
509
510
  // over is boost, under is repay
510
511
  const isBoost = ratioState === RatioState.OVER;
511
512
  let strategyOrBundleId;
513
+
514
+ if (network === ChainId.Base) {
515
+ return [isBoost ? Bundles.BaseIds.MORPHO_BLUE_BOOST : Bundles.BaseIds.MORPHO_BLUE_REPAY, true, triggerData, subData];
516
+ }
517
+
512
518
  if (isBoost) strategyOrBundleId = isEOA ? Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST : Bundles.MainnetIds.MORPHO_BLUE_BOOST;
513
519
  else strategyOrBundleId = isEOA ? Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY : Bundles.MainnetIds.MORPHO_BLUE_REPAY;
514
520
  const isBundle = true;
@@ -181,6 +181,9 @@ export namespace Bundles {
181
181
  AAVE_V3_CLOSE_TO_COLLATERAL = 3,
182
182
  COMP_V3_SW_REPAY_BUNDLE = 4,
183
183
  COMP_V3_SW_BOOST_BUNDLE = 5,
184
+ MORPHO_BLUE_REPAY = 8,
185
+ MORPHO_BLUE_BOOST = 9,
186
+ AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10,
184
187
  }
185
188
 
186
189
  export enum ArbitrumIds {