Skip to content

Tests with hasReserve == true  #153

@magnetto90

Description

@magnetto90

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions