@defisaver/automation-sdk 2.1.3 → 2.1.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.
@@ -142,6 +142,8 @@ export declare namespace Bundles {
142
142
  AAVE_V3_REPAY = 0,
143
143
  AAVE_V3_BOOST = 1,
144
144
  AAVE_V3_CLOSE_TO_DEBT = 2,
145
- AAVE_V3_CLOSE_TO_COLLATERAL = 3
145
+ AAVE_V3_CLOSE_TO_COLLATERAL = 3,
146
+ COMP_V3_SW_REPAY_BUNDLE = 4,
147
+ COMP_V3_SW_BOOST_BUNDLE = 5
146
148
  }
147
149
  }
@@ -163,5 +163,7 @@ var Bundles;
163
163
  ArbitrumIds[ArbitrumIds["AAVE_V3_BOOST"] = 1] = "AAVE_V3_BOOST";
164
164
  ArbitrumIds[ArbitrumIds["AAVE_V3_CLOSE_TO_DEBT"] = 2] = "AAVE_V3_CLOSE_TO_DEBT";
165
165
  ArbitrumIds[ArbitrumIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
166
+ ArbitrumIds[ArbitrumIds["COMP_V3_SW_REPAY_BUNDLE"] = 4] = "COMP_V3_SW_REPAY_BUNDLE";
167
+ ArbitrumIds[ArbitrumIds["COMP_V3_SW_BOOST_BUNDLE"] = 5] = "COMP_V3_SW_BOOST_BUNDLE";
166
168
  })(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
167
169
  })(Bundles = exports.Bundles || (exports.Bundles = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/index.js",
@@ -339,6 +339,16 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
339
339
  strategyId: Strategies.Identifiers.CloseToCollateral,
340
340
  protocol: PROTOCOLS.AaveV3,
341
341
  },
342
+ [Bundles.ArbitrumIds.COMP_V3_SW_BOOST_BUNDLE]: {
343
+ strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_BOOST_BUNDLE,
344
+ strategyId: Strategies.Identifiers.Boost,
345
+ protocol: PROTOCOLS.CompoundV3,
346
+ },
347
+ [Bundles.ArbitrumIds.COMP_V3_SW_REPAY_BUNDLE]: {
348
+ strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_REPAY_BUNDLE,
349
+ strategyId: Strategies.Identifiers.Repay,
350
+ protocol: PROTOCOLS.CompoundV3,
351
+ },
342
352
  };
343
353
 
344
354
  export const BUNDLES_INFO: BundlesInfo = {
@@ -417,8 +417,12 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
417
417
  const { subStruct, subId } = parseData.subscriptionEventData;
418
418
  const { isEnabled } = parseData.strategiesSubsData;
419
419
 
420
+ const subDataDecoder = position.chainId !== 1
421
+ ? subDataService.compoundV3L2LeverageManagementSubData
422
+ : subDataService.compoundV3LeverageManagementSubData;
423
+
420
424
  const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
421
- const subData = subDataService.compoundV3LeverageManagementSubData.decode(subStruct.subData);
425
+ const subData = subDataDecoder.decode(subStruct.subData);
422
426
 
423
427
  _position.strategyData.decoded.triggerData = triggerData;
424
428
  _position.strategyData.decoded.subData = subData;
@@ -18,7 +18,7 @@ import {
18
18
  morphoAaveV2Encode,
19
19
  exchangeEncode,
20
20
  sparkEncode,
21
- crvUSDEncode,
21
+ crvUSDEncode, compoundV3L2Encode,
22
22
  } from './strategySubService';
23
23
 
24
24
  describe('Feature: strategySubService.ts', () => {
@@ -833,6 +833,7 @@ describe('Feature: strategySubService.ts', () => {
833
833
  });
834
834
  });
835
835
  });
836
+
836
837
  describe('When testing strategySubService.crvUSDEncode', () => {
837
838
  describe('leverageManagement()', () => {
838
839
  const examples: Array<[
@@ -898,4 +899,35 @@ describe('Feature: strategySubService.ts', () => {
898
899
  });
899
900
  });
900
901
  });
902
+
903
+ describe('When testing strategySubService.compoundV3L2Encode', () => {
904
+ describe('leverageManagement()', () => {
905
+ const examples: Array<[string, [EthereumAddress, EthereumAddress, number, number, number, number, boolean]]> = [
906
+ [
907
+ '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
908
+ [
909
+ web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
910
+ web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
911
+ 160, 220, 180, 190,
912
+ true
913
+ ],
914
+ ],
915
+ [
916
+ '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee000000',
917
+ [
918
+ web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
919
+ web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'),
920
+ 160, 220, 180, 110,
921
+ false
922
+ ],
923
+ ],
924
+ ];
925
+ examples.forEach(([expected, actual]) => {
926
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
927
+ expect(compoundV3L2Encode.leverageManagement(...actual)).to.eql(expected);
928
+ });
929
+ });
930
+ });
931
+ });
932
+
901
933
  });
@@ -327,6 +327,20 @@ export const compoundV3Encode = {
327
327
  },
328
328
  };
329
329
 
330
+ export const compoundV3L2Encode = {
331
+ leverageManagement(
332
+ market: EthereumAddress,
333
+ baseToken: EthereumAddress,
334
+ triggerRepayRatio: number,
335
+ triggerBoostRatio: number,
336
+ targetBoostRatio: number,
337
+ targetRepayRatio: number,
338
+ boostEnabled: boolean,
339
+ ) {
340
+ return subDataService.compoundV3L2LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
341
+ },
342
+ };
343
+
330
344
  export const morphoAaveV2Encode = {
331
345
  leverageManagement(
332
346
  triggerRepayRatio: number,