def chain_snapshot(): try: print('Making chain snapshot...') chain.snapshot() yield finally: print('Reverting the chain...') chain.revert()
def test_update_prices_helper_oracle_address(pricesHelper, management): chain.snapshot() oracleAddress = pricesHelper.oracleAddress() newOracleAddress = "0x6951b5Bd815043E3F842c1b026b0Fa888Cc2DD85" assert newOracleAddress != oracleAddress pricesHelper.updateOracleAddress(newOracleAddress, {"from": management}) assert pricesHelper.oracleAddress() == newOracleAddress chain.revert()
def test_adding_feed(calculations_chainlink_registry): chain.snapshot() with brownie.reverts(): calculations_chainlink_registry.getPriceUsdc(yfiAddress) calculations_chainlink_registry.setTokenFeed(yfiAddress, yfiUsdFeed) assert calculations_chainlink_registry.getPriceUsdc(yfiAddress) > 0 chain.revert()
def test_update_curve_addresses_provider(curve_calculations, management): chain.snapshot() old_address = curve_calculations.curveAddressesProviderAddress() new_address = "0x12360e44C676ed0246c6Fb4c44B26191A5171B55" curve_calculations.updateCurveAddressesProviderAddress( new_address, {"from": management}) assert curve_calculations.curveAddressesProviderAddress() == new_address assert curve_calculations.curveAddressesProviderAddress() != old_address chain.revert()
def test_adding_multiple_feeds(calculations_chainlink_registry, management): chain.snapshot() with brownie.reverts(): calculations_chainlink_registry.getPriceUsdc(yfiAddress) with brownie.reverts(): calculations_chainlink_registry.getPriceUsdc(wethAddress) calculations_chainlink_registry.setTokenFeeds([(yfiAddress, yfiUsdFeed), (wethAddress, wethUsdFeed)], {"from": management}) assert calculations_chainlink_registry.getPriceUsdc(yfiAddress) > 0 assert calculations_chainlink_registry.getPriceUsdc(wethAddress) > 0 chain.revert()
def test_slippage(accounts, token, chain, strategist, amount, noclaim_pool_88mph, claim_88mph, noclaim_88mph, minter_88mph, gov): print("DAI balance", token.balanceOf(gov) / 1e18) token.approve(minter_88mph.address, 1e30, {"from": gov}) print("\n------Add Cover------") minter_88mph.addCover(token.address, 1622419200, 15e21, {"from": gov}) minPoolAmountOut = 0 chain.snapshot() print("\n------Single Sided Swap ------") total_bpts_before = noclaim_pool_88mph.totalSupply() / 1e18 noclaim_88mph.approve(noclaim_pool_88mph.address, 1e30, {"from": gov}) noclaim_pool_88mph.joinswapExternAmountIn( noclaim_88mph.address, # Token In 15e21, # Amount In minPoolAmountOut, # Min out {"from": gov}) total_bpts_after = noclaim_pool_88mph.totalSupply() / 1e18 my_bpts_balance = noclaim_pool_88mph.balanceOf(gov) / 1e18 my_bpts_percent = my_bpts_balance / total_bpts_after print("BPTs received from single sided", my_bpts_balance) chain.revert() print("\n------Balanced Deposit ------") noclaim_88mph.approve(noclaim_pool_88mph.address, 1e30, {"from": gov}) token.approve(noclaim_pool_88mph.address, 1e30, {"from": gov}) # Get pool reserves poolDai = token.balanceOf(noclaim_pool_88mph) poolNoClaim = noclaim_88mph.balanceOf(noclaim_pool_88mph) ratio = poolNoClaim / (poolDai + poolNoClaim) # Calc desired BPT shares out shares_out = calc_poolAmountOut_from_amountIn( noclaim_88mph, noclaim_88mph.balanceOf(gov) * ratio, noclaim_pool_88mph) # Add liquidity noclaim_pool_88mph.joinPool(shares_out - 1e10, [1e30, 1e30], {"from": gov}) print("\nBPTs received from single sided", my_bpts_balance) print("BPTs received from balanced", noclaim_pool_88mph.balanceOf(gov) / 1e18)