@@ -694,9 +694,6 @@ impl<T: Config> Pallet<T> {
694694 price_limit : TaoCurrency ,
695695 drop_fees : bool ,
696696 ) -> Result < TaoCurrency , DispatchError > {
697- // Record the protocol TAO before the swap.
698- let protocol_tao = Self :: get_protocol_tao ( netuid) ;
699-
700697 // Decrease alpha on subnet
701698 let actual_alpha_decrease =
702699 Self :: decrease_stake_for_hotkey_and_coldkey_on_subnet ( hotkey, coldkey, netuid, alpha) ;
@@ -705,13 +702,6 @@ impl<T: Config> Pallet<T> {
705702 let swap_result =
706703 Self :: swap_alpha_for_tao ( netuid, actual_alpha_decrease, price_limit, drop_fees) ?;
707704
708- // Record the protocol TAO after the swap.
709- let protocol_tao_after = Self :: get_protocol_tao ( netuid) ;
710- // This should decrease as we are removing TAO from the protocol.
711- let protocol_tao_delta: TaoCurrency = protocol_tao. saturating_sub ( protocol_tao_after) ;
712- // Use max to overstate the TAO flow from the protocol.
713- let tao_flow = protocol_tao_delta. max ( swap_result. amount_paid_out . into ( ) ) ;
714-
715705 // Refund the unused alpha (in case if limit price is hit)
716706 let refund = actual_alpha_decrease. saturating_sub (
717707 swap_result
@@ -738,7 +728,7 @@ impl<T: Config> Pallet<T> {
738728 // }
739729
740730 // Record TAO outflow
741- Self :: record_tao_outflow ( netuid, tao_flow ) ;
731+ Self :: record_tao_outflow ( netuid, swap_result . amount_paid_out . into ( ) ) ;
742732
743733 LastColdkeyHotkeyStakeBlock :: < T > :: insert ( coldkey, hotkey, Self :: get_current_block_as_u64 ( ) ) ;
744734
@@ -777,20 +767,9 @@ impl<T: Config> Pallet<T> {
777767 set_limit : bool ,
778768 drop_fees : bool ,
779769 ) -> Result < AlphaCurrency , DispatchError > {
780- // Record the protocol TAO before the swap.
781- let protocol_tao = Self :: get_protocol_tao ( netuid) ;
782-
783770 // Swap the tao to alpha.
784771 let swap_result = Self :: swap_tao_for_alpha ( netuid, tao, price_limit, drop_fees) ?;
785772
786- // Record the protocol TAO after the swap.
787- let protocol_tao_after = Self :: get_protocol_tao ( netuid) ;
788-
789- // This should increase as we are adding TAO to the protocol.
790- let protocol_tao_delta: TaoCurrency = protocol_tao_after. saturating_sub ( protocol_tao) ;
791- // Use min to understate the TAO flow into the protocol.
792- let tao_flow = protocol_tao_delta. min ( tao) ;
793-
794773 ensure ! (
795774 !swap_result. amount_paid_out. is_zero( ) ,
796775 Error :: <T >:: AmountTooLow
@@ -826,7 +805,7 @@ impl<T: Config> Pallet<T> {
826805 }
827806
828807 // Record TAO inflow
829- Self :: record_tao_inflow ( netuid, tao_flow ) ;
808+ Self :: record_tao_inflow ( netuid, swap_result . amount_paid_in . into ( ) ) ;
830809
831810 LastColdkeyHotkeyStakeBlock :: < T > :: insert ( coldkey, hotkey, Self :: get_current_block_as_u64 ( ) ) ;
832811
0 commit comments