@defisaver/automation-sdk 3.3.1 → 3.3.2-dev.0
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 +100 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/strategiesService.js +28 -9
- package/cjs/services/strategySubService.d.ts +3 -1
- package/cjs/services/strategySubService.js +15 -2
- package/cjs/services/strategySubService.test.js +314 -0
- package/cjs/services/subDataService.d.ts +25 -1
- package/cjs/services/subDataService.js +78 -2
- package/cjs/services/subDataService.test.js +456 -0
- package/cjs/services/triggerService.d.ts +9 -0
- package/cjs/services/triggerService.js +20 -1
- package/cjs/services/triggerService.test.js +46 -0
- package/cjs/types/enums.d.ts +24 -4
- package/cjs/types/enums.js +21 -0
- package/esm/constants/index.js +100 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/strategiesService.js +28 -9
- package/esm/services/strategySubService.d.ts +3 -1
- package/esm/services/strategySubService.js +15 -2
- package/esm/services/strategySubService.test.js +314 -0
- package/esm/services/subDataService.d.ts +25 -1
- package/esm/services/subDataService.js +77 -1
- package/esm/services/subDataService.test.js +456 -0
- package/esm/services/triggerService.d.ts +9 -0
- package/esm/services/triggerService.js +19 -0
- package/esm/services/triggerService.test.js +47 -1
- package/esm/types/enums.d.ts +24 -4
- package/esm/types/enums.js +21 -0
- package/package.json +1 -1
- package/src/constants/index.ts +103 -0
- package/src/index.ts +4 -2
- package/src/services/strategiesService.ts +31 -10
- package/src/services/strategySubService.test.ts +347 -0
- package/src/services/strategySubService.ts +57 -1
- package/src/services/subDataService.test.ts +532 -0
- package/src/services/subDataService.ts +122 -2
- package/src/services/triggerService.test.ts +50 -0
- package/src/services/triggerService.ts +29 -0
- package/src/types/enums.ts +21 -0
- package/src/types/index.ts +20 -0
|
@@ -52,12 +52,36 @@ export declare const aaveV3LeverageManagementSubData: {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
export declare const aaveV3LeverageManagementSubDataWithoutSubProxy: {
|
|
55
|
-
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
55
|
+
encode(targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress, isGeneric: boolean): string[];
|
|
56
56
|
decode(subData: string[]): {
|
|
57
57
|
targetRatio: number;
|
|
58
58
|
ratioState: RatioState;
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
|
+
export declare const aaveV3LeverageManagementOnPriceGeneric: {
|
|
62
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): string[];
|
|
63
|
+
decode(subData: string[]): {
|
|
64
|
+
collAsset: EthereumAddress;
|
|
65
|
+
collAssetId: number;
|
|
66
|
+
debtAsset: EthereumAddress;
|
|
67
|
+
debtAssetId: number;
|
|
68
|
+
marketAddr: EthereumAddress;
|
|
69
|
+
targetRatio: number;
|
|
70
|
+
user: EthereumAddress;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare const aaveV3CloseGenericSubData: {
|
|
74
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
75
|
+
decode(subData: string[]): {
|
|
76
|
+
collAsset: EthereumAddress;
|
|
77
|
+
collAssetId: number;
|
|
78
|
+
debtAsset: EthereumAddress;
|
|
79
|
+
debtAssetId: number;
|
|
80
|
+
closeType: CloseStrategyType;
|
|
81
|
+
marketAddr: EthereumAddress;
|
|
82
|
+
user: EthereumAddress;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
61
85
|
export declare const aaveV3QuotePriceSubData: {
|
|
62
86
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
63
87
|
decode(subData: string[]): {
|
|
@@ -3,7 +3,7 @@ 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.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.fluidLeverageManagementSubData = exports.liquityV2PaybackSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
6
|
+
exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.fluidLeverageManagementSubData = exports.liquityV2PaybackSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
9
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -127,9 +127,14 @@ exports.aaveV3LeverageManagementSubData = {
|
|
|
127
127
|
},
|
|
128
128
|
};
|
|
129
129
|
exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
130
|
-
encode(targetRatio, ratioState) {
|
|
130
|
+
encode(targetRatio, ratioState, market, user, isGeneric) {
|
|
131
131
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
132
132
|
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
133
|
+
if (isGeneric) {
|
|
134
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
135
|
+
const encodedUser = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
136
|
+
return [encodedTargetRatio, encodedRatioState, encodedMarket, encodedUser];
|
|
137
|
+
}
|
|
133
138
|
const encodedUseDefaultMarket = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
134
139
|
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
135
140
|
return [encodedTargetRatio, encodedRatioState, encodedUseDefaultMarket, encodedUseOnBehalf];
|
|
@@ -140,6 +145,77 @@ exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
|
140
145
|
return { targetRatio, ratioState };
|
|
141
146
|
},
|
|
142
147
|
};
|
|
148
|
+
exports.aaveV3LeverageManagementOnPriceGeneric = {
|
|
149
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
150
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
151
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
152
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
153
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
154
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
155
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
156
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
157
|
+
return [
|
|
158
|
+
encodedColl,
|
|
159
|
+
encodedCollId,
|
|
160
|
+
encodedDebt,
|
|
161
|
+
encodedDebtId,
|
|
162
|
+
encodedMarket,
|
|
163
|
+
encodedTargetRatio,
|
|
164
|
+
userEncoded,
|
|
165
|
+
];
|
|
166
|
+
},
|
|
167
|
+
decode(subData) {
|
|
168
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
169
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
170
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
171
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
172
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
173
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
174
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
175
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
176
|
+
return {
|
|
177
|
+
collAsset,
|
|
178
|
+
collAssetId,
|
|
179
|
+
debtAsset,
|
|
180
|
+
debtAssetId,
|
|
181
|
+
marketAddr,
|
|
182
|
+
targetRatio,
|
|
183
|
+
user,
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
exports.aaveV3CloseGenericSubData = {
|
|
188
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
189
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
190
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
191
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
192
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
193
|
+
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
194
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
195
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
196
|
+
return [
|
|
197
|
+
encodedColl,
|
|
198
|
+
encodedCollId,
|
|
199
|
+
encodedDebt,
|
|
200
|
+
encodedDebtId,
|
|
201
|
+
encodedCloseType,
|
|
202
|
+
encodedMarket,
|
|
203
|
+
userEncoded,
|
|
204
|
+
];
|
|
205
|
+
},
|
|
206
|
+
decode(subData) {
|
|
207
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
208
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
209
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
210
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
211
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
212
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
213
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
214
|
+
return {
|
|
215
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user,
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
};
|
|
143
219
|
exports.aaveV3QuotePriceSubData = {
|
|
144
220
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, nullAddress = constants_1.ZERO_ADDRESS) {
|
|
145
221
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -1455,4 +1455,460 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1455
1455
|
});
|
|
1456
1456
|
});
|
|
1457
1457
|
});
|
|
1458
|
+
describe("When testing subDataService.aaveV3LeverageManagementOnPriceGeneric", () => {
|
|
1459
|
+
describe("encode()", () => {
|
|
1460
|
+
const examples = [
|
|
1461
|
+
[
|
|
1462
|
+
[
|
|
1463
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1464
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1465
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1466
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1467
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1468
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1469
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1470
|
+
],
|
|
1471
|
+
[
|
|
1472
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1473
|
+
0,
|
|
1474
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1475
|
+
1,
|
|
1476
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1477
|
+
200,
|
|
1478
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1479
|
+
]
|
|
1480
|
+
],
|
|
1481
|
+
[
|
|
1482
|
+
[
|
|
1483
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1484
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1485
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1486
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1487
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1488
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1489
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1490
|
+
],
|
|
1491
|
+
[
|
|
1492
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1493
|
+
2,
|
|
1494
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1495
|
+
1,
|
|
1496
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1497
|
+
200,
|
|
1498
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1499
|
+
]
|
|
1500
|
+
],
|
|
1501
|
+
];
|
|
1502
|
+
examples.forEach(([expected, actual]) => {
|
|
1503
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1504
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(...actual)).to.eql(expected);
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
});
|
|
1508
|
+
describe("decode()", () => {
|
|
1509
|
+
const examples = [
|
|
1510
|
+
[
|
|
1511
|
+
{
|
|
1512
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1513
|
+
collAssetId: 0,
|
|
1514
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1515
|
+
debtAssetId: 1,
|
|
1516
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1517
|
+
targetRatio: 200,
|
|
1518
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1519
|
+
},
|
|
1520
|
+
[
|
|
1521
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1522
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1523
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1524
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1525
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1526
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1527
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1528
|
+
]
|
|
1529
|
+
],
|
|
1530
|
+
[
|
|
1531
|
+
{
|
|
1532
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1533
|
+
collAssetId: 2,
|
|
1534
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1535
|
+
debtAssetId: 1,
|
|
1536
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1537
|
+
targetRatio: 200,
|
|
1538
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1539
|
+
},
|
|
1540
|
+
[
|
|
1541
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1542
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1543
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1544
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1545
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1546
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1547
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1548
|
+
]
|
|
1549
|
+
],
|
|
1550
|
+
];
|
|
1551
|
+
examples.forEach(([expected, actual]) => {
|
|
1552
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1553
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceGeneric.decode(actual)).to.eql(expected);
|
|
1554
|
+
});
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
});
|
|
1558
|
+
describe("When testing subDataService.aaveV3CloseGenericSubData", () => {
|
|
1559
|
+
describe("encode()", () => {
|
|
1560
|
+
const examples = [
|
|
1561
|
+
// TAKE_PROFIT_IN_COLLATERAL
|
|
1562
|
+
[
|
|
1563
|
+
[
|
|
1564
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1565
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1566
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1567
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1568
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1569
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1570
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1571
|
+
],
|
|
1572
|
+
[
|
|
1573
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1574
|
+
0,
|
|
1575
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1576
|
+
1,
|
|
1577
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1578
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1579
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1580
|
+
]
|
|
1581
|
+
],
|
|
1582
|
+
// STOP_LOSS_IN_COLLATERAL
|
|
1583
|
+
[
|
|
1584
|
+
[
|
|
1585
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1586
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1587
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1588
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1589
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1590
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1591
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1595
|
+
0,
|
|
1596
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1597
|
+
1,
|
|
1598
|
+
enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
1599
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1600
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1601
|
+
]
|
|
1602
|
+
],
|
|
1603
|
+
// TAKE_PROFIT_IN_DEBT
|
|
1604
|
+
[
|
|
1605
|
+
[
|
|
1606
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1607
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1608
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1609
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1610
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1611
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1612
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1613
|
+
],
|
|
1614
|
+
[
|
|
1615
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1616
|
+
0,
|
|
1617
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1618
|
+
1,
|
|
1619
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
1620
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1621
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1622
|
+
]
|
|
1623
|
+
],
|
|
1624
|
+
// STOP_LOSS_IN_DEBT
|
|
1625
|
+
[
|
|
1626
|
+
[
|
|
1627
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1628
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1629
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1630
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1631
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
1632
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1633
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1634
|
+
],
|
|
1635
|
+
[
|
|
1636
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1637
|
+
0,
|
|
1638
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1639
|
+
1,
|
|
1640
|
+
enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
1641
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1642
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1643
|
+
]
|
|
1644
|
+
],
|
|
1645
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
|
|
1646
|
+
[
|
|
1647
|
+
[
|
|
1648
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1649
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1650
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1651
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1652
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1653
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1654
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1655
|
+
],
|
|
1656
|
+
[
|
|
1657
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1658
|
+
0,
|
|
1659
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1660
|
+
1,
|
|
1661
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1662
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1663
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1664
|
+
]
|
|
1665
|
+
],
|
|
1666
|
+
// TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
1667
|
+
[
|
|
1668
|
+
[
|
|
1669
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1670
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1671
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1672
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1673
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1674
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1675
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1676
|
+
],
|
|
1677
|
+
[
|
|
1678
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1679
|
+
2,
|
|
1680
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1681
|
+
1,
|
|
1682
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
1683
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1684
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1685
|
+
]
|
|
1686
|
+
],
|
|
1687
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
1688
|
+
[
|
|
1689
|
+
[
|
|
1690
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1691
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1692
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1693
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1694
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1695
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1696
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1697
|
+
],
|
|
1698
|
+
[
|
|
1699
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1700
|
+
2,
|
|
1701
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1702
|
+
1,
|
|
1703
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1704
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1705
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1706
|
+
]
|
|
1707
|
+
],
|
|
1708
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
1709
|
+
[
|
|
1710
|
+
[
|
|
1711
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1712
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1713
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1714
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1715
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1716
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1717
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1718
|
+
],
|
|
1719
|
+
[
|
|
1720
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1721
|
+
2,
|
|
1722
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1723
|
+
1,
|
|
1724
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1725
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1726
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1727
|
+
]
|
|
1728
|
+
],
|
|
1729
|
+
];
|
|
1730
|
+
examples.forEach(([expected, actual]) => {
|
|
1731
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1732
|
+
(0, chai_1.expect)(subDataService.aaveV3CloseGenericSubData.encode(...actual)).to.eql(expected);
|
|
1733
|
+
});
|
|
1734
|
+
});
|
|
1735
|
+
});
|
|
1736
|
+
describe("decode()", () => {
|
|
1737
|
+
const examples = [
|
|
1738
|
+
// TAKE_PROFIT_IN_COLLATERAL
|
|
1739
|
+
[
|
|
1740
|
+
{
|
|
1741
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1742
|
+
collAssetId: 0,
|
|
1743
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1744
|
+
debtAssetId: 1,
|
|
1745
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1746
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1747
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1748
|
+
},
|
|
1749
|
+
[
|
|
1750
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1751
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1752
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1753
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1754
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1755
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1756
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1757
|
+
]
|
|
1758
|
+
],
|
|
1759
|
+
// STOP_LOSS_IN_COLLATERAL
|
|
1760
|
+
[
|
|
1761
|
+
{
|
|
1762
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1763
|
+
collAssetId: 0,
|
|
1764
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1765
|
+
debtAssetId: 1,
|
|
1766
|
+
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
1767
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1768
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1769
|
+
},
|
|
1770
|
+
[
|
|
1771
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1772
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1773
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1774
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1775
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1776
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1777
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1778
|
+
]
|
|
1779
|
+
],
|
|
1780
|
+
// TAKE_PROFIT_IN_DEBT
|
|
1781
|
+
[
|
|
1782
|
+
{
|
|
1783
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1784
|
+
collAssetId: 0,
|
|
1785
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1786
|
+
debtAssetId: 1,
|
|
1787
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
1788
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1789
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1790
|
+
},
|
|
1791
|
+
[
|
|
1792
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1793
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1794
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1795
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1796
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1797
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1798
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1799
|
+
]
|
|
1800
|
+
],
|
|
1801
|
+
// STOP_LOSS_IN_DEBT
|
|
1802
|
+
[
|
|
1803
|
+
{
|
|
1804
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1805
|
+
collAssetId: 0,
|
|
1806
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1807
|
+
debtAssetId: 1,
|
|
1808
|
+
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
1809
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1810
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1811
|
+
},
|
|
1812
|
+
[
|
|
1813
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1814
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1815
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1816
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1817
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
1818
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1819
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1820
|
+
]
|
|
1821
|
+
],
|
|
1822
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
|
|
1823
|
+
[
|
|
1824
|
+
{
|
|
1825
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1826
|
+
collAssetId: 0,
|
|
1827
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1828
|
+
debtAssetId: 1,
|
|
1829
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1830
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1831
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1832
|
+
},
|
|
1833
|
+
[
|
|
1834
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1835
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1836
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1837
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1838
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1839
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1840
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1841
|
+
]
|
|
1842
|
+
],
|
|
1843
|
+
// TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
1844
|
+
[
|
|
1845
|
+
{
|
|
1846
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1847
|
+
collAssetId: 2,
|
|
1848
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1849
|
+
debtAssetId: 1,
|
|
1850
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
1851
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1852
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1853
|
+
},
|
|
1854
|
+
[
|
|
1855
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1856
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1857
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1858
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1859
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1860
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1861
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1862
|
+
]
|
|
1863
|
+
],
|
|
1864
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
1865
|
+
[
|
|
1866
|
+
{
|
|
1867
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1868
|
+
collAssetId: 2,
|
|
1869
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1870
|
+
debtAssetId: 1,
|
|
1871
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1872
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1873
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1874
|
+
},
|
|
1875
|
+
[
|
|
1876
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1877
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1878
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1879
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1880
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1881
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1882
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1883
|
+
]
|
|
1884
|
+
],
|
|
1885
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
1886
|
+
[
|
|
1887
|
+
{
|
|
1888
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1889
|
+
collAssetId: 2,
|
|
1890
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1891
|
+
debtAssetId: 1,
|
|
1892
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1893
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1894
|
+
user: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1895
|
+
},
|
|
1896
|
+
[
|
|
1897
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1898
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1899
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1900
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1901
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1902
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1903
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1904
|
+
]
|
|
1905
|
+
],
|
|
1906
|
+
];
|
|
1907
|
+
examples.forEach(([expected, actual]) => {
|
|
1908
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1909
|
+
(0, chai_1.expect)(subDataService.aaveV3CloseGenericSubData.decode(actual)).to.eql(expected);
|
|
1910
|
+
});
|
|
1911
|
+
});
|
|
1912
|
+
});
|
|
1913
|
+
});
|
|
1458
1914
|
});
|
|
@@ -266,3 +266,12 @@ export declare const compoundV3PriceRangeTrigger: {
|
|
|
266
266
|
upperPrice: string;
|
|
267
267
|
};
|
|
268
268
|
};
|
|
269
|
+
export declare const aaveV3QuotePriceRangeTrigger: {
|
|
270
|
+
encode(collToken: EthereumAddress, debtToken: EthereumAddress, lowerPrice: number, upperPrice: number): string[];
|
|
271
|
+
decode(triggerData: string[]): {
|
|
272
|
+
collToken: string;
|
|
273
|
+
debtToken: string;
|
|
274
|
+
lowerPrice: string;
|
|
275
|
+
upperPrice: string;
|
|
276
|
+
};
|
|
277
|
+
};
|