-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVERSIONS
More file actions
464 lines (365 loc) · 16.2 KB
/
VERSIONS
File metadata and controls
464 lines (365 loc) · 16.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# 📖 DAARION Smart Contract System - Version History
This document provides a comprehensive overview of the evolution of the DAARION ecosystem's core smart contracts, based on actual git commit analysis and code changes.
## 🏗️ Contract Architecture Overview
The DAARION ecosystem consists of four main upgradeable smart contracts:
1. **DAAR.sol** - ERC20 honey-backed stable token ($10 USD)
2. **DAARION.sol** - ERC20 premium utility token (scarce, cooperative access)
3. **APRStaking.sol** - Dual-token staking system with APR-based rewards
4. **DAARDistributor.sol** - DAARION staking rewards distribution system
---
## 💰 DAAR Token (DAAR.sol)
### Version 2.9 (Initial Implementation)
**Commit:** `73222fdd4d8fd140f549095c55dc9456c32df1d3` - v3.0a official release
**Date:** March 29, 2025
#### Core Features:
- **Base Architecture:** ERC20Upgradeable + UUPS proxy pattern
- **Libraries Introduced:**
- `@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol`
- `@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol`
- `@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol`
#### Key Functionality:
- Fixed supply of 8,000,000 DAAR tokens
- Backed by honey at $10 USD per token
- Upgrade authorization restricted to owner
- Standard ERC20 functionality with upgradeability
#### Technical Details:
```solidity
uint256 public constant TOTAL_SUPPLY = 8_000_000 * 10**18;
```
---
## 🔷 DAARION Token (DAARION.sol)
### Version 2.9 (Initial Implementation)
**Commit:** `73222fdd4d8fd140f549095c55dc9456c32df1d3` - v3.0a official release
**Date:** March 29, 2025
#### Core Features:
- **Base Architecture:** ERC20Upgradeable + UUPS proxy pattern
- **Libraries Used:** Same as DAAR token
#### Key Functionality:
- Fixed supply of 8,000 DAARION tokens (highly scarce)
- Premium utility token for cooperative access
- Upgrade authorization restricted to owner
- Standard ERC20 functionality with upgradeability
#### Technical Details:
```solidity
uint256 public constant TOTAL_SUPPLY = 8_000 * 10**18;
```
---
## 📈 APR Staking Contract (APRStaking.sol)
### Version 2.9 → 3.0a (Initial Implementation)
**Commit:** `73222fdd4d8fd140f549095c55dc9456c32df1d3` - v3.0a official release
**Date:** March 29, 2025
#### Core Features:
- **Base Architecture:** UUPS upgradeable contract
- **Libraries Introduced:**
- `@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol`
- `@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol`
- `@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol`
- `@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol`
- `@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol`
#### Key Functionality:
- DAARION staking to earn DAAR rewards
- Pool-based reward distribution mechanism
- Manual reward detection from contract balance changes
- Reentrancy protection
- Owner-controlled upgrade authorization
#### Technical Implementation:
```solidity
struct Stake {
uint256 amount; // Amount of DAARION staked
uint256 rewardDebt; // Reward debt (to prevent double claiming)
uint256 rewardCredit; // Accumulated rewards ready to claim
}
```
### Version 4.0 Alpha (Major Enhancement)
**Commit:** `bbe6facf68010d79b3fbe09aa23427ad526c3b2d` - v4.0 alpha release
**Date:** May 1, 2025
#### Major Changes:
- **New Library Added:** `@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol`
- **Architecture Change:** Single-token → Dual-token staking system
#### Enhanced Features:
1. **Dual Staking Pools:**
- DAARION staking (4% APR)
- DAAR staking (20% APR)
2. **Pausable Functionality:**
- Emergency pause/unpause by owner
- Prevents staking/unstaking during emergencies
3. **Separate Pool Management:**
- Independent reward calculation for each token
- Proportional reward distribution based on total staked amounts
#### Technical Implementation:
```solidity
struct StakeDAARION {
uint256 amount; // Amount of DAARION staked
uint256 rewardDebt; // Reward debt
uint256 rewardCredit; // Accumulated rewards
}
struct StakeDAAR {
uint256 amount; // Amount of DAAR staked
uint256 rewardDebt; // Reward debt
uint256 rewardCredit; // Accumulated rewards
}
uint256 public constant DAARION_APR = 400; // 4% APR
uint256 public constant DAAR_APR = 2000; // 20% APR
```
### Version 4.0 RC1 (APR Logic Enhancement)
**Commit:** `de326abb30d39fe14ed8e570873af60a8e9af43a` - v4.0rc1
**Date:** May 1, 2025
#### Major Changes:
- **APR-Based Reward Capping:** Implemented mathematical APR limits
- **Time-Based Calculations:** Added timestamp tracking for accurate APR computation
#### Enhanced Features:
1. **APR Compliance:**
- Maximum rewards capped at specified APR rates
- Time-elapsed calculations for precise reward distribution
- Excess reward reallocation between pools
2. **Mathematical Precision:**
- Seconds per year constant: `365 * 24 * 60 * 60`
- Basis points calculation (100 = 1%)
- Reward overflow protection
#### Technical Implementation:
```solidity
uint256 public lastUpdateTimestamp; // Timestamp of the last reward update
uint256 public constant SECONDS_PER_YEAR = 365 * 24 * 60 * 60;
// Calculate maximum rewards based on APR
uint256 maxDAARIONReward = (totalStakedDAARION * DAARION_APR * timeElapsed) / (10000 * SECONDS_PER_YEAR);
uint256 maxDAARReward = (totalStakedDAAR * DAAR_APR * timeElapsed) / (10000 * SECONDS_PER_YEAR);
```
### Version 4.0 Final (Staked Balance Tracking)
**Commit:** `da2931affbeec147207df1f4d999cd870cc40d54` - DAARsales added
**Date:** May 29, 2025
#### Major Changes:
- **Staked Balance Tracking:** Separated staked DAAR from reward DAAR
- **Improved Reward Calculation:** More accurate balance management
#### Enhanced Features:
1. **Balance Separation:**
- `stakedDAARBalance` tracks staked DAAR separately
- Prevents reward calculation errors
- Cleaner excess token withdrawal logic
#### Technical Implementation:
```solidity
uint256 public stakedDAARBalance; // Tracks staked DAAR balance for reward calculation
// Update staked balance on stake/unstake
stakedDAARBalance += amount; // on stake
stakedDAARBalance -= amount; // on unstake
// Reward calculation uses staked balance
uint256 reward = currentBalance > stakedDAARBalance ? currentBalance - stakedDAARBalance : 0;
```
---
## 🎯 DAAR Distributor Contract (DAARDistributor.sol)
### Version 2.9 → 3.0a (Initial Implementation)
**Commit:** `73222fdd4d8fd140f549095c55dc9456c32df1d3` - v3.0a official release
**Date:** March 29, 2025
#### Core Features:
- **Base Architecture:** UUPS upgradeable contract
- **Libraries Introduced:**
- `@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol`
- `@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol`
- `@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol`
- `@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol`
- `@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol`
#### Key Functionality:
- DAARION staking for DAAR rewards
- Automatic reward pool updates
- Balance-based reward detection
- Excess token withdrawal for wallet1
#### Technical Implementation:
```solidity
struct Stake {
uint256 amount; // Amount of DAARION staked
uint256 rewardDebt; // Reward debt
uint256 rewardCredit; // Accumulated rewards
}
function _updatePool() internal {
uint256 currentBalance = DAAR.balanceOf(address(this));
uint256 reward = currentBalance - lastRewardBalance;
if (totalStakedDAARION > 0 && reward > 0) {
accRewardPerShare += (reward * 1e12) / totalStakedDAARION;
lastRewardBalance = currentBalance;
}
}
```
### Version 4.0 Alpha (Epoch System Introduction)
**Commit:** `bbe6facf68010d79b3fbe09aa23427ad526c3b2d` - v4.0 alpha release
**Date:** May 1, 2025
#### Major Changes:
- **New Library Added:** `@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol`
- **Architecture Change:** Continuous rewards → Epoch-based distribution
#### Enhanced Features:
1. **Epoch System:**
- Time-based reward distribution periods
- Manual epoch triggering by owner
- Better reward management control
2. **Enhanced Security:**
- Pausable functionality
- Multiple token withdrawal support
- Better error handling
#### Technical Implementation:
```solidity
uint256 public epochDuration; // Duration of each epoch in seconds
uint256 public lastEpochTimestamp; // Timestamp of the last epoch distribution
mapping(uint256 => uint256) public epochRewards; // DAAR rewards per epoch
function triggerEpochDistribution() external onlyOwner {
require(block.timestamp >= lastEpochTimestamp + epochDuration, "Epoch not ended");
_updatePool();
lastRewardBalance = DAAR.balanceOf(address(this));
lastEpochTimestamp = block.timestamp;
}
```
### Version 4.0 RC1 (Manual Distribution System)
**Commit:** `de326abb30d39fe14ed8e570873af60a8e9af43a` - v4.0rc1
**Date:** May 1, 2025
#### Major Changes:
- **Library Removed:** `PausableUpgradeable` (simplified architecture)
- **Distribution Model:** Automatic → Manual owner-controlled distribution
#### Enhanced Features:
1. **Manual Distribution:**
- Owner specifies recipients and amounts
- Flexible reward allocation
- Better control over distribution logic
2. **Simplified Architecture:**
- Removed pausable functionality
- Streamlined contract structure
- Focus on core distribution functionality
#### Technical Implementation:
```solidity
struct Stake {
uint256 amount; // Amount of DAARION staked
uint256 lastClaimedEpoch; // Epoch when rewards were last claimed
}
function distributeRewards(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
require(recipients.length == amounts.length, "Array length mismatch");
require(block.timestamp >= lastEpochTimestamp + epochDuration, "Epoch not ended");
uint256 currentEpoch = getCurrentEpoch();
for (uint256 i = 0; i < recipients.length; i++) {
require(DAAR.transfer(recipients[i], amounts[i]), "DAAR transfer failed");
stakes[recipients[i]].lastClaimedEpoch = currentEpoch;
}
}
```
### Version 4.0 Final (Simplified Structure)
**Commit:** `da2931affbeec147207df1f4d999cd870cc40d54` - DAARsales added
**Date:** May 29, 2025
#### Major Changes:
- **Function Rename:** `getPendingRewards` → `getPendingRewardsDAARDistributor`
- **Code Cleanup:** Removed detailed comments, streamlined structure
#### Final Features:
- Manual epoch-based distribution
- Owner-controlled reward allocation
- Simplified but robust architecture
- Clean, production-ready code
---
## 📊 Version Summary & Evolution
| Version | Date | Key Innovation | Primary Focus |
|---------|------|----------------|---------------|
| **v2.9-3.0a** | Mar 29, 2025 | UUPS Upgradeable Architecture | Foundation & Basic Functionality |
| **v4.0α** | May 1, 2025 | Dual Staking + Pausable | Enhanced Features & Security |
| **v4.0 RC1** | May 1, 2025 | APR Logic + Manual Distribution | Mathematical Precision & Control |
| **v4.0 Final** | May 29, 2025 | Balance Tracking + Cleanup | Production Optimization |
## 🛠️ Technical Stack Evolution
### OpenZeppelin Dependencies:
- **Core:** `Initializable`, `UUPSUpgradeable`, `OwnableUpgradeable`
- **Security:** `ReentrancyGuardUpgradeable`, `PausableUpgradeable` (v4.0α only)
- **Token:** `ERC20Upgradeable`
### Key Architectural Decisions:
1. **UUPS Proxy Pattern:** Allows upgrades while maintaining state
2. **Mathematical Precision:** 1e12 scaling for reward calculations
3. **Separation of Concerns:** Distinct contracts for different functionalities
4. **Owner-Controlled Systems:** Security through centralized control
5. **Gas Optimization:** Efficient storage patterns and minimal operations
## 🎯 Current Ecosystem State (v4.0 Final)
### Deployed Contracts:
- **DAAR:** `0x5aF82259455a963eC20Ea92471f55767B5919E38`
- **DAARION:** `0x8Fe60b6F2DCBE68a1659b81175C665EB94015B16`
- **APRStaking:** `0xe9a321c213d837379ebD7027CE685B62dFDb8c3b`
- **DAARDistributor:** `0x605F5F73536ab6099ADc4381A3713Eab73384BE5`
- **DAARsales:** `0x3F9b12c4Af72c030F0A0089E50b52ea59c56DDE4`
- **DAARIONsales:** `0x1f25Fd60F5Ba29dC6f014148A156A6386918Df3f`
### Current Functionality:
1. **Token Trading:** DAAR ↔ USD, DAAR ↔ DAARION
2. **Staking Rewards:** 4% APR (DAARION), 20% APR (DAAR)
3. **Distribution System:** Manual epoch-based DAAR rewards
4. **Full Upgradeability:** All contracts support UUPS upgrades
---
## 💰 DAARsales Contract (DAARsales.sol)
### Version 4.0 Final (May 29, 2025)
**Commit:** `da2931affbeec147207df1f4d999cd870cc40d54` - DAARsales added
**Date:** May 29, 2025
#### Core Features:
- **Base Architecture:** UUPS upgradeable contract
- **Purpose:** Enable direct DAAR token purchases with USDT and POL
- **Pricing:** Fixed rate of $10 USD per DAAR token
- **Payment Methods:** USDT and POL (Polygon native token)
#### Key Functionality:
- Real-time price feeds via Chainlink oracles
- Slippage protection for price stability
- Multi-token payment support (USDT, POL)
- Pause/unpause functionality for emergency control
- Direct fiat-to-crypto gateway integration
#### Technical Implementation:
```solidity
// Fixed DAAR price in USD (with 8 decimals like Chainlink)
uint256 public constant DAAR_PRICE_USD = 10_00000000; // $10.00
// Chainlink price feed addresses
address public constant USDT_USD_FEED = 0x0A6513e40db6EB1b165753AD52E80663aeA50545;
address public constant POL_USD_FEED = 0xAB594600376Ec9fD91F8e885dADF0CE036862dE0;
function buyDAARWithUSDT(uint256 usdtAmount, uint256 minDAARAmount) external;
function buyDAARWithPOL(uint256 minDAARAmount) external payable;
function calculateDAARAmount(address paymentToken, uint256 paymentAmount) external view returns (uint256);
```
---
## 💎 DAARIONsales Contract (DAARIONsales.sol)
### Version 4.0 Final (December 2024)
**Deployment Date:** December 2024
**Contract Address:** `0x1f25Fd60F5Ba29dC6f014148A156A6386918Df3f`
#### Core Features:
- **Base Architecture:** UUPS upgradeable contract
- **Purpose:** Enable DAARION token purchases exclusively with DAAR tokens
- **Pricing:** Fixed rate of 100 DAAR per 1 DAARION
- **Access Control:** Restricted to DAAR token holders only
#### Key Functionality:
- Fixed exchange rate (1 DAARION = 100 DAAR)
- DAAR-only payment method (maintains ecosystem coherence)
- Built-in slippage protection (2%)
- Emergency pause functionality
- Direct smart contract integration
#### Technical Implementation:
```solidity
// Fixed exchange rate: 100 DAAR per 1 DAARION
uint256 public daarionRate = 100e18; // 100 DAAR per DAARION
// Core purchase function
function buyDAARION(uint256 daarAmount, uint256 minDAARIONAmount) external;
// Price calculation
function calculateDAARIONAmount(uint256 daarAmount) external view returns (uint256) {
return (daarAmount * 1e18) / daarionRate;
}
// Slippage protection built-in
modifier nonZeroAmount(uint256 amount) {
require(amount > 0, "Amount must be greater than zero");
_;
}
```
#### Economic Model:
- **Entry Requirement:** Must hold DAAR tokens to purchase DAARION
- **Value Proposition:** 1 DAARION = $1000 USD (100 DAAR × $10)
- **Ecosystem Alignment:** Ensures DAARION buyers are already ecosystem participants
- **Scarcity Mechanism:** Limited DAARION supply (8,000 tokens total)
---
## 🔄 Sales Contract Ecosystem Integration
### DAARsales → DAARIONsales Flow:
```
Fiat/Crypto → USDT/POL → DAARsales → DAAR → DAARIONsales → DAARION
↓ ↓ ↓ ↓ ↓ ↓
External Polygon $10 USD 100:1 Premium Investment
Markets Network per DAAR Rate Access Token
```
### Use Cases:
1. **New Users:** USDT/POL → DAAR (via DAARsales) → Ecosystem Access
2. **DAAR Holders:** DAAR → DAARION (via DAARIONsales) → Premium Benefits
3. **Investors:** Multi-step: Fiat → DAAR → DAARION → Staking Rewards
### Current Functionality:
1. **Token Trading:** USDT/POL ↔ DAAR, DAAR ↔ DAARION
2. **Staking Rewards:** 4% APR (DAARION), 20% APR (DAAR)
3. **Distribution System:** Manual epoch-based DAAR rewards
4. **Full Upgradeability:** All contracts support UUPS upgrades
---
*Last Updated: December 2024 - Based on successful DAARIONsales deployment `0x1f25Fd60F5Ba29dC6f014148A156A6386918Df3f`*