Skip to content
Merged
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
47 changes: 46 additions & 1 deletion src/core/ElasticDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
pragma solidity 0.7.2;
pragma experimental ABIEncoderV2;

import '../interfaces/IUniswapV2Pair.sol';

import '../libraries/ElasticMath.sol';

import '../models/DAO.sol';
import '../models/Ecosystem.sol';
import '../models/Token.sol';

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

import '@pie-dao/proxy/contracts/PProxy.sol';
import 'hardhat/console.sol';

/**
* @dev The ElasticDAO contract outlines and defines all the functionality
Expand All @@ -23,6 +26,7 @@ contract ElasticDAO is ReentrancyGuard {
address public ecosystemModelAddress;
address public controller;
address[] public summoners;
address[] public liquidityPools;
bool public initialized;

event ElasticGovernanceTokenDeployed(address indexed tokenAddress);
Expand All @@ -35,6 +39,8 @@ contract ElasticDAO is ReentrancyGuard {
uint256 actualAmount
);
event JoinDAO(address indexed memberAddress, uint256 shareAmount, uint256 ethAmount);
event LiquidityPoolAdded(address indexed poolAddress);
event LiquidityPoolRemoved(address indexed poolAddress);
event SeedDAO(address indexed summonerAddress, uint256 amount);
event SummonedDAO(address indexed summonedBy);

Expand Down Expand Up @@ -129,6 +135,17 @@ contract ElasticDAO is ReentrancyGuard {
require(success, 'ElasticDAO: Build DAO Failed');
}

function addLiquidityPool(address _poolAddress)
external
onlyController
nonReentrant
returns (bool)
{
liquidityPools.push(_poolAddress);

emit LiquidityPoolAdded(_poolAddress);
}

/**
* @notice initializes the token of the DAO
*
Expand Down Expand Up @@ -199,6 +216,14 @@ contract ElasticDAO is ReentrancyGuard {
emit ExitDAO(msg.sender, _deltaLambda, ethToBeTransfered);
}

/**
* @notice this function returns the length of the liquidity pools array
*
*/
function getLiquidityPoolCount() public view returns (uint256) {
return liquidityPools.length;
}

/**
* @notice this function is used to join the DAO after it has been summoned
* Joining the DAO is syntactically equal to minting _deltaLambda for the function caller.
Expand Down Expand Up @@ -253,6 +278,10 @@ contract ElasticDAO is ReentrancyGuard {
bool success = tokenContract.mintShares(msg.sender, token.maxLambdaPurchase);
require(success, 'ElasticDAO: Mint Shares Failed during Join');

for (uint256 i = 0; i < liquidityPools.length; i += 1) {
IUniswapV2Pair(liquidityPools[i]).sync();
}

// return extra ETH
if (success && msg.value > deltaE) {
(success, ) = msg.sender.call{ value: SafeMath.sub(msg.value, deltaE) }('');
Expand Down Expand Up @@ -298,6 +327,22 @@ contract ElasticDAO is ReentrancyGuard {
}
}

function removeLiquidityPool(address _poolAddress)
external
onlyController
nonReentrant
returns (bool)
{
for (uint256 i = 0; i < liquidityPools.length; i += 1) {
if (liquidityPools[i] == _poolAddress) {
liquidityPools[i] = liquidityPools[liquidityPools.length - 1];
liquidityPools.pop();
}
}

emit LiquidityPoolRemoved(_poolAddress);
}

/**
* @notice rewards @param _addresess with @param _amounts respectively
*
Expand Down
2 changes: 1 addition & 1 deletion src/core/ElasticDAOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma experimental ABIEncoderV2;
import './ElasticDAO.sol';

import '../models/Ecosystem.sol';
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

import '@pie-dao/proxy/contracts/PProxy.sol';

Expand Down
6 changes: 6 additions & 0 deletions src/interfaces/IUniswapV2Pair.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPLv3
pragma solidity 0.7.2;

interface IUniswapV2Pair {
function sync() external;
}
2 changes: 1 addition & 1 deletion src/models/DAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.7.2;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

import './Ecosystem.sol';
import './EternalModel.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/models/Ecosystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.7.2;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

import './EternalModel.sol';

Expand Down
2 changes: 1 addition & 1 deletion src/models/Token.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPLv3
pragma solidity 0.7.2;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

import './Ecosystem.sol';
import './EternalModel.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/models/TokenHolder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.7.2;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

import './Ecosystem.sol';
import './EternalModel.sol';
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/ElasticGovernanceToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../models/Ecosystem.sol';
import '../models/Token.sol';
import '../models/TokenHolder.sol';

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';

/**
* @dev ElasticGovernanceToken contract outlines and defines all the functionality
Expand Down