diff --git a/apps/trading/e2e/poetry.lock b/apps/trading/e2e/poetry.lock index f5215cc71..1893acb14 100644 --- a/apps/trading/e2e/poetry.lock +++ b/apps/trading/e2e/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "certifi" @@ -253,13 +253,13 @@ testing = ["hatch", "pre-commit", "pytest", "tox"] [[package]] name = "googleapis-common-protos" -version = "1.62.0" +version = "1.63.0" description = "Common protobufs used in Google APIs" optional = false python-versions = ">=3.7" files = [ - {file = "googleapis-common-protos-1.62.0.tar.gz", hash = "sha256:83f0ece9f94e5672cced82f592d2a5edf527a96ed1794f0bab36d5735c996277"}, - {file = "googleapis_common_protos-1.62.0-py2.py3-none-any.whl", hash = "sha256:4750113612205514f9f6aa4cb00d523a94f3e8c06c5ad2fee466387dc4875f07"}, + {file = "googleapis-common-protos-1.63.0.tar.gz", hash = "sha256:17ad01b11d5f1d0171c06d3ba5c04c54474e883b66b949722b4938ee2694ef4e"}, + {file = "googleapis_common_protos-1.63.0-py2.py3-none-any.whl", hash = "sha256:ae45f75702f7c08b541f750854a678bd8f534a1a6bace6afe975f1d0a82d6632"}, ] [package.dependencies] @@ -653,13 +653,13 @@ pyee = "11.0.1" [[package]] name = "plotly" -version = "5.19.0" +version = "5.20.0" description = "An open-source, interactive data visualization library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "plotly-5.19.0-py3-none-any.whl", hash = "sha256:906abcc5f15945765328c5d47edaa884bc99f5985fbc61e8cd4dc361f4ff8f5a"}, - {file = "plotly-5.19.0.tar.gz", hash = "sha256:5ea91a56571292ade3e3bc9bf712eba0b95a1fb0a941375d978cc79432e055f4"}, + {file = "plotly-5.20.0-py3-none-any.whl", hash = "sha256:837a9c8aa90f2c0a2f0d747b82544d014dc2a2bdde967b5bb1da25b53932d1a9"}, + {file = "plotly-5.20.0.tar.gz", hash = "sha256:bf901c805d22032cfa534b2ff7c5aa6b0659e037f19ec1e0cca7f585918b5c89"}, ] [package.dependencies] @@ -1019,18 +1019,18 @@ test = ["asv", "gmpy2", "hypothesis", "mpmath", "pooch", "pytest", "pytest-cov", [[package]] name = "setuptools" -version = "69.1.1" +version = "69.2.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-69.1.1-py3-none-any.whl", hash = "sha256:02fa291a0471b3a18b2b2481ed902af520c69e8ae0919c13da936542754b4c56"}, - {file = "setuptools-69.1.1.tar.gz", hash = "sha256:5c0806c7d9af348e6dd3777b4f4dbb42c7ad85b190104837488eab9a7c945cf8"}, + {file = "setuptools-69.2.0-py3-none-any.whl", hash = "sha256:c21c49fb1042386df081cb5d86759792ab89efca84cf114889191cd09aacc80c"}, + {file = "setuptools-69.2.0.tar.gz", hash = "sha256:0ff4183f8f42cd8fa3acea16c45205521a4ef28f73c6391d8a25e92893134f2e"}, ] [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] [[package]] diff --git a/apps/trading/e2e/tests/rewards/test_rewards_combo_tier_1_capped.py b/apps/trading/e2e/tests/rewards/test_rewards_combo_tier_1_capped.py new file mode 100644 index 000000000..cb06bf1f1 --- /dev/null +++ b/apps/trading/e2e/tests/rewards/test_rewards_combo_tier_1_capped.py @@ -0,0 +1,185 @@ +import pytest +from rewards_test_ids import * +from typing import Tuple, Generator +import vega_sim.proto.vega as vega_protos +from playwright.sync_api import Page, expect +from conftest import ( + init_vega, + init_page, + auth_setup, + risk_accepted_setup, + cleanup_container, +) +from fixtures.market import setup_continuous_market +from actions.utils import next_epoch, change_keys +from wallet_config import MM_WALLET +from vega_sim.null_service import VegaServiceNull + + +@pytest.fixture(scope="module") +def setup_environment(request, browser) -> Generator[Tuple[Page, str, str], None, None]: + with init_vega(request) as vega_instance: + request.addfinalizer(lambda: cleanup_container(vega_instance)) + + tDAI_market, tDAI_asset_id = setup_market_with_reward_program(vega_instance) + + with init_page(vega_instance, browser, request) as page: + risk_accepted_setup(page) + auth_setup(vega_instance, page) + page.goto(REWARDS_URL) + change_keys(page, vega_instance, PARTY_B) + yield page, tDAI_market, tDAI_asset_id + + +def setup_market_with_reward_program(vega: VegaServiceNull): + tDAI_market = setup_continuous_market(vega) + PARTY_A, PARTY_B, PARTY_C, PARTY_D = keys(vega) + tDAI_asset_id = vega.find_asset_id(symbol="tDAI") + vega.mint(key_name=PARTY_B.name, asset=tDAI_asset_id, amount=100000) + vega.mint(key_name=PARTY_C.name, asset=tDAI_asset_id, amount=100000) + vega.mint(key_name=PARTY_A.name, asset=tDAI_asset_id, amount=100000) + vega.mint(key_name=PARTY_D.name, asset=tDAI_asset_id, amount=100000) + next_epoch(vega=vega) + vega.update_network_parameter( + proposal_key=MM_WALLET.name, + parameter="rewards.activityStreak.benefitTiers", + new_value=ACTIVITY_STREAKS, + ) + print("update_network_parameter activity done") + next_epoch(vega=vega) + + vega.update_network_parameter( + proposal_key=MM_WALLET.name, + parameter="rewards.vesting.benefitTiers", + new_value=VESTING, + ) + next_epoch(vega=vega) + + tDAI_asset_id = vega.find_asset_id(symbol="tDAI") + vega.update_network_parameter( + MM_WALLET.name, parameter="reward.asset", new_value=tDAI_asset_id + ) + + next_epoch(vega=vega) + vega.recurring_transfer( + from_key_name=PARTY_A.name, + from_account_type=vega_protos.vega.ACCOUNT_TYPE_GENERAL, + to_account_type=vega_protos.vega.ACCOUNT_TYPE_GLOBAL_REWARD, + asset=tDAI_asset_id, + amount=100, + factor=1.0, + ) + vega.wait_fn(1) + vega.wait_for_total_catchup() + vega.recurring_transfer( + from_key_name=PARTY_A.name, + from_account_type=vega_protos.vega.ACCOUNT_TYPE_GENERAL, + to_account_type=vega_protos.vega.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES, + asset=tDAI_asset_id, + reference="reward", + asset_for_metric=tDAI_asset_id, + metric=vega_protos.vega.DISPATCH_METRIC_MAKER_FEES_PAID, + amount=100, + factor=1.0, + cap_reward_fee_multiple=1, + ) + vega.submit_order( + trading_key=PARTY_B.name, + market_id=tDAI_market, + order_type="TYPE_MARKET", + time_in_force="TIME_IN_FORCE_IOC", + side="SIDE_BUY", + volume=1, + ) + vega.submit_order( + trading_key=PARTY_A.name, + market_id=tDAI_market, + order_type="TYPE_MARKET", + time_in_force="TIME_IN_FORCE_IOC", + side="SIDE_BUY", + volume=1, + ) + vega.wait_fn(1) + vega.wait_for_total_catchup() + next_epoch(vega=vega) + vega.submit_order( + trading_key=PARTY_B.name, + market_id=tDAI_market, + order_type="TYPE_LIMIT", + time_in_force="TIME_IN_FORCE_GTC", + side="SIDE_BUY", + price=1, + volume=1, + ) + next_epoch(vega=vega) + vega.submit_order( + trading_key=PARTY_B.name, + market_id=tDAI_market, + order_type="TYPE_MARKET", + time_in_force="TIME_IN_FORCE_IOC", + side="SIDE_BUY", + volume=1, + ) + vega.submit_order( + trading_key=PARTY_D.name, + market_id=tDAI_market, + order_type="TYPE_MARKET", + time_in_force="TIME_IN_FORCE_IOC", + side="SIDE_BUY", + volume=1, + ) + vega.wait_fn(1) + vega.wait_for_total_catchup() + next_epoch(vega=vega) + next_epoch(vega=vega) + vega.submit_order( + trading_key=PARTY_B.name, + market_id=tDAI_market, + order_type="TYPE_MARKET", + time_in_force="TIME_IN_FORCE_IOC", + side="SIDE_BUY", + volume=1, + ) + vega.submit_order( + trading_key=PARTY_D.name, + market_id=tDAI_market, + order_type="TYPE_MARKET", + time_in_force="TIME_IN_FORCE_IOC", + side="SIDE_BUY", + volume=1, + ) + vega.wait_for_total_catchup() + next_epoch(vega=vega) + next_epoch(vega=vega) + next_epoch(vega=vega) + return tDAI_market, tDAI_asset_id + + +def test_network_reward_pot_capped( + setup_environment: Tuple[Page, str, str], +) -> None: + page, tDAI_market, tDAI_asset_id = setup_environment + expect(page.get_by_test_id(TOTAL_REWARDS)).to_have_text("31.05 tDAI") + + +def test_reward_history_capped( + setup_environment: Tuple[Page, str, str], +) -> None: + page, tDAI_market, tDAI_asset_id = setup_environment + page.locator('[name="fromEpoch"]').fill("1") + expect((page.get_by_role(ROW).locator(PRICE_TAKING_COL_ID)).nth(1)).to_have_text( + "62.10100.00%" + ) + expect((page.get_by_role(ROW).locator(TOTAL_COL_ID)).nth(1)).to_have_text("62.10") + page.get_by_test_id(EARNED_BY_ME_BUTTON).click() + expect((page.get_by_role(ROW).locator(TOTAL_COL_ID)).nth(1)).to_have_text("31.05") + + +def test_reward_card_capped( + setup_environment: Tuple[Page, str, str], +) -> None: + page, tDAI_market, tDAI_asset_id = setup_environment + expect(page.get_by_test_id("active-rewards-card")).to_have_count(2) + game_1 = page.get_by_test_id("active-rewards-card").first + expect(game_1).to_be_visible() + expect(game_1.get_by_test_id("cappedAt")).to_have_text("x1")