async def get_token_adapter(self, token_adapter_name: str, block: Union[str, int] = 'latest') -> str: words = [ remove_0x_prefix( hex(32)).zfill(64), # position of the dynamic argument remove_0x_prefix(hex(len(token_adapter_name))).zfill( 64), # length of the dynamic argument remove_0x_prefix(string_to_hash(token_adapter_name)).ljust( 64, '0') # left-aligned argument ] return await self._call(self._registry, self._get_token_adapter + ''.join(words), serializer=hash_to_address, block=block)
async def get_final_full_token_balance( self, token_type: str, token_address: str, block: Union[str, int] = 'latest') -> AssetBalance: words = [ remove_0x_prefix( hex(64)).zfill(64), # position of the dynamic argument remove_0x_prefix(token_address).zfill( 64), # second argument: address remove_0x_prefix(hex(len( bytes(token_type, 'utf-8')))).zfill(64), # length of the dynamic argument remove_0x_prefix(string_to_hash(token_type)).ljust( 64, '0') # left-aligned argument ] return await self._call( self._registry, self._get_final_full_token_balance + ''.join(words), serializer=defi_sdk_full_token_balance_to_entity, block=block)
async def get_protocol_balance( self, address: str, protocol_name: str, block: Union[str, int] = 'latest') -> ProtocolBalance: words = [ remove_0x_prefix(address).zfill(64), # first argument: address remove_0x_prefix(hex(64)).zfill( 64), # position of the dynamic argument: [protocol[]] remove_0x_prefix(hex(1)).zfill( 64), # length of the dynamic argument: [protocol[]] remove_0x_prefix(hex(32)).zfill( 64), # position of the dynamic argument: [protocol] remove_0x_prefix(hex(len(protocol_name))).zfill( 64), # length of the dynamic argument: [protocol] remove_0x_prefix(string_to_hash(protocol_name)).ljust( 64, '0') # left-aligned argument ] result = await self._call( self._registry, self._get_protocol_balances + ''.join(words), serializer=defi_sdk_protocol_balances_to_entity, block=block) return result[0]