Skip to content

Commit 1691765

Browse files
authored
Merge pull request #1623 from opentensor/feat/uniswapv3-lp-cleanup
Fix get_total_stake_for_hotkey
2 parents 930d079 + 0109dd2 commit 1691765

File tree

7 files changed

+197
-221
lines changed

7 files changed

+197
-221
lines changed

pallets/subtensor/src/staking/helpers.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,15 @@ impl<T: Config> Pallet<T> {
4747
Self::get_all_subnet_netuids()
4848
.into_iter()
4949
.map(|netuid| {
50-
let alpha = Self::get_stake_for_hotkey_on_subnet(hotkey, netuid);
51-
T::SwapInterface::swap(
52-
netuid,
53-
OrderType::Sell,
54-
alpha,
55-
T::SwapInterface::max_price(),
56-
true,
57-
)
58-
.map(|r| {
59-
let fee: u64 = U96F32::saturating_from_num(r.fee_paid)
60-
.saturating_mul(T::SwapInterface::current_alpha_price(netuid))
61-
.saturating_to_num();
62-
r.amount_paid_out.saturating_add(fee)
63-
})
64-
.unwrap_or_default()
50+
let alpha = U96F32::saturating_from_num(Self::get_stake_for_hotkey_on_subnet(
51+
hotkey, netuid,
52+
));
53+
let alpha_price =
54+
U96F32::saturating_from_num(T::SwapInterface::current_alpha_price(netuid));
55+
alpha.saturating_mul(alpha_price)
6556
})
66-
.sum()
57+
.sum::<U96F32>()
58+
.saturating_to_num::<u64>()
6759
}
6860

6961
// Returns the total amount of stake under a coldkey

pallets/subtensor/src/tests/epoch.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use sp_core::{Get, U256};
1313
use substrate_fixed::types::I32F32;
1414
use subtensor_swap_interface::SwapHandler;
1515

16-
use super::mock;
1716
use super::mock::*;
1817
use crate::epoch::math::safe_exp;
1918
use crate::*;

pallets/subtensor/src/tests/recycle_alpha.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use approx::assert_abs_diff_eq;
22
use frame_support::{assert_noop, assert_ok, traits::Currency};
3-
use serde::de::Expected;
43
use sp_core::U256;
5-
use sp_core::bytes::ExpectedLen;
64

75
use super::mock;
86
use super::mock::*;

pallets/subtensor/src/tests/registration.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use frame_support::{assert_err, assert_noop, assert_ok};
88
use frame_system::Config;
99
use sp_core::U256;
1010
use sp_runtime::traits::{DispatchInfoOf, SignedExtension};
11-
use subtensor_swap_interface::SwapHandler;
1211

1312
use super::mock;
1413
use super::mock::*;

pallets/swap-interface/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub trait SwapHandler<AccountId> {
4747
pub struct SwapResult {
4848
pub amount_paid_out: u64,
4949
pub fee_paid: u64,
50-
pub refund: u64,
5150
// calculated new tao/alpha reserves
5251
pub new_tao_reserve: u64,
5352
pub new_alpha_reserve: u64,

0 commit comments

Comments
 (0)