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