### Copy Environment Example File Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Copies the example environment file to .env. This file should then be configured with your specific settings, such as node URLs. ```shell cp .env.example .env ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Installs all project dependencies using Yarn. Run this command in the root folder after cloning the repository. ```shell yarn install ``` -------------------------------- ### Install Foundry Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Installs the Foundry blockchain development toolkit. Requires reopening the shell after execution. ```shell curl -L https://foundry.paradigm.xyz | bash # Reopen shell foundryup ``` -------------------------------- ### Deploy MgvReader Script Example Source: https://github.com/mangrovedao/mangrove-core/blob/develop/script/README.md This script deploys an MgvReader contract. It demonstrates the use of `innerRun` for core logic and `outputDeployment` for reporting the deployment. Environment variables are used to specify contract addresses. ```Solidity // SPDX-License-Identifier: MIT // This script is SmallMgvReaderDeployer.s.sol pragma solidity ^0.8.13; import {Mangrove} from "@mgv/src/core/Mangrove.sol"; import {MgvReader} from "@mgv/src/periphery/MgvReader.sol"; import {Deployer} from "@mgv/script/lib/Deployer.sol"; import "@mgv/forge-std/console.sol"; contract SmallMgvReaderDeployer is Deployer { TestToken public myToken; function run() public { innerRun({mgv: Mangrove(envAddressOrName("MGV_GOVERNANCE","MgvGovernance"))}); outputDeployment(); } function innerRun(Mangrove mgv) public { broadcast(); reader = new MgvReader({mgv: address(mgv)}); fork.set("MgvReader", address(reader)); } } ``` -------------------------------- ### Install Node.js using NVM Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Installs Node.js LTS version using Node Version Manager (nvm). Recommended for Linux and macOS. ```shell curl -o- https://raw.githubusercontent.com/nvm/nvm/v0.39.1/install.sh | bash # Reopen shell nvm install --lts ``` -------------------------------- ### Install Mangrove Core as Foundry Dependency Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Use this command to install the mangrove-core package as a dependency in your Foundry project. Note the remapping behavior for internal dependencies. ```shell forge install mangrovedao/mangrove-core ``` -------------------------------- ### Set Custom Addresses Paths via Environment Variable Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Overrides default address paths by setting the MGV_ADDRESSES_PATHS environment variable. This example sets a single custom path and disables default path reading. ```shell export MGV_ADDRESSES_PATHS='{ "addresses_paths": ["/addresses/"] }' export MGV_READ_ADDRESSES_PATHS=false ``` -------------------------------- ### Build the Project Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Compiles the project's Solidity contracts and related assets. ```shell yarn build ``` -------------------------------- ### Run Tick-Ratio Conversion Tests Source: https://github.com/mangrovedao/mangrove-core/blob/develop/test-ratios/README.md Execute this command to run the tests that verify the `ratioFromTick` and `tickFromRatio` functions. The tests take about 1 minute to complete. ```bash yarn test-ratios ``` -------------------------------- ### Generate Reference Ratios Source: https://github.com/mangrovedao/mangrove-core/blob/develop/test-ratios/README.md Run this command to generate the reference (ratio, tick) pairs used in the tests. This process takes approximately 5 minutes. ```bash yarn generate-ratios ``` -------------------------------- ### Mangrove v2 Contract Inheritance Hierarchy Source: https://github.com/mangrovedao/mangrove-core/blob/develop/src/AUDIT_TRAIL_2.md Illustrates the inheritance structure of the Mangrove v2 smart contracts, showing the relationships between different modules like MgvCommon, MgvHasOffers, and AbstractMangrove. ```text HasMgvEvents │ │ │ MgvCommon │ ┌────────────────┴──────────────────┐ │ │ MgvHasOffers │ │ │ ┌───────────┴──────────┐ ┌──────┴──────┐ │ │ │ │ MgvOfferTaking MgvOfferMaking MgvGovernable MgvView │ │ │ │ │ │ └──────┬──────┘ MgvOfferTakingWithPermit │ │ │ │ │ └───────────┬──────────┘ │ │ │ │ │ AbstractMangrove │ │ │ ▼ ▼ Mangrove MgvAppendix ``` -------------------------------- ### Clone Git Repository with Submodules Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Clones the mangrove-core repository and initializes all its submodules. Alternatively, set global git config for recursive cloning. ```shell git clone --recurse-submodules https://github.com/mangrovedao/mangrove-core.git ``` -------------------------------- ### Broadcasting Transactions with Private Keys Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md The `Deployer` contract's `broadcast()` function simplifies broadcasting transactions by reading the chain-specific private key from environment variables (e.g., `MUMBAI_PRIVATE_KEY`). It falls back to using a CLI-provided key if no environment variable is found. ```Solidity broadcast() ``` -------------------------------- ### Code Transformation Commands Source: https://github.com/mangrovedao/mangrove-core/blob/develop/src/AUDIT_TRAIL.md A series of shell commands using 'ruplacer' to transform Solidity code, followed by 'forge fmt' for formatting. These commands are used to update contract references and syntax between different versions. ```bash ruplacer ', P,' ', MgvStructs,' --go ruplacer 'P}' 'MgvStructs}' --go ruplacer 'Pack.post.sol" as P' 'Structs.post.sol" as MgvStructs' --go ruplacer 'P\.(.+?)\.t' '${1}' --go ruplacer 'P\.(.+?)Struct' '${1}Unpacked' --go ruplacer 'MgvLib as ML' 'MgvLib' --go ruplacer 'ML' 'MgvLib' --go ruplacer cancelations cancellations --go ruplacer 'offer book' 'order book' --go ruplacer availale available --go FOUNDRY_FMT_TAB_WIDTH=2 FOUNDRY_FMT_INT_TYPES="short" FOUNDRY_FMT_NUMBER_UNDERSCORE="th ousands" forge fmt ruplacer 'P\.(.+?)\.pack' 'MgvStructs.${1}.pack' --go FOUNDRY_FMT_TAB_WIDTH=2 FOUNDRY_FMT_INT_TYPES="short" FOUNDRY_FMT_NUMBER_UNDERSCORE="th ousands" forge fmt ``` -------------------------------- ### Default Addresses Configuration Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Specifies the default paths for reading and writing contract addresses. Addresses are read from npm packages like mangrove-deployments and context-addresses. ```json { "addresses_paths": ["addresses/"], "deployment_addresses_path": "addresses/" } ``` -------------------------------- ### Executing Forge Scripts Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Use `forge script` to execute arbitrary smart contract functions locally. Calls within these scripts, when preceded by the `vm.broadcast()` cheatcode, can be broadcast to a remote node. ```Shell forge script ``` -------------------------------- ### Enable Corepack for Yarn 2 Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Enables Corepack, the Node.js package manager package manager, to manage Yarn versions. Requires Node.js >= 16.10. ```shell corepack enable ``` -------------------------------- ### Debugging with Console Logs in Solidity Source: https://github.com/mangrovedao/mangrove-core/blob/develop/README.md Use `console.log` within Solidity contracts for debugging purposes. These logs are preserved even when a transaction reverts. Refer to Foundry's documentation for more details on console logging. ```Solidity string memory s = "Hello"; uint n = 31; console.log("Message %s number %d",s,d); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.