Skip to content

GLV pool #39

Description

@shivasai780
/**
 * @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);

     }
}


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

reviewReview is used by var/core contributor in order to finalise it before even deploytestnet function

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions