Comments (6)
// 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);
}
}
from governance-token-contracts.
add the function docs too
from governance-token-contracts.
Foundation Treasury Pool Smart Contract
SPDX-License-Identifier: MIT
Overview
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.
Contract Details
State Variables
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
constructor(address _treasuryWallet)
: Initializes the contract with the address of the treasury wallet.
Functions
-
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.
Events
StablecoinsReceived(address sender, address token, uint256 amount)
: Emitted when stablecoins are received in the treasury.
Usage
- Deploy the
FoundationTreasuryPool
contract by providing the address of the treasury wallet. - Participants can use the
participateInNetworkElections()
function to invest collateral for network elections, ensuring the amount is within the specified limits. - The contract owner can divert slashed tokens to the treasury using the
divertSlashedTokensToTreasury()
function. - Anyone can send stablecoins to the treasury using the
sendStablecoinsToTreasury()
function.
from governance-token-contracts.
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;
}
}
from governance-token-contracts.
check in participatory slash stake vault
from governance-token-contracts.
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.
Contract Structure
The FDV
contract is structured into different sections, each serving a specific purpose:
Struct 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.
Contract Variables
BurningAddress
: Address of the Burning contract.WeuFoundation
: Address of the foundation managing the contract.
Modifiers
onlyWeuFoundation()
: A modifier that ensures only the foundation can execute specific functions.
Constructor
The contract constructor initializes the contract owner, set to be the address deploying the contract.
Contract Functions
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.
Modifiers and Role-Based Access Control
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
).
from governance-token-contracts.
Related Issues (20)
- In the burning contract we need send the slashed amount into the glip pool,so we need to create glip pool contract and send the slashed amount into that contract HOT 2
- Burning and minting docs HOT 4
- multisig docs HOT 6
- Updated mintingPool/Vault HOT 7
- SS
- SS
- Create the Foundation Members Contract HOT 3
- Create A document File For NFT Contract HOT 2
- Create a contract for session keys for V1 ( technical (3) and research committee (1) HOT 3
- GENERATE TESTNET BRANCH
- GDV pool HOT 9
- GLV pool HOT 6
- Create a pipeline system for our repositries . HOT 2
- Create a test version for erc-4973 . HOT 3
- MintingOfInput HOT 1
- LTV HOT 5
- BondingStakingPool HOT 1
- slashedStakeWithProposal HOT 7
- testINT HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from governance-token-contracts.