@defisaver/automation-sdk 3.3.22-coll-switch-generic-dev → 3.3.22-instant-twap-close-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 +40 -60
- package/cjs/services/strategiesService.js +21 -16
- package/cjs/services/strategiesService.test.js +62 -92
- package/cjs/services/strategySubService.d.ts +1 -2
- package/cjs/services/strategySubService.js +7 -12
- package/cjs/services/strategySubService.test.js +111 -107
- package/cjs/services/subDataService.d.ts +12 -22
- package/cjs/services/subDataService.js +35 -61
- package/cjs/services/subDataService.test.js +70 -139
- package/cjs/types/enums.d.ts +18 -22
- package/cjs/types/enums.js +11 -14
- package/esm/constants/index.js +40 -60
- package/esm/services/strategiesService.js +21 -16
- package/esm/services/strategiesService.test.js +63 -93
- package/esm/services/strategySubService.d.ts +1 -2
- package/esm/services/strategySubService.js +7 -12
- package/esm/services/strategySubService.test.js +111 -107
- package/esm/services/subDataService.d.ts +12 -22
- package/esm/services/subDataService.js +33 -59
- package/esm/services/subDataService.test.js +70 -139
- package/esm/types/enums.d.ts +18 -22
- package/esm/types/enums.js +11 -14
- package/package.json +1 -1
- package/src/constants/index.ts +40 -60
- package/src/services/strategiesService.test.ts +78 -102
- package/src/services/strategiesService.ts +27 -16
- package/src/services/strategySubService.test.ts +125 -126
- package/src/services/strategySubService.ts +18 -38
- package/src/services/subDataService.test.ts +98 -149
- package/src/services/subDataService.ts +48 -88
- package/src/types/enums.ts +11 -14
|
@@ -8,102 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { expect } from 'chai';
|
|
11
|
-
import {
|
|
11
|
+
import { Bundles, CloseStrategyType, CloseToAssetType, ProtocolIdentifiers, Strategies, } from '../types/enums';
|
|
12
12
|
import '../configuration';
|
|
13
13
|
import { parseStrategiesAutomatedPosition } from './strategiesService';
|
|
14
|
+
import { aaveV3Encode } from './strategySubService';
|
|
14
15
|
describe('Feature: strategiesService.ts', () => {
|
|
15
|
-
describe('When parsing Aave V3 collateral switch subscriptions', () => {
|
|
16
|
-
const proxy = '0x9cB7E19861665366011899d74E75d4F2A419aEeD';
|
|
17
|
-
const user = '0x1234567890123456789012345678901234567890';
|
|
18
|
-
const fromAsset = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
19
|
-
const toAsset = '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf';
|
|
20
|
-
const marketAddr = '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e';
|
|
21
|
-
const amountToSwitch = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
22
|
-
const subHash = `0x${'ab'.repeat(32)}`;
|
|
23
|
-
const triggerData = [
|
|
24
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
|
|
25
|
-
+ '000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf'
|
|
26
|
-
+ '0000000000000000000000000000000000000000000000000000000000989680'
|
|
27
|
-
+ '0000000000000000000000000000000000000000000000000000000000000001',
|
|
28
|
-
];
|
|
29
|
-
function getParseData(strategyId, isGeneric, chainId = ChainId.Ethereum) {
|
|
30
|
-
const subData = [
|
|
31
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
32
|
-
isGeneric
|
|
33
|
-
? '0x0000000000000000000000000000000000000000000000000000000000000100'
|
|
34
|
-
: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
35
|
-
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
36
|
-
isGeneric
|
|
37
|
-
? '0x000000000000000000000000000000000000000000000000000000000000ffff'
|
|
38
|
-
: '0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
39
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
40
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
41
|
-
isGeneric
|
|
42
|
-
? '0x0000000000000000000000001234567890123456789012345678901234567890'
|
|
43
|
-
: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
44
|
-
];
|
|
45
|
-
const subStruct = Object.assign([String(strategyId), false, triggerData, subData], { strategyOrBundleId: String(strategyId), isBundle: false, triggerData, subData });
|
|
46
|
-
return {
|
|
47
|
-
chainId,
|
|
48
|
-
blockNumber: 18015756,
|
|
49
|
-
subscriptionEventData: {
|
|
50
|
-
subId: '379', proxy, subHash, subStruct,
|
|
51
|
-
0: '379', 1: proxy, 2: subHash, 3: subStruct,
|
|
52
|
-
},
|
|
53
|
-
strategiesSubsData: {
|
|
54
|
-
userProxy: proxy, isEnabled: true, strategySubHash: subHash,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const genericStrategies = [
|
|
59
|
-
[ChainId.Ethereum, Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH_EOA],
|
|
60
|
-
[ChainId.Optimism, Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH_EOA],
|
|
61
|
-
[ChainId.Arbitrum, Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH_EOA],
|
|
62
|
-
[ChainId.Base, Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH_EOA],
|
|
63
|
-
];
|
|
64
|
-
genericStrategies.forEach(([chainId, strategyId]) => {
|
|
65
|
-
it(`decodes generic collateral switches with the user and uint16 reserve IDs on chain ${chainId}`, () => {
|
|
66
|
-
const parseData = getParseData(strategyId, true, chainId);
|
|
67
|
-
const position = parseStrategiesAutomatedPosition(parseData);
|
|
68
|
-
expect(position).not.to.equal(null);
|
|
69
|
-
expect(position.protocol.id).to.equal(ProtocolIdentifiers.StrategiesAutomation.AaveV3);
|
|
70
|
-
expect(position.strategy.strategyId).to.equal(Strategies.Identifiers.EoaCollateralSwitch);
|
|
71
|
-
expect(position.strategy.isBundle).to.equal(false);
|
|
72
|
-
expect(position.strategyData.encoded).to.eql({
|
|
73
|
-
triggerData,
|
|
74
|
-
subData: parseData.subscriptionEventData.subStruct.subData,
|
|
75
|
-
});
|
|
76
|
-
expect(position.strategyData.decoded.triggerData).to.eql({
|
|
77
|
-
baseTokenAddress: fromAsset,
|
|
78
|
-
quoteTokenAddress: toAsset,
|
|
79
|
-
price: '0.1',
|
|
80
|
-
ratioState: RatioState.UNDER,
|
|
81
|
-
});
|
|
82
|
-
expect(position.strategyData.decoded.subData).to.eql({
|
|
83
|
-
fromAsset, fromAssetId: 256, toAsset, toAssetId: 65535, marketAddr, amountToSwitch, user,
|
|
84
|
-
});
|
|
85
|
-
expect(position.owner).to.equal(proxy.toLowerCase());
|
|
86
|
-
expect(position.positionId).to.equal(`${chainId}-aave__v3-${proxy.toLowerCase()}-${marketAddr.toLowerCase()}`);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
const legacyStrategies = [
|
|
90
|
-
[ChainId.Ethereum, Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
91
|
-
[ChainId.Optimism, Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
92
|
-
[ChainId.Arbitrum, Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
93
|
-
[ChainId.Base, Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
94
|
-
];
|
|
95
|
-
legacyStrategies.forEach(([chainId, strategyId]) => {
|
|
96
|
-
it(`continues to decode legacy collateral switches on chain ${chainId}`, () => {
|
|
97
|
-
const position = parseStrategiesAutomatedPosition(getParseData(strategyId, false, chainId));
|
|
98
|
-
expect(position).not.to.equal(null);
|
|
99
|
-
expect(position.strategy.strategyId).to.equal(Strategies.Identifiers.CollateralSwitch);
|
|
100
|
-
expect(position.strategyData.decoded.subData).to.eql({
|
|
101
|
-
fromAsset, fromAssetId: 0, toAsset, toAssetId: 7, marketAddr, amountToSwitch,
|
|
102
|
-
});
|
|
103
|
-
expect(position.positionId).to.equal(`${chainId}-aave__v3-${proxy.toLowerCase()}-${marketAddr.toLowerCase()}`);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
16
|
describe('When testing strategiesService.parseStrategiesAutomatedPosition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
17
|
// TODO: we should probably write this for every strategy?
|
|
109
18
|
const examples = [
|
|
@@ -198,4 +107,65 @@ describe('Feature: strategiesService.ts', () => {
|
|
|
198
107
|
}));
|
|
199
108
|
});
|
|
200
109
|
}));
|
|
110
|
+
describe('When parsing Aave V3 instant close bundles', () => {
|
|
111
|
+
const owner = '0x1234567890123456789012345678901234567890';
|
|
112
|
+
const market = '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e';
|
|
113
|
+
const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
114
|
+
const usdc = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
115
|
+
const bundles = [
|
|
116
|
+
['SW', Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE, Strategies.Identifiers.InstantCloseOnPrice],
|
|
117
|
+
['EOA', Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE, Strategies.Identifiers.EoaInstantCloseOnPrice],
|
|
118
|
+
];
|
|
119
|
+
bundles.forEach(([walletType, expectedBundleId, expectedStrategyId]) => {
|
|
120
|
+
describe(`${walletType} bundle`, () => {
|
|
121
|
+
const [bundleId, isBundle, triggerData, subData] = aaveV3Encode.instantCloseOnPriceGeneric(expectedBundleId, weth, 0, usdc, 1, market, owner, '1000000000000000000', '10000000000000000', 1500, CloseToAssetType.DEBT, 5000, CloseToAssetType.COLLATERAL);
|
|
122
|
+
const parseData = {
|
|
123
|
+
chainId: 1,
|
|
124
|
+
blockNumber: 1,
|
|
125
|
+
subscriptionEventData: {
|
|
126
|
+
subId: '1',
|
|
127
|
+
proxy: owner,
|
|
128
|
+
subHash: '0xhash',
|
|
129
|
+
subStruct: {
|
|
130
|
+
strategyOrBundleId: String(bundleId), isBundle, triggerData, subData,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
strategiesSubsData: { userProxy: owner, isEnabled: true, strategySubHash: '0xhash' },
|
|
134
|
+
};
|
|
135
|
+
const result = parseStrategiesAutomatedPosition(parseData);
|
|
136
|
+
it('should identify the strategy as instant close on price', () => {
|
|
137
|
+
expect(result.strategy.strategyOrBundleId).to.equal(expectedBundleId);
|
|
138
|
+
expect(result.strategy.strategyId).to.equal(expectedStrategyId);
|
|
139
|
+
expect(result.protocol.id).to.equal(ProtocolIdentifiers.StrategiesAutomation.AaveV3);
|
|
140
|
+
});
|
|
141
|
+
it('should decode sub data including tsi and slippage', () => {
|
|
142
|
+
expect(result.strategyData.decoded.subData).to.eql({
|
|
143
|
+
collAsset: weth,
|
|
144
|
+
collAssetId: 0,
|
|
145
|
+
debtAsset: usdc,
|
|
146
|
+
debtAssetId: 1,
|
|
147
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
148
|
+
marketAddr: market,
|
|
149
|
+
owner,
|
|
150
|
+
tsi: '1000000000000000000',
|
|
151
|
+
slippage: '10000000000000000',
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
it('should fill specific with prices and close types', () => {
|
|
155
|
+
expect(result.specific).to.eql({
|
|
156
|
+
collAsset: weth,
|
|
157
|
+
collAssetId: 0,
|
|
158
|
+
debtAsset: usdc,
|
|
159
|
+
debtAssetId: 1,
|
|
160
|
+
baseToken: weth,
|
|
161
|
+
quoteToken: usdc,
|
|
162
|
+
stopLossPrice: '1500',
|
|
163
|
+
takeProfitPrice: '5000',
|
|
164
|
+
stopLossType: CloseToAssetType.DEBT,
|
|
165
|
+
takeProfitType: CloseToAssetType.COLLATERAL,
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
201
171
|
});
|
|
@@ -61,9 +61,8 @@ export declare const aaveV3Encode: {
|
|
|
61
61
|
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
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
|
+
instantCloseOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, tsi: string, slippage: string, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
64
65
|
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
|
-
collateralSwitchGeneric(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
|
-
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[])[];
|
|
67
66
|
};
|
|
68
67
|
export declare const compoundV2Encode: {
|
|
69
68
|
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
@@ -164,21 +164,16 @@ export const aaveV3Encode = {
|
|
|
164
164
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
165
165
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
166
166
|
},
|
|
167
|
-
|
|
168
|
-
const isBundle =
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
collateralSwitchGeneric(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
174
|
-
const isBundle = false;
|
|
175
|
-
const subDataEncoded = subDataService.aaveV3GenericFLCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
176
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
167
|
+
instantCloseOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, tsi, slippage, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
168
|
+
const isBundle = true;
|
|
169
|
+
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
170
|
+
const subDataEncoded = subDataService.aaveV3InstantCloseGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage);
|
|
171
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
177
172
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
178
173
|
},
|
|
179
|
-
|
|
174
|
+
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
180
175
|
const isBundle = false;
|
|
181
|
-
const subDataEncoded = subDataService.
|
|
176
|
+
const subDataEncoded = subDataService.aaveV3CollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
182
177
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
183
178
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
184
179
|
},
|
|
@@ -732,6 +732,117 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
732
732
|
});
|
|
733
733
|
});
|
|
734
734
|
});
|
|
735
|
+
describe('instantCloseOnPriceGeneric()', () => {
|
|
736
|
+
const examples = [
|
|
737
|
+
// Stop loss only (to debt)
|
|
738
|
+
[
|
|
739
|
+
[
|
|
740
|
+
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
741
|
+
true,
|
|
742
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
743
|
+
[
|
|
744
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
745
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
746
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
747
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
748
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
749
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
750
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
751
|
+
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
752
|
+
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
753
|
+
],
|
|
754
|
+
],
|
|
755
|
+
[
|
|
756
|
+
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
757
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
758
|
+
0,
|
|
759
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
760
|
+
1,
|
|
761
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
762
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
763
|
+
'1000000000000000000',
|
|
764
|
+
'10000000000000000',
|
|
765
|
+
1500,
|
|
766
|
+
CloseToAssetType.DEBT,
|
|
767
|
+
0,
|
|
768
|
+
CloseToAssetType.COLLATERAL, // takeProfitType (not used since price is 0)
|
|
769
|
+
]
|
|
770
|
+
],
|
|
771
|
+
// Take profit only (to collateral), zero tsi and slippage
|
|
772
|
+
[
|
|
773
|
+
[
|
|
774
|
+
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
775
|
+
true,
|
|
776
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
777
|
+
[
|
|
778
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
779
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
780
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
781
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
782
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
783
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
784
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
785
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
786
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
787
|
+
],
|
|
788
|
+
],
|
|
789
|
+
[
|
|
790
|
+
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
791
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
792
|
+
0,
|
|
793
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
794
|
+
1,
|
|
795
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
796
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
797
|
+
'0',
|
|
798
|
+
'0',
|
|
799
|
+
0,
|
|
800
|
+
CloseToAssetType.DEBT,
|
|
801
|
+
5000,
|
|
802
|
+
CloseToAssetType.COLLATERAL, // takeProfitType
|
|
803
|
+
]
|
|
804
|
+
],
|
|
805
|
+
// Take profit (to debt) and stop loss (to collateral)
|
|
806
|
+
[
|
|
807
|
+
[
|
|
808
|
+
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
809
|
+
true,
|
|
810
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
811
|
+
[
|
|
812
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
813
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
814
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
815
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
816
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
817
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
818
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
819
|
+
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
820
|
+
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
821
|
+
],
|
|
822
|
+
],
|
|
823
|
+
[
|
|
824
|
+
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
825
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
826
|
+
0,
|
|
827
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
828
|
+
1,
|
|
829
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
830
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
831
|
+
'50000000000000000',
|
|
832
|
+
'5000000000000000',
|
|
833
|
+
1500,
|
|
834
|
+
CloseToAssetType.COLLATERAL,
|
|
835
|
+
4000,
|
|
836
|
+
CloseToAssetType.DEBT, // takeProfitType
|
|
837
|
+
]
|
|
838
|
+
],
|
|
839
|
+
];
|
|
840
|
+
examples.forEach(([expected, actual]) => {
|
|
841
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
842
|
+
expect(aaveV3Encode.instantCloseOnPriceGeneric(...actual)).to.eql(expected);
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
});
|
|
735
846
|
describe('collateralSwitch()', () => {
|
|
736
847
|
const examples = [
|
|
737
848
|
// WETH -> USDC, price 100000, state UNDER
|
|
@@ -831,113 +942,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
831
942
|
});
|
|
832
943
|
});
|
|
833
944
|
});
|
|
834
|
-
describe('collateralSwitchGeneric()', () => {
|
|
835
|
-
const strategyId = 12345;
|
|
836
|
-
const fromAsset = web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address);
|
|
837
|
-
const toAsset = web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address);
|
|
838
|
-
const marketAddr = web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39');
|
|
839
|
-
const user = web3Utils.toChecksumAddress('0x1234567890abcdef1234567890abcdef12345678');
|
|
840
|
-
const examples = [
|
|
841
|
-
[
|
|
842
|
-
RatioState.UNDER,
|
|
843
|
-
'10000000000000000000',
|
|
844
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
845
|
-
'0000000000000000000000000000000000000000000000000000000000000001',
|
|
846
|
-
],
|
|
847
|
-
[
|
|
848
|
-
RatioState.OVER,
|
|
849
|
-
MAXUINT,
|
|
850
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
851
|
-
'0000000000000000000000000000000000000000000000000000000000000000',
|
|
852
|
-
],
|
|
853
|
-
];
|
|
854
|
-
examples.forEach(([state, amountToSwitch, encodedAmount, encodedState]) => {
|
|
855
|
-
it(`encodes a generic collateral switch with the supplied quote pair and state ${state}`, () => {
|
|
856
|
-
const expectedTrigger = `0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000003e8${encodedState}`;
|
|
857
|
-
const expectedSubData = [
|
|
858
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
859
|
-
'0x0000000000000000000000000000000000000000000000000000000000000100',
|
|
860
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
861
|
-
'0x000000000000000000000000000000000000000000000000000000000000ffff',
|
|
862
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
863
|
-
encodedAmount,
|
|
864
|
-
'0x0000000000000000000000001234567890abcdef1234567890abcdef12345678',
|
|
865
|
-
];
|
|
866
|
-
expect(aaveV3Encode.collateralSwitchGeneric(strategyId, fromAsset, 256, toAsset, 65535, marketAddr, amountToSwitch, user, toAsset, fromAsset, 0.00001, state)).to.eql([strategyId, false, [expectedTrigger], expectedSubData]);
|
|
867
|
-
});
|
|
868
|
-
});
|
|
869
|
-
});
|
|
870
|
-
describe('debtSwitch()', () => {
|
|
871
|
-
const examples = [
|
|
872
|
-
// USDC -> DAI, price 100000, state UNDER
|
|
873
|
-
[
|
|
874
|
-
[
|
|
875
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
876
|
-
false,
|
|
877
|
-
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
878
|
-
[
|
|
879
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
880
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
881
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
882
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
883
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
884
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
885
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
886
|
-
],
|
|
887
|
-
],
|
|
888
|
-
[
|
|
889
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
890
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
891
|
-
1,
|
|
892
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
893
|
-
3,
|
|
894
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
895
|
-
'10000000000000000000',
|
|
896
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
897
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
898
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
899
|
-
100000,
|
|
900
|
-
RatioState.UNDER,
|
|
901
|
-
]
|
|
902
|
-
],
|
|
903
|
-
// DAI -> USDC (MaxUint256), price 1, state OVER
|
|
904
|
-
[
|
|
905
|
-
[
|
|
906
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
907
|
-
false,
|
|
908
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000'],
|
|
909
|
-
[
|
|
910
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
911
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
912
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
913
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
914
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
915
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
916
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
917
|
-
],
|
|
918
|
-
],
|
|
919
|
-
[
|
|
920
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
921
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
922
|
-
3,
|
|
923
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
924
|
-
1,
|
|
925
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
926
|
-
MAXUINT,
|
|
927
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
928
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
929
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
930
|
-
1,
|
|
931
|
-
RatioState.OVER,
|
|
932
|
-
]
|
|
933
|
-
],
|
|
934
|
-
];
|
|
935
|
-
examples.forEach(([expected, actual]) => {
|
|
936
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
937
|
-
expect(aaveV3Encode.debtSwitch(...actual)).to.eql(expected);
|
|
938
|
-
});
|
|
939
|
-
});
|
|
940
|
-
});
|
|
941
945
|
});
|
|
942
946
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
943
947
|
describe('leverageManagementOnPrice()', () => {
|
|
@@ -248,31 +248,22 @@ export declare const aaveV3CloseGenericSubData: {
|
|
|
248
248
|
owner: EthereumAddress;
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
|
-
export declare const
|
|
252
|
-
encode(
|
|
253
|
-
decode(subData: string[]): {
|
|
254
|
-
fromAsset: EthereumAddress;
|
|
255
|
-
fromAssetId: number;
|
|
256
|
-
toAsset: EthereumAddress;
|
|
257
|
-
toAssetId: number;
|
|
258
|
-
marketAddr: EthereumAddress;
|
|
259
|
-
amountToSwitch: string;
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
export declare const aaveV3GenericFLCollateralSwitchSubData: {
|
|
263
|
-
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress): string[];
|
|
251
|
+
export declare const aaveV3InstantCloseGenericSubData: {
|
|
252
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress, tsi: string, slippage: string): string[];
|
|
264
253
|
decode(subData: string[]): {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
254
|
+
collAsset: EthereumAddress;
|
|
255
|
+
collAssetId: number;
|
|
256
|
+
debtAsset: EthereumAddress;
|
|
257
|
+
debtAssetId: number;
|
|
258
|
+
closeType: CloseStrategyType;
|
|
269
259
|
marketAddr: EthereumAddress;
|
|
270
|
-
|
|
271
|
-
|
|
260
|
+
owner: EthereumAddress;
|
|
261
|
+
tsi: string;
|
|
262
|
+
slippage: string;
|
|
272
263
|
};
|
|
273
264
|
};
|
|
274
|
-
export declare const
|
|
275
|
-
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string,
|
|
265
|
+
export declare const aaveV3CollateralSwitchSubData: {
|
|
266
|
+
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean): string[];
|
|
276
267
|
decode(subData: string[]): {
|
|
277
268
|
fromAsset: EthereumAddress;
|
|
278
269
|
fromAssetId: number;
|
|
@@ -280,7 +271,6 @@ export declare const aaveV3DebtSwitchSubData: {
|
|
|
280
271
|
toAssetId: number;
|
|
281
272
|
marketAddr: EthereumAddress;
|
|
282
273
|
amountToSwitch: string;
|
|
283
|
-
user: EthereumAddress;
|
|
284
274
|
};
|
|
285
275
|
};
|
|
286
276
|
export declare const aaveV3QuotePriceSubData: {
|
|
@@ -511,78 +511,53 @@ export const aaveV3CloseGenericSubData = {
|
|
|
511
511
|
};
|
|
512
512
|
},
|
|
513
513
|
};
|
|
514
|
-
export const
|
|
515
|
-
encode(
|
|
516
|
-
const
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
const
|
|
520
|
-
const
|
|
521
|
-
const
|
|
522
|
-
const encodedUseOnBehalf = AbiCoder.encodeParameter('bool', useOnBehalf);
|
|
523
|
-
return [
|
|
524
|
-
encodedFromAsset,
|
|
525
|
-
encodedFromAssetId,
|
|
526
|
-
encodedToAsset,
|
|
527
|
-
encodedToAssetId,
|
|
528
|
-
encodedMarketAddr,
|
|
529
|
-
encodedAmountToSwitch,
|
|
530
|
-
encodedUseOnBehalf,
|
|
531
|
-
];
|
|
532
|
-
},
|
|
533
|
-
decode(subData) {
|
|
534
|
-
const fromAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
535
|
-
const fromAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
536
|
-
const toAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
537
|
-
const toAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
538
|
-
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
539
|
-
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
540
|
-
return {
|
|
541
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
542
|
-
};
|
|
543
|
-
},
|
|
544
|
-
};
|
|
545
|
-
export const aaveV3GenericFLCollateralSwitchSubData = {
|
|
546
|
-
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user) {
|
|
547
|
-
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
548
|
-
const encodedFromAssetId = AbiCoder.encodeParameter('uint16', fromAssetId);
|
|
549
|
-
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
550
|
-
const encodedToAssetId = AbiCoder.encodeParameter('uint16', toAssetId);
|
|
551
|
-
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
552
|
-
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
514
|
+
export const aaveV3InstantCloseGenericSubData = {
|
|
515
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage) {
|
|
516
|
+
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
517
|
+
const encodedCollId = AbiCoder.encodeParameter('uint16', collAssetId);
|
|
518
|
+
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
519
|
+
const encodedDebtId = AbiCoder.encodeParameter('uint16', debtAssetId);
|
|
520
|
+
const encodedCloseType = AbiCoder.encodeParameter('uint8', closeType);
|
|
521
|
+
const encodedMarket = AbiCoder.encodeParameter('address', marketAddr);
|
|
553
522
|
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
523
|
+
const encodedTsi = AbiCoder.encodeParameter('uint256', tsi);
|
|
524
|
+
const encodedSlippage = AbiCoder.encodeParameter('uint256', slippage);
|
|
554
525
|
return [
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
526
|
+
encodedColl,
|
|
527
|
+
encodedCollId,
|
|
528
|
+
encodedDebt,
|
|
529
|
+
encodedDebtId,
|
|
530
|
+
encodedCloseType,
|
|
531
|
+
encodedMarket,
|
|
561
532
|
encodedUser,
|
|
533
|
+
encodedTsi,
|
|
534
|
+
encodedSlippage,
|
|
562
535
|
];
|
|
563
536
|
},
|
|
564
537
|
decode(subData) {
|
|
565
|
-
const
|
|
566
|
-
const
|
|
567
|
-
const
|
|
568
|
-
const
|
|
569
|
-
const
|
|
570
|
-
const
|
|
571
|
-
const
|
|
538
|
+
const collAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
539
|
+
const collAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
540
|
+
const debtAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
541
|
+
const debtAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
542
|
+
const closeType = Number(AbiCoder.decodeParameter('uint8', subData[4]));
|
|
543
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[5]);
|
|
544
|
+
const owner = AbiCoder.decodeParameter('address', subData[6]);
|
|
545
|
+
const tsi = AbiCoder.decodeParameter('uint256', subData[7]);
|
|
546
|
+
const slippage = AbiCoder.decodeParameter('uint256', subData[8]);
|
|
572
547
|
return {
|
|
573
|
-
|
|
548
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner, tsi, slippage,
|
|
574
549
|
};
|
|
575
550
|
},
|
|
576
551
|
};
|
|
577
|
-
export const
|
|
578
|
-
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
552
|
+
export const aaveV3CollateralSwitchSubData = {
|
|
553
|
+
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
579
554
|
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
580
555
|
const encodedFromAssetId = AbiCoder.encodeParameter('uint8', fromAssetId);
|
|
581
556
|
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
582
557
|
const encodedToAssetId = AbiCoder.encodeParameter('uint8', toAssetId);
|
|
583
558
|
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
584
559
|
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
585
|
-
const
|
|
560
|
+
const encodedUseOnBehalf = AbiCoder.encodeParameter('bool', useOnBehalf);
|
|
586
561
|
return [
|
|
587
562
|
encodedFromAsset,
|
|
588
563
|
encodedFromAssetId,
|
|
@@ -590,7 +565,7 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
590
565
|
encodedToAssetId,
|
|
591
566
|
encodedMarketAddr,
|
|
592
567
|
encodedAmountToSwitch,
|
|
593
|
-
|
|
568
|
+
encodedUseOnBehalf,
|
|
594
569
|
];
|
|
595
570
|
},
|
|
596
571
|
decode(subData) {
|
|
@@ -600,9 +575,8 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
600
575
|
const toAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
601
576
|
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
602
577
|
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
603
|
-
const user = AbiCoder.decodeParameter('address', subData[6]);
|
|
604
578
|
return {
|
|
605
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
579
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
606
580
|
};
|
|
607
581
|
},
|
|
608
582
|
};
|