@defisaver/automation-sdk 3.2.3 → 3.2.4-dev-1
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 +90 -0
- package/cjs/services/strategiesService.js +48 -1
- package/cjs/services/strategySubService.d.ts +2 -0
- package/cjs/services/strategySubService.js +13 -0
- package/cjs/services/strategySubService.test.js +108 -0
- package/cjs/services/subDataService.d.ts +18 -0
- package/cjs/services/subDataService.js +48 -1
- package/cjs/services/subDataService.test.js +124 -48
- package/cjs/services/triggerService.d.ts +33 -0
- package/cjs/services/triggerService.js +62 -1
- package/cjs/services/triggerService.test.js +211 -0
- package/cjs/types/enums.d.ts +28 -5
- package/cjs/types/enums.js +23 -0
- package/cjs/types/index.d.ts +17 -1
- package/esm/constants/index.js +90 -0
- package/esm/services/strategiesService.js +48 -1
- package/esm/services/strategySubService.d.ts +2 -0
- package/esm/services/strategySubService.js +13 -0
- package/esm/services/strategySubService.test.js +109 -1
- package/esm/services/subDataService.d.ts +18 -0
- package/esm/services/subDataService.js +47 -0
- package/esm/services/subDataService.test.js +124 -48
- package/esm/services/triggerService.d.ts +33 -0
- package/esm/services/triggerService.js +61 -0
- package/esm/services/triggerService.test.js +212 -1
- package/esm/types/enums.d.ts +28 -5
- package/esm/types/enums.js +23 -0
- package/esm/types/index.d.ts +17 -1
- package/package.json +2 -2
- package/src/constants/index.ts +90 -1
- package/src/services/strategiesService.ts +62 -1
- package/src/services/strategySubService.test.ts +115 -1
- package/src/services/strategySubService.ts +33 -0
- package/src/services/subDataService.test.ts +128 -73
- package/src/services/subDataService.ts +73 -0
- package/src/services/triggerService.test.ts +229 -1
- package/src/services/triggerService.ts +83 -0
- package/src/types/enums.ts +23 -0
- package/src/types/index.ts +22 -1
|
@@ -448,6 +448,125 @@ describe('Feature: triggerService.ts', () => {
|
|
|
448
448
|
});
|
|
449
449
|
});
|
|
450
450
|
});
|
|
451
|
+
describe('When testing triggerService.liquityV2DebtInFrontTrigger', () => {
|
|
452
|
+
describe('encode()', () => {
|
|
453
|
+
const examples = [
|
|
454
|
+
[
|
|
455
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000006e0be8c4995af80000'],
|
|
456
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '123456789', '2030']
|
|
457
|
+
],
|
|
458
|
+
[
|
|
459
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1000000000000000000000000000000000000000000004697f83e6356dd440000'],
|
|
460
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '987654321', '333369']
|
|
461
|
+
],
|
|
462
|
+
[
|
|
463
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf00000000000000000000000000000000000000000000000000000000075bd924000000000000000000000000000000000000000000084595161401484a000000'],
|
|
464
|
+
[web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '123459876', '10000000']
|
|
465
|
+
],
|
|
466
|
+
[
|
|
467
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000000000000000002060d4950000000000000000000000000000000000000000000000000000000000989680'],
|
|
468
|
+
[web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '543216789', '0.00000000001']
|
|
469
|
+
],
|
|
470
|
+
[
|
|
471
|
+
['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a000000000000000000000000000000000000000000000000000000003ade5ca20000000000000000000000000000000000000000019d971e4fe8401e74000000'],
|
|
472
|
+
[web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '987651234', '500000000']
|
|
473
|
+
],
|
|
474
|
+
];
|
|
475
|
+
examples.forEach(([expected, actual]) => {
|
|
476
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
477
|
+
(0, chai_1.expect)(triggerService_1.liquityV2DebtInFrontTrigger.encode(...actual)).to.eql(expected);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
describe('decode()', () => {
|
|
482
|
+
const examples = [
|
|
483
|
+
[
|
|
484
|
+
{
|
|
485
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
|
|
486
|
+
troveId: '123456789',
|
|
487
|
+
debtInFrontMin: '2030',
|
|
488
|
+
},
|
|
489
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000006e0be8c4995af80000'],
|
|
490
|
+
],
|
|
491
|
+
[
|
|
492
|
+
{
|
|
493
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
|
|
494
|
+
troveId: '987654321',
|
|
495
|
+
debtInFrontMin: '333369',
|
|
496
|
+
},
|
|
497
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1000000000000000000000000000000000000000000004697f83e6356dd440000'],
|
|
498
|
+
], [
|
|
499
|
+
{
|
|
500
|
+
market: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
|
|
501
|
+
troveId: '123459876',
|
|
502
|
+
debtInFrontMin: '10000000',
|
|
503
|
+
},
|
|
504
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf00000000000000000000000000000000000000000000000000000000075bd924000000000000000000000000000000000000000000084595161401484a000000'],
|
|
505
|
+
], [
|
|
506
|
+
{
|
|
507
|
+
market: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
|
|
508
|
+
troveId: '543216789',
|
|
509
|
+
debtInFrontMin: '0.00000000001',
|
|
510
|
+
},
|
|
511
|
+
['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000000000000000002060d4950000000000000000000000000000000000000000000000000000000000989680'],
|
|
512
|
+
], [
|
|
513
|
+
{
|
|
514
|
+
market: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
|
|
515
|
+
troveId: '987651234',
|
|
516
|
+
debtInFrontMin: '500000000',
|
|
517
|
+
},
|
|
518
|
+
['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a000000000000000000000000000000000000000000000000000000003ade5ca20000000000000000000000000000000000000000019d971e4fe8401e74000000'],
|
|
519
|
+
]
|
|
520
|
+
];
|
|
521
|
+
examples.forEach(([expected, actual]) => {
|
|
522
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
523
|
+
(0, chai_1.expect)(triggerService_1.liquityV2DebtInFrontTrigger.decode(actual)).to.eql(expected);
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
describe('When testing triggerService.liquityV2AdjustTimeTrigger', () => {
|
|
529
|
+
describe('encode()', () => {
|
|
530
|
+
const examples = [
|
|
531
|
+
[
|
|
532
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd15'],
|
|
533
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '123456789']
|
|
534
|
+
],
|
|
535
|
+
[
|
|
536
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1'],
|
|
537
|
+
[web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '987654321']
|
|
538
|
+
],
|
|
539
|
+
];
|
|
540
|
+
examples.forEach(([expected, actual]) => {
|
|
541
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
542
|
+
(0, chai_1.expect)(triggerService_1.liquityV2AdjustTimeTrigger.encode(...actual)).to.eql(expected);
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
describe('decode()', () => {
|
|
547
|
+
const examples = [
|
|
548
|
+
[
|
|
549
|
+
{
|
|
550
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
|
|
551
|
+
troveId: '123456789',
|
|
552
|
+
},
|
|
553
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd15'],
|
|
554
|
+
],
|
|
555
|
+
[
|
|
556
|
+
{
|
|
557
|
+
market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
|
|
558
|
+
troveId: '987654321',
|
|
559
|
+
},
|
|
560
|
+
['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1'],
|
|
561
|
+
]
|
|
562
|
+
];
|
|
563
|
+
examples.forEach(([expected, actual]) => {
|
|
564
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
565
|
+
(0, chai_1.expect)(triggerService_1.liquityV2AdjustTimeTrigger.decode(actual)).to.eql(expected);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
});
|
|
451
570
|
describe('When testing triggerService.aaveV2RatioTrigger', () => {
|
|
452
571
|
describe('encode()', () => {
|
|
453
572
|
const examples = [
|
|
@@ -923,4 +1042,96 @@ describe('Feature: triggerService.ts', () => {
|
|
|
923
1042
|
});
|
|
924
1043
|
});
|
|
925
1044
|
});
|
|
1045
|
+
describe('When testing triggerService.compoundV3PriceTrigger', () => {
|
|
1046
|
+
describe('encode()', () => {
|
|
1047
|
+
const examples = [
|
|
1048
|
+
[
|
|
1049
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1050
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 2000, enums_1.RatioState.UNDER]
|
|
1051
|
+
],
|
|
1052
|
+
[
|
|
1053
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1054
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 3000, enums_1.RatioState.OVER]
|
|
1055
|
+
],
|
|
1056
|
+
];
|
|
1057
|
+
examples.forEach(([expected, actual]) => {
|
|
1058
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1059
|
+
(0, chai_1.expect)(triggerService_1.compoundV3PriceTrigger.encode(...actual)).to.eql(expected);
|
|
1060
|
+
});
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
describe('decode()', () => {
|
|
1064
|
+
const examples = [
|
|
1065
|
+
[
|
|
1066
|
+
{
|
|
1067
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1068
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1069
|
+
price: '2000',
|
|
1070
|
+
priceState: enums_1.RatioState.UNDER,
|
|
1071
|
+
},
|
|
1072
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1073
|
+
],
|
|
1074
|
+
[
|
|
1075
|
+
{
|
|
1076
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1077
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1078
|
+
price: '3000',
|
|
1079
|
+
priceState: enums_1.RatioState.OVER,
|
|
1080
|
+
},
|
|
1081
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1082
|
+
],
|
|
1083
|
+
];
|
|
1084
|
+
examples.forEach(([expected, actual]) => {
|
|
1085
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1086
|
+
(0, chai_1.expect)(triggerService_1.compoundV3PriceTrigger.decode(actual)).to.eql(expected);
|
|
1087
|
+
});
|
|
1088
|
+
});
|
|
1089
|
+
});
|
|
1090
|
+
});
|
|
1091
|
+
describe('When testing triggerService.compoundV3PriceRangeTrigger', () => {
|
|
1092
|
+
describe('encode()', () => {
|
|
1093
|
+
const examples = [
|
|
1094
|
+
[
|
|
1095
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1096
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
|
|
1097
|
+
],
|
|
1098
|
+
[
|
|
1099
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1100
|
+
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
|
|
1101
|
+
],
|
|
1102
|
+
];
|
|
1103
|
+
examples.forEach(([expected, actual]) => {
|
|
1104
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1105
|
+
(0, chai_1.expect)(triggerService_1.compoundV3PriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1106
|
+
});
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
describe('decode()', () => {
|
|
1110
|
+
const examples = [
|
|
1111
|
+
[
|
|
1112
|
+
{
|
|
1113
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1114
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1115
|
+
lowerPrice: '1500',
|
|
1116
|
+
upperPrice: '4000',
|
|
1117
|
+
},
|
|
1118
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1119
|
+
],
|
|
1120
|
+
[
|
|
1121
|
+
{
|
|
1122
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1123
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1124
|
+
lowerPrice: '0',
|
|
1125
|
+
upperPrice: '5000',
|
|
1126
|
+
},
|
|
1127
|
+
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1128
|
+
],
|
|
1129
|
+
];
|
|
1130
|
+
examples.forEach(([expected, actual]) => {
|
|
1131
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1132
|
+
(0, chai_1.expect)(triggerService_1.compoundV3PriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
});
|
|
926
1137
|
});
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export declare namespace Strategies {
|
|
|
114
114
|
CloseOnPriceToDebt = "close-on-price-to-debt",
|
|
115
115
|
CloseOnPriceToColl = "close-on-price-to-collateral",
|
|
116
116
|
CloseOnPrice = "close-on-price",
|
|
117
|
+
EoaCloseOnPrice = "eoa-close-on-price",
|
|
117
118
|
TrailingStopToColl = "trailing-stop-to-collateral",
|
|
118
119
|
TrailingStopToDebt = "trailing-stop-to-debt",
|
|
119
120
|
Rebond = "rebond",
|
|
@@ -125,7 +126,9 @@ export declare namespace Strategies {
|
|
|
125
126
|
OpenOrderFromCollateral = "open-order-from-collateral",
|
|
126
127
|
OpenOrderFromDebt = "open-order-from-debt",
|
|
127
128
|
BoostOnPrice = "boost-on-price",
|
|
128
|
-
RepayOnPrice = "repay-on-price"
|
|
129
|
+
RepayOnPrice = "repay-on-price",
|
|
130
|
+
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
131
|
+
EoaRepayOnPrice = "eoa-repay-on-price"
|
|
129
132
|
}
|
|
130
133
|
enum IdOverrides {
|
|
131
134
|
TakeProfit = "take-profit",
|
|
@@ -134,7 +137,9 @@ export declare namespace Strategies {
|
|
|
134
137
|
StopLossWithGasPrice = "stop-loss-with-gas-price",
|
|
135
138
|
TrailingStop = "trailing-stop",
|
|
136
139
|
LeverageManagement = "leverage-management",
|
|
137
|
-
EoaLeverageManagement = "leverage-management-eoa"
|
|
140
|
+
EoaLeverageManagement = "leverage-management-eoa",
|
|
141
|
+
LeverageManagementOnPrice = "leverage-management-on-price",
|
|
142
|
+
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
export declare namespace Bundles {
|
|
@@ -186,7 +191,13 @@ export declare namespace Bundles {
|
|
|
186
191
|
LIQUITY_V2_REPAY_ON_PRICE = 42,
|
|
187
192
|
LIQUITY_V2_BOOST_ON_PRICE = 43,
|
|
188
193
|
FLUID_T1_REPAY = 44,
|
|
189
|
-
FLUID_T1_BOOST = 45
|
|
194
|
+
FLUID_T1_BOOST = 45,
|
|
195
|
+
COMP_V3_SW_REPAY_ON_PRICE = 46,
|
|
196
|
+
COMP_V3_SW_BOOST_ON_PRICE = 47,
|
|
197
|
+
COMP_V3_SW_CLOSE = 48,
|
|
198
|
+
COMP_V3_EOA_REPAY_ON_PRICE = 49,
|
|
199
|
+
COMP_V3_EOA_BOOST_ON_PRICE = 50,
|
|
200
|
+
COMP_V3_EOA_CLOSE = 51
|
|
190
201
|
}
|
|
191
202
|
enum OptimismIds {
|
|
192
203
|
AAVE_V3_REPAY = 0,
|
|
@@ -209,7 +220,13 @@ export declare namespace Bundles {
|
|
|
209
220
|
AAVE_V3_REPAY_ON_PRICE = 11,
|
|
210
221
|
MORPHO_BLUE_BOOST_ON_PRICE = 12,
|
|
211
222
|
FLUID_T1_REPAY = 13,
|
|
212
|
-
FLUID_T1_BOOST = 14
|
|
223
|
+
FLUID_T1_BOOST = 14,
|
|
224
|
+
COMP_V3_SW_REPAY_ON_PRICE = 15,
|
|
225
|
+
COMP_V3_SW_BOOST_ON_PRICE = 16,
|
|
226
|
+
COMP_V3_SW_CLOSE = 17,
|
|
227
|
+
COMP_V3_EOA_REPAY_ON_PRICE = 18,
|
|
228
|
+
COMP_V3_EOA_BOOST_ON_PRICE = 19,
|
|
229
|
+
COMP_V3_EOA_CLOSE = 20
|
|
213
230
|
}
|
|
214
231
|
enum ArbitrumIds {
|
|
215
232
|
AAVE_V3_REPAY = 0,
|
|
@@ -221,6 +238,12 @@ export declare namespace Bundles {
|
|
|
221
238
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6,
|
|
222
239
|
AAVE_V3_REPAY_ON_PRICE = 7,
|
|
223
240
|
FLUID_T1_REPAY = 8,
|
|
224
|
-
FLUID_T1_BOOST = 9
|
|
241
|
+
FLUID_T1_BOOST = 9,
|
|
242
|
+
COMP_V3_SW_REPAY_ON_PRICE = 10,
|
|
243
|
+
COMP_V3_SW_BOOST_ON_PRICE = 11,
|
|
244
|
+
COMP_V3_SW_CLOSE = 12,
|
|
245
|
+
COMP_V3_EOA_REPAY_ON_PRICE = 13,
|
|
246
|
+
COMP_V3_EOA_BOOST_ON_PRICE = 14,
|
|
247
|
+
COMP_V3_EOA_CLOSE = 15
|
|
225
248
|
}
|
|
226
249
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -134,6 +134,7 @@ var Strategies;
|
|
|
134
134
|
Identifiers["CloseOnPriceToDebt"] = "close-on-price-to-debt";
|
|
135
135
|
Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
|
|
136
136
|
Identifiers["CloseOnPrice"] = "close-on-price";
|
|
137
|
+
Identifiers["EoaCloseOnPrice"] = "eoa-close-on-price";
|
|
137
138
|
Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
|
|
138
139
|
Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
|
|
139
140
|
Identifiers["Rebond"] = "rebond";
|
|
@@ -146,6 +147,8 @@ var Strategies;
|
|
|
146
147
|
Identifiers["OpenOrderFromDebt"] = "open-order-from-debt";
|
|
147
148
|
Identifiers["BoostOnPrice"] = "boost-on-price";
|
|
148
149
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
150
|
+
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
151
|
+
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
149
152
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
150
153
|
let IdOverrides;
|
|
151
154
|
(function (IdOverrides) {
|
|
@@ -156,6 +159,8 @@ var Strategies;
|
|
|
156
159
|
IdOverrides["TrailingStop"] = "trailing-stop";
|
|
157
160
|
IdOverrides["LeverageManagement"] = "leverage-management";
|
|
158
161
|
IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
|
|
162
|
+
IdOverrides["LeverageManagementOnPrice"] = "leverage-management-on-price";
|
|
163
|
+
IdOverrides["EoaLeverageManagementOnPrice"] = "leverage-management-on-price-eoa";
|
|
159
164
|
})(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
|
|
160
165
|
})(Strategies = exports.Strategies || (exports.Strategies = {}));
|
|
161
166
|
var Bundles;
|
|
@@ -210,6 +215,12 @@ var Bundles;
|
|
|
210
215
|
MainnetIds[MainnetIds["LIQUITY_V2_BOOST_ON_PRICE"] = 43] = "LIQUITY_V2_BOOST_ON_PRICE";
|
|
211
216
|
MainnetIds[MainnetIds["FLUID_T1_REPAY"] = 44] = "FLUID_T1_REPAY";
|
|
212
217
|
MainnetIds[MainnetIds["FLUID_T1_BOOST"] = 45] = "FLUID_T1_BOOST";
|
|
218
|
+
MainnetIds[MainnetIds["COMP_V3_SW_REPAY_ON_PRICE"] = 46] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
219
|
+
MainnetIds[MainnetIds["COMP_V3_SW_BOOST_ON_PRICE"] = 47] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
220
|
+
MainnetIds[MainnetIds["COMP_V3_SW_CLOSE"] = 48] = "COMP_V3_SW_CLOSE";
|
|
221
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 49] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
222
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 50] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
223
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_CLOSE"] = 51] = "COMP_V3_EOA_CLOSE";
|
|
213
224
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
214
225
|
let OptimismIds;
|
|
215
226
|
(function (OptimismIds) {
|
|
@@ -235,6 +246,12 @@ var Bundles;
|
|
|
235
246
|
BaseIds[BaseIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 12] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
236
247
|
BaseIds[BaseIds["FLUID_T1_REPAY"] = 13] = "FLUID_T1_REPAY";
|
|
237
248
|
BaseIds[BaseIds["FLUID_T1_BOOST"] = 14] = "FLUID_T1_BOOST";
|
|
249
|
+
BaseIds[BaseIds["COMP_V3_SW_REPAY_ON_PRICE"] = 15] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
250
|
+
BaseIds[BaseIds["COMP_V3_SW_BOOST_ON_PRICE"] = 16] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
251
|
+
BaseIds[BaseIds["COMP_V3_SW_CLOSE"] = 17] = "COMP_V3_SW_CLOSE";
|
|
252
|
+
BaseIds[BaseIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 18] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
253
|
+
BaseIds[BaseIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 19] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
254
|
+
BaseIds[BaseIds["COMP_V3_EOA_CLOSE"] = 20] = "COMP_V3_EOA_CLOSE";
|
|
238
255
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
239
256
|
let ArbitrumIds;
|
|
240
257
|
(function (ArbitrumIds) {
|
|
@@ -248,5 +265,11 @@ var Bundles;
|
|
|
248
265
|
ArbitrumIds[ArbitrumIds["AAVE_V3_REPAY_ON_PRICE"] = 7] = "AAVE_V3_REPAY_ON_PRICE";
|
|
249
266
|
ArbitrumIds[ArbitrumIds["FLUID_T1_REPAY"] = 8] = "FLUID_T1_REPAY";
|
|
250
267
|
ArbitrumIds[ArbitrumIds["FLUID_T1_BOOST"] = 9] = "FLUID_T1_BOOST";
|
|
268
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_REPAY_ON_PRICE"] = 10] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
269
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_BOOST_ON_PRICE"] = 11] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
270
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_CLOSE"] = 12] = "COMP_V3_SW_CLOSE";
|
|
271
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 13] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
272
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 14] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
273
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_CLOSE"] = 15] = "COMP_V3_EOA_CLOSE";
|
|
251
274
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
252
275
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -171,8 +171,24 @@ export declare namespace Position {
|
|
|
171
171
|
subHashBoost?: string;
|
|
172
172
|
subHashRepay?: string;
|
|
173
173
|
}
|
|
174
|
+
interface CompoundV3Base extends Base {
|
|
175
|
+
market: EthereumAddress;
|
|
176
|
+
collToken: EthereumAddress;
|
|
177
|
+
baseToken: EthereumAddress;
|
|
178
|
+
}
|
|
179
|
+
interface CompoundV3LeverageManagementOnPrice extends CompoundV3Base {
|
|
180
|
+
ratio: number;
|
|
181
|
+
price: string;
|
|
182
|
+
priceState: RatioState;
|
|
183
|
+
}
|
|
184
|
+
interface CompoundV3CloseOnPrice extends CompoundV3Base {
|
|
185
|
+
stopLossPrice: string;
|
|
186
|
+
takeProfitPrice: string;
|
|
187
|
+
stopLossType: CloseToAssetType | undefined;
|
|
188
|
+
takeProfitType: CloseToAssetType | undefined;
|
|
189
|
+
}
|
|
174
190
|
}
|
|
175
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2;
|
|
191
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.CompoundV3LeverageManagementOnPrice | Specific.CompoundV3CloseOnPrice;
|
|
176
192
|
interface Automated {
|
|
177
193
|
chainId: ChainId;
|
|
178
194
|
positionId: string;
|
package/esm/constants/index.js
CHANGED
|
@@ -392,6 +392,36 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
392
392
|
strategyId: Strategies.Identifiers.Boost,
|
|
393
393
|
protocol: PROTOCOLS.FluidT1,
|
|
394
394
|
},
|
|
395
|
+
[Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
396
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
397
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
398
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
399
|
+
},
|
|
400
|
+
[Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
401
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
402
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
403
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
404
|
+
},
|
|
405
|
+
[Bundles.MainnetIds.COMP_V3_SW_CLOSE]: {
|
|
406
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_CLOSE,
|
|
407
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
408
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
409
|
+
},
|
|
410
|
+
[Bundles.MainnetIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
411
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
412
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
413
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
414
|
+
},
|
|
415
|
+
[Bundles.MainnetIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
416
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
417
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
418
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
419
|
+
},
|
|
420
|
+
[Bundles.MainnetIds.COMP_V3_EOA_CLOSE]: {
|
|
421
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_CLOSE,
|
|
422
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
423
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
424
|
+
},
|
|
395
425
|
};
|
|
396
426
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
397
427
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -491,6 +521,36 @@ export const BASE_BUNDLES_INFO = {
|
|
|
491
521
|
strategyId: Strategies.Identifiers.Boost,
|
|
492
522
|
protocol: PROTOCOLS.FluidT1,
|
|
493
523
|
},
|
|
524
|
+
[Bundles.BaseIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
525
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
526
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
527
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
528
|
+
},
|
|
529
|
+
[Bundles.BaseIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
530
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
531
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
532
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
533
|
+
},
|
|
534
|
+
[Bundles.BaseIds.COMP_V3_SW_CLOSE]: {
|
|
535
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_CLOSE,
|
|
536
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
537
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
538
|
+
},
|
|
539
|
+
[Bundles.BaseIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
540
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
541
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
542
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
543
|
+
},
|
|
544
|
+
[Bundles.BaseIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
545
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
546
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
547
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
548
|
+
},
|
|
549
|
+
[Bundles.BaseIds.COMP_V3_EOA_CLOSE]: {
|
|
550
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_CLOSE,
|
|
551
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
552
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
553
|
+
},
|
|
494
554
|
};
|
|
495
555
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
496
556
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -543,6 +603,36 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
543
603
|
strategyId: Strategies.Identifiers.Boost,
|
|
544
604
|
protocol: PROTOCOLS.FluidT1,
|
|
545
605
|
},
|
|
606
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
607
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
608
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
609
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
610
|
+
},
|
|
611
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
612
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
613
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
614
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
615
|
+
},
|
|
616
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_CLOSE]: {
|
|
617
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_CLOSE,
|
|
618
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
619
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
620
|
+
},
|
|
621
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
622
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
623
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
624
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
625
|
+
},
|
|
626
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
627
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
628
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
629
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
630
|
+
},
|
|
631
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_CLOSE]: {
|
|
632
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_CLOSE,
|
|
633
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
634
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
635
|
+
},
|
|
546
636
|
};
|
|
547
637
|
export const BUNDLES_INFO = {
|
|
548
638
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
|
@@ -334,6 +334,48 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
334
334
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
335
335
|
return _position;
|
|
336
336
|
}
|
|
337
|
+
function parseCompoundV3LeverageManagementOnPrice(position, parseData) {
|
|
338
|
+
const _position = cloneDeep(position);
|
|
339
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
340
|
+
const triggerData = triggerService.compoundV3PriceTrigger.decode(subStruct.triggerData);
|
|
341
|
+
const subData = subDataService.compoundV3LeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
342
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
343
|
+
_position.strategyData.decoded.subData = subData;
|
|
344
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.market, Math.random());
|
|
345
|
+
_position.specific = {
|
|
346
|
+
market: subData.market,
|
|
347
|
+
collToken: subData.collToken,
|
|
348
|
+
baseToken: subData.baseToken,
|
|
349
|
+
ratio: subData.targetRatio,
|
|
350
|
+
price: triggerData.price,
|
|
351
|
+
priceState: triggerData.priceState,
|
|
352
|
+
};
|
|
353
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
354
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagementOnPrice : Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
355
|
+
return _position;
|
|
356
|
+
}
|
|
357
|
+
function parseCompoundV3CloseOnPrice(position, parseData) {
|
|
358
|
+
const _position = cloneDeep(position);
|
|
359
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
360
|
+
const triggerData = triggerService.compoundV3PriceRangeTrigger.decode(subStruct.triggerData);
|
|
361
|
+
const subData = subDataService.compoundV3CloseSubData.decode(subStruct.subData);
|
|
362
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
363
|
+
_position.strategyData.decoded.subData = subData;
|
|
364
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.market, Math.random());
|
|
365
|
+
const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
|
|
366
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
367
|
+
_position.strategy.strategyId = isEOA ? Strategies.Identifiers.EoaCloseOnPrice : Strategies.Identifiers.CloseOnPrice;
|
|
368
|
+
_position.specific = {
|
|
369
|
+
market: subData.market,
|
|
370
|
+
collToken: subData.collToken,
|
|
371
|
+
baseToken: subData.baseToken,
|
|
372
|
+
stopLossPrice: triggerData.lowerPrice,
|
|
373
|
+
takeProfitPrice: triggerData.upperPrice,
|
|
374
|
+
takeProfitType,
|
|
375
|
+
stopLossType,
|
|
376
|
+
};
|
|
377
|
+
return _position;
|
|
378
|
+
}
|
|
337
379
|
function parseChickenBondsRebond(position, parseData) {
|
|
338
380
|
const _position = cloneDeep(position);
|
|
339
381
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -659,7 +701,6 @@ function parseLiquityV2CloseOnPrice(position, parseData) {
|
|
|
659
701
|
// - Only TakeProfit
|
|
660
702
|
// - Only StopLoss
|
|
661
703
|
// - Both
|
|
662
|
-
// TODO: see on frontend what specific data we need here because stop-loss and take-profit is one bundle now
|
|
663
704
|
_position.strategy.strategyId = Strategies.Identifiers.CloseOnPrice;
|
|
664
705
|
_position.specific = {
|
|
665
706
|
market: subData.market,
|
|
@@ -794,6 +835,12 @@ const parsingMethodsMapping = {
|
|
|
794
835
|
[Strategies.Identifiers.Boost]: parseCompoundV3LeverageManagement,
|
|
795
836
|
[Strategies.Identifiers.EoaRepay]: parseCompoundV3LeverageManagement,
|
|
796
837
|
[Strategies.Identifiers.EoaBoost]: parseCompoundV3LeverageManagement,
|
|
838
|
+
[Strategies.Identifiers.RepayOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
839
|
+
[Strategies.Identifiers.BoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
840
|
+
[Strategies.Identifiers.EoaRepayOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
841
|
+
[Strategies.Identifiers.EoaBoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
842
|
+
[Strategies.Identifiers.CloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
843
|
+
[Strategies.Identifiers.EoaCloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
797
844
|
},
|
|
798
845
|
[ProtocolIdentifiers.StrategiesAutomation.ChickenBonds]: {
|
|
799
846
|
[Strategies.Identifiers.Rebond]: parseChickenBondsRebond,
|
|
@@ -66,6 +66,8 @@ export declare const compoundV2Encode: {
|
|
|
66
66
|
};
|
|
67
67
|
export declare const compoundV3Encode: {
|
|
68
68
|
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
69
|
+
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState): (number | boolean | string[])[];
|
|
70
|
+
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
69
71
|
};
|
|
70
72
|
export declare const compoundV3L2Encode: {
|
|
71
73
|
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
@@ -156,6 +156,19 @@ export const compoundV3Encode = {
|
|
|
156
156
|
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
157
157
|
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
158
158
|
},
|
|
159
|
+
leverageManagementOnPrice(strategyOrBundleId, market, collToken, baseToken, targetRatio, price, priceState) {
|
|
160
|
+
const isBundle = true;
|
|
161
|
+
const subDataEncoded = subDataService.compoundV3LeverageManagementOnPriceSubData.encode(market, collToken, baseToken, targetRatio);
|
|
162
|
+
const triggerDataEncoded = triggerService.compoundV3PriceTrigger.encode(market, collToken, price, priceState);
|
|
163
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
164
|
+
},
|
|
165
|
+
closeOnPrice(strategyOrBundleId, market, collToken, baseToken, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
166
|
+
const isBundle = true;
|
|
167
|
+
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
168
|
+
const subDataEncoded = subDataService.compoundV3CloseSubData.encode(market, collToken, baseToken, closeType);
|
|
169
|
+
const triggerDataEncoded = triggerService.compoundV3PriceRangeTrigger.encode(market, collToken, stopLossPrice, takeProfitPrice);
|
|
170
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
171
|
+
},
|
|
159
172
|
};
|
|
160
173
|
export const compoundV3L2Encode = {
|
|
161
174
|
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|