@@ -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
0 commit comments