Giter Club home page Giter Club logo

governance-token-contracts's Introduction

Voting-and-Governance

governance-token-contracts's People

Contributors

123456788940 avatar shivasai780 avatar weufounddev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

governance-token-contracts's Issues

slashedStakeWithProposal

// SPDX-License-Identifier: MIT
pragma solidity ^0.8;

import "./INT1.sol";
import "./IStaking.sol";
contract Evaluator {

Staking public stakingContract; // Reference to the staking contract
INTToken public INT;
uint totalTimechains=50 weeks;
uint public timechainDuration = 1 weeks;
uint public nextTimechainStart;
uint public selectedEvaluators;
address public owner;

struct _Evaluator {
address addr;
uint stake;
bool selected;

}

modifier onlyOwner(){
require(owner==msg.sender);
_;
}

mapping(address => _Evaluator) public evaluators;
address[] public selectedEvaluatorsQueue;

constructor(address _owner, address _INT, address _stakingContract) {
owner = _owner;
INT =INTToken(_INT);
stakingContract = Staking(_stakingContract); // Initialize the staking contract address
nextTimechainStart = block.timestamp + timechainDuration;
totalTimechains=50 weeks;
}

function takeEvaluatorRole(uint _stake) public {
uint _minStake = stakingContract.minStake(); // Get the minimum stake from the staking contract
require(!evaluators[msg.sender].selected, "evaluator not selected");
require(_stake >= _minStake, "Minimum stake not met");

require(block.timestamp <= nextTimechainStart, "Timechain ended");

require(selectedEvaluators <= 4, "Must not be more or less");
require(INT.transferFrom(msg.sender, address(this), _stake));

evaluators[msg.sender] = _Evaluator({
    addr: msg.sender,
    stake: _stake,
    selected: true
  
});

}

function addEvaluator(address evaluator) public onlyOwner{
require(msg.sender == owner, "Only owner has access");
require(evaluators[msg.sender].selected, "evaluator not selected");
selectedEvaluatorsQueue.push(evaluator);
selectedEvaluators++;
}

// Function to trigger the start of a new timechain
function startNewTimechain() public onlyOwner {
require(block.timestamp >= nextTimechainStart, "Timechain not ended yet");
totalTimechains-=1; // decrease the total timechains count
nextTimechainStart = block.timestamp + timechainDuration;
}

}

BondingStakingPool

// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract tokenSwap{
IERC20 public INT;
IERC20 public bINT;

 constructor(IERC20 _INT, IERC20 _bINT) {
     INT=_INT;
     bINT=_bINT;
 }

 function swapTokens(uint amount) external {
     require(INT.transferFrom(msg.sender, address(this), amount), "Transfer failed for INT");
     require(bINT.transfer(msg.sender, amount), "transfer failed for bINT");
 }

}

Write a Foundation Treasury Pool Smart contract

The Foundation Treasury Pool Contract is responsible for

Taking Care of investments that the committee does and investors

MintingOfInput

// SPDX-License-Identifier: MIT
pragma solidity ^0.8;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

contract USDTpeggedToken is ERC20, Ownable {
using ECDSA for bytes32;

address public reserveAddress;
mapping(address => bool) public authorizedAddresses; // Mapping of authorized addresses

constructor(address _reserveAddress) ERC20("INPUTToken", "INT") {
    reserveAddress = _reserveAddress;
    authorizedAddresses[msg.sender] = true; // Initialize the deployer as an authorized address
}

modifier onlyAuthorized() {
    require(authorizedAddresses[msg.sender], "Unauthorized address");
    _;
}

function mint(uint256 amount, bytes32 messageHash, bytes memory signature) external onlyAuthorized {
    require(amount > 0, "Amount must be greater than 0");
    require(reserveAddress != address(0), "Reserve address not set");

    address signer = messageHash.recover(signature);
    require(signer == owner(), "Invalid signature");

    _mint(msg.sender, amount);
}

function setReserveAddress(address _reserveAddress) external onlyOwner {
    reserveAddress = _reserveAddress;
}

function addAuthorizedAddress(address _address) external onlyOwner {
    authorizedAddresses[_address] = true;
}

}

