@alcorexchange/alcor-swap-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 (110) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +12 -0
  3. package/LICENSE +21 -0
  4. package/build/entities/baseCurrency.js +27 -0
  5. package/build/entities/currency.js +2 -0
  6. package/build/entities/fractions/currencyAmount.js +80 -0
  7. package/build/entities/fractions/fraction.js +117 -0
  8. package/build/entities/fractions/index.js +11 -0
  9. package/build/entities/fractions/percent.js +46 -0
  10. package/build/entities/fractions/price.js +73 -0
  11. package/build/entities/index.js +26 -0
  12. package/build/entities/pool.js +248 -0
  13. package/build/entities/position.js +364 -0
  14. package/build/entities/route.js +70 -0
  15. package/build/entities/tick.js +23 -0
  16. package/build/entities/tickDataProvider.js +30 -0
  17. package/build/entities/tickListDataProvider.js +35 -0
  18. package/build/entities/token.js +53 -0
  19. package/build/entities/trade.js +464 -0
  20. package/build/index.js +19 -0
  21. package/build/internalConstants.js +54 -0
  22. package/build/utils/computeAllRoutes.js +39 -0
  23. package/build/utils/encodeSqrtRatioX64.js +21 -0
  24. package/build/utils/fullMath.js +22 -0
  25. package/build/utils/index.js +30 -0
  26. package/build/utils/isSorted.js +18 -0
  27. package/build/utils/liquidityMath.js +23 -0
  28. package/build/utils/maxLiquidityForAmounts.js +86 -0
  29. package/build/utils/mostSignificantBit.js +27 -0
  30. package/build/utils/nearestUsableTick.js +26 -0
  31. package/build/utils/positionLibrary.js +22 -0
  32. package/build/utils/priceTickConversions.js +51 -0
  33. package/build/utils/sortedInsert.js +39 -0
  34. package/build/utils/sqrt.js +33 -0
  35. package/build/utils/sqrtPriceMath.js +92 -0
  36. package/build/utils/swapMath.js +86 -0
  37. package/build/utils/tickLibrary.js +61 -0
  38. package/build/utils/tickList.js +110 -0
  39. package/build/utils/tickMath.js +122 -0
  40. package/jest.config.js +40 -0
  41. package/nodemon.json +6 -0
  42. package/package.json +51 -0
  43. package/src/entities/baseCurrency.ts +53 -0
  44. package/src/entities/currency.ts +3 -0
  45. package/src/entities/fractions/currencyAmount.ts +129 -0
  46. package/src/entities/fractions/fraction.ts +190 -0
  47. package/src/entities/fractions/index.ts +4 -0
  48. package/src/entities/fractions/percent.ts +54 -0
  49. package/src/entities/fractions/price.ts +127 -0
  50. package/src/entities/index.ts +11 -0
  51. package/src/entities/pool.ts +399 -0
  52. package/src/entities/position.ts +591 -0
  53. package/src/entities/route.ts +84 -0
  54. package/src/entities/tick.ts +48 -0
  55. package/src/entities/tickDataProvider.ts +43 -0
  56. package/src/entities/tickListDataProvider.ts +37 -0
  57. package/src/entities/token.ts +56 -0
  58. package/src/entities/trade.ts +650 -0
  59. package/src/index.ts +3 -0
  60. package/src/internalConstants.ts +58 -0
  61. package/src/utils/computeAllRoutes.ts +64 -0
  62. package/src/utils/encodeSqrtRatioX64.ts +20 -0
  63. package/src/utils/fullMath.ts +17 -0
  64. package/src/utils/index.ts +14 -0
  65. package/src/utils/isSorted.ts +17 -0
  66. package/src/utils/liquidityMath.ts +17 -0
  67. package/src/utils/maxLiquidityForAmounts.ts +127 -0
  68. package/src/utils/mostSignificantBit.ts +25 -0
  69. package/src/utils/nearestUsableTick.ts +23 -0
  70. package/src/utils/positionLibrary.ts +37 -0
  71. package/src/utils/priceTickConversions.ts +57 -0
  72. package/src/utils/sortedInsert.ts +35 -0
  73. package/src/utils/sqrt.ts +31 -0
  74. package/src/utils/sqrtPriceMath.ts +169 -0
  75. package/src/utils/swapMath.ts +175 -0
  76. package/src/utils/tickLibrary.ts +88 -0
  77. package/src/utils/tickList.ts +147 -0
  78. package/src/utils/tickMath.ts +166 -0
  79. package/test/bestTradeExactOut.test.ts +266 -0
  80. package/test/currencyAmount.test.js +92 -0
  81. package/test/currencyAmount.test.ts +114 -0
  82. package/test/encodeSqrtRatioX64.test.ts +33 -0
  83. package/test/fixtures/pools.json +276 -0
  84. package/test/fixtures/ticks.json +608 -0
  85. package/test/fraction.test.js +87 -0
  86. package/test/fraction.test.ts +176 -0
  87. package/test/isSorted.test.ts +52 -0
  88. package/test/maxLiquidityForAmounts.test copy.ts +256 -0
  89. package/test/mostSignificantBit.test.ts +32 -0
  90. package/test/nearestUsableTick.test.ts +54 -0
  91. package/test/percent.test.js +52 -0
  92. package/test/percent.test.ts +68 -0
  93. package/test/pool.test.ts +377 -0
  94. package/test/position.test.ts +579 -0
  95. package/test/positionLibrary.test.ts +31 -0
  96. package/test/price.test.js +57 -0
  97. package/test/price.test.ts +62 -0
  98. package/test/priceTickConversions.test.ts +137 -0
  99. package/test/sqrtPriceMath.test.ts +113 -0
  100. package/test/tick.test.js +22 -0
  101. package/test/tick.test.ts +28 -0
  102. package/test/tickDataProvider.test.ts +17 -0
  103. package/test/tickLibrary.test.ts +111 -0
  104. package/test/tickList.test.ts +215 -0
  105. package/test/tickListDataProvider.test.ts +64 -0
  106. package/test/tickMath.test.ts +66 -0
  107. package/test/token.test.ts +58 -0
  108. package/test/trade.test.ts +210 -0
  109. package/test2.ts +73 -0
  110. package/tsconfig.json +24 -0
@@ -0,0 +1,276 @@
1
+ {
2
+ "rows": [{
3
+ "id": 0,
4
+ "active": 1,
5
+ "tokenA": {
6
+ "quantity": "1314.5472 TLM",
7
+ "contract": "alien.worlds"
8
+ },
9
+ "tokenB": {
10
+ "quantity": "382.26789500 WAX",
11
+ "contract": "eosio.token"
12
+ },
13
+ "fee": 3000,
14
+ "feeProtocol": 0,
15
+ "tickSpacing": 60,
16
+ "maxLiquidityPerTick": "1247497401346422",
17
+ "currSlot": {
18
+ "sqrtPriceX64": "991708566516390553386",
19
+ "tick": 79694,
20
+ "lastObservationTimestamp": 1679381679,
21
+ "currentObservationNum": 1,
22
+ "maxObservationNum": 1
23
+ },
24
+ "feeGrowthGlobalAX64": "61073176049015218",
25
+ "feeGrowthGlobalBX64": "12363045903005557614",
26
+ "protocolFeeA": "0.0000 TLM",
27
+ "protocolFeeB": "0.00000000 WAX",
28
+ "liquidity": "8156336317"
29
+ },{
30
+ "id": 1,
31
+ "active": 1,
32
+ "tokenA": {
33
+ "quantity": "2.567 AURI",
34
+ "contract": "1auriantoken"
35
+ },
36
+ "tokenB": {
37
+ "quantity": "12.6133 TLM",
38
+ "contract": "alien.worlds"
39
+ },
40
+ "fee": 3000,
41
+ "feeProtocol": 0,
42
+ "tickSpacing": 60,
43
+ "maxLiquidityPerTick": "1247497401346422",
44
+ "currSlot": {
45
+ "sqrtPriceX64": "58720362839899564841",
46
+ "tick": 23159,
47
+ "lastObservationTimestamp": 1679502630,
48
+ "currentObservationNum": 1,
49
+ "maxObservationNum": 1
50
+ },
51
+ "feeGrowthGlobalAX64": "166384683957627",
52
+ "feeGrowthGlobalBX64": "2752279980465775",
53
+ "protocolFeeA": "0.000 AURI",
54
+ "protocolFeeB": "0.0000 TLM",
55
+ "liquidity": 2660833
56
+ },{
57
+ "id": 2,
58
+ "active": 1,
59
+ "tokenA": {
60
+ "quantity": "594.9239 TLM",
61
+ "contract": "alien.worlds"
62
+ },
63
+ "tokenB": {
64
+ "quantity": "127.00796966 WAX",
65
+ "contract": "eosio.token"
66
+ },
67
+ "fee": 10000,
68
+ "feeProtocol": 0,
69
+ "tickSpacing": 200,
70
+ "maxLiquidityPerTick": "4157481197590613",
71
+ "currSlot": {
72
+ "sqrtPriceX64": "975564656570664666461",
73
+ "tick": 79366,
74
+ "lastObservationTimestamp": 1679681200,
75
+ "currentObservationNum": 1,
76
+ "maxObservationNum": 1
77
+ },
78
+ "feeGrowthGlobalAX64": "1821398004233484",
79
+ "feeGrowthGlobalBX64": "424632741919913791",
80
+ "protocolFeeA": "0.0000 TLM",
81
+ "protocolFeeB": "0.00000000 WAX",
82
+ "liquidity": "7226194136"
83
+ },{
84
+ "id": 3,
85
+ "active": 1,
86
+ "tokenA": {
87
+ "quantity": "0.0183 TLM",
88
+ "contract": "alien.worlds"
89
+ },
90
+ "tokenB": {
91
+ "quantity": "62.50448285 WAX",
92
+ "contract": "eosio.token"
93
+ },
94
+ "fee": 500,
95
+ "feeProtocol": 0,
96
+ "tickSpacing": 10,
97
+ "maxLiquidityPerTick": "207904516930692",
98
+ "currSlot": {
99
+ "sqrtPriceX64": "846996484997384679810",
100
+ "tick": 76540,
101
+ "lastObservationTimestamp": 1680112629,
102
+ "currentObservationNum": 1,
103
+ "maxObservationNum": 1
104
+ },
105
+ "feeGrowthGlobalAX64": "10076192982494",
106
+ "feeGrowthGlobalBX64": "81972777076841212",
107
+ "protocolFeeA": "0.0000 TLM",
108
+ "protocolFeeB": "0.00000000 WAX",
109
+ "liquidity": 0
110
+ },{
111
+ "id": 4,
112
+ "active": 1,
113
+ "tokenA": {
114
+ "quantity": "63.35380794 WAX",
115
+ "contract": "eosio.token"
116
+ },
117
+ "tokenB": {
118
+ "quantity": "159.02214649 CMX",
119
+ "contract": "token.mf"
120
+ },
121
+ "fee": 3000,
122
+ "feeProtocol": 0,
123
+ "tickSpacing": 60,
124
+ "maxLiquidityPerTick": "1247497401346422",
125
+ "currSlot": {
126
+ "sqrtPriceX64": "35384012338723553705",
127
+ "tick": 13028,
128
+ "lastObservationTimestamp": 1680272401,
129
+ "currentObservationNum": 1,
130
+ "maxObservationNum": 1
131
+ },
132
+ "feeGrowthGlobalAX64": "195959741376088",
133
+ "feeGrowthGlobalBX64": 0,
134
+ "protocolFeeA": "0.00000000 WAX",
135
+ "protocolFeeB": "0.00000000 CMX",
136
+ "liquidity": "143680614039"
137
+ },{
138
+ "id": 5,
139
+ "active": 1,
140
+ "tokenA": {
141
+ "quantity": "38.85194390 WAX",
142
+ "contract": "eosio.token"
143
+ },
144
+ "tokenB": {
145
+ "quantity": "53.16698469 CMX",
146
+ "contract": "token.mf"
147
+ },
148
+ "fee": 500,
149
+ "feeProtocol": 0,
150
+ "tickSpacing": 10,
151
+ "maxLiquidityPerTick": "207904516930692",
152
+ "currSlot": {
153
+ "sqrtPriceX64": "35318676081364719585",
154
+ "tick": 12991,
155
+ "lastObservationTimestamp": 1680272464,
156
+ "currentObservationNum": 1,
157
+ "maxObservationNum": 1
158
+ },
159
+ "feeGrowthGlobalAX64": "44497641052789",
160
+ "feeGrowthGlobalBX64": "11120158110407",
161
+ "protocolFeeA": "0.00000000 WAX",
162
+ "protocolFeeB": "0.00000000 CMX",
163
+ "liquidity": "308013115651"
164
+ },{
165
+ "id": 6,
166
+ "active": 1,
167
+ "tokenA": {
168
+ "quantity": "52.60568011 WAX",
169
+ "contract": "eosio.token"
170
+ },
171
+ "tokenB": {
172
+ "quantity": "212.16243115 CMX",
173
+ "contract": "token.mf"
174
+ },
175
+ "fee": 10000,
176
+ "feeProtocol": 0,
177
+ "tickSpacing": 200,
178
+ "maxLiquidityPerTick": "4157481197590613",
179
+ "currSlot": {
180
+ "sqrtPriceX64": "35625261329880876787",
181
+ "tick": 13164,
182
+ "lastObservationTimestamp": 1680272562,
183
+ "currentObservationNum": 1,
184
+ "maxObservationNum": 1
185
+ },
186
+ "feeGrowthGlobalAX64": 0,
187
+ "feeGrowthGlobalBX64": 0,
188
+ "protocolFeeA": "0.00000000 WAX",
189
+ "protocolFeeB": "0.00000000 CMX",
190
+ "liquidity": "72648854818"
191
+ },{
192
+ "id": 7,
193
+ "active": 1,
194
+ "tokenA": {
195
+ "quantity": "219.0515 TLM",
196
+ "contract": "alien.worlds"
197
+ },
198
+ "tokenB": {
199
+ "quantity": "219.87743407 CMX",
200
+ "contract": "token.mf"
201
+ },
202
+ "fee": 3000,
203
+ "feeProtocol": 0,
204
+ "tickSpacing": 60,
205
+ "maxLiquidityPerTick": "1247497401346422",
206
+ "currSlot": {
207
+ "sqrtPriceX64": "1862078609064050296734",
208
+ "tick": 92295,
209
+ "lastObservationTimestamp": 1680285053,
210
+ "currentObservationNum": 1,
211
+ "maxObservationNum": 1
212
+ },
213
+ "feeGrowthGlobalAX64": "8856712368873",
214
+ "feeGrowthGlobalBX64": 0,
215
+ "protocolFeeA": "0.0000 TLM",
216
+ "protocolFeeB": "0.00000000 CMX",
217
+ "liquidity": 775736962
218
+ },{
219
+ "id": 8,
220
+ "active": 1,
221
+ "tokenA": {
222
+ "quantity": "34.9838 TLM",
223
+ "contract": "alien.worlds"
224
+ },
225
+ "tokenB": {
226
+ "quantity": "66.73971733 CMX",
227
+ "contract": "token.mf"
228
+ },
229
+ "fee": 500,
230
+ "feeProtocol": 0,
231
+ "tickSpacing": 10,
232
+ "maxLiquidityPerTick": "207904516930692",
233
+ "currSlot": {
234
+ "sqrtPriceX64": "1858234166300152891562",
235
+ "tick": 92254,
236
+ "lastObservationTimestamp": 1680357774,
237
+ "currentObservationNum": 1,
238
+ "maxObservationNum": 1
239
+ },
240
+ "feeGrowthGlobalAX64": 0,
241
+ "feeGrowthGlobalBX64": "6783693046124036",
242
+ "protocolFeeA": "0.0000 TLM",
243
+ "protocolFeeB": "0.00000000 CMX",
244
+ "liquidity": 2057723535
245
+ },{
246
+ "id": 9,
247
+ "active": 1,
248
+ "tokenA": {
249
+ "quantity": "275.8218 TLM",
250
+ "contract": "alien.worlds"
251
+ },
252
+ "tokenB": {
253
+ "quantity": "235.38591033 CMX",
254
+ "contract": "token.mf"
255
+ },
256
+ "fee": 10000,
257
+ "feeProtocol": 0,
258
+ "tickSpacing": 200,
259
+ "maxLiquidityPerTick": "4157481197590613",
260
+ "currSlot": {
261
+ "sqrtPriceX64": "1844673594537660054688",
262
+ "tick": 92108,
263
+ "lastObservationTimestamp": 1680357849,
264
+ "currentObservationNum": 1,
265
+ "maxObservationNum": 1
266
+ },
267
+ "feeGrowthGlobalAX64": 0,
268
+ "feeGrowthGlobalBX64": 0,
269
+ "protocolFeeA": "0.0000 TLM",
270
+ "protocolFeeB": "0.00000000 CMX",
271
+ "liquidity": 922913698
272
+ }
273
+ ],
274
+ "more": false,
275
+ "next_key": ""
276
+ }