@defisaver/automation-sdk 1.0.1
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/.babelrc +3 -0
- package/.editorconfig +9 -0
- package/.eslintignore +7 -0
- package/.eslintrc.js +104 -0
- package/esm/abis/Erc20.json +223 -0
- package/esm/abis/SubStorage.json +17 -0
- package/esm/abis/UniMulticall.json +14 -0
- package/esm/abis/index.d.ts +9 -0
- package/esm/abis/index.js +18 -0
- package/esm/abis/legacy_AaveV2Subscriptions.json +8 -0
- package/esm/abis/legacy_AuthCheck.json +8 -0
- package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -0
- package/esm/abis/legacy_MakerSubscriptions.json +9 -0
- package/esm/automation/private/Automation.d.ts +12 -0
- package/esm/automation/private/Automation.js +39 -0
- package/esm/automation/private/LegacyAutomation.d.ts +25 -0
- package/esm/automation/private/LegacyAutomation.js +102 -0
- package/esm/automation/private/LegacyProtocol.d.ts +20 -0
- package/esm/automation/private/LegacyProtocol.js +34 -0
- package/esm/automation/private/Protocol.d.ts +20 -0
- package/esm/automation/private/Protocol.js +34 -0
- package/esm/automation/private/StrategiesAutomation.d.ts +24 -0
- package/esm/automation/private/StrategiesAutomation.js +111 -0
- package/esm/automation/public/ArbitrumStrategies.d.ts +5 -0
- package/esm/automation/public/ArbitrumStrategies.js +7 -0
- package/esm/automation/public/EthereumStrategies.d.ts +5 -0
- package/esm/automation/public/EthereumStrategies.js +7 -0
- package/esm/automation/public/OptimismStrategies.d.ts +5 -0
- package/esm/automation/public/OptimismStrategies.js +7 -0
- package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -0
- package/esm/automation/public/legacy/LegacyAaveAutomation.js +14 -0
- package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -0
- package/esm/automation/public/legacy/LegacyCompoundAutomation.js +14 -0
- package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -0
- package/esm/automation/public/legacy/LegacyMakerAutomation.js +14 -0
- package/esm/configuration.d.ts +1 -0
- package/esm/configuration.js +9 -0
- package/esm/constants/index.d.ts +23 -0
- package/esm/constants/index.js +153 -0
- package/esm/index.d.ts +20 -0
- package/esm/index.js +22 -0
- package/esm/services/contractService.d.ts +11 -0
- package/esm/services/contractService.js +40 -0
- package/esm/services/ethereumService.d.ts +7 -0
- package/esm/services/ethereumService.js +34 -0
- package/esm/services/strategiesService.d.ts +2 -0
- package/esm/services/strategiesService.js +244 -0
- package/esm/services/strategySubService.d.ts +32 -0
- package/esm/services/strategySubService.js +91 -0
- package/esm/services/subDataService.d.ts +62 -0
- package/esm/services/subDataService.js +148 -0
- package/esm/services/triggerService.d.ts +89 -0
- package/esm/services/triggerService.js +141 -0
- package/esm/services/utils.d.ts +24 -0
- package/esm/services/utils.js +78 -0
- package/esm/types/contracts/generated/Erc20.d.ts +53 -0
- package/esm/types/contracts/generated/Erc20.js +4 -0
- package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -0
- package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +4 -0
- package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -0
- package/esm/types/contracts/generated/Legacy_AuthCheck.js +4 -0
- package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -0
- package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +4 -0
- package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -0
- package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +4 -0
- package/esm/types/contracts/generated/SubStorage.d.ts +114 -0
- package/esm/types/contracts/generated/SubStorage.js +4 -0
- package/esm/types/contracts/generated/UniMulticall.d.ts +55 -0
- package/esm/types/contracts/generated/UniMulticall.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +7 -0
- package/esm/types/contracts/generated/index.js +1 -0
- package/esm/types/contracts/generated/types.d.ts +54 -0
- package/esm/types/contracts/generated/types.js +1 -0
- package/esm/types/enums.d.ts +97 -0
- package/esm/types/enums.js +113 -0
- package/esm/types/index.d.ts +180 -0
- package/esm/types/index.js +1 -0
- package/package.json +66 -0
- package/scripts/generateContractTypes.js +39 -0
- package/src/abis/Erc20.json +223 -0
- package/src/abis/SubStorage.json +17 -0
- package/src/abis/UniMulticall.json +14 -0
- package/src/abis/index.ts +28 -0
- package/src/abis/legacy_AaveV2Subscriptions.json +8 -0
- package/src/abis/legacy_AuthCheck.json +8 -0
- package/src/abis/legacy_CompoundV2Subscriptions.json +9 -0
- package/src/abis/legacy_MakerSubscriptions.json +9 -0
- package/src/automation/private/Automation.ts +44 -0
- package/src/automation/private/LegacyAutomation.ts +124 -0
- package/src/automation/private/LegacyProtocol.ts +45 -0
- package/src/automation/private/Protocol.ts +45 -0
- package/src/automation/private/StrategiesAutomation.ts +157 -0
- package/src/automation/public/ArbitrumStrategies.ts +10 -0
- package/src/automation/public/EthereumStrategies.ts +10 -0
- package/src/automation/public/OptimismStrategies.ts +10 -0
- package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -0
- package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -0
- package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -0
- package/src/configuration.ts +11 -0
- package/src/constants/index.ts +173 -0
- package/src/index.ts +38 -0
- package/src/services/contractService.ts +65 -0
- package/src/services/ethereumService.ts +55 -0
- package/src/services/strategiesService.ts +336 -0
- package/src/services/strategySubService.ts +202 -0
- package/src/services/subDataService.ts +212 -0
- package/src/services/triggerService.ts +173 -0
- package/src/services/utils.ts +101 -0
- package/src/types/contracts/generated/Erc20.ts +95 -0
- package/src/types/contracts/generated/Legacy_AaveV2Subscriptions.ts +207 -0
- package/src/types/contracts/generated/Legacy_AuthCheck.ts +41 -0
- package/src/types/contracts/generated/Legacy_CompoundV2Subscriptions.ts +205 -0
- package/src/types/contracts/generated/Legacy_MakerSubscriptions.ts +338 -0
- package/src/types/contracts/generated/SubStorage.ts +196 -0
- package/src/types/contracts/generated/UniMulticall.ts +83 -0
- package/src/types/contracts/generated/index.ts +10 -0
- package/src/types/contracts/generated/types.ts +73 -0
- package/src/types/enums.ts +108 -0
- package/src/types/index.ts +217 -0
- package/src/types/typings/process.d.ts +9 -0
- package/tsconfig.json +79 -0
- package/umd/web3.d.ts +28961 -0
- package/webpack.umd.js +52 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// TODO
|
|
2
|
+
// [] Check @ts-ignores and PlaceholderType
|
|
3
|
+
// [] Improve typing for subData, trigger and strategySub services
|
|
4
|
+
// [] Make possible to use any provider not only web3 (This requires changes throughout the package)
|
|
5
|
+
// [] Write unit tests
|
|
6
|
+
|
|
7
|
+
import './configuration';
|
|
8
|
+
|
|
9
|
+
import LegacyMakerAutomation from './automation/public/legacy/LegacyMakerAutomation';
|
|
10
|
+
import LegacyAaveAutomation from './automation/public/legacy/LegacyAaveAutomation';
|
|
11
|
+
import LegacyCompoundAutomation from './automation/public/legacy/LegacyCompoundAutomation';
|
|
12
|
+
|
|
13
|
+
import EthereumStrategies from './automation/public/EthereumStrategies';
|
|
14
|
+
import OptimismStrategies from './automation/public/OptimismStrategies';
|
|
15
|
+
import ArbitrumStrategies from './automation/public/ArbitrumStrategies';
|
|
16
|
+
|
|
17
|
+
import * as triggerService from './services/triggerService';
|
|
18
|
+
import * as subDataService from './services/subDataService';
|
|
19
|
+
import * as strategySubService from './services/strategySubService';
|
|
20
|
+
import * as constants from './constants';
|
|
21
|
+
|
|
22
|
+
import * as enums from './types/enums';
|
|
23
|
+
import type * as types from './types';
|
|
24
|
+
|
|
25
|
+
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId } from './services/utils';
|
|
26
|
+
|
|
27
|
+
const utils = {
|
|
28
|
+
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
LegacyMakerAutomation, LegacyAaveAutomation, LegacyCompoundAutomation,
|
|
33
|
+
EthereumStrategies, OptimismStrategies, ArbitrumStrategies,
|
|
34
|
+
triggerService, subDataService, strategySubService, utils,
|
|
35
|
+
enums, constants,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type { types };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type Web3 from 'web3';
|
|
2
|
+
import type { AbiItem } from 'web3-utils';
|
|
3
|
+
import type {
|
|
4
|
+
BlockNumber, Contract,
|
|
5
|
+
} from '../types';
|
|
6
|
+
|
|
7
|
+
import type { BaseContract } from '../types/contracts/generated/types';
|
|
8
|
+
import type { Legacy_AuthCheck, SubStorage, UniMulticall } from '../types/contracts/generated';
|
|
9
|
+
|
|
10
|
+
import { UniMulticallJson, SubStorageJson, AuthCheckJson } from '../abis';
|
|
11
|
+
|
|
12
|
+
import { isDefined } from './utils';
|
|
13
|
+
import { ChainId } from '../types/enums';
|
|
14
|
+
|
|
15
|
+
export function getAbiItem(abi: AbiItem[], itemName: string) {
|
|
16
|
+
const abiItem = abi.find(i => i.name === itemName);
|
|
17
|
+
if (isDefined(abiItem)) {
|
|
18
|
+
return abiItem;
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`Can't find abi item for itemName: ${itemName}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function makeContract<T extends BaseContract>(
|
|
24
|
+
web3: Web3,
|
|
25
|
+
contractJson: Contract.Json,
|
|
26
|
+
chainId: ChainId,
|
|
27
|
+
): Contract.WithMeta<T> {
|
|
28
|
+
const { abi } = contractJson;
|
|
29
|
+
|
|
30
|
+
let _address = '';
|
|
31
|
+
let _createdBlock: BlockNumber = 'earliest';
|
|
32
|
+
|
|
33
|
+
if (contractJson.networks) {
|
|
34
|
+
const { address, createdBlock } = contractJson.networks[chainId];
|
|
35
|
+
|
|
36
|
+
_address = address;
|
|
37
|
+
|
|
38
|
+
if (isDefined(createdBlock)) {
|
|
39
|
+
_createdBlock = createdBlock;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
abi,
|
|
45
|
+
address: _address,
|
|
46
|
+
createdBlock: _createdBlock,
|
|
47
|
+
contract: new web3.eth.Contract(abi, _address) as any as T,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function makeUniMulticallContract(web3: Web3, chainId: ChainId) {
|
|
52
|
+
return makeContract<UniMulticall>(web3, UniMulticallJson, chainId);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function makeSubStorageContract(web3: Web3, chainId: ChainId) {
|
|
56
|
+
return makeContract<SubStorage>(web3, SubStorageJson, chainId);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function makeAuthCheckerContract(web3: Web3, chainId: ChainId) {
|
|
60
|
+
return makeContract<Legacy_AuthCheck>(web3, AuthCheckJson, chainId);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function makeLegacySubscriptionContract<T extends BaseContract>(web3: Web3, contractJson: Contract.Json) {
|
|
64
|
+
return makeContract<T>(web3, contractJson, ChainId.Ethereum);
|
|
65
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type Web3 from 'web3';
|
|
2
|
+
import type { PastEventOptions } from 'web3-eth-contract';
|
|
3
|
+
import type {
|
|
4
|
+
BlockNumber, Multicall, Contract,
|
|
5
|
+
} from '../types';
|
|
6
|
+
|
|
7
|
+
import { makeUniMulticallContract } from './contractService';
|
|
8
|
+
import { addToObjectIf, isDefined } from './utils';
|
|
9
|
+
import type { BaseContract } from '../types/contracts/generated/types';
|
|
10
|
+
import type { ChainId } from '../types/enums';
|
|
11
|
+
|
|
12
|
+
const { mockedWeb3 } = process;
|
|
13
|
+
|
|
14
|
+
export async function multicall(
|
|
15
|
+
web3: Web3,
|
|
16
|
+
chainId: ChainId,
|
|
17
|
+
calls: Multicall.Calls[],
|
|
18
|
+
block: BlockNumber = 'latest',
|
|
19
|
+
): Promise<Multicall.Payload> {
|
|
20
|
+
const multicallContract = makeUniMulticallContract(web3, chainId).contract;
|
|
21
|
+
|
|
22
|
+
const formattedCalls: Multicall.FormattedCalls[] = calls.map((call) => ({
|
|
23
|
+
callData: mockedWeb3.eth.abi.encodeFunctionCall(call.abiItem, call.params),
|
|
24
|
+
target: call.target || '0x0',
|
|
25
|
+
gasLimit: call.gasLimit || 1e6,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const callResult = await multicallContract.methods.multicall(
|
|
29
|
+
formattedCalls.filter(item => item.target !== '0x0'),
|
|
30
|
+
).call({}, block);
|
|
31
|
+
|
|
32
|
+
let formattedResult: Multicall.Payload = [];
|
|
33
|
+
|
|
34
|
+
callResult.returnData.forEach(([success, gasUsed, result], i) => {
|
|
35
|
+
const formattedRes = (result !== '0x'
|
|
36
|
+
? mockedWeb3.eth.abi.decodeParameters(calls[i].abiItem.outputs!, result)
|
|
37
|
+
: undefined) as Multicall.Payload;
|
|
38
|
+
formattedResult = [...formattedResult, formattedRes];
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return formattedResult;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getEventsFromContract<T extends BaseContract>(
|
|
45
|
+
contractWithMeta: Contract.WithMeta<T>,
|
|
46
|
+
event: string, options?: PastEventOptions,
|
|
47
|
+
) {
|
|
48
|
+
return contractWithMeta.contract.getPastEvents(
|
|
49
|
+
event,
|
|
50
|
+
{
|
|
51
|
+
...addToObjectIf(isDefined(options), options),
|
|
52
|
+
fromBlock: contractWithMeta.createdBlock,
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash';
|
|
2
|
+
|
|
3
|
+
import { BUNDLES_INFO, STRATEGIES_INFO } from '../constants';
|
|
4
|
+
import type {
|
|
5
|
+
Position, ParseData, StrategiesToProtocolVersionMapping, BundleOrStrategy, StrategyOrBundleIds,
|
|
6
|
+
} from '../types';
|
|
7
|
+
import { ProtocolIdentifiers, Strategies } from '../types/enums';
|
|
8
|
+
|
|
9
|
+
import { getRatioStateInfoForAaveCloseStrategy, isRatioStateOver, wethToEthByAddress } from './utils';
|
|
10
|
+
import * as subDataService from './subDataService';
|
|
11
|
+
import * as triggerService from './triggerService';
|
|
12
|
+
|
|
13
|
+
function parseMakerSavingsLiqProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
14
|
+
const _position = cloneDeep(position);
|
|
15
|
+
|
|
16
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
17
|
+
|
|
18
|
+
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
19
|
+
const subData = subDataService.makerRepayFromSavingsSubData.decode(subStruct.subData);
|
|
20
|
+
|
|
21
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
22
|
+
_position.strategyData.decoded.subData = subData;
|
|
23
|
+
|
|
24
|
+
_position.specific = {
|
|
25
|
+
minRatio: Number(triggerData.ratio),
|
|
26
|
+
minOptimalRatio: Number(subData.targetRatio),
|
|
27
|
+
repayEnabled: true,
|
|
28
|
+
boostEnabled: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return _position;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseMakerCloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
35
|
+
const _position = cloneDeep(position);
|
|
36
|
+
|
|
37
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
38
|
+
|
|
39
|
+
const triggerData = triggerService.chainlinkPriceTrigger.decode(subStruct.triggerData);
|
|
40
|
+
const subData = subDataService.makerCloseSubData.decode(subStruct.subData);
|
|
41
|
+
|
|
42
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
43
|
+
_position.strategyData.decoded.subData = subData;
|
|
44
|
+
|
|
45
|
+
const isTakeProfit = isRatioStateOver(Number(triggerData.state));
|
|
46
|
+
|
|
47
|
+
_position.strategy.strategyId = isTakeProfit ? Strategies.IdOverrides.TakeProfit : Strategies.IdOverrides.StopLoss;
|
|
48
|
+
|
|
49
|
+
_position.specific = {
|
|
50
|
+
price: triggerData.price,
|
|
51
|
+
closeToAssetAddr: subData.closeToAssetAddr,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return _position;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseMakerTrailingStop(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
58
|
+
const _position = cloneDeep(position);
|
|
59
|
+
|
|
60
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
61
|
+
|
|
62
|
+
const triggerData = triggerService.trailingStopTrigger.decode(subStruct.triggerData);
|
|
63
|
+
const subData = subDataService.makerCloseSubData.decode(subStruct.subData);
|
|
64
|
+
|
|
65
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
66
|
+
_position.strategyData.decoded.subData = subData;
|
|
67
|
+
|
|
68
|
+
_position.strategy.strategyId = Strategies.IdOverrides.TrailingStop;
|
|
69
|
+
|
|
70
|
+
_position.specific = {
|
|
71
|
+
triggerPercentage: Number(triggerData.triggerPercentage),
|
|
72
|
+
roundId: Number(triggerData.roundId),
|
|
73
|
+
closeToAssetAddr: subData.closeToAssetAddr,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return _position;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function parseLiquityCloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
80
|
+
const _position = cloneDeep(position);
|
|
81
|
+
|
|
82
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
83
|
+
|
|
84
|
+
const triggerData = triggerService.chainlinkPriceTrigger.decode(subStruct.triggerData);
|
|
85
|
+
const subData = subDataService.liquityCloseSubData.decode(subStruct.subData);
|
|
86
|
+
|
|
87
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
88
|
+
_position.strategyData.decoded.subData = subData;
|
|
89
|
+
|
|
90
|
+
const isTakeProfit = isRatioStateOver(Number(triggerData.state));
|
|
91
|
+
|
|
92
|
+
_position.strategy.strategyId = isTakeProfit ? Strategies.IdOverrides.TakeProfit : Strategies.IdOverrides.StopLoss;
|
|
93
|
+
|
|
94
|
+
_position.specific = {
|
|
95
|
+
price: triggerData.price,
|
|
96
|
+
closeToAssetAddr: subData.closeToAssetAddr,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return _position;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function parseLiquityTrailingStop(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
103
|
+
const _position = cloneDeep(position);
|
|
104
|
+
|
|
105
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
106
|
+
|
|
107
|
+
const triggerData = triggerService.trailingStopTrigger.decode(subStruct.triggerData);
|
|
108
|
+
const subData = subDataService.liquityCloseSubData.decode(subStruct.subData);
|
|
109
|
+
|
|
110
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
111
|
+
_position.strategyData.decoded.subData = subData;
|
|
112
|
+
|
|
113
|
+
_position.strategy.strategyId = Strategies.IdOverrides.TrailingStop;
|
|
114
|
+
|
|
115
|
+
_position.specific = {
|
|
116
|
+
triggerPercentage: Number(triggerData.triggerPercentage),
|
|
117
|
+
roundId: Number(triggerData.roundId),
|
|
118
|
+
closeToAssetAddr: subData.closeToAssetAddr,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return _position;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function parseAaveV3LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
125
|
+
const _position = cloneDeep(position);
|
|
126
|
+
|
|
127
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
128
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
129
|
+
|
|
130
|
+
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
131
|
+
const subData = subDataService.aaveLeverageManagementSubData.decode(subStruct.subData);
|
|
132
|
+
|
|
133
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
134
|
+
_position.strategyData.decoded.subData = subData;
|
|
135
|
+
|
|
136
|
+
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
137
|
+
|
|
138
|
+
if (isRepay) {
|
|
139
|
+
_position.specific = {
|
|
140
|
+
minRatio: triggerData.ratio,
|
|
141
|
+
minOptimalRatio: subData.targetRatio,
|
|
142
|
+
repayEnabled: true,
|
|
143
|
+
subId1: Number(subId),
|
|
144
|
+
};
|
|
145
|
+
} else {
|
|
146
|
+
_position.specific = {
|
|
147
|
+
maxRatio: triggerData.ratio,
|
|
148
|
+
maxOptimalRatio: subData.targetRatio,
|
|
149
|
+
boostEnabled: isEnabled,
|
|
150
|
+
subId2: Number(subId),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
155
|
+
_position.specific.mergeWithSameId = true;
|
|
156
|
+
|
|
157
|
+
return _position;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function parseAaveV3CloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
161
|
+
const _position = cloneDeep(position);
|
|
162
|
+
|
|
163
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
164
|
+
|
|
165
|
+
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
166
|
+
const subData = subDataService.aaveV3QuotePriceSubData.decode(subStruct.subData);
|
|
167
|
+
|
|
168
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
169
|
+
_position.strategyData.decoded.subData = subData;
|
|
170
|
+
|
|
171
|
+
_position.specific = {
|
|
172
|
+
collAsset: subData.collAsset,
|
|
173
|
+
collAssetId: subData.collAssetId,
|
|
174
|
+
debtAsset: subData.debtAsset,
|
|
175
|
+
debtAssetId: subData.debtAssetId,
|
|
176
|
+
baseToken: triggerData.baseTokenAddress,
|
|
177
|
+
quoteToken: triggerData.quoteTokenAddress,
|
|
178
|
+
price: triggerData.price,
|
|
179
|
+
ratioState: triggerData.ratioState,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const { ratioState } = getRatioStateInfoForAaveCloseStrategy(
|
|
183
|
+
_position.specific.ratioState,
|
|
184
|
+
wethToEthByAddress(_position.specific.collAsset),
|
|
185
|
+
wethToEthByAddress(_position.specific.debtAsset),
|
|
186
|
+
parseData.chainId,
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
_position.strategy.strategyId = isRatioStateOver(ratioState) ? Strategies.IdOverrides.TakeProfit : Strategies.IdOverrides.StopLoss;
|
|
190
|
+
|
|
191
|
+
return _position;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function parseCompoundV3LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
195
|
+
const _position = cloneDeep(position);
|
|
196
|
+
|
|
197
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
198
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
199
|
+
|
|
200
|
+
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
201
|
+
const subData = subDataService.compoundV3LeverageManagementSubData.decode(subStruct.subData);
|
|
202
|
+
|
|
203
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
204
|
+
_position.strategyData.decoded.subData = subData;
|
|
205
|
+
|
|
206
|
+
const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId as Strategies.Identifiers);
|
|
207
|
+
|
|
208
|
+
if (isRepay) {
|
|
209
|
+
_position.specific = {
|
|
210
|
+
minRatio: triggerData.ratio,
|
|
211
|
+
minOptimalRatio: subData.targetRatio,
|
|
212
|
+
repayEnabled: true,
|
|
213
|
+
subId1: Number(subId),
|
|
214
|
+
};
|
|
215
|
+
} else {
|
|
216
|
+
_position.specific = {
|
|
217
|
+
maxRatio: triggerData.ratio,
|
|
218
|
+
maxOptimalRatio: subData.targetRatio,
|
|
219
|
+
boostEnabled: isEnabled,
|
|
220
|
+
subId2: Number(subId),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
225
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
226
|
+
|
|
227
|
+
_position.specific.mergeWithSameId = true;
|
|
228
|
+
|
|
229
|
+
return _position;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function parseChickenBondsRebond(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
233
|
+
const _position = cloneDeep(position);
|
|
234
|
+
|
|
235
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
236
|
+
|
|
237
|
+
_position.strategyData.decoded.triggerData = triggerService.cBondsRebondTrigger.decode(subStruct.triggerData);
|
|
238
|
+
_position.strategyData.decoded.subData = subDataService.cBondsRebondSubData.decode(subStruct.subData);
|
|
239
|
+
|
|
240
|
+
return _position;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function parseLiquityBondProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
244
|
+
const _position = cloneDeep(position);
|
|
245
|
+
|
|
246
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
247
|
+
|
|
248
|
+
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
249
|
+
_position.strategyData.decoded.subData = subDataService.liquityPaybackUsingChickenBondSubData.decode(subStruct.subData);
|
|
250
|
+
|
|
251
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
252
|
+
|
|
253
|
+
_position.specific = {
|
|
254
|
+
minRatio: Number(triggerData.ratio),
|
|
255
|
+
minOptimalRatio: Infinity, // Unknown minOptimalRatio, uses all assets from chicken bond until trove min debt (2000LUSD)
|
|
256
|
+
repayEnabled: true,
|
|
257
|
+
};
|
|
258
|
+
return _position;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
262
|
+
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
263
|
+
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection, // TODO union type by protocol
|
|
264
|
+
[Strategies.Identifiers.CloseOnPriceToDebt]: parseMakerCloseOnPrice,
|
|
265
|
+
[Strategies.Identifiers.CloseOnPriceToColl]: parseMakerCloseOnPrice,
|
|
266
|
+
[Strategies.Identifiers.TrailingStopToColl]: parseMakerTrailingStop,
|
|
267
|
+
[Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
268
|
+
},
|
|
269
|
+
[ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
270
|
+
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
271
|
+
[Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
272
|
+
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
273
|
+
},
|
|
274
|
+
[ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
275
|
+
[Strategies.Identifiers.Repay]: parseAaveV3LeverageManagement,
|
|
276
|
+
[Strategies.Identifiers.Boost]: parseAaveV3LeverageManagement,
|
|
277
|
+
[Strategies.Identifiers.CloseToDebt]: parseAaveV3CloseOnPrice,
|
|
278
|
+
[Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
279
|
+
},
|
|
280
|
+
[ProtocolIdentifiers.StrategiesAutomation.CompoundV3]: {
|
|
281
|
+
[Strategies.Identifiers.Repay]: parseCompoundV3LeverageManagement,
|
|
282
|
+
[Strategies.Identifiers.Boost]: parseCompoundV3LeverageManagement,
|
|
283
|
+
[Strategies.Identifiers.EoaRepay]: parseCompoundV3LeverageManagement,
|
|
284
|
+
[Strategies.Identifiers.EoaBoost]: parseCompoundV3LeverageManagement,
|
|
285
|
+
},
|
|
286
|
+
[ProtocolIdentifiers.StrategiesAutomation.ChickenBonds]: {
|
|
287
|
+
[Strategies.Identifiers.Rebond]: parseChickenBondsRebond,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
function getParsingMethod(id: ProtocolIdentifiers.StrategiesAutomation, strategy: BundleOrStrategy) {
|
|
292
|
+
return parsingMethodsMapping[id][strategy.strategyId];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export function parseStrategiesAutomatedPosition(parseData: ParseData): Position.Automated | null {
|
|
296
|
+
const { chainId, subscriptionEventData, strategiesSubsData } = parseData;
|
|
297
|
+
const { subStruct, proxy, subId } = subscriptionEventData;
|
|
298
|
+
const { isEnabled } = strategiesSubsData;
|
|
299
|
+
|
|
300
|
+
const id = subStruct.strategyOrBundleId as StrategyOrBundleIds;
|
|
301
|
+
|
|
302
|
+
const strategyOrBundleInfo = (
|
|
303
|
+
subStruct.isBundle
|
|
304
|
+
? BUNDLES_INFO[chainId][id]
|
|
305
|
+
: STRATEGIES_INFO[chainId][id]
|
|
306
|
+
) as BundleOrStrategy;
|
|
307
|
+
|
|
308
|
+
if (!strategyOrBundleInfo) return null;
|
|
309
|
+
|
|
310
|
+
const position: Position.Automated = {
|
|
311
|
+
isEnabled,
|
|
312
|
+
chainId,
|
|
313
|
+
subId: Number(subId),
|
|
314
|
+
owner: proxy,
|
|
315
|
+
protocol: {
|
|
316
|
+
...strategyOrBundleInfo.protocol,
|
|
317
|
+
},
|
|
318
|
+
strategy: {
|
|
319
|
+
isBundle: subStruct.isBundle,
|
|
320
|
+
...strategyOrBundleInfo,
|
|
321
|
+
},
|
|
322
|
+
strategyData: {
|
|
323
|
+
encoded: {
|
|
324
|
+
triggerData: subStruct.triggerData,
|
|
325
|
+
subData: subStruct.subData,
|
|
326
|
+
},
|
|
327
|
+
decoded: {
|
|
328
|
+
triggerData: null,
|
|
329
|
+
subData: null,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
specific: {},
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
return getParsingMethod(position.protocol.id, position.strategy)(position, parseData);
|
|
336
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import Dec from 'decimal.js';
|
|
2
|
+
import { getAssetInfo } from '@defisaver/tokens';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Bundles, ChainId, RatioState, Strategies,
|
|
6
|
+
} from '../types/enums';
|
|
7
|
+
import type { EthereumAddress, StrategyOrBundleIds } from '../types';
|
|
8
|
+
|
|
9
|
+
import * as subDataService from './subDataService';
|
|
10
|
+
import * as triggerService from './triggerService';
|
|
11
|
+
import { compareAddresses, requireAddress, requireAddresses } from './utils';
|
|
12
|
+
|
|
13
|
+
export const makerEncode = {
|
|
14
|
+
repayFromSavings(
|
|
15
|
+
bundleId: StrategyOrBundleIds,
|
|
16
|
+
vaultId: number,
|
|
17
|
+
priceOverOrUnder: RatioState,
|
|
18
|
+
targetRatio: number,
|
|
19
|
+
chainId: ChainId = ChainId.Ethereum,
|
|
20
|
+
isBundle: boolean = true,
|
|
21
|
+
daiAddr?: EthereumAddress,
|
|
22
|
+
mcdCdpManagerAddr?: EthereumAddress,
|
|
23
|
+
) {
|
|
24
|
+
const subData = subDataService.makerRepayFromSavingsSubData.encode(vaultId, targetRatio, chainId, daiAddr, mcdCdpManagerAddr);
|
|
25
|
+
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, priceOverOrUnder, RatioState.UNDER);
|
|
26
|
+
|
|
27
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
28
|
+
},
|
|
29
|
+
closeOnPrice(
|
|
30
|
+
vaultId: number,
|
|
31
|
+
ratioState: RatioState,
|
|
32
|
+
price: string,
|
|
33
|
+
closeToAssetAddr: EthereumAddress,
|
|
34
|
+
chainlinkCollAddress: EthereumAddress,
|
|
35
|
+
chainId: ChainId = ChainId.Ethereum,
|
|
36
|
+
daiAddr?: EthereumAddress,
|
|
37
|
+
mcdCdpManagerAddr?: EthereumAddress,
|
|
38
|
+
) {
|
|
39
|
+
requireAddresses([closeToAssetAddr, chainlinkCollAddress]);
|
|
40
|
+
|
|
41
|
+
const subData = subDataService.makerCloseSubData.encode(vaultId, closeToAssetAddr, chainId, daiAddr, mcdCdpManagerAddr);
|
|
42
|
+
const triggerData = triggerService.chainlinkPriceTrigger.encode(chainlinkCollAddress, price, ratioState);
|
|
43
|
+
|
|
44
|
+
const strategyOrBundleId = compareAddresses(closeToAssetAddr, getAssetInfo('DAI', chainId).address)
|
|
45
|
+
? Strategies.MainnetIds.MAKER_CLOSE_ON_PRICE_TO_DAI
|
|
46
|
+
: Strategies.MainnetIds.MAKER_CLOSE_ON_PRICE_TO_COLL;
|
|
47
|
+
|
|
48
|
+
const isBundle = false;
|
|
49
|
+
|
|
50
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
51
|
+
},
|
|
52
|
+
trailingStop(
|
|
53
|
+
vaultId: number,
|
|
54
|
+
triggerPercentage: number,
|
|
55
|
+
closeToAssetAddr: EthereumAddress,
|
|
56
|
+
chainlinkCollAddress: EthereumAddress,
|
|
57
|
+
roundId: number,
|
|
58
|
+
chainId: ChainId = ChainId.Ethereum,
|
|
59
|
+
daiAddr?: EthereumAddress,
|
|
60
|
+
mcdCdpManagerAddr?: EthereumAddress,
|
|
61
|
+
) {
|
|
62
|
+
requireAddresses([closeToAssetAddr, chainlinkCollAddress]);
|
|
63
|
+
|
|
64
|
+
const subData = subDataService.makerCloseSubData.encode(vaultId, closeToAssetAddr, chainId, daiAddr, mcdCdpManagerAddr);
|
|
65
|
+
const triggerData = triggerService.trailingStopTrigger.encode(chainlinkCollAddress, triggerPercentage, roundId);
|
|
66
|
+
|
|
67
|
+
const strategyOrBundleId = compareAddresses(closeToAssetAddr, getAssetInfo('DAI').address)
|
|
68
|
+
? Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_DAI
|
|
69
|
+
: Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_COLL;
|
|
70
|
+
|
|
71
|
+
const isBundle = false;
|
|
72
|
+
|
|
73
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const liquityEncode = {
|
|
78
|
+
closeOnPrice(
|
|
79
|
+
priceOverOrUnder: RatioState,
|
|
80
|
+
price: string,
|
|
81
|
+
closeToAssetAddr: EthereumAddress,
|
|
82
|
+
chainlinkCollAddress: EthereumAddress,
|
|
83
|
+
chainId: ChainId = ChainId.Ethereum,
|
|
84
|
+
collAddr?: EthereumAddress,
|
|
85
|
+
debtAddr?: EthereumAddress,
|
|
86
|
+
) {
|
|
87
|
+
requireAddresses([closeToAssetAddr, chainlinkCollAddress]);
|
|
88
|
+
|
|
89
|
+
const subData = subDataService.liquityCloseSubData.encode(closeToAssetAddr, chainId, collAddr, debtAddr);
|
|
90
|
+
const triggerData = triggerService.chainlinkPriceTrigger.encode(chainlinkCollAddress, price, priceOverOrUnder);
|
|
91
|
+
|
|
92
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_CLOSE_ON_PRICE_TO_COLL;
|
|
93
|
+
|
|
94
|
+
const isBundle = false;
|
|
95
|
+
|
|
96
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
97
|
+
},
|
|
98
|
+
trailingStop(
|
|
99
|
+
triggerPercentage: number,
|
|
100
|
+
closeToAssetAddr: EthereumAddress,
|
|
101
|
+
chainlinkCollAddress: EthereumAddress,
|
|
102
|
+
roundId: number,
|
|
103
|
+
chainId: ChainId = ChainId.Ethereum,
|
|
104
|
+
collAddr?: EthereumAddress,
|
|
105
|
+
debtAddr?: EthereumAddress,
|
|
106
|
+
) {
|
|
107
|
+
requireAddresses([closeToAssetAddr, chainlinkCollAddress]);
|
|
108
|
+
|
|
109
|
+
const subData = subDataService.liquityCloseSubData.encode(closeToAssetAddr, chainId, collAddr, debtAddr);
|
|
110
|
+
const triggerData = triggerService.trailingStopTrigger.encode(chainlinkCollAddress, triggerPercentage, roundId);
|
|
111
|
+
|
|
112
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_TRAILING_STOP_LOSS_TO_COLL;
|
|
113
|
+
|
|
114
|
+
const isBundle = false;
|
|
115
|
+
|
|
116
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
117
|
+
},
|
|
118
|
+
paybackFromChickenBondStrategySub(
|
|
119
|
+
proxyAddress: EthereumAddress,
|
|
120
|
+
ratio: number,
|
|
121
|
+
sourceId: string,
|
|
122
|
+
sourceType: number,
|
|
123
|
+
ratioState: RatioState = RatioState.UNDER,
|
|
124
|
+
) {
|
|
125
|
+
requireAddress(proxyAddress);
|
|
126
|
+
const subData = subDataService.liquityPaybackUsingChickenBondSubData.encode(sourceId, sourceType);
|
|
127
|
+
const triggerData = triggerService.liquityRatioTrigger.encode(proxyAddress, ratio, ratioState);
|
|
128
|
+
|
|
129
|
+
const strategyId = Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND;
|
|
130
|
+
|
|
131
|
+
const isBundle = true;
|
|
132
|
+
|
|
133
|
+
return [strategyId, isBundle, triggerData, subData];
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const chickenBondsEncode = {
|
|
138
|
+
rebond(bondId: number) {
|
|
139
|
+
return subDataService.cBondsRebondSubData.encode(bondId);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const aaveV3Encode = {
|
|
144
|
+
leverageManagement(
|
|
145
|
+
minRatio: number,
|
|
146
|
+
maxRatio: number,
|
|
147
|
+
maxOptimalRatio: number,
|
|
148
|
+
minOptimalRatio: number,
|
|
149
|
+
boostEnabled: boolean,
|
|
150
|
+
) {
|
|
151
|
+
let subInput = '0x';
|
|
152
|
+
|
|
153
|
+
subInput = subInput.concat(new Dec(minRatio).mul(1e16).toHex().slice(2)
|
|
154
|
+
.padStart(32, '0'));
|
|
155
|
+
subInput = subInput.concat(new Dec(maxRatio).mul(1e16).toHex().slice(2)
|
|
156
|
+
.padStart(32, '0'));
|
|
157
|
+
subInput = subInput.concat(new Dec(maxOptimalRatio).mul(1e16).toHex().slice(2)
|
|
158
|
+
.padStart(32, '0'));
|
|
159
|
+
subInput = subInput.concat(new Dec(minOptimalRatio).mul(1e16).toHex().slice(2)
|
|
160
|
+
.padStart(32, '0'));
|
|
161
|
+
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
162
|
+
|
|
163
|
+
return subInput;
|
|
164
|
+
},
|
|
165
|
+
closeToAsset(
|
|
166
|
+
strategyOrBundleId: number,
|
|
167
|
+
isBundle: boolean = true,
|
|
168
|
+
triggerData: {
|
|
169
|
+
baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, ratioState: RatioState
|
|
170
|
+
},
|
|
171
|
+
subData: {
|
|
172
|
+
collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number,
|
|
173
|
+
},
|
|
174
|
+
) {
|
|
175
|
+
const {
|
|
176
|
+
collAsset, collAssetId, debtAsset, debtAssetId,
|
|
177
|
+
} = subData;
|
|
178
|
+
const subDataEncoded = subDataService.aaveV3QuotePriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId);
|
|
179
|
+
|
|
180
|
+
const {
|
|
181
|
+
baseTokenAddress, quoteTokenAddress, price, ratioState,
|
|
182
|
+
} = triggerData;
|
|
183
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, ratioState);
|
|
184
|
+
|
|
185
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const compoundV3Encode = {
|
|
190
|
+
leverageManagement(
|
|
191
|
+
market: EthereumAddress,
|
|
192
|
+
baseToken: EthereumAddress,
|
|
193
|
+
repayFrom: number,
|
|
194
|
+
boostFrom: number,
|
|
195
|
+
boostTo: number,
|
|
196
|
+
repayTo: number,
|
|
197
|
+
boostEnabled: boolean,
|
|
198
|
+
isEOA: boolean,
|
|
199
|
+
) {
|
|
200
|
+
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA);
|
|
201
|
+
},
|
|
202
|
+
};
|