@oceanprotocol/lib 1.0.0-next.1 → 1.0.0-next.13

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 (103) hide show
  1. package/CHANGELOG.md +111 -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 +119 -0
  11. package/dist/src/{src/@types → @types}/Compute.d.ts +17 -0
  12. package/dist/src/{src/@types → @types}/DDO/Credentials.d.ts +0 -0
  13. package/dist/src/@types/DDO/DDO.d.ts +58 -0
  14. package/dist/src/@types/DDO/Event.d.ts +27 -0
  15. package/dist/src/@types/DDO/Metadata.d.ts +126 -0
  16. package/dist/src/@types/DDO/Service.d.ts +124 -0
  17. package/dist/src/{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/{src/interfaces/Erc20Interface.d.ts → @types/Erc20.d.ts} +0 -0
  20. package/dist/src/@types/Erc721.d.ts +12 -0
  21. package/dist/src/@types/FileMetadata.d.ts +38 -0
  22. package/dist/src/{src/interfaces/FixedRateInterface.d.ts → @types/FixedPrice.d.ts} +1 -1
  23. package/dist/src/{src/interfaces/PoolInterface.d.ts → @types/Pool.d.ts} +4 -4
  24. package/dist/src/{src/@types → @types}/Provider.d.ts +3 -2
  25. package/dist/src/@types/Router.d.ts +59 -0
  26. package/dist/src/{src/@types → @types}/index.d.ts +6 -0
  27. package/dist/src/aquarius/Aquarius.d.ts +32 -0
  28. package/dist/src/{src/aquarius → aquarius}/index.d.ts +0 -0
  29. package/dist/src/factories/NFTFactory.d.ts +273 -0
  30. package/dist/src/{src/factories → factories}/index.d.ts +0 -0
  31. package/dist/src/{src/index.d.ts → index.d.ts} +0 -1
  32. package/dist/src/models/Config.d.ts +166 -0
  33. package/dist/src/{src/models → models}/index.d.ts +0 -0
  34. package/dist/src/pools/Router.d.ts +229 -0
  35. package/dist/src/pools/balancer/Pool.d.ts +365 -0
  36. package/dist/src/{src/pools → pools}/balancer/index.d.ts +0 -0
  37. package/dist/src/pools/dispenser/Dispenser.d.ts +146 -0
  38. package/dist/src/{src/pools → pools}/dispenser/index.d.ts +0 -0
  39. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +375 -0
  40. package/dist/src/{src/pools → pools}/fixedRate/index.d.ts +0 -0
  41. package/dist/src/{src/pools → pools}/index.d.ts +0 -0
  42. package/dist/src/pools/ssContracts/SideStaking.d.ts +132 -0
  43. package/dist/src/{src/pools → pools}/ssContracts/index.d.ts +0 -0
  44. package/dist/src/provider/Provider.d.ts +147 -0
  45. package/dist/src/{src/provider → provider}/index.d.ts +0 -0
  46. package/dist/src/tokens/Datatoken.d.ts +362 -0
  47. package/dist/src/tokens/NFT.d.ts +355 -0
  48. package/dist/src/{src/tokens → tokens}/index.d.ts +0 -0
  49. package/dist/src/{src/utils → utils}/ConfigHelper.d.ts +1 -1
  50. package/dist/src/{src/utils → utils}/Constants.d.ts +1 -0
  51. package/dist/src/utils/ContractUtils.d.ts +11 -0
  52. package/dist/src/{src/utils → utils}/ConversionTypeHelper.d.ts +0 -0
  53. package/dist/src/utils/DatatokenName.d.ts +11 -0
  54. package/dist/src/{src/utils → utils}/DdoHelpers.d.ts +0 -0
  55. package/dist/src/{src/utils → utils}/FetchHelper.d.ts +3 -2
  56. package/dist/src/utils/General.d.ts +4 -0
  57. package/dist/src/{src/utils → utils}/Logger.d.ts +0 -0
  58. package/dist/src/{src/utils → utils}/SignatureUtils.d.ts +0 -0
  59. package/dist/src/utils/TokenUtils.d.ts +39 -0
  60. package/dist/src/{src/utils → utils}/index.d.ts +3 -2
  61. package/dist/src/utils/minAbi.d.ts +2 -0
  62. package/dist/{src/test → test}/TestContractHandler.d.ts +0 -0
  63. package/dist/{src/test → test}/integration/ComputeFlow.test.d.ts +0 -0
  64. package/dist/{src/test → test}/integration/Provider.test.d.ts +0 -0
  65. package/dist/{src/test → test}/integration/PublishFlows.test.d.ts +0 -0
  66. package/dist/{src/test → test}/integration/SimplePublishConsumeFlow.test.d.ts +0 -0
  67. package/dist/{src/test → test}/integration/config.d.ts +0 -0
  68. package/dist/{src/test → test}/unit/NftFactory.test.d.ts +0 -0
  69. package/dist/{src/test → test}/unit/config.d.ts +0 -0
  70. package/dist/{src/test → test}/unit/pools/Router.test.d.ts +0 -0
  71. package/dist/{src/test → test}/unit/pools/balancer/Pool.test.d.ts +0 -0
  72. package/dist/{src/test → test}/unit/pools/dispenser/Dispenser.test.d.ts +0 -0
  73. package/dist/{src/test → test}/unit/pools/fixedRate/FixedRateExchange.test.d.ts +0 -0
  74. package/dist/{src/test → test}/unit/pools/ssContracts/SideStaking.test.d.ts +0 -0
  75. package/dist/{src/test → test}/unit/tokens/Datatoken.test.d.ts +0 -0
  76. package/dist/{src/test → test}/unit/tokens/Nft.test.d.ts +0 -0
  77. package/docs/beginners_guide.md +4 -4
  78. package/docs/overview.md +100 -9
  79. package/docs/quickstart_marketplace.md +34 -33
  80. package/docs/quickstart_simple.md +18 -16
  81. package/package.json +23 -22
  82. package/dist/src/src/@types/Asset.d.ts +0 -36
  83. package/dist/src/src/@types/DDO/DDO.d.ts +0 -15
  84. package/dist/src/src/@types/DDO/Event.d.ts +0 -7
  85. package/dist/src/src/@types/DDO/Metadata.d.ts +0 -38
  86. package/dist/src/src/@types/DDO/Service.d.ts +0 -28
  87. package/dist/src/src/@types/FileMetadata.d.ts +0 -8
  88. package/dist/src/src/aquarius/Aquarius.d.ts +0 -10
  89. package/dist/src/src/factories/NFTFactory.d.ts +0 -70
  90. package/dist/src/src/interfaces/RouterInterface.d.ts +0 -12
  91. package/dist/src/src/interfaces/index.d.ts +0 -5
  92. package/dist/src/src/models/Config.d.ts +0 -34
  93. package/dist/src/src/pools/Router.d.ts +0 -46
  94. package/dist/src/src/pools/balancer/Pool.d.ts +0 -73
  95. package/dist/src/src/pools/dispenser/Dispenser.d.ts +0 -37
  96. package/dist/src/src/pools/fixedRate/FixedRateExchange.d.ts +0 -95
  97. package/dist/src/src/pools/ssContracts/SideStaking.d.ts +0 -28
  98. package/dist/src/src/provider/Provider.d.ts +0 -31
  99. package/dist/src/src/tokens/Datatoken.d.ts +0 -77
  100. package/dist/src/src/tokens/NFT.d.ts +0 -57
  101. package/dist/src/src/utils/ContractParams.d.ts +0 -4
  102. package/dist/src/src/utils/DatatokenName.d.ts +0 -7
  103. package/dist/src/src/utils/GasUtils.d.ts +0 -2
@@ -0,0 +1,365 @@
1
+ import Web3 from 'web3';
2
+ import { AbiItem } from 'web3-utils/types';
3
+ import { TransactionReceipt } from 'web3-core';
4
+ import { Contract } from 'web3-eth-contract';
5
+ import { CurrentFees, TokenInOutMarket, AmountsInMaxFee, AmountsOutMaxFee } from '../../@types';
6
+ import { Config } from '../../models';
7
+ /**
8
+ * Provides an interface to Ocean friendly fork from Balancer BPool
9
+ */
10
+ export declare class Pool {
11
+ poolAbi: AbiItem | AbiItem[];
12
+ web3: Web3;
13
+ GASLIMIT_DEFAULT: number;
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
+ */
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
+ */
33
+ estSetSwapFee(account: string, poolAddress: string, fee: string, contractInstance?: Contract): Promise<number>;
34
+ /**
35
+ * Set pool fee
36
+ * @param {String} account
37
+ * @param {String} poolAddress
38
+ * @param {String} fee 0.1=10% fee(max allowed)
39
+ */
40
+ setSwapFee(account: string, poolAddress: string, fee: string): Promise<TransactionReceipt>;
41
+ /**
42
+ * Get number of tokens composing this pool
43
+ * @param {String} poolAddress
44
+ * @return {String}
45
+ */
46
+ getNumTokens(poolAddress: string): Promise<string>;
47
+ /**
48
+ * Get total supply of pool shares
49
+ * @param {String} poolAddress
50
+ * @return {String}
51
+ */
52
+ getPoolSharesTotalSupply(poolAddress: string): Promise<string>;
53
+ /**
54
+ * Get tokens composing this pool
55
+ * @param {String} poolAddress
56
+ * @return {String[]}
57
+ */
58
+ getCurrentTokens(poolAddress: string): Promise<string[]>;
59
+ /**
60
+ * Get the final tokens composing this pool
61
+ * @param {String} poolAddress
62
+ * @return {String[]}
63
+ */
64
+ getFinalTokens(poolAddress: string): Promise<string[]>;
65
+ /**
66
+ * Get controller address of this pool
67
+ * @param {String} poolAddress
68
+ * @return {String}
69
+ */
70
+ getController(poolAddress: string): Promise<string>;
71
+ /**
72
+ * Get baseToken address of this pool
73
+ * @param {String} poolAddress
74
+ * @return {String}
75
+ */
76
+ getBaseToken(poolAddress: string): Promise<string>;
77
+ /**
78
+ * Get datatoken address of this pool
79
+ * @param {String} poolAddress
80
+ * @return {String}
81
+ */
82
+ getDatatoken(poolAddress: string): Promise<string>;
83
+ /**
84
+ * Get marketFeeCollector of this pool
85
+ * @param {String} poolAddress
86
+ * @return {String}
87
+ */
88
+ getMarketFeeCollector(poolAddress: string): Promise<string>;
89
+ /**
90
+ * Get OPC Collector of this pool
91
+ * @param {String} poolAddress
92
+ * @return {String}
93
+ */
94
+ getOPCCollector(poolAddress: string): Promise<string>;
95
+ /**
96
+ * Get if a token is bounded to a pool
97
+ * @param {String} poolAddress
98
+ * @param {String} token Address of the token
99
+ * @return {Boolean}
100
+ */
101
+ isBound(poolAddress: string, token: string): Promise<boolean>;
102
+ /**
103
+ * Get how many tokens are in the pool
104
+ * @param {String} poolAddress
105
+ * @param {String} token Address of the token
106
+ * @return {String}
107
+ */
108
+ getReserve(poolAddress: string, token: string): Promise<string>;
109
+ /**
110
+ * Get if a pool is finalized
111
+ * @param {String} poolAddress
112
+ * @return {Boolean}
113
+ */
114
+ isFinalized(poolAddress: string): Promise<boolean>;
115
+ /**
116
+ * Get pool fee
117
+ * @param {String} poolAddress
118
+ * @return {String} Swap fee. To get the percentage value, substract by 100. E.g. `0.1` represents a 10% swap fee.
119
+ */
120
+ getSwapFee(poolAddress: string): Promise<string>;
121
+ /**
122
+ * The normalized weight of a token. The combined normalized weights of all tokens will sum up to 1. (Note: the actual sum may be 1 plus or minus a few wei due to division precision loss)
123
+ * @param {String} poolAddress
124
+ * @param {String} token
125
+ * @return {String}
126
+ */
127
+ getNormalizedWeight(poolAddress: string, token: string): Promise<string>;
128
+ /**
129
+ * getDenormalizedWeight of a token in pool
130
+ * @param {String} poolAddress
131
+ * @param {String} token
132
+ * @return {String}
133
+ */
134
+ getDenormalizedWeight(poolAddress: string, token: string): Promise<string>;
135
+ /**
136
+ * getTotalDenormalizedWeight in pool
137
+ * @param {String} poolAddress
138
+ * @return {String}
139
+ */
140
+ getTotalDenormalizedWeight(poolAddress: string): Promise<string>;
141
+ /**
142
+ * Get Market Fees available to be collected for a specific token
143
+ * @param {String} poolAddress
144
+ * @param {String} token token we want to check fees
145
+ * @return {String}
146
+ */
147
+ getMarketFees(poolAddress: string, token: string): Promise<string>;
148
+ /**
149
+ * Get Community Get the current amount of fees which can be withdrawned by the Market
150
+ * @return {CurrentFees}
151
+ */
152
+ getCurrentMarketFees(poolAddress: string): Promise<CurrentFees>;
153
+ /**
154
+ * Get getCurrentOPFFees Get the current amount of fees which can be withdrawned by OPF
155
+ * @return {CurrentFees}
156
+ */
157
+ getCurrentOPCFees(poolAddress: string): Promise<CurrentFees>;
158
+ /**
159
+ * Get Community Fees available to be collected for a specific token
160
+ * @param {String} poolAddress
161
+ * @param {String} token token we want to check fees
162
+ * @return {String}
163
+ */
164
+ getCommunityFees(poolAddress: string, token: string): Promise<string>;
165
+ /**
166
+ * Estimate gas cost for collectOPF
167
+ * @param {String} address
168
+ * @param {String} poolAddress
169
+ * @param {Contract} contractInstance optional contract instance
170
+ * @return {Promise<number>}
171
+ */
172
+ estCollectOPC(address: string, poolAddress: string, contractInstance?: Contract): Promise<number>;
173
+ /**
174
+ * collectOPF - collect opf fee - can be called by anyone
175
+ * @param {String} address
176
+ * @param {String} poolAddress
177
+ * @return {TransactionReceipt}
178
+ */
179
+ collectOPC(address: string, poolAddress: string): Promise<TransactionReceipt>;
180
+ /**
181
+ * Estimate gas cost for collectMarketFee
182
+ * @param {String} address
183
+ * @param {String} poolAddress
184
+ * @param {String} to address that will receive fees
185
+ * @param {Contract} contractInstance optional contract instance
186
+ * @return {Promise<number>}
187
+ */
188
+ estCollectMarketFee(address: string, poolAddress: string, contractInstance?: Contract): Promise<number>;
189
+ /**
190
+ * collectOPF - collect market fees - can be called by the publishMarketCollector
191
+ * @param {String} address
192
+ * @param {String} poolAddress
193
+ * @param {String} to address that will receive fees
194
+ * @return {TransactionReceipt}
195
+ */
196
+ collectMarketFee(address: string, poolAddress: string): Promise<TransactionReceipt>;
197
+ /**
198
+ * Estimate gas cost for updateMarketFeeCollector
199
+ * @param {String} address
200
+ * @param {String} poolAddress
201
+ * @param {String} newCollector new market fee collector address
202
+ * @param {Contract} contractInstance optional contract instance
203
+ * @return {Promise<number>}
204
+ */
205
+ estUpdateMarketFeeCollector(address: string, poolAddress: string, newCollector: string, contractInstance?: Contract): Promise<number>;
206
+ /**
207
+ * updateMarketFeeCollector - updates marketFeeCollector - can be called only by the marketFeeCollector
208
+ * @param {String} address
209
+ * @param {String} poolAddress
210
+ * @param {String} newCollector new market fee collector address
211
+ * @return {TransactionReceipt}
212
+ */
213
+ updateMarketFeeCollector(address: string, poolAddress: string, newCollector: string): Promise<TransactionReceipt>;
214
+ /**
215
+ * Estimate gas cost for swapExactAmountIn
216
+ * @param {String} address
217
+ * @param {String} poolAddress
218
+ * @param {TokenInOutMarket} tokenInOutMarket
219
+ * @param {AmountsInMaxFee} amountsInOutMaxFee
220
+ * @param {Contract} contractInstance optional contract instance
221
+ * @return {Promise<number>}
222
+ */
223
+ estSwapExactAmountIn(address: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsInMaxFee, contractInstance?: Contract): Promise<number>;
224
+ /**
225
+ * swapExactAmountIn - Trades an exact tokenAmountIn of tokenIn taken from the caller by the pool,
226
+ * in exchange for at least minAmountOut of tokenOut given to the caller from the pool, with a maximum marginal price of maxPrice.
227
+ * Returns (tokenAmountOut, spotPriceAfter), where tokenAmountOut is the amount of token that came out of the pool,
228
+ * and spotPriceAfter is the new marginal spot price, ie, the result of getSpotPrice after the call.
229
+ * (These values are what are limited by the arguments; you are guaranteed tokenAmountOut >= minAmountOut and spotPriceAfter <= maxPrice).
230
+ * @param {String} address
231
+ * @param {String} poolAddress
232
+ * @param {TokenInOutMarket} tokenInOutMarket
233
+ * @param {AmountsInMaxFee} amountsInOutMaxFee
234
+ * @return {TransactionReceipt}
235
+ */
236
+ swapExactAmountIn(address: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsInMaxFee): Promise<TransactionReceipt>;
237
+ /**
238
+ * Estimate gas cost for swapExactAmountOut
239
+ * @param {String} address
240
+ * @param {String} poolAddress
241
+ * @param {TokenInOutMarket} tokenInOutMarket
242
+ * @param {AmountsOutMaxFee} amountsInOutMaxFee
243
+ * @param {Contract} contractInstance optional contract instance
244
+ * @return {Promise<number>}
245
+ */
246
+ estSwapExactAmountOut(address: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsOutMaxFee, contractInstance?: Contract): Promise<number>;
247
+ /**
248
+ * swapExactAmountOut
249
+ * @param {String} account
250
+ * @param {String} poolAddress
251
+ * @param {TokenInOutMarket} tokenInOutMarket
252
+ * @param {AmountsOutMaxFee} amountsInOutMaxFee
253
+ * @return {TransactionReceipt}
254
+ */
255
+ swapExactAmountOut(account: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsOutMaxFee): Promise<TransactionReceipt>;
256
+ /**
257
+ * Estimate gas cost for swapExactAmountOut
258
+ * @param {String} address
259
+ * @param {String} poolAddress
260
+ * @param {String} poolAmountOut will be converted to wei
261
+ * @param {String[]} maxAmountsIn array holding maxAmount per each token, will be converted to wei
262
+ * @param {Contract} contractInstance optional contract instance
263
+ * @return {Promise<number>}
264
+ */
265
+ estJoinPool(address: string, poolAddress: string, poolAmountOut: string, maxAmountsIn: string[], contractInstance?: Contract): Promise<number>;
266
+ /**
267
+ * Join the pool, getting poolAmountOut pool tokens. This will pull some of each of the currently trading tokens in the pool, meaning you must have called approve for each token for this pool. These values are limited by the array of maxAmountsIn in the order of the pool tokens.
268
+ * @param {String} address
269
+ * @param {String} poolAddress
270
+ * @param {String} poolAmountOut will be converted to wei
271
+ * @param {String[]} maxAmountsIn array holding maxAmount per each token, will be converted to wei
272
+ * @return {TransactionReceipt}
273
+ */
274
+ joinPool(address: string, poolAddress: string, poolAmountOut: string, maxAmountsIn: string[]): Promise<TransactionReceipt>;
275
+ /**
276
+ * Estimate gas cost for exitPool
277
+ * @param {String} address
278
+ * @param {String} poolAddress
279
+ ``* @param {String} poolAmountIn will be converted to wei
280
+ * @param {String[]} minAmountsOut array holding minAmount per each token, will be converted to wei
281
+ * @param {Contract} contractInstance optional contract instance
282
+ * @return {Promise<number>}
283
+ */
284
+ estExitPool(address: string, poolAddress: string, poolAmountIn: string, minAmountsOut: string[], contractInstance?: Contract): Promise<number>;
285
+ /**
286
+ * Exit the pool, paying poolAmountIn pool tokens and getting some of each of the currently trading tokens in return. These values are limited by the array of minAmountsOut in the order of the pool tokens.
287
+ * @param {String} account
288
+ * @param {String} poolAddress
289
+ * @param {String} poolAmountIn will be converted to wei
290
+ * @param {String[]} minAmountsOut array holding minAmount per each token, will be converted to wei
291
+ * @return {TransactionReceipt}
292
+ */
293
+ exitPool(account: string, poolAddress: string, poolAmountIn: string, minAmountsOut: string[]): Promise<TransactionReceipt>;
294
+ /**
295
+ * Estimate gas cost for joinswapExternAmountIn
296
+ * @param {String} address
297
+ * @param {String} poolAddress
298
+ * @param {String} tokenIn
299
+ * @param {String} tokenAmountIn will be converted to wei
300
+ * @param {String} minPoolAmountOut will be converted to wei
301
+ * @param {Contract} contractInstance optional contract instance
302
+ * @return {Promise<number>}
303
+ */
304
+ estJoinswapExternAmountIn(address: string, poolAddress: string, tokenAmountIn: string, minPoolAmountOut: string, contractInstance?: Contract): Promise<number>;
305
+ /**
306
+ * Pay tokenAmountIn of baseToken to join the pool, getting poolAmountOut of the pool shares.
307
+ * @param {String} account
308
+ * @param {String} poolAddress
309
+ * @param {String} tokenIn
310
+ * @param {String} tokenAmountIn will be converted to wei
311
+ * @param {String} minPoolAmountOut will be converted to wei
312
+ * @return {TransactionReceipt}
313
+ */
314
+ joinswapExternAmountIn(account: string, poolAddress: string, tokenAmountIn: string, minPoolAmountOut: string): Promise<TransactionReceipt>;
315
+ /**
316
+ * Estimate gas cost for joinswapExternAmountIn
317
+ * @param {String} address
318
+ @param {String} poolAddress
319
+ * @param {String} poolAmountIn will be converted to wei
320
+ * @param {String} minTokenAmountOut will be converted to wei
321
+ * @param {Contract} contractInstance optional contract instance
322
+ * @return {Promise<number>}
323
+ */
324
+ estExitswapPoolAmountIn(address: string, poolAddress: string, poolAmountIn: string, minTokenAmountOut: string, contractInstance?: Contract): Promise<number>;
325
+ /**
326
+ * Pay poolAmountIn pool shares into the pool, getting minTokenAmountOut of the baseToken
327
+ * @param {String} account
328
+ * @param {String} poolAddress
329
+ * @param {String} tokenOut
330
+ * @param {String} poolAmountIn will be converted to wei
331
+ * @param {String} minTokenAmountOut will be converted to wei
332
+ * @return {TransactionReceipt}
333
+ */
334
+ exitswapPoolAmountIn(account: string, poolAddress: string, poolAmountIn: string, minTokenAmountOut: string): Promise<TransactionReceipt>;
335
+ /**
336
+ * Get Spot Price of swaping tokenIn to tokenOut
337
+ * @param {String} poolAddress
338
+ * @param {String} tokenIn
339
+ * @param {String} tokenOut
340
+ * @param {String} swapMarketFe
341
+ * @return {String}
342
+ */
343
+ getSpotPrice(poolAddress: string, tokenIn: string, tokenOut: string, swapMarketFee: string): Promise<string>;
344
+ getAmountInExactOut(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountOut: string, swapMarketFee: string): Promise<string>;
345
+ getAmountOutExactIn(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountIn: string, swapMarketFee: string): Promise<string>;
346
+ calcPoolOutGivenSingleIn(poolAddress: string, tokenIn: string, tokenAmountIn: string): Promise<string>;
347
+ calcSingleInGivenPoolOut(poolAddress: string, tokenIn: string, poolAmountOut: string): Promise<string>;
348
+ calcSingleOutGivenPoolIn(poolAddress: string, tokenOut: string, poolAmountIn: string): Promise<string>;
349
+ calcPoolInGivenSingleOut(poolAddress: string, tokenOut: string, tokenAmountOut: string): Promise<string>;
350
+ /**
351
+ * Get LOG_SWAP encoded topic
352
+ * @return {String}
353
+ */
354
+ getSwapEventSignature(): string;
355
+ /**
356
+ * Get LOG_JOIN encoded topic
357
+ * @return {String}
358
+ */
359
+ getJoinEventSignature(): string;
360
+ /**
361
+ * Get LOG_EXIT encoded topic
362
+ * @return {String}
363
+ */
364
+ getExitEventSignature(): string;
365
+ }
@@ -0,0 +1,146 @@
1
+ import Web3 from 'web3';
2
+ import { AbiItem } from 'web3-utils';
3
+ import { Contract } from 'web3-eth-contract';
4
+ import { TransactionReceipt } from 'web3-eth';
5
+ import { Datatoken } from '../../tokens';
6
+ import { Config } from '../../models/index.js';
7
+ export interface DispenserToken {
8
+ active: boolean;
9
+ owner: string;
10
+ maxTokens: string;
11
+ maxBalance: string;
12
+ balance: string;
13
+ isMinter: boolean;
14
+ allowedSwapper: string;
15
+ }
16
+ export declare class Dispenser {
17
+ GASLIMIT_DEFAULT: number;
18
+ web3: Web3;
19
+ dispenserAddress: string;
20
+ config: Config;
21
+ dispenserAbi: AbiItem | AbiItem[];
22
+ dispenserContract: Contract;
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
137
+ ownerWithdraw(dtAddress: string, address: string): Promise<TransactionReceipt>;
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>;
146
+ }