@defisaver/automation-sdk 3.3.21-debt-switch-dev-dev → 3.3.21-npm-token-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 +0 -40
- package/cjs/services/strategiesService.js +0 -13
- package/cjs/services/strategySubService.d.ts +0 -1
- package/cjs/services/strategySubService.js +0 -6
- package/cjs/services/strategySubService.test.js +0 -71
- package/cjs/services/subDataService.d.ts +0 -12
- package/cjs/services/subDataService.js +2 -34
- package/cjs/services/subDataService.test.js +0 -104
- package/cjs/types/enums.d.ts +4 -14
- package/cjs/types/enums.js +0 -10
- package/esm/constants/index.js +0 -40
- package/esm/services/strategiesService.js +0 -13
- package/esm/services/strategySubService.d.ts +0 -1
- package/esm/services/strategySubService.js +0 -6
- package/esm/services/strategySubService.test.js +0 -71
- package/esm/services/subDataService.d.ts +0 -12
- package/esm/services/subDataService.js +0 -32
- package/esm/services/subDataService.test.js +0 -104
- package/esm/types/enums.d.ts +4 -14
- package/esm/types/enums.js +0 -10
- package/package.json +1 -1
- package/src/constants/index.ts +0 -40
- package/src/services/strategiesService.ts +0 -15
- package/src/services/strategySubService.test.ts +0 -89
- package/src/services/strategySubService.ts +0 -22
- package/src/services/subDataService.test.ts +0 -108
- package/src/services/subDataService.ts +0 -50
- package/src/types/enums.ts +0 -10
package/cjs/constants/index.js
CHANGED
|
@@ -127,16 +127,6 @@ exports.MAINNET_STRATEGIES_INFO = {
|
|
|
127
127
|
strategyId: enums_1.Strategies.Identifiers.EoaCollateralSwitch,
|
|
128
128
|
protocol: exports.PROTOCOLS.Spark,
|
|
129
129
|
},
|
|
130
|
-
[enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH]: {
|
|
131
|
-
strategyOrBundleId: enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
132
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
133
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
134
|
-
},
|
|
135
|
-
[enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
136
|
-
strategyOrBundleId: enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
137
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
138
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
139
|
-
},
|
|
140
130
|
};
|
|
141
131
|
exports.OPTIMISM_STRATEGIES_INFO = {
|
|
142
132
|
[enums_1.Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -154,16 +144,6 @@ exports.OPTIMISM_STRATEGIES_INFO = {
|
|
|
154
144
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
155
145
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
156
146
|
},
|
|
157
|
-
[enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH]: {
|
|
158
|
-
strategyOrBundleId: enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH,
|
|
159
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
160
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
161
|
-
},
|
|
162
|
-
[enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
163
|
-
strategyOrBundleId: enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
164
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
165
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
166
|
-
},
|
|
167
147
|
};
|
|
168
148
|
exports.BASE_STRATEGIES_INFO = {
|
|
169
149
|
[enums_1.Strategies.BaseIds.EXCHANGE_DCA]: {
|
|
@@ -181,16 +161,6 @@ exports.BASE_STRATEGIES_INFO = {
|
|
|
181
161
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
182
162
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
183
163
|
},
|
|
184
|
-
[enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH]: {
|
|
185
|
-
strategyOrBundleId: enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH,
|
|
186
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
187
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
188
|
-
},
|
|
189
|
-
[enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
190
|
-
strategyOrBundleId: enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
191
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
192
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
193
|
-
},
|
|
194
164
|
};
|
|
195
165
|
exports.ARBITRUM_STRATEGIES_INFO = {
|
|
196
166
|
[enums_1.Strategies.ArbitrumIds.EXCHANGE_DCA]: {
|
|
@@ -208,16 +178,6 @@ exports.ARBITRUM_STRATEGIES_INFO = {
|
|
|
208
178
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
209
179
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
210
180
|
},
|
|
211
|
-
[enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH]: {
|
|
212
|
-
strategyOrBundleId: enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH,
|
|
213
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
214
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
215
|
-
},
|
|
216
|
-
[enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
217
|
-
strategyOrBundleId: enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
218
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
219
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
220
|
-
},
|
|
221
181
|
};
|
|
222
182
|
exports.STRATEGIES_INFO = {
|
|
223
183
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_STRATEGIES_INFO,
|
|
@@ -356,17 +356,6 @@ function parseAaveV3CollateralSwitch(position, parseData) {
|
|
|
356
356
|
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
357
357
|
return _position;
|
|
358
358
|
}
|
|
359
|
-
function parseAaveV3DebtSwitch(position, parseData) {
|
|
360
|
-
const _position = (0, lodash_1.cloneDeep)(position);
|
|
361
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
362
|
-
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
363
|
-
const subData = subDataService.aaveV3DebtSwitchSubData.decode(subStruct.subData);
|
|
364
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
365
|
-
_position.strategyData.decoded.subData = subData;
|
|
366
|
-
// TODO -> This isn't enough for ID
|
|
367
|
-
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
368
|
-
return _position;
|
|
369
|
-
}
|
|
370
359
|
function parseSparkCollateralSwitch(position, parseData) {
|
|
371
360
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
372
361
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1257,8 +1246,6 @@ const parsingMethodsMapping = {
|
|
|
1257
1246
|
[enums_1.Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1258
1247
|
[enums_1.Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1259
1248
|
[enums_1.Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1260
|
-
[enums_1.Strategies.Identifiers.DebtSwitch]: parseAaveV3DebtSwitch,
|
|
1261
|
-
[enums_1.Strategies.Identifiers.EoaDebtSwitch]: parseAaveV3DebtSwitch,
|
|
1262
1249
|
[enums_1.Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1263
1250
|
[enums_1.Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1264
1251
|
},
|
|
@@ -62,7 +62,6 @@ export declare const aaveV3Encode: {
|
|
|
62
62
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
63
63
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
64
64
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
65
|
-
debtSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
66
65
|
};
|
|
67
66
|
export declare const compoundV2Encode: {
|
|
68
67
|
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
@@ -196,12 +196,6 @@ exports.aaveV3Encode = {
|
|
|
196
196
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
197
197
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
198
198
|
},
|
|
199
|
-
debtSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
200
|
-
const isBundle = false;
|
|
201
|
-
const subDataEncoded = subDataService.aaveV3DebtSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
202
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
203
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
204
|
-
},
|
|
205
199
|
};
|
|
206
200
|
exports.compoundV2Encode = {
|
|
207
201
|
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
@@ -856,77 +856,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
856
856
|
});
|
|
857
857
|
});
|
|
858
858
|
});
|
|
859
|
-
describe('debtSwitch()', () => {
|
|
860
|
-
const examples = [
|
|
861
|
-
// USDC -> DAI, price 100000, state UNDER
|
|
862
|
-
[
|
|
863
|
-
[
|
|
864
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
865
|
-
false,
|
|
866
|
-
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
867
|
-
[
|
|
868
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
869
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
870
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
871
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
872
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
873
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
874
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
875
|
-
],
|
|
876
|
-
],
|
|
877
|
-
[
|
|
878
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
879
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
880
|
-
1,
|
|
881
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
882
|
-
3,
|
|
883
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
884
|
-
'10000000000000000000',
|
|
885
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
886
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
887
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
888
|
-
100000,
|
|
889
|
-
enums_1.RatioState.UNDER,
|
|
890
|
-
]
|
|
891
|
-
],
|
|
892
|
-
// DAI -> USDC (MaxUint256), price 1, state OVER
|
|
893
|
-
[
|
|
894
|
-
[
|
|
895
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
896
|
-
false,
|
|
897
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000'],
|
|
898
|
-
[
|
|
899
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
900
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
901
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
902
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
903
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
904
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
905
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
906
|
-
],
|
|
907
|
-
],
|
|
908
|
-
[
|
|
909
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
910
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
911
|
-
3,
|
|
912
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
913
|
-
1,
|
|
914
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
915
|
-
tokens_1.MAXUINT,
|
|
916
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
917
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
918
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
919
|
-
1,
|
|
920
|
-
enums_1.RatioState.OVER,
|
|
921
|
-
]
|
|
922
|
-
],
|
|
923
|
-
];
|
|
924
|
-
examples.forEach(([expected, actual]) => {
|
|
925
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
926
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.debtSwitch(...actual)).to.eql(expected);
|
|
927
|
-
});
|
|
928
|
-
});
|
|
929
|
-
});
|
|
930
859
|
});
|
|
931
860
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
932
861
|
describe('leverageManagementOnPrice()', () => {
|
|
@@ -259,18 +259,6 @@ export declare const aaveV3CollateralSwitchSubData: {
|
|
|
259
259
|
amountToSwitch: string;
|
|
260
260
|
};
|
|
261
261
|
};
|
|
262
|
-
export declare const aaveV3DebtSwitchSubData: {
|
|
263
|
-
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress): string[];
|
|
264
|
-
decode(subData: string[]): {
|
|
265
|
-
fromAsset: EthereumAddress;
|
|
266
|
-
fromAssetId: number;
|
|
267
|
-
toAsset: EthereumAddress;
|
|
268
|
-
toAssetId: number;
|
|
269
|
-
marketAddr: EthereumAddress;
|
|
270
|
-
amountToSwitch: string;
|
|
271
|
-
user: EthereumAddress;
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
262
|
export declare const aaveV3QuotePriceSubData: {
|
|
275
263
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
276
264
|
decode(subData: string[]): {
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sparkCloseGenericSubData = exports.sparkGenericLiquidationProtectionSubData = exports.sparkGenericLeverageManagementSubData = exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubData = exports.legacySparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.legacyExchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.legacyCompoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.
|
|
7
|
-
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkGenericFLCollateralSwitchSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceGenericSubData =
|
|
6
|
+
exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkGenericLiquidationProtectionSubData = exports.sparkGenericLeverageManagementSubData = exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubData = exports.legacySparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.legacyExchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.legacyCompoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LiquidationProtectionSubData = exports.aaveV3LeverageManagementSubData = exports.legacyAaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.legacyAaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.legacyLiquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLiquidationProtectionSubData = exports.makerLeverageManagementSubData = exports.legacyMakerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
|
+
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkGenericFLCollateralSwitchSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceGenericSubData = void 0;
|
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
9
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
10
10
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -549,38 +549,6 @@ exports.aaveV3CollateralSwitchSubData = {
|
|
|
549
549
|
};
|
|
550
550
|
},
|
|
551
551
|
};
|
|
552
|
-
exports.aaveV3DebtSwitchSubData = {
|
|
553
|
-
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user) {
|
|
554
|
-
const encodedFromAsset = web3_eth_abi_1.default.encodeParameter('address', fromAsset);
|
|
555
|
-
const encodedFromAssetId = web3_eth_abi_1.default.encodeParameter('uint8', fromAssetId);
|
|
556
|
-
const encodedToAsset = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
557
|
-
const encodedToAssetId = web3_eth_abi_1.default.encodeParameter('uint8', toAssetId);
|
|
558
|
-
const encodedMarketAddr = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
559
|
-
const encodedAmountToSwitch = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
560
|
-
const encodedUser = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
561
|
-
return [
|
|
562
|
-
encodedFromAsset,
|
|
563
|
-
encodedFromAssetId,
|
|
564
|
-
encodedToAsset,
|
|
565
|
-
encodedToAssetId,
|
|
566
|
-
encodedMarketAddr,
|
|
567
|
-
encodedAmountToSwitch,
|
|
568
|
-
encodedUser,
|
|
569
|
-
];
|
|
570
|
-
},
|
|
571
|
-
decode(subData) {
|
|
572
|
-
const fromAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
573
|
-
const fromAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
574
|
-
const toAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
575
|
-
const toAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
576
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
577
|
-
const amountToSwitch = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
578
|
-
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
579
|
-
return {
|
|
580
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user,
|
|
581
|
-
};
|
|
582
|
-
},
|
|
583
|
-
};
|
|
584
552
|
exports.aaveV3QuotePriceSubData = {
|
|
585
553
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, nullAddress = constants_1.ZERO_ADDRESS) {
|
|
586
554
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -535,110 +535,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
535
535
|
});
|
|
536
536
|
});
|
|
537
537
|
});
|
|
538
|
-
describe('When testing subDataService.aaveV3DebtSwitchSubData', () => {
|
|
539
|
-
describe('encode()', () => {
|
|
540
|
-
const examples = [
|
|
541
|
-
// USDC -> DAI
|
|
542
|
-
[
|
|
543
|
-
[
|
|
544
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
545
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
546
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
547
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
548
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
549
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
550
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
551
|
-
],
|
|
552
|
-
[
|
|
553
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
554
|
-
1,
|
|
555
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
556
|
-
3,
|
|
557
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
558
|
-
'10000000000000000000',
|
|
559
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
560
|
-
]
|
|
561
|
-
],
|
|
562
|
-
// DAI -> USDC (MaxUint256)
|
|
563
|
-
[
|
|
564
|
-
[
|
|
565
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
566
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
567
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
568
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
569
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
570
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
571
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
572
|
-
],
|
|
573
|
-
[
|
|
574
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
575
|
-
3,
|
|
576
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
577
|
-
1,
|
|
578
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
579
|
-
tokens_2.MAXUINT,
|
|
580
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
581
|
-
]
|
|
582
|
-
],
|
|
583
|
-
];
|
|
584
|
-
examples.forEach(([expected, actual]) => {
|
|
585
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
586
|
-
(0, chai_1.expect)(subDataService.aaveV3DebtSwitchSubData.encode(...actual)).to.eql(expected);
|
|
587
|
-
});
|
|
588
|
-
});
|
|
589
|
-
});
|
|
590
|
-
describe('decode()', () => {
|
|
591
|
-
const examples = [
|
|
592
|
-
// USDC -> DAI
|
|
593
|
-
[
|
|
594
|
-
{
|
|
595
|
-
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
596
|
-
fromAssetId: 1,
|
|
597
|
-
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
598
|
-
toAssetId: 3,
|
|
599
|
-
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
600
|
-
amountToSwitch: '10000000000000000000',
|
|
601
|
-
user: web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
602
|
-
},
|
|
603
|
-
[
|
|
604
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
605
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
606
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
607
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
608
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
609
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
610
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
611
|
-
],
|
|
612
|
-
],
|
|
613
|
-
// DAI -> USDC (MaxUint256)
|
|
614
|
-
[
|
|
615
|
-
{
|
|
616
|
-
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
617
|
-
fromAssetId: 3,
|
|
618
|
-
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
619
|
-
toAssetId: 1,
|
|
620
|
-
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
621
|
-
amountToSwitch: tokens_2.MAXUINT,
|
|
622
|
-
user: web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
623
|
-
},
|
|
624
|
-
[
|
|
625
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
626
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
627
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
628
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
629
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
630
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
631
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
632
|
-
],
|
|
633
|
-
],
|
|
634
|
-
];
|
|
635
|
-
examples.forEach(([expected, actual]) => {
|
|
636
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
637
|
-
(0, chai_1.expect)(subDataService.aaveV3DebtSwitchSubData.decode(actual)).to.eql(expected);
|
|
638
|
-
});
|
|
639
|
-
});
|
|
640
|
-
});
|
|
641
|
-
});
|
|
642
538
|
describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
|
|
643
539
|
describe('encode()', () => {
|
|
644
540
|
const examples = [
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -91,30 +91,22 @@ export declare namespace Strategies {
|
|
|
91
91
|
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
92
|
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
93
93
|
SPARK_COLLATERAL_SWITCH = 156,
|
|
94
|
-
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167
|
|
95
|
-
AAVE_V3_DEBT_SWITCH = 168,
|
|
96
|
-
AAVE_V3_DEBT_SWITCH_EOA = 169
|
|
94
|
+
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167
|
|
97
95
|
}
|
|
98
96
|
enum OptimismIds {
|
|
99
97
|
EXCHANGE_DCA = 8,
|
|
100
98
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
101
|
-
AAVE_V3_COLLATERAL_SWITCH = 24
|
|
102
|
-
AAVE_V3_DEBT_SWITCH = 25,
|
|
103
|
-
AAVE_V3_DEBT_SWITCH_EOA = 26
|
|
99
|
+
AAVE_V3_COLLATERAL_SWITCH = 24
|
|
104
100
|
}
|
|
105
101
|
enum BaseIds {
|
|
106
102
|
EXCHANGE_DCA = 8,
|
|
107
103
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
108
|
-
AAVE_V3_COLLATERAL_SWITCH = 56
|
|
109
|
-
AAVE_V3_DEBT_SWITCH = 61,
|
|
110
|
-
AAVE_V3_DEBT_SWITCH_EOA = 62
|
|
104
|
+
AAVE_V3_COLLATERAL_SWITCH = 56
|
|
111
105
|
}
|
|
112
106
|
enum ArbitrumIds {
|
|
113
107
|
EXCHANGE_DCA = 8,
|
|
114
108
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
115
|
-
AAVE_V3_COLLATERAL_SWITCH = 50
|
|
116
|
-
AAVE_V3_DEBT_SWITCH = 55,
|
|
117
|
-
AAVE_V3_DEBT_SWITCH_EOA = 56
|
|
109
|
+
AAVE_V3_COLLATERAL_SWITCH = 50
|
|
118
110
|
}
|
|
119
111
|
enum Identifiers {
|
|
120
112
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
@@ -148,8 +140,6 @@ export declare namespace Strategies {
|
|
|
148
140
|
EoaRepayOnPrice = "eoa-repay-on-price",
|
|
149
141
|
CollateralSwitch = "collateral-switch",
|
|
150
142
|
EoaCollateralSwitch = "eoa-collateral-switch",
|
|
151
|
-
DebtSwitch = "debt-switch",
|
|
152
|
-
EoaDebtSwitch = "eoa-debt-switch",
|
|
153
143
|
LiquidationProtection = "liquidation-protection",
|
|
154
144
|
EoaLiquidationProtection = "liquidation-protection-eoa"
|
|
155
145
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -108,32 +108,24 @@ var Strategies;
|
|
|
108
108
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
109
109
|
MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
|
|
110
110
|
MainnetIds[MainnetIds["SPARK_GENERIC_FL_COLLATERAL_SWITCH"] = 167] = "SPARK_GENERIC_FL_COLLATERAL_SWITCH";
|
|
111
|
-
MainnetIds[MainnetIds["AAVE_V3_DEBT_SWITCH"] = 168] = "AAVE_V3_DEBT_SWITCH";
|
|
112
|
-
MainnetIds[MainnetIds["AAVE_V3_DEBT_SWITCH_EOA"] = 169] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
113
111
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
114
112
|
let OptimismIds;
|
|
115
113
|
(function (OptimismIds) {
|
|
116
114
|
OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
117
115
|
OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
118
116
|
OptimismIds[OptimismIds["AAVE_V3_COLLATERAL_SWITCH"] = 24] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
119
|
-
OptimismIds[OptimismIds["AAVE_V3_DEBT_SWITCH"] = 25] = "AAVE_V3_DEBT_SWITCH";
|
|
120
|
-
OptimismIds[OptimismIds["AAVE_V3_DEBT_SWITCH_EOA"] = 26] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
121
117
|
})(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
|
|
122
118
|
let BaseIds;
|
|
123
119
|
(function (BaseIds) {
|
|
124
120
|
BaseIds[BaseIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
125
121
|
BaseIds[BaseIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
126
122
|
BaseIds[BaseIds["AAVE_V3_COLLATERAL_SWITCH"] = 56] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
127
|
-
BaseIds[BaseIds["AAVE_V3_DEBT_SWITCH"] = 61] = "AAVE_V3_DEBT_SWITCH";
|
|
128
|
-
BaseIds[BaseIds["AAVE_V3_DEBT_SWITCH_EOA"] = 62] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
129
123
|
})(BaseIds = Strategies.BaseIds || (Strategies.BaseIds = {}));
|
|
130
124
|
let ArbitrumIds;
|
|
131
125
|
(function (ArbitrumIds) {
|
|
132
126
|
ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
133
127
|
ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
134
128
|
ArbitrumIds[ArbitrumIds["AAVE_V3_COLLATERAL_SWITCH"] = 50] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
135
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_DEBT_SWITCH"] = 55] = "AAVE_V3_DEBT_SWITCH";
|
|
136
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_DEBT_SWITCH_EOA"] = 56] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
137
129
|
})(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
|
|
138
130
|
let Identifiers;
|
|
139
131
|
(function (Identifiers) {
|
|
@@ -168,8 +160,6 @@ var Strategies;
|
|
|
168
160
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
169
161
|
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
170
162
|
Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
|
|
171
|
-
Identifiers["DebtSwitch"] = "debt-switch";
|
|
172
|
-
Identifiers["EoaDebtSwitch"] = "eoa-debt-switch";
|
|
173
163
|
Identifiers["LiquidationProtection"] = "liquidation-protection";
|
|
174
164
|
Identifiers["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
175
165
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
package/esm/constants/index.js
CHANGED
|
@@ -121,16 +121,6 @@ export const MAINNET_STRATEGIES_INFO = {
|
|
|
121
121
|
strategyId: Strategies.Identifiers.EoaCollateralSwitch,
|
|
122
122
|
protocol: PROTOCOLS.Spark,
|
|
123
123
|
},
|
|
124
|
-
[Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH]: {
|
|
125
|
-
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
126
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
127
|
-
protocol: PROTOCOLS.AaveV3,
|
|
128
|
-
},
|
|
129
|
-
[Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
130
|
-
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
131
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
132
|
-
protocol: PROTOCOLS.AaveV3,
|
|
133
|
-
},
|
|
134
124
|
};
|
|
135
125
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
136
126
|
[Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -148,16 +138,6 @@ export const OPTIMISM_STRATEGIES_INFO = {
|
|
|
148
138
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
149
139
|
protocol: PROTOCOLS.AaveV3,
|
|
150
140
|
},
|
|
151
|
-
[Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH]: {
|
|
152
|
-
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH,
|
|
153
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
154
|
-
protocol: PROTOCOLS.AaveV3,
|
|
155
|
-
},
|
|
156
|
-
[Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
157
|
-
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
158
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
159
|
-
protocol: PROTOCOLS.AaveV3,
|
|
160
|
-
},
|
|
161
141
|
};
|
|
162
142
|
export const BASE_STRATEGIES_INFO = {
|
|
163
143
|
[Strategies.BaseIds.EXCHANGE_DCA]: {
|
|
@@ -175,16 +155,6 @@ export const BASE_STRATEGIES_INFO = {
|
|
|
175
155
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
176
156
|
protocol: PROTOCOLS.AaveV3,
|
|
177
157
|
},
|
|
178
|
-
[Strategies.BaseIds.AAVE_V3_DEBT_SWITCH]: {
|
|
179
|
-
strategyOrBundleId: Strategies.BaseIds.AAVE_V3_DEBT_SWITCH,
|
|
180
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
181
|
-
protocol: PROTOCOLS.AaveV3,
|
|
182
|
-
},
|
|
183
|
-
[Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
184
|
-
strategyOrBundleId: Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
185
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
186
|
-
protocol: PROTOCOLS.AaveV3,
|
|
187
|
-
},
|
|
188
158
|
};
|
|
189
159
|
export const ARBITRUM_STRATEGIES_INFO = {
|
|
190
160
|
[Strategies.ArbitrumIds.EXCHANGE_DCA]: {
|
|
@@ -202,16 +172,6 @@ export const ARBITRUM_STRATEGIES_INFO = {
|
|
|
202
172
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
203
173
|
protocol: PROTOCOLS.AaveV3,
|
|
204
174
|
},
|
|
205
|
-
[Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH]: {
|
|
206
|
-
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH,
|
|
207
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
208
|
-
protocol: PROTOCOLS.AaveV3,
|
|
209
|
-
},
|
|
210
|
-
[Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
211
|
-
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
212
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
213
|
-
protocol: PROTOCOLS.AaveV3,
|
|
214
|
-
},
|
|
215
175
|
};
|
|
216
176
|
export const STRATEGIES_INFO = {
|
|
217
177
|
[ChainId.Ethereum]: MAINNET_STRATEGIES_INFO,
|
|
@@ -327,17 +327,6 @@ function parseAaveV3CollateralSwitch(position, parseData) {
|
|
|
327
327
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
328
328
|
return _position;
|
|
329
329
|
}
|
|
330
|
-
function parseAaveV3DebtSwitch(position, parseData) {
|
|
331
|
-
const _position = cloneDeep(position);
|
|
332
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
333
|
-
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
334
|
-
const subData = subDataService.aaveV3DebtSwitchSubData.decode(subStruct.subData);
|
|
335
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
336
|
-
_position.strategyData.decoded.subData = subData;
|
|
337
|
-
// TODO -> This isn't enough for ID
|
|
338
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
339
|
-
return _position;
|
|
340
|
-
}
|
|
341
330
|
function parseSparkCollateralSwitch(position, parseData) {
|
|
342
331
|
const _position = cloneDeep(position);
|
|
343
332
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1228,8 +1217,6 @@ const parsingMethodsMapping = {
|
|
|
1228
1217
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1229
1218
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1230
1219
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1231
|
-
[Strategies.Identifiers.DebtSwitch]: parseAaveV3DebtSwitch,
|
|
1232
|
-
[Strategies.Identifiers.EoaDebtSwitch]: parseAaveV3DebtSwitch,
|
|
1233
1220
|
[Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1234
1221
|
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1235
1222
|
},
|
|
@@ -62,7 +62,6 @@ export declare const aaveV3Encode: {
|
|
|
62
62
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
63
63
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
64
64
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
65
|
-
debtSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
66
65
|
};
|
|
67
66
|
export declare const compoundV2Encode: {
|
|
68
67
|
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
@@ -170,12 +170,6 @@ export const aaveV3Encode = {
|
|
|
170
170
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
171
171
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
172
172
|
},
|
|
173
|
-
debtSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
174
|
-
const isBundle = false;
|
|
175
|
-
const subDataEncoded = subDataService.aaveV3DebtSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
176
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
177
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
178
|
-
},
|
|
179
173
|
};
|
|
180
174
|
export const compoundV2Encode = {
|
|
181
175
|
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|