@@ -93,7 +93,7 @@ pub mod pallet {
93
93
use crate :: {
94
94
curves:: { balance_to_fixed, fixed_to_balance, BondingFunction , Curve , CurveInput } ,
95
95
traits:: { FreezeAccounts , NextAssetIds , ResetTeam } ,
96
- types:: { Locks , PoolDetails , PoolManagingTeam , PoolStatus , Round , TokenMeta } ,
96
+ types:: { CurrencySettings , Locks , PoolDetails , PoolManagingTeam , PoolStatus , Round , TokenMeta } ,
97
97
WeightInfo ,
98
98
} ;
99
99
@@ -131,6 +131,7 @@ pub mod pallet {
131
131
BoundedCurrencyVec < T > ,
132
132
CollateralAssetIdOf < T > ,
133
133
DepositBalanceOf < T > ,
134
+ CurrencySettings ,
134
135
> ;
135
136
136
137
/// Minimum required amount of integer and fractional bits to perform ln,
@@ -367,13 +368,17 @@ pub mod pallet {
367
368
curve : CurveInput < CurveParameterInputOf < T > > ,
368
369
collateral_id : CollateralAssetIdOf < T > ,
369
370
currencies : BoundedVec < TokenMetaOf < T > , T :: MaxCurrenciesPerPool > ,
370
- denomination : u8 ,
371
- transferable : bool ,
372
- enable_asset_management : bool ,
373
- min_operation_balance : u128 ,
371
+ currency_settings : CurrencySettings ,
374
372
) -> DispatchResult {
375
373
let who = T :: PoolCreateOrigin :: ensure_origin ( origin) ?;
376
374
375
+ let CurrencySettings {
376
+ denomination,
377
+ transferable,
378
+ enable_asset_management,
379
+ min_operation_balance,
380
+ } = currency_settings;
381
+
377
382
ensure ! ( denomination <= T :: MaxDenomination :: get( ) , Error :: <T >:: InvalidInput ) ;
378
383
let checked_curve = curve. try_into ( ) . map_err ( |_| Error :: < T > :: InvalidInput ) ?;
379
384
@@ -501,7 +506,7 @@ pub mod pallet {
501
506
ensure ! ( number_of_currencies <= currency_count, Error :: <T >:: CurrencyCount ) ;
502
507
503
508
ensure ! (
504
- pool_details. enable_asset_management && pool_details. is_manager( & who) ,
509
+ pool_details. currency_settings . enable_asset_management && pool_details. is_manager( & who) ,
505
510
Error :: <T >:: NoPermission
506
511
) ;
507
512
ensure ! ( pool_details. state. is_live( ) , Error :: <T >:: PoolNotLive ) ;
@@ -709,7 +714,7 @@ pub mod pallet {
709
714
ensure ! ( number_of_currencies <= currency_count, Error :: <T >:: CurrencyCount ) ;
710
715
711
716
ensure ! (
712
- amount_to_mint >= pool_details. min_operation_balance. saturated_into( ) ,
717
+ amount_to_mint >= pool_details. currency_settings . min_operation_balance. saturated_into( ) ,
713
718
TokenError :: BelowMinimum
714
719
) ;
715
720
@@ -729,14 +734,14 @@ pub mod pallet {
729
734
730
735
let ( active_pre, passive) = Self :: calculate_normalized_passive_issuance (
731
736
& bonded_currencies,
732
- pool_details. denomination ,
737
+ pool_details. currency_settings . denomination ,
733
738
currency_idx,
734
739
round_kind,
735
740
) ?;
736
741
737
742
let normalized_amount_to_mint = balance_to_fixed (
738
743
amount_to_mint. saturated_into :: < u128 > ( ) ,
739
- pool_details. denomination ,
744
+ pool_details. currency_settings . denomination ,
740
745
round_kind,
741
746
) ?;
742
747
@@ -769,7 +774,7 @@ pub mod pallet {
769
774
770
775
T :: Fungibles :: mint_into ( target_currency_id. clone ( ) , & beneficiary, amount_to_mint) ?;
771
776
772
- if !pool_details. transferable {
777
+ if !pool_details. currency_settings . transferable {
773
778
T :: Fungibles :: freeze ( target_currency_id, & beneficiary) . map_err ( |freeze_error| {
774
779
log:: info!( target: LOG_TARGET , "Failed to freeze account: {:?}" , freeze_error) ;
775
780
freeze_error. into ( )
@@ -838,7 +843,7 @@ pub mod pallet {
838
843
let pool_details = Pools :: < T > :: get ( & pool_id) . ok_or ( Error :: < T > :: PoolUnknown ) ?;
839
844
840
845
ensure ! (
841
- amount_to_burn >= pool_details. min_operation_balance. saturated_into( ) ,
846
+ amount_to_burn >= pool_details. currency_settings . min_operation_balance. saturated_into( ) ,
842
847
TokenError :: BelowMinimum
843
848
) ;
844
849
@@ -859,12 +864,13 @@ pub mod pallet {
859
864
860
865
let ( high, passive) = Self :: calculate_normalized_passive_issuance (
861
866
& bonded_currencies,
862
- pool_details. denomination ,
867
+ pool_details. currency_settings . denomination ,
863
868
currency_idx,
864
869
round_kind,
865
870
) ?;
866
871
867
- let normalized_amount_to_burn = balance_to_fixed ( amount_to_burn, pool_details. denomination , round_kind) ?;
872
+ let normalized_amount_to_burn =
873
+ balance_to_fixed ( amount_to_burn, pool_details. currency_settings . denomination , round_kind) ?;
868
874
869
875
let low = high
870
876
. checked_sub ( normalized_amount_to_burn)
@@ -910,7 +916,7 @@ pub mod pallet {
910
916
911
917
let account_exists = T :: Fungibles :: total_balance ( target_currency_id. clone ( ) , & who) > Zero :: zero ( ) ;
912
918
913
- if !pool_details. transferable && account_exists {
919
+ if !pool_details. currency_settings . transferable && account_exists {
914
920
// Restore locks.
915
921
T :: Fungibles :: freeze ( target_currency_id, & who) . map_err ( |freeze_error| {
916
922
log:: info!( target: LOG_TARGET , "Failed to freeze account: {:?}" , freeze_error) ;
0 commit comments