@defisaver/automation-sdk 3.3.14 → 3.3.15-liq-prot-1-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 +130 -0
- package/cjs/index.d.ts +4 -3
- package/cjs/index.js +6 -2
- package/cjs/services/strategiesService.js +178 -17
- package/cjs/services/strategySubService.d.ts +14 -13
- package/cjs/services/strategySubService.js +79 -63
- package/cjs/services/strategySubService.test.js +0 -234
- package/cjs/services/subDataService.d.ts +92 -4
- package/cjs/services/subDataService.js +245 -35
- package/cjs/services/subDataService.test.js +0 -110
- package/cjs/services/utils.d.ts +3 -1
- package/cjs/services/utils.js +34 -1
- package/cjs/services/utils.test.js +25 -0
- package/cjs/types/enums.d.ts +36 -6
- package/cjs/types/enums.js +30 -0
- package/esm/constants/index.js +130 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +7 -3
- package/esm/services/strategiesService.js +178 -17
- package/esm/services/strategySubService.d.ts +14 -13
- package/esm/services/strategySubService.js +79 -60
- package/esm/services/strategySubService.test.js +2 -236
- package/esm/services/subDataService.d.ts +92 -4
- package/esm/services/subDataService.js +243 -34
- package/esm/services/subDataService.test.js +0 -110
- package/esm/services/utils.d.ts +3 -1
- package/esm/services/utils.js +32 -1
- package/esm/services/utils.test.js +27 -2
- package/esm/types/enums.d.ts +36 -6
- package/esm/types/enums.js +30 -0
- package/package.json +1 -1
- package/src/constants/index.ts +132 -1
- package/src/index.ts +24 -6
- package/src/services/strategiesService.ts +242 -17
- package/src/services/strategySubService.test.ts +0 -279
- package/src/services/strategySubService.ts +209 -116
- package/src/services/subDataService.test.ts +0 -120
- package/src/services/subDataService.ts +335 -49
- package/src/services/utils.test.ts +32 -1
- package/src/services/utils.ts +32 -1
- package/src/types/enums.ts +30 -2
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
leverageManagement(vaultId: number, triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string, targetRepayRatio: string, boostEnabled: boolean): (string | number | boolean)[];
|
|
9
8
|
leverageManagementWithoutSubProxy(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)[];
|
|
10
10
|
};
|
|
11
11
|
export declare const liquityEncode: {
|
|
12
12
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
13
13
|
trailingStop(triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
14
14
|
paybackFromChickenBondStrategySub(proxyAddress: EthereumAddress, ratio: number, sourceId: string, sourceType: number, ratioState?: RatioState): (boolean | string[] | Bundles.MainnetIds)[];
|
|
15
|
-
|
|
15
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
16
16
|
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
17
17
|
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
18
18
|
debtInFrontRepay(proxyAddress: EthereumAddress, debtInFrontMin: string, targetRatioIncrease: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
@@ -21,10 +21,9 @@ export declare const chickenBondsEncode: {
|
|
|
21
21
|
rebond(bondId: number): string[];
|
|
22
22
|
};
|
|
23
23
|
export declare const aaveV2Encode: {
|
|
24
|
-
|
|
24
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
25
25
|
};
|
|
26
26
|
export declare const aaveV3Encode: {
|
|
27
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
28
27
|
closeToAsset(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
29
28
|
baseTokenAddress: EthereumAddress;
|
|
30
29
|
quoteTokenAddress: EthereumAddress;
|
|
@@ -62,30 +61,28 @@ export declare const aaveV3Encode: {
|
|
|
62
61
|
targetRatio: number;
|
|
63
62
|
}): (number | boolean | string[])[];
|
|
64
63
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, isGeneric?: boolean): (number | boolean | string[])[];
|
|
64
|
+
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
65
65
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
66
66
|
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[])[];
|
|
67
67
|
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[])[];
|
|
68
68
|
};
|
|
69
69
|
export declare const compoundV2Encode: {
|
|
70
|
-
|
|
70
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
71
71
|
};
|
|
72
72
|
export declare const compoundV3Encode: {
|
|
73
|
-
|
|
73
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
74
|
+
liquidationProtectionWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
74
75
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
75
76
|
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[])[];
|
|
76
77
|
};
|
|
77
|
-
export declare const compoundV3L2Encode: {
|
|
78
|
-
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA?: boolean): string;
|
|
79
|
-
};
|
|
80
78
|
export declare const morphoAaveV2Encode: {
|
|
81
79
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
82
80
|
};
|
|
83
81
|
export declare const exchangeEncode: {
|
|
84
82
|
dca(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, timestamp: number, interval: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
85
|
-
|
|
83
|
+
limitOrderWithoutSubProxy(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)[];
|
|
86
84
|
};
|
|
87
85
|
export declare const sparkEncode: {
|
|
88
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
89
86
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
90
87
|
baseTokenAddr: EthereumAddress;
|
|
91
88
|
quoteTokenAddr: EthereumAddress;
|
|
@@ -101,6 +98,7 @@ export declare const sparkEncode: {
|
|
|
101
98
|
}): (number | boolean | string[])[];
|
|
102
99
|
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[])[];
|
|
103
100
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
101
|
+
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
104
102
|
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[])[];
|
|
105
103
|
};
|
|
106
104
|
export declare const crvUSDEncode: {
|
|
@@ -109,6 +107,7 @@ export declare const crvUSDEncode: {
|
|
|
109
107
|
};
|
|
110
108
|
export declare const morphoBlueEncode: {
|
|
111
109
|
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)[];
|
|
110
|
+
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)[];
|
|
112
111
|
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[])[];
|
|
113
112
|
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[])[];
|
|
114
113
|
};
|
|
@@ -120,9 +119,11 @@ export declare const liquityV2Encode: {
|
|
|
120
119
|
};
|
|
121
120
|
export declare const fluidEncode: {
|
|
122
121
|
leverageManagement(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
122
|
+
liquidationProtection(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
123
123
|
};
|
|
124
124
|
export declare const aaveV4Encode: {
|
|
125
125
|
leverageManagement(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
126
|
+
liquidationProtection(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
126
127
|
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[])[];
|
|
127
128
|
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[])[];
|
|
128
129
|
collateralSwitch(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string, price: string, ratioState: RatioState): (number | boolean | string[])[];
|
|
@@ -22,15 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.
|
|
30
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
26
|
+
exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.chickenBondsEncode = exports.liquityEncode = exports.makerEncode = void 0;
|
|
31
27
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
|
-
const enums_1 = require("../types/enums");
|
|
33
28
|
const constants_1 = require("../constants");
|
|
29
|
+
const enums_1 = require("../types/enums");
|
|
34
30
|
const subDataService = __importStar(require("./subDataService"));
|
|
35
31
|
const triggerService = __importStar(require("./triggerService"));
|
|
36
32
|
const utils_1 = require("./utils");
|
|
@@ -60,16 +56,6 @@ exports.makerEncode = {
|
|
|
60
56
|
const isBundle = false;
|
|
61
57
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
62
58
|
},
|
|
63
|
-
leverageManagement(vaultId, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
64
|
-
return [
|
|
65
|
-
vaultId,
|
|
66
|
-
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
67
|
-
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
68
|
-
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
69
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
70
|
-
boostEnabled,
|
|
71
|
-
];
|
|
72
|
-
},
|
|
73
59
|
leverageManagementWithoutSubProxy(vaultId, triggerRatio, targetRatio, ratioState, isBoost, daiAddr) {
|
|
74
60
|
const bundleId = isBoost ? enums_1.Bundles.MainnetIds.MAKER_BOOST : enums_1.Bundles.MainnetIds.MAKER_REPAY;
|
|
75
61
|
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
@@ -81,6 +67,17 @@ exports.makerEncode = {
|
|
|
81
67
|
subData,
|
|
82
68
|
];
|
|
83
69
|
},
|
|
70
|
+
liquidationProtection(vaultId, triggerRatio, targetRatio, ratioState, daiAddr) {
|
|
71
|
+
const bundleId = enums_1.Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION;
|
|
72
|
+
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
73
|
+
const subData = subDataService.makerLiquidationProtectionSubData.encode(vaultId, targetRatio, daiAddr);
|
|
74
|
+
return [
|
|
75
|
+
bundleId,
|
|
76
|
+
true,
|
|
77
|
+
triggerData,
|
|
78
|
+
subData,
|
|
79
|
+
];
|
|
80
|
+
},
|
|
84
81
|
};
|
|
85
82
|
exports.liquityEncode = {
|
|
86
83
|
closeOnPrice(priceOverOrUnder, price, closeToAssetAddr, chainlinkCollAddress, chainId = enums_1.ChainId.Ethereum, collAddr, debtAddr) {
|
|
@@ -107,14 +104,11 @@ exports.liquityEncode = {
|
|
|
107
104
|
const isBundle = true;
|
|
108
105
|
return [strategyId, isBundle, triggerData, subData];
|
|
109
106
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
116
|
-
boostEnabled,
|
|
117
|
-
];
|
|
107
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
108
|
+
const isBundle = true;
|
|
109
|
+
const subData = subDataService.liquityLeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
110
|
+
const triggerData = triggerService.liquityRatioTrigger.encode(user, triggerRatio, ratioState);
|
|
111
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
118
112
|
},
|
|
119
113
|
dsrPayback(proxyAddress, triggerRatio, targetRatio) {
|
|
120
114
|
(0, utils_1.requireAddress)(proxyAddress);
|
|
@@ -147,24 +141,14 @@ exports.chickenBondsEncode = {
|
|
|
147
141
|
},
|
|
148
142
|
};
|
|
149
143
|
exports.aaveV2Encode = {
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
145
|
+
const isBundle = true;
|
|
146
|
+
const subData = subDataService.aaveV2LeverageManagementSubDataWithoutSubProxy.encode(market, targetRatio, ratioState);
|
|
147
|
+
const triggerData = triggerService.aaveV2RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
148
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
152
149
|
},
|
|
153
150
|
};
|
|
154
151
|
exports.aaveV3Encode = {
|
|
155
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
156
|
-
let subInput = '0x';
|
|
157
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
158
|
-
.padStart(32, '0'));
|
|
159
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
160
|
-
.padStart(32, '0'));
|
|
161
|
-
subInput = subInput.concat(new decimal_js_1.default(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
162
|
-
.padStart(32, '0'));
|
|
163
|
-
subInput = subInput.concat(new decimal_js_1.default(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
164
|
-
.padStart(32, '0'));
|
|
165
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
166
|
-
return subInput;
|
|
167
|
-
},
|
|
168
152
|
closeToAsset(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
169
153
|
const { collAsset, collAssetId, debtAsset, debtAssetId, } = subData;
|
|
170
154
|
const subDataEncoded = subDataService.aaveV3QuotePriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId);
|
|
@@ -192,6 +176,12 @@ exports.aaveV3Encode = {
|
|
|
192
176
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
193
177
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
194
178
|
},
|
|
179
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
180
|
+
const isBundle = true;
|
|
181
|
+
const subData = subDataService.aaveV3LiquidationProtectionSubData.encode(targetRatio, ratioState, market, user);
|
|
182
|
+
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
183
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
184
|
+
},
|
|
195
185
|
leverageManagementOnPriceGeneric(strategyOrBundleId, price, ratioState, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
196
186
|
const isBundle = true;
|
|
197
187
|
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user);
|
|
@@ -213,13 +203,25 @@ exports.aaveV3Encode = {
|
|
|
213
203
|
},
|
|
214
204
|
};
|
|
215
205
|
exports.compoundV2Encode = {
|
|
216
|
-
|
|
217
|
-
|
|
206
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
207
|
+
const isBundle = true;
|
|
208
|
+
const subData = subDataService.compoundV2LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
209
|
+
const triggerData = triggerService.compoundV2RatioTrigger.encode(user, triggerRatio, ratioState);
|
|
210
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
218
211
|
},
|
|
219
212
|
};
|
|
220
213
|
exports.compoundV3Encode = {
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
215
|
+
const isBundle = true;
|
|
216
|
+
const subData = subDataService.compoundV3LeverageManagementSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
|
|
217
|
+
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
218
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
219
|
+
},
|
|
220
|
+
liquidationProtectionWithoutSubProxy(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
221
|
+
const isBundle = true;
|
|
222
|
+
const subData = subDataService.compoundV3LiquidationProtectionSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
|
|
223
|
+
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
224
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
223
225
|
},
|
|
224
226
|
leverageManagementOnPrice(strategyOrBundleId, market, collToken, baseToken, targetRatio, price, priceState, ratioState, // REPAY for repay on price, BOOST for boost on price
|
|
225
227
|
user) {
|
|
@@ -236,11 +238,6 @@ exports.compoundV3Encode = {
|
|
|
236
238
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
237
239
|
},
|
|
238
240
|
};
|
|
239
|
-
exports.compoundV3L2Encode = {
|
|
240
|
-
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA = false) {
|
|
241
|
-
return subDataService.compoundV3L2LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
241
|
exports.morphoAaveV2Encode = {
|
|
245
242
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
246
243
|
return subDataService.morphoAaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
@@ -254,24 +251,15 @@ exports.exchangeEncode = {
|
|
|
254
251
|
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
255
252
|
return [strategyId, false, triggerData, subData];
|
|
256
253
|
},
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
limitOrderWithoutSubProxy(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
255
|
+
(0, utils_1.requireAddresses)([fromToken, toToken]);
|
|
256
|
+
const subData = subDataService.exchangeLimitOrderSubDataWithoutSubProxy.encode(fromToken, toToken, amount);
|
|
257
|
+
const triggerData = triggerService.exchangeOffchainPriceTrigger.encode(targetPrice, Number(goodUntil), orderType, fromTokenDecimals, toTokenDecimals);
|
|
258
|
+
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_LIMIT_ORDER;
|
|
259
|
+
return [strategyId, false, triggerData, subData];
|
|
259
260
|
},
|
|
260
261
|
};
|
|
261
262
|
exports.sparkEncode = {
|
|
262
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
263
|
-
let subInput = '0x';
|
|
264
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
265
|
-
.padStart(32, '0'));
|
|
266
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
267
|
-
.padStart(32, '0'));
|
|
268
|
-
subInput = subInput.concat(new decimal_js_1.default(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
269
|
-
.padStart(32, '0'));
|
|
270
|
-
subInput = subInput.concat(new decimal_js_1.default(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
271
|
-
.padStart(32, '0'));
|
|
272
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
273
|
-
return subInput;
|
|
274
|
-
},
|
|
275
263
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
276
264
|
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
277
265
|
const subDataEncoded = subDataService.sparkLeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
@@ -292,6 +280,12 @@ exports.sparkEncode = {
|
|
|
292
280
|
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
293
281
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
294
282
|
},
|
|
283
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
284
|
+
const isBundle = true;
|
|
285
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.encode(targetRatio, ratioState);
|
|
286
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
287
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
288
|
+
},
|
|
295
289
|
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
296
290
|
const isBundle = false;
|
|
297
291
|
const subDataEncoded = subDataService.sparkCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
@@ -334,6 +328,16 @@ exports.morphoBlueEncode = {
|
|
|
334
328
|
const isBundle = true;
|
|
335
329
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
336
330
|
},
|
|
331
|
+
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
332
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
333
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
334
|
+
// Type casting because there is no MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION for Base chain.
|
|
335
|
+
// That is fine because we will just always send isEOA == false for Base chain.
|
|
336
|
+
const bundleNetwork = (0, utils_1.getBundleIdsByNetwork)(network);
|
|
337
|
+
const bundleId = isEOA ? bundleNetwork.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundleNetwork.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
338
|
+
const isBundle = true;
|
|
339
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
340
|
+
},
|
|
337
341
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState) {
|
|
338
342
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
339
343
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
@@ -382,6 +386,12 @@ exports.fluidEncode = {
|
|
|
382
386
|
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
383
387
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
384
388
|
},
|
|
389
|
+
liquidationProtection(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
390
|
+
const isBundle = true;
|
|
391
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
|
|
392
|
+
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
393
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
394
|
+
},
|
|
385
395
|
};
|
|
386
396
|
exports.aaveV4Encode = {
|
|
387
397
|
leverageManagement(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
@@ -390,6 +400,12 @@ exports.aaveV4Encode = {
|
|
|
390
400
|
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
391
401
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
392
402
|
},
|
|
403
|
+
liquidationProtection(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
404
|
+
const isBundle = true;
|
|
405
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
|
|
406
|
+
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
407
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
408
|
+
},
|
|
393
409
|
leverageManagementOnPrice(strategyOrBundleId, owner, spoke, collAsset, collAssetId, debtAsset, debtAssetId, targetRatio, price, priceState, ratioState) {
|
|
394
410
|
const isBundle = true;
|
|
395
411
|
const subData = subDataService.aaveV4LeverageManagementOnPriceSubData.encode(spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio);
|
|
@@ -124,28 +124,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
-
describe('leverageManagement()', () => {
|
|
128
|
-
const examples = [
|
|
129
|
-
[
|
|
130
|
-
[
|
|
131
|
-
5791,
|
|
132
|
-
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
133
|
-
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
134
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
135
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
136
|
-
true,
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
5791, '210', '290', '240', '240', true,
|
|
140
|
-
]
|
|
141
|
-
]
|
|
142
|
-
];
|
|
143
|
-
examples.forEach(([expected, actual]) => {
|
|
144
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
145
|
-
(0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
127
|
describe('leverageManagementWithoutSubProxy()', () => {
|
|
150
128
|
const examples = [
|
|
151
129
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
@@ -245,27 +223,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
245
223
|
});
|
|
246
224
|
});
|
|
247
225
|
});
|
|
248
|
-
describe('leverageManagement()', () => {
|
|
249
|
-
const examples = [
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
253
|
-
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
254
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
255
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
256
|
-
false,
|
|
257
|
-
],
|
|
258
|
-
[
|
|
259
|
-
'210', '290', '240', '240', false,
|
|
260
|
-
]
|
|
261
|
-
]
|
|
262
|
-
];
|
|
263
|
-
examples.forEach(([expected, actual]) => {
|
|
264
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
265
|
-
(0, chai_1.expect)(strategySubService_1.liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
226
|
describe('paybackFromChickenBondStrategySub()', () => {
|
|
270
227
|
const examples = [
|
|
271
228
|
[
|
|
@@ -352,43 +309,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
352
309
|
});
|
|
353
310
|
});
|
|
354
311
|
});
|
|
355
|
-
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
356
|
-
describe('leverageManagement()', () => {
|
|
357
|
-
const examples = [
|
|
358
|
-
[
|
|
359
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
360
|
-
[160, 220, 180, 190, true]
|
|
361
|
-
],
|
|
362
|
-
[
|
|
363
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
364
|
-
[160, 200, 180, 190, false]
|
|
365
|
-
],
|
|
366
|
-
];
|
|
367
|
-
examples.forEach(([expected, actual]) => {
|
|
368
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
369
|
-
(0, chai_1.expect)(strategySubService_1.aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
312
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
375
|
-
describe('leverageManagement()', () => {
|
|
376
|
-
const examples = [
|
|
377
|
-
[
|
|
378
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
379
|
-
[160, 220, 180, 190, true]
|
|
380
|
-
],
|
|
381
|
-
[
|
|
382
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
383
|
-
[160, 200, 180, 190, false]
|
|
384
|
-
],
|
|
385
|
-
];
|
|
386
|
-
examples.forEach(([expected, actual]) => {
|
|
387
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
388
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
313
|
describe('closeToAsset()', () => {
|
|
393
314
|
const examples = [
|
|
394
315
|
[
|
|
@@ -955,69 +876,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
955
876
|
});
|
|
956
877
|
});
|
|
957
878
|
});
|
|
958
|
-
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
959
|
-
describe('leverageManagement()', () => {
|
|
960
|
-
const examples = [
|
|
961
|
-
[
|
|
962
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
963
|
-
[160, 220, 180, 190, true]
|
|
964
|
-
],
|
|
965
|
-
[
|
|
966
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
967
|
-
[160, 200, 180, 190, false]
|
|
968
|
-
],
|
|
969
|
-
];
|
|
970
|
-
examples.forEach(([expected, actual]) => {
|
|
971
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
972
|
-
(0, chai_1.expect)(strategySubService_1.compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
973
|
-
});
|
|
974
|
-
});
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
879
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
978
|
-
describe('leverageManagement()', () => {
|
|
979
|
-
const examples = [
|
|
980
|
-
[
|
|
981
|
-
[
|
|
982
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
983
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
984
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
985
|
-
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
986
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
987
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
988
|
-
true, false,
|
|
989
|
-
],
|
|
990
|
-
[
|
|
991
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
992
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
993
|
-
160, 220, 180, 190,
|
|
994
|
-
true, false,
|
|
995
|
-
]
|
|
996
|
-
],
|
|
997
|
-
[
|
|
998
|
-
[
|
|
999
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1000
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1001
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
1002
|
-
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
1003
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
1004
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
1005
|
-
false, true,
|
|
1006
|
-
],
|
|
1007
|
-
[
|
|
1008
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1009
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1010
|
-
160, 210, 180, 190,
|
|
1011
|
-
false, true,
|
|
1012
|
-
]
|
|
1013
|
-
],
|
|
1014
|
-
];
|
|
1015
|
-
examples.forEach(([expected, actual]) => {
|
|
1016
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1017
|
-
(0, chai_1.expect)(strategySubService_1.compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
|
-
});
|
|
1021
880
|
describe('leverageManagementOnPrice()', () => {
|
|
1022
881
|
const examples = [
|
|
1023
882
|
[
|
|
@@ -1192,51 +1051,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1192
1051
|
});
|
|
1193
1052
|
});
|
|
1194
1053
|
});
|
|
1195
|
-
describe('limitOrder()', () => {
|
|
1196
|
-
const examples = [
|
|
1197
|
-
[
|
|
1198
|
-
[
|
|
1199
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1200
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1201
|
-
'2131',
|
|
1202
|
-
'0.53123',
|
|
1203
|
-
'1696590921159',
|
|
1204
|
-
`${enums_1.OrderType.STOP_LOSS}`
|
|
1205
|
-
],
|
|
1206
|
-
[
|
|
1207
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1208
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1209
|
-
'2131',
|
|
1210
|
-
'0.53123',
|
|
1211
|
-
1696590921159,
|
|
1212
|
-
enums_1.OrderType.STOP_LOSS
|
|
1213
|
-
]
|
|
1214
|
-
],
|
|
1215
|
-
[
|
|
1216
|
-
[
|
|
1217
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1218
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1219
|
-
'2131',
|
|
1220
|
-
'0.43123',
|
|
1221
|
-
'1646590921159',
|
|
1222
|
-
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
1223
|
-
],
|
|
1224
|
-
[
|
|
1225
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1226
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1227
|
-
'2131',
|
|
1228
|
-
'0.43123',
|
|
1229
|
-
1646590921159,
|
|
1230
|
-
enums_1.OrderType.TAKE_PROFIT
|
|
1231
|
-
]
|
|
1232
|
-
],
|
|
1233
|
-
];
|
|
1234
|
-
examples.forEach(([expected, actual]) => {
|
|
1235
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1236
|
-
(0, chai_1.expect)(strategySubService_1.exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
1237
|
-
});
|
|
1238
|
-
});
|
|
1239
|
-
});
|
|
1240
1054
|
});
|
|
1241
1055
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
1242
1056
|
describe('leverageManagement()', () => {
|
|
@@ -1450,55 +1264,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1450
1264
|
});
|
|
1451
1265
|
});
|
|
1452
1266
|
});
|
|
1453
|
-
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
1454
|
-
describe('leverageManagement()', () => {
|
|
1455
|
-
const examples = [
|
|
1456
|
-
[
|
|
1457
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1458
|
-
[
|
|
1459
|
-
web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1460
|
-
web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1461
|
-
160, 220, 180, 190,
|
|
1462
|
-
true,
|
|
1463
|
-
false,
|
|
1464
|
-
],
|
|
1465
|
-
],
|
|
1466
|
-
[
|
|
1467
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1468
|
-
[
|
|
1469
|
-
web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1470
|
-
web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1471
|
-
160, 220, 180, 110,
|
|
1472
|
-
false,
|
|
1473
|
-
false,
|
|
1474
|
-
],
|
|
1475
|
-
],
|
|
1476
|
-
];
|
|
1477
|
-
examples.forEach(([expected, actual]) => {
|
|
1478
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1479
|
-
(0, chai_1.expect)(strategySubService_1.compoundV3L2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1480
|
-
});
|
|
1481
|
-
});
|
|
1482
|
-
});
|
|
1483
|
-
});
|
|
1484
1267
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1485
|
-
describe('leverageManagement()', () => {
|
|
1486
|
-
const examples = [
|
|
1487
|
-
[
|
|
1488
|
-
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1489
|
-
[140, 240, 210, 190, true]
|
|
1490
|
-
],
|
|
1491
|
-
[
|
|
1492
|
-
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1493
|
-
[137, 184, 289, 246, false]
|
|
1494
|
-
]
|
|
1495
|
-
];
|
|
1496
|
-
examples.forEach(([expected, actual]) => {
|
|
1497
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1498
|
-
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1499
|
-
});
|
|
1500
|
-
});
|
|
1501
|
-
});
|
|
1502
1268
|
describe('leverageManagementOnPrice()', () => {
|
|
1503
1269
|
const examples = [
|
|
1504
1270
|
[
|