Open shivasai780 opened 1 year ago
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract FoundationTreasuryPool is Ownable, ReentrancyGuard { address public treasuryWallet; uint256 public totalCollateral;
mapping(address => uint256) public protocolInvestments;
constructor(address _treasuryWallet) {
treasuryWallet = _treasuryWallet;
}
function participateInNetworkElections(uint256 amount) external nonReentrant { // Ensure the amount is valid and within 10% of the treasury pool require(amount > 0 && amount <= (totalCollateral / 10), "Invalid amount");
// Transfer |V1 GOV| tokens from the sender to this contract
require(IERC20(treasuryWallet).transferFrom(msg.sender, address(this), amount), "Transfer failed");
// Add the participant's collateral to the protocol investments
protocolInvestments[msg.sender] += amount;
}
function divertSlashedTokensToTreasury(address token, uint256 amount) external onlyOwner {
require(amount > 0, "Invalid amount");
// Transfer slashed tokens to the Treasury
IERC20(token).transferFrom(msg.sender, address(this), amount);
}
// Allow anyone to send funds in the form of stablecoins to the Treasury
event StablecoinsReceived(address, address, uint);
function sendStablecoinsToTreasury(address token, uint256 amount) external nonReentrant {
require(token != address(0), "Invalid token address");
require(amount > 0, "Invalid amount");
IERC20(token).transferFrom(msg.sender, address(this), amount);
emit StablecoinsReceived(msg.sender, token, amount);
}
}
add the function docs too
SPDX-License-Identifier: MIT
The FoundationTreasuryPool
smart contract is a decentralized financial solution designed to manage and utilize funds within a foundation or organization. It provides functionalities for participating in network elections, diverting slashed tokens to the treasury, and receiving stablecoins. This document provides a high-level description of the contract's key features and functions.
treasuryWallet
: The address of the treasury wallet where funds are managed.totalCollateral
: Total amount of collateral in the treasury.protocolInvestments
: A mapping of participant addresses to their invested amounts.constructor(address _treasuryWallet)
: Initializes the contract with the address of the treasury wallet.participateInNetworkElections(uint256 amount)
: Allows participants to invest collateral for network elections. The invested amount must be valid and within 10% of the total collateral.
divertSlashedTokensToTreasury(address token, uint256 amount)
: Allows the contract owner to divert slashed tokens to the treasury. Slashed tokens are transferred to the contract.
sendStablecoinsToTreasury(address token, uint256 amount)
: Allows anyone to send stablecoins to the treasury. Stablecoins are transferred to the contract.
StablecoinsReceived(address sender, address token, uint256 amount)
: Emitted when stablecoins are received in the treasury.FoundationTreasuryPool
contract by providing the address of the treasury wallet.participateInNetworkElections()
function to invest collateral for network elections, ensuring the amount is within the specified limits.divertSlashedTokensToTreasury()
function.sendStablecoinsToTreasury()
function.Please Check this
//**
* @title FDV - Foundation Contract
* @dev This smart contract manages funds for protocols and users, facilitating investment
* The contract is owned by an address and can only be interacted with by designated parties.
* It allows protocols to send investments, manage their funding details, and transfer amounts to a burning contract.
* Only the designated foundation (multisig)address is allowed to trigger transfers to the burning contract.
*/
pragma solidity ^0.8.16;
import "./IBurning.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract FDV is Ownable {
// Struct to store investment details for each protocol
struct Protocol {
uint Investments; // Total investments received for the protocol
uint AmountTransferred; // Total amount transferred to the burning contract
address UsdUsed; // Address of the USD token used for investments
}
mapping(address => Protocol) public Details; // Protocol-specific investment details
mapping(address => uint) public UserAmount; // User-specific received amounts
mapping (address =>uint )public SlashedAmount; //Slashed Amount
IBurning public BurningAddress; // Address of the Burning contract
address public WeuFoundation; // Address of the foundation managing the contract
// Modifier to ensure that only the foundation can execute certain functions
modifier onlyWeuFoundation() {
require(msg.sender == WeuFoundation, "Only the foundation can call this function");
_;
}
/**
* @dev Receives an investment for a protocol.
* @param _Protocol Address of the protocol sending the investment.
* @param _amount Amount of the investment.
* @param usdUsed Address of the USD token used for the investment.
*/
function ReceiveInvestment(address _protocol, uint _amount, address usdUsed) external {
require(_protocol != address(0), "Protocol address must not be zero");
require(BurningAddress.UsdUsed(usdUsed) == true, "Token is not registered");
Details[_protocol].Investments += _amount;
Details[_protocol].UsdUsed = usdUsed;
IERC20(usdUsed).transferFrom(msg.sender, address(this), _amount);
}
/**
* @dev Sets the address of the burning contract.
* @param _burningAddress Address of the burning contract.
*/
function SetBurningAddress(address _burningAddress) external onlyOwner {
require(_burningAddress != address(0), "Burning address cannot be zero");
BurningAddress = IBurning(_burningAddress);
}
/**
* @dev Receives an amount from a user.
* @param usdUsed Address of the USD token used for the transaction.
* @param _amount Amount received from the user.
*/
function ReceiveAmount(address usdUsed, uint _amount) external {
require(usdUsed != address(0), "USD address must not be zero");
require(_amount > 0, "Received amount must be greater than zero");
UserAmount[msg.sender] += _amount;
IERC20(usdUsed).transferFrom(msg.sender, address(this), _amount);
}
/**
* @dev Receives an amount from a user for slashed tokens.
* @param usdUsed Address of the USD token used for the transaction.
* @param _amount Amount received from the user.
*/
function ReceiveSlashedTokensToTreasury(address usdUsed, uint256 amount) external onlyOwner {
require(amount > 0, "Invalid amount");
SlashedAmount[UsdUsed]=amount;
// Transfer slashed tokens to the Treasury
IERC20(usdUsed).transferFrom(msg.sender, address(this), amount);
}
/**
* @dev Transfers an amount to the burning contract for a protocol.
* @param _protocol Address of the protocol to transfer funds from.
* @param _amount Amount to be transferred.
*/
function TransferToBurning(address _protocol, uint _amount) external onlyWeuFoundation {
require(_protocol != address(0), "Protocol address must not be zero");
require((_amount + Details[_protocol].AmountTransferred) <= Details[_protocol].Investments);
if (BurningAddress.getProtocolInitiated(_protocol) == true) {
IERC20(Details[_protocol].UsdUsed).approve(address(BurningAddress), _amount);
BurningAddress.addAmountToBurningPool(_protocol, _amount);
Details[_protocol].AmountTransferred += _amount;
} else {
IERC20(Details[_protocol].UsdUsed).approve(address(BurningAddress), _amount);
BurningAddress.initializeBurningPool(_protocol, Details[_protocol].UsdUsed, _amount);
Details[_protocol].AmountTransferred += _amount;
}
}
/**
* @dev Sets the address of the foundation managing the contract.
* @param _weuFoundation Address of the foundation.
*/
function setWeuFoundation(address _weuFoundation) external onlyOwner {
require(_weuFoundation != address(0), "Foundation address cannot be zero");
WeuFoundation = _weuFoundation;
}
}
check in participatory slash stake vault
The FDV
(Foundation Contract) is a Solidity smart contract designed to manage funds for investment protocols and users within a decentralized finance (DeFi) ecosystem. This contract is owned by an address and can be interacted with by designated parties. It facilitates investment processes, manages investment details for protocols, and allows the transfer of amounts to a burning contract. The contract also implements role-based access control, where only the designated foundation address is allowed to trigger specific functions.
The FDV
contract is structured into different sections, each serving a specific purpose:
Protocol
The Protocol
struct holds investment details for each protocol. It includes:
Investments
: Total investments received for the protocol.AmountTransferred
: Total amount transferred to the burning contract.UsdUsed
: Address of the USD token used for investments.BurningAddress
: Address of the Burning contract.WeuFoundation
: Address of the foundation managing the contract.onlyWeuFoundation()
: A modifier that ensures only the foundation can execute specific functions.The contract constructor initializes the contract owner, set to be the address deploying the contract.
The FDV
contract defines several functions to manage investments, transfers, and protocol-related operations:
ReceiveInvestment(address _protocol, uint _amount, address usdUsed)
This function allows protocols to send investments to the contract. It records investment details and the associated USD token. Only protocols can call this function.
SetBurningAddress(address _burningAddress)
Sets the address of the burning contract that will be interacted with for burning tokens. Only the contract owner can set this address.
ReceiveAmount(address usdUsed, uint _amount)
Receives an amount from a user and records it in the UserAmount
mapping. The user's USD token used for the transaction must be specified.
ReceiveSlashedTokensToTreasury(address usdUsed, uint256 amount)
Receives slashed tokens from the foundation and transfers them to the contract. The foundation must specify the amount and the USD token used for the transaction.
TransferToBurning(address _protocol, uint _amount)
Transfers an amount to the burning contract for a protocol. The foundation can call this function to transfer funds from a specific protocol to the burning contract. It checks whether the protocol's burning pool is initialized and interacts with the burning contract accordingly.
setWeuFoundation(address _weuFoundation)
Sets the address of the foundation managing the contract. Only the contract owner can set this address.
The FDV
contract implements role-based access control using the onlyWeuFoundation
modifier. This modifier ensures that certain functions can only be called by the designated foundation address (WeuFoundation
).
The Foundation Treasury Pool Contract is responsible for
Taking Care of investments that the committee does and investors
Need to create the function which will accept the investment From the protocol members
The investment needs to go to the burning contract with the approval of the Research members and Technical Committee
https://weu-foundation.gitbook.io/weu-foundation-website-design/governance-and-protocol-designs/governance-or-v1-or/foundation-treasury-pool-ftp