testINT

// SPDX-License-Identifier: MIT
pragma solidity ^0.8;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TestINT is ERC20 {
constructor(uint256 initialSupply) ERC20("TestINT", "TINT") {
_mint(msg.sender, initialSupply * (10 ** uint256(decimals())));
}
}

multisig docs

This Solidity contract is a MultiSigWallet, which allows multiple owners to collectively manage a single wallet. The contract requires a certain number of confirmations from the owners before any transaction can be executed.

Here are the main components and functionalities of the contract:

  1. Constructor: It is the constructor of the contract. It initializes the contract by setting the initial owners and the required number of confirmations for executing a transaction.

  2. Events: The contract defines several events to track important activities such as depositing funds, submitting a transaction, confirming a transaction, revoking confirmation, and executing a transaction. These events are used to emit information about the contract state changes, and they can be listened to off-chain.

  3. Modifiers:

    • onlyOwner: A custom modifier that ensures the function can only be executed by the 75% quorum of total contract owners.
    • txExists: A custom modifier that checks if a given transaction index exists in the transactions array.
    • notExecuted: A custom modifier that verifies if a transaction with a given index has not been executed yet.
    • notConfirmed: A custom modifier that checks if the sender has not confirmed a specific transaction yet.
  4. Struct: The contract defines a struct named Transaction, which represents each transaction submitted to the contract. It contains fields such as to (recipient address), value (transaction value), data (transaction data), executed (flag to indicate if the transaction has been executed), and numConfirmations (number of confirmations received for the transaction).

  5. Mappings:

    • isOwner: A mapping that keeps track of whether an address is one of the owners of the wallet.
    • isConfirmed: A nested mapping that tracks the confirmation status of each transaction for each owner. It helps prevent duplicate confirmations.
  6. Arrays:

    • owners: An array that stores the addresses of all the owners of the wallet.
    • transactions: An array that stores all the submitted transactions.
  7. Fallback Function: The receive() function is a fallback function that allows the contract to receive usdt,usdc,DAI when FOUNDATION REVENUE POOL contract sends funds to it with providing specific function data for which minting pool the supply has to be added for. It emits a Deposit event when funds are received.

  8. Public Functions:

    • submitTransaction: Allows the devs and researchers to submit a burning transaction to the contract. The transaction details (recipient, value, and data) are provided as parameters . It emits a SubmitTransaction event .
    • confirmTransaction: Allows an 75% quorum of council members to confirm a specific transaction by providing its index. The function updates the confirmation status and emits a ConfirmTransaction event.
    • executeTransaction: Allows the 75% quorum to execute a confirmed transaction. The function verifies if the required number of confirmations is met, then executes the transaction by sending the specified amount to the recipient and calling the provided data if available. It emits an ExecuteTransaction event.
    • revokeConfirmation: Allows the 26% quorum of council members to revoke their confirmation for a specific transaction. It decreases the number of confirmations and emits a RevokeConfirmation event.
    • getOwners: Returns the array of wallet owners.
    • getTransactionCount: Returns the total number of submitted transactions.
    • getTransaction: Returns details of a specific transaction based on its index.
  9. Utility Function:

    • combineKeys: A pure function that takes an array of bytes32 values and returns a single bytes32 value by combining the keys using the keccak256/poseidon is more preferred as a hash function. This function can be used for various purposes within the contract.

Overall, the contract provides a basic implementation of a multi-signature wallet, allowing multiple owners to manage transactions with a required number of confirmations for execution.

LTV

