@lifi/sdk 1.0.0

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 (63) hide show
  1. package/CHANGELOG.md +354 -0
  2. package/LICENSE +1 -0
  3. package/README.md +16 -0
  4. package/dist/Lifi.d.ts +186 -0
  5. package/dist/Lifi.js +461 -0
  6. package/dist/allowance/index.d.ts +22 -0
  7. package/dist/allowance/index.js +160 -0
  8. package/dist/allowance/utils.d.ts +14 -0
  9. package/dist/allowance/utils.js +137 -0
  10. package/dist/balances/index.d.ts +11 -0
  11. package/dist/balances/index.js +104 -0
  12. package/dist/balances/utils.d.ts +5 -0
  13. package/dist/balances/utils.js +255 -0
  14. package/dist/connectors.d.ts +6 -0
  15. package/dist/connectors.js +150 -0
  16. package/dist/execution/StatusManager.d.ts +63 -0
  17. package/dist/execution/StatusManager.js +150 -0
  18. package/dist/execution/StepExecutor.d.ts +15 -0
  19. package/dist/execution/StepExecutor.js +139 -0
  20. package/dist/execution/allowance.execute.d.ts +4 -0
  21. package/dist/execution/allowance.execute.js +156 -0
  22. package/dist/execution/balanceCheck.execute.d.ts +3 -0
  23. package/dist/execution/balanceCheck.execute.js +86 -0
  24. package/dist/execution/bridges/bridge.execute.d.ts +7 -0
  25. package/dist/execution/bridges/bridge.execute.js +218 -0
  26. package/dist/execution/exchanges/swap.execute.d.ts +7 -0
  27. package/dist/execution/exchanges/swap.execute.js +222 -0
  28. package/dist/execution/index.d.ts +1 -0
  29. package/dist/execution/index.js +17 -0
  30. package/dist/execution/switchChain.d.ts +16 -0
  31. package/dist/execution/switchChain.js +102 -0
  32. package/dist/execution/utils.d.ts +5 -0
  33. package/dist/execution/utils.js +175 -0
  34. package/dist/helpers.d.ts +18 -0
  35. package/dist/helpers.js +85 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +27 -0
  38. package/dist/services/ApiService.d.ts +14 -0
  39. package/dist/services/ApiService.js +350 -0
  40. package/dist/services/ChainsService.d.ts +11 -0
  41. package/dist/services/ChainsService.js +108 -0
  42. package/dist/services/ConfigService.d.ts +23 -0
  43. package/dist/services/ConfigService.js +133 -0
  44. package/dist/typeguards.d.ts +4 -0
  45. package/dist/typeguards.js +55 -0
  46. package/dist/types/ERC20.d.ts +22 -0
  47. package/dist/types/ERC20.js +53 -0
  48. package/dist/types/index.d.ts +4 -0
  49. package/dist/types/index.js +22 -0
  50. package/dist/types/internal.types.d.ts +75 -0
  51. package/dist/types/internal.types.js +2 -0
  52. package/dist/utils/errors.d.ts +73 -0
  53. package/dist/utils/errors.js +147 -0
  54. package/dist/utils/getProvider.d.ts +3 -0
  55. package/dist/utils/getProvider.js +11 -0
  56. package/dist/utils/multicall.d.ts +10 -0
  57. package/dist/utils/multicall.js +111 -0
  58. package/dist/utils/multicallAbi.json +313 -0
  59. package/dist/utils/parseError.d.ts +37 -0
  60. package/dist/utils/parseError.js +184 -0
  61. package/dist/utils/utils.d.ts +26 -0
  62. package/dist/utils/utils.js +188 -0
  63. package/package.json +90 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,354 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ## [1.0.0](https://github.com/lifinance/sdk/compare/v1.0.0-beta.14...v1.0.0) (2022-07-12)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * move to a new @lifi scope (#85)
