Skip to content
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
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export KOVAN_RPC_URL='www.infura.io/asdfadsfafdadf'
export PRIVATE_KEY='abcdef'
export ALCHEMY_MAINNET_RPC_URL="https://eth-mainnet.alchemyapi.io/v2/your-api-key"
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
KOVAN_RPC_URL='https://kovan.infura.io/v3/1234567890'
PRIVATE_KEY='abcdefg'
ALCHEMY_MAINNET_RPC_URL="https://eth-mainnet.alchemyapi.io/v2/your-api-key"
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"parser": "babel-eslint"
}

2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode
node_modules

#Hardhat files
cache
artifacts
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@
To get a local copy up and running follow these simple example steps.

- Fork the repository
- Git clone https://github.com/your-username/bnbCodedClass
- Git clone https://github.com/your-username/MC16Coin
- git checkout -b branch name
- git remote add upstream https://github.com/cloud9n/bnbCodedClass
- yarn install
- git remote add upstream https://github.com/MasterClass16/MC16Coin
- git pull upstream develop
- git commit -m "commit message"
- git push -u origin HEAD

## Compiling

$ npx hardhat compile

## Author(s)

## 🤝 Contributing
Expand Down
25 changes: 10 additions & 15 deletions CoinPriceOracle.sol → contracts/CoinPriceOracle.sol
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
pragma solidity ^0.7.6;
pragma solidity ^0.6.8;
// SPDX-License-Identifier: MIT

import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/ChainlinkClient.sol";
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
import "./RebaseToken.sol";


