Skip to content

Commit 9f588f4

Browse files
committed
init simple stable
1 parent f863517 commit 9f588f4

19 files changed

+1091
-3
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
env:
9+
FOUNDRY_PROFILE: ci
10+
11+
jobs:
12+
check:
13+
name: Foundry project
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
23+
- name: Show Forge version
24+
run: |
25+
forge --version
26+
27+
- name: Run Forge fmt
28+
run: |
29+
forge fmt --check
30+
id: fmt
31+
32+
- name: Run Forge build
33+
run: |
34+
forge build --sizes
35+
id: build
36+
37+
- name: Run Forge tests
38+
run: |
39+
forge test -vvv
40+
id: test

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Simple Stable Coin
2+
3+
Demonstrates a simple-version of an overcollateralized stablecoin. This stablecoin has the following features:
4+
**NOT PRODUCTION READY**
5+
6+
1. ETH Collateralization
7+
8+
- Accepts ETH as collateral with Chainlink price feeds
9+
- 150% minimum collateralization ratio
10+
- 130% liquidation threshold
11+
12+
2. Core Functionality
13+
14+
- Mint stablecoins by depositing ETH
15+
- Repay debt to retrieve collateral
16+
- Liquidation system for undercollateralized positions
17+
18+
3. Simple Vault System
19+
20+
- One vault per user
21+
- Tracks collateral and debt amounts
22+
- Standard ERC20 implementation ("Simple USD" - sUSD)
23+
24+
Deploy:
25+
26+
```
27+
forge script script/DeployStablecoin.s.sol:DeployStablecoin --rpc-url your_rpc_url --private-key your_private_key_here --broadcast -vvvv
28+
```
29+
30+
Mint Tokens:
31+
32+
```
33+
forge script script/VaultOperations.s.sol:VaultOperations --sig "createAndMint()" \
34+
--rpc-url https://your_rpc_url \
35+
--private-key your_private_key_here \
36+
--broadcast \
37+
-vvvv
38+
```
39+
40+
Repay and Get Eth Back:
41+
42+
```
43+
forge script script/VaultOperations.s.sol:VaultOperations --sig "repayAndWithdraw(uint256)" AMOUNT_IN_WEI \
44+
--rpc-url https://your_rpc_url \
45+
--private-key your_private_key_here \
46+
--broadcast \
47+
-vvvv
48+
```
49+
50+
Check Vault Status:
51+
52+
```
53+
forge script script/VaultOperations.s.sol:VaultOperations --sig "checkLiquidation(address)" "TARGET_ADDRESS" \
54+
--rpc-url https://your_rpc_url \
55+
-vvvv
56+
```
57+
58+
Liquidate Unsafe Positions
59+
60+
```
61+
forge script script/VaultOperations.s.sol:VaultOperations --sig "liquidatePosition(address)" "TARGET_ADDRESS" \
62+
--rpc-url https://your_rpc_url \
63+
--private-key your_private_key_here \
64+
--broadcast \
65+
-vvvv
66+
```

broadcast/DeployStablecoin.s.sol/11155111/run-1750466365.json

Lines changed: 48 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployStablecoin.s.sol/11155111/run-latest.json

