Smart Contracts For The Morpheus Network
This repository contains following smart contracts for the Morpheus Network.
MOR OFT- The Morpheus Network Token with integrated LayerZero OFT (Omnichain Fungible Token) standard.
-
DistributionV6- the basis of the previous version of the protocol (Distribution V5). Contains logic with the extension of the possibility of claiming instead of the initial staker. -
DepositPool- the basis of the previous version of the protocol (Distribution V6). Adds the ability to stake multiple tokens, changes the mechanism for calculating rewards and yield. Each stake token has its ownDepositPool -
ChainLinkDataConsumer- realizes integration with ChainLink, used for receiving the price feeds. -
L1SenderV2- takes all protocol yields fromDepositPools, converts to wstETH, and forwards to L2. -
RewardPool- the MOR reward calculation curve is in this contract. Allows to create reward pools, set curves and calculate the required number of rewards. -
Distributor- brings all the contracts together in one place for L1. Calculates rewards for users, calculates protocol yield.
L2TokenReceiverV2- A contract that receives tokens from the L1Sender contract. It is used to Uniswap market making.L2MessageReceiver- A contract that receives messages from the L1Sender contract.
BuilderSubnets- The main contract for builders, accepts user stakes, calculates rewards and gives them out.FeeConfig- The contract is responsible for the fees of the protocol.
To install the dependencies, run the following command:
npm installTo compile the contracts, use the next script:
npm run compileBefore any following steps, you need to create an .env file following the example of .env.example.
To run the tests, execute the following command:
npm run testTo run the tests for forked mainnet, run:
npm run test-forkYou need to set the
INFURA_KEYandPRIVATE_KEYenvironment variables to run the tests for forked mainnet.
Or to see the coverage, run:
npm run coverageYou need to set the
INFURA_KEYandPRIVATE_KEYenvironment variables to run the coverage.
You need to fill out config file deploy/data/config.json (yoy may choose another file name, based on the network). The example of the config file is already provided. Make sure to fill out all the fields, specifically the payoutStart field.
Next, call script located in deploy/deploy-all.sh with the following arguments:
./deploy/deploy-all.sh <L1 network> <L2 network>Where the first argument is the L1 network name and the second argument is the L2 network name.
(network is the name of the network, which should be in hardhat.config.js)
To deploy the contracts locally, run the following commands (in the different terminals):
npm run private-network
./deploy/deploy-all.sh localhost localhostThe local deployment is may fail due to the lack of third-party contracts. To fix this, you may run test deployment on the forked mainnet.
The command to generate the bindings is as follows:
npm run generate-typesSee the full list of available commands in the
package.jsonfile.