MrPeachesSale

Claim Peaches

1
function claimPeaches() external {
2
3
require(liquidityGeneratedAt != 0, 'Liquidity not generated');
4
uint tokens = tokenBalances[msg.sender];
5
require(tokens > 0 , "Nothing to claim");
6
7
stableCoinContributed[msg.sender] = 0;
8
tokenBalances[msg.sender] = 0;
9
10
peaches.safeTransfer(msg.sender, tokens);
11
12
emit PeachesClaimed(msg.sender, tokens);
13
}
Copied!

Liquidity Generation

1
function generateLiquidity() external {
2
3
require(publicSaleClosedAt != 0, 'Public sale open');
4
require(liquidityGeneratedAt == 0, 'Liquidity generated');
5
require(block.timestamp > publicSaleClosedAt.add(30 minutes), 'Too early');
6
7
uint stableCoinBalance = stableCoin.balanceOf(address(this));
8
require(stableCoinBalance > 0, 'Stablecoin balance is zero');
9
stableCoin.safeApprove(address(uniswapRouter), stableCoinBalance);
10
uint amountPeaches = stableCoinBalance.mul(multiplier).div(uniswapRate);
11
peaches.safeApprove(address(uniswapRouter), amountPeaches);
12
13
(uint amountA, uint amountB, uint liquidity) = uniswapRouter.addLiquidity(
14
address(peaches),
15
address(stableCoin),
16
amountPeaches,
17
stableCoinBalance,
18
amountPeaches.sub(amountPeaches / 10),
19
stableCoinBalance.sub(stableCoinBalance / 10),
20
address(this),
21
block.timestamp.add(2 hours)
22
);
23
24
liquidityGeneratedAt = block.timestamp;
25
26
emit LiquidityGenerated(amountA, amountB, liquidity);
27
}
Copied!

Emergency Withdraw

1
function emergencyWithdrawCoins() external {
2
3
require(publicSaleClosedAt != 0, 'Public sale open');
4
require(liquidityGeneratedAt == 0, 'Liquidity generated');
5
require(block.timestamp > publicSaleClosedAt.add(30 minutes).add(3 days), 'Too early');
6
7
uint contributedAmount = stableCoinContributed[msg.sender];
8
require(contributedAmount > 0, 'Nothing to withdraw');
9
10
tokenBalances[msg.sender] = 0;
11
stableCoinContributed[msg.sender] = 0;
12
13
stableCoin.safeTransfer(msg.sender, contributedAmount);
14
15
emit EmergencyWithdrawn(msg.sender, contributedAmount);
16
}
Copied!
This software is experimental please use at your own risk.
Last modified 5mo ago