@@ -1292,6 +1292,7 @@ def ProcessRecoverStake(self):
12921292 def GetStake (self , account , args = None ):
12931293 stake = self .local .db .get ("stake" )
12941294 usePool = self .local .db .get ("usePool" )
1295+ useController = self .local .db .get ("useController" )
12951296 stakePercent = self .local .db .get ("stakePercent" , 99 )
12961297 vconfig = self .GetValidatorConfig ()
12971298 validators = vconfig .get ("validators" )
@@ -1408,6 +1409,7 @@ def GetValidatorWallet(self, mode="stake"):
14081409
14091410 def ElectionEntry (self , args = None ):
14101411 usePool = self .local .db .get ("usePool" )
1412+ useController = self .local .db .get ("useController" )
14111413 wallet = self .GetValidatorWallet ()
14121414 addrB64 = wallet .addrB64
14131415 if wallet is None :
@@ -1500,9 +1502,9 @@ def ElectionEntry(self, args=None):
15001502 resultFilePath = self .SignBocWithWallet (wallet , resultFilePath , pool .addrB64 , 1.3 )
15011503 self .SendFile (resultFilePath , wallet )
15021504 elif useController :
1503- var1 = self .CreateElectionRequest (controllerAddr , startWorkTime , adnlAddr , maxFactor )
1505+ var1 = self .CreateElectionRequest (controllerAddr , startWorkTime , adnl_addr , maxFactor )
15041506 validatorSignature = self .GetValidatorSignature (validatorKey , var1 )
1505- validatorPubkey , resultFilePath = self .SignElectionRequestWithController (controllerAddr , startWorkTime , adnlAddr , validatorPubkey_b64 , validatorSignature , maxFactor , stake )
1507+ validatorPubkey , resultFilePath = self .SignElectionRequestWithController (controllerAddr , startWorkTime , adnl_addr , validatorPubkey_b64 , validatorSignature , maxFactor , stake )
15061508
15071509 # Send boc file to TON
15081510 resultFilePath = self .SignBocWithWallet (wallet , resultFilePath , controllerAddr , 1.03 )
@@ -3691,20 +3693,20 @@ def GetPoolData(self, addrB64):
36913693 #end define
36923694
36933695 def GetLiquidPoolAddr (self ):
3694- liquid_pool_addr = local .db .get ("liquid_pool_addr" )
3696+ liquid_pool_addr = self . local .db .get ("liquid_pool_addr" )
36953697 if liquid_pool_addr is None :
36963698 raise Exception ("GetLiquidPoolAddr error: liquid_pool_addr not set" )
36973699 return liquid_pool_addr
36983700 #end define
36993701
37003702 def CreateControllers (self ):
37013703 new_controllers = self .GetControllers ()
3702- old_controllers = local .db .get ("using_controllers" , list ())
3704+ old_controllers = self . local .db .get ("using_controllers" , list ())
37033705 if new_controllers == old_controllers :
37043706 return
37053707 #end if
37063708
3707- local .add_log ("start CreateControllers function" , "debug" )
3709+ self . local .add_log ("start CreateControllers function" , "debug" )
37083710 wallet = self .GetValidatorWallet ()
37093711 liquid_pool_addr = self .GetLiquidPoolAddr ()
37103712 contractPath = self .contractsDir + "jetton_pool/"
@@ -3721,9 +3723,9 @@ def CreateControllers(self):
37213723 self .SendFile (resultFilePath1 , wallet )
37223724
37233725 # Сохранить новые контроллеры
3724- local .db ["old_controllers" ] = old_controllers
3725- local .db ["using_controllers" ] = new_controllers
3726- local .save ()
3726+ self . local .db ["old_controllers" ] = old_controllers
3727+ self . local .db ["using_controllers" ] = new_controllers
3728+ self . local .save ()
37273729 #end define
37283730
37293731 def GetControllerAddress (self , controller_id ):
@@ -3741,9 +3743,9 @@ def GetControllerAddress(self, controller_id):
37413743 #end define
37423744
37433745 def CheckController (self , controllerAddr ):
3744- local .add_log ("start CheckController function" , "debug" )
3746+ self . local .add_log ("start CheckController function" , "debug" )
37453747 controllerData = self .GetControllerData (controllerAddr )
3746- using_controllers = local .db .get ("using_controllers" , list ())
3748+ using_controllers = self . local .db .get ("using_controllers" , list ())
37473749 if controllerData is None :
37483750 raise Exception (f"CheckController error: controller not initialized. Use new_controllers" )
37493751 if controllerData ["approved" ] != - 1 :
@@ -3753,7 +3755,7 @@ def CheckController(self, controllerAddr):
37533755 #end define
37543756
37553757 def GetControllers (self ):
3756- local .add_log ("start GetControllers function" , "debug" )
3758+ self . local .add_log ("start GetControllers function" , "debug" )
37573759 controller0 = self .GetControllerAddress (controller_id = 0 )
37583760 controller1 = self .GetControllerAddress (controller_id = 1 )
37593761 controllers = [controller0 , controller1 ]
@@ -3782,10 +3784,10 @@ def GetControllerRequiredBalanceForLoan(self, controllerAddr, credit, interest):
37823784 #end define
37833785
37843786 def IsControllerReadyToStake (self , addrB64 ):
3785- stop_controllers_list = local .db .get ("stop_controllers_list" )
3787+ stop_controllers_list = self . local .db .get ("stop_controllers_list" )
37863788 if stop_controllers_list is not None and addrB64 in stop_controllers_list :
37873789 return False
3788- now = GetTimestamp ()
3790+ now = get_timestamp ()
37893791 config15 = self .GetConfig15 ()
37903792 controllerData = self .GetControllerData (addrB64 )
37913793 if controllerData is None :
@@ -3817,16 +3819,16 @@ def GetControllerData(self, controllerAddr):
38173819 #end define
38183820
38193821 def CreateLoanRequest (self , controllerAddr ):
3820- local .add_log ("start CreateLoanRequest function" , "debug" )
3821- min_loan = local .db .get ("min_loan" , 41000 )
3822- max_loan = local .db .get ("max_loan" , 43000 )
3823- max_interest_percent = local .db .get ("max_interest_percent" , 1.5 )
3822+ self . local .add_log ("start CreateLoanRequest function" , "debug" )
3823+ min_loan = self . local .db .get ("min_loan" , 41000 )
3824+ max_loan = self . local .db .get ("max_loan" , 43000 )
3825+ max_interest_percent = self . local .db .get ("max_interest_percent" , 1.5 )
38243826 max_interest = int (max_interest_percent / 100 * 16777216 )
38253827
38263828 # Проверить наличие действующего кредита
38273829 controllerData = self .GetControllerData (controllerAddr )
38283830 if controllerData ["borrowed_amount" ] > 0 :
3829- local .add_log ("CreateLoanRequest warning: past loan found" , "warning" )
3831+ self . local .add_log ("CreateLoanRequest warning: past loan found" , "warning" )
38303832 return
38313833 #end define
38323834
@@ -3873,15 +3875,15 @@ def CalculateLoanAmount(self, min_loan, max_loan, max_interest):
38733875 #end define
38743876
38753877 def CalculateLoanAmount_test (self ):
3876- min_loan = local .db .get ("min_loan" , 41000 )
3877- max_loan = local .db .get ("max_loan" , 43000 )
3878- max_interest_percent = local .db .get ("max_interest_percent" , 1.5 )
3878+ min_loan = self . local .db .get ("min_loan" , 41000 )
3879+ max_loan = self . local .db .get ("max_loan" , 43000 )
3880+ max_interest_percent = self . local .db .get ("max_interest_percent" , 1.5 )
38793881 max_interest = int (max_interest_percent / 100 * 16777216 )
38803882 return self .CalculateLoanAmount (min_loan , max_loan , max_interest )
38813883 #end define
38823884
38833885 def WaitLoan (self , controllerAddr ):
3884- local .add_log ("start WaitLoan function" , "debug" )
3886+ self . local .add_log ("start WaitLoan function" , "debug" )
38853887 for i in range (10 ):
38863888 time .sleep (3 )
38873889 controllerData = self .GetControllerData (controllerAddr )
@@ -3891,15 +3893,15 @@ def WaitLoan(self, controllerAddr):
38913893 #end define
38923894
38933895 def ReturnUnusedLoan (self , controllerAddr ):
3894- local .add_log ("start ReturnUnusedLoan function" , "debug" )
3896+ self . local .add_log ("start ReturnUnusedLoan function" , "debug" )
38953897 wallet = self .GetValidatorWallet ()
38963898 fileName = self .contractsDir + "jetton_pool/fift-scripts/return_unused_loan.boc"
38973899 resultFilePath = self .SignBocWithWallet (wallet , fileName , controllerAddr , 1.05 )
38983900 self .SendFile (resultFilePath , wallet )
38993901 #end define
39003902
39013903 def DepositToController (self , controllerAddr , amount ):
3902- local .add_log ("start DepositToController function" , "debug" )
3904+ self . local .add_log ("start DepositToController function" , "debug" )
39033905 wallet = self .GetValidatorWallet ()
39043906 fileName = self .contractsDir + "jetton_pool/fift-scripts/top-up.boc"
39053907 resultFilePath = self .SignBocWithWallet (wallet , fileName , controllerAddr , amount )
@@ -3922,7 +3924,7 @@ def WithdrawFromControllerProcess(self, controllerAddr, amount):
39223924 return
39233925 #end if
39243926
3925- local .add_log ("start WithdrawFromControllerProcess function" , "debug" )
3927+ self . local .add_log ("start WithdrawFromControllerProcess function" , "debug" )
39263928 wallet = self .GetValidatorWallet ()
39273929 fiftScript = self .contractsDir + "jetton_pool/fift-scripts/withdraw-controller.fif"
39283930 resultFilePath = self .tempDir + self .nodeName + wallet .name + "_withdraw_request.boc"
@@ -3933,10 +3935,10 @@ def WithdrawFromControllerProcess(self, controllerAddr, amount):
39333935 #end define
39343936
39353937 def PendWithdrawFromController (self , controllerAddr , amount ):
3936- local .add_log ("start PendWithdrawFromController function" , "debug" )
3938+ self . local .add_log ("start PendWithdrawFromController function" , "debug" )
39373939 controllerPendingWithdraws = self .GetControllerPendingWithdraws ()
39383940 controllerPendingWithdraws [controllerAddr ] = amount
3939- local .save ()
3941+ self . local .save ()
39403942 #end define
39413943
39423944 def HandleControllerPendingWithdraw (self , controllerPendingWithdraws , controllerAddr ):
@@ -3947,37 +3949,37 @@ def HandleControllerPendingWithdraw(self, controllerPendingWithdraws, controller
39473949
39483950 def GetControllerPendingWithdraws (self ):
39493951 bname = "controllerPendingWithdraws"
3950- controllerPendingWithdraws = local .db .get (bname )
3952+ controllerPendingWithdraws = self . local .db .get (bname )
39513953 if controllerPendingWithdraws is None :
39523954 controllerPendingWithdraws = dict ()
3953- local .db [bname ] = controllerPendingWithdraws
3955+ self . local .db [bname ] = controllerPendingWithdraws
39543956 return controllerPendingWithdraws
39553957 #end define
39563958
39573959 def SignElectionRequestWithController (self , controllerAddr , startWorkTime , adnlAddr , validatorPubkey_b64 , validatorSignature , maxFactor , stake ):
3958- local .add_log ("start SignElectionRequestWithController function" , "debug" )
3960+ self . local .add_log ("start SignElectionRequestWithController function" , "debug" )
39593961 fileName = self .tempDir + str (startWorkTime ) + "_validator-query.boc"
39603962 fiftScript = self .contractsDir + "jetton_pool/fift-scripts/controller-elect-signed.fif"
39613963 args = [fiftScript , controllerAddr , startWorkTime , maxFactor , adnlAddr , validatorPubkey_b64 , validatorSignature , fileName , stake ]
3962- local .add_log (f"SignElectionRequestWithController args: { args } " , "debug" )
3964+ self . local .add_log (f"SignElectionRequestWithController args: { args } " , "debug" )
39633965 result = self .fift .Run (args )
3964- local .add_log (f"SignElectionRequestWithController result: { result } " , "debug" )
3965- pubkey = Pars (result , "validator public key " , '\n ' )
3966- fileName = Pars (result , "Saved to file " , '\n ' )
3966+ self . local .add_log (f"SignElectionRequestWithController result: { result } " , "debug" )
3967+ pubkey = parse (result , "validator public key " , '\n ' )
3968+ fileName = parse (result , "Saved to file " , '\n ' )
39673969 return pubkey , fileName
39683970 #end define
39693971
39703972 def ControllersUpdateValidatorSet (self ):
3971- local .add_log ("start ControllersUpdateValidatorSet function" , "debug" )
3972- using_controllers = local .db .get ("using_controllers" )
3973- user_controllers = local .db .get ("user_controllers" , list ())
3974- old_controllers = local .db .get ("old_controllers" , list ())
3973+ self . local .add_log ("start ControllersUpdateValidatorSet function" , "debug" )
3974+ using_controllers = self . local .db .get ("using_controllers" )
3975+ user_controllers = self . local .db .get ("user_controllers" , list ())
3976+ old_controllers = self . local .db .get ("old_controllers" , list ())
39753977 for controller in using_controllers + user_controllers + old_controllers :
39763978 self .ControllerUpdateValidatorSet (controller )
39773979 #end define
39783980
39793981 def ControllerUpdateValidatorSet (self , controllerAddr ):
3980- local .add_log ("start ControllerUpdateValidatorSet function" , "debug" )
3982+ self . local .add_log ("start ControllerUpdateValidatorSet function" , "debug" )
39813983 wallet = self .GetValidatorWallet ()
39823984 controllers = self .GetControllers ()
39833985 controllerData = self .GetControllerData (controllerAddr )
@@ -4012,48 +4014,48 @@ def ControllerUpdateValidatorSet(self, controllerAddr):
40124014 #end define
40134015
40144016 def ControllerUpdateValidatorSetProcess (self , controllerAddr , wallet ):
4015- local .add_log ("start ControllerUpdateValidatorSetProcess function" , "debug" )
4017+ self . local .add_log ("start ControllerUpdateValidatorSetProcess function" , "debug" )
40164018 fileName = self .contractsDir + "jetton_pool/fift-scripts/update_validator_hash.boc"
40174019 resultFilePath = self .SignBocWithWallet (wallet , fileName , controllerAddr , 1.07 )
40184020 self .SendFile (resultFilePath , wallet )
4019- local .add_log ("ControllerUpdateValidatorSetProcess completed" )
4021+ self . local .add_log ("ControllerUpdateValidatorSetProcess completed" )
40204022 #end define
40214023
40224024 def ControllerRecoverStake (self , controllerAddr ):
40234025 wallet = self .GetValidatorWallet ()
4024- local .add_log ("start ControllerRecoverStake function" , "debug" )
4026+ self . local .add_log ("start ControllerRecoverStake function" , "debug" )
40254027 fileName = self .contractsDir + "jetton_pool/fift-scripts/recover_stake.boc"
40264028 resultFilePath = self .SignBocWithWallet (wallet , fileName , controllerAddr , 1.04 )
40274029 self .SendFile (resultFilePath , wallet )
4028- local .add_log ("ControllerRecoverStake completed" )
4030+ self . local .add_log ("ControllerRecoverStake completed" )
40294031 #end define
40304032
40314033 def StopController (self , controllerAddr ):
4032- stop_controllers_list = local .db .get ("stop_controllers_list" )
4034+ stop_controllers_list = self . local .db .get ("stop_controllers_list" )
40334035 if stop_controllers_list is None :
40344036 stop_controllers_list = list ()
40354037 if controllerAddr not in stop_controllers_list :
40364038 stop_controllers_list .append (controllerAddr )
4037- local .db ["stop_controllers_list" ] = stop_controllers_list
4039+ self . local .db ["stop_controllers_list" ] = stop_controllers_list
40384040
4039- user_controllers = local .db .get ("user_controllers" )
4041+ user_controllers = self . local .db .get ("user_controllers" )
40404042 if user_controllers is not None and controllerAddr in user_controllers :
40414043 user_controllers .remove (controllerAddr )
4042- local .save ()
4044+ self . local .save ()
40434045 #end define
40444046
40454047 def AddController (self , controllerAddr ):
4046- user_controllers = local .db .get ("user_controllers" )
4048+ user_controllers = self . local .db .get ("user_controllers" )
40474049 if user_controllers is None :
40484050 user_controllers = list ()
40494051 if controllerAddr not in user_controllers :
40504052 user_controllers .append (controllerAddr )
4051- local .db ["user_controllers" ] = user_controllers
4053+ self . local .db ["user_controllers" ] = user_controllers
40524054
4053- stop_controllers_list = local .db .get ("stop_controllers_list" )
4055+ stop_controllers_list = self . local .db .get ("stop_controllers_list" )
40544056 if stop_controllers_list is not None and controllerAddr in stop_controllers_list :
40554057 stop_controllers_list .remove (controllerAddr )
4056- local .save ()
4058+ self . local .save ()
40574059 #end define
40584060
40594061 def CheckLiquidPool (self ):
0 commit comments