@oceanprotocol/lib 1.0.0-next.2 → 1.0.0-next.20

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