banner
cover

MetaBeta 期货释放合约(WIP

A

MetaBeta 期货释放合约核心想要解决的问题是,如何让处于释放状态的 MetaBeta 依然可以在市场上流通,由于每枚 MetaBeta 在不同时期剩余可被领取的 Meta 数量不同,属于非标品,因而类似于 Uniswap V3 我们使用的解决方案是,发 NFT!

和流动性挖矿合约不同的是,MetaBeta 在一旦质押旋即销毁,合约根据质押量、抵押时间,生成相应的 NFT 交给用户,该 NFT 记录了用户质押的时间以及质押的总量,合约根据此 NFT 发放剩余的 Meta 代币奖励。

    contract MetaGamma is ERC721 {
        mapping (uint256 => uint256) public total;
        mapping (uint256 => uint256) public claimed;        
    }
    
    modifier onlyNFTOwner(uint _id) {
        require(ownerOf(_id) == msg.sender, "not NFT owner");
        _;
    }

    // 销毁一定数量的 MetaBeta 生成相应 NFT
    function recast(uint _amount) external {
        require(_amount > 0, "recast amount must be greater than 0");    
        IERC20 m = IERC20(_metabeta);
        m.transferFrom(msg.sender, address(0), _amount);    
        counter = counter + 1;
        _mint(msg.sender, counter);
        total[counter] = _amount;
    }

    // 收菜
    function claim(uint _id) external onlyNFTOwner(_id) {
        IERC20 m = IERC20(_meta);        
        uint target = Math.min(block.timestamp.sub(start_timestamp).mul(unitReleaseRate).mul(total[_id]), total[_id]);
    	m.transfer(msg.sender, target.sub(claimed[_id]));
        claimed[_id] = target;
    }

This article was posted on 瞬matataki, This article uses Knowledge Sharing 署名-非商业性使用-禁止演绎 4.0 protocol Please follow the agreement to reprint

Disclaimer: This article was uploaded and published by the user "小岛美奈子", and the content is the author's independent opinion. It does not represent the position of 瞬Matataki and does not constitute investment advice. Please be cautious.

Loading...
Current price:
No price
Introduction

Nothing

Already held:

0

If you like, get a Fan ticket~

avatar
0/500
Comment0 Reward0