11
+
12
+ ### Features
13
+
14
+ * add func to check for correct native token ([#84](https://github.com/lifinance/sdk/issues/84)) ([865bc14](https://github.com/lifinance/sdk/commit/865bc14594902c7b94c30f5a910b7897b1133bd5))
15
+ * move to a new [@lifi](https://github.com/lifi) scope ([#85](https://github.com/lifinance/sdk/issues/85)) ([b58c5a1](https://github.com/lifinance/sdk/commit/b58c5a10e2c47fff3e1c43ae15516514b90b9197))
16
+ * new error messages ([#83](https://github.com/lifinance/sdk/issues/83)) ([ccebe17](https://github.com/lifinance/sdk/commit/ccebe170d32001377eb7b632afd76729252a8994))
17
+
18
+ ## [1.0.0-beta.14](https://github.com/lifinance/sdk/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2022-07-06)
19
+
20
+
21
+ ### Features
22
+
23
+ * add more error logging ([#82](https://github.com/lifinance/sdk/issues/82)) ([edb4f85](https://github.com/lifinance/sdk/commit/edb4f851111bf905a266d831aae591f8a86518d0))
24
+ * use new substates from api ([#81](https://github.com/lifinance/sdk/issues/81)) ([4ad51a2](https://github.com/lifinance/sdk/commit/4ad51a2a8c946a99e5a4b6c5663f856f2f7fd497))
25
+
26
+ ## [1.0.0-beta.13](https://github.com/lifinance/sdk/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2022-07-05)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * wait for replaced transaction ([#80](https://github.com/lifinance/sdk/issues/80)) ([6d29b2e](https://github.com/lifinance/sdk/commit/6d29b2e587f76355fb1d8c07e6334160d7aaccb6))
32
+
33
+ ## [1.0.0-beta.12](https://github.com/lifinance/sdk/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2022-06-29)
34
+
35
+
36
+ ### Features
37
+
38
+ * better resume of failed transactions ([#78](https://github.com/lifinance/sdk/issues/78)) ([1558c47](https://github.com/lifinance/sdk/commit/1558c4768c39b8d9e42c2b6e92d78236c7d29669))
39
+ * handle slippage errors ([#79](https://github.com/lifinance/sdk/issues/79)) ([b672ed9](https://github.com/lifinance/sdk/commit/b672ed905db146a87cce62fa8045d8a476da0cfb))
40
+
41
+ ## [1.0.0-beta.11](https://github.com/lifinance/sdk/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2022-06-08)
42
+
43
+ ## [1.0.0-beta.10](https://github.com/lifinance/sdk/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2022-06-07)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * fix dist folder ([868bcc9](https://github.com/lifinance/sdk/commit/868bcc9628c8ae02809cb65fd0ffc1d2ec254666))
49
+
50
+ ## [1.0.0-beta.9](https://github.com/lifinance/sdk/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2022-06-07)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * updated e2e + added tsc compilation on push ([#77](https://github.com/lifinance/sdk/issues/77)) ([7d99cd1](https://github.com/lifinance/sdk/commit/7d99cd11a705cf30d48903dea2c158aa16ae7a7e))
56
+
57
+ ## [1.0.0-beta.8](https://github.com/lifinance/sdk/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2022-06-02)
58
+
59
+
60
+ ### Features
61
+
62
+ * use tryBlockAndAggregate to fetch balances ([#76](https://github.com/lifinance/sdk/issues/76)) ([5f01961](https://github.com/lifinance/sdk/commit/5f019619c11269c197a777c323eb18de11a403dd))
63
+
64
+ ## [1.0.0-beta.7](https://github.com/lifinance/sdk/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2022-06-01)
65
+
66
+
67
+ ### Features
68
+
69
+ * improve balance error messages ([#74](https://github.com/lifinance/sdk/issues/74)) ([b249732](https://github.com/lifinance/sdk/commit/b249732cfef182158106de52fec24948e2a5dbe3))
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * added toolDetails + workaround for non EVM chains testing ([#70](https://github.com/lifinance/sdk/issues/70)) ([f972477](https://github.com/lifinance/sdk/commit/f972477573d5f969c7294b3054b96c1357e42893))
75
+ * fix yarn.lock ([abdef57](https://github.com/lifinance/sdk/commit/abdef57b6ee1d444602cdcd6e34b61c3e66d86ab))
76
+ * log error if provider can not be configured ([#75](https://github.com/lifinance/sdk/issues/75)) ([85e22e9](https://github.com/lifinance/sdk/commit/85e22e96427b08381eefe263a079a5b1057988df))
77
+ * **utils:** only allow one status poll loop per tx ([#69](https://github.com/lifinance/sdk/issues/69)) ([0cc7e2b](https://github.com/lifinance/sdk/commit/0cc7e2b73222614262e7fd263112407791d62a4b))
78
+
79
+ ## [1.0.0-beta.6](https://github.com/lifinance/sdk/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2022-05-17)
80
+
81
+
82
+ ### Features
83
+
84
+ * expose error codes ([e151051](https://github.com/lifinance/sdk/commit/e151051e96d57c99606bc447d4391e9f7bc8a266))
85
+
86
+ ## [1.0.0-beta.5](https://github.com/lifinance/sdk/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2022-05-17)
87
+
88
+
89
+ ### Bug Fixes
90
+
91
+ * add missing toAddress param ([#68](https://github.com/lifinance/sdk/issues/68)) ([c9318ed](https://github.com/lifinance/sdk/commit/c9318edef9b5ec2b2c86b7e2f8f1645ae597437e))
92
+
93
+ ## [1.0.0-beta.4](https://github.com/lifinance/sdk/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2022-05-13)
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * fix types for requests cancellation ([36d7b55](https://github.com/lifinance/sdk/commit/36d7b5561d2cc2c1b47eba2ac75f07554dfca118))
99
+
100
+ ## [1.0.0-beta.3](https://github.com/lifinance/sdk/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2022-05-13)
101
+
102
+
103
+ ### Features
104
+
105
+ * add getTokens endpoint ([#65](https://github.com/lifinance/sdk/issues/65)) ([5d9319c](https://github.com/lifinance/sdk/commit/5d9319c3ee749a6b5a81847440a3e803ffe40ee8))
106
+ * add requests cancellation ([#67](https://github.com/lifinance/sdk/issues/67)) ([32d0595](https://github.com/lifinance/sdk/commit/32d059590e0c03844245138f9f2aa9e76d7b6166))
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * remove duplicated getRoutes logic ([#66](https://github.com/lifinance/sdk/issues/66)) ([52bb994](https://github.com/lifinance/sdk/commit/52bb994ea1f6d5be90755f4dea4e1f5198557a95))
112
+
113
+ ## [1.0.0-beta.2](https://github.com/lifinance/sdk/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2022-05-06)
114
+
115
+
116
+ ### ⚠ BREAKING CHANGES
117
+
118
+ * refine error messages and codes (#64)
119
+
120
+ ### Features
121
+
122
+ * refine error messages and codes ([#64](https://github.com/lifinance/sdk/issues/64)) ([543bd28](https://github.com/lifinance/sdk/commit/543bd28b7d41c8daee3a82ca95cde1fce56f8db9))
123
+
124
+ ## [1.0.0-beta.1](https://github.com/lifinance/sdk/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2022-05-06)
125
+
126
+
127
+ ### ⚠ BREAKING CHANGES
128
+
129
+ * deep clone incoming routes to prevent side effects (#62)
130
+ * improve status management (#63)
131
+
132
+ ### Features
133
+
134
+ * add retry logic to jest ([#59](https://github.com/lifinance/sdk/issues/59)) ([c62ac37](https://github.com/lifinance/sdk/commit/c62ac370504e6bf652c24c75888d1fc44d394683))
135
+ * added getTools ([#61](https://github.com/lifinance/sdk/issues/61)) ([82e8ddd](https://github.com/lifinance/sdk/commit/82e8ddd6becbbbb197bc8f68376f12cfc6426ec1))
136
+ * improve status management ([#63](https://github.com/lifinance/sdk/issues/63)) ([e22ab60](https://github.com/lifinance/sdk/commit/e22ab6077f2b4e4fd88ca6519154d6c74e7480e7))
137
+
138
+
139
+ ### Bug Fixes
140
+
141
+ * deep clone incoming routes to prevent side effects ([#62](https://github.com/lifinance/sdk/issues/62)) ([6040757](https://github.com/lifinance/sdk/commit/6040757f96a77ef8d370abc92ea0128c555a6696)), closes [#61](https://github.com/lifinance/sdk/issues/61) [#63](https://github.com/lifinance/sdk/issues/63)
142
+ * fix optimism balance loading ([#57](https://github.com/lifinance/sdk/issues/57)) ([219c3a9](https://github.com/lifinance/sdk/commit/219c3a903e7568f4df9d058d9b83f6d99744766b))
143
+ * fix undefined route error ([#58](https://github.com/lifinance/sdk/issues/58)) ([8cb120e](https://github.com/lifinance/sdk/commit/8cb120eb509ae12afdc9cea933081b2f4c1cdc5f))
144
+
145
+ ## [1.0.0-beta.0](https://github.com/lifinance/sdk/compare/v0.5.3...v1.0.0-beta.0) (2022-04-13)
146
+
147
+
148
+ ### ⚠ BREAKING CHANGES
149
+
150
+ * use object pattern for public methods with many params (#56)
151
+ * load available chains from the backend (#53)
152
+
153
+ ### Features
154
+
155
+ * load available chains from the backend ([#53](https://github.com/lifinance/sdk/issues/53)) ([67cff83](https://github.com/lifinance/sdk/commit/67cff834aa7643234ec43626489059869e018787))
156
+ * use /status for swap execution handling ([#55](https://github.com/lifinance/sdk/issues/55)) ([0e4821c](https://github.com/lifinance/sdk/commit/0e4821c3784d87e0e4ac725eea14b3f14fe8b03c))
157
+ * use object pattern for public methods with many params ([#56](https://github.com/lifinance/sdk/issues/56)) ([b167240](https://github.com/lifinance/sdk/commit/b167240602b13d3733e5e4de5271411b5fdbd4b2))
158
+
159
+
160
+ ### Bug Fixes
161
+
162
+ * handle status result 'FAILED' correctly ([#54](https://github.com/lifinance/sdk/issues/54)) ([a2113a4](https://github.com/lifinance/sdk/commit/a2113a42dc05c3cc9666a6f73bc64fe0b083372b))
163
+ * route undefined bug ([#52](https://github.com/lifinance/sdk/issues/52)) ([f0bd05e](https://github.com/lifinance/sdk/commit/f0bd05e8e8454ee570ed908b9584d24dcfadc10e))
164
+
165
+ ### [0.5.4](https://github.com/lifinance/sdk/compare/v0.5.3...v0.5.4) (2022-04-04)
166
+
167
+ ### [0.5.3](https://github.com/lifinance/sdk/compare/v0.5.2...v0.5.3) (2022-04-04)
168
+
169
+ ### [0.5.2](https://github.com/lifinance/sdk/compare/v0.5.1...v0.5.2) (2022-04-04)
170
+
171
+
172
+ ### Features
173
+
174
+ * adjust status handling to new behaviour ([#50](https://github.com/lifinance/sdk/issues/50)) ([3d3c540](https://github.com/lifinance/sdk/commit/3d3c5403da8392d3e9e62271c0b84c71042b73c4))
175
+
176
+
177
+ ### Bug Fixes
178
+
179
+ * continue status calls after failure ([#49](https://github.com/lifinance/sdk/issues/49)) ([3db0a62](https://github.com/lifinance/sdk/commit/3db0a626cc6eb8449c11ed5b3091a748f9c38094))
180
+
181
+ ### [0.5.1](https://github.com/lifinance/sdk/compare/v0.5.0...v0.5.1) (2022-03-24)
182
+
183
+ ## [0.5.0](https://github.com/lifinance/sdk/compare/v0.4.11...v0.5.0) (2022-03-24)
184
+
185
+ ### [0.4.11](https://github.com/lifinance/sdk/compare/v0.4.10...v0.4.11) (2022-03-24)
186
+
187
+
188
+ ### Features
189
+
190
+ * add infinite approval to execution settings ([#47](https://github.com/lifinance/sdk/issues/47)) ([e2b3995](https://github.com/lifinance/sdk/commit/e2b39950a8e3d06998ce492ffd6bfcc2b36c35de))
191
+ * add token approval methods ([#48](https://github.com/lifinance/sdk/issues/48)) ([1f3b64d](https://github.com/lifinance/sdk/commit/1f3b64d8e545a0eb4ca33e94065b6b99dd02b0e3))
192
+
193
+ ### [0.4.10](https://github.com/lifinance/sdk/compare/v0.4.9...v0.4.10) (2022-03-20)
194
+
195
+
196
+ ### Features
197
+
198
+ * add chains endpoint to SDK ([#46](https://github.com/lifinance/sdk/issues/46)) ([4b500d7](https://github.com/lifinance/sdk/commit/4b500d738303e1c67f54c929447157a1fab26f8a))
199
+
200
+ ### [0.4.9](https://github.com/lifinance/sdk/compare/v0.4.8...v0.4.9) (2022-03-15)
201
+
202
+
203
+ ### Bug Fixes
204
+
205
+ * store received token in execution object ([#45](https://github.com/lifinance/sdk/issues/45)) ([8115ccd](https://github.com/lifinance/sdk/commit/8115ccde4123c420d7e3f96b1e3e2b67c4773e68))
206
+
207
+ ### [0.4.8](https://github.com/lifinance/sdk/compare/v0.4.7...v0.4.8) (2022-03-07)
208
+
209
+
210
+ ### Features
211
+
212
+ * randomly select RPCs to prevent quota issues ([#44](https://github.com/lifinance/sdk/issues/44)) ([4346282](https://github.com/lifinance/sdk/commit/4346282ccd82072cba0e8ba1101f1b55b5bbd8f4))
213
+
214
+ ### [0.4.7](https://github.com/lifinance/sdk/compare/v0.4.6...v0.4.7) (2022-02-24)
215
+
216
+
217
+ ### Features
218
+
219
+ * use common bridge executor for all known BridgeTools ([#43](https://github.com/lifinance/sdk/issues/43)) ([77626b3](https://github.com/lifinance/sdk/commit/77626b35c617a594f7f1924fc6860c35b9fafa8c))
220
+
221
+ ### [0.4.6](https://github.com/lifinance/sdk/compare/v0.4.5-beta.2...v0.4.6) (2022-02-24)
222
+
223
+ ### Bug Fixes
224
+
225
+ * handle tokens with 0xeee... zero
226
+ addresses ([#41](https://github.com/lifinance/sdk/issues/41)) ([130df5](https://github.com/lifinance/sdk/commit/130df5a3c60e4e5848e7893035c19bec6a9e8365))
227
+
228
+ ### Features
229
+
230
+ * use common bridge executor for bridge
231
+ calls ([#42](https://github.com/lifinance/sdk/issues/40)) ([2c8865](https://github.com/lifinance/sdk/commit/2c88651532af66a31108489dd455a2fece54436b))
232
+ * **Hop:** use common bridge executor for hop
233
+ transfers ([#40](https://github.com/lifinance/sdk/issues/40)) ([b65519](https://github.com/lifinance/sdk/commit/b655190a481a29b1b09b09e97c1c9edd1d25fd92))
234
+
235
+ ### [0.4.5](https://github.com/lifinance/sdk/compare/v0.4.4...v0.4.5) (2022-02-10)
236
+
237
+ ### [0.4.4](https://github.com/lifinance/sdk/compare/v0.4.2...v0.4.4) (2022-02-09)
238
+
239
+ ### Bug Fixes
240
+
241
+ * check chain before sending
242
+ transactions ([#33](https://github.com/lifinance/sdk/issues/33)) ([6b92a77](https://github.com/lifinance/sdk/commit/6b92a7740d00427244c48df2a4c30f255e2a89ec))
243
+ * fix type changes ([59b9981](https://github.com/lifinance/sdk/commit/59b9981d7b71704bcb137ecc2de4af09f3f819a8))
244
+ * **nxtp:** wait for subgraph setup before calling
245
+ waitFor ([62c7f73](https://github.com/lifinance/sdk/commit/62c7f73fe186c6ebd70fdbb38c84863abb71fc52))
246
+ * show better connext error
247
+ message ([#32](https://github.com/lifinance/sdk/issues/32)) ([e3f9998](https://github.com/lifinance/sdk/commit/e3f9998c12a16b99e2b3d3b638b47016d90a85fe))
248
+
249
+ ### [0.4.3](https://github.com/lifinance/sdk/compare/v0.4.2...v0.4.3) (2022-01-29)
250
+
251
+ ### [0.4.2](https://github.com/lifinance/sdk/compare/v0.4.1...v0.4.2) (2022-01-28)
252
+
253
+ ### Features
254
+
255
+ * add new API endpoints to
256
+ SDK ([#30](https://github.com/lifinance/sdk/issues/30)) ([89ace22](https://github.com/lifinance/sdk/commit/89ace22ed6f7a76900ebdffb85b4393ba687770c))
257
+ * improve handling of wallet & backend
258
+ errors ([#22](https://github.com/lifinance/sdk/issues/22)) ([05e94d6](https://github.com/lifinance/sdk/commit/05e94d617ac22928bbc3265d3a75579e7e5a833d))
259
+ * use v1 LiFi
260
+ endpoints ([#29](https://github.com/lifinance/sdk/issues/29)) ([c271425](https://github.com/lifinance/sdk/commit/c2714252a9be2df0ea1e1a30b7f01be3839bb563))
261
+
262
+ ### Bug Fixes
263
+
264
+ * **Hop:** check subgraphs for success confirmation instead of using hop
265
+ sdk ([#24](https://github.com/lifinance/sdk/issues/24)) ([ce95623](https://github.com/lifinance/sdk/commit/ce956233f19c16ba017606207715f5ab61143032))
266
+ * **nxtp:** improve nxtp timeout
267
+ handling ([#23](https://github.com/lifinance/sdk/issues/23)) ([fa12dec](https://github.com/lifinance/sdk/commit/fa12dec9834d236ae8a621866b3813d19a56107e))
268
+ * **nxtp:** use transactionId returned by the backend (
269
+ LF-78) ([121c103](https://github.com/lifinance/sdk/commit/121c1032a989a137d8d473af233e362e0d80ff3b))
270
+ * resolve eslint
271
+ issues ([#27](https://github.com/lifinance/sdk/issues/27)) ([5b307ce](https://github.com/lifinance/sdk/commit/5b307ce749c6f9e87513155778421eb6323b148a))
272
+ * type in
273
+ hook ([#28](https://github.com/lifinance/sdk/issues/28)) ([9e72a39](https://github.com/lifinance/sdk/commit/9e72a3917a9fa6441b859dc6492b73dd9568df92))
274
+
275
+ ### [0.4.1](https://github.com/lifinance/sdk/compare/v0.4.0...v0.4.1) (2022-01-14)
276
+
277
+ ## [0.4.0](https://github.com/lifinance/sdk/compare/v0.3.3...v0.4.0) (2022-01-14)
278
+
279
+ ### ⚠ BREAKING CHANGES
280
+
281
+ * interface of external status management methods changed
282
+
283
+ ### Bug Fixes
284
+
285
+ * **nxtp:** handle cancelled
286
+ transfers ([#18](https://github.com/lifinance/sdk/issues/18)) ([02cd6de](https://github.com/lifinance/sdk/commit/02cd6deb499e5b6b08ee111dcefe2ebda81da548))
287
+ * **scripts:** make install script OS
288
+ agnostic ([6792a8f](https://github.com/lifinance/sdk/commit/6792a8fceb4246ed77b18ef58481fa56a6bca92c))
289
+
290
+
291
+ * refactor status
292
+ handling ([#5](https://github.com/lifinance/sdk/issues/5)) ([aa924d8](https://github.com/lifinance/sdk/commit/aa924d80a3b151b8ca750a311436fb10aa4f8f7a))
293
+
294
+ ### [0.3.4](https://github.com/lifinance/sdk/compare/v0.3.3...v0.3.4) (2022-01-12)
295
+
296
+ ### Bug Fixes
297
+
298
+ * **nxtp:** handle cancelled
299
+ transfers ([#18](https://github.com/lifinance/sdk/issues/18)) ([02cd6de](https://github.com/lifinance/sdk/commit/02cd6deb499e5b6b08ee111dcefe2ebda81da548))
300
+ * **scripts:** make install script OS
301
+ agnostic ([6792a8f](https://github.com/lifinance/sdk/commit/6792a8fceb4246ed77b18ef58481fa56a6bca92c))
302
+
303
+ ### [0.3.3](https://github.com/lifinance/sdk/compare/v0.2.3...v0.3.3) (2022-01-04)
304
+
305
+ ### Bug Fixes
306
+
307
+ * **nxtp:** wait until balance rpc contains block number larger than claim block
308
+ number ([#14](https://github.com/lifinance/sdk/issues/14)) ([5146af0](https://github.com/lifinance/sdk/commit/5146af0a2596f202eec74ffc0af89905264ab66c))
309
+
310
+ ### [0.2.3](https://github.com/lifinance/sdk/compare/v0.2.2...v0.2.3) (2021-12-30)
311
+
312
+ ### Features
313
+
314
+ * **bal:** add local balance checks to avoid impossible
315
+ transactions ([2a8e0b2](https://github.com/lifinance/sdk/commit/2a8e0b2fd25622cdb9f253e610e25fc0cde9d3f7))
316
+ * **balance:** update multicall contract usage in balance
317
+ util ([#9](https://github.com/lifinance/sdk/issues/9)) ([74b1d8f](https://github.com/lifinance/sdk/commit/74b1d8fe4c2a4da505584db65826c015608ebebe))
318
+ * **dex:** parse exchange
319
+ transactions ([97cba56](https://github.com/lifinance/sdk/commit/97cba56fdd97c6f7998e9da8b8346832ee5d25eb))
320
+
321
+ ### [0.2.2](https://github.com/lifinance/sdk/compare/v0.2.1...v0.2.2) (2021-12-28)
322
+
323
+ ### Bug Fixes
324
+
325
+ * **paraswap:** improve receipt
326
+ parsing ([ee604a5](https://github.com/lifinance/sdk/commit/ee604a5e7fe4ae1e5c433441b7cb8fb0fd4e241d))
327
+
328
+ ### [0.2.1](https://github.com/lifinance/sdk/compare/v0.2.0...v0.2.1) (2021-12-16)
329
+
330
+ ## [0.2.0](https://github.com/lifinance/sdk/compare/v0.1.1...v0.2.0) (2021-12-16)
331
+
332
+ ### Features
333
+
334
+ * **config:** allow to edit the underlying
335
+ config ([#2](https://github.com/lifinance/sdk/issues/2)) ([3c04ead](https://github.com/lifinance/sdk/commit/3c04ead754097ae9d39071b87fe9f7174dee50e4))
336
+
337
+ ### Bug Fixes
338
+
339
+ * **balance:** split large token lists into
340
+ chunks ([#7](https://github.com/lifinance/sdk/issues/7)) ([d19f837](https://github.com/lifinance/sdk/commit/d19f837b2df88427444ea954016ed61a1cc2e0f8))
341
+
342
+ ### [0.1.1](https://github.com/lifinance/sdk/compare/v0.1.0...v0.1.1) (2021-12-13)
343
+
344
+ ### Features
345
+
346
+ * **balances:** handle empty token
347
+ lists ([b0a4837](https://github.com/lifinance/sdk/commit/b0a48376b70b92266eff368437b56ac26a715c39))
348
+ * **nxtp:** handle encryption/decryption via
349
+ hooks ([#4](https://github.com/lifinance/sdk/issues/4)) ([4e4f27d](https://github.com/lifinance/sdk/commit/4e4f27de798f2ccb9b04def0a518afdebb26cf43))
350
+
351
+ ## [0.1.0](https://github.com/lifinance/sdk/compare/v0.0.2...v0.1.0) (2021-12-10)
352
+
353
+ * **Token:** refactor token and coin
354
+ usage ([#1](https://github.com/lifinance/sdk/issues/1)) ([5ee4d86](https://github.com/lifinance/sdk/commit/5ee4d86ac037f74de0981139f8275031be58c82b))
package/LICENSE ADDED
@@ -0,0 +1 @@
1
+ UNLICENSED
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ ### Installation
2
+
3
+ ```bash
4
+ yarn add @lifi/sdk
5
+ ```
6
+
7
+ or
8
+
9
+ ```bash
10
+ npm install --save @lifi/sdk
11
+ ```
12
+
13
+ ### Summary
14
+
15
+ This package allows accessing to LI.FI API which finds the best cross-chain routes on different bridges. The routes can
16
+ then be executed via the SDK. Learn more about LI.FI on (https://li.fi).
package/dist/Lifi.d.ts ADDED
@@ -0,0 +1,186 @@
1
+ import { Chain, ChainId, ChainKey, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, Route, RoutesRequest, RoutesResponse, StatusResponse, Step, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
2
+ import { Signer } from 'ethers';
3
+ import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
4
+ import { Config, ConfigUpdate, ExecutionSettings, RevokeTokenData } from './types';
5
+ export default class LIFI {
6
+ private activeRouteDictionary;
7
+ private configService;
8
+ private chainsService;
9
+ constructor(configUpdate?: ConfigUpdate);
10
+ /**
11
+ * Get the current configuration of the SDK
12
+ * @return {Config} - The config object
13
+ */
14
+ getConfig: () => Config;
15
+ /**
16
+ * Get the SDK configuration after all setup calls are finished
17
+ * @return {Promise<Config>} - The config object
18
+ */
19
+ getConfigAsync: () => Promise<Config>;
20
+ /**
21
+ * Set a new confuration for the SDK
22
+ * @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
23
+ * @return {Config} The renewed config object
24
+ */
25
+ setConfig: (configUpdate: ConfigUpdate) => Config;
26
+ /**
27
+ * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
28
+ * @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
29
+ * @return {Promise<PossibilitiesResponse>} Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
30
+ * @throws {LifiError} Throws a LifiError if request fails.
31
+ */
32
+ getPossibilities: (request?: PossibilitiesRequest, options?: RequestOptions) => Promise<PossibilitiesResponse>;
33
+ /**
34
+ * Fetch information about a Token
35
+ * @param {ChainKey | ChainId} chain - Id or key of the chain that contains the token
36
+ * @param {string} token - Address or symbol of the token on the requested chain
37
+ * @throws {LifiError} - Throws a LifiError if request fails
38
+ */
39
+ getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions) => Promise<Token>;
40
+ /**
41
+ * Get a quote for a token transfer
42
+ * @param {QuoteRequest} request - The configuration of the requested quote
43
+ * @throws {LifiError} - Throws a LifiError if request fails
44
+ */
45
+ getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<Step>;
46
+ /**
47
+ * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
48
+ * @param {GetStatusRequest} request - Configuration of the requested status
49
+ * @throws {LifiError} - Throws a LifiError if request fails
50
+ */
51
+ getStatus: (request: GetStatusRequest, options?: RequestOptions) => Promise<StatusResponse>;
52
+ /**
53
+ * Get the available tools to bridge and swap tokens.
54
+ * @param {ToolsRequest?} request - The configuration of the requested tools
55
+ * @returns The tools that are available on the requested chains
56
+ */
57
+ getTools: (request?: ToolsRequest, options?: RequestOptions) => Promise<ToolsResponse>;
58
+ /**
59
+ * Get all known tokens.
60
+ * @param {TokensRequest?} request - The configuration of the requested tokens
61
+ * @returns The tokens that are available on the requested chains
62
+ */
63
+ getTokens: (request?: TokensRequest, options?: RequestOptions) => Promise<TokensResponse>;
64
+ /**
65
+ * Get all available chains
66
+ * @return {Promise<Chain[]>} A list of all available chains
67
+ * @throws {LifiError} Throws a LifiError if request fails.
68
+ */
69
+ getChains: () => Promise<Chain[]>;
70
+ /**
71
+ * Get a set of routes for a request that describes a transfer of tokens.
72
+ * @param {RoutesRequest} routesRequest - A description of the transfer.
73
+ * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
74
+ * @throws {LifiError} Throws a LifiError if request fails.
75
+ */
76
+ getRoutes: (request: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
77
+ /**
78
+ * Get the transaction data for a single step of a route
79
+ * @param {Step} step - The step object.
80
+ * @return {Promise<Step>} The step populated with the transaction data.
81
+ * @throws {LifiError} Throws a LifiError if request fails.
82
+ */
83
+ getStepTransaction: (step: Step, options?: RequestOptions) => Promise<Step>;
84
+ /**
85
+ * Stops the execution of an active route.
86
+ * @param {Route} route - A route that is currently in execution.
87
+ * @return {Route} The stopped route.
88
+ */
89
+ stopExecution: (route: Route) => Route;
90
+ /**
91
+ * Executes a route until a user interaction is necessary (signing transactions, etc.) and then halts until the route is resumed.
92
+ * @param {Route} route - A route that is currently in execution.
93
+ */
94
+ moveExecutionToBackground: (route: Route) => void;
95
+ /**
96
+ * Execute a route.
97
+ * @param {Signer} signer - The signer required to send the transactions.
98
+ * @param {Route} route - The route that should be executed. Cannot be an active route.
99
+ * @param {ExecutionSettings} settings - An object containing settings and callbacks.
100
+ * @return {Promise<Route>} The executed route.
101
+ * @throws {LifiError} Throws a LifiError if the execution fails.
102
+ */
103
+ executeRoute: (signer: Signer, route: Route, settings?: ExecutionSettings) => Promise<Route>;
104
+ /**
105
+ * Resume the execution of a route that has been stopped or had an error while executing.
106
+ * @param {Signer} signer - The signer required to send the transactions.
107
+ * @param {Route} route - The route that is to be executed. Cannot be an active route.
108
+ * @param {ExecutionSettings} settings - An object containing settings and callbacks.
109
+ * @return {Promise<Route>} The executed route.
110
+ * @throws {LifiError} Throws a LifiError if the execution fails.
111
+ */
112
+ resumeRoute: (signer: Signer, route: Route, settings?: ExecutionSettings) => Promise<Route>;
113
+ private executeSteps;
114
+ /**
115
+ * Update the ExecutionSettings for an active route.
116
+ * @param {ExecutionSettings} settings - An object with execution settings.
117
+ * @param {Route} route - The active route that gets the new execution settings.
118
+ * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
119
+ */
120
+ updateExecutionSettings: (settings: ExecutionSettings, route: Route) => void;
121
+ /**
122
+ * Get the list of active routes.
123
+ * @return {Route[]} A list of routes.
124
+ */
125
+ getActiveRoutes: () => Route[];
126
+ /**
127
+ * Return the current route information for given route. The route has to be active.
128
+ * @param {Route} route - A route object.
129
+ * @return {Route} The updated route.
130
+ */
131
+ getActiveRoute: (route: Route) => Route | undefined;
132
+ /**
133
+ * Returns the balances of a specific token a wallet holds across all aggregated chains.
134
+ * @param {string} walletAddress - A wallet address.
135
+ * @param {Token} token - A Token object.
136
+ * @return {Promise<TokenAmount | null>} An object containing the token and the amounts on different chains.
137
+ * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
138
+ */
139
+ getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
140
+ /**
141
+ * Returns the balances for a list tokens a wallet holds across all aggregated chains.
142
+ * @param {string} walletAddress - A wallet address.
143
+ * @param {Token[]} tokens - A list of Token objects.
144
+ * @return {Promise<TokenAmount[]>} A list of objects containing the tokens and the amounts on different chains.
145
+ * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
146
+ */
147
+ getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
148
+ /**
149
+ * This method queries the balances of tokens for a specific list of chains for a given wallet.
150
+ * @param {string} walletAddress - A walletaddress.
151
+ * @param {{ [chainId: number]: Token[] }} tokensByChain - A list of Token objects organized by chain ids.
152
+ * @return {Promise<{ [chainId: number]: TokenAmount[] }} A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
153
+ * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
154
+ */
155
+ getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
156
+ [chainId: number]: Token[];
157
+ }) => Promise<{
158
+ [chainId: number]: TokenAmount[];
159
+ }>;
160
+ /**
161
+ * Get the current approval for a certain token.
162
+ * @param signer - The signer owning the token
163
+ * @param token - The token that should be checked
164
+ * @param approvalAddress - The address that has be approved
165
+ */
166
+ getTokenApproval: (signer: Signer, token: Token, approvalAddress: string) => Promise<string | undefined>;
167
+ /**
168
+ * Get the current approval for a list of token / approval address pairs.
169
+ * @param signer - The signer owning the tokens
170
+ * @param tokenData - A list of token and approval address pairs
171
+ */
172
+ bulkGetTokenApproval: (signer: Signer, tokenData: RevokeTokenData[]) => Promise<{
173
+ token: Token;
174
+ approval: string | undefined;
175
+ }[]>;
176
+ /**
177
+ * Set approval for a certain token and amount.
178
+ * @param { ApproveTokenRequest } request - The approval request
179
+ */
180
+ approveToken: (request: ApproveTokenRequest) => Promise<void>;
181
+ /**
182
+ * Revoke approval for a certain token.
183
+ * @param { RevokeApprovalRequest } request - The revoke request
184
+ */
185
+ revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
186
+ }