@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
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const chai_1 = require("chai");
|
|
30
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
|
+
const sdk_1 = require("@defisaver/sdk");
|
|
32
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
33
|
+
const web3Utils = __importStar(require("web3-utils"));
|
|
34
|
+
const enums_1 = require("../types/enums");
|
|
35
|
+
const strategySubService_1 = require("./strategySubService");
|
|
36
|
+
describe('Feature: strategySubService.ts', () => {
|
|
37
|
+
describe('When testing strategySubService.makerEncode', () => {
|
|
38
|
+
// @ts-ignore // TODO - this requires change in @defisaver/tokens
|
|
39
|
+
const mcdCdpManagerAddr = (0, sdk_1.otherAddresses)(enums_1.ChainId.Ethereum).McdCdpManager;
|
|
40
|
+
describe('repayFromSavings()', () => {
|
|
41
|
+
const examples = [
|
|
42
|
+
[
|
|
43
|
+
[
|
|
44
|
+
enums_1.Bundles.MainnetIds.MAKER_REPAY_FROM_SMART_SAVINGS_RARI,
|
|
45
|
+
true,
|
|
46
|
+
['0x00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
47
|
+
[
|
|
48
|
+
'0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
49
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
|
|
50
|
+
],
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
enums_1.Bundles.MainnetIds.MAKER_REPAY_FROM_SMART_SAVINGS_RARI,
|
|
54
|
+
222,
|
|
55
|
+
140,
|
|
56
|
+
180,
|
|
57
|
+
true,
|
|
58
|
+
enums_1.ChainId.Ethereum,
|
|
59
|
+
(0, tokens_1.getAssetInfo)('DAI').address,
|
|
60
|
+
mcdCdpManagerAddr,
|
|
61
|
+
]
|
|
62
|
+
]
|
|
63
|
+
];
|
|
64
|
+
examples.forEach(([expected, actual]) => {
|
|
65
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
66
|
+
(0, chai_1.expect)(strategySubService_1.makerEncode.repayFromSavings(...actual)).to.eql(expected);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('closeOnPrice()', () => {
|
|
71
|
+
const examples = [
|
|
72
|
+
[
|
|
73
|
+
[
|
|
74
|
+
enums_1.Strategies.MainnetIds.MAKER_CLOSE_ON_PRICE_TO_DAI,
|
|
75
|
+
false,
|
|
76
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000002cc9e4c0000000000000000000000000000000000000000000000000000000000000000'],
|
|
77
|
+
[
|
|
78
|
+
'0x0000000000000000000000000000000000000000000000000000000000000078', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
79
|
+
'0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
|
|
80
|
+
],
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
120,
|
|
84
|
+
enums_1.RatioState.OVER,
|
|
85
|
+
'0.469643',
|
|
86
|
+
(0, tokens_1.getAssetInfo)('DAI').address,
|
|
87
|
+
(0, tokens_1.getAssetInfo)('WBTC').address,
|
|
88
|
+
enums_1.ChainId.Ethereum,
|
|
89
|
+
]
|
|
90
|
+
]
|
|
91
|
+
];
|
|
92
|
+
examples.forEach(([expected, actual]) => {
|
|
93
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
94
|
+
(0, chai_1.expect)(strategySubService_1.makerEncode.closeOnPrice(...actual)).to.eql(expected);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
describe('trailingStop()', () => {
|
|
99
|
+
const examples = [
|
|
100
|
+
[
|
|
101
|
+
[
|
|
102
|
+
enums_1.Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_COLL,
|
|
103
|
+
false,
|
|
104
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000055ae82600000000000000000000000000000000000000000000000000000000000000007b'],
|
|
105
|
+
[
|
|
106
|
+
'0x000000000000000000000000000000000000000000000000000000000000096e', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
107
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
|
|
108
|
+
],
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
2414,
|
|
112
|
+
230,
|
|
113
|
+
(0, tokens_1.getAssetInfo)('WBTC').address,
|
|
114
|
+
(0, tokens_1.getAssetInfo)('WBTC').address,
|
|
115
|
+
123,
|
|
116
|
+
enums_1.ChainId.Ethereum,
|
|
117
|
+
]
|
|
118
|
+
]
|
|
119
|
+
];
|
|
120
|
+
examples.forEach(([expected, actual]) => {
|
|
121
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
122
|
+
(0, chai_1.expect)(strategySubService_1.makerEncode.trailingStop(...actual)).to.eql(expected);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('leverageManagement()', () => {
|
|
127
|
+
const examples = [
|
|
128
|
+
[
|
|
129
|
+
[
|
|
130
|
+
5791,
|
|
131
|
+
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
132
|
+
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
133
|
+
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
134
|
+
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
135
|
+
true,
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
5791, '210', '290', '240', '240', true,
|
|
139
|
+
]
|
|
140
|
+
]
|
|
141
|
+
];
|
|
142
|
+
examples.forEach(([expected, actual]) => {
|
|
143
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
144
|
+
(0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('When testing strategySubService.liquityEncode', () => {
|
|
150
|
+
describe('closeOnPrice()', () => {
|
|
151
|
+
const examples = [
|
|
152
|
+
[
|
|
153
|
+
[
|
|
154
|
+
enums_1.Strategies.MainnetIds.LIQUITY_CLOSE_ON_PRICE_TO_COLL,
|
|
155
|
+
false,
|
|
156
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000001c027053000000000000000000000000000000000000000000000000000000000000000000'],
|
|
157
|
+
[
|
|
158
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
159
|
+
],
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
enums_1.RatioState.OVER,
|
|
163
|
+
'1203',
|
|
164
|
+
(0, tokens_1.getAssetInfo)('WETH').address,
|
|
165
|
+
(0, tokens_1.getAssetInfo)('WETH').address,
|
|
166
|
+
]
|
|
167
|
+
]
|
|
168
|
+
];
|
|
169
|
+
examples.forEach(([expected, actual]) => {
|
|
170
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
171
|
+
(0, chai_1.expect)(strategySubService_1.liquityEncode.closeOnPrice(...actual)).to.eql(expected);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
describe('trailingStop()', () => {
|
|
176
|
+
const examples = [
|
|
177
|
+
[
|
|
178
|
+
[
|
|
179
|
+
enums_1.Strategies.MainnetIds.LIQUITY_TRAILING_STOP_LOSS_TO_COLL,
|
|
180
|
+
false,
|
|
181
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000055ae826000000000000000000000000000000000000000000000000000000000000000c97'],
|
|
182
|
+
[
|
|
183
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
184
|
+
],
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
230,
|
|
188
|
+
(0, tokens_1.getAssetInfo)('WETH').address,
|
|
189
|
+
(0, tokens_1.getAssetInfo)('WETH').address,
|
|
190
|
+
3223,
|
|
191
|
+
]
|
|
192
|
+
]
|
|
193
|
+
];
|
|
194
|
+
examples.forEach(([expected, actual]) => {
|
|
195
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
196
|
+
(0, chai_1.expect)(strategySubService_1.liquityEncode.trailingStop(...actual)).to.eql(expected);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
describe('leverageManagement()', () => {
|
|
201
|
+
const examples = [
|
|
202
|
+
[
|
|
203
|
+
[
|
|
204
|
+
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
205
|
+
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
206
|
+
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
207
|
+
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
208
|
+
false,
|
|
209
|
+
],
|
|
210
|
+
[
|
|
211
|
+
'210', '290', '240', '240', false,
|
|
212
|
+
]
|
|
213
|
+
]
|
|
214
|
+
];
|
|
215
|
+
examples.forEach(([expected, actual]) => {
|
|
216
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
217
|
+
(0, chai_1.expect)(strategySubService_1.liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
describe('paybackFromChickenBondStrategySub()', () => {
|
|
222
|
+
const examples = [
|
|
223
|
+
[
|
|
224
|
+
[
|
|
225
|
+
enums_1.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND,
|
|
226
|
+
true,
|
|
227
|
+
['0x0000000000000000000000002439d211133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002dcbf4840eca00000000000000000000000000000000000000000000000000000000000000000000'],
|
|
228
|
+
[
|
|
229
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
230
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
231
|
+
],
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
web3Utils.toChecksumAddress('0x2439d211133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
235
|
+
330,
|
|
236
|
+
'123',
|
|
237
|
+
0,
|
|
238
|
+
enums_1.RatioState.OVER
|
|
239
|
+
]
|
|
240
|
+
]
|
|
241
|
+
];
|
|
242
|
+
examples.forEach(([expected, actual]) => {
|
|
243
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
244
|
+
(0, chai_1.expect)(strategySubService_1.liquityEncode.paybackFromChickenBondStrategySub(...actual)).to.eql(expected);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
describe('dsrPayback()', () => {
|
|
249
|
+
const examples = [
|
|
250
|
+
[
|
|
251
|
+
[
|
|
252
|
+
enums_1.Strategies.MainnetIds.LIQUITY_DSR_PAYBACK,
|
|
253
|
+
false,
|
|
254
|
+
['0x0000000000000000000000002439d211133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000250dbeda8e4b00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
255
|
+
[
|
|
256
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x00000000000000000000000000000000000000000000000029a2241af62c0000',
|
|
257
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
258
|
+
],
|
|
259
|
+
],
|
|
260
|
+
[web3Utils.toChecksumAddress('0x2439d211133AFaB8F2B819B1066c7E434Ad94E9e'), 267, 300]
|
|
261
|
+
]
|
|
262
|
+
];
|
|
263
|
+
examples.forEach(([expected, actual]) => {
|
|
264
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
265
|
+
(0, chai_1.expect)(strategySubService_1.liquityEncode.dsrPayback(...actual)).to.eql(expected);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
describe('debtInFrontRepay()', () => {
|
|
270
|
+
const examples = [
|
|
271
|
+
[
|
|
272
|
+
[
|
|
273
|
+
enums_1.Strategies.MainnetIds.LIQUITY_DEBT_IN_FRONT_REPAY,
|
|
274
|
+
false,
|
|
275
|
+
['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
|
|
276
|
+
[
|
|
277
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
278
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
279
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000'
|
|
280
|
+
],
|
|
281
|
+
],
|
|
282
|
+
[web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000', 45]
|
|
283
|
+
]
|
|
284
|
+
];
|
|
285
|
+
examples.forEach(([expected, actual]) => {
|
|
286
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
287
|
+
(0, chai_1.expect)(strategySubService_1.liquityEncode.debtInFrontRepay(...actual)).to.eql(expected);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
describe('When testing strategySubService.chickenBondsEncode', () => {
|
|
293
|
+
describe('rebond()', () => {
|
|
294
|
+
const examples = [
|
|
295
|
+
[
|
|
296
|
+
["0x00000000000000000000000000000000000000000000000000000000000005e3"],
|
|
297
|
+
[1507]
|
|
298
|
+
]
|
|
299
|
+
];
|
|
300
|
+
examples.forEach(([expected, actual]) => {
|
|
301
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
302
|
+
(0, chai_1.expect)(strategySubService_1.chickenBondsEncode.rebond(...actual)).to.eql(expected);
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
308
|
+
describe('leverageManagement()', () => {
|
|
309
|
+
const examples = [
|
|
310
|
+
[
|
|
311
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
312
|
+
[160, 220, 180, 190, true]
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
316
|
+
[160, 200, 180, 190, false]
|
|
317
|
+
],
|
|
318
|
+
];
|
|
319
|
+
examples.forEach(([expected, actual]) => {
|
|
320
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
321
|
+
(0, chai_1.expect)(strategySubService_1.aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
327
|
+
describe('leverageManagement()', () => {
|
|
328
|
+
const examples = [
|
|
329
|
+
[
|
|
330
|
+
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
331
|
+
[160, 220, 180, 190, true]
|
|
332
|
+
],
|
|
333
|
+
[
|
|
334
|
+
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
335
|
+
[160, 200, 180, 190, false]
|
|
336
|
+
],
|
|
337
|
+
];
|
|
338
|
+
examples.forEach(([expected, actual]) => {
|
|
339
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
340
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
describe('closeToAsset()', () => {
|
|
345
|
+
const examples = [
|
|
346
|
+
[
|
|
347
|
+
[
|
|
348
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
|
|
349
|
+
true,
|
|
350
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
|
|
351
|
+
[
|
|
352
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
353
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
354
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
355
|
+
],
|
|
356
|
+
],
|
|
357
|
+
[
|
|
358
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
|
|
359
|
+
true,
|
|
360
|
+
{
|
|
361
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
|
|
365
|
+
},
|
|
366
|
+
]
|
|
367
|
+
],
|
|
368
|
+
[
|
|
369
|
+
[
|
|
370
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
|
|
371
|
+
true,
|
|
372
|
+
['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
|
|
373
|
+
[
|
|
374
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
375
|
+
'0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
376
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
377
|
+
],
|
|
378
|
+
],
|
|
379
|
+
[
|
|
380
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
|
|
381
|
+
true,
|
|
382
|
+
{
|
|
383
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
|
|
387
|
+
},
|
|
388
|
+
]
|
|
389
|
+
]
|
|
390
|
+
];
|
|
391
|
+
examples.forEach(([expected, actual]) => {
|
|
392
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
393
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeToAsset(...actual)).to.eql(expected);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
describe('closeToAssetWithMaximumGasPrice()', () => {
|
|
398
|
+
const examples = [
|
|
399
|
+
[
|
|
400
|
+
[
|
|
401
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
|
|
402
|
+
true,
|
|
403
|
+
[
|
|
404
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000',
|
|
405
|
+
'0x00000000000000000000000000000000000000000000000000000002cb417800',
|
|
406
|
+
],
|
|
407
|
+
[
|
|
408
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
409
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
410
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
411
|
+
],
|
|
412
|
+
],
|
|
413
|
+
[
|
|
414
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
|
|
415
|
+
true,
|
|
416
|
+
{
|
|
417
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER, maximumGasPrice: 12,
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
|
|
421
|
+
},
|
|
422
|
+
]
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
[
|
|
426
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
|
|
427
|
+
true,
|
|
428
|
+
[
|
|
429
|
+
'0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001',
|
|
430
|
+
'0x0000000000000000000000000000000000000000000000000000004a817c8000',
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
434
|
+
'0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
435
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
436
|
+
],
|
|
437
|
+
],
|
|
438
|
+
[
|
|
439
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
|
|
440
|
+
true,
|
|
441
|
+
{
|
|
442
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER, maximumGasPrice: 320,
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
|
|
446
|
+
},
|
|
447
|
+
]
|
|
448
|
+
]
|
|
449
|
+
];
|
|
450
|
+
examples.forEach(([expected, actual]) => {
|
|
451
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
452
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeToAssetWithMaximumGasPrice(...actual)).to.eql(expected);
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
458
|
+
describe('leverageManagement()', () => {
|
|
459
|
+
const examples = [
|
|
460
|
+
[
|
|
461
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
462
|
+
[160, 220, 180, 190, true]
|
|
463
|
+
],
|
|
464
|
+
[
|
|
465
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
466
|
+
[160, 200, 180, 190, false]
|
|
467
|
+
],
|
|
468
|
+
];
|
|
469
|
+
examples.forEach(([expected, actual]) => {
|
|
470
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
471
|
+
(0, chai_1.expect)(strategySubService_1.compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
477
|
+
describe('leverageManagement()', () => {
|
|
478
|
+
const examples = [
|
|
479
|
+
[
|
|
480
|
+
[
|
|
481
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
482
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
483
|
+
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
484
|
+
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
485
|
+
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
486
|
+
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
487
|
+
true, false,
|
|
488
|
+
],
|
|
489
|
+
[
|
|
490
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
491
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
492
|
+
160, 220, 180, 190,
|
|
493
|
+
true, false,
|
|
494
|
+
]
|
|
495
|
+
],
|
|
496
|
+
[
|
|
497
|
+
[
|
|
498
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
499
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
500
|
+
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
501
|
+
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
502
|
+
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
503
|
+
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
504
|
+
false, true,
|
|
505
|
+
],
|
|
506
|
+
[
|
|
507
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
508
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
509
|
+
160, 210, 180, 190,
|
|
510
|
+
false, true,
|
|
511
|
+
]
|
|
512
|
+
],
|
|
513
|
+
];
|
|
514
|
+
examples.forEach(([expected, actual]) => {
|
|
515
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
516
|
+
(0, chai_1.expect)(strategySubService_1.compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
describe('When testing strategySubService.morphoAaveV2Encode', () => {
|
|
522
|
+
describe('leverageManagement()', () => {
|
|
523
|
+
const examples = [
|
|
524
|
+
[
|
|
525
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
526
|
+
[160, 220, 180, 190, true]
|
|
527
|
+
],
|
|
528
|
+
[
|
|
529
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
530
|
+
[160, 200, 180, 190, false]
|
|
531
|
+
],
|
|
532
|
+
];
|
|
533
|
+
examples.forEach(([expected, actual]) => {
|
|
534
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
535
|
+
(0, chai_1.expect)(strategySubService_1.morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
describe('When testing strategySubService.exchangeEncode', () => {
|
|
541
|
+
describe('dca()', () => {
|
|
542
|
+
const examples = [
|
|
543
|
+
[
|
|
544
|
+
[
|
|
545
|
+
enums_1.Strategies.ArbitrumIds.EXCHANGE_DCA,
|
|
546
|
+
false,
|
|
547
|
+
['0x0000000000000000000000000000000000000000000000000000018b23bd88cd000000000000000000000000000000000000000000000000000000000012d068'],
|
|
548
|
+
[
|
|
549
|
+
'0x000000000000000000000000da10009cbd5d07dd0cecc66161fc93d7c9000da1', '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831',
|
|
550
|
+
'0x0000000000000000000000000000000000000000000000000000000000038270', '0x000000000000000000000000000000000000000000000000000000000012d068'
|
|
551
|
+
],
|
|
552
|
+
],
|
|
553
|
+
[(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Arbitrum).address, (0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address, '230000', 1697111705805, 1233000, enums_1.ChainId.Arbitrum]
|
|
554
|
+
],
|
|
555
|
+
[
|
|
556
|
+
[
|
|
557
|
+
enums_1.Strategies.MainnetIds.EXCHANGE_DCA,
|
|
558
|
+
false,
|
|
559
|
+
['0x0000000000000000000000000000000000000000000000000000018b23bd88cd0000000000000000000000000000000000000000000000000000000000067458'],
|
|
560
|
+
[
|
|
561
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599', '0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
562
|
+
'0x0000000000000000000000000000000000000000000000000000000000000015', '0x0000000000000000000000000000000000000000000000000000000000067458',
|
|
563
|
+
],
|
|
564
|
+
],
|
|
565
|
+
[(0, tokens_1.getAssetInfo)('WBTC').address, (0, tokens_1.getAssetInfo)('ETH').address, '21', 1697111705805, 423000, enums_1.ChainId.Ethereum]
|
|
566
|
+
],
|
|
567
|
+
];
|
|
568
|
+
examples.forEach(([expected, actual]) => {
|
|
569
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
570
|
+
(0, chai_1.expect)(strategySubService_1.exchangeEncode.dca(...actual)).to.eql(expected);
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
describe('limitOrder()', () => {
|
|
575
|
+
const examples = [
|
|
576
|
+
[
|
|
577
|
+
[
|
|
578
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
579
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
580
|
+
'2131',
|
|
581
|
+
'0.53123',
|
|
582
|
+
'1696590921159',
|
|
583
|
+
`${enums_1.OrderType.STOP_LOSS}`
|
|
584
|
+
],
|
|
585
|
+
[
|
|
586
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
587
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
588
|
+
'2131',
|
|
589
|
+
'0.53123',
|
|
590
|
+
1696590921159,
|
|
591
|
+
enums_1.OrderType.STOP_LOSS
|
|
592
|
+
]
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
[
|
|
596
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
597
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
598
|
+
'2131',
|
|
599
|
+
'0.43123',
|
|
600
|
+
'1646590921159',
|
|
601
|
+
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
602
|
+
],
|
|
603
|
+
[
|
|
604
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
605
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
606
|
+
'2131',
|
|
607
|
+
'0.43123',
|
|
608
|
+
1646590921159,
|
|
609
|
+
enums_1.OrderType.TAKE_PROFIT
|
|
610
|
+
]
|
|
611
|
+
],
|
|
612
|
+
];
|
|
613
|
+
examples.forEach(([expected, actual]) => {
|
|
614
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
615
|
+
(0, chai_1.expect)(strategySubService_1.exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
describe('When testing strategySubService.sparkEncode', () => {
|
|
621
|
+
describe('leverageManagement()', () => {
|
|
622
|
+
const examples = [
|
|
623
|
+
[
|
|
624
|
+
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
625
|
+
[160, 220, 180, 190, true]
|
|
626
|
+
],
|
|
627
|
+
[
|
|
628
|
+
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
629
|
+
[160, 200, 180, 190, false]
|
|
630
|
+
],
|
|
631
|
+
];
|
|
632
|
+
examples.forEach(([expected, actual]) => {
|
|
633
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
634
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
635
|
+
});
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
describe('closeToAsset()', () => {
|
|
639
|
+
const examples = [
|
|
640
|
+
[
|
|
641
|
+
[
|
|
642
|
+
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
643
|
+
true,
|
|
644
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
|
|
645
|
+
[
|
|
646
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
647
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
648
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
649
|
+
],
|
|
650
|
+
],
|
|
651
|
+
[
|
|
652
|
+
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
653
|
+
true,
|
|
654
|
+
{
|
|
655
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
|
|
659
|
+
},
|
|
660
|
+
]
|
|
661
|
+
],
|
|
662
|
+
[
|
|
663
|
+
[
|
|
664
|
+
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
665
|
+
true,
|
|
666
|
+
['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
|
|
667
|
+
[
|
|
668
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
669
|
+
'0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
670
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
671
|
+
],
|
|
672
|
+
],
|
|
673
|
+
[
|
|
674
|
+
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
675
|
+
true,
|
|
676
|
+
{
|
|
677
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
|
|
681
|
+
},
|
|
682
|
+
]
|
|
683
|
+
]
|
|
684
|
+
];
|
|
685
|
+
examples.forEach(([expected, actual]) => {
|
|
686
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
687
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.closeToAsset(...actual)).to.eql(expected);
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
});
|