Address Contract Verified
Address
0xcDf4b3857B531741DD3D1416e280Df5cb9ed1ACD
Balance
0.016095 ETH
Nonce
1
Code Size
6347 bytes
Creator
0xC319515d...8EFF at tx 0x2b4be87e...888e3c
Indexed Transactions
0
Contract Bytecode
6347 bytes
0x608060405260043610610099575f3560e01c8063476343ee11610060578063476343ee146101675780636027ce511461017b578063680bfe58146101a857806397f548f7146101c7578063afdb0a9f146101e6578063c3d1ab24146101f957005b806302329a29146100a257806305118b7b146100c15780630f4bb963146100f5578063151166e2146101145780632e3ab18c1461013357005b366100a057005b005b3480156100ad575f80fd5b506100a06100bc366004611571565b610218565b3480156100cc575f80fd5b506100e06100db3660046115a7565b61030e565b60405190151581526020015b60405180910390f35b348015610100575f80fd5b506100a061010f366004611608565b610735565b34801561011f575f80fd5b506100e061012e366004611623565b61086f565b34801561013e575f80fd5b5061015261014d36600461165d565b61096b565b604080519283526020830191909152016100ec565b348015610172575f80fd5b506100a06109f5565b348015610186575f80fd5b5061019a61019536600461165d565b610b4f565b6040519081526020016100ec565b3480156101b3575f80fd5b506101526101c236600461165d565b610c4b565b3480156101d2575f80fd5b506100a06101e1366004611608565b610c8f565b6100e06101f436600461168b565b6110fb565b348015610204575f80fd5b5061019a61021336600461165d565b611280565b73c6b021de4c4d0d2c07f847adeefc1dbc1b31f66160405163bcaa0c5560e01b8152600760048201526001600160a01b03919091169063bcaa0c5590602401602060405180830381865afa158015610272573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029691906116de565b6001600160a01b0316336001600160a01b0316146102fb5760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420746865206f776e657200000000000000000060448201526064015b60405180910390fd5b6001805460ff1916911515919091179055565b5f610317611339565b6001600160a01b0316336001600160a01b0316146103775760405162461bcd60e51b815260206004820152601a60248201527f464c41554e545f524f555445523a204e4f545f414c4c4f57454400000000000060448201526064016102f2565b6001600160a01b03861661053957828410156103e85760405162461bcd60e51b815260206004820152602a60248201527f464c41554e545f524f555445523a204d696e416d6f756e744f757420455448206044820152690dcdee840cadcdeeaced60b31b60648201526084016102f2565b5f60646103f686600161170d565b610400919061172a565b90505f61040d8287611749565b90508160025f828254610420919061175c565b90915550506002545f906104349047611749565b9050808211156104865760405162461bcd60e51b815260206004820152601d60248201527f464c41554e545f524f555445523a204e4f5f4554485f42414c414e434500000060448201526064016102f2565b5f886001600160a01b0316836040515f6040518083038185875af1925050503d805f81146104cf576040519150601f19603f3d011682016040523d82523d5f602084013e6104d4565b606091505b50509050806105305760405162461bcd60e51b815260206004820152602260248201527f464c41554e545f524f555445523a204554485f5452414e534645525f4641494c604482015261115160f21b60648201526084016102f2565b50505050610728565b8284101561059e5760405162461bcd60e51b815260206004820152602c60248201527f464c41554e545f524f555445523a204d696e416d6f756e744f757420544f4b4560448201526b09c40dcdee840cadcdeeaced60a31b60648201526084016102f2565b8115610650575f856001600160a01b0316836040515f6040518083038185875af1925050503d805f81146105ed576040519150601f19603f3d011682016040523d82523d5f602084013e6105f2565b606091505b505090508061064e5760405162461bcd60e51b815260206004820152602260248201527f464c41554e545f524f555445523a20544f4b454e5f524546554e445f4641494c604482015261115160f21b60648201526084016102f2565b505b6040516323b872dd60e01b81526001600160a01b0388811660048301528681166024830152604482018690525f91908816906323b872dd906064016020604051808303815f875af11580156106a7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106cb919061176f565b9050806107265760405162461bcd60e51b8152602060048201526024808201527f464c41554e545f524f555445523a2045524332305f5452414e534645525f46416044820152631253115160e21b60648201526084016102f2565b505b5060019695505050505050565b61073d6113b3565b6001600160a01b0316336001600160a01b03161461078f5760405162461bcd60e51b815260206004820152600f60248201526e1bdb9b1e481b185d5b98da1c1bdbdb608a1b60448201526064016102f2565b6040516370a0823160e01b81523060048201526001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa1580156107db573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107ff919061178a565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303815f875af1158015610847573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061086b919061176f565b5050565b6001545f9060ff16156108945760405162461bcd60e51b81526004016102f2906117a1565b82428110156108de5760405162461bcd60e51b815260206004820152601660248201527511931055539517d493d55511548e881156141254915160521b60448201526064016102f2565b6108e66113ed565b5f861161092b5760405162461bcd60e51b81526020600482015260136024820152724e65656420746f2073656c6c20746f6b656e7360681b60448201526064016102f2565b5f610934611339565b9050335f6109428989610b4f565b905061095283898b84868b611444565b6001945050505061096260015f55565b50949350505050565b5f805f610976611339565b604051637f048d6b60e11b8152600481018790526001600160a01b0386811660248301529192509082169063fe091ad6906044015b6040805180830381865afa1580156109c5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109e991906117c9565b92509250509250929050565b5f60025411610a465760405162461bcd60e51b815260206004820181905260248201527f464c41554e545f524f555445523a204e4f5f464545535f415641494c41424c4560448201526064016102f2565b5f610a4f6114b3565b9050336001600160a01b03821614610a975760405162461bcd60e51b815260206004820152600b60248201526a1b9bdd08185b1b1bddd95960aa1b60448201526064016102f2565b600280545f918290556040519091906001600160a01b0384169083908381818185875af1925050503d805f8114610ae9576040519150601f19603f3d011682016040523d82523d5f602084013e610aee565b606091505b5050905080610b4a5760405162461bcd60e51b815260206004820152602260248201527f464c41554e545f524f555445523a204645455f5452414e534645525f4641494c604482015261115160f21b60648201526084016102f2565b505050565b5f8073c6b021de4c4d0d2c07f847adeefc1dbc1b31f66160405163bcaa0c5560e01b8152600e60048201526001600160a01b03919091169063bcaa0c5590602401602060405180830381865afa158015610bab573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bcf91906116de565b604051631179600f60e11b8152600481018690526001600160a01b038581166024830152919250908216906322f2c01e906044015b602060405180830381865afa158015610c1f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c43919061178a565b949350505050565b5f805f610c56611339565b6040516397faae2d60e01b8152600481018790526001600160a01b038681166024830152919250908216906397faae2d906044016109ab565b60015460ff1615610cb25760405162461bcd60e51b81526004016102f2906117a1565b610cba6114ed565b6001600160a01b0316336001600160a01b031614610d085760405162461bcd60e51b815260206004820152600b60248201526a1b9bdd08185b1b1bddd95960aa1b60448201526064016102f2565b5f610d11611339565b60405163bbe4f6db60e01b81526001600160a01b0384811660048301529192505f9182919084169063bbe4f6db9060240160a060405180830381865afa158015610d5d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8191906117eb565b509350935050508015610dca5760405162461bcd60e51b81526020600482015260116024820152701b1a5c48185b1c9958591e481859191959607a1b60448201526064016102f2565b674563918244f40000821015610e115760405162461bcd60e51b815260206004820152600c60248201526b6e6f7420636f6d706c65746560a01b60448201526064016102f2565b60405163a9059cbb60e01b81523360048201526ade83a42671f85a0518000060248201526001600160a01b0385169063a9059cbb906044016020604051808303815f875af1158015610e65573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e89919061176f565b5067016345785d8a0000674563918244f400005f610ea56114ed565b6001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610eec576040519150601f19603f3d011682016040523d82523d5f602084013e610ef1565b606091505b505090505f876001600160a01b031663e927fc5c6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610f33573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f5791906116de565b6001600160a01b0316846040515f6040518083038185875af1925050503d805f8114610f9e576040519150601f19603f3d011682016040523d82523d5f602084013e610fa3565b606091505b505090505f848488610fb59190611749565b610fbf9190611749565b90508060025f828254610fd2919061175c565b9091555083905061103a5760405162461bcd60e51b815260206004820152602c60248201527f464c41554e545f524f555445523a204554485f4c49515549444954595f54524160448201526b1394d1915497d1905253115160a21b60648201526084016102f2565b8161109a5760405162461bcd60e51b815260206004820152602a60248201527f464c41554e545f524f555445523a204554485f43524541544f525f5452414e5360448201526911915497d1905253115160b21b60648201526084016102f2565b604051630aad7ead60e41b81526001600160a01b038a8116600483015289169063aad7ead0906024015f604051808303815f87803b1580156110da575f80fd5b505af11580156110ec573d5f803e3d5ffd5b50505050505050505050505050565b6001545f9060ff16156111205760405162461bcd60e51b81526004016102f2906117a1565b834281101561116a5760405162461bcd60e51b815260206004820152601660248201527511931055539517d493d55511548e881156141254915160521b60448201526064016102f2565b6111726113ed565b5f34116111b45760405162461bcd60e51b815260206004820152601060248201526f09ccacac840e8de40e6cadcc8408aa8960831b60448201526064016102f2565b335f6111be611339565b90505f60646111ce34600161170d565b6111d8919061172a565b90505f6111e58234611749565b90508160025f8282546111f8919061175c565b909155505f9050611209828c611280565b9050611219848c8388868e611527565b6001600160c01b031988161561126e57604080513481526001600160c01b03198a16602082015233917fc6ce43dd485df0c1038c68be45421544698dbb0c34fb91175586978f6d4b9857910160405180910390a25b60019650505050505061096260015f55565b5f8073c6b021de4c4d0d2c07f847adeefc1dbc1b31f66160405163bcaa0c5560e01b8152600e60048201526001600160a01b03919091169063bcaa0c5590602401602060405180830381865afa1580156112dc573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061130091906116de565b604051637d3d011160e01b8152600481018690526001600160a01b03858116602483015291925090821690637d3d011190604401610c04565b60405163bcaa0c5560e01b8152600e60048201525f9073c6b021de4c4d0d2c07f847adeefc1dbc1b31f6619063bcaa0c55906024015b602060405180830381865afa15801561138a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113ae91906116de565b905090565b60405163bcaa0c5560e01b8152600860048201525f9073c6b021de4c4d0d2c07f847adeefc1dbc1b31f6619063bcaa0c559060240161136f565b60025f540361143e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f2565b60025f55565b604051632809df7160e21b81526001600160a01b0387169063a0277dc49061147e90889088905f90899033908a9084908b90600401611849565b5f604051808303815f87803b158015611495575f80fd5b505af11580156114a7573d5f803e3d5ffd5b50505050505050505050565b60405163bcaa0c5560e01b8152600360048201525f9073c6b021de4c4d0d2c07f847adeefc1dbc1b31f6619063bcaa0c559060240161136f565b60405163bcaa0c5560e01b8152600160048201525f9073c6b021de4c4d0d2c07f847adeefc1dbc1b31f6619063bcaa0c559060240161136f565b604051632809df7160e21b81526001600160a01b0387169063a0277dc49061147e9088905f908990829033908b908b908b90600401611849565b801515811461156e575f80fd5b50565b5f60208284031215611581575f80fd5b813561158c81611561565b9392505050565b6001600160a01b038116811461156e575f80fd5b5f805f805f8060c087890312156115bc575f80fd5b86356115c781611593565b955060208701356115d781611593565b945060408701356115e781611593565b959894975094956060810135955060808101359460a0909101359350915050565b5f60208284031215611618575f80fd5b813561158c81611593565b5f805f8060808587031215611636575f80fd5b84359350602085013561164881611593565b93969395505050506040820135916060013590565b5f806040838503121561166e575f80fd5b82359150602083013561168081611593565b809150509250929050565b5f805f806080858703121561169e575f80fd5b84356116a981611593565b9350602085013592506040850135915060608501356001600160c01b0319811681146116d3575f80fd5b939692955090935050565b5f602082840312156116ee575f80fd5b815161158c81611593565b634e487b7160e01b5f52601160045260245ffd5b8082028115828204841417611724576117246116f9565b92915050565b5f8261174457634e487b7160e01b5f52601260045260245ffd5b500490565b81810381811115611724576117246116f9565b80820180821115611724576117246116f9565b5f6020828403121561177f575f80fd5b815161158c81611561565b5f6020828403121561179a575f80fd5b5051919050565b6020808252600e908201526d536563757269747920706175736560901b604082015260600190565b5f80604083850312156117da575f80fd5b505080516020909101519092909150565b5f805f805f60a086880312156117ff575f80fd5b855161180a81611593565b809550506020860151935060408601519250606086015161182a81611561565b608087015190925061183b81611561565b809150509295509295909350565b6001600160a01b039889168152602081019790975260408701959095526060860193909352908516608085015290931660a083015260c082019290925260e0810191909152610100019056fea2646970667358221220e2162aa044ce35fe3dcca1b6b826a845611e0058559b3739ad665a1be56cba5864736f6c63430008150033
Verified Source Code Full Match
Compiler: v0.8.21+commit.d9974bed
EVM: shanghai
Optimization: Yes (200 runs)
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
FlauntRouter.sol 453 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./interfaces/IFlauntFactory.sol";
import "./interfaces/IFlauntRouter.sol";
import "./interfaces/IFlauntBondingPool.sol";
/**
* @title FLAUNT_ROUTER
* @dev Router contract for Flaunt Platform, implementing UUPS upgradeability and Ownable access control.
*/
contract FlauntRouter is ReentrancyGuard {
bool private paused = false;
uint256 private feeBalance;
function pause(bool _status) external onlyOwner {
paused = _status;
}
modifier isPaused() {
require(paused == false, "Security pause");
_;
}
function protcolAddress() private pure returns (IProtcolAddress) {
return IProtcolAddress(0xC6B021DE4C4d0D2C07f847AdeEFC1dBc1B31f661);
}
function bondingPoolManager() private view returns (address) {
return protcolAddress().getAddress(14);
}
function feeReceiver() private view returns (address) {
return protcolAddress().getAddress(3);
}
function flauntUniswapV3Manager() private view returns (address) {
return protcolAddress().getAddress(1);
}
function flauntLaunchPool() private view returns (address) {
return protcolAddress().getAddress(8);
}
modifier onlyAuthorized() {
require(
msg.sender == protcolAddress().getAddress(0),
"FLAUNT_ROUTER: Not authorized"
);
_;
}
modifier onlyOwner() {
require(
msg.sender == protcolAddress().getAddress(7),
"Caller is not the owner"
);
_;
}
/**
* @notice Ensures that the transaction is executed before the deadline.
* @param deadline Unix timestamp after which the transaction will revert.
*/
modifier ensure(uint256 deadline) {
require(deadline >= block.timestamp, "FLAUNT_ROUTER: EXPIRED");
_;
}
// Events for tracking buy and sell transactions with ETH value and referall code in bytes
event BuyTokensWithETH(
address indexed wallet,
uint256 ethSpent,
bytes8 ref
);
/**
* @notice Swaps an exact amount of ETH for tokens.
* @dev Only callable externally. Ensures the path length is 2 and starts with ETH.
* @param tokenToBuy token addresse.
* @param deadline Unix timestamp after which the transaction will revert.
* @return status Array of amounts for each step in the path.
*/
function swapExactETHForTokens(
address tokenToBuy,
uint256 deadline,
uint256 minTokenAmountOut,
bytes8 ref
)
public
payable
isPaused
ensure(deadline)
nonReentrant
returns (bool status)
{
require(msg.value > 0, "Need to send ETH");
address to = msg.sender;
address bondingPool = bondingPoolManager();
// Calculate fee and swap amount
uint256 feeAmount = (msg.value * 1) / 100; // 1% fee
uint256 swapAmount = msg.value - feeAmount;
feeBalance += feeAmount;
// Perform swap
uint256 amountOut = getTokenAmountOut(swapAmount, tokenToBuy);
_executeSwapETHForTokens(
bondingPool,
tokenToBuy,
amountOut,
to,
swapAmount,
minTokenAmountOut
);
if (ref != 0x0000000000000000) {
emit BuyTokensWithETH(msg.sender, msg.value, ref);
}
return true;
}
// Internal helper to transfer ETH
function _transferETH(address recipient, uint256 amount) internal {
(bool success, ) = recipient.call{value: amount}("");
require(success, "FLAUNT_ROUTER: ETH_TRANSFER_FAILED");
}
// Internal helper to execute the swap
function _executeSwapETHForTokens(
address bondingPool,
address tokenOut,
uint256 amountOut,
address to,
uint256 ethAmount,
uint256 minTokenAmountOut // min user willing to get
) internal {
IFlauntBondingPool(bondingPool).swap(
tokenOut,
0,
amountOut,
0,
msg.sender,
to,
ethAmount,
minTokenAmountOut
);
}
/**
* @notice Swaps an exact amount of tokens for ETH.
* @dev Only callable externally. Ensures the path length is 2 and ends with ETH.
* @param amountIn Amount of tokens to swap.
* @param tokenToSell token addresses
* @param deadline Unix timestamp after which the transaction will revert.
*/
function swapExactTokensForETH(
uint256 amountIn,
address tokenToSell,
uint256 deadline,
uint256 minEthAmountOut // user min eth willing to get
) external isPaused ensure(deadline) nonReentrant returns (bool status) {
require(amountIn > 0, "Need to sell tokens");
address bondingPool = bondingPoolManager();
address to = msg.sender;
// Calculate amount out
uint256 amountOut = getETHAmountOut(amountIn, tokenToSell);
// Perform swap
_executeSwapTokensForETH(
bondingPool,
tokenToSell,
amountIn,
amountOut,
to,
minEthAmountOut
);
return true;
}
// Internal helper to execute the swap
function _executeSwapTokensForETH(
address bondingPool,
address tokenIn,
uint256 amountIn,
uint256 amountOut,
address to,
uint256 minEthAmountOut
) internal {
IFlauntBondingPool(bondingPool).swap(
tokenIn,
amountIn,
0,
amountOut,
msg.sender,
to,
0,
minEthAmountOut
);
}
/**
* @notice Calculates the output amount for a given input.
* @param tokenAmountIn Input amount.
* @return amount Amount out.
*/
function getETHAmountOut(
uint tokenAmountIn,
address token
) public view returns (uint256 amount) {
// Get the bondingPool address using the library
address bondingPool = protcolAddress().getAddress(14);
// Token to ETH swap
amount = IFlauntBondingPool(bondingPool).calculateSellToken(
tokenAmountIn,
token
);
}
/**
* @notice Calculates the output amount for a given input.
* @param ethAmountIn Input amount.
* @return amount Amount out.
*/
function getTokenAmountOut(
uint ethAmountIn,
address token
) public view returns (uint256 amount) {
// Get the bondingPool address using the library
address bondingPool = protcolAddress().getAddress(14);
// ETH to token swap
amount = IFlauntBondingPool(bondingPool).calculateBuyToken(
ethAmountIn,
token
);
}
/**
* @notice Returns the ETH required to buy a given amount of tokens from bonding pool.
* If requested tokenAmount exceeds remaining supply, it returns capped values.
* @param tokenAmount The requested token amount (scaled to 1e18)
* @param token The bonding pool token address
* @return actualTokenAmount The final token amount used (may be capped)
* @return ethRequired The ETH needed to buy the specified (or capped) token amount
*/
function getETHRequiredForTokens(
uint256 tokenAmount,
address token
) external view returns (uint256 actualTokenAmount, uint256 ethRequired) {
address bondingPool = bondingPoolManager();
return
IFlauntBondingPool(bondingPool).ethRequiredForTokens(
tokenAmount,
token
);
}
/**
* @notice Simulates how many tokens user would receive and the actual ETH required
* @param ethAmount The ETH amount user intends to spend
* @param token The token to simulate buy for
* @return tokenAmount The amount of tokens receivable
* @return adjustedETH The actual ETH that would be used for the purchase
*/
function simulateBuyTokenOut(
uint256 ethAmount,
address token
) external view returns (uint256 tokenAmount, uint256 adjustedETH) {
address bondingPool = bondingPoolManager();
return
IFlauntBondingPool(bondingPool).simulateBuyToken(ethAmount, token);
}
function executeTrade(
address from,
address token,
address to,
uint256 value,
uint256 minAmountOut,
uint256 refund
) public returns (bool) {
require(
msg.sender == bondingPoolManager(),
"FLAUNT_ROUTER: NOT_ALLOWED"
);
if (token == address(0)) {
require(
value >= minAmountOut,
"FLAUNT_ROUTER: MinAmountOut ETH not enough"
);
// Deduct 1% ETH fee before sending
uint256 feeAmount = (value * 1) / 100; // 1% fee
uint256 finalAmount = value - feeAmount; // Remaining ETH
feeBalance += feeAmount;
uint256 ethBalance = address(this).balance - feeBalance;
require(finalAmount <= ethBalance, "FLAUNT_ROUTER: NO_ETH_BALANCE");
// Send remaining ETH to recipient
(bool success, ) = to.call{value: finalAmount}("");
require(success, "FLAUNT_ROUTER: ETH_TRANSFER_FAILED");
} else {
require(
value >= minAmountOut,
"FLAUNT_ROUTER: MinAmountOut TOKEN not enough"
);
// Refund excess ETH first
if (refund > 0) {
(bool refundSuccess, ) = to.call{value: refund}("");
require(refundSuccess, "FLAUNT_ROUTER: TOKEN_REFUND_FAILED");
}
// Then send tokens from bonding pool (router) to user
bool success = IERC20token(token).transferFrom(from, to, value);
require(success, "FLAUNT_ROUTER: ERC20_TRANSFER_FAILED");
}
return true;
}
function graduateToken(address _tokenTogradute) public isPaused {
require(msg.sender == flauntUniswapV3Manager(), "not allowed");
address bondingPool = bondingPoolManager();
(
,
,
uint256 totalCollected,
bool liquidityAddedToUniswap,
) = IFlauntBondingPool(bondingPool).getPool(_tokenTogradute);
require(!liquidityAddedToUniswap, "liq already added");
require(totalCollected >= 5 ether, "not complete");
IERC20token(_tokenTogradute).transfer(
msg.sender,
269_003_190 * 10 ** 18
);
uint256 creatorEthReward = 0.1 ether;
uint256 liqAmount = 5 ether;
(bool b, ) = flauntUniswapV3Manager().call{value: liqAmount}(""); // liquidty
(bool c, ) = IERC20token(_tokenTogradute).creatorAddress().call{
value: creatorEthReward
}(""); // creator
uint256 rest = totalCollected - liqAmount - creatorEthReward;
feeBalance += rest;
require(b, "FLAUNT_ROUTER: ETH_LIQUIDITY_TRANSFER_FAILED");
require(c, "FLAUNT_ROUTER: ETH_CREATOR_TRANSFER_FAILED");
IFlauntBondingPool(bondingPool).setLiquidityAddedToUniswap(
_tokenTogradute
);
}
/**
* @notice Withdraws the accumulated fee balance to the owner's address.
*/
function withdrawFees() external {
require(feeBalance > 0, "FLAUNT_ROUTER: NO_FEES_AVAILABLE");
address feeReceiverAddress = feeReceiver();
require(msg.sender == feeReceiverAddress, "not allowed");
uint256 amount = feeBalance;
feeBalance = 0;
(bool feeSuccess, ) = feeReceiverAddress.call{value: amount}("");
require(feeSuccess, "FLAUNT_ROUTER: FEE_TRANSFER_FAILED");
}
function createLaunchPool(address _token) external {
require(msg.sender == flauntLaunchPool(), "only launchpool");
IERC20token(_token).transfer(
msg.sender,
IERC20token(_token).balanceOf(address(this))
);
}
/**
* @notice Fallback function to accept ETH.
*/
receive() external payable {}
/**
* @notice Fallback function to accept ETH.
*/
fallback() external payable {}
}
interface IFlauntLiquidityManager {
function countSoldOut() external returns (uint256);
}
/**
* @title IERC20token
* @dev Minimal interface for ERC20 tokens used in FLAUNT_ROUTER.
*/
interface IERC20token {
function creatorAddress() external returns (address);
/**
* @notice Transfers tokens from one address to another.
* @param from Address to transfer tokens from.
* @param to Address to transfer tokens to.
* @param value Amount of tokens to transfer.
* @return Success status.
*/
function transferFrom(
address from,
address to,
uint value
) external returns (bool);
/**
* @notice Transfers tokens to another address.
* @param to Address to transfer tokens to.
* @param value Amount of tokens to transfer.
* @return Success status.
*/
function transfer(address to, uint value) external returns (bool);
/**
* @notice Gets the token balance of a specific address.
* @param account Address to query the balance of.
* @return Token balance of the specified address.
*/
function balanceOf(address account) external view returns (uint256);
function approve(address spender, uint value) external returns (bool);
}
interface IProtcolAddress {
function getAddress(uint8 index) external view returns (address addr);
}
IFlauntBondingPool.sol 54 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
interface IFlauntBondingPool {
function getReserves(
address token
) external view returns (uint256 _reserve0, uint256 _reserve1);
function swap(
address token,
uint256 amountOftokensToSell,
uint256 amountTokenOut,
uint256 amountETHOut,
address from,
address to,
uint256 ethValue,
uint256 minAmountOut
) external payable;
function calculateBuyToken(
uint256 ethAmount,
address tokenAddress
) external view returns (uint256 tokens);
function calculateSellToken(
uint256 tokensToSell,
address tokenAddress
) external view returns (uint256 ethAmountOut);
function simulateBuyToken(
uint256 ethAmount,
address tokenAddress
) external view returns (uint256 tokenAmount, uint256 adjustedETH);
function ethRequiredForTokens(
uint256 tokenAmount,
address tokenAddress
) external view returns (uint256 actualTokenAmount, uint256 ethRequired);
function getPool(
address _token
)
external
view
returns (
address token,
uint256 totalSupply,
uint256 totalCollected,
bool liquidityAddedToUniswap,
bool initialized
);
function setLiquidityAddedToUniswap(address _token) external;
}
IFlauntFactory.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
interface IFlauntFactory {
function launchToken(
bytes calldata name_,
bytes calldata symbol_,
bytes calldata tokenURI,
address creator,
bytes calldata telegram_,
bytes calldata twitter_,
bytes calldata website_
) external payable;
}
IFlauntRouter.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
interface IFlauntRouter {
function swapExactETHForTokens(
address[] calldata path,
address to,
uint256 deadline,
bytes8 ref
) external payable returns (bool status);
function swapExactTokensForETH(
uint256 amountIn,
address[] calldata path,
address to,
uint256 deadline
) external returns (bool status);
function getEthAmountOut(
uint ethAmountIn,
address token
) external view returns (uint256 amount);
function getTokenAmountOut(
uint tokenAamountIn,
address token
) external view returns (uint256 amount);
}
Read Contract
getETHAmountOut 0x6027ce51 → uint256
getETHRequiredForTokens 0x680bfe58 → uint256, uint256
getTokenAmountOut 0xc3d1ab24 → uint256
simulateBuyTokenOut 0x2e3ab18c → uint256, uint256
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
createLaunchPool 0x0f4bb963
address _token
executeTrade 0x05118b7b
address from
address token
address to
uint256 value
uint256 minAmountOut
uint256 refund
returns: bool
graduateToken 0x97f548f7
address _tokenTogradute
pause 0x02329a29
bool _status
swapExactETHForTokens 0xafdb0a9f
address tokenToBuy
uint256 deadline
uint256 minTokenAmountOut
bytes8 ref
returns: bool
swapExactTokensForETH 0x151166e2
uint256 amountIn
address tokenToSell
uint256 deadline
uint256 minEthAmountOut
returns: bool
withdrawFees 0x476343ee
No parameters
Recent Transactions
No transactions found for this address