@defisaver/automation-sdk 3.3.14 → 3.3.15-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 +95 -0
- package/cjs/index.d.ts +4 -3
- package/cjs/index.js +6 -2
- package/cjs/services/strategiesService.js +181 -17
- package/cjs/services/strategySubService.d.ts +14 -13
- package/cjs/services/strategySubService.js +74 -63
- package/cjs/services/strategySubService.test.js +0 -234
- package/cjs/services/subDataService.d.ts +98 -1
- package/cjs/services/subDataService.js +264 -6
- package/cjs/services/subDataService.test.js +0 -42
- 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 +29 -6
- package/cjs/types/enums.js +23 -0
- package/esm/constants/index.js +95 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +7 -3
- package/esm/services/strategiesService.js +181 -17
- package/esm/services/strategySubService.d.ts +14 -13
- package/esm/services/strategySubService.js +74 -60
- package/esm/services/strategySubService.test.js +2 -236
- package/esm/services/subDataService.d.ts +98 -1
- package/esm/services/subDataService.js +262 -5
- package/esm/services/subDataService.test.js +0 -42
- 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 +29 -6
- package/esm/types/enums.js +23 -0
- package/package.json +1 -1
- package/src/constants/index.ts +96 -0
- package/src/index.ts +24 -6
- package/src/services/strategiesService.ts +246 -17
- package/src/services/strategySubService.test.ts +0 -279
- package/src/services/strategySubService.ts +196 -110
- package/src/services/subDataService.test.ts +0 -48
- package/src/services/subDataService.ts +363 -4
- package/src/services/utils.test.ts +32 -1
- package/src/services/utils.ts +32 -1
- package/src/types/enums.ts +23 -0
|
@@ -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
|
+
liquidationProtection(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: 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_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,22 @@ 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
|
+
liquidationProtection(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
221
|
+
return subDataService.compoundV3LiquidationProtectionSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
223
222
|
},
|
|
224
223
|
leverageManagementOnPrice(strategyOrBundleId, market, collToken, baseToken, targetRatio, price, priceState, ratioState, // REPAY for repay on price, BOOST for boost on price
|
|
225
224
|
user) {
|
|
@@ -236,11 +235,6 @@ exports.compoundV3Encode = {
|
|
|
236
235
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
237
236
|
},
|
|
238
237
|
};
|
|
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
238
|
exports.morphoAaveV2Encode = {
|
|
245
239
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
246
240
|
return subDataService.morphoAaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
@@ -254,24 +248,15 @@ exports.exchangeEncode = {
|
|
|
254
248
|
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
255
249
|
return [strategyId, false, triggerData, subData];
|
|
256
250
|
},
|
|
257
|
-
|
|
258
|
-
|
|
251
|
+
limitOrderWithoutSubProxy(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
252
|
+
(0, utils_1.requireAddresses)([fromToken, toToken]);
|
|
253
|
+
const subData = subDataService.exchangeLimitOrderSubDataWithoutSubProxy.encode(fromToken, toToken, amount);
|
|
254
|
+
const triggerData = triggerService.exchangeOffchainPriceTrigger.encode(targetPrice, Number(goodUntil), orderType, fromTokenDecimals, toTokenDecimals);
|
|
255
|
+
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_LIMIT_ORDER;
|
|
256
|
+
return [strategyId, false, triggerData, subData];
|
|
259
257
|
},
|
|
260
258
|
};
|
|
261
259
|
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
260
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
276
261
|
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
277
262
|
const subDataEncoded = subDataService.sparkLeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
@@ -292,6 +277,12 @@ exports.sparkEncode = {
|
|
|
292
277
|
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
293
278
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
294
279
|
},
|
|
280
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
281
|
+
const isBundle = true;
|
|
282
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.encode(targetRatio, ratioState);
|
|
283
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
284
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
285
|
+
},
|
|
295
286
|
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
296
287
|
const isBundle = false;
|
|
297
288
|
const subDataEncoded = subDataService.sparkCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
@@ -334,6 +325,14 @@ exports.morphoBlueEncode = {
|
|
|
334
325
|
const isBundle = true;
|
|
335
326
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
336
327
|
},
|
|
328
|
+
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
329
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
330
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
331
|
+
// TODO -> Check if need to deploy separate bundles for EOA, or can reuse this for EOA. Logic above is different for EOA and SW on arbi and mainnet. Base uses same for both, not sure if because of lack of EOA support or because it is using same bundle for both.
|
|
332
|
+
const bundleId = (0, utils_1.getBundleIdsByNetwork)(network).MORPHO_BLUE_LIQUIDATION_PROTECTION;
|
|
333
|
+
const isBundle = true;
|
|
334
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
335
|
+
},
|
|
337
336
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState) {
|
|
338
337
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
339
338
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
@@ -382,6 +381,12 @@ exports.fluidEncode = {
|
|
|
382
381
|
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
383
382
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
384
383
|
},
|
|
384
|
+
liquidationProtection(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
385
|
+
const isBundle = true;
|
|
386
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
|
|
387
|
+
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
388
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
389
|
+
},
|
|
385
390
|
};
|
|
386
391
|
exports.aaveV4Encode = {
|
|
387
392
|
leverageManagement(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
@@ -390,6 +395,12 @@ exports.aaveV4Encode = {
|
|
|
390
395
|
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
391
396
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
392
397
|
},
|
|
398
|
+
liquidationProtection(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
399
|
+
const isBundle = true;
|
|
400
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
|
|
401
|
+
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
402
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
403
|
+
},
|
|
393
404
|
leverageManagementOnPrice(strategyOrBundleId, owner, spoke, collAsset, collAssetId, debtAsset, debtAssetId, targetRatio, price, priceState, ratioState) {
|
|
394
405
|
const isBundle = true;
|
|
395
406
|
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
|
[
|