Skip to content
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

GLV pool #39

Open
shivasai780 opened this issue Aug 9, 2023 · 6 comments
Open

GLV pool #39

shivasai780 opened this issue Aug 9, 2023 · 6 comments
Assignees
Labels
review Review is used by var/core contributor in order to finalise it before even deploytestnet function

Comments

@shivasai780
Copy link
Collaborator

shivasai780 commented Aug 9, 2023

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

     }
}


@shivasai780 shivasai780 added the review Review is used by var/core contributor in order to finalise it before even deploytestnet function label Aug 9, 2023
@shivasai780
Copy link
Collaborator Author

Need to add the functionality regarding to 1/4 of amount

@WeuFoundDev
Copy link
Owner

so add it up and finalise it with docs by tommorow . will have separate v2 and v1 branch for testnet

@WeuFoundDev
Copy link
Owner

@shivasai780 when it will be done...

@shivasai780
Copy link
Collaborator Author

shivasai780 commented Aug 15, 2023

This Solidity contract, named GLV, serves as a vault for receiving and storing funds from the Burning contract for a specific protocol. The contract allows the Burning contract to deposit funds into it, tracks the accumulated amounts for different protocols, and enables the foundation to interact with certain functions. Here's a detailed breakdown of its features:

Contract Overview: The GlipsVault contract acts as an intermediary between the Burning contract, associated protocols, and a minting pool. It's used to securely manage and distribute funds for a particular protocol.

Modifiers:

OnlyBurning: This modifier ensures that only the Burning contract is allowed to call the function it's applied to.

OnlyWeuFoundation: This modifier ensures that only the specified foundation (WeuFoundation) is allowed to call the function it's applied to.
State Variables:

ProtocolAmount: A mapping that stores the accumulated amounts for each protocol. The keys are protocol addresses, and the values represent the total amount of funds received for that protocol.

BurningPool: The address of the Burning contract that is allowed to interact with this vault.

ProtocolAddress: The address of the associated protocol for which funds are being managed.

WeuFoundation: The address of the foundation that manages the contract and has permission to call certain functions.

MintingPool: The address of the minting pool contract associated with this vault.

Functions:

initialize(...): This function is used to initialize the contract with essential addresses. It can only be called by the Burning contract. It sets the addresses of the Burning contract, the associated protocol, the foundation managing the contract, and the minting pool.

ReceiveAmount(...): This function allows the Burning contract to deposit funds for a specific protocol. The protocol address, amount, and the USD token used are specified as arguments. The function checks the allowance of the contract and then transfers the funds from the Burning contract to the vault. It updates the accumulated amount for the protocol.

sendAmount(...): This function sends a quarter of the accumulated funds for the associated protocol back to the Burning contract. Additionally, it decreases the maximum minted amount in the Minting contract by the sent amount. This function helps manage the balance of funds and prevents over-minting.

The GLV contract provides a mechanism for safely handling and distributing funds between the Burning contract, protocols, and the minting pool. Its functionality is geared towards maintaining proper fund management and preventing unauthorized access to key actions.

@WeuFoundDev
Copy link
Owner

Its GLV - Generation Lineage Vault .
The last function send amount will be used for two way - when a protocol is not able to go mainnet within 50 timechain ( which means the GDV pool has a zero balance related to the protocol and minting pool also has 0 bal. , then it will allow the certain minting contract to send a request for reallocation of 1/4 funds , if approved then the funds will be send to the GDV pool and the same proportion will be added to mint from the minting pool .
You can add a function like- Bal of GDV is always proportional to minting pool .
2 . send amount will also be used to send the funds to protocol contract if the protocol is launched within 50 timechains - remaining funds will be transferred. @shivasai780

@WeuFoundDev
Copy link
Owner

hey @shivasai780 no changes being made...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Review is used by var/core contributor in order to finalise it before even deploytestnet function
Projects
None yet
Development

No branches or pull requests

2 participants