def main(): deployer = accounts.at('0xB593d82d53e2c187dc49673709a6E9f806cdC835', force=True) # deployer = accounts.load('gh') # deploy safeboxes safebox_eth = SafeBoxETH.deploy( '0x41c84c0e2EE0b740Cf0d31F63f3B6F627DC6b393', 'Interest Bearing Ether v2', 'ibETHv2', {'from': deployer}) safebox_dai = SafeBox.deploy('0x8e595470Ed749b85C6F7669de83EAe304C2ec68F', 'Interest Bearing Dai Stablecoin v2', 'ibDAIv2', {'from': deployer}) safebox_usdt = SafeBox.deploy('0x48759F220ED983dB51fA7A8C0D2AAb8f3ce4166a', 'Interest Bearing Tether USD v2', 'ibUSDTv2', {'from': deployer}) safebox_usdc = SafeBox.deploy('0x76Eb2FE28b36B3ee97F3Adae0C69606eeDB2A37c', 'Interest Bearing USD Coin v2', 'ibUSDCv2', {'from': deployer}) safebox_yfi = SafeBox.deploy('0xFa3472f7319477c9bFEcdD66E4B948569E7621b9', 'Interest Bearing yearn.finance v2', 'ibYFIv2', {'from': deployer}) # add banks usdt = interface.IERC20Ex('0xdAC17F958D2ee523a2206206994597C13D831ec7') usdc = interface.IERC20Ex('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') yfi = interface.IERC20Ex('0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e') cyusdt = '0x48759F220ED983dB51fA7A8C0D2AAb8f3ce4166a' cyusdc = '0x76Eb2FE28b36B3ee97F3Adae0C69606eeDB2A37c' cyyfi = '0xFa3472f7319477c9bFEcdD66E4B948569E7621b9' bank = HomoraBank.at('0x5f5Cd91070960D13ee549C9CC47e7a4Cd00457bb') bank.addBank(usdt, cyusdt, {'from': deployer}) bank.addBank(usdc, cyusdc, {'from': deployer})
def main(): safebox_eth = SafeBoxETH.at('0xeEa3311250FE4c3268F8E684f7C87A82fF183Ec1') safebox_usdt = SafeBox.at('0x020eDC614187F9937A1EfEeE007656C6356Fb13A') safebox_usdc = SafeBox.at('0x08bd64BFC832F1C2B3e07e634934453bA7Fa2db2') safebox_dai = SafeBox.at('0xee8389d235E092b2945fE363e97CDBeD121A0439') cy_eth = interface.IAny(safebox_eth.cToken()) cy_usdt = interface.IAny(safebox_usdt.cToken()) cy_usdc = interface.IAny(safebox_usdc.cToken()) cy_dai = interface.IAny(safebox_dai.cToken()) print('eth', safebox_eth.totalSupply() * cy_eth.exchangeRateStored() / 1e36) print('usdt', safebox_usdt.totalSupply() * cy_usdt.exchangeRateStored() / 1e24) print('usdc', safebox_usdc.totalSupply() * cy_usdc.exchangeRateStored() / 1e24) print('dai', safebox_dai.totalSupply() * cy_dai.exchangeRateStored() / 1e36)
def main(): deployer = accounts.at('0xB593d82d53e2c187dc49673709a6E9f806cdC835', force=True) # deployer = accounts.load('gh') # deploy safeboxes safebox_eth = SafeBoxETH.deploy( '0x41c84c0e2EE0b740Cf0d31F63f3B6F627DC6b393', 'Interest Bearing Ether v2', 'ibETHv2', {'from': deployer}) safebox_dai = SafeBox.deploy('0x8e595470Ed749b85C6F7669de83EAe304C2ec68F', 'Interest Bearing Dai Stablecoin v2', 'ibDAIv2', {'from': deployer}) safebox_usdt = SafeBox.deploy('0x48759F220ED983dB51fA7A8C0D2AAb8f3ce4166a', 'Interest Bearing Tether USD v2', 'ibUSDTv2', {'from': deployer}) safebox_usdc = SafeBox.deploy('0x76Eb2FE28b36B3ee97F3Adae0C69606eeDB2A37c', 'Interest Bearing USD Coin v2', 'ibUSDCv2', {'from': deployer}) safebox_yfi = SafeBox.deploy('0xFa3472f7319477c9bFEcdD66E4B948569E7621b9', 'Interest Bearing yearn.finance v2', 'ibYFIv2', {'from': deployer})
def main(): deployer = accounts.at('0xB593d82d53e2c187dc49673709a6E9f806cdC835', force=True) # deployer = accounts.load('gh') snx = interface.IERC20Ex('0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F') susd = interface.IERC20Ex('0x57Ab1ec28D129707052df4dF418D58a2D46d5f51') cysnx = interface.IERC20Ex('0x12A9cC33A980DAa74E00cc2d1A0E74C57A93d12C') cysusd = interface.IERC20Ex('0x4e3a36A633f63aee0aB57b5054EC78867CB3C0b8') # add safeboxes safebox_snx = SafeBox.deploy( cysnx, 'Interest Bearing Synthetix Network Token v2', 'ibSNXv2', {'from': deployer}) safebox_susd = SafeBox.deploy(cysusd, 'Interest Bearing Synth sUSD v2', 'ibsUSDv2', {'from': deployer}) # add banks bank = HomoraBank.at('0x5f5Cd91070960D13ee549C9CC47e7a4Cd00457bb') bank.addBank(snx, cysnx, {'from': deployer}) bank.addBank(susd, cysusd, {'from': deployer})
def get_safebox(token): if token == Tokens.weth: return SafeBoxETH.at('0xeEa3311250FE4c3268F8E684f7C87A82fF183Ec1') elif token == Tokens.dai: return SafeBox.at('0xee8389d235E092b2945fE363e97CDBeD121A0439') elif token == Tokens.usdt: return SafeBox.at('0x020eDC614187F9937A1EfEeE007656C6356Fb13A') elif token == Tokens.usdc: return SafeBox.at('0x08bd64BFC832F1C2B3e07e634934453bA7Fa2db2') elif token == Tokens.yfi: return SafeBox.at('0x3614644AE157280b5C1d17AE686C153a204aaf3b') elif token == Tokens.dpi: return SafeBox.at('0x9E6aCA6B13a0Bc3364D035fF6D97ff4dB319F88A') elif token == Tokens.snx: return SafeBox.at('0x9446614037a839730A92E28a7ec870344B7B8F09') elif token == Tokens.susd: return SafeBox.at('0x3E1F2Feb27738609a22aa8B192a1a9138c445aa0') else: raise Exception(f'safebox not supported for token {token}')
def main(): admin = accounts[0] alice = accounts[1] bob = accounts[2] dai = interface.IERC20Ex('0x6B175474E89094C44Da98b954EedeAC495271d0F') cydai = interface.IERC20Ex('0x8e595470ed749b85c6f7669de83eae304c2ec68f') homora = HomoraBank.deploy({'from': admin}) safebox = SafeBox.deploy(cydai, 'Yearn Wrapped DAI', 'cyDAI', {'from': admin}) # set up funds to alice mint_tokens(dai, alice) mint_tokens(dai, bob) # approve dai dai.approve(safebox, 2**256 - 1, {'from': alice}) dai.approve(safebox, 2**256 - 1, {'from': bob}) ################################################################# # deposit print('====================================') print('Case 1. deposit') prevDAIAlice = dai.balanceOf(alice) prevDAIBob = dai.balanceOf(bob) prevIBDAIAlice = safebox.balanceOf(alice) prevIBDAIBob = safebox.balanceOf(bob) alice_amt = 10**18 bob_amt = 10**18 safebox.deposit(alice_amt, {'from': alice}) chain.mine(20) safebox.deposit(bob_amt, {'from': bob}) curDAIAlice = dai.balanceOf(alice) curDAIBob = dai.balanceOf(bob) curIBDAIAlice = safebox.balanceOf(alice) curIBDAIBob = safebox.balanceOf(bob) print('∆ dai alice', curDAIAlice - prevDAIAlice) print('∆ dai bob', curDAIBob - prevDAIBob) print('∆ ibDAI bal alice', curIBDAIAlice - prevIBDAIAlice) print('∆ ibDAI bal bob', curIBDAIBob - prevIBDAIBob) print('calculated ibDAI alice', alice_amt * 10**18 // cydai.exchangeRateStored()) print('calculated ibDAI bob', bob_amt * 10**18 // cydai.exchangeRateStored()) assert curDAIAlice - prevDAIAlice == -alice_amt, 'incorrect alice amount' assert curDAIBob - prevDAIBob == -bob_amt, 'incorrect bob amount' assert almostEqual(curIBDAIAlice - prevIBDAIAlice, alice_amt * 10**18 // cydai.exchangeRateStored()) assert almostEqual(curIBDAIBob - prevIBDAIBob, bob_amt * 10**18 // cydai.exchangeRateStored()) chain.mine(200) ################################################################# # alice withdraws 1/3 & 2/3. bob withdraws all. print('====================================') print('Case 2. withdraw') alice_withdraw_1 = safebox.balanceOf(alice) // 3 alice_withdraw_2 = safebox.balanceOf(alice) - alice_withdraw_1 bob_withdraw = safebox.balanceOf(bob) prevDAIAlice = dai.balanceOf(alice) prevDAIBob = dai.balanceOf(bob) prevIBDAIAlice = safebox.balanceOf(alice) prevIBDAIBob = safebox.balanceOf(bob) safebox.withdraw(alice_withdraw_1, {'from': alice}) chain.mine(20) safebox.withdraw(bob_withdraw, {'from': bob}) curDAIAlice = dai.balanceOf(alice) curDAIBob = dai.balanceOf(bob) curIBDAIAlice = safebox.balanceOf(alice) curIBDAIBob = safebox.balanceOf(bob) print('∆ dai alice', curDAIAlice - prevDAIAlice) print('∆ dai bob', curDAIBob - prevDAIBob) print('∆ ibDAI bal alice', curIBDAIAlice - prevIBDAIAlice) print('∆ ibDAI bal bob', curIBDAIBob - prevIBDAIBob) assert almostEqual(curDAIAlice - prevDAIAlice, alice_amt // 3), 'incorrect alice withdraw dai amount' assert almostEqual(curDAIBob - prevDAIBob, bob_amt), 'incorrect bob withdraw dai amount' assert curIBDAIAlice - prevIBDAIAlice == -alice_withdraw_1, 'incorrect alice ∆ibDAI' assert curIBDAIBob - prevIBDAIBob == -bob_withdraw, 'incorrect bob ∆ibDAI' chain.mine(20) prevDAIAlice = dai.balanceOf(alice) prevIBDAIAlice = safebox.balanceOf(alice) safebox.withdraw(alice_withdraw_2, {'from': alice}) curDAIAlice = dai.balanceOf(alice) curIBDAIAlice = safebox.balanceOf(alice) print('∆ dai alice', curDAIAlice - prevDAIAlice) print('∆ dai bob', curDAIBob - prevDAIBob) print('∆ ibDAI bal alice', curIBDAIAlice - prevIBDAIAlice) print('∆ ibDAI bal bob', curIBDAIBob - prevIBDAIBob) assert almostEqual(curDAIAlice - prevDAIAlice, alice_amt * 2 // 3), 'incorrect alice second withdraw dai amount' assert curIBDAIAlice - prevIBDAIAlice == -alice_withdraw_2, 'incorrect alice second ∆ibDAI '
def main(): admin = accounts[0] alice = accounts[1] bob = accounts[2] usdt = interface.IERC20Ex('0xdac17f958d2ee523a2206206994597c13d831ec7') cyusdt = interface.IERC20Ex('0x48759f220ed983db51fa7a8c0d2aab8f3ce4166a') homora = HomoraBank.deploy({'from': admin}) safebox = SafeBox.deploy(cyusdt, 'ibUSDTv2', 'ibUSDTv2', {'from': admin}) # set up funds to alice mint_tokens(usdt, alice) mint_tokens(usdt, bob) # approve usdt usdt.approve(safebox, 2**256 - 1, {'from': alice}) usdt.approve(cyusdt, 2**256 - 1, {'from': bob}) ################################################################# # check decimals assert safebox.decimals() == cyusdt.decimals(), 'incorrect decimals' ################################################################# # deposit print('====================================') print('Case 1. deposit') prevUSDTAlice = usdt.balanceOf(alice) prevUSDTBob = usdt.balanceOf(bob) prevIBUSDTAlice = safebox.balanceOf(alice) prevcyUSDTBob = cyusdt.balanceOf(bob) alice_amt = 10**6 bob_amt = 10**6 safebox.deposit(alice_amt, {'from': alice}) chain.mine(20) cyusdt.mint(bob_amt, {'from': bob}) curUSDTAlice = usdt.balanceOf(alice) curUSDTBob = usdt.balanceOf(bob) curIBUSDTAlice = safebox.balanceOf(alice) curcyUSDTBob = cyusdt.balanceOf(bob) print('∆ usdt alice', curUSDTAlice - prevUSDTAlice) print('∆ usdt bob', curUSDTBob - prevUSDTBob) print('∆ ibUSDT bal alice', curIBUSDTAlice - prevIBUSDTAlice) print('∆ cyUSDT bal bob', curcyUSDTBob - prevcyUSDTBob) print('calculated ibUSDT alice', alice_amt * 10**18 // cyusdt.exchangeRateStored()) assert curUSDTAlice - prevUSDTAlice == -alice_amt, 'incorrect alice amount' assert curUSDTBob - prevUSDTBob == -bob_amt, 'incorrect bob amount' assert almostEqual(curIBUSDTAlice - prevIBUSDTAlice, curcyUSDTBob - prevcyUSDTBob) chain.mine(200) ################################################################# # alice withdraws 1/3 & 2/3. bob withdraws all. print('====================================') print('Case 2. withdraw') alice_withdraw_1 = safebox.balanceOf(alice) // 3 alice_withdraw_2 = safebox.balanceOf(alice) - alice_withdraw_1 bob_withdraw = cyusdt.balanceOf(bob) // 3 prevUSDTAlice = usdt.balanceOf(alice) prevUSDTBob = usdt.balanceOf(bob) prevIBUSDTAlice = safebox.balanceOf(alice) prevcyUSDTBob = cyusdt.balanceOf(bob) safebox.withdraw(alice_withdraw_1, {'from': alice}) chain.mine(20) cyusdt.redeem(bob_withdraw, {'from': bob}) curUSDTAlice = usdt.balanceOf(alice) curUSDTBob = usdt.balanceOf(bob) curIBUSDTAlice = safebox.balanceOf(alice) curcyUSDTBob = cyusdt.balanceOf(bob) print('∆ usdt alice', curUSDTAlice - prevUSDTAlice) print('∆ usdt bob', curUSDTBob - prevUSDTBob) print('∆ ibUSDT bal alice', curIBUSDTAlice - prevIBUSDTAlice) print('∆ cyUSDT bal bob', curcyUSDTBob - prevcyUSDTBob) assert almostEqual(curUSDTAlice - prevUSDTAlice, alice_amt // 3), 'incorrect alice withdraw usdt amount' assert almostEqual(curUSDTBob - prevUSDTBob, bob_amt // 3), 'incorrect bob withdraw usdt amount' assert almostEqual(curIBUSDTAlice - prevIBUSDTAlice, curcyUSDTBob - prevcyUSDTBob), 'incorrect withdraw amount' chain.mine(20) prevUSDTAlice = usdt.balanceOf(alice) prevIBUSDTAlice = safebox.balanceOf(alice) safebox.withdraw(alice_withdraw_2, {'from': alice}) curUSDTAlice = usdt.balanceOf(alice) curIBUSDTAlice = safebox.balanceOf(alice) print('∆ usdt alice', curUSDTAlice - prevUSDTAlice) print('∆ usdt bob', curUSDTBob - prevUSDTBob) print('∆ ibUSDT bal alice', curIBUSDTAlice - prevIBUSDTAlice) print('∆ ibUSDT bal bob', curcyUSDTBob - prevcyUSDTBob) assert almostEqual(curUSDTAlice - prevUSDTAlice, alice_amt * 2 // 3), 'incorrect alice second withdraw usdt amount'