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
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.

4 changes: 2 additions & 2 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@ impl<T: Config + pallet_balances::Config<Balance = u64>>
pallet_balances::Pallet::<T>::free_balance(account_id)
}

fn alpha_balance(netuid: u16, account_id: &T::AccountId) -> u64 {
TotalHotkeyAlpha::<T>::get(account_id, netuid)
fn alpha_balance(netuid: u16, coldkey: &T::AccountId, hotkey: &T::AccountId) -> u64 {
Self::get_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid)
}
}
4 changes: 2 additions & 2 deletions pallets/subtensor/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ impl LiquidityDataProvider<AccountId> for SubtensorModule {
Balances::free_balance(account_id)
}

fn alpha_balance(netuid: u16, account_id: &AccountId) -> u64 {
TotalHotkeyAlpha::<Test>::get(account_id, netuid)
fn alpha_balance(netuid: u16, coldkey: &AccountId, hotkey: &AccountId) -> u64 {
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/swap-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ pub trait LiquidityDataProvider<AccountId> {
fn tao_reserve(netuid: u16) -> u64;
fn alpha_reserve(netuid: u16) -> u64;
fn tao_balance(account_id: &AccountId) -> u64;
fn alpha_balance(netuid: u16, account_id: &AccountId) -> u64;
fn alpha_balance(netuid: u16, coldkey_account_id: &AccountId, hotkey_account_id: &AccountId) -> u64;
}
2 changes: 2 additions & 0 deletions pallets/swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sp-std = { workspace = true }
substrate-fixed = { workspace = true }

subtensor-swap-interface = { workspace = true }
pallet-subtensor = { version = "4.0.0-dev", default-features = false, path = "../subtensor" }

[lints]
workspace = true
Expand All @@ -33,6 +34,7 @@ std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-subtensor/std",
"subtensor-swap-interface/std",
"safe-math/std",
"scale-info/std",
Expand Down
23 changes: 15 additions & 8 deletions pallets/swap/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ construct_runtime!(

pub type Block = frame_system::mocking::MockBlock<Test>;
pub type AccountId = u32;
pub const OK_ACCOUNT_ID: AccountId = 1;
pub const OK_COLDKEY_ACCOUNT_ID: AccountId = 1;
pub const OK_HOTKEY_ACCOUNT_ID: AccountId = 1000;

parameter_types! {
pub const BlockHashCount: u64 = 250;
Expand Down Expand Up @@ -70,24 +71,30 @@ parameter_types! {
pub struct MockLiquidityProvider;

impl LiquidityDataProvider<AccountId> for MockLiquidityProvider {
fn tao_reserve(_: u16) -> u64 {
1_000_000_000_000
fn tao_reserve(netuid: u16) -> u64 {
match netuid {
123 => 1_000,
_ => 1_000_000_000_000
}
}

fn alpha_reserve(_: u16) -> u64 {
4_000_000_000_000
fn alpha_reserve(netuid: u16) -> u64 {
match netuid {
123 => 1,
_ => 4_000_000_000_000
}
}

fn tao_balance(account_id: &AccountId) -> u64 {
if *account_id == OK_ACCOUNT_ID {
if *account_id == OK_COLDKEY_ACCOUNT_ID {
100_000_000_000_000
} else {
1_000_000_000
}
}

fn alpha_balance(_: u16, account_id: &AccountId) -> u64 {
if *account_id == OK_ACCOUNT_ID {
fn alpha_balance(_: u16, coldkey_account_id: &AccountId, hotkey_account_id: &AccountId) -> u64 {
if (*coldkey_account_id == OK_COLDKEY_ACCOUNT_ID) && (*hotkey_account_id == OK_HOTKEY_ACCOUNT_ID) {
100_000_000_000_000
} else {
1_000_000_000
Expand Down
Loading
Loading