@gearbox-protocol/sdk 0.0.67 → 0.0.68

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.
Files changed (66) hide show
  1. package/lib/contracts/adapters.d.ts +15 -0
  2. package/lib/contracts/adapters.js +19 -0
  3. package/lib/contracts/contracts.d.ts +60 -0
  4. package/lib/contracts/contracts.js +242 -0
  5. package/lib/contracts/contractsRegister.d.ts +2 -0
  6. package/lib/contracts/contractsRegister.js +58 -0
  7. package/lib/contracts/protocols.d.ts +13 -0
  8. package/lib/contracts/protocols.js +39 -0
  9. package/lib/core/events.js +1 -1
  10. package/lib/core/tradeTypes.d.ts +1 -1
  11. package/lib/core/transactions.js +1 -1
  12. package/lib/index.d.ts +8 -9
  13. package/lib/index.js +10 -10
  14. package/lib/oracles/oracles.d.ts +38 -0
  15. package/lib/oracles/oracles.js +12 -0
  16. package/lib/oracles/priceFeeds.d.ts +3 -0
  17. package/lib/oracles/priceFeeds.js +492 -0
  18. package/lib/pathfinder/convexLP.d.ts +1 -1
  19. package/lib/pathfinder/convexLP.js +2 -20
  20. package/lib/pathfinder/curveLP.d.ts +2 -2
  21. package/lib/pathfinder/curveLP.js +8 -27
  22. package/lib/pathfinder/path.d.ts +2 -8
  23. package/lib/pathfinder/path.js +27 -34
  24. package/lib/pathfinder/trade.d.ts +35 -0
  25. package/lib/pathfinder/trade.js +62 -0
  26. package/lib/pathfinder/tradeTypes.d.ts +83 -0
  27. package/lib/pathfinder/tradeTypes.js +26 -0
  28. package/lib/pathfinder/yVault.d.ts +1 -1
  29. package/lib/pathfinder/yVault.js +4 -23
  30. package/lib/tokens/convex.d.ts +2 -2
  31. package/lib/tokens/convex.js +1 -1
  32. package/lib/tokens/curveLP.d.ts +1 -1
  33. package/lib/tokens/curveLP.js +1 -1
  34. package/lib/tokens/gear.d.ts +1 -1
  35. package/lib/tokens/normal.d.ts +1 -1
  36. package/lib/tokens/normal.js +1 -1
  37. package/lib/tokens/token.d.ts +1 -1
  38. package/lib/tokens/token.js +5 -5
  39. package/lib/tokens/yearn.d.ts +2 -2
  40. package/lib/tokens/yearn.js +3 -3
  41. package/package.json +1 -1
  42. package/src/{core → contracts}/adapters.ts +0 -0
  43. package/src/{core → contracts}/contracts.ts +3 -3
  44. package/src/{core → contracts}/contractsRegister.ts +0 -0
  45. package/src/{core → contracts}/protocols.ts +0 -0
  46. package/src/core/events.ts +932 -915
  47. package/src/core/transactions.ts +360 -352
  48. package/src/index.ts +8 -9
  49. package/src/{core → oracles}/oracles.ts +0 -0
  50. package/src/oracles/priceFeeds.ts +528 -0
  51. package/src/pathfinder/convexLP.ts +1 -1
  52. package/src/pathfinder/curveLP.ts +3 -4
  53. package/src/pathfinder/path.ts +23 -53
  54. package/src/pathfinder/trade.ts +83 -0
  55. package/src/{core → pathfinder}/tradeTypes.ts +6 -6
  56. package/src/pathfinder/yVault.ts +1 -2
  57. package/src/tokens/convex.ts +2 -2
  58. package/src/tokens/curveLP.ts +1 -1
  59. package/src/tokens/gear.ts +1 -1
  60. package/src/tokens/normal.ts +1 -1
  61. package/src/tokens/token.ts +17 -7
  62. package/src/tokens/yearn.ts +4 -4
  63. package/src/core/creditCard.ts +0 -15
  64. package/src/core/priceFeeds.ts +0 -528
  65. package/src/core/swap.ts +0 -4
  66. package/src/core/trade.ts +0 -83
