def main(): badger = connect_badger("deploy-final.json") digg = badger.digg admin = badger.devProxyAdmin multisig = badger.devMultisig contracts = badger.contracts_upgradeable deployer = badger.deployer expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77" assert multisig == expectedMultisig safe = ApeSafe(badger.devMultisig.address) abi = Sett.abi diggToken = safe.contract(digg.token.address) bDigg = safe.contract_from_abi( badger.getSett("native.digg").address, "Sett", abi) rewardsEscrow = safe.contract_from_abi(badger.rewardsEscrow.address, "RewardsEscrow", RewardsEscrow.abi) teamVesting = safe.contract(badger.teamVesting.address) voting = safe.contract_from_abi(badger.daoBadgerTimelock.address, "IVoting", interface.IVoting.abi) aragon = AragonSystem() aragonVoting = aragon.getVotingAt( web3.toChecksumAddress("0xdc344bfb12522bf3fa58ef0d6b9a41256fc79a1b")) token_registry = registry.token_system() dev = accounts.at(badger.devMultisig.address, force=True) tokens = [ token_registry.erc20_by_address(registry.tokens.farm), token_registry.erc20_by_address(registry.tokens.xSushi), token_registry.erc20_by_address(registry.curve.pools.sbtcCrv.token), token_registry.erc20_by_address(registry.curve.pools.renCrv.token), token_registry.erc20_by_address(registry.curve.pools.tbtcCrv.token), token_registry.erc20_by_address(registry.sushi.lpTokens.sushiWbtcWeth), token_registry.erc20_by_address(registry.tokens.dfd), ] snap = BalanceSnapshotter(tokens, [badger.devMultisig, badger.dao.agent]) snap.snap(name="Before Transfers") for id in vote_ids: voting.vote(id, True, True) rewardsEscrow.call(aragonVoting, 0, aragonVoting.vote.encode_input(id, True, True)) teamVesting.call(aragonVoting, 0, aragonVoting.vote.encode_input(id, True, True)) snap.snap(name="After Transfers") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger() multisig = badger.devMultisig safe = ApeSafe(multisig.address) abi = Sett.abi bBadger = safe.contract_from_abi( badger.getSett("native.badger").address, "Sett", abi ) usdcToken = safe.contract_from_abi( registry.tokens.usdc, "IERC20", interface.IERC20.abi ) badgerToken = safe.contract_from_abi( badger.token.address, "IERC20", interface.IERC20.abi ) wbtcToken = safe.contract_from_abi( registry.tokens.wbtc, "IERC20", interface.IERC20.abi ) rewardsEscrow = safe.contract(badger.rewardsEscrow.address) # TODO: Do this in bBadger going forward - this is the way. # Approve treasury multi to stake # Deposit badger -> bBadger snap = BalanceSnapshotter( [badgerToken, usdcToken, wbtcToken], [multisig, badger.deployer, badger.rewardsEscrow], ) opolis_dest = "0x27657399177403a891CC7A22Bd6F2C00621Db7b0" test_usdc = 1 * 10 ** 6 full_usdc = 499999 * 10 ** 6 full_badger = Wei("10163.59 ether") full_wbtc = 3.805754301 * 10 ** 8 console.print("Sending Amounts") snap.snap(name="Before Transfers") usdcToken.transfer(opolis_dest, full_usdc) rewardsEscrow.approveRecipient(opolis_dest) rewardsEscrow.transfer(badger.token, opolis_dest, full_badger) # badgerToken.transfer(opolis_dest, full_badger) wbtcToken.transfer(opolis_dest, full_wbtc) snap.snap(name="After Transfers") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger() multisig = badger.paymentsMultisig safe = ApeSafe(multisig.address) payments = load_ltcc_recipients("data/ltcc_recipients.csv") payments.calc_totals() payments.print_recipients() abi = Sett.abi bBadger = safe.contract_from_abi( badger.getSett("native.badger").address, "Sett", abi ) usdcToken = safe.contract_from_abi( registry.tokens.usdc, "IERC20", interface.IERC20.abi ) badgerToken = safe.contract_from_abi( badger.token.address, "IERC20", interface.IERC20.abi ) # TODO: Do this in bBadger going forward - this is the way. # Approve treasury multi to stake # Deposit badger -> bBadger snap = BalanceSnapshotter( [badgerToken, bBadger, usdcToken], [multisig, badger.deployer, badger.rewardsEscrow], ) for recipient in payments.recipients: snap.add_account(recipient.address) snap.snap(name="Before bBadger Deposit") assert bBadger.approved(multisig) badger_total = payments.totals["badger"] assert badgerToken.balanceOf(multisig.address) >= badger_total bBadger_total = badger_to_bBadger(badger, badger_total) badgerToken.approve(bBadger, badger_total) assert badgerToken.allowance(multisig.address, bBadger.address) >= badger_total bBadger.deposit(badger_total) snap.snap(name="After bBadger Deposit") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger() multisig = badger.devMultisig safe = ApeSafe(multisig.address) payments = load_ltcc_recipients("scripts/actions/treasury/ltcc_recipients.csv") payments.print_recipients() abi = Sett.abi bBadger = safe.contract_from_abi( badger.getSett("native.badger").address, "Sett", abi ) usdcToken = safe.contract_from_abi(registry.tokens.usdc, "IERC20", interface.IERC20.abi) badgerToken = safe.contract_from_abi(badger.token.address, "IERC20", interface.IERC20.abi) # TODO: Do this in bBadger going forward - this is the way. # Approve treasury multi to stake # Deposit badger -> bBadger snap = BalanceSnapshotter( [badgerToken, bBadger, usdcToken], [multisig, badger.deployer, badger.rewardsEscrow] ) for recipient in payments.recipients: snap.add_account(recipient.address) snap.snap(name="Before Transfers") for recipient in payments.recipients: bBadger_amount = badger_to_bBadger(badger, recipient.get_amount("badger")) console.print(recipient.address, recipient.get_amount("badger"), bBadger_amount) diff = bBadger_amount - bBadger.balanceOf(multisig) console.print(bBadger.balanceOf(multisig), diff) if bBadger.balanceOf(multisig) < bBadger_amount: assert diff < Wei("0.1 ether") bBadger_amount = bBadger.balanceOf(multisig) # tx = usdcToken.transfer(recipient.address, recipient.get_amount("usdc")) tx = bBadger.transfer(recipient.address, bBadger_amount) snap.snap(name="After Transfers") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger("deploy-final.json") digg = badger.digg admin = badger.devProxyAdmin multisig = badger.devMultisig contracts = badger.contracts_upgradeable deployer = badger.deployer expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77" assert multisig == expectedMultisig safe = ApeSafe(badger.devMultisig.address) abi = Sett.abi diggToken = safe.contract(digg.token.address) bDigg = safe.contract_from_abi( badger.getSett("native.digg").address, "Sett", abi) rewardsEscrow = safe.contract(badger.rewardsEscrow.address) snap = BalanceSnapshotter( [diggToken, bDigg], [badger.devMultisig, badger.deployer, badger.rewardsEscrow]) snap.snap(name="Before Transfers") ppfs = bDigg.getPricePerFullShare() digg_to_deposit = 10 * (10**18) // (10**9) console.print("digg_to_deposit", digg_to_deposit, ppfs) # Transfer assets to multisig rewardsEscrow.transfer(diggToken, badger.devMultisig, digg_to_deposit) snap.snap(name="After Transfers") snap.diff_last_two() # Deposit bDigg diggToken.approve(bDigg.address, digg_to_deposit) tx = bDigg.deposit(digg_to_deposit) print(tx.events) snap.snap(name="After Deposits") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger("deploy-final.json") digg = badger.digg admin = badger.devProxyAdmin multisig = badger.devMultisig contracts = badger.contracts_upgradeable deployer = badger.deployer expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77" assert multisig == expectedMultisig recipient = accounts.at("0x8Ea8a668f89a9A203d37D8a1E27e38De5bEb8380", force=True) safe = ApeSafe(badger.devMultisig.address) abi = Sett.abi badgerToken = safe.contract(badger.token.address) diggToken = safe.contract(digg.token.address) bBadger = safe.contract_from_abi( badger.getSett("native.badger").address, "Sett", abi) bDigg = safe.contract_from_abi( badger.getSett("native.digg").address, "Sett", abi) snap = BalanceSnapshotter( [badgerToken, diggToken, bBadger, bDigg], [badger.devMultisig, badger.deployer, badger.rewardsEscrow, recipient], ) snap.snap(name="Before Transfers", print=True) bBadger_amount = Wei("4585.501571219566358195 ether") bDigg_amount = Wei("6.96203478522210066 ether") # Transfer receieved amounts to badger deployer for transfer over bridge bBadger.transfer(recipient, bBadger_amount) bDigg.transfer(recipient, bDigg_amount) snap.snap(name="After Transfers") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger() safe = ApeSafe(badger.opsMultisig.address) nft = safe.contract_from_abi( badger_nft_address, "IBadgerERC1155", interface.IBadgerERC1155.abi ) assert nft.totalSupply(nft_id) == 210 print(len(third_set)) for recipient in third_set: nft.safeTransferFrom(badger.opsMultisig.address, recipient, nft_id, 1, "0x") console.print(recipient, nft.balanceOf(recipient, nft_id)) assert nft.balanceOf(recipient, nft_id) == 1 print("Remaining After Transfer", nft.balanceOf(badger.opsMultisig, nft_id)) safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger() digg = badger.digg safe = ApeSafe(badger.paymentsMultisig.address) abi = Sett.abi badgerToken = safe.contract(badger.token.address) diggToken = safe.contract(digg.token.address) bBadger = safe.contract_from_abi( badger.getSett("native.badger").address, "Sett", abi) bDigg = safe.contract_from_abi( badger.getSett("native.digg").address, "Sett", abi) rewardsEscrow = safe.contract(badger.rewardsEscrow.address) badger_usd = fetch_usd_price(badger.token.address) eth_usd = fetch_usd_price_eth() # USD Denominated # badger_to_send = Wei(str(total_usd / badger_usd) + " ether") # Badger Denominated badger_to_send = Wei("5970.744318 ether") table = [] table.append(["badger", badger_to_send, badger_usd]) table.append(["eth", 0, eth_usd]) print(tabulate(table, headers=["asset", "to send", "$ price"])) snap = BalanceSnapshotter( [badgerToken, bBadger], [badger.devMultisig, badger.deployer, badger.rewardsEscrow], ) snap.snap(name="Before Transfers") # Transfer assets to multisig # rewardsEscrow.transfer(badgerToken, safe, badger_to_send) snap.snap(name="After Transfers") snap.diff_last_two() # Deposit bBadger badgerToken.approve(bBadger.address, badger_to_send) bBadgerBefore = bBadger.balanceOf(safe) tx = bBadger.deposit(badger_to_send) bBadgerAfter = bBadger.balanceOf(badger.devMultisig) print( "bBadger to transfer", bBadgerAfter - bBadgerBefore, val(bBadgerAfter - bBadgerBefore), ) # bBadger.transfer(badger.paymentsMultisig, bBadgerAfter - bBadgerBefore) print(tx.events) snap.snap(name="After Deposits") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)
def main(): badger = connect_badger("deploy-final.json") digg = badger.digg tx_data = { "to": "0x8D29bE29923b68abfDD21e541b9374737B49cdAD", "data": "0x8d80ff0a000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000009fe00b65cef03b9b89f99517643226d76e286ee999e7700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024694e80c300000000000000000000000000000000000000000000000000000000000000010019d099670a21bc0a8211a89b84cedf59abb4377f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064beabacc80000000000000000000000003472a5a71965499acd81997a54bba8d852c6e53d000000000000000000000000b65cef03b9b89f99517643226d76e286ee999e7700000000000000000000000000000000000000000000017c5d213c7a8f712f400019d099670a21bc0a8211a89b84cedf59abb4377f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064beabacc8000000000000000000000000798d1be841a82a273720ce31c822c61a67a601c3000000000000000000000000b65cef03b9b89f99517643226d76e286ee999e7700000000000000000000000000000000000000000000000000000001b69e2595003472a5a71965499acd81997a54bba8d852c6e53d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f000000000000000000000000000000000000000000000068bce40cf18444c28000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001244a25d94a000000000000000000000000000000000000000000000002b01ee2a20a8a2a90000000000000000000000000000000000000000000000068bce40cf18444c28000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000b65cef03b9b89f99517643226d76e286ee999e7700000000000000000000000000000000000000000000000000000000604be4d100000000000000000000000000000000000000000000000000000000000000030000000000000000000000003472a5a71965499acd81997a54bba8d852c6e53d0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2003472a5a71965499acd81997a54bba8d852c6e53d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b300000000000000000000000019d97d8fa813ee2f51ad4b4e04ea08baf4dffc28000000000000000000000000000000000000000000000113a03d2f890b2c6cc00019d97d8fa813ee2f51ad4b4e04ea08baf4dffc2800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024b6b55f25000000000000000000000000000000000000000000000113a03d2f890b2c6cc000798d1be841a82a273720ce31c822c61a67a601c300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000007e7e112a68d8d2e221e11047a72ffc1065c38e1a00000000000000000000000000000000000000000000000000000001b69e2595007e7e112a68d8d2e221e11047a72ffc1065c38e1a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000246c361865000000000000000000000000b65cef03b9b89f99517643226d76e286ee999e77007e7e112a68d8d2e221e11047a72ffc1065c38e1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024b6b55f2500000000000000000000000000000000000000000000000000000001b69e25950019d97d8fa813ee2f51ad4b4e04ea08baf4dffc2800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f0000000000000000000000000000000000000000000000e203f5dc3c00323a8000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f00000000000000000000000000000000000000000000000777723ca5ab7fcb9000000000000000000000000000000000000000000000000000000000000000c4f305d71900000000000000000000000019d97d8fa813ee2f51ad4b4e04ea08baf4dffc280000000000000000000000000000000000000000000000e203f5dc3c00323a800000000000000000000000000000000000000000000000e203f5dc3c00323a8000000000000000000000000000000000000000000000000777723ca5ab7fcb90000000000000000000000000b65cef03b9b89f99517643226d76e286ee999e7700000000000000000000000000000000000000000000000000000000604be4db007e7e112a68d8d2e221e11047a72ffc1065c38e1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f00000000000000000000000000000000000000000000000048ada1feff60844a00d9e1ce17f2641f24ae83637ab66a2cca9c378b9f00000000000000000000000000000000000000000000000777723ca5ab7fcb9000000000000000000000000000000000000000000000000000000000000000c4f305d7190000000000000000000000007e7e112a68d8d2e221e11047a72ffc1065c38e1a00000000000000000000000000000000000000000000000048ada1feff60844a00000000000000000000000000000000000000000000000048ada1feff60844a00000000000000000000000000000000000000000000000777723ca5ab7fcb90000000000000000000000000b65cef03b9b89f99517643226d76e286ee999e7700000000000000000000000000000000000000000000000000000000604be4dd0000", } sushiBbadgerPair = "0x0a54d4b378c8dbfc7bc93be50c85debafdb87439" sushiBDiggPair = "0xf9440fedc72a0b8030861dcdac39a75b544e7a3c" sushiswap = SushiswapSystem() pair = interface.IUniswapV2Pair(sushiBbadgerPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) pair = interface.IUniswapV2Pair(sushiBDiggPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) usd_amount = 500000 weth = interface.IERC20(registry.tokens.weth) console.log("..Before Safe") safe = ApeSafe(badger.devMultisig.address) ops_safe = ApeSafe(badger.opsMultisig.address) console.log("..After Safe Setup") # multi = GnosisSafe(badger.devMultisig) # multi.execute( # MultisigTxMetadata(description="Run TX"), # {"to": tx_data["to"], "data": tx_data["data"], "operation": 1}, # ) after = get_token_balances( [ badger.token, digg.token, interface.IERC20(registry.tokens.usdc), interface.IERC20(sushiBbadgerPair), interface.IERC20(sushiBDiggPair), ], [badger.devMultisig], ) after.print() pair = interface.IUniswapV2Pair(sushiBbadgerPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) pair = interface.IUniswapV2Pair(sushiBDiggPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) router = safe.contract(sushiswap.router.address) rewardsEscrow = safe.contract(badger.rewardsEscrow.address) badgerToken = safe.contract(badger.token.address) diggToken = safe.contract(digg.token.address) digg_to_lp = Wei("8.4 gwei") usd_per_side = 250000 # TODO: Use banteg's nice value calc script. badger_usd = fetch_usd_price(badger.token.address) digg_usd = fetch_usd_price(digg.token.address) eth_usd = fetch_usd_price_eth() console.log(eth_usd) badger_to_swap = Wei(str(95000 / badger_usd) + " ether") badger_to_lp = Wei(str(usd_per_side / badger_usd) + " ether") digg_to_lp = Wei(str(usd_per_side / digg_usd) + " gwei") eth_out = Wei(str(usd_per_side / eth_usd) + " ether") console.print({ "badger_to_swap": badger_to_swap, "badger_to_lp": badger_to_lp, "digg_to_lp": digg_to_lp, "eth_out": eth_out, "badger_usd": badger_usd, "digg_usd": digg_usd, "eth_usd": eth_usd, }) badger_to_get_from_escrow = badger_to_swap + badger_to_lp # Get 250k worth of bBadger + $90k Amount to swap to ETH rewardsEscrow.transfer(badger.token, badger.devMultisig, badger_to_get_from_escrow) # Get 250k worth of bDigg rewardsEscrow.transfer(digg.token, badger.devMultisig, digg_to_lp) # Sell badger for 90k USD exact_eth = Wei(str(90000 / eth_usd) + " ether") console.print("exact_eth", exact_eth) assert badger.token.balanceOf(badger.devMultisig) >= badger_to_swap print("a") badgerToken.approve(sushiswap.router.address, badger_to_swap) print("b") assert (badger.token.allowance(badger.devMultisig, sushiswap.router.address) == badger_to_swap) router.swapTokensForExactETH( exact_eth, int(badger_to_swap * 1.02), [badger.token, registry.tokens.wbtc, registry.tokens.weth], badger.devMultisig, chain.time() + 200000, ) print("d") after = get_token_balances([badger.token, digg.token], [badger.devMultisig]) after.print() # Deposit Badger for bBadger # Deposit DIGG for bDigg bBadger_address = badger.getSett("native.badger").address bDigg_address = badger.getSett("native.digg").address console.print(bBadger_address, bDigg_address) abi = Sett.abi bBadger = safe.contract_from_abi(bBadger_address, "Sett", abi) bDigg = safe.contract_from_abi(bDigg_address, "Sett", abi) badgerToken.approve(bBadger.address, badger_to_lp) print(bBadger) console.print(bBadger) bBadger.deposit(badger_to_lp) diggToken.approve(bDigg.address, digg_to_lp) bDigg.approveContractAccess(badger.devMultisig) tx = bDigg.deposit(digg_to_lp) console.print(tx.events) # tx = bDigg.withdraw(bDigg.balanceOf(badger.devMultisig)) # console.print(tx.events) after = get_token_balances( [ badger.token, digg.token, interface.IERC20(bDigg.address), interface.IERC20(bBadger.address), ], [badger.devMultisig], ) after.print() # Seed pools: 250k worth of bToken, 250k worth of ETH tokenA = bBadger amountA = (badger_to_lp * 10**18) / bBadger.getPricePerFullShare() amountB = eth_out # TODO: Set the amount of ETH to what is required. after = get_token_balances( [ badger.token, digg.token, interface.IERC20(bDigg.address), interface.IERC20(bBadger.address), interface.IERC20(sushiBbadgerPair), interface.IERC20(sushiBDiggPair), ], [badger.devMultisig], ) after.print() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx) """ How do we get exactly 250k worth of each asset? Calculate how much you need to get 250k ===== Normal Assets ===== 250k / USD price of asset ===== For bTokens ===== How much original token to get: 250k / USD price of underlying asset bToken will handle itself """ tokenA.approve(sushiswap.router, amountA) console.print( "addLiquidityETH", { "tokenA": tokenA.address, "amountA": amountA, "amountB": amountB, "badger ppfs": bBadger.getPricePerFullShare(), "original supply": Wei("4000 gwei"), "current supply": digg.token.totalSupply(), }, ) router.addLiquidityETH( tokenA.address, amountA, int(amountA * 0.95), int(eth_out * 0.95), badger.devMultisig, chain.time() + 200000, {"value": eth_out}, ) tokenA = bDigg amountA = ((digg_to_lp * 10**9) * 10**18) / bDigg.getPricePerFullShare() amountA = amountA * (Wei("4000 gwei")) / digg.token.totalSupply() print("expected bDigg", amountA) amountA = bDigg.balanceOf(badger.devMultisig) print("actual bDigg", amountA) tokenA.approve(sushiswap.router, amountA) console.print( "addLiquidityETH", { "tokenA": tokenA.address, "amountA": amountA, "amountB": amountB, "digg ppfs": bDigg.getPricePerFullShare(), }, ) router.addLiquidityETH( tokenA.address, amountA, int(amountA * 0.95), int(eth_out * 0.95), badger.devMultisig, chain.time() + 200000, {"value": eth_out}, ) after = get_token_balances( [ badger.token, digg.token, interface.IERC20(bDigg.address), interface.IERC20(bBadger.address), interface.IERC20(sushiBbadgerPair), interface.IERC20(sushiBDiggPair), ], [badger.devMultisig], ) after.print() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx) pair = interface.IUniswapV2Pair(sushiBbadgerPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) pair = interface.IUniswapV2Pair(sushiBDiggPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) safe.post_transaction(safe_tx) pair = interface.IUniswapV2Pair(sushiBbadgerPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), }) pair = interface.IUniswapV2Pair(sushiBDiggPair) console.print({ "getReserves": pair.getReserves(), "token0": pair.token0(), "token1": pair.token1(), "price0CumulativeLast": pair.price0CumulativeLast(), "price1CumulativeLast": pair.price1CumulativeLast(), })
def main(): badger = connect_badger("deploy-final.json") digg = badger.digg admin = badger.devProxyAdmin multisig = badger.devMultisig contracts = badger.contracts_upgradeable deployer = badger.deployer expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77" assert multisig == expectedMultisig safe = ApeSafe(badger.devMultisig.address) abi = Sett.abi badgerToken = safe.contract(badger.token.address) diggToken = safe.contract(digg.token.address) bBadger = safe.contract_from_abi( badger.getSett("native.badger").address, "Sett", abi) bDigg = safe.contract_from_abi( badger.getSett("native.digg").address, "Sett", abi) rewardsEscrow = safe.contract(badger.rewardsEscrow.address) badger_usd = fetch_usd_price(badger.token.address) eth_usd = fetch_usd_price_eth() # USD Denominated # badger_to_send = Wei(str(total_usd / badger_usd) + " ether") # Badger denominated badger_to_send = Wei("5970.744318 ether") table = [] table.append(["badger", badger_to_send, badger_usd]) table.append(["eth", 0, eth_usd]) print(tabulate(table, headers=["asset", "to send", "$ price"])) snap = BalanceSnapshotter( [badgerToken, bBadger], [badger.devMultisig, badger.deployer, badger.rewardsEscrow]) snap.snap(name="Before Transfers") # Transfer assets to multisig rewardsEscrow.transfer(badgerToken, badger.devMultisig, badger_to_send) snap.snap(name="After Transfers") snap.diff_last_two() # Deposit bBadger badgerToken.approve(bBadger.address, badger_to_send) bBadgerBefore = bBadger.balanceOf(badger.devMultisig) tx = bBadger.deposit(badger_to_send) bBadgerAfter = bBadger.balanceOf(badger.devMultisig) print("bBadger to transfer", bBadgerAfter - bBadgerBefore, val(bBadgerAfter - bBadgerBefore)) # bBadger.transfer(badger.treasuryMultisig, bBadgerAfter - bBadgerBefore) print(tx.events) snap.snap(name="After Deposits") snap.diff_last_two() safe_tx = safe.multisend_from_receipts() safe.preview(safe_tx) data = safe.print_transaction(safe_tx) safe.post_transaction(safe_tx)