Skip to content

Commit

Permalink
Merge pull request #81 from bnb-party/issue-1
Browse files Browse the repository at this point in the history
ironblocks integration
  • Loading branch information
YouStillAlive authored Sep 20, 2024
2 parents 95c7bd5 + bb4380c commit b34cdb9
Show file tree
Hide file tree
Showing 7 changed files with 1,060 additions and 337 deletions.
2 changes: 1 addition & 1 deletion contracts/BNBPartyCreation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract contract BNBPartyCreation is BNBPartySwaps {
/// @param _token Address of the token to be used in the liquidity pool
/// @return liquidityPool Address of the newly created liquidity pool
/// @dev Sets the token amounts based on the balance and initializes the pool
function _createFLP(address _token) internal returns (address liquidityPool, uint256 tokenId) {
function _createFLP(address _token) internal firewallProtectedSig(0x1dbc68c8) returns (address liquidityPool, uint256 tokenId) {
(address token0, address token1, uint160 sqrtPrice, Ticks memory ticks) = _getTokenPairAndPrice(_token);
// Determine the token amounts
(uint256 amount0, uint256 amount1) = _calculateAmounts(token0);
Expand Down
1 change: 1 addition & 0 deletions contracts/BNBPartyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ contract BNBPartyFactory is BNBPartyLiquidity, ReentrancyGuard, BNBPartyManageab
external
payable
override
firewallProtected
nonReentrant
insufficientBNB(party.createTokenFee)
whenNotPaused
Expand Down
4 changes: 2 additions & 2 deletions contracts/BNBPartyFee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ abstract contract BNBPartyFee is BNBPartyState {
function _withdrawLPFees(
address[] calldata liquidityPools,
INonfungiblePositionManager manager
) internal {
) internal firewallProtectedSig(0x5892c0be) {
if (liquidityPools.length == 0) {
revert ZeroLength();
}
Expand All @@ -149,7 +149,7 @@ abstract contract BNBPartyFee is BNBPartyState {
function _collectFee(
address liquidityPool,
INonfungiblePositionManager manager
) internal notZeroAddress(liquidityPool) {
) internal firewallProtectedSig(0xbbd73307) notZeroAddress(liquidityPool) {
manager.collect(
INonfungiblePositionManager.CollectParams({
tokenId: lpToTokenId[liquidityPool],
Expand Down
16 changes: 8 additions & 8 deletions contracts/BNBPartyManageable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract contract BNBPartyManageable is BNBPartyFee, Pausable {
function setNonfungiblePositionManager(
INonfungiblePositionManager _BNBPositionManager,
INonfungiblePositionManager _positionManager
) external onlyOwner {
) external onlyOwner firewallProtected {
if (_BNBPositionManager == BNBPositionManager && _positionManager == positionManager) {
revert PositionManagerAlreadySet();
}
Expand All @@ -27,19 +27,19 @@ abstract contract BNBPartyManageable is BNBPartyFee, Pausable {
/// @dev Reverts if the new swap router is identical to the current one
function setBNBPartySwapRouter(
ISwapRouter _swapRouter
) external onlyOwner swapRouterAlreadySet(_swapRouter, BNBSwapRouter) {
) external onlyOwner firewallProtected swapRouterAlreadySet(_swapRouter, BNBSwapRouter) {
BNBSwapRouter = _swapRouter;
}

function setSwapRouter(
ISwapRouter _swapRouter
) external onlyOwner swapRouterAlreadySet(_swapRouter, swapRouter) {
) external onlyOwner firewallProtected swapRouterAlreadySet(_swapRouter, swapRouter) {
swapRouter = _swapRouter;
}

/// @notice Withdraws the balance of BNB from token creation fees
/// @dev Reverts if the contract balance is zero
function withdrawFee() external onlyOwner {
function withdrawFee() external onlyOwner firewallProtected {
if (address(this).balance > 0) {
emit TransferOutBNB(msg.sender, address(this).balance); // Emits an event indicating the transfer of BNB
payable(msg.sender).transfer(address(this).balance); // Transfers the entire BNB balance to the owner
Expand All @@ -50,23 +50,23 @@ abstract contract BNBPartyManageable is BNBPartyFee, Pausable {
/// @param liquidityPools Array of liquidity pool addresses from which fees will be withdrawn
function withdrawPartyLPFee(
address[] calldata liquidityPools
) external onlyOwner {
) external onlyOwner firewallProtected {
_withdrawLPFees(liquidityPools, BNBPositionManager);
}

/// @notice Withdraws LP fees from Pancakeswap V3 for specified liquidity pools
/// @param liquidityPools Array of liquidity pool addresses from which fees will be withdrawn
function withdrawLPFee(address[] calldata liquidityPools) external onlyOwner {
function withdrawLPFee(address[] calldata liquidityPools) external onlyOwner firewallProtected {
_withdrawLPFees(liquidityPools, positionManager);
}

/// @notice Pauses the contract
function pause() external onlyOwner {
function pause() external onlyOwner firewallProtected {
_pause();
}

/// @notice Unpauses the contract
function unpause() external onlyOwner {
function unpause() external onlyOwner firewallProtected {
_unpause();
}
}
3 changes: 2 additions & 1 deletion contracts/BNBPartyState.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@ironblocks/firewall-consumer/contracts/FirewallConsumer.sol";
import "./interfaces/ISqrtPriceCalculator.sol";
import "./interfaces/INonfungiblePositionManager.sol";
import "./interfaces/IWBNB.sol";
import "./BNBPartyModifiers.sol";

/// @title BNBPartyState
/// @notice This abstract contract handles the state variables and initial setup for the BNBParty system.
abstract contract BNBPartyState is BNBPartyModifiers, Ownable {
abstract contract BNBPartyState is BNBPartyModifiers, Ownable, FirewallConsumer {
INonfungiblePositionManager public BNBPositionManager; // BNB Party position manager
INonfungiblePositionManager public positionManager; // Default Pancakeswap V3 position manager
ISwapRouter public BNBSwapRouter; // V3 swap router
Expand Down
Loading

0 comments on commit b34cdb9

Please sign in to comment.