def grant_token_locking_permission(badger: BadgerSystem, locker): multi = GnosisSafe(badger.devMultisig) for key in keys: geyser = badger.getGeyser(key) print(key, geyser) multi.execute( MultisigTxMetadata( description="Add Geyser permission for {} to {}".format(key, locker) ), { "to": geyser.address, "data": geyser.grantRole.encode_input(TOKEN_LOCKER_ROLE, locker), }, ) assert geyser.hasRole(TOKEN_LOCKER_ROLE, locker)
def test_signal_token_lock(badger: BadgerSystem, locker): opsMulti = GnosisSafe(badger.opsMultisig) for key in keys: geyser = badger.getGeyser(key) print(key, geyser) opsMulti.execute( MultisigTxMetadata(description="Test signal token lock"), { "to": locker.address, "data": locker.signalTokenLocks.encode_input([ (geyser, badger.token, 1, 1, chain.time()), (geyser, badger.digg.token, 2, 2, chain.time()), ]), }, ) print(geyser.getUnlockSchedulesFor(badger.token)) print(geyser.getUnlockSchedulesFor(badger.digg.token))
def post_deploy_config(badger: BadgerSystem): deployer = badger.deployer """ Set initial conditions on immediate post-deploy Badger Transfer tokens to thier initial locations - Rewards Escrow (40%, minus tokens initially distributed via Sett Special StakingRewards) - Badger Hunt (15%) - DAO Timelock (35%) - Founder Rewards (10%) """ # Approve BadgerTree to recieve rewards tokens print(deployer) print(badger.rewardsEscrow.owner()) # badger.rewardsEscrow.approveRecipient(badger.badgerTree, {"from": deployer}) # badger.rewardsEscrow.approveRecipient( # badger.getGeyser("native.badger"), {"from": deployer} # ) # badger.rewardsEscrow.approveRecipient( # badger.getGeyser("native.uniBadgerWbtc"), {"from": deployer} # ) # badger.rewardsEscrow.approveRecipient( # badger.getGeyser("native.renCrv"), {"from": deployer} # ) # badger.rewardsEscrow.approveRecipient( # badger.getGeyser("native.sbtcCrv"), {"from": deployer} # ) # badger.rewardsEscrow.approveRecipient( # badger.getGeyser("native.tbtcCrv"), {"from": deployer} # ) # badger.rewardsEscrow.approveRecipient( # badger.getGeyser("harvest.renCrv"), {"from": deployer} # ) # console.log("before signal locks", badger.token.balanceOf(deployer) / 1e18) # # Geyser Signals # """ # These signals are used to calculate the rewards distributions distributed via BadgerTree. The tokens are actually held in the RewardsEscrow and sent to the BadgerTree as needed. # The escrow will only send a few days worth of rewards initially at a time to the RewardsTree as another failsafe mechanism. # renbtcCRV — 76750 $BADGER # sbtcCRV — 76,750 $BADGER # tbtcCRV — 76,750 $BADGER # Badger — 90,000 $BADGER / 2 # - 45000 in Sett StakingRewards # - 45000 in Geyser # Badger <>wBTC Uniswap LP — 130,000 $BADGER / 2 # - 65000 in Sett StakingRewards # - 65000 in Geyser # Super Sett # Pickle renbtcCRV — 76,750 $BADGER # Harvest renbtc CRV — 76,750 $BADGER # """ # badger.signal_token_lock( # "native.badger", badger_config.geyserParams.unlockSchedules.badger[0] # ) # badger.signal_token_lock( # "native.uniBadgerWbtc", # badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0], # ) # badger.signal_token_lock( # "native.renCrv", badger_config.geyserParams.unlockSchedules.bRenCrv[0] # ) # badger.signal_token_lock( # "native.sbtcCrv", badger_config.geyserParams.unlockSchedules.bSbtcCrv[0] # ) # badger.signal_token_lock( # "native.tbtcCrv", badger_config.geyserParams.unlockSchedules.bTbtcCrv[0] # ) # badger.signal_token_lock( # "harvest.renCrv", # badger_config.geyserParams.unlockSchedules.bSuperRenCrvHarvest[0], # ) # console.log( # "before initial token distribution", badger.token.balanceOf(deployer) / 1e18 # ) # ===== Initial Token Distribution ===== # == Native Badger == rewards = badger.getSettRewards("native.badger") strategy = badger.getStrategy("native.badger") badger.distribute_staking_rewards( "native.badger", badger_config.geyserParams.unlockSchedules.badger[0].amount, notify=False, ) rewards.grantRole(APPROVED_STAKER_ROLE, strategy, {"from": deployer}) # == Uni LP == rewards = badger.getSettRewards("native.uniBadgerWbtc") strategy = badger.getStrategy("native.uniBadgerWbtc") badger.distribute_staking_rewards( "native.uniBadgerWbtc", badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0].amount, notify=False, ) rewards.grantRole(APPROVED_STAKER_ROLE, strategy, {"from": deployer}) console.log( "remaining after special pool distributions", badger.token.balanceOf(deployer) / 1e18, ) distributedToPools = ( badger_config.geyserParams.unlockSchedules.badger[0].amount + badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0].amount) # print( # badger_config.geyserParams.unlockSchedules.badger[0], # badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0], # badger_config.geyserParams.unlockSchedules.bRenCrv[0], # badger_config.geyserParams.unlockSchedules.bSbtcCrv[0], # badger_config.geyserParams.unlockSchedules.bTbtcCrv[0], # badger_config.geyserParams.unlockSchedules.bSuperRenCrvHarvest[0] # ) supplyForWeek1Rewards = ( badger_config.geyserParams.unlockSchedules.badger[0].amount + badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0].amount + badger_config.geyserParams.unlockSchedules.bRenCrv[0].amount + badger_config.geyserParams.unlockSchedules.bSbtcCrv[0].amount + badger_config.geyserParams.unlockSchedules.bTbtcCrv[0].amount + badger_config.geyserParams.unlockSchedules.bSuperRenCrvHarvest[0]. amount) toEscrow = (badger_config.rewardsEscrowBadgerAmount - distributedToPools - supplyForWeek1Rewards) badger.initialRewardsEscrowBalance = toEscrow badger.initialBadgerTreeBalance = supplyForWeek1Rewards console.log(locals(), badger_config.rewardsEscrowBadgerAmount) # == Badger Hunt == badger.token.transfer( badger.badgerHunt, badger_config.huntParams.badgerAmount, {"from": deployer}, ) # == Badger Tree == badger.token.transfer( badger.badgerTree, supplyForWeek1Rewards, {"from": deployer}, ) # == Rewards Escrow == badger.token.transfer( badger.rewardsEscrow, toEscrow, {"from": deployer}, ) # == DAO Timelock == badger.token.transfer( badger.daoBadgerTimelock, badger_config.tokenLockParams.badgerLockAmount, {"from": deployer}, ) console.log("after daoBadgerTimelock", badger.token.balanceOf(deployer) / 1e18) # == Team Vesting == badger.token.transfer(badger.teamVesting, badger_config.founderRewardsAmount, {"from": deployer}) tokenDistributionTargets = { "deployer": 0, "rewardsEscrow": toEscrow, "native.badger Pool": badger_config.geyserParams.unlockSchedules.badger[0].amount, "native.uniBadgerWbtc Pool": badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0].amount, "native.badger geyser": badger_config.geyserParams.unlockSchedules.badger[0].amount, "native.uniBadgerWbtc geyser": badger_config.geyserParams.unlockSchedules.uniBadgerWbtc[0].amount, "native.renCrv geyser": badger_config.geyserParams.unlockSchedules.bRenCrv[0].amount, "native.sbtcCrv geyser": badger_config.geyserParams.unlockSchedules.bSbtcCrv[0].amount, "native.tbtcCrv geyser": badger_config.geyserParams.unlockSchedules.bTbtcCrv[0].amount, "harvest.renCrv geyser": badger_config.geyserParams.unlockSchedules.bSuperRenCrvHarvest[0]. amount, "daoBadgerTimelock": badger_config.tokenLockParams.badgerLockAmount, "teamVesting": badger_config.founderRewardsAmount, "badgerHunt": badger_config.huntParams.badgerAmount, "badgerTree": 0, } tokenDistributionBalances = { "deployer": badger.token.balanceOf(deployer), "rewardsEscrow": badger.token.balanceOf(badger.rewardsEscrow), "native.badger Pool": badger.token.balanceOf(badger.getSettRewards("native.badger")), "native.uniBadgerWbtc Pool": badger.token.balanceOf(badger.getSettRewards("native.uniBadgerWbtc")), "native.badger geyser": badger.token.balanceOf(badger.getGeyser("native.badger")), "native.uniBadgerWbtc geyser": badger.token.balanceOf(badger.getGeyser("native.uniBadgerWbtc")), "native.renCrv geyser": badger.token.balanceOf(badger.getGeyser("native.renCrv")), "native.sbtcCrv geyser": badger.token.balanceOf(badger.getGeyser("native.sbtcCrv")), "native.tbtcCrv geyser": badger.token.balanceOf(badger.getGeyser("native.tbtcCrv")), "harvest.renCrv geyser": badger.token.balanceOf(badger.getGeyser("harvest.renCrv")), "daoBadgerTimelock": badger.token.balanceOf(badger.daoBadgerTimelock), "teamVesting": badger.token.balanceOf(badger.teamVesting), "badgerHunt": badger.token.balanceOf(badger.badgerHunt), "badgerTree": badger.initialBadgerTreeBalance, } if not badger.test: expectedSum = 0 actualSum = 0 for key, value in tokenDistributionTargets.items(): print("expected", key, value / 1e18) print("actual", key, tokenDistributionBalances[key] / 1e18) expectedSum += value actualSum += tokenDistributionBalances[key] print("expectedSum", expectedSum / 1e18) print("actualSum", actualSum / 1e18) # assert expectedSum == badger_total_supply # assert actualSum == badger_total_supply console.log("after teamVesting", badger.token.balanceOf(deployer) / 1e18) """ ===== Transfer Ownership ===== - proxyAdmin should be owned by multisig - All contract owner / admin rights should be given to multisig """ badger.rewardsEscrow.transferOwnership(badger.devMultisig, {"from": deployer})
def init_prod_digg(badger: BadgerSystem, user): deployer = badger.deployer digg = badger.digg multi = GnosisSafe(badger.devMultisig) digg_liquidity_amount = 1000000000 wbtc_liquidity_amount = 100000000 print("TOKEN_LOCKER_ROLE", TOKEN_LOCKER_ROLE) locker_role = "0x4bf6f2cdcc8ad6c087a7a4fbecf46150b3686b71387234cac2b3e2e6dc70e345" # TODO: Have this as proxy in real deploy seederLogic = DiggSeeder.deploy({"from": deployer}) seeder = deploy_proxy( "DiggSeeder", DiggSeeder.abi, seederLogic.address, badger.devProxyAdmin.address, seederLogic.initialize.encode_input(digg.diggDistributor), deployer, ) # # Take initial liquidity from DAO # aragon = AragonSystem() # voting = aragon.getVotingAt("0xdc344bfb12522bf3fa58ef0d6b9a41256fc79a1b") # PROD: Configure DIGG digg.uFragmentsPolicy.setCpiOracle( digg.cpiMedianOracle, {"from": deployer}, ) digg.uFragmentsPolicy.setMarketOracle( digg.marketMedianOracle, {"from": deployer}, ) digg.uFragmentsPolicy.setOrchestrator( digg.orchestrator, {"from": deployer}, ) digg.uFragments.setMonetaryPolicy( digg.uFragmentsPolicy, {"from": deployer}, ) # ===== Upgrade DAOTimelock to allow voting ===== # print(badger.logic.SimpleTimelockWithVoting.address) # timelockWithVotingLogic = SimpleTimelockWithVoting.at(badger.logic.SimpleTimelockWithVoting.address) # timelock = interface.ISimpleTimelockWithVoting(badger.daoBadgerTimelock.address) # multi.execute( # MultisigTxMetadata(description="Upgrade DAO Badger Timelock to Allow voting",), # { # "to": badger.devProxyAdmin.address, # "data": badger.devProxyAdmin.upgrade.encode_input( # badger.daoBadgerTimelock, timelockWithVotingLogic # ), # }, # ) # # ===== Vote to move initial liquidity funds to multisig ===== # tx = multi.execute( # MultisigTxMetadata(description="Vote on DAO Timelock from multisig",), # { # "to": timelock.address, # "data": timelock.vote.encode_input(0, True, True) # }, # ) # # Approve DAO voting as recipient # multi.execute( # MultisigTxMetadata(description="Approve DAO voting as recipient",), # { # "to": badger.rewardsEscrow.address, # "data": badger.rewardsEscrow.approveRecipient.encode_input(voting), # }, # ) # # Vote on DAO voting as rewardsEscrow # before = badger.token.balanceOf(badger.rewardsEscrow) # tx = multi.execute( # MultisigTxMetadata(description="Vote on Rewards Escrow from multisig",), # { # "to": badger.rewardsEscrow.address, # "data": badger.rewardsEscrow.call.encode_input( # voting, 0, voting.vote.encode_input(0, True, True) # ), # }, # ) # after = badger.token.balanceOf(badger.rewardsEscrow) # print(tx.call_trace()) # assert after == before # crvRen = interface.IERC20(registry.curve.pools.renCrv.token) wbtc = interface.IERC20(registry.tokens.wbtc) # assert crvRen.balanceOf(badger.devMultisig) >= wbtc_liquidity_amount * 10 ** 10 * 2 # crvPool = interface.ICurveZap(registry.curve.pools.renCrv.swap) # # crvPool.Remove_liquidity_one_coin( # # wbtc_liquidity_amount * 10 ** 10, 1, wbtc_liquidity_amount # # ) # # ===== Convert crvRen to wBTC on multisig ===== # tx = multi.execute( # MultisigTxMetadata(description="Withdraw crvRen for 100% WBTC",), # { # "to": crvPool.address, # "data": crvPool.remove_liquidity_one_coin.encode_input( # wbtc_liquidity_amount * 10 ** 10 * 2, 1, wbtc_liquidity_amount * 2 # ), # }, # ) # assert wbtc.balanceOf(badger.devMultisig) >= wbtc_liquidity_amount * 2 # ===== Move initial liquidity funds to Seeder ===== multi.execute( MultisigTxMetadata( description="Transfer initial liquidity WBTC to the Seeder", ), { "to": wbtc.address, "data": wbtc.transfer.encode_input(seeder, 200000000), }, ) # ===== Move DIGG to Seeder ===== digg.token.transfer(seeder, digg.token.totalSupply(), {"from": deployer}) # ===== Move Required Badger to Seeder from RewardsEscrow ===== multi.execute( MultisigTxMetadata( description="Move Required Badger to Seeder from RewardsEscrow", ), { "to": badger.rewardsEscrow.address, "data": badger.rewardsEscrow.transfer.encode_input(badger.token, seeder, Wei("30000 ether")), }, ) # ===== Add DIGG token to all geyser distribution lists ===== # (Also, add Seeder as approved schedule creator) geyser_keys = [ "native.badger", "native.renCrv", "native.sbtcCrv", "native.tbtcCrv", "native.uniBadgerWbtc", "harvest.renCrv", "native.sushiWbtcEth", "native.sushiBadgerWbtc", "native.uniDiggWbtc", "native.sushiDiggWbtc", ] for key in geyser_keys: geyser = badger.getGeyser(key) print(key, geyser) id = multi.addTx( MultisigTxMetadata( description="Add DIGG token to distribution tokens on {} geyser" .format(key), ), { "to": geyser.address, "data": geyser.addDistributionToken.encode_input(digg.token), }, ) tx = multi.executeTx(id) assert geyser.hasRole(DEFAULT_ADMIN_ROLE, badger.devMultisig) multi.execute( MultisigTxMetadata( description="Allow Seeder to set unlock schedules on {} geyser" .format(key), ), { "to": geyser.address, "data": geyser.grantRole.encode_input(locker_role, seeder), }, ) assert geyser.hasRole(locker_role, seeder) # Seeder needs to have admin role to config Faucets. Remove role as part of seed. rewards_keys = [ "native.digg", "native.uniDiggWbtc", "native.sushiDiggWbtc", ] for key in rewards_keys: rewards = badger.getSettRewards(key) rewards.grantRole(DEFAULT_ADMIN_ROLE, seeder, {"from": deployer}) rewards.grantRole(DEFAULT_ADMIN_ROLE, badger.devMultisig, {"from": deployer}) rewards.renounceRole(DEFAULT_ADMIN_ROLE, deployer, {"from": deployer}) # print(digg.token.balanceOf(deployer)) # assert digg.token.balanceOf(deployer) == digg.token.totalSupply() # digg.token.transfer(seeder, digg.token.totalSupply(), {"from": deployer}) # wbtc = interface.IERC20(token_registry.wbtc) # wbtc.transfer(seeder, 200000000, {"from": user}) # ===== Seed Prep ===== print("wbtc.balanceOf(seeder)", wbtc.balanceOf(seeder)) assert digg.token.balanceOf(seeder) >= digg.token.totalSupply() assert wbtc.balanceOf(seeder) >= 200000000 print(digg.diggDistributor.address) print("digg.diggDistributor", digg.diggDistributor.isOpen()) digg.diggDistributor.transferOwnership(seeder, {"from": deployer}) print("prePreSeed", digg.token.balanceOf(seeder)) seeder.preSeed({"from": deployer}) print("postPreSeed", digg.token.balanceOf(seeder)) seeder.seed({"from": deployer}) # seeder.transferOwnership(badger.devMultisig, {'from': deployer}) # tx = multi.execute( # MultisigTxMetadata(description="Withdraw crvRen for 100% WBTC",), # { # "to": seeder.address, # "data": seeder.preSeed.encode_input(), # }, # ) # seeder.initialize({"from": deployer}) # Unpause all Setts setts_to_unpause = [ "native.digg", "native.uniDiggWbtc", "native.sushiDiggWbtc", ] for key in setts_to_unpause: sett = badger.getSett(key) id = multi.addTx( MultisigTxMetadata(description="Unpause Sett {}".format(key), ), { "to": sett.address, "data": sett.unpause.encode_input(), }, ) tx = multi.executeTx(id) assert sett.paused() == False
def confirm_setup_rewards(badger: BadgerSystem): # Badger Tree confirm_badger_tree_params( badger, badger.badgerTree, DotMap( admin=badger.devMultisig, rootUpdater=badger.deployer, guardian=badger.deployer, # initialBalance=badger.initialBadgerTreeBalance, ), ) # Rewards Escrow confirm_rewards_escrow_params(badger.rewardsEscrow, DotMap(owner=badger.devMultisig)) # Badger Hunt confirm_badger_hunt_params( badger.badgerHunt, DotMap( token=badger.token, merkleRoot=EmptyBytes32, epochDuration=days(1), rewardReductionPerEpoch=2000, claimsStart=badger_config.globalStartTime, gracePeriod=days(2), rewardsEscrow=badger.rewardsEscrow, currentRewardRate=10000, ), ) # Badger Geysers common_geyser_params = DotMap( tokenLockers=[badger.rewardsEscrow.address], admin=badger.devMultisig, initialDistributionToken=badger.token, ) params = common_geyser_params params.stakingToken = badger.getSett("native.renCrv") confirm_badger_geyser_params(badger.getGeyser("native.renCrv"), params) params.stakingToken = badger.getSett("native.sbtcCrv") confirm_badger_geyser_params(badger.getGeyser("native.sbtcCrv"), params) params.stakingToken = badger.getSett("native.tbtcCrv") confirm_badger_geyser_params(badger.getGeyser("native.tbtcCrv"), params) params.stakingToken = badger.getSett("native.badger") confirm_badger_geyser_params(badger.getGeyser("native.badger"), params) params.stakingToken = badger.getSett("harvest.renCrv") confirm_badger_geyser_params(badger.getGeyser("harvest.renCrv"), params) # # Ensure staking not possible # for key, geyser in badger.geysers.items(): # with brownie.reverts("BadgerGeyser: Distribution not started"): # geyser.stake(0, "0x", {"from": badger.deployer}) # geyser.stakeFor(0, "0x", badger.deployer, {"from": badger.deployer}) # Badger Balances # Some of the initial supply is distributed to Sett special StakingRewards pools & BadgerTree assert (badger.token.balanceOf( badger.rewardsEscrow) == badger.initialRewardsEscrowBalance) assert (badger.token.balanceOf( badger.badgerHunt) == badger_config.huntParams.badgerAmount) assert (badger.token.balanceOf(badger.daoBadgerTimelock) == badger_config.tokenLockParams.badgerLockAmount)