Skip to content
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

F/pots #28

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"name": "@buttergov/molten-core",
"version": "0.1.0",
"description": "Molten core contracts",
"files": ["out/"],
"files": [
"out/"
],
"directories": {
"lib": "lib",
"test": "test"
Expand Down
2 changes: 1 addition & 1 deletion script/SetupTestEnv.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.17;

import {Script} from "forge-std/Script.sol";
import {console2} from "forge-std/console2.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/MToken.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
// solhint-disable no-empty-blocks
pragma solidity ^0.8.13;
pragma solidity ^0.8.17;

import {ERC20, ERC20Pausable, Pausable} from "openzeppelin/token/ERC20/extensions/ERC20Pausable.sol";
import {Owned} from "solmate/auth/Owned.sol";
Expand Down
84 changes: 84 additions & 0 deletions src/MoltenCampaign.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: UNLICENSED
// solhint-disable not-rely-on-time
pragma solidity ^0.8.17;

import {MToken} from "./MToken.sol";
import {IERC20Votes} from "./interfaces/IERC20Votes.sol";

/// [XXX] Rename to MoltenElection
contract MoltenCampaignMarket {
IERC20Votes public daoToken;
// Threshold in daoToken-weis.
uint256 public threshold;
uint32 public duration;

constructor(
address daoTokenAddress,
uint256 _threshold,
uint32 _duration
) {
daoToken = IERC20Votes(daoTokenAddress);
threshold = _threshold;
duration = _duration;
}

// [XXX] We could further dependency-inject by having a separate libs
// MTokenDeployer and MoltenCampaignDeployer which addresses are passed as
// argument of the constructor (or the function?).
function makeCampaign() external returns (MoltenCampaign) {
MToken mToken = new MToken(
string.concat("Molten ", daoToken.name()),
string.concat("m", daoToken.symbol()), // [XXX] Add campaigner (delegate) name
address(this)
);
MoltenCampaign mc = new MoltenCampaign(
msg.sender,
address(this),
address(mToken)
);
mToken.transferOwnership(address(mc));
return mc;
}
}

contract MoltenCampaign {
address public representative;
MoltenCampaignMarket public market;
MToken public mToken;

uint256 public totalStaked;
mapping(address => uint256) public staked;

// 💜 dumb constructors.
constructor(
address _representative,
address marketAddress,
address mTokenAddress
) {
representative = _representative;
market = MoltenCampaignMarket(marketAddress);
mToken = MToken(mTokenAddress);
}

function _getDaoToken() private view returns (IERC20Votes) {
return IERC20Votes(market.daoToken());
}

function stake(uint256 amount) public {
staked[msg.sender] += amount;
totalStaked += amount;

mToken.mint(msg.sender, amount);
_getDaoToken().transferFrom(msg.sender, address(this), amount);
}

function unstake() public {
uint256 _staked = staked[msg.sender];

staked[msg.sender] = 0;
totalStaked -= _staked;

mToken.burn(msg.sender, _staked);
_getDaoToken().transferFrom(address(this), msg.sender, _staked);
}
}
2 changes: 1 addition & 1 deletion src/MoltenFunding.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
// solhint-disable not-rely-on-time
pragma solidity ^0.8.13;
pragma solidity ^0.8.17;

import {IERC20} from "openzeppelin/token/ERC20/ERC20.sol";
import {ReentrancyGuard} from "solmate/utils/ReentrancyGuard.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/UniswapV3Adapter.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.13;
pragma solidity ^0.8.17;

import {IUniswapV3OracleConsulter} from "molten-oracle/interfaces/IUniswapV3OracleConsulter.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IERC20Votes.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.17;

import {IERC20} from "openzeppelin/token/ERC20/ERC20.sol";

Expand Down
Loading