1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
//! Defines the pool structs and their methods.
//!
//! # Pools
//!
//! NB: Many Pool operations are done via the [`Vault`](crate::vault)!.
//!
//! # Basic Usage
//!
//! ## Create Weighted Pool instance
//! ```rust
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//!
//! const RPC_URL: &str = "https://rpc.flashbots.net/";
//! const POOL_ADDRESS: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let transport = ethcontract::web3::transports::Http::new(RPC_URL).unwrap();
//! let web3 = ethcontract::Web3::new(transport);
//!
//! let pool_instance = WeightedPool::new(web3, addr!(POOL_ADDRESS));
//! ```
//!
//! ## Domain specific structs, enums, macros
//! Some of the examples below use "helper" structs, enums, macros, etc. from this crate taken from the Balancer domain.
//! Here are a few for easy reference:
//!
//! - [`addr!` macro](crate::addr)
//! - [`swap_fee!` macro](crate::swap_fee)
//! - [`pool_id!` macro](crate::pool_id)
//! - [`UserData`](crate::UserData)
//!
//!
//! ## Examples
//! ## Pools Methods - Base Pool
//! [See Balancer's Pool API documentation](https://dev.balancer.fi/references/contracts/apis/pools)
//!
//! Since all pools share a base API, we can use the Weighted Pool for the examples below
//!
//! #### get_vault()
//! [See interface](struct.WeightedPool.html#method.get_vault)
//!
//! Returns pool's Vault.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools#getvault)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let vault_address = pool_instance.get_vault()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_pool_id()
//! [See interface](struct.WeightedPool.html#method.get_pool_id)
//!
//! Returns pool's poolId.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools#getpoolid)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let vault_address = pool_instance.get_pool_id()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_swap_fee_percentage()
//! [See interface](struct.WeightedPool.html#method.get_swap_fee_percentage)
//!
//! Returns the pool's current swap fee.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools#getSwapFeePercentage)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let vault_address = pool_instance.get_swap_fee_percentage()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### set_swap_fee_percentage()
//! [See interface](struct.WeightedPool.html#method.set_swap_fee_percentage)
//!
//! Returns the pool's current swap fee.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools#setSwapFeePercentage)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let vault_address = pool_instance.set_swap_fee_percentage(
//! swap_fee!(0.10).into()
//! )
//! .send()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_normalized_weights()
//! [See interface](struct.WeightedPool.html#method.get_normalized_weights)
//!
//! Returns the pool's token weights.
//!
//! [See Balancer documentation](https://dev.balancer.fi/resources/pool-interfacing/weighted-pool#getting-pool-data)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let weights: Vec<U256> = pool_instance.get_normalized_weights()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### set_paused()
//! [See interface](struct.WeightedPool.html#method.set_paused)
//!
//! Pauses trading within the pool. Users can exit their positions proportionally.
//!
//! Note: This can only be called by an authorized account and is intended to be used only as an emergency stop if something goes wrong.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools#setpaused)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let vault_address = pool_instance.set_paused(true)
//! .send()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### on_swap()
//! [See interface](struct.WeightedPool.html#method.on_swap)
//!
//! When the Vault is handling a swap, it will call onSwap to ask the pool what the amounts should be. Pools that use weighted math only need the input/output tokens to determine price.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool#onswap)
//!
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool::new(web3, addr!(pool_address));
//! let swap_request = SwapRequest {
//! kind: SwapKind::GivenIn,
//! token_in: addr!("0x0"),
//! token_out: addr!("0x0"),
//! amount: u256!(0),
//! pool_id: pool_id!("0x0"),
//! last_change_block: u256!(12),
//! from: addr!("0x0"),
//! to: addr!("0x0"),
//! user_data: UserData("0x")
//! };
//! let balance_token_in = u256!(123);
//! let balance_token_out = u256!(123);
//!
//! let amount_out = pool_instance
//! .on_swap(
//! swap_request.into(),
//! balance_token_in,
//! balance_token_out,
//! )
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! ## Pools Methods - Weighted2PoolTokens
//! [See Balancer's Pool API documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokens)
//!
//! ### on_swap()
//! See Base Pool Methods above
//!
//! #### enable_oracle()
//! [See interface](struct.WeightedPool2Tokens.html#method.enable_oracle)
//!
//! Enables the oracle functionality.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokensenableoracle)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool2Tokens;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool2Tokens::new(web3, addr!(pool_address));
//!
//! pool_instance.enable_oracle()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_misc_data()
//! [See interface](struct.WeightedPool2Tokens.html#method.get_misc_data)
//!
//! Returns a variety of data fields:
//!
//! ```solidity
//! getMiscData()
//! returns (
//! int256 logInvariant,
//! int256 logTotalSupply,
//! uint256 oracleSampleCreationTimestamp,
//! uint256 oracleIndex,
//! bool oracleEnabled,
//! uint256 swapFeePercentage)
//! ```
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokensgetMiscData)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool2Tokens;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool2Tokens::new(web3, addr!(pool_address));
//!
//! let misc_data = pool_instance.get_misc_data()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_largest_safe_query_window()
//! [See interface](struct.WeightedPool2Tokens.html#method.get_largest_safe_query_window)
//!
//! Returns largest safe query window.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokensgetLargestSafeQueryWindow)
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool2Tokens;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool2Tokens::new(web3, addr!(pool_address));
//!
//! let misc_data = pool_instance.get_largest_safe_query_window()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_latest()
//! [See interface](struct.WeightedPool2Tokens.html#method.get_latest)
//!
//! Returns latest pair price, BPT price, or invariant depending on what variable enum you pass. Samples are recorded by the pool as calculated with the pre-operation balances. For example, the spot price before a swap is the value stored as the most recent PAIR_PRICE.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokens#getlatest)
//!
//! Uses [`Variable`](crate::Variable) enum
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool2Tokens;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool2Tokens::new(web3, addr!(pool_address));
//!
//! let misc_data = pool_instance.get_latest(Variable::PairPrice as u8)
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_time_weighted_average()
//! [See interface](struct.WeightedPool2Tokens.html#method.get_time_weighted_average)
//!
//! Returns time weighted average prices corresponding to the variables in each query. secs is the duration of the query in seconds, and ago is the time in seconds from since end of that duration. Prices are represented as 18 decimal fixed point values.
//! > **Note**
//! > Note that you can only call get_time_weighted_average after the buffer is full, or it will revert with ORACLE_NOT_INITIALIZED. If you call get_sample(1023) and it returns 0's, that means the buffer's not full yet.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokens#getTimeWeightedAverage)
//!
//! Uses [`Variable`](crate::Variable) enum
//! Uses [`OracleAverageQuery`](crate::OracleAverageQuery) struct
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool2Tokens;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool2Tokens::new(web3, addr!(pool_address));
//! let query = OracleAverageQuery {
//! variable: Variable::PairPrice,
//! secs: u256!(10000),
//! ago: u256!(1234),
//! };
//!
//! let misc_data = pool_instance.get_time_weighted_average(vec![query.into()])
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_past_accumulators()
//! [See interface](struct.WeightedPool2Tokens.html#method.get_past_accumulators)
//!
//! Returns estimates for the accumulator at a time ago seconds ago for each query.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/weightedpool2tokens#getPastAccumulators)
//!
//! Uses [`Variable`](crate::Variable) enum
//! Uses [`OracleAccumulatorQuery`](crate::OracleAccumulatorQuery) struct
//!
//! ```no_run
//! use balancer_sdk::pools::WeightedPool2Tokens;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x01abc00e86c7e258823b9a055fd62ca6cf61a163";
//! let pool_instance = WeightedPool2Tokens::new(web3, addr!(pool_address));
//! let query = OracleAccumulatorQuery {
//! variable: Variable::PairPrice,
//! ago: u256!(1234),
//! };
//!
//! let misc_data = pool_instance.get_past_accumulators(vec![query.into()])
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! ## Pools Methods - LiquidityBootstrappingPool
//! [See Balancer's Pool API documentation](https://dev.balancer.fi/references/contracts/apis/pools/LiquidityBootstrappingPool)
//!
//! ### on_swap()
//! See Base Pool Methods above
//!
//! #### get_swap_enabled()
//! [See interface](struct.LiquidityBootstrappingPool.html#method.get_swap_enabled)
//!
//! Returns True if the pool has swaps enabled.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/LiquidityBootstrappingPool#getswapenabled)
//!
//! ```no_run
//! use balancer_sdk::pools::LiquidityBootstrappingPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = LiquidityBootstrappingPool::new(web3, addr!(pool_address));
//!
//! pool_instance.get_swap_enabled()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_gradual_weight_update_params()
//! [See interface](struct.LiquidityBootstrappingPool.html#method.get_gradual_weight_update_params)
//!
//! Return start time, end time, and endWeights as an array. Current weights should be retrieved via [get_normalized_weights](struct.WeightedPool.html#method.get_normalized_weights).
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/LiquidityBootstrappingPool#getGradualWeightUpdateParams)
//!
//! ```no_run
//! use balancer_sdk::pools::LiquidityBootstrappingPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = LiquidityBootstrappingPool::new(web3, addr!(pool_address));
//!
//! let (start_time, end_time, end_weights) = pool_instance
//! .get_gradual_weight_update_params()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//!
//! ### Permissioned Functions
//! All of the following functions are only callable by the pool owner.
//!
//! #### set_swap_enabled()
//! [See interface](struct.LiquidityBootstrappingPool.html#method.set_swap_enabled)
//!
//! Enables swaps if passed True, disables them if passed False.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/LiquidityBootstrappingPool#setSwapEnabled)
//!
//! ```no_run
//! use balancer_sdk::pools::LiquidityBootstrappingPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = LiquidityBootstrappingPool::new(web3, addr!(pool_address));
//!
//! pool_instance
//! .set_swap_enabled(true)
//! .send()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### update_weights_gradually()
//! [See interface](struct.LiquidityBootstrappingPool.html#method.update_weights_gradually)
//!
//! Schedule a gradual weight change, from the current weights to the given endWeights, from startTime to endTime.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/LiquidityBootstrappingPool#updateWeightsGradually)
//!
//! ```no_run
//! use balancer_sdk::pools::LiquidityBootstrappingPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = LiquidityBootstrappingPool::new(web3, addr!(pool_address));
//! let start_time = u256!(0);
//! let end_time = u256!(1);
//! let end_weights = vec![u256!(0.1), u256!(0.1), u256!(0.8)];
//!
//! pool_instance.update_weights_gradually(start_time, end_time, end_weights)
//! .send()
//! .await
//! .unwrap();
//! # });
//! ```
//! ## Pools Methods - ManagedPools (prev. "InvestmentPools")
//! [See Balancer's ManagedPools API documentation](https://dev.balancer.fi/references/contracts/apis/pools/investmentpools)
//!
//! See pool methods above for examples for the following methods:
//! - on_swap()
//! - get_swap_enabled()
//! - get_gradual_weight_update_param()
//!
//! #### get_management_swap_fee_percentage()
//! [See interface](struct.ManagedPool.html#method.get_management_swap_fee_percentage)
//!
//! Returns the management swap fee percentage with 18 decimals.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/investmentpools#getmanagementswapfeepercentage)
//!
//! ```no_run
//! use balancer_sdk::pools::ManagedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = ManagedPool::new(web3, addr!(pool_address));
//!
//! let percentage: U256 = pool_instance.get_management_swap_fee_percentage()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_minimum_weight_change_duration()
//! [See interface](struct.ManagedPool.html#method.get_minimum_weight_change_duration)
//!
//! Returns the minimum duration of a gradual weight change.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/investmentpools#getMinimumWeightChangeDuration)
//!
//! ```no_run
//! use balancer_sdk::pools::ManagedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = ManagedPool::new(web3, addr!(pool_address));
//!
//! let duration: U256 = pool_instance.get_minimum_weight_change_duration()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//!
//! #### get_collected_management_fees()
//! [See interface](struct.ManagedPool.html#method.get_collected_management_fees)
//!
//! Returns the amount of management fees collected
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/investmentpools#getCollectedManagementFees)
//!
//! ```no_run
//! use balancer_sdk::pools::ManagedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = ManagedPool::new(web3, addr!(pool_address));
//!
//! let (tokens, collected_fees): (Vec<IERC20>, Vec<U256>) = pool_instance.get_collected_management_fees()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//!
//! ### Permissioned Functions
//! All of the following functions are only callable by the pool owner.
//!
//! See pool methods above for examples for the following methods:
//! - set_swap_enabled()
//! - update_weights_gradually()
//!
//! #### withdraw_collected_management_fees()
//! [See interface](struct.ManagedPool.html#method.withdraw_collected_management_fees)
//!
//! Withdraw the collected management fees.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/investmentpools#withdrawCollectedManagementFees)
//!
//! ```no_run
//! use balancer_sdk::pools::ManagedPool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = ManagedPool::new(web3, addr!(pool_address));
//! let recipient = addr!("0x0");
//!
//! pool_instance
//! .withdraw_collected_management_fees(recipient)
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//!
//! ## Pool Methods - StablePools
//! [See Balancer's StablePools API documentation](https://dev.balancer.fi/references/contracts/apis/pools/stablepools)
//!
//! See pool methods above for examples for the following methods:
//! - on_swap()
//!
//! #### get_amplification_parameter()
//! [See interface](struct.StablePool.html#method.get_amplification_parameter)
//!
//! Returns the amplification parameter value, a boolean to determine if it's updating, and its precision.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/stablepools#getamplificationparameter)
//!
//! ```no_run
//! use balancer_sdk::pools::StablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = StablePool::new(web3, addr!(pool_address));
//!
//! let (value, is_updating, precision): (U256, bool, U256) = pool_instance.get_amplification_parameter()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! ### Permissioned Functions
//! All of the following functions are only callable by the pool owner.
//!
//! #### start_amplification_parameter_update(raw_end_value: U256, end_time: U256)
//! [See interface](struct.StablePool.html#method.start_amplification_parameter_update)
//!
//! Begins changing the amplification parameter to `raw_end_value` over time. The value will change linearly until `end_time` is reached, when it will be `raw_end_value`.
//!
//! > **Note**
//! > Internally, the amplification parameter is represented using higher precision. The values returned by get_amplification_parameter have to be corrected to account for this when comparing to `raw_end_value`.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/stablepools#startAmplificationParameterUpdate)
//!
//! ```no_run
//! use balancer_sdk::pools::StablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = StablePool::new(web3, addr!(pool_address));
//!
//! let raw_end_value: U256 = u256!(0);
//! let end_time: U256 = u256!(1234);
//!
//! pool_instance
//! .start_amplification_parameter_update(raw_end_value, end_time)
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### stop_amplification_parameter_update
//! [See interface](struct.StablePool.html#method.stop_amplification_parameter_update)
//!
//! Stops the amplification parameter change process, keeping the current value.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/stablepools#stopAmplificationParameterUpdate)
//!
//! ```no_run
//! use balancer_sdk::pools::StablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = StablePool::new(web3, addr!(pool_address));
//!
//! pool_instance
//! .stop_amplification_parameter_update()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//!
//! ## Pool Methods - MetaStablePools
//! [See Balancer's StablePools API documentation](https://dev.balancer.fi/references/contracts/apis/pools/metastablepools)
//!
//! See pool methods above for examples for the following methods:
//! - on_swap()
//! - get_amplification_parameter()
//! - enable_oracle()
//! - get_misc_data()
//! - get_largest_safe_query_window()
//! - get_latest()
//! - get_time_weighted_average()
//! - get_past_accumulators()
//!
//! #### get_rate_providers()
//! [See interface](struct.MetaStablePool.html#method.get_rate_providers)
//!
//! Returns rate providers that provide exchange rates between the tokens
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/metastablepools#getrateproviders)
//!
//! ```no_run
//! use balancer_sdk::pools::MetaStablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = MetaStablePool::new(web3, addr!(pool_address));
//!
//! let providers: Vec<Address> = pool_instance.get_rate_providers()
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### get_price_rate_cache()
//! [See interface](struct.MetaStablePool.html#method.get_price_rate_cache)
//!
//! Returned the cached rate, the cache duration, and the time of expiry for the current rate.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/metastablepools#getPriceRateCache)
//!
//! ```no_run
//! use balancer_sdk::pools::MetaStablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = MetaStablePool::new(web3, addr!(pool_address));
//! let token_address: IERC20 = addr!("0x0");
//!
//! let (rate, duration, expires): (U256, U256, U256) = pool_instance
//! .get_price_rate_cache(token_address)
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//! #### update_price_rate_cache()
//! [See interface](struct.MetaStablePool.html#method.update_price_rate_cache)
//!
//! Updates the cached price rate for the given token.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/metastablepools#updatePriceRateCache)
//!
//! ```no_run
//! use balancer_sdk::pools::MetaStablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = MetaStablePool::new(web3, addr!(pool_address));
//!
//! let token_address: IERC20 = addr!("0x0");
//!
//! pool_instance
//! .update_price_rate_cache(token_address)
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
//!
//!
//! ### Permissioned Functions
//! All of the following functions are only callable by the pool owner.
//!
//! See pool methods above for examples for the following methods:
//! - start_amplification_parameter_update()
//! - stop_amplification_parameter_update()
//!
//! #### set_price_rate_cache_duration()
//! [See interface](struct.MetaStablePool.html#method.set_price_rate_cache_duration)
//!
//! Sets the given `token`'s price rate cache duration to duration.
//!
//! [See Balancer documentation](https://dev.balancer.fi/references/contracts/apis/pools/metastablepools#setPriceRateCacheDuration)
//!
//! ```no_run
//! use balancer_sdk::pools::MetaStablePool;
//! use balancer_sdk::*;
//! # use balancer_sdk::helpers::*;
//!
//! # tokio_test::block_on(async {
//! # let web3 = build_web3(&get_env_var("RPC_URL"));
//! let pool_address: &str = "0x0";
//! let pool_instance = MetaStablePool::new(web3, addr!(pool_address));
//!
//! let token_address: IERC20 = addr!("0x0");
//! let duration: U256 = u256!("0");
//!
//! pool_instance
//! .set_price_rate_cache_duration(token_address, duration)
//! .call()
//! .await
//! .unwrap();
//! # });
//! ```
pub use crate*;
pub use LiquidityBootstrappingPool;
pub use ManagedPool;
pub use MetaStablePool;
pub use StablePool;
pub use WeightedPool;
pub use WeightedPool2Tokens;
use Address;
define_contract!;
define_contract!;
define_contract!;
define_contract!;
define_contract!;
define_contract!;