@defisaver/automation-sdk 3.3.6 → 3.3.7-morpho-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 +20 -10
- package/cjs/services/strategiesService.js +41 -14
- package/cjs/services/strategySubService.d.ts +2 -11
- package/cjs/services/strategySubService.js +12 -5
- package/cjs/services/strategySubService.test.js +38 -72
- package/cjs/services/subDataService.d.ts +24 -9
- package/cjs/services/subDataService.js +63 -20
- package/cjs/services/subDataService.test.js +52 -72
- package/cjs/services/triggerService.d.ts +19 -9
- package/cjs/services/triggerService.js +40 -19
- package/cjs/services/triggerService.test.js +48 -46
- package/cjs/services/utils.test.js +0 -77
- package/cjs/types/enums.d.ts +7 -5
- package/cjs/types/enums.js +4 -2
- package/esm/constants/index.js +20 -10
- package/esm/services/strategiesService.js +41 -14
- package/esm/services/strategySubService.d.ts +2 -11
- package/esm/services/strategySubService.js +12 -5
- package/esm/services/strategySubService.test.js +39 -73
- package/esm/services/subDataService.d.ts +24 -9
- package/esm/services/subDataService.js +62 -19
- package/esm/services/subDataService.test.js +52 -72
- package/esm/services/triggerService.d.ts +19 -9
- package/esm/services/triggerService.js +39 -18
- package/esm/services/triggerService.test.js +49 -47
- package/esm/services/utils.test.js +1 -52
- package/esm/types/enums.d.ts +7 -5
- package/esm/types/enums.js +4 -2
- package/package.json +1 -1
- package/src/constants/index.ts +20 -12
- package/src/services/strategiesService.ts +55 -22
- package/src/services/strategySubService.test.ts +59 -94
- package/src/services/strategySubService.ts +36 -16
- package/src/services/subDataService.test.ts +60 -78
- package/src/services/subDataService.ts +92 -31
- package/src/services/triggerService.test.ts +53 -51
- package/src/services/triggerService.ts +61 -26
- package/src/services/utils.test.ts +0 -59
- package/src/types/enums.ts +4 -2
|
@@ -5,7 +5,7 @@ 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';
|
|
8
|
-
import { aaveV2Encode, chickenBondsEncode, liquityEncode, makerEncode, aaveV3Encode, compoundV2Encode, compoundV3Encode, morphoAaveV2Encode, exchangeEncode,
|
|
8
|
+
import { aaveV2Encode, chickenBondsEncode, liquityEncode, makerEncode, aaveV3Encode, compoundV2Encode, compoundV3Encode, morphoAaveV2Encode, exchangeEncode, crvUSDEncode, compoundV3L2Encode, morphoBlueEncode, } from './strategySubService';
|
|
9
9
|
describe('Feature: strategySubService.ts', () => {
|
|
10
10
|
describe('When testing strategySubService.makerEncode', () => {
|
|
11
11
|
// @ts-ignore // TODO - this requires change in @defisaver/tokens
|
|
@@ -1163,78 +1163,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1163
1163
|
});
|
|
1164
1164
|
});
|
|
1165
1165
|
});
|
|
1166
|
-
describe('When testing strategySubService.sparkEncode', () => {
|
|
1167
|
-
describe('leverageManagement()', () => {
|
|
1168
|
-
const examples = [
|
|
1169
|
-
[
|
|
1170
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
1171
|
-
[160, 220, 180, 190, true]
|
|
1172
|
-
],
|
|
1173
|
-
[
|
|
1174
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
1175
|
-
[160, 200, 180, 190, false]
|
|
1176
|
-
],
|
|
1177
|
-
];
|
|
1178
|
-
examples.forEach(([expected, actual]) => {
|
|
1179
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1180
|
-
expect(sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1181
|
-
});
|
|
1182
|
-
});
|
|
1183
|
-
});
|
|
1184
|
-
describe('closeToAsset()', () => {
|
|
1185
|
-
const examples = [
|
|
1186
|
-
[
|
|
1187
|
-
[
|
|
1188
|
-
Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
1189
|
-
true,
|
|
1190
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1191
|
-
[
|
|
1192
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
1193
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
1194
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1195
|
-
],
|
|
1196
|
-
],
|
|
1197
|
-
[
|
|
1198
|
-
Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
1199
|
-
true,
|
|
1200
|
-
{
|
|
1201
|
-
baseTokenAddress: getAssetInfo('WETH').address, quoteTokenAddress: getAssetInfo('DAI').address, price: 1670, ratioState: RatioState.OVER
|
|
1202
|
-
},
|
|
1203
|
-
{
|
|
1204
|
-
collAsset: getAssetInfo('WETH').address, collAssetId: 21, debtAsset: getAssetInfo('DAI').address, debtAssetId: 32,
|
|
1205
|
-
},
|
|
1206
|
-
]
|
|
1207
|
-
],
|
|
1208
|
-
[
|
|
1209
|
-
[
|
|
1210
|
-
Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
1211
|
-
true,
|
|
1212
|
-
['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1213
|
-
[
|
|
1214
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
1215
|
-
'0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
1216
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1217
|
-
],
|
|
1218
|
-
],
|
|
1219
|
-
[
|
|
1220
|
-
Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
1221
|
-
true,
|
|
1222
|
-
{
|
|
1223
|
-
baseTokenAddress: getAssetInfo('LINK').address, quoteTokenAddress: getAssetInfo('DAI').address, price: 0.00544, ratioState: RatioState.UNDER
|
|
1224
|
-
},
|
|
1225
|
-
{
|
|
1226
|
-
collAsset: getAssetInfo('DAI').address, collAssetId: 21, debtAsset: getAssetInfo('LINK').address, debtAssetId: 32,
|
|
1227
|
-
},
|
|
1228
|
-
]
|
|
1229
|
-
]
|
|
1230
|
-
];
|
|
1231
|
-
examples.forEach(([expected, actual]) => {
|
|
1232
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1233
|
-
expect(sparkEncode.closeToAsset(...actual)).to.eql(expected);
|
|
1234
|
-
});
|
|
1235
|
-
});
|
|
1236
|
-
});
|
|
1237
|
-
});
|
|
1238
1166
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
1239
1167
|
describe('leverageManagement()', () => {
|
|
1240
1168
|
const examples = [
|
|
@@ -1408,6 +1336,44 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1408
1336
|
});
|
|
1409
1337
|
});
|
|
1410
1338
|
});
|
|
1339
|
+
describe('closeOnPrice()', () => {
|
|
1340
|
+
const examples = [
|
|
1341
|
+
[
|
|
1342
|
+
[
|
|
1343
|
+
Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1344
|
+
true,
|
|
1345
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1346
|
+
[
|
|
1347
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1348
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1349
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1350
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1351
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1352
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1353
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1354
|
+
],
|
|
1355
|
+
],
|
|
1356
|
+
[
|
|
1357
|
+
Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1358
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1359
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1360
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1361
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1362
|
+
'945000000000000000',
|
|
1363
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1364
|
+
1500,
|
|
1365
|
+
CloseToAssetType.DEBT,
|
|
1366
|
+
4000,
|
|
1367
|
+
CloseToAssetType.COLLATERAL
|
|
1368
|
+
]
|
|
1369
|
+
],
|
|
1370
|
+
];
|
|
1371
|
+
examples.forEach(([expected, actual]) => {
|
|
1372
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1373
|
+
expect(morphoBlueEncode.closeOnPrice(...actual)).to.eql(expected);
|
|
1374
|
+
});
|
|
1375
|
+
});
|
|
1376
|
+
});
|
|
1411
1377
|
});
|
|
1412
1378
|
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
1413
1379
|
describe('leverageManagement()', () => {
|
|
@@ -166,15 +166,6 @@ export declare const sparkLeverageManagementSubData: {
|
|
|
166
166
|
targetRatio: number;
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
|
-
export declare const sparkQuotePriceSubData: {
|
|
170
|
-
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
171
|
-
decode(subData: string[]): {
|
|
172
|
-
collAsset: EthereumAddress;
|
|
173
|
-
collAssetId: number;
|
|
174
|
-
debtAsset: EthereumAddress;
|
|
175
|
-
debtAssetId: number;
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
169
|
export declare const liquityDsrPaybackSubData: {
|
|
179
170
|
encode: (targetRatio: number) => string[];
|
|
180
171
|
decode: (subData: string[]) => {
|
|
@@ -315,3 +306,27 @@ export declare const compoundV3CloseSubData: {
|
|
|
315
306
|
owner: EthereumAddress;
|
|
316
307
|
};
|
|
317
308
|
};
|
|
309
|
+
export declare const sparkCloseGenericSubData: {
|
|
310
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
311
|
+
decode(subData: string[]): {
|
|
312
|
+
collAsset: EthereumAddress;
|
|
313
|
+
collAssetId: number;
|
|
314
|
+
debtAsset: EthereumAddress;
|
|
315
|
+
debtAssetId: number;
|
|
316
|
+
closeType: CloseStrategyType;
|
|
317
|
+
marketAddr: EthereumAddress;
|
|
318
|
+
owner: EthereumAddress;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
export declare const morphoBlueCloseOnPriceSubData: {
|
|
322
|
+
encode(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, closeType: CloseStrategyType): string[];
|
|
323
|
+
decode(subData: string[]): {
|
|
324
|
+
loanToken: string;
|
|
325
|
+
collToken: string;
|
|
326
|
+
oracle: string;
|
|
327
|
+
irm: string;
|
|
328
|
+
lltv: string;
|
|
329
|
+
user: string;
|
|
330
|
+
closeType: CloseStrategyType;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
@@ -411,25 +411,6 @@ export const sparkLeverageManagementSubData = {
|
|
|
411
411
|
return { targetRatio };
|
|
412
412
|
},
|
|
413
413
|
};
|
|
414
|
-
export const sparkQuotePriceSubData = {
|
|
415
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, nullAddress = ZERO_ADDRESS) {
|
|
416
|
-
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
417
|
-
const encodedCollId = AbiCoder.encodeParameter('uint8', collAssetId);
|
|
418
|
-
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
419
|
-
const encodedDebtId = AbiCoder.encodeParameter('uint8', debtAssetId);
|
|
420
|
-
const encodedNullAddress = AbiCoder.encodeParameter('address', nullAddress);
|
|
421
|
-
return [encodedColl, encodedCollId, encodedDebt, encodedDebtId, encodedNullAddress];
|
|
422
|
-
},
|
|
423
|
-
decode(subData) {
|
|
424
|
-
const collAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
425
|
-
const collAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
426
|
-
const debtAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
427
|
-
const debtAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
428
|
-
return {
|
|
429
|
-
collAsset, collAssetId, debtAsset, debtAssetId,
|
|
430
|
-
};
|
|
431
|
-
},
|
|
432
|
-
};
|
|
433
414
|
export const liquityDsrPaybackSubData = {
|
|
434
415
|
encode: (targetRatio) => {
|
|
435
416
|
const daiAddress = getAssetInfo('DAI').address;
|
|
@@ -839,3 +820,65 @@ export const compoundV3CloseSubData = {
|
|
|
839
820
|
};
|
|
840
821
|
},
|
|
841
822
|
};
|
|
823
|
+
export const sparkCloseGenericSubData = {
|
|
824
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
825
|
+
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
826
|
+
const encodedCollId = AbiCoder.encodeParameter('uint8', collAssetId);
|
|
827
|
+
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
828
|
+
const encodedDebtId = AbiCoder.encodeParameter('uint8', debtAssetId);
|
|
829
|
+
const encodedCloseType = AbiCoder.encodeParameter('uint8', closeType);
|
|
830
|
+
const encodedMarket = AbiCoder.encodeParameter('address', marketAddr);
|
|
831
|
+
const userEncoded = AbiCoder.encodeParameter('address', user);
|
|
832
|
+
return [
|
|
833
|
+
encodedColl,
|
|
834
|
+
encodedCollId,
|
|
835
|
+
encodedDebt,
|
|
836
|
+
encodedDebtId,
|
|
837
|
+
encodedCloseType,
|
|
838
|
+
encodedMarket,
|
|
839
|
+
userEncoded,
|
|
840
|
+
];
|
|
841
|
+
},
|
|
842
|
+
decode(subData) {
|
|
843
|
+
const collAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
844
|
+
const collAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
845
|
+
const debtAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
846
|
+
const debtAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
847
|
+
const closeType = Number(AbiCoder.decodeParameter('uint8', subData[4]));
|
|
848
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[5]);
|
|
849
|
+
const owner = AbiCoder.decodeParameter('address', subData[6]);
|
|
850
|
+
return {
|
|
851
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner,
|
|
852
|
+
};
|
|
853
|
+
},
|
|
854
|
+
};
|
|
855
|
+
export const morphoBlueCloseOnPriceSubData = {
|
|
856
|
+
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
857
|
+
const loanTokenEncoded = AbiCoder.encodeParameter('address', loanToken);
|
|
858
|
+
const collTokenEncoded = AbiCoder.encodeParameter('address', collToken);
|
|
859
|
+
const oracleEncoded = AbiCoder.encodeParameter('address', oracle);
|
|
860
|
+
const irmEncoded = AbiCoder.encodeParameter('address', irm);
|
|
861
|
+
const lltvEncoded = AbiCoder.encodeParameter('uint256', lltv);
|
|
862
|
+
const userEncoded = AbiCoder.encodeParameter('address', user);
|
|
863
|
+
const closeTypeEncoded = AbiCoder.encodeParameter('uint8', closeType);
|
|
864
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
865
|
+
},
|
|
866
|
+
decode(subData) {
|
|
867
|
+
const loanToken = AbiCoder.decodeParameter('address', subData[0]);
|
|
868
|
+
const collToken = AbiCoder.decodeParameter('address', subData[1]);
|
|
869
|
+
const oracle = AbiCoder.decodeParameter('address', subData[2]);
|
|
870
|
+
const irm = AbiCoder.decodeParameter('address', subData[3]);
|
|
871
|
+
const lltv = AbiCoder.decodeParameter('uint256', subData[4]);
|
|
872
|
+
const user = AbiCoder.decodeParameter('address', subData[5]);
|
|
873
|
+
const closeType = Number(AbiCoder.decodeParameter('uint8', subData[6]));
|
|
874
|
+
return {
|
|
875
|
+
loanToken,
|
|
876
|
+
collToken,
|
|
877
|
+
oracle,
|
|
878
|
+
irm,
|
|
879
|
+
lltv,
|
|
880
|
+
user,
|
|
881
|
+
closeType,
|
|
882
|
+
};
|
|
883
|
+
},
|
|
884
|
+
};
|
|
@@ -873,78 +873,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
873
873
|
});
|
|
874
874
|
});
|
|
875
875
|
});
|
|
876
|
-
describe('When testing subDataService.sparkQuotePriceSubData', () => {
|
|
877
|
-
describe('encode()', () => {
|
|
878
|
-
const examples = [
|
|
879
|
-
[
|
|
880
|
-
[
|
|
881
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
882
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
883
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
884
|
-
],
|
|
885
|
-
[
|
|
886
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
887
|
-
2,
|
|
888
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
889
|
-
4,
|
|
890
|
-
]
|
|
891
|
-
],
|
|
892
|
-
[
|
|
893
|
-
[
|
|
894
|
-
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
895
|
-
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
896
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
897
|
-
],
|
|
898
|
-
[
|
|
899
|
-
web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
900
|
-
6,
|
|
901
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
902
|
-
2,
|
|
903
|
-
]
|
|
904
|
-
],
|
|
905
|
-
];
|
|
906
|
-
examples.forEach(([expected, actual]) => {
|
|
907
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
908
|
-
expect(subDataService.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
909
|
-
});
|
|
910
|
-
});
|
|
911
|
-
});
|
|
912
|
-
describe('decode()', () => {
|
|
913
|
-
const examples = [
|
|
914
|
-
[
|
|
915
|
-
{
|
|
916
|
-
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
917
|
-
collAssetId: 2,
|
|
918
|
-
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
919
|
-
debtAssetId: 4,
|
|
920
|
-
},
|
|
921
|
-
[
|
|
922
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
923
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
924
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
925
|
-
],
|
|
926
|
-
],
|
|
927
|
-
[
|
|
928
|
-
{
|
|
929
|
-
collAsset: web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
930
|
-
collAssetId: 6,
|
|
931
|
-
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
932
|
-
debtAssetId: 2,
|
|
933
|
-
},
|
|
934
|
-
[
|
|
935
|
-
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
936
|
-
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
937
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
938
|
-
],
|
|
939
|
-
],
|
|
940
|
-
];
|
|
941
|
-
examples.forEach(([expected, actual]) => {
|
|
942
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
943
|
-
expect(subDataService.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
|
|
944
|
-
});
|
|
945
|
-
});
|
|
946
|
-
});
|
|
947
|
-
});
|
|
948
876
|
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
949
877
|
describe('encode()', () => {
|
|
950
878
|
const examples = [
|
|
@@ -1336,6 +1264,58 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1336
1264
|
});
|
|
1337
1265
|
});
|
|
1338
1266
|
});
|
|
1267
|
+
describe('When testing subDataService.morphoBlueCloseOnPriceSubData', () => {
|
|
1268
|
+
describe('encode()', () => {
|
|
1269
|
+
const examples = [
|
|
1270
|
+
[
|
|
1271
|
+
[
|
|
1272
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1273
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1274
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1275
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1276
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1277
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1278
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1279
|
+
],
|
|
1280
|
+
[web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'), '945000000000000000', web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT]
|
|
1281
|
+
],
|
|
1282
|
+
];
|
|
1283
|
+
examples.forEach(([expected, actual]) => {
|
|
1284
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1285
|
+
expect(subDataService.morphoBlueCloseOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1286
|
+
});
|
|
1287
|
+
});
|
|
1288
|
+
});
|
|
1289
|
+
describe('decode()', () => {
|
|
1290
|
+
const examples = [
|
|
1291
|
+
[
|
|
1292
|
+
{
|
|
1293
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1294
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1295
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1296
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1297
|
+
lltv: '945000000000000000',
|
|
1298
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1299
|
+
closeType: CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1300
|
+
},
|
|
1301
|
+
[
|
|
1302
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1303
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1304
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1305
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1306
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1307
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1308
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1309
|
+
],
|
|
1310
|
+
],
|
|
1311
|
+
];
|
|
1312
|
+
examples.forEach(([expected, actual]) => {
|
|
1313
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1314
|
+
expect(subDataService.morphoBlueCloseOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1315
|
+
});
|
|
1316
|
+
});
|
|
1317
|
+
});
|
|
1318
|
+
});
|
|
1339
1319
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1340
1320
|
describe('encode()', () => {
|
|
1341
1321
|
const examples = [
|
|
@@ -153,15 +153,6 @@ export declare const sparkRatioTrigger: {
|
|
|
153
153
|
ratioState: number;
|
|
154
154
|
};
|
|
155
155
|
};
|
|
156
|
-
export declare const sparkQuotePriceTrigger: {
|
|
157
|
-
encode(baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, ratioState: RatioState): string[];
|
|
158
|
-
decode(triggerData: string[]): {
|
|
159
|
-
baseTokenAddress: EthereumAddress;
|
|
160
|
-
quoteTokenAddress: EthereumAddress;
|
|
161
|
-
price: string;
|
|
162
|
-
ratioState: RatioState;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
156
|
export declare const curveUsdBorrowRateTrigger: {
|
|
166
157
|
encode(market: EthereumAddress, targetRate: string, rateState: RatioState): string[];
|
|
167
158
|
decode(triggerData: string[]): {
|
|
@@ -275,3 +266,22 @@ export declare const aaveV3QuotePriceRangeTrigger: {
|
|
|
275
266
|
upperPrice: string;
|
|
276
267
|
};
|
|
277
268
|
};
|
|
269
|
+
export declare const sparkQuotePriceRangeTrigger: {
|
|
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
|
+
};
|
|
278
|
+
export declare const morphoBluePriceRangeTrigger: {
|
|
279
|
+
encode(oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, lowerPrice: number, upperPrice: number): string[];
|
|
280
|
+
decode(triggerData: string[]): {
|
|
281
|
+
oracle: string;
|
|
282
|
+
collateralToken: string;
|
|
283
|
+
loanToken: string;
|
|
284
|
+
lowerPrice: string;
|
|
285
|
+
upperPrice: string;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
@@ -261,24 +261,6 @@ export const sparkRatioTrigger = {
|
|
|
261
261
|
};
|
|
262
262
|
},
|
|
263
263
|
};
|
|
264
|
-
export const sparkQuotePriceTrigger = {
|
|
265
|
-
encode(baseTokenAddress, quoteTokenAddress, price, ratioState) {
|
|
266
|
-
// Price is always in 8 decimals
|
|
267
|
-
const _price = new Dec(price.toString()).mul(Math.pow(10, 8)).floor().toString();
|
|
268
|
-
return [AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint8'], [baseTokenAddress, quoteTokenAddress, _price, ratioState])];
|
|
269
|
-
},
|
|
270
|
-
decode(triggerData) {
|
|
271
|
-
const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
|
|
272
|
-
// Price is always in 8 decimals
|
|
273
|
-
const price = new Dec(decodedData[2]).div(Math.pow(10, 8)).toDP(8).toString();
|
|
274
|
-
return {
|
|
275
|
-
price,
|
|
276
|
-
baseTokenAddress: decodedData[0],
|
|
277
|
-
quoteTokenAddress: decodedData[1],
|
|
278
|
-
ratioState: +decodedData[3],
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
264
|
export const curveUsdBorrowRateTrigger = {
|
|
283
265
|
encode(market, targetRate, rateState) {
|
|
284
266
|
// the form is x = (e**(rate*365*86400))-1 where x*100 is number in %
|
|
@@ -497,3 +479,42 @@ export const aaveV3QuotePriceRangeTrigger = {
|
|
|
497
479
|
};
|
|
498
480
|
},
|
|
499
481
|
};
|
|
482
|
+
export const sparkQuotePriceRangeTrigger = {
|
|
483
|
+
encode(collToken, debtToken, lowerPrice, upperPrice) {
|
|
484
|
+
// Price is scaled to 1e8
|
|
485
|
+
const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
|
|
486
|
+
const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
|
|
487
|
+
return [
|
|
488
|
+
AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint256'], [collToken, debtToken, lowerPriceFormatted, upperPriceFormatted]),
|
|
489
|
+
];
|
|
490
|
+
},
|
|
491
|
+
decode(triggerData) {
|
|
492
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint256'], triggerData[0]);
|
|
493
|
+
return {
|
|
494
|
+
collToken: decodedData[0],
|
|
495
|
+
debtToken: decodedData[1],
|
|
496
|
+
lowerPrice: new Dec(decodedData[2]).div(1e8).toString(),
|
|
497
|
+
upperPrice: new Dec(decodedData[3]).div(1e8).toString(),
|
|
498
|
+
};
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
export const morphoBluePriceRangeTrigger = {
|
|
502
|
+
encode(oracle, collateralToken, loanToken, lowerPrice, upperPrice) {
|
|
503
|
+
// Price is scaled to 1e8
|
|
504
|
+
const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
|
|
505
|
+
const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
|
|
506
|
+
return [
|
|
507
|
+
AbiCoder.encodeParameters(['address', 'address', 'address', 'uint256', 'uint256'], [oracle, collateralToken, loanToken, lowerPriceFormatted, upperPriceFormatted]),
|
|
508
|
+
];
|
|
509
|
+
},
|
|
510
|
+
decode(triggerData) {
|
|
511
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'address', 'address', 'uint256', 'uint256'], triggerData[0]);
|
|
512
|
+
return {
|
|
513
|
+
oracle: decodedData[0],
|
|
514
|
+
collateralToken: decodedData[1],
|
|
515
|
+
loanToken: decodedData[2],
|
|
516
|
+
lowerPrice: new Dec(decodedData[3]).div(1e8).toString(),
|
|
517
|
+
upperPrice: new Dec(decodedData[4]).div(1e8).toString(),
|
|
518
|
+
};
|
|
519
|
+
},
|
|
520
|
+
};
|
|
@@ -3,7 +3,7 @@ import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
|
3
3
|
import * as web3Utils from 'web3-utils';
|
|
4
4
|
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
5
5
|
import '../configuration';
|
|
6
|
-
import { aaveV2RatioTrigger, aaveV3QuotePriceTrigger, aaveV3QuotePriceWithMaximumGasPriceTrigger, aaveV3RatioTrigger, cBondsRebondTrigger, chainlinkPriceTrigger, compoundV2RatioTrigger, compoundV3RatioTrigger, compoundV3PriceTrigger, curveUsdBorrowRateTrigger, curveUsdSoftLiquidationTrigger, exchangeOffchainPriceTrigger, exchangeTimestampTrigger, liquityDebtInFrontTrigger, makerRatioTrigger, morphoAaveV2RatioTrigger,
|
|
6
|
+
import { aaveV2RatioTrigger, aaveV3QuotePriceTrigger, aaveV3QuotePriceWithMaximumGasPriceTrigger, aaveV3RatioTrigger, cBondsRebondTrigger, chainlinkPriceTrigger, compoundV2RatioTrigger, compoundV3RatioTrigger, compoundV3PriceTrigger, curveUsdBorrowRateTrigger, curveUsdSoftLiquidationTrigger, exchangeOffchainPriceTrigger, exchangeTimestampTrigger, liquityDebtInFrontTrigger, makerRatioTrigger, morphoAaveV2RatioTrigger, sparkRatioTrigger, trailingStopTrigger, liquityDebtInFrontWithLimitTrigger, crvUSDRatioTrigger, morphoBlueRatioTrigger, crvUsdHealthRatioTrigger, liquityV2DebtInFrontTrigger, liquityV2AdjustTimeTrigger, compoundV3PriceRangeTrigger, aaveV3QuotePriceRangeTrigger, morphoBluePriceRangeTrigger, } from './triggerService';
|
|
7
7
|
describe('Feature: triggerService.ts', () => {
|
|
8
8
|
describe('When testing triggerService.chainlinkPriceTrigger', () => {
|
|
9
9
|
describe('encode()', () => {
|
|
@@ -781,52 +781,6 @@ describe('Feature: triggerService.ts', () => {
|
|
|
781
781
|
});
|
|
782
782
|
});
|
|
783
783
|
});
|
|
784
|
-
describe('When testing triggerService.sparkQuotePriceTrigger', () => {
|
|
785
|
-
describe('encode()', () => {
|
|
786
|
-
const examples = [
|
|
787
|
-
[
|
|
788
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
|
|
789
|
-
[getAssetInfo('DAI', ChainId.Ethereum).address, getAssetInfo('wstETH', ChainId.Ethereum).address, 0.0004321, RatioState.UNDER]
|
|
790
|
-
],
|
|
791
|
-
[
|
|
792
|
-
['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
|
|
793
|
-
[getAssetInfo('WBTC', ChainId.Arbitrum).address, getAssetInfo('USDC', ChainId.Arbitrum).address, 0.00100023, RatioState.OVER]
|
|
794
|
-
],
|
|
795
|
-
];
|
|
796
|
-
examples.forEach(([expected, actual]) => {
|
|
797
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
798
|
-
expect(sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
|
-
describe('decode()', () => {
|
|
803
|
-
const examples = [
|
|
804
|
-
[
|
|
805
|
-
{
|
|
806
|
-
baseTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
807
|
-
quoteTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Ethereum).address),
|
|
808
|
-
price: '0.0004321',
|
|
809
|
-
ratioState: RatioState.UNDER,
|
|
810
|
-
},
|
|
811
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
|
|
812
|
-
],
|
|
813
|
-
[
|
|
814
|
-
{
|
|
815
|
-
baseTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
|
|
816
|
-
quoteTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
817
|
-
price: '0.00100023',
|
|
818
|
-
ratioState: RatioState.OVER,
|
|
819
|
-
},
|
|
820
|
-
['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
|
|
821
|
-
]
|
|
822
|
-
];
|
|
823
|
-
examples.forEach(([expected, actual]) => {
|
|
824
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
825
|
-
expect(sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
|
|
826
|
-
});
|
|
827
|
-
});
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
784
|
describe('When testing triggerService.curveUsdBorrowRateTrigger', () => {
|
|
831
785
|
describe('encode()', () => {
|
|
832
786
|
const examples = [
|
|
@@ -1157,4 +1111,52 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1157
1111
|
});
|
|
1158
1112
|
});
|
|
1159
1113
|
});
|
|
1114
|
+
describe('When testing triggerService.morphoBluePriceRangeTrigger', () => {
|
|
1115
|
+
describe('encode()', () => {
|
|
1116
|
+
const examples = [
|
|
1117
|
+
[
|
|
1118
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1119
|
+
[web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
|
|
1120
|
+
],
|
|
1121
|
+
[
|
|
1122
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1123
|
+
[web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
|
|
1124
|
+
],
|
|
1125
|
+
];
|
|
1126
|
+
examples.forEach(([expected, actual]) => {
|
|
1127
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1128
|
+
expect(morphoBluePriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1129
|
+
});
|
|
1130
|
+
});
|
|
1131
|
+
});
|
|
1132
|
+
describe('decode()', () => {
|
|
1133
|
+
const examples = [
|
|
1134
|
+
[
|
|
1135
|
+
{
|
|
1136
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1137
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1138
|
+
loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1139
|
+
lowerPrice: '1500',
|
|
1140
|
+
upperPrice: '4000',
|
|
1141
|
+
},
|
|
1142
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1143
|
+
],
|
|
1144
|
+
[
|
|
1145
|
+
{
|
|
1146
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1147
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1148
|
+
loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1149
|
+
lowerPrice: '0',
|
|
1150
|
+
upperPrice: '5000',
|
|
1151
|
+
},
|
|
1152
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8dA6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1153
|
+
],
|
|
1154
|
+
];
|
|
1155
|
+
examples.forEach(([expected, actual]) => {
|
|
1156
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1157
|
+
expect(morphoBluePriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1158
|
+
});
|
|
1159
|
+
});
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1160
1162
|
});
|