Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
6e586de
Update README.md
stevenkcolin Dec 29, 2020
577cdf3
Update README.md
stevenkcolin Dec 29, 2020
5c1f894
submit
stevenkcolin Dec 29, 2020
3680563
Merge branch 'master' of https://github.com/stevenkcolin/basiscash-pr…
stevenkcolin Dec 29, 2020
d13920f
submit
stevenkcolin Dec 29, 2020
ddd1d5b
Update README.md
stevenkcolin Dec 29, 2020
35e70cc
submit
stevenkcolin Dec 29, 2020
c55bda4
Merge branch 'master' of https://github.com/stevenkcolin/basiscash-pr…
stevenkcolin Dec 29, 2020
c8c0d12
Update truffle-config.js
stevenkcolin Dec 29, 2020
697fcd5
Update truffle-config.js
stevenkcolin Dec 29, 2020
511291b
Update truffle-config.js
stevenkcolin Dec 29, 2020
1a47d2e
Update README.md
stevenkcolin Dec 29, 2020
b825530
Update README.md
stevenkcolin Dec 29, 2020
17c3ac9
Update README.md
stevenkcolin Dec 29, 2020
1003943
submit
stevenkcolin Dec 30, 2020
d67c06d
Merge branch 'master' of https://github.com/stevenkcolin/basiscash-pr…
stevenkcolin Dec 30, 2020
3b406af
submit
stevenkcolin Dec 30, 2020
97e4161
Update truffle-config.js
stevenkcolin Dec 31, 2020
01414ba
submit
stevenkcolin Jan 2, 2021
2d734c7
Update README.md
stevenkcolin Jan 2, 2021
5bc8f78
submit
stevenkcolin Jan 2, 2021
78929b9
Update README.md
stevenkcolin Jan 6, 2021
2e0d408
submit
stevenkcolin Jan 6, 2021
288b953
Merge branch 'master' of https://github.com/stevenkcolin/basiscash-pr…
stevenkcolin Jan 6, 2021
2780b35
submit
stevenkcolin Jan 6, 2021
f6713e1
submit
stevenkcolin Jan 10, 2021
4d0ca7f
submit
stevenkcolin Jan 11, 2021
bf5d366
submit
stevenkcolin Jan 11, 2021
7ceb096
Create 1100_ethers_learn.js
stevenkcolin Jan 11, 2021
2727e3e
submit
stevenkcolin Jan 22, 2021
28d59ce
Update 33_bac_mint.js
stevenkcolin Jan 22, 2021
1f6e118
submit
stevenkcolin Jan 26, 2021
1ffe905
update code
stevenkcolin Jan 26, 2021
5a259df
submit
stevenkcolin Jan 27, 2021
fffe62d
Update Treasury.sol
stevenkcolin Jan 27, 2021
a42d580
submit
stevenkcolin Jan 27, 2021
dd5dc0b
submit
stevenkcolin Jan 27, 2021
ddbf12f
submit
stevenkcolin Jan 28, 2021
9a7169c
submit
stevenkcolin Jan 28, 2021
6c613a7
submit
stevenkcolin Jan 28, 2021
ad63548
submit
stevenkcolin Jan 29, 2021
2433c47
submit
stevenkcolin Jan 29, 2021
2bf7c37
submit
stevenkcolin Jan 29, 2021
7f9a88b
submit
stevenkcolin Jan 30, 2021
e916d15
submit
stevenkcolin Jan 30, 2021
8853278
Create learn1.ts
stevenkcolin Jan 30, 2021
a0e83e7
submit
stevenkcolin Jan 30, 2021
f235630
submit
stevenkcolin Jan 30, 2021
452f67e
add some log event
hepf Jan 30, 2021
adb521c
submit
stevenkcolin Jan 30, 2021
bfd7745
Merge branch 'Yamato' of https://github.com/stevenkcolin/basiscash-pr…
stevenkcolin Jan 30, 2021
89c936c
submit
stevenkcolin Jan 31, 2021
30b1df5
submit
stevenkcolin Jan 31, 2021
f5d9d4c
remove fund in allocateSeigniorage
hepf Jan 31, 2021
bf994fb
Update 013101.json
stevenkcolin Jan 31, 2021
1a7a9ee
submit
stevenkcolin Feb 1, 2021
af0e869
submit
stevenkcolin Feb 1, 2021
e7717bb
Update treasury_info.ts
stevenkcolin Feb 1, 2021
f97bf5d
Update UniswapV2Library.sol
stevenkcolin Feb 1, 2021
64a2e15
update
stevenkcolin Feb 1, 2021
7e559e9
submit
stevenkcolin Feb 1, 2021
02fd74b
submit
stevenkcolin Feb 4, 2021
9e853e5
Update treasury_info.ts
stevenkcolin Feb 4, 2021
4c1cc77
submit
stevenkcolin Feb 4, 2021
ae22889
submit
stevenkcolin Feb 4, 2021
7935507
Update 013101.json
stevenkcolin Feb 4, 2021
e3d6ad9
submit
stevenkcolin Feb 4, 2021
d9fd8b1
Update 013101.json
stevenkcolin Feb 4, 2021
96ad70c
Update pools.js
stevenkcolin Feb 4, 2021
9d05e7b
submit
stevenkcolin Feb 4, 2021
7dca91a
submit
stevenkcolin Feb 4, 2021
65a519c
submit
stevenkcolin Feb 4, 2021
092bccf
submit
stevenkcolin Feb 4, 2021
327aa56
submit
stevenkcolin Feb 4, 2021
740dd8e
add setLockUp function to Treasury.sol
hepf Feb 4, 2021
ab60d25
submit
stevenkcolin Feb 11, 2021
3e03fd2
submit
stevenkcolin Feb 12, 2021
8fddf23
Update 013101.json
stevenkcolin Feb 14, 2021
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
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# Deploy & Test

