Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests with hasReserve == true #153

Open
magnetto90 opened this issue Jan 17, 2024 · 0 comments
Open

Tests with hasReserve == true #153

magnetto90 opened this issue Jan 17, 2024 · 0 comments

Comments

@magnetto90
Copy link
Contributor

These test don't apply anymore since Uniswap feed were removed.

def test_cap_notional_front_run_bound(market, feed):
idx = RiskParameter.LMBDA.value
lmbda = Decimal(market.params(idx)) / Decimal(1e18)
data = feed.latest()
# NOTE: assumes using UniswapV3 feed with hasReserve = true
_, _, _, _, _, _, reserve_micro, _ = data
# check front run bound is lmbda * reserveOverMicro when has reserve
expect = int(lmbda * Decimal(reserve_micro))
actual = market.frontRunBound(data)
assert int(actual) == approx(expect)
def test_cap_notional_back_run_bound(market, feed):
idx = RiskParameter.DELTA.value
delta = Decimal(market.params(idx)) / Decimal(1e18)
data = feed.latest()
# NOTE: assumes using UniswapV3 feed with hasReserve = true
average_block_time = market.params(RiskParameter.AVERAGE_BLOCK_TIME.value)
_, _, macro_window, _, _, _, reserve_micro, _ = data
# check back run bound is macroWindowInBlocks * reserveInOvl * 2 * delta
# when has reserve
window = Decimal(macro_window) / Decimal(average_block_time)
expect = int(Decimal(2) * delta * Decimal(reserve_micro) * window)
actual = market.backRunBound(data)
assert int(actual) == approx(expect)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant