@@ -4,6 +4,7 @@ pragma solidity 0.8.25;
44
55import "@openzeppelin/contracts/access/Ownable2Step.sol " ;
66import "@openzeppelin/contracts/security/ReentrancyGuard.sol " ;
7+ import { SafeCastLib } from "solady/utils/SafeCastLib.sol " ;
78import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
89import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
910import { IShare } from "../interface/IShare.sol " ;
@@ -34,7 +35,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
3435
3536 uint256 public shareIndex;
3637 uint256 public depositedETHAmount;
37- uint256 public referralFeePercent = 5 * 1e16 ;
38+ uint256 public referralFeePercent = 2 * 1e16 ;
3839 uint256 public creatorFeePercent = 5 * 1e16 ;
3940 uint256 public migrationDeadline;
4041
@@ -43,7 +44,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
4344 address public blankAggregator;
4445
4546 event QueueMigrateYield (address indexed newAggregator , uint256 deadline );
46- event MigrateYield (address indexed newAggregator , uint256 timestamp );
47+ event MigrateYield (address indexed newAggregator );
4748 event ClaimYield (uint256 amount , address indexed to );
4849 event SetCurve (uint8 indexed curveType );
4950 event SetFee (uint256 indexed feePercent , string feeType );
@@ -63,9 +64,9 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
6364
6465 // Set default curve params
6566 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 ;
6970 linearPriceSlope: _linearPriceSlope, // 0;
7071 exists: true
7172 });
@@ -84,17 +85,12 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
8485 function getCurve (uint8 curveType ) public view returns (uint96 , uint32 , uint128 , uint128 , bool ) {
8586 require (curvesMap[curveType].exists, "Invalid curveType " );
8687 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);
9389 }
9490
9591 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 );
9894 }
9995
10096 function setReferralFeePercent (uint256 _feePercent ) external onlyOwner {
@@ -313,8 +309,9 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
313309 (, uint8 curveType ) = getShare (shareId);
314310 uint256 fromSupply = IShare (ERC1155 ).shareFromSupply (shareId);
315311 uint256 actualReferralFeePercent = referral != address (0 ) ? referralFeePercent : 0 ;
312+ require (fromSupply + uint256 (quantity) <= type (uint32 ).max, "Exceeds max supply " );
316313
317- buyPrice = getSubTotal (uint32 (fromSupply), quantity, curveType);
314+ buyPrice = getSubTotal (SafeCastLib. toUint32 (fromSupply), quantity, curveType);
318315 referralFee = (buyPrice * actualReferralFeePercent) / 1 ether ;
319316 creatorFee = (buyPrice * creatorFeePercent) / 1 ether ;
320317 buyPriceAfterFee = buyPrice + referralFee + creatorFee;
@@ -346,7 +343,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
346343 uint256 actualReferralFeePercent = referral != address (0 ) ? referralFeePercent : 0 ;
347344 require (fromSupply >= quantity, "Exceeds supply " );
348345
349- sellPrice = getSubTotal (uint32 (fromSupply) - quantity, quantity, curveType);
346+ sellPrice = getSubTotal (SafeCastLib. toUint32 (fromSupply) - quantity, quantity, curveType);
350347 referralFee = (sellPrice * actualReferralFeePercent) / 1 ether ;
351348 creatorFee = (sellPrice * creatorFeePercent) / 1 ether ;
352349 sellPriceAfterFee = sellPrice - referralFee - creatorFee;
@@ -381,7 +378,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
381378 // Step 4: Deposit all ETH into the new yieldAggregator as yieldToken.
382379 _depositAllETHToYieldToken ();
383380
384- emit MigrateYield (address (_yieldAggregator), block . timestamp );
381+ emit MigrateYield (address (_yieldAggregator));
385382 }
386383
387384 /**
@@ -414,7 +411,7 @@ contract SharesFactoryV1 is Ownable2Step, ReentrancyGuard {
414411 uint32 inflectionPoint ,
415412 uint128 inflectionPrice ,
416413 uint128 linearPriceSlope
417- ) public pure returns (uint256 subTotal ) {
414+ ) internal pure returns (uint256 subTotal ) {
418415 unchecked {
419416 subTotal = basePrice * quantity;
420417 subTotal += BondingCurveLib.linearSum (linearPriceSlope, fromSupply, quantity);
0 commit comments