@nayms/contracts-next v1.0.2
contracts-playground
Nayms V3 smart contract repository.
Get Started
Install Foundry
curl -L https://foundry.paradigm.xyz | bashUpdate Foundry
foundryupInstall Forge dependencies
forge updateUpdate Rust, Foundry, and Forge dependencies
make updateBuild Project
In order to test the Nayms platform, first build the platforms that Nayms composes with, such as Uniswap v3:
make buniswapmake buildFormatter and Linter
Run yarn to install package.json which includes our formatter and linter. We will switch over to Foundry's sol formatter and linter once released.
Set your environment variables
Check .env.example to see some of the environment variables you should have set in .env in order to run some of the commands.
Current Directory Structure
.
├── contracts
│ ├── diamonds
│ │ ├── nayms
│ │ │ ├── facets
│ │ │ ├── interfaces
│ │ │ └── libs
│ │ └── shared
│ │ ├── facets
│ │ ├── interfaces
│ │ └── libs
│ ├── ERC20
│ └── utils
├── docs
│ └── adr
|── lib
├── scripts
├── src
│ └── test
│ └── utils
│ └── users
└── testSolidity Scripting
You can now write scripts with Solidity.
forge script <name of script in script folder>Give a valid Alchemy Eth mainnet API key in .env ALCHEMY_ETH_MAINNET_API_KEY, then try running:
make swapNayms Deployment Flow
- Create3 Nayms system deployment contract
- Deploy all facets
- Deploy Nayms Diamond using create3 Nayms system deployment contract
- Call the method
diamondCut()from the Nayms Diamond and cut in facets. Also, in the same call with the 2nd and 3rd parameter on thediamondCut()method, pass in theInitDiamondcontract address with a signed transaction calling theinitialization()method inInitDiamond.sol. See this being done in, for example,./script/DeployNayms.s.sol.
Deploy a specific contract:
make deploy-<NETWORK_NAME> contract=<CONTRACT_NAME>NETWORK_NAME can be:
mainnet
goerli
anvil
Development Flow
Run tests using Forge
make testWe test with mainnet forking.
We have test defaults in ./test/defaults/. Defaults follow a hierarchy:
D00: Global configuration
D01: Nayms protocol deployment
D02: Testing defaults such as deploying test tokens and giving addresses starting balances
D03: Protocol level defaults such as setting Nayms internal IDs
Tests follow a hierarchy:
T01: Test defaults, deployment
T02: RBAC, Admin functions
T03: Token transfer level
T03SystemFacet - test creating entities
T04: Business functions
Tests should be fixed in order of the hierarchy (T01 first).
Output, compare gas snapshots
make gasBuild Troubleshooting Tips
In case you run into an issue of forge not being able to find a compatible version of solidity compiler for one of your contracts/scripts, you may want to install the solidity version manager svm. To be able to do so, you will need to have Rust installed on your system and with it the acompanying package manager cargo. Once that is done, to install svm run the following command:
cargo install svm-rsTo list the available versions of solidity compiler run:
svm listMake sure the version you need is in this list, or choose the closest one and install it:
svm install "0.7.6"Staging for Production Deployment Flow
Run integration tests with mainnet forking.
Ensure "initialization" of entire system.
Use deterministic deployment.
Monitor all events, Nayms Diamond transactions, mempool.
Production Flow
Helpful Links
Louper Diamond Inspector - Etherscan for Diamonds
Acknowledgements
Ramesh Nair @hiddentao
Foundry
Nick Mudge