Skip to content
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
254 changes: 11 additions & 243 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pallet-subtensor-swap-runtime-api = { path = "pallets/swap/runtime-api", default
pallet-subtensor-swap-rpc = { path = "pallets/swap/rpc", default-features = false }
procedural-fork = { path = "support/procedural-fork", default-features = false }
safe-math = { path = "primitives/safe-math", default-features = false }
safe-bigmath = { package = "safe-bigmath", default-features = false, git = "https://github.com/sam0x17/safe-bigmath" }
share-pool = { path = "primitives/share-pool", default-features = false }
subtensor-macros = { path = "support/macros", default-features = false }
subtensor-custom-rpc = { default-features = false, path = "pallets/subtensor/rpc" }
Expand Down
4 changes: 2 additions & 2 deletions chain-extensions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use pallet_subtensor_proxy as pallet_proxy;
use pallet_subtensor_proxy::WeightInfo;
use sp_runtime::{DispatchError, Weight, traits::StaticLookup};
use sp_std::marker::PhantomData;
use substrate_fixed::types::U64F64;
use substrate_fixed::types::U96F32;
use subtensor_runtime_common::{AlphaCurrency, NetUid, ProxyType, TaoCurrency};
use subtensor_swap_interface::SwapHandler;

Expand Down Expand Up @@ -520,7 +520,7 @@ where
netuid.into(),
);

let price = current_alpha_price.saturating_mul(U64F64::from_num(1_000_000_000));
let price = current_alpha_price.saturating_mul(U96F32::from_num(1_000_000_000));
let price: u64 = price.saturating_to_num();

let encoded_result = price.encode();
Expand Down
22 changes: 8 additions & 14 deletions chain-extensions/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sp_runtime::{
traits::{BlakeTwo256, Convert, IdentityLookup},
};
use sp_std::{cell::RefCell, cmp::Ordering, sync::OnceLock};
use subtensor_runtime_common::{AlphaCurrency, AuthorshipInfo, NetUid, TaoCurrency};
use subtensor_runtime_common::{AlphaCurrency, NetUid, TaoCurrency};

type Block = frame_system::mocking::MockBlock<Test>;

Expand Down Expand Up @@ -262,14 +262,6 @@ parameter_types! {
pub const AnnouncementDepositFactor: Balance = 1;
}

pub struct MockAuthorshipProvider;

impl AuthorshipInfo<U256> for MockAuthorshipProvider {
fn author() -> Option<U256> {
Some(U256::from(12345u64))
}
}

parameter_types! {
pub const InitialMinAllowedWeights: u16 = 0;
pub const InitialEmissionValue: u16 = 0;
Expand Down Expand Up @@ -333,8 +325,9 @@ parameter_types! {
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
pub const InitialYuma3On: bool = false; // Default value for Yuma3On
pub const InitialColdkeySwapAnnouncementDelay: u64 = 50;
pub const InitialColdkeySwapReannouncementDelay: u64 = 10;
// pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED)
pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
pub const InitialColdkeySwapRescheduleDuration: u64 = 24 * 60 * 60 / 12; // Default as 1 day
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
pub const InitialTaoWeight: u64 = 0; // 100% global weight.
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
Expand Down Expand Up @@ -404,8 +397,8 @@ impl pallet_subtensor::Config for Test {
type LiquidAlphaOn = InitialLiquidAlphaOn;
type Yuma3On = InitialYuma3On;
type Preimages = Preimage;
type InitialColdkeySwapAnnouncementDelay = InitialColdkeySwapAnnouncementDelay;
type InitialColdkeySwapReannouncementDelay = InitialColdkeySwapReannouncementDelay;
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
type InitialColdkeySwapRescheduleDuration = InitialColdkeySwapRescheduleDuration;
type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration;
type InitialTaoWeight = InitialTaoWeight;
type InitialEmaPriceHalvingPeriod = InitialEmaPriceHalvingPeriod;
Expand All @@ -419,13 +412,13 @@ impl pallet_subtensor::Config for Test {
type MaxImmuneUidsPercentage = MaxImmuneUidsPercentage;
type CommitmentsInterface = CommitmentsI;
type EvmKeyAssociateRateLimit = EvmKeyAssociateRateLimit;
type AuthorshipProvider = MockAuthorshipProvider;
}

// Swap-related parameter types
parameter_types! {
pub const SwapProtocolId: PalletId = PalletId(*b"ten/swap");
pub const SwapMaxFeeRate: u16 = 10000; // 15.26%
pub const SwapMaxPositions: u32 = 100;
pub const SwapMinimumLiquidity: u64 = 1_000;
pub const SwapMinimumReserve: NonZeroU64 = NonZeroU64::new(100).unwrap();
}
Expand All @@ -437,6 +430,7 @@ impl pallet_subtensor_swap::Config for Test {
type TaoReserve = TaoCurrencyReserve<Self>;
type AlphaReserve = AlphaCurrencyReserve<Self>;
type MaxFeeRate = SwapMaxFeeRate;
type MaxPositions = SwapMaxPositions;
type MinimumLiquidity = SwapMinimumLiquidity;
type MinimumReserve = SwapMinimumReserve;
type WeightInfo = ();
Expand Down
4 changes: 2 additions & 2 deletions chain-extensions/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use pallet_subtensor::DefaultMinStake;
use sp_core::Get;
use sp_core::U256;
use sp_runtime::DispatchError;
use substrate_fixed::types::U64F64;
use substrate_fixed::types::U96F32;
use subtensor_runtime_common::{AlphaCurrency, Currency as CurrencyTrait, NetUid, TaoCurrency};
use subtensor_swap_interface::SwapHandler;

Expand Down Expand Up @@ -985,7 +985,7 @@ fn get_alpha_price_returns_encoded_price() {
<pallet_subtensor_swap::Pallet<mock::Test> as SwapHandler>::current_alpha_price(
netuid.into(),
);
let expected_price_scaled = expected_price.saturating_mul(U64F64::from_num(1_000_000_000));
let expected_price_scaled = expected_price.saturating_mul(U96F32::from_num(1_000_000_000));
let expected_price_u64: u64 = expected_price_scaled.saturating_to_num();

let mut env = MockEnv::new(FunctionId::GetAlphaPriceV1, caller, netuid.encode());
Expand Down
6 changes: 0 additions & 6 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ pub trait BalanceOps<AccountId> {
) -> Result<AlphaCurrency, DispatchError>;
}

/// Allows to query the current block author
pub trait AuthorshipInfo<AccountId> {
/// Return the current block author
fn author() -> Option<AccountId>;
}

pub mod time {
use super::*;

Expand Down
Loading
Loading