approval amounts needed decimals
This commit is contained in:
parent
44ff8514c2
commit
3260783d98
1 changed files with 2 additions and 2 deletions
4
core.py
4
core.py
|
|
@ -137,7 +137,7 @@ def convert_tokens(account, token0_address, token1_address, output_amount, attem
|
||||||
|
|
||||||
# call the buy function with amount or default to no args
|
# call the buy function with amount or default to no args
|
||||||
call_function = routes_functions[token1_address]['functions'][token0_address]
|
call_function = routes_functions[token1_address]['functions'][token0_address]
|
||||||
approve_token_spending(account, token0_address, token1_address, get_token_supply(token0_address))
|
approve_token_spending(account, token0_address, token1_address, get_token_supply(token0_address, True))
|
||||||
token1_contract = load_contract(token1_address, load_contract_abi(token1_address))
|
token1_contract = load_contract(token1_address, load_contract_abi(token1_address))
|
||||||
amount = to_token_decimals(output_amount, token1_contract.functions.decimals().call())
|
amount = to_token_decimals(output_amount, token1_contract.functions.decimals().call())
|
||||||
try:
|
try:
|
||||||
|
|
@ -228,7 +228,7 @@ def convert_tokens_multi(account, multi_address, token0_address, token1_address,
|
||||||
logging.error("Need {} more tokens".format(tokens_required - tokens_balance))
|
logging.error("Need {} more tokens".format(tokens_required - tokens_balance))
|
||||||
return False
|
return False
|
||||||
# approve the tokens required to convert and determine how many loops
|
# approve the tokens required to convert and determine how many loops
|
||||||
approve_token_spending(account, token0_address, multi_address, get_token_supply(token0_address))
|
approve_token_spending(account, token0_address, multi_address, get_token_supply(token0_address, True))
|
||||||
loops = math.floor(iterations / routes_functions[multi_address]['max_iterations'])
|
loops = math.floor(iterations / routes_functions[multi_address]['max_iterations'])
|
||||||
if iterations % routes_functions[multi_address]['max_iterations'] != 0:
|
if iterations % routes_functions[multi_address]['max_iterations'] != 0:
|
||||||
loops += 1
|
loops += 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue