Skip to content

Commit 3fb0373

Browse files
authored
modify iro allocation (#486)
1 parent f919b7a commit 3fb0373

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

modules/pallets/bridge-drop/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ pub mod pallet {
267267
origin: OriginFor<T>,
268268
beneficiary: T::AccountId,
269269
amount: <<T as Config>::Currency as Currency<T::AccountId>>::Balance,
270+
bonus_amount: <<T as Config>::Currency as Currency<T::AccountId>>::Balance,
270271
) -> DispatchResult {
271272
T::BridgeDropOrigin::ensure_origin(origin)?;
272273

@@ -278,12 +279,13 @@ pub mod pallet {
278279
let percent = Permill::from_parts(250_000);
279280
let unlocked_balance = percent * u128::from(amount);
280281

281-
let locked = u128::from(amount).saturating_sub(unlocked_balance);
282+
let total_amount = u128::from(amount).saturating_add(u128::from(bonus_amount));
283+
let locked = total_amount.saturating_sub(unlocked_balance);
282284

283285
<<T as Config>::Currency as Currency<T::AccountId>>::transfer(
284286
&Self::account_id(),
285287
&beneficiary,
286-
amount.into(),
288+
total_amount.into(),
287289
ExistenceRequirement::AllowDeath,
288290
)?;
289291

@@ -299,9 +301,9 @@ pub mod pallet {
299301
starting_block,
300302
)?;
301303

302-
IroAllocations::<T>::insert(&beneficiary, u128::from(amount));
304+
IroAllocations::<T>::insert(&beneficiary, total_amount);
303305

304-
Self::deposit_event(Event::<T>::Allocated { beneficiary, amount });
306+
Self::deposit_event(Event::<T>::Allocated { beneficiary, amount: total_amount.into() });
305307

306308
Ok(())
307309
}

modules/pallets/testsuite/src/tests/pallet_bridge_airdrop.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,24 @@ fn should_allocate_iro_correctly() {
138138

139139
let beneficiary = AccountId32::new(H256::random().0);
140140
let amount = 3500_000_000_000_000u128;
141+
let bonus_amount = 3500_000_000_000u128;
141142

142143
pallet_bridge_airdrop::Pallet::<Test>::allocate_iro_tokens(
143144
RuntimeOrigin::root(),
144145
beneficiary.clone(),
145146
amount,
147+
bonus_amount
146148
)
147149
.unwrap();
148150

149151
let account_data = frame_system::Account::<Test>::get(beneficiary.clone());
150152

151153
let initial_unlocked = Permill::from_parts(250_000) * amount;
152-
let locked = amount.saturating_sub(initial_unlocked);
154+
let locked = amount
155+
.saturating_sub(initial_unlocked)
156+
.saturating_add(bonus_amount);
153157

154-
assert_eq!(account_data.data.free, amount);
158+
assert_eq!(account_data.data.free, amount.saturating_add(bonus_amount));
155159

156160
// transfer above unlocked balance should fail
157161
let res = Balances::transfer_keep_alive(
@@ -189,6 +193,7 @@ fn should_allocate_iro_correctly() {
189193
RuntimeOrigin::root(),
190194
beneficiary.clone(),
191195
amount.clone(),
196+
bonus_amount
192197
);
193198

194199
assert_err!(res, pallet_bridge_airdrop::pallet::Error::<Test>::AlreadyAllocated);

parachain/runtimes/gargantua/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
239239
spec_name: Cow::Borrowed("gargantua"),
240240
impl_name: Cow::Borrowed("gargantua"),
241241
authoring_version: 1,
242-
spec_version: 3_800,
242+
spec_version: 3_900,
243243
impl_version: 0,
244244
apis: RUNTIME_API_VERSIONS,
245245
transaction_version: 1,
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
[
22
{
33
"beneficiary": "16kZJGPJ37uYxjs7adswyEHbPYeHS9jQHSaSUJhkfvWPcoeF",
4-
"amount": 3076000000000000
4+
"amount": 3076000000000000,
5+
"bonus_amount": 30760000000000
56
},
67
{
78
"beneficiary": "1egYCubF1U5CGWiXjQnsXduiJYP49KTs8eX1jn1JrTqCYyQ",
8-
"amount": 1661040000000000
9+
"amount": 1661040000000000,
10+
"bonus_amount": 1661040000000
911
},
1012
{
1113
"beneficiary": "126TwBzBM4jUEK2gTphmW4oLoBWWnYvPp8hygmduTr4uds57",
12-
"amount": 67130863680000000
14+
"amount": 67130863680000000,
15+
"bonus_amount": 1661040000
1316
}
1417
]

parachain/simtests/src/token_allocation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use subxt_utils::Hyperbridge;
2424
struct AllocationRecord {
2525
beneficiary: String,
2626
amount: u128,
27+
#[serde(default)]
28+
bonus_amount: Option<u128>,
2729
}
2830

2931
#[tokio::test]
@@ -79,6 +81,7 @@ async fn should_perform_batch_allocations() -> Result<(), anyhow::Error> {
7981
let call = RuntimeCall::BridgeDrop(BridgeDropCall::allocate_iro_tokens {
8082
beneficiary: dest.into(),
8183
amount: record.amount,
84+
bonus_amount: record.bonus_amount.unwrap()
8285
});
8386
calls.push(call);
8487
records_to_check.push(record);

0 commit comments

Comments
 (0)