Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Celo Mainnet RPC URL
CELO=https://celo-mainnet.g.alchemy.com/v2/YOUR_API_KEY
# Ethereum Mainnet RPC URL
ETH=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
run: forge build

- name: Run tests
run: forge test
run: ./bin/test
env:
ARBITRUM_RPC: $${{ secrets.ARBITRUM_RPC}}
ARBITRUM_RPC: ${{ secrets.ARBITRUM_RPC }}
MAINNET_RPC: ${{ secrets.MAINNET_RPC }}
ETH: ${{ secrets.MAINNET_RPC }}
CELO: ${{ secrets.CELO_RPC }}
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ crytic-export/
.VsCodeCounter/

# Foundry
out/
out/
cache/
broadcast/
cache/solidity-files-cache.json
.env

# Local / generated
*.log
MIGRATION_COMPLETE.md
68 changes: 58 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Yield Protocol Vault v2
# Manager

The Yield Protocol Vault v2 is a Collateralized Debt Engine for zero-coupon bonds, loosely integrated with [YieldSpace Automated Market Makers](https://yield.is/Yield.pdf), as described by Dan Robinson and Allan Niemerg.
A collateralized debt vault that issues tokenized, synthetic treasury bills on ERC-20 based foreign currencies.

**Now deployed on Celo!** 🌴 See [CELO_MIGRATION.md](./CELO_MIGRATION.md) for migration details and deployment guide.

## Smart Contracts

Expand Down Expand Up @@ -63,22 +65,68 @@ $ yarn coverage
```

### Test
Be sure to have an `.env` file located at `packages/foundry` with the value `MAINNET_RPC=<your rpc url>` to be used for forked tests.

Compile and test the smart contracts with [Foundry](https://getfoundry.sh/):
#### Environment Setup
Create a `.env` file with RPC URLs for both Ethereum and Celo:

```bash
ETH=https://eth-mainnet.g.alchemy.com/v2/YOUR_ETH_API_KEY
CELO=https://celo-mainnet.g.alchemy.com/v2/YOUR_CELO_API_KEY
PRIVATE_KEY=0x... # For deployments
GOVERNANCE=0x... # Governance address
```
$ cd packages/foundry
$ forge test
```

Additional tests can be run with Hardhat using npm or yarn:
#### Run Tests
Compile and test the smart contracts with [Foundry](https://getfoundry.sh/):

```bash
# Load environment variables
source .env

# Run all tests (fast dev profile recommended)
./bin/test

# Run only Ethereum fork tests
./bin/test --match-path "src/test/oracles/Chainlink*.sol"

# Run only Celo fork tests
./bin/test --match-path "src/test/oracles/VariableIR*.sol"

# Run specific test with verbose output
./bin/test --match-contract MentoSpotOracleTest -vvv
```
$ cd packages/hardhat
$ npm run hardhat:test

**Performance Tip**: Use `./bin/test` (defaults to the dev profile) for fast compilation (~1-2s instead of 120s+).

See [src/test/README.md](./src/test/README.md) for comprehensive testing documentation.

### Deploy

#### Celo Deployment
Deploy to Celo mainnet:

```bash
source .env
forge script script/DeployMinimalCeloSystem.s.sol \
--rpc-url $CELO_RPC_URL \
--broadcast \
--slow \
-vvvv
```

**Deployed Contracts** (Chain ID: 42220):
- Cauldron: `0xdf9ce55F0389341221c70BbCe171bF5ab983c21F`
- Ladle: `0x71dc46418a0b368618999FEd7fC1237a7720E662`
- Witch: `0xdF4Bc5bef2aAeF3D78ad0B9369f39C5ABdBe081E`
- MentoOracle: `0xD89cF4B4c739a0100FC96d2Ab0167A081cc2bCEB`
- cKES Join: `0xA1f65d6B7FC4ABB1f7331cBBD441E478fb76E164`
- USDT Join: `0xCA12b75Bf6fb0A76b3B8D7Ed805071dBF6221A7d`
- fyUSDT: `0x8d0c33Bf1CEbE94109dd10632dd4D03096cDDe7e`

**Config**: cKES collateral, USDT debt, 150% ratio, 1M max debt. Oracle configured with cKES/USD (Mento) at 600s maxAge, 0.003-0.015 bounds.

**Idempotent**: Set env vars (`CAULDRON`, `LADLE`, etc) to reuse existing contracts. Script validates reused oracles and skips already-configured assets.

## Bug Bounty
Yield is offering bounties for bugs disclosed to us at [security@yield.is](mailto:security@yield.is). The bounty reward is up to $500,000, depending on severity. Please include full details of the vulnerability and steps/code to reproduce. We ask that you permit us time to review and remediate any findings before public disclosure.

Expand Down
53 changes: 53 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail

export FOUNDRY_PROFILE="${FOUNDRY_PROFILE:-dev}"

if [[ -z "${ETH:-}" && -n "${ETH_RPC_URL:-}" ]]; then
export ETH="${ETH_RPC_URL}"
fi

needs_celo=0
if [[ "$#" -eq 0 ]]; then
needs_celo=1
else
for arg in "$@"; do
if [[ "$arg" == *VariableIR* ]] || [[ "$arg" == *tether* ]] || [[ "$arg" == *Celo* ]] || [[ "$arg" == *CELO* ]]; then
needs_celo=1
break
fi
done
fi

if [[ -z "${ETH:-}" ]]; then
echo "ERROR: ETH RPC is required. Set ETH (or ETH_RPC_URL) to an Ethereum mainnet RPC URL." >&2
exit 1
fi

if [[ -z "${CELO:-}" && -n "${CELO_RPC_URL:-}" ]]; then
export CELO="${CELO_RPC_URL}"
fi

if [[ "$needs_celo" -eq 1 && -z "${CELO:-}" ]]; then
echo "ERROR: CELO RPC is required for Celo fork tests. Set CELO (or CELO_RPC_URL) to a Celo mainnet RPC URL." >&2
exit 1
fi

if [[ "$#" -eq 0 ]]; then
suite_desc="all (includes Celo fork tests)"
else
if [[ "$needs_celo" -eq 1 ]]; then
suite_desc="filtered (includes Celo fork tests)"
else
suite_desc="filtered (no Celo fork tests)"
fi
fi

echo "Running tests: suite=${suite_desc}"
if [[ "$needs_celo" -eq 1 ]]; then
echo "RPCs: ETH=${ETH} CELO=${CELO}"
else
echo "RPCs: ETH=${ETH}"
fi

exec forge test "$@"
Loading