Skip to content

Updated Contracts-1 #28

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 10 commits into
base: mainnet
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
36 changes: 36 additions & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "mainnet" branch
push:
branches: [ "mainnet" ]
pull_request:
branches: [ "mainnet" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
54 changes: 34 additions & 20 deletions Burning.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./Iint.sol";

import "./Minting.sol";
import "./IMinting.sol";
import "./IGlipVault.sol";
contract TimechainProtocol is ReentrancyGuard{
// Define the structure for the protocol's Burning pool
struct BurningPool {
uint256 totalInputs;
uint256 timeChainsLeft;
mapping(uint=>mapping(uint=>uint)) slashingPercentage;//slashingpercent[number of investment][Amount]=slashpercent
mapping(uint => uint)amountStaked;
mapping(uint => uint)amountStaked;//Investment number-->amount staked
address Mintingaddress;
uint256 noOfinvestments;
address usdUsed;
uint256 startingBlock;
Expand All @@ -22,21 +25,23 @@ contract TimechainProtocol is ReentrancyGuard{
mapping(address => BurningPool) public BurningPools;

// GLIPs vault to hold the slashed INT
mapping(address => uint256) public glipsVaultAmount;
// mapping(address => uint256) public glipsVaultAmount;

address public stableCoin1;
address public stableCoin2;
address public stableCoin3;
address public stableCoin4;
address public glipsVault;
Iint public intToken;
address public owner;
constructor(address _stableCoin1,address _stableCoin2,address _stableCoin3,address _stableCoin4,address _intToken) {
address public WeuFoundation;
constructor(address _stableCoin1,address _stableCoin2,address _stableCoin3,address _intToken,address weuFoundation,address _glipsVault) {
stableCoin1 = _stableCoin1;
stableCoin2=_stableCoin2;
stableCoin3=_stableCoin3;
stableCoin4=_stableCoin4;

intToken=Iint(_intToken);
WeuFoundation= weuFoundation;
glipsVault =_glipsVault;
owner = msg.sender;
}

Expand All @@ -51,14 +56,18 @@ contract TimechainProtocol is ReentrancyGuard{
require(_totalamount != 0,"the given amount cannot be equal to zero ");
require(BurningPools[_protocolAddress].totalInputs == 0, "Burning pool already initialized");
require(BurningPools[_protocolAddress].noOfinvestments == 0,"The pool is already initialized");
require(usdUsed == stableCoin1 || usdUsed == stableCoin2 || usdUsed ==stableCoin3 || usdUsed == stableCoin4 ,"The tokem used should be any one of them");
require(usdUsed == stableCoin1 || usdUsed == stableCoin2 || usdUsed ==stableCoin3 ,"The tokem used should be any one of them");
BurningPools[_protocolAddress].totalInputs=_totalamount;
BurningPools[_protocolAddress].timeChainsLeft=50;
BurningPools[_protocolAddress].slashingPercentage[1][_totalamount]=2;
BurningPools[_protocolAddress].noOfinvestments=1;
BurningPools[_protocolAddress].amountStaked[1]=_totalamount;
BurningPools[_protocolAddress].usdUsed=usdUsed;
BurningPools[_protocolAddress].startingBlock = block.timestamp;
Minting minting=new Minting();
address contaddress=address(minting);
IMinting(minting).initialize(usdUsed, WeuFoundation, address(intToken), _protocolAddress);
BurningPools[_protocolAddress].Mintingaddress=contaddress;
//transfer the usd to this account,before that he need to give the approval for this contract
IERC20(usdUsed).transferFrom(msg.sender,address(this),_totalamount);

Expand All @@ -69,15 +78,17 @@ contract TimechainProtocol is ReentrancyGuard{
require(_protocolAddress!=address(0),"The address cannot be equal to zero address");
require(_totalamount != 0,"the given amount cannot be equal to zero ");
BurningPool storage pool = BurningPools[_protocolAddress];

require(pool.noOfinvestments != 0,"The no of investments cannot be equal to zero ");
require(pool.Mintingaddress != address(0),"The pool Haven't initialized");
// Calculate the slashing percentage for the new supply of INT
uint256 slashingPercentage = 100 / pool.timeChainsLeft;

// Update the Burning pool data with the new inputs and slashing percentage
pool.totalInputs += _totalamount;
pool.noOfinvestments +=1;
pool.amountStaked[1]=_totalamount;
pool.amountStaked[pool.noOfinvestments]=_totalamount;
pool.slashingPercentage[pool.noOfinvestments][_totalamount]=slashingPercentage;
IMinting(pool.Mintingaddress).InceaseMaxSupply(_totalamount);
IERC20(pool.usdUsed).transferFrom(msg.sender,address(this),_totalamount);

}
Expand All @@ -100,7 +111,9 @@ contract TimechainProtocol is ReentrancyGuard{
// Update the Burning pool's total inputs after slashing
pool.totalslashedAmount += slashedAmount;
// Add the slashed amount to the GLIPs vault
glipsVaultAmount[msg.sender] += slashedAmount;
// glipsVaultAmount[msg.sender] += slashedAmount;
IERC20(pool.usdUsed).approve(glipsVault,slashedAmount);
IGlipVault(glipsVault).ReceiveAmount(_protocolAddress,slashedAmount,pool.usdUsed);
// Decrease the number of timechains left
pool.timeChainsLeft -= completedTimeChains;
//send the amount to the glipsVault
Expand All @@ -116,28 +129,29 @@ contract TimechainProtocol is ReentrancyGuard{
}


function burnandClaim(uint256 amount) external nonReentrant {
function burnandClaim(address _protocol,uint256 amount) external nonReentrant {
require(amount!=0,"The address cannot be equal to zero address");
require(intToken.balanceOf(msg.sender)>= amount,"Not Sufficient Amount in your wallet");
require(IERC20(stableCoin1).balanceOf(address(this))>=amount || IERC20(stableCoin2).balanceOf(address(this))>=amount || IERC20(stableCoin3).balanceOf(address(this))>=amount || IERC20(stableCoin4).balanceOf(address(this))>=amount,"No sufficient Amount in the pool");
address currentStableCoin = findGreatest(stableCoin1, stableCoin2, stableCoin3, stableCoin4);
require(IERC20(stableCoin1).balanceOf(address(this))>=amount || IERC20(stableCoin2).balanceOf(address(this))>=amount || IERC20(stableCoin3).balanceOf(address(this))>=amount );
BurningPool storage pool = BurningPools[_protocolAddress];
require((block.timestamp - pool.startingBlock) >= 7 days,"The timechain had till not completed");
address currentStableCoin = findGreatest(stableCoin1, stableCoin2, stableCoin3);
intToken.transferFrom(msg.sender,address(this),amount);
intToken.burn(amount);
IERC20(currentStableCoin).transfer(msg.sender,amount);
}

function findGreatest(address _stableCoin1,address _stableCoin2,address _stableCoin3,address _stableCoin4) public view returns (address) {
function findGreatest(address _stableCoin1,address _stableCoin2,address _stableCoin3) public view returns (address) {
// Using if-else statements
address greatestCoin;

if ( IERC20(_stableCoin1).balanceOf(address(this))>= IERC20(_stableCoin2).balanceOf(address(this)) && IERC20(_stableCoin1).balanceOf(address(this)) >= IERC20(_stableCoin3).balanceOf(address(this)) && IERC20(_stableCoin1).balanceOf(address(this)) >= IERC20(_stableCoin4).balanceOf(address(this))) {
if ( IERC20(_stableCoin1).balanceOf(address(this))>= IERC20(_stableCoin2).balanceOf(address(this)) && IERC20(_stableCoin1).balanceOf(address(this)) >= IERC20(_stableCoin3).balanceOf(address(this)) ) {
greatestCoin = _stableCoin1;
} else if (IERC20(_stableCoin2).balanceOf(address(this)) >= IERC20(_stableCoin1).balanceOf(address(this)) && IERC20(_stableCoin2).balanceOf(address(this)) >= IERC20(_stableCoin3).balanceOf(address(this)) && IERC20(_stableCoin2).balanceOf(address(this)) >= IERC20(_stableCoin4).balanceOf(address(this))) {
} else if (IERC20(_stableCoin2).balanceOf(address(this)) >= IERC20(_stableCoin1).balanceOf(address(this)) && IERC20(_stableCoin2).balanceOf(address(this)) >= IERC20(_stableCoin3).balanceOf(address(this))) {
greatestCoin = _stableCoin2;
} else if (IERC20(_stableCoin3).balanceOf(address(this)) >= IERC20(_stableCoin1).balanceOf(address(this)) && IERC20(_stableCoin3).balanceOf(address(this)) >= IERC20(_stableCoin2).balanceOf(address(this)) && IERC20(_stableCoin3).balanceOf(address(this)) >= IERC20(_stableCoin4).balanceOf(address(this))) {
} else{
greatestCoin = _stableCoin3;
} else {
greatestCoin = _stableCoin4;
}
}

return greatestCoin;
}
Expand Down
36 changes: 36 additions & 0 deletions GlipsVault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pragma solidity ^0.8.16;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract GlipsVault{

mapping(address => uint)public ProtocolAmount;
address public BurningPool;
address public Owner;

constructor()
{
Owner=msg.sender;
}
modifier OnlyOwner()
{
require(msg.sender == Owner,"The owner needs to be msg.sender");
_;
}
modifier OnlyBurning()
{
require(msg.sender == BurningPool,"The caller needs to be the burning contract");
_;
}
function ReceiveAmount(address _protocol,uint _amount,address usdUsed)external OnlyBurning
{
require(_protocol != address(0),"The protocol address cannot be equal to address zero");
require(_amount != 0,"The amount cannot be equal to zero ");
require(IERC20(usdUsed).allowance(BurningPool,address(this))>= _amount);
IERC20(usdUsed).transferFrom(BurningPool,address(this),_amount);
ProtocolAmount[_protocol]=_amount;

}
function ChangeBurningContract(address _burningcontract)external OnlyOwner{
require(_burningcontract != address(0),"The burning contract address cannot be equal to the zero address");
BurningPool = _burningcontract;
}
}
7 changes: 7 additions & 0 deletions IBurning.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma solidity ^0.8.16;

interface IBurning
{
function initialize(uint,address,address,address)external;
function InceaseMaxSupply(uint)external;
}
7 changes: 7 additions & 0 deletions IGlipsVault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma solidity ^0.8.16;

interface IGlipVault
{
function ReceiveAmount(address,uint ,address)external;

}
7 changes: 7 additions & 0 deletions IMinting.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma solidity ^0.8.16;

interface IMinting
{
function initialize(uint,address,address,address)external;
function InceaseMaxSupply(uint)external;
}
43 changes: 35 additions & 8 deletions INTtoken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ contract INT is ERC20 {
address public weuFoundation;
address public BurningAddress;
address public Owner;
address public MintingAddress;

constructor() ERC20("INT Token", "INPUT") {
Owner = msg.sender;
}

modifier onlyWEUFoundation() {
require(msg.sender == weuFoundation, "Only WEU Foundation can perform this action");
_;
}
modifier onlyOwner() {
require(msg.sender == owner, "Only WEU Foundation can perform this action");
require(msg.sender == Owner, "Only WEU Foundation can perform this action");
_;
}
modifier onlyBurning(){
require(msg.sender == BurningAddress,"Only burning address can perform this action");
_;
}
modifier onlyMinting()
{
require(msg.sender == MintingAddress,"Only Minting address can perform this action");
_;
}

function mint(address account, uint256 amount) external onlyWEUFoundation {
function mint(address account, uint256 amount) external onlyMinting {
require(account != address(0),"The account address should not be equal to zero address");
_mint(account, amount);
}
Expand All @@ -34,12 +36,37 @@ contract INT is ERC20 {
weuFoundation = _weuFoundation;
}

function changeBurningAddress(address _burningAddress)external onlyBurning{
function changeBurningAddress(address _burningAddress)external onlyOwner{
require(_burningAddress != address(0),"The Burning address should not be equal to zero address");
BurningAddress = _burningAddress;
}
function burn(uint256 amount) external onlyBurning {
_burn(msg.sender, amount);
}

}
function transfer(address to,uint256 value)public override virtual returns(bool)
{
require(msg.sender == weuFoundation,"the caller needs to be from WeuFoundation");
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}

function transferFrom(address _from,address _to,uint256 value)public override virtual returns(bool)
{
require(msg.sender == weuFoundation || msg.sender == BurningAddress,"the caller needs to be from WeuFoundation or the burning Contract");
address spender = _msgSender();
_spendAllowance(_from, spender, value);
_transfer(_from, _to, value);
return true;
}

function approve(address spender,uint256 value)public override virtual returns(bool)
{
require(msg.sender == weuFoundation || spender == BurningAddress,"the caller needs to be from WeuFoundation or the to address needs to be the burning address");
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}

}
83 changes: 43 additions & 40 deletions Minting.sol
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract MintingPool is Ownable {
using SafeMath for uint256;

uint256 public timechain = 50;
uint256 public intToken = 1000000;
uint256 public slashPercentage = 2 * 10**6; // 2% represented as 2 * 10^6 (6 decimal places)

// Function to burn and claim INT tokens based on the minting pool algorithm
function burnAndClaim() external onlyOwner returns (uint256) {
uint256 newSupply = 2000000; // Example: New inputs added to minting pool

// Calculate the slashing percentage for the new supply
uint256 remainingTimechain = timechain.sub(5); // Assuming 5 timechain periods have passed
uint256 slashingPercentage = calculateSlashingPercentage(remainingTimechain);

// Calculate the slashing amount for each portion
uint256 slashingAmountForExisting = intToken.mul(slashPercentage).div(10*8); // Divide by 10*8 due to 6 decimal places
uint256 slashingAmountForNew = newSupply.mul(slashingPercentage).div(10*8); // Divide by 10*8 due to 6 decimal places

// Calculate the total slashed amount
uint256 totalSlashedAmount = slashingAmountForExisting.add(slashingAmountForNew);

// Update the INT token balance in the minting pool after slashing
intToken = intToken.sub(totalSlashedAmount);

// Decrease the timechain period
timechain--;

return intToken;
pragma solidity ^0.8.16;

import "./Iint.sol";


contract Minting {

uint public MaxSupply;
uint public PresentSupply;
address public BurningAddress;
mapping(address => uint) public Devamount;
address public WeuFoundation;
Iint public intToken;
address public ProtocolAddress;
modifier OnlyBurning(){
require(msg.sender == BurningAddress,"The sender needs to be burning address");
_;
}

// Function to calculate the slashing percentage for new supply based on the remaining timechain periods
function calculateSlashingPercentage(uint256 remainingTimechain) internal pure returns (uint256) {
return uint256(100 * 10*6).div(remainingTimechain); // Divide by 10*6 to get 6 decimal places
modifier OnlyFoundation(){
require(msg.sender == WeuFoundation,"The sender needs to be WeuFoundation address");
_;
}
}
constructor(){
BurningAddress = msg.sender;
}
function initialize(uint _supply,address _weuFoundation,address _intToken,address _protocol)external OnlyBurning{
require(ProtocolAddress == address(0),"The Protocol is already initialized");
MaxSupply=_supply;
WeuFoundation=_weuFoundation;
intToken=Iint(_intToken);
ProtocolAddress =_protocol;
}
function InceaseMaxSupply(uint _supply)external OnlyBurning{
require(_supply!=0,"The supply cannot be equal to zero ");
MaxSupply += _supply;
}
function mintSupply(uint _supply,address _dev)external OnlyFoundation {
require(_supply !=0 && _dev!=address(0),"The supply amount cannot be equal to zero and _dev address should not be equal to zero address");
require(MaxSupply >= (PresentSupply+_supply));
intToken.mint(_dev, _supply);
PresentSupply += _supply;
}


}