Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Latest 25 from a total of 564 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Pause | 13536699 | 1476 days ago | IN | 0 ETH | 0.00337524 | ||||
| Mint And Stake | 13508749 | 1480 days ago | IN | 0 ETH | 0.05214705 | ||||
| Mint And Stake | 13503762 | 1481 days ago | IN | 0 ETH | 0.04158042 | ||||
| Mint And Stake | 13503751 | 1481 days ago | IN | 0 ETH | 0.00629549 | ||||
| Mint And Stake | 13496323 | 1482 days ago | IN | 0 ETH | 0.03373907 | ||||
| Mint And Stake | 13475360 | 1485 days ago | IN | 0 ETH | 0.02074518 | ||||
| Mint And Stake | 13475312 | 1485 days ago | IN | 0 ETH | 0.02049995 | ||||
| Mint And Stake | 13471850 | 1486 days ago | IN | 0 ETH | 0.01607975 | ||||
| Mint And Stake | 13468096 | 1486 days ago | IN | 0 ETH | 0.01917819 | ||||
| Mint And Stake | 13465893 | 1487 days ago | IN | 0 ETH | 0.02184196 | ||||
| Mint And Stake | 13465032 | 1487 days ago | IN | 0 ETH | 0.02137936 | ||||
| Mint And Stake | 13464964 | 1487 days ago | IN | 0 ETH | 0.02269683 | ||||
| Mint And Stake | 13464676 | 1487 days ago | IN | 0 ETH | 0.01817045 | ||||
| Mint And Stake | 13464525 | 1487 days ago | IN | 0 ETH | 0.02200157 | ||||
| Mint And Stake | 13463715 | 1487 days ago | IN | 0 ETH | 0.0197965 | ||||
| Mint And Stake | 13463283 | 1487 days ago | IN | 0 ETH | 0.02231855 | ||||
| Mint And Stake | 13463261 | 1487 days ago | IN | 0 ETH | 0.0029968 | ||||
| Mint And Stake | 13463142 | 1487 days ago | IN | 0 ETH | 0.02890098 | ||||
| Mint And Stake | 13463025 | 1487 days ago | IN | 0 ETH | 0.02159717 | ||||
| Mint And Stake | 13462787 | 1487 days ago | IN | 0 ETH | 0.02840913 | ||||
| Mint And Stake | 13462755 | 1487 days ago | IN | 0 ETH | 0.00518144 | ||||
| Mint And Stake | 13462353 | 1487 days ago | IN | 0 ETH | 0.03737343 | ||||
| Mint And Stake | 13462305 | 1487 days ago | IN | 0 ETH | 0.03235182 | ||||
| Mint And Stake | 13462135 | 1487 days ago | IN | 0 ETH | 0.05745784 | ||||
| Mint And Stake | 13462129 | 1487 days ago | IN | 0 ETH | 0.00945045 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Presale
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./TempleERC20Token.sol";
import "./TempleTreasury.sol";
import "./TempleStaking.sol";
import "./PresaleAllocation.sol";
import "./LockedOGTemple.sol";
/**
* Presale campaign, which lets users to mint and stake based on current IV and a whitelist
*/
contract Presale is Ownable, Pausable {
IERC20 public STABLEC; // STABLEC contract address
TempleERC20Token public TEMPLE; // TEMPLE ERC20 contract
TempleTreasury public TREASURY;
TempleStaking public STAKING; // Staking contract
LockedOGTemple public STAKING_LOCK; // contract where OG Temple is locked
PresaleAllocation public PRESALE_ALLOCATION; // Allocation per address
// Unlock timestamp. This will change during the presale period, but will always be in a 2 week range.
uint256 public unlockTimestamp;
// presale mint multiple
uint256 public mintMultiple;
// How much allocation has each user used.
mapping(address => uint256) public allocationUsed;
event MintComplete(address minter, uint256 acceptedStablec, uint256 mintedTemple, uint256 mintedOGTemple);
constructor(
IERC20 _STABLEC,
TempleERC20Token _TEMPLE,
TempleStaking _STAKING,
LockedOGTemple _STAKING_LOCK,
TempleTreasury _TREASURY,
PresaleAllocation _PRESALE_ALLOCATION,
uint256 _mintMultiple,
uint256 _unlockTimestamp) {
STABLEC = _STABLEC;
TEMPLE = _TEMPLE;
STAKING = _STAKING;
STAKING_LOCK = _STAKING_LOCK;
TREASURY = _TREASURY;
PRESALE_ALLOCATION = _PRESALE_ALLOCATION;
mintMultiple = _mintMultiple;
unlockTimestamp = _unlockTimestamp;
}
function setUnlockTimestamp(uint256 _unlockTimestamp) external onlyOwner {
unlockTimestamp = _unlockTimestamp;
}
/** mint temple and immediately stake, with a bonus + lockin period */
function mintAndStake(uint256 _amountPaidStablec) external whenNotPaused {
(uint256 totalAllocation, uint256 allocationEpoch) = PRESALE_ALLOCATION.allocationOf(msg.sender);
require(_amountPaidStablec + allocationUsed[msg.sender] <= totalAllocation, "Amount requested exceed address allocation");
require(allocationEpoch <= STAKING.currentEpoch(), "User's allocated epoch is in the future");
(uint256 _stablec, uint256 _temple) = TREASURY.intrinsicValueRatio();
allocationUsed[msg.sender] += _amountPaidStablec;
uint256 _templeMinted = _amountPaidStablec * _temple / _stablec / mintMultiple;
// pull stablec from staker and immediately transfer back to treasury
SafeERC20.safeTransferFrom(STABLEC, msg.sender, address(TREASURY), _amountPaidStablec);
// mint temple and allocate to the staking contract
TEMPLE.mint(address(this), _templeMinted);
SafeERC20.safeIncreaseAllowance(TEMPLE, address(STAKING), _templeMinted);
uint256 amountOgTemple = STAKING.stake(_templeMinted);
SafeERC20.safeIncreaseAllowance(STAKING.OG_TEMPLE(), address(STAKING_LOCK), amountOgTemple);
STAKING_LOCK.lockFor(msg.sender, amountOgTemple, unlockTimestamp);
emit MintComplete(msg.sender, _amountPaidStablec, _templeMinted, amountOgTemple);
}
/**
* Pause contract. Either emergency or at the end of presale
*/
function pause() external onlyOwner {
_pause();
}
/**
* Revert pause
*/
function unpause() external onlyOwner {
_unpause();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.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;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
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));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
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");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @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");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
contract TempleERC20Token is ERC20, ERC20Burnable, Ownable, AccessControl {
bytes32 public constant CAN_MINT = keccak256("CAN_MINT");
constructor() ERC20("Temple", "TEMPLE") {
_setupRole(DEFAULT_ADMIN_ROLE, owner());
}
function mint(address to, uint256 amount) external {
require(hasRole(CAN_MINT, msg.sender), "Caller cannot mint");
_mint(to, amount);
}
function addMinter(address account) external onlyOwner {
grantRole(CAN_MINT, account);
}
function removeMinter(address account) external onlyOwner {
revokeRole(CAN_MINT, account);
}
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./TempleERC20Token.sol";
import "./ITreasuryAllocation.sol";
import "./MintAllowance.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// import "hardhat/console.sol";
contract TempleTreasury is Ownable {
// Underlying TEMPLE token
TempleERC20Token private TEMPLE;
// underlying stable token we are holding and valuing treasury with
IERC20 private STABLEC;
// Minted temple allocated to various investment contracts
MintAllowance public MINT_ALLOWANCE;
// Ratio of treasury value in stablec to open supply of temple.
struct IntrinsicValueRatio {
uint256 stablec;
uint256 temple;
}
IntrinsicValueRatio public intrinsicValueRatio;
// Temple rewards harvested, and (yet) to be allocated to a pool
uint256 public harvestedRewardsTemple;
// Has treasury been seeded with STABLEC yet (essentially, has seedMint been called)
// this will bootstrap IV
bool public seeded = false;
// all active pools. A pool is anything
// that gets allocated some portion of harvest
address[] public pools;
mapping(address => uint96) public poolHarvestShare;
uint96 public totalHarvestShares;
// Current treasury STABLEC allocations
mapping(ITreasuryAllocation => uint256) public treasuryAllocationsStablec;
uint256 public totalAllocationStablec;
event RewardsHarvested(uint256 _amount);
event HarvestDistributed(address _contract, uint256 _amount);
constructor(TempleERC20Token _TEMPLE, IERC20 _STABLEC) {
TEMPLE = _TEMPLE;
STABLEC = _STABLEC;
MINT_ALLOWANCE = new MintAllowance(_TEMPLE);
}
function numPools() external view returns (uint256) {
return pools.length;
}
/**
* Seed treasury with STABLEC and Temple to bootstrap
*/
function seedMint(uint256 amountStablec, uint256 amountTemple) external onlyOwner {
require(!seeded, "Owner has already seeded treasury");
seeded = true;
// can this go in the constructor?
intrinsicValueRatio.stablec = amountStablec;
intrinsicValueRatio.temple = amountTemple;
SafeERC20.safeTransferFrom(STABLEC, msg.sender, address(this), amountStablec);
TEMPLE.mint(msg.sender, amountTemple);
}
/**
* Harvest rewards.
*
* For auditing, we harvest and allocate in two steps
*/
function harvest(uint256 distributionPercent) external onlyOwner {
require(distributionPercent <= 100, "Scaling factor interpreted as a %, needs to be between 0 (no harvest) and 100 (max harvest)");
uint256 reserveStablec = STABLEC.balanceOf(address(this)) + totalAllocationStablec;
// // Burn any excess temple, that is Any temple over and beyond harvestedRewardsTemple.
// // NOTE: If we don't do this, IV could drop...
if (TEMPLE.balanceOf(address(this)) > harvestedRewardsTemple) {
// NOTE: there isn't a Reentrancy issue as we control the TEMPLE ERC20 contract, and configure
// treasury with an address on contract creation
TEMPLE.burn(TEMPLE.balanceOf(address(this)) - harvestedRewardsTemple);
}
uint256 totalSupplyTemple = TEMPLE.totalSupply() - TEMPLE.balanceOf(address(MINT_ALLOWANCE));
uint256 impliedSupplyAtCurrentIVTemple = reserveStablec * intrinsicValueRatio.temple / intrinsicValueRatio.stablec;
require(impliedSupplyAtCurrentIVTemple >= totalSupplyTemple, "Cannot run harvest when IV drops");
uint256 newHarvestTemple = (impliedSupplyAtCurrentIVTemple - totalSupplyTemple) * distributionPercent / 100;
harvestedRewardsTemple += newHarvestTemple;
intrinsicValueRatio.stablec = reserveStablec;
intrinsicValueRatio.temple = totalSupplyTemple + newHarvestTemple;
TEMPLE.mint(address(this), newHarvestTemple);
emit RewardsHarvested(newHarvestTemple);
}
/**
* ResetIV
*
* Not expected to be used in day to day operations, as opposed to harvest which
* will be called ~ once per epoch.
*
* Only to be called if we have to post a treasury loss, and restart IV growth from
* a new baseline.
*/
function resetIV() external onlyOwner {
uint256 reserveStablec = STABLEC.balanceOf(address(this)) + totalAllocationStablec;
uint256 totalSupplyTemple = TEMPLE.totalSupply() - TEMPLE.balanceOf(address(MINT_ALLOWANCE));
intrinsicValueRatio.stablec = reserveStablec;
intrinsicValueRatio.temple = totalSupplyTemple;
}
/**
* Allocate rewards to each pool.
*/
function distributeHarvest() external onlyOwner {
// transfer rewards as per defined allocation
uint256 totalAllocated = 0;
for (uint256 i = 0; i < pools.length; i++) {
uint256 allocatedRewards = harvestedRewardsTemple * poolHarvestShare[pools[i]] / totalHarvestShares;
// integer rounding may cause the last allocation to exceed harvested
// rewards. Handle gracefully
if ((totalAllocated + allocatedRewards) > harvestedRewardsTemple) {
allocatedRewards = harvestedRewardsTemple - totalAllocated;
}
totalAllocated += allocatedRewards;
SafeERC20.safeTransfer(TEMPLE, pools[i], allocatedRewards);
emit HarvestDistributed(pools[i], allocatedRewards);
}
harvestedRewardsTemple -= totalAllocated;
}
/**
* Mint and Allocate treasury TEMPLE.
*/
function mintAndAllocateTemple(address _contract, uint256 amountTemple) external onlyOwner {
require(amountTemple > 0, "TEMPLE to mint and allocate must be > 0");
// Mint and Allocate TEMPLE via MINT_ALLOWANCE helper
TEMPLE.mint(address(this), amountTemple);
SafeERC20.safeIncreaseAllowance(TEMPLE, address(MINT_ALLOWANCE), amountTemple);
MINT_ALLOWANCE.increaseMintAllowance(_contract, amountTemple);
}
/**
* Burn minted temple associated with a specific contract
*/
function unallocateAndBurnUnusedMintedTemple(address _contract) external onlyOwner {
MINT_ALLOWANCE.burnUnusedMintAllowance(_contract);
}
/**
* Allocate treasury STABLEC.
*/
function allocateTreasuryStablec(ITreasuryAllocation _contract, uint256 amountStablec) external onlyOwner {
require(amountStablec > 0, "STABLEC to allocate must be > 0");
treasuryAllocationsStablec[_contract] += amountStablec;
totalAllocationStablec += amountStablec;
SafeERC20.safeTransfer(STABLEC, address(_contract), amountStablec);
}
/**
* Update treasury with latest mark to market for a given treasury allocation
*/
function updateMarkToMarket(ITreasuryAllocation _contract) external onlyOwner {
uint256 oldReval = treasuryAllocationsStablec[_contract];
uint256 newReval = _contract.reval();
totalAllocationStablec = totalAllocationStablec + newReval - oldReval;
treasuryAllocationsStablec[_contract] = newReval;
}
/**
* Withdraw from a contract.
*
* Expects that pre-withdrawal reval() includes the unwithdrawn allowance, and post withdrawal reval()
* drops by exactly this amount.
*/
function withdraw(ITreasuryAllocation _contract) external onlyOwner {
uint256 preWithdrawlReval = _contract.reval();
uint256 pendingWithdrawal = STABLEC.allowance(address(_contract), address(this));
// NOTE: Reentrancy considered and it's safe STABLEC is a well known unchanging contract
SafeERC20.safeTransferFrom(STABLEC, address(_contract), address(this), pendingWithdrawal);
uint256 postWithdrawlReval = _contract.reval();
totalAllocationStablec = totalAllocationStablec - pendingWithdrawal;
treasuryAllocationsStablec[_contract] -= pendingWithdrawal;
require(postWithdrawlReval + pendingWithdrawal == preWithdrawlReval);
}
/**
* Withdraw from a contract which has some treasury allocation
*
* Ejects a contract out of treasury, pulling in any allowance of STABLEC
* We only expect to use this if (for whatever reason). The booking in
* The given TreasuryAllocation results in withdraw not working.
*
* Precondition, contract given has allocated all of it's Stablec assets
* to be transfered into treasury as an allowance.
*
* This will only ever reduce treasury IV.
*/
function ejectTreasuryAllocation(ITreasuryAllocation _contract) external onlyOwner {
uint256 pendingWithdrawal = STABLEC.allowance(address(_contract), address(this));
totalAllocationStablec -= treasuryAllocationsStablec[_contract];
treasuryAllocationsStablec[_contract] = 0;
SafeERC20.safeTransferFrom(STABLEC, address(_contract), address(this), pendingWithdrawal);
}
/**
* Add or update a pool, and transfer in treasury assets
*/
function upsertPool(address _contract, uint96 _poolHarvestShare) external onlyOwner {
require(_poolHarvestShare > 0, "Harvest share must be > 0");
totalHarvestShares = totalHarvestShares + _poolHarvestShare - poolHarvestShare[_contract];
// first time, add contract to array as well
if (poolHarvestShare[_contract] == 0) {
pools.push(_contract);
}
poolHarvestShare[_contract] = _poolHarvestShare;
}
/**
* Remove a given investment pool.
*/
function removePool(uint256 idx, address _contract) external onlyOwner {
require(idx < pools.length, "No pool at the specified index");
require(pools[idx] == _contract, "Pool at index and passed in address don't match");
pools[idx] = pools[pools.length-1];
pools.pop();
totalHarvestShares -= poolHarvestShare[_contract];
delete poolHarvestShare[_contract];
}
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ABDKMath64x64.sol";
import "./TempleERC20Token.sol";
import "./OGTemple.sol";
import "./ExitQueue.sol";
// import "hardhat/console.sol";
/**
* Mechancics of how a user can stake temple.
*/
contract TempleStaking is Ownable {
using ABDKMath64x64 for int128;
TempleERC20Token immutable public TEMPLE; // The token being staked, for which TEMPLE rewards are generated
OGTemple immutable public OG_TEMPLE; // Token used to redeem staked TEMPLE
ExitQueue public EXIT_QUEUE; // unstake exit queue
// epoch percentage yield, as an ABDKMath64x64
int128 public epy;
// epoch size, in seconds
uint256 public epochSizeSeconds;
// The starting timestamp. from where staking starts
uint256 public startTimestamp;
// epy compounded over every epoch since the contract creation up
// until lastUpdatedEpoch. Represented as an ABDKMath64x64
int128 public accumulationFactor;
// the epoch up to which we have calculated accumulationFactor.
uint256 public lastUpdatedEpoch;
event StakeCompleted(address _staker, uint256 _amount, uint256 _lockedUntil);
event AccumulationFactorUpdated(uint256 _epochsProcessed, uint256 _currentEpoch, uint256 _accumulationFactor);
event UnstakeCompleted(address _staker, uint256 _amount);
constructor(
TempleERC20Token _TEMPLE,
ExitQueue _EXIT_QUEUE,
uint256 _epochSizeSeconds,
uint256 _startTimestamp) {
require(_startTimestamp < block.timestamp, "Start timestamp must be in the past");
require(_startTimestamp > (block.timestamp - (24 * 2 * 60 * 60)), "Start timestamp can't be more than 2 days in the past");
TEMPLE = _TEMPLE;
EXIT_QUEUE = _EXIT_QUEUE;
// Each version of the staking contract needs it's own instance of OGTemple users can use to
// claim back rewards
OG_TEMPLE = new OGTemple();
epochSizeSeconds = _epochSizeSeconds;
startTimestamp = _startTimestamp;
epy = ABDKMath64x64.fromUInt(1);
accumulationFactor = ABDKMath64x64.fromUInt(1);
}
/** Sets epoch percentage yield */
function setExitQueue(ExitQueue _EXIT_QUEUE) external onlyOwner {
EXIT_QUEUE = _EXIT_QUEUE;
}
/** Sets epoch percentage yield */
function setEpy(uint256 _numerator, uint256 _denominator) external onlyOwner {
_updateAccumulationFactor();
epy = ABDKMath64x64.fromUInt(1).add(ABDKMath64x64.divu(_numerator, _denominator));
}
/** Get EPY as uint, scaled up the given factor (for reporting) */
function getEpy(uint256 _scale) external view returns (uint256) {
return epy.sub(ABDKMath64x64.fromUInt(1)).mul(ABDKMath64x64.fromUInt(_scale)).toUInt();
}
function currentEpoch() public view returns (uint256) {
return (block.timestamp - startTimestamp) / epochSizeSeconds;
}
/** Return current accumulation factor, scaled up to account for fractional component */
function getAccumulationFactor(uint256 _scale) external view returns(uint256) {
return _accumulationFactorAt(currentEpoch()).mul(ABDKMath64x64.fromUInt(_scale)).toUInt();
}
/** Calculate the updated accumulation factor, based on the current epoch */
function _accumulationFactorAt(uint256 epoch) private view returns(int128) {
uint256 _nUnupdatedEpochs = epoch - lastUpdatedEpoch;
return accumulationFactor.mul(epy.pow(_nUnupdatedEpochs));
}
/** Balance in TEMPLE for a given amount of OG_TEMPLE */
function balance(uint256 amountOgTemple) public view returns(uint256) {
return _overflowSafeMul1e18(
ABDKMath64x64.divu(amountOgTemple, 1e18).mul(_accumulationFactorAt(currentEpoch()))
);
}
/** updates rewards in pool */
function _updateAccumulationFactor() internal {
uint256 _currentEpoch = currentEpoch();
// still in previous epoch, no action.
// NOTE: should be a pre-condition that _currentEpoch >= lastUpdatedEpoch
// It's possible to end up in this state if we shorten epoch size.
// As such, it's not baked as a precondition
if (_currentEpoch <= lastUpdatedEpoch) {
return;
}
accumulationFactor = _accumulationFactorAt(_currentEpoch);
lastUpdatedEpoch = _currentEpoch;
uint256 _nUnupdatedEpochs = _currentEpoch - lastUpdatedEpoch;
emit AccumulationFactorUpdated(_nUnupdatedEpochs, _currentEpoch, accumulationFactor.mul(10000).toUInt());
}
/** Stake on behalf of a given address. Used by other contracts (like Presale) */
function stakeFor(address _staker, uint256 _amountTemple) public returns(uint256 amountOgTemple) {
require(_amountTemple > 0, "Cannot stake 0 tokens");
_updateAccumulationFactor();
// net past value/genesis value/OG Value for the temple you are putting in.
amountOgTemple = _overflowSafeMul1e18(ABDKMath64x64.divu(_amountTemple, 1e18).div(accumulationFactor));
SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amountTemple);
OG_TEMPLE.mint(_staker, amountOgTemple);
emit StakeCompleted(_staker, _amountTemple, 0);
return amountOgTemple;
}
/** Stake temple */
function stake(uint256 _amountTemple) external returns(uint256 amountOgTemple) {
return stakeFor(msg.sender, _amountTemple);
}
/** Unstake temple */
function unstake(uint256 _amountOgTemple) external {
require(OG_TEMPLE.allowance(msg.sender, address(this)) >= _amountOgTemple, 'Insufficient OGTemple allowance. Cannot unstake');
_updateAccumulationFactor();
uint256 unstakeBalanceTemple = balance(_amountOgTemple);
OG_TEMPLE.burnFrom(msg.sender, _amountOgTemple);
SafeERC20.safeIncreaseAllowance(TEMPLE, address(EXIT_QUEUE), unstakeBalanceTemple);
EXIT_QUEUE.join(msg.sender, unstakeBalanceTemple);
emit UnstakeCompleted(msg.sender, _amountOgTemple);
}
function _overflowSafeMul1e18(int128 amountFixedPoint) internal pure returns (uint256) {
uint256 integralDigits = amountFixedPoint.toUInt();
uint256 fractionalDigits = amountFixedPoint.sub(ABDKMath64x64.fromUInt(integralDigits)).mul(ABDKMath64x64.fromUInt(1e18)).toUInt();
return (integralDigits * 1e18) + fractionalDigits;
}
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./TempleERC20Token.sol";
import "./TempleTreasury.sol";
import "./TempleStaking.sol";
/**
* Who has what allocation in the presale period
*/
contract PresaleAllocation is Ownable {
struct Allocation {
uint256 amount;
uint256 epoch;
}
// maximum stablec each address can buy temple
mapping(address => Allocation) public allocationOf;
function setAllocation(address staker, uint256 amount, uint256 epoch) external onlyOwner {
allocationOf[staker].epoch = epoch;
allocationOf[staker].amount = amount;
}
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./OGTemple.sol";
/**
* Bookkeeping for OGTemple that's locked
*/
contract LockedOGTemple {
struct LockedEntry {
// How many tokens are locked
uint256 BalanceOGTemple;
// WHen can the user unlock these tokens
uint256 LockedUntilTimestamp;
}
// All temple locked for any given user
mapping(address => LockedEntry[]) public locked;
OGTemple public OG_TEMPLE; // The token being staked, for which TEMPLE rewards are generated
event OGTempleLocked(address _staker, uint256 _amount, uint256 _lockedUntil);
event OGTempleWithdraw(address _staker, uint256 _amount);
constructor(OGTemple _OG_TEMPLE) {
OG_TEMPLE = _OG_TEMPLE;
}
function numLocks(address _staker) external view returns(uint256) {
return locked[_staker].length;
}
/** lock up OG */
function lockFor(address _staker, uint256 _amountOGTemple, uint256 _lockedUntilTimestamp) public {
LockedEntry memory lockEntry = LockedEntry({BalanceOGTemple: _amountOGTemple, LockedUntilTimestamp: _lockedUntilTimestamp});
locked[_staker].push(lockEntry);
SafeERC20.safeTransferFrom(OG_TEMPLE, msg.sender, address(this), _amountOGTemple);
emit OGTempleLocked(_staker, _amountOGTemple, _lockedUntilTimestamp);
}
function lock(uint256 _amountOGTemple, uint256 _lockedUntilTimestamp) external {
lockFor(msg.sender, _amountOGTemple, _lockedUntilTimestamp);
}
/** Withdraw a specific locked entry */
function withdrawFor(address _staker, uint256 _idx) public {
LockedEntry[] storage lockedEntries = locked[_staker];
require(_idx < lockedEntries.length, "No lock entry at the specified index");
require(lockedEntries[_idx].LockedUntilTimestamp < block.timestamp, "Specified entry is still locked");
LockedEntry memory entry = lockedEntries[_idx];
lockedEntries[_idx] = lockedEntries[lockedEntries.length-1];
lockedEntries.pop();
SafeERC20.safeTransfer(OG_TEMPLE, _staker, entry.BalanceOGTemple);
emit OGTempleWithdraw(_staker, entry.BalanceOGTemple);
}
function withdraw(uint256 _idx) external {
withdrawFor(msg.sender, _idx);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(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) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(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) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason 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 {
// 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
unchecked {
_approve(account, _msgSender(), currentAllowance - amount);
}
_burn(account, amount);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
/**
* Contract which has treasury allocated from Stablec
*
* Reports back it's mark to market (so DAO can rebalance IV accordingly, from time to time)
*/
interface ITreasuryAllocation {
/**
* mark to market of treasury investment, denominated in Treasury Stablec
*/
function reval() external view returns (uint256);
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "./TempleERC20Token.sol";
/**
* Newly minted temple allocated to various temple strategies
*
* Any temple held by this contract is assumed to be unused,
* and hence doesn't effect the intrinsinc value calculation.
*
* It's only considered in circulation once a pool pulls
* it's allowance.
*/
contract MintAllowance is Ownable {
// Temple contract address
TempleERC20Token TEMPLE;
constructor(TempleERC20Token _TEMPLE) {
TEMPLE = _TEMPLE;
}
/**
* Increase mint allowance for the given pool
*
* Atomically pulls amount from treasury before increasing allownance
* as an extra check and balance
*/
function increaseMintAllowance(address _pool, uint256 _amount) external onlyOwner {
SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amount);
SafeERC20.safeIncreaseAllowance(TEMPLE, _pool, _amount);
}
/**
* Burn any unused mint allowance for a given pool
*/
function burnUnusedMintAllowance(address _pool) external onlyOwner {
uint256 unusedMintAllowance = TEMPLE.allowance(address(this), _pool);
SafeERC20.safeDecreaseAllowance(TEMPLE, _pool, unusedMintAllowance);
TEMPLE.burn(unusedMintAllowance);
}
}// SPDX-License-Identifier: BSD-4-Clause /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity ^0.8.4; /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /* * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /* * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { unchecked { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { unchecked { return int64 (x >> 64); } } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { unchecked { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (int256 (x << 64)); } } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { unchecked { require (x >= 0); return uint64 (uint128 (x >> 64)); } } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { unchecked { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { unchecked { return int256 (x) << 64; } } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { unchecked { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { unchecked { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (int256 (x)) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { unchecked { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { unchecked { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { unchecked { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return -x; } } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return x < 0 ? -x : x; } } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { unchecked { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { unchecked { return int128 ((int256 (x) + int256 (y)) >> 1); } } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); } } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { unchecked { bool negative = x < 0 && y & 1 == 1; uint256 absX = uint128 (x < 0 ? -x : x); uint256 absResult; absResult = 0x100000000000000000000000000000000; if (absX <= 0x10000000000000000) { absX <<= 63; while (y != 0) { if (y & 0x1 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x2 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x4 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x8 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; y >>= 4; } absResult >>= 64; } else { uint256 absXShift = 63; if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; } if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; } if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; } if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; } if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; } if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; } uint256 resultShift = 0; while (y != 0) { require (absXShift < 64); if (y & 0x1 != 0) { absResult = absResult * absX >> 127; resultShift += absXShift; if (absResult > 0x100000000000000000000000000000000) { absResult >>= 1; resultShift += 1; } } absX = absX * absX >> 127; absXShift <<= 1; if (absX >= 0x100000000000000000000000000000000) { absX >>= 1; absXShift += 1; } y >>= 1; } require (resultShift < 64); absResult >>= 64 - resultShift; } int256 result = negative ? -int256 (absResult) : int256 (absResult); require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { unchecked { require (x >= 0); return int128 (sqrtu (uint256 (int256 (x)) << 64)); } } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { unchecked { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb); for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { unchecked { require (x > 0); return int128 (int256 ( uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128)); } } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= uint256 (int256 (63 - (x >> 64))); require (result <= uint256 (int256 (MAX_64x64))); return int128 (int256 (result)); } } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { unchecked { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x) private pure returns (uint128) { unchecked { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint128 (r < r1 ? r : r1); } } } }
pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
/**
* Created and owned by the staking contract.
*
* It mints and burns OGTemple as users stake/unstake
*/
contract OGTemple is ERC20, ERC20Burnable, Ownable {
constructor() ERC20("OGTemple", "OG_TEMPLE") {}
function mint(address to, uint256 amount) external onlyOwner {
_mint(to, amount);
}
}pragma solidity ^0.8.4;
// SPDX-License-Identifier: GPL-3.0-or-later
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
// import "hardhat/console.sol";
/**
* How all exit of TEMPLE rewards are managed.
*/
contract ExitQueue is Ownable {
struct User {
// Total currently in queue
uint256 Amount;
// First epoch for which the user is in the unstake queue
uint256 FirstExitEpoch;
// Last epoch for which the user has a pending unstake
uint256 LastExitEpoch;
// All epochs where the user has an exit allocation
mapping(uint256 => uint256) Exits;
}
// total queued to be exited in a given epoch
mapping(uint256 => uint256) public totalPerEpoch;
// The first unwithdrawn epoch for the user
mapping(address => User) public userData;
IERC20 public TEMPLE; // TEMPLE
// Limit of how much temple can exit per epoch
uint256 public maxPerEpoch;
// Limit of how much temple can exit per address per epoch
uint256 public maxPerAddress;
// epoch size, in blocks
uint256 public epochSize;
// the block we use to work out what epoch we are in
uint256 public firstBlock;
// The next free block on which a user can commence their unstake
uint256 public nextUnallocatedEpoch;
event JoinQueue(address exiter, uint256 amount);
event Withdrawal(address exiter, uint256 amount);
constructor(
address _TEMPLE,
uint256 _maxPerEpoch,
uint256 _maxPerAddress,
uint256 _epochSize) {
TEMPLE = IERC20(_TEMPLE);
maxPerEpoch = _maxPerEpoch;
maxPerAddress = _maxPerAddress;
epochSize = _epochSize;
firstBlock = block.number;
nextUnallocatedEpoch = 0;
}
function setMaxPerEpoch(uint256 _maxPerEpoch) external onlyOwner {
maxPerEpoch = _maxPerEpoch;
}
function setMaxPerAddress(uint256 _maxPerAddress) external onlyOwner {
maxPerAddress = _maxPerAddress;
}
function setEpochSize(uint256 _epochSize) external onlyOwner {
epochSize = _epochSize;
}
function setStartingBlock(uint256 _firstBlock) external onlyOwner {
require(_firstBlock < firstBlock, "Can only move start block back, not forward");
firstBlock = _firstBlock;
}
function currentEpoch() public view returns (uint256) {
return (block.number - firstBlock) / epochSize;
}
function currentEpochAllocation(address _exiter, uint256 _epoch) external view returns (uint256) {
return userData[_exiter].Exits[_epoch];
}
function join(address _exiter, uint256 _amount) external {
require(_amount > 0, "Amount must be > 0");
if (nextUnallocatedEpoch < currentEpoch()) {
nextUnallocatedEpoch = currentEpoch();
}
User storage user = userData[_exiter];
uint256 unallocatedAmount = _amount;
uint256 _nextUnallocatedEpoch = nextUnallocatedEpoch;
uint256 nextAvailableEpochForUser = _nextUnallocatedEpoch;
if (user.LastExitEpoch > nextAvailableEpochForUser) {
nextAvailableEpochForUser = user.LastExitEpoch;
}
while (unallocatedAmount > 0) {
// work out allocation for the next available epoch
uint256 allocationForEpoch = unallocatedAmount;
if (user.Exits[nextAvailableEpochForUser] + allocationForEpoch > maxPerAddress) {
allocationForEpoch = maxPerAddress - user.Exits[nextAvailableEpochForUser];
}
if (totalPerEpoch[nextAvailableEpochForUser] + allocationForEpoch > maxPerEpoch) {
allocationForEpoch = maxPerEpoch - totalPerEpoch[nextAvailableEpochForUser];
}
// Bookkeeping
if (allocationForEpoch > 0) {
if (user.Amount == 0) {
user.FirstExitEpoch = nextAvailableEpochForUser;
}
user.Amount += allocationForEpoch;
user.Exits[nextAvailableEpochForUser] += allocationForEpoch;
totalPerEpoch[nextAvailableEpochForUser] += allocationForEpoch;
user.LastExitEpoch = nextAvailableEpochForUser;
if (totalPerEpoch[nextAvailableEpochForUser] >= maxPerEpoch) {
_nextUnallocatedEpoch = nextAvailableEpochForUser;
}
unallocatedAmount -= allocationForEpoch;
}
nextAvailableEpochForUser += 1;
}
// update outside of main loop, so we spend gas once
nextUnallocatedEpoch = _nextUnallocatedEpoch;
SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amount);
emit JoinQueue(_exiter, _amount);
}
/**
* Withdraw processed allowance from a specific epoch
*/
function withdraw(uint256 epoch) external {
require(epoch < currentEpoch(), "Can only withdraw from past epochs");
User storage user = userData[msg.sender];
uint256 amount = user.Exits[epoch];
delete user.Exits[epoch];
totalPerEpoch[epoch] -= amount; // TODO: WHen this goes to 0, is it the same as the data being removed?
user.Amount -= amount;
// Once all allocations on queue have been claimed, reset user state
if (user.Amount == 0) {
// NOTE: triggers ExitQueue.withdraw(uint256) (contracts/ExitQueue.sol #150-167) deletes ExitQueue.User (contracts/ExitQueue.sol#15-27) which contains a mapping
// This is okay as if Amount is 0, we'd expect user.Exits to be empty as well
// TODO: Confirm this via tests
delete userData[msg.sender];
}
SafeERC20.safeTransfer(TEMPLE, msg.sender, amount);
emit Withdrawal(msg.sender, amount);
}
}{
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IERC20","name":"_STABLEC","type":"address"},{"internalType":"contract TempleERC20Token","name":"_TEMPLE","type":"address"},{"internalType":"contract TempleStaking","name":"_STAKING","type":"address"},{"internalType":"contract LockedOGTemple","name":"_STAKING_LOCK","type":"address"},{"internalType":"contract TempleTreasury","name":"_TREASURY","type":"address"},{"internalType":"contract PresaleAllocation","name":"_PRESALE_ALLOCATION","type":"address"},{"internalType":"uint256","name":"_mintMultiple","type":"uint256"},{"internalType":"uint256","name":"_unlockTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"acceptedStablec","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintedTemple","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintedOGTemple","type":"uint256"}],"name":"MintComplete","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"PRESALE_ALLOCATION","outputs":[{"internalType":"contract PresaleAllocation","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STABLEC","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STAKING","outputs":[{"internalType":"contract TempleStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STAKING_LOCK","outputs":[{"internalType":"contract LockedOGTemple","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TEMPLE","outputs":[{"internalType":"contract TempleERC20Token","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TREASURY","outputs":[{"internalType":"contract TempleTreasury","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allocationUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountPaidStablec","type":"uint256"}],"name":"mintAndStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintMultiple","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_unlockTimestamp","type":"uint256"}],"name":"setUnlockTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b50604051620026c4380380620026c4833981810160405281019062000037919062000380565b620000576200004b6200021360201b60201c565b6200021b60201b60201c565b60008060146101000a81548160ff02191690831515021790555087600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555086600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555085600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600881905550806007819055505050505050505050620005af565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081519050620002f081620004f9565b92915050565b600081519050620003078162000513565b92915050565b6000815190506200031e816200052d565b92915050565b600081519050620003358162000547565b92915050565b6000815190506200034c8162000561565b92915050565b60008151905062000363816200057b565b92915050565b6000815190506200037a8162000595565b92915050565b600080600080600080600080610100898b0312156200039e57600080fd5b6000620003ae8b828c01620002df565b9850506020620003c18b828c0162000324565b9750506040620003d48b828c016200033b565b9650506060620003e78b828c01620002f6565b9550506080620003fa8b828c0162000352565b94505060a06200040d8b828c016200030d565b93505060c0620004208b828c0162000369565b92505060e0620004338b828c0162000369565b9150509295985092959890939650565b60006200045082620004cf565b9050919050565b6000620004648262000443565b9050919050565b6000620004788262000443565b9050919050565b60006200048c8262000443565b9050919050565b6000620004a08262000443565b9050919050565b6000620004b48262000443565b9050919050565b6000620004c88262000443565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b620005048162000457565b81146200051057600080fd5b50565b6200051e816200046b565b81146200052a57600080fd5b50565b62000538816200047f565b81146200054457600080fd5b50565b620005528162000493565b81146200055e57600080fd5b50565b6200056c81620004a7565b81146200057857600080fd5b50565b6200058681620004bb565b81146200059257600080fd5b50565b620005a081620004ef565b8114620005ac57600080fd5b50565b61210580620005bf6000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c80638456cb59116100a2578063a12d69a911610071578063a12d69a91461024c578063aa082a9d1461026a578063c7b5a48c14610288578063d960b37a146102a6578063f2fde38b146102c25761010b565b80638456cb59146101e85780638da5cb5b146101f257806391f01f561461021057806397610f301461022e5761010b565b806358b6ffce116100de57806358b6ffce146101745780635c975abb146101a4578063715018a6146101c2578063844c9026146101cc5761010b565b80632a768465146101105780632d2c55651461012e5780633f4ba83a1461014c57806350e23d0014610156575b600080fd5b6101186102de565b6040516101259190611b42565b60405180910390f35b6101366102e4565b60405161014391906119e5565b60405180910390f35b61015461030a565b005b61015e610390565b60405161016b91906119af565b60405180910390f35b61018e600480360381019061018991906114d7565b6103b6565b60405161019b9190611b42565b60405180910390f35b6101ac6103ce565b6040516101b99190611943565b60405180910390f35b6101ca6103e4565b005b6101e660048036038101906101e19190611552565b61046c565b005b6101f06104f2565b005b6101fa610578565b6040516102079190611823565b60405180910390f35b6102186105a1565b6040516102259190611979565b60405180910390f35b6102366105c7565b60405161024391906119ca565b60405180910390f35b6102546105ed565b604051610261919061195e565b60405180910390f35b610272610613565b60405161027f9190611b42565b60405180910390f35b610290610619565b60405161029d9190611994565b60405180910390f35b6102c060048036038101906102bb9190611552565b61063f565b005b6102dc60048036038101906102d791906114d7565b610d4f565b005b60085481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610312610e47565b73ffffffffffffffffffffffffffffffffffffffff16610330610578565b73ffffffffffffffffffffffffffffffffffffffff1614610386576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037d90611ae2565b60405180910390fd5b61038e610e4f565b565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60096020528060005260406000206000915090505481565b60008060149054906101000a900460ff16905090565b6103ec610e47565b73ffffffffffffffffffffffffffffffffffffffff1661040a610578565b73ffffffffffffffffffffffffffffffffffffffff1614610460576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045790611ae2565b60405180910390fd5b61046a6000610ef0565b565b610474610e47565b73ffffffffffffffffffffffffffffffffffffffff16610492610578565b73ffffffffffffffffffffffffffffffffffffffff16146104e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104df90611ae2565b60405180910390fd5b8060078190555050565b6104fa610e47565b73ffffffffffffffffffffffffffffffffffffffff16610518610578565b73ffffffffffffffffffffffffffffffffffffffff161461056e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056590611ae2565b60405180910390fd5b610576610fb4565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106476103ce565b15610687576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067e90611aa2565b60405180910390fd5b600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a4f82f27336040518263ffffffff1660e01b81526004016106e59190611823565b604080518083038186803b1580156106fc57600080fd5b505afa158015610710573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073491906115a4565b9150915081600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054846107849190611b8f565b11156107c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107bc90611a62565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663766718086040518163ffffffff1660e01b815260040160206040518083038186803b15801561082d57600080fd5b505afa158015610841573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610865919061157b565b8111156108a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089e90611ac2565b60405180910390fd5b600080600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a340bae26040518163ffffffff1660e01b8152600401604080518083038186803b15801561091157600080fd5b505afa158015610925573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094991906115a4565b9150915084600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461099c9190611b8f565b9250508190555060006008548383886109b59190611c16565b6109bf9190611be5565b6109c99190611be5565b9050610a1b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1689611057565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1930836040518363ffffffff1660e01b8152600401610a7892919061189e565b600060405180830381600087803b158015610a9257600080fd5b505af1158015610aa6573d6000803e3d6000fd5b50505050610af9600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836110e0565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a694fc3a836040518263ffffffff1660e01b8152600401610b569190611b42565b602060405180830381600087803b158015610b7057600080fd5b505af1158015610b84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba8919061157b565b9050610c76600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638f1284aa6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c1557600080fd5b505afa158015610c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4d9190611529565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836110e0565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166383e25f8a33836007546040518463ffffffff1660e01b8152600401610cd7939291906118c7565b600060405180830381600087803b158015610cf157600080fd5b505af1158015610d05573d6000803e3d6000fd5b505050507f5602d566c861324fa96773f7477d690ee55a90458f92bd5f17472a36fd78515633888484604051610d3e94939291906118fe565b60405180910390a150505050505050565b610d57610e47565b73ffffffffffffffffffffffffffffffffffffffff16610d75610578565b73ffffffffffffffffffffffffffffffffffffffff1614610dcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc290611ae2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3290611a42565b60405180910390fd5b610e4481610ef0565b50565b600033905090565b610e576103ce565b610e96576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8d90611a22565b60405180910390fd5b60008060146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610ed9610e47565b604051610ee69190611823565b60405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b610fbc6103ce565b15610ffc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff390611aa2565b60405180910390fd5b6001600060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611040610e47565b60405161104d9190611823565b60405180910390a1565b6110da846323b872dd60e01b85858560405160240161107893929190611867565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611201565b50505050565b6000818473ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30866040518363ffffffff1660e01b815260040161111e92919061183e565b60206040518083038186803b15801561113657600080fd5b505afa15801561114a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116e919061157b565b6111789190611b8f565b90506111fb8463095ea7b360e01b858460405160240161119992919061189e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611201565b50505050565b6000611263826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166112c89092919063ffffffff16565b90506000815111156112c357808060200190518101906112839190611500565b6112c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b990611b22565b60405180910390fd5b5b505050565b60606112d784846000856112e0565b90509392505050565b606082471015611325576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131c90611a82565b60405180910390fd5b61132e856113f4565b61136d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136490611b02565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611396919061180c565b60006040518083038185875af1925050503d80600081146113d3576040519150601f19603f3d011682016040523d82523d6000602084013e6113d8565b606091505b50915091506113e8828286611407565b92505050949350505050565b600080823b905060008111915050919050565b6060831561141757829050611467565b60008351111561142a5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145e9190611a00565b60405180910390fd5b9392505050565b60008135905061147d81612073565b92915050565b6000815190506114928161208a565b92915050565b6000815190506114a7816120a1565b92915050565b6000813590506114bc816120b8565b92915050565b6000815190506114d1816120b8565b92915050565b6000602082840312156114e957600080fd5b60006114f78482850161146e565b91505092915050565b60006020828403121561151257600080fd5b600061152084828501611483565b91505092915050565b60006020828403121561153b57600080fd5b600061154984828501611498565b91505092915050565b60006020828403121561156457600080fd5b6000611572848285016114ad565b91505092915050565b60006020828403121561158d57600080fd5b600061159b848285016114c2565b91505092915050565b600080604083850312156115b757600080fd5b60006115c5858286016114c2565b92505060206115d6858286016114c2565b9150509250929050565b6115e981611c70565b82525050565b6115f881611c82565b82525050565b600061160982611b5d565b6116138185611b73565b9350611623818560208601611da2565b80840191505092915050565b61163881611cca565b82525050565b61164781611cee565b82525050565b61165681611d12565b82525050565b61166581611d36565b82525050565b61167481611d5a565b82525050565b61168381611d7e565b82525050565b600061169482611b68565b61169e8185611b7e565b93506116ae818560208601611da2565b6116b781611e33565b840191505092915050565b60006116cf601483611b7e565b91506116da82611e44565b602082019050919050565b60006116f2602683611b7e565b91506116fd82611e6d565b604082019050919050565b6000611715602a83611b7e565b915061172082611ebc565b604082019050919050565b6000611738602683611b7e565b915061174382611f0b565b604082019050919050565b600061175b601083611b7e565b915061176682611f5a565b602082019050919050565b600061177e602783611b7e565b915061178982611f83565b604082019050919050565b60006117a1602083611b7e565b91506117ac82611fd2565b602082019050919050565b60006117c4601d83611b7e565b91506117cf82611ffb565b602082019050919050565b60006117e7602a83611b7e565b91506117f282612024565b604082019050919050565b61180681611cc0565b82525050565b600061181882846115fe565b915081905092915050565b600060208201905061183860008301846115e0565b92915050565b600060408201905061185360008301856115e0565b61186060208301846115e0565b9392505050565b600060608201905061187c60008301866115e0565b61188960208301856115e0565b61189660408301846117fd565b949350505050565b60006040820190506118b360008301856115e0565b6118c060208301846117fd565b9392505050565b60006060820190506118dc60008301866115e0565b6118e960208301856117fd565b6118f660408301846117fd565b949350505050565b600060808201905061191360008301876115e0565b61192060208301866117fd565b61192d60408301856117fd565b61193a60608301846117fd565b95945050505050565b600060208201905061195860008301846115ef565b92915050565b6000602082019050611973600083018461162f565b92915050565b600060208201905061198e600083018461163e565b92915050565b60006020820190506119a9600083018461164d565b92915050565b60006020820190506119c4600083018461165c565b92915050565b60006020820190506119df600083018461166b565b92915050565b60006020820190506119fa600083018461167a565b92915050565b60006020820190508181036000830152611a1a8184611689565b905092915050565b60006020820190508181036000830152611a3b816116c2565b9050919050565b60006020820190508181036000830152611a5b816116e5565b9050919050565b60006020820190508181036000830152611a7b81611708565b9050919050565b60006020820190508181036000830152611a9b8161172b565b9050919050565b60006020820190508181036000830152611abb8161174e565b9050919050565b60006020820190508181036000830152611adb81611771565b9050919050565b60006020820190508181036000830152611afb81611794565b9050919050565b60006020820190508181036000830152611b1b816117b7565b9050919050565b60006020820190508181036000830152611b3b816117da565b9050919050565b6000602082019050611b5760008301846117fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000611b9a82611cc0565b9150611ba583611cc0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611bda57611bd9611dd5565b5b828201905092915050565b6000611bf082611cc0565b9150611bfb83611cc0565b925082611c0b57611c0a611e04565b5b828204905092915050565b6000611c2182611cc0565b9150611c2c83611cc0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611c6557611c64611dd5565b5b828202905092915050565b6000611c7b82611ca0565b9050919050565b60008115159050919050565b6000611c9982611c70565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000611cd582611cdc565b9050919050565b6000611ce782611ca0565b9050919050565b6000611cf982611d00565b9050919050565b6000611d0b82611ca0565b9050919050565b6000611d1d82611d24565b9050919050565b6000611d2f82611ca0565b9050919050565b6000611d4182611d48565b9050919050565b6000611d5382611ca0565b9050919050565b6000611d6582611d6c565b9050919050565b6000611d7782611ca0565b9050919050565b6000611d8982611d90565b9050919050565b6000611d9b82611ca0565b9050919050565b60005b83811015611dc0578082015181840152602081019050611da5565b83811115611dcf576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74207265717565737465642065786365656420616464726573732060008201527f616c6c6f636174696f6e00000000000000000000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f55736572277320616c6c6f63617465642065706f636820697320696e2074686560008201527f2066757475726500000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b61207c81611c70565b811461208757600080fd5b50565b61209381611c82565b811461209e57600080fd5b50565b6120aa81611c8e565b81146120b557600080fd5b50565b6120c181611cc0565b81146120cc57600080fd5b5056fea2646970667358221220e51389f1e557102bfc55eeee5df1a0679572202c512ae9ad544f595c51e291aa64736f6c63430008040033000000000000000000000000853d955acef822db058eb8505911ed77f175b99e000000000000000000000000470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b70000000000000000000000004d14b24edb751221b3ff08bbb8bd91d4b1c8bc77000000000000000000000000879b843868da248b1f2f53b4f8cc6e17e7e8b94900000000000000000000000022c2fe05f55f81bf32310acd9a7c51c4d7b4e4430000000000000000000000006cf2a119f98a4b4a7fa4fd08a1e72d7af3ba72fe00000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000061964040
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c80638456cb59116100a2578063a12d69a911610071578063a12d69a91461024c578063aa082a9d1461026a578063c7b5a48c14610288578063d960b37a146102a6578063f2fde38b146102c25761010b565b80638456cb59146101e85780638da5cb5b146101f257806391f01f561461021057806397610f301461022e5761010b565b806358b6ffce116100de57806358b6ffce146101745780635c975abb146101a4578063715018a6146101c2578063844c9026146101cc5761010b565b80632a768465146101105780632d2c55651461012e5780633f4ba83a1461014c57806350e23d0014610156575b600080fd5b6101186102de565b6040516101259190611b42565b60405180910390f35b6101366102e4565b60405161014391906119e5565b60405180910390f35b61015461030a565b005b61015e610390565b60405161016b91906119af565b60405180910390f35b61018e600480360381019061018991906114d7565b6103b6565b60405161019b9190611b42565b60405180910390f35b6101ac6103ce565b6040516101b99190611943565b60405180910390f35b6101ca6103e4565b005b6101e660048036038101906101e19190611552565b61046c565b005b6101f06104f2565b005b6101fa610578565b6040516102079190611823565b60405180910390f35b6102186105a1565b6040516102259190611979565b60405180910390f35b6102366105c7565b60405161024391906119ca565b60405180910390f35b6102546105ed565b604051610261919061195e565b60405180910390f35b610272610613565b60405161027f9190611b42565b60405180910390f35b610290610619565b60405161029d9190611994565b60405180910390f35b6102c060048036038101906102bb9190611552565b61063f565b005b6102dc60048036038101906102d791906114d7565b610d4f565b005b60085481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610312610e47565b73ffffffffffffffffffffffffffffffffffffffff16610330610578565b73ffffffffffffffffffffffffffffffffffffffff1614610386576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037d90611ae2565b60405180910390fd5b61038e610e4f565b565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60096020528060005260406000206000915090505481565b60008060149054906101000a900460ff16905090565b6103ec610e47565b73ffffffffffffffffffffffffffffffffffffffff1661040a610578565b73ffffffffffffffffffffffffffffffffffffffff1614610460576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045790611ae2565b60405180910390fd5b61046a6000610ef0565b565b610474610e47565b73ffffffffffffffffffffffffffffffffffffffff16610492610578565b73ffffffffffffffffffffffffffffffffffffffff16146104e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104df90611ae2565b60405180910390fd5b8060078190555050565b6104fa610e47565b73ffffffffffffffffffffffffffffffffffffffff16610518610578565b73ffffffffffffffffffffffffffffffffffffffff161461056e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056590611ae2565b60405180910390fd5b610576610fb4565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106476103ce565b15610687576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067e90611aa2565b60405180910390fd5b600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a4f82f27336040518263ffffffff1660e01b81526004016106e59190611823565b604080518083038186803b1580156106fc57600080fd5b505afa158015610710573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073491906115a4565b9150915081600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054846107849190611b8f565b11156107c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107bc90611a62565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663766718086040518163ffffffff1660e01b815260040160206040518083038186803b15801561082d57600080fd5b505afa158015610841573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610865919061157b565b8111156108a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089e90611ac2565b60405180910390fd5b600080600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a340bae26040518163ffffffff1660e01b8152600401604080518083038186803b15801561091157600080fd5b505afa158015610925573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094991906115a4565b9150915084600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461099c9190611b8f565b9250508190555060006008548383886109b59190611c16565b6109bf9190611be5565b6109c99190611be5565b9050610a1b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1689611057565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1930836040518363ffffffff1660e01b8152600401610a7892919061189e565b600060405180830381600087803b158015610a9257600080fd5b505af1158015610aa6573d6000803e3d6000fd5b50505050610af9600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836110e0565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a694fc3a836040518263ffffffff1660e01b8152600401610b569190611b42565b602060405180830381600087803b158015610b7057600080fd5b505af1158015610b84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba8919061157b565b9050610c76600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638f1284aa6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c1557600080fd5b505afa158015610c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4d9190611529565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836110e0565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166383e25f8a33836007546040518463ffffffff1660e01b8152600401610cd7939291906118c7565b600060405180830381600087803b158015610cf157600080fd5b505af1158015610d05573d6000803e3d6000fd5b505050507f5602d566c861324fa96773f7477d690ee55a90458f92bd5f17472a36fd78515633888484604051610d3e94939291906118fe565b60405180910390a150505050505050565b610d57610e47565b73ffffffffffffffffffffffffffffffffffffffff16610d75610578565b73ffffffffffffffffffffffffffffffffffffffff1614610dcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc290611ae2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3290611a42565b60405180910390fd5b610e4481610ef0565b50565b600033905090565b610e576103ce565b610e96576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8d90611a22565b60405180910390fd5b60008060146101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610ed9610e47565b604051610ee69190611823565b60405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b610fbc6103ce565b15610ffc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff390611aa2565b60405180910390fd5b6001600060146101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611040610e47565b60405161104d9190611823565b60405180910390a1565b6110da846323b872dd60e01b85858560405160240161107893929190611867565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611201565b50505050565b6000818473ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30866040518363ffffffff1660e01b815260040161111e92919061183e565b60206040518083038186803b15801561113657600080fd5b505afa15801561114a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116e919061157b565b6111789190611b8f565b90506111fb8463095ea7b360e01b858460405160240161119992919061189e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611201565b50505050565b6000611263826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166112c89092919063ffffffff16565b90506000815111156112c357808060200190518101906112839190611500565b6112c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b990611b22565b60405180910390fd5b5b505050565b60606112d784846000856112e0565b90509392505050565b606082471015611325576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131c90611a82565b60405180910390fd5b61132e856113f4565b61136d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136490611b02565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611396919061180c565b60006040518083038185875af1925050503d80600081146113d3576040519150601f19603f3d011682016040523d82523d6000602084013e6113d8565b606091505b50915091506113e8828286611407565b92505050949350505050565b600080823b905060008111915050919050565b6060831561141757829050611467565b60008351111561142a5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145e9190611a00565b60405180910390fd5b9392505050565b60008135905061147d81612073565b92915050565b6000815190506114928161208a565b92915050565b6000815190506114a7816120a1565b92915050565b6000813590506114bc816120b8565b92915050565b6000815190506114d1816120b8565b92915050565b6000602082840312156114e957600080fd5b60006114f78482850161146e565b91505092915050565b60006020828403121561151257600080fd5b600061152084828501611483565b91505092915050565b60006020828403121561153b57600080fd5b600061154984828501611498565b91505092915050565b60006020828403121561156457600080fd5b6000611572848285016114ad565b91505092915050565b60006020828403121561158d57600080fd5b600061159b848285016114c2565b91505092915050565b600080604083850312156115b757600080fd5b60006115c5858286016114c2565b92505060206115d6858286016114c2565b9150509250929050565b6115e981611c70565b82525050565b6115f881611c82565b82525050565b600061160982611b5d565b6116138185611b73565b9350611623818560208601611da2565b80840191505092915050565b61163881611cca565b82525050565b61164781611cee565b82525050565b61165681611d12565b82525050565b61166581611d36565b82525050565b61167481611d5a565b82525050565b61168381611d7e565b82525050565b600061169482611b68565b61169e8185611b7e565b93506116ae818560208601611da2565b6116b781611e33565b840191505092915050565b60006116cf601483611b7e565b91506116da82611e44565b602082019050919050565b60006116f2602683611b7e565b91506116fd82611e6d565b604082019050919050565b6000611715602a83611b7e565b915061172082611ebc565b604082019050919050565b6000611738602683611b7e565b915061174382611f0b565b604082019050919050565b600061175b601083611b7e565b915061176682611f5a565b602082019050919050565b600061177e602783611b7e565b915061178982611f83565b604082019050919050565b60006117a1602083611b7e565b91506117ac82611fd2565b602082019050919050565b60006117c4601d83611b7e565b91506117cf82611ffb565b602082019050919050565b60006117e7602a83611b7e565b91506117f282612024565b604082019050919050565b61180681611cc0565b82525050565b600061181882846115fe565b915081905092915050565b600060208201905061183860008301846115e0565b92915050565b600060408201905061185360008301856115e0565b61186060208301846115e0565b9392505050565b600060608201905061187c60008301866115e0565b61188960208301856115e0565b61189660408301846117fd565b949350505050565b60006040820190506118b360008301856115e0565b6118c060208301846117fd565b9392505050565b60006060820190506118dc60008301866115e0565b6118e960208301856117fd565b6118f660408301846117fd565b949350505050565b600060808201905061191360008301876115e0565b61192060208301866117fd565b61192d60408301856117fd565b61193a60608301846117fd565b95945050505050565b600060208201905061195860008301846115ef565b92915050565b6000602082019050611973600083018461162f565b92915050565b600060208201905061198e600083018461163e565b92915050565b60006020820190506119a9600083018461164d565b92915050565b60006020820190506119c4600083018461165c565b92915050565b60006020820190506119df600083018461166b565b92915050565b60006020820190506119fa600083018461167a565b92915050565b60006020820190508181036000830152611a1a8184611689565b905092915050565b60006020820190508181036000830152611a3b816116c2565b9050919050565b60006020820190508181036000830152611a5b816116e5565b9050919050565b60006020820190508181036000830152611a7b81611708565b9050919050565b60006020820190508181036000830152611a9b8161172b565b9050919050565b60006020820190508181036000830152611abb8161174e565b9050919050565b60006020820190508181036000830152611adb81611771565b9050919050565b60006020820190508181036000830152611afb81611794565b9050919050565b60006020820190508181036000830152611b1b816117b7565b9050919050565b60006020820190508181036000830152611b3b816117da565b9050919050565b6000602082019050611b5760008301846117fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000611b9a82611cc0565b9150611ba583611cc0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611bda57611bd9611dd5565b5b828201905092915050565b6000611bf082611cc0565b9150611bfb83611cc0565b925082611c0b57611c0a611e04565b5b828204905092915050565b6000611c2182611cc0565b9150611c2c83611cc0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611c6557611c64611dd5565b5b828202905092915050565b6000611c7b82611ca0565b9050919050565b60008115159050919050565b6000611c9982611c70565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000611cd582611cdc565b9050919050565b6000611ce782611ca0565b9050919050565b6000611cf982611d00565b9050919050565b6000611d0b82611ca0565b9050919050565b6000611d1d82611d24565b9050919050565b6000611d2f82611ca0565b9050919050565b6000611d4182611d48565b9050919050565b6000611d5382611ca0565b9050919050565b6000611d6582611d6c565b9050919050565b6000611d7782611ca0565b9050919050565b6000611d8982611d90565b9050919050565b6000611d9b82611ca0565b9050919050565b60005b83811015611dc0578082015181840152602081019050611da5565b83811115611dcf576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74207265717565737465642065786365656420616464726573732060008201527f616c6c6f636174696f6e00000000000000000000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f55736572277320616c6c6f63617465642065706f636820697320696e2074686560008201527f2066757475726500000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b61207c81611c70565b811461208757600080fd5b50565b61209381611c82565b811461209e57600080fd5b50565b6120aa81611c8e565b81146120b557600080fd5b50565b6120c181611cc0565b81146120cc57600080fd5b5056fea2646970667358221220e51389f1e557102bfc55eeee5df1a0679572202c512ae9ad544f595c51e291aa64736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000853d955acef822db058eb8505911ed77f175b99e000000000000000000000000470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b70000000000000000000000004d14b24edb751221b3ff08bbb8bd91d4b1c8bc77000000000000000000000000879b843868da248b1f2f53b4f8cc6e17e7e8b94900000000000000000000000022c2fe05f55f81bf32310acd9a7c51c4d7b4e4430000000000000000000000006cf2a119f98a4b4a7fa4fd08a1e72d7af3ba72fe00000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000061964040
-----Decoded View---------------
Arg [0] : _STABLEC (address): 0x853d955aCEf822Db058eb8505911ED77F175b99e
Arg [1] : _TEMPLE (address): 0x470EBf5f030Ed85Fc1ed4C2d36B9DD02e77CF1b7
Arg [2] : _STAKING (address): 0x4D14b24EDb751221B3Ff08BBB8bd91D4b1c8bc77
Arg [3] : _STAKING_LOCK (address): 0x879B843868dA248B1F2F53b4f8CC6e17e7E8b949
Arg [4] : _TREASURY (address): 0x22c2fE05f55F81Bf32310acD9a7C51c4d7b4e443
Arg [5] : _PRESALE_ALLOCATION (address): 0x6cf2A119f98A4B4A7FA4Fd08A1E72D7aF3ba72FE
Arg [6] : _mintMultiple (uint256): 6
Arg [7] : _unlockTimestamp (uint256): 1637236800
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000853d955acef822db058eb8505911ed77f175b99e
Arg [1] : 000000000000000000000000470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7
Arg [2] : 0000000000000000000000004d14b24edb751221b3ff08bbb8bd91d4b1c8bc77
Arg [3] : 000000000000000000000000879b843868da248b1f2f53b4f8cc6e17e7e8b949
Arg [4] : 00000000000000000000000022c2fe05f55f81bf32310acd9a7c51c4d7b4e443
Arg [5] : 0000000000000000000000006cf2a119f98a4b4a7fa4fd08a1e72d7af3ba72fe
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [7] : 0000000000000000000000000000000000000000000000000000000061964040
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 100.00% | $0.993674 | 51 | $50.68 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.