Skip to content

Commit

Permalink
MargPOptimizer: division by zero [v5.1.1]
Browse files Browse the repository at this point in the history
  • Loading branch information
sklbancor committed Aug 27, 2023
1 parent 21dad6c commit 273cbeb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fastlane_bot/tools/optimizer/margpoptimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ def dtknfromp_f(p, *, islog10=True, asdct=False, quiet=False):

sum_by_tkn = {t: 0 for t in alltokens_s}
for pair, (tknb, tknq) in zip(pairs, pairs_t):
price = get(p, tokens_ix.get(tknb)) / get(p, tokens_ix.get(tknq))
try:
price = get(p, tokens_ix.get(tknb)) / get(p, tokens_ix.get(tknq))
except Exception as e:
if not get(p, tokens_ix.get(tknq)) == 0:
raise Exception(f"Error while calculating price for pair {pair}: {e} [{p}]")
price = 1
curves = curves_by_pair[pair]
c0 = curves[0]
dxdy = tuple(dxdy_f(c.dxdyfromp_f(price)) for c in curves)
Expand Down

0 comments on commit 273cbeb

Please sign in to comment.