polkamarkets-js 1.0.2 → 3.1.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 (163) hide show
  1. package/.openzeppelin/unknown-1337.json +2056 -0
  2. package/CONTRIBUTING.md +36 -0
  3. package/README.md +24 -25
  4. package/_book/README.md +590 -0
  5. package/_book/core.md +50 -0
  6. package/_book/gitbook/fonts/fontawesome/FontAwesome.otf +0 -0
  7. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot +0 -0
  8. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.svg +685 -0
  9. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
  10. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff +0 -0
  11. package/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2 +0 -0
  12. package/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js +240 -0
  13. package/_book/gitbook/gitbook-plugin-fontsettings/website.css +291 -0
  14. package/_book/gitbook/gitbook-plugin-highlight/ebook.css +135 -0
  15. package/_book/gitbook/gitbook-plugin-highlight/website.css +434 -0
  16. package/_book/gitbook/gitbook-plugin-lunr/lunr.min.js +7 -0
  17. package/_book/gitbook/gitbook-plugin-lunr/search-lunr.js +59 -0
  18. package/_book/gitbook/gitbook-plugin-search/lunr.min.js +7 -0
  19. package/_book/gitbook/gitbook-plugin-search/search-engine.js +50 -0
  20. package/_book/gitbook/gitbook-plugin-search/search.css +35 -0
  21. package/_book/gitbook/gitbook-plugin-search/search.js +213 -0
  22. package/_book/gitbook/gitbook-plugin-sharing/buttons.js +90 -0
  23. package/_book/gitbook/gitbook.js +4 -0
  24. package/_book/gitbook/images/apple-touch-icon-precomposed-152.png +0 -0
  25. package/_book/gitbook/images/favicon.ico +0 -0
  26. package/_book/gitbook/style.css +9 -0
  27. package/_book/gitbook/theme.js +4 -0
  28. package/_book/index.html +705 -0
  29. package/_book/intro.md +32 -0
  30. package/_book/search_index.json +1 -0
  31. package/book.json +8 -0
  32. package/build/contracts/AccessControl.json +1 -0
  33. package/build/contracts/AccessControlEnumerable.json +1 -0
  34. package/build/contracts/Achievements.json +1 -0
  35. package/build/contracts/Address.json +1 -0
  36. package/build/contracts/BalanceHolder.json +1 -0
  37. package/build/contracts/BalanceHolder_ERC20.json +1 -0
  38. package/build/contracts/CeilDiv.json +1 -0
  39. package/build/contracts/Clones.json +1 -0
  40. package/build/contracts/Context.json +1 -0
  41. package/build/contracts/Counters.json +1 -0
  42. package/build/contracts/ERC165.json +1 -0
  43. package/build/contracts/ERC20.json +1 -0
  44. package/build/contracts/ERC20Burnable.json +1 -0
  45. package/build/contracts/ERC20Pausable.json +1 -0
  46. package/build/contracts/ERC20PresetMinterPauser.json +1 -0
  47. package/build/contracts/ERC721.json +1 -0
  48. package/build/contracts/EnumerableMap.json +1 -0
  49. package/build/contracts/EnumerableSet.json +1 -0
  50. package/build/contracts/FantasyERC20.json +1 -0
  51. package/build/contracts/IAccessControl.json +1 -0
  52. package/build/contracts/IAccessControlEnumerable.json +1 -0
  53. package/build/contracts/IBalanceHolder_ERC20.json +1 -0
  54. package/build/contracts/IERC165.json +1 -0
  55. package/build/contracts/IERC20.json +1 -0
  56. package/build/contracts/IERC20Metadata.json +1 -0
  57. package/build/contracts/IERC20Permit.json +1 -0
  58. package/build/contracts/IERC721.json +1 -0
  59. package/build/contracts/IERC721Enumerable.json +1 -0
  60. package/build/contracts/IERC721Metadata.json +1 -0
  61. package/build/contracts/IERC721Receiver.json +1 -0
  62. package/build/contracts/IFantasyERC20.json +1 -0
  63. package/build/contracts/IPredictionMarketV3.json +1 -0
  64. package/build/contracts/IPredictionMarketV3Factory.json +1 -0
  65. package/build/contracts/IPredictionMarketV3Manager.json +1 -0
  66. package/build/contracts/IRealityETH_ERC20.json +1 -0
  67. package/build/contracts/IRealityETH_IERC20.json +1 -0
  68. package/build/contracts/IWETH.json +1 -0
  69. package/build/contracts/LandFactory.json +1 -0
  70. package/build/contracts/Math.json +1 -0
  71. package/build/contracts/Migrations.json +1 -0
  72. package/build/contracts/Ownable.json +1 -0
  73. package/build/contracts/Pausable.json +1 -0
  74. package/build/contracts/PredictionMarket.json +1 -0
  75. package/build/contracts/PredictionMarketV2.json +1 -0
  76. package/build/contracts/PredictionMarketV3.json +1 -0
  77. package/build/contracts/PredictionMarketV3Controller.json +1 -0
  78. package/build/contracts/PredictionMarketV3Factory.json +1 -0
  79. package/build/contracts/PredictionMarketV3Manager.json +1 -0
  80. package/build/contracts/PredictionMarketV3Querier.json +1 -0
  81. package/build/contracts/RealitioERC20.json +1 -0
  82. package/build/contracts/RealitioForeignArbitrationProxyWithAppeals.json +1 -0
  83. package/build/contracts/RealitioHomeArbitrationProxy.json +1 -0
  84. package/build/contracts/RealitioSafeMath256.json +1 -0
  85. package/build/contracts/RealitioSafeMath32.json +1 -0
  86. package/build/contracts/RealityETH_ERC20_Factory.json +1 -0
  87. package/build/contracts/RealityETH_ERC20_v3_0.json +1 -0
  88. package/build/contracts/ReentrancyGuard.json +1 -0
  89. package/build/contracts/SafeERC20.json +1 -0
  90. package/build/contracts/SafeMath.json +1 -0
  91. package/build/contracts/Strings.json +1 -0
  92. package/build/contracts/Voting.json +1 -0
  93. package/build/contracts/WETH9.json +1 -0
  94. package/build/contracts/test.json +1 -0
  95. package/cleanContracts.js +22 -0
  96. package/contracts/FantasyERC20.sol +81 -0
  97. package/contracts/IFantasyERC20.sol +20 -0
  98. package/contracts/IPredictionMarketV3.sol +207 -0
  99. package/contracts/IPredictionMarketV3Factory.sol +10 -0
  100. package/contracts/IPredictionMarketV3Manager.sol +12 -0
  101. package/contracts/IRealityETH_ERC20.sol +64 -0
  102. package/contracts/LandFactory.sol +248 -0
  103. package/contracts/Migrations.sol +24 -0
  104. package/contracts/PredictionMarketV3.sol +1332 -0
  105. package/contracts/PredictionMarketV3Controller.sol +87 -0
  106. package/contracts/PredictionMarketV3Factory.sol +205 -0
  107. package/contracts/PredictionMarketV3Manager.sol +45 -0
  108. package/contracts/PredictionMarketV3Querier.sol +79 -0
  109. package/contracts/RealityETH_ERC20_Factory.sol +54 -0
  110. package/contracts/Voting.sol +153 -0
  111. package/contracts/WETH9.sol +62 -0
  112. package/help.txt +8 -0
  113. package/index.js +3 -0
  114. package/migrations/10_deploy_weth.js +5 -0
  115. package/migrations/11_deploy_full_flow.js +99 -0
  116. package/migrations/12_deploy_pm_v3_querier.js +7 -0
  117. package/migrations/13_deploy_pm_v3_factory.js +14 -0
  118. package/migrations/1_initial_migration.js +5 -0
  119. package/migrations/2_deploy_erc20.js +10 -0
  120. package/migrations/3_deploy_realitio.js +11 -0
  121. package/migrations/4_deploy_pm.js +20 -0
  122. package/migrations/5_seed_markets.js +51 -0
  123. package/migrations/6_deploy_achievements.js +5 -0
  124. package/migrations/7_deploy_voting.js +14 -0
  125. package/migrations/8_deploy_pm_v2.js +20 -0
  126. package/migrations/9_seed_markets_v2.js +68 -0
  127. package/package.json +106 -13
  128. package/src/Application.js +421 -0
  129. package/src/interfaces/index.js +19 -0
  130. package/src/models/AchievementsContract.js +217 -0
  131. package/src/models/ArbitrationContract.js +69 -0
  132. package/src/models/ArbitrationProxyContract.js +32 -0
  133. package/src/models/ERC20Contract.js +156 -0
  134. package/src/models/FantasyERC20Contract.js +92 -0
  135. package/src/models/IContract.js +1002 -0
  136. package/src/models/PolkamarketsSmartAccount.js +100 -0
  137. package/src/models/PredictionMarketContract.js +562 -0
  138. package/src/models/PredictionMarketV2Contract.js +830 -0
  139. package/src/models/PredictionMarketV3Contract.js +233 -0
  140. package/src/models/PredictionMarketV3ControllerContract.js +102 -0
  141. package/src/models/PredictionMarketV3FactoryContract.js +96 -0
  142. package/src/models/PredictionMarketV3ManagerContract.js +111 -0
  143. package/src/models/PredictionMarketV3QuerierContract.js +24 -0
  144. package/src/models/RealitioERC20Contract.js +286 -0
  145. package/src/models/VotingContract.js +182 -0
  146. package/src/models/WETH9Contract.js +92 -0
  147. package/src/models/index.js +33 -0
  148. package/src/utils/Account.js +40 -0
  149. package/src/utils/Contract.js +120 -0
  150. package/src/utils/Numbers.js +94 -0
  151. package/tests/fantasyERC20Contract.js +225 -0
  152. package/tests/index.js +10 -0
  153. package/tests/predictionMarketContract.js +466 -0
  154. package/tests/predictionMarketV2Contract.js +1042 -0
  155. package/tests/predictionMarketV3Contract.js +1079 -0
  156. package/tests/predictionMarketV3ControllerContract.js +613 -0
  157. package/tests/predictionMarketV3FactoryContract.js +469 -0
  158. package/tests/predictionMarketV3ManagerContract.js +610 -0
  159. package/tests/utils.js +16 -0
  160. package/tests/votingContract.js +490 -0
  161. package/tooling/docs/jsdoc.json +6 -0
  162. package/truffle-config.js +134 -0
  163. package/polkamarkets.js +0 -436
@@ -0,0 +1,590 @@
1
+ ## Classes
2
+
3
+ <dl>
4
+ <dt><a href="#FixedSwapContract">FixedSwapContract</a></dt>
5
+ <dd></dd>
6
+ </dl>
7
+
8
+ ## Functions
9
+
10
+ <dl>
11
+ <dt><a href="#setNewOwner">setNewOwner(address)</a></dt>
12
+ <dd><p>Set New Owner of the Contract</p>
13
+ </dd>
14
+ <dt><a href="#owner">owner()</a> ⇒ <code>string</code></dt>
15
+ <dd><p>Get Owner of the Contract</p>
16
+ </dd>
17
+ <dt><a href="#isPaused">isPaused()</a> ⇒ <code>boolean</code></dt>
18
+ <dd><p>Get Owner of the Contract</p>
19
+ </dd>
20
+ <dt><a href="#pauseContract">pauseContract()</a> ⇒ <code>admin</code></dt>
21
+ <dd><p>Pause Contract</p>
22
+ </dd>
23
+ <dt><a href="#erc20">erc20()</a> ⇒ <code>Address</code></dt>
24
+ <dd><p>Get Token Address</p>
25
+ </dd>
26
+ <dt><a href="#decimals">decimals()</a> ⇒ <code>Integer</code></dt>
27
+ <dd><p>Get Decimals</p>
28
+ </dd>
29
+ <dt><a href="#unpauseContract">unpauseContract()</a> ⇒ <code>admin</code></dt>
30
+ <dd><p>Unpause Contract</p>
31
+ </dd>
32
+ <dt><a href="#tradeValue">tradeValue()</a> ⇒ <code>Integer</code></dt>
33
+ <dd><p>Get swapratio for the pool</p>
34
+ </dd>
35
+ <dt><a href="#startDate">startDate()</a> ⇒ <code>Date</code></dt>
36
+ <dd><p>Get Start Date of Pool</p>
37
+ </dd>
38
+ <dt><a href="#endDate">endDate()</a> ⇒ <code>Date</code></dt>
39
+ <dd><p>Get End Date of Pool</p>
40
+ </dd>
41
+ <dt><a href="#isFinalized">isFinalized()</a> ⇒ <code>Boolean</code></dt>
42
+ <dd><p>To see if contract was finalized</p>
43
+ </dd>
44
+ <dt><a href="#individualMinimumAmount">individualMinimumAmount()</a> ⇒ <code>Integer</code></dt>
45
+ <dd><p>Get Individual Minimum Amount for each address</p>
46
+ </dd>
47
+ <dt><a href="#individualMaximumAmount">individualMaximumAmount()</a> ⇒ <code>Integer</code></dt>
48
+ <dd><p>Get Individual Maximum Amount for each address</p>
49
+ </dd>
50
+ <dt><a href="#minimumRaiseAchieved">minimumRaiseAchieved()</a> ⇒ <code>Boolean</code></dt>
51
+ <dd><p>Was Minimum Raise Achieved</p>
52
+ </dd>
53
+ <dt><a href="#minimumRaise">minimumRaise()</a> ⇒ <code>Integer</code></dt>
54
+ <dd><p>Get Minimum Raise amount for Token Sale</p>
55
+ </dd>
56
+ <dt><a href="#tokensAllocated">tokensAllocated()</a> ⇒ <code>Integer</code></dt>
57
+ <dd><p>Get Total tokens Allocated already, therefore the tokens bought until now</p>
58
+ </dd>
59
+ <dt><a href="#tokensForSale">tokensForSale()</a> ⇒ <code>Integer</code></dt>
60
+ <dd><p>Get Total tokens Allocated/In Sale for the Pool</p>
61
+ </dd>
62
+ <dt><a href="#hasMinimumRaise">hasMinimumRaise()</a> ⇒ <code>Boolea</code></dt>
63
+ <dd><p>See if hasMinimumRaise</p>
64
+ </dd>
65
+ <dt><a href="#minimumReached">minimumReached()</a> ⇒ <code>Integer</code></dt>
66
+ <dd><p>See if minimumRaise was Reached</p>
67
+ </dd>
68
+ <dt><a href="#tokensAvailable">tokensAvailable()</a> ⇒ <code>Integer</code></dt>
69
+ <dd><p>Get Total tokens owned by the Pool</p>
70
+ </dd>
71
+ <dt><a href="#tokensLeft">tokensLeft()</a> ⇒ <code>Integer</code></dt>
72
+ <dd><p>Get Total tokens available to be sold in the pool</p>
73
+ </dd>
74
+ <dt><a href="#withdrawableUnsoldTokens">withdrawableUnsoldTokens()</a> ⇒ <code>Integer</code></dt>
75
+ <dd><p>Get Total tokens available to be withdrawn by the admin</p>
76
+ </dd>
77
+ <dt><a href="#withdrawableFunds">withdrawableFunds()</a> ⇒ <code>Integer</code></dt>
78
+ <dd><p>Get Total funds raised to be withdrawn by the admin</p>
79
+ </dd>
80
+ <dt><a href="#isTokenSwapAtomic">isTokenSwapAtomic()</a> ⇒ <code>Boolean</code></dt>
81
+ <dd><p>Verify if the Token Swap is atomic on this pool</p>
82
+ </dd>
83
+ <dt><a href="#hasWhitelisting">hasWhitelisting()</a> ⇒ <code>Boolean</code></dt>
84
+ <dd><p>Verify if swap has whitelisting</p>
85
+ </dd>
86
+ <dt><a href="#isWhitelisted">isWhitelisted()</a> ⇒ <code>Boolean</code></dt>
87
+ <dd><p>Verify if address is whitelisted</p>
88
+ </dd>
89
+ <dt><a href="#wereUnsoldTokensReedemed">wereUnsoldTokensReedemed()</a> ⇒ <code>Boolean</code></dt>
90
+ <dd><p>Verify if the admin already reemeded unsold tokens</p>
91
+ </dd>
92
+ <dt><a href="#isFunded">isFunded()</a> ⇒ <code>Boolean</code></dt>
93
+ <dd><p>Verify if the Token Sale is Funded with all Tokens proposed in tokensForSale</p>
94
+ </dd>
95
+ <dt><a href="#isOpen">isOpen()</a> ⇒ <code>Boolean</code></dt>
96
+ <dd><p>Verify if the Token Sale is Open for Swap</p>
97
+ </dd>
98
+ <dt><a href="#hasStarted">hasStarted()</a> ⇒ <code>Boolean</code></dt>
99
+ <dd><p>Verify if the Token Sale has started the Swap</p>
100
+ </dd>
101
+ <dt><a href="#hasFinalized">hasFinalized()</a> ⇒ <code>Boolean</code></dt>
102
+ <dd><p>Verify if the Token Sale has finalized, if the current date is after endDate</p>
103
+ </dd>
104
+ <dt><a href="#isPreStart">isPreStart()</a> ⇒ <code>Boolean</code></dt>
105
+ <dd><p>Verify if the Token Sale in not open yet, where the admin can fund the pool</p>
106
+ </dd>
107
+ <dt><a href="#getPurchase">getPurchase(purchase_id)</a> ⇒ <code>Integer</code> | <code>Integer</code> | <code>Address</code> | <code>Integer</code> | <code>Date</code> | <code>Boolean</code> | <code>Boolean</code></dt>
108
+ <dd><p>Get Purchase based on ID</p>
109
+ </dd>
110
+ <dt><a href="#getWhiteListedAddresses">getWhiteListedAddresses()</a> ⇒ <code>Array</code> | <code>Address</code></dt>
111
+ <dd><p>Get Whitelisted Addresses</p>
112
+ </dd>
113
+ <dt><a href="#getBuyers">getBuyers()</a> ⇒ <code>Array</code> | <code>Integer</code></dt>
114
+ <dd><p>Get Buyers</p>
115
+ </dd>
116
+ <dt><a href="#getPurchaseIds">getPurchaseIds()</a> ⇒ <code>Array</code> | <code>Integer</code></dt>
117
+ <dd><p>Get All Purchase Ids</p>
118
+ </dd>
119
+ <dt><a href="#getPurchaseIds">getPurchaseIds(address)</a> ⇒ <code>Array</code> | <code>Integer</code></dt>
120
+ <dd><p>Get All Purchase Ids filter by Address/Purchaser</p>
121
+ </dd>
122
+ <dt><a href="#getETHCostFromTokens">getETHCostFromTokens(tokenAmount)</a> ⇒ <code>Integer</code></dt>
123
+ <dd><p>Get ETH Cost from Tokens Amount</p>
124
+ </dd>
125
+ <dt><a href="#swap">swap(tokenAmount)</a></dt>
126
+ <dd><p>Swap tokens by Ethereum</p>
127
+ </dd>
128
+ <dt><a href="#redeemTokens(isStandard)">redeemTokens(purchase_id)</a></dt>
129
+ <dd><p>Reedem tokens bought</p>
130
+ </dd>
131
+ <dt><a href="#redeemGivenMinimumGoalNotAchieved(isStandard)">redeemGivenMinimumGoalNotAchieved(purchase_id)</a></dt>
132
+ <dd><p>Reedem Ethereum from sale that did not achieve minimum goal</p>
133
+ </dd>
134
+ <dt><a href="#withdrawUnsoldTokens">withdrawUnsoldTokens()</a></dt>
135
+ <dd><p>Withdraw unsold tokens of sale</p>
136
+ </dd>
137
+ <dt><a href="#withdrawFunds">withdrawFunds()</a></dt>
138
+ <dd><p>Withdraw all funds from tokens sold</p>
139
+ </dd>
140
+ <dt><a href="#approveFundERC20">approveFundERC20()</a></dt>
141
+ <dd><p>Approve the pool to use approved tokens for sale</p>
142
+ </dd>
143
+ <dt><a href="#isApproved">isApproved(tokenAmount, address)</a> ⇒ <code>Boolean</code></dt>
144
+ <dd><p>Verify if the Admin has approved the pool to use receive the tokens for sale</p>
145
+ </dd>
146
+ <dt><a href="#fund">fund(tokenAmount)</a></dt>
147
+ <dd><p>Send tokens to pool for sale, fund the sale</p>
148
+ </dd>
149
+ <dt><a href="#addWhitelistedAddress">addWhitelistedAddress(Addresses)</a></dt>
150
+ <dd><p>add WhiteListed Address</p>
151
+ </dd>
152
+ <dt><a href="#removeWhitelistedAddress">removeWhitelistedAddress()</a></dt>
153
+ <dd><p>remove WhiteListed Address</p>
154
+ </dd>
155
+ <dt><a href="#safePull">safePull()</a></dt>
156
+ <dd><p>Safe Pull all tokens &amp; ETH</p>
157
+ </dd>
158
+ <dt><a href="#removeOtherERC20Tokens">removeOtherERC20Tokens(tokenAddress, toAddress)</a></dt>
159
+ <dd><p>Remove Tokens from other ERC20 Address (in case of accident)</p>
160
+ </dd>
161
+ <dt><a href="#deploy">deploy()</a></dt>
162
+ <dd><p>Deploy the Pool Contract</p>
163
+ </dd>
164
+ <dt><a href="#getOwner">getOwner(Address)</a></dt>
165
+ <dd><p>Get owner address of contract</p>
166
+ </dd>
167
+ <dt><a href="#getBalance">getBalance(Balance)</a></dt>
168
+ <dd><p>Get Balance of Contract</p>
169
+ </dd>
170
+ </dl>
171
+
172
+ <a name="FixedSwapContract"></a>
173
+
174
+ ## FixedSwapContract
175
+ **Kind**: global class
176
+ <a name="new_FixedSwapContract_new"></a>
177
+
178
+ ### new FixedSwapContract(web3, tokenAddress, decimals, contractAddress)
179
+ Fixed Swap Object
180
+
181
+
182
+ | Param | Type | Description |
183
+ | --- | --- | --- |
184
+ | web3 | <code>Web3</code> | |
185
+ | tokenAddress | <code>Address</code> | |
186
+ | decimals | <code>Integer</code> | |
187
+ | contractAddress | <code>Address</code> | ? (opt) |
188
+
189
+ <a name="setNewOwner"></a>
190
+
191
+ ## setNewOwner(address)
192
+ Set New Owner of the Contract
193
+
194
+ **Kind**: global function
195
+
196
+ | Param | Type |
197
+ | --- | --- |
198
+ | address | <code>string</code> |
199
+
200
+ <a name="owner"></a>
201
+
202
+ ## owner() ⇒ <code>string</code>
203
+ Get Owner of the Contract
204
+
205
+ **Kind**: global function
206
+ **Returns**: <code>string</code> - address
207
+ <a name="isPaused"></a>
208
+
209
+ ## isPaused() ⇒ <code>boolean</code>
210
+ Get Owner of the Contract
211
+
212
+ **Kind**: global function
213
+ <a name="pauseContract"></a>
214
+
215
+ ## pauseContract() ⇒ <code>admin</code>
216
+ Pause Contract
217
+
218
+ **Kind**: global function
219
+ <a name="erc20"></a>
220
+
221
+ ## erc20() ⇒ <code>Address</code>
222
+ Get Token Address
223
+
224
+ **Kind**: global function
225
+ **Returns**: <code>Address</code> - Token Address
226
+ <a name="decimals"></a>
227
+
228
+ ## decimals() ⇒ <code>Integer</code>
229
+ Get Decimals
230
+
231
+ **Kind**: global function
232
+ **Returns**: <code>Integer</code> - Integer
233
+ <a name="unpauseContract"></a>
234
+
235
+ ## unpauseContract() ⇒ <code>admin</code>
236
+ Unpause Contract
237
+
238
+ **Kind**: global function
239
+ <a name="tradeValue"></a>
240
+
241
+ ## tradeValue() ⇒ <code>Integer</code>
242
+ Get swapratio for the pool
243
+
244
+ **Kind**: global function
245
+ **Returns**: <code>Integer</code> - trade value against ETH
246
+ <a name="startDate"></a>
247
+
248
+ ## startDate() ⇒ <code>Date</code>
249
+ Get Start Date of Pool
250
+
251
+ **Kind**: global function
252
+ <a name="endDate"></a>
253
+
254
+ ## endDate() ⇒ <code>Date</code>
255
+ Get End Date of Pool
256
+
257
+ **Kind**: global function
258
+ <a name="isFinalized"></a>
259
+
260
+ ## isFinalized() ⇒ <code>Boolean</code>
261
+ To see if contract was finalized
262
+
263
+ **Kind**: global function
264
+ <a name="individualMinimumAmount"></a>
265
+
266
+ ## individualMinimumAmount() ⇒ <code>Integer</code>
267
+ Get Individual Minimum Amount for each address
268
+
269
+ **Kind**: global function
270
+ <a name="individualMaximumAmount"></a>
271
+
272
+ ## individualMaximumAmount() ⇒ <code>Integer</code>
273
+ Get Individual Maximum Amount for each address
274
+
275
+ **Kind**: global function
276
+ <a name="minimumRaiseAchieved"></a>
277
+
278
+ ## minimumRaiseAchieved() ⇒ <code>Boolean</code>
279
+ Was Minimum Raise Achieved
280
+
281
+ **Kind**: global function
282
+ <a name="minimumRaise"></a>
283
+
284
+ ## minimumRaise() ⇒ <code>Integer</code>
285
+ Get Minimum Raise amount for Token Sale
286
+
287
+ **Kind**: global function
288
+ **Returns**: <code>Integer</code> - Amount in Tokens
289
+ <a name="tokensAllocated"></a>
290
+
291
+ ## tokensAllocated() ⇒ <code>Integer</code>
292
+ Get Total tokens Allocated already, therefore the tokens bought until now
293
+
294
+ **Kind**: global function
295
+ **Returns**: <code>Integer</code> - Amount in Tokens
296
+ <a name="tokensForSale"></a>
297
+
298
+ ## tokensForSale() ⇒ <code>Integer</code>
299
+ Get Total tokens Allocated/In Sale for the Pool
300
+
301
+ **Kind**: global function
302
+ **Returns**: <code>Integer</code> - Amount in Tokens
303
+ <a name="hasMinimumRaise"></a>
304
+
305
+ ## hasMinimumRaise() ⇒ <code>Boolea</code>
306
+ See if hasMinimumRaise
307
+
308
+ **Kind**: global function
309
+ <a name="minimumReached"></a>
310
+
311
+ ## minimumReached() ⇒ <code>Integer</code>
312
+ See if minimumRaise was Reached
313
+
314
+ **Kind**: global function
315
+ <a name="tokensAvailable"></a>
316
+
317
+ ## tokensAvailable() ⇒ <code>Integer</code>
318
+ Get Total tokens owned by the Pool
319
+
320
+ **Kind**: global function
321
+ **Returns**: <code>Integer</code> - Amount in Tokens
322
+ <a name="tokensLeft"></a>
323
+
324
+ ## tokensLeft() ⇒ <code>Integer</code>
325
+ Get Total tokens available to be sold in the pool
326
+
327
+ **Kind**: global function
328
+ **Returns**: <code>Integer</code> - Amount in Tokens
329
+ <a name="withdrawableUnsoldTokens"></a>
330
+
331
+ ## withdrawableUnsoldTokens() ⇒ <code>Integer</code>
332
+ Get Total tokens available to be withdrawn by the admin
333
+
334
+ **Kind**: global function
335
+ **Returns**: <code>Integer</code> - Amount in Tokens
336
+ <a name="withdrawableFunds"></a>
337
+
338
+ ## withdrawableFunds() ⇒ <code>Integer</code>
339
+ Get Total funds raised to be withdrawn by the admin
340
+
341
+ **Kind**: global function
342
+ **Returns**: <code>Integer</code> - Amount in ETH
343
+ <a name="isTokenSwapAtomic"></a>
344
+
345
+ ## isTokenSwapAtomic() ⇒ <code>Boolean</code>
346
+ Verify if the Token Swap is atomic on this pool
347
+
348
+ **Kind**: global function
349
+ <a name="hasWhitelisting"></a>
350
+
351
+ ## hasWhitelisting() ⇒ <code>Boolean</code>
352
+ Verify if swap has whitelisting
353
+
354
+ **Kind**: global function
355
+ <a name="isWhitelisted"></a>
356
+
357
+ ## isWhitelisted() ⇒ <code>Boolean</code>
358
+ Verify if address is whitelisted
359
+
360
+ **Kind**: global function
361
+ <a name="wereUnsoldTokensReedemed"></a>
362
+
363
+ ## wereUnsoldTokensReedemed() ⇒ <code>Boolean</code>
364
+ Verify if the admin already reemeded unsold tokens
365
+
366
+ **Kind**: global function
367
+ <a name="isFunded"></a>
368
+
369
+ ## isFunded() ⇒ <code>Boolean</code>
370
+ Verify if the Token Sale is Funded with all Tokens proposed in tokensForSale
371
+
372
+ **Kind**: global function
373
+ <a name="isOpen"></a>
374
+
375
+ ## isOpen() ⇒ <code>Boolean</code>
376
+ Verify if the Token Sale is Open for Swap
377
+
378
+ **Kind**: global function
379
+ <a name="hasStarted"></a>
380
+
381
+ ## hasStarted() ⇒ <code>Boolean</code>
382
+ Verify if the Token Sale has started the Swap
383
+
384
+ **Kind**: global function
385
+ <a name="hasFinalized"></a>
386
+
387
+ ## hasFinalized() ⇒ <code>Boolean</code>
388
+ Verify if the Token Sale has finalized, if the current date is after endDate
389
+
390
+ **Kind**: global function
391
+ <a name="isPreStart"></a>
392
+
393
+ ## isPreStart() ⇒ <code>Boolean</code>
394
+ Verify if the Token Sale in not open yet, where the admin can fund the pool
395
+
396
+ **Kind**: global function
397
+ <a name="getPurchase"></a>
398
+
399
+ ## getPurchase(purchase_id) ⇒ <code>Integer</code> \| <code>Integer</code> \| <code>Address</code> \| <code>Integer</code> \| <code>Date</code> \| <code>Boolean</code> \| <code>Boolean</code>
400
+ Get Purchase based on ID
401
+
402
+ **Kind**: global function
403
+ **Returns**: <code>Integer</code> - _id<code>Integer</code> - amount<code>Address</code> - purchaser<code>Integer</code> - ethAmount<code>Date</code> - timestamp<code>Boolean</code> - wasFinalized<code>Boolean</code> - reverted
404
+
405
+ | Param | Type |
406
+ | --- | --- |
407
+ | purchase_id | <code>Integer</code> |
408
+
409
+ <a name="getWhiteListedAddresses"></a>
410
+
411
+ ## getWhiteListedAddresses() ⇒ <code>Array</code> \| <code>Address</code>
412
+ Get Whitelisted Addresses
413
+
414
+ **Kind**: global function
415
+ **Returns**: <code>Array</code> \| <code>Address</code> - addresses
416
+ <a name="getBuyers"></a>
417
+
418
+ ## getBuyers() ⇒ <code>Array</code> \| <code>Integer</code>
419
+ Get Buyers
420
+
421
+ **Kind**: global function
422
+ **Returns**: <code>Array</code> \| <code>Integer</code> - _ids
423
+ <a name="getPurchaseIds"></a>
424
+
425
+ ## getPurchaseIds() ⇒ <code>Array</code> \| <code>Integer</code>
426
+ Get All Purchase Ids
427
+
428
+ **Kind**: global function
429
+ **Returns**: <code>Array</code> \| <code>Integer</code> - _ids
430
+ <a name="getPurchaseIds"></a>
431
+
432
+ ## getPurchaseIds(address) ⇒ <code>Array</code> \| <code>Integer</code>
433
+ Get All Purchase Ids filter by Address/Purchaser
434
+
435
+ **Kind**: global function
436
+ **Returns**: <code>Array</code> \| <code>Integer</code> - _ids
437
+
438
+ | Param | Type |
439
+ | --- | --- |
440
+ | address | <code>Address</code> |
441
+
442
+ <a name="getETHCostFromTokens"></a>
443
+
444
+ ## getETHCostFromTokens(tokenAmount) ⇒ <code>Integer</code>
445
+ Get ETH Cost from Tokens Amount
446
+
447
+ **Kind**: global function
448
+ **Returns**: <code>Integer</code> - ethAmount
449
+
450
+ | Param | Type |
451
+ | --- | --- |
452
+ | tokenAmount | <code>Integer</code> |
453
+
454
+ <a name="swap"></a>
455
+
456
+ ## swap(tokenAmount)
457
+ Swap tokens by Ethereum
458
+
459
+ **Kind**: global function
460
+
461
+ | Param | Type |
462
+ | --- | --- |
463
+ | tokenAmount | <code>Integer</code> |
464
+
465
+ <a name="redeemTokens(isStandard)"></a>
466
+
467
+ ## redeemTokens(purchase_id)
468
+ Reedem tokens bought
469
+
470
+ **Kind**: global function
471
+
472
+ | Param | Type |
473
+ | --- | --- |
474
+ | purchase_id | <code>Integer</code> |
475
+
476
+ <a name="redeemGivenMinimumGoalNotAchieved(isStandard)"></a>
477
+
478
+ ## redeemGivenMinimumGoalNotAchieved(purchase_id)
479
+ Reedem Ethereum from sale that did not achieve minimum goal
480
+
481
+ **Kind**: global function
482
+
483
+ | Param | Type |
484
+ | --- | --- |
485
+ | purchase_id | <code>Integer</code> |
486
+
487
+ <a name="withdrawUnsoldTokens"></a>
488
+
489
+ ## withdrawUnsoldTokens()
490
+ Withdraw unsold tokens of sale
491
+
492
+ **Kind**: global function
493
+ <a name="withdrawFunds"></a>
494
+
495
+ ## withdrawFunds()
496
+ Withdraw all funds from tokens sold
497
+
498
+ **Kind**: global function
499
+ <a name="approveFundERC20"></a>
500
+
501
+ ## approveFundERC20()
502
+ Approve the pool to use approved tokens for sale
503
+
504
+ **Kind**: global function
505
+ <a name="isApproved"></a>
506
+
507
+ ## isApproved(tokenAmount, address) ⇒ <code>Boolean</code>
508
+ Verify if the Admin has approved the pool to use receive the tokens for sale
509
+
510
+ **Kind**: global function
511
+
512
+ | Param | Type |
513
+ | --- | --- |
514
+ | tokenAmount | <code>Integer</code> |
515
+ | address | <code>Address</code> |
516
+
517
+ <a name="fund"></a>
518
+
519
+ ## fund(tokenAmount)
520
+ Send tokens to pool for sale, fund the sale
521
+
522
+ **Kind**: global function
523
+
524
+ | Param | Type |
525
+ | --- | --- |
526
+ | tokenAmount | <code>Integer</code> |
527
+
528
+ <a name="addWhitelistedAddress"></a>
529
+
530
+ ## addWhitelistedAddress(Addresses)
531
+ add WhiteListed Address
532
+
533
+ **Kind**: global function
534
+
535
+ | Param | Type |
536
+ | --- | --- |
537
+ | Addresses | <code>Array</code> \| <code>Addresses</code> |
538
+
539
+ <a name="removeWhitelistedAddress"></a>
540
+
541
+ ## removeWhitelistedAddress()
542
+ remove WhiteListed Address
543
+
544
+ **Kind**: global function
545
+ <a name="safePull"></a>
546
+
547
+ ## safePull()
548
+ Safe Pull all tokens & ETH
549
+
550
+ **Kind**: global function
551
+ <a name="removeOtherERC20Tokens"></a>
552
+
553
+ ## removeOtherERC20Tokens(tokenAddress, toAddress)
554
+ Remove Tokens from other ERC20 Address (in case of accident)
555
+
556
+ **Kind**: global function
557
+
558
+ | Param | Type |
559
+ | --- | --- |
560
+ | tokenAddress | <code>Address</code> |
561
+ | toAddress | <code>Address</code> |
562
+
563
+ <a name="deploy"></a>
564
+
565
+ ## deploy()
566
+ Deploy the Pool Contract
567
+
568
+ **Kind**: global function
569
+ <a name="getOwner"></a>
570
+
571
+ ## getOwner(Address)
572
+ Get owner address of contract
573
+
574
+ **Kind**: global function
575
+
576
+ | Param | Type |
577
+ | --- | --- |
578
+ | Address | <code>Address</code> |
579
+
580
+ <a name="getBalance"></a>
581
+
582
+ ## getBalance(Balance)
583
+ Get Balance of Contract
584
+
585
+ **Kind**: global function
586
+
587
+ | Param | Type |
588
+ | --- | --- |
589
+ | Balance | <code>Integer</code> |
590
+
package/_book/core.md ADDED
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: Pools
3
+ tags: pools, documentation
4
+ ---
5
+
6
+ # Introduction
7
+
8
+ Each Uniswap liquidity pool is a trading venue for a pair of ERC20 tokens. When a pool contract is created, its balances of each token are 0; in order for the pool to begin facilitating trades, someone must seed it with an initial deposit of each token. This first liquidity provider is the one who sets the initial price of the pool. They are incentivized to deposit an equal _value_ of both tokens into the pool. To see why, consider the case where the first liquidity provider deposits tokens at a ratio different from the current market rate. This immediately creates a profitable arbitrage opportunity, which is likely to be taken by an external party.
9
+
10
+ When other liquidity providers add to an existing pool, they must deposit pair tokens proportional to the current price. If they don’t, the liquidity they added is at risk of being arbitraged as well. If they believe the current price is not correct, they may arbitrage it to the level they desire, and add liquidity at that price.
11
+
12
+ # Pool tokens
13
+
14
+ Whenever liquidity is deposited into a pool, special tokens known as _liquidity tokens_ are minted to the provider’s address, in proportion to how much liquidity they contributed to the pool. These tokens are a representation of a liquidity provider’s contribution to a pool. Whenever a trade occurs, the 0.3% fee which is levied is distributed _pro-rata_ to all LPs in the pool at the moment of the trade. To receive the underlying liquidity back, plus any fees that were accrued while their liquidity was locked, LPs must burn their liquidity tokens.
15
+
16
+ Liquidity providers can also choose to sell, transfer, or otherwise use their liquidity tokens in any way they see fit.
17
+
18
+ Learn more with advanced topics :
19
+
20
+ # Why pools?
21
+
22
+ Uniswap is unique in that it doesn’t use an order book to derive the price of an asset or to match buyers and sellers of tokens. Instead, Uniswap uses what are called Liquidity Pools.
23
+
24
+ Liquidity is typically represented by discrete orders placed by individuals onto a centrally operated order book. A participant looking to provide liquidity or make markets must actively manage their orders, continuously updating them in response to the activity of others in the marketplace.
25
+
26
+ While order books are foundational to finance and work great for certain usecases, they suffer from a few important limitations that are especially magnified when applied to a decentralized or blockchain-native setting. Order books require intermediary infrastructure to host the orderbook and match orders. This creates points of control and adds additional layers of complexity. They also require active participation and management from market makers who usually use sophsticated infrastructure and algorithms, limiting participation to advanced traders. Order books were invented in a world with relatively few assets being traded, so it is not surprising they aren't ideal for an ecosystem where anyone can create their own token and those tokens usually have low liquidity. In sum, with the infrastrucural trade-offs presented by a platform like Ethereum, order books are not the native architecture for implementing a liquidity protocol on a blockchain.
27
+
28
+ Uniswap focuses on the strengths of Ethereum to reimagine token swaps from first principles.
29
+
30
+ A blockchain-native liquidity protocol should take advantage of the trusted code execution environment, the autonomous and perpetually running virtual machine, and an open, permissionless, and inclusive access model that produces an exponentially growing ecosystem of virtual assets.
31
+
32
+ <!-- Enter Uniswap and its underlying core mechanism of Liquidity Pools.
33
+
34
+ The goal of a liquidity provider is to earn fees from making markets (enabling the trading) for some asset. Instead of requiring liquidity providers to place discrete orders onto an order book, Uniswap combines (or pools) all available liquidity between two tokens in an Ethereum smart contract called a Liquidity Pool.
35
+
36
+ A liquidity pool is an autonomous program (smart contract) that holds a supply of two different tokens and enforces a novel set of rules about how those tokens can be added or removed.
37
+
38
+ These rules enable functionality one might expect from a token liquidity protocol.
39
+
40
+ Users can swap one token for another by depositing a token into one side of the pool and withdrawing tokens from the other side. The price is determined automatically by the pool based on a predetermined formula.
41
+
42
+ Liquidity providers can earn fees by supplying an equal proportion of tokens to the pool. -->
43
+
44
+ It is important to reiterate that a Pool is just a smart contract, operated by users calling functions on it. Swapping tokens is calling `swap` on a Pool contract instance, while providing liquidity is calling `deposit`.
45
+
46
+ Just how end-users can interact with the Uniswap protocol through the Interface (which in turn interacts with the underlying contracts), developers can interact directly with the smart contracts and integrate Uniswap functionality into their own applications without relying on intermediaries or needing permission.
47
+
48
+ # Developer resources
49
+
50
+ - To see how to pool tokens in a smart contract read [Providing Liquidity](/docs/v2/smart-contract-integration/providing-liquidity/).