Skip to content

Commit 024a304

Browse files
authored
Merge pull request #2271 from subtrahend-labs/taoflow-flow-calc-hotfix
hotfix: taoflow calc to use original methodology with user LPs now re…
2 parents 3face26 + b49791a commit 024a304

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,6 @@ impl<T: Config> Pallet<T> {
692692
price_limit: TaoCurrency,
693693
drop_fees: bool,
694694
) -> Result<TaoCurrency, DispatchError> {
695-
// Record the protocol TAO before the swap.
696-
let protocol_tao = Self::get_protocol_tao(netuid);
697-
698695
// Decrease alpha on subnet
699696
let actual_alpha_decrease =
700697
Self::decrease_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid, alpha);
@@ -703,13 +700,6 @@ impl<T: Config> Pallet<T> {
703700
let swap_result =
704701
Self::swap_alpha_for_tao(netuid, actual_alpha_decrease, price_limit, drop_fees)?;
705702

706-
// Record the protocol TAO after the swap.
707-
let protocol_tao_after = Self::get_protocol_tao(netuid);
708-
// This should decrease as we are removing TAO from the protocol.
709-
let protocol_tao_delta: TaoCurrency = protocol_tao.saturating_sub(protocol_tao_after);
710-
// Use max to overstate the TAO flow from the protocol.
711-
let tao_flow = protocol_tao_delta.max(swap_result.amount_paid_out.into());
712-
713703
// Refund the unused alpha (in case if limit price is hit)
714704
let refund = actual_alpha_decrease.saturating_sub(
715705
swap_result
@@ -736,7 +726,7 @@ impl<T: Config> Pallet<T> {
736726
// }
737727

738728
// Record TAO outflow
739-
Self::record_tao_outflow(netuid, tao_flow);
729+
Self::record_tao_outflow(netuid, swap_result.amount_paid_out.into());
740730

741731
LastColdkeyHotkeyStakeBlock::<T>::insert(coldkey, hotkey, Self::get_current_block_as_u64());
742732

@@ -775,20 +765,9 @@ impl<T: Config> Pallet<T> {
775765
set_limit: bool,
776766
drop_fees: bool,
777767
) -> Result<AlphaCurrency, DispatchError> {
778-
// Record the protocol TAO before the swap.
779-
let protocol_tao = Self::get_protocol_tao(netuid);
780-
781768
// Swap the tao to alpha.
782769
let swap_result = Self::swap_tao_for_alpha(netuid, tao, price_limit, drop_fees)?;
783770

784-
// Record the protocol TAO after the swap.
785-
let protocol_tao_after = Self::get_protocol_tao(netuid);
786-
787-
// This should increase as we are adding TAO to the protocol.
788-
let protocol_tao_delta: TaoCurrency = protocol_tao_after.saturating_sub(protocol_tao);
789-
// Use min to understate the TAO flow into the protocol.
790-
let tao_flow = protocol_tao_delta.min(tao);
791-
792771
ensure!(
793772
!swap_result.amount_paid_out.is_zero(),
794773
Error::<T>::AmountTooLow
@@ -824,7 +803,7 @@ impl<T: Config> Pallet<T> {
824803
}
825804

826805
// Record TAO inflow
827-
Self::record_tao_inflow(netuid, tao_flow);
806+
Self::record_tao_inflow(netuid, swap_result.amount_paid_in.into());
828807

829808
LastColdkeyHotkeyStakeBlock::<T>::insert(coldkey, hotkey, Self::get_current_block_as_u64());
830809

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
220220
// `spec_version`, and `authoring_version` are the same between Wasm and native.
221221
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
222222
// the compatible custom types.
223-
spec_version: 351,
223+
spec_version: 352,
224224
impl_version: 1,
225225
apis: RUNTIME_API_VERSIONS,
226226
transaction_version: 1,

0 commit comments

Comments
 (0)