This repository contains smart contracts for the Aegis protocol.
Before running tests, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/your-repo/aegis-contracts.git cd aegis-contracts -
Install dependencies:
yarn install
-
Create a
.envfile based on the example (if not already present):cp .env.example .env
To run all tests in the test suite:
yarn testTo run specific test files, use the following command:
npx hardhat test test/StYUSD.test.jsTo generate a test coverage report:
npx hardhat coverageThe coverage report will be available in the coverage/ directory.
If you encounter errors related to ethers API changes like:
TypeError: Cannot read properties of undefined (reading 'AddressZero')
This is due to the ethers library upgrade from v5 to v6. The API has changed in several ways:
ethers.constants.AddressZero→ethers.ZeroAddressethers.utils.parseEther()→ethers.parseEther()ethers.constants.MaxUint256→ethers.MaxUint256ethers.utils.keccak256()→ethers.keccak256()ethers.utils.toUtf8Bytes()→ethers.toUtf8Bytes()
Also, contract deployment and interaction patterns have changed:
contract.deployed()→contract.waitForDeployment()contract.address→await contract.getAddress()
To fix these issues in test files:
- Search for any usage of the old API
- Replace with the corresponding new API methods
- For JavaScript files, no type changes are needed
- For TypeScript files, you may need to update type imports as well
If tests are failing with errors like:
TypeError: sYusd.connect(...).stake is not a function
This indicates that the contract interface has changed. The current contract implementation might not include certain functions that the tests are trying to call. To fix:
- Review the current contract implementation in
contracts/sYUSD.sol - Update tests to use the functions that exist in the contract
- For ERC4626 implementations, use standard functions like:
- Use
deposit()instead of customstake() - Use
withdraw()instead of customunstake() - Use
previewDeposit()orconvertToShares()for exchange calculations
- Use
The test directory contains the following test files:
1_deploy_contracts.spec.ts- Tests for contract deployments2_yusd.spec.ts- Tests for the YUSD token functionality3_aegis_minting_admin.spec.ts- Tests for AegisMinting admin functions4_aegis_minting.spec.ts- Tests for AegisMinting core functionality5_aegis_minting_mint.spec.ts- Tests for AegisMinting mint operations6_aegis_minting_redeem.spec.ts- Tests for AegisMinting redeem operations7_aegis_rewards.spec.ts- Tests for the AegisRewards contract8_aegis_oracle.spec.ts- Tests for the AegisOracle contract9_aegis_config.spec.ts- Tests for the AegisConfig contractStYUSD.test.js- Tests for the sYUSD (Staked YUSD) token
For detailed information about deploying and testing cross-chain YUSD transfers using LayerZero, see:
📖 Cross-Chain Deployment Guide
If you encounter issues running tests:
- Make sure your Node.js version is compatible (v16+)
- Try deleting
node_modules,cache, andartifactsdirectories and reinstalling dependencies - Verify that your
.envfile contains the necessary values - Check the Solidity compiler version in
hardhat.config.tsmatches the pragma in your contracts
To check for linting errors:
npx eslint .To format your code:
npx prettier --write "**/*.{js,ts,sol}"This project is licensed under the MIT License - see the LICENSE file for details.