Skip to content

Commit

Permalink
downbad superfluid
Browse files Browse the repository at this point in the history
  • Loading branch information
parseb committed May 15, 2022
1 parent 37aa627 commit 86bd194
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
31 changes: 22 additions & 9 deletions contracts/CashCow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import "../interfaces/IUniswapV2Interfaces.sol";

import "parseb/[email protected]/contracts/interfaces/superfluid/ISuperfluid.sol";
import "parseb/[email protected]/contracts/interfaces/agreements/IConstantFlowAgreementV1.sol";
//import "parseb/[email protected]/contracts/interfaces/superfluid/ISuperToken.sol";

import "parseb/[email protected]/contracts/apps/CFAv1Library.sol";
import "parseb/[email protected]/contracts/interfaces/superfluid/ISuperTokenFactory.sol";


// import "parseb/[email protected]/contracts/interfaces/superfluid/ISuperToken.sol";


contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
Expand All @@ -33,6 +32,7 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
using CFAv1Library for CFAv1Library.InitData;
CFAv1Library.InitData public cfaV1;
address SFtokenFactory;
ISuperfluid host;


//// Errors
Expand Down Expand Up @@ -61,7 +61,8 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
DAI.approve(_v2Router, MAXUINT);
sweeper = _sweepTo;
tempId = 1;
ISuperfluid host = ISuperfluid(_superfluidHost);

host = ISuperfluid(_superfluidHost);
SFtokenFactory = _superfluidTokenFactory;

cfaV1 = CFAv1Library.InitData(
Expand Down Expand Up @@ -261,20 +262,32 @@ contract CashCow is ERC721("Cash Cow Quest", "COWQ") {
timeElapsed(_dealId)
returns (bool s)
{
Cow memory cow = cashCowById[_dealId];


// ISuperToken token = ISuperTokenFactory(SFtokenFactory).createERC20Wrapper(
// ISuperTokenFactory TF = ISuperTokenFactory(SFtokenFactory);

ISuperTokenFactory factory = host.getSuperTokenFactory();

factory.createERC20Wrapper(
IERC20(cashCowById[_dealId].owners[3]),
18,
1,
"FluidCow",
"aCow"
);
// ISuperToken t= ISuperTokenFactory(SFtokenFactory).createERC20Wrapper(
// IERC20(cashCowById[_dealId].owners[3]),
// 18,
// 1,
// "FluidCow",
// "aCow"
// );

ISuperToken t = ISuperToken(cashCowById[_dealId].owners[3]);

// ISuperToken t = ISuperToken(cow.owners[3]);
//int96 tokensPerSecond = cow.amounts[2] / (cow.vestStartEnd[1] - cow.vestStartEnd[0]);
// // with optional user data
cfaV1.createFlow(msg.sender, t, 33342, bytes("cow"));

// createFlow(msg.sender, ISuperToken , 33342, bytes("cow"));
// cfaV1.updateFlow(receiver, token, flowRate, userData);
// cfaV1.deleteFlow(sender, receiver, token, userData);

Expand Down
16 changes: 14 additions & 2 deletions tests/0_default_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,22 @@ def test_happy_cow(CCOW, DAI, VC):
assert interface.IERC20(pool).balanceOf(accounts[4].address, {"from": accounts[4]}) == 0
b0_beforeLiquidation = interface.IERC20(deal[0][2]).balanceOf(accounts[4].address, {"from": accounts[4]})
b1_beforeLiquidation = DAI.balanceOf(accounts[4].address, {"from": accounts[4]})

CCOW.LiquidateDeal(1, {'from': accounts[4]})
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)

chain.revert()

sfToken = interface.ISuperToken(pool)
assert sfToken.balanceOf(accounts[4].address) == 0
CCOW.VestDeal(1, {'from': accounts[4]})
chain.sleep(3342 * 10)
assert sfToken.balanceOf(accounts[4].address) > 0





0 comments on commit 86bd194

Please sign in to comment.