// SPDX-License-Identifier: MIT
pragma solidity ^0.8;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract LTVexchange is Ownable {
using SafeERC20 for IERC20;

IERC20 public stablecoin;
IERC20 public INT;
uint public exchangeRate;
address public contractAddress;
mapping(address => bool) public authorizedAddresses;

event Exchange(address indexed user, uint stblAmount, uint intAmount);
event AuthorizationChanged(address indexed authorizedAddress, bool isAuthorized);

constructor(
    IERC20 _stablecoin,
    IERC20 _INT,
    uint _initialRate,
    address _ownerAddress,
    address _contractAddress
) {
    stablecoin = _stablecoin;
    INT = _INT;
    exchangeRate = _initialRate;
    contractAddress = _contractAddress;
    authorizedAddresses[_ownerAddress] = true;
}

modifier onlyAuthorized() {
    require(authorizedAddresses[msg.sender], "Unauthorized");
    _;
}

function setExchangeRate(uint newRate) external onlyOwner {
    exchangeRate = newRate;
}

function authorizeAddress(address _address, bool _isAuthorized) external onlyOwner {
    authorizedAddresses[_address] = _isAuthorized;
    emit AuthorizationChanged(_address, _isAuthorized);
}

function exchangeStablecoinForINT(uint stblAmount) external onlyAuthorized {
    uint intAmount = (stblAmount * exchangeRate) / 10**18;
    require(intAmount > 0, "Amount too low to exchange");
    stablecoin.safeTransferFrom(msg.sender, contractAddress, stblAmount);
    INT.safeTransfer(msg.sender, intAmount);
    emit Exchange(msg.sender, stblAmount, intAmount);
}

}

Burning and minting docs

The provided smart contract is called "Minting" and it facilitates the minting of a custom token. Let's break down the contract and its components:

  1. // SPDX-License-Identifier: MIT: This is a SPDX license identifier that indicates the licensing of the smart contract. In this case, the MIT license is used, which is a permissive open-source license.

  2. pragma solidity ^0.8.0;: This line specifies the version of the Solidity compiler required to compile the contract. In this case, version 0.8.0 or higher is needed.

  3. Import Statements:

    • import "@openzeppelin/contracts/access/Ownable.sol";: This imports the Ownable contract from the OpenZeppelin library. The Ownable contract provides a modifier that restricts certain functions to be callable only by the contract owner.
    • import "@openzeppelin/contracts/utils/math/SafeMath.sol";: This imports the SafeMath library from the OpenZeppelin library. The SafeMath library provides safe arithmetic operations to prevent integer overflows and underflows.
    • import "./Iint.sol";: This imports the interface Iint, which defines the function signature for the minting of the custom token. This interface will be used later in the contract.
  4. Interface:

    • interface Iint { function mint(address to, uint256 amount) external; }: This is the interface Iint, which defines a single function mint. The purpose of this interface is to interact with the external contract that implements this function for minting tokens.
  5. Contract Structure:

    • contract Minting is Ownable { ... }: The Minting contract inherits from the Ownable contract, meaning it will have the access control functionality provided by Ownable. It is a standard practice to use access control mechanisms to manage ownership and permissions within a smart contract.
  6. State Variables:

    • uint256 public immutable MaxSupply;: This variable represents the maximum supply of the custom token and is declared as immutable, meaning it can only be set during contract deployment and cannot be changed thereafter.
    • uint256 public presentSupply;: This variable keeps track of the current supply of the custom token.
    • address public immutable BurningAddress;: This variable stores the address that has permission to perform specific actions (defined by the onlyBurning modifier).
    • address public immutable WeuFoundation;: This variable stores the address of the WeuFoundation, which is granted permission to perform specific actions (defined by the onlyFoundation modifier).
    • Iint public immutable intToken;: This variable is of type Iint, representing the interface of the contract that implements the minting function.
    • address public immutable ProtocolAddress;: This variable stores the address of a protocol.
  7. Modifiers:

    • modifier onlyBurning() { ... }: This modifier restricts access to certain functions to the BurningAddress.
    • modifier onlyFoundation() { ... }: This modifier restricts access to certain functions to the WeuFoundation.
  8. Constructor:

    • constructor(uint256 _maxSupply) { ... }: This is the constructor function that is executed once during the contract deployment. It sets the MaxSupply and initializes the BurningAddress with the address of the deployer.
  9. External Functions:

    • function initialize(uint _supply, address _weuFoundation, address _intToken, address _protocol) external OnlyBurning { ... }: This function can be called by the BurningAddress to initialize various parameters of the contract, such as the MaxSupply, WeuFoundation, intToken, and ProtocolAddress.
    • function increaseMaxSupply(uint256 _supply) external onlyBurning { ... }: This function allows the BurningAddress to increase the maximum supply by a specified amount.
    • function mintSupply(uint256 _supply, address _dev) external onlyFoundation { ... }: This function allows the WeuFoundation to mint new tokens and increase the present supply.

