Skip to content

Commit b6691e3

Browse files
authored
Update README.md
1 parent 24555b4 commit b6691e3

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

contracts/README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# DPMC – Dynamic Price Modeling Concept (On-Rails Sale)
2+
3+
> **On-rails token release** that prices by the **integral** of a pre-announced curve, mirrors a **decaying reward**, and streams a fixed share of every purchase to the **Fund** and **Global Shareholding** (plus optional referrers). Built with [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts) and [PRBMath](https://github.com/PaulRBerg/prb-math).
4+
5+
---
6+
7+
## Overview
8+
9+
**DPMC** sells a fixed `saleSupply` of ERC-20 tokens along a continuous price curve while releasing supply **only** when buyers pay for it.
10+
It prevents oversupply and hype dumps by **throttling circulating supply to real demand** and routing a programmable cut of each purchase into ecosystem treasuries (Fund & Shareholding).
11+
12+
- **Contract:** `DPMC.sol` (Solidity ^0.8.20)
13+
- **Dependencies:**
14+
- OpenZeppelin 4.9.x
15+
- PRBMath 4.0.x (UD60x18 fixed-point)
16+
- **Standards:** Ownable2Step, Pausable, ReentrancyGuard
17+
18+
---
19+
20+
## Economics
21+
22+
Let progress be `x ∈ [0,1]`, where:
23+
24+
x = tokensSold / saleSupply
25+
26+
27+
**Price curve**
28+
29+
p(x) = P0 + (P1 - P0) * (1 - exp(-K * x))
30+
31+
**Reward curve (mirror)**
32+
33+
r(x) = R0 * (1 - x^ALPHA) // e.g. sqrt mirror when ALPHA = 0.5e18
34+
35+
**ETH charged** (integral pricing):
36+
37+
ETH = saleSupply * ( I(x1) - I(x0) )
38+
39+
I(x) = P0*x + (P1-P0) * ( x - (1 - exp(-Kx)) / K )
40+
41+
42+
---
43+
44+
## Why this matters
45+
46+
-**Fair to whales & minnows:** everyone pays the curve integral.
47+
-**No oversupply:** supply only mints against real paid demand.
48+
-**Early premium:** lower price + higher reward for early buyers.
49+
-**On-chain value capture:** Fund + Shareholding streams are automatic.
50+
-**DAO-ready:** parameters can be locked; ownership belongs to timelock/governor.
51+
52+
---
53+
54+
## Key Features
55+
56+
- Continuous **exponential price ramp** + mirrored **reward decay**.
57+
- **Integral pricing** using PRBMath UD60x18.
58+
- **Revenue rails** to Fund / Shareholding / Referrer (configurable).
59+
- Safe: **Pausable**, **ReentrancyGuard**, **Ownable2Step**.
60+
- View helpers for UIs:
61+
- `price(x)` → price at progress `x`
62+
- `rewardFactor(x)` → reward factor at progress `x`
63+
64+
---
65+
66+
## Contract Interface
67+
68+
### Public state
69+
- `token` → ERC20 sold
70+
- `saleSupply` → total allocated to DPMC
71+
- `tokensSold` → current progress
72+
- `P0, P1, K, R0, ALPHA` → curve parameters (UD60x18)
73+
- `fundTreasury`, `shareholdingTreasury`, `fundBps`, `shareBps`, `referrerBps`
74+
- `paramsLocked` → freeze status
75+
76+
### User flows
77+
- `buy()` / `buyWithRef(address)` (payable ETH)
78+
- `price(uint256 x_ud)` → wei per token at progress `x`
79+
- `rewardFactor(uint256 x_ud)` → reward multiplier at `x`
80+
81+
### Admin
82+
- `pause()` / `unpause()`
83+
- `updateRails(fund, share, fundBps, shareBps, refBps)`
84+
- `updateCurve(P0,P1,K,R0,ALPHA)` (only before lock)
85+
- `lockParams()` → freeze economics
86+
- Rescue functions: `rescueERC20()`, `rescueETH()`
87+
88+
---
89+
90+
## Parameters & Tuning
91+
92+
| Param | Description | Example |
93+
|---------|------------------------------------|-------------|
94+
| `P0` | Initial price (wei per token) | `1e14` (0.0001 ETH) |
95+
| `P1` | Target price (wei per token) | `1e16` (0.01 ETH) |
96+
| `K` | Steepness (higher = faster ramp) | `0.05e18` |
97+
| `R0` | Initial reward factor | `0.50e18` (50%) |
98+
| `ALPHA` | Reward decay power | `0.5e18` (sqrt) |
99+
100+
**Rails:**
101+
- `fundBps` → % to Fund Treasury (e.g., 300 = 3.00%)
102+
- `shareBps` → % to Shareholding (e.g., 200 = 2.00%)
103+
- `referrerBps` → % to optional referrer
104+
105+
---
106+
107+
## Install / Build
108+
109+
### Remix (zero setup)
110+
- Paste `DPMC.sol` into Remix.
111+
- Compiler: **0.8.20**, Optimizer: **ON (200)**.
112+
- Imports raw GitHub URLs (OZ 4.9.6, PRBMath 4.0.2).
113+
114+
### Local (Hardhat/Foundry)
115+
```bash
116+
npm install @openzeppelin/contracts @prb/math
117+
# or
118+
yarn add @openzeppelin/contracts @prb/math
119+
120+
Update imports to use package paths:
121+
122+
import "@openzeppelin/contracts/access/Ownable2Step.sol";
123+
import "@prb/math/src/UD60x18.sol";
124+
import "@prb/math/src/ud60x18/Math.sol";
125+
126+
127+
Deploy
128+
129+
DPMC(
130+
address token,
131+
uint256 saleSupply, // e.g. 1_000_000e18
132+
uint256 P0_weiPerToken,
133+
uint256 P1_weiPerToken,
134+
uint256 K_ud,
135+
uint256 R0_ud,
136+
uint256 ALPHA_ud,
137+
address fundTreasury,
138+
address shareholdingTreasury
139+
)
140+
141+
Steps:
142+
143+
Deploy with chosen parameters.
144+
145+
Transfer sale tokens into the contract.
146+
147+
Configure rails if needed.
148+
149+
Call lockParams() to freeze.
150+
151+
Transfer ownership to DAO timelock.
152+
153+
154+
Funding the Sale
155+
156+
The contract must hold enough tokens to cover saleSupply + rewards.
157+
A safe start: saleSupply * (1 + R0)
158+
159+
KPIs to Track
160+
161+
Progress % = tokensSold / saleSupply
162+
163+
DEX spread = DEX price – DPMC price
164+
165+
Fund & Shareholding inflows (ETH)
166+
167+
Reward emitted (cumulative)
168+
169+
Adoption velocity (time to 25% / 50% / 75%)
170+
171+
Unique buyers & repeat purchases
172+
173+
Security Notes
174+
175+
Sale uses Pausable + ReentrancyGuard.
176+
177+
No mint: contract only transfers pre-funded tokens.
178+
179+
Binary search solver capped at 60 iterations → ~1e-18 precision.
180+
181+
Always lock params and DAO-control ownership after setup.
182+
183+
License
184+
185+
MIT © Modulexo
186+
187+
Attribution:
188+
189+
OpenZeppelin Contracts 4.9.x
190+
191+
PRBMath 4.0.x
192+
193+
Please keep attribution and share improvements via PRs.

0 commit comments

Comments
 (0)