MCPcopy Create free account
hub / github.com/ccxt/ccxt / initialize_client

Method initialize_client

python/ccxt/grvt.py:555–611  ·  view source on GitHub ↗
(self, params={})

Source from the content-addressed store, hash-verified

553 return response
554
555 def initialize_client(self, params={}):
556 builderFee = self.safe_bool(params, 'builderFee', self.safe_bool(self.options, 'builderFee', True)) # we shouldn't omit here
557 if not builderFee:
558 return False # skip if builder fee is not enabled
559 approvedBuilderFee = self.safe_bool(self.options, 'approvedBuilderFee', False)
560 if approvedBuilderFee:
561 return True # skip if builder fee is already approved
562 results = [self.privateTradingPostFullV1GetAuthorizedBuilders(), self.load_account_infos()]
563 #
564 # {
565 # "results": [{
566 # "builder_account_id": "GRVT_MAIN_ACCOUNT_ID_HERE",
567 # "max_futures_fee_rate": 0.001,
568 # "max_spot_fee_rate": 0.0001
569 # }]
570 # }
571 #
572 currentBuilders = results[0]
573 approvedBuilder = self.safe_list(currentBuilders, 'results', [])
574 length = len(approvedBuilder)
575 found = False
576 for i in range(0, length):
577 builderInfo = self.safe_dict(approvedBuilder, i, {})
578 builderAccountId = self.safe_string(builderInfo, 'builder_account_id')
579 if builderAccountId == self.safe_string(self.options, 'builder'):
580 found = True
581 break
582 if found:
583 self.options['approvedBuilderFee'] = True
584 else:
585 try:
586 defaultFromAccountId = self.safe_string(self.options, 'userMainAccountId') # self.eth_get_address_from_private_key(self.secret) # self.safe_string(self.options, 'userMainAccountId')
587 request = {
588 'main_account_id': defaultFromAccountId,
589 'builder_account_id': self.safe_string(self.options, 'builder'),
590 'max_futures_fee_rate': self.safe_string(self.options, 'builderRate'),
591 'max_spot_fee_rate': self.safe_string(self.options, 'builderRate'),
592 'signature': self.default_signature(),
593 }
594 request = self.create_signed_request(request, 'EIP712_BUILDER_APPROVAL_TYPE')
595 authResponse = self.privateTradingPostFullV1AuthorizeBuilder(self.extend(request, params))
596 #
597 # {
598 # "result": {
599 # "ack": "true",
600 # "tx_id":"0"
601 # }
602 # }
603 #
604 authResult = self.safe_dict(authResponse, 'result')
605 ack = self.safe_bool(authResult, 'ack')
606 if not ack:
607 raise ExchangeError('Builder authorization failed, ' + self.json(authResponse))
608 self.options['approvedBuilderFee'] = True
609 except Exception as e:
610 self.options['builderFee'] = False # disable builder fee if an error occurs
611 return None # just c#
612

Callers 1

sign_inMethod · 0.95

Calls 13

load_account_infosMethod · 0.95
default_signatureMethod · 0.95
create_signed_requestMethod · 0.95
ExchangeErrorClass · 0.90
safe_boolMethod · 0.80
safe_listMethod · 0.80
safe_dictMethod · 0.80
safe_stringMethod · 0.80
rangeFunction · 0.50
extendMethod · 0.45

Tested by

no test coverage detected