Latest 18 from a total of 18 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Claim | 23716212 | 107 days ago | IN | 0 ETH | 0.00016199 | ||||
| Claim | 23275309 | 169 days ago | IN | 0 ETH | 0.00012609 | ||||
| Claim | 23221232 | 176 days ago | IN | 0 ETH | 0.00003298 | ||||
| Claim | 23210696 | 178 days ago | IN | 0 ETH | 0.00010785 | ||||
| Claim | 23205010 | 178 days ago | IN | 0 ETH | 0.00016201 | ||||
| Claim | 23203845 | 179 days ago | IN | 0 ETH | 0.00012141 | ||||
| Claim | 23203747 | 179 days ago | IN | 0 ETH | 0.00002032 | ||||
| Claim | 23203542 | 179 days ago | IN | 0 ETH | 0.00003707 | ||||
| Transfer | 23203091 | 179 days ago | IN | 0.03 ETH | 0.00007434 | ||||
| Transfer | 23180370 | 182 days ago | IN | 10 ETH | 0.00000971 | ||||
| Transfer | 23165902 | 184 days ago | IN | 0.1 ETH | 0.00013015 | ||||
| Transfer | 23165321 | 184 days ago | IN | 0.1 ETH | 0.00014915 | ||||
| Transfer | 23157234 | 185 days ago | IN | 0.1 ETH | 0.00012483 | ||||
| Transfer | 23057925 | 199 days ago | IN | 0.5 ETH | 0.00007471 | ||||
| Transfer | 23052204 | 200 days ago | IN | 0.1 ETH | 0.00001512 | ||||
| Transfer | 23047102 | 200 days ago | IN | 0.1 ETH | 0.00043246 | ||||
| Transfer | 23039228 | 202 days ago | IN | 0.5 ETH | 0.00033078 | ||||
| Transfer | 22993600 | 208 days ago | IN | 2 ETH | 0.00002877 |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Minimal Proxy Contract for 0x7cfb70dd50baa538bfcd1749f56e8ae0563c96f1
Contract Name:
TemplateV1_5
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 10000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./BaseTemplate.sol";
import "./interfaces/IFeeDistributor.sol";
/// @author DeFiGeek Community Japan
/// @title TemplateV1_5
/// @notice Minimal Proxy Platform-ish fork of the HegicInitialOffering.sol
contract TemplateV1_5 is BaseTemplate, ReentrancyGuard {
using SafeERC20 for IERC20;
uint256 private constant TOKEN_UPPER_BOUND = 1e50;
uint256 private constant TOKEN_BOTTOM_BOUND = 1e6;
uint256 private constant ETH_UPPER_BOUND = 1_000_000_000 ether;
/* Multiplier derived from the practical max number of digits for eth (18 + 8) + 1 to avoid rounding error. */
uint256 private constant SCALE_FACTOR = 1e27;
/* Minimum bidding amount is set to minimize the possibility of refunds. */
uint256 private constant MIN_BID_AMOUNT = 0.001 ether;
/// Fixed rate for calculate the reward score
uint256 private constant REWARD_SCORE_RATE = 100;
// fee = gross / FEE_DENOMINATOR
uint256 private constant FEE_DENOMINATOR = 100;
IERC20 public erc20onsale;
uint256 public allocatedAmount;
uint256 public minRaisedAmount;
uint256 public totalRaised;
mapping(address => uint256) public raised;
constructor(
address factory_,
address feePool_,
address distributor_
) BaseTemplate(factory_, feePool_, distributor_) {}
/// @notice Initialize an auction
/// @dev Expected to be called by the factory's deployAuction function
/// @param owner_ Auction owner
/// @param startingAt_ Timestamp when the auction starts
/// @param eventDuration_ The duration of the auction in seconds
/// @param token_ The token address to be auctioned
/// @param allocatedAmount_ The amount of tokens to be auctioned
/// @param minRaisedAmount_ The minimum amount of tokens to be raised for the auction to be regarded as a success
function initialize(
address owner_,
uint256 startingAt_,
uint256 eventDuration_,
address token_,
uint256 allocatedAmount_,
uint256 minRaisedAmount_
) external payable onlyFactory returns (address, uint256) {
require(!initialized, "This contract has already been initialized");
initialized = true;
require(
msg.value == 0,
"This contract does not accept the creation fee"
);
require(owner_ != address(0), "owner must be there");
require(token_ != address(0), "Go with non null address.");
require(
allocatedAmount_ >= TOKEN_BOTTOM_BOUND,
"allocatedAmount must be greater than or equal to 1e6."
);
require(
allocatedAmount_ <= TOKEN_UPPER_BOUND,
"allocatedAmount must be less than or equal to 1e50."
);
require(
block.timestamp <= startingAt_,
"startingAt must be in the future"
);
require(eventDuration_ >= 1 days, "event duration is too short");
require(eventDuration_ <= 30 days, "event duration is too long");
require(
minRaisedAmount_ <= ETH_UPPER_BOUND,
"minRaisedAmount must be less than or equal to 1e27."
);
owner = owner_;
startingAt = startingAt_;
closingAt = startingAt_ + eventDuration_;
erc20onsale = IERC20(token_);
allocatedAmount = allocatedAmount_;
minRaisedAmount = minRaisedAmount_;
emit Deployed(
address(this),
owner_,
startingAt_,
closingAt,
token_,
abi.encodePacked(address(0)),
abi.encode(allocatedAmount_, minRaisedAmount_)
);
return (token_, allocatedAmount_);
}
receive() external payable {
require(
startingAt <= block.timestamp,
"The offering has not started yet"
);
require(block.timestamp <= closingAt, "The offering has already ended");
require(
msg.value >= MIN_BID_AMOUNT,
"The amount must be greater than or equal to 0.001ETH"
);
uint256 newTotalRaised = totalRaised + msg.value;
require(
newTotalRaised < SCALE_FACTOR,
"totalRaised is unexpectedly high"
);
totalRaised = newTotalRaised;
raised[msg.sender] += msg.value;
emit Raised(msg.sender, address(0), msg.value);
}
/// @notice Claim allocated tokens
/// @param participant The address of the user who contributed
/// @param recipient The address of the user who received the token allocation
function claim(
address participant,
address recipient
) external nonReentrant {
require(
block.timestamp > closingAt,
"Early to claim. Sale is not finished."
);
uint256 raisedAmount = raised[participant];
require(raisedAmount > 0, "You don't have any contribution.");
raised[participant] = 0;
uint256 erc20allocation = _calculateAllocation(
raisedAmount,
totalRaised,
allocatedAmount
);
if (totalRaised >= minRaisedAmount && erc20allocation != 0) {
if (msg.sender != participant && participant != recipient) {
revert("participant or recipient invalid");
}
erc20onsale.safeTransfer(recipient, erc20allocation);
IDistributor(distributor).addScore(
participant,
raisedAmount * REWARD_SCORE_RATE
);
emit Claimed(participant, recipient, raisedAmount, erc20allocation);
} else {
/* Refund process */
(bool success, ) = payable(participant).call{value: raisedAmount}(
""
);
require(success, "transfer failed");
emit Claimed(participant, recipient, raisedAmount, 0);
}
}
/// @param us usershare
/// @param tr totalraised
/// @param aa allocatedamount
/// @return al allocation
function _calculateAllocation(
uint256 us,
uint256 tr,
uint256 aa
) internal pure returns (uint256 al) {
al = (((us * SCALE_FACTOR) / tr) * aa) / SCALE_FACTOR;
}
/// @notice Send raised Ether to the owner
/// @dev The auction is finished, and enough Ether has been raised. The owner withdraws Ether, and contributors claim and receive their ERC-20 tokens.
function withdrawRaisedETH() external nonReentrant {
require(closingAt < block.timestamp, "Withdrawal unavailable yet.");
require(
totalRaised >= minRaisedAmount,
"The required amount has not been raised!"
);
if (closingAt + 3 days >= block.timestamp) {
uint256 minAllocation = _calculateAllocation(
MIN_BID_AMOUNT,
totalRaised,
allocatedAmount
);
require(
minAllocation > 0,
"Refund candidates may exist. Withdrawal unavailable yet."
);
}
uint256 gross = address(this).balance;
uint256 fee = gross / FEE_DENOMINATOR; // 1% of sales
(bool feeDistributorSuccess, ) = payable(feePool).call{value: fee}("");
require(feeDistributorSuccess, "Transfer to FeeDistributor failed");
IFeeDistributor(feePool).checkpointToken(address(0));
IDistributor(distributor).addScore(owner, gross * REWARD_SCORE_RATE);
(bool success, ) = payable(owner).call{value: address(this).balance}(
""
);
require(success, "Withdraw failed");
}
/// @notice Send auction tokens back to the owner
/// @dev The auction is finished, but the amount raised is not enough (Failed sale). The owner withdraws tokens, and contributors can get refunded.
function withdrawERC20Onsale() external {
require(closingAt < block.timestamp, "The offering must be completed");
require(
totalRaised < minRaisedAmount || totalRaised == 0,
"The required amount has been raised!"
);
erc20onsale.safeTransfer(owner, allocatedAmount);
}
/// @notice Send tokens to the specified address
/// @dev Expected to be used for funding the auction contract, to be delegate-called by the factory's deployAuction function
/// @param token_ Auction token address
/// @param amount_ Auction token amount
/// @param to_ Receiver
function initializeTransfer(
address token_,
uint256 amount_,
address to_
) external onlyDelegateFactory {
IERC20(token_).safeTransferFrom(msg.sender, to_, amount_);
}
}// 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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./interfaces/IDistributor.sol";
/// @title BaseTemplate
/// @author DeFiGeek Community Japan
/// @notice Base template for each auction template
/// @dev Extend this contract for each auction template
contract BaseTemplate {
/// Flags that manage instance initialization
bool initialized;
address immutable feePool;
address immutable factory;
address immutable distributor;
address public owner;
uint256 public startingAt;
uint256 public closingAt;
/// @notice Record deployed parameters
/// @dev Use primitives for important information, bytes type compression for other information.
/// @param deployedAddress Deployed address of an auction
/// @param owner The address of auction owner
/// @param startingAt The timestamp when the auction starts
/// @param closingAt The timestamp when the auction ends
/// @param auctionToken The address of the token being auctioned
/// @param raisedTokens Concatenated addresses of the raised tokens
/// @param args Concatenated template-specific parameters in bytes
event Deployed(
address deployedAddress,
address owner,
uint256 startingAt,
uint256 closingAt,
address auctionToken,
bytes raisedTokens,
bytes args
);
/// @notice Record claim parameters
/// @dev Emit this event to track claim information when participants claim
/// @param participant The address of the user who contributed
/// @param recipient The address of the user who received the token allocation
/// @param userShare The amount of the participant's contribution
/// @param allocation The amount of the participant's token allocation
event Claimed(
address indexed participant,
address indexed recipient,
uint256 userShare,
uint256 allocation
);
/// @notice Record raised parameters
/// @dev Emit this event when the auction receives funds from participants to track raised information
/// @param participant The address of the user who contributed
/// @param token The address of the raised token
/// @param amount The amount of the raised token
event Raised(address indexed participant, address token, uint256 amount);
constructor(address factory_, address feePool_, address distributor_) {
factory = factory_;
feePool = feePool_;
distributor = distributor_;
}
/// @dev Allow only owner of auction instance
modifier onlyOwner() {
require(msg.sender == owner, "You are not the owner.");
_;
}
/// @dev Allow only delegatecall from factory
modifier onlyDelegateFactory() {
require(address(this) == factory, "You are not the factory.");
_;
}
/// @dev Allow only call from factory
modifier onlyFactory() {
require(msg.sender == factory, "You are not the factory.");
_;
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
interface IDistributor {
function addScore(address targetAddress, uint256 amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IFeeDistributor {
function addRewardToken(address coin_) external returns (bool);
function tokenFlags(address _address) external view returns (bool);
function checkpointToken(address token_) external;
}{
"optimizer": {
"enabled": true,
"runs": 10000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"factory_","type":"address"},{"internalType":"address","name":"feePool_","type":"address"},{"internalType":"address","name":"distributor_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"participant","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"userShare","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"allocation","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"deployedAddress","type":"address"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"startingAt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"closingAt","type":"uint256"},{"indexed":false,"internalType":"address","name":"auctionToken","type":"address"},{"indexed":false,"internalType":"bytes","name":"raisedTokens","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"args","type":"bytes"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"participant","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Raised","type":"event"},{"inputs":[],"name":"allocatedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"participant","type":"address"},{"internalType":"address","name":"recipient","type":"address"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"closingAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc20onsale","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"uint256","name":"startingAt_","type":"uint256"},{"internalType":"uint256","name":"eventDuration_","type":"uint256"},{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"allocatedAmount_","type":"uint256"},{"internalType":"uint256","name":"minRaisedAmount_","type":"uint256"}],"name":"initialize","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"address","name":"to_","type":"address"}],"name":"initializeTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minRaisedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"raised","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startingAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRaised","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawERC20Onsale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawRaisedETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.