Git Product home page Git Product logo

muon-tokenomics-contracts's Introduction

The Muon staking system is used for adding nodes to the Muon oracle network. To find out more details about how the Muon staking system works you can see this wiki page.

Installation

To install and set up the Muon staking system, follow these steps:

  1. Clone the repository:

    git clone https://github.com/muon-protocol/muon-tokenomics-contracts.git
    
  2. Install the required dependencies:

    npm install
    

Testing

To run the tests for the Muon staking system using Hardhat, execute the following command:

npx hardhat test

This will execute the test suite and provide detailed output regarding the functionality and behavior of the contracts. or execute

REPORT_GAS=true npx hardhat test

This command will execute the test suite while also providing detailed gas consumption reports for each test case. It allows developers and auditors to analyze the gas usage of the contract functions and assess their efficiency.

Deployment

To deploy the Muon staking contracts to a specific network, ensure that the network settings are correctly configured in the deployment scripts. Then, run the deployment command:

npx hardhat run scripts/deploy.ts --network <network-name>

Replace <network-name> with the desired network identifier, such as mainnet. This will deploy the contracts to the specified network.

Please note that the deployment process may require additional configuration, such as providing the necessary account credentials or API keys for interacting with the target network.

muon-tokenomics-contracts's People

Contributors

sayaghoubnejad avatar bakhshandeh avatar 0xsullivan avatar abramsymons avatar

Watchers

 avatar Mohsen Khan-mohammad-zadeh avatar

muon-tokenomics-contracts's Issues

Add a boolean flag to enable transfer

There is no way to enable transfer for all users without upgrading the contract.
It would be good to add a Boolean flag and let the owner disable or enable public transfer.

Booster: validations

It's necessary to check if Uniswap pair tokens are USDC and PION, reserves are zero or not and also check that the boost amount is greater than zero.

Redundant inheritance

Inheritance from ERC20Upgradeable is redundant because it’s already inherited in the ERC20BurnableUpgradeable contract.

contract Token is
    Initializable,
    ERC20Upgradeable,
    ERC20BurnableUpgradeable,
    PausableUpgradeable,
    AccessControlUpgradeable
{

The same is true for ERC721.

contract BondedToken is
    Initializable,
    ERC721Upgradeable,
    PausableUpgradeable,
    AccessControlUpgradeable,
    OwnableUpgradeable,
    ERC721BurnableUpgradeable
{

Naming conventions

All state variables should be named using mixed case style like tokensWhitelist.

uint256 public _tokenIdCounter;

address public Token;

address public treasury;

address[] public tokensWhitelist;

merge and split is not possible by other contracts

We have this assertion on merge and split:

require(ownerOf(tokenIdA) == msg.sender, "Not Owned");

and only the owner of the NFT can call these functions.

There is no way to approve and let another contract call them.

( we do not need to implement it. we need to discuss and make a decision )

MuonNodeStaking: Merge amount validations in getReward()

It's better and more gas efficient to merge 3 amount validations and validate it before Muon signature verification.

function getReward(
uint256 amount,
uint256 paidRewardPerToken,
bytes calldata reqId,
SchnorrSign calldata signature
) public whenFunctionNotPaused("getReward") {
require(amount > 0, "Invalid amount.");
IMuonNodeManager.Node memory node = nodeManager.stakerAddressInfo(
msg.sender
);
require(node.id != 0, "Node not found.");
User memory user = users[msg.sender];
require(
user.paidRewardPerToken <= paidRewardPerToken &&
paidRewardPerToken <= rewardPerToken(),
"Invalid paidRewardPerToken."
);
// Verify the authenticity of the withdrawal request.
bytes32 hash = keccak256(
abi.encodePacked(
muonAppId,
reqId,
msg.sender,
user.paidReward,
paidRewardPerToken,
amount
)
);
bool verified = muonVerify(
reqId,
uint256(hash),
signature,
muonPublicKey
);
require(verified, "Invalid signature.");
uint256 maxReward = (user.balance *
(paidRewardPerToken - user.paidRewardPerToken)) /
1e18 +
user.pendingRewards;
require(amount <= maxReward, "Invalid withdrawal amount.");
notPaidRewards += (maxReward - amount);
require(amount <= earned(msg.sender), "Invalid withdrawal amount.");

Support multiple tokens in the codes

We have multiple platforms(ALICE, PION, MUON) and the code base should support all of them.

Something like this:

contract veToken{
 // existing codes
}


contract vePION is veToken{
  // customize name, symbol, ...
}

contract veALICE is veToken{
 // ...
}

Questions about Minting Reversion and PION Address Setter

I have a couple of questions regarding the current implementation of Minter:

  1. Minting Reversion: Instead of doing nothing, would it be better to revert the minting if the mintPeriod is not over yet? This would provide more transparent behaviour feedback.

  2. PION Address Setter: Could we implement a setter function for the PION address?

Optimize _beforeTokenTransfer

This is more gas efficient:

if(!isPublicTransferEnabled){
            require(
                    from == address(0) ||
                   to == address(0) ||
                    hasRole(TRANSFERABLE_ADDRESS_ROLE, from) ||
                    hasRole(TRANSFERABLE_ADDRESS_ROLE, to),
                "Transfer is Limited"
            );
}
// rest of codes

typo errors

whitelist contract address for transfering

Why not use AccessControl for transferWhitelist?

We want to grant access to a limited list of wallets and it is a good use case for AccessControl.

There could be 2 roles:

OWNER_ROLE -- no need to use Ownable anymore
TRANSFER_WHITELIST_ROLE

This seems more standard.

In the current code, there is no way to remove a wallet from the whitelist.

Bypassing transfer limit is possible

Using the split function, it is possible to transfer all of the locked tokens from tokenA to tokenB with another owner.
It is a kind of bypassing the transfer limits.

keep the contract ownable

We discussed and mentioned that there is no need to have more than one owner/manager.
Let's keep the contract ownable and use onlyOwner for the functions that are using onlyRole(MANAGER_ROLE).

So there will be only TRANSFERABLE_ADDRESS_ROLE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.