@defisaver/automation-sdk 3.1.10 → 3.1.14-spark-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/automation/private/StrategiesAutomation.d.ts +5 -3
- package/cjs/automation/private/StrategiesAutomation.js +27 -10
- package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
- package/cjs/constants/index.d.ts +1 -0
- package/cjs/constants/index.js +352 -11
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/ethereumService.js +21 -14
- package/cjs/services/ethereumService.test.js +3 -0
- package/cjs/services/strategiesService.js +329 -54
- package/cjs/services/strategiesService.test.js +1 -0
- package/cjs/services/strategySubService.d.ts +24 -5
- package/cjs/services/strategySubService.js +116 -10
- package/cjs/services/strategySubService.test.js +1049 -173
- package/cjs/services/subDataService.d.ts +361 -88
- package/cjs/services/subDataService.js +799 -249
- package/cjs/services/subDataService.test.js +1287 -142
- package/cjs/services/triggerService.d.ts +100 -9
- package/cjs/services/triggerService.js +188 -19
- package/cjs/services/triggerService.test.js +437 -46
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +10 -2
- package/cjs/services/utils.test.js +0 -77
- package/cjs/types/enums.d.ts +88 -12
- package/cjs/types/enums.js +78 -2
- package/cjs/types/index.d.ts +59 -1
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -3
- package/esm/automation/private/StrategiesAutomation.js +27 -10
- package/esm/automation/private/StrategiesAutomation.test.js +25 -0
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +351 -10
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/ethereumService.js +21 -14
- package/esm/services/ethereumService.test.js +3 -0
- package/esm/services/strategiesService.js +330 -55
- package/esm/services/strategiesService.test.js +1 -0
- package/esm/services/strategySubService.d.ts +24 -5
- package/esm/services/strategySubService.js +115 -9
- package/esm/services/strategySubService.test.js +1052 -176
- package/esm/services/subDataService.d.ts +361 -88
- package/esm/services/subDataService.js +799 -249
- package/esm/services/subDataService.test.js +1288 -143
- package/esm/services/triggerService.d.ts +100 -9
- package/esm/services/triggerService.js +187 -18
- package/esm/services/triggerService.test.js +438 -47
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +10 -2
- package/esm/services/utils.test.js +1 -52
- package/esm/types/enums.d.ts +88 -12
- package/esm/types/enums.js +78 -2
- package/esm/types/index.d.ts +59 -1
- package/package.json +4 -5
- package/src/automation/private/StrategiesAutomation.test.ts +40 -0
- package/src/automation/private/StrategiesAutomation.ts +38 -15
- package/src/constants/index.ts +353 -11
- package/src/index.ts +4 -2
- package/src/services/ethereumService.test.ts +3 -0
- package/src/services/ethereumService.ts +23 -16
- package/src/services/strategiesService.test.ts +1 -0
- package/src/services/strategiesService.ts +387 -72
- package/src/services/strategySubService.test.ts +1330 -316
- package/src/services/strategySubService.ts +365 -12
- package/src/services/subDataService.test.ts +1413 -170
- package/src/services/subDataService.ts +1148 -431
- package/src/services/triggerService.test.ts +482 -52
- package/src/services/triggerService.ts +272 -27
- package/src/services/utils.test.ts +0 -59
- package/src/services/utils.ts +15 -4
- package/src/types/enums.ts +78 -2
- package/src/types/index.ts +74 -1
- package/umd/index.js +0 -34219
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
chainlinkPriceTrigger,
|
|
16
16
|
compoundV2RatioTrigger,
|
|
17
17
|
compoundV3RatioTrigger,
|
|
18
|
+
compoundV3PriceTrigger,
|
|
18
19
|
curveUsdBorrowRateTrigger,
|
|
19
20
|
curveUsdSoftLiquidationTrigger,
|
|
20
21
|
exchangeOffchainPriceTrigger,
|
|
@@ -22,13 +23,19 @@ import {
|
|
|
22
23
|
liquityDebtInFrontTrigger,
|
|
23
24
|
makerRatioTrigger,
|
|
24
25
|
morphoAaveV2RatioTrigger,
|
|
25
|
-
sparkQuotePriceTrigger,
|
|
26
26
|
sparkRatioTrigger,
|
|
27
27
|
trailingStopTrigger,
|
|
28
28
|
liquityDebtInFrontWithLimitTrigger,
|
|
29
29
|
crvUSDRatioTrigger,
|
|
30
30
|
morphoBlueRatioTrigger,
|
|
31
|
-
crvUsdHealthRatioTrigger,
|
|
31
|
+
crvUsdHealthRatioTrigger, liquityV2DebtInFrontTrigger, liquityV2AdjustTimeTrigger,
|
|
32
|
+
compoundV3PriceRangeTrigger,
|
|
33
|
+
aaveV3QuotePriceRangeTrigger,
|
|
34
|
+
morphoBluePriceRangeTrigger,
|
|
35
|
+
sparkQuotePriceTrigger,
|
|
36
|
+
aaveV4RatioTrigger,
|
|
37
|
+
aaveV4QuotePriceTrigger,
|
|
38
|
+
aaveV4QuotePriceRangeTrigger,
|
|
32
39
|
} from './triggerService';
|
|
33
40
|
|
|
34
41
|
describe('Feature: triggerService.ts', () => {
|
|
@@ -487,6 +494,132 @@ describe('Feature: triggerService.ts', () => {
|
|
|
487
494
|
});
|
|
488
495
|
});
|
|
489
496
|
|
|
497
|
+
describe('When testing triggerService.liquityV2DebtInFrontTrigger', () => {
|
|
498
|
+
describe('encode()', () => {
|
|
499
|
+
const examples: Array<[[string], [market: EthereumAddress, troveId: string, debtInFrontMin: string]]> = [
|
|
500
|
+
[
|
|
501
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000006e0be8c4995af80000'],
|
|
502
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '123456789', '2030']
|
|
503
|
+
],
|
|
504
|
+
[
|
|
505
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1000000000000000000000000000000000000000000004697f83e6356dd440000'],
|
|
506
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '987654321', '333369']
|
|
507
|
+
],
|
|
508
|
+
[
|
|
509
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf00000000000000000000000000000000000000000000000000000000075bd924000000000000000000000000000000000000000000084595161401484a000000'],
|
|
510
|
+
[web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '123459876', '10000000']
|
|
511
|
+
],
|
|
512
|
+
[
|
|
513
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000000000000000002060d4950000000000000000000000000000000000000000000000000000000000989680'],
|
|
514
|
+
[web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '543216789', '0.00000000001']
|
|
515
|
+
],
|
|
516
|
+
[
|
|
517
|
+
['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a000000000000000000000000000000000000000000000000000000003ade5ca20000000000000000000000000000000000000000019d971e4fe8401e74000000'],
|
|
518
|
+
[web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '987651234', '500000000']
|
|
519
|
+
],
|
|
520
|
+
];
|
|
521
|
+
|
|
522
|
+
examples.forEach(([expected, actual]) => {
|
|
523
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
524
|
+
expect(liquityV2DebtInFrontTrigger.encode(...actual)).to.eql(expected);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
describe('decode()', () => {
|
|
530
|
+
const examples: Array<[{ market: EthereumAddress, troveId: string, debtInFrontMin: string }, TriggerData]> = [
|
|
531
|
+
[
|
|
532
|
+
{
|
|
533
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
|
|
534
|
+
troveId: '123456789',
|
|
535
|
+
debtInFrontMin: '2030',
|
|
536
|
+
},
|
|
537
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000006e0be8c4995af80000'],
|
|
538
|
+
],
|
|
539
|
+
[
|
|
540
|
+
{
|
|
541
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
|
|
542
|
+
troveId: '987654321',
|
|
543
|
+
debtInFrontMin: '333369',
|
|
544
|
+
},
|
|
545
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1000000000000000000000000000000000000000000004697f83e6356dd440000'],
|
|
546
|
+
], [
|
|
547
|
+
{
|
|
548
|
+
market: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
|
|
549
|
+
troveId: '123459876',
|
|
550
|
+
debtInFrontMin: '10000000',
|
|
551
|
+
},
|
|
552
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf00000000000000000000000000000000000000000000000000000000075bd924000000000000000000000000000000000000000000084595161401484a000000'],
|
|
553
|
+
], [
|
|
554
|
+
{
|
|
555
|
+
market: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
|
|
556
|
+
troveId: '543216789',
|
|
557
|
+
debtInFrontMin: '0.00000000001',
|
|
558
|
+
},
|
|
559
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000000000000000002060d4950000000000000000000000000000000000000000000000000000000000989680'],
|
|
560
|
+
], [
|
|
561
|
+
{
|
|
562
|
+
market: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
|
|
563
|
+
troveId: '987651234',
|
|
564
|
+
debtInFrontMin: '500000000',
|
|
565
|
+
},
|
|
566
|
+
['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a000000000000000000000000000000000000000000000000000000003ade5ca20000000000000000000000000000000000000000019d971e4fe8401e74000000'],
|
|
567
|
+
]
|
|
568
|
+
];
|
|
569
|
+
|
|
570
|
+
examples.forEach(([expected, actual]) => {
|
|
571
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
572
|
+
expect(liquityV2DebtInFrontTrigger.decode(actual)).to.eql(expected);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
describe('When testing triggerService.liquityV2AdjustTimeTrigger', () => {
|
|
579
|
+
describe('encode()', () => {
|
|
580
|
+
const examples: Array<[[string], [market: EthereumAddress, troveId: string]]> = [
|
|
581
|
+
[
|
|
582
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd15'],
|
|
583
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '123456789']
|
|
584
|
+
],
|
|
585
|
+
[
|
|
586
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1'],
|
|
587
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '987654321']
|
|
588
|
+
],
|
|
589
|
+
];
|
|
590
|
+
|
|
591
|
+
examples.forEach(([expected, actual]) => {
|
|
592
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
593
|
+
expect(liquityV2AdjustTimeTrigger.encode(...actual)).to.eql(expected);
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
describe('decode()', () => {
|
|
599
|
+
const examples: Array<[{ market: EthereumAddress, troveId: string }, TriggerData]> = [
|
|
600
|
+
[
|
|
601
|
+
{
|
|
602
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
|
|
603
|
+
troveId: '123456789',
|
|
604
|
+
},
|
|
605
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd15'],
|
|
606
|
+
],
|
|
607
|
+
[
|
|
608
|
+
{
|
|
609
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
|
|
610
|
+
troveId: '987654321',
|
|
611
|
+
},
|
|
612
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1'],
|
|
613
|
+
]
|
|
614
|
+
];
|
|
615
|
+
|
|
616
|
+
examples.forEach(([expected, actual]) => {
|
|
617
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
618
|
+
expect(liquityV2AdjustTimeTrigger.decode(actual)).to.eql(expected);
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
});
|
|
490
623
|
describe('When testing triggerService.aaveV2RatioTrigger', () => {
|
|
491
624
|
describe('encode()', () => {
|
|
492
625
|
const examples: Array<[[string], [owner: EthereumAddress, market: EthereumAddress, ratioPercentage: number, ratioState: RatioState]]> = [
|
|
@@ -750,56 +883,6 @@ describe('Feature: triggerService.ts', () => {
|
|
|
750
883
|
});
|
|
751
884
|
});
|
|
752
885
|
|
|
753
|
-
describe('When testing triggerService.sparkQuotePriceTrigger', () => {
|
|
754
|
-
describe('encode()', () => {
|
|
755
|
-
const examples: Array<[[string], [baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, ratioState: RatioState]]> = [
|
|
756
|
-
[
|
|
757
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
|
|
758
|
-
[getAssetInfo('DAI', ChainId.Ethereum).address, getAssetInfo('wstETH', ChainId.Ethereum).address, 0.0004321, RatioState.UNDER]
|
|
759
|
-
],
|
|
760
|
-
[
|
|
761
|
-
['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
|
|
762
|
-
[getAssetInfo('WBTC', ChainId.Arbitrum).address, getAssetInfo('USDC', ChainId.Arbitrum).address, 0.00100023, RatioState.OVER]
|
|
763
|
-
],
|
|
764
|
-
];
|
|
765
|
-
|
|
766
|
-
examples.forEach(([expected, actual]) => {
|
|
767
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
768
|
-
expect(sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
|
|
769
|
-
});
|
|
770
|
-
});
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
describe('decode()', () => {
|
|
774
|
-
const examples: Array<[{ baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: string, ratioState: RatioState }, TriggerData]> = [
|
|
775
|
-
[
|
|
776
|
-
{
|
|
777
|
-
baseTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
778
|
-
quoteTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Ethereum).address),
|
|
779
|
-
price: '0.0004321',
|
|
780
|
-
ratioState: RatioState.UNDER,
|
|
781
|
-
},
|
|
782
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
|
|
783
|
-
],
|
|
784
|
-
[
|
|
785
|
-
{
|
|
786
|
-
baseTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
|
|
787
|
-
quoteTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
788
|
-
price: '0.00100023',
|
|
789
|
-
ratioState: RatioState.OVER,
|
|
790
|
-
},
|
|
791
|
-
['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
|
|
792
|
-
]
|
|
793
|
-
];
|
|
794
|
-
|
|
795
|
-
examples.forEach(([expected, actual]) => {
|
|
796
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
797
|
-
expect(sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
|
|
798
|
-
});
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
|
-
|
|
803
886
|
describe('When testing triggerService.curveUsdBorrowRateTrigger', () => {
|
|
804
887
|
describe('encode()', () => {
|
|
805
888
|
const examples: Array<[[string], [market: EthereumAddress, targetRate: string, rateState: RatioState]]> = [
|
|
@@ -1001,4 +1084,351 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1001
1084
|
});
|
|
1002
1085
|
});
|
|
1003
1086
|
});
|
|
1087
|
+
|
|
1088
|
+
describe('When testing triggerService.compoundV3PriceTrigger', () => {
|
|
1089
|
+
describe('encode()', () => {
|
|
1090
|
+
const examples: Array<[[string], [market: EthereumAddress, collToken: EthereumAddress, user: EthereumAddress, price: number, priceState: RatioState]]> = [
|
|
1091
|
+
[
|
|
1092
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f07775030000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1093
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'), 2000, RatioState.UNDER]
|
|
1094
|
+
],
|
|
1095
|
+
[
|
|
1096
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f077750300000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1097
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'), 3000, RatioState.OVER]
|
|
1098
|
+
],
|
|
1099
|
+
];
|
|
1100
|
+
|
|
1101
|
+
examples.forEach(([expected, actual]) => {
|
|
1102
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1103
|
+
expect(compoundV3PriceTrigger.encode(...actual)).to.eql(expected);
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
describe('decode()', () => {
|
|
1109
|
+
const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, user: EthereumAddress, price: string, priceState: RatioState }, TriggerData]> = [
|
|
1110
|
+
[
|
|
1111
|
+
{
|
|
1112
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1113
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1114
|
+
user: web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'),
|
|
1115
|
+
price: '2000',
|
|
1116
|
+
priceState: RatioState.UNDER,
|
|
1117
|
+
},
|
|
1118
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f07775030000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1119
|
+
],
|
|
1120
|
+
[
|
|
1121
|
+
{
|
|
1122
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1123
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1124
|
+
user: web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'),
|
|
1125
|
+
price: '3000',
|
|
1126
|
+
priceState: RatioState.OVER,
|
|
1127
|
+
},
|
|
1128
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f077750300000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1129
|
+
],
|
|
1130
|
+
];
|
|
1131
|
+
|
|
1132
|
+
examples.forEach(([expected, actual]) => {
|
|
1133
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1134
|
+
expect(compoundV3PriceTrigger.decode(actual)).to.eql(expected);
|
|
1135
|
+
});
|
|
1136
|
+
});
|
|
1137
|
+
});
|
|
1138
|
+
});
|
|
1139
|
+
|
|
1140
|
+
describe('When testing triggerService.compoundV3PriceRangeTrigger', () => {
|
|
1141
|
+
describe('encode()', () => {
|
|
1142
|
+
const examples: Array<[[string], [market: EthereumAddress, collToken: EthereumAddress, lowerPrice: number, upperPrice: number]]> = [
|
|
1143
|
+
[
|
|
1144
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1145
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
|
|
1146
|
+
],
|
|
1147
|
+
[
|
|
1148
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1149
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
|
|
1150
|
+
],
|
|
1151
|
+
];
|
|
1152
|
+
|
|
1153
|
+
examples.forEach(([expected, actual]) => {
|
|
1154
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1155
|
+
expect(compoundV3PriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1156
|
+
});
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
describe('decode()', () => {
|
|
1161
|
+
const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, lowerPrice: string, upperPrice: string }, TriggerData]> = [
|
|
1162
|
+
[
|
|
1163
|
+
{
|
|
1164
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1165
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1166
|
+
lowerPrice: '1500',
|
|
1167
|
+
upperPrice: '4000',
|
|
1168
|
+
},
|
|
1169
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1170
|
+
],
|
|
1171
|
+
[
|
|
1172
|
+
{
|
|
1173
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1174
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1175
|
+
lowerPrice: '0',
|
|
1176
|
+
upperPrice: '5000',
|
|
1177
|
+
},
|
|
1178
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1179
|
+
],
|
|
1180
|
+
];
|
|
1181
|
+
|
|
1182
|
+
examples.forEach(([expected, actual]) => {
|
|
1183
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1184
|
+
expect(compoundV3PriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1185
|
+
});
|
|
1186
|
+
});
|
|
1187
|
+
});
|
|
1188
|
+
});
|
|
1189
|
+
describe('When testing triggerService.aaveV3PriceRangeTrigger', () => {
|
|
1190
|
+
describe('encode()', () => {
|
|
1191
|
+
const examples: Array<[[string], [collToken: EthereumAddress, debtToken: EthereumAddress, lowerPrice: number, upperPrice: number]]> = [
|
|
1192
|
+
[
|
|
1193
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1194
|
+
[web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 1500, 4000]
|
|
1195
|
+
],
|
|
1196
|
+
[
|
|
1197
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1198
|
+
[web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 0, 5000]
|
|
1199
|
+
],
|
|
1200
|
+
];
|
|
1201
|
+
|
|
1202
|
+
examples.forEach(([expected, actual]) => {
|
|
1203
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1204
|
+
expect(aaveV3QuotePriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1205
|
+
});
|
|
1206
|
+
});
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
describe('decode()', () => {
|
|
1210
|
+
const examples: Array<[{ collToken: EthereumAddress, debtToken: EthereumAddress, lowerPrice: string, upperPrice: string }, TriggerData]> = [
|
|
1211
|
+
[
|
|
1212
|
+
{
|
|
1213
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1214
|
+
debtToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1215
|
+
lowerPrice: '1500',
|
|
1216
|
+
upperPrice: '4000',
|
|
1217
|
+
},
|
|
1218
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1219
|
+
],
|
|
1220
|
+
[
|
|
1221
|
+
{
|
|
1222
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1223
|
+
debtToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1224
|
+
lowerPrice: '0',
|
|
1225
|
+
upperPrice: '5000',
|
|
1226
|
+
},
|
|
1227
|
+
['000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1228
|
+
],
|
|
1229
|
+
];
|
|
1230
|
+
|
|
1231
|
+
examples.forEach(([expected, actual]) => {
|
|
1232
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1233
|
+
expect(aaveV3QuotePriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1234
|
+
});
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
describe('When testing triggerService.morphoBluePriceRangeTrigger', () => {
|
|
1240
|
+
describe('encode()', () => {
|
|
1241
|
+
const examples: Array<[[string], [oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, lowerPrice: number, upperPrice: number]]> = [
|
|
1242
|
+
[
|
|
1243
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1244
|
+
[web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
|
|
1245
|
+
],
|
|
1246
|
+
[
|
|
1247
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1248
|
+
[web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
|
|
1249
|
+
],
|
|
1250
|
+
];
|
|
1251
|
+
|
|
1252
|
+
examples.forEach(([expected, actual]) => {
|
|
1253
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1254
|
+
expect(morphoBluePriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1255
|
+
});
|
|
1256
|
+
});
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
describe('decode()', () => {
|
|
1260
|
+
const examples: Array<[{ oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, lowerPrice: string, upperPrice: string }, TriggerData]> = [
|
|
1261
|
+
[
|
|
1262
|
+
{
|
|
1263
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1264
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1265
|
+
loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1266
|
+
lowerPrice: '1500',
|
|
1267
|
+
upperPrice: '4000',
|
|
1268
|
+
},
|
|
1269
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1270
|
+
],
|
|
1271
|
+
[
|
|
1272
|
+
{
|
|
1273
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1274
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1275
|
+
loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1276
|
+
lowerPrice: '0',
|
|
1277
|
+
upperPrice: '5000',
|
|
1278
|
+
},
|
|
1279
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8dA6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1280
|
+
],
|
|
1281
|
+
];
|
|
1282
|
+
|
|
1283
|
+
examples.forEach(([expected, actual]) => {
|
|
1284
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1285
|
+
expect(morphoBluePriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1286
|
+
});
|
|
1287
|
+
});
|
|
1288
|
+
});
|
|
1289
|
+
});
|
|
1290
|
+
describe('When testing triggerService.aaveV4RatioTrigger', () => {
|
|
1291
|
+
describe('encode()', () => {
|
|
1292
|
+
const examples: Array<[[string], [owner: EthereumAddress, spoke: EthereumAddress, ratioPercentage: number, ratioState: RatioState]]> = [
|
|
1293
|
+
[
|
|
1294
|
+
['0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1295
|
+
[web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), 120, RatioState.UNDER]
|
|
1296
|
+
],
|
|
1297
|
+
];
|
|
1298
|
+
|
|
1299
|
+
examples.forEach(([expected, actual]) => {
|
|
1300
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1301
|
+
expect(aaveV4RatioTrigger.encode(...actual)).to.eql(expected);
|
|
1302
|
+
});
|
|
1303
|
+
});
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
describe('decode()', () => {
|
|
1307
|
+
const examples: Array<[{ owner: EthereumAddress, spoke: EthereumAddress, ratio: number, ratioState: RatioState }, TriggerData]> = [
|
|
1308
|
+
[
|
|
1309
|
+
{ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), ratio: 120, ratioState: RatioState.UNDER },
|
|
1310
|
+
['0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1311
|
+
],
|
|
1312
|
+
];
|
|
1313
|
+
|
|
1314
|
+
examples.forEach(([expected, actual]) => {
|
|
1315
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1316
|
+
expect(aaveV4RatioTrigger.decode(actual)).to.eql(expected);
|
|
1317
|
+
});
|
|
1318
|
+
});
|
|
1319
|
+
});
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1322
|
+
describe('When testing triggerService.aaveV4QuotePriceTrigger', () => {
|
|
1323
|
+
describe('encode()', () => {
|
|
1324
|
+
const examples: Array<[[string], [spoke: EthereumAddress, baseTokenId: number, quoteTokenId: number, price: string, ratioState: RatioState]]> = [
|
|
1325
|
+
[
|
|
1326
|
+
['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000005150ae84a8cdf000000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1327
|
+
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), 10, 20, '1500', RatioState.OVER]
|
|
1328
|
+
],
|
|
1329
|
+
];
|
|
1330
|
+
|
|
1331
|
+
examples.forEach(([expected, actual]) => {
|
|
1332
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1333
|
+
expect(aaveV4QuotePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1336
|
+
});
|
|
1337
|
+
|
|
1338
|
+
describe('decode()', () => {
|
|
1339
|
+
const examples: Array<[{ spoke: EthereumAddress, baseTokenId: number, quoteTokenId: number, price: string, ratioState: RatioState }, TriggerData]> = [
|
|
1340
|
+
[
|
|
1341
|
+
{ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), baseTokenId: 10, quoteTokenId: 20, price: '1500', ratioState: RatioState.OVER },
|
|
1342
|
+
['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000005150ae84a8cdf000000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1343
|
+
],
|
|
1344
|
+
];
|
|
1345
|
+
|
|
1346
|
+
examples.forEach(([expected, actual]) => {
|
|
1347
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1348
|
+
expect(aaveV4QuotePriceTrigger.decode(actual)).to.eql(expected);
|
|
1349
|
+
});
|
|
1350
|
+
});
|
|
1351
|
+
});
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
describe('When testing triggerService.aaveV4QuotePriceRangeTrigger', () => {
|
|
1355
|
+
describe('encode()', () => {
|
|
1356
|
+
const examples: Array<[[string], [spoke: EthereumAddress, baseTokenId: number, quoteTokenId: number, lowerPrice: string, upperPrice: string]]> = [
|
|
1357
|
+
[
|
|
1358
|
+
['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000004be4e7267b6ae00000000000000000000000000000000000000000000000000056bc75e2d631000000'],
|
|
1359
|
+
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), 10, 20, '1400', '1600']
|
|
1360
|
+
],
|
|
1361
|
+
];
|
|
1362
|
+
|
|
1363
|
+
examples.forEach(([expected, actual]) => {
|
|
1364
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1365
|
+
expect(aaveV4QuotePriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1366
|
+
});
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
|
|
1370
|
+
describe('decode()', () => {
|
|
1371
|
+
const examples: Array<[{ spoke: EthereumAddress, baseTokenId: number, quoteTokenId: number, lowerPrice: string, upperPrice: string }, TriggerData]> = [
|
|
1372
|
+
[
|
|
1373
|
+
{ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), baseTokenId: 10, quoteTokenId: 20, lowerPrice: '1400', upperPrice: '1600' },
|
|
1374
|
+
['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000004be4e7267b6ae00000000000000000000000000000000000000000000000000056bc75e2d631000000'],
|
|
1375
|
+
],
|
|
1376
|
+
];
|
|
1377
|
+
|
|
1378
|
+
examples.forEach(([expected, actual]) => {
|
|
1379
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1380
|
+
expect(aaveV4QuotePriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
1383
|
+
});
|
|
1384
|
+
});
|
|
1385
|
+
describe('When testing triggerService.sparkQuotePriceTrigger', () => {
|
|
1386
|
+
describe('encode()', () => {
|
|
1387
|
+
const examples: Array<[[string], [baseTokenAddr: EthereumAddress, quoteTokenAddr: EthereumAddress, price: number, ratioState: RatioState]]> = [
|
|
1388
|
+
[
|
|
1389
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1390
|
+
[web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address), web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address), 2500, RatioState.UNDER]
|
|
1391
|
+
],
|
|
1392
|
+
[
|
|
1393
|
+
['0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000c1c0000000000000000000000000000000000000000000000000000000000000000'],
|
|
1394
|
+
[web3Utils.toChecksumAddress(getAssetInfo('USDT', ChainId.Ethereum).address), web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address), 0.000031, RatioState.OVER]
|
|
1395
|
+
],
|
|
1396
|
+
];
|
|
1397
|
+
|
|
1398
|
+
examples.forEach(([expected, actual]) => {
|
|
1399
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1400
|
+
expect(sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1401
|
+
});
|
|
1402
|
+
});
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
describe('decode()', () => {
|
|
1406
|
+
const examples: Array<[{ baseTokenAddr: EthereumAddress, quoteTokenAddr: EthereumAddress, price: string, ratioState: RatioState }, TriggerData]> = [
|
|
1407
|
+
[
|
|
1408
|
+
{
|
|
1409
|
+
baseTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1410
|
+
quoteTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1411
|
+
price: '2500',
|
|
1412
|
+
ratioState: RatioState.UNDER
|
|
1413
|
+
},
|
|
1414
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001']
|
|
1415
|
+
],
|
|
1416
|
+
[
|
|
1417
|
+
{
|
|
1418
|
+
baseTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('USDT', ChainId.Ethereum).address),
|
|
1419
|
+
quoteTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1420
|
+
price: '0.000031',
|
|
1421
|
+
ratioState: RatioState.OVER
|
|
1422
|
+
},
|
|
1423
|
+
['0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000c1c0000000000000000000000000000000000000000000000000000000000000000']
|
|
1424
|
+
]
|
|
1425
|
+
];
|
|
1426
|
+
|
|
1427
|
+
examples.forEach(([expected, actual]) => {
|
|
1428
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1429
|
+
expect(sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
|
|
1430
|
+
});
|
|
1431
|
+
});
|
|
1432
|
+
});
|
|
1433
|
+
});
|
|
1004
1434
|
});
|