Skip to content

added draft proposal and deployemnt script #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions scripts/dao-proposals/OOIP-20-crvusd/proposal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from brownie import *

exec(open("./scripts/env/set-eth.py").read())

description = "OOIP-20-crvusd"

targets = []
values = []
calldatas = []


exec(open("./scripts/env/set-eth.py").read())
MINIMAL_RATES = {
"icrvUSD": 0.1e18
}

loanTokenLogicStandard = Contract.from_abi("loanTokenLogicStandard", address="0x624f7f89414011b276c60ea2337bfba936d1cbbe", abi=LoanTokenLogicStandard.abi)
loanTokenAddress = "0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0"
priceFeedAddress = "0x986b5E1e1755e3C2440e960477f25201B0a8bbD4" #Chainlink USDC pricefeed

calldatas.append(PRICE_FEED.setPriceFeed.encode_input([loanTokenAddress], [priceFeedAddress]))
targets.append(PRICE_FEED.address)

calldatas.append(PRICE_FEED.setDecimals.encode_input([loanTokenAddress]))
targets.append(PRICE_FEED.address)
deployer = accounts[0]
iProxy = LoanToken.deploy(deployer, loanTokenLogicStandard, {"from": deployer})
iToken = Contract.from_abi("iToken", iProxy, LoanTokenLogicStandard.abi)
underlyingSymbol = "crvUSD"
iTokenSymbol = "i{}".format(underlyingSymbol)
iTokenName = "Ooki {} iToken ({})".format(underlyingSymbol, iTokenSymbol)
iToken.initialize(loanTokenAddress, iTokenName, iTokenSymbol, {'from': deployer})
iToken.initializeDomainSeparator({"from": deployer})
iToken.setDemandCurve(CUI,{"from": deployer})

iProxy.transferOwnership(TIMELOCK, {'from': deployer})

calldatas.append(iToken.setDemandCurve.encode_input(CUI))
targets.append(iToken.address)

calldatas.append(BZX.setApprovals.encode_input([loanTokenAddress], [1,2]))
targets.append(BZX.address)

calldatas.append(BZX.setupLoanPoolTWAI.encode_input(iToken))
targets.append(BZX.address)

calldatas.append(BZX.setLoanPool.encode_input([iToken], [loanTokenAddress]))
targets.append(BZX.address)

calldatas.append(BZX.setSupportedTokens.encode_input([loanTokenAddress, iToken], [True, True], True))
targets.append(BZX.address)

values = [0] * len(targets) # empty array
signatures = [""] * len(targets) # empty signatures array

# Make proposal
call = DAO.propose(targets, values, signatures, calldatas, description, {'from': TEAM_VOTING_MULTISIG, "required_confs": 1})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to include flash loan fix

print("call", call)
34 changes: 34 additions & 0 deletions scripts/deployment/mainnet/deploy_icrvusd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

exec(open("./scripts/env/set-eth.py").read())
MINIMAL_RATES = {
"icrvUSD": 0.1e18
}

loanTokenLogicStandard = Contract.from_abi("loanTokenLogicStandard", address="0x624f7f89414011b276c60ea2337bfba936d1cbbe", abi=LoanTokenLogicStandard.abi)
loanTokenAddress = "0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0"

priceFeedAddress = "0x986b5E1e1755e3C2440e960477f25201B0a8bbD4"
PRICE_FEED.setPriceFeed([loanTokenAddress], [priceFeedAddress], {"from": TIMELOCK})
PRICE_FEED.setDecimals([loanTokenAddress], {"from": TIMELOCK})

iProxy = LoanToken.deploy(deployer, loanTokenLogicStandard, {"from": deployer})
#iProxy = Contract.from_abi("iToken", address="0x08bd8Dc0721eF4898537a5FBE1981333D430F50f", abi=LoanToken.abi)
iToken = Contract.from_abi("iToken", iProxy, LoanTokenLogicStandard.abi)
underlyingSymbol = "crvUSD"
iTokenSymbol = "i{}".format(underlyingSymbol)
iTokenName = "Ooki {} iToken ({})".format(underlyingSymbol, iTokenSymbol)
iToken.initialize(loanTokenAddress, iTokenName, iTokenSymbol, {'from': deployer})
iToken.initializeDomainSeparator({"from": deployer})
iProxy.transferOwnership(TIMELOCK, {'from': deployer})

iToken.setDemandCurve(CUI,{"from": deployer})

