sample_exchange_rate
Function
def sample_exchange_rate(router_name, token_address, quote_address, attempts=18):
while attempts > 0:
token_result = estimate_swap_result(router_name, token_address, quote_address, 1)
if len(token_result) == 0:
attempts -= 1
time.sleep(1)
continue
else:
return token_result[1]
return None
Description
Loop while there are attempts remaining
Get the token info
Set the token amount to 1 full token
Estimate the swap result
Return the outcome or null