Skip to content

updating RedeemingCreate to allow any address to recieve #90

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 1 commit into
base: staging
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
61 changes: 43 additions & 18 deletions contracts/src/creaton/RedeemCreate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,78 +32,98 @@ contract RedeemCreate{

}

function startTeamStream(uint256 amountPutIn) public returns (uint256 streamID){
function startTeamStream(uint256 amountPutIn, address target) public returns (uint256 streamID){
address sender = target;
if (target == address(0x00)){
address sender = msg.sender;
}

//sender, amount, create Address, now, to two years from now
protoTeam.transferFrom(msg.sender, address(this), amountPutIn);


uint256 roundOver = amountPutIn%(86400*365*2);
ERC20(create).approve(address(sablier), amountPutIn);
uint256 streamID = sablier.createStream(msg.sender, amountPutIn - roundOver, create, block.timestamp + days180, block.timestamp + 86400*365*2 + days180);
uint256 streamID = sablier.createStream(sender, amountPutIn - roundOver, create, block.timestamp + days180, block.timestamp + 86400*365*2 + days180);
console.log(streamID);
emit streamStarted(address(protoTeam), amountPutIn - roundOver, block.timestamp+days180, block.timestamp+86400*365*2+days180, msg.sender, streamID);
emit streamStarted(address(protoTeam), amountPutIn - roundOver, block.timestamp+days180, block.timestamp+86400*365*2+days180, sender, streamID);

if (roundOver > 0){
uint256 overflowStream = sablier.createStream(msg.sender, roundOver, create, block.timestamp + 86400*365*2 + days180, block.timestamp + 86400*365*2 + days180+1);
uint256 overflowStream = sablier.createStream(sender, roundOver, create, block.timestamp + 86400*365*2 + days180, block.timestamp + 86400*365*2 + days180+1);
console.log(overflowStream);
}
return streamID;
}

function startAdvisorStream(uint256 amountPutIn) public returns (uint256 streamID){
function startAdvisorStream(uint256 amountPutIn, address target) public returns (uint256 streamID){
address sender = target;
if (target == address(0x00)){
address sender = msg.sender;
}

protoAdvisor.transferFrom(msg.sender, address(this), amountPutIn);

uint256 roundOver = amountPutIn%(86400*304);
ERC20(create).approve(address(sablier), amountPutIn);
uint256 streamID = sablier.createStream(msg.sender, amountPutIn - roundOver, create, block.timestamp + days180, block.timestamp + 86400*304 + days180);
uint256 streamID = sablier.createStream(sender, amountPutIn - roundOver, create, block.timestamp + days180, block.timestamp + 86400*304 + days180);
//86400 for seconds in a day, 304 for 10 months
console.log(streamID);
emit streamStarted(address(protoAdvisor), amountPutIn - roundOver, block.timestamp+days180, block.timestamp+86400*304+days180, msg.sender, streamID);
emit streamStarted(address(protoAdvisor), amountPutIn - roundOver, block.timestamp+days180, block.timestamp+86400*304+days180, sender, streamID);

if (roundOver > 0){
uint256 overflowStream = sablier.createStream(msg.sender, roundOver, create, block.timestamp+86400*304+days180, block.timestamp+86400*304+days180 + 1);
uint256 overflowStream = sablier.createStream(sender, roundOver, create, block.timestamp+86400*304+days180, block.timestamp+86400*304+days180 + 1);
console.log(overflowStream);
}
return streamID;
}

function startAmbassadorStream(uint256 amountPutIn) public returns (uint256 streamID){
function startAmbassadorStream(uint256 amountPutIn, address target) public returns (uint256 streamID){
address sender = target;
if (target == address(0x00)){
address sender = msg.sender;
}

protoAmbassador.transferFrom(msg.sender, address(this), amountPutIn);

uint256 roundOver = amountPutIn%(86400*304);
ERC20(create).approve(address(sablier), amountPutIn);
uint256 streamID = sablier.createStream(msg.sender, amountPutIn - roundOver, create, block.timestamp + 86400*30, block.timestamp + 86400*304 + 86400*30);
uint256 streamID = sablier.createStream(sender, amountPutIn - roundOver, create, block.timestamp + 86400*30, block.timestamp + 86400*304 + 86400*30);
//86400 for seconds in a day, 304 for 10 months
console.log(streamID);
emit streamStarted(address(protoAmbassador), amountPutIn - roundOver, block.timestamp+86400*30, block.timestamp+86400*304+86400*30, msg.sender, streamID);
emit streamStarted(address(protoAmbassador), amountPutIn - roundOver, block.timestamp+86400*30, block.timestamp+86400*304+86400*30, sender, streamID);

if (roundOver>0){
console.log(sablier.createStream(msg.sender, roundOver, create, block.timestamp + 86400*304, block.timestamp + 86400*304+1));
console.log(sablier.createStream(sender, roundOver, create, block.timestamp + 86400*304, block.timestamp + 86400*304+1));
}

return streamID;
}

function startSeedStream(uint256 amountPutIn) public returns (uint256 streamID){
function startSeedStream(uint256 amountPutIn, address target) public returns (uint256 streamID){
address sender = target;
if (target == address(0x00)){
address sender = msg.sender;
}

//sender, amount, create Address, now, to two years from now
protoSeed.transferFrom(msg.sender, address(this), amountPutIn);
uint256 roundOver = amountPutIn%(86400*243);

ERC20(create).approve(address(sablier), amountPutIn);
uint256 streamID = sablier.createStream(msg.sender, amountPutIn - roundOver, create, block.timestamp + 86400*30, block.timestamp + 86400*(243+30));
uint256 streamID = sablier.createStream(sender, amountPutIn - roundOver, create, block.timestamp + 86400*30, block.timestamp + 86400*(243+30));
//86400 for seconds in a day
console.log(streamID);
emit streamStarted(address(protoSeed), amountPutIn - roundOver, block.timestamp+86400*30, block.timestamp+86400*(243+30), msg.sender, streamID);
emit streamStarted(address(protoSeed), amountPutIn - roundOver, block.timestamp+86400*30, block.timestamp+86400*(243+30), sender, streamID);

if (roundOver>0){
emit streamStarted(
address(protoSeed),
roundOver,
block.timestamp + 86400*(243+30),
block.timestamp + 86400*(243+30)+1,
msg.sender,
sender,
sablier.createStream(
msg.sender,
sender,
roundOver,
create,
block.timestamp + 86400*(243+30),
Expand All @@ -112,7 +132,12 @@ contract RedeemCreate{
return streamID;
}

function startPrivateStream(uint256 amountPutIn) public returns (uint256 streamID){
function startPrivateStream(uint256 amountPutIn, address target) public returns (uint256 streamID){
address sender = target;
if (target == address(0x00)){
address sender = msg.sender;
}

//sender, amount, create Address, now, to two years from now
ProtoPrivate.transferFrom(msg.sender, address(this), amountPutIn);

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/reaction/ReactionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {
ISuperfluid
} from "@superfluid-finance_1/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
import "@superfluid-finance_1/ethereum-contracts/contracts/interfaces/ux/IResolver.sol";
import "@superfluid-finance_1/ethereum-contracts/contracts/interfaces/misc/IResolver.sol";

import "./ReactionToken.sol";
import "./StakedFlow.sol";
Expand Down
18 changes: 9 additions & 9 deletions contracts/test/RedeemCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
expect(await protoTeam.balanceOf(teamMember.address)).to.equal(ethers.utils.parseEther("63072"));

await protoTeam.connect(teamMember).approve(redeemCreate.address, ethers.utils.parseEther("63072"));
await redeemCreate.connect(teamMember).startTeamStream(ethers.utils.parseEther("63072"));
await redeemCreate.connect(teamMember).startTeamStream(ethers.utils.parseEther("63072"), teamMember.address);

await timeTravel(365*2*24*60*60+ 10 + 180*86400);//2 years
console.log(await sablierContract.balanceOf(100000, teamMember.address));
Expand All @@ -72,7 +72,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoAdvisor.balanceOf(advisorMember.address)).to.equal(ethers.utils.parseEther("262656"));
await protoAdvisor.connect(advisorMember).approve(redeemCreate.address, ethers.utils.parseEther("262656"));
await redeemCreate.connect(advisorMember).startAdvisorStream(ethers.utils.parseEther("262656"));
await redeemCreate.connect(advisorMember).startAdvisorStream(ethers.utils.parseEther("262656"), advisorMember.address);

await timeTravel(365*2*24*60*60+ 10);//2 years
console.log(await sablierContract.balanceOf(100000, advisorMember.address));
Expand All @@ -88,7 +88,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoAmbassador.balanceOf(ambassadorMember.address)).to.equal(ethers.utils.parseEther("262656"));
await protoAmbassador.connect(ambassadorMember).approve(redeemCreate.address, ethers.utils.parseEther("262656"));
await redeemCreate.connect(ambassadorMember).startAmbassadorStream(ethers.utils.parseEther("262656"));
await redeemCreate.connect(ambassadorMember).startAmbassadorStream(ethers.utils.parseEther("262656"), ambassadorMember.address);

await timeTravel(365*2*24*60*60+ 10);//2 years
console.log(await sablierContract.balanceOf(100000, ambassadorMember.address));
Expand All @@ -104,7 +104,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoSeed.balanceOf(seedMember.address)).to.equal(ethers.utils.parseEther("209952"));
await protoSeed.connect(seedMember).approve(redeemCreate.address, ethers.utils.parseEther("209952"));
await redeemCreate.connect(seedMember).startSeedStream(ethers.utils.parseEther("209952"));
await redeemCreate.connect(seedMember).startSeedStream(ethers.utils.parseEther("209952"), seedMember.address);

await timeTravel(365*2*24*60*60+ 10);//2 years
console.log(await sablierContract.balanceOf(100000, seedMember.address));
Expand All @@ -120,7 +120,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoPrivate.balanceOf(privateMember.address)).to.equal(ethers.utils.parseEther("104544"));
await protoPrivate.connect(privateMember).approve(redeemCreate.address, ethers.utils.parseEther("104544"));
await redeemCreate.connect(privateMember).startPrivateStream(ethers.utils.parseEther("104544"));
await redeemCreate.connect(privateMember).startPrivateStream(ethers.utils.parseEther("104544"), privateMember.address);

await timeTravel(365*2*24*60*60+ 10);//1 year
console.log(await sablierContract.balanceOf(100000, privateMember.address));
Expand All @@ -137,7 +137,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
expect(await protoTeam.balanceOf(teamMember.address)).to.equal(ethers.utils.parseEther("1"));

await protoTeam.connect(teamMember).approve(redeemCreate.address, ethers.utils.parseEther("1"));
await redeemCreate.connect(teamMember).startTeamStream(ethers.utils.parseEther("1"));
await redeemCreate.connect(teamMember).startTeamStream(ethers.utils.parseEther("1"), teamMember.address);

await timeTravel(365*2*24*60*60+ 10 + 180*86400);//2 years
// console.log(await sablierContract.balanceOf(100000, teamMember.address));
Expand All @@ -157,7 +157,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoAdvisor.balanceOf(advisorMember.address)).to.equal(ethers.utils.parseEther("1.5"));
await protoAdvisor.connect(advisorMember).approve(redeemCreate.address, ethers.utils.parseEther("1.5"));
await redeemCreate.connect(advisorMember).startAdvisorStream(ethers.utils.parseEther("1.5"));
await redeemCreate.connect(advisorMember).startAdvisorStream(ethers.utils.parseEther("1.5"), advisorMember.address);

await timeTravel(365*2*24*60*60+ 10);//2 years
// console.log(await sablierContract.balanceOf(100000, advisorMember.address));
Expand All @@ -175,7 +175,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoAmbassador.balanceOf(ambassadorMember.address)).to.equal(ethers.utils.parseEther("1.5"));
await protoAmbassador.connect(ambassadorMember).approve(redeemCreate.address, ethers.utils.parseEther("1.5"));
await redeemCreate.connect(ambassadorMember).startAmbassadorStream(ethers.utils.parseEther("1.5"));
await redeemCreate.connect(ambassadorMember).startAmbassadorStream(ethers.utils.parseEther("1.5"), ambassadorMember.address);

await timeTravel(365*2*24*60*60+ 10);//2 years
console.log(await sablierContract.balanceOf(100000, ambassadorMember.address));
Expand All @@ -192,7 +192,7 @@ describe('Redeeming Create For Investors Based On Proto Create', function(){
//just confirm that it transferred correctly.
expect(await protoPrivate.balanceOf(privateMember.address)).to.equal(ethers.utils.parseEther("104544"));
await protoPrivate.connect(privateMember).approve(redeemCreate.address, ethers.utils.parseEther("104544"));
await redeemCreate.connect(privateMember).startPrivateStream(ethers.utils.parseEther("104544"));
await redeemCreate.connect(privateMember).startPrivateStream(ethers.utils.parseEther("104544"), privateMember.address);

await timeTravel(365*2*24*60*60+ 10);//1 year
console.log(await sablierContract.balanceOf(100000, privateMember.address));
Expand Down