@defisaver/automation-sdk 2.0.6 → 2.0.9
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/.env +4 -0
- package/.env.dev +5 -0
- package/.tests.sh +3 -0
- package/README.md +3 -1
- package/esm/automation/private/LegacyAutomation.js +9 -3
- package/esm/automation/private/LegacyProtocol.test.d.ts +1 -0
- package/esm/automation/private/LegacyProtocol.test.js +25 -0
- package/esm/automation/private/Protocol.test.d.ts +1 -0
- package/esm/automation/private/Protocol.test.js +25 -0
- package/esm/automation/private/StrategiesAutomation.d.ts +4 -0
- package/esm/automation/private/StrategiesAutomation.js +29 -4
- package/esm/constants/index.js +5 -0
- package/esm/services/contractService.d.ts +3 -2
- package/esm/services/contractService.js +7 -1
- package/esm/services/ethereumService.test.d.ts +1 -0
- package/esm/services/ethereumService.test.js +241 -0
- package/esm/services/strategiesService.js +14 -0
- package/esm/services/strategiesService.test.d.ts +1 -0
- package/esm/services/strategiesService.test.js +108 -0
- package/esm/services/strategySubService.d.ts +5 -3
- package/esm/services/strategySubService.js +10 -6
- package/esm/services/strategySubService.test.d.ts +1 -0
- package/esm/services/strategySubService.test.js +692 -0
- package/esm/services/subDataService.d.ts +8 -1
- package/esm/services/subDataService.js +23 -14
- package/esm/services/subDataService.test.d.ts +1 -0
- package/esm/services/subDataService.test.js +993 -0
- package/esm/services/triggerService.d.ts +7 -0
- package/esm/services/triggerService.js +14 -1
- package/esm/services/triggerService.test.js +119 -17
- package/esm/types/enums.d.ts +4 -2
- package/esm/types/enums.js +2 -0
- package/esm/types/index.d.ts +13 -4
- package/package.json +5 -5
- package/src/automation/private/LegacyAutomation.ts +14 -4
- package/src/automation/private/LegacyProtocol.test.ts +24 -0
- package/src/automation/private/Protocol.test.ts +24 -0
- package/src/automation/private/StrategiesAutomation.ts +40 -6
- package/src/constants/index.ts +5 -0
- package/src/services/contractService.ts +17 -4
- package/src/services/ethereumService.test.ts +256 -0
- package/src/services/ethereumService.ts +2 -1
- package/src/services/strategiesService.test.ts +103 -0
- package/src/services/strategiesService.ts +27 -3
- package/src/services/strategySubService.test.ts +835 -0
- package/src/services/strategySubService.ts +28 -15
- package/src/services/subDataService.test.ts +1063 -0
- package/src/services/subDataService.ts +29 -14
- package/src/services/triggerService.test.ts +131 -19
- package/src/services/triggerService.ts +14 -0
- package/src/services/utils.test.ts +1 -1
- package/src/types/enums.ts +2 -0
- package/src/types/index.ts +20 -5
- package/umd/index.js +919 -523
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
3
3
|
|
|
4
|
+
import type { OrderType } from '../types/enums';
|
|
4
5
|
import {
|
|
5
6
|
Bundles, ChainId, RatioState, Strategies,
|
|
6
7
|
} from '../types/enums';
|
|
7
8
|
import type { EthereumAddress, StrategyOrBundleIds } from '../types';
|
|
8
9
|
|
|
10
|
+
import { STRATEGY_IDS } from '../constants';
|
|
11
|
+
|
|
9
12
|
import * as subDataService from './subDataService';
|
|
10
13
|
import * as triggerService from './triggerService';
|
|
11
14
|
import { compareAddresses, requireAddress, requireAddresses } from './utils';
|
|
@@ -73,12 +76,12 @@ export const makerEncode = {
|
|
|
73
76
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
74
77
|
},
|
|
75
78
|
leverageManagement(
|
|
76
|
-
vaultId:number,
|
|
77
|
-
triggerRepayRatio:string,
|
|
78
|
-
triggerBoostRatio:string,
|
|
79
|
-
targetBoostRatio:string,
|
|
80
|
-
targetRepayRatio:string,
|
|
81
|
-
boostEnabled:boolean,
|
|
79
|
+
vaultId: number,
|
|
80
|
+
triggerRepayRatio: string,
|
|
81
|
+
triggerBoostRatio: string,
|
|
82
|
+
targetBoostRatio: string,
|
|
83
|
+
targetRepayRatio: string,
|
|
84
|
+
boostEnabled: boolean,
|
|
82
85
|
) {
|
|
83
86
|
return [
|
|
84
87
|
vaultId,
|
|
@@ -192,6 +195,21 @@ export const liquityEncode = {
|
|
|
192
195
|
|
|
193
196
|
const isBundle = false;
|
|
194
197
|
|
|
198
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
199
|
+
},
|
|
200
|
+
debtInFrontRepay(
|
|
201
|
+
proxyAddress: EthereumAddress,
|
|
202
|
+
debtInFrontMin: string,
|
|
203
|
+
targetRatioIncrease: number,
|
|
204
|
+
) {
|
|
205
|
+
requireAddress(proxyAddress);
|
|
206
|
+
const subData = subDataService.liquityDebtInFrontRepaySubData.encode(targetRatioIncrease);
|
|
207
|
+
const triggerData = triggerService.liquityDebtInFrontWithLimitTrigger.encode(proxyAddress, debtInFrontMin);
|
|
208
|
+
|
|
209
|
+
const strategyOrBundleId = Strategies.MainnetIds.LIQUITY_DEBT_IN_FRONT_REPAY;
|
|
210
|
+
|
|
211
|
+
const isBundle = false;
|
|
212
|
+
|
|
195
213
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
196
214
|
},
|
|
197
215
|
};
|
|
@@ -328,18 +346,13 @@ export const exchangeEncode = {
|
|
|
328
346
|
amount: string,
|
|
329
347
|
timestamp: number,
|
|
330
348
|
interval: number,
|
|
331
|
-
network:
|
|
349
|
+
network: ChainId,
|
|
332
350
|
) {
|
|
333
351
|
requireAddresses([fromToken, toToken]);
|
|
334
352
|
const subData = subDataService.exchangeDcaSubData.encode(fromToken, toToken, amount, interval);
|
|
335
353
|
const triggerData = triggerService.exchangeTimestampTrigger.encode(timestamp, interval);
|
|
336
|
-
const selectedNetwork = network === 1
|
|
337
|
-
? 'MainnetIds'
|
|
338
|
-
: network === 10
|
|
339
|
-
? 'OptimismIds'
|
|
340
|
-
: 'ArbitrumIds';
|
|
341
354
|
|
|
342
|
-
const strategyId =
|
|
355
|
+
const strategyId = STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
343
356
|
|
|
344
357
|
return [strategyId, false, triggerData, subData];
|
|
345
358
|
},
|
|
@@ -348,8 +361,8 @@ export const exchangeEncode = {
|
|
|
348
361
|
toToken: EthereumAddress,
|
|
349
362
|
amount: string,
|
|
350
363
|
targetPrice: string,
|
|
351
|
-
goodUntil: string,
|
|
352
|
-
orderType:
|
|
364
|
+
goodUntil: string | number,
|
|
365
|
+
orderType: OrderType,
|
|
353
366
|
) {
|
|
354
367
|
return subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount, targetPrice, goodUntil, orderType);
|
|
355
368
|
},
|