@@ -4,6 +4,7 @@ pragma solidity 0.8.25;
4
4
5
5
import "@openzeppelin/contracts/access/Ownable2Step.sol " ;
6
6
import "@openzeppelin/contracts/security/ReentrancyGuard.sol " ;
7
+ import { SafeCastLib } from "solady/utils/SafeCastLib.sol " ;
7
8
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
8
9
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
9
10
import { IShare } from "../interface/IShare.sol " ;
@@ -34,7 +35,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
34
35
35
36
uint256 public shareIndex;
36
37
uint256 public depositedETHAmount;
37
- uint256 public referralFeePercent = 5 * 1e16 ;
38
+ uint256 public referralFeePercent = 2 * 1e16 ;
38
39
uint256 public creatorFeePercent = 5 * 1e16 ;
39
40
uint256 public migrationDeadline;
40
41
@@ -43,7 +44,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
43
44
address public blankAggregator;
44
45
45
46
event QueueMigrateYield (address indexed newAggregator , uint256 deadline );
46
- event MigrateYield (address indexed newAggregator , uint256 timestamp );
47
+ event MigrateYield (address indexed newAggregator );
47
48
event ClaimYield (uint256 amount , address indexed to );
48
49
event SetCurve (uint8 indexed curveType );
49
50
event SetFee (uint256 indexed feePercent , string feeType );
@@ -63,9 +64,9 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
63
64
64
65
// Set default curve params
65
66
curvesMap[0 ] = Curve ({
66
- basePrice: _basePrice, // 5000000000000000 ;
67
- inflectionPoint: _inflectionPoint, // 1500 ;
68
- inflectionPrice: _inflectionPrice, // 102500000000000000 ;
67
+ basePrice: _basePrice, // 0.001 ether ;
68
+ inflectionPoint: _inflectionPoint, // 1000 ;
69
+ inflectionPrice: _inflectionPrice, // 0.1 ether ;
69
70
linearPriceSlope: _linearPriceSlope, // 0;
70
71
exists: true
71
72
});
@@ -84,17 +85,12 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
84
85
function getCurve (uint8 curveType ) public view returns (uint96 , uint32 , uint128 , uint128 , bool ) {
85
86
require (curvesMap[curveType].exists, "Invalid curveType " );
86
87
Curve memory curve = curvesMap[curveType];
87
- uint96 basePrice = curve.basePrice;
88
- uint32 g = curve.inflectionPoint;
89
- uint128 h = curve.inflectionPrice;
90
- uint128 m = curve.linearPriceSlope;
91
- bool exists = curve.exists;
92
- return (basePrice, g, h, m, exists);
88
+ return (curve.basePrice, curve.inflectionPoint, curve.inflectionPrice, curve.linearPriceSlope, curve.exists);
93
89
}
94
90
95
91
function getSubTotal (uint32 fromSupply , uint32 quantity , uint8 curveType ) public view returns (uint256 ) {
96
- (uint96 basePrice , uint32 g , uint128 h , uint128 m ,) = getCurve (curveType);
97
- return _subTotal (fromSupply, quantity, basePrice, g, h, m );
92
+ (uint96 basePrice , uint32 inflectionPoint , uint128 inflectionPrice , uint128 linearPriceSlope ,) = getCurve (curveType);
93
+ return _subTotal (fromSupply, quantity, basePrice, inflectionPoint, inflectionPrice, linearPriceSlope );
98
94
}
99
95
100
96
function setReferralFeePercent (uint256 _feePercent ) external onlyOwner {
@@ -313,8 +309,9 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
313
309
(, uint8 curveType ) = getShare (shareId);
314
310
uint256 fromSupply = IShare (ERC1155 ).shareFromSupply (shareId);
315
311
uint256 actualReferralFeePercent = referral != address (0 ) ? referralFeePercent : 0 ;
312
+ require (fromSupply + uint256 (quantity) <= type (uint32 ).max, "Exceeds max supply " );
316
313
317
- buyPrice = getSubTotal (uint32 (fromSupply), quantity, curveType);
314
+ buyPrice = getSubTotal (SafeCastLib. toUint32 (fromSupply), quantity, curveType);
318
315
referralFee = (buyPrice * actualReferralFeePercent) / 1 ether ;
319
316
creatorFee = (buyPrice * creatorFeePercent) / 1 ether ;
320
317
buyPriceAfterFee = buyPrice + referralFee + creatorFee;
@@ -346,7 +343,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
346
343
uint256 actualReferralFeePercent = referral != address (0 ) ? referralFeePercent : 0 ;
347
344
require (fromSupply >= quantity, "Exceeds supply " );
348
345
349
- sellPrice = getSubTotal (uint32 (fromSupply) - quantity, quantity, curveType);
346
+ sellPrice = getSubTotal (SafeCastLib. toUint32 (fromSupply) - quantity, quantity, curveType);
350
347
referralFee = (sellPrice * actualReferralFeePercent) / 1 ether ;
351
348
creatorFee = (sellPrice * creatorFeePercent) / 1 ether ;
352
349
sellPriceAfterFee = sellPrice - referralFee - creatorFee;
@@ -381,7 +378,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
381
378
// Step 4: Deposit all ETH into the new yieldAggregator as yieldToken.
382
379
_depositAllETHToYieldToken ();
383
380
384
- emit MigrateYield (address (_yieldAggregator), block . timestamp );
381
+ emit MigrateYield (address (_yieldAggregator));
385
382
}
386
383
387
384
/**
@@ -414,7 +411,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
414
411
uint32 inflectionPoint ,
415
412
uint128 inflectionPrice ,
416
413
uint128 linearPriceSlope
417
- ) public pure returns (uint256 subTotal ) {
414
+ ) internal pure returns (uint256 subTotal ) {
418
415
unchecked {
419
416
subTotal = basePrice * quantity;
420
417
subTotal += BondingCurveLib.linearSum (linearPriceSlope, fromSupply, quantity);
0 commit comments