Skip to content

Commit

Permalink
twap module and tests - precommit run
Browse files Browse the repository at this point in the history
  • Loading branch information
heswithme committed Sep 13, 2024
1 parent c502134 commit 66d9982
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ repos:
hooks:
- id: isort
args: ["--profile", "black", --line-length=79]

default_language_version:
python: python3.10.4
13 changes: 9 additions & 4 deletions tests/unitary/rewards_handler/test_twap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import boa
import pytest


def test_boa_timemachine():
Expand Down Expand Up @@ -36,7 +35,9 @@ def test_twap_single_deposit(vault, crvusd, rewards_handler, lens, vault_god):
), "TWAP does not match expected deposit amount"


def test_twap_multiple_deposits(vault, crvusd, rewards_handler, lens, vault_god):
def test_twap_multiple_deposits(
vault, crvusd, rewards_handler, lens, vault_god
):
# Prepare Alice's balance
alice = boa.env.generate_address()
boa.deal(crvusd, alice, 100_000_000 * 10**18)
Expand Down Expand Up @@ -84,8 +85,12 @@ def test_twap_multiple_deposits(vault, crvusd, rewards_handler, lens, vault_god)
twap = rewards_handler.tvl_twap()

# Actual staked rate
staked_rate = AMT_DEPOSIT * N_ITERATIONS * 10**18 // lens.circulating_supply()
staked_rate = (
AMT_DEPOSIT * N_ITERATIONS * 10**18 // lens.circulating_supply()
)
print(f"Staked rate: {staked_rate}, TWAP: {twap}")
# Compare the expected TWAP to the contract's TWAP
assert twap < staked_rate, "TWAP is too high"
assert twap == expected_twap, f"TWAP {twap} does not match expected {expected_twap}"
assert (
twap == expected_twap
), f"TWAP {twap} does not match expected {expected_twap}"

0 comments on commit 66d9982

Please sign in to comment.