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

Method is_unified_enabled

python/ccxt/async_support/hyperliquid.py:1783–1823  ·  view source on GitHub ↗

https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-abstraction-state returns enableUnifiedMargin so the user can check if unified account is enabled :param str method: the method for which we want to check if unified margin is en

(self, method: str, address: Str = None, shouldRefresh=False, params={})

Source from the content-addressed store, hash-verified

1781 return True
1782
1783 async def is_unified_enabled(self, method: str, address: Str = None, shouldRefresh=False, params={}) -> list:
1784 """
1785
1786 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-abstraction-state
1787
1788 returns enableUnifiedMargin so the user can check if unified account is enabled
1789 :param str method: the method for which we want to check if unified margin is enabled, self is used to check options for specific methods(e.g. fetchBalance can have a specific option to enable unified margin)
1790 :param str [address]: the wallet address to query; defaults to the configured walletAddress
1791 :param boolean [shouldRefresh]: force a fresh request instead of returning the cached value
1792 :param dict [params]: extra parameters specific to the exchange API endpoint
1793 :returns bool: enableUnifiedMargin
1794 """
1795 userAddress = None
1796 if address is not None:
1797 userAddress = address
1798 else:
1799 userAddress, params = self.handle_public_address('isUnifiedEnabled', params)
1800 enableUnifiedMargin = None
1801 enableUnifiedMargin, params = self.handle_option_and_params(params, method, 'enableUnifiedMargin')
1802 if enableUnifiedMargin is None or shouldRefresh:
1803 request = {
1804 'type': 'userAbstraction',
1805 'user': userAddress,
1806 }
1807 response = None
1808 try:
1809 response = await self.publicPostInfo(self.extend(request, params))
1810 except Exception as e:
1811 if isinstance(e, InvalidProxySettings):
1812 raise e # reraise self error since it means the user has a problem with their proxy settings that needs to be fixed
1813 response = None # ignore self error and assume unified margin is not enabled
1814 #
1815 # "unifiedAccount" | "portfolioMargin" | "disabled" | "default" | "dexAbstraction"
1816 #
1817 if response is not None:
1818 response = response.replace('"', '')
1819 response = response.replace('"', '')
1820 enableUnifiedMargin = response == 'unifiedAccount'
1821 # don't cache self result if self is a different addresss
1822 self.options['enableUnifiedMargin'] = enableUnifiedMargin # cache self for future calls
1823 return [enableUnifiedMargin, params]
1824
1825 async def set_user_abstraction(self, abstraction: str, params={}):
1826 """

Callers 2

fetch_balanceMethod · 0.95
initialize_clientMethod · 0.95

Calls 5

handle_public_addressMethod · 0.95
replaceMethod · 0.80
publicPostInfoMethod · 0.65
extendMethod · 0.45

Tested by

no test coverage detected