@@ -1,528 +0,0 @@
1
- import { OracleType, TokenPriceFeedData } from "../core/oracles";
2
- import { SupportedToken } from "../tokens/token";
3
-
4
- export const priceFeedsByNetwork: Record<SupportedToken, TokenPriceFeedData> = {
5
- "1INCH": {
6
- priceFeedETH: {
7
- type: OracleType.CHAINLINK_ORACLE,
8
- address: "0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8",
9
- kovan: "0x5b65757C2d37c4FDc3c029ECb8F2C7AD3FD361C9"
10
- },
11
- priceFeedUSD: {
12
- type: OracleType.CHAINLINK_ORACLE,
13
- address: "0xc929ad75B72593967DE83E7F7Cda0493458261D9",
14
- kovan: "0xb32946c38C4F2e3e44Ce2aB059BfFec163816A4E"
15
- }
16
- },
17
-
18
- AAVE: {
19
- priceFeedETH: {
20
- type: OracleType.CHAINLINK_ORACLE,
21
- address: "0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012",
22
- kovan: "0x3e12e9aE09F4ce9D5809E4b863bF4eef16f9949C"
23
- },
24
- priceFeedUSD: {
25
- type: OracleType.CHAINLINK_ORACLE,
26
- address: "0x547a514d5e3769680Ce22B2361c10Ea13619e8a9",
27
- kovan: "0xF1594a023a3e061765c11af09EC6B7c63e2e9Ab5"
28
- }
29
- },
30
-
31
- COMP: {
32
- priceFeedETH: {
33
- type: OracleType.CHAINLINK_ORACLE,
34
- address: "0x1B39Ee86Ec5979ba5C322b826B3ECb8C79991699",
35
- kovan: "0x2d2fAc1CBf67b24d3643ce084f3758115b1dCFe0"
36
- },
37
- priceFeedUSD: {
38
- type: OracleType.CHAINLINK_ORACLE,
39
- address: "0xdbd020CAeF83eFd542f4De03e3cF0C28A4428bd5",
40
- kovan: "0xECF93D14d25E02bA2C13698eeDca9aA98348EFb6"
41
- }
42
- },
43
-
44
- CRV: {
45
- priceFeedETH: {
46
- type: OracleType.CHAINLINK_ORACLE,
47
- address: "0x8a12Be339B0cD1829b91Adc01977caa5E9ac121e",
48
- kovan: "0x57F80b54722B294F0C1942AA70468Bb46437AD19"
49
- },
50
- priceFeedUSD: {
51
- type: OracleType.CHAINLINK_ORACLE,
52
- address: "0xcd627aa160a6fa45eb793d19ef54f5062f20f33f",
53
- kovan: "0x55fe324Ece17b6902c2b3776c1baB1095Eb5deB0"
54
- }
55
- },
56
-
57
- DAI: {
58
- priceFeedETH: {
59
- type: OracleType.CHAINLINK_ORACLE,
60
- address: "0x773616E4d11A78F511299002da57A0a94577F1f4",
61
- kovan: "0x22B58f1EbEDfCA50feF632bD73368b2FdA96D541"
62
- },
63
- priceFeedUSD: {
64
- type: OracleType.CHAINLINK_ORACLE,
65
- address: "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9",
66
- kovan: "0x777A68032a88E5A84678A77Af2CD65A7b3c0775a"
67
- }
68
- },
69
-
70
- DPI: {
71
- priceFeedETH: {
72
- type: OracleType.CHAINLINK_ORACLE,
73
- address: "0x029849bbc0b1d93b85a8b6190e979fd38F5760E2",
74
- kovan: "0x4c1b676445935dA58a48b6dA8B2564684d80fAEE"
75
- },
76
- priceFeedUSD: {
77
- type: OracleType.CHAINLINK_ORACLE,
78
- address: "0xD2A593BF7594aCE1faD597adb697b5645d5edDB2",
79
- kovan: "0x39EcBDd1069C795e65Aa3355cC42F3acD29797d8"
80
- }
81
- },
82
-
83
- FEI: {
84
- priceFeedETH: {
85
- type: OracleType.CHAINLINK_ORACLE,
86
- address: "0x7f0d2c2838c6ac24443d13e23d99490017bde370",
87
- kovan: "0x1E13BFc6e358410f4F94EAC84C1008A138FB115B"
88
- },
89
- priceFeedUSD: {
90
- type: OracleType.CHAINLINK_ORACLE,
91
- address: "0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9",
92
- kovan: "0x9FE550626246234EF48a1176e8e2452A14CbbA24"
93
- }
94
- },
95
-
96
- GUSD: {
97
- priceFeedUSD: {
98
- type: OracleType.CHAINLINK_ORACLE,
99
- address: "0xa89f5d2365ce98B3cD68012b6f503ab1416245Fc",
100
- kovan: "0x36AD5755A58c5faB253D5e40e7F0f86293d6A5f9"
101
- }
102
- },
103
-
104
- LINK: {
105
- priceFeedETH: {
106
- type: OracleType.CHAINLINK_ORACLE,
107
- address: "0xDC530D9457755926550b59e8ECcdaE7624181557",
108
- kovan: "0x3Af8C569ab77af5230596Acf0E8c2F9351d24C38"
109
- },
110
- priceFeedUSD: {
111
- type: OracleType.CHAINLINK_ORACLE,
112
- address: "0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c",
113
- kovan: "0x396c5E36DD0a0F5a5D33dae44368D4193f69a1F0"
114
- }
115
- },
116
-
117
- SNX: {
118
- priceFeedETH: {
119
- type: OracleType.CHAINLINK_ORACLE,
120
- address: "0x79291A9d692Df95334B1a0B3B4AE6bC606782f8c",
121
- kovan: "0xF9A76ae7a1075Fe7d646b06fF05Bd48b9FA5582e"
122
- },
123
- priceFeedUSD: {
124
- type: OracleType.CHAINLINK_ORACLE,
125
- address: "0xDC3EA94CD0AC27d9A86C180091e7f78C683d3699",
126
- kovan: "0x31f93DA9823d737b7E44bdee0DF389Fe62Fd1AcD"
127
- }
128
- },
129
-
130
- SUSHI: {
131
- priceFeedETH: {
132
- type: OracleType.CHAINLINK_ORACLE,
133
- address: "0xe572CeF69f43c2E488b33924AF04BDacE19079cf",
134
- kovan: "0x6A8b2Aae8bf973EdA172C1f0e450c9D4e3C2E360"
135
- },
136
- priceFeedUSD: {
137
- type: OracleType.CHAINLINK_ORACLE,
138
- address: "0xcc70f09a6cc17553b2e31954cd36e4a2d89501f7",
139
- kovan: "0x40D447115370C4B65A0d8C63275033C54A3ed61F"
140
- }
141
- },
142
-
143
- UNI: {
144
- priceFeedETH: {
145
- type: OracleType.CHAINLINK_ORACLE,
146
- address: "0xD6aA3D25116d8dA79Ea0246c4826EB951872e02e",
147
- kovan: "0x006A9A6c0A6b5230d89f05eb1e4603AA6B1508BE"
148
- },
149
- priceFeedUSD: {
150
- type: OracleType.CHAINLINK_ORACLE,
151
- address: "0x553303d460EE0afB37EdFf9bE42922D8FF63220e",
152
- kovan: "0xDA5904BdBfB4EF12a3955aEcA103F51dc87c7C39"
153
- }
154
- },
155
-
156
- USDC: {
157
- priceFeedETH: {
158
- type: OracleType.CHAINLINK_ORACLE,
159
- address: "0x986b5E1e1755e3C2440e960477f25201B0a8bbD4",
160
- kovan: "0x64EaC61A2DFda2c3Fa04eED49AA33D021AeC8838"
161
- },
162
- priceFeedUSD: {
163
- type: OracleType.CHAINLINK_ORACLE,
164
- address: "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6",
165
- kovan: "0x9211c6b3BF41A10F78539810Cf5c64e1BB78Ec60"
166
- }
167
- },
168
-
169
- USDT: {
170
- priceFeedETH: {
171
- type: OracleType.CHAINLINK_ORACLE,
172
- address: "0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46",
173
- kovan: "0x0bF499444525a23E7Bb61997539725cA2e928138"
174
- },
175
- priceFeedUSD: {
176
- type: OracleType.CHAINLINK_ORACLE,
177
- address: "0x3e7d1eab13ad0104d2750b8863b489d65364e32d",
178
- kovan: "0x2ca5A90D34cA333661083F89D831f757A9A50148"
179
- }
180
- },
181
-
182
- WBTC: {
183
- priceFeedETH: {
184
- type: OracleType.CHAINLINK_ORACLE,
185
- address: "0xdeb288F737066589598e9214E782fa5A8eD689e8",
186
- kovan: "0xB4F231198CAA3446fd4623e59f2EF27e7A58A54b"
187
- },
188
- priceFeedUSD: {
189
- type: OracleType.CHAINLINK_ORACLE,
190
- address: "0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c",
191
- kovan: "0x6135b13325bfC4B00278B4abC5e20bbce2D6580e"
192
- }
193
- },
194
-
195
- WETH: {
196
- priceFeedUSD: {
197
- type: OracleType.CHAINLINK_ORACLE,
198
- address: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
199
- kovan: "0x9326BFA02ADD2366b30bacB125260Af641031331"
200
- }
201
- },
202
-
203
- YFI: {
204
- priceFeedETH: {
205
- type: OracleType.CHAINLINK_ORACLE,
206
- address: "0x7c5d4F8345e66f68099581Db340cd65B078C41f4",
207
- kovan: "0x29d651D233ffFdec4Df5244a9cE842FB253fAA09"
208
- },
209
- priceFeedUSD: {
210
- type: OracleType.CHAINLINK_ORACLE,
211
- address: "0xA027702dbb89fbd58938e4324ac03B58d812b0E1",
212
- kovan: "0x7f6a535B75E2c815f8865CF39Ad847971AcCC3bE"
213
- }
214
- },
215
-
216
- /// UPDATE
217
- STETH: {
218
- priceFeedETH: {
219
- type: OracleType.CHAINLINK_ORACLE,
220
- address: "0xcfe54b5cd566ab89272946f602d76ea879cab4a8",
221
- kovan: "0x087154969f935218e10f621D81e523C8f46C6dF9"
222
- },
223
- priceFeedUSD: {
224
- type: OracleType.CHAINLINK_ORACLE,
225
- address: "0xCfE54B5cD566aB89272946F602D76Ea879CAb4a8",
226
- kovan: "0x94dd77F85E0B1e6942B044E604EBA4869369453c"
227
- }
228
- },
229
-
230
- FTM: {
231
- priceFeedETH: {
232
- type: OracleType.CHAINLINK_ORACLE,
233
- address: "0x2de7e4a9488488e0058b95854cc2f7955b35dc9b",
234
- kovan: "0xdCd1eB60388F340d7bF6584aa4295D95b355686c"
235
- }
236
- },
237
-
238
- CVX: {
239
- priceFeedUSD: {
240
- type: OracleType.CHAINLINK_ORACLE,
241
- address: "0xd962fc30a72a84ce50161031391756bf2876af5d",
242
- kovan: "0xa6CeAbA9326C3a7Ed6A03A1cb0809A397ed286ae"
243
- }
244
- },
245
-
246
- FRAX: {
247
- priceFeedUSD: {
248
- type: OracleType.CHAINLINK_ORACLE,
249
- address: "0xb9e1e3a9feff48998e45fa90847ed4d467e8bcfd",
250
- kovan: "0xD696fF0750F753A605236Ab499E5432e0FdeCd72"
251
- }
252
- },
253
- LUSD: {
254
- priceFeedUSD: {
255
- type: OracleType.CHAINLINK_ORACLE,
256
- address: "0x3D7aE7E594f2f2091Ad8798313450130d0Aba3a0",
257
- kovan: "0xc17F8AE0c6C060F76303Be13f5f059144b38e75e"
258
- }
259
- },
260
- sUSD: {
261
- priceFeedUSD: {
262
- type: OracleType.CHAINLINK_ORACLE,
263
- address: "0xad35bd71b9afe6e4bdc266b345c198eadef9ad94",
264
- kovan: "0xe45b2D1e60d94209ef36e2E66a232daefc418de2"
265
- }
266
- },
267
-
268
- FXS: {
269
- priceFeedUSD: {
270
- type: OracleType.CHAINLINK_ORACLE,
271
- address: "0x6ebc52c8c1089be9eb3945c4350b68b8e4c2233f",
272
- kovan: "0xC6f5343637279AF7e2a4e12066Fb5ae567275E5F"
273
- }
274
- },
275
- LDO: {
276
- priceFeedETH: {
277
- type: OracleType.CHAINLINK_ORACLE,
278
- address: "0x4e844125952d32acdf339be976c98e22f6f318db",
279
- kovan: "0x6204148EF888786A2988E7b09c8e0A67e32cb387"
280
- },
281
- priceFeedUSD: {
282
- type: OracleType.ZERO_ORACLE
283
- }
284
-
285
- // ADD ETH-> DAI Oracle!
286
- },
287
- LQTY: {
288
- priceFeedUSD: {
289
- type: OracleType.ZERO_ORACLE
290
- }
291
- },
292
- SPELL: {
293
- priceFeedUSD: {
294
- type: OracleType.CHAINLINK_ORACLE,
295
- address: "0x8c110b94c5f1d347facf5e1e938ab2db60e3c9a8",
296
- kovan: "0x68da666AcD151A3edB62c1ad1b748cCcFca026d7"
297
- }
298
- },
299
- LUNA: {
300
- priceFeedETH: {
301
- type: OracleType.CHAINLINK_ORACLE,
302
- address: "0x91e9331556ed76c9393055719986409e11b56f73",
303
- kovan: "0xEfAe1275132C3D2EE009148748e3e3e384095E5f"
304
- }
305
- },
306
-
307
- yvDAI: {
308
- priceFeedETH: {
309
- type: OracleType.YEARN_TOKEN_ORACLE,
310
- token: "DAI",
311
- deployedKovan: ""
312
- },
313
- priceFeedUSD: {
314
- type: OracleType.YEARN_TOKEN_ORACLE,
315
- token: "DAI"
316
- }
317
- },
318
- yvUSDC: {
319
- priceFeedETH: {
320
- type: OracleType.YEARN_TOKEN_ORACLE,
321
- token: "USDC",
322
- deployedKovan: ""
323
- },
324
- priceFeedUSD: {
325
- type: OracleType.YEARN_TOKEN_ORACLE,
326
- token: "USDC"
327
- }
328
- },
329
- yvWETH: {
330
- priceFeedUSD: {
331
- type: OracleType.YEARN_TOKEN_ORACLE,
332
- token: "WETH"
333
- }
334
- },
335
- yvWBTC: {
336
- priceFeedUSD: {
337
- type: OracleType.YEARN_TOKEN_ORACLE,
338
- token: "WBTC"
339
- }
340
- },
341
-
342
- // CURVE LP TOKENS
343
-
344
- "3Crv": {
345
- priceFeedUSD: {
346
- type: OracleType.CURVE_LP_ORACLE,
347
- assets: ["DAI", "USDC", "USDT"]
348
- }
349
- },
350
-
351
- steCRV: {
352
- priceFeedUSD: {
353
- type: OracleType.CURVE_LP_ORACLE,
354
- assets: ["STETH", "WETH"]
355
- }
356
- },
357
- FRAX3CRV: {
358
- priceFeedUSD: {
359
- type: OracleType.CURVE_LP_ORACLE,
360
- assets: ["FRAX", "DAI", "USDC", "USDT"]
361
- }
362
- },
363
-
364
- LUSD3CRV: {
365
- priceFeedUSD: {
366
- type: OracleType.CURVE_LP_ORACLE,
367
- assets: ["LUSD", "DAI", "USDC", "USDT"]
368
- }
369
- },
370
-
371
- crvPlain3andSUSD: {
372
- priceFeedUSD: {
373
- type: OracleType.CURVE_LP_ORACLE,
374
- assets: ["DAI", "USDC", "USDT", "sUSD"]
375
- }
376
- },
377
-
378
- gusd3CRV: {
379
- priceFeedUSD: {
380
- type: OracleType.CURVE_LP_ORACLE,
381
- assets: ["GUSD", "DAI", "USDC", "USDT"]
382
- }
383
- },
384
-
385
- // YEARN- CURVE TOKENS
386
-
387
- yvCurve_stETH: {
388
- priceFeedUSD: {
389
- type: OracleType.YEARN_CURVE_LP_ORACLE,
390
- curveSymbol: "steCRV"
391
- }
392
- },
393
- yvCURVE_FRAX_POOL: {
394
- priceFeedUSD: {
395
- type: OracleType.YEARN_CURVE_LP_ORACLE,
396
- curveSymbol: "FRAX3CRV"
397
- }
398
- },
399
-
400
- // CVX tokens
401
- cvx3Crv: {
402
- priceFeedUSD: {
403
- type: OracleType.LIKE_CURVE_LP_ORACLE,
404
- curveSymbol: "3Crv"
405
- }
406
- },
407
- cvxsteCRV: {
408
- priceFeedUSD: {
409
- type: OracleType.LIKE_CURVE_LP_ORACLE,
410
- curveSymbol: "steCRV"
411
- }
412
- },
413
- cvxFRAX3CRV: {
414
- priceFeedUSD: {
415
- type: OracleType.LIKE_CURVE_LP_ORACLE,
416
- curveSymbol: "FRAX3CRV"
417
- }
418
- },
419
- cvxcrvPlain3andSUSD: {
420
- priceFeedUSD: {
421
- type: OracleType.LIKE_CURVE_LP_ORACLE,
422
- curveSymbol: "crvPlain3andSUSD"
423
- }
424
- },
425
- cvxgusd3CRV: {
426
- priceFeedUSD: {
427
- type: OracleType.LIKE_CURVE_LP_ORACLE,
428
- curveSymbol: "gusd3CRV"
429
- }
430
- },
431
- // CVX tokens
432
- stkcvx3Crv: {
433
- priceFeedUSD: {
434
- type: OracleType.LIKE_CURVE_LP_ORACLE,
435
- curveSymbol: "3Crv"
436
- }
437
- },
438
- stkcvxsteCRV: {
439
- priceFeedUSD: {
440
- type: OracleType.LIKE_CURVE_LP_ORACLE,
441
- curveSymbol: "steCRV"
442
- }
443
- },
444
- stkcvxFRAX3CRV: {
445
- priceFeedUSD: {
446
- type: OracleType.LIKE_CURVE_LP_ORACLE,
447
- curveSymbol: "FRAX3CRV"
448
- }
449
- },
450
- stkcvxcrvPlain3andSUSD: {
451
- priceFeedUSD: {
452
- type: OracleType.LIKE_CURVE_LP_ORACLE,
453
- curveSymbol: "crvPlain3andSUSD"
454
- }
455
- },
456
- stkcvxgusd3CRV: {
457
- priceFeedUSD: {
458
- type: OracleType.LIKE_CURVE_LP_ORACLE,
459
- curveSymbol: "gusd3CRV"
460
- }
461
- },
462
-
463
- //GEARBOX
464
- dDAI: {
465
- priceFeedETH: {
466
- type: OracleType.CHAINLINK_ORACLE,
467
- address: "",
468
- kovan: ""
469
- },
470
- priceFeedUSD: {
471
- type: OracleType.CHAINLINK_ORACLE,
472
- address: "",
473
- kovan: ""
474
- }
475
- },
476
-
477
- dUSDC: {
478
- priceFeedETH: {
479
- type: OracleType.CHAINLINK_ORACLE,
480
- address: "",
481
- kovan: ""
482
- },
483
- priceFeedUSD: {
484
- type: OracleType.CHAINLINK_ORACLE,
485
- address: "",
486
- kovan: ""
487
- }
488
- },
489
-
490
- dWBTC: {
491
- priceFeedETH: {
492
- type: OracleType.CHAINLINK_ORACLE,
493
- address: "",
494
- kovan: ""
495
- },
496
- priceFeedUSD: {
497
- type: OracleType.CHAINLINK_ORACLE,
498
- address: "",
499
- kovan: ""
500
- }
501
- },
502
-
503
- dWETH: {
504
- priceFeedETH: {
505
- type: OracleType.CHAINLINK_ORACLE,
506
- address: "",
507
- kovan: ""
508
- },
509
- priceFeedUSD: {
510
- type: OracleType.CHAINLINK_ORACLE,
511
- address: "",
512
- kovan: ""
513
- }
514
- },
515
-
516
- GEAR: {
517
- priceFeedETH: {
518
- type: OracleType.CHAINLINK_ORACLE,
519
- address: "",
520
- kovan: ""
521
- },
522
- priceFeedUSD: {
523
- type: OracleType.CHAINLINK_ORACLE,
524
- address: "",
525
- kovan: ""
526
- }
527
- }
528
- };
package/src/core/swap.ts DELETED
@@ -1,4 +0,0 @@
1
- export enum SwapType {
2
- ExactInput = 1,
3
- ExactOutput = 2,
4
- }
package/src/core/trade.ts DELETED
@@ -1,83 +0,0 @@
1
- import { BigNumber } from "ethers";
2
- import { SwapType } from "./swap";
3
- import { BytesLike } from "@ethersproject/bytes";
4
- import { PERCENTAGE_FACTOR, WAD } from "./constants";
5
-
6
- export interface CloseTradePath {
7
- path: Array<string>;
8
- amountOutMin: BigNumber;
9
- }
10
-
11
- export class TradePath {
12
- public readonly swapType: SwapType;
13
- public readonly amount: BigNumber;
14
- public readonly rate: BigNumber;
15
- public readonly path: Array<string>;
16
- public readonly expectedAmount: BigNumber;
17
- public readonly pathUniV3: BytesLike | undefined;
18
- public readonly i: number | undefined;
19
- public readonly j: number | undefined;
20
- public readonly operationName: string | undefined;
21
-
22
- constructor(params: {
23
- swapType: SwapType;
24
- amount: BigNumber;
25
- path: Array<string>;
26
- expectedAmount: BigNumber;
27
- pathUniV3?: BytesLike;
28
- i?: number;
29
- j?: number;
30
- operationName?: string;
31
- }) {
32
- this.swapType = params.swapType;
33
- this.amount = params.amount;
34
- this.path = params.path;
35
- this.expectedAmount = params.expectedAmount;
36
- this.pathUniV3 = params.pathUniV3;
37
- this.rate =
38
- params.swapType !== SwapType.ExactInput
39
- ? params.expectedAmount.mul(WAD).div(params.amount)
40
- : WAD.mul(params.amount).div(params.expectedAmount);
41
- this.i = params.i;
42
- this.j = params.j;
43
- this.operationName = params.operationName;
44
- }
45
-
46
- getExpectedAmountWithSlippage(slippage: number): BigNumber {
47
- return this.swapType === SwapType.ExactInput
48
- ? this.getAmountOutMin(slippage)
49
- : this.getAmountInMax(slippage);
50
- }
51
-
52
- getAmountInMax(slippage: number): BigNumber {
53
- return this.expectedAmount
54
- .mul(PERCENTAGE_FACTOR + slippage)
55
- .div(PERCENTAGE_FACTOR);
56
- }
57
-
58
- getAmountOutMin(slippage: number): BigNumber {
59
- return this.expectedAmount
60
- .mul(PERCENTAGE_FACTOR)
61
- .div(PERCENTAGE_FACTOR + slippage);
62
- }
63
-
64
- public get from(): string {
65
- return this.path[0];
66
- }
67
-
68
- public get to(): string {
69
- return this.path[this.path.length - 1];
70
- }
71
-
72
- getFromAmount(slippage: number): BigNumber {
73
- return this.swapType === SwapType.ExactInput
74
- ? this.amount
75
- : this.getExpectedAmountWithSlippage(slippage);
76
- }
77
-
78
- getToAmount(slippage: number): BigNumber {
79
- return this.swapType === SwapType.ExactOutput
80
- ? this.amount
81
- : this.getExpectedAmountWithSlippage(slippage);
82
- }
83
- }