Skip to content

Commit

Permalink
test: event on swap failure
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoCentonze committed May 28, 2024
1 parent fe78922 commit a8a5d1b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/unitary/pool/stateful/test_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def exchange_rule(self, data, i: int, user: str):
# if the exchange was successful it alters the pool
# composition so we report the new equilibrium
self.report_equilibrium()
else:
# if the exchange was not successful we add an
# event to make sure that failure was reasonable
event(
"swap failed (balance = {:.2e}) {:.2%} of liquidity with A: "
"{:.2e} and gamma: {:.2e}".format(
self.equilibrium,
dx / liquidity,
self.pool.A(),
self.pool.gamma(),
)
)


class UpOnlyLiquidityStateful(OnlySwapStateful):
Expand Down

0 comments on commit a8a5d1b

Please sign in to comment.