Skip to content

added address of erc20 to be emitted from PoolAdded event and create… #11

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: master
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
6 changes: 0 additions & 6 deletions .env.example

This file was deleted.

845 changes: 845 additions & 0 deletions contract-map-LinearVestingProjectUpgradeable.drawio

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions contracts-layout.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<mxfile host="65bd71144e">
<diagram id="yU2J-Tcu2Rwsxy_KYUA6" name="Page-1">
<mxGraphModel dx="1058" dy="833" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="31" style="edgeStyle=none;html=1;fontSize=18;startArrow=none;" parent="1" source="32" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="250" y="330" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="4" value="&lt;font size=&quot;3&quot;&gt;1&lt;/font&gt;" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="155" y="100" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="5" value="Deploy vesting project for beacon" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
<mxGeometry x="90" y="50" width="200" height="30" as="geometry"/>
</mxCell>
<mxCell id="6" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;LinearVestingProjectRemovableUpgradeable.sol&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
<mxGeometry x="35" y="70" width="320" height="30" as="geometry"/>
</mxCell>
<mxCell id="28" style="edgeStyle=none;html=1;fontSize=18;" parent="1" source="10" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="195" y="430" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="10" value="&lt;font size=&quot;3&quot;&gt;2&lt;/font&gt;" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="155" y="290" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="11" value="LinearVestingProjectFactoryUpgradeable.sol" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=14;" parent="1" vertex="1">
<mxGeometry x="45" y="260" width="300" height="30" as="geometry"/>
</mxCell>
<mxCell id="17" value="Deploy project factory and set beacon" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
<mxGeometry x="85" y="240" width="220" height="30" as="geometry"/>
</mxCell>
<mxCell id="20" value="LinearVestingProjectBeacon.sol" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=14;" parent="1" vertex="1">
<mxGeometry x="85" y="440" width="220" height="30" as="geometry"/>
</mxCell>
<mxCell id="21" value="&lt;font size=&quot;3&quot;&gt;3&lt;/font&gt;" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="155" y="470" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="30" value="user" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=18;" parent="1" vertex="1">
<mxGeometry x="415" y="260" width="60" height="40" as="geometry"/>
</mxCell>
<mxCell id="32" value="&lt;font style=&quot;font-size: 12px;&quot;&gt;Create Org with &lt;br&gt;ERC20 address&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=18;" parent="1" vertex="1">
<mxGeometry x="280" y="300" width="110" height="60" as="geometry"/>
</mxCell>
<mxCell id="33" value="" style="edgeStyle=none;html=1;fontSize=18;endArrow=none;" parent="1" source="2" target="32" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="250" y="330" as="targetPoint"/>
<mxPoint x="425" y="330" as="sourcePoint"/>
</mxGeometry>
</mxCell>
<mxCell id="2" value="" style="shape=actor;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="425" y="300" width="40" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="4" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=18;" parent="1" vertex="1">
<mxGeometry x="430" y="320" width="30" height="40" as="geometry"/>
</mxCell>
<mxCell id="35" value="Beacon address" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="235" y="125" width="110" height="30" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
73 changes: 54 additions & 19 deletions contracts/linear-vesting/ILinearVestingProjectUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ pragma solidity ^0.8.4;
* Taken from https://github.com/dandelionlabs-io/linear-vesting-contracts/blob/master/contracts/linear-vesting/ILinearVestingProjectUpgradeable.sol
*/
interface ILinearVestingProjectUpgradeable {

/// @notice Pool definition
struct Pool {
string name; // Name of the pool
/// @notice Vesting Schedule definition
struct VestingSchedule {
address token;
string metadataUrl; // Name of the vesting schedule
uint startTime; // Starting time of the vesting period in unix timestamp format
uint endTime; // Ending time of the vesting period in unix timestamp format
uint vestingDuration; // In seconds
uint amount; // Total size of pool
uint amount; // Total size of vesting
uint totalClaimed; // Total amount claimed till moment
uint grants; // Amount of stakeholders
}
Expand All @@ -26,60 +26,95 @@ interface ILinearVestingProjectUpgradeable {
uint perSecond; // Reward per second
}

/// @notice Event emitted when a new pool is created
event PoolAdded(uint indexed index, address createdBy, string name, uint startTime, uint endTime);
/// @notice Event emitted when a new vesting schedule is created
event VestingScheduleAdded(
address token,
string metadataUrl,
uint indexed index,
address createdBy,
uint startTime,
uint endTime
);

/// @notice Event emitted when a new grant is created
event GrantAdded(uint indexed poolIndex, address indexed addedBy, address indexed recipient, uint amount);
event GrantAdded(
uint indexed vestingIndex,
address indexed addedBy,
address indexed recipient,
uint amount
);

/// @notice Event emitted when tokens are claimed by a recipient from a grant
event GrantClaimed(uint indexed poolIndex, address indexed recipient, uint amountClaimed);
event GrantClaimed(
uint indexed vestingIndex,
address indexed recipient,
uint amountClaimed
);

/// @notice Event emitted when metadata url is changed
event MetadataUrlChanged(address indexed changedBy, string metadataUrl);

/**
* @notice Creates a new pool
* @notice Creates a new vesting schedule
* @param _startTime starting time of the vesting period in timestamp format
* @param _vestingDuration duration time of the vesting period in timestamp format
*/
function createPool(string memory _name, uint256 _startTime, uint256 _vestingDuration) external returns (uint256);
function createVestingSchedule(
address token,
string memory _metadataUrl,
uint256 _startTime,
uint256 _vestingDuration
) external returns (uint256);

/**
* @notice Creates a new pool
* @notice Creates a new vesting schedule grants
* @param _startTime starting time of the vesting period in timestamp format
* @param _vestingDuration duration time of the vesting period in timestamp format
*/
function createPoolWithGrants(string memory _name, uint256 _startTime, uint256 _vestingDuration, address[] memory _recipients, uint256[] memory _amounts) external returns (uint256);
function createVestingScheduleWithGrants(
address token,
string memory _metadataUrl,
uint256 _startTime,
uint256 _vestingDuration,
address[] memory _recipients,
uint256[] memory _amounts
) external returns (uint256);

/**
* @notice Add list of grants in batch.
* @param _recipients list of addresses of the stakeholders
* @param _amounts list of amounts to be assigned to the stakeholders
* @param _recipients list of addresses of the beneficiaries
* @param _amounts list of amounts to be assigned to the beneficiaries
*/
function addGrants(uint _poolIndex, address[] memory _recipients, uint256[] memory _amounts) external;
function addGrants(
uint _vestingIndex,
address[] memory _recipients,
uint256[] memory _amounts
) external;

/**
* @notice Calculate the vested and unclaimed tokens available for `recipient` to claim
* @dev Due to rounding errors once grant duration is reached, returns the entire left grant amount
* @param _recipient The address that has a grant
* @return The amount recipient can claim
*/
function calculateGrantClaim(uint _poolIndex, address _recipient) external view returns (uint256);
function calculateGrantClaim(
uint _vestingIndex,
address _recipient
) external view returns (uint256);

/**
* @notice Allows a grant recipient to claim their vested tokens
* @dev Errors if no tokens have vested
* @dev It is advised recipients check they are entitled to claim via `calculateGrantClaim` before calling this
*/
function claimVestedTokens(uint _poolIndex) external;
function claimVestedTokens(uint _vestingIndex) external;

/**
* @notice Allows a grant recipient to claim multiple vested tokens
* @dev Errors if no tokens have vested
* @dev It is advised recipients check they are entitled to claim via `calculateGrantClaim` before calling this
*/
function claimMultiplePools(uint[] memory _poolIndexes) external;
function claimMultipleVestings(uint[] memory _vestingIndexes) external;

function setMetadataUrl(string memory _metadata) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import "./LinearVestingProjectUpgradeable.sol";
import "./LinearVestingProjectBeacon.sol";

contract LinearVestingProjectFactoryUpgradeable is OwnableUpgradeable {

address[] private projects;
uint public projectsCount;
LinearVestingProjectBeacon beacon;

/**
* @dev Emitted when a new project is created.
* @dev Emitted when a new project is created.
*/
event ProjectCreated(
uint indexed index,
Expand All @@ -24,12 +23,16 @@ contract LinearVestingProjectFactoryUpgradeable is OwnableUpgradeable {
string metadataUrl
);

function __LinearVestingProjectFactory_initialize(address _initBlueprint) public initializer onlyInitializing {
function __LinearVestingProjectFactory_initialize(
address _initBlueprint
) public initializer onlyInitializing {
__Ownable_init();
__LinearVestingProjectFactory_initialize_unchained(_initBlueprint);
}

function __LinearVestingProjectFactory_initialize_unchained(address _initBlueprint) public onlyInitializing {
function __LinearVestingProjectFactory_initialize_unchained(
address _initBlueprint
) public onlyInitializing {
beacon = new LinearVestingProjectBeacon(_initBlueprint);
}

Expand All @@ -41,7 +44,9 @@ contract LinearVestingProjectFactoryUpgradeable is OwnableUpgradeable {
BeaconProxy project = new BeaconProxy(
address(beacon),
abi.encodeWithSelector(
LinearVestingProjectUpgradeable(address(0)).__LinearVestingProject_initialize.selector,
LinearVestingProjectUpgradeable(address(0))
.__LinearVestingProject_initialize
.selector,
_token,
_metadataUrl
)
Expand Down Expand Up @@ -69,7 +74,9 @@ contract LinearVestingProjectFactoryUpgradeable is OwnableUpgradeable {
return address(beacon);
}

function getProjectAddress(uint projectIndex) external view returns (address) {
function getProjectAddress(
uint projectIndex
) external view returns (address) {
return projects[projectIndex];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//// SPDX-License-Identifier: MIT
//pragma solidity ^0.8.4;
//
//import "./LinearVestingProjectUpgradeable.sol";
//
//abstract contract LinearVestingProjectTransferableUpgradeable is LinearVestingProjectUpgradeable {
// // SPDX-License-Identifier: MIT
// pragma solidity ^0.8.4;

// import "./LinearVestingProjectUpgradeable.sol";

// abstract contract LinearVestingProjectTransferableUpgradeable is LinearVestingProjectUpgradeable {
// using SafeMathUpgradeable for uint256;
//

// /// @notice Event emitted when the grant investor is changed
// event GrantChanged(address indexed oldOwner, address indexed newOwner);
//

// /// @notice List of investors who got blacklist tokens.
// /// @dev Structure of the map: investor => new address
// mapping(address => address) public blacklist;
//

// /**
// * @notice In case if the user doesn't want to change the grant.
// * @param _oldAddress existing address from the investor which we want to change
Expand All @@ -38,19 +38,19 @@
// tokenGrants[_oldAddress].amount > 0,
// "VestingPeriod::changeInvestor: oldAddress has no remaining balance"
// );
//

// tokenGrants[_newAddress] = Grant(
// tokenGrants[_oldAddress].amount,
// tokenGrants[_oldAddress].totalClaimed,
// tokenGrants[_oldAddress].perSecond
// );
// delete tokenGrants[_oldAddress];
//

// blacklist[_oldAddress] = _newAddress;
//

// emit GrantChanged(_oldAddress, _newAddress);
// }
//

// function addTokenGrants(
// address[] memory _recipients,
// uint256[] memory _amounts
Expand All @@ -67,7 +67,7 @@
// _recipients.length == _amounts.length,
// "VestingPeriod::addTokenGrants: invalid parameters length (they should be same)"
// );
//

// uint256 amountSum = 0;
// for (uint16 i = 0; i < _recipients.length; i++) {
// require(
Expand All @@ -82,20 +82,20 @@
// blacklist[_recipients[i]] == address(0),
// "VestingPeriod:addTOkenGrants: Blacklisted address"
// );
//

// require(
// _amounts[i] > 0,
// "VestingPeriod::addTokenGrant: amount == 0"
// );
// amountSum = amountSum.add(_amounts[i]);
// }
//

// // Transfer the grant tokens under the control of the vesting contract
// require(
// token.transferFrom(msg.sender, address(this), amountSum),
// "VestingPeriod::addTokenGrants: transfer failed"
// );
//

// for (uint16 i = 0; i < _recipients.length; i++) {
// Grant memory grant = Grant({
// amount: _amounts[i],
Expand All @@ -105,7 +105,7 @@
// tokenGrants[_recipients[i]] = grant;
// emit GrantAdded(_recipients[i], _amounts[i]);
// }
//

// pool.amount = pool.amount.add(amountSum);
// }
//}
// }
Loading