@defisaver/automation-sdk 3.1.5 → 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 +35 -0
- package/cjs/services/strategiesService.js +123 -0
- package/cjs/services/strategySubService.d.ts +9 -1
- package/cjs/services/strategySubService.js +30 -1
- package/cjs/services/subDataService.d.ts +43 -1
- package/cjs/services/subDataService.js +143 -1
- package/cjs/services/triggerService.d.ts +33 -0
- package/cjs/services/triggerService.js +63 -1
- package/cjs/services/utils.d.ts +6 -1
- package/cjs/services/utils.js +52 -1
- package/cjs/types/enums.d.ts +34 -2
- package/cjs/types/enums.js +37 -1
- package/cjs/types/index.d.ts +12 -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 +35 -0
- package/esm/services/strategiesService.js +124 -1
- package/esm/services/strategySubService.d.ts +9 -1
- package/esm/services/strategySubService.js +31 -2
- package/esm/services/subDataService.d.ts +43 -1
- package/esm/services/subDataService.js +143 -1
- package/esm/services/triggerService.d.ts +33 -0
- package/esm/services/triggerService.js +62 -0
- package/esm/services/utils.d.ts +6 -1
- package/esm/services/utils.js +50 -1
- package/esm/types/enums.d.ts +34 -2
- package/esm/types/enums.js +36 -0
- package/esm/types/index.d.ts +12 -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 +35 -0
- package/src/services/strategiesService.ts +159 -1
- package/src/services/strategySubService.ts +80 -1
- package/src/services/subDataService.ts +202 -2
- package/src/services/triggerService.ts +96 -0
- package/src/services/utils.ts +60 -1
- package/src/types/enums.ts +36 -0
- package/src/types/index.ts +13 -1
- package/umd/index.js +34219 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
3
|
-
import { Bundles, ChainId, RatioState, Strategies, } from '../types/enums';
|
|
3
|
+
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies, } from '../types/enums';
|
|
4
4
|
import { STRATEGY_IDS } from '../constants';
|
|
5
5
|
import * as subDataService from './subDataService';
|
|
6
6
|
import * as triggerService from './triggerService';
|
|
7
|
-
import { compareAddresses, requireAddress, requireAddresses } from './utils';
|
|
7
|
+
import { compareAddresses, getCloseStrategyType, requireAddress, requireAddresses, } from './utils';
|
|
8
8
|
export const makerEncode = {
|
|
9
9
|
repayFromSavings(bundleId, vaultId, triggerRepayRatio, targetRepayRatio, isBundle = true, chainId = ChainId.Ethereum, daiAddr, mcdCdpManagerAddr) {
|
|
10
10
|
const subData = subDataService.makerRepayFromSavingsSubData.encode(vaultId, targetRepayRatio, chainId, daiAddr, mcdCdpManagerAddr);
|
|
@@ -241,3 +241,32 @@ export const morphoBlueEncode = {
|
|
|
241
241
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
242
242
|
},
|
|
243
243
|
};
|
|
244
|
+
export const liquityV2Encode = {
|
|
245
|
+
leverageManagement(market, troveId, collToken, boldToken, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
246
|
+
const isBundle = true;
|
|
247
|
+
const subData = subDataService.liquityV2LeverageManagementSubData.encode(market, troveId, collToken, boldToken, ratioState, targetRatio);
|
|
248
|
+
const triggerData = triggerService.liquityV2RatioTrigger.encode(market, troveId, triggerRatio, ratioState);
|
|
249
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
250
|
+
},
|
|
251
|
+
closeOnPrice(strategyOrBundleId, market, troveId, collToken, boldToken, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
252
|
+
const isBundle = true;
|
|
253
|
+
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
254
|
+
const subData = subDataService.liquityV2CloseSubData.encode(market, troveId, collToken, boldToken, closeType);
|
|
255
|
+
const triggerData = triggerService.closePriceTrigger.encode(collToken, stopLossPrice, takeProfitPrice);
|
|
256
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
257
|
+
},
|
|
258
|
+
leverageManagementOnPrice(strategyOrBundleId, market, price, state, troveId, collToken, boldToken, targetRatio, isRepayOnPrice) {
|
|
259
|
+
const subDataEncoded = subDataService.liquityV2LeverageManagementOnPriceSubData.encode(market, troveId, collToken, boldToken, targetRatio, isRepayOnPrice);
|
|
260
|
+
const triggerDataEncoded = triggerService.liquityV2QuotePriceTrigger.encode(market, price, state);
|
|
261
|
+
const isBundle = true;
|
|
262
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
export const fluidEncode = {
|
|
266
|
+
leverageManagement(nftId, vault, collToken, debtToken, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
267
|
+
const isBundle = true;
|
|
268
|
+
const subData = subDataService.fluidLeverageManagementSubData.encode(nftId, vault, collToken, debtToken, ratioState, targetRatio);
|
|
269
|
+
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
270
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
271
|
+
},
|
|
272
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthereumAddress } from '../types';
|
|
2
|
-
import type { OrderType } from '../types/enums';
|
|
2
|
+
import type { CloseStrategyType, OrderType } from '../types/enums';
|
|
3
3
|
import { ChainId, RatioState } from '../types/enums';
|
|
4
4
|
export declare const makerRepayFromSavingsSubData: {
|
|
5
5
|
encode(vaultId: number, targetRatioPercentage: number, chainId: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): string[];
|
|
@@ -190,6 +190,37 @@ export declare const aaveV3LeverageManagementOnPriceSubData: {
|
|
|
190
190
|
targetRatio: number;
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
+
export declare const liquityV2LeverageManagementSubData: {
|
|
194
|
+
encode: (market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
195
|
+
decode: (subData: string[]) => {
|
|
196
|
+
market: string;
|
|
197
|
+
troveId: string;
|
|
198
|
+
collToken: string;
|
|
199
|
+
boldToken: string;
|
|
200
|
+
ratioState: RatioState;
|
|
201
|
+
targetRatio: number;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
export declare const liquityV2CloseSubData: {
|
|
205
|
+
encode(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, closeType: CloseStrategyType): string[];
|
|
206
|
+
decode(subData: string[]): {
|
|
207
|
+
market: EthereumAddress;
|
|
208
|
+
troveId: string;
|
|
209
|
+
collToken: EthereumAddress;
|
|
210
|
+
boldToken: EthereumAddress;
|
|
211
|
+
closeType: CloseStrategyType;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
export declare const liquityV2LeverageManagementOnPriceSubData: {
|
|
215
|
+
encode(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, targetRatio: number, isRepayOnPrice: boolean): string[];
|
|
216
|
+
decode(subData: string[]): {
|
|
217
|
+
market: EthereumAddress;
|
|
218
|
+
troveId: string;
|
|
219
|
+
collToken: EthereumAddress;
|
|
220
|
+
boldToken: EthereumAddress;
|
|
221
|
+
targetRatio: number;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
193
224
|
export declare const morphoBlueLeverageManagementOnPriceSubData: {
|
|
194
225
|
encode(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress): string[];
|
|
195
226
|
decode(subData: string[]): {
|
|
@@ -202,3 +233,14 @@ export declare const morphoBlueLeverageManagementOnPriceSubData: {
|
|
|
202
233
|
user: string;
|
|
203
234
|
};
|
|
204
235
|
};
|
|
236
|
+
export declare const fluidLeverageManagementSubData: {
|
|
237
|
+
encode: (nftId: string, vault: EthereumAddress, collToken: EthereumAddress, debtToken: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
238
|
+
decode: (subData: string[]) => {
|
|
239
|
+
nftId: string;
|
|
240
|
+
vault: string;
|
|
241
|
+
collToken: string;
|
|
242
|
+
debtToken: string;
|
|
243
|
+
ratioState: RatioState;
|
|
244
|
+
targetRatio: number;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
@@ -3,7 +3,7 @@ import AbiCoder from 'web3-eth-abi';
|
|
|
3
3
|
import { fromWei, toWei } from 'web3-utils';
|
|
4
4
|
import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
5
5
|
import { otherAddresses } from '@defisaver/sdk';
|
|
6
|
-
import { ChainId, RatioState } from '../types/enums';
|
|
6
|
+
import { ChainId, CollActionType, DebtActionType, RatioState, } from '../types/enums';
|
|
7
7
|
import { ZERO_ADDRESS } from '../constants';
|
|
8
8
|
import { compareAddresses, ratioPercentageToWei, weiToRatioPercentage } from './utils';
|
|
9
9
|
export const makerRepayFromSavingsSubData = {
|
|
@@ -467,6 +467,109 @@ export const aaveV3LeverageManagementOnPriceSubData = {
|
|
|
467
467
|
};
|
|
468
468
|
},
|
|
469
469
|
};
|
|
470
|
+
export const liquityV2LeverageManagementSubData = {
|
|
471
|
+
encode: (market, troveId, collToken, boldToken, ratioState, targetRatio) => {
|
|
472
|
+
const marketEncoded = AbiCoder.encodeParameter('address', market);
|
|
473
|
+
const troveIdEncoded = AbiCoder.encodeParameter('uint256', troveId);
|
|
474
|
+
const collTokenEncoded = AbiCoder.encodeParameter('address', collToken);
|
|
475
|
+
const boldTokenEncoded = AbiCoder.encodeParameter('address', boldToken);
|
|
476
|
+
const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
|
|
477
|
+
const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
478
|
+
const isRepay = ratioState === RatioState.UNDER;
|
|
479
|
+
const collActionType = isRepay ? CollActionType.WITHDRAW : CollActionType.SUPPLY;
|
|
480
|
+
const debtActionType = isRepay ? DebtActionType.PAYBACK : DebtActionType.BORROW;
|
|
481
|
+
const collActionTypeEncoded = AbiCoder.encodeParameter('uint8', collActionType);
|
|
482
|
+
const debtActionTypeEncoded = AbiCoder.encodeParameter('uint8', debtActionType);
|
|
483
|
+
return [
|
|
484
|
+
marketEncoded,
|
|
485
|
+
troveIdEncoded,
|
|
486
|
+
collTokenEncoded,
|
|
487
|
+
boldTokenEncoded,
|
|
488
|
+
ratioStateEncoded,
|
|
489
|
+
targetRatioEncoded,
|
|
490
|
+
collActionTypeEncoded,
|
|
491
|
+
debtActionTypeEncoded,
|
|
492
|
+
];
|
|
493
|
+
},
|
|
494
|
+
decode: (subData) => {
|
|
495
|
+
const market = AbiCoder.decodeParameter('address', subData[0]);
|
|
496
|
+
const troveId = AbiCoder.decodeParameter('uint256', subData[1]);
|
|
497
|
+
const collToken = AbiCoder.decodeParameter('address', subData[2]);
|
|
498
|
+
const boldToken = AbiCoder.decodeParameter('address', subData[3]);
|
|
499
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[4]);
|
|
500
|
+
const weiRatio = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
501
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
502
|
+
return {
|
|
503
|
+
market, troveId, collToken, boldToken, ratioState, targetRatio,
|
|
504
|
+
};
|
|
505
|
+
},
|
|
506
|
+
};
|
|
507
|
+
export const liquityV2CloseSubData = {
|
|
508
|
+
encode(market, troveId, collToken, boldToken, closeType) {
|
|
509
|
+
const marketEncoded = AbiCoder.encodeParameter('address', market);
|
|
510
|
+
const troveIdEncoded = AbiCoder.encodeParameter('uint256', troveId);
|
|
511
|
+
const collAddrEncoded = AbiCoder.encodeParameter('address', collToken);
|
|
512
|
+
const boldTokenEncoded = AbiCoder.encodeParameter('address', boldToken);
|
|
513
|
+
const wethAddress = getAssetInfo('WETH').address;
|
|
514
|
+
const wethAddressEncoded = AbiCoder.encodeParameter('address', wethAddress);
|
|
515
|
+
const gasCompensation = new Dec('0.0375').mul(1e18).toString();
|
|
516
|
+
const gasCompensationEncoded = AbiCoder.encodeParameter('uint256', gasCompensation);
|
|
517
|
+
const closeTypeEncoded = AbiCoder.encodeParameter('uint8', closeType);
|
|
518
|
+
return [
|
|
519
|
+
marketEncoded,
|
|
520
|
+
troveIdEncoded,
|
|
521
|
+
collAddrEncoded,
|
|
522
|
+
boldTokenEncoded,
|
|
523
|
+
wethAddressEncoded,
|
|
524
|
+
gasCompensationEncoded,
|
|
525
|
+
closeTypeEncoded,
|
|
526
|
+
];
|
|
527
|
+
},
|
|
528
|
+
decode(subData) {
|
|
529
|
+
const market = AbiCoder.decodeParameter('address', subData[0]);
|
|
530
|
+
const troveId = AbiCoder.decodeParameter('uint256', subData[1]);
|
|
531
|
+
const collToken = AbiCoder.decodeParameter('address', subData[2]);
|
|
532
|
+
const boldToken = AbiCoder.decodeParameter('address', subData[3]);
|
|
533
|
+
// skip wethAddress and gasCompensation
|
|
534
|
+
const closeType = AbiCoder.decodeParameter('uint8', subData[6]);
|
|
535
|
+
return {
|
|
536
|
+
market, troveId, collToken, boldToken, closeType,
|
|
537
|
+
};
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
export const liquityV2LeverageManagementOnPriceSubData = {
|
|
541
|
+
encode(market, troveId, collToken, boldToken, targetRatio, isRepayOnPrice) {
|
|
542
|
+
const encodedMarket = AbiCoder.encodeParameter('address', market);
|
|
543
|
+
const encodedTroveId = AbiCoder.encodeParameter('uint256', troveId);
|
|
544
|
+
const encodedCollToken = AbiCoder.encodeParameter('address', collToken);
|
|
545
|
+
const encodedBoldToken = AbiCoder.encodeParameter('address', boldToken);
|
|
546
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
547
|
+
const collActionType = isRepayOnPrice ? CollActionType.WITHDRAW : CollActionType.SUPPLY;
|
|
548
|
+
const debtActionType = isRepayOnPrice ? DebtActionType.PAYBACK : DebtActionType.BORROW;
|
|
549
|
+
const encodedCollActionType = AbiCoder.encodeParameter('uint8', collActionType);
|
|
550
|
+
const encodedDebtActionType = AbiCoder.encodeParameter('uint8', debtActionType);
|
|
551
|
+
return [
|
|
552
|
+
encodedMarket,
|
|
553
|
+
encodedTroveId,
|
|
554
|
+
encodedCollToken,
|
|
555
|
+
encodedBoldToken,
|
|
556
|
+
encodedTargetRatio,
|
|
557
|
+
encodedCollActionType,
|
|
558
|
+
encodedDebtActionType,
|
|
559
|
+
];
|
|
560
|
+
},
|
|
561
|
+
decode(subData) {
|
|
562
|
+
const market = AbiCoder.decodeParameter('address', subData[0]);
|
|
563
|
+
const troveId = AbiCoder.decodeParameter('uint256', subData[1]);
|
|
564
|
+
const collToken = AbiCoder.decodeParameter('address', subData[2]);
|
|
565
|
+
const boldToken = AbiCoder.decodeParameter('address', subData[3]);
|
|
566
|
+
const weiRatio = AbiCoder.decodeParameter('uint256', subData[4]);
|
|
567
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
568
|
+
return {
|
|
569
|
+
market, troveId, collToken, boldToken, targetRatio,
|
|
570
|
+
};
|
|
571
|
+
},
|
|
572
|
+
};
|
|
470
573
|
export const morphoBlueLeverageManagementOnPriceSubData = {
|
|
471
574
|
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
472
575
|
const loanTokenEncoded = AbiCoder.encodeParameter('address', loanToken);
|
|
@@ -498,3 +601,42 @@ export const morphoBlueLeverageManagementOnPriceSubData = {
|
|
|
498
601
|
};
|
|
499
602
|
},
|
|
500
603
|
};
|
|
604
|
+
export const fluidLeverageManagementSubData = {
|
|
605
|
+
encode: (nftId, vault, collToken, debtToken, ratioState, targetRatio) => {
|
|
606
|
+
const nftIdEncoded = AbiCoder.encodeParameter('uint256', nftId);
|
|
607
|
+
const vaultEncoded = AbiCoder.encodeParameter('address', vault);
|
|
608
|
+
const collTokenEncoded = AbiCoder.encodeParameter('address', collToken);
|
|
609
|
+
const debtTokenEncoded = AbiCoder.encodeParameter('address', debtToken);
|
|
610
|
+
const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
|
|
611
|
+
const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
612
|
+
const wrapEthEncoded = AbiCoder.encodeParameter('bool', true);
|
|
613
|
+
const isRepay = ratioState === RatioState.UNDER;
|
|
614
|
+
const collActionType = isRepay ? CollActionType.WITHDRAW : CollActionType.SUPPLY;
|
|
615
|
+
const debtActionType = isRepay ? DebtActionType.PAYBACK : DebtActionType.BORROW;
|
|
616
|
+
const collActionTypeEncoded = AbiCoder.encodeParameter('uint8', collActionType);
|
|
617
|
+
const debtActionTypeEncoded = AbiCoder.encodeParameter('uint8', debtActionType);
|
|
618
|
+
return [
|
|
619
|
+
nftIdEncoded,
|
|
620
|
+
vaultEncoded,
|
|
621
|
+
collTokenEncoded,
|
|
622
|
+
debtTokenEncoded,
|
|
623
|
+
ratioStateEncoded,
|
|
624
|
+
targetRatioEncoded,
|
|
625
|
+
wrapEthEncoded,
|
|
626
|
+
collActionTypeEncoded,
|
|
627
|
+
debtActionTypeEncoded,
|
|
628
|
+
];
|
|
629
|
+
},
|
|
630
|
+
decode: (subData) => {
|
|
631
|
+
const nftId = AbiCoder.decodeParameter('uint256', subData[0]);
|
|
632
|
+
const vault = AbiCoder.decodeParameter('address', subData[1]);
|
|
633
|
+
const collToken = AbiCoder.decodeParameter('address', subData[2]);
|
|
634
|
+
const debtToken = AbiCoder.decodeParameter('address', subData[3]);
|
|
635
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[4]);
|
|
636
|
+
const weiRatio = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
637
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
638
|
+
return {
|
|
639
|
+
nftId, vault, collToken, debtToken, ratioState, targetRatio,
|
|
640
|
+
};
|
|
641
|
+
},
|
|
642
|
+
};
|
|
@@ -189,6 +189,31 @@ 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
|
+
};
|
|
192
217
|
export declare const morphoBluePriceTrigger: {
|
|
193
218
|
encode(oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, price: number, priceState: RatioState): string[];
|
|
194
219
|
decode(triggerData: string[]): {
|
|
@@ -199,3 +224,11 @@ export declare const morphoBluePriceTrigger: {
|
|
|
199
224
|
priceState: number;
|
|
200
225
|
};
|
|
201
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
|
+
};
|
|
@@ -336,6 +336,54 @@ export const morphoBlueRatioTrigger = {
|
|
|
336
336
|
};
|
|
337
337
|
},
|
|
338
338
|
};
|
|
339
|
+
export const liquityV2RatioTrigger = {
|
|
340
|
+
encode(market, troveId, ratioPercentage, ratioState) {
|
|
341
|
+
const ratioWei = ratioPercentageToWei(ratioPercentage);
|
|
342
|
+
return [AbiCoder.encodeParameters(['address', 'uint256', 'uint256', 'uint8'], [market, troveId, ratioWei, ratioState])];
|
|
343
|
+
},
|
|
344
|
+
decode(triggerData) {
|
|
345
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
346
|
+
return {
|
|
347
|
+
market: decodedData[0],
|
|
348
|
+
troveId: decodedData[1],
|
|
349
|
+
ratio: weiToRatioPercentage(decodedData[2]),
|
|
350
|
+
ratioState: Number(decodedData[3]),
|
|
351
|
+
};
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
export const liquityV2QuotePriceTrigger = {
|
|
355
|
+
encode(market, price, ratioState) {
|
|
356
|
+
// Price is always in 18 decimals
|
|
357
|
+
const _price = new Dec(price.toString()).mul(Math.pow(10, 18)).floor().toString();
|
|
358
|
+
return [AbiCoder.encodeParameters(['address', 'uint256', 'uint8'], [market, _price, ratioState])];
|
|
359
|
+
},
|
|
360
|
+
decode(triggerData) {
|
|
361
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint8'], triggerData[0]);
|
|
362
|
+
const price = new Dec(decodedData[1]).div(Math.pow(10, 18)).toDP(18).toString();
|
|
363
|
+
return {
|
|
364
|
+
market: decodedData[0],
|
|
365
|
+
price,
|
|
366
|
+
ratioState: Number(decodedData[2]),
|
|
367
|
+
};
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
export const closePriceTrigger = {
|
|
371
|
+
encode(tokenAddr, lowerPrice, upperPrice) {
|
|
372
|
+
const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
|
|
373
|
+
const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
|
|
374
|
+
return [
|
|
375
|
+
AbiCoder.encodeParameters(['address', 'uint256', 'uint256'], [tokenAddr, lowerPriceFormatted, upperPriceFormatted]),
|
|
376
|
+
];
|
|
377
|
+
},
|
|
378
|
+
decode(triggerData) {
|
|
379
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint256'], triggerData[0]);
|
|
380
|
+
return {
|
|
381
|
+
tokenAddr: decodedData[0],
|
|
382
|
+
lowerPrice: new Dec(decodedData[1]).div(1e8).toString(),
|
|
383
|
+
upperPrice: new Dec(decodedData[2]).div(1e8).toString(),
|
|
384
|
+
};
|
|
385
|
+
},
|
|
386
|
+
};
|
|
339
387
|
export const morphoBluePriceTrigger = {
|
|
340
388
|
encode(oracle, collateralToken, loanToken, price, priceState) {
|
|
341
389
|
const _price = new Dec(price.toString()).mul(1e8).floor().toString();
|
|
@@ -354,3 +402,17 @@ export const morphoBluePriceTrigger = {
|
|
|
354
402
|
};
|
|
355
403
|
},
|
|
356
404
|
};
|
|
405
|
+
export const fluidRatioTrigger = {
|
|
406
|
+
encode(nftId, ratioPercentage, ratioState) {
|
|
407
|
+
const ratioWei = ratioPercentageToWei(ratioPercentage);
|
|
408
|
+
return [AbiCoder.encodeParameters(['uint256', 'uint256', 'uint8'], [nftId, ratioWei, ratioState])];
|
|
409
|
+
},
|
|
410
|
+
decode(triggerData) {
|
|
411
|
+
const decodedData = AbiCoder.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
412
|
+
return {
|
|
413
|
+
nftId: decodedData[0],
|
|
414
|
+
ratio: weiToRatioPercentage(decodedData[1]),
|
|
415
|
+
ratioState: Number(decodedData[2]),
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
};
|
package/esm/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/esm/services/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import Dec from 'decimal.js';
|
|
|
2
2
|
import * as web3Utils from 'web3-utils';
|
|
3
3
|
import AbiCoder from 'web3-eth-abi';
|
|
4
4
|
import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
5
|
-
import { ChainId, RatioState } from '../types/enums';
|
|
5
|
+
import { ChainId, CloseStrategyType, CloseToAssetType, RatioState, } from '../types/enums';
|
|
6
6
|
export function isDefined(value) {
|
|
7
7
|
return value !== undefined && value !== null;
|
|
8
8
|
}
|
|
@@ -80,3 +80,52 @@ export function getRatioStateInfoForAaveCloseStrategy(currentRatioState, collAss
|
|
|
80
80
|
export function getPositionId(...args) {
|
|
81
81
|
return args.map(arg => arg.toString().toLowerCase().split(' ').join('_')).join('-');
|
|
82
82
|
}
|
|
83
|
+
export function getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType) {
|
|
84
|
+
const isStopLoss = stopLossPrice > 0;
|
|
85
|
+
const isTakeProfit = takeProfitPrice > 0;
|
|
86
|
+
if (!isStopLoss && !isTakeProfit) {
|
|
87
|
+
throw new Error('CloseOnPrice: At least one price must be defined');
|
|
88
|
+
}
|
|
89
|
+
if (isStopLoss && isTakeProfit) {
|
|
90
|
+
if (stopLossType === CloseToAssetType.COLLATERAL && takeProfitType === CloseToAssetType.COLLATERAL) {
|
|
91
|
+
return CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL;
|
|
92
|
+
}
|
|
93
|
+
if (stopLossType === CloseToAssetType.COLLATERAL) {
|
|
94
|
+
return CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL;
|
|
95
|
+
}
|
|
96
|
+
if (takeProfitType === CloseToAssetType.COLLATERAL) {
|
|
97
|
+
return CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT;
|
|
98
|
+
}
|
|
99
|
+
return CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT;
|
|
100
|
+
}
|
|
101
|
+
if (isStopLoss) {
|
|
102
|
+
return stopLossType === CloseToAssetType.COLLATERAL
|
|
103
|
+
? CloseStrategyType.STOP_LOSS_IN_COLLATERAL
|
|
104
|
+
: CloseStrategyType.STOP_LOSS_IN_DEBT;
|
|
105
|
+
}
|
|
106
|
+
return takeProfitType === CloseToAssetType.COLLATERAL
|
|
107
|
+
? CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL
|
|
108
|
+
: CloseStrategyType.TAKE_PROFIT_IN_DEBT;
|
|
109
|
+
}
|
|
110
|
+
export function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyType) {
|
|
111
|
+
switch (closeStrategyType) {
|
|
112
|
+
case CloseStrategyType.STOP_LOSS_IN_COLLATERAL:
|
|
113
|
+
return { stopLossType: CloseToAssetType.COLLATERAL, takeProfitType: undefined };
|
|
114
|
+
case CloseStrategyType.STOP_LOSS_IN_DEBT:
|
|
115
|
+
return { stopLossType: CloseToAssetType.DEBT, takeProfitType: undefined };
|
|
116
|
+
case CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL:
|
|
117
|
+
return { stopLossType: undefined, takeProfitType: CloseToAssetType.COLLATERAL };
|
|
118
|
+
case CloseStrategyType.TAKE_PROFIT_IN_DEBT:
|
|
119
|
+
return { stopLossType: undefined, takeProfitType: CloseToAssetType.DEBT };
|
|
120
|
+
case CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT:
|
|
121
|
+
return { stopLossType: CloseToAssetType.DEBT, takeProfitType: CloseToAssetType.COLLATERAL };
|
|
122
|
+
case CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL:
|
|
123
|
+
return { stopLossType: CloseToAssetType.COLLATERAL, takeProfitType: CloseToAssetType.DEBT };
|
|
124
|
+
case CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT:
|
|
125
|
+
return { stopLossType: CloseToAssetType.DEBT, takeProfitType: CloseToAssetType.DEBT };
|
|
126
|
+
case CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL:
|
|
127
|
+
return { stopLossType: CloseToAssetType.COLLATERAL, takeProfitType: CloseToAssetType.COLLATERAL };
|
|
128
|
+
default:
|
|
129
|
+
throw new Error('CloseStrategyType not supported');
|
|
130
|
+
}
|
|
131
|
+
}
|
package/esm/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",
|
|
@@ -153,7 +178,14 @@ export declare namespace Bundles {
|
|
|
153
178
|
MORPHO_BLUE_EOA_BOOST = 35,
|
|
154
179
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36,
|
|
155
180
|
AAVE_V3_REPAY_ON_PRICE = 37,
|
|
156
|
-
MORPHO_BLUE_BOOST_ON_PRICE = 38
|
|
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
|
|
157
189
|
}
|
|
158
190
|
enum OptimismIds {
|
|
159
191
|
AAVE_V3_REPAY = 0,
|
package/esm/types/enums.js
CHANGED
|
@@ -21,6 +21,32 @@ export var BundleProtocols;
|
|
|
21
21
|
BundleProtocols["Yearn"] = "yearn";
|
|
22
22
|
BundleProtocols["Rari"] = "rari";
|
|
23
23
|
})(BundleProtocols || (BundleProtocols = {}));
|
|
24
|
+
export var CollActionType;
|
|
25
|
+
(function (CollActionType) {
|
|
26
|
+
CollActionType[CollActionType["SUPPLY"] = 0] = "SUPPLY";
|
|
27
|
+
CollActionType[CollActionType["WITHDRAW"] = 1] = "WITHDRAW";
|
|
28
|
+
})(CollActionType || (CollActionType = {}));
|
|
29
|
+
export var DebtActionType;
|
|
30
|
+
(function (DebtActionType) {
|
|
31
|
+
DebtActionType[DebtActionType["PAYBACK"] = 0] = "PAYBACK";
|
|
32
|
+
DebtActionType[DebtActionType["BORROW"] = 1] = "BORROW";
|
|
33
|
+
})(DebtActionType || (DebtActionType = {}));
|
|
34
|
+
export var CloseStrategyType;
|
|
35
|
+
(function (CloseStrategyType) {
|
|
36
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_COLLATERAL"] = 0] = "TAKE_PROFIT_IN_COLLATERAL";
|
|
37
|
+
CloseStrategyType[CloseStrategyType["STOP_LOSS_IN_COLLATERAL"] = 1] = "STOP_LOSS_IN_COLLATERAL";
|
|
38
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_DEBT"] = 2] = "TAKE_PROFIT_IN_DEBT";
|
|
39
|
+
CloseStrategyType[CloseStrategyType["STOP_LOSS_IN_DEBT"] = 3] = "STOP_LOSS_IN_DEBT";
|
|
40
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL"] = 4] = "TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL";
|
|
41
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT"] = 5] = "TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT";
|
|
42
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT"] = 6] = "TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT";
|
|
43
|
+
CloseStrategyType[CloseStrategyType["TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL"] = 7] = "TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL";
|
|
44
|
+
})(CloseStrategyType || (CloseStrategyType = {}));
|
|
45
|
+
export var CloseToAssetType;
|
|
46
|
+
(function (CloseToAssetType) {
|
|
47
|
+
CloseToAssetType[CloseToAssetType["COLLATERAL"] = 0] = "COLLATERAL";
|
|
48
|
+
CloseToAssetType[CloseToAssetType["DEBT"] = 1] = "DEBT";
|
|
49
|
+
})(CloseToAssetType || (CloseToAssetType = {}));
|
|
24
50
|
/**
|
|
25
51
|
* @dev Follow the naming convention:
|
|
26
52
|
* - Enum name consists of two parts, name and version
|
|
@@ -34,6 +60,7 @@ export var ProtocolIdentifiers;
|
|
|
34
60
|
(function (StrategiesAutomation) {
|
|
35
61
|
StrategiesAutomation["MakerDAO"] = "MakerDAO";
|
|
36
62
|
StrategiesAutomation["Liquity"] = "Liquity";
|
|
63
|
+
StrategiesAutomation["LiquityV2"] = "Liquity__V2";
|
|
37
64
|
StrategiesAutomation["ChickenBonds"] = "Chicken Bonds";
|
|
38
65
|
StrategiesAutomation["CompoundV2"] = "Compound__V2";
|
|
39
66
|
StrategiesAutomation["CompoundV3"] = "Compound__V3";
|
|
@@ -44,6 +71,7 @@ export var ProtocolIdentifiers;
|
|
|
44
71
|
StrategiesAutomation["Spark"] = "Spark";
|
|
45
72
|
StrategiesAutomation["CrvUSD"] = "CurveUSD";
|
|
46
73
|
StrategiesAutomation["MorphoBlue"] = "MorphoBlue";
|
|
74
|
+
StrategiesAutomation["FluidT1"] = "FluidT1";
|
|
47
75
|
})(StrategiesAutomation = ProtocolIdentifiers.StrategiesAutomation || (ProtocolIdentifiers.StrategiesAutomation = {}));
|
|
48
76
|
let LegacyAutomation;
|
|
49
77
|
(function (LegacyAutomation) {
|
|
@@ -101,6 +129,7 @@ export var Strategies;
|
|
|
101
129
|
Identifiers["CloseToCollateralWithGasPrice"] = "close-to-collateral-with-gas-price";
|
|
102
130
|
Identifiers["CloseOnPriceToDebt"] = "close-on-price-to-debt";
|
|
103
131
|
Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
|
|
132
|
+
Identifiers["CloseOnPrice"] = "close-on-price";
|
|
104
133
|
Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
|
|
105
134
|
Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
|
|
106
135
|
Identifiers["Rebond"] = "rebond";
|
|
@@ -170,6 +199,13 @@ export var Bundles;
|
|
|
170
199
|
MainnetIds[MainnetIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 36] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
171
200
|
MainnetIds[MainnetIds["AAVE_V3_REPAY_ON_PRICE"] = 37] = "AAVE_V3_REPAY_ON_PRICE";
|
|
172
201
|
MainnetIds[MainnetIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 38] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
202
|
+
MainnetIds[MainnetIds["LIQUITY_V2_REPAY"] = 39] = "LIQUITY_V2_REPAY";
|
|
203
|
+
MainnetIds[MainnetIds["LIQUITY_V2_BOOST"] = 40] = "LIQUITY_V2_BOOST";
|
|
204
|
+
MainnetIds[MainnetIds["LIQUITY_V2_CLOSE"] = 41] = "LIQUITY_V2_CLOSE";
|
|
205
|
+
MainnetIds[MainnetIds["LIQUITY_V2_REPAY_ON_PRICE"] = 42] = "LIQUITY_V2_REPAY_ON_PRICE";
|
|
206
|
+
MainnetIds[MainnetIds["LIQUITY_V2_BOOST_ON_PRICE"] = 43] = "LIQUITY_V2_BOOST_ON_PRICE";
|
|
207
|
+
MainnetIds[MainnetIds["FLUID_T1_REPAY"] = 44] = "FLUID_T1_REPAY";
|
|
208
|
+
MainnetIds[MainnetIds["FLUID_T2_BOOST"] = 45] = "FLUID_T2_BOOST";
|
|
173
209
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
174
210
|
let OptimismIds;
|
|
175
211
|
(function (OptimismIds) {
|
package/esm/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;
|
|
@@ -138,6 +138,15 @@ export declare namespace Position {
|
|
|
138
138
|
maximumGasPrice: string;
|
|
139
139
|
ratioState: RatioState;
|
|
140
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
|
+
}
|
|
141
150
|
interface TrailingStop extends Base {
|
|
142
151
|
roundId: number;
|
|
143
152
|
triggerPercentage: number;
|
|
@@ -152,7 +161,7 @@ export declare namespace Position {
|
|
|
152
161
|
subHashRepay?: string;
|
|
153
162
|
}
|
|
154
163
|
}
|
|
155
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.BoostOnPriceMorpho;
|
|
164
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho;
|
|
156
165
|
interface Automated {
|
|
157
166
|
chainId: ChainId;
|
|
158
167
|
positionId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/automation-sdk",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6-fluid-dev",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@defisaver/eslint-config": "^1.0.1",
|
|
27
|
-
"@defisaver/sdk": "^1.
|
|
28
|
-
"@defisaver/tokens": "^1.5.
|
|
27
|
+
"@defisaver/sdk": "^1.2.17",
|
|
28
|
+
"@defisaver/tokens": "^1.5.54",
|
|
29
29
|
"@ethersproject/address": "^5.0.10",
|
|
30
30
|
"@ethersproject/solidity": "^5.0.9",
|
|
31
31
|
"decimal.js": "^10.4.3",
|