Lines changed: 48 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"transactions": [
3+
{
4+
"hash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
5+
"transactionType": "CALL",
6+
"contractName": null,
7+
"contractAddress": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
8+
"function": "mint()",
9+
"arguments": [],
10+
"transaction": {
11+
"from": "0x47ef3bf350f70724f2fd34206990cde9c3a6b6f0",
12+
"to": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
13+
"gas": "0x2f3f3",
14+
"value": "0x16345785d8a0000",
15+
"input": "0x1249c58b",
16+
"nonce": "0xdf",
17+
"chainId": "0xaa36a7"
18+
},
19+
"additionalContracts": [],
20+
"isFixedGasLimit": false
21+
}
22+
],
23+
"receipts": [
24+
{
25+
"status": "0x1",
26+
"cumulativeGasUsed": "0xe4c7a1",
27+
"logs": [
28+
{
29+
"address": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
30+
"topics": [
31+
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
32+
"0x0000000000000000000000000000000000000000000000000000000000000000",
33+
"0x00000000000000000000000047ef3bf350f70724f2fd34206990cde9c3a6b6f0"
34+
],
35+
"data": "0x000000000000000000000000000000000000000000000008af3215d4c11fbaaa",
36+
"blockHash": "0xa3fd188fb094b0357e741cd202127264bdd097b0ade531934c1b0e8775a52535",
37+
"blockNumber": "0x8320fd",
38+
"transactionHash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
39+
"transactionIndex": "0x66",
40+
"logIndex": "0x55",
41+
"removed": false
42+
},
43+
{
44+
"address": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
45+
"topics": [
46+
"0x78f5f4fe573a0f848b230b1151919d737f07fd52424347dbd007dd57fb906e00",
47+
"0x00000000000000000000000047ef3bf350f70724f2fd34206990cde9c3a6b6f0"
48+
],
49+
"data": "0x000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000008af3215d4c11fbaaa",
50+
"blockHash": "0xa3fd188fb094b0357e741cd202127264bdd097b0ade531934c1b0e8775a52535",
51+
"blockNumber": "0x8320fd",
52+
"transactionHash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
53+
"transactionIndex": "0x66",
54+
"logIndex": "0x56",
55+
"removed": false
56+
}
57+
],
58+
"logsBloom": "0x00000000020000000000000000000000000100000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000004000020000000000000000000800000000000000000000000010000004000000000000000000000000020000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000020000000020000000000000000800000000000000000000000000000000000000000",
59+
"type": "0x2",
60+
"transactionHash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
61+
"transactionIndex": "0x66",
62+
"blockHash": "0xa3fd188fb094b0357e741cd202127264bdd097b0ade531934c1b0e8775a52535",
63+
"blockNumber": "0x8320fd",
64+
"gasUsed": "0x2234c",
65+
"effectiveGasPrice": "0xf425f",
66+
"from": "0x47ef3bf350f70724f2fd34206990cde9c3a6b6f0",
67+
"to": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
68+
"contractAddress": null
69+
}
70+
],
71+
"libraries": [],
72+
"pending": [],
73+
"returns": {},
74+
"timestamp": 1750466498,
75+
"chain": 11155111,
76+
"commit": null
77+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"transactions": [
3+
{
4+
"hash": "0x26447d6eb9925890376d7d144b29b8d36a32519722e394bb4ea508416f3e1709",
5+
"transactionType": "CALL",
6+
"contractName": null,
7+
"contractAddress": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
8+
"function": "repay(uint256)",
9+
"arguments": [
10+
"159198129298666666666"
11+
],
12+
"transaction": {
13+
"from": "0x47ef3bf350f70724f2fd34206990cde9c3a6b6f0",
14+
"to": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
15+
"gas": "0x100d3",
16+
"value": "0x0",
17+
"input": "0x371fd8e6000000000000000000000000000000000000000000000008a1515f2119bbbaaa",
18+
"nonce": "0xe1",
19+
"chainId": "0xaa36a7"
20+
},
21+
"additionalContracts": [],
22+
"isFixedGasLimit": false
23+
}
24+
],
25+
"receipts": [
26+
{
27+
"status": "0x1",
28+
"cumulativeGasUsed": "0xda5866",
29+
"logs": [
30+
{
31+
"address": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
32+
"topics": [
33+
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
34+
"0x00000000000000000000000047ef3bf350f70724f2fd34206990cde9c3a6b6f0",
35+
"0x0000000000000000000000000000000000000000000000000000000000000000"
36+
],
37+
"data": "0x000000000000000000000000000000000000000000000008a1515f2119bbbaaa",
38+
"blockHash": "0x28ffd003a0d93a1a692cfa43cec25704f5b5167f1577b40abebc733b81984f21",
39+
"blockNumber": "0x83213c",
40+
"transactionHash": "0x26447d6eb9925890376d7d144b29b8d36a32519722e394bb4ea508416f3e1709",
41+
"transactionIndex": "0x122",
42+
"logIndex": "0xba",
43+
"removed": false
44+
},
45+
{
46+
"address": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
47+
"topics": [
48+
"0x78f5f4fe573a0f848b230b1151919d737f07fd52424347dbd007dd57fb906e00",
49+
"0x00000000000000000000000047ef3bf350f70724f2fd34206990cde9c3a6b6f0"
50+
],
51+
"data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
52+
"blockHash": "0x28ffd003a0d93a1a692cfa43cec25704f5b5167f1577b40abebc733b81984f21",
53+
"blockNumber": "0x83213c",
54+
"transactionHash": "0x26447d6eb9925890376d7d144b29b8d36a32519722e394bb4ea508416f3e1709",
55+
"transactionIndex": "0x122",
56+
"logIndex": "0xbb",
57+
"removed": false
58+
}
59+
],
60+
"logsBloom": "0x00000000020000000000000000000000000100000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000004000020000000000000000000800000000000000000000000010000004000000000000000000000000020000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000020000000020000000000000000800000000000000000000000000000000000000000",
61+
"type": "0x2",
62+
"transactionHash": "0x26447d6eb9925890376d7d144b29b8d36a32519722e394bb4ea508416f3e1709",
63+
"transactionIndex": "0x122",
64+
"blockHash": "0x28ffd003a0d93a1a692cfa43cec25704f5b5167f1577b40abebc733b81984f21",
65+
"blockNumber": "0x83213c",
66+
"gasUsed": "0xb9f0",
67+
"effectiveGasPrice": "0x7a358",
68+
"from": "0x47ef3bf350f70724f2fd34206990cde9c3a6b6f0",
69+
"to": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
70+
"contractAddress": null
71+
}
72+
],
73+
"libraries": [],
74+
"pending": [],
75+
"returns": {},
76+
"timestamp": 1750467253,
77+
"chain": 11155111,
78+
"commit": null
79+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"transactions": [
3+
{
4+
"hash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
5+
"transactionType": "CALL",
6+
"contractName": null,
7+
"contractAddress": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
8+
"function": "mint()",
9+
"arguments": [],
10+
"transaction": {
11+
"from": "0x47ef3bf350f70724f2fd34206990cde9c3a6b6f0",
12+
"to": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
13+
"gas": "0x2f3f3",
14+
"value": "0x16345785d8a0000",
15+
"input": "0x1249c58b",
16+
"nonce": "0xdf",
17+
"chainId": "0xaa36a7"
18+
},
19+
"additionalContracts": [],
20+
"isFixedGasLimit": false
21+
}
22+
],
23+
"receipts": [
24+
{
25+
"status": "0x1",
26+
"cumulativeGasUsed": "0xe4c7a1",
27+
"logs": [
28+
{
29+
"address": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
30+
"topics": [
31+
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
32+
"0x0000000000000000000000000000000000000000000000000000000000000000",
33+
"0x00000000000000000000000047ef3bf350f70724f2fd34206990cde9c3a6b6f0"
34+
],
35+
"data": "0x000000000000000000000000000000000000000000000008af3215d4c11fbaaa",
36+
"blockHash": "0xa3fd188fb094b0357e741cd202127264bdd097b0ade531934c1b0e8775a52535",
37+
"blockNumber": "0x8320fd",
38+
"transactionHash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
39+
"transactionIndex": "0x66",
40+
"logIndex": "0x55",
41+
"removed": false
42+
},
43+
{
44+
"address": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
45+
"topics": [
46+
"0x78f5f4fe573a0f848b230b1151919d737f07fd52424347dbd007dd57fb906e00",
47+
"0x00000000000000000000000047ef3bf350f70724f2fd34206990cde9c3a6b6f0"
48+
],
49+
"data": "0x000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000008af3215d4c11fbaaa",
50+
"blockHash": "0xa3fd188fb094b0357e741cd202127264bdd097b0ade531934c1b0e8775a52535",
51+
"blockNumber": "0x8320fd",
52+
"transactionHash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
53+
"transactionIndex": "0x66",
54+
"logIndex": "0x56",
55+
"removed": false
56+
}
57+
],
58+
"logsBloom": "0x00000000020000000000000000000000000100000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000004000020000000000000000000800000000000000000000000010000004000000000000000000000000020000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000020000000020000000000000000800000000000000000000000000000000000000000",
59+
"type": "0x2",
60+
"transactionHash": "0x561c9172e4b4ae6c9956897bf1c8b13b21cfc15d2b041290a52f06e63e133b7c",
61+
"transactionIndex": "0x66",
62+
"blockHash": "0xa3fd188fb094b0357e741cd202127264bdd097b0ade531934c1b0e8775a52535",
63+
"blockNumber": "0x8320fd",
64+
"gasUsed": "0x2234c",
65+
"effectiveGasPrice": "0xf425f",
66+
"from": "0x47ef3bf350f70724f2fd34206990cde9c3a6b6f0",
67+
"to": "0x8734d6f16e59f14973fb5170e0c9a1d511ea1ad1",
68+
"contractAddress": null
69+
}
70+
],
71+
"libraries": [],
72+
"pending": [],
73+
"returns": {},
74+
"timestamp": 1750466498,
75+
"chain": 11155111,
76+
"commit": null
77+
}

0 commit comments

Comments
 (0)