@defisaver/automation-sdk 3.3.4 → 3.3.5
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 +20 -0
- package/cjs/services/strategiesService.js +11 -0
- package/cjs/services/strategySubService.d.ts +1 -0
- package/cjs/services/strategySubService.js +6 -0
- package/cjs/services/strategySubService.test.js +99 -0
- package/cjs/services/subDataService.d.ts +11 -0
- package/cjs/services/subDataService.js +32 -1
- package/cjs/services/subDataService.test.js +142 -0
- package/cjs/types/enums.d.ts +10 -5
- package/cjs/types/enums.js +5 -0
- package/esm/constants/index.js +20 -0
- package/esm/services/strategiesService.js +11 -0
- package/esm/services/strategySubService.d.ts +1 -0
- package/esm/services/strategySubService.js +6 -0
- package/esm/services/strategySubService.test.js +100 -1
- package/esm/services/subDataService.d.ts +11 -0
- package/esm/services/subDataService.js +31 -0
- package/esm/services/subDataService.test.js +142 -0
- package/esm/types/enums.d.ts +10 -5
- package/esm/types/enums.js +5 -0
- package/package.json +1 -1
- package/src/constants/index.ts +20 -0
- package/src/services/strategiesService.ts +13 -0
- package/src/services/strategySubService.test.ts +117 -1
- package/src/services/strategySubService.ts +21 -0
- package/src/services/subDataService.test.ts +146 -0
- package/src/services/subDataService.ts +49 -0
- package/src/types/enums.ts +5 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import Dec from 'decimal.js';
|
|
3
3
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
|
-
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
|
+
import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
5
5
|
import * as web3Utils from 'web3-utils';
|
|
6
6
|
import { Bundles, ChainId, CloseToAssetType, OrderType, RatioState, Strategies } from '../types/enums';
|
|
7
7
|
import '../configuration';
|
|
@@ -780,6 +780,105 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
780
780
|
});
|
|
781
781
|
});
|
|
782
782
|
});
|
|
783
|
+
describe('collateralSwitch()', () => {
|
|
784
|
+
const examples = [
|
|
785
|
+
// WETH -> USDC, price 100000, state UNDER
|
|
786
|
+
[
|
|
787
|
+
[
|
|
788
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
789
|
+
false,
|
|
790
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
791
|
+
[
|
|
792
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
793
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
794
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
795
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
796
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
797
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
798
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
799
|
+
],
|
|
800
|
+
],
|
|
801
|
+
[
|
|
802
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
803
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
804
|
+
0,
|
|
805
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
806
|
+
1,
|
|
807
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
808
|
+
'10000000000000000000',
|
|
809
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
810
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
811
|
+
100000,
|
|
812
|
+
RatioState.UNDER,
|
|
813
|
+
]
|
|
814
|
+
],
|
|
815
|
+
// USDC -> WETH, price 0.00001, state OVER
|
|
816
|
+
[
|
|
817
|
+
[
|
|
818
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
819
|
+
false,
|
|
820
|
+
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000000'],
|
|
821
|
+
[
|
|
822
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
823
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
824
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
825
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
826
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
827
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
828
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
829
|
+
],
|
|
830
|
+
],
|
|
831
|
+
[
|
|
832
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
833
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
834
|
+
1,
|
|
835
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
836
|
+
0,
|
|
837
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
838
|
+
MAXUINT,
|
|
839
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
840
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
841
|
+
0.00001,
|
|
842
|
+
RatioState.OVER,
|
|
843
|
+
]
|
|
844
|
+
],
|
|
845
|
+
// WETH -> WBTC, price 1, state UNDER
|
|
846
|
+
[
|
|
847
|
+
[
|
|
848
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
849
|
+
false,
|
|
850
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000001'],
|
|
851
|
+
[
|
|
852
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
853
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
854
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
855
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
856
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
857
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
858
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
859
|
+
],
|
|
860
|
+
],
|
|
861
|
+
[
|
|
862
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
863
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
864
|
+
0,
|
|
865
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
866
|
+
2,
|
|
867
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
868
|
+
'5000000000000000000',
|
|
869
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
870
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
871
|
+
1,
|
|
872
|
+
RatioState.UNDER,
|
|
873
|
+
]
|
|
874
|
+
],
|
|
875
|
+
];
|
|
876
|
+
examples.forEach(([expected, actual]) => {
|
|
877
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
878
|
+
expect(aaveV3Encode.collateralSwitch(...actual)).to.eql(expected);
|
|
879
|
+
});
|
|
880
|
+
});
|
|
881
|
+
});
|
|
783
882
|
});
|
|
784
883
|
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
785
884
|
describe('leverageManagement()', () => {
|
|
@@ -82,6 +82,17 @@ export declare const aaveV3CloseGenericSubData: {
|
|
|
82
82
|
owner: EthereumAddress;
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
+
export declare const aaveV3CollateralSwitchSubData: {
|
|
86
|
+
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean): string[];
|
|
87
|
+
decode(subData: string[]): {
|
|
88
|
+
fromAsset: EthereumAddress;
|
|
89
|
+
fromAssetId: number;
|
|
90
|
+
toAsset: EthereumAddress;
|
|
91
|
+
toAssetId: number;
|
|
92
|
+
marketAddr: EthereumAddress;
|
|
93
|
+
amountToSwitch: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
85
96
|
export declare const aaveV3QuotePriceSubData: {
|
|
86
97
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
87
98
|
decode(subData: string[]): {
|
|
@@ -210,6 +210,37 @@ export const aaveV3CloseGenericSubData = {
|
|
|
210
210
|
};
|
|
211
211
|
},
|
|
212
212
|
};
|
|
213
|
+
export const aaveV3CollateralSwitchSubData = {
|
|
214
|
+
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
215
|
+
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
216
|
+
const encodedFromAssetId = AbiCoder.encodeParameter('uint8', fromAssetId);
|
|
217
|
+
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
218
|
+
const encodedToAssetId = AbiCoder.encodeParameter('uint8', toAssetId);
|
|
219
|
+
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
220
|
+
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
221
|
+
const encodedUseOnBehalf = AbiCoder.encodeParameter('bool', useOnBehalf);
|
|
222
|
+
return [
|
|
223
|
+
encodedFromAsset,
|
|
224
|
+
encodedFromAssetId,
|
|
225
|
+
encodedToAsset,
|
|
226
|
+
encodedToAssetId,
|
|
227
|
+
encodedMarketAddr,
|
|
228
|
+
encodedAmountToSwitch,
|
|
229
|
+
encodedUseOnBehalf,
|
|
230
|
+
];
|
|
231
|
+
},
|
|
232
|
+
decode(subData) {
|
|
233
|
+
const fromAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
234
|
+
const fromAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
235
|
+
const toAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
236
|
+
const toAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
237
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
238
|
+
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
239
|
+
return {
|
|
240
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
241
|
+
};
|
|
242
|
+
},
|
|
243
|
+
};
|
|
213
244
|
export const aaveV3QuotePriceSubData = {
|
|
214
245
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, nullAddress = ZERO_ADDRESS) {
|
|
215
246
|
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
@@ -2,6 +2,7 @@ import Dec from 'decimal.js';
|
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
4
|
import * as web3Utils from 'web3-utils';
|
|
5
|
+
import { MAXUINT } from '@defisaver/tokens';
|
|
5
6
|
import { ChainId, CloseStrategyType, OrderType, RatioState } from '../types/enums';
|
|
6
7
|
import '../configuration';
|
|
7
8
|
import * as subDataService from './subDataService';
|
|
@@ -330,6 +331,147 @@ describe('Feature: subDataService.ts', () => {
|
|
|
330
331
|
});
|
|
331
332
|
});
|
|
332
333
|
});
|
|
334
|
+
describe('When testing subDataService.aaveV3CollateralSwitchSubData', () => {
|
|
335
|
+
describe('encode()', () => {
|
|
336
|
+
const examples = [
|
|
337
|
+
// WETH -> USDC
|
|
338
|
+
[
|
|
339
|
+
[
|
|
340
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
341
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
342
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
343
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
344
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
345
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
346
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
347
|
+
],
|
|
348
|
+
[
|
|
349
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
350
|
+
0,
|
|
351
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
352
|
+
1,
|
|
353
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
354
|
+
'10000000000000000000',
|
|
355
|
+
false,
|
|
356
|
+
]
|
|
357
|
+
],
|
|
358
|
+
// USDC -> WETH (MaxUint256)
|
|
359
|
+
[
|
|
360
|
+
[
|
|
361
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
362
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
363
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
364
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
365
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
366
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
367
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
368
|
+
],
|
|
369
|
+
[
|
|
370
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
371
|
+
1,
|
|
372
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
373
|
+
0,
|
|
374
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
375
|
+
MAXUINT, // MaxUint256
|
|
376
|
+
]
|
|
377
|
+
],
|
|
378
|
+
// WETH -> WBTC
|
|
379
|
+
[
|
|
380
|
+
[
|
|
381
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
382
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
383
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
384
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
385
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
386
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
387
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
388
|
+
],
|
|
389
|
+
[
|
|
390
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
391
|
+
0,
|
|
392
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
393
|
+
2,
|
|
394
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
395
|
+
'5000000000000000000', // 5 WETH
|
|
396
|
+
]
|
|
397
|
+
],
|
|
398
|
+
];
|
|
399
|
+
examples.forEach(([expected, actual]) => {
|
|
400
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
401
|
+
expect(subDataService.aaveV3CollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
describe('decode()', () => {
|
|
406
|
+
const examples = [
|
|
407
|
+
// WETH -> USDC
|
|
408
|
+
[
|
|
409
|
+
{
|
|
410
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
411
|
+
fromAssetId: 0,
|
|
412
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
413
|
+
toAssetId: 1,
|
|
414
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
415
|
+
amountToSwitch: '10000000000000000000',
|
|
416
|
+
},
|
|
417
|
+
[
|
|
418
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
419
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
420
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
421
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
422
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
423
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
424
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
425
|
+
],
|
|
426
|
+
],
|
|
427
|
+
// USDC -> WETH (MaxUint256)
|
|
428
|
+
[
|
|
429
|
+
{
|
|
430
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
431
|
+
fromAssetId: 1,
|
|
432
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
433
|
+
toAssetId: 0,
|
|
434
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
435
|
+
amountToSwitch: MAXUINT,
|
|
436
|
+
},
|
|
437
|
+
[
|
|
438
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
439
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
440
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
441
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
442
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
443
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
444
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
445
|
+
],
|
|
446
|
+
],
|
|
447
|
+
// WETH -> WBTC
|
|
448
|
+
[
|
|
449
|
+
{
|
|
450
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
451
|
+
fromAssetId: 0,
|
|
452
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
453
|
+
toAssetId: 2,
|
|
454
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
455
|
+
amountToSwitch: '5000000000000000000',
|
|
456
|
+
},
|
|
457
|
+
[
|
|
458
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
459
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
460
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
461
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
462
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
463
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
464
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
465
|
+
],
|
|
466
|
+
],
|
|
467
|
+
];
|
|
468
|
+
examples.forEach(([expected, actual]) => {
|
|
469
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
470
|
+
expect(subDataService.aaveV3CollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
});
|
|
333
475
|
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
334
476
|
describe('encode()', () => {
|
|
335
477
|
const examples = [
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -85,19 +85,23 @@ export declare namespace Strategies {
|
|
|
85
85
|
LIQUITY_DSR_SUPPLY = 70,
|
|
86
86
|
LIQUITY_DEBT_IN_FRONT_REPAY = 75,
|
|
87
87
|
CURVEUSD_PAYBACK = 92,
|
|
88
|
-
LIQUITY_V2_PAYBACK = 113
|
|
88
|
+
LIQUITY_V2_PAYBACK = 113,
|
|
89
|
+
AAVE_V3_COLLATERAL_SWITCH = 135
|
|
89
90
|
}
|
|
90
91
|
enum OptimismIds {
|
|
91
92
|
EXCHANGE_DCA = 8,
|
|
92
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
93
|
+
EXCHANGE_LIMIT_ORDER = 9,
|
|
94
|
+
AAVE_V3_COLLATERAL_SWITCH = 24
|
|
93
95
|
}
|
|
94
96
|
enum BaseIds {
|
|
95
97
|
EXCHANGE_DCA = 8,
|
|
96
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
98
|
+
EXCHANGE_LIMIT_ORDER = 9,
|
|
99
|
+
AAVE_V3_COLLATERAL_SWITCH = 56
|
|
97
100
|
}
|
|
98
101
|
enum ArbitrumIds {
|
|
99
102
|
EXCHANGE_DCA = 8,
|
|
100
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
103
|
+
EXCHANGE_LIMIT_ORDER = 9,
|
|
104
|
+
AAVE_V3_COLLATERAL_SWITCH = 50
|
|
101
105
|
}
|
|
102
106
|
enum Identifiers {
|
|
103
107
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
@@ -128,7 +132,8 @@ export declare namespace Strategies {
|
|
|
128
132
|
BoostOnPrice = "boost-on-price",
|
|
129
133
|
RepayOnPrice = "repay-on-price",
|
|
130
134
|
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
131
|
-
EoaRepayOnPrice = "eoa-repay-on-price"
|
|
135
|
+
EoaRepayOnPrice = "eoa-repay-on-price",
|
|
136
|
+
CollateralSwitch = "collateral-switch"
|
|
132
137
|
}
|
|
133
138
|
enum IdOverrides {
|
|
134
139
|
TakeProfit = "take-profit",
|
package/esm/types/enums.js
CHANGED
|
@@ -99,21 +99,25 @@ export var Strategies;
|
|
|
99
99
|
MainnetIds[MainnetIds["LIQUITY_DEBT_IN_FRONT_REPAY"] = 75] = "LIQUITY_DEBT_IN_FRONT_REPAY";
|
|
100
100
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
101
101
|
MainnetIds[MainnetIds["LIQUITY_V2_PAYBACK"] = 113] = "LIQUITY_V2_PAYBACK";
|
|
102
|
+
MainnetIds[MainnetIds["AAVE_V3_COLLATERAL_SWITCH"] = 135] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
102
103
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
103
104
|
let OptimismIds;
|
|
104
105
|
(function (OptimismIds) {
|
|
105
106
|
OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
106
107
|
OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
108
|
+
OptimismIds[OptimismIds["AAVE_V3_COLLATERAL_SWITCH"] = 24] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
107
109
|
})(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
|
|
108
110
|
let BaseIds;
|
|
109
111
|
(function (BaseIds) {
|
|
110
112
|
BaseIds[BaseIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
111
113
|
BaseIds[BaseIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
114
|
+
BaseIds[BaseIds["AAVE_V3_COLLATERAL_SWITCH"] = 56] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
112
115
|
})(BaseIds = Strategies.BaseIds || (Strategies.BaseIds = {}));
|
|
113
116
|
let ArbitrumIds;
|
|
114
117
|
(function (ArbitrumIds) {
|
|
115
118
|
ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
116
119
|
ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
120
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_COLLATERAL_SWITCH"] = 50] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
117
121
|
})(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
|
|
118
122
|
let Identifiers;
|
|
119
123
|
(function (Identifiers) {
|
|
@@ -146,6 +150,7 @@ export var Strategies;
|
|
|
146
150
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
147
151
|
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
148
152
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
153
|
+
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
149
154
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
150
155
|
let IdOverrides;
|
|
151
156
|
(function (IdOverrides) {
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -118,6 +118,11 @@ export const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo = {
|
|
|
118
118
|
strategyId: Strategies.Identifiers.Payback,
|
|
119
119
|
protocol: PROTOCOLS.LiquityV2,
|
|
120
120
|
},
|
|
121
|
+
[Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
122
|
+
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
123
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
124
|
+
protocol: PROTOCOLS.AaveV3,
|
|
125
|
+
},
|
|
121
126
|
};
|
|
122
127
|
|
|
123
128
|
export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
@@ -131,6 +136,11 @@ export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
|
131
136
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
132
137
|
protocol: PROTOCOLS.Exchange,
|
|
133
138
|
},
|
|
139
|
+
[Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
140
|
+
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
141
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
142
|
+
protocol: PROTOCOLS.AaveV3,
|
|
143
|
+
},
|
|
134
144
|
};
|
|
135
145
|
|
|
136
146
|
export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
@@ -144,6 +154,11 @@ export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
|
144
154
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
145
155
|
protocol: PROTOCOLS.Exchange,
|
|
146
156
|
},
|
|
157
|
+
[Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
158
|
+
strategyOrBundleId: Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
159
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
160
|
+
protocol: PROTOCOLS.AaveV3,
|
|
161
|
+
},
|
|
147
162
|
};
|
|
148
163
|
|
|
149
164
|
export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
@@ -157,6 +172,11 @@ export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
|
157
172
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
158
173
|
protocol: PROTOCOLS.Exchange,
|
|
159
174
|
},
|
|
175
|
+
[Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
176
|
+
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
177
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
178
|
+
protocol: PROTOCOLS.AaveV3,
|
|
179
|
+
},
|
|
160
180
|
};
|
|
161
181
|
|
|
162
182
|
export const STRATEGIES_INFO: StrategiesInfo = {
|
|
@@ -375,6 +375,18 @@ function parseAaveV3CloseOnPrice(position: Position.Automated, parseData: ParseD
|
|
|
375
375
|
return _position;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
function parseAaveV3CollateralSwitch(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
379
|
+
const _position = cloneDeep(position);
|
|
380
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
381
|
+
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
382
|
+
const subData = subDataService.aaveV3CollateralSwitchSubData.decode(subStruct.subData);
|
|
383
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
384
|
+
_position.strategyData.decoded.subData = subData;
|
|
385
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
386
|
+
|
|
387
|
+
return _position;
|
|
388
|
+
}
|
|
389
|
+
|
|
378
390
|
function parseMorphoAaveV2LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
379
391
|
const _position = cloneDeep(position);
|
|
380
392
|
|
|
@@ -1160,6 +1172,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1160
1172
|
[Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1161
1173
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1162
1174
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1175
|
+
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1163
1176
|
},
|
|
1164
1177
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
1165
1178
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import Dec from 'decimal.js';
|
|
3
3
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
|
-
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
|
+
import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
5
5
|
import * as web3Utils from 'web3-utils';
|
|
6
6
|
|
|
7
7
|
import { Bundles, ChainId, CloseToAssetType, OrderType, RatioState, Strategies } from '../types/enums';
|
|
@@ -965,6 +965,122 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
965
965
|
});
|
|
966
966
|
});
|
|
967
967
|
});
|
|
968
|
+
|
|
969
|
+
describe('collateralSwitch()', () => {
|
|
970
|
+
const examples: Array<[
|
|
971
|
+
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
972
|
+
[
|
|
973
|
+
strategyOrBundleId: number,
|
|
974
|
+
fromAsset: EthereumAddress,
|
|
975
|
+
fromAssetId: number,
|
|
976
|
+
toAsset: EthereumAddress,
|
|
977
|
+
toAssetId: number,
|
|
978
|
+
marketAddr: EthereumAddress,
|
|
979
|
+
amountToSwitch: string,
|
|
980
|
+
baseTokenAddress: EthereumAddress,
|
|
981
|
+
quoteTokenAddress: EthereumAddress,
|
|
982
|
+
price: number,
|
|
983
|
+
state: RatioState,
|
|
984
|
+
]
|
|
985
|
+
]> = [
|
|
986
|
+
// WETH -> USDC, price 100000, state UNDER
|
|
987
|
+
[
|
|
988
|
+
[
|
|
989
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
990
|
+
false,
|
|
991
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
992
|
+
[
|
|
993
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
994
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
995
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
996
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
997
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
998
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
999
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1000
|
+
],
|
|
1001
|
+
],
|
|
1002
|
+
[
|
|
1003
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
1004
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1005
|
+
0,
|
|
1006
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1007
|
+
1,
|
|
1008
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1009
|
+
'10000000000000000000', // 10 WETH
|
|
1010
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1011
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1012
|
+
100000,
|
|
1013
|
+
RatioState.UNDER,
|
|
1014
|
+
]
|
|
1015
|
+
],
|
|
1016
|
+
// USDC -> WETH, price 0.00001, state OVER
|
|
1017
|
+
[
|
|
1018
|
+
[
|
|
1019
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
1020
|
+
false,
|
|
1021
|
+
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000000'],
|
|
1022
|
+
[
|
|
1023
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1024
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1025
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1026
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1027
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1028
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
1029
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1030
|
+
],
|
|
1031
|
+
],
|
|
1032
|
+
[
|
|
1033
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
1034
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1035
|
+
1,
|
|
1036
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1037
|
+
0,
|
|
1038
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1039
|
+
MAXUINT, // MaxUint256
|
|
1040
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1041
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1042
|
+
0.00001,
|
|
1043
|
+
RatioState.OVER,
|
|
1044
|
+
]
|
|
1045
|
+
],
|
|
1046
|
+
// WETH -> WBTC, price 1, state UNDER
|
|
1047
|
+
[
|
|
1048
|
+
[
|
|
1049
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
1050
|
+
false,
|
|
1051
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1052
|
+
[
|
|
1053
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1054
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1055
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1056
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1057
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1058
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
1059
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1060
|
+
],
|
|
1061
|
+
],
|
|
1062
|
+
[
|
|
1063
|
+
Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
1064
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1065
|
+
0,
|
|
1066
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1067
|
+
2,
|
|
1068
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1069
|
+
'5000000000000000000', // 5 WETH
|
|
1070
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1071
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1072
|
+
1,
|
|
1073
|
+
RatioState.UNDER,
|
|
1074
|
+
]
|
|
1075
|
+
],
|
|
1076
|
+
];
|
|
1077
|
+
|
|
1078
|
+
examples.forEach(([expected, actual]) => {
|
|
1079
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1080
|
+
expect(aaveV3Encode.collateralSwitch(...actual)).to.eql(expected);
|
|
1081
|
+
});
|
|
1082
|
+
});
|
|
1083
|
+
});
|
|
968
1084
|
});
|
|
969
1085
|
|
|
970
1086
|
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
@@ -393,6 +393,27 @@ export const aaveV3Encode = {
|
|
|
393
393
|
|
|
394
394
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
395
395
|
},
|
|
396
|
+
|
|
397
|
+
collateralSwitch(
|
|
398
|
+
strategyOrBundleId: number,
|
|
399
|
+
fromAsset: EthereumAddress,
|
|
400
|
+
fromAssetId: number,
|
|
401
|
+
toAsset: EthereumAddress,
|
|
402
|
+
toAssetId: number,
|
|
403
|
+
marketAddr: EthereumAddress,
|
|
404
|
+
amountToSwitch: string,
|
|
405
|
+
baseTokenAddress: EthereumAddress,
|
|
406
|
+
quoteTokenAddress: EthereumAddress,
|
|
407
|
+
price: number,
|
|
408
|
+
state: RatioState,
|
|
409
|
+
) {
|
|
410
|
+
const isBundle = false;
|
|
411
|
+
|
|
412
|
+
const subDataEncoded = subDataService.aaveV3CollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
413
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
414
|
+
|
|
415
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
416
|
+
},
|
|
396
417
|
};
|
|
397
418
|
|
|
398
419
|
export const compoundV2Encode = {
|