@defisaver/automation-sdk 2.0.1 → 2.0.2
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/esm/constants/index.js +10 -0
- package/esm/services/strategiesService.js +17 -0
- package/esm/services/strategySubService.d.ts +2 -0
- package/esm/services/strategySubService.js +16 -0
- package/esm/services/subDataService.d.ts +12 -0
- package/esm/services/subDataService.js +33 -1
- package/esm/services/triggerService.d.ts +3 -3
- package/esm/services/triggerService.js +2 -2
- package/esm/types/enums.d.ts +9 -1
- package/esm/types/enums.js +9 -0
- package/package.json +2 -2
- package/src/constants/index.ts +10 -0
- package/src/services/strategiesService.ts +24 -0
- package/src/services/strategySubService.ts +30 -0
- package/src/services/subDataService.ts +39 -1
- package/src/services/triggerService.ts +4 -3
- package/src/types/enums.ts +9 -0
- package/umd/index.js +96 -3
package/esm/constants/index.js
CHANGED
|
@@ -69,6 +69,16 @@ export const MAINNET_STRATEGIES_INFO = {
|
|
|
69
69
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
70
70
|
protocol: PROTOCOLS.Exchange,
|
|
71
71
|
},
|
|
72
|
+
[Strategies.MainnetIds.LIQUITY_DSR_PAYBACK]: {
|
|
73
|
+
strategyOrBundleId: Strategies.MainnetIds.LIQUITY_DSR_PAYBACK,
|
|
74
|
+
strategyId: Strategies.Identifiers.SavingsDsrPayback,
|
|
75
|
+
protocol: PROTOCOLS.Liquity,
|
|
76
|
+
},
|
|
77
|
+
[Strategies.MainnetIds.LIQUITY_DSR_SUPPLY]: {
|
|
78
|
+
strategyOrBundleId: Strategies.MainnetIds.LIQUITY_DSR_SUPPLY,
|
|
79
|
+
strategyId: Strategies.Identifiers.SavingsDsrSupply,
|
|
80
|
+
protocol: PROTOCOLS.Liquity,
|
|
81
|
+
},
|
|
72
82
|
};
|
|
73
83
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
74
84
|
[Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -393,6 +393,21 @@ function parseSparkCloseOnPrice(position, parseData) {
|
|
|
393
393
|
_position.strategy.strategyId = isRatioStateOver(ratioState) ? Strategies.IdOverrides.TakeProfit : Strategies.IdOverrides.StopLoss;
|
|
394
394
|
return _position;
|
|
395
395
|
}
|
|
396
|
+
function parseLiquitySavingsLiqProtection(position, parseData) {
|
|
397
|
+
const _position = cloneDeep(position);
|
|
398
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
399
|
+
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
400
|
+
const subData = subDataService.makerRepayFromSavingsSubData.decode(subStruct.subData);
|
|
401
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
402
|
+
_position.strategyData.decoded.subData = subData;
|
|
403
|
+
_position.specific = {
|
|
404
|
+
triggerRepayRatio: triggerData.ratio,
|
|
405
|
+
targetRepayRatio: subData.targetRatio,
|
|
406
|
+
repayEnabled: true,
|
|
407
|
+
boostEnabled: false,
|
|
408
|
+
};
|
|
409
|
+
return _position;
|
|
410
|
+
}
|
|
396
411
|
const parsingMethodsMapping = {
|
|
397
412
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
398
413
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -409,6 +424,8 @@ const parsingMethodsMapping = {
|
|
|
409
424
|
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
410
425
|
[Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
411
426
|
[Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
427
|
+
[Strategies.Identifiers.SavingsDsrPayback]: parseLiquitySavingsLiqProtection,
|
|
428
|
+
[Strategies.Identifiers.SavingsDsrSupply]: parseLiquitySavingsLiqProtection,
|
|
412
429
|
},
|
|
413
430
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV2]: {
|
|
414
431
|
[Strategies.Identifiers.Repay]: parseAaveV2LeverageManagement,
|
|
@@ -11,6 +11,8 @@ export declare const liquityEncode: {
|
|
|
11
11
|
trailingStop(triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
12
12
|
paybackFromChickenBondStrategySub(proxyAddress: EthereumAddress, ratio: number, sourceId: string, sourceType: number, ratioState?: RatioState): (boolean | string[] | Bundles.MainnetIds)[];
|
|
13
13
|
leverageManagement(triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string, targetRepayRatio: string, boostEnabled: boolean): (string | boolean)[];
|
|
14
|
+
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
15
|
+
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
14
16
|
};
|
|
15
17
|
export declare const chickenBondsEncode: {
|
|
16
18
|
rebond(bondId: number): string[];
|
|
@@ -75,6 +75,22 @@ export const liquityEncode = {
|
|
|
75
75
|
boostEnabled,
|
|
76
76
|
];
|
|
77
77
|
},
|
|
78
|
+
dsrPayback(proxyAddress, triggerRatio, targetRatio) {
|
|
79
|
+
requireAddress(proxyAddress);
|
|
80
|
+
const subData = subDataService.liquityDsrPaybackSubData.encode(targetRatio);
|
|
81
|
+
const triggerData = triggerService.liquityRatioTrigger.encode(proxyAddress, triggerRatio, RatioState.UNDER);
|
|
82
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_DSR_PAYBACK;
|
|
83
|
+
const isBundle = false;
|
|
84
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
85
|
+
},
|
|
86
|
+
dsrSupply(proxyAddress, triggerRatio, targetRatio) {
|
|
87
|
+
requireAddress(proxyAddress);
|
|
88
|
+
const subData = subDataService.liquityDsrSupplySubData.encode(targetRatio);
|
|
89
|
+
const triggerData = triggerService.liquityRatioTrigger.encode(proxyAddress, triggerRatio, RatioState.UNDER);
|
|
90
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_DSR_SUPPLY;
|
|
91
|
+
const isBundle = false;
|
|
92
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
93
|
+
},
|
|
78
94
|
};
|
|
79
95
|
export const chickenBondsEncode = {
|
|
80
96
|
rebond(bondId) {
|
|
@@ -121,3 +121,15 @@ export declare const sparkQuotePriceSubData: {
|
|
|
121
121
|
debtAssetId: number;
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
+
export declare const liquityDsrPaybackSubData: {
|
|
125
|
+
encode: (targetRatio: number) => string[];
|
|
126
|
+
decode: (subData: string[]) => {
|
|
127
|
+
targetRatio: number;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export declare const liquityDsrSupplySubData: {
|
|
131
|
+
encode: (targetRatio: number) => string[];
|
|
132
|
+
decode: (subData: string[]) => {
|
|
133
|
+
targetRatio: number;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
3
3
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
|
-
import { ChainId } from '../types/enums';
|
|
4
|
+
import { ChainId, RatioState } from '../types/enums';
|
|
5
5
|
import { ZERO_ADDRESS } from '../constants';
|
|
6
6
|
import { compareAddresses, ratioPercentageToWei, weiToRatioPercentage } from './utils';
|
|
7
7
|
const { mockedWeb3 } = process;
|
|
@@ -286,3 +286,35 @@ export const sparkQuotePriceSubData = {
|
|
|
286
286
|
};
|
|
287
287
|
},
|
|
288
288
|
};
|
|
289
|
+
export const liquityDsrPaybackSubData = {
|
|
290
|
+
encode: (targetRatio) => {
|
|
291
|
+
const daiAddress = getAssetInfo('DAI').address;
|
|
292
|
+
const lusdAddress = getAssetInfo('LUSD').address;
|
|
293
|
+
const ratioStateEncoded = mockedWeb3.eth.abi.encodeParameter('uint8', RatioState.UNDER);
|
|
294
|
+
const targetRatioEncoded = mockedWeb3.eth.abi.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
295
|
+
const daiAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', daiAddress);
|
|
296
|
+
const lusdAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', lusdAddress);
|
|
297
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, lusdAddressEncoded];
|
|
298
|
+
},
|
|
299
|
+
decode: (subData) => {
|
|
300
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
301
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
302
|
+
return { targetRatio };
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
export const liquityDsrSupplySubData = {
|
|
306
|
+
encode: (targetRatio) => {
|
|
307
|
+
const daiAddress = getAssetInfo('DAI').address;
|
|
308
|
+
const wethAddress = getAssetInfo('WETH').address;
|
|
309
|
+
const ratioStateEncoded = mockedWeb3.eth.abi.encodeParameter('uint8', RatioState.UNDER);
|
|
310
|
+
const targetRatioEncoded = mockedWeb3.eth.abi.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
311
|
+
const daiAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', daiAddress);
|
|
312
|
+
const wethAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', wethAddress);
|
|
313
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, wethAddressEncoded];
|
|
314
|
+
},
|
|
315
|
+
decode: (subData) => {
|
|
316
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
317
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
318
|
+
return { targetRatio };
|
|
319
|
+
},
|
|
320
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthereumAddress } from '../types';
|
|
2
|
-
import type { RatioState } from '../types/enums';
|
|
2
|
+
import type { RatioState, OrderType } from '../types/enums';
|
|
3
3
|
export declare const chainlinkPriceTrigger: {
|
|
4
4
|
encode(tokenAddr: EthereumAddress, price: string, state: RatioState): string[];
|
|
5
5
|
decode(triggerData: string[]): {
|
|
@@ -105,9 +105,9 @@ export declare const exchangeTimestampTrigger: {
|
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
export declare const exchangeOffchainPriceTrigger: {
|
|
108
|
-
encode(targetPrice: string, goodUntil: number, fromTokenDecimals: number): string[];
|
|
108
|
+
encode(targetPrice: string, goodUntil: number, orderType: OrderType, fromTokenDecimals: number): string[];
|
|
109
109
|
decode(triggerData: string[], fromTokenDecimals: number, toTokenDecimals: number): {
|
|
110
|
-
orderType:
|
|
110
|
+
orderType: OrderType;
|
|
111
111
|
targetPrice: string;
|
|
112
112
|
goodUntil: any;
|
|
113
113
|
};
|
|
@@ -173,10 +173,10 @@ export const exchangeTimestampTrigger = {
|
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
175
|
export const exchangeOffchainPriceTrigger = {
|
|
176
|
-
encode(targetPrice, goodUntil, fromTokenDecimals) {
|
|
176
|
+
encode(targetPrice, goodUntil, orderType, fromTokenDecimals) {
|
|
177
177
|
const price = new Dec(targetPrice.toString()).mul(Math.pow(10, fromTokenDecimals)).floor().toString();
|
|
178
178
|
const goodUntilWei = mockedWeb3.utils.toWei(new Dec(goodUntil).toString());
|
|
179
|
-
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei])];
|
|
179
|
+
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei, orderType])];
|
|
180
180
|
},
|
|
181
181
|
decode(triggerData, fromTokenDecimals, toTokenDecimals) {
|
|
182
182
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare enum RatioState {
|
|
|
7
7
|
OVER = 0,
|
|
8
8
|
UNDER = 1
|
|
9
9
|
}
|
|
10
|
+
export declare enum OrderType {
|
|
11
|
+
TAKE_PROFIT = 0,
|
|
12
|
+
STOP_LOSS = 1
|
|
13
|
+
}
|
|
10
14
|
export declare enum BundleProtocols {
|
|
11
15
|
MStable = "mstable",
|
|
12
16
|
Yearn = "yearn",
|
|
@@ -49,7 +53,9 @@ export declare namespace Strategies {
|
|
|
49
53
|
LIQUITY_CLOSE_ON_PRICE_TO_COLL = 14,
|
|
50
54
|
CHICKEN_BONDS_REBOND = 31,
|
|
51
55
|
EXCHANGE_DCA = 46,
|
|
52
|
-
EXCHANGE_LIMIT_ORDER = 51
|
|
56
|
+
EXCHANGE_LIMIT_ORDER = 51,
|
|
57
|
+
LIQUITY_DSR_PAYBACK = 69,
|
|
58
|
+
LIQUITY_DSR_SUPPLY = 70
|
|
53
59
|
}
|
|
54
60
|
enum OptimismIds {
|
|
55
61
|
EXCHANGE_DCA = 8,
|
|
@@ -61,6 +67,8 @@ export declare namespace Strategies {
|
|
|
61
67
|
}
|
|
62
68
|
enum Identifiers {
|
|
63
69
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
70
|
+
SavingsDsrPayback = "smart-savings-dsr-payback",
|
|
71
|
+
SavingsDsrSupply = "smart-savings-dsr-supply",
|
|
64
72
|
Repay = "repay",
|
|
65
73
|
EoaRepay = "eoa-repay",
|
|
66
74
|
Boost = "boost",
|
package/esm/types/enums.js
CHANGED
|
@@ -9,6 +9,11 @@ export var RatioState;
|
|
|
9
9
|
RatioState[RatioState["OVER"] = 0] = "OVER";
|
|
10
10
|
RatioState[RatioState["UNDER"] = 1] = "UNDER";
|
|
11
11
|
})(RatioState || (RatioState = {}));
|
|
12
|
+
export var OrderType;
|
|
13
|
+
(function (OrderType) {
|
|
14
|
+
OrderType[OrderType["TAKE_PROFIT"] = 0] = "TAKE_PROFIT";
|
|
15
|
+
OrderType[OrderType["STOP_LOSS"] = 1] = "STOP_LOSS";
|
|
16
|
+
})(OrderType || (OrderType = {}));
|
|
12
17
|
export var BundleProtocols;
|
|
13
18
|
(function (BundleProtocols) {
|
|
14
19
|
BundleProtocols["MStable"] = "mstable";
|
|
@@ -58,6 +63,8 @@ export var Strategies;
|
|
|
58
63
|
MainnetIds[MainnetIds["CHICKEN_BONDS_REBOND"] = 31] = "CHICKEN_BONDS_REBOND";
|
|
59
64
|
MainnetIds[MainnetIds["EXCHANGE_DCA"] = 46] = "EXCHANGE_DCA";
|
|
60
65
|
MainnetIds[MainnetIds["EXCHANGE_LIMIT_ORDER"] = 51] = "EXCHANGE_LIMIT_ORDER";
|
|
66
|
+
MainnetIds[MainnetIds["LIQUITY_DSR_PAYBACK"] = 69] = "LIQUITY_DSR_PAYBACK";
|
|
67
|
+
MainnetIds[MainnetIds["LIQUITY_DSR_SUPPLY"] = 70] = "LIQUITY_DSR_SUPPLY";
|
|
61
68
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
62
69
|
let OptimismIds;
|
|
63
70
|
(function (OptimismIds) {
|
|
@@ -72,6 +79,8 @@ export var Strategies;
|
|
|
72
79
|
let Identifiers;
|
|
73
80
|
(function (Identifiers) {
|
|
74
81
|
Identifiers["SavingsLiqProtection"] = "smart-savings-liquidation-protection";
|
|
82
|
+
Identifiers["SavingsDsrPayback"] = "smart-savings-dsr-payback";
|
|
83
|
+
Identifiers["SavingsDsrSupply"] = "smart-savings-dsr-supply";
|
|
75
84
|
Identifiers["Repay"] = "repay";
|
|
76
85
|
Identifiers["EoaRepay"] = "eoa-repay";
|
|
77
86
|
Identifiers["Boost"] = "boost";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/automation-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./umd/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"web3-eth-abi": "^1.8.0",
|
|
62
62
|
"web3-eth-contract": "^1.8.1",
|
|
63
63
|
"web3-utils": "^1.8.0",
|
|
64
|
-
"webpack": "^5.
|
|
64
|
+
"webpack": "^5.76.0",
|
|
65
65
|
"webpack-cli": "^4.10.0"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/constants/index.ts
CHANGED
|
@@ -80,6 +80,16 @@ export const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo = {
|
|
|
80
80
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
81
81
|
protocol: PROTOCOLS.Exchange,
|
|
82
82
|
},
|
|
83
|
+
[Strategies.MainnetIds.LIQUITY_DSR_PAYBACK]: {
|
|
84
|
+
strategyOrBundleId: Strategies.MainnetIds.LIQUITY_DSR_PAYBACK,
|
|
85
|
+
strategyId: Strategies.Identifiers.SavingsDsrPayback,
|
|
86
|
+
protocol: PROTOCOLS.Liquity,
|
|
87
|
+
},
|
|
88
|
+
[Strategies.MainnetIds.LIQUITY_DSR_SUPPLY]: {
|
|
89
|
+
strategyOrBundleId: Strategies.MainnetIds.LIQUITY_DSR_SUPPLY,
|
|
90
|
+
strategyId: Strategies.Identifiers.SavingsDsrSupply,
|
|
91
|
+
protocol: PROTOCOLS.Liquity,
|
|
92
|
+
},
|
|
83
93
|
};
|
|
84
94
|
|
|
85
95
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
@@ -530,6 +530,28 @@ function parseSparkCloseOnPrice(position: Position.Automated, parseData: ParseDa
|
|
|
530
530
|
return _position;
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
+
function parseLiquitySavingsLiqProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
534
|
+
const _position = cloneDeep(position);
|
|
535
|
+
|
|
536
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
537
|
+
|
|
538
|
+
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
539
|
+
const subData = subDataService.makerRepayFromSavingsSubData.decode(subStruct.subData);
|
|
540
|
+
|
|
541
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
542
|
+
_position.strategyData.decoded.subData = subData;
|
|
543
|
+
|
|
544
|
+
_position.specific = {
|
|
545
|
+
triggerRepayRatio: triggerData.ratio,
|
|
546
|
+
targetRepayRatio: subData.targetRatio,
|
|
547
|
+
repayEnabled: true,
|
|
548
|
+
boostEnabled: false,
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
return _position;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
|
|
533
555
|
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
534
556
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
535
557
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -546,6 +568,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
546
568
|
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
547
569
|
[Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
548
570
|
[Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
571
|
+
[Strategies.Identifiers.SavingsDsrPayback]: parseLiquitySavingsLiqProtection,
|
|
572
|
+
[Strategies.Identifiers.SavingsDsrSupply]: parseLiquitySavingsLiqProtection,
|
|
549
573
|
},
|
|
550
574
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV2]: {
|
|
551
575
|
[Strategies.Identifiers.Repay]: parseAaveV2LeverageManagement,
|
|
@@ -164,6 +164,36 @@ export const liquityEncode = {
|
|
|
164
164
|
boostEnabled,
|
|
165
165
|
];
|
|
166
166
|
},
|
|
167
|
+
dsrPayback(
|
|
168
|
+
proxyAddress: EthereumAddress,
|
|
169
|
+
triggerRatio: number,
|
|
170
|
+
targetRatio: number,
|
|
171
|
+
) {
|
|
172
|
+
requireAddress(proxyAddress);
|
|
173
|
+
const subData = subDataService.liquityDsrPaybackSubData.encode(targetRatio);
|
|
174
|
+
const triggerData = triggerService.liquityRatioTrigger.encode(proxyAddress, triggerRatio, RatioState.UNDER);
|
|
175
|
+
|
|
176
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_DSR_PAYBACK;
|
|
177
|
+
|
|
178
|
+
const isBundle = false;
|
|
179
|
+
|
|
180
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
181
|
+
},
|
|
182
|
+
dsrSupply(
|
|
183
|
+
proxyAddress: EthereumAddress,
|
|
184
|
+
triggerRatio: number,
|
|
185
|
+
targetRatio: number,
|
|
186
|
+
) {
|
|
187
|
+
requireAddress(proxyAddress);
|
|
188
|
+
const subData = subDataService.liquityDsrSupplySubData.encode(targetRatio);
|
|
189
|
+
const triggerData = triggerService.liquityRatioTrigger.encode(proxyAddress, triggerRatio, RatioState.UNDER);
|
|
190
|
+
|
|
191
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_DSR_SUPPLY;
|
|
192
|
+
|
|
193
|
+
const isBundle = false;
|
|
194
|
+
|
|
195
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
196
|
+
},
|
|
167
197
|
};
|
|
168
198
|
|
|
169
199
|
export const chickenBondsEncode = {
|
|
@@ -3,7 +3,7 @@ import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress } from '@defisave
|
|
|
3
3
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
4
|
|
|
5
5
|
import type { EthereumAddress, SubData } from '../types';
|
|
6
|
-
import { ChainId } from '../types/enums';
|
|
6
|
+
import { ChainId, RatioState } from '../types/enums';
|
|
7
7
|
|
|
8
8
|
import { ZERO_ADDRESS } from '../constants';
|
|
9
9
|
|
|
@@ -391,3 +391,41 @@ export const sparkQuotePriceSubData = {
|
|
|
391
391
|
};
|
|
392
392
|
},
|
|
393
393
|
};
|
|
394
|
+
|
|
395
|
+
export const liquityDsrPaybackSubData = {
|
|
396
|
+
encode: (targetRatio: number) => {
|
|
397
|
+
const daiAddress = getAssetInfo('DAI').address;
|
|
398
|
+
const lusdAddress = getAssetInfo('LUSD').address;
|
|
399
|
+
|
|
400
|
+
const ratioStateEncoded = mockedWeb3.eth.abi.encodeParameter('uint8', RatioState.UNDER);
|
|
401
|
+
const targetRatioEncoded = mockedWeb3.eth.abi.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
402
|
+
const daiAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', daiAddress);
|
|
403
|
+
const lusdAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', lusdAddress);
|
|
404
|
+
|
|
405
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, lusdAddressEncoded];
|
|
406
|
+
},
|
|
407
|
+
decode: (subData: SubData) => {
|
|
408
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]) as any as string;
|
|
409
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
410
|
+
return { targetRatio };
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
export const liquityDsrSupplySubData = {
|
|
415
|
+
encode: (targetRatio: number) => {
|
|
416
|
+
const daiAddress = getAssetInfo('DAI').address;
|
|
417
|
+
const wethAddress = getAssetInfo('WETH').address;
|
|
418
|
+
|
|
419
|
+
const ratioStateEncoded = mockedWeb3.eth.abi.encodeParameter('uint8', RatioState.UNDER);
|
|
420
|
+
const targetRatioEncoded = mockedWeb3.eth.abi.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
421
|
+
const daiAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', daiAddress);
|
|
422
|
+
const wethAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', wethAddress);
|
|
423
|
+
|
|
424
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, wethAddressEncoded];
|
|
425
|
+
},
|
|
426
|
+
decode: (subData: SubData) => {
|
|
427
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]) as any as string;
|
|
428
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
429
|
+
return { targetRatio };
|
|
430
|
+
},
|
|
431
|
+
};
|
|
@@ -3,7 +3,7 @@ import Dec from 'decimal.js';
|
|
|
3
3
|
import type {
|
|
4
4
|
EthereumAddress, TriggerData,
|
|
5
5
|
} from '../types';
|
|
6
|
-
import type { RatioState } from '../types/enums';
|
|
6
|
+
import type { RatioState, OrderType } from '../types/enums';
|
|
7
7
|
|
|
8
8
|
import { ratioPercentageToWei } from './utils';
|
|
9
9
|
|
|
@@ -215,17 +215,18 @@ export const exchangeOffchainPriceTrigger = {
|
|
|
215
215
|
encode(
|
|
216
216
|
targetPrice: string,
|
|
217
217
|
goodUntil: number,
|
|
218
|
+
orderType: OrderType,
|
|
218
219
|
fromTokenDecimals: number,
|
|
219
220
|
) {
|
|
220
221
|
const price = new Dec(targetPrice.toString()).mul(10 ** fromTokenDecimals).floor().toString();
|
|
221
222
|
const goodUntilWei = mockedWeb3.utils.toWei(new Dec(goodUntil).toString());
|
|
222
|
-
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei])];
|
|
223
|
+
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei, orderType])];
|
|
223
224
|
},
|
|
224
225
|
decode(
|
|
225
226
|
triggerData: TriggerData,
|
|
226
227
|
fromTokenDecimals: number,
|
|
227
228
|
toTokenDecimals: number,
|
|
228
|
-
): { orderType:
|
|
229
|
+
): { orderType: OrderType; targetPrice: string; goodUntil: any } {
|
|
229
230
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
230
231
|
const decimals = new Dec(toTokenDecimals).plus(18).minus(fromTokenDecimals).toString();
|
|
231
232
|
const price = new Dec(decodedData[0]).div(new Dec(10).pow(decimals)).toDP(fromTokenDecimals).toString();
|
package/src/types/enums.ts
CHANGED
|
@@ -9,6 +9,11 @@ export enum RatioState {
|
|
|
9
9
|
UNDER = 1,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export enum OrderType {
|
|
13
|
+
TAKE_PROFIT = 0,
|
|
14
|
+
STOP_LOSS = 1,
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export enum BundleProtocols {
|
|
13
18
|
MStable = 'mstable',
|
|
14
19
|
Yearn = 'yearn',
|
|
@@ -55,6 +60,8 @@ export namespace Strategies {
|
|
|
55
60
|
CHICKEN_BONDS_REBOND = 31,
|
|
56
61
|
EXCHANGE_DCA = 46,
|
|
57
62
|
EXCHANGE_LIMIT_ORDER = 51,
|
|
63
|
+
LIQUITY_DSR_PAYBACK = 69,
|
|
64
|
+
LIQUITY_DSR_SUPPLY = 70,
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
export enum OptimismIds {
|
|
@@ -69,6 +76,8 @@ export namespace Strategies {
|
|
|
69
76
|
|
|
70
77
|
export enum Identifiers {
|
|
71
78
|
SavingsLiqProtection = 'smart-savings-liquidation-protection',
|
|
79
|
+
SavingsDsrPayback = 'smart-savings-dsr-payback',
|
|
80
|
+
SavingsDsrSupply = 'smart-savings-dsr-supply',
|
|
72
81
|
Repay = 'repay',
|
|
73
82
|
EoaRepay = 'eoa-repay',
|
|
74
83
|
Boost = 'boost',
|
package/umd/index.js
CHANGED
|
@@ -174,6 +174,16 @@ var MAINNET_STRATEGIES_INFO = {
|
|
|
174
174
|
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.MainnetIds.EXCHANGE_LIMIT_ORDER,
|
|
175
175
|
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.LimitOrder,
|
|
176
176
|
protocol: PROTOCOLS.Exchange
|
|
177
|
+
},
|
|
178
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.MainnetIds.LIQUITY_DSR_PAYBACK]: {
|
|
179
|
+
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.MainnetIds.LIQUITY_DSR_PAYBACK,
|
|
180
|
+
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.SavingsDsrPayback,
|
|
181
|
+
protocol: PROTOCOLS.Liquity
|
|
182
|
+
},
|
|
183
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.MainnetIds.LIQUITY_DSR_SUPPLY]: {
|
|
184
|
+
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.MainnetIds.LIQUITY_DSR_SUPPLY,
|
|
185
|
+
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.SavingsDsrSupply,
|
|
186
|
+
protocol: PROTOCOLS.Liquity
|
|
177
187
|
}
|
|
178
188
|
};
|
|
179
189
|
var OPTIMISM_STRATEGIES_INFO = {
|
|
@@ -415,6 +425,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
415
425
|
/* harmony export */ "BundleProtocols": () => (/* binding */ BundleProtocols),
|
|
416
426
|
/* harmony export */ "Bundles": () => (/* binding */ Bundles),
|
|
417
427
|
/* harmony export */ "ChainId": () => (/* binding */ ChainId),
|
|
428
|
+
/* harmony export */ "OrderType": () => (/* binding */ OrderType),
|
|
418
429
|
/* harmony export */ "ProtocolIdentifiers": () => (/* binding */ ProtocolIdentifiers),
|
|
419
430
|
/* harmony export */ "RatioState": () => (/* binding */ RatioState),
|
|
420
431
|
/* harmony export */ "Strategies": () => (/* binding */ Strategies)
|
|
@@ -430,6 +441,11 @@ var RatioState;
|
|
|
430
441
|
RatioState[RatioState["OVER"] = 0] = "OVER";
|
|
431
442
|
RatioState[RatioState["UNDER"] = 1] = "UNDER";
|
|
432
443
|
})(RatioState || (RatioState = {}));
|
|
444
|
+
var OrderType;
|
|
445
|
+
(function (OrderType) {
|
|
446
|
+
OrderType[OrderType["TAKE_PROFIT"] = 0] = "TAKE_PROFIT";
|
|
447
|
+
OrderType[OrderType["STOP_LOSS"] = 1] = "STOP_LOSS";
|
|
448
|
+
})(OrderType || (OrderType = {}));
|
|
433
449
|
var BundleProtocols;
|
|
434
450
|
|
|
435
451
|
/**
|
|
@@ -482,6 +498,8 @@ var Strategies;
|
|
|
482
498
|
MainnetIds[MainnetIds["CHICKEN_BONDS_REBOND"] = 31] = "CHICKEN_BONDS_REBOND";
|
|
483
499
|
MainnetIds[MainnetIds["EXCHANGE_DCA"] = 46] = "EXCHANGE_DCA";
|
|
484
500
|
MainnetIds[MainnetIds["EXCHANGE_LIMIT_ORDER"] = 51] = "EXCHANGE_LIMIT_ORDER";
|
|
501
|
+
MainnetIds[MainnetIds["LIQUITY_DSR_PAYBACK"] = 69] = "LIQUITY_DSR_PAYBACK";
|
|
502
|
+
MainnetIds[MainnetIds["LIQUITY_DSR_SUPPLY"] = 70] = "LIQUITY_DSR_SUPPLY";
|
|
485
503
|
})(MainnetIds || (MainnetIds = {}));
|
|
486
504
|
_Strategies.MainnetIds = MainnetIds;
|
|
487
505
|
var OptimismIds;
|
|
@@ -499,6 +517,8 @@ var Strategies;
|
|
|
499
517
|
var Identifiers;
|
|
500
518
|
(function (Identifiers) {
|
|
501
519
|
Identifiers["SavingsLiqProtection"] = "smart-savings-liquidation-protection";
|
|
520
|
+
Identifiers["SavingsDsrPayback"] = "smart-savings-dsr-payback";
|
|
521
|
+
Identifiers["SavingsDsrSupply"] = "smart-savings-dsr-supply";
|
|
502
522
|
Identifiers["Repay"] = "repay";
|
|
503
523
|
Identifiers["EoaRepay"] = "eoa-repay";
|
|
504
524
|
Identifiers["Boost"] = "boost";
|
|
@@ -1956,6 +1976,23 @@ function parseSparkCloseOnPrice(position, parseData) {
|
|
|
1956
1976
|
_position.strategy.strategyId = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.isRatioStateOver)(ratioState) ? _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.TakeProfit : _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.StopLoss;
|
|
1957
1977
|
return _position;
|
|
1958
1978
|
}
|
|
1979
|
+
function parseLiquitySavingsLiqProtection(position, parseData) {
|
|
1980
|
+
var _position = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(position);
|
|
1981
|
+
var {
|
|
1982
|
+
subStruct
|
|
1983
|
+
} = parseData.subscriptionEventData;
|
|
1984
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.makerRatioTrigger.decode(subStruct.triggerData);
|
|
1985
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.makerRepayFromSavingsSubData.decode(subStruct.subData);
|
|
1986
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1987
|
+
_position.strategyData.decoded.subData = subData;
|
|
1988
|
+
_position.specific = {
|
|
1989
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1990
|
+
targetRepayRatio: subData.targetRatio,
|
|
1991
|
+
repayEnabled: true,
|
|
1992
|
+
boostEnabled: false
|
|
1993
|
+
};
|
|
1994
|
+
return _position;
|
|
1995
|
+
}
|
|
1959
1996
|
var parsingMethodsMapping = {
|
|
1960
1997
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
1961
1998
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -1971,7 +2008,9 @@ var parsingMethodsMapping = {
|
|
|
1971
2008
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
1972
2009
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
1973
2010
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
1974
|
-
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Boost]: parseLiquityLeverageManagement
|
|
2011
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
2012
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.SavingsDsrPayback]: parseLiquitySavingsLiqProtection,
|
|
2013
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.SavingsDsrSupply]: parseLiquitySavingsLiqProtection
|
|
1975
2014
|
},
|
|
1976
2015
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.AaveV2]: {
|
|
1977
2016
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay]: parseAaveV2LeverageManagement,
|
|
@@ -19283,6 +19322,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
19283
19322
|
/* harmony export */ "exchangeDcaSubData": () => (/* binding */ exchangeDcaSubData),
|
|
19284
19323
|
/* harmony export */ "exchangeLimitOrderSubData": () => (/* binding */ exchangeLimitOrderSubData),
|
|
19285
19324
|
/* harmony export */ "liquityCloseSubData": () => (/* binding */ liquityCloseSubData),
|
|
19325
|
+
/* harmony export */ "liquityDsrPaybackSubData": () => (/* binding */ liquityDsrPaybackSubData),
|
|
19326
|
+
/* harmony export */ "liquityDsrSupplySubData": () => (/* binding */ liquityDsrSupplySubData),
|
|
19286
19327
|
/* harmony export */ "liquityLeverageManagementSubData": () => (/* binding */ liquityLeverageManagementSubData),
|
|
19287
19328
|
/* harmony export */ "liquityPaybackUsingChickenBondSubData": () => (/* binding */ liquityPaybackUsingChickenBondSubData),
|
|
19288
19329
|
/* harmony export */ "makerCloseSubData": () => (/* binding */ makerCloseSubData),
|
|
@@ -19608,6 +19649,42 @@ var sparkQuotePriceSubData = {
|
|
|
19608
19649
|
};
|
|
19609
19650
|
}
|
|
19610
19651
|
};
|
|
19652
|
+
var liquityDsrPaybackSubData = {
|
|
19653
|
+
encode: targetRatio => {
|
|
19654
|
+
var daiAddress = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfo)('DAI').address;
|
|
19655
|
+
var lusdAddress = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfo)('LUSD').address;
|
|
19656
|
+
var ratioStateEncoded = mockedWeb3.eth.abi.encodeParameter('uint8', _types_enums__WEBPACK_IMPORTED_MODULE_3__.RatioState.UNDER);
|
|
19657
|
+
var targetRatioEncoded = mockedWeb3.eth.abi.encodeParameter('uint256', (0,_utils__WEBPACK_IMPORTED_MODULE_5__.ratioPercentageToWei)(targetRatio));
|
|
19658
|
+
var daiAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', daiAddress);
|
|
19659
|
+
var lusdAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', lusdAddress);
|
|
19660
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, lusdAddressEncoded];
|
|
19661
|
+
},
|
|
19662
|
+
decode: subData => {
|
|
19663
|
+
var weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
19664
|
+
var targetRatio = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.weiToRatioPercentage)(weiRatio);
|
|
19665
|
+
return {
|
|
19666
|
+
targetRatio
|
|
19667
|
+
};
|
|
19668
|
+
}
|
|
19669
|
+
};
|
|
19670
|
+
var liquityDsrSupplySubData = {
|
|
19671
|
+
encode: targetRatio => {
|
|
19672
|
+
var daiAddress = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfo)('DAI').address;
|
|
19673
|
+
var wethAddress = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfo)('WETH').address;
|
|
19674
|
+
var ratioStateEncoded = mockedWeb3.eth.abi.encodeParameter('uint8', _types_enums__WEBPACK_IMPORTED_MODULE_3__.RatioState.UNDER);
|
|
19675
|
+
var targetRatioEncoded = mockedWeb3.eth.abi.encodeParameter('uint256', (0,_utils__WEBPACK_IMPORTED_MODULE_5__.ratioPercentageToWei)(targetRatio));
|
|
19676
|
+
var daiAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', daiAddress);
|
|
19677
|
+
var wethAddressEncoded = mockedWeb3.eth.abi.encodeParameter('address', wethAddress);
|
|
19678
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, wethAddressEncoded];
|
|
19679
|
+
},
|
|
19680
|
+
decode: subData => {
|
|
19681
|
+
var weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
19682
|
+
var targetRatio = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.weiToRatioPercentage)(weiRatio);
|
|
19683
|
+
return {
|
|
19684
|
+
targetRatio
|
|
19685
|
+
};
|
|
19686
|
+
}
|
|
19687
|
+
};
|
|
19611
19688
|
|
|
19612
19689
|
/***/ }),
|
|
19613
19690
|
/* 30 */
|
|
@@ -29543,10 +29620,10 @@ var exchangeTimestampTrigger = {
|
|
|
29543
29620
|
}
|
|
29544
29621
|
};
|
|
29545
29622
|
var exchangeOffchainPriceTrigger = {
|
|
29546
|
-
encode(targetPrice, goodUntil, fromTokenDecimals) {
|
|
29623
|
+
encode(targetPrice, goodUntil, orderType, fromTokenDecimals) {
|
|
29547
29624
|
var price = new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(targetPrice.toString()).mul(10 ** fromTokenDecimals).floor().toString();
|
|
29548
29625
|
var goodUntilWei = mockedWeb3.utils.toWei(new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(goodUntil).toString());
|
|
29549
|
-
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei])];
|
|
29626
|
+
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei, orderType])];
|
|
29550
29627
|
},
|
|
29551
29628
|
decode(triggerData, fromTokenDecimals, toTokenDecimals) {
|
|
29552
29629
|
var decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
@@ -29785,6 +29862,22 @@ var liquityEncode = {
|
|
|
29785
29862
|
},
|
|
29786
29863
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
29787
29864
|
return [new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(triggerRepayRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(triggerBoostRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(targetBoostRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(targetRepayRatio).mul(1e16).toString(), boostEnabled];
|
|
29865
|
+
},
|
|
29866
|
+
dsrPayback(proxyAddress, triggerRatio, targetRatio) {
|
|
29867
|
+
(0,_utils__WEBPACK_IMPORTED_MODULE_5__.requireAddress)(proxyAddress);
|
|
29868
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_3__.liquityDsrPaybackSubData.encode(targetRatio);
|
|
29869
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_4__.liquityRatioTrigger.encode(proxyAddress, triggerRatio, _types_enums__WEBPACK_IMPORTED_MODULE_2__.RatioState.UNDER);
|
|
29870
|
+
var strategyOrBundleId = _types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.MainnetIds.LIQUITY_DSR_PAYBACK;
|
|
29871
|
+
var isBundle = false;
|
|
29872
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
29873
|
+
},
|
|
29874
|
+
dsrSupply(proxyAddress, triggerRatio, targetRatio) {
|
|
29875
|
+
(0,_utils__WEBPACK_IMPORTED_MODULE_5__.requireAddress)(proxyAddress);
|
|
29876
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_3__.liquityDsrSupplySubData.encode(targetRatio);
|
|
29877
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_4__.liquityRatioTrigger.encode(proxyAddress, triggerRatio, _types_enums__WEBPACK_IMPORTED_MODULE_2__.RatioState.UNDER);
|
|
29878
|
+
var strategyOrBundleId = _types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.MainnetIds.LIQUITY_DSR_SUPPLY;
|
|
29879
|
+
var isBundle = false;
|
|
29880
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
29788
29881
|
}
|
|
29789
29882
|
};
|
|
29790
29883
|
var chickenBondsEncode = {
|