Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
myenv/
node_modules/
package-lock.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "foundry/lib/forge-std"]
path = foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
3 changes: 3 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}
29 changes: 29 additions & 0 deletions contracts/core/stablecoin/Stablecoin.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

// Importing the necessary libraries
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // Importing the ERC20 standard from OpenZeppelin
import "@openzeppelin/contracts/access/Ownable.sol"; // Importing the Ownable contract from OpenZeppelin

/**
* @title Stablecoin
* @dev Implementation of the algorithmic stablecoin with dynamic stability mechanism
*/
contract Stablecoin is ERC20, Ownable {
// State variables of the contract
uint256 public pegTarget; // The target peg value for the stablecoin
uint256 public collateralRatio; // Dynamic collateral ratio

// Events
event Mint(address indexed user, uint256 amount); // Event emitted when new stablecoins are minted
event Burn(address indexed user, uint256 amount); // Event emitted when stablecoins are burned

// Constructor to initialize the stablecoin
constructor(string memory name, string memory symbol, uint256 initialPegTarget) ERC20(name, symbol) Ownable(msg.sender) {
pegTarget = initialPegTarget; // Set the initial peg target
collateralRatio = 100; // Set the initial collateral ratio to 100%
}

// TODO: Core functionality to be implemented
}
22 changes: 22 additions & 0 deletions contracts/governance/GovernanceToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

// Import necessary libraries
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // Import ERC20 standard for token implementation
import "@openzeppelin/contracts/access/Ownable.sol"; // Import Ownable contract for ownership management

/**
* @title GovernanceToken
* @dev Token used for governance in the stablecoin ecosystem
*/
contract GovernanceToken is ERC20, Ownable {
// Voting power mapping
mapping(address => uint256) public votingPower;

// Constructor to initialize the token
constructor(string memory name, string memory symbol) ERC20(name, symbol) Ownable(msg.sender){
// TODO: Initial token distribution logic
}

// TODO: Implement voting and governance functions
}
16 changes: 16 additions & 0 deletions contracts/oracle/OracleAggregator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/**
* @title OracleAggregator
* @dev Aggregates price data from multiple oracles
*/
contract OracleAggregator {
// TODO: State variables for the contract

// Function to get the validated price from multiple oracles
function getValidatedPrice() external view returns (uint256) {
// TODO: Implement logic to aggregate prices from oracles
return 0; // Placeholder return value
}
}
43 changes: 43 additions & 0 deletions foundry/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

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
run: |
forge test -vvv
id: test
16 changes: 16 additions & 0 deletions foundry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compiler files
cache/
out/

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

# Docs
docs/

# Dotenv file
.env

README.md
9 changes: 9 additions & 0 deletions foundry/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[profile.default]
solc_version = "0.8.28"
fuzz_runs = 1000
verbosity = 3
src = "../contracts"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions foundry/lib/forge-std
Submodule forge-std added at 3b20d6
25 changes: 25 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
version: "0.8.28",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},

networks: {
hardhat: {},
localhost: {
url: "http://127.0.0.1:8545",
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
};
5 changes: 5 additions & 0 deletions mythril.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"remappings": [
"@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/"
]
}
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "algorithmic-stablecoin-with-governance",
"version": "1.0.0",
"description": "An algorithmic stable coin that integrates a hybrid collateral system, decentralized oracle aggregation, and an adaptive governance model",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"dev": "npx hardhat node",
"deploy": "npx hardhat run scripts/deploy.js --network localhost",
"lint": "solhint 'contracts/**/*.sol'"
},
"keywords": [
"stablecoin",
"defi",
"blockchain",
"ethereum",
"governance"
],
"author": "Srivatsav Erramilli",
"license": "MIT",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"hardhat": "^2.22.19",
"solhint": "^5.0.5"
},
"dependencies": {
"@openzeppelin/contracts": "^5.2.0"
}
}
Loading