-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdefaults.rs
171 lines (149 loc) · 6.96 KB
/
defaults.rs
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
// Polimec Blockchain – https://www.polimec.org/
// Copyright (C) Polimec 2022. All rights reserved.
// The Polimec Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Polimec Blockchain is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::PolimecRuntime;
use frame_support::BoundedVec;
pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToUSDBalance};
use pallet_funding::{
AcceptedFundingAsset, BiddingTicketSizes, ContributingTicketSizes, CurrencyMetadata, ParticipantsAccountType,
ParticipationMode, PriceProviderOf, ProjectMetadata, ProjectMetadataOf, TicketSize,
};
use sp_arithmetic::{FixedPointNumber, Percent};
use macros::generate_accounts;
use polimec_common::{ProvideAssetPrice, USD_DECIMALS, USD_UNIT};
use polimec_runtime::{AccountId, PLMC};
use sp_runtime::{traits::ConstU32, Perquintill};
use ParticipationMode::{Classic, OTM};
pub const IPFS_CID: &str = "QmeuJ24ffwLAZppQcgcggJs3n689bewednYkuc8Bx5Gngz";
pub const CT_DECIMALS: u8 = 18;
pub const CT_UNIT: u128 = 10_u128.pow(CT_DECIMALS as u32);
pub type IntegrationInstantiator = pallet_funding::instantiator::Instantiator<
PolimecRuntime,
<PolimecRuntime as pallet_funding::Config>::AllPalletsWithoutSystem,
<PolimecRuntime as pallet_funding::Config>::RuntimeEvent,
>;
generate_accounts!(
ISSUER, EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1,
BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6,
);
pub fn bounded_name() -> BoundedVec<u8, ConstU32<64>> {
BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap()
}
pub fn bounded_symbol() -> BoundedVec<u8, ConstU32<64>> {
BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap()
}
pub fn ipfs_hash() -> BoundedVec<u8, ConstU32<96>> {
BoundedVec::try_from(IPFS_CID.as_bytes().to_vec()).unwrap()
}
pub fn default_weights() -> Vec<u8> {
vec![20u8, 15u8, 10u8, 25u8, 30u8]
}
pub fn default_bidder_modes() -> Vec<ParticipationMode> {
vec![Classic(1u8), Classic(6u8), OTM, OTM, Classic(3u8)]
}
pub fn default_contributor_modes() -> Vec<ParticipationMode> {
vec![Classic(1u8), Classic(1u8), OTM, OTM, Classic(3u8)]
}
pub fn default_project_metadata(issuer: AccountId) -> ProjectMetadataOf<polimec_runtime::Runtime> {
ProjectMetadata {
token_information: CurrencyMetadata { name: bounded_name(), symbol: bounded_symbol(), decimals: CT_DECIMALS },
mainnet_token_max_supply: 8_000_000 * CT_UNIT,
total_allocation_size: 1_000_000 * CT_UNIT,
auction_round_allocation_percentage: Percent::from_percent(50u8),
minimum_price: PriceProviderOf::<PolimecRuntime>::calculate_decimals_aware_price(
sp_runtime::FixedU128::from_float(10.0),
USD_DECIMALS,
CT_DECIMALS,
)
.unwrap(),
bidding_ticket_sizes: BiddingTicketSizes {
professional: TicketSize::new(5000 * USD_UNIT, None),
institutional: TicketSize::new(5000 * USD_UNIT, None),
phantom: Default::default(),
},
contributing_ticket_sizes: ContributingTicketSizes {
retail: TicketSize::new(USD_UNIT, None),
professional: TicketSize::new(USD_UNIT, None),
institutional: TicketSize::new(USD_UNIT, None),
phantom: Default::default(),
},
participation_currencies: vec![AcceptedFundingAsset::USDT].try_into().unwrap(),
funding_destination_account: issuer,
policy_ipfs_cid: Some(ipfs_hash()),
participants_account_type: ParticipantsAccountType::Polkadot,
}
}
pub fn default_evaluations() -> Vec<UserToUSDBalance<PolimecRuntime>> {
vec![
UserToUSDBalance::new(EVAL_1.into(), 500_000 * PLMC),
UserToUSDBalance::new(EVAL_2.into(), 250_000 * PLMC),
UserToUSDBalance::new(EVAL_3.into(), 320_000 * PLMC),
]
}
pub fn default_bidders() -> Vec<AccountId> {
vec![BIDDER_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into(), BIDDER_5.into()]
}
pub fn default_bids() -> Vec<BidParams<PolimecRuntime>> {
let inst = IntegrationInstantiator::new(None);
let default_metadata = default_project_metadata(ISSUER.into());
let auction_allocation =
default_metadata.auction_round_allocation_percentage * default_metadata.total_allocation_size;
let auction_90_percent = Perquintill::from_percent(90) * auction_allocation;
let auction_usd_funding = default_metadata.minimum_price.saturating_mul_int(auction_90_percent);
inst.generate_bids_from_total_usd(
auction_usd_funding,
default_metadata.minimum_price,
default_weights(),
default_bidders(),
default_bidder_modes(),
)
}
pub fn default_community_contributions() -> Vec<ContributionParams<PolimecRuntime>> {
let inst = IntegrationInstantiator::new(None);
let default_metadata = default_project_metadata(ISSUER.into());
let auction_allocation =
default_metadata.auction_round_allocation_percentage * default_metadata.total_allocation_size;
let contribution_allocation = default_metadata.total_allocation_size - auction_allocation;
let eighty_percent_funding_ct = Perquintill::from_percent(80) * contribution_allocation;
let eighty_percent_funding_usd = default_metadata.minimum_price.saturating_mul_int(eighty_percent_funding_ct);
inst.generate_contributions_from_total_usd(
eighty_percent_funding_usd,
default_metadata.minimum_price,
default_weights(),
default_community_contributors(),
default_contributor_modes(),
)
}
pub fn default_remainder_contributions() -> Vec<ContributionParams<PolimecRuntime>> {
let inst = IntegrationInstantiator::new(None);
let default_metadata = default_project_metadata(ISSUER.into());
let auction_allocation =
default_metadata.auction_round_allocation_percentage * default_metadata.total_allocation_size;
let contribution_allocation = default_metadata.total_allocation_size - auction_allocation;
let ten_percent_auction = Perquintill::from_percent(10) * auction_allocation;
let ten_percent_auction_usd = default_metadata.minimum_price.saturating_mul_int(ten_percent_auction);
let ten_percent_contribution = Perquintill::from_percent(10) * contribution_allocation;
let ten_percent_contribution_usd = default_metadata.minimum_price.saturating_mul_int(ten_percent_contribution);
inst.generate_contributions_from_total_usd(
ten_percent_auction_usd + ten_percent_contribution_usd,
default_metadata.minimum_price,
vec![20u8, 15u8, 10u8, 25u8, 23u8, 7u8],
default_remainder_contributors(),
default_contributor_modes(),
)
}
pub fn default_community_contributors() -> Vec<AccountId> {
vec![BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()]
}
pub fn default_remainder_contributors() -> Vec<AccountId> {
vec![EVAL_4.into(), BUYER_6.into(), BIDDER_6.into(), EVAL_1.into(), BUYER_1.into(), BIDDER_1.into()]
}