Venus Protocol Oracle — Solidity smart contract project using Hardhat.
This is a DeFi protocol handling real funds. Always write clean, secure code — never apply quick patches or workarounds without understanding all side effects. Verify the impact of every change across the codebase. Every task deserves the same level of rigour; nothing should be treated as low priority or left at low quality. Never assume — if in doubt, ask and confirm before proceeding.
Use yarn — never use npm.
yarn install # install dependenciesyarn compile # compile contracts (regular + zksync)
yarn build # full build (tsc + hardhat compile + copy artifacts)
yarn test # compile + run all tests
npx hardhat test <file> # run a specific test file
yarn lint # ESLint + Prettier + Solhint check
yarn prettier # auto-format code
yarn docgen # generate contract docs# Requires FORK=true + FORKED_NETWORK + ARCHIVE_NODE_<network> in .env
FORK=true FORKED_NETWORK=bscmainnet npx hardhat test test/fork/<test-file>.tsyarn deploy:testnet # deploy to BSC testnet
yarn configure:testnet # configure on BSC testnet
npx hardhat --network <network> deploy --tags <tag> # targeted deploy
yarn verify # Etherscan verificationcontracts/
├── interfaces/ # All contract interfaces
├── lib/ # Shared libraries
├── oracles/ # Individual oracle implementations
│ └── common/ # Shared oracle base contracts
├── test/ # Test-only contracts (mocks)
├── DeviationBoundedOracle.sol
├── ReferenceOracle.sol
└── ResilientOracle.sol
test/
├── fork/ # Fork-based integration tests (FORK=true)
├── utils/ # Test helpers
└── <OracleName>.ts # Unit tests per oracle (mirrors contracts/oracles/)
deploy/ # Hardhat-deploy scripts (numbered, run in order)
deployments/ # Hardhat-deploy artifacts per network (git-tracked)
networks/ # Network-specific deployment addresses (mainnet.json)
helpers/ # TypeScript deployment helpers
artifacts/ # Compiled ABIs & artifacts (NOT git-tracked)
If tests exist and code changes are made: make the code change first, then immediately ask the user if you should update the tests before touching them.
The core is ResilientOracle.sol — aggregates prices from up to 3 configured sources (MAIN, PIVOT, FALLBACK) per asset with BoundValidator deviation checks. Individual oracle contracts fetch prices from external sources (Chainlink, Binance, staking protocols, etc.).
ResilientOracle.sol— Main entry point; routes price requests, applies bound validationBoundValidator.sol— Validates price deviation ratio between two oracle sourcesDeviationBoundedOracle.sol— Wraps an oracle and reverts if price deviates beyond threshold vs a referenceReferenceOracle.sol— Simple oracle wrapper for reference price comparisoncontracts/oracles/— All individual oracle implementations (Chainlink, Binance, OneJump, ERC4626, Pendle, LST/LRT oracles, etc.)
All oracle contracts implement OracleInterface (getPrice(address asset)).
Mainnets: bscmainnet, ethereum, arbitrumone, opmainnet, opbnbmainnet, zksyncmainnet, basemainnet, unichainmainnet
Testnets: bsctestnet, sepolia, arbitrumsepolia, opsepolia, opbnbtestnet, zksyncsepolia, basesepolia, unichainsepolia
ZkSync uses a separate config: hardhat.config.zksync.ts
Requires archive node URLs in .env for fork tests (see .env.example):
ARCHIVE_NODE_bscmainnet=https://...
ARCHIVE_NODE_ethereum=https://...
- Solidity
^0.8.25, OpenZeppelin upgradeable contracts (UUPS pattern) - Tests use
@defi-wonderland/smockfor mocking andloadFixturefor snapshot isolation - Commit messages follow conventional commits (enforced by commitlint + husky)
- Prettier: 120 char width, double quotes (single quotes for Solidity), sorted imports
- Solhint enforces Solidity style (
.solhint.json) - Deploy scripts are numbered and tagged — use
--tagsto deploy selectively
- Remote: https://github.com/VenusProtocol (use
ghfor CLI access) - Deployed addresses: venus-protocol-documentation
- Related repos:
venus-protocol,isolated-pools,vips,governance-contracts