Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 25 from a total of 254 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Deposit | 24511362 | 1 min ago | IN | 0 ETH | 0.00002231 | ||||
| Deposit | 24511343 | 5 mins ago | IN | 0 ETH | 0.00000791 | ||||
| Deposit | 24511218 | 30 mins ago | IN | 0 ETH | 0.00003138 | ||||
| Deposit | 24510138 | 4 hrs ago | IN | 0 ETH | 0.00006408 | ||||
| Deposit | 24509917 | 4 hrs ago | IN | 0 ETH | 0.00001835 | ||||
| Deposit | 24509856 | 5 hrs ago | IN | 0 ETH | 0.00001877 | ||||
| Deposit | 24509837 | 5 hrs ago | IN | 0 ETH | 0.00001713 | ||||
| Deposit | 24509803 | 5 hrs ago | IN | 0 ETH | 0.00001213 | ||||
| Deposit | 24509798 | 5 hrs ago | IN | 0 ETH | 0.00001781 | ||||
| Deposit | 24509759 | 5 hrs ago | IN | 0 ETH | 0.00001775 | ||||
| Deposit | 24509736 | 5 hrs ago | IN | 0 ETH | 0.00001695 | ||||
| Deposit | 24509288 | 6 hrs ago | IN | 0 ETH | 0.00001086 | ||||
| Deposit | 24508898 | 8 hrs ago | IN | 0 ETH | 0.0000249 | ||||
| Deposit | 24508871 | 8 hrs ago | IN | 0 ETH | 0.00002272 | ||||
| Deposit | 24508811 | 8 hrs ago | IN | 0 ETH | 0.00006552 | ||||
| Deposit | 24508785 | 8 hrs ago | IN | 0 ETH | 0.00003147 | ||||
| Deposit | 24508772 | 8 hrs ago | IN | 0 ETH | 0.00001813 | ||||
| Deposit | 24508731 | 8 hrs ago | IN | 0 ETH | 0.00001981 | ||||
| Deposit | 24507922 | 11 hrs ago | IN | 0 ETH | 0.0000639 | ||||
| Deposit | 24507904 | 11 hrs ago | IN | 0 ETH | 0.00006445 | ||||
| Deposit | 24507025 | 14 hrs ago | IN | 0 ETH | 0.00004141 | ||||
| Deposit | 24506975 | 14 hrs ago | IN | 0 ETH | 0.00004744 | ||||
| Deposit | 24506923 | 14 hrs ago | IN | 0 ETH | 0.00002159 | ||||
| Deposit | 24506872 | 15 hrs ago | IN | 0 ETH | 0.00001186 | ||||
| Deposit | 24506831 | 15 hrs ago | IN | 0 ETH | 0.00001668 |
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x61022060 | 24470154 | 5 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x40f348C8...8cF250935 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
GaugeCL
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT OR GPL-3.0-or-later
pragma solidity 0.8.13;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import '@cryptoalgebra/integral-core/contracts/interfaces/IAlgebraPool.sol';
import '../interfaces/IAlgebraEternalFarmingCustom.sol';
import '../interfaces/IAlgebraCustomCommunityVault.sol';
import '../interfaces/IGaugeFactoryCL.sol';
import '../interfaces/IGaugeManager.sol';
import '@cryptoalgebra/integral-periphery/contracts/interfaces/INonfungiblePositionManager.sol';
import '@cryptoalgebra/integral-farming/contracts/interfaces/IAlgebraEternalFarming.sol';
import '@cryptoalgebra/integral-farming/contracts/interfaces/IAlgebraEternalVirtualPool.sol';
import '@cryptoalgebra/integral-farming/contracts/interfaces/IFarmingCenter.sol';
import '@cryptoalgebra/integral-farming/contracts/base/IncentiveKey.sol';
import '@cryptoalgebra/integral-core/contracts/interfaces/IERC20Minimal.sol';
import '../interfaces/IBribe.sol';
import {BlackTimeLibrary} from "../libraries/BlackTimeLibrary.sol";
import {IncentiveId} from '@cryptoalgebra/integral-farming/contracts/libraries/IncentiveId.sol';
import {REFERRAL_FEE_DENOMINATOR} from '../libraries/Constants.sol';
import '../interfaces/IGaugeCL.sol';
contract GaugeCL is ReentrancyGuard, Ownable, IGaugeCL {
using SafeERC20 for IERC20;
IERC20 public immutable rewardToken;
IERC20 public immutable bonusRewardToken;
address public immutable VE;
address public immutable DISTRIBUTION;
address public immutable internal_bribe;
address public immutable external_bribe;
uint256 public immutable DURATION;
uint256 internal _periodFinish;
uint256 public rewardRate;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
IFarmingCenter public immutable farmingCenter;
IAlgebraEternalFarming public immutable algebraEternalFarming;
IAlgebraPool public immutable algebraPool;
address public immutable poolAddress;
INonfungiblePositionManager public immutable nonfungiblePositionManager;
bool public emergency;
address immutable factory;
uint16 private constant ALGEBRA_FEE_DENOMINATOR = 1000;
event RewardAdded(uint256 reward);
event Deposit(address indexed user, uint256 amount);
event Withdraw(address indexed user, uint256 amount);
event Harvest(address indexed user, uint256 reward);
event ClaimFees(address indexed from, uint256 claimed0, uint256 claimed1);
event EmergencyActivated();
event EmergencyDeactivated();
constructor(address _rewardToken, address _ve, address _pool, address _distribution, address _internal_bribe,
address _external_bribe, IGaugeManager.FarmingParam memory _farmingParam, address _bonusRewardToken, address _factory) {
factory = _factory;
rewardToken = IERC20(_rewardToken); // main reward
bonusRewardToken = IERC20(_bonusRewardToken);
VE = _ve; // vested
poolAddress = _pool;
algebraPool = IAlgebraPool(_pool);
DISTRIBUTION = _distribution; // distro address (GaugeManager)
DURATION = BlackTimeLibrary.WEEK;
internal_bribe = _internal_bribe; // lp fees goes here
external_bribe = _external_bribe; // bribe fees goes here
farmingCenter = IFarmingCenter(_farmingParam.farmingCenter);
algebraEternalFarming = IAlgebraEternalFarming(_farmingParam.algebraEternalFarming);
nonfungiblePositionManager = INonfungiblePositionManager(_farmingParam.nfpm);
emergency = false;
}
modifier onlyDistribution() {
require(msg.sender == DISTRIBUTION, "NA");
_;
}
modifier isNotEmergency() {
require(!emergency, "emergency");
_;
}
function activateEmergencyMode() external onlyOwner {
require(!emergency, "emergency");
emergency = true;
emit EmergencyActivated();
}
function stopEmergencyMode() external onlyOwner {
require(emergency, "emergency");
emergency = false;
emit EmergencyDeactivated();
}
function balanceOf(uint256 tokenId) external view returns (uint256) {
(IERC20Minimal rewardTokenAdd, IERC20Minimal bonusRewardTokenAdd, IAlgebraPool pool, uint256 nonce) =
algebraEternalFarming.incentiveKeys(poolAddress);
IncentiveKey memory incentivekey = IncentiveKey(rewardTokenAdd, bonusRewardTokenAdd, pool, nonce);
(uint128 liquidity,,,,) = algebraEternalFarming.farms(tokenId, IncentiveId.compute(incentivekey));
return liquidity;
}
function earned(uint256 tokenId) external view returns (uint256 reward, uint256 bonusReward) {
(IERC20Minimal rewardTokenAdd, IERC20Minimal bonusRewardTokenAdd, IAlgebraPool pool, uint256 nonce) =
algebraEternalFarming.incentiveKeys(poolAddress);
IncentiveKey memory incentivekey = IncentiveKey(rewardTokenAdd, bonusRewardTokenAdd, pool, nonce);
/// @notice reward amounts can be outdated by using getRewardInfo, actual amounts could be obtained via static call of `collectRewards` in FarmingCenter
(reward, bonusReward) = IAlgebraEternalFarmingCustom(address(algebraEternalFarming)).getRewardInfo(incentivekey, tokenId);
return (reward, bonusReward);
}
function deposit(uint256 tokenId) external nonReentrant isNotEmergency {
require(msg.sender == nonfungiblePositionManager.ownerOf(tokenId));
nonfungiblePositionManager.approveForFarming(tokenId, true, address(farmingCenter));
(IERC20Minimal rewardTokenAdd, IERC20Minimal bonusRewardTokenAdd, IAlgebraPool pool, uint256 nonce) =
algebraEternalFarming.incentiveKeys(poolAddress);
IncentiveKey memory incentivekey = IncentiveKey(rewardTokenAdd, bonusRewardTokenAdd, pool, nonce);
farmingCenter.enterFarming(incentivekey, tokenId);
emit Deposit(msg.sender, tokenId);
}
function withdraw(uint256 tokenId) external nonReentrant isNotEmergency {
require(msg.sender == nonfungiblePositionManager.ownerOf(tokenId));
(IERC20Minimal rewardTokenAdd, IERC20Minimal bonusRewardTokenAdd, IAlgebraPool pool, uint256 nonce) =
algebraEternalFarming.incentiveKeys(poolAddress);
IncentiveKey memory incentivekey = IncentiveKey(rewardTokenAdd, bonusRewardTokenAdd, pool, nonce);
farmingCenter.exitFarming(incentivekey, tokenId);
emit Withdraw(msg.sender, tokenId);
}
function notifyRewardAmount(address token, uint256 reward) external nonReentrant
isNotEmergency onlyDistribution returns (IncentiveKey memory, uint256, uint128) {
require(token == address(rewardToken), "not rew token");
// Transfer emission to Farming Virtual Pool address
uint256 duration = BlackTimeLibrary.epochNext(block.timestamp) - block.timestamp;
if (block.timestamp >= _periodFinish) {
rewardRate = reward / duration;
} else {
uint256 leftover = duration * rewardRate;
rewardRate = (reward + leftover) / duration;
}
_periodFinish = BlackTimeLibrary.epochNext(block.timestamp);
(IERC20Minimal rewardTokenAdd, IERC20Minimal bonusRewardTokenAdd, IAlgebraPool pool, uint256 nonce) =
algebraEternalFarming.incentiveKeys(poolAddress);
IncentiveKey memory incentivekey = IncentiveKey(rewardTokenAdd, bonusRewardTokenAdd, pool, nonce);
// set RewardRate to AlgebraVirtual Pool
(,,address virtualPoolAddress,,,) = algebraEternalFarming.incentives(IncentiveId.compute(incentivekey));
(,uint128 bonusRewardRate) = IAlgebraEternalVirtualPool(virtualPoolAddress).rewardRates();
rewardToken.safeTransferFrom(msg.sender, address(this), reward);
IERC20(token).forceApprove(address(algebraEternalFarming), reward);
// transfer emission Reward to Algebra Virtual Pool
algebraEternalFarming.addRewards(incentivekey, uint128(reward), 0);
emit RewardAdded(reward);
return(incentivekey, rewardRate, bonusRewardRate);
}
function gaugeBalances() external view returns (uint256 token0, uint256 token1){
address _token0 = algebraPool.token0();
address _token1 = algebraPool.token1();
token0 = IERC20(_token0).balanceOf(address(this));
token1 = IERC20(_token1).balanceOf(address(this));
}
function claimFees() external nonReentrant returns (uint256 claimed0, uint256 claimed1) {
return _claimFees();
}
function _claimFees() internal returns (uint256 claimed0, uint256 claimed1) {
address _token0 = algebraPool.token0();
address _token1 = algebraPool.token1();
// Fetch fee from the whole epoch which just ended and transfer it to internal Bribe address.
claimed0 = IERC20(_token0).balanceOf(address(this));
claimed1 = IERC20(_token1).balanceOf(address(this));
if (claimed0 > 0 || claimed1 > 0) {
// Deduct dibsPercentage from fee accrued and transfer to dibs address(Foundation address)
uint256 referralFee = IGaugeFactoryCL(factory).dibsPercentage();
address dibs = IGaugeFactoryCL(factory).dibs();
uint256 _dibsFeeToken0 = (dibs != address(0)) ? (claimed0 * referralFee / REFERRAL_FEE_DENOMINATOR) : 0;
uint256 _dibsFeeToken1 = (dibs != address(0)) ? (claimed1 * referralFee / REFERRAL_FEE_DENOMINATOR) : 0;
if (_dibsFeeToken0 > 0) {
_safeTransfer(_token0, dibs, _dibsFeeToken0); // Transfer dibs fees
claimed0 = claimed0 - _dibsFeeToken0;
}
if (_dibsFeeToken1 > 0) {
_safeTransfer(_token1, dibs, _dibsFeeToken1); // Transfer dibs fees
claimed1 = claimed1 - _dibsFeeToken1;
}
if (claimed0 > 0) {
IERC20(_token0).forceApprove(internal_bribe, claimed0);
IBribe(internal_bribe).notifyRewardAmount(_token0, claimed0);
}
if (claimed1 > 0) {
IERC20(_token1).forceApprove(internal_bribe, claimed1);
IBribe(internal_bribe).notifyRewardAmount(_token1, claimed1);
}
emit ClaimFees(msg.sender, claimed0, claimed1);
}
}
///@notice get total reward for the duration
function rewardForDuration() external view returns (uint256) {
return rewardRate * DURATION;
}
function _safeTransfer(address token,address to,uint256 value) internal {
require(token.code.length > 0);
(bool success, bytes memory data) = token.call(abi.encodeCall(IERC20.transfer, (to, value)));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
function stakedFees() external view returns (uint256 totalFeeToken0, uint256 totalFeeToken1) {
// Balance of token0/token1 at Gauge Address and AlgebraCommunityVault address.
uint256 gaugeAccruedFeeToken0 = IERC20(algebraPool.token0()).balanceOf(address(this));
uint256 gaugeAccruedFeeToken1 = IERC20(algebraPool.token1()).balanceOf(address(this));
(uint256 communityVaultAccruedFeeToken0, uint256 communityVaultAccruedFeeToken1)
= getCommunityVaultAccruedFee();
totalFeeToken0 = gaugeAccruedFeeToken0 + communityVaultAccruedFeeToken0;
totalFeeToken1 = gaugeAccruedFeeToken1 + communityVaultAccruedFeeToken1;
uint256 referralFee = IGaugeFactoryCL(factory).dibsPercentage();
address dibs = IGaugeFactoryCL(factory).dibs();
uint256 _dibsFeeToken0 = (dibs != address(0)) ? (totalFeeToken0 * referralFee / REFERRAL_FEE_DENOMINATOR) : 0;
uint256 _dibsFeeToken1 = (dibs != address(0)) ? (totalFeeToken1 * referralFee / REFERRAL_FEE_DENOMINATOR) : 0;
totalFeeToken0 -= _dibsFeeToken0;
totalFeeToken1 -= _dibsFeeToken1;
}
function getCommunityVaultAccruedFee() internal view returns (uint256 communityVaultAccruedFeeToken0, uint256 communityVaultAccruedFeeToken1) {
address communityVaultAddress = algebraPool.communityVault();
communityVaultAccruedFeeToken0 = IERC20(algebraPool.token0()).balanceOf(communityVaultAddress);
communityVaultAccruedFeeToken1 = IERC20(algebraPool.token1()).balanceOf(communityVaultAddress);
(uint128 communityFeePending0, uint128 communityFeePending1) = algebraPool.getCommunityFeePending();
communityVaultAccruedFeeToken0 += communityFeePending0;
communityVaultAccruedFeeToken1 += communityFeePending1;
uint16 algebraFee = IAlgebraCustomCommunityVault(communityVaultAddress).algebraFee();
uint256 algebraFeeToken0 = communityVaultAccruedFeeToken0 * algebraFee / ALGEBRA_FEE_DENOMINATOR;
uint256 algebraFeeToken1 = communityVaultAccruedFeeToken1 * algebraFee / ALGEBRA_FEE_DENOMINATOR;
communityVaultAccruedFeeToken0 -= algebraFeeToken0;
communityVaultAccruedFeeToken1 -= algebraFeeToken1;
}
///@notice total liquidity in the active tick
function totalActiveSupply() public view returns (uint256 _totalActiveSupply) {
(IERC20Minimal rewardTokenAdd, IERC20Minimal bonusRewardTokenAdd, IAlgebraPool pool, uint256 nonce) =
algebraEternalFarming.incentiveKeys(poolAddress);
IncentiveKey memory incentivekey = IncentiveKey(rewardTokenAdd, bonusRewardTokenAdd, pool, nonce);
bytes32 incentiveId = IncentiveId.compute(incentivekey);
// set RewardRate to AlgebraVirtual Pool
(,,address virtualPoolAddress,,,) = algebraEternalFarming.incentives(incentiveId);
_totalActiveSupply = IAlgebraEternalVirtualPool(virtualPoolAddress).currentLiquidity();
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the virtual pool
/// @dev Used to calculate active liquidity in farmings
interface IAlgebraVirtualPool {
/// @dev This function is called by the main pool if an initialized ticks are crossed by swap.
/// If any one of crossed ticks is also initialized in a virtual pool it should be crossed too
/// @param targetTick The target tick up to which we need to cross all active ticks
/// @param zeroToOne Swap direction
function crossTo(int24 targetTick, bool zeroToOne) external returns (bool success);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the Algebra farming plugin
/// @dev This contract used for virtual pools in farms
interface IFarmingPlugin {
/// @notice Emitted when new activeIncentive is set
/// @param newIncentive The address of the new incentive
event Incentive(address newIncentive);
/// @notice Connects or disconnects an incentive.
/// @dev Only farming can connect incentives.
/// The one who connected it and the current farming has the right to disconnect the incentive.
/// @param newIncentive The address associated with the incentive or zero address
function setIncentive(address newIncentive) external;
/// @notice Checks if the incentive is connected to pool
/// @dev Returns false if the plugin has a different incentive set, the plugin is not connected to the pool,
/// or the plugin configuration is incorrect.
/// @param targetIncentive The address of the incentive to be checked
/// @return Indicates whether the target incentive is active
function isIncentiveConnected(address targetIncentive) external view returns (bool);
/// @notice Returns the address of active incentive
/// @dev if there is no active incentive at the moment, incentiveAddress would be equal to address(0)
/// @return The address associated with the current active incentive
function incentive() external view returns (address);
/// @notice Returns the address of the pool the plugin is created for
/// @return address of the pool
function getPool() external view returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.4;
import './pool/IAlgebraPoolImmutables.sol';
import './pool/IAlgebraPoolState.sol';
import './pool/IAlgebraPoolActions.sol';
import './pool/IAlgebraPoolPermissionedActions.sol';
import './pool/IAlgebraPoolEvents.sol';
import './pool/IAlgebraPoolErrors.sol';
/// @title The interface for a Algebra Pool
/// @dev The pool interface is broken up into many smaller pieces.
/// This interface includes custom error definitions and cannot be used in older versions of Solidity.
/// For older versions of Solidity use #IAlgebraPoolLegacy
/// Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPool is
IAlgebraPoolImmutables,
IAlgebraPoolState,
IAlgebraPoolActions,
IAlgebraPoolPermissionedActions,
IAlgebraPoolEvents,
IAlgebraPoolErrors
{
// used only for combining interfaces
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Minimal ERC20 interface for Algebra
/// @notice Contains a subset of the full ERC20 interface that is used in Algebra
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IERC20Minimal {
/// @notice Returns the balance of a token
/// @param account The account for which to look up the number of tokens it has, i.e. its balance
/// @return The number of tokens held by the account
function balanceOf(address account) external view returns (uint256);
/// @notice Transfers the amount of token from the `msg.sender` to the recipient
/// @param recipient The account that will receive the amount transferred
/// @param amount The number of tokens to send from the sender to the recipient
/// @return Returns true for a successful transfer, false for an unsuccessful transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/// @notice Returns the current allowance given to a spender by an owner
/// @param owner The account of the token owner
/// @param spender The account of the token spender
/// @return The current allowance granted by `owner` to `spender`
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
/// @param spender The account which will be allowed to spend a given amount of the owners tokens
/// @param amount The amount of tokens allowed to be used by `spender`
/// @return Returns true for a successful approval, false for unsuccessful
function approve(address spender, uint256 amount) external returns (bool);
/// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
/// @param sender The account from which the transfer will be initiated
/// @param recipient The recipient of the transfer
/// @param amount The amount of the transfer
/// @return Returns true for a successful transfer, false for unsuccessful
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
/// @param from The account from which the tokens were sent, i.e. the balance decreased
/// @param to The account to which the tokens were sent, i.e. the balance increased
/// @param value The amount of tokens that were transferred
event Transfer(address indexed from, address indexed to, uint256 value);
/// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
/// @param owner The account that approved spending of its tokens
/// @param spender The account for which the spending allowance was modified
/// @param value The new allowance from the owner to the spender
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @dev Initialization should be done in one transaction with pool creation to avoid front-running
/// @param initialPrice The initial sqrt price of the pool as a Q64.96
function initialize(uint160 initialPrice) external;
/// @notice Adds liquidity for the given recipient/bottomTick/topTick position
/// @dev The caller of this method receives a callback in the form of IAlgebraMintCallback#algebraMintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on bottomTick, topTick, the amount of liquidity, and the current price.
/// @param leftoversRecipient The address which will receive potential surplus of paid tokens
/// @param recipient The address for which the liquidity will be created
/// @param bottomTick The lower tick of the position in which to add liquidity
/// @param topTick The upper tick of the position in which to add liquidity
/// @param liquidityDesired The desired amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return liquidityActual The actual minted amount of liquidity
function mint(
address leftoversRecipient,
address recipient,
int24 bottomTick,
int24 topTick,
uint128 liquidityDesired,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1, uint128 liquidityActual);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param bottomTick The lower tick of the position for which to collect fees
/// @param topTick The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 bottomTick,
int24 topTick,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param bottomTick The lower tick of the position for which to burn liquidity
/// @param topTick The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @param data Any data that should be passed through to the plugin
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(int24 bottomTick, int24 topTick, uint128 amount, bytes calldata data) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IAlgebraSwapCallback#algebraSwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroToOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountRequired The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param limitSqrtPrice The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback. If using the Router it should contain SwapRouter#SwapCallbackData
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroToOne,
int256 amountRequired,
uint160 limitSqrtPrice,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Swap token0 for token1, or token1 for token0 with prepayment
/// @dev The caller of this method receives a callback in the form of IAlgebraSwapCallback#algebraSwapCallback
/// caller must send tokens in callback before swap calculation
/// the actually sent amount of tokens is used for further calculations
/// @param leftoversRecipient The address which will receive potential surplus of paid tokens
/// @param recipient The address to receive the output of the swap
/// @param zeroToOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountToSell The amount of the swap, only positive (exact input) amount allowed
/// @param limitSqrtPrice The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback. If using the Router it should contain SwapRouter#SwapCallbackData
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swapWithPaymentInAdvance(
address leftoversRecipient,
address recipient,
bool zeroToOne,
int256 amountToSell,
uint160 limitSqrtPrice,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IAlgebraFlashCallback#algebraFlashCallback
/// @dev All excess tokens paid in the callback are distributed to currently in-range liquidity providers as an additional fee.
/// If there are no in-range liquidity providers, the fee will be transferred to the first active provider in the future
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(address recipient, uint256 amount0, uint256 amount1, bytes calldata data) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.4;
/// @title Errors emitted by a pool
/// @notice Contains custom errors emitted by the pool
/// @dev Custom errors are separated from the common pool interface for compatibility with older versions of Solidity
interface IAlgebraPoolErrors {
// #### pool errors ####
/// @notice Emitted by the reentrancy guard
error locked();
/// @notice Emitted if arithmetic error occurred
error arithmeticError();
/// @notice Emitted if an attempt is made to initialize the pool twice
error alreadyInitialized();
/// @notice Emitted if an attempt is made to mint or swap in uninitialized pool
error notInitialized();
/// @notice Emitted if 0 is passed as amountRequired to swap function
error zeroAmountRequired();
/// @notice Emitted if invalid amount is passed as amountRequired to swap function
error invalidAmountRequired();
/// @notice Emitted if plugin fee param greater than fee/override fee
error incorrectPluginFee();
/// @notice Emitted if the pool received fewer tokens than it should have
error insufficientInputAmount();
/// @notice Emitted if there was an attempt to mint zero liquidity
error zeroLiquidityDesired();
/// @notice Emitted if actual amount of liquidity is zero (due to insufficient amount of tokens received)
error zeroLiquidityActual();
/// @notice Emitted if the pool received fewer tokens0 after flash than it should have
error flashInsufficientPaid0();
/// @notice Emitted if the pool received fewer tokens1 after flash than it should have
error flashInsufficientPaid1();
/// @notice Emitted if limitSqrtPrice param is incorrect
error invalidLimitSqrtPrice();
/// @notice Tick must be divisible by tickspacing
error tickIsNotSpaced();
/// @notice Emitted if a method is called that is accessible only to the factory owner or dedicated role
error notAllowed();
/// @notice Emitted if new tick spacing exceeds max allowed value
error invalidNewTickSpacing();
/// @notice Emitted if new community fee exceeds max allowed value
error invalidNewCommunityFee();
/// @notice Emitted if an attempt is made to manually change the fee value, but dynamic fee is enabled
error dynamicFeeActive();
/// @notice Emitted if an attempt is made by plugin to change the fee value, but dynamic fee is disabled
error dynamicFeeDisabled();
/// @notice Emitted if an attempt is made to change the plugin configuration, but the plugin is not connected
error pluginIsNotConnected();
/// @notice Emitted if a plugin returns invalid selector after hook call
/// @param expectedSelector The expected selector
error invalidHookResponse(bytes4 expectedSelector);
// #### LiquidityMath errors ####
/// @notice Emitted if liquidity underflows
error liquiditySub();
/// @notice Emitted if liquidity overflows
error liquidityAdd();
// #### TickManagement errors ####
/// @notice Emitted if the topTick param not greater then the bottomTick param
error topTickLowerOrEqBottomTick();
/// @notice Emitted if the bottomTick param is lower than min allowed value
error bottomTickLowerThanMIN();
/// @notice Emitted if the topTick param is greater than max allowed value
error topTickAboveMAX();
/// @notice Emitted if the liquidity value associated with the tick exceeds MAX_LIQUIDITY_PER_TICK
error liquidityOverflow();
/// @notice Emitted if an attempt is made to interact with an uninitialized tick
error tickIsNotInitialized();
/// @notice Emitted if there is an attempt to insert a new tick into the list of ticks with incorrect indexes of the previous and next ticks
error tickInvalidLinks();
// #### SafeTransfer errors ####
/// @notice Emitted if token transfer failed internally
error transferFailed();
// #### TickMath errors ####
/// @notice Emitted if tick is greater than the maximum or less than the minimum allowed value
error tickOutOfRange();
/// @notice Emitted if price is greater than the maximum or less than the minimum allowed value
error priceOutOfRange();
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swaps cannot be emitted by the pool before Initialize
/// @param price The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 price, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param bottomTick The lower tick of the position
/// @param topTick The upper tick of the position
/// @param liquidityAmount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed bottomTick,
int24 indexed topTick,
uint128 liquidityAmount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @param owner The owner of the position for which fees are collected
/// @param recipient The address that received fees
/// @param bottomTick The lower tick of the position
/// @param topTick The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(address indexed owner, address recipient, int24 indexed bottomTick, int24 indexed topTick, uint128 amount0, uint128 amount1);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param bottomTick The lower tick of the position
/// @param topTick The upper tick of the position
/// @param liquidityAmount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed bottomTick,
int24 indexed topTick,
uint128 liquidityAmount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when a plugin fee is applied during a burn
/// @param owner The owner of the position
/// @param pluginFee The fee to be sent to the plugin
event BurnFee(address indexed owner, uint24 pluginFee);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param price The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 price,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool after any swaps
/// @param sender The address that initiated the swap
/// @param overrideFee The fee to be applied to the trade
/// @param pluginFee The fee to be sent to the plugin
event SwapFee(address indexed sender, uint24 overrideFee, uint24 pluginFee);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1);
/// @notice Emitted when the pool has higher balances than expected.
/// Any excess of tokens will be distributed between liquidity providers as fee.
/// @dev Fees after flash also will trigger this event due to mechanics of flash.
/// @param amount0 The excess of token0
/// @param amount1 The excess of token1
event ExcessTokens(uint256 amount0, uint256 amount1);
/// @notice Emitted when the community fee is changed by the pool
/// @param communityFeeNew The updated value of the community fee in thousandths (1e-3)
event CommunityFee(uint16 communityFeeNew);
/// @notice Emitted when the tick spacing changes
/// @param newTickSpacing The updated value of the new tick spacing
event TickSpacing(int24 newTickSpacing);
/// @notice Emitted when the plugin address changes
/// @param newPluginAddress New plugin address
event Plugin(address newPluginAddress);
/// @notice Emitted when the plugin config changes
/// @param newPluginConfig New plugin config
event PluginConfig(uint8 newPluginConfig);
/// @notice Emitted when the fee changes inside the pool
/// @param fee The current fee in hundredths of a bip, i.e. 1e-6
event Fee(uint16 fee);
/// @notice Emitted when the community vault address changes
/// @param newCommunityVault New community vault
event CommunityVault(address newCommunityVault);
/// @notice Emitted when the plugin does skim the excess of tokens
/// @param to THe receiver of tokens (plugin)
/// @param amount0 The amount of token0
/// @param amount1 The amount of token1
event Skim(address indexed to, uint256 amount0, uint256 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolImmutables {
/// @notice The Algebra factory contract, which must adhere to the IAlgebraFactory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by permissioned addresses
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolPermissionedActions {
/// @notice Set the community's % share of the fees. Only factory owner or POOLS_ADMINISTRATOR_ROLE role
/// @param newCommunityFee The new community fee percent in thousandths (1e-3)
function setCommunityFee(uint16 newCommunityFee) external;
/// @notice Set the new tick spacing values. Only factory owner or POOLS_ADMINISTRATOR_ROLE role
/// @param newTickSpacing The new tick spacing value
function setTickSpacing(int24 newTickSpacing) external;
/// @notice Set the new plugin address. Only factory owner or POOLS_ADMINISTRATOR_ROLE role
/// @param newPluginAddress The new plugin address
function setPlugin(address newPluginAddress) external;
/// @notice Set new plugin config. Only factory owner or POOLS_ADMINISTRATOR_ROLE role
/// @param newConfig In the new configuration of the plugin,
/// each bit of which is responsible for a particular hook.
function setPluginConfig(uint8 newConfig) external;
/// @notice Set new community fee vault address. Only factory owner or POOLS_ADMINISTRATOR_ROLE role
/// @dev Community fee vault receives collected community fees.
/// **accumulated but not yet sent to the vault community fees once will be sent to the `newCommunityVault` address**
/// @param newCommunityVault The address of new community fee vault
function setCommunityVault(address newCommunityVault) external;
/// @notice Set new pool fee. Can be called by owner if dynamic fee is disabled.
/// Called by the plugin if dynamic fee is enabled
/// @param newFee The new fee value
function setFee(uint16 newFee) external;
/// @notice Forces balances to match reserves. Excessive tokens will be distributed between active LPs
/// @dev Only plugin can call this function
function sync() external;
/// @notice Forces balances to match reserves. Excessive tokens will be sent to msg.sender
/// @dev Only plugin can call this function
function skim() external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that can change
/// @dev Important security note: when using this data by external contracts, it is necessary to take into account the possibility
/// of manipulation (including read-only reentrancy).
/// This interface is based on the UniswapV3 interface, credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPoolState {
/// @notice Safely get most important state values of Algebra Integral AMM
/// @dev Several values exposed as a single method to save gas when accessed externally.
/// **Important security note: this method checks reentrancy lock and should be preferred in most cases**.
/// @return sqrtPrice The current price of the pool as a sqrt(dToken1/dToken0) Q64.96 value
/// @return tick The current global tick of the pool. May not always be equal to SqrtTickMath.getTickAtSqrtRatio(price) if the price is on a tick boundary
/// @return lastFee The current (last known) pool fee value in hundredths of a bip, i.e. 1e-6 (so '100' is '0.01%'). May be obsolete if using dynamic fee plugin
/// @return pluginConfig The current plugin config as bitmap. Each bit is responsible for enabling/disabling the hooks, the last bit turns on/off dynamic fees logic
/// @return activeLiquidity The currently in-range liquidity available to the pool
/// @return nextTick The next initialized tick after current global tick
/// @return previousTick The previous initialized tick before (or at) current global tick
function safelyGetStateOfAMM()
external
view
returns (uint160 sqrtPrice, int24 tick, uint16 lastFee, uint8 pluginConfig, uint128 activeLiquidity, int24 nextTick, int24 previousTick);
/// @notice Allows to easily get current reentrancy lock status
/// @dev can be used to prevent read-only reentrancy.
/// This method just returns `globalState.unlocked` value
/// @return unlocked Reentrancy lock flag, true if the pool currently is unlocked, otherwise - false
function isUnlocked() external view returns (bool unlocked);
// ! IMPORTANT security note: the pool state can be manipulated.
// ! The following methods do not check reentrancy lock themselves.
/// @notice The globalState structure in the pool stores many values but requires only one slot
/// and is exposed as a single method to save gas when accessed externally.
/// @dev **important security note: caller should check `unlocked` flag to prevent read-only reentrancy**
/// @return price The current price of the pool as a sqrt(dToken1/dToken0) Q64.96 value
/// @return tick The current tick of the pool, i.e. according to the last tick transition that was run
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(price) if the price is on a tick boundary
/// @return lastFee The current (last known) pool fee value in hundredths of a bip, i.e. 1e-6 (so '100' is '0.01%'). May be obsolete if using dynamic fee plugin
/// @return pluginConfig The current plugin config as bitmap. Each bit is responsible for enabling/disabling the hooks, the last bit turns on/off dynamic fees logic
/// @return communityFee The community fee represented as a percent of all collected fee in thousandths, i.e. 1e-3 (so 100 is 10%)
/// @return unlocked Reentrancy lock flag, true if the pool currently is unlocked, otherwise - false
function globalState() external view returns (uint160 price, int24 tick, uint16 lastFee, uint8 pluginConfig, uint16 communityFee, bool unlocked);
/// @notice Look up information about a specific tick in the pool
/// @dev **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @param tick The tick to look up
/// @return liquidityTotal The total amount of position liquidity that uses the pool either as tick lower or tick upper
/// @return liquidityDelta How much liquidity changes when the pool price crosses the tick
/// @return prevTick The previous tick in tick list
/// @return nextTick The next tick in tick list
/// @return outerFeeGrowth0Token The fee growth on the other side of the tick from the current tick in token0
/// @return outerFeeGrowth1Token The fee growth on the other side of the tick from the current tick in token1
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(
int24 tick
)
external
view
returns (
uint256 liquidityTotal,
int128 liquidityDelta,
int24 prevTick,
int24 nextTick,
uint256 outerFeeGrowth0Token,
uint256 outerFeeGrowth1Token
);
/// @notice The timestamp of the last sending of tokens to vault/plugin
/// @return The timestamp truncated to 32 bits
function lastFeeTransferTimestamp() external view returns (uint32);
/// @notice The amounts of token0 and token1 that will be sent to the vault
/// @dev Will be sent FEE_TRANSFER_FREQUENCY after communityFeeLastTimestamp
/// @return communityFeePending0 The amount of token0 that will be sent to the vault
/// @return communityFeePending1 The amount of token1 that will be sent to the vault
function getCommunityFeePending() external view returns (uint128 communityFeePending0, uint128 communityFeePending1);
/// @notice The amounts of token0 and token1 that will be sent to the plugin
/// @dev Will be sent FEE_TRANSFER_FREQUENCY after feeLastTransferTimestamp
/// @return pluginFeePending0 The amount of token0 that will be sent to the plugin
/// @return pluginFeePending1 The amount of token1 that will be sent to the plugin
function getPluginFeePending() external view returns (uint128 pluginFeePending0, uint128 pluginFeePending1);
/// @notice Returns the address of currently used plugin
/// @dev The plugin is subject to change
/// @return pluginAddress The address of currently used plugin
function plugin() external view returns (address pluginAddress);
/// @notice The contract to which community fees are transferred
/// @return communityVaultAddress The communityVault address
function communityVault() external view returns (address communityVaultAddress);
/// @notice Returns 256 packed tick initialized boolean values. See TickTree for more information
/// @param wordPosition Index of 256-bits word with ticks
/// @return The 256-bits word with packed ticks info
function tickTable(int16 wordPosition) external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
/// @return The fee growth accumulator for token0
function totalFeeGrowth0Token() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
/// @return The fee growth accumulator for token1
function totalFeeGrowth1Token() external view returns (uint256);
/// @notice The current pool fee value
/// @dev In case dynamic fee is enabled in the pool, this method will call the plugin to get the current fee.
/// If the plugin implements complex fee logic, this method may return an incorrect value or revert.
/// In this case, see the plugin implementation and related documentation.
/// @dev **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @return currentFee The current pool fee value in hundredths of a bip, i.e. 1e-6
function fee() external view returns (uint16 currentFee);
/// @notice The tracked token0 and token1 reserves of pool
/// @dev If at any time the real balance is larger, the excess will be transferred to liquidity providers as additional fee.
/// If the balance exceeds uint128, the excess will be sent to the communityVault.
/// @return reserve0 The last known reserve of token0
/// @return reserve1 The last known reserve of token1
function getReserves() external view returns (uint128 reserve0, uint128 reserve1);
/// @notice Returns the information about a position by the position's key
/// @dev **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @param key The position's key is a packed concatenation of the owner address, bottomTick and topTick indexes
/// @return liquidity The amount of liquidity in the position
/// @return innerFeeGrowth0Token Fee growth of token0 inside the tick range as of the last mint/burn/poke
/// @return innerFeeGrowth1Token Fee growth of token1 inside the tick range as of the last mint/burn/poke
/// @return fees0 The computed amount of token0 owed to the position as of the last mint/burn/poke
/// @return fees1 The computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(
bytes32 key
) external view returns (uint256 liquidity, uint256 innerFeeGrowth0Token, uint256 innerFeeGrowth1Token, uint128 fees0, uint128 fees1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks.
/// Returned value cannot exceed type(uint128).max
/// @dev **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @return The current in range liquidity
function liquidity() external view returns (uint128);
/// @notice The current tick spacing
/// @dev Ticks can only be initialized by new mints at multiples of this value
/// e.g.: a tickSpacing of 60 means ticks can be initialized every 60th tick, i.e., ..., -120, -60, 0, 60, 120, ...
/// However, tickspacing can be changed after the ticks have been initialized.
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The current tick spacing
function tickSpacing() external view returns (int24);
/// @notice The previous initialized tick before (or at) current global tick
/// @dev **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @return The previous initialized tick
function prevTickGlobal() external view returns (int24);
/// @notice The next initialized tick after current global tick
/// @dev **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @return The next initialized tick
function nextTickGlobal() external view returns (int24);
/// @notice The root of tick search tree
/// @dev Each bit corresponds to one node in the second layer of tick tree: '1' if node has at least one active bit.
/// **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @return The root of tick search tree as bitmap
function tickTreeRoot() external view returns (uint32);
/// @notice The second layer of tick search tree
/// @dev Each bit in node corresponds to one node in the leafs layer (`tickTable`) of tick tree: '1' if leaf has at least one active bit.
/// **important security note: caller should check reentrancy lock to prevent read-only reentrancy**
/// @return The node of tick search tree second layer
function tickTreeSecondLayer(int16) external view returns (uint256);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the Algebra community fee vault
/// @notice Community fee from pools is sent here, if it is enabled
/// @dev Version: Algebra Integral
interface IAlgebraCommunityVault {
/// @notice Event emitted when a fees has been claimed
/// @param token The address of token fee
/// @param to The address where claimed rewards were sent to
/// @param amount The amount of fees tokens claimed by communityFeeReceiver
event TokensWithdrawal(address indexed token, address indexed to, uint256 amount);
/// @notice Event emitted when a fees has been claimed
/// @param token The address of token fee
/// @param to The address where claimed rewards were sent to
/// @param amount The amount of fees tokens claimed by Algebra
event AlgebraTokensWithdrawal(address indexed token, address indexed to, uint256 amount);
/// @notice Emitted when a AlgebraFeeReceiver address changed
/// @param newAlgebraFeeReceiver New Algebra fee receiver address
event AlgebraFeeReceiver(address newAlgebraFeeReceiver);
/// @notice Emitted when a AlgebraFeeManager address change proposed
/// @param pendingAlgebraFeeManager New pending Algebra fee manager address
event PendingAlgebraFeeManager(address pendingAlgebraFeeManager);
/// @notice Emitted when a new Algebra fee value proposed
/// @param proposedNewAlgebraFee The new proposed Algebra fee value
event AlgebraFeeProposal(uint16 proposedNewAlgebraFee);
/// @notice Emitted when a Algebra fee proposal canceled
event CancelAlgebraFeeProposal();
/// @notice Emitted when a AlgebraFeeManager address changed
/// @param newAlgebraFeeManager New Algebra fee manager address
event AlgebraFeeManager(address newAlgebraFeeManager);
/// @notice Emitted when the Algebra fee is changed
/// @param newAlgebraFee The new Algebra fee value
event AlgebraFee(uint16 newAlgebraFee);
/// @notice Emitted when a CommunityFeeReceiver address changed
/// @param newCommunityFeeReceiver New fee receiver address
event CommunityFeeReceiver(address newCommunityFeeReceiver);
/// @notice Withdraw protocol fees from vault
/// @dev Can only be called by algebraFeeManager or communityFeeReceiver
/// @param token The token address
/// @param amount The amount of token
function withdraw(address token, uint256 amount) external;
struct WithdrawTokensParams {
address token;
uint256 amount;
}
/// @notice Withdraw protocol fees from vault. Used to claim fees for multiple tokens
/// @dev Can be called by algebraFeeManager or communityFeeReceiver
/// @param params Array of WithdrawTokensParams objects containing token addresses and amounts to withdraw
function withdrawTokens(WithdrawTokensParams[] calldata params) external;
// ### algebra factory owner permissioned actions ###
/// @notice Accepts the proposed new Algebra fee
/// @dev Can only be called by the factory owner.
/// The new value will also be used for previously accumulated tokens that have not yet been withdrawn
/// @param newAlgebraFee New Algebra fee value
function acceptAlgebraFeeChangeProposal(uint16 newAlgebraFee) external;
/// @notice Change community fee receiver address
/// @dev Can only be called by the factory owner
/// @param newCommunityFeeReceiver New community fee receiver address
function changeCommunityFeeReceiver(address newCommunityFeeReceiver) external;
// ### algebra fee manager permissioned actions ###
/// @notice Transfers Algebra fee manager role
/// @param _newAlgebraFeeManager new Algebra fee manager address
function transferAlgebraFeeManagerRole(address _newAlgebraFeeManager) external;
/// @notice accept Algebra FeeManager role
function acceptAlgebraFeeManagerRole() external;
/// @notice Proposes new Algebra fee value for protocol
/// @dev the new value will also be used for previously accumulated tokens that have not yet been withdrawn
/// @param newAlgebraFee new Algebra fee value
function proposeAlgebraFeeChange(uint16 newAlgebraFee) external;
/// @notice Cancels Algebra fee change proposal
function cancelAlgebraFeeChangeProposal() external;
/// @notice Change Algebra community fee part receiver
/// @param newAlgebraFeeReceiver The address of new Algebra fee receiver
function changeAlgebraFeeReceiver(address newAlgebraFeeReceiver) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
pragma abicoder v2;
import '@cryptoalgebra/integral-core/contracts/interfaces/IERC20Minimal.sol';
import '@cryptoalgebra/integral-core/contracts/interfaces/IAlgebraPool.sol';
/// @param rewardToken The token being distributed as a reward (token0)
/// @param bonusRewardToken The bonus token being distributed as a reward (token1)
/// @param pool The Algebra pool
/// @param nonce The nonce of incentive
struct IncentiveKey {
IERC20Minimal rewardToken;
IERC20Minimal bonusRewardToken;
IAlgebraPool pool;
uint256 nonce;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.4;
import '@cryptoalgebra/integral-periphery/contracts/interfaces/INonfungiblePositionManager.sol';
import '../base/IncentiveKey.sol';
/// @title Algebra Eternal Farming Interface
/// @notice Allows farming nonfungible liquidity tokens in exchange for reward tokens without locking NFT for incentive time
interface IAlgebraEternalFarming {
/// @notice Details of the incentive to create
struct IncentiveParams {
uint128 reward; // The amount of reward tokens to be distributed
uint128 bonusReward; // The amount of bonus reward tokens to be distributed
uint128 rewardRate; // The rate of reward distribution per second
uint128 bonusRewardRate; // The rate of bonus reward distribution per second
uint24 minimalPositionWidth; // The minimal allowed width of position (tickUpper - tickLower)
}
error farmDoesNotExist();
error tokenAlreadyFarmed();
error incentiveNotExist();
error incentiveStopped();
error anotherFarmingIsActive();
error pluginNotConnected();
error minimalPositionWidthTooWide();
error zeroRewardAmount();
error positionIsTooNarrow();
error zeroLiquidity();
error invalidPool();
error claimToZeroAddress();
error invalidTokenAmount();
error emergencyActivated();
error reentrancyLock();
error poolReentrancyLock();
/// @notice Returns hash of 'INCENTIVE_MAKER_ROLE', used as role for incentive creation
function INCENTIVE_MAKER_ROLE() external view returns (bytes32);
/// @notice Returns hash of 'FARMINGS_ADMINISTRATOR_ROLE', used as role for permissioned actions in farming
function FARMINGS_ADMINISTRATOR_ROLE() external view returns (bytes32);
/// @notice The nonfungible position manager with which this farming contract is compatible
function nonfungiblePositionManager() external view returns (INonfungiblePositionManager);
/// @notice Represents a farming incentive
/// @param incentiveId The ID of the incentive computed from its parameters
function incentives(
bytes32 incentiveId
)
external
view
returns (
uint128 totalReward,
uint128 bonusReward,
address virtualPoolAddress,
uint24 minimalPositionWidth,
bool deactivated,
address pluginAddress
);
/// @notice Check if incentive is deactivated (manually or automatically)
/// @dev Does not check if the incentive is indeed currently connected to the Algebra pool or not
/// @param incentiveId The ID of the incentive computed from its parameters
/// @return True if incentive is deactivated (manually or automatically)
function isIncentiveDeactivated(bytes32 incentiveId) external view returns (bool);
/// @notice Returns address of current farmingCenter
function farmingCenter() external view returns (address);
/// @notice Users can withdraw liquidity without any checks if active.
function isEmergencyWithdrawActivated() external view returns (bool);
/// @notice Detach incentive from the pool and deactivate it
/// @param key The key of the incentive
function deactivateIncentive(IncentiveKey memory key) external;
/// @notice Add rewards for incentive
/// @param key The key of the incentive
/// @param rewardAmount The amount of token0
/// @param bonusRewardAmount The amount of token1
function addRewards(IncentiveKey memory key, uint128 rewardAmount, uint128 bonusRewardAmount) external;
/// @notice Decrease rewards for incentive and withdraw
/// @param key The key of the incentive
/// @param rewardAmount The amount of token0
/// @param bonusRewardAmount The amount of token1
function decreaseRewardsAmount(IncentiveKey memory key, uint128 rewardAmount, uint128 bonusRewardAmount) external;
/// @notice Changes `isEmergencyWithdrawActivated`. Users can withdraw liquidity without any checks if activated.
/// User cannot enter to farmings if activated.
/// _Must_ only be used in emergency situations. Farmings may be unusable after activation.
/// @dev only farmings administrator
/// @param newStatus The new status of `isEmergencyWithdrawActivated`.
function setEmergencyWithdrawStatus(bool newStatus) external;
/// @notice Returns amount of created incentives
function numOfIncentives() external view returns (uint256);
/// @notice Returns amounts of reward tokens owed to a given address according to the last time all farms were updated
/// @param owner The owner for which the rewards owed are checked
/// @param rewardToken The token for which to check rewards
/// @return rewardsOwed The amount of the reward token claimable by the owner
function rewards(address owner, IERC20Minimal rewardToken) external view returns (uint256 rewardsOwed);
/// @notice Updates farming center address
/// @param _farmingCenter The new farming center contract address
function setFarmingCenterAddress(address _farmingCenter) external;
/// @notice enter farming for Algebra LP token
/// @param key The key of the incentive for which to enter farming
/// @param tokenId The ID of the token to enter farming
function enterFarming(IncentiveKey memory key, uint256 tokenId) external;
/// @notice exitFarmings for Algebra LP token
/// @param key The key of the incentive for which to exit farming
/// @param tokenId The ID of the token to exit farming
/// @param _owner Owner of the token
function exitFarming(IncentiveKey memory key, uint256 tokenId, address _owner) external;
/// @notice Transfers `amountRequested` of accrued `rewardToken` (if possible) rewards from the contract to the recipient `to`
/// @param rewardToken The token being distributed as a reward
/// @param to The address where claimed rewards will be sent to
/// @param amountRequested The amount of reward tokens to claim. Claims entire reward amount if set to 0.
/// @return rewardBalanceBefore The total amount of unclaimed reward *before* claim
function claimReward(IERC20Minimal rewardToken, address to, uint256 amountRequested) external returns (uint256 rewardBalanceBefore);
/// @notice Transfers `amountRequested` of accrued `rewardToken` (if possible) rewards from the contract to the recipient `to`
/// @notice only for FarmingCenter
/// @param rewardToken The token being distributed as a reward
/// @param from The address of position owner
/// @param to The address where claimed rewards will be sent to
/// @param amountRequested The amount of reward tokens to claim. Claims entire reward amount if set to 0.
/// @return rewardBalanceBefore The total amount of unclaimed reward *before* claim
function claimRewardFrom(
IERC20Minimal rewardToken,
address from,
address to,
uint256 amountRequested
) external returns (uint256 rewardBalanceBefore);
/// @notice Calculates the reward amount that will be received for the given farm
/// @param key The key of the incentive
/// @param tokenId The ID of the token
/// @return reward The reward accrued to the NFT for the given incentive thus far
/// @return bonusReward The bonus reward accrued to the NFT for the given incentive thus far
function getRewardInfo(IncentiveKey memory key, uint256 tokenId) external returns (uint256 reward, uint256 bonusReward);
/// @notice Returns information about a farmed liquidity NFT
/// @param tokenId The ID of the farmed token
/// @param incentiveId The ID of the incentive for which the token is farmed
/// @return liquidity The amount of liquidity in the NFT as of the last time the rewards were computed,
/// @return tickLower The lower tick of position,
/// @return tickUpper The upper tick of position,
/// @return innerRewardGrowth0 The last saved reward0 growth inside position,
/// @return innerRewardGrowth1 The last saved reward1 growth inside position
function farms(
uint256 tokenId,
bytes32 incentiveId
) external view returns (uint128 liquidity, int24 tickLower, int24 tickUpper, uint256 innerRewardGrowth0, uint256 innerRewardGrowth1);
/// @notice Returns connected to pool incentive key
function incentiveKeys(
address poolAddress
) external view returns (IERC20Minimal rewardToken, IERC20Minimal bonusRewardToken, IAlgebraPool pool, uint256 nonce);
/// @notice Creates a new liquidity farming incentive program
/// @param key Details of the incentive to create
/// @param params Params of incentive
/// @param plugin The address of corresponding plugin
/// @return virtualPool The created virtual pool
function createEternalFarming(IncentiveKey memory key, IncentiveParams memory params, address plugin) external returns (address virtualPool);
/// @notice Change reward rates for incentive
/// @param key The key of incentive
/// @param rewardRate The new rate of main token (token0) distribution per sec
/// @param bonusRewardRate The new rate of bonus token (token1) distribution per sec
function setRates(IncentiveKey memory key, uint128 rewardRate, uint128 bonusRewardRate) external;
/// @notice Collect rewards for tokenId
/// @dev only FarmingCenter
/// @param key The key of incentive
/// @param tokenId The ID of the token to exit farming
/// @param _owner Owner of the token
/// @return reward The amount of main token (token0) collected
/// @param bonusReward The amount of bonus token (token1) collected
function collectRewards(IncentiveKey memory key, uint256 tokenId, address _owner) external returns (uint256 reward, uint256 bonusReward);
/// @notice Event emitted when a liquidity mining incentive has been stopped from the outside
/// @param incentiveId The stopped incentive
event IncentiveDeactivated(bytes32 indexed incentiveId);
/// @notice Event emitted when a Algebra LP token has been farmed
/// @param tokenId The unique identifier of an Algebra LP token
/// @param incentiveId The incentive in which the token is farming
/// @param liquidity The amount of liquidity farmed
event FarmEntered(uint256 indexed tokenId, bytes32 indexed incentiveId, uint128 liquidity);
/// @notice Event emitted when a Algebra LP token exited from farming
/// @param tokenId The unique identifier of an Algebra LP token
/// @param incentiveId The incentive in which the token is farming
/// @param rewardAddress The token being distributed as a reward
/// @param bonusRewardToken The token being distributed as a bonus reward
/// @param owner The address where claimed rewards were sent to
/// @param reward The amount of reward tokens to be claimed
/// @param bonusReward The amount of bonus reward tokens to be claimed
event FarmEnded(
uint256 indexed tokenId,
bytes32 indexed incentiveId,
address indexed rewardAddress,
address bonusRewardToken,
address owner,
uint256 reward,
uint256 bonusReward
);
/// @notice Emitted when the farming center is changed
/// @param farmingCenter The farming center after the address was changed
event FarmingCenter(address indexed farmingCenter);
/// @notice Event emitted when rewards were added
/// @param rewardAmount The additional amount of main token
/// @param bonusRewardAmount The additional amount of bonus token
/// @param incentiveId The ID of the incentive for which rewards were added
event RewardsAdded(uint256 rewardAmount, uint256 bonusRewardAmount, bytes32 incentiveId);
/// @notice Event emitted when rewards were decreased
/// @param rewardAmount The withdrawn amount of main token
/// @param bonusRewardAmount The withdrawn amount of bonus token
/// @param incentiveId The ID of the incentive for which rewards were decreased
event RewardAmountsDecreased(uint256 rewardAmount, uint256 bonusRewardAmount, bytes32 incentiveId);
/// @notice Event emitted when a reward token has been claimed
/// @param to The address where claimed rewards were sent to
/// @param reward The amount of reward tokens claimed
/// @param rewardAddress The token reward address
/// @param owner The address where claimed rewards were claimed from
event RewardClaimed(address indexed to, uint256 reward, address indexed rewardAddress, address indexed owner);
/// @notice Event emitted when reward rates were changed
/// @param rewardRate The new rate of main token (token0) distribution per sec
/// @param bonusRewardRate The new rate of bonus token (token1) distribution per sec
/// @param incentiveId The ID of the incentive for which rates were changed
event RewardsRatesChanged(uint128 rewardRate, uint128 bonusRewardRate, bytes32 incentiveId);
/// @notice Event emitted when rewards were collected
/// @param tokenId The ID of the token for which rewards were collected
/// @param incentiveId The ID of the incentive for which rewards were collected
/// @param rewardAmount Collected amount of reward
/// @param bonusRewardAmount Collected amount of bonus reward
event RewardsCollected(uint256 tokenId, bytes32 incentiveId, uint256 rewardAmount, uint256 bonusRewardAmount);
/// @notice Event emitted when a liquidity mining incentive has been created
/// @param rewardToken The token being distributed as a reward
/// @param bonusRewardToken The token being distributed as a bonus reward
/// @param pool The Algebra pool
/// @param virtualPool The virtual pool address
/// @param nonce The nonce of new farming
/// @param reward The amount of reward tokens to be distributed
/// @param bonusReward The amount of bonus reward tokens to be distributed
/// @param minimalAllowedPositionWidth The minimal allowed position width (tickUpper - tickLower)
event EternalFarmingCreated(
IERC20Minimal indexed rewardToken,
IERC20Minimal indexed bonusRewardToken,
IAlgebraPool indexed pool,
address virtualPool,
uint256 nonce,
uint256 reward,
uint256 bonusReward,
uint24 minimalAllowedPositionWidth
);
/// @notice Emitted when status of `isEmergencyWithdrawActivated` changes
/// @param newStatus New value of `isEmergencyWithdrawActivated`. Users can withdraw liquidity without any checks if active.
event EmergencyWithdraw(bool newStatus);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.4;
import '@cryptoalgebra/integral-base-plugin/contracts/interfaces/IAlgebraVirtualPool.sol';
/// @title Algebra eternal virtual pool interface
/// @notice Used to track active liquidity in farming and distribute rewards
interface IAlgebraEternalVirtualPool is IAlgebraVirtualPool {
error onlyPlugin();
error onlyFarming();
/// @notice Returns address of the AlgebraEternalFarming
function farmingAddress() external view returns (address);
/// @notice Returns address of the plugin for which this virtual pool was created
function plugin() external view returns (address);
/// @notice Returns data associated with a tick
function ticks(
int24 tickId
)
external
view
returns (
uint256 liquidityTotal,
int128 liquidityDelta,
int24 prevTick,
int24 nextTick,
uint256 outerFeeGrowth0Token,
uint256 outerFeeGrowth1Token
);
/// @notice Returns the current liquidity in virtual pool
function currentLiquidity() external view returns (uint128);
/// @notice Returns the current tick in virtual pool
function globalTick() external view returns (int24);
/// @notice Returns the timestamp after previous virtual pool update
function prevTimestamp() external view returns (uint32);
/// @notice Returns true if virtual pool is deactivated
function deactivated() external view returns (bool);
/// @dev This function is called when anyone changes their farmed liquidity. The position in a virtual pool should be changed accordingly.
/// If the virtual pool is deactivated, does nothing.
/// @param bottomTick The bottom tick of a position
/// @param topTick The top tick of a position
/// @param liquidityDelta The amount of liquidity in a position
/// @param currentTick The current tick in the main pool
function applyLiquidityDeltaToPosition(int24 bottomTick, int24 topTick, int128 liquidityDelta, int24 currentTick) external;
/// @dev This function is called by farming to increase rewards per liquidity accumulator.
/// Can only be called by farming
function distributeRewards() external;
/// @notice Change reward rates
/// @param rate0 The new rate of main token distribution per sec
/// @param rate1 The new rate of bonus token distribution per sec
function setRates(uint128 rate0, uint128 rate1) external;
/// @notice This function is used to deactivate virtual pool
/// @dev Can only be called by farming
function deactivate() external;
/// @notice Top up rewards reserves
/// @param token0Amount The amount of token0
/// @param token1Amount The amount of token1
function addRewards(uint128 token0Amount, uint128 token1Amount) external;
/// @notice Withdraw rewards from reserves directly
/// @param token0Amount The amount of token0
/// @param token1Amount The amount of token1
function decreaseRewards(uint128 token0Amount, uint128 token1Amount) external;
/// @notice Retrieves rewards growth data inside specified range
/// @dev Should only be used for relative comparison of the same range over time
/// @param bottomTick The lower tick boundary of the range
/// @param topTick The upper tick boundary of the range
/// @return rewardGrowthInside0 The all-time reward growth in token0, per unit of liquidity, inside the range's tick boundaries
/// @return rewardGrowthInside1 The all-time reward growth in token1, per unit of liquidity, inside the range's tick boundaries
function getInnerRewardsGrowth(int24 bottomTick, int24 topTick) external view returns (uint256 rewardGrowthInside0, uint256 rewardGrowthInside1);
/// @notice Get reserves of rewards in one call
/// @return reserve0 The reserve of token0
/// @return reserve1 The reserve of token1
function rewardReserves() external view returns (uint128 reserve0, uint128 reserve1);
/// @notice Get rates of rewards in one call
/// @return rate0 The rate of token0, rewards / sec
/// @return rate1 The rate of token1, rewards / sec
function rewardRates() external view returns (uint128 rate0, uint128 rate1);
/// @notice Get reward growth accumulators
/// @return rewardGrowth0 The reward growth for reward0, per unit of liquidity, has only relative meaning
/// @return rewardGrowth1 The reward growth for reward1, per unit of liquidity, has only relative meaning
function totalRewardGrowth() external view returns (uint256 rewardGrowth0, uint256 rewardGrowth1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
pragma abicoder v2;
import '@cryptoalgebra/integral-core/contracts/interfaces/IERC20Minimal.sol';
import '@cryptoalgebra/integral-periphery/contracts/interfaces/IMulticall.sol';
import '@cryptoalgebra/integral-periphery/contracts/interfaces/INonfungiblePositionManager.sol';
import '@cryptoalgebra/integral-base-plugin/contracts/interfaces/plugins/IFarmingPlugin.sol';
import '../base/IncentiveKey.sol';
import '../interfaces/IAlgebraEternalFarming.sol';
/// @title Algebra main farming contract interface
/// @dev Manages users deposits and performs entry, exit and other actions.
interface IFarmingCenter is IMulticall {
/// @notice Returns current virtual pool address for Algebra pool
function virtualPoolAddresses(address poolAddress) external view returns (address virtualPoolAddresses);
/// @notice The nonfungible position manager with which this farming contract is compatible
function nonfungiblePositionManager() external view returns (INonfungiblePositionManager);
/// @notice The eternal farming contract
function eternalFarming() external view returns (IAlgebraEternalFarming);
/// @notice The Algebra poolDeployer contract
function algebraPoolDeployer() external view returns (address);
/// @notice Returns information about a deposited NFT
/// @param tokenId The ID of the deposit (and token) that is being transferred
/// @return eternalIncentiveId The id of eternal incentive that is active for this NFT
function deposits(uint256 tokenId) external view returns (bytes32 eternalIncentiveId);
/// @notice Returns incentive key for specific incentiveId
/// @param incentiveId The hash of incentive key
function incentiveKeys(
bytes32 incentiveId
) external view returns (IERC20Minimal rewardToken, IERC20Minimal bonusRewardToken, IAlgebraPool pool, uint256 nonce);
/// @notice Used to connect incentive to compatible AlgebraPool plugin
/// @dev only farming can do it
/// Will revert if something is already connected to the plugin
/// @param virtualPool The virtual pool to be connected, must not be zero address
/// @param plugin The Algebra farming plugin
function connectVirtualPoolToPlugin(address virtualPool, IFarmingPlugin plugin) external;
/// @notice Used to disconnect incentive from compatible AlgebraPool plugin
/// @dev only farming can do it.
/// If the specified virtual pool is not connected to the plugin, nothing will happen
/// @param virtualPool The virtual pool to be disconnected, must not be zero address
/// @param plugin The Algebra farming plugin
function disconnectVirtualPoolFromPlugin(address virtualPool, IFarmingPlugin plugin) external;
/// @notice Enters in incentive (eternal farming) with NFT-position token
/// @dev msg.sender must be the owner of NFT
/// @param key The incentive key
/// @param tokenId The id of position NFT
function enterFarming(IncentiveKey memory key, uint256 tokenId) external;
/// @notice Exits from incentive (eternal farming) with NFT-position token
/// @dev msg.sender must be the owner of NFT
/// @param key The incentive key
/// @param tokenId The id of position NFT
function exitFarming(IncentiveKey memory key, uint256 tokenId) external;
/// @notice Used to collect reward from eternal farming. Then reward can be claimed.
/// @param key The incentive key
/// @param tokenId The id of position NFT
/// @return reward The amount of collected reward
/// @return bonusReward The amount of collected bonus reward
function collectRewards(IncentiveKey memory key, uint256 tokenId) external returns (uint256 reward, uint256 bonusReward);
/// @notice Used to claim and send rewards from farming(s)
/// @dev can be used via static call to get current rewards for user
/// @param rewardToken The token that is a reward
/// @param to The address to be rewarded
/// @param amountRequested Amount to claim in eternal farming
/// @return rewardBalanceBefore The total amount of unclaimed reward *before* claim
function claimReward(IERC20Minimal rewardToken, address to, uint256 amountRequested) external returns (uint256 rewardBalanceBefore);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
import '../base/IncentiveKey.sol';
library IncentiveId {
/// @notice Calculate the key for a farming incentive
/// @param key The components used to compute the incentive identifier
/// @return incentiveId The identifier for the incentive
function compute(IncentiveKey memory key) internal pure returns (bytes32 incentiveId) {
return keccak256(abi.encode(key));
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
/// @notice The permit typehash used in the permit signature
/// @return The typehash for the permit
function PERMIT_TYPEHASH() external pure returns (bytes32);
/// @notice The domain separator used in the permit signature
/// @return The domain separator used in encoding of permit signature
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Approve of a specific token ID for spending by spender via signature
/// @param spender The account that is being approved
/// @param tokenId The ID of the token that is being approved for spending
/// @param deadline The deadline timestamp by which the call must be mined for the approve to work
/// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
/// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
/// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Multicall interface
/// @notice Enables calling multiple methods in a single call to the contract
interface IMulticall {
/// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed
/// @dev The `msg.value` should not be trusted for any method callable from multicall.
/// @param data The encoded function data for each of the calls to make to this contract
/// @return results The results from each of the calls passed in via data
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
import './IPoolInitializer.sol';
import './IERC721Permit.sol';
import './IPeripheryPayments.sol';
import './IPeripheryImmutableState.sol';
/// @title Non-fungible token for positions
/// @notice Wraps Algebra positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface INonfungiblePositionManager is
IPoolInitializer,
IPeripheryPayments,
IPeripheryImmutableState,
IERC721Metadata,
IERC721Enumerable,
IERC721Permit
{
/// @notice Emitted when liquidity is increased for a position NFT
/// @dev Also emitted when a token is minted
/// @param tokenId The ID of the token for which liquidity was increased
/// @param liquidityDesired The amount by which liquidity for the NFT position was increased
/// @param actualLiquidity the actual liquidity that was added into a pool. Could differ from
/// _liquidity_ when using FeeOnTransfer tokens
/// @param amount0 The amount of token0 that was paid for the increase in liquidity
/// @param amount1 The amount of token1 that was paid for the increase in liquidity
event IncreaseLiquidity(
uint256 indexed tokenId,
uint128 liquidityDesired,
uint128 actualLiquidity,
uint256 amount0,
uint256 amount1,
address pool
);
/// @notice Emitted when liquidity is decreased for a position NFT
/// @param tokenId The ID of the token for which liquidity was decreased
/// @param liquidity The amount by which liquidity for the NFT position was decreased
/// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
/// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when tokens are collected for a position NFT
/// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
/// @param tokenId The ID of the token for which underlying tokens were collected
/// @param recipient The address of the account that received the collected tokens
/// @param amount0 The amount of token0 owed to the position that was collected
/// @param amount1 The amount of token1 owed to the position that was collected
event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);
/// @notice Emitted if farming failed in call from NonfungiblePositionManager.
/// @dev Should never be emitted
/// @param tokenId The ID of corresponding token
event FarmingFailed(uint256 indexed tokenId);
/// @notice Returns the position information associated with a given token ID.
/// @dev Throws if the token ID is not valid.
/// @param tokenId The ID of the token that represents the position
/// @return nonce The nonce for permits
/// @return operator The address that is approved for spending
/// @return token0 The address of the token0 for a specific pool
/// @return token1 The address of the token1 for a specific pool
/// @return deployer The address of the custom pool deployer
/// @return tickLower The lower end of the tick range for the position
/// @return tickUpper The higher end of the tick range for the position
/// @return liquidity The liquidity of the position
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function positions(
uint256 tokenId
)
external
view
returns (
uint88 nonce,
address operator,
address token0,
address token1,
address deployer,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct MintParams {
address token0;
address token1;
address deployer;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
/// @notice Creates a new position wrapped in a NFT
/// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
/// a method does not exist, i.e. the pool is assumed to be initialized.
/// @dev If native token is used as input, this function should be accompanied by a `refundNativeToken` in multicall to avoid potential loss of native tokens
/// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
/// @return tokenId The ID of the token that represents the minted position
/// @return liquidity The liquidity delta amount as a result of the increase
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function mint(
MintParams calldata params
) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
/// @param params tokenId The ID of the token for which liquidity is being increased,
/// amount0Desired The desired amount of token0 to be spent,
/// amount1Desired The desired amount of token1 to be spent,
/// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
/// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
/// deadline The time by which the transaction must be included to effect the change
/// @dev If native token is used as input, this function should be accompanied by a `refundNativeToken` in multicall to avoid potential loss of native tokens
/// @return liquidity The liquidity delta amount as a result of the increase
/// @return amount0 The amount of token0 to achieve resulting liquidity
/// @return amount1 The amount of token1 to achieve resulting liquidity
function increaseLiquidity(
IncreaseLiquidityParams calldata params
) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1);
struct DecreaseLiquidityParams {
uint256 tokenId;
uint128 liquidity;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Decreases the amount of liquidity in a position and accounts it to the position
/// @param params tokenId The ID of the token for which liquidity is being decreased,
/// amount The amount by which liquidity will be decreased,
/// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
/// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
/// deadline The time by which the transaction must be included to effect the change
/// @return amount0 The amount of token0 accounted to the position's tokens owed
/// @return amount1 The amount of token1 accounted to the position's tokens owed
function decreaseLiquidity(
DecreaseLiquidityParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
/// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
/// @param params tokenId The ID of the NFT for which tokens are being collected,
/// recipient The account that should receive the tokens,
/// amount0Max The maximum amount of token0 to collect,
/// amount1Max The maximum amount of token1 to collect
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
/// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
/// must be collected first.
/// @param tokenId The ID of the token that is being burned
function burn(uint256 tokenId) external payable;
/// @notice Changes approval of token ID for farming.
/// @param tokenId The ID of the token that is being approved / unapproved
/// @param approve New status of approval
/// @param farmingAddress The address of farming: used to prevent tx frontrun
function approveForFarming(uint256 tokenId, bool approve, address farmingAddress) external payable;
/// @notice Changes farming status of token to 'farmed' or 'not farmed'
/// @dev can be called only by farmingCenter
/// @param tokenId The ID of the token
/// @param toActive The new status
function switchFarmingStatus(uint256 tokenId, bool toActive) external;
/// @notice Changes address of farmingCenter
/// @dev can be called only by factory owner or NONFUNGIBLE_POSITION_MANAGER_ADMINISTRATOR_ROLE
/// @param newFarmingCenter The new address of farmingCenter
function setFarmingCenter(address newFarmingCenter) external;
/// @notice Returns whether `spender` is allowed to manage `tokenId`
/// @dev Requirement: `tokenId` must exist
function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool);
/// @notice Returns the address of currently connected farming, if any
/// @return The address of the farming center contract, which handles farmings logic
function farmingCenter() external view returns (address);
/// @notice Returns the address of farming that is approved for this token, if any
function farmingApprovals(uint256 tokenId) external view returns (address);
/// @notice Returns the address of farming in which this token is farmed, if any
function tokenFarmedIn(uint256 tokenId) external view returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Immutable state
/// @notice Functions that return immutable state of the router
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface IPeripheryImmutableState {
/// @return Returns the address of the Algebra factory
function factory() external view returns (address);
/// @return Returns the address of the pool Deployer
function poolDeployer() external view returns (address);
/// @return Returns the address of WNativeToken
function WNativeToken() external view returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of NativeToken
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface IPeripheryPayments {
/// @notice Unwraps the contract's WNativeToken balance and sends it to recipient as NativeToken.
/// @dev The amountMinimum parameter prevents malicious contracts from stealing WNativeToken from users.
/// @param amountMinimum The minimum amount of WNativeToken to unwrap
/// @param recipient The address receiving NativeToken
function unwrapWNativeToken(uint256 amountMinimum, address recipient) external payable;
/// @notice Refunds any NativeToken balance held by this contract to the `msg.sender`
/// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
/// that use ether for the input amount
function refundNativeToken() external payable;
/// @notice Transfers the full amount of a token held by this contract to recipient
/// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
/// @param token The contract address of the token which will be transferred to `recipient`
/// @param amountMinimum The minimum amount of token required for a transfer
/// @param recipient The destination address of the token
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Creates and initializes Algebra Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
interface IPoolInitializer {
/// @notice Creates a new pool if it does not exist, then initializes if not initialized
/// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
/// @param token0 The contract address of token0 of the pool
/// @param token1 The contract address of token1 of the pool
/// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
/// @param data Data for plugin initialization
/// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
function createAndInitializePoolIfNecessary(
address token0,
address token1,
address deployer,
uint160 sqrtPriceX96,
bytes calldata data
) external payable returns (address pool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
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() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(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");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
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);
}// SPDX-License-Identifier: GPL-3.0-or-later
// BlackHole Foundation 2025
pragma solidity 0.8.13;
import { IAlgebraCommunityVault } from '@cryptoalgebra/integral-core/contracts/interfaces/vault/IAlgebraCommunityVault.sol';
interface IAlgebraCustomCommunityVault is IAlgebraCommunityVault {
function algebraFee() external view returns (uint16);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.13;
import '@cryptoalgebra/integral-farming/contracts/base/IncentiveKey.sol';
import '@cryptoalgebra/integral-farming/contracts/interfaces/IAlgebraEternalFarming.sol';
interface IAlgebraEternalFarmingCustom {
function createEternalFarming(
IncentiveKey memory key,
IAlgebraEternalFarming.IncentiveParams memory params,
address plugin,
address deployer
) external returns (address virtualPool);
function deactivateIncentive(IncentiveKey memory key, address deployer) external;
function getRewardInfo(IncentiveKey memory key, uint256 tokenId) external view returns (uint256 reward, uint256 bonusReward);
}// SPDX-License-Identifier: MIT OR GPL-3.0-or-later
pragma solidity 0.8.13;
interface IBribe {
function deposit(uint amount, uint tokenId) external;
function withdraw(uint amount, uint tokenId) external;
function getRewardForAddress(address _owner, address[] memory tokens) external;
function notifyRewardAmount(address token, uint amount) external;
function left(address token) external view returns (uint);
function getReward(uint tokenId, address[] memory tokens) external;
function bribeTokens(uint256 i) external view returns(address);
function rewardsListLength() external view returns (uint256);
function tokenRewardsPerEpoch(address _token, uint256 epochStart) external view returns(uint256);
}// SPDX-License-Identifier: MIT OR GPL-3.0-or-later
pragma solidity 0.8.13;
import '@cryptoalgebra/integral-farming/contracts/base/IncentiveKey.sol';
interface IGaugeCL {
function notifyRewardAmount(address token, uint amount) external returns (IncentiveKey memory incentivekey, uint256 rewardRate, uint128 bonusRewardRate);
function claimFees() external returns (uint claimed0, uint claimed1);
function balanceOf(uint256 tokenId) external view returns (uint256);
function emergency() external returns (bool);
function earned(uint256 tokenId) external view returns (uint256 reward, uint256 bonusReward);
function totalActiveSupply() external view returns (uint);
function rewardRate() external view returns (uint);
function rewardForDuration() external view returns (uint256);
function stakedFees() external view returns (uint256, uint256);
function activateEmergencyMode() external;
function stopEmergencyMode() external;
}// SPDX-License-Identifier: MIT OR GPL-3.0-or-later
pragma solidity 0.8.13;
import "./IGaugeManager.sol";
interface IGaugeFactoryCL {
function createGauge(address _rewardToken,address _ve,address _token,address _distribution, address _internal_bribe, address _external_bribe, IGaugeManager.FarmingParam memory farmingParam, address bonusRewardToken) external returns (address) ;
function gauges(uint256 i) external view returns(address);
function length() external view returns(uint);
function dibs() external view returns (address);
function dibsPercentage() external view returns (uint256);
}// SPDX-License-Identifier: MIT OR GPL-3.0-or-later
pragma solidity 0.8.13;
interface IGaugeManager {
struct FarmingParam {
address farmingCenter;
address algebraEternalFarming;
address nfpm;
}
function fetchInternalBribeFromPool(address _pool) external returns (address);
function fetchExternalBribeFromPool(address _pool) external returns (address);
function isGaugeAliveForPool(address _pool) external returns (bool);
function notifyRewardAmount(uint amount) external;
function minter() external view returns(address);
function createGauge(address _pool, uint256 _gaugeType) external returns (address _gauge, address _internal_bribe, address _external_bribe);
function gauges(address _pair) external view returns (address);
function isGauge(address _gauge) external view returns (bool);
function poolForGauge(address _gauge) external view returns (address);
function internal_bribes(address _gauge) external view returns (address);
function external_bribes(address _gauge) external view returns (address);
function pools(uint256 i) external view returns(address);
function getBlackGovernor() external view returns (address);
function setBlackGovernor(address _blackGovernor) external;
function acceptAlgebraFeeChangeProposal (address _pool, uint16 newAlgebraFee) external;
function length() external view returns(uint);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.13;
library BlackTimeLibrary {
uint256 internal constant WEEK = 7 * 86400;
uint internal constant NO_VOTING_WINDOW = 3600;
uint256 internal constant MAX_LOCK_DURATION = 86400 * 365 * 4;
/// @dev Returns start of epoch based on current timestamp
function epochStart(uint256 timestamp) internal pure returns (uint256) {
unchecked {
return timestamp - (timestamp % WEEK);
}
}
/// @dev Returns start of next epoch / end of current epoch
function epochNext(uint256 timestamp) internal pure returns (uint256) {
unchecked {
return timestamp - (timestamp % WEEK) + WEEK;
}
}
/// @dev Returns start of voting window
function epochVoteStart(uint256 timestamp) internal pure returns (uint256) {
unchecked {
return timestamp - (timestamp % WEEK) + NO_VOTING_WINDOW;
}
}
/// @dev Returns end of voting window / beginning of unrestricted voting window
function epochVoteEnd(uint256 timestamp) internal pure returns (uint256) {
unchecked {
return timestamp - (timestamp % WEEK) + WEEK - NO_VOTING_WINDOW;
}
}
/// @dev Returns the status if it is the last hour of the epoch
function isLastHour(uint256 timestamp) internal pure returns (bool) {
// return block.timestamp % 7 days >= 6 days + 23 hours;
return timestamp >= BlackTimeLibrary.epochVoteEnd(timestamp)
&& timestamp < BlackTimeLibrary.epochNext(timestamp);
}
/// @dev Returns duration in multiples of epoch
function epochMultiples(uint256 duration) internal pure returns (uint256) {
unchecked {
return (duration / WEEK) * WEEK;
}
}
function isLastEpoch(uint256 timestamp, uint256 endTime) internal pure returns (bool) {
unchecked {
return endTime - WEEK <= timestamp && timestamp < endTime;
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.13; // Define constants as standalone constants that can be imported by name uint256 constant MAX_FEE = 500; // 5% maximum fee uint256 constant MAX_REFERRAL_FEE_CAP = 500; // 5% max referral fee uint256 constant REFERRAL_FEE_DENOMINATOR = 10000; // basis points denominator
{
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_ve","type":"address"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_distribution","type":"address"},{"internalType":"address","name":"_internal_bribe","type":"address"},{"internalType":"address","name":"_external_bribe","type":"address"},{"components":[{"internalType":"address","name":"farmingCenter","type":"address"},{"internalType":"address","name":"algebraEternalFarming","type":"address"},{"internalType":"address","name":"nfpm","type":"address"}],"internalType":"struct IGaugeManager.FarmingParam","name":"_farmingParam","type":"tuple"},{"internalType":"address","name":"_bonusRewardToken","type":"address"},{"internalType":"address","name":"_factory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"claimed0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimed1","type":"uint256"}],"name":"ClaimFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[],"name":"EmergencyActivated","type":"event"},{"anonymous":false,"inputs":[],"name":"EmergencyDeactivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"Harvest","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":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DISTRIBUTION","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activateEmergencyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"algebraEternalFarming","outputs":[{"internalType":"contract IAlgebraEternalFarming","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"algebraPool","outputs":[{"internalType":"contract IAlgebraPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonusRewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimFees","outputs":[{"internalType":"uint256","name":"claimed0","type":"uint256"},{"internalType":"uint256","name":"claimed1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"earned","outputs":[{"internalType":"uint256","name":"reward","type":"uint256"},{"internalType":"uint256","name":"bonusReward","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergency","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"external_bribe","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"farmingCenter","outputs":[{"internalType":"contract IFarmingCenter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gaugeBalances","outputs":[{"internalType":"uint256","name":"token0","type":"uint256"},{"internalType":"uint256","name":"token1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"internal_bribe","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonfungiblePositionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[{"components":[{"internalType":"contract IERC20Minimal","name":"rewardToken","type":"address"},{"internalType":"contract IERC20Minimal","name":"bonusRewardToken","type":"address"},{"internalType":"contract IAlgebraPool","name":"pool","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct IncentiveKey","name":"","type":"tuple"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakedFees","outputs":[{"internalType":"uint256","name":"totalFeeToken0","type":"uint256"},{"internalType":"uint256","name":"totalFeeToken1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stopEmergencyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalActiveSupply","outputs":[{"internalType":"uint256","name":"_totalActiveSupply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
0x6102206040523480156200001257600080fd5b50604051620034db380380620034db833981016040819052620000359162000127565b60016000556200004533620000b8565b6001600160a01b0390811661020052978816608052871660a05294861660c0529285166101c08190526101a05290841660e05262093a80610140528316610100528216610120528051821661016052602081015182166101805260400151166101e0526006805460ff1916905562000255565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b03811681146200012257600080fd5b919050565b6000806000806000806000806000898b036101608112156200014857600080fd5b620001538b6200010a565b99506200016360208c016200010a565b98506200017360408c016200010a565b97506200018360608c016200010a565b96506200019360808c016200010a565b9550620001a360a08c016200010a565b9450606060bf1982011215620001b857600080fd5b50604051606081016001600160401b0381118282101715620001ea57634e487b7160e01b600052604160045260246000fd5b604052620001fb60c08c016200010a565b81526200020b60e08c016200010a565b60208201526200021f6101008c016200010a565b60408201529250620002356101208b016200010a565b9150620002466101408b016200010a565b90509295985092959850929598565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e051610200516130ae6200042d600039600081816109b601528181610a3c0152818161246901526124ef0152600081816103c50152818161055401528181611871015261194e015260008181610233015281816105fb01528181610b5901528181610d600152818161116f015281816114fd01526119bf015260008181610396015281816107ae0152818161089e01528181610f5201528181610fd801528181611cb501528181611d3901528181611e2901528181611f1c0152818161227301526122f90152600081816102ec0152818161062c01528181610b8e01528181610c4301528181610d3101528181610e6201528181611140015281816112460152818161152e015281816115e50152818161172c0152818161175301526119f201526000818161047e015281816106e1015281816119260152611aa701526000818161025a0152610ce2015260006101ef015260008181610313015281816126220152818161266d015281816126df015261272a01526000818161034301526113b701526000610421015260006104ae0152600081816104e80152818161140b01526116f501526130ae6000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80639cc7f7081161010f578063caa6fea4116100a2578063df136d6511610071578063df136d65146104a0578063ef405caf146104a9578063f2fde38b146104d0578063f7c618c1146104e357600080fd5b8063caa6fea41461044c578063d009601014610469578063d294f09314610471578063dd56e5d81461047957600080fd5b8063b66503cf116100de578063b66503cf146103e7578063b6b55f2514610409578063c863657d1461041c578063c8f33c911461044357600080fd5b80639cc7f7081461037e5780639f747b2014610391578063b1534ecd146103b8578063b44a2722146103c057600080fd5b8063715018a6116101875780637b0a47ee116101565780637b0a47ee146103355780637c91e4eb1461033e578063833d3212146103655780638da5cb5b1461036d57600080fd5b8063715018a6146102d757806372069264146102df578063737869c6146102e7578063770f85711461030e57600080fd5b80632e1a7d4d116101c35780632e1a7d4d1461028a5780633513f1df1461029f5780634d6ed8c4146102bc5780636946a235146102cf57600080fd5b806303fbf83a146101ea5780631755ff211461022e5780631be0528914610255575b600080fd5b6102117f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6102117f000000000000000000000000000000000000000000000000000000000000000081565b61027c7f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610225565b61029d610298366004612bcd565b61050a565b005b6102a76107a7565b60408051928352602083019190915201610225565b6102a76102ca366004612bcd565b610b42565b61027c610cde565b61029d610d13565b61027c610d27565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b61027c60035481565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b6102a7610f4b565b6001546001600160a01b0316610211565b61027c61038c366004612bcd565b611136565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b61029d6112fd565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b6103fa6103f5366004612bfb565b61135c565b60405161022593929190612c5a565b61029d610417366004612bcd565b611830565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b61027c60045481565b6006546104599060ff1681565b6040519015158152602001610225565b61029d611b57565b6102a7611bba565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b61027c60055481565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b61029d6104de366004612c85565b611bdf565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b610512611c55565b60065460ff161561053e5760405162461bcd60e51b815260040161053590612ca9565b60405180910390fd5b6040516331a9108f60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa1580156105a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c79190612ccc565b6001600160a01b0316336001600160a01b0316146105e457600080fd5b604051632bb2ac2360e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526000918291829182917f00000000000000000000000000000000000000000000000000000000000000001690635765584690602401608060405180830381865afa158015610673573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106979190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634473eca682886040518363ffffffff1660e01b815260040161072d929190612d3c565b600060405180830381600087803b15801561074757600080fd5b505af115801561075b573d6000803e3d6000fd5b50506040518881523392507f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436491506020015b60405180910390a250505050506107a46001600055565b50565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561080a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082e9190612ccc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610874573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108989190612d57565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091e9190612ccc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610964573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109889190612d57565b9050600080610995611cae565b90925090506109a48285612d86565b95506109b08184612d86565b945060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637cfc29956040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a369190612d57565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637be1623e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abc9190612ccc565b905060006001600160a01b038216610ad5576000610aec565b612710610ae2848b612d9e565b610aec9190612dbd565b905060006001600160a01b038316610b05576000610b1c565b612710610b12858b612d9e565b610b1c9190612dbd565b9050610b28828b612ddf565b9950610b34818a612ddf565b985050505050505050509091565b604051632bb2ac2360e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152600091829182918291829182917f00000000000000000000000000000000000000000000000000000000000000001690635765584690602401608060405180830381865afa158015610bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf99190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166396da9bd5828a6040518363ffffffff1660e01b8152600401610c8f929190612d3c565b6040805180830381865afa158015610cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccf9190612df6565b90999098509650505050505050565b60007f0000000000000000000000000000000000000000000000000000000000000000600354610d0e9190612d9e565b905090565b610d1b612090565b610d2560006120ea565b565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663576558467f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401610daa91906001600160a01b0391909116815260200190565b608060405180830381865afa158015610dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610deb9190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090506000610e3e8261213c565b604051636077779560e01b8152600481018290529091506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063607777959060240160c060405180830381865afa158015610ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecd9190612e46565b50505092505050806001600160a01b03166346caf2ae6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f369190612ecb565b6001600160801b031697505050505050505090565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd29190612ccc565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110589190612ccc565b6040516370a0823160e01b81523060048201529091506001600160a01b038316906370a0823190602401602060405180830381865afa15801561109f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c39190612d57565b6040516370a0823160e01b81523060048201529094506001600160a01b038216906370a0823190602401602060405180830381865afa15801561110a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112e9190612d57565b925050509091565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663576558467f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b81526004016111b991906001600160a01b0391909116815260200190565b608060405180830381865afa1580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111fa9190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b0316815260200183815250905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166327e6a99a8961127d8561213c565b6040516001600160e01b031960e085901b1681526004810192909252602482015260440160a060405180830381865afa1580156112be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e29190612ef8565b50506001600160801b039092169a9950505050505050505050565b611305612090565b60065460ff166113275760405162461bcd60e51b815260040161053590612ca9565b6006805460ff191690556040517f9c68e6e839755352b6969c9291d44f48f0d0e85817dc99069e54615ec62131b390600090a1565b60408051608081018252600080825260208201819052918101829052606081018290529080611389611c55565b60065460ff16156113ac5760405162461bcd60e51b815260040161053590612ca9565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146114095760405162461bcd60e51b81526020600482015260026024820152614e4160f01b6044820152606401610535565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316856001600160a01b03161461147a5760405162461bcd60e51b815260206004820152600d60248201526c3737ba103932bb903a37b5b2b760991b6044820152606401610535565b600061148f4262093a80808206820301612ddf565b905060025442106114ac576114a48186612dbd565b6003556114d8565b6000600354826114bc9190612d9e565b9050816114c98288612d86565b6114d39190612dbd565b600355505b62093a8042818106900301600255604051632bb2ac2360e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526000918291829182917f00000000000000000000000000000000000000000000000000000000000000001690635765584690602401608060405180830381865afa158015611575573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115999190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b0316815260200183815250905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636077779561161b8461213c565b6040518263ffffffff1660e01b815260040161163991815260200190565b60c060405180830381865afa158015611656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167a9190612e46565b505050925050506000816001600160a01b031663a88a5c166040518163ffffffff1660e01b81526004016040805180830381865afa1580156116c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e49190612f4e565b915061171d90506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308f61216c565b6117516001600160a01b038e167f00000000000000000000000000000000000000000000000000000000000000008e6121dd565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f26ebf7a848e60006040518463ffffffff1660e01b81526004016117a293929190612f81565b600060405180830381600087803b1580156117bc57600080fd5b505af11580156117d0573d6000803e3d6000fd5b505050507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d8c60405161180591815260200190565b60405180910390a1600354929a509198509096505050505050506118296001600055565b9250925092565b611838611c55565b60065460ff161561185b5760405162461bcd60e51b815260040161053590612ca9565b6040516331a9108f60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa1580156118c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e49190612ccc565b6001600160a01b0316336001600160a01b03161461190157600080fd5b604051634197b18560e11b815260048101829052600160248201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660448301527f0000000000000000000000000000000000000000000000000000000000000000169063832f630a90606401600060405180830381600087803b15801561199257600080fd5b505af11580156119a6573d6000803e3d6000fd5b5050604051632bb2ac2360e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260009350839250829182917f00000000000000000000000000000000000000000000000000000000000000001690635765584690602401608060405180830381865afa158015611a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5d9190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635739f0b982886040518363ffffffff1660e01b8152600401611af3929190612d3c565b600060405180830381600087803b158015611b0d57600080fd5b505af1158015611b21573d6000803e3d6000fd5b50506040518881523392507fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c915060200161078d565b611b5f612090565b60065460ff1615611b825760405162461bcd60e51b815260040161053590612ca9565b6006805460ff191660011790556040517fd596bbda13fdbf0904b2a7ce45e50145b26720d719bd8dd257f3020fe7bf880f90600090a1565b600080611bc5611c55565b611bcd61226c565b91509150611bdb6001600055565b9091565b611be7612090565b6001600160a01b038116611c4c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610535565b6107a4816120ea565b600260005403611ca75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610535565b6002600055565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166353e978686040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d359190612ccc565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db99190612ccc565b6040516370a0823160e01b81526001600160a01b03838116600483015291909116906370a0823190602401602060405180830381865afa158015611e01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e259190612d57565b92507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea99190612ccc565b6040516370a0823160e01b81526001600160a01b03838116600483015291909116906370a0823190602401602060405180830381865afa158015611ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f159190612d57565b91506000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637bd780256040518163ffffffff1660e01b81526004016040805180830381865afa158015611f77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9b9190612f4e565b9092509050611fb36001600160801b03831686612d86565b9450611fc86001600160801b03821685612d86565b93506000836001600160a01b0316639f856b8d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561200a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202e9190612fb0565b905060006103e861204361ffff841689612d9e565b61204d9190612dbd565b905060006103e861206261ffff851689612d9e565b61206c9190612dbd565b90506120788289612ddf565b97506120848188612ddf565b96505050505050509091565b6001546001600160a01b03163314610d255760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610535565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008160405160200161214f9190612fd4565b604051602081830303815290604052805190602001209050919050565b6040516001600160a01b03808516602483015283166044820152606481018290526121d79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526127cd565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261222e84826128a7565b6121d7576040516001600160a01b03841660248201526000604482015261226290859063095ea7b360e01b906064016121a0565b6121d784826127cd565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f39190612ccc565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612355573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123799190612ccc565b6040516370a0823160e01b81523060048201529091506001600160a01b038316906370a0823190602401602060405180830381865afa1580156123c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e49190612d57565b6040516370a0823160e01b81523060048201529094506001600160a01b038216906370a0823190602401602060405180830381865afa15801561242b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244f9190612d57565b925060008411806124605750600083115b156127c75760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637cfc29956040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124e99190612d57565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637be1623e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561254b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256f9190612ccc565b905060006001600160a01b03821661258857600061259f565b6127106125958489612d9e565b61259f9190612dbd565b905060006001600160a01b0383166125b85760006125cf565b6127106125c58589612d9e565b6125cf9190612dbd565b905081156125ef576125e2868484612950565b6125ec8289612ddf565b97505b801561260d57612600858483612950565b61260a8188612ddf565b96505b87156126ca576126476001600160a01b0387167f00000000000000000000000000000000000000000000000000000000000000008a6121dd565b60405163b66503cf60e01b81526001600160a01b038781166004830152602482018a90527f0000000000000000000000000000000000000000000000000000000000000000169063b66503cf90604401600060405180830381600087803b1580156126b157600080fd5b505af11580156126c5573d6000803e3d6000fd5b505050505b8615612787576127046001600160a01b0386167f0000000000000000000000000000000000000000000000000000000000000000896121dd565b60405163b66503cf60e01b81526001600160a01b038681166004830152602482018990527f0000000000000000000000000000000000000000000000000000000000000000169063b66503cf90604401600060405180830381600087803b15801561276e57600080fd5b505af1158015612782573d6000803e3d6000fd5b505050505b604080518981526020810189905233917fbc567d6cbad26368064baa0ab5a757be46aae4d70f707f9203d9d9b6c8ccbfa3910160405180910390a2505050505b50509091565b6000612822826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a3d9092919063ffffffff16565b90508051600014806128435750808060200190518101906128439190612fe2565b6128a25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610535565b505050565b6000806000846001600160a01b0316846040516128c49190613029565b6000604051808303816000865af19150503d8060008114612901576040519150601f19603f3d011682016040523d82523d6000602084013e612906565b606091505b50915091508180156129305750805115806129305750808060200190518101906129309190612fe2565b801561294557506001600160a01b0385163b15155b925050505b92915050565b6000836001600160a01b03163b1161296757600080fd5b6040516001600160a01b03838116602483015260448201839052600091829186169060640160408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052516129c19190613029565b6000604051808303816000865af19150503d80600081146129fe576040519150601f19603f3d011682016040523d82523d6000602084013e612a03565b606091505b5091509150818015612a2d575080511580612a2d575080806020019051810190612a2d9190612fe2565b612a3657600080fd5b5050505050565b6060612a4c8484600085612a54565b949350505050565b606082471015612ab55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610535565b600080866001600160a01b03168587604051612ad19190613029565b60006040518083038185875af1925050503d8060008114612b0e576040519150601f19603f3d011682016040523d82523d6000602084013e612b13565b606091505b5091509150612b2487838387612b2f565b979650505050505050565b60608315612b9e578251600003612b97576001600160a01b0385163b612b975760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610535565b5081612a4c565b612a4c8383815115612bb35781518083602001fd5b8060405162461bcd60e51b81526004016105359190613045565b600060208284031215612bdf57600080fd5b5035919050565b6001600160a01b03811681146107a457600080fd5b60008060408385031215612c0e57600080fd5b8235612c1981612be6565b946020939093013593505050565b80516001600160a01b03908116835260208083015182169084015260408083015190911690830152606090810151910152565b60c08101612c688286612c27565b8360808301526001600160801b03831660a0830152949350505050565b600060208284031215612c9757600080fd5b8135612ca281612be6565b9392505050565b602080825260099082015268656d657267656e637960b81b604082015260600190565b600060208284031215612cde57600080fd5b8151612ca281612be6565b60008060008060808587031215612cff57600080fd5b8451612d0a81612be6565b6020860151909450612d1b81612be6565b6040860151909350612d2c81612be6565b6060959095015193969295505050565b60a08101612d4a8285612c27565b8260808301529392505050565b600060208284031215612d6957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612d9957612d99612d70565b500190565b6000816000190483118215151615612db857612db8612d70565b500290565b600082612dda57634e487b7160e01b600052601260045260246000fd5b500490565b600082821015612df157612df1612d70565b500390565b60008060408385031215612e0957600080fd5b505080516020909101519092909150565b80516001600160801b0381168114612e3157600080fd5b919050565b80518015158114612e3157600080fd5b60008060008060008060c08789031215612e5f57600080fd5b612e6887612e1a565b9550612e7660208801612e1a565b94506040870151612e8681612be6565b606088015190945062ffffff81168114612e9f57600080fd5b9250612ead60808801612e36565b915060a0870151612ebd81612be6565b809150509295509295509295565b600060208284031215612edd57600080fd5b612ca282612e1a565b8051600281900b8114612e3157600080fd5b600080600080600060a08688031215612f1057600080fd5b612f1986612e1a565b9450612f2760208701612ee6565b9350612f3560408701612ee6565b6060870151608090970151959894975095949392505050565b60008060408385031215612f6157600080fd5b612f6a83612e1a565b9150612f7860208401612e1a565b90509250929050565b60c08101612f8f8286612c27565b6001600160801b03808516608084015280841660a084015250949350505050565b600060208284031215612fc257600080fd5b815161ffff81168114612ca257600080fd5b6080810161294a8284612c27565b600060208284031215612ff457600080fd5b612ca282612e36565b60005b83811015613018578181015183820152602001613000565b838111156121d75750506000910152565b6000825161303b818460208701612ffd565b9190910192915050565b6020815260008251806020840152613064816040850160208701612ffd565b601f01601f1916919091016040019291505056fea2646970667358221220b6e6612f1d04a350634162a31f7a13575120ed033c2cd870e796d8378f9e73e564736f6c634300080d003300000000000000000000000000da8466b296e382e5da2bf20962d0cb87200c780000000000000000000000004c3e7640b3e3a39a2e5d030a0c1412d80fee1d44000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf0500000000000000000000000019a410046afc4203aece5fbfc7a6ac1a4f517ae200000000000000000000000009d6f648b217ae223ad8e856888f709c8a3dc8bf000000000000000000000000da6afdae9e74558355fda7d9bf756ea11d847d11000000000000000000000000428ea5b4ac84ab687851e6a2688411bdbd6c91af0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a33700000000000000000000000000d5bbd0fe275efee371a2b34d0a4b95b0c8aaaa00000000000000000000000000da8466b296e382e5da2bf20962d0cb87200c780000000000000000000000008d38206e38ec86b14530186aa36cc3b1ed8cd674
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80639cc7f7081161010f578063caa6fea4116100a2578063df136d6511610071578063df136d65146104a0578063ef405caf146104a9578063f2fde38b146104d0578063f7c618c1146104e357600080fd5b8063caa6fea41461044c578063d009601014610469578063d294f09314610471578063dd56e5d81461047957600080fd5b8063b66503cf116100de578063b66503cf146103e7578063b6b55f2514610409578063c863657d1461041c578063c8f33c911461044357600080fd5b80639cc7f7081461037e5780639f747b2014610391578063b1534ecd146103b8578063b44a2722146103c057600080fd5b8063715018a6116101875780637b0a47ee116101565780637b0a47ee146103355780637c91e4eb1461033e578063833d3212146103655780638da5cb5b1461036d57600080fd5b8063715018a6146102d757806372069264146102df578063737869c6146102e7578063770f85711461030e57600080fd5b80632e1a7d4d116101c35780632e1a7d4d1461028a5780633513f1df1461029f5780634d6ed8c4146102bc5780636946a235146102cf57600080fd5b806303fbf83a146101ea5780631755ff211461022e5780631be0528914610255575b600080fd5b6102117f000000000000000000000000da6afdae9e74558355fda7d9bf756ea11d847d1181565b6040516001600160a01b0390911681526020015b60405180910390f35b6102117f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf0581565b61027c7f0000000000000000000000000000000000000000000000000000000000093a8081565b604051908152602001610225565b61029d610298366004612bcd565b61050a565b005b6102a76107a7565b60408051928352602083019190915201610225565b6102a76102ca366004612bcd565b610b42565b61027c610cde565b61029d610d13565b61027c610d27565b6102117f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a33781565b6102117f00000000000000000000000009d6f648b217ae223ad8e856888f709c8a3dc8bf81565b61027c60035481565b6102117f00000000000000000000000019a410046afc4203aece5fbfc7a6ac1a4f517ae281565b6102a7610f4b565b6001546001600160a01b0316610211565b61027c61038c366004612bcd565b611136565b6102117f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf0581565b61029d6112fd565b6102117f00000000000000000000000000d5bbd0fe275efee371a2b34d0a4b95b0c8aaaa81565b6103fa6103f5366004612bfb565b61135c565b60405161022593929190612c5a565b61029d610417366004612bcd565b611830565b6102117f0000000000000000000000004c3e7640b3e3a39a2e5d030a0c1412d80fee1d4481565b61027c60045481565b6006546104599060ff1681565b6040519015158152602001610225565b61029d611b57565b6102a7611bba565b6102117f000000000000000000000000428ea5b4ac84ab687851e6a2688411bdbd6c91af81565b61027c60055481565b6102117f00000000000000000000000000da8466b296e382e5da2bf20962d0cb87200c7881565b61029d6104de366004612c85565b611bdf565b6102117f00000000000000000000000000da8466b296e382e5da2bf20962d0cb87200c7881565b610512611c55565b60065460ff161561053e5760405162461bcd60e51b815260040161053590612ca9565b60405180910390fd5b6040516331a9108f60e11b8152600481018290527f00000000000000000000000000d5bbd0fe275efee371a2b34d0a4b95b0c8aaaa6001600160a01b031690636352211e90602401602060405180830381865afa1580156105a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c79190612ccc565b6001600160a01b0316336001600160a01b0316146105e457600080fd5b604051632bb2ac2360e11b81526001600160a01b037f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf05811660048301526000918291829182917f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3371690635765584690602401608060405180830381865afa158015610673573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106979190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090507f000000000000000000000000428ea5b4ac84ab687851e6a2688411bdbd6c91af6001600160a01b0316634473eca682886040518363ffffffff1660e01b815260040161072d929190612d3c565b600060405180830381600087803b15801561074757600080fd5b505af115801561075b573d6000803e3d6000fd5b50506040518881523392507f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436491506020015b60405180910390a250505050506107a46001600055565b50565b60008060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561080a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082e9190612ccc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610874573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108989190612d57565b905060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091e9190612ccc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610964573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109889190612d57565b9050600080610995611cae565b90925090506109a48285612d86565b95506109b08184612d86565b945060007f0000000000000000000000008d38206e38ec86b14530186aa36cc3b1ed8cd6746001600160a01b0316637cfc29956040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a369190612d57565b905060007f0000000000000000000000008d38206e38ec86b14530186aa36cc3b1ed8cd6746001600160a01b0316637be1623e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abc9190612ccc565b905060006001600160a01b038216610ad5576000610aec565b612710610ae2848b612d9e565b610aec9190612dbd565b905060006001600160a01b038316610b05576000610b1c565b612710610b12858b612d9e565b610b1c9190612dbd565b9050610b28828b612ddf565b9950610b34818a612ddf565b985050505050505050509091565b604051632bb2ac2360e11b81526001600160a01b037f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf0581166004830152600091829182918291829182917f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3371690635765584690602401608060405180830381865afa158015610bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf99190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090507f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3376001600160a01b03166396da9bd5828a6040518363ffffffff1660e01b8152600401610c8f929190612d3c565b6040805180830381865afa158015610cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccf9190612df6565b90999098509650505050505050565b60007f0000000000000000000000000000000000000000000000000000000000093a80600354610d0e9190612d9e565b905090565b610d1b612090565b610d2560006120ea565b565b60008060008060007f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3376001600160a01b031663576558467f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056040518263ffffffff1660e01b8152600401610daa91906001600160a01b0391909116815260200190565b608060405180830381865afa158015610dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610deb9190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090506000610e3e8261213c565b604051636077779560e01b8152600481018290529091506000906001600160a01b037f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a337169063607777959060240160c060405180830381865afa158015610ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecd9190612e46565b50505092505050806001600160a01b03166346caf2ae6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f369190612ecb565b6001600160801b031697505050505050505090565b60008060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd29190612ccc565b905060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110589190612ccc565b6040516370a0823160e01b81523060048201529091506001600160a01b038316906370a0823190602401602060405180830381865afa15801561109f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c39190612d57565b6040516370a0823160e01b81523060048201529094506001600160a01b038216906370a0823190602401602060405180830381865afa15801561110a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112e9190612d57565b925050509091565b60008060008060007f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3376001600160a01b031663576558467f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056040518263ffffffff1660e01b81526004016111b991906001600160a01b0391909116815260200190565b608060405180830381865afa1580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111fa9190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b0316815260200183815250905060007f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3376001600160a01b03166327e6a99a8961127d8561213c565b6040516001600160e01b031960e085901b1681526004810192909252602482015260440160a060405180830381865afa1580156112be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e29190612ef8565b50506001600160801b039092169a9950505050505050505050565b611305612090565b60065460ff166113275760405162461bcd60e51b815260040161053590612ca9565b6006805460ff191690556040517f9c68e6e839755352b6969c9291d44f48f0d0e85817dc99069e54615ec62131b390600090a1565b60408051608081018252600080825260208201819052918101829052606081018290529080611389611c55565b60065460ff16156113ac5760405162461bcd60e51b815260040161053590612ca9565b336001600160a01b037f00000000000000000000000019a410046afc4203aece5fbfc7a6ac1a4f517ae216146114095760405162461bcd60e51b81526020600482015260026024820152614e4160f01b6044820152606401610535565b7f00000000000000000000000000da8466b296e382e5da2bf20962d0cb87200c786001600160a01b0316856001600160a01b03161461147a5760405162461bcd60e51b815260206004820152600d60248201526c3737ba103932bb903a37b5b2b760991b6044820152606401610535565b600061148f4262093a80808206820301612ddf565b905060025442106114ac576114a48186612dbd565b6003556114d8565b6000600354826114bc9190612d9e565b9050816114c98288612d86565b6114d39190612dbd565b600355505b62093a8042818106900301600255604051632bb2ac2360e11b81526001600160a01b037f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf05811660048301526000918291829182917f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3371690635765584690602401608060405180830381865afa158015611575573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115999190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b0316815260200183815250905060007f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3376001600160a01b0316636077779561161b8461213c565b6040518263ffffffff1660e01b815260040161163991815260200190565b60c060405180830381865afa158015611656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167a9190612e46565b505050925050506000816001600160a01b031663a88a5c166040518163ffffffff1660e01b81526004016040805180830381865afa1580156116c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e49190612f4e565b915061171d90506001600160a01b037f00000000000000000000000000da8466b296e382e5da2bf20962d0cb87200c781633308f61216c565b6117516001600160a01b038e167f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3378e6121dd565b7f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3376001600160a01b031663f26ebf7a848e60006040518463ffffffff1660e01b81526004016117a293929190612f81565b600060405180830381600087803b1580156117bc57600080fd5b505af11580156117d0573d6000803e3d6000fd5b505050507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d8c60405161180591815260200190565b60405180910390a1600354929a509198509096505050505050506118296001600055565b9250925092565b611838611c55565b60065460ff161561185b5760405162461bcd60e51b815260040161053590612ca9565b6040516331a9108f60e11b8152600481018290527f00000000000000000000000000d5bbd0fe275efee371a2b34d0a4b95b0c8aaaa6001600160a01b031690636352211e90602401602060405180830381865afa1580156118c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e49190612ccc565b6001600160a01b0316336001600160a01b03161461190157600080fd5b604051634197b18560e11b815260048101829052600160248201526001600160a01b037f000000000000000000000000428ea5b4ac84ab687851e6a2688411bdbd6c91af811660448301527f00000000000000000000000000d5bbd0fe275efee371a2b34d0a4b95b0c8aaaa169063832f630a90606401600060405180830381600087803b15801561199257600080fd5b505af11580156119a6573d6000803e3d6000fd5b5050604051632bb2ac2360e11b81526001600160a01b037f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf058116600483015260009350839250829182917f0000000000000000000000001e862624eda92b8fe532c16253356d17dd70a3371690635765584690602401608060405180830381865afa158015611a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5d9190612ce9565b935093509350935060006040518060800160405280866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381525090507f000000000000000000000000428ea5b4ac84ab687851e6a2688411bdbd6c91af6001600160a01b0316635739f0b982886040518363ffffffff1660e01b8152600401611af3929190612d3c565b600060405180830381600087803b158015611b0d57600080fd5b505af1158015611b21573d6000803e3d6000fd5b50506040518881523392507fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c915060200161078d565b611b5f612090565b60065460ff1615611b825760405162461bcd60e51b815260040161053590612ca9565b6006805460ff191660011790556040517fd596bbda13fdbf0904b2a7ce45e50145b26720d719bd8dd257f3020fe7bf880f90600090a1565b600080611bc5611c55565b611bcd61226c565b91509150611bdb6001600055565b9091565b611be7612090565b6001600160a01b038116611c4c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610535565b6107a4816120ea565b600260005403611ca75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610535565b6002600055565b60008060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b03166353e978686040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d359190612ccc565b90507f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db99190612ccc565b6040516370a0823160e01b81526001600160a01b03838116600483015291909116906370a0823190602401602060405180830381865afa158015611e01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e259190612d57565b92507f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea99190612ccc565b6040516370a0823160e01b81526001600160a01b03838116600483015291909116906370a0823190602401602060405180830381865afa158015611ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f159190612d57565b91506000807f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b0316637bd780256040518163ffffffff1660e01b81526004016040805180830381865afa158015611f77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9b9190612f4e565b9092509050611fb36001600160801b03831686612d86565b9450611fc86001600160801b03821685612d86565b93506000836001600160a01b0316639f856b8d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561200a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202e9190612fb0565b905060006103e861204361ffff841689612d9e565b61204d9190612dbd565b905060006103e861206261ffff851689612d9e565b61206c9190612dbd565b90506120788289612ddf565b97506120848188612ddf565b96505050505050509091565b6001546001600160a01b03163314610d255760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610535565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008160405160200161214f9190612fd4565b604051602081830303815290604052805190602001209050919050565b6040516001600160a01b03808516602483015283166044820152606481018290526121d79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526127cd565b50505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261222e84826128a7565b6121d7576040516001600160a01b03841660248201526000604482015261226290859063095ea7b360e01b906064016121a0565b6121d784826127cd565b60008060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f39190612ccc565b905060007f000000000000000000000000ed1050e2fe96f7327dc659613c79e41458e9cf056001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612355573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123799190612ccc565b6040516370a0823160e01b81523060048201529091506001600160a01b038316906370a0823190602401602060405180830381865afa1580156123c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e49190612d57565b6040516370a0823160e01b81523060048201529094506001600160a01b038216906370a0823190602401602060405180830381865afa15801561242b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244f9190612d57565b925060008411806124605750600083115b156127c75760007f0000000000000000000000008d38206e38ec86b14530186aa36cc3b1ed8cd6746001600160a01b0316637cfc29956040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124e99190612d57565b905060007f0000000000000000000000008d38206e38ec86b14530186aa36cc3b1ed8cd6746001600160a01b0316637be1623e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561254b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256f9190612ccc565b905060006001600160a01b03821661258857600061259f565b6127106125958489612d9e565b61259f9190612dbd565b905060006001600160a01b0383166125b85760006125cf565b6127106125c58589612d9e565b6125cf9190612dbd565b905081156125ef576125e2868484612950565b6125ec8289612ddf565b97505b801561260d57612600858483612950565b61260a8188612ddf565b96505b87156126ca576126476001600160a01b0387167f00000000000000000000000009d6f648b217ae223ad8e856888f709c8a3dc8bf8a6121dd565b60405163b66503cf60e01b81526001600160a01b038781166004830152602482018a90527f00000000000000000000000009d6f648b217ae223ad8e856888f709c8a3dc8bf169063b66503cf90604401600060405180830381600087803b1580156126b157600080fd5b505af11580156126c5573d6000803e3d6000fd5b505050505b8615612787576127046001600160a01b0386167f00000000000000000000000009d6f648b217ae223ad8e856888f709c8a3dc8bf896121dd565b60405163b66503cf60e01b81526001600160a01b038681166004830152602482018990527f00000000000000000000000009d6f648b217ae223ad8e856888f709c8a3dc8bf169063b66503cf90604401600060405180830381600087803b15801561276e57600080fd5b505af1158015612782573d6000803e3d6000fd5b505050505b604080518981526020810189905233917fbc567d6cbad26368064baa0ab5a757be46aae4d70f707f9203d9d9b6c8ccbfa3910160405180910390a2505050505b50509091565b6000612822826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a3d9092919063ffffffff16565b90508051600014806128435750808060200190518101906128439190612fe2565b6128a25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610535565b505050565b6000806000846001600160a01b0316846040516128c49190613029565b6000604051808303816000865af19150503d8060008114612901576040519150601f19603f3d011682016040523d82523d6000602084013e612906565b606091505b50915091508180156129305750805115806129305750808060200190518101906129309190612fe2565b801561294557506001600160a01b0385163b15155b925050505b92915050565b6000836001600160a01b03163b1161296757600080fd5b6040516001600160a01b03838116602483015260448201839052600091829186169060640160408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052516129c19190613029565b6000604051808303816000865af19150503d80600081146129fe576040519150601f19603f3d011682016040523d82523d6000602084013e612a03565b606091505b5091509150818015612a2d575080511580612a2d575080806020019051810190612a2d9190612fe2565b612a3657600080fd5b5050505050565b6060612a4c8484600085612a54565b949350505050565b606082471015612ab55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610535565b600080866001600160a01b03168587604051612ad19190613029565b60006040518083038185875af1925050503d8060008114612b0e576040519150601f19603f3d011682016040523d82523d6000602084013e612b13565b606091505b5091509150612b2487838387612b2f565b979650505050505050565b60608315612b9e578251600003612b97576001600160a01b0385163b612b975760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610535565b5081612a4c565b612a4c8383815115612bb35781518083602001fd5b8060405162461bcd60e51b81526004016105359190613045565b600060208284031215612bdf57600080fd5b5035919050565b6001600160a01b03811681146107a457600080fd5b60008060408385031215612c0e57600080fd5b8235612c1981612be6565b946020939093013593505050565b80516001600160a01b03908116835260208083015182169084015260408083015190911690830152606090810151910152565b60c08101612c688286612c27565b8360808301526001600160801b03831660a0830152949350505050565b600060208284031215612c9757600080fd5b8135612ca281612be6565b9392505050565b602080825260099082015268656d657267656e637960b81b604082015260600190565b600060208284031215612cde57600080fd5b8151612ca281612be6565b60008060008060808587031215612cff57600080fd5b8451612d0a81612be6565b6020860151909450612d1b81612be6565b6040860151909350612d2c81612be6565b6060959095015193969295505050565b60a08101612d4a8285612c27565b8260808301529392505050565b600060208284031215612d6957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612d9957612d99612d70565b500190565b6000816000190483118215151615612db857612db8612d70565b500290565b600082612dda57634e487b7160e01b600052601260045260246000fd5b500490565b600082821015612df157612df1612d70565b500390565b60008060408385031215612e0957600080fd5b505080516020909101519092909150565b80516001600160801b0381168114612e3157600080fd5b919050565b80518015158114612e3157600080fd5b60008060008060008060c08789031215612e5f57600080fd5b612e6887612e1a565b9550612e7660208801612e1a565b94506040870151612e8681612be6565b606088015190945062ffffff81168114612e9f57600080fd5b9250612ead60808801612e36565b915060a0870151612ebd81612be6565b809150509295509295509295565b600060208284031215612edd57600080fd5b612ca282612e1a565b8051600281900b8114612e3157600080fd5b600080600080600060a08688031215612f1057600080fd5b612f1986612e1a565b9450612f2760208701612ee6565b9350612f3560408701612ee6565b6060870151608090970151959894975095949392505050565b60008060408385031215612f6157600080fd5b612f6a83612e1a565b9150612f7860208401612e1a565b90509250929050565b60c08101612f8f8286612c27565b6001600160801b03808516608084015280841660a084015250949350505050565b600060208284031215612fc257600080fd5b815161ffff81168114612ca257600080fd5b6080810161294a8284612c27565b600060208284031215612ff457600080fd5b612ca282612e36565b60005b83811015613018578181015183820152602001613000565b838111156121d75750506000910152565b6000825161303b818460208701612ffd565b9190910192915050565b6020815260008251806020840152613064816040850160208701612ffd565b601f01601f1916919091016040019291505056fea2646970667358221220b6e6612f1d04a350634162a31f7a13575120ed033c2cd870e796d8378f9e73e564736f6c634300080d0033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.