Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Show Forge version
run: |
forge --version

- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Run Forge build
run: |
forge build --sizes
id: build

- name: Run Forge tests
env:
RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
run: |
forge test -vvv
id: test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin"]
path = lib/openzeppelin
url = https://github.com/OpenZeppelin/openzeppelin-contracts.git
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate.git
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# PSM
# PSM

### Key Features

- **Direct Minting/Redemption**: Buy DOLA with collateral or sell DOLA for collateral
- **ERC4626 Vault Integration**: Collateral is automatically deposited into yield-generating vaults
- **Fed Integration**: Automated DOLA supply management through PSMFed contract
- **Configurable Fees**: Adjustable buy/sell fees to manage protocol economics
- **Profit Distribution**: Automatic profit taking from vault yields to governance
- **Vault migration**: Allows to migrate into a new vault automatically or manually via governance if some deposit or redeem limits in the vaults.

### Core Contracts

#### PSM.sol
The main contract that handles:
- DOLA buying and selling in exchange for collateral
- Collateral management through ERC4626 vaults
- Fee collection and profit distribution
- Vault migration capabilities
- Governance controls

#### PSMFed.sol
Federal Reserve-style contract for DOLA supply management:
- Mint new DOLA for PSM operations (expansion)
- Burn DOLA to reduce supply (contraction)
- Supply cap enforcement
- Chair-based monetary policy controls

#### Controller.sol
Access control layer for buy/sell operations:
- Validates transaction permissions
- Can implement custom logic for rate limiting, KYC, etc.
- Currently allows all operations (template implementation)

20 changes: 20 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[profile.default]
evm_version = "prague"
src = "src"
out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 10000
solc = "0.8.20"
remappings = [
"@openzeppelin/contracts/=lib/openzeppelin/contracts/",
"forge-std/=lib/forge-std/src/",
"openzeppelin/=lib/openzeppelin/",
"solmate/=lib/solmate/src/",
]
[rpc_endpoints]
mainnet = "${RPC_MAINNET}"
[etherscan]
mainnet = {key = "${ETHERSCAN_API_KEY}"}

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 77041d
1 change: 1 addition & 0 deletions lib/openzeppelin
Submodule openzeppelin added at be547e
1 change: 1 addition & 0 deletions lib/solmate
Submodule solmate added at c93f77
32 changes: 32 additions & 0 deletions src/Controller.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

// Warning: Contracts using this template must include require(msg.sender == PSM) for any state-mutating functions.
// Omitting this check can introduce vulnerabilities if future controllers forget to enforce it.
contract Controller {
/**
* @notice Checks if a buy operation is allowed.
* @dev This function can be modified to include specific conditions for allowing buys.
* @param amount The amount of collateral to be sold.
* @return bool Returns true if the buy operation is allowed, false otherwise.
* For now, it returns true to allow all buy operations.
*/
function onBuy(address user, uint256 amount) external returns (bool) {
user;
amount; // To avoid unused variable warning
return true;
}

/**
* @notice Checks if a sell operation is allowed.
* @dev This function can be modified to include specific conditions for allowing sells.
* @param amount The amount of DOLA to be sold.
* @return bool Returns true if the sell operation is allowed, false otherwise.
* For now, it returns true to allow all sell operations.
*/
function onSell(address user, uint256 amount) external returns (bool) {
user;
amount; // To avoid unused variable warning
return true; // For now, we allow all calls
}
}
Loading