Skip to content

Commit

Permalink
before vest import
Browse files Browse the repository at this point in the history
  • Loading branch information
parseb committed May 15, 2022
1 parent aa2bcd2 commit f67596e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 14 additions & 4 deletions contracts/CashCow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
ofPoolBalance = IERC20(pool).balanceOf(address(this));
} else {
pool = UniFactory.createPair(cow.owners[2], address(DAI));
maxApprove(address(V2Router), cow.owners[2]);
maxApprove(address(V2Router), cow.owners[2], pool);
}

cow.owners[3] = pool;
Expand Down Expand Up @@ -185,13 +185,14 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
return true;
}

function maxApprove(address _router, address _projectToken)
function maxApprove(address _router, address _projectToken, address _pool)
private
returns (bool)
{
return
DAI.approve(_router, MAXUINT) &&
IERC20(_projectToken).approve(_router, MAXUINT);
IERC20(_projectToken).approve(address(V2Router), MAXUINT) &&
IERC20(_pool).approve(address(V2Router), MAXUINT);

}

/// @notice Cancel public offering
Expand Down Expand Up @@ -237,6 +238,14 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
{
Cow memory cow = cashCowById[_dealId];

DAI.approve(address(V2Router), MAXUINT);
V2Router.removeLiquidity(cow.owners[2],
address(DAI), cow.amounts[2] / 2 , 1, 1, address(this), block.timestamp);
address[] memory path = new address[](2);
path[0] = address(DAI);
path[1] = cow.owners[2];

V2Router.swapExactTokensForTokens(DAI.balanceOf(address(this)), 1, path , address(this), block.timestamp + 1000);

}

Expand All @@ -246,6 +255,7 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
return cashCowById[_id];
}


/// Override

function tokenURI(uint256 _tokenId)
Expand Down
8 changes: 8 additions & 0 deletions tests/0_default_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_happy_cow(CCOW, DAI, VC):
chain.mine(1)

chain.snapshot()

CCOW.LiquidateDeal(1, {'from': accounts[4]})
assert interface.IERC20(pool).balanceOf(accounts[4].address ) >= ( deal[1][2] // 2)
assert interface.IERC20(pool).balanceOf(accounts[0].address) >= ( deal[1][2] // 2)
Expand All @@ -104,9 +105,16 @@ def test_happy_cow(CCOW, DAI, VC):

sfToken = interface.ISuperToken(pool)
assert sfToken.balanceOf(accounts[4].address) == 0

b1 = DAI.balanceOf(CCOW.address, {"from": accounts[4]})
b2 = VC.balanceOf(CCOW.address, {"from": accounts[4]})

CCOW.VestDeal(1, {'from': accounts[4]})
chain.sleep(3342 * 10)

b3 = DAI.balanceOf(CCOW.address, {"from": accounts[4]})
b4 = VC.balanceOf(CCOW.address, {"from": accounts[4]})




Expand Down

0 comments on commit f67596e

Please sign in to comment.