smfang / ECM

https://ecomonitor.xyz
0 stars 0 forks source link

Vault Contract: A vault used to take the forward tokens #51

Open smfang opened 11 months ago

smfang commented 11 months ago

Description The vault holds the balance of the forward token. The buyer can deposit ETH or USDC to the vault and receive shares of the vault that represent the % of the total ETH or USDC pool they own.

Buyers can choose to deposit the stablecoin or USDC into a vault contract to provide liquidity for the forward carbon credits or spot carbon credits. The deposit will be deposited to forward carbon pools to receive passive yield and liquidty fees. i) Users deposit USDC or ETH into the FWD vault ii) Users mint certificates proving their share in the vault

iii) Funds are used to provide liquidity to carbon credit pools as liquidity provider

iv) Vault funds will be deployed directly carbon liquidity pool and to purchase debt tokens financing carbon sequestration projects ranging from junior to senior tranche (i.e. Real World Asset pools). Contract will stream payment to liquidity pool.

Requirements

  1. Hold the actual balance of the forward token
  2. The amount of the tokens are adjusted automatically (frozen) base on data service inputs
  3. Token balance can be queried
  4. Each project (with an NFT) has an individual vault
  5. Vault share representing the value of the input funds are issued to buyers
    1. Note: this allow user to buyers to just put in an amount for credits

Vault Reference: Enzyme: https://app.enzyme.finance/discover/vaults?currency=ETH

Vault Function: `// SPDX-License-Identifier: MIT pragma solidity ^0.8.17;

contract Vault { address payable public owner; uint256 public feePercent = 10; c lockDuration = 86400; // duration in seconds (1 day) }

constructor() {
    owner = payable(msg.sender);
}

contract Vault {
mapping(address => uint256) public balances;

}

contract Vault {

constructor() {
    owner = payable(msg.sender);
}

function deposit() public payable {
    require(msg.value > 0, "Amount must be positive");
    uint256 fee = (msg.value * feePercent) / 100;
    address payable ownerPayable = owner;
    ownerPayable.transfer(fee);
    uint256 depositAmount = msg.value - fee;
    balances[msg.sender] += depositAmount;
}

}

contract Vault {

function checkBalance() public view returns (uint256) {
    return balances[msg.sender];
}

}

contract Vault {

function changeOwner(address payable newOwner) public {
    require(msg.sender == owner, "Only owner can change it");
    owner = newOwner;
}

}

contract Vault {

function ownerWithdraw(uint256 amount) public payable {
    require(msg.sender == owner, "Only owner can withdraw");
    require(balances[owner] >= amount, "Not enough balance");
    owner.transfer(amount);
    balances[owner] -= amount;
}

}

contract {

function releaseAmount() public payable {
    require(block.timestamp >= lockDuration, "Amount is still locked");
    require(balances[msg.sender] > 0, "Balance is low to withdraw");
    payable(msg.sender).transfer(balances[msg.sender]);
    balances[msg.sender] = 0;
}

}`

smfang commented 11 months ago

@VGabriel45 , this is in reference to the vault contract that we discussed in the chat.

smfang commented 11 months ago

Also, I want to confirm the ERC20 tokens can be frozen based on the updated amount from F6?

VGabriel45 commented 11 months ago

@smfang Is this a new feature request ? From what I understand you want to add this Vault into the project ? I'm confused because this is in issues

VGabriel45 commented 11 months ago

Also, I want to confirm the ERC20 tokens can be frozen based on the updated amount from F6?

An amount of tokens cannot be frozen, the whole token contract can be frozen if anything bad happens. Based on the updated amount from F6 we can decrease/increase token supply from contract.

smfang commented 11 months ago

@VGabriel45 , Re: Vault, yes it is a feature request. The rationale/use case is to enable user who just want to support a project and profit off the appreciation for these type of environmental assets through a green or biodiversity vault.