// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return 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: BUSL-1.1
pragma solidity 0.8.19;
import {IAero} from "./interfaces/IAero.sol";
import {IVotingEscrow} from "./interfaces/IVotingEscrow.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IAirdropDistributor} from "./interfaces/IAirdropDistributor.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract AirdropDistributor is IAirdropDistributor, Ownable {
using SafeERC20 for IAero;
/// @inheritdoc IAirdropDistributor
IAero public immutable aero;
/// @inheritdoc IAirdropDistributor
IVotingEscrow public immutable ve;
constructor(address _ve) {
ve = IVotingEscrow(_ve);
aero = IAero(IVotingEscrow(_ve).token());
}
/// @inheritdoc IAirdropDistributor
function distributeTokens(address[] memory _wallets, uint256[] memory _amounts) external override onlyOwner {
uint256 _len = _wallets.length;
if (_len != _amounts.length) revert InvalidParams();
uint256 _sum;
for (uint256 i = 0; i < _len; i++) {
_sum += _amounts[i];
}
if (_sum > aero.balanceOf(address(this))) revert InsufficientBalance();
aero.safeApprove(address(ve), _sum);
address _wallet;
uint256 _amount;
uint256 _tokenId;
for (uint256 i = 0; i < _len; i++) {
_wallet = _wallets[i];
_amount = _amounts[i];
_tokenId = ve.createLock(_amount, 1 weeks);
ve.lockPermanent(_tokenId);
ve.safeTransferFrom(address(this), _wallet, _tokenId);
emit Airdrop(_wallet, _amount, _tokenId);
}
aero.safeApprove(address(ve), 0);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IAero is IERC20 {
error NotMinter();
error NotOwner();
/// @notice Mint an amount of tokens to an account
/// Only callable by Minter.sol
/// @return True if success
function mint(address account, uint256 amount) external returns (bool);
/// @notice Address of Minter.sol
function minter() external view returns (address);
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;
import {IAero} from "./IAero.sol";
import {IVotingEscrow} from "./IVotingEscrow.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
interface IAirdropDistributor {
error InvalidParams();
error InsufficientBalance();
event Airdrop(address indexed _wallet, uint256 _amount, uint256 _tokenId);
/// @notice Interface of Aero.sol
function aero() external view returns (IAero);
/// @notice Interface of IVotingEscrow.sol
function ve() external view returns (IVotingEscrow);
/// @notice Distributes permanently locked NFTs to the desired addresses
/// @param _wallets Addresses of wallets to receive the Airdrop
/// @param _amounts Amounts to be Airdropped
function distributeTokens(address[] memory _wallets, uint256[] memory _amounts) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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 v4.4.1 (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.
*/
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].
*/
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
pragma solidity ^0.8.0;
import "./IERC165.sol";
import "./IERC721.sol";
/// @title EIP-721 Metadata Update Extension
interface IERC4906 is IERC165, IERC721 {
/// @dev This event emits when the metadata of a token is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFT.
event MetadataUpdate(uint256 _tokenId);
/// @dev This event emits when the metadata of a range of tokens is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFTs.
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (interfaces/IERC6372.sol)
pragma solidity ^0.8.0;
interface IERC6372 {
/**
* @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
*/
function clock() external view returns (uint48);
/**
* @dev Description of the clock
*/
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol)
pragma solidity ^0.8.0;
import "../token/ERC721/IERC721.sol";
// 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: BUSL-1.1
pragma solidity ^0.8.0;
/// Modified IVotes interface for tokenId based voting
interface IVotes {
/**
* @dev Emitted when an account changes their delegate.
*/
event DelegateChanged(address indexed delegator, uint256 indexed fromDelegate, uint256 indexed toDelegate);
/**
* @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
*/
event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);
/**
* @dev Returns the amount of votes that `tokenId` had at a specific moment in the past.
* If the account passed in is not the owner, returns 0.
*/
function getPastVotes(address account, uint256 tokenId, uint256 timepoint) external view returns (uint256);
/**
* @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value the end of the corresponding block.
*
* NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
* Votes that have not been delegated are still part of total supply, even though they would not participate in a
* vote.
*/
function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
/**
* @dev Returns the delegate that `tokenId` has chosen. Can never be equal to the delegator's `tokenId`.
* Returns 0 if not delegated.
*/
function delegates(uint256 tokenId) external view returns (uint256);
/**
* @dev Delegates votes from the sender to `delegatee`.
*/
function delegate(uint256 delegator, uint256 delegatee) external;
/**
* @dev Delegates votes from `delegator` to `delegatee`. Signer must own `delegator`.
*/
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC165, IERC721, IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {IERC6372} from "@openzeppelin/contracts/interfaces/IERC6372.sol";
import {IERC4906} from "@openzeppelin/contracts/interfaces/IERC4906.sol";
import {IVotes} from "../governance/IVotes.sol";
interface IVotingEscrow is IVotes, IERC4906, IERC6372, IERC721Metadata {
struct LockedBalance {
int128 amount;
uint256 end;
bool isPermanent;
}
struct UserPoint {
int128 bias;
int128 slope; // # -dweight / dt
uint256 ts;
uint256 blk; // block
uint256 permanent;
}
struct GlobalPoint {
int128 bias;
int128 slope; // # -dweight / dt
uint256 ts;
uint256 blk; // block
uint256 permanentLockBalance;
}
/// @notice A checkpoint for recorded delegated voting weights at a certain timestamp
struct Checkpoint {
uint256 fromTimestamp;
address owner;
uint256 delegatedBalance;
uint256 delegatee;
}
enum DepositType {
DEPOSIT_FOR_TYPE,
CREATE_LOCK_TYPE,
INCREASE_LOCK_AMOUNT,
INCREASE_UNLOCK_TIME
}
/// @dev Different types of veNFTs:
/// NORMAL - typical veNFT
/// LOCKED - veNFT which is locked into a MANAGED veNFT
/// MANAGED - veNFT which can accept the deposit of NORMAL veNFTs
enum EscrowType {
NORMAL,
LOCKED,
MANAGED
}
error AlreadyVoted();
error AmountTooBig();
error ERC721ReceiverRejectedTokens();
error ERC721TransferToNonERC721ReceiverImplementer();
error InvalidNonce();
error InvalidSignature();
error InvalidSignatureS();
error InvalidManagedNFTId();
error LockDurationNotInFuture();
error LockDurationTooLong();
error LockExpired();
error LockNotExpired();
error NoLockFound();
error NonExistentToken();
error NotApprovedOrOwner();
error NotDistributor();
error NotEmergencyCouncilOrGovernor();
error NotGovernor();
error NotGovernorOrManager();
error NotManagedNFT();
error NotManagedOrNormalNFT();
error NotLockedNFT();
error NotNormalNFT();
error NotPermanentLock();
error NotOwner();
error NotTeam();
error NotVoter();
error OwnershipChange();
error PermanentLock();
error SameAddress();
error SameNFT();
error SameState();
error SplitNoOwner();
error SplitNotAllowed();
error SignatureExpired();
error TooManyTokenIDs();
error ZeroAddress();
error ZeroAmount();
error ZeroBalance();
event Deposit(
address indexed provider,
uint256 indexed tokenId,
DepositType indexed depositType,
uint256 value,
uint256 locktime,
uint256 ts
);
event Withdraw(address indexed provider, uint256 indexed tokenId, uint256 value, uint256 ts);
event LockPermanent(address indexed _owner, uint256 indexed _tokenId, uint256 amount, uint256 _ts);
event UnlockPermanent(address indexed _owner, uint256 indexed _tokenId, uint256 amount, uint256 _ts);
event Supply(uint256 prevSupply, uint256 supply);
event Merge(
address indexed _sender,
uint256 indexed _from,
uint256 indexed _to,
uint256 _amountFrom,
uint256 _amountTo,
uint256 _amountFinal,
uint256 _locktime,
uint256 _ts
);
event Split(
uint256 indexed _from,
uint256 indexed _tokenId1,
uint256 indexed _tokenId2,
address _sender,
uint256 _splitAmount1,
uint256 _splitAmount2,
uint256 _locktime,
uint256 _ts
);
event CreateManaged(
address indexed _to,
uint256 indexed _mTokenId,
address indexed _from,
address _lockedManagedReward,
address _freeManagedReward
);
event DepositManaged(
address indexed _owner,
uint256 indexed _tokenId,
uint256 indexed _mTokenId,
uint256 _weight,
uint256 _ts
);
event WithdrawManaged(
address indexed _owner,
uint256 indexed _tokenId,
uint256 indexed _mTokenId,
uint256 _weight,
uint256 _ts
);
event SetAllowedManager(address indexed _allowedManager);
// State variables
/// @notice Address of Meta-tx Forwarder
function forwarder() external view returns (address);
/// @notice Address of FactoryRegistry.sol
function factoryRegistry() external view returns (address);
/// @notice Address of token (AERO) used to create a veNFT
function token() external view returns (address);
/// @notice Address of RewardsDistributor.sol
function distributor() external view returns (address);
/// @notice Address of Voter.sol
function voter() external view returns (address);
/// @notice Address of Protocol Team multisig
function team() external view returns (address);
/// @notice Address of art proxy used for on-chain art generation
function artProxy() external view returns (address);
/// @dev address which can create managed NFTs
function allowedManager() external view returns (address);
/// @dev Current count of token
function tokenId() external view returns (uint256);
/*///////////////////////////////////////////////////////////////
MANAGED NFT STORAGE
//////////////////////////////////////////////////////////////*/
/// @dev Mapping of token id to escrow type
/// Takes advantage of the fact default value is EscrowType.NORMAL
function escrowType(uint256 tokenId) external view returns (EscrowType);
/// @dev Mapping of token id to managed id
function idToManaged(uint256 tokenId) external view returns (uint256 managedTokenId);
/// @dev Mapping of user token id to managed token id to weight of token id
function weights(uint256 tokenId, uint256 managedTokenId) external view returns (uint256 weight);
/// @dev Mapping of managed id to deactivated state
function deactivated(uint256 tokenId) external view returns (bool inactive);
/// @dev Mapping from managed nft id to locked managed rewards
/// `token` denominated rewards (rebases/rewards) stored in locked managed rewards contract
/// to prevent co-mingling of assets
function managedToLocked(uint256 tokenId) external view returns (address);
/// @dev Mapping from managed nft id to free managed rewards contract
/// these rewards can be freely withdrawn by users
function managedToFree(uint256 tokenId) external view returns (address);
/*///////////////////////////////////////////////////////////////
MANAGED NFT LOGIC
//////////////////////////////////////////////////////////////*/
/// @notice Create managed NFT (a permanent lock) for use within ecosystem.
/// @dev Throws if address already owns a managed NFT.
/// @return _mTokenId managed token id.
function createManagedLockFor(address _to) external returns (uint256 _mTokenId);
/// @notice Delegates balance to managed nft
/// Note that NFTs deposited into a managed NFT will be re-locked
/// to the maximum lock time on withdrawal.
/// Permanent locks that are deposited will automatically unlock.
/// @dev Managed nft will remain max-locked as long as there is at least one
/// deposit or withdrawal per week.
/// Throws if deposit nft is managed.
/// Throws if recipient nft is not managed.
/// Throws if deposit nft is already locked.
/// Throws if not called by voter.
/// @param _tokenId tokenId of NFT being deposited
/// @param _mTokenId tokenId of managed NFT that will receive the deposit
function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;
/// @notice Retrieves locked rewards and withdraws balance from managed nft.
/// Note that the NFT withdrawn is re-locked to the maximum lock time.
/// @dev Throws if NFT not locked.
/// Throws if not called by voter.
/// @param _tokenId tokenId of NFT being deposited.
function withdrawManaged(uint256 _tokenId) external;
/// @notice Permit one address to call createManagedLockFor() that is not Voter.governor()
function setAllowedManager(address _allowedManager) external;
/// @notice Set Managed NFT state. Inactive NFTs cannot be deposited into.
/// @param _mTokenId managed nft state to set
/// @param _state true => inactive, false => active
function setManagedState(uint256 _mTokenId, bool _state) external;
/*///////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function version() external view returns (string memory);
function decimals() external view returns (uint8);
function setTeam(address _team) external;
function setArtProxy(address _proxy) external;
/// @inheritdoc IERC721Metadata
function tokenURI(uint256 tokenId) external view returns (string memory);
/*//////////////////////////////////////////////////////////////
ERC721 BALANCE/OWNER STORAGE
//////////////////////////////////////////////////////////////*/
/// @dev Mapping from owner address to mapping of index to tokenId
function ownerToNFTokenIdList(address _owner, uint256 _index) external view returns (uint256 _tokenId);
/// @inheritdoc IERC721
function ownerOf(uint256 tokenId) external view returns (address owner);
/// @inheritdoc IERC721
function balanceOf(address owner) external view returns (uint256 balance);
/*//////////////////////////////////////////////////////////////
ERC721 APPROVAL STORAGE
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IERC721
function getApproved(uint256 _tokenId) external view returns (address operator);
/// @inheritdoc IERC721
function isApprovedForAll(address owner, address operator) external view returns (bool);
/// @notice Check whether spender is owner or an approved user for a given veNFT
/// @param _spender .
/// @param _tokenId .
function isApprovedOrOwner(address _spender, uint256 _tokenId) external returns (bool);
/*//////////////////////////////////////////////////////////////
ERC721 LOGIC
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IERC721
function approve(address to, uint256 tokenId) external;
/// @inheritdoc IERC721
function setApprovalForAll(address operator, bool approved) external;
/// @inheritdoc IERC721
function transferFrom(address from, address to, uint256 tokenId) external;
/// @inheritdoc IERC721
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/// @inheritdoc IERC721
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/*//////////////////////////////////////////////////////////////
ERC165 LOGIC
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IERC165
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
/*//////////////////////////////////////////////////////////////
ESCROW STORAGE
//////////////////////////////////////////////////////////////*/
/// @notice Total count of epochs witnessed since contract creation
function epoch() external view returns (uint256);
/// @notice Total amount of token() deposited
function supply() external view returns (uint256);
/// @notice Aggregate permanent locked balances
function permanentLockBalance() external view returns (uint256);
function userPointEpoch(uint256 _tokenId) external view returns (uint256 _epoch);
/// @notice time -> signed slope change
function slopeChanges(uint256 _timestamp) external view returns (int128);
/// @notice account -> can split
function canSplit(address _account) external view returns (bool);
/// @notice Global point history at a given index
function pointHistory(uint256 _loc) external view returns (GlobalPoint memory);
/// @notice Get the LockedBalance (amount, end) of a _tokenId
/// @param _tokenId .
/// @return LockedBalance of _tokenId
function locked(uint256 _tokenId) external view returns (LockedBalance memory);
/// @notice User -> UserPoint[userEpoch]
function userPointHistory(uint256 _tokenId, uint256 _loc) external view returns (UserPoint memory);
/*//////////////////////////////////////////////////////////////
ESCROW LOGIC
//////////////////////////////////////////////////////////////*/
/// @notice Record global data to checkpoint
function checkpoint() external;
/// @notice Deposit `_value` tokens for `_tokenId` and add to the lock
/// @dev Anyone (even a smart contract) can deposit for someone else, but
/// cannot extend their locktime and deposit for a brand new user
/// @param _tokenId lock NFT
/// @param _value Amount to add to user's lock
function depositFor(uint256 _tokenId, uint256 _value) external;
/// @notice Deposit `_value` tokens for `msg.sender` and lock for `_lockDuration`
/// @param _value Amount to deposit
/// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week)
/// @return TokenId of created veNFT
function createLock(uint256 _value, uint256 _lockDuration) external returns (uint256);
/// @notice Deposit `_value` tokens for `_to` and lock for `_lockDuration`
/// @param _value Amount to deposit
/// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week)
/// @param _to Address to deposit
/// @return TokenId of created veNFT
function createLockFor(uint256 _value, uint256 _lockDuration, address _to) external returns (uint256);
/// @notice Deposit `_value` additional tokens for `_tokenId` without modifying the unlock time
/// @param _value Amount of tokens to deposit and add to the lock
function increaseAmount(uint256 _tokenId, uint256 _value) external;
/// @notice Extend the unlock time for `_tokenId`
/// Cannot extend lock time of permanent locks
/// @param _lockDuration New number of seconds until tokens unlock
function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external;
/// @notice Withdraw all tokens for `_tokenId`
/// @dev Only possible if the lock is both expired and not permanent
/// This will burn the veNFT. Any rebases or rewards that are unclaimed
/// will no longer be claimable. Claim all rebases and rewards prior to calling this.
function withdraw(uint256 _tokenId) external;
/// @notice Merges `_from` into `_to`.
/// @dev Cannot merge `_from` locks that are permanent or have already voted this epoch.
/// Cannot merge `_to` locks that have already expired.
/// This will burn the veNFT. Any rebases or rewards that are unclaimed
/// will no longer be claimable. Claim all rebases and rewards prior to calling this.
/// @param _from VeNFT to merge from.
/// @param _to VeNFT to merge into.
function merge(uint256 _from, uint256 _to) external;
/// @notice Splits veNFT into two new veNFTS - one with oldLocked.amount - `_amount`, and the second with `_amount`
/// @dev This burns the tokenId of the target veNFT
/// Callable by approved or owner
/// If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs
/// Returns the two new split veNFTs to owner
/// If `from` is permanent, will automatically dedelegate.
/// This will burn the veNFT. Any rebases or rewards that are unclaimed
/// will no longer be claimable. Claim all rebases and rewards prior to calling this.
/// @param _from VeNFT to split.
/// @param _amount Amount to split from veNFT.
/// @return _tokenId1 Return tokenId of veNFT with oldLocked.amount - `_amount`.
/// @return _tokenId2 Return tokenId of veNFT with `_amount`.
function split(uint256 _from, uint256 _amount) external returns (uint256 _tokenId1, uint256 _tokenId2);
/// @notice Toggle split for a specific address.
/// @dev Toggle split for address(0) to enable or disable for all.
/// @param _account Address to toggle split permissions
/// @param _bool True to allow, false to disallow
function toggleSplit(address _account, bool _bool) external;
/// @notice Permanently lock a veNFT. Voting power will be equal to
/// `LockedBalance.amount` with no decay. Required to delegate.
/// @dev Only callable by unlocked normal veNFTs.
/// @param _tokenId tokenId to lock.
function lockPermanent(uint256 _tokenId) external;
/// @notice Unlock a permanently locked veNFT. Voting power will decay.
/// Will automatically dedelegate if delegated.
/// @dev Only callable by permanently locked veNFTs.
/// Cannot unlock if already voted this epoch.
/// @param _tokenId tokenId to unlock.
function unlockPermanent(uint256 _tokenId) external;
/*///////////////////////////////////////////////////////////////
GAUGE VOTING STORAGE
//////////////////////////////////////////////////////////////*/
/// @notice Get the voting power for _tokenId at the current timestamp
/// @dev Returns 0 if called in the same block as a transfer.
/// @param _tokenId .
/// @return Voting power
function balanceOfNFT(uint256 _tokenId) external view returns (uint256);
/// @notice Get the voting power for _tokenId at a given timestamp
/// @param _tokenId .
/// @param _t Timestamp to query voting power
/// @return Voting power
function balanceOfNFTAt(uint256 _tokenId, uint256 _t) external view returns (uint256);
/// @notice Calculate total voting power at current timestamp
/// @return Total voting power at current timestamp
function totalSupply() external view returns (uint256);
/// @notice Calculate total voting power at a given timestamp
/// @param _t Timestamp to query total voting power
/// @return Total voting power at given timestamp
function totalSupplyAt(uint256 _t) external view returns (uint256);
/*///////////////////////////////////////////////////////////////
GAUGE VOTING LOGIC
//////////////////////////////////////////////////////////////*/
/// @notice See if a queried _tokenId has actively voted
/// @param _tokenId .
/// @return True if voted, else false
function voted(uint256 _tokenId) external view returns (bool);
/// @notice Set the global state voter and distributor
/// @dev This is only called once, at setup
function setVoterAndDistributor(address _voter, address _distributor) external;
/// @notice Set `voted` for _tokenId to true or false
/// @dev Only callable by voter
/// @param _tokenId .
/// @param _voted .
function voting(uint256 _tokenId, bool _voted) external;
/*///////////////////////////////////////////////////////////////
DAO VOTING STORAGE
//////////////////////////////////////////////////////////////*/
/// @notice The number of checkpoints for each tokenId
function numCheckpoints(uint256 tokenId) external view returns (uint48);
/// @notice A record of states for signing / validating signatures
function nonces(address account) external view returns (uint256);
/// @inheritdoc IVotes
function delegates(uint256 delegator) external view returns (uint256);
/// @notice A record of delegated token checkpoints for each account, by index
/// @param tokenId .
/// @param index .
/// @return Checkpoint
function checkpoints(uint256 tokenId, uint48 index) external view returns (Checkpoint memory);
/// @inheritdoc IVotes
function getPastVotes(address account, uint256 tokenId, uint256 timestamp) external view returns (uint256);
/// @inheritdoc IVotes
function getPastTotalSupply(uint256 timestamp) external view returns (uint256);
/*///////////////////////////////////////////////////////////////
DAO VOTING LOGIC
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IVotes
function delegate(uint256 delegator, uint256 delegatee) external;
/// @inheritdoc IVotes
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
/*//////////////////////////////////////////////////////////////
ERC6372 LOGIC
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IERC6372
function clock() external view returns (uint48);
/// @inheritdoc IERC6372
function CLOCK_MODE() external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_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.8.0) (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;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
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");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
{
"compilationTarget": {
"contracts/AirdropDistributor.sol": "AirdropDistributor"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@opengsn/=lib/gsn/packages/",
":@openzeppelin/=lib/openzeppelin-contracts/",
":@uniswap/v3-core/=lib/v3-core/",
":ds-test/=lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":eth-gas-reporter/=node_modules/eth-gas-reporter/",
":forge-std/=lib/forge-std/src/",
":gsn/=lib/gsn/",
":hardhat-deploy/=node_modules/hardhat-deploy/",
":hardhat/=node_modules/hardhat/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":utils/=test/utils/",
":v3-core/=lib/v3-core/"
]
}
[{"inputs":[{"internalType":"address","name":"_ve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidParams","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_wallet","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Airdrop","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"},{"inputs":[],"name":"aero","outputs":[{"internalType":"contract IAero","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_wallets","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"distributeTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ve","outputs":[{"internalType":"contract IVotingEscrow","name":"","type":"address"}],"stateMutability":"view","type":"function"}]