This repository contains Solidity smart contracts for vaults, token sale and token vesting.
- VaultFactory: Deploys vault instances as clones of a single vault implementation (OpenZeppelin
Clones) and wires each vault with the shared License, Oracle, Scoring, Staking and Treasury contracts. It also tracks deposit tokens and keeps a registry of all deployed vaults. - Vault: An
ERC4626-based vault (Initializable, deployed as a clone) that accepts deposits from an entity and its depositors, swaps between the deposit token and the protocol token through Uniswap, and interacts with Scoring, Staking and Treasury during its lifecycle. - License: Handles license applications and approvals for entities, including KYB verification through Quadrata and collecting application and monthly fees.
- Treasury: Holds and manages collateral in the protocol token, tracks borrowed amounts per entity and enforces the required collateral percentage.
- Scoring: Calculates an entity score from token collateral, reputation, financial health and market condition, and keeps a history of past scores.
- Staking: A reward-per-block staking contract for the protocol token, used to distribute part of vault funds to stakers.
- Oracle: Reads the protocol token price from a Uniswap V3 pool using a TWAP over a configurable time window.
- TokenSale: Runs the public sale of the token in rounds, accepting ETH, USDC and USDT, pricing purchases through a Chainlink price feed and forwarding vesting schedules to the vesting contract.
- TokenVesting: Creates and tracks vesting schedules with a cliff and linear release, and lets recipients claim unlocked tokens.
- Solidity: 0.8.27, with the optimizer and
viaIRenabled. - Hardhat Framework: development, testing and deployment.
- OpenZeppelin Contracts: access control and token standards for the sale and vesting contracts.
- OpenZeppelin Contracts Upgradeable:
Initializableand a bundledERC4626Upgradeableused by the vault clones. - Uniswap V2/V3: swaps inside the vaults and TWAP pricing in the oracle.
- Chainlink: price feed used by the token sale.
- Quadrata: KYB verification used by the license contract.
- Unit Tests: TypeScript tests for the sale, vesting and vault contracts, with coverage via
.solcover.js.
- Clone the repository.
- Install dependencies using
npm install. - Create a
.envfile from.env.exampleand fill it in. - Compile the smart contracts using
npx hardhat compile. - Run tests using
npx hardhat test. - Check coverage using
npx hardhat coverage. - Deploy using
npx hardhat run scripts/deployVaults.ts --network arbitrumSepolia(orscripts/deploySale.ts,scripts/deployVesting.ts), witharbitrumSepoliaorarbitrumas the network.