Overall, this contract is designed to handle the minting of a custom token with controlled access to specific functions. The actual minting of tokens is done through an external contract that implements the mint function as defined in the Iint interface. The contract enforces access control through the onlyBurning and onlyFoundation modifiers, ensuring that only the designated addresses can perform certain actions.

As always, it's crucial to ensure that the interfaces and external contracts used in this contract are implemented securely and have been audited for potential vulnerabilities before deploying this contract to the mainnet or any production environment.

Create the Foundation Members Contract

This Contracts will be responsible for storing the Different category members in our Foundation

  • Technical Committee
  • Council Members
  • Research Committee
  • Variable and core contributers

GLV pool

/**
 * @title GLVault
 * @dev This contract acts as a vault for receiving and storing funds from the Burning contract for a specific protocol.
 */
pragma solidity ^0.8.16;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./IBurning.sol";
import "./IMinting.sol";

contract GLVault {
    uint public ProtocolAmount; // Mapping to store the accumulated amounts for each protocol

    address public BurningPool; // Address of the Burning contract
    address public ProtocolAddress; // Address of the associated protocol
    address public WeuFoundation; // Address of the foundation managing the contract
    address public MintingPool;//Address of the minting pool of the contract
    address public UsdUsed;//usd used in this pool

    modifier OnlyBurning() {
        require(msg.sender == BurningPool, "Only the Burning contract can call this function");
        _;
    }

    modifier OnlyWeuFoundation() {
        require(msg.sender == WeuFoundation, "Only the WeuFoundation can call this function");
        _;
    }

    /**
     * @dev Initializes the GLVault contract with necessary addresses.
     * @param _burning Address of the Burning contract.
     * @param _weuFoundation Address of the WeuFoundation.
     * @param _protocol Address of the associated protocol.
     */
    function initialize(address _burning, address _weuFoundation, address _protocol,address _usdused) external OnlyBurning {
        require(ProtocolAddress == address(0), "The Protocol is already initialized");

        WeuFoundation = _weuFoundation;
        ProtocolAddress = _protocol;
        BurningPool = _burning;
        UsdUsed = _usdused;

    }
    /**
        @dev 
     */
     function UpdateMintingAddress(address _mintingAddress)external OnlyBurning{
        require(_mintingAddress != address(0),"Mintingaddres cannot be equal to zero");
        MintingPool = _mintingAddress;
     }

    /**
       @dev Receives funds from the Burning contract for a specific protocol.
       @param _amount Amount of funds received.
       @param usdUsed Address of the USD token used for the transaction.
     */
    function ReceiveAmount(uint _amount, address usdUsed) external OnlyBurning {
        require(_amount != 0, "Amount cannot be equal to zero");
        require(IERC20(usdUsed).allowance(BurningPool, address(this)) >= _amount, "Insufficient allowance");
        
        // Transfer funds from the Burning contract to the vault
        IERC20(usdUsed).transferFrom(BurningPool, address(this), _amount);
        ProtocolAmount += _amount;
    }

    /**
        @dev Send the 1/4 amount to the burning contract
     */
     function sendamount(address _usdUsed)external OnlyBurning{
        require(_usdUsed != address(0),"The Provided address cannot be equal to zero");
        uint amounttoBeTransffered=(ProtocolAmount/4);
        IERC20(_usdUsed).transfer(BurningPool,amounttoBeTransffered);
        IMinting(MintingPool).InceaseMaxSupply(amounttoBeTransffered);
     }
     /**
        @dev Send the remaining amount to the protocol
      */

     function SendtoProtocol(address _protocolAddress)external OnlyWeuFoundation{
        require(_protocolAddress != address(0),"The Protocol address cannot be equal to zero");
        uint presentAmount=IERC20(UsdUsed).balanceOf(address(this));
        IERC20(UsdUsed).transfer(_protocolAddress,presentAmount);

     }
}


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.