Smart contract that connects a treasury to various liquidity pools and DeFi protocols, allowing for the management of funds through different platforms. The contract facilitates receiving stable coins, distributing them among protocols, swapping for different tokens, and calculating aggregated percentage yields.
The objective is to create a smart contract that connects a treasury to multiple DeFi protocols and liquidity pools, enabling the following capabilities:
- Receiving stable coins (e.g., USDC) into the treasury smart contract.
- Dynamic distribution of funds among different liquidity pools and DeFi protocols.
- Swapping received funds for other tokens such as USDT or DAI through platforms like Uniswap.
- Interaction with the Aave protocol to deposit DAI.
- Flexible adjustment of fund distribution ratios by the contract owner post deployment.
- Calculation of the aggregated percentage yield across all integrated protocols.
- Utilization of third-party services like Beefy Finance for enhanced functionalities.
- Install
NodeJS
project dependencies:
npm install
- You should use this guide, in your
ETH_FORK_URL
I recommend using a Mainnet fork
- Launch a local Hardhat node (automatically takes over the
URL
ofETH_FORK_URL
) - it is Mainnet forked:
- In another terminal window run the command:
npx hardhat node
- In your principal terminal window run the command:
npx hardhat run scripts/deployTreasury.js --network hardhat
or
npx hardhat run scripts/deployTreasury.js --network mumbai
The Smart Contract provides the following functions:
depositStableCoin
: Deposit stable coins into the treasury.adjustDistributionRatios
: Dynamically change the allocation ratios for different protocols.swapTokens
: Swap funds between stable coins and other tokens using Uniswap.depositToAave
: Deposit DAI into the Aave protocol.withdrawFromAave
: Withdraw DAI from the Aave protocol.calculateAggregatedYield
: Calculate the combined percentage yield from all integrated protocols.
Ensure the robustness of the Smart Contract by running the test suite:
npx hardhat test
- You can see the complete document and flow diagram here:
Has been deployed on the Polygon Mumbai testnet. You can interact with the contract at the following address:
Deployed Contract Address: Treausry Contract Address