Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,990 changes: 3,970 additions & 20 deletions .openzeppelin/base-sepolia.json

Large diffs are not rendered by default.

83 changes: 70 additions & 13 deletions contracts/launchpadv2/BondingV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ contract BondingV2 is
uint256 initialPurchase;
uint256 virtualId;
bool launchExecuted;
bool isRobotics;
}

struct Data {
Expand Down Expand Up @@ -192,6 +193,31 @@ contract BondingV2 is
launchParams = params;
}

function preLaunchV2(
string memory _name,
string memory _ticker,
uint8[] memory cores,
string memory desc,
string memory img,
string[4] memory urls,
uint256 purchaseAmount,
uint256 startTime,
bool isRobotics
) public nonReentrant returns (address, address, uint, uint256) {
return
_preLaunch(
_name,
_ticker,
cores,
desc,
img,
urls,
purchaseAmount,
startTime,
isRobotics
);
}

function preLaunch(
string memory _name,
string memory _ticker,
Expand All @@ -202,6 +228,31 @@ contract BondingV2 is
uint256 purchaseAmount,
uint256 startTime
) public nonReentrant returns (address, address, uint, uint256) {
return
_preLaunch(
_name,
_ticker,
cores,
desc,
img,
urls,
purchaseAmount,
startTime,
false
);
}

function _preLaunch(
string memory _name,
string memory _ticker,
uint8[] memory cores,
string memory desc,
string memory img,
string[4] memory urls,
uint256 purchaseAmount,
uint256 startTime,
bool isRobotics
) internal returns (address, address, uint, uint256) {
if (purchaseAmount < fee || cores.length <= 0) {
revert InvalidInput();
}
Expand All @@ -224,15 +275,16 @@ contract BondingV2 is
.createNewAgentTokenAndApplication(
_name, // without "fun " prefix
_ticker,
abi.encode( // tokenSupplyParams
initialSupply,
0, // lpSupply, will mint to agentTokenAddress
initialSupply, // vaultSupply, will mint to vault
initialSupply,
initialSupply,
0,
address(this) // vault, is the bonding contract itself
),
abi.encode(
// tokenSupplyParams
initialSupply,
0, // lpSupply, will mint to agentTokenAddress
initialSupply, // vaultSupply, will mint to vault
initialSupply,
initialSupply,
0,
address(this) // vault, is the bonding contract itself
),
cores,
_deployParams.tbaSalt,
_deployParams.tbaImplementation,
Expand Down Expand Up @@ -293,6 +345,7 @@ contract BondingV2 is
newToken.initialPurchase = initialPurchase;
newToken.virtualId = VirtualIdBase + tokenInfos.length;
newToken.launchExecuted = false;
newToken.isRobotics = isRobotics;

// Set Data struct fields
newToken.data.token = token;
Expand Down Expand Up @@ -446,10 +499,12 @@ contract BondingV2 is
revert InvalidInput();
}

(uint256 amount0In, uint256 amount1Out) = router.sell(
bool isRobotics = tokenInfo[tokenAddress].isRobotics;
(uint256 amount0In, uint256 amount1Out) = router.sellV2(
amountIn,
tokenAddress,
msg.sender
msg.sender,
isRobotics
);

if (amount1Out < amountOutMin) {
Expand Down Expand Up @@ -486,11 +541,13 @@ contract BondingV2 is

(uint256 reserveA, uint256 reserveB) = pair.getReserves();

(uint256 amount1In, uint256 amount0Out) = router.buy(
bool isRobotics = tokenInfo[tokenAddress].isRobotics;
(uint256 amount1In, uint256 amount0Out) = router.buyV2(
amountIn,
tokenAddress,
buyer,
isInitialPurchase
isInitialPurchase,
isRobotics
);

if (amount0Out < amountOutMin) {
Expand Down
Loading