Skip to content

Commit

Permalink
fix meta
Browse files Browse the repository at this point in the history
  • Loading branch information
amfet42 committed Aug 20, 2023
1 parent b551aaf commit fc4447f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
7 changes: 1 addition & 6 deletions tests/pools/meta/test_exchange_underlying.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import pytest
from pytest import approx

from tests.utils.transactions import call_returning_result_and_logs

pytestmark = pytest.mark.usefixtures("initial_setup")


Expand Down Expand Up @@ -64,9 +62,6 @@ def test_min_dy_underlying(
underlying_tokens[sending]._mint_for_testing(bob, amount, sender=bob)

expected = swap.get_dy_underlying(sending, receiving, amount)
_, events = call_returning_result_and_logs(
swap, "exchange_underlying", sending, receiving, amount, 0, sender=bob
)
received = events[0]
received = swap.exchange_underlying(sending, receiving, amount, 0, sender=bob)

assert abs(expected - received) / received < 0.00001
2 changes: 1 addition & 1 deletion tests/pools/meta/test_exchange_underlying_reverts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_min_dy_too_high(self, bob, swap, underlying_tokens, meta_decimals, base
amount = 10 ** underlying_decimals[sending]
underlying_tokens[sending]._mint_for_testing(bob, amount, sender=bob)

min_dy = swap.get_dy_underlying(sending, receiving, amount * 1.0001)
min_dy = swap.get_dy_underlying(sending, receiving, int(amount * 1.0001))
with boa.reverts():
swap.exchange_underlying(sending, receiving, amount, min_dy, sender=bob)

Expand Down
5 changes: 4 additions & 1 deletion tests/pools/meta/test_get_virtual_price_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@


@pytest.mark.parametrize("sending,receiving", itertools.permutations(range(4), 2))
def test_exchange_underlying(bob, swap, sending, receiving, meta_decimals, base_pool_decimals):
def test_exchange_underlying(bob, swap, sending, receiving, meta_decimals, base_pool_decimals, underlying_tokens):
underlying_decimals = [meta_decimals] + base_pool_decimals
virtual_price = swap.get_virtual_price()

amount = 10 ** underlying_decimals[sending]
if sending > 0:
underlying_tokens[sending + 1]._mint_for_testing(bob, amount)

swap.exchange_underlying(sending, receiving, amount, 0, sender=bob)

assert swap.get_virtual_price() > virtual_price
14 changes: 7 additions & 7 deletions tests/pools/meta/test_receiver_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
pytestmark = pytest.mark.usefixtures("initial_setup")


def test_exchange_underlying(alice, charlie, swap, underlying_tokens, meta_decimals, base_pool_decimals):
underlying_decimals = [meta_decimals] + base_pool_decimals
underlying_tokens = [underlying_tokens[0], *underlying_tokens[2:]]
amount = 10 ** underlying_decimals[1]
underlying_tokens[1]._mint_for_testing(alice, amount, sender=alice)
def test_exchange_underlying(bob, charlie, swap, underlying_tokens, meta_decimals, base_pool_decimals):
initial_amount = underlying_tokens[0].balanceOf(bob)

swap.exchange_underlying(1, 0, amount, 0, charlie, sender=alice)
amount = 10 ** base_pool_decimals[0]
underlying_tokens[2]._mint_for_testing(bob, amount)

swap.exchange_underlying(1, 0, amount, 0, charlie, sender=bob)
assert underlying_tokens[0].balanceOf(charlie) > 0
assert underlying_tokens[0].balanceOf(alice) == 0
assert underlying_tokens[0].balanceOf(bob) == initial_amount

0 comments on commit fc4447f

Please sign in to comment.