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

Changed traits and parachain-staking in primitives/src/traits #1289

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"makefile.extensionOutputFolder": "./.vscode",
"rust-analyzer.cargo.features": "all"
"rust-analyzer.cargo.features": "all",
"rust-analyzer.checkOnSave": false
}
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pallets/parachain-staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version = "3.0.1"
[dependencies]
log = { workspace = true }
serde = { workspace = true, features = ["derive"] }
bifrost-primitives = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, optional = true }
Expand Down
7 changes: 3 additions & 4 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
mod delegation_requests;
pub mod inflation;
pub mod migrations;
pub mod traits;
pub mod types;
pub mod weights;

Expand All @@ -68,12 +67,12 @@ pub use delegation_requests::{CancelledScheduledRequest, DelegationAction, Sched
use frame_support::pallet;
pub use inflation::{InflationInfo, Range};
pub use pallet::*;
pub use traits::*;
pub use types::*;
use weights::WeightInfo;
pub use RoundIndex;
pub use pallet::RoundIndex;
pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
use frame_support::pallet_prelude::DispatchResultWithPostInfo;
pub use bifrost_primitives::parachain_staking::*;

#[pallet]
pub mod pallet {
Expand All @@ -99,10 +98,10 @@ pub mod pallet {
use crate::{
delegation_requests::{CancelledScheduledRequest, DelegationAction, ScheduledRequest},
set::OrderedSet,
traits::*,
types::*,
InflationInfo, Range, WeightInfo,
};
use bifrost_primitives::parachain_staking::*;

/// Pallet for parachain staking
#[pallet::pallet]
Expand Down
52 changes: 50 additions & 2 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
#![cfg_attr(not(feature = "std"), no_std)]

use parity_scale_codec::MaxEncodedLen;
use scale_info::TypeInfo;
use sp_core::{Decode, Encode, RuntimeDebug, H160};
use scale_info::{TypeInfo, prelude::collections::BTreeMap};
use sp_core::{Decode, Encode, RuntimeDebug, H160, U256};
use sp_runtime::{
generic,
traits::{BlakeTwo256, IdentifyAccount, Verify},
FixedU128, MultiSignature, OpaqueExtrinsic, Permill,
DispatchResult, DispatchError
};
use xcm::v4::{prelude::*, Asset, Location};
use xcm_executor::traits::{AssetTransferError, TransferType, XcmAssetTransfers};
Expand All @@ -35,6 +36,9 @@ pub mod currency;
mod salp;
pub mod traits;
pub use salp::*;
pub use frame_support::{dispatch::Parameter, storage::types::StorageMap};
use sp_std::{vec::Vec, boxed::Box};
use core::ops::{Add, Mul};

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -155,6 +159,17 @@ pub type DerivativeIndex = u16;

pub type TimeStampedPrice = orml_oracle::TimestampedValue<Price, Moment>;

pub type PoolTokenIndex = u32;

pub type StableAssetPoolId = u32;

pub type ChainId = u32;

pub type RoundIndex = u32;

pub type QueryId = u64;


#[derive(
Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug, PartialOrd, Ord, scale_info::TypeInfo,
)]
Expand Down Expand Up @@ -344,3 +359,36 @@ impl Default for ExtraFeeInfo {
}
}
}

pub struct Point<Balance, BlockNumber> {
bias: i128, // i128
slope: i128, // dweight / dt
block: BlockNumber,
amount: Balance,
}

pub struct IncentiveConfig<CurrencyId, Balance, BlockNumber, AccountId> {
pub reward_rate: BTreeMap<CurrencyId, Balance>,
pub reward_per_token_stored: BTreeMap<CurrencyId, Balance>,
pub rewards_duration: BlockNumber,
pub period_finish: BlockNumber,
pub last_update_time: BlockNumber,
pub incentive_controller: Option<AccountId>,
pub last_reward: Vec<(CurrencyId, Balance)>,
}

#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
pub enum RedeemTo<AccountId> {
/// Native chain.
Native(AccountId),
/// Astar chain.
Astar(AccountId),
/// Moonbeam chain.
Moonbeam(H160),
/// Hydradx chain.
Hydradx(AccountId),
/// Interlay chain.
Interlay(AccountId),
/// Manta chain.
Manta(AccountId),
}
18 changes: 18 additions & 0 deletions primitives/src/traits/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pub mod traits;
pub mod parachain_staking;
// pub mod slp;
// pub mod stable_pool;
// pub mod ve_minting;
// pub mod vtoken_minting;
// pub mod xcm_interface;

pub use traits::*;
pub use parachain_staking::*;
// pub use slp::*;
// pub use stable_pool::*;
// pub use ve_minting::*;
// pub use vtoken_minting::*;
// pub use xcm_interface::*;



8 changes: 4 additions & 4 deletions primitives/src/traits.rs → primitives/src/traits/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use crate::{
AssetIds, DerivativeIndex, ExtraFeeInfo, LeasePeriod, ParaId, PoolId, RedeemType, TokenId,
TokenSymbol, XcmOperationType,
TokenSymbol, XcmOperationType, Vec
};
use frame_support::pallet_prelude::{DispatchResultWithPostInfo, Weight};
use parity_scale_codec::{Decode, Encode, FullCodec};
Expand All @@ -32,7 +32,7 @@ use sp_runtime::{
},
BoundedVec, DispatchError, DispatchResult, TokenError, TypeId,
};
use sp_std::{fmt::Debug, vec::Vec};
use sp_std::fmt::Debug;

pub trait TokenInfo {
fn name(&self) -> Option<&str>;
Expand Down Expand Up @@ -81,11 +81,11 @@ pub trait MultiCurrencyExt<AccountId> {
}

pub trait BancorHandler<Balance> {
fn add_token(currency_id: super::CurrencyId, amount: Balance) -> DispatchResult;
fn add_token(currency_id: super::super::CurrencyId, amount: Balance) -> DispatchResult;
}

impl<Balance> BancorHandler<Balance> for () {
fn add_token(_currency_id: super::CurrencyId, _amount: Balance) -> DispatchResult {
fn add_token(_currency_id: super::super::CurrencyId, _amount: Balance) -> DispatchResult {
DispatchResult::from(DispatchError::Token(TokenError::FundsUnavailable))
}
}
Expand Down
Loading