Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Sep 8, 2024
1 parent c8aa2da commit 99054c1
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 61 deletions.
135 changes: 102 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,135 @@
## Foundry
# Yieldnest Cross-Chain Contracts

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
This project contains the smart contracts and scripts for deploying cross-chain Yieldnest tokens using LayerZero technology. It leverages the Foundry development toolkit for testing, building, and deploying contracts, and uses Yarn to manage dependencies.

Foundry consists of:
## Project Overview

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
This repository includes:

## Documentation
- **Smart Contracts**: Contracts for Yieldnest's cross-chain tokens.
- **Deployment Scripts**: Scripts for deploying and configuring the contracts across multiple chains.
- **Testing Framework**: Tests using Foundry's Forge tool.

### Key Contracts and Scripts

- **Main Contracts**:
- `L2YnERC20Upgradeable.sol`: Layer 2 upgradeable ERC20 token contract.
- `ImmutableMultiChainDeployer.sol`: Handles multi-chain deployment of contracts.
- `L1YnOFTAdapterUpgradeable.sol`: Adapter for Layer 1 OFT (Omnichain Fungible Token).
- `L2YnOFTAdapterUpgradeable.sol`: Adapter for Layer 2 OFT.

- **Deployment Scripts**:
- `DeployMultiChainDeployer.s.sol`: Deploys the `ImmutableMultiChainDeployer`.
- `DeployL2OFTAdapter.s.sol`: Deploys the Layer 2 ERC20 token and OFT Adapter.
- `DeployL1OFTAdapter.s.sol`: Deploys the Layer 1 OFT Adapter.
- `SetPeersOFTAdapter.s.sol`: Configures peer relationships between the OFT adapters.

## Prerequisites

- **Foundry**: A fast, portable, and modular toolkit for Ethereum development.
- **Yarn**: Dependency management tool used in this project.
- **Solidity**: For developing smart contracts.

## Installation

### 1. Clone the Repository

```bash
git clone https://github.com/yieldnest/yieldnest-cross-chain.git
cd yieldnest-cross-chain
```

https://book.getfoundry.sh/
### 2. Install Dependencies

This project uses `yarn` to manage dependencies

```bash
yarn install
```

## Usage

### Build

```shell
$ forge build
To build the project, use the following command. This will compile all Solidity contracts:

```bash
yarn build
```

### Compile

You can compile contracts using Foundry's `forge`:

```bash
forge compile
```

### Test

```shell
$ forge test
Run the tests with the following command:

```bash
forge test -vvv
```

The `-vvv` flag provides verbose output for more detailed test results.

### Format

```shell
$ forge fmt
You can format your Solidity code using:

```bash
forge fmt
```

### Deploy

To deploy one of the main scripts (e.g., `DeployMultiChainDeployer`), use the following pattern:

```bash
forge script script/DeployMultiChainDeployer.s.sol:DeployMultiChainDeployer \
--rpc-url ${rpc} --sig "run(string calldata)" ${path} \
--account ${deployerAccountName} --sender ${deployer} \
--broadcast --etherscan-api-key ${api} --verify
```

Replace `DeployMultiChainDeployer` with the desired contract name for other scripts.

### Gas Snapshots

```shell
$ forge snapshot
To generate gas usage reports for the contracts, run:

```bash
forge snapshot
```

### Anvil

```shell
$ anvil
You can use Anvil, the local Ethereum testnet, with:

```bash
anvil
```

### Deploy
## Project Structure

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```
- `src/`: Contains the core smart contracts for the project.
- `script/`: Contains deployment scripts for the contracts.
- `test/`: Contains tests for the contracts, utilizing Forge.
- `deployments/`: Contains deployment artifacts and configuration files for different environments.
- `foundry.toml`: Foundry configuration file.
- `package.json`: Yarn configuration file for managing dependencies.
- `remappings.txt`: Foundry remappings for import resolution.

### Cast
## Linting

```shell
$ cast <subcommand>
```
This project uses `husky` for Git hooks and `forge fmt` for Solidity file formatting. Pre-commit hooks are set up using `lint-staged` to automatically format `.sol` files on commit.

### Help
## Documentation

```shell
$ forge --help
$ anvil --help
$ cast --help
```
For more information on Foundry and how to use it, please refer to the [Foundry Book](https://book.getfoundry.sh/).

## License

This project is licensed under the MIT License.
4 changes: 0 additions & 4 deletions deployments/ImmutableMultiChainDeployer-17000.json

This file was deleted.

15 changes: 0 additions & 15 deletions deployments/L2OFTAdapter-17000.json

This file was deleted.

5 changes: 0 additions & 5 deletions deployments/MainnetImplementations-17000.json

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"main": "index.js",
"repository": "https://github.com/yieldnest/yieldnest-cross-chain",
"scripts": {
"build": "yarn install && forge install && forge build",
"build": "yarn install && forge build",
"compile": "forge compile",
"format": "forge fmt --root .",
"test": "forge test -vvv",
Expand Down
2 changes: 1 addition & 1 deletion src/L2YnOFTAdapterUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract L2YnOFTAdapterUpgradeable is OFTAdapterUpgradeable, AccessControlUpgrad
// @dev In NON-default OFT, amountSentLD could be 100, with a 10% fee, the amountReceivedLD amount is 90,
// therefore amountSentLD CAN differ from amountReceivedLD.

// @dev Default OFT burns on src. Requires approval.
// @dev OFT burns on src. Requires approval.
IMintableBurnableERC20(address(innerToken)).burnFrom(_msgSender(), amountSentLD);
}

Expand Down
2 changes: 0 additions & 2 deletions src/factory/ImmutableMultiChainDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {RateLimiter} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/utils/Ra
import {IImmutableMultiChainDeployer} from "@interfaces/IImmutableMultiChainDeployer.sol";
import {L2YnOFTAdapterUpgradeable} from "@/L2YnOFTAdapterUpgradeable.sol";
import {L2YnERC20Upgradeable} from "@/L2YnERC20Upgradeable.sol";
import "forge-std/console.sol";

contract ImmutableMultiChainDeployer is IImmutableMultiChainDeployer {
/// @notice Emitted when a new contract is deployed
Expand Down Expand Up @@ -68,7 +67,6 @@ contract ImmutableMultiChainDeployer is IImmutableMultiChainDeployer {
address _proxyController,
bytes memory _l2YnOFTAdapterBytecode
) public override returns (address deployedContract) {
console.log(msg.sender);
bytes memory _constructorParams = abi.encode(_token, _lzEndpoint);
bytes memory _contractCode = abi.encodePacked(_l2YnOFTAdapterBytecode, _constructorParams);
bytes memory _initializeArgs =
Expand Down

0 comments on commit 99054c1

Please sign in to comment.