From 086bca38521ce3269c837a44c1e6ba408e2b8a16 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 19 Sep 2024 12:28:00 +0200 Subject: [PATCH] otm_funding_tests --- Cargo.lock | 1 + .../funding/src/instantiator/calculations.rs | 13 +- pallets/funding/src/instantiator/tests.rs | 28 ++--- pallets/funding/src/mock.rs | 26 ++-- pallets/funding/src/tests/2_evaluation.rs | 2 +- pallets/funding/src/tests/3_auction.rs | 29 +++-- pallets/funding/src/tests/4_contribution.rs | 114 +++++++++++++++++- pallets/funding/src/tests/6_settlement.rs | 2 +- pallets/funding/src/tests/misc.rs | 20 +-- pallets/funding/src/tests/mod.rs | 4 +- pallets/funding/src/tests/runtime_api.rs | 4 +- pallets/proxy-bonding/Cargo.toml | 1 + 12 files changed, 185 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa0bafbe8..a17c304ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7772,6 +7772,7 @@ dependencies = [ "polimec-common", "scale-info", "serde", + "sp-core", "sp-io", "sp-runtime", ] diff --git a/pallets/funding/src/instantiator/calculations.rs b/pallets/funding/src/instantiator/calculations.rs index 47ce3415a..70c888564 100644 --- a/pallets/funding/src/instantiator/calculations.rs +++ b/pallets/funding/src/instantiator/calculations.rs @@ -15,6 +15,10 @@ impl< T::ExistentialDeposit::get() } + pub fn get_funding_asset_ed(&mut self, asset_id: AssetIdOf) -> Balance { + self.execute(|| T::FundingCurrency::minimum_balance(asset_id)) + } + pub fn get_ct_account_deposit(&self) -> Balance { ::ContributionTokenCurrency::deposit_required(One::one()) } @@ -433,7 +437,14 @@ impl< .unwrap() }); let usd_ticket_size = token_usd_price.saturating_mul_int(cont.amount); - let funding_asset_spent = funding_asset_usd_price.reciprocal().unwrap().saturating_mul_int(usd_ticket_size); + let mut funding_asset_spent = + funding_asset_usd_price.reciprocal().unwrap().saturating_mul_int(usd_ticket_size); + if cont.mode == ParticipationMode::OTM { + let multiplier: MultiplierOf = cont.mode.multiplier().try_into().ok().unwrap(); + let plmc_bond = multiplier.calculate_bonding_requirement::(usd_ticket_size).unwrap(); + let otm_fee = >::calculate_fee(plmc_bond, funding_asset_id).unwrap(); + funding_asset_spent += otm_fee; + } output.push(UserToFundingAsset::new(cont.contributor, funding_asset_spent, cont.asset.id())); } output diff --git a/pallets/funding/src/instantiator/tests.rs b/pallets/funding/src/instantiator/tests.rs index 91bd80edd..51a88b987 100644 --- a/pallets/funding/src/instantiator/tests.rs +++ b/pallets/funding/src/instantiator/tests.rs @@ -16,12 +16,12 @@ use sp_arithmetic::Percent; fn dry_run_wap() { let mut inst = tests::MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - const ADAM: u32 = 60; - const TOM: u32 = 61; - const SOFIA: u32 = 62; - const FRED: u32 = 63; - const ANNA: u32 = 64; - const DAMIAN: u32 = 65; + const ADAM: AccountIdOf = 60; + const TOM: AccountIdOf = 61; + const SOFIA: AccountIdOf = 62; + const FRED: AccountIdOf = 63; + const ANNA: AccountIdOf = 64; + const DAMIAN: AccountIdOf = 65; let accounts = vec![ADAM, TOM, SOFIA, FRED, ANNA, DAMIAN]; @@ -50,7 +50,7 @@ fn dry_run_wap() { phantom: Default::default(), }, participation_currencies: vec![AcceptedFundingAsset::USDT].try_into().unwrap(), - funding_destination_account: 0u32, + funding_destination_account: 0, policy_ipfs_cid: Some(metadata_hash), }; @@ -98,12 +98,12 @@ fn dry_run_wap() { fn find_bucket_for_wap() { let mut inst = tests::MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - const ADAM: u32 = 60; - const TOM: u32 = 61; - const SOFIA: u32 = 62; - const FRED: u32 = 63; - const ANNA: u32 = 64; - const DAMIAN: u32 = 65; + const ADAM: AccountIdOf = 60; + const TOM: AccountIdOf = 61; + const SOFIA: AccountIdOf = 62; + const FRED: AccountIdOf = 63; + const ANNA: AccountIdOf = 64; + const DAMIAN: AccountIdOf = 65; let accounts = vec![ADAM, TOM, SOFIA, FRED, ANNA, DAMIAN]; @@ -132,7 +132,7 @@ fn find_bucket_for_wap() { phantom: Default::default(), }, participation_currencies: vec![AcceptedFundingAsset::USDT].try_into().unwrap(), - funding_destination_account: 0u32, + funding_destination_account: 0, policy_ipfs_cid: Some(metadata_hash), }; diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 646e09728..d7346a409 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -53,7 +53,7 @@ pub const MILLI_PLMC: Balance = PLMC / 10u128.pow(3); pub const MICRO_PLMC: Balance = PLMC / 10u128.pow(6); pub const EXISTENTIAL_DEPOSIT: Balance = 10 * MILLI_PLMC; pub type Block = frame_system::mocking::MockBlock; -pub type AccountId = u32; +pub type AccountId = u64; pub type BlockNumber = u64; pub type Identifier = u32; pub type Price = FixedU128; @@ -71,7 +71,7 @@ pub const fn free_deposit() -> Balance { pub struct SignedToAccountIndex(PhantomData<(RuntimeOrigin, AccountId, Network)>); -impl, Network: Get>> +impl, Network: Get>> TryConvert for SignedToAccountIndex where RuntimeOrigin::PalletsOrigin: @@ -80,7 +80,7 @@ where fn try_convert(o: RuntimeOrigin) -> Result { o.try_with_caller(|caller| match caller.try_into() { Ok(SystemRawOrigin::Signed(who)) => - Ok(Junction::AccountIndex64 { network: Network::get(), index: Into::::into(who).into() }.into()), + Ok(Junction::AccountIndex64 { network: Network::get(), index: Into::::into(who).into() }.into()), Ok(other) => Err(other.into()), Err(other) => Err(other), }) @@ -296,7 +296,7 @@ parameter_types! { pub const CommunityRoundDuration: BlockNumber = 18u64; pub const RemainderRoundDuration: BlockNumber = 6u64; - pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); + pub const FundingPalletId: PalletId = PalletId(*b"plmc-fun"); pub FeeBrackets: Vec<(Percent, Balance)> = vec![ (Percent::from_percent(10), 1_000_000 * USD_UNIT), (Percent::from_percent(8), 4_000_000 * USD_UNIT), @@ -353,14 +353,14 @@ pub struct DummyConverter; impl sp_runtime::traits::Convert for DummyConverter { fn convert(a: AccountId) -> [u8; 32] { let mut account: [u8; 32] = [0u8; 32]; - account[0..4].copy_from_slice(a.to_le_bytes().as_slice()); + account[0..8].copy_from_slice(a.to_le_bytes().as_slice()); account } } impl ConvertBack for DummyConverter { fn convert_back(bytes: [u8; 32]) -> AccountId { - let account: [u8; 4] = bytes[0..3].try_into().unwrap(); - u32::from_le_bytes(account) + let account: [u8; 8] = bytes[0..7].try_into().unwrap(); + u64::from_le_bytes(account) } } thread_local! { @@ -437,7 +437,7 @@ impl Config for TestRuntime { parameter_types! { pub const FeePercentage: Perbill = Perbill::from_percent(5); - pub const FeeRecipient: AccountId = 80085u32; + pub const FeeRecipient: AccountId = 80085; pub const RootId: PalletId = PalletId(*b"treasury"); } impl pallet_proxy_bonding::Config for TestRuntime { @@ -482,7 +482,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities { balances: vec![ (::PalletId::get().into_account_truncating(), ed), (::ContributionTreasury::get(), ed), - (::BlockchainOperationTreasury::get(), ed), + /// Treasury account needs PLMC for the One Token Model participations + (::BlockchainOperationTreasury::get(), 1_000_000 * PLMC), ], }, foreign_assets: ForeignAssetsConfig { @@ -490,19 +491,20 @@ pub fn new_test_ext() -> sp_io::TestExternalities { ( AcceptedFundingAsset::USDT.id(), ::PalletId::get().into_account_truncating(), - false, + // asset is sufficient, i.e. participants can hold only this asset to participate with OTM + true, 10, ), ( AcceptedFundingAsset::USDC.id(), ::PalletId::get().into_account_truncating(), - false, + true, 10, ), ( AcceptedFundingAsset::DOT.id(), ::PalletId::get().into_account_truncating(), - false, + true, 10, ), ], diff --git a/pallets/funding/src/tests/2_evaluation.rs b/pallets/funding/src/tests/2_evaluation.rs index 98c8e9f53..df16a6ede 100644 --- a/pallets/funding/src/tests/2_evaluation.rs +++ b/pallets/funding/src/tests/2_evaluation.rs @@ -764,7 +764,7 @@ mod evaluate_extrinsic { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project_metadata(ISSUER_1); let evaluations = (0u32..::MaxEvaluationsPerProject::get()) - .map(|i| UserToUSDBalance::::new(i as u32 + 420u32, (100u128 * CT_UNIT).into())) + .map(|i| UserToUSDBalance::::new(i as u64 + 420, (100u128 * CT_UNIT).into())) .collect_vec(); let failing_evaluation = UserToUSDBalance::new(EVALUATOR_1, 1000 * CT_UNIT); diff --git a/pallets/funding/src/tests/3_auction.rs b/pallets/funding/src/tests/3_auction.rs index 8251e91ed..efe29edf5 100644 --- a/pallets/funding/src/tests/3_auction.rs +++ b/pallets/funding/src/tests/3_auction.rs @@ -262,7 +262,7 @@ mod round_flow { let max_bids_per_project: u32 = ::MaxBidsPerProject::get(); let big_bid: BidParams = (BIDDER_1, total_allocation).into(); let small_bids: Vec> = - (0..max_bids_per_project - 1).map(|i| (i + BIDDER_1, min_bid_ct).into()).collect(); + (0..max_bids_per_project - 1).map(|i| (i as u64 + BIDDER_1, min_bid_ct).into()).collect(); let all_bids = vec![vec![big_bid.clone()], small_bids.clone()].into_iter().flatten().collect_vec(); let mut project_metadata = default_project_metadata(ISSUER_1); @@ -1014,8 +1014,7 @@ mod bid_extrinsic { let evaluations = inst.generate_successful_evaluations(project_metadata.clone(), vec![EVALUATOR_1], vec![100u8]); let max_bids_per_project: u32 = ::MaxBidsPerProject::get(); - let bids = - (0u32..max_bids_per_project - 1).map(|i| (i as u32 + 420u32, 5000 * CT_UNIT).into()).collect_vec(); + let bids = (0u32..max_bids_per_project - 1).map(|i| (i as u64 + 420, 5000 * CT_UNIT).into()).collect_vec(); let project_id = inst.create_auctioning_project(project_metadata.clone(), ISSUER_1, None, evaluations); @@ -1574,12 +1573,12 @@ mod end_auction_extrinsic { // From the knowledge hub: https://hub.polimec.org/learn/calculation-example#auction-round-calculation-example let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - const ADAM: u32 = 60; - const TOM: u32 = 61; - const SOFIA: u32 = 62; - const FRED: u32 = 63; - const ANNA: u32 = 64; - const DAMIAN: u32 = 65; + const ADAM: AccountIdOf = 60; + const TOM: AccountIdOf = 61; + const SOFIA: AccountIdOf = 62; + const FRED: AccountIdOf = 63; + const ANNA: AccountIdOf = 64; + const DAMIAN: AccountIdOf = 65; let accounts = vec![ADAM, TOM, SOFIA, FRED, ANNA, DAMIAN]; @@ -1801,12 +1800,12 @@ mod end_auction_extrinsic { // From the knowledge hub: https://hub.polimec.org/learn/calculation-example#auction-round-calculation-example let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - const ADAM: u32 = 60; - const TOM: u32 = 61; - const SOFIA: u32 = 62; - const FRED: u32 = 63; - const ANNA: u32 = 64; - const DAMIAN: u32 = 65; + const ADAM: AccountIdOf = 60; + const TOM: AccountIdOf = 61; + const SOFIA: AccountIdOf = 62; + const FRED: AccountIdOf = 63; + const ANNA: AccountIdOf = 64; + const DAMIAN: AccountIdOf = 65; let accounts = vec![ADAM, TOM, SOFIA, FRED, ANNA, DAMIAN]; let mut project_metadata = default_project_metadata(ISSUER_1); diff --git a/pallets/funding/src/tests/4_contribution.rs b/pallets/funding/src/tests/4_contribution.rs index f3e4c2f1e..fad612ba4 100644 --- a/pallets/funding/src/tests/4_contribution.rs +++ b/pallets/funding/src/tests/4_contribution.rs @@ -332,6 +332,7 @@ mod contribute_extrinsic { #[cfg(test)] mod success { use super::*; + use crate::traits::BondingRequirementCalculation; use frame_support::{dispatch::DispatchResultWithPostInfo, traits::fungible::InspectFreeze}; #[test] @@ -1005,7 +1006,7 @@ mod contribute_extrinsic { fn participant_was_evaluator_and_bidder() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER_1; - let participant = 42069u32; + let participant = 42069; let project_metadata = default_project_metadata(issuer); let mut evaluations = default_evaluations(); evaluations.push((participant, 100 * USD_UNIT).into()); @@ -1030,6 +1031,117 @@ mod contribute_extrinsic { remainder_contributions, ); } + + #[test] + fn one_token_mode_contribution() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let issuer = ISSUER_1; + + let mut project_metadata = default_project_metadata(issuer); + project_metadata.mainnet_token_max_supply = 50_000 * CT_UNIT; + project_metadata.total_allocation_size = 5_000 * CT_UNIT; + project_metadata.minimum_price = ::PriceProvider::calculate_decimals_aware_price( + PriceOf::::from_float(1.0), + USD_DECIMALS, + CT_DECIMALS, + ) + .unwrap(); + + let evaluations = + inst.generate_successful_evaluations(project_metadata.clone(), default_evaluators(), default_weights()); + + let project_id = + inst.create_community_contributing_project(project_metadata.clone(), issuer, None, evaluations, vec![]); + let wap = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let otm_multiplier: MultiplierOf = + ParticipationMode::OTM.multiplier().try_into().ok().unwrap(); + + const USDT_ID: u32 = AcceptedFundingAsset::USDT.id(); + const USDT_PARTICIPATION: u128 = 3000 * USDT_UNIT; + + const OTM_USDT_FEE: u128 = 30 * USDT_UNIT; + let usdt_ed = inst.get_funding_asset_ed(AcceptedFundingAsset::USDT.id()); + let required_usdt = UserToFundingAsset::new(BUYER_1, USDT_PARTICIPATION + OTM_USDT_FEE + usdt_ed, USDT_ID); + inst.mint_funding_asset_to(vec![required_usdt.clone()]); + + let ct_participation = inst.execute(|| { + >::funding_asset_to_ct_amount( + project_id, + AcceptedFundingAsset::USDT, + USDT_PARTICIPATION, + ) + }); + /// USDT has the same decimals and price as our baseline USD + let expected_plmc_bond = >::calculate_plmc_bond(USDT_PARTICIPATION, otm_multiplier).unwrap(); + dbg!(&expected_plmc_bond); + let otm_lock_time = otm_multiplier.calculate_vesting_duration::(); + + let otm_escrow_account = + ::RootId::get().into_sub_account_truncating(project_id); + let otm_treasury_account = ::Treasury::get(); + let otm_fee_recipient_account = ::FeeRecipient::get(); + let funding_project_escrow = PolimecFunding::fund_account_id(project_id); + + assert!(funding_project_escrow != otm_escrow_account); + + let pre_participation_treasury_free_plmc = inst.get_free_plmc_balance_for(otm_treasury_account); + let pre_participation_otm_escrow_held_plmc = + inst.get_reserved_plmc_balance_for(otm_escrow_account, HoldReason::Participation.into()); + let pre_participation_otm_escrow_usdt = + inst.get_free_funding_asset_balance_for(USDT_ID, otm_escrow_account); + let pre_participation_otm_fee_recipient_usdt = + inst.get_free_funding_asset_balance_for(USDT_ID, otm_fee_recipient_account); + let pre_participation_buyer_usdt = inst.get_free_funding_asset_balance_for(USDT_ID, BUYER_1); + + inst.execute(|| { + assert_ok!(PolimecFunding::contribute( + RuntimeOrigin::signed(BUYER_1), + get_mock_jwt_with_cid( + BUYER_1, + InvestorType::Retail, + generate_did_from_account(BUYER_1), + project_metadata.clone().policy_ipfs_cid.unwrap() + ), + project_id, + ct_participation, + ParticipationMode::OTM, + AcceptedFundingAsset::USDT + )); + }); + + let post_participation_treasury_free_plmc = inst.get_free_plmc_balance_for(otm_treasury_account); + let post_participation_otm_escrow_held_plmc = + inst.get_reserved_plmc_balance_for(otm_escrow_account, HoldReason::Participation.into()); + let post_participation_otm_escrow_usdt = + inst.get_free_funding_asset_balance_for(USDT_ID, otm_escrow_account); + let post_participation_otm_fee_recipient_usdt = + inst.get_free_funding_asset_balance_for(USDT_ID, otm_fee_recipient_account); + let post_participation_buyer_usdt = inst.get_free_funding_asset_balance_for(USDT_ID, BUYER_1); + + assert_eq!( + post_participation_treasury_free_plmc, + pre_participation_treasury_free_plmc - expected_plmc_bond - inst.get_ed() + ); + assert_eq!( + post_participation_otm_escrow_held_plmc, + pre_participation_otm_escrow_held_plmc + expected_plmc_bond + ); + assert_eq!(post_participation_otm_escrow_usdt, pre_participation_otm_escrow_usdt + OTM_USDT_FEE); + assert_eq!(post_participation_otm_fee_recipient_usdt, pre_participation_otm_fee_recipient_usdt); + assert_eq!(post_participation_buyer_usdt, pre_participation_buyer_usdt - USDT_PARTICIPATION - OTM_USDT_FEE); + + assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::FundingSuccessful); + assert_eq!(inst.go_to_next_state(project_id), ProjectStatus::SettlementStarted(FundingOutcome::Success)); + inst.settle_project(project_id, true); + + // let post_settlement_treasury_free_plmc = inst.get_free_plmc_balance_for(otm_treasury_account); + // let post_settlement_otm_escrow_held_plmc = inst.get_free_plmc_balance_for(otm_escrow_account); + // let post_settlement_otm_escrow_usdt = inst.get_free_funding_asset_balance_for(otm_escrow_account, AcceptedFundingAsset::USDT); + // let post_settlement_otm_fee_recipient_usdt = inst.get_free_funding_asset_balance_for(otm_fee_recipient_account, AcceptedFundingAsset::USDT); + // let post_settlement_buyer_usdt = inst.get_free_funding_asset_balance_for(BUYER_1, AcceptedFundingAsset::USDT); + + // assert_eq!(post_settlement_treasury_free_plmc, post_participation_treasury_free_plmc); + } } #[cfg(test)] diff --git a/pallets/funding/src/tests/6_settlement.rs b/pallets/funding/src/tests/6_settlement.rs index e2196d0da..4498093c9 100644 --- a/pallets/funding/src/tests/6_settlement.rs +++ b/pallets/funding/src/tests/6_settlement.rs @@ -255,7 +255,7 @@ mod settle_evaluation_extrinsic { RuntimeOrigin::signed(evaluator), project_id, evaluator, - evaluator - 21 // The First evaluation index is 0, the first evaluator account is 21 + (evaluator - 21) as u32 // The First evaluation index is 0, the first evaluator account is 21 ))); let ct_rewarded = inst.get_ct_asset_balance_for(project_id, evaluator); assert_close_enough!(ct_rewarded, expected_reward, Perquintill::from_float(0.9999)); diff --git a/pallets/funding/src/tests/misc.rs b/pallets/funding/src/tests/misc.rs index 995a6486f..62738e0c7 100644 --- a/pallets/funding/src/tests/misc.rs +++ b/pallets/funding/src/tests/misc.rs @@ -66,23 +66,23 @@ mod helper_functions { #[test] fn calculate_evaluation_plmc_spent() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - const EVALUATOR_1: AccountIdOf = 1u32; + const EVALUATOR_1: AccountIdOf = 1; const USD_AMOUNT_1: Balance = 150_000 * USD_UNIT; const EXPECTED_PLMC_AMOUNT_1: f64 = 17_857.1428571428f64; - const EVALUATOR_2: AccountIdOf = 2u32; + const EVALUATOR_2: AccountIdOf = 2; const USD_AMOUNT_2: Balance = 50_000 * USD_UNIT; const EXPECTED_PLMC_AMOUNT_2: f64 = 5_952.3809523809f64; - const EVALUATOR_3: AccountIdOf = 3u32; + const EVALUATOR_3: AccountIdOf = 3; const USD_AMOUNT_3: Balance = 75_000 * USD_UNIT; const EXPECTED_PLMC_AMOUNT_3: f64 = 8_928.5714285714f64; - const EVALUATOR_4: AccountIdOf = 4u32; + const EVALUATOR_4: AccountIdOf = 4; const USD_AMOUNT_4: Balance = 100 * USD_UNIT; const EXPECTED_PLMC_AMOUNT_4: f64 = 11.9047619047f64; - const EVALUATOR_5: AccountIdOf = 5u32; + const EVALUATOR_5: AccountIdOf = 5; // 123.7 USD const USD_AMOUNT_5: Balance = 1237 * USD_UNIT / 10; @@ -246,31 +246,31 @@ mod helper_functions { const PLMC_PRICE: f64 = 8.4f64; const CT_PRICE: f64 = 16.32f64; - const CONTRIBUTOR_1: AccountIdOf = 1u32; + const CONTRIBUTOR_1: AccountIdOf = 1; const TOKEN_AMOUNT_1: u128 = 120 * CT_UNIT; const MULTIPLIER_1: u8 = 1u8; const _TICKET_SIZE_USD_1: u128 = 1_958_4_000_000_000_u128; const EXPECTED_PLMC_AMOUNT_1: f64 = 233.1_428_571_428f64; - const CONTRIBUTOR_2: AccountIdOf = 2u32; + const CONTRIBUTOR_2: AccountIdOf = 2; const TOKEN_AMOUNT_2: u128 = 5023 * CT_UNIT; const MULTIPLIER_2: u8 = 2u8; const _TICKET_SIZE_USD_2: u128 = 81_975_3_600_000_000_u128; const EXPECTED_PLMC_AMOUNT_2: f64 = 4_879.4_857_142_857f64; - const CONTRIBUTOR_3: AccountIdOf = 3u32; + const CONTRIBUTOR_3: AccountIdOf = 3; const TOKEN_AMOUNT_3: u128 = 20_000 * CT_UNIT; const MULTIPLIER_3: u8 = 17u8; const _TICKET_SIZE_USD_3: u128 = 326_400_0_000_000_000_u128; const EXPECTED_PLMC_AMOUNT_3: f64 = 2_285.7_142_857_142f64; - const CONTRIBUTOR_4: AccountIdOf = 4u32; + const CONTRIBUTOR_4: AccountIdOf = 4; const TOKEN_AMOUNT_4: u128 = 1_000_000 * CT_UNIT; const MULTIPLIER_4: u8 = 25u8; const _TICKET_SIZE_4: u128 = 16_320_000_0_000_000_000_u128; const EXPECTED_PLMC_AMOUNT_4: f64 = 77_714.2_857_142_857f64; - const CONTRIBUTOR_5: AccountIdOf = 5u32; + const CONTRIBUTOR_5: AccountIdOf = 5; // 0.1233 CTs const TOKEN_AMOUNT_5: u128 = 1_233 * CT_UNIT / 10_000; const MULTIPLIER_5: u8 = 10u8; diff --git a/pallets/funding/src/tests/mod.rs b/pallets/funding/src/tests/mod.rs index 5b4392343..2a83b671d 100644 --- a/pallets/funding/src/tests/mod.rs +++ b/pallets/funding/src/tests/mod.rs @@ -482,7 +482,7 @@ pub fn create_finished_project_with_usd_raised( usd_raised: Balance, usd_target: Balance, ) -> (MockInstantiator, ProjectId) { - let issuer = inst.get_new_nonce() as u32; + let issuer = inst.get_new_nonce(); let mut project_metadata = default_project_metadata(issuer); project_metadata.total_allocation_size = project_metadata.minimum_price.reciprocal().unwrap().saturating_mul_int(usd_target); @@ -505,7 +505,7 @@ pub fn create_finished_project_with_usd_raised( let evaluations = default_evaluations(); - let bids = inst.generate_bids_that_take_price_to(project_metadata.clone(), required_price, 420, |acc| acc + 1u32); + let bids = inst.generate_bids_that_take_price_to(project_metadata.clone(), required_price, 420, |acc| acc + 1); let project_id = inst.create_community_contributing_project(project_metadata, issuer, None, evaluations, bids); diff --git a/pallets/funding/src/tests/runtime_api.rs b/pallets/funding/src/tests/runtime_api.rs index 8e6cb057f..a7623da4f 100644 --- a/pallets/funding/src/tests/runtime_api.rs +++ b/pallets/funding/src/tests/runtime_api.rs @@ -363,7 +363,7 @@ fn funding_asset_to_ct_amount() { PriceProviderOf::::calculate_decimals_aware_price(new_price, USD_DECIMALS, CT_DECIMALS).unwrap(); let bids = - inst.generate_bids_that_take_price_to(project_metadata_2.clone(), decimal_aware_price, 420u32, |acc| acc + 1); + inst.generate_bids_that_take_price_to(project_metadata_2.clone(), decimal_aware_price, 420, |acc| acc + 1); let project_id_2 = inst.create_community_contributing_project( project_metadata_2.clone(), ISSUER_2, @@ -403,7 +403,7 @@ fn funding_asset_to_ct_amount() { let bids = inst.generate_bids_from_bucket( project_metadata_3.clone(), bucket, - 420u32, + 420, |acc| acc + 1, AcceptedFundingAsset::USDT, ); diff --git a/pallets/proxy-bonding/Cargo.toml b/pallets/proxy-bonding/Cargo.toml index f7b262e14..b025c7855 100644 --- a/pallets/proxy-bonding/Cargo.toml +++ b/pallets/proxy-bonding/Cargo.toml @@ -21,6 +21,7 @@ polimec-common.workspace = true parity-scale-codec.workspace = true scale-info.workspace = true serde = { workspace = true, features = ["derive"] } +sp-core.workspace = true [dev-dependencies] sp-io.workspace = true