@oceanprotocol/lib 1.0.0-next.4 → 1.0.0-next.42

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