@@ -4,10 +4,8 @@ use common_structs::{FarmToken, FarmTokenAttributes, Nonce};
44use config:: ConfigModule ;
55use contexts:: storage_cache:: StorageCache ;
66use core:: marker:: PhantomData ;
7- use farm_token:: FarmTokenModule ;
87use fixed_supply_token:: FixedSupplyToken ;
98use mergeable:: Mergeable ;
10- use multiversx_sc_modules:: transfer_role_proxy:: PaymentsVec ;
119use rewards:: RewardsModule ;
1210
1311pub trait AllBaseFarmImplTraits :
@@ -184,63 +182,6 @@ pub trait FarmContract {
184182
185183 new_attributes. into ( )
186184 }
187-
188- fn check_and_update_user_farm_position (
189- sc : & Self :: FarmSc ,
190- user : & ManagedAddress < <Self :: FarmSc as ContractBase >:: Api > ,
191- farm_positions : & PaymentsVec < <Self :: FarmSc as ContractBase >:: Api > ,
192- ) {
193- let farm_token_mapper = sc. farm_token ( ) ;
194- for farm_position in farm_positions {
195- farm_token_mapper. require_same_token ( & farm_position. token_identifier ) ;
196-
197- if sc. is_old_farm_position ( farm_position. token_nonce ) {
198- continue ;
199- }
200-
201- let token_attributes: FarmTokenAttributes < <Self :: FarmSc as ContractBase >:: Api > =
202- farm_token_mapper. get_token_attributes ( farm_position. token_nonce ) ;
203-
204- if & token_attributes. original_owner != user {
205- Self :: decrease_user_farm_position ( sc, & farm_position) ;
206- Self :: increase_user_farm_position ( sc, user, & farm_position. amount ) ;
207- }
208- }
209- }
210-
211- #[ inline]
212- fn increase_user_farm_position (
213- sc : & Self :: FarmSc ,
214- user : & ManagedAddress < <Self :: FarmSc as ContractBase >:: Api > ,
215- increase_farm_position_amount : & BigUint < <Self :: FarmSc as ContractBase >:: Api > ,
216- ) {
217- sc. user_total_farm_position ( user)
218- . update ( |total_farm_position| * total_farm_position += increase_farm_position_amount) ;
219- }
220-
221- fn decrease_user_farm_position (
222- sc : & Self :: FarmSc ,
223- farm_position : & EsdtTokenPayment < <Self :: FarmSc as ContractBase >:: Api > ,
224- ) {
225- if sc. is_old_farm_position ( farm_position. token_nonce ) {
226- return ;
227- }
228-
229- let farm_token_mapper = sc. farm_token ( ) ;
230- let token_attributes: FarmTokenAttributes < <Self :: FarmSc as ContractBase >:: Api > =
231- farm_token_mapper. get_token_attributes ( farm_position. token_nonce ) ;
232-
233- let user_total_farm_position_mapper =
234- sc. user_total_farm_position ( & token_attributes. original_owner ) ;
235- let mut user_total_farm_position = user_total_farm_position_mapper. get ( ) ;
236-
237- if user_total_farm_position > farm_position. amount {
238- user_total_farm_position -= & farm_position. amount ;
239- user_total_farm_position_mapper. set ( user_total_farm_position) ;
240- } else {
241- user_total_farm_position_mapper. clear ( ) ;
242- }
243- }
244185}
245186
246187pub struct DefaultFarmWrapper < T >
0 commit comments