编译器
0.8.10+commit.fc410830
文件 1 的 15:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
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");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
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");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 15:ApeCoinStaking.sol
pragma solidity 0.8.10;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
contract ApeCoinStaking is Ownable {
using SafeCast for uint256;
using SafeCast for int256;
struct Pool {
uint48 lastRewardedTimestampHour;
uint16 lastRewardsRangeIndex;
uint96 stakedAmount;
uint96 accumulatedRewardsPerShare;
TimeRange[] timeRanges;
}
struct TimeRange {
uint48 startTimestampHour;
uint48 endTimestampHour;
uint96 rewardsPerHour;
uint96 capPerPosition;
}
struct PoolUI {
uint256 poolId;
uint256 stakedAmount;
TimeRange currentTimeRange;
}
struct Position {
uint256 stakedAmount;
int256 rewardsDebt;
}
mapping (address => Position) public addressPosition;
struct SingleNft {
uint32 tokenId;
uint224 amount;
}
struct PairNftDepositWithAmount {
uint32 mainTokenId;
uint32 bakcTokenId;
uint184 amount;
}
struct PairNftWithdrawWithAmount {
uint32 mainTokenId;
uint32 bakcTokenId;
uint184 amount;
bool isUncommit;
}
struct PairNft {
uint128 mainTokenId;
uint128 bakcTokenId;
}
struct PairingStatus {
uint248 tokenId;
bool isPaired;
}
struct DashboardStake {
uint256 poolId;
uint256 tokenId;
uint256 deposited;
uint256 unclaimed;
uint256 rewards24hr;
DashboardPair pair;
}
struct DashboardPair {
uint256 mainTokenId;
uint256 mainTypePoolId;
}
DashboardPair private NULL_PAIR = DashboardPair(0, 0);
IERC20 public immutable apeCoin;
uint256 private constant APE_COIN_PRECISION = 1e18;
uint256 private constant MIN_DEPOSIT = 1 * APE_COIN_PRECISION;
uint256 private constant SECONDS_PER_HOUR = 3600;
uint256 private constant SECONDS_PER_MINUTE = 60;
uint256 constant APECOIN_POOL_ID = 0;
uint256 constant BAYC_POOL_ID = 1;
uint256 constant MAYC_POOL_ID = 2;
uint256 constant BAKC_POOL_ID = 3;
Pool[4] public pools;
mapping(uint256 => ERC721Enumerable) public nftContracts;
mapping(uint256 => mapping(uint256 => Position)) public nftPosition;
mapping(uint256 => mapping(uint256 => PairingStatus)) public mainToBakc;
mapping(uint256 => mapping(uint256 => PairingStatus)) public bakcToMain;
event UpdatePool(
uint256 indexed poolId,
uint256 lastRewardedBlock,
uint256 stakedAmount,
uint256 accumulatedRewardsPerShare
);
event Deposit(
address indexed user,
uint256 amount,
address recipient
);
event DepositNft(
address indexed user,
uint256 indexed poolId,
uint256 amount,
uint256 tokenId
);
event DepositPairNft(
address indexed user,
uint256 amount,
uint256 mainTypePoolId,
uint256 mainTokenId,
uint256 bakcTokenId
);
event Withdraw(
address indexed user,
uint256 amount,
address recipient
);
event WithdrawNft(
address indexed user,
uint256 indexed poolId,
uint256 amount,
address recipient,
uint256 tokenId
);
event WithdrawPairNft(
address indexed user,
uint256 amount,
uint256 mainTypePoolId,
uint256 mainTokenId,
uint256 bakcTokenId
);
event ClaimRewards(
address indexed user,
uint256 amount,
address recipient
);
event ClaimRewardsNft(
address indexed user,
uint256 indexed poolId,
uint256 amount,
uint256 tokenId
);
event ClaimRewardsPairNft(
address indexed user,
uint256 amount,
uint256 mainTypePoolId,
uint256 mainTokenId,
uint256 bakcTokenId
);
error DepositMoreThanOneAPE();
error InvalidPoolId();
error StartMustBeGreaterThanEnd();
error StartNotWholeHour();
error EndNotWholeHour();
error StartMustEqualLastEnd();
error CallerNotOwner();
error MainTokenNotOwnedOrPaired();
error BAKCNotOwnedOrPaired();
error BAKCAlreadyPaired();
error ExceededCapAmount();
error NotOwnerOfMain();
error NotOwnerOfBAKC();
error ProvidedTokensNotPaired();
error ExceededStakedAmount();
error NeitherTokenInPairOwnedByCaller();
error SplitPairCantPartiallyWithdraw();
error UncommitWrongParameters();
constructor(
address _apeCoinContractAddress,
address _baycContractAddress,
address _maycContractAddress,
address _bakcContractAddress
) {
apeCoin = IERC20(_apeCoinContractAddress);
nftContracts[BAYC_POOL_ID] = ERC721Enumerable(_baycContractAddress);
nftContracts[MAYC_POOL_ID] = ERC721Enumerable(_maycContractAddress);
nftContracts[BAKC_POOL_ID] = ERC721Enumerable(_bakcContractAddress);
}
function depositApeCoin(uint256 _amount, address _recipient) public {
if (_amount < MIN_DEPOSIT) revert DepositMoreThanOneAPE();
updatePool(APECOIN_POOL_ID);
Position storage position = addressPosition[_recipient];
_deposit(APECOIN_POOL_ID, position, _amount);
apeCoin.transferFrom(msg.sender, address(this), _amount);
emit Deposit(msg.sender, _amount, _recipient);
}
function depositSelfApeCoin(uint256 _amount) external {
depositApeCoin(_amount, msg.sender);
}
function depositBAYC(SingleNft[] calldata _nfts) external {
_depositNft(BAYC_POOL_ID, _nfts);
}
function depositMAYC(SingleNft[] calldata _nfts) external {
_depositNft(MAYC_POOL_ID, _nfts);
}
function depositBAKC(PairNftDepositWithAmount[] calldata _baycPairs, PairNftDepositWithAmount[] calldata _maycPairs) external {
updatePool(BAKC_POOL_ID);
_depositPairNft(BAYC_POOL_ID, _baycPairs);
_depositPairNft(MAYC_POOL_ID, _maycPairs);
}
function claimApeCoin(address _recipient) public {
updatePool(APECOIN_POOL_ID);
Position storage position = addressPosition[msg.sender];
uint256 rewardsToBeClaimed = _claim(APECOIN_POOL_ID, position, _recipient);
emit ClaimRewards(msg.sender, rewardsToBeClaimed, _recipient);
}
function claimSelfApeCoin() external {
claimApeCoin(msg.sender);
}
function claimBAYC(uint256[] calldata _nfts, address _recipient) external {
_claimNft(BAYC_POOL_ID, _nfts, _recipient);
}
function claimSelfBAYC(uint256[] calldata _nfts) external {
_claimNft(BAYC_POOL_ID, _nfts, msg.sender);
}
function claimMAYC(uint256[] calldata _nfts, address _recipient) external {
_claimNft(MAYC_POOL_ID, _nfts, _recipient);
}
function claimSelfMAYC(uint256[] calldata _nfts) external {
_claimNft(MAYC_POOL_ID, _nfts, msg.sender);
}
function claimBAKC(PairNft[] calldata _baycPairs, PairNft[] calldata _maycPairs, address _recipient) public {
updatePool(BAKC_POOL_ID);
_claimPairNft(BAYC_POOL_ID, _baycPairs, _recipient);
_claimPairNft(MAYC_POOL_ID, _maycPairs, _recipient);
}
function claimSelfBAKC(PairNft[] calldata _baycPairs, PairNft[] calldata _maycPairs) external {
claimBAKC(_baycPairs, _maycPairs, msg.sender);
}
function withdrawApeCoin(uint256 _amount, address _recipient) public {
updatePool(APECOIN_POOL_ID);
Position storage position = addressPosition[msg.sender];
if (_amount == position.stakedAmount) {
uint256 rewardsToBeClaimed = _claim(APECOIN_POOL_ID, position, _recipient);
emit ClaimRewards(msg.sender, rewardsToBeClaimed, _recipient);
}
_withdraw(APECOIN_POOL_ID, position, _amount);
apeCoin.transfer(_recipient, _amount);
emit Withdraw(msg.sender, _amount, _recipient);
}
function withdrawSelfApeCoin(uint256 _amount) external {
withdrawApeCoin(_amount, msg.sender);
}
function withdrawBAYC(SingleNft[] calldata _nfts, address _recipient) external {
_withdrawNft(BAYC_POOL_ID, _nfts, _recipient);
}
function withdrawSelfBAYC(SingleNft[] calldata _nfts) external {
_withdrawNft(BAYC_POOL_ID, _nfts, msg.sender);
}
function withdrawMAYC(SingleNft[] calldata _nfts, address _recipient) external {
_withdrawNft(MAYC_POOL_ID, _nfts, _recipient);
}
function withdrawSelfMAYC(SingleNft[] calldata _nfts) external {
_withdrawNft(MAYC_POOL_ID, _nfts, msg.sender);
}
function withdrawBAKC(PairNftWithdrawWithAmount[] calldata _baycPairs, PairNftWithdrawWithAmount[] calldata _maycPairs) external {
updatePool(BAKC_POOL_ID);
_withdrawPairNft(BAYC_POOL_ID, _baycPairs);
_withdrawPairNft(MAYC_POOL_ID, _maycPairs);
}
function addTimeRange(
uint256 _poolId,
uint256 _amount,
uint256 _startTimestamp,
uint256 _endTimeStamp,
uint256 _capPerPosition) external onlyOwner
{
if (_poolId > BAKC_POOL_ID) revert InvalidPoolId();
if (_startTimestamp >= _endTimeStamp) revert StartMustBeGreaterThanEnd();
if (getMinute(_startTimestamp) > 0 || getSecond(_startTimestamp) > 0) revert StartNotWholeHour();
if (getMinute(_endTimeStamp) > 0 || getSecond(_endTimeStamp) > 0) revert EndNotWholeHour();
Pool storage pool = pools[_poolId];
uint256 length = pool.timeRanges.length;
if (length > 0) {
if (_startTimestamp != pool.timeRanges[length - 1].endTimestampHour) revert StartMustEqualLastEnd();
}
uint256 hoursInSeconds = _endTimeStamp - _startTimestamp;
uint256 rewardsPerHour = _amount * SECONDS_PER_HOUR / hoursInSeconds;
TimeRange memory next = TimeRange(_startTimestamp.toUint48(), _endTimeStamp.toUint48(),
rewardsPerHour.toUint96(), _capPerPosition.toUint96());
pool.timeRanges.push(next);
}
function removeLastTimeRange(uint256 _poolId) external onlyOwner {
pools[_poolId].timeRanges.pop();
}
function getTimeRangeBy(uint256 _poolId, uint256 _index) public view returns (TimeRange memory) {
return pools[_poolId].timeRanges[_index];
}
function rewardsBy(uint256 _poolId, uint256 _from, uint256 _to) public view returns (uint256, uint256) {
Pool memory pool = pools[_poolId];
uint256 currentIndex = pool.lastRewardsRangeIndex;
if(_to < pool.timeRanges[0].startTimestampHour) return (0, currentIndex);
while(_from > pool.timeRanges[currentIndex].endTimestampHour && _to > pool.timeRanges[currentIndex].endTimestampHour) {
unchecked {
++currentIndex;
}
}
uint256 rewards;
TimeRange memory current;
uint256 startTimestampHour;
uint256 endTimestampHour;
uint256 length = pool.timeRanges.length;
for(uint256 i = currentIndex; i < length;) {
current = pool.timeRanges[i];
startTimestampHour = _from <= current.startTimestampHour ? current.startTimestampHour : _from;
endTimestampHour = _to <= current.endTimestampHour ? _to : current.endTimestampHour;
rewards = rewards + (endTimestampHour - startTimestampHour) * current.rewardsPerHour / SECONDS_PER_HOUR;
if(_to <= endTimestampHour) {
return (rewards, i);
}
unchecked {
++i;
}
}
return (rewards, length - 1);
}
function updatePool(uint256 _poolId) public {
Pool storage pool = pools[_poolId];
if (block.timestamp < pool.timeRanges[0].startTimestampHour) return;
if (block.timestamp <= pool.lastRewardedTimestampHour + SECONDS_PER_HOUR) return;
uint48 lastTimestampHour = pool.timeRanges[pool.timeRanges.length-1].endTimestampHour;
uint48 previousTimestampHour = getPreviousTimestampHour().toUint48();
if (pool.stakedAmount == 0) {
pool.lastRewardedTimestampHour = previousTimestampHour > lastTimestampHour ? lastTimestampHour : previousTimestampHour;
return;
}
(uint256 rewards, uint256 index) = rewardsBy(_poolId, pool.lastRewardedTimestampHour, previousTimestampHour);
if (pool.lastRewardsRangeIndex != index) {
pool.lastRewardsRangeIndex = index.toUint16();
}
pool.accumulatedRewardsPerShare = (pool.accumulatedRewardsPerShare + (rewards * APE_COIN_PRECISION) / pool.stakedAmount).toUint96();
pool.lastRewardedTimestampHour = previousTimestampHour > lastTimestampHour ? lastTimestampHour : previousTimestampHour;
emit UpdatePool(_poolId, pool.lastRewardedTimestampHour, pool.stakedAmount, pool.accumulatedRewardsPerShare);
}
function getCurrentTimeRangeIndex(Pool memory pool) private view returns (uint256) {
uint256 current = pool.lastRewardsRangeIndex;
if (block.timestamp < pool.timeRanges[current].startTimestampHour) return current;
for(current = pool.lastRewardsRangeIndex; current < pool.timeRanges.length; ++current) {
TimeRange memory currentTimeRange = pool.timeRanges[current];
if (currentTimeRange.startTimestampHour <= block.timestamp && block.timestamp <= currentTimeRange.endTimestampHour) return current;
}
revert("distribution ended");
}
function getPoolsUI() public view returns (PoolUI memory, PoolUI memory, PoolUI memory, PoolUI memory) {
Pool memory apeCoinPool = pools[0];
Pool memory baycPool = pools[1];
Pool memory maycPool = pools[2];
Pool memory bakcPool = pools[3];
uint256 current = getCurrentTimeRangeIndex(apeCoinPool);
return (PoolUI(0,apeCoinPool.stakedAmount, apeCoinPool.timeRanges[current]),
PoolUI(1,baycPool.stakedAmount, baycPool.timeRanges[current]),
PoolUI(2,maycPool.stakedAmount, maycPool.timeRanges[current]),
PoolUI(3,bakcPool.stakedAmount, bakcPool.timeRanges[current]));
}
function stakedTotal(address _address) external view returns (uint256) {
uint256 total = addressPosition[_address].stakedAmount;
total += _stakedTotal(BAYC_POOL_ID, _address);
total += _stakedTotal(MAYC_POOL_ID, _address);
total += _stakedTotalPair(_address);
return total;
}
function _stakedTotal(uint256 _poolId, address _addr) private view returns (uint256) {
uint256 total = 0;
uint256 nftCount = nftContracts[_poolId].balanceOf(_addr);
for(uint256 i = 0; i < nftCount; ++i) {
uint256 tokenId = nftContracts[_poolId].tokenOfOwnerByIndex(_addr, i);
total += nftPosition[_poolId][tokenId].stakedAmount;
}
return total;
}
function _stakedTotalPair(address _addr) private view returns (uint256) {
uint256 total = 0;
uint256 nftCount = nftContracts[BAYC_POOL_ID].balanceOf(_addr);
for(uint256 i = 0; i < nftCount; ++i) {
uint256 baycTokenId = nftContracts[BAYC_POOL_ID].tokenOfOwnerByIndex(_addr, i);
if (mainToBakc[BAYC_POOL_ID][baycTokenId].isPaired) {
uint256 bakcTokenId = mainToBakc[BAYC_POOL_ID][baycTokenId].tokenId;
total += nftPosition[BAKC_POOL_ID][bakcTokenId].stakedAmount;
}
}
nftCount = nftContracts[MAYC_POOL_ID].balanceOf(_addr);
for(uint256 i = 0; i < nftCount; ++i) {
uint256 maycTokenId = nftContracts[MAYC_POOL_ID].tokenOfOwnerByIndex(_addr, i);
if (mainToBakc[MAYC_POOL_ID][maycTokenId].isPaired) {
uint256 bakcTokenId = mainToBakc[MAYC_POOL_ID][maycTokenId].tokenId;
total += nftPosition[BAKC_POOL_ID][bakcTokenId].stakedAmount;
}
}
return total;
}
function getAllStakes(address _address) public view returns (DashboardStake[] memory) {
DashboardStake memory apeCoinStake = getApeCoinStake(_address);
DashboardStake[] memory baycStakes = getBaycStakes(_address);
DashboardStake[] memory maycStakes = getMaycStakes(_address);
DashboardStake[] memory bakcStakes = getBakcStakes(_address);
DashboardStake[] memory splitStakes = getSplitStakes(_address);
uint256 count = (baycStakes.length + maycStakes.length + bakcStakes.length + splitStakes.length + 1);
DashboardStake[] memory allStakes = new DashboardStake[](count);
uint256 offset = 0;
allStakes[offset] = apeCoinStake;
++offset;
for(uint256 i = 0; i < baycStakes.length; ++i) {
allStakes[offset] = baycStakes[i];
++offset;
}
for(uint256 i = 0; i < maycStakes.length; ++i) {
allStakes[offset] = maycStakes[i];
++offset;
}
for(uint256 i = 0; i < bakcStakes.length; ++i) {
allStakes[offset] = bakcStakes[i];
++offset;
}
for(uint256 i = 0; i < splitStakes.length; ++i) {
allStakes[offset] = splitStakes[i];
++offset;
}
return allStakes;
}
function getApeCoinStake(address _address) public view returns (DashboardStake memory) {
uint256 tokenId = 0;
uint256 deposited = addressPosition[_address].stakedAmount;
uint256 unclaimed = deposited > 0 ? this.pendingRewards(0, _address, tokenId) : 0;
uint256 rewards24Hrs = deposited > 0 ? _estimate24HourRewards(0, _address, 0) : 0;
return DashboardStake(APECOIN_POOL_ID, tokenId, deposited, unclaimed, rewards24Hrs, NULL_PAIR);
}
function getBaycStakes(address _address) public view returns (DashboardStake[] memory) {
return _getStakes(_address, BAYC_POOL_ID);
}
function getMaycStakes(address _address) public view returns (DashboardStake[] memory) {
return _getStakes(_address, MAYC_POOL_ID);
}
function getBakcStakes(address _address) public view returns (DashboardStake[] memory) {
return _getStakes(_address, BAKC_POOL_ID);
}
function getSplitStakes(address _address) public view returns (DashboardStake[] memory) {
uint256 baycSplits = _getSplitStakeCount(nftContracts[BAYC_POOL_ID].balanceOf(_address), _address, BAYC_POOL_ID);
uint256 maycSplits = _getSplitStakeCount(nftContracts[MAYC_POOL_ID].balanceOf(_address), _address, MAYC_POOL_ID);
uint256 totalSplits = baycSplits + maycSplits;
if(totalSplits == 0) {
return new DashboardStake[](0);
}
DashboardStake[] memory baycSplitStakes = _getSplitStakes(baycSplits, _address, BAYC_POOL_ID);
DashboardStake[] memory maycSplitStakes = _getSplitStakes(maycSplits, _address, MAYC_POOL_ID);
DashboardStake[] memory splitStakes = new DashboardStake[](totalSplits);
uint256 offset = 0;
for(uint256 i = 0; i < baycSplitStakes.length; ++i) {
splitStakes[offset] = baycSplitStakes[i];
++offset;
}
for(uint256 i = 0; i < maycSplitStakes.length; ++i) {
splitStakes[offset] = maycSplitStakes[i];
++offset;
}
return splitStakes;
}
function _getSplitStakes(uint256 splits, address _address, uint256 _mainPoolId) private view returns (DashboardStake[] memory) {
DashboardStake[] memory dashboardStakes = new DashboardStake[](splits);
uint256 counter;
for(uint256 i = 0; i < nftContracts[_mainPoolId].balanceOf(_address); ++i) {
uint256 mainTokenId = nftContracts[_mainPoolId].tokenOfOwnerByIndex(_address, i);
if(mainToBakc[_mainPoolId][mainTokenId].isPaired) {
uint256 bakcTokenId = mainToBakc[_mainPoolId][mainTokenId].tokenId;
address currentOwner = nftContracts[BAKC_POOL_ID].ownerOf(bakcTokenId);
if (currentOwner != _address) {
uint256 deposited = nftPosition[BAKC_POOL_ID][bakcTokenId].stakedAmount;
uint256 unclaimed = deposited > 0 ? this.pendingRewards(BAKC_POOL_ID, currentOwner, bakcTokenId) : 0;
uint256 rewards24Hrs = deposited > 0 ? _estimate24HourRewards(BAKC_POOL_ID, currentOwner, bakcTokenId): 0;
DashboardPair memory pair = NULL_PAIR;
if(bakcToMain[bakcTokenId][_mainPoolId].isPaired) {
pair = DashboardPair(bakcToMain[bakcTokenId][_mainPoolId].tokenId, _mainPoolId);
}
DashboardStake memory dashboardStake = DashboardStake(BAKC_POOL_ID, bakcTokenId, deposited, unclaimed, rewards24Hrs, pair);
dashboardStakes[counter] = dashboardStake;
++counter;
}
}
}
return dashboardStakes;
}
function _getSplitStakeCount(uint256 nftCount, address _address, uint256 _mainPoolId) private view returns (uint256) {
uint256 splitCount;
for(uint256 i = 0; i < nftCount; ++i) {
uint256 mainTokenId = nftContracts[_mainPoolId].tokenOfOwnerByIndex(_address, i);
if(mainToBakc[_mainPoolId][mainTokenId].isPaired) {
uint256 bakcTokenId = mainToBakc[_mainPoolId][mainTokenId].tokenId;
address currentOwner = nftContracts[BAKC_POOL_ID].ownerOf(bakcTokenId);
if (currentOwner != _address) {
++splitCount;
}
}
}
return splitCount;
}
function _getStakes(address _address, uint256 _poolId) private view returns (DashboardStake[] memory) {
uint256 nftCount = nftContracts[_poolId].balanceOf(_address);
DashboardStake[] memory dashboardStakes = nftCount > 0 ? new DashboardStake[](nftCount) : new DashboardStake[](0);
if(nftCount == 0) {
return dashboardStakes;
}
for(uint256 i = 0; i < nftCount; ++i) {
uint256 tokenId = nftContracts[_poolId].tokenOfOwnerByIndex(_address, i);
uint256 deposited = nftPosition[_poolId][tokenId].stakedAmount;
uint256 unclaimed = deposited > 0 ? this.pendingRewards(_poolId, _address, tokenId) : 0;
uint256 rewards24Hrs = deposited > 0 ? _estimate24HourRewards(_poolId, _address, tokenId): 0;
DashboardPair memory pair = NULL_PAIR;
if(_poolId == BAKC_POOL_ID) {
if(bakcToMain[tokenId][BAYC_POOL_ID].isPaired) {
pair = DashboardPair(bakcToMain[tokenId][BAYC_POOL_ID].tokenId, BAYC_POOL_ID);
} else if(bakcToMain[tokenId][MAYC_POOL_ID].isPaired) {
pair = DashboardPair(bakcToMain[tokenId][MAYC_POOL_ID].tokenId, MAYC_POOL_ID);
}
}
DashboardStake memory dashboardStake = DashboardStake(_poolId, tokenId, deposited, unclaimed, rewards24Hrs, pair);
dashboardStakes[i] = dashboardStake;
}
return dashboardStakes;
}
function _estimate24HourRewards(uint256 _poolId, address _address, uint256 _tokenId) private view returns (uint256) {
Pool memory pool = pools[_poolId];
Position memory position = _poolId == 0 ? addressPosition[_address]: nftPosition[_poolId][_tokenId];
TimeRange memory rewards = getTimeRangeBy(_poolId, pool.lastRewardsRangeIndex);
return (position.stakedAmount * uint256(rewards.rewardsPerHour) * 24) / uint256(pool.stakedAmount);
}
function pendingRewards(uint256 _poolId, address _address, uint256 _tokenId) external view returns (uint256) {
Pool memory pool = pools[_poolId];
Position memory position = _poolId == 0 ? addressPosition[_address]: nftPosition[_poolId][_tokenId];
(uint256 rewardsSinceLastCalculated,) = rewardsBy(_poolId, pool.lastRewardedTimestampHour, getPreviousTimestampHour());
uint256 accumulatedRewardsPerShare = pool.accumulatedRewardsPerShare;
if (block.timestamp > pool.lastRewardedTimestampHour + SECONDS_PER_HOUR && pool.stakedAmount != 0) {
accumulatedRewardsPerShare = accumulatedRewardsPerShare + rewardsSinceLastCalculated * APE_COIN_PRECISION / pool.stakedAmount;
}
return ((position.stakedAmount * accumulatedRewardsPerShare).toInt256() - position.rewardsDebt).toUint256() / APE_COIN_PRECISION;
}
function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {
uint256 secs = timestamp % SECONDS_PER_HOUR;
minute = secs / SECONDS_PER_MINUTE;
}
function getSecond(uint256 timestamp) internal pure returns (uint256 second) {
second = timestamp % SECONDS_PER_MINUTE;
}
function getPreviousTimestampHour() internal view returns (uint256) {
return block.timestamp - (getMinute(block.timestamp) * 60 + getSecond(block.timestamp));
}
function _deposit(uint256 _poolId, Position storage _position, uint256 _amount) private {
Pool storage pool = pools[_poolId];
_position.stakedAmount += _amount;
pool.stakedAmount += _amount.toUint96();
_position.rewardsDebt += (_amount * pool.accumulatedRewardsPerShare).toInt256();
}
function _depositNft(uint256 _poolId, SingleNft[] calldata _nfts) private {
updatePool(_poolId);
uint256 tokenId;
uint256 amount;
Position storage position;
uint256 length = _nfts.length;
uint256 totalDeposit;
for(uint256 i; i < length;) {
tokenId = _nfts[i].tokenId;
position = nftPosition[_poolId][tokenId];
if (position.stakedAmount == 0) {
if (nftContracts[_poolId].ownerOf(tokenId) != msg.sender) revert CallerNotOwner();
}
amount = _nfts[i].amount;
_depositNftGuard(_poolId, position, amount);
totalDeposit += amount;
emit DepositNft(msg.sender, _poolId, amount, tokenId);
unchecked {
++i;
}
}
if (totalDeposit > 0) apeCoin.transferFrom(msg.sender, address(this), totalDeposit);
}
function _depositPairNft(uint256 mainTypePoolId, PairNftDepositWithAmount[] calldata _nfts) private {
uint256 length = _nfts.length;
uint256 totalDeposit;
PairNftDepositWithAmount memory pair;
Position storage position;
for(uint256 i; i < length;) {
pair = _nfts[i];
position = nftPosition[BAKC_POOL_ID][pair.bakcTokenId];
if(position.stakedAmount == 0) {
if (nftContracts[mainTypePoolId].ownerOf(pair.mainTokenId) != msg.sender
|| mainToBakc[mainTypePoolId][pair.mainTokenId].isPaired) revert MainTokenNotOwnedOrPaired();
if (nftContracts[BAKC_POOL_ID].ownerOf(pair.bakcTokenId) != msg.sender
|| bakcToMain[pair.bakcTokenId][mainTypePoolId].isPaired) revert BAKCNotOwnedOrPaired();
mainToBakc[mainTypePoolId][pair.mainTokenId] = PairingStatus(pair.bakcTokenId, true);
bakcToMain[pair.bakcTokenId][mainTypePoolId] = PairingStatus(pair.mainTokenId, true);
} else if (pair.mainTokenId != bakcToMain[pair.bakcTokenId][mainTypePoolId].tokenId
|| pair.bakcTokenId != mainToBakc[mainTypePoolId][pair.mainTokenId].tokenId)
revert BAKCAlreadyPaired();
_depositNftGuard(BAKC_POOL_ID, position, pair.amount);
totalDeposit += pair.amount;
emit DepositPairNft(msg.sender, pair.amount, mainTypePoolId, pair.mainTokenId, pair.bakcTokenId);
unchecked {
++i;
}
}
if (totalDeposit > 0) apeCoin.transferFrom(msg.sender, address(this), totalDeposit);
}
function _depositNftGuard(uint256 _poolId, Position storage _position, uint256 _amount) private {
if (_amount < MIN_DEPOSIT) revert DepositMoreThanOneAPE();
if (_amount + _position.stakedAmount > pools[_poolId].timeRanges[pools[_poolId].lastRewardsRangeIndex].capPerPosition)
revert ExceededCapAmount();
_deposit(_poolId, _position, _amount);
}
function _claim(uint256 _poolId, Position storage _position, address _recipient) private returns (uint256 rewardsToBeClaimed) {
Pool storage pool = pools[_poolId];
int256 accumulatedApeCoins = (_position.stakedAmount * uint256(pool.accumulatedRewardsPerShare)).toInt256();
rewardsToBeClaimed = (accumulatedApeCoins - _position.rewardsDebt).toUint256() / APE_COIN_PRECISION;
_position.rewardsDebt = accumulatedApeCoins;
if (rewardsToBeClaimed != 0) {
apeCoin.transfer(_recipient, rewardsToBeClaimed);
}
}
function _claimNft(uint256 _poolId, uint256[] calldata _nfts, address _recipient) private {
updatePool(_poolId);
uint256 tokenId;
uint256 rewardsToBeClaimed;
uint256 length = _nfts.length;
for(uint256 i; i < length;) {
tokenId = _nfts[i];
if (nftContracts[_poolId].ownerOf(tokenId) != msg.sender) revert CallerNotOwner();
Position storage position = nftPosition[_poolId][tokenId];
rewardsToBeClaimed = _claim(_poolId, position, _recipient);
emit ClaimRewardsNft(msg.sender, _poolId, rewardsToBeClaimed, tokenId);
unchecked {
++i;
}
}
}
function _claimPairNft(uint256 mainTypePoolId, PairNft[] calldata _pairs, address _recipient) private {
uint256 length = _pairs.length;
uint256 mainTokenId;
uint256 bakcTokenId;
Position storage position;
PairingStatus storage mainToSecond;
PairingStatus storage secondToMain;
for(uint256 i; i < length;) {
mainTokenId = _pairs[i].mainTokenId;
if (nftContracts[mainTypePoolId].ownerOf(mainTokenId) != msg.sender) revert NotOwnerOfMain();
bakcTokenId = _pairs[i].bakcTokenId;
if (nftContracts[BAKC_POOL_ID].ownerOf(bakcTokenId) != msg.sender) revert NotOwnerOfBAKC();
mainToSecond = mainToBakc[mainTypePoolId][mainTokenId];
secondToMain = bakcToMain[bakcTokenId][mainTypePoolId];
if (mainToSecond.tokenId != bakcTokenId || !mainToSecond.isPaired
|| secondToMain.tokenId != mainTokenId || !secondToMain.isPaired) revert ProvidedTokensNotPaired();
position = nftPosition[BAKC_POOL_ID][bakcTokenId];
uint256 rewardsToBeClaimed = _claim(BAKC_POOL_ID, position, _recipient);
emit ClaimRewardsPairNft(msg.sender, rewardsToBeClaimed, mainTypePoolId, mainTokenId, bakcTokenId);
unchecked {
++i;
}
}
}
function _withdraw(uint256 _poolId, Position storage _position, uint256 _amount) private {
if (_amount > _position.stakedAmount) revert ExceededStakedAmount();
Pool storage pool = pools[_poolId];
_position.stakedAmount -= _amount;
pool.stakedAmount -= _amount.toUint96();
_position.rewardsDebt -= (_amount * pool.accumulatedRewardsPerShare).toInt256();
}
function _withdrawNft(uint256 _poolId, SingleNft[] calldata _nfts, address _recipient) private {
updatePool(_poolId);
uint256 tokenId;
uint256 amount;
uint256 length = _nfts.length;
uint256 totalWithdraw;
Position storage position;
for(uint256 i; i < length;) {
tokenId = _nfts[i].tokenId;
if (nftContracts[_poolId].ownerOf(tokenId) != msg.sender) revert CallerNotOwner();
amount = _nfts[i].amount;
position = nftPosition[_poolId][tokenId];
if (amount == position.stakedAmount) {
uint256 rewardsToBeClaimed = _claim(_poolId, position, _recipient);
emit ClaimRewardsNft(msg.sender, _poolId, rewardsToBeClaimed, tokenId);
}
_withdraw(_poolId, position, amount);
totalWithdraw += amount;
emit WithdrawNft(msg.sender, _poolId, amount, _recipient, tokenId);
unchecked {
++i;
}
}
if (totalWithdraw > 0) apeCoin.transfer(_recipient, totalWithdraw);
}
function _withdrawPairNft(uint256 mainTypePoolId, PairNftWithdrawWithAmount[] calldata _nfts) private {
address mainTokenOwner;
address bakcOwner;
PairNftWithdrawWithAmount memory pair;
PairingStatus storage mainToSecond;
PairingStatus storage secondToMain;
Position storage position;
uint256 length = _nfts.length;
for(uint256 i; i < length;) {
pair = _nfts[i];
mainTokenOwner = nftContracts[mainTypePoolId].ownerOf(pair.mainTokenId);
bakcOwner = nftContracts[BAKC_POOL_ID].ownerOf(pair.bakcTokenId);
if (mainTokenOwner != msg.sender) {
if (bakcOwner != msg.sender) revert NeitherTokenInPairOwnedByCaller();
}
mainToSecond = mainToBakc[mainTypePoolId][pair.mainTokenId];
secondToMain = bakcToMain[pair.bakcTokenId][mainTypePoolId];
if (mainToSecond.tokenId != pair.bakcTokenId || !mainToSecond.isPaired
|| secondToMain.tokenId != pair.mainTokenId || !secondToMain.isPaired) revert ProvidedTokensNotPaired();
position = nftPosition[BAKC_POOL_ID][pair.bakcTokenId];
if(!pair.isUncommit) {
if(pair.amount == position.stakedAmount) revert UncommitWrongParameters();
}
if (mainTokenOwner != bakcOwner) {
if (!pair.isUncommit) revert SplitPairCantPartiallyWithdraw();
}
if (pair.isUncommit) {
uint256 rewardsToBeClaimed = _claim(BAKC_POOL_ID, position, bakcOwner);
mainToBakc[mainTypePoolId][pair.mainTokenId] = PairingStatus(0, false);
bakcToMain[pair.bakcTokenId][mainTypePoolId] = PairingStatus(0, false);
emit ClaimRewardsPairNft(msg.sender, rewardsToBeClaimed, mainTypePoolId, pair.mainTokenId, pair.bakcTokenId);
}
uint256 finalAmountToWithdraw = pair.isUncommit ? position.stakedAmount: pair.amount;
_withdraw(BAKC_POOL_ID, position, finalAmountToWithdraw);
apeCoin.transfer(mainTokenOwner, finalAmountToWithdraw);
emit WithdrawPairNft(msg.sender, finalAmountToWithdraw, mainTypePoolId, pair.mainTokenId, pair.bakcTokenId);
unchecked {
++i;
}
}
}
}
文件 3 的 15:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 4 的 15:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 5 的 15:ERC721.sol
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 => address) private _owners;
mapping(address => uint256) private _balances;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_safeTransfer(from, to, tokenId, data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
文件 6 的 15:ERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
mapping(uint256 => uint256) private _ownedTokensIndex;
uint256[] private _allTokens;
mapping(uint256 => uint256) private _allTokensIndex;
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId;
_ownedTokensIndex[lastTokenId] = tokenIndex;
}
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId;
_allTokensIndex[lastTokenId] = tokenIndex;
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
文件 7 的 15:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 8 的 15:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 9 的 15:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool _approved) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
文件 10 的 15:IERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Enumerable is IERC721 {
function totalSupply() external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 11 的 15:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 12 的 15:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 13 的 15:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 14 的 15:SafeCast.sol
pragma solidity ^0.8.0;
library SafeCast {
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
function toInt248(int256 value) internal pure returns (int248) {
require(value >= type(int248).min && value <= type(int248).max, "SafeCast: value doesn't fit in 248 bits");
return int248(value);
}
function toInt240(int256 value) internal pure returns (int240) {
require(value >= type(int240).min && value <= type(int240).max, "SafeCast: value doesn't fit in 240 bits");
return int240(value);
}
function toInt232(int256 value) internal pure returns (int232) {
require(value >= type(int232).min && value <= type(int232).max, "SafeCast: value doesn't fit in 232 bits");
return int232(value);
}
function toInt224(int256 value) internal pure returns (int224) {
require(value >= type(int224).min && value <= type(int224).max, "SafeCast: value doesn't fit in 224 bits");
return int224(value);
}
function toInt216(int256 value) internal pure returns (int216) {
require(value >= type(int216).min && value <= type(int216).max, "SafeCast: value doesn't fit in 216 bits");
return int216(value);
}
function toInt208(int256 value) internal pure returns (int208) {
require(value >= type(int208).min && value <= type(int208).max, "SafeCast: value doesn't fit in 208 bits");
return int208(value);
}
function toInt200(int256 value) internal pure returns (int200) {
require(value >= type(int200).min && value <= type(int200).max, "SafeCast: value doesn't fit in 200 bits");
return int200(value);
}
function toInt192(int256 value) internal pure returns (int192) {
require(value >= type(int192).min && value <= type(int192).max, "SafeCast: value doesn't fit in 192 bits");
return int192(value);
}
function toInt184(int256 value) internal pure returns (int184) {
require(value >= type(int184).min && value <= type(int184).max, "SafeCast: value doesn't fit in 184 bits");
return int184(value);
}
function toInt176(int256 value) internal pure returns (int176) {
require(value >= type(int176).min && value <= type(int176).max, "SafeCast: value doesn't fit in 176 bits");
return int176(value);
}
function toInt168(int256 value) internal pure returns (int168) {
require(value >= type(int168).min && value <= type(int168).max, "SafeCast: value doesn't fit in 168 bits");
return int168(value);
}
function toInt160(int256 value) internal pure returns (int160) {
require(value >= type(int160).min && value <= type(int160).max, "SafeCast: value doesn't fit in 160 bits");
return int160(value);
}
function toInt152(int256 value) internal pure returns (int152) {
require(value >= type(int152).min && value <= type(int152).max, "SafeCast: value doesn't fit in 152 bits");
return int152(value);
}
function toInt144(int256 value) internal pure returns (int144) {
require(value >= type(int144).min && value <= type(int144).max, "SafeCast: value doesn't fit in 144 bits");
return int144(value);
}
function toInt136(int256 value) internal pure returns (int136) {
require(value >= type(int136).min && value <= type(int136).max, "SafeCast: value doesn't fit in 136 bits");
return int136(value);
}
function toInt128(int256 value) internal pure returns (int128) {
require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
return int128(value);
}
function toInt120(int256 value) internal pure returns (int120) {
require(value >= type(int120).min && value <= type(int120).max, "SafeCast: value doesn't fit in 120 bits");
return int120(value);
}
function toInt112(int256 value) internal pure returns (int112) {
require(value >= type(int112).min && value <= type(int112).max, "SafeCast: value doesn't fit in 112 bits");
return int112(value);
}
function toInt104(int256 value) internal pure returns (int104) {
require(value >= type(int104).min && value <= type(int104).max, "SafeCast: value doesn't fit in 104 bits");
return int104(value);
}
function toInt96(int256 value) internal pure returns (int96) {
require(value >= type(int96).min && value <= type(int96).max, "SafeCast: value doesn't fit in 96 bits");
return int96(value);
}
function toInt88(int256 value) internal pure returns (int88) {
require(value >= type(int88).min && value <= type(int88).max, "SafeCast: value doesn't fit in 88 bits");
return int88(value);
}
function toInt80(int256 value) internal pure returns (int80) {
require(value >= type(int80).min && value <= type(int80).max, "SafeCast: value doesn't fit in 80 bits");
return int80(value);
}
function toInt72(int256 value) internal pure returns (int72) {
require(value >= type(int72).min && value <= type(int72).max, "SafeCast: value doesn't fit in 72 bits");
return int72(value);
}
function toInt64(int256 value) internal pure returns (int64) {
require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
return int64(value);
}
function toInt56(int256 value) internal pure returns (int56) {
require(value >= type(int56).min && value <= type(int56).max, "SafeCast: value doesn't fit in 56 bits");
return int56(value);
}
function toInt48(int256 value) internal pure returns (int48) {
require(value >= type(int48).min && value <= type(int48).max, "SafeCast: value doesn't fit in 48 bits");
return int48(value);
}
function toInt40(int256 value) internal pure returns (int40) {
require(value >= type(int40).min && value <= type(int40).max, "SafeCast: value doesn't fit in 40 bits");
return int40(value);
}
function toInt32(int256 value) internal pure returns (int32) {
require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
return int32(value);
}
function toInt24(int256 value) internal pure returns (int24) {
require(value >= type(int24).min && value <= type(int24).max, "SafeCast: value doesn't fit in 24 bits");
return int24(value);
}
function toInt16(int256 value) internal pure returns (int16) {
require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
return int16(value);
}
function toInt8(int256 value) internal pure returns (int8) {
require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
return int8(value);
}
function toInt256(uint256 value) internal pure returns (int256) {
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
文件 15 的 15:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
{
"compilationTarget": {
"contracts/ApeCoinStaking.sol": "ApeCoinStaking"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_apeCoinContractAddress","type":"address"},{"internalType":"address","name":"_baycContractAddress","type":"address"},{"internalType":"address","name":"_maycContractAddress","type":"address"},{"internalType":"address","name":"_bakcContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BAKCAlreadyPaired","type":"error"},{"inputs":[],"name":"BAKCNotOwnedOrPaired","type":"error"},{"inputs":[],"name":"CallerNotOwner","type":"error"},{"inputs":[],"name":"DepositMoreThanOneAPE","type":"error"},{"inputs":[],"name":"EndNotWholeHour","type":"error"},{"inputs":[],"name":"ExceededCapAmount","type":"error"},{"inputs":[],"name":"ExceededStakedAmount","type":"error"},{"inputs":[],"name":"InvalidPoolId","type":"error"},{"inputs":[],"name":"MainTokenNotOwnedOrPaired","type":"error"},{"inputs":[],"name":"NeitherTokenInPairOwnedByCaller","type":"error"},{"inputs":[],"name":"NotOwnerOfBAKC","type":"error"},{"inputs":[],"name":"NotOwnerOfMain","type":"error"},{"inputs":[],"name":"ProvidedTokensNotPaired","type":"error"},{"inputs":[],"name":"SplitPairCantPartiallyWithdraw","type":"error"},{"inputs":[],"name":"StartMustBeGreaterThanEnd","type":"error"},{"inputs":[],"name":"StartMustEqualLastEnd","type":"error"},{"inputs":[],"name":"StartNotWholeHour","type":"error"},{"inputs":[],"name":"UncommitWrongParameters","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"ClaimRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ClaimRewardsNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mainTypePoolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bakcTokenId","type":"uint256"}],"name":"ClaimRewardsPairNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"DepositNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mainTypePoolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bakcTokenId","type":"uint256"}],"name":"DepositPairNft","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":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastRewardedBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accumulatedRewardsPerShare","type":"uint256"}],"name":"UpdatePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"WithdrawNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mainTypePoolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bakcTokenId","type":"uint256"}],"name":"WithdrawPairNft","type":"event"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"},{"internalType":"uint256","name":"_endTimeStamp","type":"uint256"},{"internalType":"uint256","name":"_capPerPosition","type":"uint256"}],"name":"addTimeRange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressPosition","outputs":[{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"internalType":"int256","name":"rewardsDebt","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"apeCoin","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"bakcToMain","outputs":[{"internalType":"uint248","name":"tokenId","type":"uint248"},{"internalType":"bool","name":"isPaired","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"claimApeCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint128","name":"mainTokenId","type":"uint128"},{"internalType":"uint128","name":"bakcTokenId","type":"uint128"}],"internalType":"struct ApeCoinStaking.PairNft[]","name":"_baycPairs","type":"tuple[]"},{"components":[{"internalType":"uint128","name":"mainTokenId","type":"uint128"},{"internalType":"uint128","name":"bakcTokenId","type":"uint128"}],"internalType":"struct ApeCoinStaking.PairNft[]","name":"_maycPairs","type":"tuple[]"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"claimBAKC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nfts","type":"uint256[]"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"claimBAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nfts","type":"uint256[]"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"claimMAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimSelfApeCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint128","name":"mainTokenId","type":"uint128"},{"internalType":"uint128","name":"bakcTokenId","type":"uint128"}],"internalType":"struct ApeCoinStaking.PairNft[]","name":"_baycPairs","type":"tuple[]"},{"components":[{"internalType":"uint128","name":"mainTokenId","type":"uint128"},{"internalType":"uint128","name":"bakcTokenId","type":"uint128"}],"internalType":"struct ApeCoinStaking.PairNft[]","name":"_maycPairs","type":"tuple[]"}],"name":"claimSelfBAKC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nfts","type":"uint256[]"}],"name":"claimSelfBAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nfts","type":"uint256[]"}],"name":"claimSelfMAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"depositApeCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"mainTokenId","type":"uint32"},{"internalType":"uint32","name":"bakcTokenId","type":"uint32"},{"internalType":"uint184","name":"amount","type":"uint184"}],"internalType":"struct ApeCoinStaking.PairNftDepositWithAmount[]","name":"_baycPairs","type":"tuple[]"},{"components":[{"internalType":"uint32","name":"mainTokenId","type":"uint32"},{"internalType":"uint32","name":"bakcTokenId","type":"uint32"},{"internalType":"uint184","name":"amount","type":"uint184"}],"internalType":"struct ApeCoinStaking.PairNftDepositWithAmount[]","name":"_maycPairs","type":"tuple[]"}],"name":"depositBAKC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"tokenId","type":"uint32"},{"internalType":"uint224","name":"amount","type":"uint224"}],"internalType":"struct ApeCoinStaking.SingleNft[]","name":"_nfts","type":"tuple[]"}],"name":"depositBAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"tokenId","type":"uint32"},{"internalType":"uint224","name":"amount","type":"uint224"}],"internalType":"struct ApeCoinStaking.SingleNft[]","name":"_nfts","type":"tuple[]"}],"name":"depositMAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositSelfApeCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getAllStakes","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"unclaimed","type":"uint256"},{"internalType":"uint256","name":"rewards24hr","type":"uint256"},{"components":[{"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"internalType":"uint256","name":"mainTypePoolId","type":"uint256"}],"internalType":"struct ApeCoinStaking.DashboardPair","name":"pair","type":"tuple"}],"internalType":"struct ApeCoinStaking.DashboardStake[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getApeCoinStake","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"unclaimed","type":"uint256"},{"internalType":"uint256","name":"rewards24hr","type":"uint256"},{"components":[{"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"internalType":"uint256","name":"mainTypePoolId","type":"uint256"}],"internalType":"struct ApeCoinStaking.DashboardPair","name":"pair","type":"tuple"}],"internalType":"struct ApeCoinStaking.DashboardStake","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getBakcStakes","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"unclaimed","type":"uint256"},{"internalType":"uint256","name":"rewards24hr","type":"uint256"},{"components":[{"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"internalType":"uint256","name":"mainTypePoolId","type":"uint256"}],"internalType":"struct ApeCoinStaking.DashboardPair","name":"pair","type":"tuple"}],"internalType":"struct ApeCoinStaking.DashboardStake[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getBaycStakes","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"unclaimed","type":"uint256"},{"internalType":"uint256","name":"rewards24hr","type":"uint256"},{"components":[{"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"internalType":"uint256","name":"mainTypePoolId","type":"uint256"}],"internalType":"struct ApeCoinStaking.DashboardPair","name":"pair","type":"tuple"}],"internalType":"struct ApeCoinStaking.DashboardStake[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getMaycStakes","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"unclaimed","type":"uint256"},{"internalType":"uint256","name":"rewards24hr","type":"uint256"},{"components":[{"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"internalType":"uint256","name":"mainTypePoolId","type":"uint256"}],"internalType":"struct ApeCoinStaking.DashboardPair","name":"pair","type":"tuple"}],"internalType":"struct ApeCoinStaking.DashboardStake[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPoolsUI","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"components":[{"internalType":"uint48","name":"startTimestampHour","type":"uint48"},{"internalType":"uint48","name":"endTimestampHour","type":"uint48"},{"internalType":"uint96","name":"rewardsPerHour","type":"uint96"},{"internalType":"uint96","name":"capPerPosition","type":"uint96"}],"internalType":"struct ApeCoinStaking.TimeRange","name":"currentTimeRange","type":"tuple"}],"internalType":"struct ApeCoinStaking.PoolUI","name":"","type":"tuple"},{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"components":[{"internalType":"uint48","name":"startTimestampHour","type":"uint48"},{"internalType":"uint48","name":"endTimestampHour","type":"uint48"},{"internalType":"uint96","name":"rewardsPerHour","type":"uint96"},{"internalType":"uint96","name":"capPerPosition","type":"uint96"}],"internalType":"struct ApeCoinStaking.TimeRange","name":"currentTimeRange","type":"tuple"}],"internalType":"struct ApeCoinStaking.PoolUI","name":"","type":"tuple"},{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"components":[{"internalType":"uint48","name":"startTimestampHour","type":"uint48"},{"internalType":"uint48","name":"endTimestampHour","type":"uint48"},{"internalType":"uint96","name":"rewardsPerHour","type":"uint96"},{"internalType":"uint96","name":"capPerPosition","type":"uint96"}],"internalType":"struct ApeCoinStaking.TimeRange","name":"currentTimeRange","type":"tuple"}],"internalType":"struct ApeCoinStaking.PoolUI","name":"","type":"tuple"},{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"components":[{"internalType":"uint48","name":"startTimestampHour","type":"uint48"},{"internalType":"uint48","name":"endTimestampHour","type":"uint48"},{"internalType":"uint96","name":"rewardsPerHour","type":"uint96"},{"internalType":"uint96","name":"capPerPosition","type":"uint96"}],"internalType":"struct ApeCoinStaking.TimeRange","name":"currentTimeRange","type":"tuple"}],"internalType":"struct ApeCoinStaking.PoolUI","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getSplitStakes","outputs":[{"components":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"unclaimed","type":"uint256"},{"internalType":"uint256","name":"rewards24hr","type":"uint256"},{"components":[{"internalType":"uint256","name":"mainTokenId","type":"uint256"},{"internalType":"uint256","name":"mainTypePoolId","type":"uint256"}],"internalType":"struct ApeCoinStaking.DashboardPair","name":"pair","type":"tuple"}],"internalType":"struct ApeCoinStaking.DashboardStake[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getTimeRangeBy","outputs":[{"components":[{"internalType":"uint48","name":"startTimestampHour","type":"uint48"},{"internalType":"uint48","name":"endTimestampHour","type":"uint48"},{"internalType":"uint96","name":"rewardsPerHour","type":"uint96"},{"internalType":"uint96","name":"capPerPosition","type":"uint96"}],"internalType":"struct ApeCoinStaking.TimeRange","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"mainToBakc","outputs":[{"internalType":"uint248","name":"tokenId","type":"uint248"},{"internalType":"bool","name":"isPaired","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftContracts","outputs":[{"internalType":"contract ERC721Enumerable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftPosition","outputs":[{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"internalType":"int256","name":"rewardsDebt","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pools","outputs":[{"internalType":"uint48","name":"lastRewardedTimestampHour","type":"uint48"},{"internalType":"uint16","name":"lastRewardsRangeIndex","type":"uint16"},{"internalType":"uint96","name":"stakedAmount","type":"uint96"},{"internalType":"uint96","name":"accumulatedRewardsPerShare","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"removeLastTimeRange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"uint256","name":"_from","type":"uint256"},{"internalType":"uint256","name":"_to","type":"uint256"}],"name":"rewardsBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"stakedTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"withdrawApeCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"mainTokenId","type":"uint32"},{"internalType":"uint32","name":"bakcTokenId","type":"uint32"},{"internalType":"uint184","name":"amount","type":"uint184"},{"internalType":"bool","name":"isUncommit","type":"bool"}],"internalType":"struct ApeCoinStaking.PairNftWithdrawWithAmount[]","name":"_baycPairs","type":"tuple[]"},{"components":[{"internalType":"uint32","name":"mainTokenId","type":"uint32"},{"internalType":"uint32","name":"bakcTokenId","type":"uint32"},{"internalType":"uint184","name":"amount","type":"uint184"},{"internalType":"bool","name":"isUncommit","type":"bool"}],"internalType":"struct ApeCoinStaking.PairNftWithdrawWithAmount[]","name":"_maycPairs","type":"tuple[]"}],"name":"withdrawBAKC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"tokenId","type":"uint32"},{"internalType":"uint224","name":"amount","type":"uint224"}],"internalType":"struct ApeCoinStaking.SingleNft[]","name":"_nfts","type":"tuple[]"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"withdrawBAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"tokenId","type":"uint32"},{"internalType":"uint224","name":"amount","type":"uint224"}],"internalType":"struct ApeCoinStaking.SingleNft[]","name":"_nfts","type":"tuple[]"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"withdrawMAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawSelfApeCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"tokenId","type":"uint32"},{"internalType":"uint224","name":"amount","type":"uint224"}],"internalType":"struct ApeCoinStaking.SingleNft[]","name":"_nfts","type":"tuple[]"}],"name":"withdrawSelfBAYC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"tokenId","type":"uint32"},{"internalType":"uint224","name":"amount","type":"uint224"}],"internalType":"struct ApeCoinStaking.SingleNft[]","name":"_nfts","type":"tuple[]"}],"name":"withdrawSelfMAYC","outputs":[],"stateMutability":"nonpayable","type":"function"}]