From 1fbf1228b99b75c6f59955ec48eddb9ff6d3d9f7 Mon Sep 17 00:00:00 2001 From: NingBo Wang <2536935847@qq.com> Date: Tue, 23 Apr 2024 10:56:45 +0800 Subject: [PATCH] Add token burn logic on slpx (#1229) --- pallets/slpx/src/lib.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pallets/slpx/src/lib.rs b/pallets/slpx/src/lib.rs index 790973a12..c533e77d3 100644 --- a/pallets/slpx/src/lib.rs +++ b/pallets/slpx/src/lib.rs @@ -44,10 +44,10 @@ use frame_system::{ use orml_traits::{MultiCurrency, XcmTransfer}; pub use pallet::*; use parity_scale_codec::{Decode, Encode}; -use polkadot_parachain_primitives::primitives::Sibling; +use polkadot_parachain_primitives::primitives::{Id, Sibling}; use sp_core::{Hasher, H160, U256}; use sp_runtime::{ - traits::{AccountIdConversion, BlakeTwo256, CheckedSub}, + traits::{AccountIdConversion, BlakeTwo256, CheckedSub, UniqueSaturatedFrom}, BoundedVec, DispatchError, }; use sp_std::{vec, vec::Vec}; @@ -60,6 +60,8 @@ mod types; pub mod weights; pub use weights::WeightInfo; +const BIFROST_KUSAMA_PARA_ID: u32 = 2001; + #[cfg(test)] mod mock; @@ -73,6 +75,7 @@ mod benchmarking; pub mod pallet { use super::*; use crate::types::{Order, OrderType}; + use bifrost_primitives::{currency::MOVR, GLMR}; use bifrost_stable_pool::{traits::StablePoolHandler, PoolTokenIndex, StableAssetPoolId}; use frame_support::{ pallet_prelude::{ValueQuery, *}, @@ -362,9 +365,21 @@ pub mod pallet { vtoken_amount, }); + let mut target_fee_currency_id = GLMR; + if T::ParachainId::get() == Id::from(BIFROST_KUSAMA_PARA_ID) { + target_fee_currency_id = MOVR; + } + + // Will not check results and will be sent regardless of the success of + // the burning + let _ = T::MultiCurrency::withdraw( + target_fee_currency_id, + &T::TreasuryAccount::get(), + BalanceOf::::unique_saturated_from(configuration.xcm_fee), + ); + configuration.last_block = n; XcmEthereumCallConfiguration::::put(configuration); - currency_list.rotate_left(1); CurrencyIdList::::put(BoundedVec::try_from(currency_list).unwrap());