Skip to content

Commit

Permalink
Fixed checks in lrna_swap
Browse files Browse the repository at this point in the history
  • Loading branch information
poliwop committed Nov 5, 2024
1 parent f7a894e commit c45fc3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hydradx/model/amm/omnipool_amm.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ def lrna_swap(

if delta_qa < 0:
asset_fee = self.asset_fee[tkn].compute()
if -delta_qa + self.lrna[tkn] <= 0:
return self.fail_transaction('insufficient lrna in pool', agent)
if "LRNA" not in agent.holdings or delta_qa + agent.holdings["LRNA"] < 0:
return self.fail_transaction('Agent has insufficient LRNA', agent)
delta_ra = -self.liquidity[tkn] * delta_qa / (-delta_qa + self.lrna[tkn]) * (1 - asset_fee)

delta_qm = asset_fee * (-delta_qa) / self.lrna[tkn] * (self.lrna[tkn] - delta_qa) * self.lrna_mint_pct
Expand All @@ -564,6 +564,8 @@ def lrna_swap(
return self.fail_transaction('insufficient assets in pool', agent)
denom = (self.liquidity[tkn] * (1 - asset_fee) - delta_ra)
delta_qa = -self.lrna[tkn] * delta_ra / denom
if "LRNA" not in agent.holdings or delta_qa + agent.holdings["LRNA"] < 0:
return self.fail_transaction('Agent has insufficient LRNA', agent)
delta_qm = -asset_fee * (1 - asset_fee) * (self.liquidity[tkn] / denom) * delta_qa * self.lrna_mint_pct
delta_q = -delta_qa + delta_qm

Expand Down

0 comments on commit c45fc3c

Please sign in to comment.