@oceanprotocol/lib 1.0.0-next.7 → 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 (68) hide show
  1. package/CHANGELOG.md +405 -1
  2. package/CodeExamples.md +918 -0
  3. package/README.md +12 -80
  4. package/dist/lib.js +1 -1
  5. package/dist/lib.js.map +1 -1
  6. package/dist/lib.modern.js +1 -1
  7. package/dist/lib.modern.js.map +1 -1
  8. package/dist/lib.module.js +1 -1
  9. package/dist/lib.module.js.map +1 -1
  10. package/dist/lib.umd.js +1 -1
  11. package/dist/lib.umd.js.map +1 -1
  12. package/dist/src/@types/Asset.d.ts +83 -0
  13. package/dist/src/@types/Compute.d.ts +18 -1
  14. package/dist/src/@types/DDO/DDO.d.ts +43 -0
  15. package/dist/src/@types/DDO/Event.d.ts +20 -0
  16. package/dist/src/@types/DDO/Metadata.d.ts +92 -0
  17. package/dist/src/@types/DDO/Service.d.ts +72 -6
  18. package/dist/src/{interfaces/DispenserInterface.d.ts → @types/Dispenser.d.ts} +0 -0
  19. package/dist/src/@types/DownloadResponse.d.ts +4 -0
  20. package/dist/src/@types/Erc20.d.ts +21 -0
  21. package/dist/src/@types/Erc721.d.ts +12 -0
  22. package/dist/src/@types/FileMetadata.d.ts +29 -0
  23. package/dist/src/{interfaces/FixedRateInterface.d.ts → @types/FixedPrice.d.ts} +7 -1
  24. package/dist/src/{interfaces/PoolInterface.d.ts → @types/Pool.d.ts} +11 -2
  25. package/dist/src/@types/Provider.d.ts +9 -0
  26. package/dist/src/@types/Router.d.ts +59 -0
  27. package/dist/src/@types/index.d.ts +6 -0
  28. package/dist/src/aquarius/Aquarius.d.ts +26 -4
  29. package/dist/src/factories/NFTFactory.d.ts +222 -13
  30. package/dist/src/index.d.ts +1 -1
  31. package/dist/src/models/Config.d.ts +128 -0
  32. package/dist/src/pools/Router.d.ts +193 -12
  33. package/dist/src/pools/balancer/Pool.d.ts +357 -37
  34. package/dist/src/pools/dispenser/Dispenser.d.ts +109 -2
  35. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +311 -19
  36. package/dist/src/pools/index.d.ts +2 -0
  37. package/dist/src/pools/ssContracts/SideStaking.d.ts +110 -7
  38. package/dist/src/provider/Provider.d.ts +137 -14
  39. package/dist/src/tokens/Datatoken.d.ts +347 -7
  40. package/dist/src/tokens/NFT.d.ts +301 -6
  41. package/dist/src/utils/ConfigHelper.d.ts +1 -1
  42. package/dist/src/utils/Constants.d.ts +1 -0
  43. package/dist/src/utils/ContractUtils.d.ts +13 -2
  44. package/dist/src/utils/DatatokenName.d.ts +4 -0
  45. package/dist/src/utils/FetchHelper.d.ts +3 -2
  46. package/dist/src/utils/General.d.ts +4 -0
  47. package/dist/src/utils/PoolHelpers.d.ts +8 -0
  48. package/dist/src/utils/SignatureUtils.d.ts +0 -2
  49. package/dist/src/utils/TokenUtils.d.ts +69 -0
  50. package/dist/src/utils/index.d.ts +3 -0
  51. package/dist/src/utils/minAbi.d.ts +2 -0
  52. package/dist/test/TestContractHandler.d.ts +8 -36
  53. package/dist/test/config.d.ts +5 -0
  54. package/dist/test/{unit/NftFactory.test.d.ts → integration/CodeExamples.test.d.ts} +0 -0
  55. package/dist/test/unit/factories/NftFactory.test.d.ts +1 -0
  56. package/package.json +38 -34
  57. package/dist/src/interfaces/Erc20Interface.d.ts +0 -11
  58. package/dist/src/interfaces/RouterInterface.d.ts +0 -12
  59. package/dist/src/interfaces/index.d.ts +0 -5
  60. package/dist/test/integration/config.d.ts +0 -3
  61. package/dist/test/unit/config.d.ts +0 -3
  62. package/docs/beginners_guide.md +0 -338
  63. package/docs/get-test-OCEAN.md +0 -24
  64. package/docs/overview.md +0 -394
  65. package/docs/quickstart_marketplace.md +0 -423
  66. package/docs/quickstart_simple.md +0 -272
  67. package/docs/services.md +0 -94
  68. package/docs/wallets.md +0 -98