contract CoinPriceOracle is ChainlinkClient {

uint256 public price;

address owner_;
address private oracle;
bytes32 private jobId;
uint256 private fee;
uint32 public defaultDuration;


/**
* Network: Kovan
* Chainlink - 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e
* Chainlink - 29fa9aa13bf1468788b7cc4a500a45b8
* Network: Binance Smart Chain Testnet
* Oracle: Chainlink - 0x3b3D60B4a33B8B8c7798F7B3E8964b76FBE1E176
* Job ID: Chainlink - 76bea30a605846cea6af93dbae70ed39
* Fee: 0.1 LINK
*/
constructor() public {
owner_ = msg.sender;
setPublicChainlinkToken();
oracle = 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e;
jobId = "29fa9aa13bf1468788b7cc4a500a45b8";
oracle = 0x3b3D60B4a33B8B8c7798F7B3E8964b76FBE1E176;
jobId = "76bea30a605846cea6af93dbae70ed39";
fee = 0.1 * 10 ** 18; // 0.1 LINK
defaultDuration = 60 * 60 * 24;
}
Expand All @@ -33,14 +36,6 @@ contract CoinPriceOracle is ChainlinkClient {
require(msg.sender == owner_,"Only the owner of the contract can use");
_;
}

function triggerRebase() external {
rebaseC.rebase(block.timestamp, supplyDelta);
}

function setRebaseC(RebaseToken addr) external onlyOwner {
rebaseC = addr;
}

function requestPriceData() external returns (bytes32 requestId)
{
Expand Down
23 changes: 23 additions & 0 deletions contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.6.8;

import "hardhat/console.sol";


contract Greeter {
string greeting;

constructor(string memory _greeting) public {
console.log("Deploying a Greeter with greeting:", _greeting);
greeting = _greeting;
}

function greet() public view returns (string memory) {
return greeting;
}

function setGreeting(string memory _greeting) public {
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
greeting = _greeting;
}
}
16 changes: 9 additions & 7 deletions MonetaryPolicy.sol → contracts/MonetaryPolicy.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
pragma solidity ^0.7.6;
pragma solidity ^0.6.8;
// SPDX-License-Identifier: MIT

import "./SafeMath.sol";
import "./SafeMathInt.sol";
import "./UInt256Lib.sol";


interface ICoinPriceOracle {
function price() external returns (uint256 price)
function price() external returns (uint256 _price);
}

interface IRebaseToken {
Expand All @@ -29,6 +30,7 @@ contract MonetaryPolicy {
);

ICoinPriceOracle public coinPrice;
address owner_;
IRebaseToken public rebaseToken;

// If the current exchange rate is within this fractional distance from the target, no supply
Expand Down Expand Up @@ -95,13 +97,13 @@ contract MonetaryPolicy {

epoch = epoch.add(1);

uint256 exchangeRate = coinPriceOracle.price();
uint256 exchangeRate = coinPrice.price();

if (exchangeRate > MAX_RATE) {
exchangeRate = MAX_RATE;
}

int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate);
int256 supplyDelta = computeSupplyDelta(exchangeRate, 1);

// Apply the Dampening factor.
supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());
Expand Down Expand Up @@ -170,12 +172,12 @@ contract MonetaryPolicy {
}

constructor() public {
owner_ = msg.sender
owner_ = msg.sender;
}

function initialize(
IRebaseToken rebaseToken_,
) public initializer {
IRebaseToken rebaseToken_
) public {

// deviationThreshold = 0.05e18 = 5e16
deviationThreshold = 5 * 10**(DECIMALS - 2);
Expand Down
25 changes: 13 additions & 12 deletions Orchestrator.sol → contracts/Orchestrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* - BSC LINK faucet: https://linkfaucet.protofire.io/bsctest
*/

pragma solidity ^0.7.6;
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.8;

import "https://raw.githubusercontent.com/smartcontractkit/chainlink/develop/evm-contracts/src/v0.6/ChainlinkClient.sol";
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";

interface IMonetaryPolicy {
function triggerRebase() external
function triggerRebase() external;
}

interface ICoinPriceOracle {
function requestPriceData() external returns (bytes32 requestId)
function requestPriceData() external returns (bytes32 requestId);
}

contract Orchestrator is ChainlinkClient {
Expand All @@ -28,16 +29,16 @@ contract Orchestrator is ChainlinkClient {
uint256 public lastRebaseTimestampSec;

/**
* Network: Kovan
* Oracle: Chainlink - 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b
* Job ID: Chainlink - 982105d690504c5d9ce374d040c08654
* Network: Binance Smart Chain Testnet
* Oracle: Chainlink - 0x3b3D60B4a33B8B8c7798F7B3E8964b76FBE1E176
* Job ID: Chainlink - 76bea30a605846cea6af93dbae70ed39
* Fee: 0.1 LINK
*/
constructor() public {
owner_ = msg.sender;
setPublicChainlinkToken();
oracle = 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b;
jobId = "982105d690504c5d9ce374d040c08654";
oracle = 0x3b3D60B4a33B8B8c7798F7B3E8964b76FBE1E176;
jobId = "76bea30a605846cea6af93dbae70ed39";
fee = 0.1 * 10 ** 18; // 0.1 LINK
defaultDuration = 60 * 60 * 24;
defaultCoinPriceLead = 60 * 5;
Expand Down Expand Up @@ -66,7 +67,7 @@ contract Orchestrator is ChainlinkClient {

function initialRebaseRequest(uint256 durationInSeconds) external onlyOwner returns (bytes32 requestId)
{
Chainlink.Request memory request = buildChainlinkRequest(jobId, this, this.fulfill.selector);
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfillRebase.selector);
if(lastRebaseTimestampSec == 0){
lastRebaseTimestampSec = block.timestamp;
}
Expand All @@ -77,7 +78,7 @@ contract Orchestrator is ChainlinkClient {

function rebaseRequest() private returns (bytes32 requestId)
{
Chainlink.Request memory request = buildChainlinkRequest(jobId, this, this.fulfillRebase.selector);
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfillRebase.selector);
require(lastRebaseTimestampSec != 0, "lastRebaseTimestampSec not initialized");
lastRebaseTimestampSec = lastRebaseTimestampSec + defaultDuration;
request.addUint("until", lastRebaseTimestampSec);
Expand All @@ -87,7 +88,7 @@ contract Orchestrator is ChainlinkClient {
// must not be called before calling rebaseRequest
function coinPriceRequest() private returns (bytes32 requestId)
{
Chainlink.Request memory request = buildChainlinkRequest(jobId, this, this.fulfillPriceQuery.selector);
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfillPriceQuery.selector);
require(lastRebaseTimestampSec != 0, "lastRebaseTimestampSec not initialized");
// schedules coin price retrieval defaultCoinPriceLead seconds before rebase
request.addUint("until", lastRebaseTimestampSec - defaultCoinPriceLead);
Expand Down
6 changes: 4 additions & 2 deletions RebaseToken.sol → contracts/RebaseToken.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
pragma solidity ^0.7.6;
pragma solidity ^0.6.8;
// SPDX-License-Identifier: MIT

import "./SafeMath.sol";
import "./SafeMathInt.sol";


contract RebaseToken {
string public name = "ALPHONE";
string public symbol = "ALP";
Expand Down Expand Up @@ -45,7 +47,7 @@ contract RebaseToken {
_;
}

constructor() public {
constructor() public {
owner_ = msg.sender;
}

Expand Down
3 changes: 2 additions & 1 deletion SafeMath.sol → contracts/SafeMath.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.7.6;
pragma solidity ^0.6.8;
// SPDX-License-Identifier: MIT

/**
* @title SafeMath
Expand Down
3 changes: 2 additions & 1 deletion SafeMathInt.sol → contracts/SafeMathInt.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.7.6;
pragma solidity ^0.6.8;
// SPDX-License-Identifier: MIT

/**
* @title SafeMathInt
Expand Down
3 changes: 2 additions & 1 deletion UInt256Lib.sol → contracts/UInt256Lib.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity 0.7.6;
pragma solidity 0.6.8;
// SPDX-License-Identifier: MIT

/**
* @title Various utilities useful for uint256.
Expand Down
4 changes: 4 additions & 0 deletions contracts/test/LinkToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;

import "@chainlink/token/contracts/v0.6/LinkToken.sol";
Loading