@defisaver/automation-sdk 3.3.16-dev-13082-morpho-eoa-dev → 3.3.16-liq-prot-dev
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.
- package/cjs/constants/index.js +117 -42
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/strategiesService.js +157 -12
- package/cjs/services/strategySubService.d.ts +18 -21
- package/cjs/services/strategySubService.js +78 -74
- package/cjs/services/strategySubService.test.js +3 -149
- package/cjs/services/subDataService.d.ts +70 -20
- package/cjs/services/subDataService.js +23 -79
- package/cjs/services/subDataService.test.js +17 -202
- package/cjs/services/utils.d.ts +2 -1
- package/cjs/services/utils.js +14 -1
- package/cjs/types/enums.d.ts +36 -17
- package/cjs/types/enums.js +30 -11
- package/esm/constants/index.js +117 -42
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/strategiesService.js +157 -12
- package/esm/services/strategySubService.d.ts +18 -21
- package/esm/services/strategySubService.js +78 -73
- package/esm/services/strategySubService.test.js +4 -147
- package/esm/services/subDataService.d.ts +70 -20
- package/esm/services/subDataService.js +21 -77
- package/esm/services/subDataService.test.js +18 -200
- package/esm/services/utils.d.ts +2 -1
- package/esm/services/utils.js +13 -1
- package/esm/types/enums.d.ts +36 -17
- package/esm/types/enums.js +30 -11
- package/package.json +1 -1
- package/src/constants/index.ts +119 -43
- package/src/index.ts +22 -6
- package/src/services/strategiesService.ts +221 -12
- package/src/services/strategySubService.test.ts +3 -191
- package/src/services/strategySubService.ts +173 -121
- package/src/services/subDataService.test.ts +18 -214
- package/src/services/subDataService.ts +42 -106
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +15 -1
- package/src/types/enums.ts +30 -13
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies } from '../types/enums';
|
|
1
|
+
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies } from '../types/enums';
|
|
3
2
|
import type { EthereumAddress, StrategyOrBundleIds } from '../types';
|
|
3
|
+
import type { OrderType } from '../types/enums';
|
|
4
4
|
export declare const makerEncode: {
|
|
5
5
|
repayFromSavings(bundleId: StrategyOrBundleIds, vaultId: number, triggerRepayRatio: number, targetRepayRatio: number, isBundle?: boolean, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds | Bundles.MainnetIds | Bundles.OptimismIds | Bundles.ArbitrumIds | Bundles.BaseIds)[];
|
|
6
6
|
closeOnPrice(vaultId: number, ratioState: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
7
7
|
trailingStop(vaultId: number, triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
8
|
-
|
|
8
|
+
leverageManagement(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, isBoost: boolean, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
9
|
+
liquidationProtection(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
9
10
|
};
|
|
10
11
|
export declare const liquityEncode: {
|
|
11
12
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
12
13
|
trailingStop(triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
13
14
|
paybackFromChickenBondStrategySub(proxyAddress: EthereumAddress, ratio: number, sourceId: string, sourceType: number, ratioState?: RatioState): (boolean | string[] | Bundles.MainnetIds)[];
|
|
14
|
-
|
|
15
|
+
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
15
16
|
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
16
17
|
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
17
18
|
debtInFrontRepay(proxyAddress: EthereumAddress, debtInFrontMin: string, targetRatioIncrease: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
18
19
|
};
|
|
19
|
-
export declare const chickenBondsEncode: {
|
|
20
|
-
rebond(bondId: number): string[];
|
|
21
|
-
};
|
|
22
20
|
export declare const aaveV2Encode: {
|
|
23
|
-
|
|
21
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
24
22
|
};
|
|
25
23
|
export declare const aaveV3Encode: {
|
|
26
24
|
closeToAsset(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
@@ -59,25 +57,24 @@ export declare const aaveV3Encode: {
|
|
|
59
57
|
marketAddr: EthereumAddress;
|
|
60
58
|
targetRatio: number;
|
|
61
59
|
}): (number | boolean | string[])[];
|
|
62
|
-
|
|
60
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, isGeneric?: boolean): (number | boolean | string[])[];
|
|
61
|
+
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
63
62
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
64
63
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
65
64
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
66
65
|
};
|
|
67
66
|
export declare const compoundV2Encode: {
|
|
68
|
-
|
|
67
|
+
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
69
68
|
};
|
|
70
69
|
export declare const compoundV3Encode: {
|
|
71
|
-
|
|
70
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
71
|
+
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
72
72
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
73
73
|
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, stopLossPrice: number | undefined, stopLossType: CloseToAssetType | undefined, takeProfitPrice: number | undefined, takeProfitType: CloseToAssetType | undefined, user: EthereumAddress): (number | boolean | string[])[];
|
|
74
74
|
};
|
|
75
|
-
export declare const morphoAaveV2Encode: {
|
|
76
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
77
|
-
};
|
|
78
75
|
export declare const exchangeEncode: {
|
|
79
76
|
dca(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, timestamp: number, interval: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
80
|
-
|
|
77
|
+
limitOrder(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType, fromTokenDecimals: number, toTokenDecimals: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
81
78
|
};
|
|
82
79
|
export declare const sparkEncode: {
|
|
83
80
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
@@ -94,21 +91,19 @@ export declare const sparkEncode: {
|
|
|
94
91
|
targetRatio: number;
|
|
95
92
|
}): (number | boolean | string[])[];
|
|
96
93
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
97
|
-
|
|
94
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
95
|
+
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
98
96
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
99
97
|
};
|
|
100
98
|
export declare const crvUSDEncode: {
|
|
101
99
|
leverageManagement(owner: EthereumAddress, controllerAddr: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, collTokenAddr: EthereumAddress, crvUSDAddr: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
102
100
|
payback(proxyAddress: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress, controllerAddr: EthereumAddress, minHealthRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
103
101
|
};
|
|
104
|
-
export type MorphoBlueBundleStrategy = 'repay' | 'boost' | 'repayOnPrice' | 'boostOnPrice' | 'close';
|
|
105
|
-
export declare function getMorphoBlueBundleId(network: ChainId, strategy: MorphoBlueBundleStrategy, isEOA: boolean): number;
|
|
106
102
|
export declare const morphoBlueEncode: {
|
|
107
|
-
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): (
|
|
103
|
+
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.BaseIds)[] | (boolean | string[] | Bundles.MainnetIds | Bundles.ArbitrumIds)[];
|
|
104
|
+
liquidationProtection(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)[];
|
|
108
105
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, targetRatio: number, price: number, priceState: RatioState): (number | boolean | string[])[];
|
|
109
|
-
leverageManagementOnPriceGeneric(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, isBoost: boolean, isEOA: boolean, network: ChainId): (number | boolean | string[])[];
|
|
110
106
|
closeOnPrice(strategyOrBundleId: number, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
111
|
-
closeOnPriceGeneric(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, stopLossPrice: number | undefined, stopLossType: CloseToAssetType | undefined, takeProfitPrice: number | undefined, takeProfitType: CloseToAssetType | undefined, isEOA: boolean, network: ChainId): (number | boolean | string[])[];
|
|
112
107
|
};
|
|
113
108
|
export declare const liquityV2Encode: {
|
|
114
109
|
leverageManagement(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
@@ -118,9 +113,11 @@ export declare const liquityV2Encode: {
|
|
|
118
113
|
};
|
|
119
114
|
export declare const fluidEncode: {
|
|
120
115
|
leverageManagement(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
116
|
+
liquidationProtection(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
121
117
|
};
|
|
122
118
|
export declare const aaveV4Encode: {
|
|
123
119
|
leverageManagement(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
120
|
+
liquidationProtection(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
124
121
|
leverageManagementOnPrice(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, targetRatio: number, price: string, priceState: RatioState, ratioState: RatioState): (number | boolean | string[])[];
|
|
125
122
|
closeOnPrice(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, stopLossPrice?: string, stopLossType?: CloseToAssetType, takeProfitPrice?: string, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
126
123
|
collateralSwitch(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string, price: string, ratioState: RatioState): (number | boolean | string[])[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
2
|
-
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies, } from '../types/enums';
|
|
3
2
|
import { STRATEGY_IDS } from '../constants';
|
|
3
|
+
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies, } from '../types/enums';
|
|
4
4
|
import * as subDataService from './subDataService';
|
|
5
5
|
import * as triggerService from './triggerService';
|
|
6
|
-
import { compareAddresses, getCloseStrategyType, requireAddress, requireAddresses, } from './utils';
|
|
6
|
+
import { compareAddresses, getBundleIdsByNetwork, getCloseStrategyType, requireAddress, requireAddresses, } from './utils';
|
|
7
7
|
export const makerEncode = {
|
|
8
8
|
repayFromSavings(bundleId, vaultId, triggerRepayRatio, targetRepayRatio, isBundle = true, chainId = ChainId.Ethereum, daiAddr, mcdCdpManagerAddr) {
|
|
9
9
|
const subData = subDataService.makerRepayFromSavingsSubData.encode(vaultId, targetRepayRatio, chainId, daiAddr, mcdCdpManagerAddr);
|
|
@@ -30,10 +30,21 @@ export const makerEncode = {
|
|
|
30
30
|
const isBundle = false;
|
|
31
31
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
leverageManagement(vaultId, triggerRatio, targetRatio, ratioState, isBoost, daiAddr) {
|
|
34
34
|
const bundleId = isBoost ? Bundles.MainnetIds.MAKER_BOOST : Bundles.MainnetIds.MAKER_REPAY;
|
|
35
35
|
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
36
|
-
const subData = subDataService.
|
|
36
|
+
const subData = subDataService.makerLeverageManagementSubData.encode(vaultId, targetRatio, daiAddr);
|
|
37
|
+
return [
|
|
38
|
+
bundleId,
|
|
39
|
+
true,
|
|
40
|
+
triggerData,
|
|
41
|
+
subData,
|
|
42
|
+
];
|
|
43
|
+
},
|
|
44
|
+
liquidationProtection(vaultId, triggerRatio, targetRatio, ratioState, daiAddr) {
|
|
45
|
+
const bundleId = Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION;
|
|
46
|
+
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
47
|
+
const subData = subDataService.makerLiquidationProtectionSubData.encode(vaultId, targetRatio, daiAddr);
|
|
37
48
|
return [
|
|
38
49
|
bundleId,
|
|
39
50
|
true,
|
|
@@ -67,9 +78,9 @@ export const liquityEncode = {
|
|
|
67
78
|
const isBundle = true;
|
|
68
79
|
return [strategyId, isBundle, triggerData, subData];
|
|
69
80
|
},
|
|
70
|
-
|
|
81
|
+
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
71
82
|
const isBundle = true;
|
|
72
|
-
const subData = subDataService.
|
|
83
|
+
const subData = subDataService.liquityLeverageManagementSubData.encode(targetRatio, ratioState);
|
|
73
84
|
const triggerData = triggerService.liquityRatioTrigger.encode(user, triggerRatio, ratioState);
|
|
74
85
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
75
86
|
},
|
|
@@ -98,15 +109,10 @@ export const liquityEncode = {
|
|
|
98
109
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
99
110
|
},
|
|
100
111
|
};
|
|
101
|
-
export const chickenBondsEncode = {
|
|
102
|
-
rebond(bondId) {
|
|
103
|
-
return subDataService.cBondsRebondSubData.encode(bondId);
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
112
|
export const aaveV2Encode = {
|
|
107
|
-
|
|
113
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
108
114
|
const isBundle = true;
|
|
109
|
-
const subData = subDataService.
|
|
115
|
+
const subData = subDataService.aaveV2LeverageManagementSubData.encode(market, targetRatio, ratioState);
|
|
110
116
|
const triggerData = triggerService.aaveV2RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
111
117
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
112
118
|
},
|
|
@@ -133,9 +139,15 @@ export const aaveV3Encode = {
|
|
|
133
139
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
134
140
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
135
141
|
},
|
|
136
|
-
|
|
142
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio, isGeneric = false) {
|
|
137
143
|
const isBundle = true;
|
|
138
|
-
const subData = subDataService.
|
|
144
|
+
const subData = subDataService.aaveV3LeverageManagementSubData.encode(targetRatio, ratioState, market, user, isGeneric);
|
|
145
|
+
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
146
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
147
|
+
},
|
|
148
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
149
|
+
const isBundle = true;
|
|
150
|
+
const subData = subDataService.aaveV3LiquidationProtectionSubData.encode(targetRatio, ratioState, market, user, true);
|
|
139
151
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
140
152
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
141
153
|
},
|
|
@@ -160,17 +172,23 @@ export const aaveV3Encode = {
|
|
|
160
172
|
},
|
|
161
173
|
};
|
|
162
174
|
export const compoundV2Encode = {
|
|
163
|
-
|
|
175
|
+
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
164
176
|
const isBundle = true;
|
|
165
|
-
const subData = subDataService.
|
|
177
|
+
const subData = subDataService.compoundV2LeverageManagementSubData.encode(targetRatio, ratioState);
|
|
166
178
|
const triggerData = triggerService.compoundV2RatioTrigger.encode(user, triggerRatio, ratioState);
|
|
167
179
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
168
180
|
},
|
|
169
181
|
};
|
|
170
182
|
export const compoundV3Encode = {
|
|
171
|
-
|
|
183
|
+
leverageManagement(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
184
|
+
const isBundle = true;
|
|
185
|
+
const subData = subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, targetRatio, ratioState);
|
|
186
|
+
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
187
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
188
|
+
},
|
|
189
|
+
liquidationProtection(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
172
190
|
const isBundle = true;
|
|
173
|
-
const subData = subDataService.
|
|
191
|
+
const subData = subDataService.compoundV3LiquidationProtectionSubData.encode(market, baseToken, targetRatio, ratioState);
|
|
174
192
|
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
175
193
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
176
194
|
},
|
|
@@ -189,11 +207,6 @@ export const compoundV3Encode = {
|
|
|
189
207
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
190
208
|
},
|
|
191
209
|
};
|
|
192
|
-
export const morphoAaveV2Encode = {
|
|
193
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
194
|
-
return subDataService.morphoAaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
210
|
export const exchangeEncode = {
|
|
198
211
|
dca(fromToken, toToken, amount, timestamp, interval, network) {
|
|
199
212
|
requireAddresses([fromToken, toToken]);
|
|
@@ -202,9 +215,9 @@ export const exchangeEncode = {
|
|
|
202
215
|
const strategyId = STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
203
216
|
return [strategyId, false, triggerData, subData];
|
|
204
217
|
},
|
|
205
|
-
|
|
218
|
+
limitOrder(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
206
219
|
requireAddresses([fromToken, toToken]);
|
|
207
|
-
const subData = subDataService.
|
|
220
|
+
const subData = subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount);
|
|
208
221
|
const triggerData = triggerService.exchangeOffchainPriceTrigger.encode(targetPrice, Number(goodUntil), orderType, fromTokenDecimals, toTokenDecimals);
|
|
209
222
|
const strategyId = STRATEGY_IDS[network].EXCHANGE_LIMIT_ORDER;
|
|
210
223
|
return [strategyId, false, triggerData, subData];
|
|
@@ -225,9 +238,15 @@ export const sparkEncode = {
|
|
|
225
238
|
const triggerDataEncoded = triggerService.sparkQuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
226
239
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
227
240
|
},
|
|
228
|
-
|
|
241
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
242
|
+
const isBundle = true;
|
|
243
|
+
const subData = subDataService.sparkLeverageManagementSubData.encode(targetRatio, ratioState);
|
|
244
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
245
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
246
|
+
},
|
|
247
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
229
248
|
const isBundle = true;
|
|
230
|
-
const subData = subDataService.
|
|
249
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.encode(targetRatio, ratioState);
|
|
231
250
|
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
232
251
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
233
252
|
},
|
|
@@ -255,42 +274,31 @@ export const crvUSDEncode = {
|
|
|
255
274
|
return [strategyId, isBundle, triggerData, subData];
|
|
256
275
|
},
|
|
257
276
|
};
|
|
258
|
-
function getMorphoBlueBundlesIds(network) {
|
|
259
|
-
switch (network) {
|
|
260
|
-
case ChainId.Ethereum:
|
|
261
|
-
return Bundles.MainnetIds;
|
|
262
|
-
case ChainId.Base:
|
|
263
|
-
return Bundles.BaseIds;
|
|
264
|
-
case ChainId.Arbitrum:
|
|
265
|
-
return Bundles.ArbitrumIds;
|
|
266
|
-
default:
|
|
267
|
-
throw new Error(`Morpho Blue strategies are not supported on chain ${network}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
export function getMorphoBlueBundleId(network, strategy, isEOA) {
|
|
271
|
-
const bundlesIds = getMorphoBlueBundlesIds(network);
|
|
272
|
-
switch (strategy) {
|
|
273
|
-
case 'repay':
|
|
274
|
-
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY : bundlesIds.MORPHO_BLUE_REPAY;
|
|
275
|
-
case 'boost':
|
|
276
|
-
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST : bundlesIds.MORPHO_BLUE_BOOST;
|
|
277
|
-
case 'repayOnPrice':
|
|
278
|
-
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE : bundlesIds.MORPHO_BLUE_REPAY_ON_PRICE;
|
|
279
|
-
case 'boostOnPrice':
|
|
280
|
-
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE : bundlesIds.MORPHO_BLUE_BOOST_ON_PRICE;
|
|
281
|
-
case 'close':
|
|
282
|
-
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_CLOSE : bundlesIds.MORPHO_BLUE_CLOSE;
|
|
283
|
-
default:
|
|
284
|
-
throw new Error(`Unknown Morpho Blue strategy: ${strategy}`);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
277
|
export const morphoBlueEncode = {
|
|
288
278
|
leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
289
279
|
const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
290
280
|
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
291
281
|
// over is boost, under is repay
|
|
292
282
|
const isBoost = ratioState === RatioState.OVER;
|
|
293
|
-
|
|
283
|
+
let strategyOrBundleId;
|
|
284
|
+
if (network === ChainId.Base) {
|
|
285
|
+
return [isBoost ? Bundles.BaseIds.MORPHO_BLUE_BOOST : Bundles.BaseIds.MORPHO_BLUE_REPAY, true, triggerData, subData];
|
|
286
|
+
}
|
|
287
|
+
const bundlesIds = network === ChainId.Arbitrum ? Bundles.ArbitrumIds : Bundles.MainnetIds;
|
|
288
|
+
if (isBoost)
|
|
289
|
+
strategyOrBundleId = isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST : bundlesIds.MORPHO_BLUE_BOOST;
|
|
290
|
+
else
|
|
291
|
+
strategyOrBundleId = isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY : bundlesIds.MORPHO_BLUE_REPAY;
|
|
292
|
+
const isBundle = true;
|
|
293
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
294
|
+
},
|
|
295
|
+
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
296
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
297
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
298
|
+
// Type casting because there is no MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION for Base chain.
|
|
299
|
+
// That is fine because we will just always send isEOA == false for Base chain.
|
|
300
|
+
const bundleNetwork = getBundleIdsByNetwork(network);
|
|
301
|
+
const bundleId = isEOA ? bundleNetwork.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundleNetwork.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
294
302
|
const isBundle = true;
|
|
295
303
|
return [bundleId, isBundle, triggerData, subData];
|
|
296
304
|
},
|
|
@@ -299,13 +307,6 @@ export const morphoBlueEncode = {
|
|
|
299
307
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
300
308
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
301
309
|
},
|
|
302
|
-
leverageManagementOnPriceGeneric(loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState, isBoost, isEOA, network) {
|
|
303
|
-
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
304
|
-
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
305
|
-
const bundleId = getMorphoBlueBundleId(network, isBoost ? 'boostOnPrice' : 'repayOnPrice', isEOA);
|
|
306
|
-
const isBundle = true;
|
|
307
|
-
return [bundleId, isBundle, triggerData, subData];
|
|
308
|
-
},
|
|
309
310
|
closeOnPrice(strategyOrBundleId, loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
310
311
|
const isBundle = true;
|
|
311
312
|
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
@@ -313,14 +314,6 @@ export const morphoBlueEncode = {
|
|
|
313
314
|
const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
|
|
314
315
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
315
316
|
},
|
|
316
|
-
closeOnPriceGeneric(loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL, isEOA, network) {
|
|
317
|
-
const isBundle = true;
|
|
318
|
-
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
319
|
-
const subDataEncoded = subDataService.morphoBlueCloseOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, user, closeType);
|
|
320
|
-
const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
|
|
321
|
-
const bundleId = getMorphoBlueBundleId(network, 'close', isEOA);
|
|
322
|
-
return [bundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
323
|
-
},
|
|
324
317
|
};
|
|
325
318
|
export const liquityV2Encode = {
|
|
326
319
|
leverageManagement(market, troveId, collToken, boldToken, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
@@ -357,6 +350,12 @@ export const fluidEncode = {
|
|
|
357
350
|
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
358
351
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
359
352
|
},
|
|
353
|
+
liquidationProtection(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
354
|
+
const isBundle = true;
|
|
355
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
|
|
356
|
+
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
357
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
358
|
+
},
|
|
360
359
|
};
|
|
361
360
|
export const aaveV4Encode = {
|
|
362
361
|
leverageManagement(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
@@ -365,6 +364,12 @@ export const aaveV4Encode = {
|
|
|
365
364
|
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
366
365
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
367
366
|
},
|
|
367
|
+
liquidationProtection(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
368
|
+
const isBundle = true;
|
|
369
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
|
|
370
|
+
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
371
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
372
|
+
},
|
|
368
373
|
leverageManagementOnPrice(strategyOrBundleId, owner, spoke, collAsset, collAssetId, debtAsset, debtAssetId, targetRatio, price, priceState, ratioState) {
|
|
369
374
|
const isBundle = true;
|
|
370
375
|
const subData = subDataService.aaveV4LeverageManagementOnPriceSubData.encode(spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import Dec from 'decimal.js';
|
|
3
2
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
3
|
import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
5
4
|
import * as web3Utils from 'web3-utils';
|
|
6
5
|
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies } from '../types/enums';
|
|
7
6
|
import '../configuration';
|
|
8
|
-
import {
|
|
7
|
+
import { liquityEncode, makerEncode, aaveV3Encode, compoundV3Encode, exchangeEncode, crvUSDEncode, morphoBlueEncode, sparkEncode, aaveV4Encode, } from './strategySubService';
|
|
9
8
|
describe('Feature: strategySubService.ts', () => {
|
|
10
9
|
describe('When testing strategySubService.makerEncode', () => {
|
|
11
10
|
// @ts-ignore // TODO - this requires change in @defisaver/tokens
|
|
@@ -96,7 +95,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
96
95
|
});
|
|
97
96
|
});
|
|
98
97
|
});
|
|
99
|
-
describe('
|
|
98
|
+
describe('leverageManagement()', () => {
|
|
100
99
|
const examples = [
|
|
101
100
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
102
101
|
[
|
|
@@ -139,7 +138,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
139
138
|
];
|
|
140
139
|
examples.forEach(([expected, actual]) => {
|
|
141
140
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
142
|
-
expect(makerEncode.
|
|
141
|
+
expect(makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
143
142
|
});
|
|
144
143
|
});
|
|
145
144
|
});
|
|
@@ -266,21 +265,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
266
265
|
});
|
|
267
266
|
});
|
|
268
267
|
});
|
|
269
|
-
describe('When testing strategySubService.chickenBondsEncode', () => {
|
|
270
|
-
describe('rebond()', () => {
|
|
271
|
-
const examples = [
|
|
272
|
-
[
|
|
273
|
-
['0x00000000000000000000000000000000000000000000000000000000000005e3'],
|
|
274
|
-
[1507]
|
|
275
|
-
]
|
|
276
|
-
];
|
|
277
|
-
examples.forEach(([expected, actual]) => {
|
|
278
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
279
|
-
expect(chickenBondsEncode.rebond(...actual)).to.eql(expected);
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
268
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
285
269
|
describe('closeToAsset()', () => {
|
|
286
270
|
const examples = [
|
|
@@ -970,25 +954,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
970
954
|
});
|
|
971
955
|
});
|
|
972
956
|
});
|
|
973
|
-
describe('When testing strategySubService.morphoAaveV2Encode', () => {
|
|
974
|
-
describe('leverageManagement()', () => {
|
|
975
|
-
const examples = [
|
|
976
|
-
[
|
|
977
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
978
|
-
[160, 220, 180, 190, true]
|
|
979
|
-
],
|
|
980
|
-
[
|
|
981
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
982
|
-
[160, 200, 180, 190, false]
|
|
983
|
-
],
|
|
984
|
-
];
|
|
985
|
-
examples.forEach(([expected, actual]) => {
|
|
986
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
987
|
-
expect(morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
988
|
-
});
|
|
989
|
-
});
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
957
|
describe('When testing strategySubService.exchangeEncode', () => {
|
|
993
958
|
describe('dca()', () => {
|
|
994
959
|
const examples = [
|
|
@@ -1264,75 +1229,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1264
1229
|
});
|
|
1265
1230
|
});
|
|
1266
1231
|
});
|
|
1267
|
-
describe('leverageManagementOnPriceGeneric()', () => {
|
|
1268
|
-
const examples = [
|
|
1269
|
-
[
|
|
1270
|
-
[
|
|
1271
|
-
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1272
|
-
true,
|
|
1273
|
-
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1274
|
-
[
|
|
1275
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1276
|
-
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1277
|
-
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1278
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1279
|
-
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1280
|
-
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1281
|
-
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1282
|
-
],
|
|
1283
|
-
],
|
|
1284
|
-
[
|
|
1285
|
-
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1286
|
-
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1287
|
-
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1288
|
-
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1289
|
-
'945000000000000000',
|
|
1290
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1291
|
-
200,
|
|
1292
|
-
2500,
|
|
1293
|
-
RatioState.UNDER,
|
|
1294
|
-
false,
|
|
1295
|
-
false,
|
|
1296
|
-
ChainId.Ethereum,
|
|
1297
|
-
],
|
|
1298
|
-
],
|
|
1299
|
-
[
|
|
1300
|
-
[
|
|
1301
|
-
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1302
|
-
true,
|
|
1303
|
-
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1304
|
-
[
|
|
1305
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1306
|
-
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1307
|
-
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1308
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1309
|
-
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1310
|
-
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1311
|
-
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1312
|
-
],
|
|
1313
|
-
],
|
|
1314
|
-
[
|
|
1315
|
-
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1316
|
-
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1317
|
-
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1318
|
-
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1319
|
-
'945000000000000000',
|
|
1320
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1321
|
-
160,
|
|
1322
|
-
4000,
|
|
1323
|
-
RatioState.OVER,
|
|
1324
|
-
true,
|
|
1325
|
-
false,
|
|
1326
|
-
ChainId.Ethereum,
|
|
1327
|
-
],
|
|
1328
|
-
],
|
|
1329
|
-
];
|
|
1330
|
-
examples.forEach(([expected, actual]) => {
|
|
1331
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1332
|
-
expect(morphoBlueEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
1333
|
-
});
|
|
1334
|
-
});
|
|
1335
|
-
});
|
|
1336
1232
|
describe('closeOnPrice()', () => {
|
|
1337
1233
|
const examples = [
|
|
1338
1234
|
[
|
|
@@ -1361,7 +1257,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1361
1257
|
1500,
|
|
1362
1258
|
CloseToAssetType.DEBT,
|
|
1363
1259
|
4000,
|
|
1364
|
-
CloseToAssetType.COLLATERAL
|
|
1260
|
+
CloseToAssetType.COLLATERAL
|
|
1365
1261
|
]
|
|
1366
1262
|
],
|
|
1367
1263
|
];
|
|
@@ -1371,45 +1267,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1371
1267
|
});
|
|
1372
1268
|
});
|
|
1373
1269
|
});
|
|
1374
|
-
describe('closeOnPriceGeneric()', () => {
|
|
1375
|
-
const examples = [
|
|
1376
|
-
[
|
|
1377
|
-
[
|
|
1378
|
-
Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1379
|
-
true,
|
|
1380
|
-
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1381
|
-
[
|
|
1382
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1383
|
-
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1384
|
-
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1385
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1386
|
-
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1387
|
-
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1388
|
-
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1389
|
-
],
|
|
1390
|
-
],
|
|
1391
|
-
[
|
|
1392
|
-
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1393
|
-
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1394
|
-
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1395
|
-
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1396
|
-
'945000000000000000',
|
|
1397
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1398
|
-
1500,
|
|
1399
|
-
CloseToAssetType.DEBT,
|
|
1400
|
-
4000,
|
|
1401
|
-
CloseToAssetType.COLLATERAL,
|
|
1402
|
-
false,
|
|
1403
|
-
ChainId.Ethereum,
|
|
1404
|
-
]
|
|
1405
|
-
],
|
|
1406
|
-
];
|
|
1407
|
-
examples.forEach(([expected, actual]) => {
|
|
1408
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1409
|
-
expect(morphoBlueEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1410
|
-
});
|
|
1411
|
-
});
|
|
1412
|
-
});
|
|
1413
1270
|
});
|
|
1414
1271
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1415
1272
|
describe('leverageManagementOnPrice()', () => {
|