Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more slp v2 docs #1419

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pallets/slp-v2/src/astar_dapp_staking/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<T: Config> Pallet<T> {
let (query_id, xcm_message) =
Self::get_query_id_and_xcm_message(call, delegator_index, &pending_status)?;
if let Some(query_id) = query_id {
let pending_status = pending_status.clone().ok_or(Error::<T>::MissingXcmFee)?;
let pending_status = pending_status.clone().ok_or(Error::<T>::XcmFeeNotFound)?;
PendingStatusByQueryId::<T>::insert(query_id, pending_status.clone());
}
Self::send_xcm_message(ASTAR_DAPP_STAKING, xcm_message)?;
Expand Down Expand Up @@ -208,13 +208,13 @@ impl<T: Config> Pallet<T> {
let currency_id = ASTAR_DAPP_STAKING.info().currency_id;
let current_time_unit =
T::VtokenMinting::get_ongoing_time_unit(currency_id)
.ok_or(Error::<T>::TimeUnitNotExist)?;
.ok_or(Error::<T>::TimeUnitNotFound)?;
let configuration =
ConfigurationByStakingProtocol::<T>::get(ASTAR_DAPP_STAKING)
.ok_or(Error::<T>::ConfigurationNotFound)?;
let unlock_time = current_time_unit
.add(configuration.unlock_period)
.ok_or(Error::<T>::TimeUnitNotExist)?;
.ok_or(Error::<T>::TimeUnitNotFound)?;
pending_ledger
.unlocking
.try_push(AstarUnlockingRecord { amount, unlock_time })
Expand All @@ -226,7 +226,7 @@ impl<T: Config> Pallet<T> {
let currency_id = ASTAR_DAPP_STAKING.info().currency_id;
let current_time_unit =
T::VtokenMinting::get_ongoing_time_unit(currency_id)
.ok_or(Error::<T>::TimeUnitNotExist)?;
.ok_or(Error::<T>::TimeUnitNotFound)?;
pending_ledger.unlocking.retain(|record| {
current_time_unit.cmp(&record.unlock_time) != Ordering::Greater
});
Expand Down
8 changes: 4 additions & 4 deletions pallets/slp-v2/src/common/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<T: Config> Pallet<T> {
staking_protocol: &StakingProtocol,
amount: Balance,
) -> Result<Vec<u8>, Error<T>> {
let polkadot_xcm_pallet_index = staking_protocol.info().polkadot_xcm_pallet_index;
let xcm_pallet_index = staking_protocol.info().xcm_pallet_index;
let bifrost_dest_location = staking_protocol.info().bifrost_dest_location;
let (entrance_account, _) = T::VtokenMinting::get_entrance_and_exit_accounts();
let account_id = entrance_account
Expand All @@ -219,7 +219,7 @@ impl<T: Config> Pallet<T> {
let fee_asset_item = 0u32;
let weight_limit = WeightLimit::Unlimited;

let mut calldata = polkadot_xcm_pallet_index.encode();
let mut calldata = xcm_pallet_index.encode();
calldata.extend(LIMITED_RESERVE_TRANSFER_ASSETS_CALL_INDEX.encode());
// bifrost_dest_location
calldata.extend(VersionedLocation::V4(bifrost_dest_location).encode());
Expand Down Expand Up @@ -299,8 +299,8 @@ impl<T: Config> Pallet<T> {
let dest_location = staking_protocol.info().remote_dest_location;
let (ticket, _price) =
T::XcmSender::validate(&mut Some(dest_location), &mut Some(xcm_message))
.map_err(|_| Error::<T>::ErrorValidating)?;
T::XcmSender::deliver(ticket).map_err(|_| Error::<T>::ErrorDelivering)?;
.map_err(|_| Error::<T>::ValidatingFailed)?;
T::XcmSender::deliver(ticket).map_err(|_| Error::<T>::DeliveringFailed)?;
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions pallets/slp-v2/src/common/types/kusama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl StakingProtocol {
match self {
StakingProtocol::MoonriverParachainStaking => StakingProtocolInfo {
utility_pallet_index: 30,
polkadot_xcm_pallet_index: 103,
xcm_pallet_index: 103,
currency_id: MOVR,
unlock_period: TimeUnit::Round(28),
remote_fee_location: Location::new(0, [PalletInstance(10)]),
Expand All @@ -61,7 +61,7 @@ impl StakingProtocol {
},
StakingProtocol::KusamaStaking => StakingProtocolInfo {
utility_pallet_index: 24,
polkadot_xcm_pallet_index: 99,
xcm_pallet_index: 99,
currency_id: KSM,
unlock_period: TimeUnit::Era(28),
remote_fee_location: Location::here(),
Expand Down
21 changes: 20 additions & 1 deletion pallets/slp-v2/src/common/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,48 @@ use xcm::v4::{Location, Weight};
pub type DelegatorIndex = u16;
/// Pallet index in remote chain.
pub type PalletIndex = u8;
/// As derivative call index
pub const AS_DERIVATIVE_CALL_INDEX: u8 = 1;
/// Reserve transfer assets call index
pub const LIMITED_RESERVE_TRANSFER_ASSETS_CALL_INDEX: u8 = 8;

/// Configuration of the protocol
#[derive(Encode, Decode, MaxEncodedLen, Default, Clone, Debug, PartialEq, Eq, TypeInfo)]
pub struct ProtocolConfiguration<AccountId> {
/// Xcm fee for the task
pub xcm_task_fee: XcmFee,
/// Protocol fee rate
pub protocol_fee_rate: Permill,
/// Unlock period
pub unlock_period: TimeUnit,
/// Staking Protocol operator
pub operator: AccountId,
/// Max update token exchange rate
pub max_update_token_exchange_rate: Permill,
/// Update time unit interval
pub update_time_unit_interval: BlockNumber,
/// Update exchange rate interval
pub update_exchange_rate_interval: BlockNumber,
}

/// Staking protocol information
#[derive(Encode, Decode, MaxEncodedLen, Default, Clone, Debug, PartialEq, Eq, TypeInfo)]
pub struct StakingProtocolInfo {
/// Utility pallet index
pub utility_pallet_index: PalletIndex,
pub polkadot_xcm_pallet_index: PalletIndex,
/// Xcm pallet index
pub xcm_pallet_index: PalletIndex,
/// Currency Id for Staking Protocol
pub currency_id: CurrencyId,
/// Unlock period
pub unlock_period: TimeUnit,
/// Remote chain supports fee location.
pub remote_fee_location: Location,
/// Remote chain supports refund location.
pub remote_refund_beneficiary: Location,
/// Dest location for remote chain
pub remote_dest_location: Location,
/// Bifrost dest location
pub bifrost_dest_location: Location,
}

Expand Down
6 changes: 3 additions & 3 deletions pallets/slp-v2/src/common/types/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl StakingProtocol {
match self {
StakingProtocol::AstarDappStaking => StakingProtocolInfo {
utility_pallet_index: 11,
polkadot_xcm_pallet_index: 51,
xcm_pallet_index: 51,
currency_id: ASTR,
unlock_period: TimeUnit::Era(9),
remote_fee_location: Location::here(),
Expand All @@ -67,7 +67,7 @@ impl StakingProtocol {
},
StakingProtocol::MoonbeamParachainStaking => StakingProtocolInfo {
utility_pallet_index: 30,
polkadot_xcm_pallet_index: 103,
xcm_pallet_index: 103,
currency_id: GLMR,
unlock_period: TimeUnit::Round(28),
remote_fee_location: Location::new(0, [PalletInstance(10)]),
Expand All @@ -83,7 +83,7 @@ impl StakingProtocol {
},
StakingProtocol::PolkadotStaking => StakingProtocolInfo {
utility_pallet_index: 26,
polkadot_xcm_pallet_index: 99,
xcm_pallet_index: 99,
currency_id: DOT,
unlock_period: TimeUnit::Era(28),
remote_fee_location: Location::here(),
Expand Down
Loading