Skip to content

Commit

Permalink
fix: 🐛 pool ID for bbBNC (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
yooml authored Oct 16, 2024
1 parent bcd1527 commit 8fe2c9c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pallets/bb-bnc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub type CurrencyIdOf<T> = <<T as Config>::MultiCurrency as MultiCurrency<

const BB_LOCK_ID: LockIdentifier = *b"bbbnclck";
const MARKUP_LOCK_ID: LockIdentifier = *b"bbbncmkp";
const BB_BNC_SYSTEM_POOL_ID: PoolId = u32::MAX;
pub const BB_BNC_SYSTEM_POOL_ID: PoolId = u32::MAX;
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Default)]
pub struct BbConfig<Balance, BlockNumber> {
/// Minimum number of TokenType that users can lock
Expand Down
5 changes: 2 additions & 3 deletions pallets/buy-back/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod benchmarking;

pub mod weights;

use bb_bnc::BbBNCInterface;
use bb_bnc::{BbBNCInterface, BB_BNC_SYSTEM_POOL_ID};
use bifrost_primitives::{currency::BNC, CurrencyId, CurrencyIdRegister, TryConvertFrom};
use cumulus_primitives_core::ParaId;
use frame_support::{
Expand Down Expand Up @@ -414,9 +414,8 @@ pub mod pallet {
T::MultiCurrency::withdraw(BNC, &buyback_address, destruction_amount)?;
}
let bnc_balance = T::MultiCurrency::free_balance(BNC, &buyback_address);
let pool_id = 0;
T::BbBNC::notify_reward(
pool_id,
BB_BNC_SYSTEM_POOL_ID,
&Some(buyback_address.clone()),
vec![(BNC, bnc_balance)],
)
Expand Down
36 changes: 30 additions & 6 deletions pallets/buy-back/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ fn buy_back_with_burn_should_work() {
assert_eq!(Currencies::free_balance(BNC, &zenlink_pair_account_id), 2000);
assert_eq!(Currencies::free_balance(BNC, &buyback_account), 0);
assert_eq!(Currencies::free_balance(BNC, &incentive_account), 0);
BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(buyback_account.clone()));
BbBNC::set_incentive(
BB_BNC_SYSTEM_POOL_ID,
Some(7 * 86400 / 12),
Some(buyback_account.clone()),
);
assert_ok!(BuyBack::charge(RuntimeOrigin::signed(ALICE), VKSM, 1000));
let infos = Infos::<Runtime>::get(VKSM).unwrap();
assert_ok!(BuyBack::buy_back(&buyback_account, VKSM, &infos, 0));
Expand Down Expand Up @@ -146,7 +150,11 @@ fn buy_back_no_burn_should_work() {
assert_eq!(Currencies::free_balance(BNC, &zenlink_pair_account_id), 2000);
assert_eq!(Currencies::free_balance(BNC, &buyback_account), 0);
assert_eq!(Currencies::free_balance(BNC, &incentive_account), 0);
BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(buyback_account.clone()));
BbBNC::set_incentive(
BB_BNC_SYSTEM_POOL_ID,
Some(7 * 86400 / 12),
Some(buyback_account.clone()),
);
assert_ok!(BuyBack::charge(RuntimeOrigin::signed(ALICE), VKSM, 1000));
let infos = Infos::<Runtime>::get(VKSM).unwrap();
assert_ok!(BuyBack::buy_back(&buyback_account, VKSM, &infos, 0));
Expand Down Expand Up @@ -184,7 +192,11 @@ fn on_initialize_no_burn_should_work() {
assert_eq!(Currencies::free_balance(BNC, &zenlink_pair_account_id), 2000);
assert_eq!(Currencies::free_balance(BNC, &buyback_account), 0);
assert_eq!(Currencies::free_balance(BNC, &incentive_account), 0);
BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(buyback_account.clone()));
BbBNC::set_incentive(
BB_BNC_SYSTEM_POOL_ID,
Some(7 * 86400 / 12),
Some(buyback_account.clone()),
);
assert_ok!(BuyBack::charge(RuntimeOrigin::signed(ALICE), VKSM, 1000));
BuyBack::on_initialize(1);
BuyBack::on_initialize(2);
Expand Down Expand Up @@ -222,7 +234,11 @@ fn on_initialize_with_burn_should_work() {
assert_eq!(Currencies::free_balance(BNC, &zenlink_pair_account_id), 2000);
assert_eq!(Currencies::free_balance(BNC, &buyback_account), 0);
assert_eq!(Currencies::free_balance(BNC, &incentive_account), 0);
BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(buyback_account.clone()));
BbBNC::set_incentive(
BB_BNC_SYSTEM_POOL_ID,
Some(7 * 86400 / 12),
Some(buyback_account.clone()),
);
assert_ok!(BuyBack::charge(RuntimeOrigin::signed(ALICE), VKSM, 1000));
BuyBack::on_initialize(<frame_system::Pallet<Runtime>>::block_number() + 1);
System::set_block_number(System::block_number() + 1);
Expand Down Expand Up @@ -261,7 +277,11 @@ fn on_initialize_with_bias_should_work() {
assert_eq!(Currencies::free_balance(BNC, &zenlink_pair_account_id), 2000);
assert_eq!(Currencies::free_balance(BNC, &buyback_account), 0);
assert_eq!(Currencies::free_balance(BNC, &incentive_account), 0);
BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(buyback_account.clone()));
BbBNC::set_incentive(
BB_BNC_SYSTEM_POOL_ID,
Some(7 * 86400 / 12),
Some(buyback_account.clone()),
);
assert_ok!(BuyBack::charge(RuntimeOrigin::signed(ALICE), VKSM, 1000));
BuyBack::on_initialize(1);
let path = vec![
Expand Down Expand Up @@ -311,7 +331,11 @@ fn on_initialize_with_bias_should_not_work() {
assert_eq!(Currencies::free_balance(BNC, &zenlink_pair_account_id), 2000);
assert_eq!(Currencies::free_balance(BNC, &buyback_account), 0);
assert_eq!(Currencies::free_balance(BNC, &incentive_account), 0);
BbBNC::set_incentive(0, Some(7 * 86400 / 12), Some(buyback_account.clone()));
BbBNC::set_incentive(
BB_BNC_SYSTEM_POOL_ID,
Some(7 * 86400 / 12),
Some(buyback_account.clone()),
);
assert_ok!(BuyBack::charge(RuntimeOrigin::signed(ALICE), VKSM, 1000));
BuyBack::on_initialize(1);
let path = vec![
Expand Down

0 comments on commit 8fe2c9c

Please sign in to comment.