```
yarn node

yarn deploy:dev
```

```
rm -rf build

yarn compile

yarn deploy:ropsten

yarn deploy:huobitest
```

```
rm -rf build

yarn compile

truffle migrate -f 1 --to 1 --network ropsten --skip-dry-run
```


# Basis Cash

![Background Image](./assets/bg.jpeg)
Expand Down
63 changes: 63 additions & 0 deletions contracts/Boardroom.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ contract Boardroom is ShareWrapper, ContractGuard, Operator {
using SafeMath for uint256;
using Safe112 for uint112;


/* ========== PARAMETERS =============== */
uint256 public withdrawLockupEpochs = 4;
uint256 public rewardLockupEpochs = 0;
uint256 public epochAlignTimestamp = 1608883200;
uint256 public epochPeriod = 28800;

/* ========== DATA STRUCTURES ========== */

struct Boardseat {
uint256 lastSnapshotIndex;
uint256 rewardEarned;
uint256 epochTimerStart;
}

struct BoardSnapshot {
Expand Down Expand Up @@ -131,6 +139,31 @@ contract Boardroom is ShareWrapper, ContractGuard, Operator {
return boardHistory[getLastSnapshotIndexOf(director)];
}

function getCurrentEpochTimestamp() public view returns(uint256) {
return epochAlignTimestamp.add(
block.timestamp
.sub(epochAlignTimestamp)
.div(epochPeriod)
.mul(epochPeriod)
);
}
function getCanWithdrawTime(address director) public view returns(uint256) {
return directors[director].epochTimerStart.add(
withdrawLockupEpochs.mul(epochPeriod)
);
}
function getCanClaimTime(address director) public view returns(uint256) {
return directors[director].epochTimerStart.add(
rewardLockupEpochs.mul(epochPeriod)
);
}
function canWithdraw(address director) public view returns (bool) {
return getCanWithdrawTime(director) <= getCurrentEpochTimestamp();
}
function canClaimReward(address director) public view returns (bool) {
return getCanClaimTime(director) <= getCurrentEpochTimestamp();
}

// =========== Director getters

function rewardPerShare() public view returns (uint256) {
Expand All @@ -147,6 +180,33 @@ contract Boardroom is ShareWrapper, ContractGuard, Operator {
);
}

/* ========== GOVERNANCE ================== */
function setLockUp(
uint256 _withdrawLockupEpochs,
uint256 _rewardLockupEpochs,
uint256 _epochAlignTimestamp,
uint256 _epochPeriod
)
external
onlyOperator
{
require(
_withdrawLockupEpochs >= _rewardLockupEpochs
&& _withdrawLockupEpochs <= 21,
"LockupEpochs: out of range"
);
require(_epochPeriod <= 1 days, "EpochPeriod: out of range");
require(
_epochAlignTimestamp.add(_epochPeriod.mul(2)) < block.timestamp,
"EpochAlignTimestamp: too late"
);
withdrawLockupEpochs = _withdrawLockupEpochs;
rewardLockupEpochs = _rewardLockupEpochs;
epochAlignTimestamp = _epochAlignTimestamp;
epochPeriod = _epochPeriod;
}


/* ========== MUTATIVE FUNCTIONS ========== */

function stake(uint256 amount)
Expand All @@ -157,6 +217,7 @@ contract Boardroom is ShareWrapper, ContractGuard, Operator {
{
require(amount > 0, 'Boardroom: Cannot stake 0');
super.stake(amount);
directors[msg.sender].epochTimerStart = getCurrentEpochTimestamp();
emit Staked(msg.sender, amount);
}

Expand All @@ -168,6 +229,7 @@ contract Boardroom is ShareWrapper, ContractGuard, Operator {
updateReward(msg.sender)
{
require(amount > 0, 'Boardroom: Cannot withdraw 0');
require(canWithdraw(msg.sender), "Boardroom: still in withdraw lockup");
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
Expand All @@ -180,6 +242,7 @@ contract Boardroom is ShareWrapper, ContractGuard, Operator {
function claimReward() public updateReward(msg.sender) {
uint256 reward = directors[msg.sender].rewardEarned;
if (reward > 0) {
require(canClaimReward(msg.sender), "Boardroom: still in claimReward lockup");
directors[msg.sender].rewardEarned = 0;
cash.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
Expand Down
2 changes: 1 addition & 1 deletion contracts/Bond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ contract Bond is ERC20Burnable, Ownable, Operator {
/**
* @notice Constructs the Basis Bond ERC-20 contract.
*/
constructor() public ERC20('BAB', 'BAB') {}
constructor() public ERC20('BDB', 'BDB') {}

/**
* @notice Operator mints basis bonds to a recipient
Expand Down
2 changes: 1 addition & 1 deletion contracts/Cash.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ contract Cash is ERC20Burnable, Operator {
/**
* @notice Constructs the Basis Cash ERC-20 contract.
*/
constructor() public ERC20('BAC', 'BAC') {
constructor() public ERC20('BDC', 'BDC') {
// Mints 1 Basis Cash to contract creator for initial Uniswap oracle deployment.
// Will be burned after oracle deployment
_mint(msg.sender, 1 * 10**18);
Expand Down
2 changes: 1 addition & 1 deletion contracts/Share.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './owner/Operator.sol';
import '@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol';

contract Share is ERC20Burnable, Operator {
constructor() public ERC20('BAS', 'BAS') {
constructor() public ERC20('BDS', 'BDS') {
// Mints 1 Basis Share to contract creator for initial Uniswap oracle deployment.
// Will be burned after oracle deployment
_mint(msg.sender, 1 * 10**18);
Expand Down
2 changes: 1 addition & 1 deletion contracts/Timelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract Timelock {
);

uint256 public constant GRACE_PERIOD = 14 days;
uint256 public constant MINIMUM_DELAY = 2 days;
uint256 public constant MINIMUM_DELAY = 0 days;
uint256 public constant MAXIMUM_DELAY = 30 days;

address public admin;
Expand Down
58 changes: 50 additions & 8 deletions contracts/Treasury.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ contract Treasury is ContractGuard, Epoch {
uint256 public bondDepletionFloor;
uint256 private accumulatedSeigniorage = 0;
uint256 public fundAllocationRate = 2; // %
// add inflationPercentCeil
uint256 public inflationPercentCeil;
uint256 public seigniorageCeil;

/* ========== CONSTRUCTOR ========== */

Expand All @@ -62,7 +65,7 @@ contract Treasury is ContractGuard, Epoch {
address _boardroom,
address _fund,
uint256 _startTime
) public Epoch(1 days, _startTime, 0) {
) public Epoch(10 minutes, _startTime, 0) {
cash = _cash;
bond = _bond;
share = _share;
Expand All @@ -75,6 +78,10 @@ contract Treasury is ContractGuard, Epoch {
cashPriceOne = 10**18;
cashPriceCeiling = uint256(105).mul(cashPriceOne).div(10**2);

// inflation at most 6%
inflationPercentCeil = uint256(6).mul(cashPriceOne).div(10**2);
seigniorageCeil = uint256(100000).mul(cashPriceOne);

bondDepletionFloor = uint256(1000).mul(cashPriceOne);
}

Expand Down Expand Up @@ -169,6 +176,22 @@ contract Treasury is ContractGuard, Epoch {
emit ContributionPoolRateChanged(msg.sender, rate);
}

function setInflationPercentCeil(uint256 inflationPercentCeil_)
public
onlyOperator
{
inflationPercentCeil = inflationPercentCeil_;
}

function setSeigniorageCeil(uint256 _seigniorageCeil)
public
onlyOperator
{
seigniorageCeil = _seigniorageCeil;
}



/* ========== MUTABLE FUNCTIONS ========== */

function _updateCashPrice() internal {
Expand Down Expand Up @@ -240,8 +263,10 @@ contract Treasury is ContractGuard, Epoch {
checkEpoch
checkOperator
{

_updateCashPrice();
uint256 cashPrice = _getCashPrice(seigniorageOracle);

if (cashPrice <= cashPriceCeiling) {
return; // just advance epoch instead revert
}
Expand All @@ -250,19 +275,26 @@ contract Treasury is ContractGuard, Epoch {
uint256 cashSupply = IERC20(cash).totalSupply().sub(
accumulatedSeigniorage
);
uint256 percentage = cashPrice.sub(cashPriceOne);
// Note: we change cashPriceOne to cashPriceCeiling
uint256 percentage = cashPrice.sub(cashPriceCeiling);

// add inflation as maximum = 4%
percentage = Math.min(percentage, inflationPercentCeil);
uint256 seigniorage = cashSupply.mul(percentage).div(1e18);
seigniorage = Math.min(seigniorage,seigniorageCeil);

IBasisAsset(cash).mint(address(this), seigniorage);


// ======================== BIP-3
uint256 fundReserve = seigniorage.mul(fundAllocationRate).div(100);
if (fundReserve > 0) {
IERC20(cash).safeApprove(fund, fundReserve);
ISimpleERCFund(fund).deposit(
cash,
fundReserve,
'Treasury: Seigniorage Allocation'
);
IERC20(cash).safeApprove(fund, fundReserve);
ISimpleERCFund(fund).deposit(
cash,
fundReserve,
'Treasury: Seigniorage Allocation'
);
emit ContributionPoolFunded(now, fundReserve);
}

Expand All @@ -289,6 +321,15 @@ contract Treasury is ContractGuard, Epoch {
}
}

function setLockUp(
uint256 _withdrawLockupEpochs,
uint256 _rewardLockupEpochs,
uint256 _epochAlignTimestamp,
uint256 _epochPeriod
) external onlyOperator {
IBoardroom(boardroom).setLockUp(_withdrawLockupEpochs, _rewardLockupEpochs, _epochAlignTimestamp, _epochPeriod);
}

// GOV
event Initialized(address indexed executor, uint256 at);
event Migration(address indexed target);
Expand All @@ -304,4 +345,5 @@ contract Treasury is ContractGuard, Epoch {
event TreasuryFunded(uint256 timestamp, uint256 seigniorage);
event BoardroomFunded(uint256 timestamp, uint256 seigniorage);
event ContributionPoolFunded(uint256 timestamp, uint256 seigniorage);
event LogError(address indexed from, uint256 indexed at, string reason);
}
13 changes: 11 additions & 2 deletions contracts/distribution/DAIBACLPTokenSharePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ contract DAIBACLPTokenSharePool is
IRewardDistributionRecipient
{
IERC20 public basisShare;

// add address FoundationA
address public foundationA;
uint256 public basAllocationPercentage = 10;

uint256 public constant DURATION = 30 days;

uint256 public initreward = 18479995 * 10**16; // 184,799.95 Shares
Expand All @@ -88,10 +93,12 @@ contract DAIBACLPTokenSharePool is
constructor(
address basisShare_,
address lptoken_,
address foundationA_,
uint256 starttime_
) public {
basisShare = IERC20(basisShare_);
lpt = IERC20(lptoken_);
foundationA = foundationA_;
starttime = starttime_;
}

Expand Down Expand Up @@ -165,14 +172,16 @@ contract DAIBACLPTokenSharePool is
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
basisShare.safeTransfer(msg.sender, reward);
basisShare.safeTransfer(msg.sender, reward.mul(100-basAllocationPercentage).div(100));
uint256 totalFee = reward.mul(basAllocationPercentage).div(100);
basisShare.safeTransfer(foundationA, totalFee);
emit RewardPaid(msg.sender, reward);
}
}

modifier checkhalve() {
if (block.timestamp >= periodFinish) {
initreward = initreward.mul(75).div(100);
initreward = initreward.mul(50).div(100);

rewardRate = initreward.div(DURATION);
periodFinish = block.timestamp.add(DURATION);
Expand Down
14 changes: 12 additions & 2 deletions contracts/distribution/DAIBASLPTokenSharePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ contract DAIBASLPTokenSharePool is
IRewardDistributionRecipient
{
IERC20 public basisShare;
uint256 public DURATION = 365 days;

// add address FoundationA
address public foundationA;
uint256 public basAllocationPercentage = 10;

uint256 public DURATION = 150 days;

uint256 public starttime;
uint256 public periodFinish = 0;
Expand All @@ -87,10 +92,12 @@ contract DAIBASLPTokenSharePool is
constructor(
address basisShare_,
address lptoken_,
address foundationA_,
uint256 starttime_
) public {
basisShare = IERC20(basisShare_);
lpt = IERC20(lptoken_);
foundationA = foundationA_;
starttime = starttime_;
}

Expand Down Expand Up @@ -170,7 +177,10 @@ contract DAIBASLPTokenSharePool is
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
basisShare.safeTransfer(msg.sender, reward);
basisShare.safeTransfer(msg.sender, reward.mul(100-basAllocationPercentage).div(100));
uint256 totalFee = reward.mul(basAllocationPercentage).div(100);
basisShare.safeTransfer(foundationA, totalFee);

emit RewardPaid(msg.sender, reward);
}
}
Expand Down
6 changes: 6 additions & 0 deletions contracts/interfaces/IBoardroom.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ pragma solidity ^0.6.0;

interface IBoardroom {
function allocateSeigniorage(uint256 amount) external;
function setLockUp(
uint256 _withdrawLockupEpochs,
uint256 _rewardLockupEpochs,
uint256 _epochAlignTimestamp,
uint256 _epochPeriod
) external;
}
Loading