BZX.setApprovals([loanTokenAddress], [1,2], {'from': TIMELOCK})
BZX.setupLoanPoolTWAI(iProxy, {"from": TIMELOCK})

BZX.setLoanPool([iToken], [loanTokenAddress], {"from": TIMELOCK})
BZX.setSupportedTokens([loanTokenAddress, iToken], [True, True], True, {"from": TIMELOCK})


exec(open("./scripts/env/set-eth.py").read())
crvUSD = TestToken.at(loanTokenAddress)
162 changes: 162 additions & 0 deletions testsmainnet/dao-proposals/ooip-20/test_ooip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/usr/bin/python3

import pytest
from brownie import *
import pdb


@pytest.fixture(scope="module")
def requireMainnetFork():
assert (network.show_active() ==
"mainnet-fork" or network.show_active() == "mainnet-fork-alchemy")


@pytest.fixture(scope="module")
def DAO(GovernorBravoDelegate):
return Contract.from_abi("governorBravoDelegator", address="0x3133b4f4dcffc083724435784fefad510fa659c6", abi=GovernorBravoDelegate.abi)


@pytest.fixture(scope="module")
def TIMELOCK(Timelock, accounts):
return Contract.from_abi("TIMELOCK", address="0xfedC4dD5247B93feb41e899A09C44cFaBec29Cbc", abi=Timelock.abi)


@pytest.fixture(scope="module")
def OOKI(accounts, TestToken):
return Contract.from_abi("OOKI", address="0x0De05F6447ab4D22c8827449EE4bA2D5C288379B", abi=TestToken.abi)


@pytest.fixture(scope="module")
def iUSDT(accounts, LoanTokenLogicStandard):
return Contract.from_abi("iUSDT", address="0x7e9997a38A439b2be7ed9c9C4628391d3e055D48", abi=LoanTokenLogicStandard.abi)

@pytest.fixture(scope="module")
def iUSDC(accounts, LoanTokenLogicStandard):
return Contract.from_abi("iUSDC", address="0x32E4c68B3A4a813b710595AebA7f6B7604Ab9c15", abi=LoanTokenLogicStandard.abi)

@pytest.fixture(scope="module")
def iWBTC(accounts, LoanTokenLogicStandard):
return Contract.from_abi("iWBTC", address="0x2ffa85f655752fB2aCB210287c60b9ef335f5b6E", abi=LoanTokenLogicStandard.abi)

@pytest.fixture(scope="module")
def iWETH(accounts, LoanTokenLogicStandard):
return Contract.from_abi("iWETH", address="0xB983E01458529665007fF7E0CDdeCDB74B967Eb6", abi=LoanTokenLogicStandard.abi)

@pytest.fixture(scope="module")
def LINK(accounts, TestToken):
return Contract.from_abi("iUSDC", address="0x514910771AF9Ca656af840dff83E8264EcF986CA", abi=TestToken.abi)

@pytest.fixture(scope="module")
def BZX(interface):
return Contract.from_abi("bzx", address="0xD8Ee69652E4e4838f2531732a46d1f7F584F0b7f", abi=interface.IBZx.abi)

@pytest.fixture(scope="module")
def USDT(TestToken):
return Contract.from_abi("USDT", address="0xdAC17F958D2ee523a2206206994597C13D831ec7", abi=TestToken.abi)

@pytest.fixture(scope="module")
def USDC(TestToken):
return Contract.from_abi("USDC", address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", abi=TestToken.abi)

@pytest.fixture(scope="module")
def CRVUSD(TestToken):
return Contract.from_abi("CRVUSD", address="0xf71040d20Cc3FFBb28c1abcEF46134C7936624e0", abi=TestToken.abi)


@pytest.fixture(scope="module")
def WBTC(TestToken):
return Contract.from_abi("WBTC", address="0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", abi=TestToken.abi)

@pytest.fixture(scope="module")
def WETH(TestToken):
return Contract.from_abi("WETH", address="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", abi=TestToken.abi)

@pytest.fixture(scope="module")
def GUARDIAN_MULTISIG():
return "0x9B43a385E08EE3e4b402D4312dABD11296d09E93"

@pytest.fixture(scope="module")
def INFRASTRUCTURE_MULTISIG():
return "0x2a599cEba64CAb8C88549c2c7314ea02A161fC70"

def testGovernanceProposal(requireMainnetFork, accounts, DAO, TIMELOCK, iUSDC, OOKI, interface, INFRASTRUCTURE_MULTISIG, USDC, USDT, BZX, iUSDT, TokenRegistry):
proposerAddress = "0x02c6819c2cb8519ab72fd1204a8a0992b5050c6e"
voter1 = "0x9B43a385E08EE3e4b402D4312dABD11296d09E93"
voter2 = "0xE9d5472Cc0107938bBcaa630c2e4797F75A2D382"


exec(open("./scripts/dao-proposals/OOIP-20-crvusd/proposal.py").read())

proposalCount = DAO.proposalCount()
proposal = DAO.proposals(proposalCount)
id = proposal[0]
startBlock = proposal[3]
endBlock = proposal[4]
forVotes = proposal[5]
againstVotes = proposal[6]

assert DAO.state.call(id) == 0
chain.mine(startBlock - chain.height + 1)
assert DAO.state.call(id) == 1

tx = DAO.castVote(id, 1, {"from": proposerAddress})
tx = DAO.castVote(id, 1, {"from": voter1})
tx = DAO.castVote(id, 1, {"from": voter2})


assert DAO.state.call(id) == 1

chain.mine(endBlock - chain.height)
assert DAO.state.call(id) == 1
chain.mine()
assert DAO.state.call(id) == 4

DAO.queue(id, {"from": proposerAddress})

proposal = DAO.proposals(proposalCount)
eta = proposal[2]
chain.sleep(eta - chain.time())
chain.mine()


DAO.execute(id, {"from": proposerAddress})
exec(open("./scripts/env/set-eth.py").read())
acc = accounts[0]
crvUSD.approve(icrvUSD, 2**256-1, {'from': acc})
crvUSD.mint(acc, 20000e18, {'from': "0xFF051db87ADFb0bE398016EE5C68280ad49F1Fd8"})
icrvUSD.mint(acc, 1000e18, {'from': acc})
assert history[-1].status.name == 'Confirmed'

USDC.transfer(acc, 10000e6, {'from': '0x915dA56c5995EAaf66fd06BA3AeD62a4D3BD011A'})
USDC.approve(icrvUSD, 2**256-1, {'from': acc})
icrvUSD.borrow("", 50e18, 0, 110e6, USDC, acc, acc, b"", {'from': acc})
assert history[-1].status.name == 'Confirmed'

crvUSD.approve(SUSHI_ROUTER, 2**256-1, {'from': acc})
SUSHI_ROUTER.addLiquidityETH(crvUSD, 1000e18, 1000e18, 0.6e18, acc, chain.time()+10000, {'from': acc, 'value': 0.6e18})
icrvUSD.marginTrade(0x0000000000000000000000000000000000000000000000000000000000000000, 2000000000000000000, 0, 10000000000000000, '0x0000000000000000000000000000000000000000', acc, b'', {'from': acc, 'value': 10000000000000000})
assert history[-1].status.name == 'Confirmed'

USDC.approve(SUSHI_ROUTER, 2**256-1, {'from': acc})
SUSHI_ROUTER.addLiquidity(crvUSD, USDC, 1000e18, 1000e6, 1000e18, 1000e6, acc, chain.time() + 1000, {'from': acc})
icrvUSD.marginTrade(0x0000000000000000000000000000000000000000000000000000000000000000, 2000000000000000000, 0, 10e6, USDC, acc, b'', {'from': acc})
assert history[-1].status.name == 'Confirmed'

crvUSD.approve(iUSDC, 2**256-1, {'from': acc})
icrvUSD.approve(iUSDC, 2**256-1, {'from': acc})
iUSDC.borrow("", 50e6, 0, 100e18, crvUSD, acc, acc, b"", {'from': acc})
assert history[-1].status.name == 'Confirmed'
iUSDC.borrow("", 50e6, 0, 100e18, icrvUSD, acc, acc, b"", {'from': acc})
assert history[-1].status.name == 'Confirmed'
iUSDC.marginTrade(0x0000000000000000000000000000000000000000000000000000000000000000, 2000000000000000000, 0, 10000000000000000, '0x0000000000000000000000000000000000000000', acc, b'', {'from': acc, 'value': 10000000000000000})
assert history[-1].status.name == 'Confirmed'
iUSDC.marginTrade(0x0000000000000000000000000000000000000000000000000000000000000000, 2000000000000000000, 0, 10e18, crvUSD, acc, b'', {'from': acc})
assert history[-1].status.name == 'Confirmed'

iUSDC.marginTrade(0x0000000000000000000000000000000000000000000000000000000000000000, 2000000000000000000, 0, 10e18, icrvUSD, acc, b'', {'from': acc})
assert history[-1].status.name == 'Confirmed'

assert False