How usepicnic/picnic-contracts works
Project type and purpose
• This repo (“defibasket-contracts”) is a Solidity-based smart-contract codebase for DeFi Basket, a blockchain portfolio-sharing platform. It provides on-chain components (core contracts + bridge adapters) plus off-chain tooling (Hardhat, scripts, tests, CI/CD).
File structure
• Top-level directories & files:
• contracts/ – Solidity code subdivided into:
– bridges/ – one adapter per external DeFi protocol (Aave, Compound, Curve, Uniswap, etc.)
– interfaces/ – interface definitions for external protocols
– libraries/ – shared helper libraries
– tests/ – contract unit tests
• scripts/ – TypeScript scripts for deployment, utility actions via Hardhat
• test/ – end-to-end and bridge-specific tests
• hardhat.config.ts, tsconfig.json, package.json – project configuration
• .github/workflows – CI pipelines (compile, lint, slither, test)
• audits/ – third-party security reports
Extract additional insights from the README
• Built with Hardhat + Solidity v0.8.6
• Contracts expose a developer-API (see documentation)
• A modular “bridge” pattern: core contract calls out to protocol-specific adapters
Main components & their interactions
a. On-chain components:
• CoreController (DeFiBasket central logic & registry)
• BridgeRegistry (maps strategy IDs to bridge contracts)
• Bridge Adapters (one per external protocol)
• Shared Libraries (math, asset helpers)
• Interfaces (contract ABIs for Aave, Compound, etc.)
b. Off-chain components:
• Hardhat environment (compiler, network simulation)
• Deployment & utility scripts (scripts/*.ts)
• Test harness (test/*, contracts/tests/)
• CI/CD workflows (.github/workflows)
c. External on-chain services:
• Aave, Compound, Curve, Uniswap, etc. – each bridge invokes their on-chain contracts
Architectural patterns & design principles
• Adapter pattern: one Bridge contract per external protocol, unified by a common interface
• Registry/factory: dynamic lookup of supported bridges in the core contract
• Separation of concerns: core logic vs. protocol-specific logic vs. libraries
• Immutable deployment scripts & extensive test coverage for safety