def approve_strategies_timelock(badger): """ Approve and set strategies on the controller """ all_timelock_params = {} for key in strategies_to_initialize: strategy = badger.getStrategy(key) vault = badger.getSett(key) console.print(f"Initializing strat {key} ({strategy.address})") controller = badger.getController("native") print(controller.governance(), controller.strategist()) assert controller.governance() == badger.governanceTimelock assert strategy.getName() == "StrategyConvexStakingOptimizer" assert vault.token() == strategy.want() timelock_params = { "target": controller.address, "signature": "approveStrategy(address,address)", "data": encode_abi( ["address", "address"], [strategy.want(), strategy.address] ), "eta": chain.time() + days(3.1), } console.print(timelock_params) console.print(f"TX Executable at {to_utc_date(timelock_params['eta'])}") all_timelock_params[key] = timelock_params console.print("timelock_params", timelock_params) txFilename = badger.governance_queue_transaction( timelock_params["target"], timelock_params["signature"], timelock_params["data"], timelock_params["eta"], ) chain.sleep(days(3.2)) chain.mine() for key in strategies_to_initialize: strategy = badger.getStrategy(key) timelock_params = all_timelock_params[key] badger.governance_execute_transaction_from_params(timelock_params) chain.mine() console.print( f"Checking strategy approval for {strategy.want()} {strategy} {controller.approvedStrategies(strategy.want(), strategy)}" ) assert controller.approvedStrategies(strategy.want(), strategy) == True
def get_expected_total_rewards(periodEndTime): startTime = 1611489600 timePassed = periodEndTime - startTime print("timePassed", timePassed) badger_base = Wei("4248761 ether") badger_per_day = Wei("184452 ether") // 7 digg_base = Wei("45 gwei") digg_per_day = Wei("138.4 gwei") // 7 return { "badger": badger_base + (badger_per_day * timePassed // days(1)), "digg": digg_base + (digg_per_day * timePassed // days(1)), }
def update_rewards(badger: BadgerSystem) -> str: data = encode_abi(["address"], [GOVERNANCE_MULTISIG_ADDRESS]) delay = 2 * days(2) eta = web3.eth.getBlock("latest")["timestamp"] + delay return badger.governance_queue_transaction(CONTROLLER_ADDRESS, FUNCTION_TO_CALL, data, eta)
def post_deploy_setup(self, deploy=True): """ Distribute digg to geyser and allow strategy to take """ super().post_deploy_setup(deploy=deploy) # Track our digg system within badger system for convenience. self.badger.add_existing_digg(self.digg) if not deploy: return digg = self.digg.token # Transfer initial emissions to DiggFaucet amount = digg_config_test.geyserParams.unlockSchedules.digg[0].amount digg.transfer(self.rewards, amount, {"from": self.deployer}) self.rewards.notifyRewardAmount( chain.time(), days(7), digg.fragmentsToShares(amount), {"from": self.deployer}, ) self.rewards.grantRole(PAUSER_ROLE, self.keeper, {"from": self.deployer}) self.rewards.grantRole(UNPAUSER_ROLE, self.guardian, {"from": self.deployer}) # Make strategy the recipient of the DIGG faucet self.rewards.initializeRecipient(self.strategy, {"from": self.deployer}) if self.strategy.paused(): self.strategy.unpause({"from": self.governance})
def post_deploy_setup(self, deploy=True): """ Distribute digg to Geyser and allow strategy to take """ super().post_deploy_setup(deploy=deploy) if not deploy: return amount = digg_config_test.geyserParams.unlockSchedules.digg[0].amount digg = self.digg.token digg.transfer(self.rewards, amount, {'from': self.deployer}) self.rewards.notifyRewardAmount(chain.time(), days(7), digg.fragmentsToShares(amount), {'from': self.deployer}) print(digg.balanceOf(self.rewards), digg.sharesOf(self.rewards)) self.rewards.grantRole(PAUSER_ROLE, self.keeper, {'from': self.deployer}) self.rewards.grantRole(UNPAUSER_ROLE, self.guardian, {'from': self.deployer}) # Make strategy the recipient of the DIGG faucet self.rewards.initializeRecipient(self.strategy, {"from": self.deployer})
def timelock_run_direct(self, target, signature, data, eta, eth=0): multi = accounts.at(self.devMultisig.address, force=True) self.governanceTimelock.queueTransaction(target, eth, signature, data, eta, {"from": multi}) chain.sleep(days(5)) self.governanceTimelock.executeTransaction(target, eth, signature, data, eta, {"from": multi})
def queue_upgrade(self, proxyAddress, newLogicAddress, delay=2 * days(2)) -> str: target = self.devProxyAdmin.address signature = "upgrade(address,address)" data = encode_abi(["address", "address"], [proxyAddress, newLogicAddress]) eta = web3.eth.getBlock("latest")["timestamp"] + delay return self.governance_queue_transaction(target, signature, data, eta)
def main(): badger = connect_badger("deploy-final.json") admin = badger.devProxyAdmin multisig = badger.devMultisig contracts = badger.contracts_upgradeable deployer = badger.deployer expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77" assert multisig == expectedMultisig """ Total $BADGER 603,750 Setts renbtcCRV — 83,437.5 $BADGER sbtcCRV — 83,437.5 $BADGER tbtcCRV — 83,437.5 $BADGER Badger — 70,000 $BADGER (NEW) wBTC/ETH Sushiswap LP — 40,000 $BADGER Badger <>wBTC Uniswap LP — 110,000 $BADGER (NEW) Badger <>wBTC Sushiswap LP— 50,000 $BADGER wbtc/eth = 34,285 $BADGER (which should be distributed evenly over 3 days ie today 1pm to tomorrow, tomorrow to wednesday, wed- thursday then new emissions) Badger <>wBTC Sushiswap LP— 30,000 $BADGER (10k/day) Super Sett Harvest renbtc CRV —83,437.5 $BADGER """ rest = RewardsSchedule(badger) rest.setStart(to_timestamp(datetime.datetime(2020, 12, 31, 12, 00))) rest.setDuration(days(7)) rest.setAmounts({ "native.renCrv": Wei("83437.5 ether"), "native.sbtcCrv": Wei("83437.5 ether"), "native.tbtcCrv": Wei("83437.5 ether"), "native.badger": Wei("60000 ether"), "native.sushiWbtcEth": Wei("80000 ether"), "native.uniBadgerWbtc": Wei("80000 ether"), "native.sushiBadgerWbtc": Wei("80000 ether"), "harvest.renCrv": Wei("83437.5 ether"), }) rest.testTransactions() rest.printState("Week 5 - Sushi Continues") total = rest.total expected = Wei("633750 ether") print("overall total ", total) print("expected total ", expected) assert total == expected console.print("\n[green] ✅ Total matches expected {} [/green]".format( val(expected)))
def get_active_rewards_schedule(badger: BadgerSystem): rest = RewardsSchedule(badger) rest.setStart(to_timestamp(datetime.datetime(2021, 5, 13, 12, 00))) rest.setDuration(days(7)) # TODO: Set to read from config emissions. Emit auto-compounding events & on-chain readable data in Unified Rewards Logger. rest.setAmounts(emissions.active) rest.setTotals(emissions.active) return rest
def state_setup(badger, settConfig): settId = settConfig["id"] # TODO: Make this fetch based on the sett prefix name if it has dot controller = badger.getControllerFor(settId) sett = badger.getSett(settId) strategy = badger.getStrategy(settId) want = badger.getStrategyWant(settId) deployer = badger.deployer settKeeper = accounts.at(sett.keeper(), force=True) strategyKeeper = accounts.at(strategy.keeper(), force=True) tendable = strategy.isTendable() startingBalance = want.balanceOf(deployer) depositAmount = int(startingBalance * 0.8) assert startingBalance >= depositAmount want.approve(sett, MaxUint256, {"from": deployer}) sett.deposit(depositAmount, {"from": deployer}) chain.sleep(days(1)) chain.mine() sett.earn({"from": settKeeper}) chain.sleep(days(1)) chain.mine() if tendable: strategy.tend({"from": strategyKeeper}) strategy.harvest({"from": strategyKeeper}) chain.sleep(days(1)) chain.mine() accounts.at(badger.deployer, force=True) accounts.at(strategy.governance(), force=True) accounts.at(strategy.strategist(), force=True) accounts.at(strategy.keeper(), force=True) accounts.at(strategy.guardian(), force=True) accounts.at(controller, force=True)
def _deploy_mocks_and_upgrade_bridge(badger, bridge): # NB: Deploy/use mock gateway bridge.deploy_mocks() bridge.adapter.setRegistry( bridge.mocks.registry, {"from": badger.devMultisig}, ) # NB: Temporarily upgrade and configure bridge to use curve token wrapper. txFilename = upgrade_bridge(badger, bridge) chain.sleep(2*days(2)) badger.governance_execute_transaction(txFilename) configure_bridge(badger, bridge)
def test_update_rewards(badger: BadgerSystem) -> str: data = encode_abi(["address"], [GOVERNANCE_MULTISIG_ADDRESS]) delay = 2 * days(2) eta = web3.eth.getBlock("latest")["timestamp"] + delay result = badger.timelock_run_direct(CONTROLLER_ADDRESS, FUNCTION_TO_CALL, data, eta) controller = badger.getController("native") assert controller.rewards() == GOVERNANCE_MULTISIG_ADDRESS console.print("[orange] Controller Rewards {} [/orange]".format( controller.rewards())) return result
def printUniTrade(method, params): path = params[2] input_token = path[0] output_token = path[-1] table = [] table.append(["input token", input_token]) table.append(["output token", output_token]) table.append(["expected output", params[0]]) table.append(["max input", params[1]]) table.append(["path", params[2]]) table.append(["recipient", params[3]]) table.append(["expiration time", to_utc_date(params[4])]) table.append(["time until expiration", days(params[4] - chain.time())]) console.print(tabulate(table, headers=["metric", "value"]))
def main(): badger = connect_badger(load_deployer=True) safe = ApeSafe(badger.opsMultisig.address) helper = ApeSafeHelper(badger, safe) logger = helper.contract_from_abi(badger.rewardsLogger.address, "RewardsLogger", RewardsLogger.abi) schedules = [] # Concat schedules for all vaults for key in vaults_to_run: vault = badger.getSett(key) start = 1625158800 duration = days(7) end = start + duration badger_amount = Wei("360 ether") schedules.append( LoggerUnlockSchedule(( vault, badger.token.address, badger_amount, start, end, duration, )), ) # Add all schedules to logger for i in range(0, len(schedules)): schedule = schedules[i] logger.setUnlockSchedule( schedule.beneficiary, schedule.token, schedule.amount, schedule.start, schedule.end, schedule.duration, ) # Print for key in vaults_to_run: vault = badger.getSett(key) badger.print_logger_unlock_schedules(vault, name=vault.name()) helper.publish()
def distribute_staking_rewards(self, id, amount, notify=False): deployer = self.deployer rewards = self.getSettRewards(id) rewardsToken = interface.IERC20(rewards.rewardsToken()) assert rewardsToken.balanceOf(deployer) >= amount rewardsToken.transfer( rewards, amount, {"from": deployer}, ) ## uint256 startTimestamp, uint256 _rewardsDuration, uint256 reward assert rewardsToken.balanceOf(rewards) >= amount if notify: rewards.notifyRewardAmount(chain.time(), days(7), amount, {"from": deployer})
def test_simulation_after_upgrade_crv_setts(settID): # Upgrade crv setts kkk badger = connect_badger(badger_config.prod_json) txFilename = queue_upgrade_crv_sett(badger, settID) # Sleep 2 days to pass timelock delay period. chain.sleep(2*days(2)) badger.governance_execute_transaction(txFilename) sett = interface.ISett("0x6dEf55d2e18486B9dDfaA075bc4e4EE0B28c1545") snap = SnapshotManager(badger, settID) simulation = SimulationManager(badger, snap, settID) simulation.provision() # Randomize 30 actions. simulation.randomize(30) simulation.run()
def test_simulation_after_upgrade_crv_setts(settID): # Upgrade crv strategy badger = connect_badger(badger_config.prod_json) """ TODO Get the Implementation before upgrade """ txFilename = queue_upgrade_crv_strat(badger, settID) # Sleep 2 days to pass timelock delay period. chain.sleep(2 * days(2)) badger.governance_execute_transaction(txFilename) """ TODO assert tht implementation has changed """ ## Object representing the sett we want and the mode we're in thisSettConfig = {"id": settID, "mode": "test"} ## Get badger so we can get info in sett and strats badger = badger_single_sett(thisSettConfig) ## We now have the want, we can mint some deployer = badger.deployer ## Mints token for us distribute_from_whales(deployer) snap = SnapshotManager(badger, settID) simulation = SimulationManager(badger, snap, settID) simulation.provision() # Randomize 30 actions. simulation.randomize(30) simulation.run() assert_deposit_withdraw_single_user_flow(thisSettConfig) assert_single_user_harvest_flow(thisSettConfig) assert_migrate_single_user(thisSettConfig) assert_withdraw_other(thisSettConfig) assert_single_user_harvest_flow_remove_fees(thisSettConfig) assert_strategy_action_permissions(thisSettConfig) assert_strategy_config_permissions(thisSettConfig) assert_strategy_pausing_permissions(thisSettConfig) assert_sett_pausing_permissions(thisSettConfig) assert_sett_config_permissions(thisSettConfig) assert_controller_permissions(thisSettConfig)
def single_user_harvest_flow(badger: BadgerSystem, settConfig, user): strategy = badger.getStrategy(settConfig["id"]) want = interface.IERC20(registry.pancake.chefPairs.bnbBtcb) snap = SnapshotManager(badger, settConfig["id"]) sett = badger.getSett(settConfig["id"]) settKeeper = accounts.at(sett.keeper(), force=True) strategyKeeper = accounts.at(strategy.keeper(), force=True) randomUser = accounts[6] tendable = strategy.isTendable() startingBalance = want.balanceOf(user) depositAmount = startingBalance // 200 assert startingBalance >= depositAmount assert startingBalance >= 0 # Deposit want.approve(sett, MaxUint256, {"from": user}) snap.settDeposit(depositAmount, {"from": user}) assert want.balanceOf(sett) > 0 print("want.balanceOf(sett)", want.balanceOf(sett)) # Earn snap.settEarn({"from": settKeeper}) if tendable: with brownie.reverts("onlyAuthorizedActors"): strategy.tend({"from": randomUser}) numTends = 48 timeBetweenTends = days(365) // numTends console.print({"numTends": numTends, "timeBetweenTends": timeBetweenTends}) for i in range(0, numTends): console.print("Tend {}".format(i)) snap.settTend({"from": strategyKeeper}) chain.sleep(timeBetweenTends) chain.mine() with brownie.reverts("onlyAuthorizedActors"): strategy.harvest({"from": randomUser}) snap.settHarvest({"from": strategyKeeper})
def test_simulation_after_upgrade_sushi_strategies(args): (strategyID, artifactName) = args # Upgrade crv setts kkk badger = connect_badger(badger_config.prod_json) txFilename = queue_upgrade_strategy(badger, strategyID, artifactName) # Sleep 2 days to pass timelock delay period. chain.sleep(2 * days(2)) badger.governance_execute_transaction(txFilename) # NB: strategy/sett IDs align snap = SnapshotManager(badger, strategyID) simulation = SimulationManager(badger, snap, strategyID) simulation.provision() # Randomize 30 actions. simulation.randomize(30) simulation.run()
def main(): """ Connect to badger, distribute assets to specified test user, and keep ganache open. Ganache will run with your default brownie settings for mainnet-fork """ # The address to test with user = accounts.at(decouple.config("TEST_ACCOUNT"), force=True) badger = connect_badger(badger_config.prod_json) console.print("[blue]=== 🦡 Test ENV for account {} 🦡 ===[/blue]".format(user)) distribute_test_ether(user, Wei("10 ether")) distribute_from_whales(badger, user) console.print("[green]=== ✅ Test ENV Setup Complete ✅ ===[/green]") # Keep ganache open until closed time.sleep(days(365))
def __init__(self, key): self.key = key self.events = DotMap() self.stakes = DotMap() self.totalShareSeconds = 0 self.users = DotMap() self.unlockSchedules = DotMap() self.distributionTokens = [] self.totalDistributions = DotMap() self.totalShareSecondsInRange = 0 self.logic = LinearLogic( { "x": 0, "y": badger_config.startMultiplier }, { "x": days(7 * 8), "y": badger_config.endMultiplier }, )
def main(): """ Connect to badger, distribute assets to specified test user, and keep ganache open. Ganache will run with your default brownie settings for mainnet-fork """ # The address to test with user = accounts.at(decouple.config("TEST_ACCOUNT"), force=True) badger = connect_badger() tree = badger.badgerTree newLogic = BadgerTreeV2.at("0x603ad0e0e0fc873371bd1d98f06e567a8c752ac8") ops = accounts.at(badger.opsMultisig, force=True) badger.opsProxyAdmin.upgrade(tree, newLogic, {"from": ops}) distribute_from_whales(user) console.print("[green]=== ✅ Test ENV Setup Complete ✅ ===[/green]") # Keep ganache open until closed time.sleep(days(365))
def main(): badger = connect_badger(load_deployer=True) admin = badger.devProxyAdmin multisig = badger.devMultisig contracts = badger.contracts_upgradeable deployer = badger.deployer safe = ApeSafe(badger.opsMultisig.address) logger = safe.contract(badger.rewardsLogger.address) experimental_vault = "0x8a8ffec8f4a0c8c9585da95d9d97e8cd6de273de" start = 1620943200 duration = days(7) end = start + duration badger_amount = int(Wei("4000 ether") * .9) digg_amount = int(fragments_to_shares(0.4) * .9) dfd_amount = int(Wei("205131 ether") * .9) schedules = [ LoggerUnlockSchedule((experimental_vault, badger.token.address, badger_amount, start, end, duration)), LoggerUnlockSchedule((experimental_vault, badger.digg.token.address, digg_amount, start, end, duration)), LoggerUnlockSchedule((experimental_vault, registry.tokens.dfd, dfd_amount, start, end, duration)) ] for i in range(0, len(schedules)): schedule = schedules[i] logger.setUnlockSchedule( schedule.beneficiary, schedule.token, schedule.amount, schedule.start, schedule.end, schedule.duration ) badger.print_logger_unlock_schedules(experimental_vault, name="Experimental iBBTC Vault") helper = ApeSafeHelper(badger, safe) helper.publish()
def main(): badger = connect_badger("deploy-final.json") bBadger = badger.getSett("native.badger") escrows = [ "0x1fc3C85456322C8514c0ff7694Ea4Ef5bC7F9f37", "0xaeDb773C226e6d74f2cd3542372076779Ff6fA6E" ] timelocks = [ "0x2Bc1A5E26ad0316375E68942fe0B387adE6b9254", "0x7C651D13DfB87748b0F05914dFb40E5B15a78D35", "0xB6c9e9Ba41291044Cf5dadFB22D72d3fe9312880", "0xdbd185c59f64d2d39c6ababf5d701669417a002d" # "0x1fc3C85456322C8514c0ff7694Ea4Ef5bC7F9f37", # "0xaeDb773C226e6d74f2cd3542372076779Ff6fA6E" ] for address in timelocks: vesting = interface.ITokenTimelock(address) console.print( { "token": vesting.token(), "beneficiary": vesting.beneficiary(), "releaseTime": vesting.releaseTime(), "releaseDate": to_utc_date(vesting.releaseTime()), } ) chain.sleep(days(182)) chain.mine() for address in timelocks: vesting = interface.ITokenTimelock(address) beneficiary = accounts.at(vesting.beneficiary(), force=True) pre = get_token_balances([bBadger], [vesting, beneficiary]) vesting.release({"from": badger.deployer}) post = get_token_balances([bBadger], [vesting, beneficiary]) diff_token_balances(pre, post)
def main(): badger = connect_badger("deploy-final.json") test_user = accounts.at(decouple.config("TEST_ACCOUNT"), force=True) distribute_test_ether(test_user, Wei("20 ether")) distribute_from_whales(test_user, assets=["bBadger", "badger", "usdc"]) rest = get_active_rewards_schedule(badger) usdc = interface.IERC20(registry.tokens.usdc) usdc_per_badger = 40.37 * 0.75 usdc_total = 13386240 multi = GnosisSafe(badger.devMultisig) badger_total_scaled = usdc_total / usdc_per_badger badger_total = Wei(str(badger_total_scaled) + " ether") bBadger = badger.getSett("native.badger") ppfs = bBadger.getPricePerFullShare() bBadger_total = int(badger_total / ppfs * 10**18) badger_total = Wei(str(badger_total_scaled) + " ether") console.print({ "TRADE": "BASED", "usdc_per_badger": usdc_per_badger, "usdc_total": usdc_total, "badger_total_scaled": badger_total_scaled, "badger_total": badger_total, "ppfs": ppfs, "bBadger_total": str(bBadger_total), }) params = { "beneficiary": "0x3159b46a7829a0dbfa856888af768fe7146e7418", "duration": days(182), "usdcAmount": usdc_total * 10**6, "bBadgerAmount": bBadger_total, # "usdcAmount": 0, # "bBadgerAmount": 0, } console.print(params) # # Oxb1 Test beneficiary = accounts.at(params["beneficiary"], force=True) escrow = OtcEscrow.at("0x7163fB2fA38Ea3BBc1F8525F3d8D0417C0c9d903") # bBadger.transfer(badger.devMultisig, Wei("100000 ether"), {"from": test_user}) pre = get_token_balances( [usdc, bBadger], [test_user, escrow, badger.devMultisig, beneficiary]) pre.print() # assert usdc.balanceOf(params["beneficiary"]) >= params["usdcAmount"] # multi.execute(MultisigTxMetadata(description="Transfer to 0xb1"), { # "to": bBadger.address, # "data": bBadger.transfer.encode_input(escrow, bBadger_total + Wei("1000 ether")) # }) # assert usdc.allowance(beneficiary, escrow) >= params["usdcAmount"] # usdc.approve(escrow, params["usdcAmount"], {"from": beneficiary}) # tx = escrow.swap({"from": beneficiary}) tx = multi.execute(MultisigTxMetadata(description="Swap"), { "to": escrow.address, "data": escrow.swap.encode_input() }, print_output=False) chain.mine() print(tx.call_trace()) vesting = interface.ITokenTimelock( tx.events["VestingDeployed"][0]["vesting"]) console.print({ "token": vesting.token(), "beneficiary": vesting.beneficiary(), "releaseTime": to_utc_date(vesting.releaseTime()), }) post = get_token_balances( [usdc, bBadger], [test_user, escrow, badger.devMultisig, beneficiary]) diff_token_balances(pre, post) try: vesting.release({"from": test_user}) except: print("early vest failed!") chain.sleep(days(182)) chain.mine() # End vesting.release({"from": test_user}) post = get_token_balances( [usdc, bBadger], [test_user, escrow, badger.devMultisig, beneficiary]) diff_token_balances(pre, post) return escrow = OtcEscrow.deploy( params["beneficiary"], params["duration"], params["usdcAmount"], params["bBadgerAmount"], {"from": badger.deployer}, ) beneficiary = accounts.at(params["beneficiary"], force=True) usdc.transfer(beneficiary, params["usdcAmount"], {"from": test_user}) usdc.transfer(beneficiary, 1500000000000, {"from": test_user}) badger.token.transfer(badger.devMultisig, badger_total, {"from": test_user}) multi.execute( MultisigTxMetadata(description="Whitelist Multi"), { "to": bBadger.address, "data": bBadger.approveContractAccess.encode_input( badger.devMultisig), }, ) assert badger.token.balanceOf(badger.devMultisig) > Wei("100 ether") multi.execute( MultisigTxMetadata(description="Approve bBadger Contract"), { "to": badger.token.address, "data": badger.token.approve.encode_input(bBadger, badger_total), }, ) multi.execute( MultisigTxMetadata(description="Deposit"), { "to": bBadger.address, "data": bBadger.deposit.encode_input(badger_total) }, ) console.print( "bBadger.balanceOf(badger.devMultisig)", bBadger.balanceOf(badger.devMultisig), params["bBadgerAmount"], params["bBadgerAmount"] - bBadger.balanceOf(badger.devMultisig)) assert bBadger.balanceOf(badger.devMultisig) >= params["bBadgerAmount"] chain.mine() chain.sleep(14) chain.mine() multi.execute( MultisigTxMetadata(description="Transfer"), { "to": bBadger.address, "data": bBadger.transfer.encode_input(escrow, params["bBadgerAmount"]), }, ) assert bBadger.balanceOf(escrow) == params["bBadgerAmount"] multi.execute( MultisigTxMetadata(description="Revoke"), { "to": escrow.address, "data": escrow.revoke.encode_input() }, ) assert bBadger.balanceOf(escrow) == 0 assert bBadger.balanceOf(badger.devMultisig) >= params["bBadgerAmount"] print(bBadger.balanceOf(badger.devMultisig)) bBadger.transfer(escrow, params["bBadgerAmount"], {"from": test_user}) pre = get_token_balances( [usdc, bBadger], [test_user, escrow, badger.devMultisig, beneficiary]) console.print(pre) assert usdc.balanceOf(beneficiary) >= params["usdcAmount"] assert bBadger.balanceOf(escrow) == params["bBadgerAmount"] usdc.approve(escrow, params["usdcAmount"], {"from": beneficiary}) tx = escrow.swap({"from": beneficiary}) post = get_token_balances( [usdc, bBadger], [test_user, escrow, badger.devMultisig, beneficiary]) console.print(tx.events) post.print() diff_token_balances(pre, post) vesting = interface.ITokenTimelock( tx.events["VestingDeployed"][0]["vesting"]) console.print({ "token": vesting.token(), "beneficiary": vesting.beneficiary(), "releaseTime": to_utc_date(vesting.releaseTime()), }) chain.sleep(days(365)) chain.mine() vesting.release({"from": test_user})
def main(): """ Connect to badger, distribute assets to specified test user, and keep ganache open. Ganache will run with your default brownie settings for mainnet-fork """ # The address to test with user = accounts.at(decouple.config("TEST_ACCOUNT"), force=True) badger = connect_badger("deploy-final.json", load_deployer=True, load_keeper=True, load_guardian=True) digg = connect_digg("deploy-final.json") digg.token = digg.uFragments badger.add_existing_digg(digg) console.print( "[blue]=== 🦡 Test ENV for account {} 🦡 ===[/blue]".format(user)) distribute_test_ether(user, Wei("10 ether")) distribute_test_ether(badger.deployer, Wei("20 ether")) distribute_from_whales(user) wbtc = interface.IERC20(token_registry.wbtc) assert wbtc.balanceOf(user) >= 200000000 init_prod_digg(badger, user) accounts.at(digg.daoDiggTimelock, force=True) digg.token.transfer(user, 20000000000, {"from": digg.daoDiggTimelock}) digg_liquidity_amount = 1000000000 wbtc_liquidity_amount = 100000000 assert digg.token.balanceOf(user) >= digg_liquidity_amount * 2 assert wbtc.balanceOf(user) >= wbtc_liquidity_amount * 2 uni = UniswapSystem() wbtc.approve(uni.router, wbtc_liquidity_amount, {"from": user}) digg.token.approve(uni.router, digg_liquidity_amount, {"from": user}) uni.router.addLiquidity( digg.token, wbtc, digg_liquidity_amount, wbtc_liquidity_amount, digg_liquidity_amount, wbtc_liquidity_amount, user, chain.time() + 1000, {"from": user}, ) sushi = SushiswapSystem() wbtc.approve(sushi.router, wbtc_liquidity_amount, {"from": user}) digg.token.approve(sushi.router, digg_liquidity_amount, {"from": user}) sushi.router.addLiquidity( digg.token, wbtc, digg_liquidity_amount, wbtc_liquidity_amount, digg_liquidity_amount, wbtc_liquidity_amount, user, chain.time() + 1000, {"from": user}, ) console.print("[green]=== ✅ Test ENV Setup Complete ✅ ===[/green]") # Keep ganache open until closed time.sleep(days(365))
def tokensPerDay(self, amount): return amount * days(1) / self.duration
) globalStartTime = 1607014800 badger_config = DotMap( prod_json="deploy-final.json", test_mode=False, startMultiplier=1, endMultiplier=3, multisig=multisig_config, dao=dao_config, globalStartTime=globalStartTime, huntParams=DotMap( startTime=int(time.time()), badgerAmount=badger_total_supply * 10 // 100, gracePeriod=days(2), epochDuration=days(1), merkleRoot=Airdrop["merkleRoot"], claimReductionPerEpoch=2000, ), founderRewardsAmount=badger_total_supply * 10 // 100, initialHuntAmount=badger_total_supply * 5 // 100, rewardsEscrowBadgerAmount=badger_total_supply * 40 // 100, tokenLockParams=DotMap( badgerLockAmount=badger_total_supply * 35 // 100, lockDuration=days(30), ), teamVestingParams=DotMap( startTime=globalStartTime, cliffDuration=days(30), totalDuration=days(365),
initial_fragments_to_current_fragments, shares_to_fragments, to_digg_shares, val, ) from rich import pretty from rich.console import Console from scripts.systems.badger_system import BadgerSystem, connect_badger from tabulate import tabulate from ape_safe import ApeSafe console = Console() pretty.install() start = to_timestamp(datetime.datetime(2021, 7, 8, 13, 00)) duration = days(7) def set_schedules(logger, schedules): for i in range(0, len(schedules)): schedule = schedules[i] logger.setUnlockSchedule( schedule.beneficiary, schedule.token, schedule.amount, schedule.start, schedule.end, schedule.duration, )
"native.tricrypto", "native.cvxCrv", "native.cvx", ], }, "bsc": { "harvest": ["native.pancakeBnbBtcB", "native.pancakeBnbBtcb", "native.test"], "tend": [], "earn": [], }, } run_intervals = { "eth": { "harvest": days(1), "tend": hours(12), "earn": minutes(60), }, "bsc": { "harvest": minutes(10), "tend": minutes(15), "earn": minutes(10), }, } earn_default_percentage_threshold = 0.01 btc_threshold = Wei("2 ether") earn_threshold_value_override = { "eth": {