@@ -2,74 +2,394 @@ import Web3 from 'web3';
2
2
  import { AbiItem } from 'web3-utils/types';
3
3
  import { TransactionReceipt } from 'web3-core';
4
4
  import { Contract } from 'web3-eth-contract';
5
- import { Logger } from '../../utils';
6
- import { CurrentFees, TokenInOutMarket, AmountsInMaxFee, AmountsOutMaxFee } from '../../interfaces';
5
+ import { CurrentFees, TokenInOutMarket, AmountsInMaxFee, AmountsOutMaxFee, PoolPriceAndFees } from '../../@types';
7
6
  import { Config } from '../../models';
7
+ /**
8
+ * Provides an interface to Ocean friendly fork from Balancer BPool
9
+ */
8
10
  export declare class Pool {
9
11
  poolAbi: AbiItem | AbiItem[];
10
12
  web3: Web3;
11
- GASLIMIT_DEFAULT: number;
12
- private logger;
13
13
  private config;
14
- constructor(web3: Web3, logger: Logger, poolAbi?: AbiItem | AbiItem[], config?: Config);
15
- estApprove(account: string, tokenAddress: string, spender: string, amount: string, contractInstance?: Contract): Promise<number>;
16
- allowance(tokenAddress: string, owner: string, spender: string): Promise<string>;
17
- approve(account: string, tokenAddress: string, spender: string, amount: string, force?: boolean): Promise<TransactionReceipt | string>;
14
+ constructor(web3: Web3, network?: string | number, poolAbi?: AbiItem | AbiItem[], config?: Config);
15
+ amountToUnits(token: string, amount: string, tokenDecimals?: number): Promise<string>;
16
+ unitsToAmount(token: string, amount: string, tokenDecimals?: number): Promise<string>;
17
+ /**
18
+ * Get user shares of pool tokens
19
+ * @param {String} account
20
+ * @param {String} poolAddress
21
+ * @return {String}
22
+ */
18
23
  sharesBalance(account: string, poolAddress: string): Promise<string>;
24
+ /**
25
+ * Estimate gas cost for setSwapFee
26
+ * @param {String} account
27
+ * @param {String} tokenAddress
28
+ * @param {String} spender
29
+ * @param {String} amount
30
+ * @param {String} force
31
+ * @param {Contract} contractInstance optional contract instance
32
+ * @return {Promise<number>}
33
+ */
19
34
  estSetSwapFee(account: string, poolAddress: string, fee: string, contractInstance?: Contract): Promise<number>;
35
+ /**
36
+ * Allows controller to change the swapFee
37
+ * @param {String} account
38
+ * @param {String} poolAddress
39
+ * @param {String} fee swap fee (1e17 = 10 % , 1e16 = 1% , 1e15 = 0.1%, 1e14 = 0.01%)
40
+ */
20
41
  setSwapFee(account: string, poolAddress: string, fee: string): Promise<TransactionReceipt>;
42
+ /**
43
+ * Returns number of tokens bounded to pool
44
+ * @param {String} poolAddress
45
+ * @return {String}
46
+ */
21
47
  getNumTokens(poolAddress: string): Promise<string>;
48
+ /**
49
+ * Get total supply of pool shares
50
+ * @param {String} poolAddress
51
+ * @return {String}
52
+ */
22
53
  getPoolSharesTotalSupply(poolAddress: string): Promise<string>;
54
+ /**
55
+ * Get tokens composing this poo
56
+ * Returns tokens bounded to pool, before the pool is finalizedl
57
+ * @param {String} poolAddress
58
+ * @return {String[]}
59
+ */
23
60
  getCurrentTokens(poolAddress: string): Promise<string[]>;
61
+ /**
62
+ * Get the final tokens composing this pool
63
+ * Returns tokens bounded to pool, after the pool was finalized
64
+ * @param {String} poolAddress
65
+ * @return {String[]}
66
+ */
24
67
  getFinalTokens(poolAddress: string): Promise<string[]>;
68
+ /**
69
+ * Returns the current controller address (ssBot)
70
+ * @param {String} poolAddress
71
+ * @return {String}
72
+ */
25
73
  getController(poolAddress: string): Promise<string>;
74
+ /**
75
+ * Returns the current baseToken address of the pool
76
+ * @param {String} poolAddress
77
+ * @return {String}
78
+ */
26
79
  getBaseToken(poolAddress: string): Promise<string>;
80
+ /**
81
+ * Returns the current datatoken address
82
+ * @param {String} poolAddress
83
+ * @return {String}
84
+ */
27
85
  getDatatoken(poolAddress: string): Promise<string>;
86
+ /**
87
+ * Get getMarketFee
88
+ * @param {String} poolAddress
89
+ * @return {String}
90
+ */
91
+ getMarketFee(poolAddress: string): Promise<string>;
92
+ /**
93
+ * Get marketFeeCollector of this pool
94
+ * @param {String} poolAddress
95
+ * @return {String}
96
+ */
28
97
  getMarketFeeCollector(poolAddress: string): Promise<string>;
29
- getOPFCollector(poolAddress: string): Promise<string>;
98
+ /**
99
+ * Get if a token is bounded to a pool
100
+ * Returns true if token is bound
101
+ * @param {String} poolAddress
102
+ * @param {String} token Address of the token to be checked
103
+ * @return {Boolean}
104
+ */
30
105
  isBound(poolAddress: string, token: string): Promise<boolean>;
31
- getReserve(poolAddress: string, token: string): Promise<string>;
106
+ /**
107
+ * Returns the current token reserve amount
108
+ * @param {String} poolAddress
109
+ * @param {String} token Address of the token to be checked
110
+ * @param {number} tokenDecimals optional number of decimals of the token
111
+ * @return {String}
112
+ */
113
+ getReserve(poolAddress: string, token: string, tokenDecimals?: number): Promise<string>;
114
+ /**
115
+ * Get if a pool is finalized
116
+ * Returns true if pool is finalized
117
+ * @param {String} poolAddress
118
+ * @return {Boolean}
119
+ */
32
120
  isFinalized(poolAddress: string): Promise<boolean>;
121
+ /**
122
+ * Returns the current Liquidity Providers swap fee
123
+ * @param {String} poolAddress
124
+ * @return {String} Swap fee. To get the percentage value, substract by 100. E.g. `0.1` represents a 10% swap fee.
125
+ */
33
126
  getSwapFee(poolAddress: string): Promise<string>;
127
+ /**
128
+ * Returns normalized weight of a token.
129
+ * The combined normalized weights of all tokens will sum up to 1.
130
+ * (Note: the actual sum may be 1 plus or minus a few wei due to division precision loss)
131
+ * @param {String} poolAddress
132
+ * @param {String} token token to be checked
133
+ * @return {String}
134
+ */
34
135
  getNormalizedWeight(poolAddress: string, token: string): Promise<string>;
136
+ /**
137
+ * Returns denormalized weight of a token
138
+ * @param {String} poolAddress
139
+ * @param {String} token token to be checked
140
+ * @return {String}
141
+ */
35
142
  getDenormalizedWeight(poolAddress: string, token: string): Promise<string>;
143
+ /**
144
+ * getTotalDenormalizedWeight
145
+ * Returns total denormalized weught of the pool
146
+ * @param {String} poolAddress
147
+ * @return {String}
148
+ */
36
149
  getTotalDenormalizedWeight(poolAddress: string): Promise<string>;
37
- getMarketFees(poolAddress: string, token: string): Promise<string>;
150
+ /**
151
+ * Returns the current fee of publishingMarket
152
+ * Get Market Fees available to be collected for a specific token
153
+ * @param {String} poolAddress
154
+ * @param {String} token token we want to check fees
155
+ * @param {number} tokenDecimals optional number of decimals of the token
156
+ * @return {String}
157
+ */
158
+ getMarketFees(poolAddress: string, token: string, tokenDecimals?: number): Promise<string>;
159
+ /**
160
+ * Get Community Get the current amount of fees which can be withdrawned by the Market
161
+ * @return {CurrentFees}
162
+ */
38
163
  getCurrentMarketFees(poolAddress: string): Promise<CurrentFees>;
39
- getCurrentOPFFees(poolAddress: string): Promise<CurrentFees>;
40
- getCommunityFees(poolAddress: string, token: string): Promise<string>;
41
- estCollectOPF(address: string, poolAddress: string, contractInstance?: Contract): Promise<number>;
42
- collectOPF(address: string, poolAddress: string): Promise<TransactionReceipt>;
164
+ /**
165
+ * Get getCurrentOPFFees Get the current amount of fees which can be withdrawned by OPF
166
+ * @return {CurrentFees}
167
+ */
168
+ getCurrentOPCFees(poolAddress: string): Promise<CurrentFees>;
169
+ /**
170
+ * Get Community Fees available to be collected for a specific token
171
+ * @param {String} poolAddress
172
+ * @param {String} token token we want to check fees
173
+ * @param {number} tokenDecimals optional number of decimals of the token
174
+ * @return {String}
175
+ */
176
+ getCommunityFees(poolAddress: string, token: string, tokenDecimals?: number): Promise<string>;
177
+ /**
178
+ * Estimate gas cost for collectOPF
179
+ * @param {String} address
180
+ * @param {String} poolAddress
181
+ * @param {Contract} contractInstance optional contract instance
182
+ * @return {Promise<number>}
183
+ */
184
+ estCollectOPC(address: string, poolAddress: string, contractInstance?: Contract): Promise<number>;
185
+ /**
186
+ * collectOPF - collect opf fee - can be called by anyone
187
+ * @param {String} address
188
+ * @param {String} poolAddress
189
+ * @return {TransactionReceipt}
190
+ */
191
+ collectOPC(address: string, poolAddress: string): Promise<TransactionReceipt>;
192
+ /**
193
+ * Estimate gas cost for collectMarketFee
194
+ * @param {String} address
195
+ * @param {String} poolAddress
196
+ * @param {String} to address that will receive fees
197
+ * @param {Contract} contractInstance optional contract instance
198
+ * @return {Promise<number>}
199
+ */
43
200
  estCollectMarketFee(address: string, poolAddress: string, contractInstance?: Contract): Promise<number>;
201
+ /**
202
+ * collectOPF - collect market fees - can be called by the publishMarketCollector
203
+ * @param {String} address
204
+ * @param {String} poolAddress
205
+ * @param {String} to address that will receive fees
206
+ * @return {TransactionReceipt}
207
+ */
44
208
  collectMarketFee(address: string, poolAddress: string): Promise<TransactionReceipt>;
45
- estUpdateMarketFeeCollector(address: string, poolAddress: string, newCollector: string, contractInstance?: Contract): Promise<number>;
46
- updateMarketFeeCollector(address: string, poolAddress: string, newCollector: string): Promise<TransactionReceipt>;
47
- amountToUnits(token: string, amount: string): Promise<string>;
48
- unitsToAmount(token: string, amount: string): Promise<string>;
209
+ /**
210
+ * Estimate gas cost for updatePublishMarketFee
211
+ * @param {String} address
212
+ * @param {String} poolAddress
213
+ * @param {String} newPublishMarketAddress new market address
214
+ * @param {String} newPublishMarketSwapFee new market swap fee
215
+ * @param {Contract} contractInstance optional contract instance
216
+ * @return {Promise<number>}
217
+ */
218
+ estUpdatePublishMarketFee(address: string, poolAddress: string, newPublishMarketAddress: string, newPublishMarketSwapFee: string, contractInstance?: Contract): Promise<number>;
219
+ /**
220
+ * updatePublishMarketFee - sets a new newPublishMarketAddress and new newPublishMarketSwapFee- can be called only by the marketFeeCollector
221
+ * @param {String} address
222
+ * @param {String} poolAddress
223
+ * @param {String} newPublishMarketAddress new market fee collector address
224
+ * @param {String} newPublishMarketSwapFee fee recieved by the publisher market when a dt is swaped from a pool, percent
225
+ * @return {TransactionReceipt}
226
+ */
227
+ updatePublishMarketFee(address: string, poolAddress: string, newPublishMarketAddress: string, newPublishMarketSwapFee: string): Promise<TransactionReceipt>;
228
+ /**
229
+ * Estimate gas cost for swapExactAmountIn
230
+ * @param {String} address
231
+ * @param {String} poolAddress
232
+ * @param {TokenInOutMarket} tokenInOutMarket object contianing addresses like tokenIn, tokenOut, consumeMarketFeeAddress
233
+ * @param {AmountsInMaxFee} amountsInOutMaxFee object contianing tokenAmountIn, minAmountOut, maxPrice, consumeMarketSwapFee
234
+ * @param {Contract} contractInstance optional contract instance
235
+ * @return {Promise<number>}
236
+ */
49
237
  estSwapExactAmountIn(address: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsInMaxFee, contractInstance?: Contract): Promise<number>;
238
+ /**
239
+ * Swaps an exact amount of tokensIn to get a mimum amount of tokenOut
240
+ * Trades an exact tokenAmountIn of tokenIn taken from the caller by the pool,
241
+ * in exchange for at least minAmountOut of tokenOut given to the caller from the pool, with a maximum marginal price of maxPrice.
242
+ * Returns (tokenAmountOut, spotPriceAfter), where tokenAmountOut is the amount of token that came out of the pool,
243
+ * and spotPriceAfter is the new marginal spot price, ie, the result of getSpotPrice after the call.
244
+ * (These values are what are limited by the arguments; you are guaranteed tokenAmountOut >= minAmountOut and spotPriceAfter <= maxPrice).
245
+ * @param {String} address
246
+ * @param {String} poolAddress
247
+ * @param {TokenInOutMarket} tokenInOutMarket object contianing addresses like tokenIn, tokenOut, consumeMarketFeeAddress
248
+ * @param {AmountsInMaxFee} amountsInOutMaxFee object contianing tokenAmountIn, minAmountOut, maxPrice, consumeMarketSwapFee
249
+ * @return {TransactionReceipt}
250
+ */
50
251
  swapExactAmountIn(address: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsInMaxFee): Promise<TransactionReceipt>;
252
+ /**
253
+ * Estimate gas cost for swapExactAmountOut
254
+ * @param {String} address
255
+ * @param {String} poolAddress
256
+ * @param {TokenInOutMarket} tokenInOutMarket
257
+ * @param {AmountsOutMaxFee} amountsInOutMaxFee
258
+ * @param {Contract} contractInstance optional contract instance
259
+ * @return {Promise<number>}
260
+ */
51
261
  estSwapExactAmountOut(address: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsOutMaxFee, contractInstance?: Contract): Promise<number>;
262
+ /**
263
+ * Swaps a maximum maxAmountIn of tokensIn to get an exact amount of tokenOut
264
+ * @param {String} account
265
+ * @param {String} poolAddress
266
+ * @param {TokenInOutMarket} tokenInOutMarket Object containing addresses like tokenIn, tokenOut, consumeMarketFeeAddress
267
+ * @param {AmountsOutMaxFee} amountsInOutMaxFee Object containging maxAmountIn,tokenAmountOut,maxPrice, consumeMarketSwapFee]
268
+ * @return {TransactionReceipt}
269
+ */
52
270
  swapExactAmountOut(account: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsOutMaxFee): Promise<TransactionReceipt>;
53
- estJoinPool(address: string, poolAddress: string, poolAmountOut: string, maxAmountsIn: string[], contractInstance?: Contract): Promise<number>;
54
- joinPool(address: string, poolAddress: string, poolAmountOut: string, maxAmountsIn: string[]): Promise<TransactionReceipt>;
55
- estExitPool(address: string, poolAddress: string, poolAmountIn: string, minAmountsOut: string[], contractInstance?: Contract): Promise<number>;
56
- exitPool(account: string, poolAddress: string, poolAmountIn: string, minAmountsOut: string[]): Promise<TransactionReceipt>;
57
- estJoinswapExternAmountIn(address: string, poolAddress: string, tokenIn: string, tokenAmountIn: string, minPoolAmountOut: string, contractInstance?: Contract): Promise<number>;
58
- joinswapExternAmountIn(account: string, poolAddress: string, tokenIn: string, tokenAmountIn: string, minPoolAmountOut: string): Promise<TransactionReceipt>;
59
- estJoinswapPoolAmountOut(address: string, poolAddress: string, tokenIn: string, poolAmountOut: string, maxAmountIn: string, contractInstance?: Contract): Promise<number>;
60
- joinswapPoolAmountOut(account: string, poolAddress: string, tokenIn: string, poolAmountOut: string, maxAmountIn: string): Promise<TransactionReceipt>;
61
- estExitswapPoolAmountIn(address: string, poolAddress: string, tokenOut: string, poolAmountIn: string, minTokenAmountOut: string, contractInstance?: Contract): Promise<number>;
62
- exitswapPoolAmountIn(account: string, poolAddress: string, tokenOut: string, poolAmountIn: string, minTokenAmountOut: string): Promise<TransactionReceipt>;
63
- estExitswapExternAmountOut(address: string, poolAddress: string, tokenOut: string, tokenAmountOut: string, maxPoolAmountIn: string, contractInstance?: Contract): Promise<number>;
64
- exitswapExternAmountOut(account: string, poolAddress: string, tokenOut: string, tokenAmountOut: string, maxPoolAmountIn: string): Promise<TransactionReceipt>;
271
+ /**
272
+ * Estimate gas cost for joinswapExternAmountIn
273
+ * @param {String} address
274
+ * @param {String} poolAddress
275
+ * @param {String} tokenIn
276
+ * @param {String} tokenAmountIn exact number of base tokens to spend
277
+ * @param {String} minPoolAmountOut minimum of pool shares expectex
278
+ * @param {Contract} contractInstance optional contract instance
279
+ * @return {Promise<number>}
280
+ */
281
+ estJoinswapExternAmountIn(address: string, poolAddress: string, tokenAmountIn: string, minPoolAmountOut: string, contractInstance?: Contract): Promise<number>;
282
+ /**
283
+ * Single side add liquidity to the pool,
284
+ * expecting a minPoolAmountOut of shares for spending tokenAmountIn basetokens.
285
+ * Pay tokenAmountIn of baseToken to join the pool, getting poolAmountOut of the pool shares.
286
+ * @param {String} account
287
+ * @param {String} poolAddress
288
+ * @param {String} tokenAmountIn exact number of base tokens to spend
289
+ * @param {String} minPoolAmountOut minimum of pool shares expectex
290
+ * @param {number} tokenInDecimals optional number of decimals of the token
291
+ * @return {TransactionReceipt}
292
+ */
293
+ joinswapExternAmountIn(account: string, poolAddress: string, tokenAmountIn: string, minPoolAmountOut: string, tokenInDecimals?: number): Promise<TransactionReceipt>;
294
+ /**
295
+ * Estimate gas cost for exitswapPoolAmountIn
296
+ * @param {String} address
297
+ * @param {String} poolAddress
298
+ * @param {String} poolAmountIn exact number of pool shares to spend
299
+ * @param {String} minTokenAmountOut minimum amount of basetokens expected
300
+ * @param {Contract} contractInstance optional contract instance
301
+ * @return {Promise<number>}
302
+ */
303
+ estExitswapPoolAmountIn(address: string, poolAddress: string, poolAmountIn: string, minTokenAmountOut: string, contractInstance?: Contract): Promise<number>;
304
+ /**
305
+ * Single side remove liquidity from the pool,
306
+ * expecting a minAmountOut of basetokens for spending poolAmountIn pool shares
307
+ * Pay poolAmountIn pool shares into the pool, getting minTokenAmountOut of the baseToken
308
+ * @param {String} account
309
+ * @param {String} poolAddress
310
+ * @param {String} poolAmountIn exact number of pool shares to spend
311
+ * @param {String} minTokenAmountOut minimum amount of basetokens expected
312
+ * @param {number} poolDecimals optional number of decimals of the poool
313
+ * @return {TransactionReceipt}
314
+ */
315
+ exitswapPoolAmountIn(account: string, poolAddress: string, poolAmountIn: string, minTokenAmountOut: string, poolDecimals?: number): Promise<TransactionReceipt>;
316
+ /**
317
+ * Return the spot price of swapping tokenIn to tokenOut
318
+ * @param {String} poolAddress
319
+ * @param {String} tokenIn in token
320
+ * @param {String} tokenOut out token
321
+ * @param {String} swapMarketFe consume market swap fee
322
+ * @return {String}
323
+ */
65
324
  getSpotPrice(poolAddress: string, tokenIn: string, tokenOut: string, swapMarketFee: string): Promise<string>;
66
- getAmountInExactOut(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountOut: string, swapMarketFee: string): Promise<string>;
67
- getAmountOutExactIn(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountIn: string, swapMarketFee: string): Promise<string>;
68
- calcPoolOutGivenSingleIn(poolAddress: string, tokenIn: string, tokenAmountIn: string): Promise<string>;
69
- calcSingleInGivenPoolOut(poolAddress: string, tokenIn: string, poolAmountOut: string): Promise<string>;
70
- calcSingleOutGivenPoolIn(poolAddress: string, tokenOut: string, poolAmountIn: string): Promise<string>;
71
- calcPoolInGivenSingleOut(poolAddress: string, tokenOut: string, tokenAmountOut: string): Promise<string>;
325
+ /**
326
+ * How many tokensIn do you need in order to get exact tokenAmountOut.
327
+ * Returns: tokenAmountIn, swapFee, opcFee , consumeMarketSwapFee, publishMarketSwapFee
328
+ * Returns: tokenAmountIn, LPFee, opcFee , publishMarketSwapFee, consumeMarketSwapFee
329
+ * @param tokenIn token to be swaped
330
+ * @param tokenOut token to get
331
+ * @param tokenAmountOut exact amount of tokenOut
332
+ * @param swapMarketFee consume market swap fee
333
+ * @param {number} tokenInDecimals optional number of decimals of the token to be swaped
334
+ * @param {number} tokenOutDecimals optional number of decimals of the token to get
335
+ */
336
+ getAmountInExactOut(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountOut: string, swapMarketFee: string, tokenInDecimals?: number, tokenOutDecimals?: number): Promise<PoolPriceAndFees>;
337
+ /**
338
+ * How many tokensOut you will get for a exact tokenAmountIn
339
+ * Returns: tokenAmountOut, LPFee, opcFee , publishMarketSwapFee, consumeMarketSwapFee
340
+ * @param tokenIn token to be swaped
341
+ * @param tokenOut token to get
342
+ * @param tokenAmountIn exact amount of tokenIn
343
+ * @param swapMarketFee
344
+ * @param {number} tokenInDecimals optional number of decimals of the token to be swaped
345
+ * @param {number} tokenOutDecimals optional number of decimals of the token to get
346
+ */
347
+ getAmountOutExactIn(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountIn: string, swapMarketFee: string, tokenInDecimals?: number, tokenOutDecimals?: number): Promise<PoolPriceAndFees>;
348
+ /**
349
+ * Returns number of poolshares obtain by staking exact tokenAmountIn tokens
350
+ * @param tokenIn tokenIn
351
+ * @param tokenAmountIn exact number of tokens staked
352
+ * @param {number} poolDecimals optional number of decimals of the poool
353
+ * @param {number} tokenInDecimals optional number of decimals of the token
354
+ */
355
+ calcPoolOutGivenSingleIn(poolAddress: string, tokenIn: string, tokenAmountIn: string, poolDecimals?: number, tokenInDecimals?: number): Promise<string>;
356
+ /**
357
+ * Returns number of tokens to be staked to the pool in order to get an exact number of poolshares
358
+ * @param tokenIn tokenIn
359
+ * @param poolAmountOut expected amount of pool shares
360
+ * @param {number} poolDecimals optional number of decimals of the pool
361
+ * @param {number} tokenInDecimals optional number of decimals of the token
362
+ */
363
+ calcSingleInGivenPoolOut(poolAddress: string, tokenIn: string, poolAmountOut: string, poolDecimals?: number, tokenInDecimals?: number): Promise<string>;
364
+ /**
365
+ * Returns expected amount of tokenOut for removing exact poolAmountIn pool shares from the pool
366
+ * @param tokenOut tokenOut
367
+ * @param poolAmountIn amount of shares spent
368
+ * @param {number} poolDecimals optional number of decimals of the pool
369
+ * @param {number} tokenOutDecimals optional number of decimals of the token
370
+ */
371
+ calcSingleOutGivenPoolIn(poolAddress: string, tokenOut: string, poolAmountIn: string, poolDecimals?: number, tokenOutDecimals?: number): Promise<string>;
372
+ /**
373
+ * Returns number of poolshares needed to withdraw exact tokenAmountOut tokens
374
+ * @param tokenOut tokenOut
375
+ * @param tokenAmountOut expected amount of tokensOut
376
+ * @param {number} poolDecimals optional number of decimals of the pool
377
+ * @param {number} tokenOutDecimals optional number of decimals of the token
378
+ */
379
+ calcPoolInGivenSingleOut(poolAddress: string, tokenOut: string, tokenAmountOut: string, poolDecimals?: number, tokenOutDecimals?: number): Promise<string>;
380
+ /**
381
+ * Get LOG_SWAP encoded topic
382
+ * @return {String}
383
+ */
72
384
  getSwapEventSignature(): string;
385
+ /**
386
+ * Get LOG_JOIN encoded topic
387
+ * @return {String}
388
+ */
73
389
  getJoinEventSignature(): string;
390
+ /**
391
+ * Get LOG_EXIT encoded topic
392
+ * @return {String}
393
+ */
74
394
  getExitEventSignature(): string;
75
395
  }
@@ -14,25 +14,132 @@ export interface DispenserToken {
14
14
  allowedSwapper: string;
15
15
  }
16
16
  export declare class Dispenser {
17
- GASLIMIT_DEFAULT: number;
18
17
  web3: Web3;
19
18
  dispenserAddress: string;
20
19
  config: Config;
21
20
  dispenserAbi: AbiItem | AbiItem[];
22
21
  dispenserContract: Contract;
23
- constructor(web3: Web3, dispenserAddress?: string, dispenserAbi?: AbiItem | AbiItem[], config?: Config);
22
+ /**
23
+ * Instantiate Dispenser
24
+ * @param {any} web3
25
+ * @param {String} dispenserAddress
26
+ * @param {any} dispenserABI
27
+ */
28
+ constructor(web3: Web3, network?: string | number, dispenserAddress?: string, dispenserAbi?: AbiItem | AbiItem[], config?: Config);
29
+ /**
30
+ * Get information about a datatoken dispenser
31
+ * @param {String} dtAddress
32
+ * @return {Promise<FixedPricedExchange>} Exchange details
33
+ */
24
34
  status(dtAdress: string): Promise<DispenserToken>;
35
+ /**
36
+ * Estimate gas cost for create method
37
+ * @param {String} dtAddress Datatoken address
38
+ * @param {String} address Owner address
39
+ * @param {String} maxTokens max tokens to dispense
40
+ * @param {String} maxBalance max balance of requester
41
+ * @param {String} allowedSwapper if !=0, only this address can request DTs
42
+ * @return {Promise<any>}
43
+ */
25
44
  estGasCreate(dtAddress: string, address: string, maxTokens: string, maxBalance: string, allowedSwapper: string): Promise<any>;
45
+ /**
46
+ * Creates a new Dispenser
47
+ * @param {String} dtAddress Datatoken address
48
+ * @param {String} address Owner address
49
+ * @param {String} maxTokens max tokens to dispense
50
+ * @param {String} maxBalance max balance of requester
51
+ * @param {String} allowedSwapper only account that can ask tokens. set address(0) if not required
52
+ * @return {Promise<TransactionReceipt>} transactionId
53
+ */
26
54
  create(dtAddress: string, address: string, maxTokens: string, maxBalance: string, allowedSwapper: string): Promise<TransactionReceipt>;
55
+ /**
56
+ * Estimate gas for activate method
57
+ * @param {String} dtAddress
58
+ * @param {Number} maxTokens max amount of tokens to dispense
59
+ * @param {Number} maxBalance max balance of user. If user balance is >, then dispense will be rejected
60
+ * @param {String} address User address (must be owner of the datatoken)
61
+ * @return {Promise<any>}
62
+ */
27
63
  estGasActivate(dtAddress: string, maxTokens: string, maxBalance: string, address: string): Promise<any>;
64
+ /**
65
+ * Activates a new dispener.
66
+ * @param {String} dtAddress refers to datatoken address.
67
+ * @param {Number} maxTokens max amount of tokens to dispense
68
+ * @param {Number} maxBalance max balance of user. If user balance is >, then dispense will be rejected
69
+ * @param {String} address User address (must be owner of the datatoken)
70
+ * @return {Promise<TransactionReceipt>} TransactionReceipt
71
+ */
28
72
  activate(dtAddress: string, maxTokens: string, maxBalance: string, address: string): Promise<TransactionReceipt>;
73
+ /**
74
+ * Estimate gas for deactivate method
75
+ * @param {String} dtAddress
76
+ * @param {String} address User address (must be owner of the datatoken)
77
+ * @return {Promise<any>}
78
+ */
29
79
  estGasDeactivate(dtAddress: string, address: string): Promise<any>;
80
+ /**
81
+ * Deactivate an existing dispenser.
82
+ * @param {String} dtAddress refers to datatoken address.
83
+ * @param {String} address User address (must be owner of the datatoken)
84
+ * @return {Promise<TransactionReceipt>} TransactionReceipt
85
+ */
30
86
  deactivate(dtAddress: string, address: string): Promise<TransactionReceipt>;
87
+ /**
88
+ * Estimate gas for setAllowedSwapper method
89
+ * @param {String} dtAddress refers to datatoken address.
90
+ * @param {String} address User address (must be owner of the datatoken)
91
+ * @param {String} newAllowedSwapper refers to the new allowedSwapper
92
+ * @return {Promise<any>}
93
+ */
31
94
  estGasSetAllowedSwapper(dtAddress: string, address: string, newAllowedSwapper: string): Promise<any>;
95
+ /**
96
+ * Sets a new allowedSwapper.
97
+ * @param {String} dtAddress refers to datatoken address.
98
+ * @param {String} address User address (must be owner of the datatoken)
99
+ * @param {String} newAllowedSwapper refers to the new allowedSwapper
100
+ * @return {Promise<TransactionReceipt>} TransactionReceipt
101
+ */
32
102
  setAllowedSwapper(dtAddress: string, address: string, newAllowedSwapper: string): Promise<TransactionReceipt>;
103
+ /**
104
+ * Estimate gas for dispense method
105
+ * @param {String} dtAddress refers to datatoken address.
106
+ * @param {String} address User address (must be owner of the datatoken)
107
+ * @param {String} newAllowedSwapper refers to the new allowedSwapper
108
+ * @return {Promise<any>}
109
+ */
33
110
  estGasDispense(dtAddress: string, address: string, amount: string, destination: string): Promise<any>;
111
+ /**
112
+ * Dispense datatokens to caller.
113
+ * The dispenser must be active, hold enough DT (or be able to mint more)
114
+ * and respect maxTokens/maxBalance requirements
115
+ * @param {String} dtAddress refers to datatoken address.
116
+ * @param {String} address User address
117
+ * @param {String} amount amount of datatokens required.
118
+ * @param {String} destination who will receive the tokens
119
+ * @return {Promise<TransactionReceipt>} TransactionReceipt
120
+ */
34
121
  dispense(dtAddress: string, address: string, amount: string, destination: string): Promise<TransactionReceipt>;
122
+ /**
123
+ * Estimate gas for ownerWithdraw method
124
+ * @param {String} dtAddress refers to datatoken address.
125
+ * @param {String} address User address (must be owner of the datatoken)
126
+ * @param {String} newAllowedSwapper refers to the new allowedSwapper
127
+ * @return {Promise<any>}
128
+ */
35
129
  estGasOwnerWithdraw(dtAddress: string, address: string): Promise<any>;
130
+ /**
131
+ * Withdraw all tokens from the dispenser
132
+ * @param {String} dtAddress refers to datatoken address.
133
+ * @param {String} address User address (must be owner of the dispenser)
134
+ * @return {Promise<TransactionReceipt>} TransactionReceipt
135
+ */
36
136
  ownerWithdraw(dtAddress: string, address: string): Promise<TransactionReceipt>;
137
+ /**
138
+ * Check if tokens can be dispensed
139
+ * @param {String} dtAddress
140
+ * @param {String} address User address that will receive datatokens
141
+ * @param {String} amount amount of datatokens required.
142
+ * @return {Promise<Boolean>}
143
+ */
37
144
  isDispensable(dtAddress: string, datatoken: Datatoken, address: string, amount?: string): Promise<Boolean>;
38
145
  }