Yield Dex L1 is an advanced platform designed to streamline Layer 2 (L2) financial requests and responses. It integrates various contracts to facilitate smooth operations between different blockchain layers and financial strategies. Below is an improved overview of its components:
- Pooling Manager (
PoolingManager.sol.sol
): Acts as a central hub, interfacing between bridges, StarkNet Core, and various financial strategies. - Error Library (
lib/ErrorLib.sol
): A dedicated library containing comprehensive error naming conventions, enhancing error tracking and debugging. - Messaging Library (
lib/Messaging.sol
): Provides utility functions for efficient communication with bridges and StarkNet core scripts. - Strategy Base Contract (
strategies/StrategyBase.sol
): An abstract contract serving as a foundational template for developing custom financial strategies. - Uniswap V3 Strategy (
uniswap/uniswapV3.sol
): Implements a strategy for swapping between an underlying asset and a yield token using Uniswap V3. - Uniswap V3 with Different Decimals Strategy (
uniswap/uniswapV3DiffDecimals.sol
): A variant of the Uniswap V3 strategy, tailored for assets with differing decimal places. - Saving Dai Strategy (
savingDai/savingDai.sol
): Manages deposits and withdrawals in a saving Dai contract, focusing on Dai stablecoin operations.
Ensure your system meets the following requirements:
- Node.js: Version 12 or later. Download Node.js
- Package Manager: Either Yarn or npm. Install Yarn | Install npm
Follow these steps to set up the Yield Dex L1 environment:
Install Dependencies: Run the following command in your terminal to install the necessary packages:
yarn
For deploying your contracts with Hardhat-Deploy, use the following command:
Before running the above commands, make sure to set up your environment variables. Change the .env.example file to .env and update the values file in the root directory of your project and fill it as per the example provided in .env.example :
ALCHEMY_RPC_URL=<Your Alchemy Key>
PRIVATE_KEY=<Your Private Key>
NETWORK=goerli
STRATEGY_NAME=sdai
ALCHEMY_RPC_URL: Your project ID from Infura, used to connect to Ethereum networks.
PRIVATE_KEY: Your Ethereum private key, used for transactions and contract deployment.
NETWORK: The network id, can be sepolia
, goerli
or mainnet
STRATEGY_NAME: The strategy name you want to deploy, required by ./setup.sh
Duplicate the .env.example
and rename it to .env
file and update the envs.
To compile the smart contracts, use the following command:
yarn hardhat compile
Run the tests to verify the correct functioning of the contracts:
yarn hardhat test
To run deployment scripts or any other custom scripts, use:
yarn hardhat run <script-path> --network <chosen-network>
Scripts are located in the scipts folder.
For deploying your contracts with Hardhat-Deploy, use the following command:
- Core contracts (PoolingManager)
yarn hardhat deploy --network ${NETWORK} --deploy-scripts deploy/core
- Deploy Mock contracts (testnet only)
yarn hardhat deploy --network ${NETWORK} --deploy-scripts deploy/mocks
- Deploy sDAI strategy
yarn hardhat deploy --network ${NETWORK} --deploy-scripts deploy/strategies/sdai
This command will execute the deployment scripts using Hardhat-Deploy, deploying your contracts to the specified network.
You can build a new strategy building contract inheriting from StrategyBase.sol, you'll need to override virtual methods and add potential additional logic related to the strategy you want to build. 2 built strategies are proposed as exemples savingDai.sol and uniswapV3.sol
Inside the deploy/strategies folder, implement the logic to deploy your strategy. Then update the STRATEGY_NAME
with the path of your strategy. For example, to deploy sDAI STRATEGY_NAME=sdai
then run:
To register the strategy, update the config file config.json
. For example for sdai
{
...
"sdaiStrategy": {
"strategy": "0x2fbbaf2b56D4bC8adEc9563b680097F9bbA02B23",
"underlying": "0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844",
"bridge": "0xaB00D7EE6cFE37cCCAd006cEC4Db6253D7ED3a22"
}
}
it's important to have such naming <startegyname>Strategy
. Then run the script
When you are done with the setup run the following script to deploy and setup your strategy
./setup.sh