@defisaver/automation-sdk 3.1.4 → 3.1.6-fluid-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 +2 -2
- package/cjs/automation/public/Strategies.test.d.ts +1 -0
- package/cjs/automation/public/Strategies.test.js +61 -0
- package/cjs/constants/index.js +45 -0
- package/cjs/services/strategiesService.js +155 -0
- package/cjs/services/strategySubService.d.ts +10 -1
- package/cjs/services/strategySubService.js +35 -1
- package/cjs/services/subDataService.d.ts +55 -1
- package/cjs/services/subDataService.js +174 -1
- package/cjs/services/triggerService.d.ts +43 -0
- package/cjs/services/triggerService.js +81 -1
- package/cjs/services/utils.d.ts +6 -1
- package/cjs/services/utils.js +52 -1
- package/cjs/types/enums.d.ts +38 -3
- package/cjs/types/enums.js +40 -1
- package/cjs/types/index.d.ts +16 -3
- package/esm/automation/private/StrategiesAutomation.d.ts +2 -2
- package/esm/automation/public/Strategies.test.d.ts +1 -0
- package/esm/automation/public/Strategies.test.js +56 -0
- package/esm/constants/index.js +45 -0
- package/esm/services/strategiesService.js +153 -1
- package/esm/services/strategySubService.d.ts +10 -1
- package/esm/services/strategySubService.js +36 -2
- package/esm/services/subDataService.d.ts +55 -1
- package/esm/services/subDataService.js +174 -1
- package/esm/services/triggerService.d.ts +43 -0
- package/esm/services/triggerService.js +80 -0
- package/esm/services/utils.d.ts +6 -1
- package/esm/services/utils.js +50 -1
- package/esm/types/enums.d.ts +38 -3
- package/esm/types/enums.js +39 -0
- package/esm/types/index.d.ts +16 -3
- package/package.json +3 -3
- package/src/automation/private/StrategiesAutomation.ts +2 -2
- package/src/automation/public/Strategies.test.ts +49 -0
- package/src/constants/index.ts +45 -0
- package/src/services/strategiesService.ts +199 -1
- package/src/services/strategySubService.ts +97 -1
- package/src/services/subDataService.ts +243 -2
- package/src/services/triggerService.ts +125 -0
- package/src/services/utils.ts +60 -1
- package/src/types/enums.ts +39 -0
- package/src/types/index.ts +20 -2
- package/umd/index.js +34219 -0
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.aaveV3LeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
6
|
+
exports.fluidLeverageManagementSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
9
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -473,3 +473,176 @@ exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
|
473
473
|
};
|
|
474
474
|
},
|
|
475
475
|
};
|
|
476
|
+
exports.liquityV2LeverageManagementSubData = {
|
|
477
|
+
encode: (market, troveId, collToken, boldToken, ratioState, targetRatio) => {
|
|
478
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
479
|
+
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
480
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
481
|
+
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
482
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
483
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
484
|
+
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
485
|
+
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
486
|
+
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
487
|
+
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
488
|
+
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
489
|
+
return [
|
|
490
|
+
marketEncoded,
|
|
491
|
+
troveIdEncoded,
|
|
492
|
+
collTokenEncoded,
|
|
493
|
+
boldTokenEncoded,
|
|
494
|
+
ratioStateEncoded,
|
|
495
|
+
targetRatioEncoded,
|
|
496
|
+
collActionTypeEncoded,
|
|
497
|
+
debtActionTypeEncoded,
|
|
498
|
+
];
|
|
499
|
+
},
|
|
500
|
+
decode: (subData) => {
|
|
501
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
502
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
503
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
504
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
505
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
506
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
507
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
508
|
+
return {
|
|
509
|
+
market, troveId, collToken, boldToken, ratioState, targetRatio,
|
|
510
|
+
};
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
exports.liquityV2CloseSubData = {
|
|
514
|
+
encode(market, troveId, collToken, boldToken, closeType) {
|
|
515
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
516
|
+
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
517
|
+
const collAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
518
|
+
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
519
|
+
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
520
|
+
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
521
|
+
const gasCompensation = new decimal_js_1.default('0.0375').mul(1e18).toString();
|
|
522
|
+
const gasCompensationEncoded = web3_eth_abi_1.default.encodeParameter('uint256', gasCompensation);
|
|
523
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
524
|
+
return [
|
|
525
|
+
marketEncoded,
|
|
526
|
+
troveIdEncoded,
|
|
527
|
+
collAddrEncoded,
|
|
528
|
+
boldTokenEncoded,
|
|
529
|
+
wethAddressEncoded,
|
|
530
|
+
gasCompensationEncoded,
|
|
531
|
+
closeTypeEncoded,
|
|
532
|
+
];
|
|
533
|
+
},
|
|
534
|
+
decode(subData) {
|
|
535
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
536
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
537
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
538
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
539
|
+
// skip wethAddress and gasCompensation
|
|
540
|
+
const closeType = web3_eth_abi_1.default.decodeParameter('uint8', subData[6]);
|
|
541
|
+
return {
|
|
542
|
+
market, troveId, collToken, boldToken, closeType,
|
|
543
|
+
};
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
exports.liquityV2LeverageManagementOnPriceSubData = {
|
|
547
|
+
encode(market, troveId, collToken, boldToken, targetRatio, isRepayOnPrice) {
|
|
548
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
549
|
+
const encodedTroveId = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
550
|
+
const encodedCollToken = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
551
|
+
const encodedBoldToken = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
552
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
553
|
+
const collActionType = isRepayOnPrice ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
554
|
+
const debtActionType = isRepayOnPrice ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
555
|
+
const encodedCollActionType = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
556
|
+
const encodedDebtActionType = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
557
|
+
return [
|
|
558
|
+
encodedMarket,
|
|
559
|
+
encodedTroveId,
|
|
560
|
+
encodedCollToken,
|
|
561
|
+
encodedBoldToken,
|
|
562
|
+
encodedTargetRatio,
|
|
563
|
+
encodedCollActionType,
|
|
564
|
+
encodedDebtActionType,
|
|
565
|
+
];
|
|
566
|
+
},
|
|
567
|
+
decode(subData) {
|
|
568
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
569
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
570
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
571
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
572
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
573
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
574
|
+
return {
|
|
575
|
+
market, troveId, collToken, boldToken, targetRatio,
|
|
576
|
+
};
|
|
577
|
+
},
|
|
578
|
+
};
|
|
579
|
+
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
580
|
+
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
581
|
+
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
582
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
583
|
+
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
584
|
+
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
585
|
+
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
586
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
587
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
588
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, targetRatioEncoded, userEncoded];
|
|
589
|
+
},
|
|
590
|
+
decode(subData) {
|
|
591
|
+
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
592
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
593
|
+
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
594
|
+
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
595
|
+
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
596
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
597
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
598
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
599
|
+
return {
|
|
600
|
+
loanToken,
|
|
601
|
+
collToken,
|
|
602
|
+
oracle,
|
|
603
|
+
irm,
|
|
604
|
+
lltv,
|
|
605
|
+
targetRatio,
|
|
606
|
+
user,
|
|
607
|
+
};
|
|
608
|
+
},
|
|
609
|
+
};
|
|
610
|
+
exports.fluidLeverageManagementSubData = {
|
|
611
|
+
encode: (nftId, vault, collToken, debtToken, ratioState, targetRatio) => {
|
|
612
|
+
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
613
|
+
const vaultEncoded = web3_eth_abi_1.default.encodeParameter('address', vault);
|
|
614
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
615
|
+
const debtTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', debtToken);
|
|
616
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
617
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
618
|
+
const wrapEthEncoded = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
619
|
+
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
620
|
+
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
621
|
+
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
622
|
+
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
623
|
+
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
624
|
+
return [
|
|
625
|
+
nftIdEncoded,
|
|
626
|
+
vaultEncoded,
|
|
627
|
+
collTokenEncoded,
|
|
628
|
+
debtTokenEncoded,
|
|
629
|
+
ratioStateEncoded,
|
|
630
|
+
targetRatioEncoded,
|
|
631
|
+
wrapEthEncoded,
|
|
632
|
+
collActionTypeEncoded,
|
|
633
|
+
debtActionTypeEncoded,
|
|
634
|
+
];
|
|
635
|
+
},
|
|
636
|
+
decode: (subData) => {
|
|
637
|
+
const nftId = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
638
|
+
const vault = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
639
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
640
|
+
const debtToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
641
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
642
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
643
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
644
|
+
return {
|
|
645
|
+
nftId, vault, collToken, debtToken, ratioState, targetRatio,
|
|
646
|
+
};
|
|
647
|
+
},
|
|
648
|
+
};
|
|
@@ -189,3 +189,46 @@ export declare const morphoBlueRatioTrigger: {
|
|
|
189
189
|
ratioState: number;
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
|
+
export declare const liquityV2RatioTrigger: {
|
|
193
|
+
encode(market: EthereumAddress, troveId: string, ratioPercentage: number, ratioState: RatioState): string[];
|
|
194
|
+
decode(triggerData: string[]): {
|
|
195
|
+
market: string;
|
|
196
|
+
troveId: string;
|
|
197
|
+
ratio: number;
|
|
198
|
+
ratioState: number;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
export declare const liquityV2QuotePriceTrigger: {
|
|
202
|
+
encode(market: EthereumAddress, price: number, ratioState: RatioState): string[];
|
|
203
|
+
decode(triggerData: string[]): {
|
|
204
|
+
market: string;
|
|
205
|
+
price: string;
|
|
206
|
+
ratioState: number;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
export declare const closePriceTrigger: {
|
|
210
|
+
encode(tokenAddr: EthereumAddress, lowerPrice: number, upperPrice: number): string[];
|
|
211
|
+
decode(triggerData: string[]): {
|
|
212
|
+
tokenAddr: EthereumAddress;
|
|
213
|
+
lowerPrice: string;
|
|
214
|
+
upperPrice: string;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
export declare const morphoBluePriceTrigger: {
|
|
218
|
+
encode(oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, price: number, priceState: RatioState): string[];
|
|
219
|
+
decode(triggerData: string[]): {
|
|
220
|
+
oracle: string;
|
|
221
|
+
collateralToken: string;
|
|
222
|
+
loanToken: string;
|
|
223
|
+
price: string;
|
|
224
|
+
priceState: number;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
export declare const fluidRatioTrigger: {
|
|
228
|
+
encode(nftId: string, ratioPercentage: number, ratioState: RatioState): string[];
|
|
229
|
+
decode(triggerData: string[]): {
|
|
230
|
+
nftId: string;
|
|
231
|
+
ratio: number;
|
|
232
|
+
ratioState: number;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.morphoBlueRatioTrigger = exports.crvUsdHealthRatioTrigger = exports.crvUSDRatioTrigger = exports.curveUsdSoftLiquidationTrigger = exports.curveUsdBorrowRateTrigger = exports.sparkQuotePriceTrigger = exports.sparkRatioTrigger = exports.exchangeOffchainPriceTrigger = exports.exchangeTimestampTrigger = exports.compoundV3RatioTrigger = exports.cBondsRebondTrigger = exports.aaveV2RatioTrigger = exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger = exports.liquityRatioTrigger = exports.compoundV2RatioTrigger = exports.aaveV3QuotePriceWithMaximumGasPriceTrigger = exports.aaveV3QuotePriceTrigger = exports.morphoAaveV2RatioTrigger = exports.aaveV3RatioTrigger = exports.makerRatioTrigger = exports.trailingStopTrigger = exports.chainlinkPriceTrigger = void 0;
|
|
29
|
+
exports.fluidRatioTrigger = exports.morphoBluePriceTrigger = exports.closePriceTrigger = exports.liquityV2QuotePriceTrigger = exports.liquityV2RatioTrigger = exports.morphoBlueRatioTrigger = exports.crvUsdHealthRatioTrigger = exports.crvUSDRatioTrigger = exports.curveUsdSoftLiquidationTrigger = exports.curveUsdBorrowRateTrigger = exports.sparkQuotePriceTrigger = exports.sparkRatioTrigger = exports.exchangeOffchainPriceTrigger = exports.exchangeTimestampTrigger = exports.compoundV3RatioTrigger = exports.cBondsRebondTrigger = exports.aaveV2RatioTrigger = exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger = exports.liquityRatioTrigger = exports.compoundV2RatioTrigger = exports.aaveV3QuotePriceWithMaximumGasPriceTrigger = exports.aaveV3QuotePriceTrigger = exports.morphoAaveV2RatioTrigger = exports.aaveV3RatioTrigger = exports.makerRatioTrigger = exports.trailingStopTrigger = exports.chainlinkPriceTrigger = void 0;
|
|
30
30
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
31
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
32
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
@@ -365,3 +365,83 @@ exports.morphoBlueRatioTrigger = {
|
|
|
365
365
|
};
|
|
366
366
|
},
|
|
367
367
|
};
|
|
368
|
+
exports.liquityV2RatioTrigger = {
|
|
369
|
+
encode(market, troveId, ratioPercentage, ratioState) {
|
|
370
|
+
const ratioWei = (0, utils_1.ratioPercentageToWei)(ratioPercentage);
|
|
371
|
+
return [web3_eth_abi_1.default.encodeParameters(['address', 'uint256', 'uint256', 'uint8'], [market, troveId, ratioWei, ratioState])];
|
|
372
|
+
},
|
|
373
|
+
decode(triggerData) {
|
|
374
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
375
|
+
return {
|
|
376
|
+
market: decodedData[0],
|
|
377
|
+
troveId: decodedData[1],
|
|
378
|
+
ratio: (0, utils_1.weiToRatioPercentage)(decodedData[2]),
|
|
379
|
+
ratioState: Number(decodedData[3]),
|
|
380
|
+
};
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
exports.liquityV2QuotePriceTrigger = {
|
|
384
|
+
encode(market, price, ratioState) {
|
|
385
|
+
// Price is always in 18 decimals
|
|
386
|
+
const _price = new decimal_js_1.default(price.toString()).mul(Math.pow(10, 18)).floor().toString();
|
|
387
|
+
return [web3_eth_abi_1.default.encodeParameters(['address', 'uint256', 'uint8'], [market, _price, ratioState])];
|
|
388
|
+
},
|
|
389
|
+
decode(triggerData) {
|
|
390
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'uint256', 'uint8'], triggerData[0]);
|
|
391
|
+
const price = new decimal_js_1.default(decodedData[1]).div(Math.pow(10, 18)).toDP(18).toString();
|
|
392
|
+
return {
|
|
393
|
+
market: decodedData[0],
|
|
394
|
+
price,
|
|
395
|
+
ratioState: Number(decodedData[2]),
|
|
396
|
+
};
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
exports.closePriceTrigger = {
|
|
400
|
+
encode(tokenAddr, lowerPrice, upperPrice) {
|
|
401
|
+
const lowerPriceFormatted = new decimal_js_1.default(lowerPrice).mul(1e8).floor().toString();
|
|
402
|
+
const upperPriceFormatted = new decimal_js_1.default(upperPrice).mul(1e8).floor().toString();
|
|
403
|
+
return [
|
|
404
|
+
web3_eth_abi_1.default.encodeParameters(['address', 'uint256', 'uint256'], [tokenAddr, lowerPriceFormatted, upperPriceFormatted]),
|
|
405
|
+
];
|
|
406
|
+
},
|
|
407
|
+
decode(triggerData) {
|
|
408
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'uint256', 'uint256'], triggerData[0]);
|
|
409
|
+
return {
|
|
410
|
+
tokenAddr: decodedData[0],
|
|
411
|
+
lowerPrice: new decimal_js_1.default(decodedData[1]).div(1e8).toString(),
|
|
412
|
+
upperPrice: new decimal_js_1.default(decodedData[2]).div(1e8).toString(),
|
|
413
|
+
};
|
|
414
|
+
},
|
|
415
|
+
};
|
|
416
|
+
exports.morphoBluePriceTrigger = {
|
|
417
|
+
encode(oracle, collateralToken, loanToken, price, priceState) {
|
|
418
|
+
const _price = new decimal_js_1.default(price.toString()).mul(1e8).floor().toString();
|
|
419
|
+
return [
|
|
420
|
+
web3_eth_abi_1.default.encodeParameters(['address', 'address', 'address', 'uint256', 'uint8'], [oracle, collateralToken, loanToken, _price, priceState]),
|
|
421
|
+
];
|
|
422
|
+
},
|
|
423
|
+
decode(triggerData) {
|
|
424
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'address', 'address', 'uint256', 'uint8'], triggerData[0]);
|
|
425
|
+
return {
|
|
426
|
+
oracle: decodedData[0],
|
|
427
|
+
collateralToken: decodedData[1],
|
|
428
|
+
loanToken: decodedData[2],
|
|
429
|
+
price: new decimal_js_1.default(decodedData[3]).div(1e8).toString(),
|
|
430
|
+
priceState: Number(decodedData[4]),
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
exports.fluidRatioTrigger = {
|
|
435
|
+
encode(nftId, ratioPercentage, ratioState) {
|
|
436
|
+
const ratioWei = (0, utils_1.ratioPercentageToWei)(ratioPercentage);
|
|
437
|
+
return [web3_eth_abi_1.default.encodeParameters(['uint256', 'uint256', 'uint8'], [nftId, ratioWei, ratioState])];
|
|
438
|
+
},
|
|
439
|
+
decode(triggerData) {
|
|
440
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
441
|
+
return {
|
|
442
|
+
nftId: decodedData[0],
|
|
443
|
+
ratio: (0, utils_1.weiToRatioPercentage)(decodedData[1]),
|
|
444
|
+
ratioState: Number(decodedData[2]),
|
|
445
|
+
};
|
|
446
|
+
},
|
|
447
|
+
};
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthereumAddress } from '../types';
|
|
2
|
-
import { ChainId, RatioState } from '../types/enums';
|
|
2
|
+
import { ChainId, CloseStrategyType, CloseToAssetType, RatioState } from '../types/enums';
|
|
3
3
|
export declare function isDefined<T>(value: T): value is NonNullable<T>;
|
|
4
4
|
export declare function isUndefined(value: unknown): boolean;
|
|
5
5
|
export declare function compareAddresses(firstAddress: EthereumAddress, secondAddress: EthereumAddress): boolean;
|
|
@@ -23,3 +23,8 @@ export declare function getRatioStateInfoForAaveCloseStrategy(currentRatioState:
|
|
|
23
23
|
ratioState: RatioState;
|
|
24
24
|
};
|
|
25
25
|
export declare function getPositionId(...args: (number | string)[]): string;
|
|
26
|
+
export declare function getCloseStrategyType(stopLossPrice: number, stopLossType: CloseToAssetType, takeProfitPrice: number, takeProfitType: CloseToAssetType): CloseStrategyType;
|
|
27
|
+
export declare function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyType: CloseStrategyType): {
|
|
28
|
+
stopLossType: CloseToAssetType | undefined;
|
|
29
|
+
takeProfitType: CloseToAssetType | undefined;
|
|
30
|
+
};
|
package/cjs/services/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getPositionId = exports.getRatioStateInfoForAaveCloseStrategy = exports.requireAddresses = exports.requireAddress = exports.isEmptyBytes = exports.isRatioStateUnder = exports.isRatioStateOver = exports.weiToRatioPercentage = exports.ratioPercentageToWei = exports.encodeSubId = exports.compareSubHashes = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.addToArrayIf = exports.isAddress = exports.compareAddresses = exports.isUndefined = exports.isDefined = void 0;
|
|
29
|
+
exports.getStopLossAndTakeProfitTypeByCloseStrategyType = exports.getCloseStrategyType = exports.getPositionId = exports.getRatioStateInfoForAaveCloseStrategy = exports.requireAddresses = exports.requireAddress = exports.isEmptyBytes = exports.isRatioStateUnder = exports.isRatioStateOver = exports.weiToRatioPercentage = exports.ratioPercentageToWei = exports.encodeSubId = exports.compareSubHashes = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.addToArrayIf = exports.isAddress = exports.compareAddresses = exports.isUndefined = exports.isDefined = void 0;
|
|
30
30
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
31
|
const web3Utils = __importStar(require("web3-utils"));
|
|
32
32
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
@@ -129,3 +129,54 @@ function getPositionId(...args) {
|
|
|
129
129
|
return args.map(arg => arg.toString().toLowerCase().split(' ').join('_')).join('-');
|
|
130
130
|
}
|
|
131
131
|
exports.getPositionId = getPositionId;
|
|
132
|
+
function getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType) {
|
|
133
|
+
const isStopLoss = stopLossPrice > 0;
|
|
134
|
+
const isTakeProfit = takeProfitPrice > 0;
|
|
135
|
+
if (!isStopLoss && !isTakeProfit) {
|
|
136
|
+
throw new Error('CloseOnPrice: At least one price must be defined');
|
|
137
|
+
}
|
|
138
|
+
if (isStopLoss && isTakeProfit) {
|
|
139
|
+
if (stopLossType === enums_1.CloseToAssetType.COLLATERAL && takeProfitType === enums_1.CloseToAssetType.COLLATERAL) {
|
|
140
|
+
return enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL;
|
|
141
|
+
}
|
|
142
|
+
if (stopLossType === enums_1.CloseToAssetType.COLLATERAL) {
|
|
143
|
+
return enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL;
|
|
144
|
+
}
|
|
145
|
+
if (takeProfitType === enums_1.CloseToAssetType.COLLATERAL) {
|
|
146
|
+
return enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT;
|
|
147
|
+
}
|
|
148
|
+
return enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT;
|
|
149
|
+
}
|
|
150
|
+
if (isStopLoss) {
|
|
151
|
+
return stopLossType === enums_1.CloseToAssetType.COLLATERAL
|
|
152
|
+
? enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL
|
|
153
|
+
: enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT;
|
|
154
|
+
}
|
|
155
|
+
return takeProfitType === enums_1.CloseToAssetType.COLLATERAL
|
|
156
|
+
? enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL
|
|
157
|
+
: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT;
|
|
158
|
+
}
|
|
159
|
+
exports.getCloseStrategyType = getCloseStrategyType;
|
|
160
|
+
function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyType) {
|
|
161
|
+
switch (closeStrategyType) {
|
|
162
|
+
case enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL:
|
|
163
|
+
return { stopLossType: enums_1.CloseToAssetType.COLLATERAL, takeProfitType: undefined };
|
|
164
|
+
case enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT:
|
|
165
|
+
return { stopLossType: enums_1.CloseToAssetType.DEBT, takeProfitType: undefined };
|
|
166
|
+
case enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL:
|
|
167
|
+
return { stopLossType: undefined, takeProfitType: enums_1.CloseToAssetType.COLLATERAL };
|
|
168
|
+
case enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT:
|
|
169
|
+
return { stopLossType: undefined, takeProfitType: enums_1.CloseToAssetType.DEBT };
|
|
170
|
+
case enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT:
|
|
171
|
+
return { stopLossType: enums_1.CloseToAssetType.DEBT, takeProfitType: enums_1.CloseToAssetType.COLLATERAL };
|
|
172
|
+
case enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL:
|
|
173
|
+
return { stopLossType: enums_1.CloseToAssetType.COLLATERAL, takeProfitType: enums_1.CloseToAssetType.DEBT };
|
|
174
|
+
case enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT:
|
|
175
|
+
return { stopLossType: enums_1.CloseToAssetType.DEBT, takeProfitType: enums_1.CloseToAssetType.DEBT };
|
|
176
|
+
case enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL:
|
|
177
|
+
return { stopLossType: enums_1.CloseToAssetType.COLLATERAL, takeProfitType: enums_1.CloseToAssetType.COLLATERAL };
|
|
178
|
+
default:
|
|
179
|
+
throw new Error('CloseStrategyType not supported');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.getStopLossAndTakeProfitTypeByCloseStrategyType = getStopLossAndTakeProfitTypeByCloseStrategyType;
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -17,6 +17,28 @@ export declare enum BundleProtocols {
|
|
|
17
17
|
Yearn = "yearn",
|
|
18
18
|
Rari = "rari"
|
|
19
19
|
}
|
|
20
|
+
export declare enum CollActionType {
|
|
21
|
+
SUPPLY = 0,
|
|
22
|
+
WITHDRAW = 1
|
|
23
|
+
}
|
|
24
|
+
export declare enum DebtActionType {
|
|
25
|
+
PAYBACK = 0,
|
|
26
|
+
BORROW = 1
|
|
27
|
+
}
|
|
28
|
+
export declare enum CloseStrategyType {
|
|
29
|
+
TAKE_PROFIT_IN_COLLATERAL = 0,
|
|
30
|
+
STOP_LOSS_IN_COLLATERAL = 1,
|
|
31
|
+
TAKE_PROFIT_IN_DEBT = 2,
|
|
32
|
+
STOP_LOSS_IN_DEBT = 3,
|
|
33
|
+
TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL = 4,
|
|
34
|
+
TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT = 5,
|
|
35
|
+
TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT = 6,
|
|
36
|
+
TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL = 7
|
|
37
|
+
}
|
|
38
|
+
export declare enum CloseToAssetType {
|
|
39
|
+
COLLATERAL = 0,
|
|
40
|
+
DEBT = 1
|
|
41
|
+
}
|
|
20
42
|
/**
|
|
21
43
|
* @dev Follow the naming convention:
|
|
22
44
|
* - Enum name consists of two parts, name and version
|
|
@@ -28,6 +50,7 @@ export declare namespace ProtocolIdentifiers {
|
|
|
28
50
|
enum StrategiesAutomation {
|
|
29
51
|
MakerDAO = "MakerDAO",
|
|
30
52
|
Liquity = "Liquity",
|
|
53
|
+
LiquityV2 = "Liquity__V2",
|
|
31
54
|
ChickenBonds = "Chicken Bonds",
|
|
32
55
|
CompoundV2 = "Compound__V2",
|
|
33
56
|
CompoundV3 = "Compound__V3",
|
|
@@ -37,7 +60,8 @@ export declare namespace ProtocolIdentifiers {
|
|
|
37
60
|
Exchange = "Exchange",
|
|
38
61
|
Spark = "Spark",
|
|
39
62
|
CrvUSD = "CurveUSD",
|
|
40
|
-
MorphoBlue = "MorphoBlue"
|
|
63
|
+
MorphoBlue = "MorphoBlue",
|
|
64
|
+
FluidT1 = "FluidT1"
|
|
41
65
|
}
|
|
42
66
|
enum LegacyAutomation {
|
|
43
67
|
MakerDAO = "MakerDAO",
|
|
@@ -88,6 +112,7 @@ export declare namespace Strategies {
|
|
|
88
112
|
CloseToCollateralWithGasPrice = "close-to-collateral-with-gas-price",
|
|
89
113
|
CloseOnPriceToDebt = "close-on-price-to-debt",
|
|
90
114
|
CloseOnPriceToColl = "close-on-price-to-collateral",
|
|
115
|
+
CloseOnPrice = "close-on-price",
|
|
91
116
|
TrailingStopToColl = "trailing-stop-to-collateral",
|
|
92
117
|
TrailingStopToDebt = "trailing-stop-to-debt",
|
|
93
118
|
Rebond = "rebond",
|
|
@@ -98,6 +123,7 @@ export declare namespace Strategies {
|
|
|
98
123
|
DebtInFrontRepay = "debt-in-front-repay",
|
|
99
124
|
OpenOrderFromCollateral = "open-order-from-collateral",
|
|
100
125
|
OpenOrderFromDebt = "open-order-from-debt",
|
|
126
|
+
BoostOnPrice = "boost-on-price",
|
|
101
127
|
RepayOnPrice = "repay-on-price"
|
|
102
128
|
}
|
|
103
129
|
enum IdOverrides {
|
|
@@ -151,7 +177,15 @@ export declare namespace Bundles {
|
|
|
151
177
|
MORPHO_BLUE_EOA_REPAY = 34,
|
|
152
178
|
MORPHO_BLUE_EOA_BOOST = 35,
|
|
153
179
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36,
|
|
154
|
-
AAVE_V3_REPAY_ON_PRICE = 37
|
|
180
|
+
AAVE_V3_REPAY_ON_PRICE = 37,
|
|
181
|
+
MORPHO_BLUE_BOOST_ON_PRICE = 38,
|
|
182
|
+
LIQUITY_V2_REPAY = 39,
|
|
183
|
+
LIQUITY_V2_BOOST = 40,
|
|
184
|
+
LIQUITY_V2_CLOSE = 41,
|
|
185
|
+
LIQUITY_V2_REPAY_ON_PRICE = 42,
|
|
186
|
+
LIQUITY_V2_BOOST_ON_PRICE = 43,
|
|
187
|
+
FLUID_T1_REPAY = 44,
|
|
188
|
+
FLUID_T2_BOOST = 45
|
|
155
189
|
}
|
|
156
190
|
enum OptimismIds {
|
|
157
191
|
AAVE_V3_REPAY = 0,
|
|
@@ -171,7 +205,8 @@ export declare namespace Bundles {
|
|
|
171
205
|
MORPHO_BLUE_REPAY = 8,
|
|
172
206
|
MORPHO_BLUE_BOOST = 9,
|
|
173
207
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10,
|
|
174
|
-
AAVE_V3_REPAY_ON_PRICE = 11
|
|
208
|
+
AAVE_V3_REPAY_ON_PRICE = 11,
|
|
209
|
+
MORPHO_BLUE_BOOST_ON_PRICE = 12
|
|
175
210
|
}
|
|
176
211
|
enum ArbitrumIds {
|
|
177
212
|
AAVE_V3_REPAY = 0,
|
package/cjs/types/enums.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Bundles = exports.Strategies = exports.ProtocolIdentifiers = exports.BundleProtocols = exports.OrderType = exports.RatioState = exports.ChainId = void 0;
|
|
3
|
+
exports.Bundles = exports.Strategies = exports.ProtocolIdentifiers = exports.CloseToAssetType = exports.CloseStrategyType = exports.DebtActionType = exports.CollActionType = exports.BundleProtocols = exports.OrderType = exports.RatioState = exports.ChainId = void 0;
|
|
4
4
|
var ChainId;
|
|
5
5
|
(function (ChainId) {
|
|
6
6
|
ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
|
|
@@ -24,6 +24,32 @@ var BundleProtocols;
|
|
|
24
24
|
BundleProtocols["Yearn"] = "yearn";
|
|
25
25
|
BundleProtocols["Rari"] = "rari";
|
|
26
26
|
})(BundleProtocols = exports.BundleProtocols || (exports.BundleProtocols = {}));
|
|
27
|
+
var CollActionType;
|
|
28
|
+
(function (CollActionType) {
|
|
29
|
+
CollActionType[CollActionType["SUPPLY"] = 0] = "SUPPLY";
|
|
30
|
+
CollActionType[CollActionType["WITHDRAW"] = 1] = "WITHDRAW";
|
|
31
|
+
})(CollActionType = exports.CollActionType || (exports.CollActionType = {}));
|
|
32
|
+
var DebtActionType;
|
|
33
|
+
(function (DebtActionType) {
|
|
34
|
+
DebtActionType[DebtActionType["PAYBACK"] = 0] = "PAYBACK";
|
|
35
|
+
DebtActionType[DebtActionType["BORROW"] = 1] = "BORROW";
|
|
36
|
+
})(DebtActionType = exports.DebtActionType || (exports.DebtActionType = {}));
|
|
37
|
+
var CloseStrategyType;
|
|
38
|
+
(function (CloseStrategyType) {
|
|
39
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_COLLATERAL"] = 0] = "TAKE_PROFIT_IN_COLLATERAL";
|
|
40
|
+
CloseStrategyType[CloseStrategyType["STOP_LOSS_IN_COLLATERAL"] = 1] = "STOP_LOSS_IN_COLLATERAL";
|
|
41
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_DEBT"] = 2] = "TAKE_PROFIT_IN_DEBT";
|
|
42
|
+
CloseStrategyType[CloseStrategyType["STOP_LOSS_IN_DEBT"] = 3] = "STOP_LOSS_IN_DEBT";
|
|
43
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL"] = 4] = "TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL";
|
|
44
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT"] = 5] = "TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT";
|
|
45
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT"] = 6] = "TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT";
|
|
46
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL"] = 7] = "TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL";
|
|
47
|
+
})(CloseStrategyType = exports.CloseStrategyType || (exports.CloseStrategyType = {}));
|
|
48
|
+
var CloseToAssetType;
|
|
49
|
+
(function (CloseToAssetType) {
|
|
50
|
+
CloseToAssetType[CloseToAssetType["COLLATERAL"] = 0] = "COLLATERAL";
|
|
51
|
+
CloseToAssetType[CloseToAssetType["DEBT"] = 1] = "DEBT";
|
|
52
|
+
})(CloseToAssetType = exports.CloseToAssetType || (exports.CloseToAssetType = {}));
|
|
27
53
|
/**
|
|
28
54
|
* @dev Follow the naming convention:
|
|
29
55
|
* - Enum name consists of two parts, name and version
|
|
@@ -37,6 +63,7 @@ var ProtocolIdentifiers;
|
|
|
37
63
|
(function (StrategiesAutomation) {
|
|
38
64
|
StrategiesAutomation["MakerDAO"] = "MakerDAO";
|
|
39
65
|
StrategiesAutomation["Liquity"] = "Liquity";
|
|
66
|
+
StrategiesAutomation["LiquityV2"] = "Liquity__V2";
|
|
40
67
|
StrategiesAutomation["ChickenBonds"] = "Chicken Bonds";
|
|
41
68
|
StrategiesAutomation["CompoundV2"] = "Compound__V2";
|
|
42
69
|
StrategiesAutomation["CompoundV3"] = "Compound__V3";
|
|
@@ -47,6 +74,7 @@ var ProtocolIdentifiers;
|
|
|
47
74
|
StrategiesAutomation["Spark"] = "Spark";
|
|
48
75
|
StrategiesAutomation["CrvUSD"] = "CurveUSD";
|
|
49
76
|
StrategiesAutomation["MorphoBlue"] = "MorphoBlue";
|
|
77
|
+
StrategiesAutomation["FluidT1"] = "FluidT1";
|
|
50
78
|
})(StrategiesAutomation = ProtocolIdentifiers.StrategiesAutomation || (ProtocolIdentifiers.StrategiesAutomation = {}));
|
|
51
79
|
let LegacyAutomation;
|
|
52
80
|
(function (LegacyAutomation) {
|
|
@@ -104,6 +132,7 @@ var Strategies;
|
|
|
104
132
|
Identifiers["CloseToCollateralWithGasPrice"] = "close-to-collateral-with-gas-price";
|
|
105
133
|
Identifiers["CloseOnPriceToDebt"] = "close-on-price-to-debt";
|
|
106
134
|
Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
|
|
135
|
+
Identifiers["CloseOnPrice"] = "close-on-price";
|
|
107
136
|
Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
|
|
108
137
|
Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
|
|
109
138
|
Identifiers["Rebond"] = "rebond";
|
|
@@ -114,6 +143,7 @@ var Strategies;
|
|
|
114
143
|
Identifiers["DebtInFrontRepay"] = "debt-in-front-repay";
|
|
115
144
|
Identifiers["OpenOrderFromCollateral"] = "open-order-from-collateral";
|
|
116
145
|
Identifiers["OpenOrderFromDebt"] = "open-order-from-debt";
|
|
146
|
+
Identifiers["BoostOnPrice"] = "boost-on-price";
|
|
117
147
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
118
148
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
119
149
|
let IdOverrides;
|
|
@@ -171,6 +201,14 @@ var Bundles;
|
|
|
171
201
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST"] = 35] = "MORPHO_BLUE_EOA_BOOST";
|
|
172
202
|
MainnetIds[MainnetIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 36] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
173
203
|
MainnetIds[MainnetIds["AAVE_V3_REPAY_ON_PRICE"] = 37] = "AAVE_V3_REPAY_ON_PRICE";
|
|
204
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 38] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
205
|
+
MainnetIds[MainnetIds["LIQUITY_V2_REPAY"] = 39] = "LIQUITY_V2_REPAY";
|
|
206
|
+
MainnetIds[MainnetIds["LIQUITY_V2_BOOST"] = 40] = "LIQUITY_V2_BOOST";
|
|
207
|
+
MainnetIds[MainnetIds["LIQUITY_V2_CLOSE"] = 41] = "LIQUITY_V2_CLOSE";
|
|
208
|
+
MainnetIds[MainnetIds["LIQUITY_V2_REPAY_ON_PRICE"] = 42] = "LIQUITY_V2_REPAY_ON_PRICE";
|
|
209
|
+
MainnetIds[MainnetIds["LIQUITY_V2_BOOST_ON_PRICE"] = 43] = "LIQUITY_V2_BOOST_ON_PRICE";
|
|
210
|
+
MainnetIds[MainnetIds["FLUID_T1_REPAY"] = 44] = "FLUID_T1_REPAY";
|
|
211
|
+
MainnetIds[MainnetIds["FLUID_T2_BOOST"] = 45] = "FLUID_T2_BOOST";
|
|
174
212
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
175
213
|
let OptimismIds;
|
|
176
214
|
(function (OptimismIds) {
|
|
@@ -193,6 +231,7 @@ var Bundles;
|
|
|
193
231
|
BaseIds[BaseIds["MORPHO_BLUE_BOOST"] = 9] = "MORPHO_BLUE_BOOST";
|
|
194
232
|
BaseIds[BaseIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 10] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
195
233
|
BaseIds[BaseIds["AAVE_V3_REPAY_ON_PRICE"] = 11] = "AAVE_V3_REPAY_ON_PRICE";
|
|
234
|
+
BaseIds[BaseIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 12] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
196
235
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
197
236
|
let ArbitrumIds;
|
|
198
237
|
(function (ArbitrumIds) {
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type Web3 from 'web3';
|
|
|
2
2
|
import type { AbiItem } from 'web3-utils';
|
|
3
3
|
import type { BaseContract, BlockType } from './contracts/generated/types';
|
|
4
4
|
import type { Subscribe, StrategyModel } from './contracts/generated/SubStorage';
|
|
5
|
-
import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState } from './enums';
|
|
5
|
+
import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState, CloseToAssetType } from './enums';
|
|
6
6
|
export type PlaceholderType = any;
|
|
7
7
|
export type EthereumAddress = string;
|
|
8
8
|
export type BlockNumber = BlockType;
|
|
@@ -69,7 +69,7 @@ export declare namespace Interfaces {
|
|
|
69
69
|
}
|
|
70
70
|
interface Automation {
|
|
71
71
|
provider: Web3;
|
|
72
|
-
providerFork
|
|
72
|
+
providerFork?: Web3;
|
|
73
73
|
}
|
|
74
74
|
interface LegacyAutomation<T extends BaseContract> {
|
|
75
75
|
provider: Web3;
|
|
@@ -123,6 +123,10 @@ export declare namespace Position {
|
|
|
123
123
|
interface BoostOnPriceAave extends CloseOnPriceAave {
|
|
124
124
|
ratio: number;
|
|
125
125
|
}
|
|
126
|
+
interface BoostOnPriceMorpho extends Base {
|
|
127
|
+
marketId: string;
|
|
128
|
+
subHash: string;
|
|
129
|
+
}
|
|
126
130
|
interface CloseOnPriceWithMaximumGasPriceAave extends Base {
|
|
127
131
|
collAsset: EthereumAddress;
|
|
128
132
|
collAssetId: number;
|
|
@@ -134,6 +138,15 @@ export declare namespace Position {
|
|
|
134
138
|
maximumGasPrice: string;
|
|
135
139
|
ratioState: RatioState;
|
|
136
140
|
}
|
|
141
|
+
interface CloseOnPriceLiquityV2 extends Base {
|
|
142
|
+
market: EthereumAddress;
|
|
143
|
+
troveId: string;
|
|
144
|
+
stopLossPrice: string;
|
|
145
|
+
takeProfitPrice: string;
|
|
146
|
+
closeToAssetAddr: EthereumAddress;
|
|
147
|
+
stopLossType: CloseToAssetType | undefined;
|
|
148
|
+
takeProfitType: CloseToAssetType | undefined;
|
|
149
|
+
}
|
|
137
150
|
interface TrailingStop extends Base {
|
|
138
151
|
roundId: number;
|
|
139
152
|
triggerPercentage: number;
|
|
@@ -148,7 +161,7 @@ export declare namespace Position {
|
|
|
148
161
|
subHashRepay?: string;
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD;
|
|
164
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho;
|
|
152
165
|
interface Automated {
|
|
153
166
|
chainId: ChainId;
|
|
154
167
|
positionId: string;
|