Transaction Hash:
Block:
13652792 at Nov-20-2021 03:49:32 PM +UTC
Transaction Fee:
0.254408164412605 ETH
$1,095.39
Gas Used:
2,287,880 Gas / 111.198211625 Gwei
Emitted Events:
38 |
UniswapV2Factory.PairCreated( token0=WOOL, token1=WETH9, pair=UniswapV2Pair, 2263 )
|
39 |
WOOL.Transfer( from=[Sender] 0xeea357ce1a449c6e67c86d4d3cd3691b41d68f35, to=UniswapV2Pair, value=21200000000000000000000 )
|
40 |
WOOL.Approval( owner=[Sender] 0xeea357ce1a449c6e67c86d4d3cd3691b41d68f35, spender=[Receiver] UniswapV2Router02, value=115792089237316195423570985008687907853269984665640564018257584007913129639935 )
|
41 |
WETH9.Deposit( dst=[Receiver] UniswapV2Router02, wad=800000000000000000 )
|
42 |
WETH9.Transfer( src=[Receiver] UniswapV2Router02, dst=UniswapV2Pair, wad=800000000000000000 )
|
43 |
UniswapV2Pair.Transfer( from=0x0000000000000000000000000000000000000000, to=0x0000000000000000000000000000000000000000, value=1000 )
|
44 |
UniswapV2Pair.Transfer( from=0x0000000000000000000000000000000000000000, to=[Sender] 0xeea357ce1a449c6e67c86d4d3cd3691b41d68f35, value=130230564768797650098 )
|
45 |
UniswapV2Pair.Sync( reserve0=21200000000000000000000, reserve1=800000000000000000 )
|
46 |
UniswapV2Pair.Mint( sender=[Receiver] UniswapV2Router02, amount0=21200000000000000000000, amount1=800000000000000000 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x63d364FD...956E0A324 |
0 Eth
Nonce: 0
|
0 Eth
Nonce: 1
| |||
0x8355DBE8...FC855e525 | |||||
0xC02aaA39...83C756Cc2 | 7,487,504.684273889549823781 Eth | 7,487,505.484273889549823781 Eth | 0.8 | ||
0xC0AEe478...cE9e4f2Ac | (SushiSwap: SushiV2Factory) | ||||
0xEA674fdD...16B898ec8
Miner
| (Ethermine) | 1,563.239479483478118413 Eth | 1,563.244055243478118413 Eth | 0.00457576 | |
0xEea357CE...b41d68F35 |
1.209985638645130783 Eth
Nonce: 141
|
0.155577474232525783 Eth
Nonce: 142
| 1.054408164412605 |
Execution Trace
ETH 0.8
UniswapV2Router02.addLiquidityETH( token=0x8355DBE8B0e275ABAd27eB843F3eaF3FC855e525, amountTokenDesired=21200000000000000000000, amountTokenMin=21200000000000000000000, amountETHMin=800000000000000000, to=0xEea357CE1a449C6E67c86d4d3cD3691b41d68F35, deadline=1637425011 ) => ( amountToken=21200000000000000000000, amountETH=800000000000000000, liquidity=130230564768797650098 )
-
UniswapV2Factory.getPair( 0x8355DBE8B0e275ABAd27eB843F3eaF3FC855e525, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 ) => ( 0x0000000000000000000000000000000000000000 )
UniswapV2Factory.createPair( tokenA=0x8355DBE8B0e275ABAd27eB843F3eaF3FC855e525, tokenB=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 ) => ( pair=0x63d364FDaBe9D768b979249F0969f20956E0A324 )
-
UniswapV2Pair.60806040( )
-
UniswapV2Pair.initialize( _token0=0x8355DBE8B0e275ABAd27eB843F3eaF3FC855e525, _token1=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 )
-
-
UniswapV2Pair.STATICCALL( )
-
WOOL.transferFrom( sender=0xEea357CE1a449C6E67c86d4d3cD3691b41d68F35, recipient=0x63d364FDaBe9D768b979249F0969f20956E0A324, amount=21200000000000000000000 ) => ( True )
- ETH 0.8
WETH9.CALL( )
-
WETH9.transfer( dst=0x63d364FDaBe9D768b979249F0969f20956E0A324, wad=800000000000000000 ) => ( True )
UniswapV2Pair.mint( to=0xEea357CE1a449C6E67c86d4d3cD3691b41d68F35 ) => ( liquidity=130230564768797650098 )
-
WOOL.balanceOf( account=0x63d364FDaBe9D768b979249F0969f20956E0A324 ) => ( 21200000000000000000000 )
-
WETH9.balanceOf( 0x63d364FDaBe9D768b979249F0969f20956E0A324 ) => ( 800000000000000000 )
-
UniswapV2Factory.STATICCALL( )
-
UniswapV2Factory.STATICCALL( )
-
addLiquidityETH[UniswapV2Router02 (ln:463)]
_addLiquidity[UniswapV2Router02 (ln:471)]
getPair[UniswapV2Router02 (ln:428)]
createPair[UniswapV2Router02 (ln:429)]
getReserves[UniswapV2Router02 (ln:431)]
sortTokens[UniswapV2Library (ln:105)]
getReserves[UniswapV2Library (ln:106)]
pairFor[UniswapV2Library (ln:106)]
sortTokens[UniswapV2Library (ln:94)]
pairFor[UniswapV2Router02 (ln:479)]
sortTokens[UniswapV2Library (ln:94)]
safeTransferFrom[UniswapV2Router02 (ln:480)]
call[TransferHelper (ln:181)]
encodeWithSelector[TransferHelper (ln:181)]
decode[TransferHelper (ln:182)]
deposit[UniswapV2Router02 (ln:481)]
transfer[UniswapV2Router02 (ln:482)]
mint[UniswapV2Router02 (ln:483)]
safeTransferETH[UniswapV2Router02 (ln:485)]
File 1 of 5: UniswapV2Router02
File 2 of 5: UniswapV2Factory
File 3 of 5: UniswapV2Pair
File 4 of 5: WOOL
File 5 of 5: WETH9
12345678910111213141516// File: contracts/uniswapv2/interfaces/IUniswapV2Pair.solpragma solidity >=0.5.0;interface IUniswapV2Pair {event Approval(address indexed owner, address indexed spender, uint value);event Transfer(address indexed from, address indexed to, uint value);function name() external pure returns (string memory);function symbol() external pure returns (string memory);function decimals() external pure returns (uint8);function totalSupply() external view returns (uint);function balanceOf(address owner) external view returns (uint);function allowance(address owner, address spender) external view returns (uint);function approve(address spender, uint value) external returns (bool);
File 2 of 5: UniswapV2Factory
12345678910111213141516// File: contracts/uniswapv2/interfaces/IUniswapV2Factory.solpragma solidity >=0.5.0;interface IUniswapV2Factory {event PairCreated(address indexed token0, address indexed token1, address pair, uint);function feeTo() external view returns (address);function feeToSetter() external view returns (address);function migrator() external view returns (address);function getPair(address tokenA, address tokenB) external view returns (address pair);function allPairs(uint) external view returns (address pair);function allPairsLength() external view returns (uint);function createPair(address tokenA, address tokenB) external returns (address pair);
File 3 of 5: UniswapV2Pair
12345678910111213141516// File: contracts/uniswapv2/interfaces/IUniswapV2Factory.solpragma solidity >=0.5.0;interface IUniswapV2Factory {event PairCreated(address indexed token0, address indexed token1, address pair, uint);function feeTo() external view returns (address);function feeToSetter() external view returns (address);function migrator() external view returns (address);function getPair(address tokenA, address tokenB) external view returns (address pair);function allPairs(uint) external view returns (address pair);function allPairsLength() external view returns (uint);function createPair(address tokenA, address tokenB) external returns (address pair);
File 4 of 5: WOOL
1{"Address.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the addresstype\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It isunsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n* Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n* - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but wasdestroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies onextcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructorexecution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size \u003e 0;\n}\n\n /**\n * @dev Replacement for Solidity\u0027s `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas andreverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possiblymaking contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue}removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n* IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n* {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\nrequire(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidityfunction call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n*\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n* Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * -`target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n functionfunctionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-levelcall failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage`as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n addresstarget,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n returnfunctionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contractmust have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n*/\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns(bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallbackrevert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success,returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * butperforming a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data)internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n/**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n *_Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memoryerrorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n(bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n}\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n* _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\nreturn functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\nfunction functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns(bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memoryreturndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Toolto verifies that a low level call was successful, and revert if it wasn\u0027t, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\nstring memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else{\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiestway to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"},"Barn.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Receiver.sol\";\nimport \"./Pausable.sol\";\nimport \"./Woolf.sol\";\nimport \"./WOOL.sol\";\n\ncontract Barn is Ownable,IERC721Receiver, Pausable {\n \n // maximum alpha score for a Wolf\n uint8 public constant MAX_ALPHA = 8;\n\n // struct to store a stake\u0027stoken, owner, and earning values\n struct Stake {\n uint16 tokenId;\n uint80 value;\n address owner;\n }\n\n event TokenStaked(addressowner, uint256 tokenId, uint256 value);\n event SheepClaimed(uint256 tokenId, uint256 earned, bool unstaked);\n event WolfClaimed(uint256 tokenId, uint256 earned, bool unstaked);\n\n // reference to the Woolf NFT contract\n Woolf woolf;\n // reference to the $WOOL contract for minting$WOOL earnings\n WOOL wool;\n\n // maps tokenId to stake\n mapping(uint256 =\u003e Stake) public barn; \n // maps alpha to all Wolf stakes withthat alpha\n mapping(uint256 =\u003e Stake[]) public pack; \n // tracks location of each Wolf in Pack\n mapping(uint256 =\u003e uint256) publicpackIndices; \n // total alpha scores staked\n uint256 public totalAlphaStaked = 0; \n // any rewards distributed when no wolves are staked\nuint256 public unaccountedRewards = 0; \n // amount of $WOOL due for each alpha point staked\n uint256 public woolPerAlpha = 0; \n\n // sheepearn 10000 $WOOL per day\n uint256 public constant DAILY_WOOL_RATE = 10000 ether;\n // sheep must have 2 days worth of $WOOL to unstake or elseit\u0027s too cold\n uint256 public constant MINIMUM_TO_EXIT = 2 days;\n // wolves take a 20% tax on all $WOOL claimed\n uint256 public constantWOOL_CLAIM_TAX_PERCENTAGE = 20;\n // there will only ever be (roughly) 2.4 billion $WOOL earned through staking\n uint256 public constantMAXIMUM_GLOBAL_WOOL = 2400000000 ether;\n\n // amount of $WOOL earned so far\n uint256 public totalWoolEarned;\n // number of Sheep staked inthe Barn\n uint256 public totalSheepStaked;\n // the last time $WOOL was claimed\n uint256 public lastClaimTimestamp;\n\n // emergency rescueto allow unstaking without any checks but without $WOOL\n bool public rescueEnabled = false;\n\n /**\n * @param _woolf reference to the WoolfNFT contract\n * @param _wool reference to the $WOOL token\n */\n constructor(address _woolf, address _wool) { \n woolf = Woolf(_woolf);\nwool = WOOL(_wool);\n }\n\n /** STAKING */\n\n /**\n * adds Sheep and Wolves to the Barn and Pack\n * @param account the address of thestaker\n * @param tokenIds the IDs of the Sheep and Wolves to stake\n */\n function addManyToBarnAndPack(address account, uint16[] calldatatokenIds) external {\n require(account == _msgSender() || _msgSender() == address(woolf), \"DONT GIVE YOUR TOKENS AWAY\");\n for (uint i = 0;i \u003c tokenIds.length; i++) {\n if (_msgSender() != address(woolf)) { // dont do this step if its a mint + stake\n require(woolf.ownerOf(tokenIds[i]) == _msgSender(), \"AINT YO TOKEN\");\n woolf.transferFrom(_msgSender(), address(this), tokenIds[i]);\n } else if(tokenIds[i] == 0) {\n continue; // there may be gaps in the array for stolen tokens\n }\n\n if (isSheep(tokenIds[i])) \n_addSheepToBarn(account, tokenIds[i]);\n else \n _addWolfToPack(account, tokenIds[i]);\n }\n }\n\n /**\n * adds a single Sheepto the Barn\n * @param account the address of the staker\n * @param tokenId the ID of the Sheep to add to the Barn\n */\n function_addSheepToBarn(address account, uint256 tokenId) internal whenNotPaused _updateEarnings {\n barn[tokenId] = Stake({\n owner: account,\ntokenId: uint16(tokenId),\n value: uint80(block.timestamp)\n });\n totalSheepStaked += 1;\n emit TokenStaked(account, tokenId,block.timestamp);\n }\n\n /**\n * adds a single Wolf to the Pack\n * @param account the address of the staker\n * @param tokenId the ID ofthe Wolf to add to the Pack\n */\n function _addWolfToPack(address account, uint256 tokenId) internal {\n uint256 alpha = _alphaForWolf(tokenId);\n totalAlphaStaked += alpha; // Portion of earnings ranges from 8 to 5\n packIndices[tokenId] = pack[alpha].length; // Store thelocation of the wolf in the Pack\n pack[alpha].push(Stake({\n owner: account,\n tokenId: uint16(tokenId),\n value: uint80(woolPerAlpha)\n })); // Add the wolf to the Pack\n emit TokenStaked(account, tokenId, woolPerAlpha);\n }\n\n /** CLAIMING / UNSTAKING*/\n\n /**\n * realize $WOOL earnings and optionally unstake tokens from the Barn / Pack\n * to unstake a Sheep it will require it has 2 daysworth of $WOOL unclaimed\n * @param tokenIds the IDs of the tokens to claim earnings from\n * @param unstake whether or not to unstake ALL ofthe tokens listed in tokenIds\n */\n function claimManyFromBarnAndPack(uint16[] calldata tokenIds, bool unstake) external whenNotPaused_updateEarnings {\n uint256 owed = 0;\n for (uint i = 0; i \u003c tokenIds.length; i++) {\n if (isSheep(tokenIds[i]))\n owed +=_claimSheepFromBarn(tokenIds[i], unstake);\n else\n owed += _claimWolfFromPack(tokenIds[i], unstake);\n }\n if (owed == 0) return;\n wool.mint(_msgSender(), owed);\n }\n\n /**\n * realize $WOOL earnings for a single Sheep and optionally unstake it\n * if notunstaking, pay a 20% tax to the staked Wolves\n * if unstaking, there is a 50% chance all $WOOL is stolen\n * @param tokenId the ID of theSheep to claim earnings from\n * @param unstake whether or not to unstake the Sheep\n * @return owed - the amount of $WOOL earned\n */\nfunction _claimSheepFromBarn(uint256 tokenId, bool unstake) internal returns (uint256 owed) {\n Stake memory stake = barn[tokenId];\n require(stake.owner == _msgSender(), \"SWIPER, NO SWIPING\");\n require(!(unstake \u0026\u0026 block.timestamp - stake.value \u003c MINIMUM_TO_EXIT),\"GONNA BE COLD WITHOUT TWO DAY\u0027S WOOL\");\n if (totalWoolEarned \u003c MAXIMUM_GLOBAL_WOOL) {\n owed = (block.timestamp - stake.value) * DAILY_WOOL_RATE / 1 days;\n } else if (stake.value \u003e lastClaimTimestamp) {\n owed = 0; // $WOOL production stopped already\n }else {\n owed = (lastClaimTimestamp - stake.value) * DAILY_WOOL_RATE / 1 days; // stop earning additional $WOOL if it\u0027s all been earned\n}\n if (unstake) {\n if (random(tokenId) \u0026 1 == 1) { // 50% chance of all $WOOL stolen\n _payWolfTax(owed);\n owed =0;\n }\n woolf.safeTransferFrom(address(this), _msgSender(), tokenId, \"\"); // send back Sheep\n delete barn[tokenId];\ntotalSheepStaked -= 1;\n } else {\n _payWolfTax(owed * WOOL_CLAIM_TAX_PERCENTAGE / 100); // percentage tax to staked wolves\n owed =owed * (100 - WOOL_CLAIM_TAX_PERCENTAGE) / 100; // remainder goes to Sheep owner\n barn[tokenId] = Stake({\n owner: _msgSender(),\ntokenId: uint16(tokenId),\n value: uint80(block.timestamp)\n }); // reset stake\n }\n emit SheepClaimed(tokenId, owed,unstake);\n }\n\n /**\n * realize $WOOL earnings for a single Wolf and optionally unstake it\n * Wolves earn $WOOL proportional to theirAlpha rank\n * @param tokenId the ID of the Wolf to claim earnings from\n * @param unstake whether or not to unstake the Wolf\n * @returnowed - the amount of $WOOL earned\n */\n function _claimWolfFromPack(uint256 tokenId, bool unstake) internal returns (uint256 owed) {\nrequire(woolf.ownerOf(tokenId) == address(this), \"AINT A PART OF THE PACK\");\n uint256 alpha = _alphaForWolf(tokenId);\n Stake memory stake= pack[alpha][packIndices[tokenId]];\n require(stake.owner == _msgSender(), \"SWIPER, NO SWIPING\");\n owed = (alpha) * (woolPerAlpha - stake.value); // Calculate portion of tokens based on Alpha\n if (unstake) {\n totalAlphaStaked -= alpha; // Remove Alpha from total staked\nwoolf.safeTransferFrom(address(this), _msgSender(), tokenId, \"\"); // Send back Wolf\n Stake memory lastStake = pack[alpha][pack[alpha].length - 1];\n pack[alpha][packIndices[tokenId]] = lastStake; // Shuffle last Wolf to current position\n packIndices[lastStake.tokenId]= packIndices[tokenId];\n pack[alpha].pop(); // Remove duplicate\n delete packIndices[tokenId]; // Delete old mapping\n } else {\npack[alpha][packIndices[tokenId]] = Stake({\n owner: _msgSender(),\n tokenId: uint16(tokenId),\n value: uint80(woolPerAlpha)\n }); // reset stake\n }\n emit WolfClaimed(tokenId, owed, unstake);\n }\n\n /**\n * emergency unstake tokens\n * @paramtokenIds the IDs of the tokens to claim earnings from\n */\n function rescue(uint256[] calldata tokenIds) external {\n require(rescueEnabled,\"RESCUE DISABLED\");\n uint256 tokenId;\n Stake memory stake;\n Stake memory lastStake;\n uint256 alpha;\n for (uint i = 0; i\u003c tokenIds.length; i++) {\n tokenId = tokenIds[i];\n if (isSheep(tokenId)) {\n stake = barn[tokenId];\n require(stake.owner == _msgSender(), \"SWIPER, NO SWIPING\");\n woolf.safeTransferFrom(address(this), _msgSender(), tokenId, \"\"); // send back Sheep\ndelete barn[tokenId];\n totalSheepStaked -= 1;\n emit SheepClaimed(tokenId, 0, true);\n } else {\n alpha =_alphaForWolf(tokenId);\n stake = pack[alpha][packIndices[tokenId]];\n require(stake.owner == _msgSender(), \"SWIPER, NO SWIPING\");\n totalAlphaStaked -= alpha; // Remove Alpha from total staked\n woolf.safeTransferFrom(address(this), _msgSender(), tokenId, \"\"); // Send back Wolf\n lastStake = pack[alpha][pack[alpha].length - 1];\n pack[alpha][packIndices[tokenId]] = lastStake; // Shufflelast Wolf to current position\n packIndices[lastStake.tokenId] = packIndices[tokenId];\n pack[alpha].pop(); // Remove duplicate\ndelete packIndices[tokenId]; // Delete old mapping\n emit WolfClaimed(tokenId, 0, true);\n }\n }\n }\n\n /** ACCOUNTING */\n\n/** \n * add $WOOL to claimable pot for the Pack\n * @param amount $WOOL to add to the pot\n */\n function _payWolfTax(uint256 amount)internal {\n if (totalAlphaStaked == 0) { // if there\u0027s no staked wolves\n unaccountedRewards += amount; // keep track of $WOOL due towolves\n return;\n }\n // makes sure to include any unaccounted $WOOL \n woolPerAlpha += (amount + unaccountedRewards) /totalAlphaStaked;\n unaccountedRewards = 0;\n }\n\n /**\n * tracks $WOOL earnings to ensure it stops once 2.4 billion is eclipsed\n */\nmodifier _updateEarnings() {\n if (totalWoolEarned \u003c MAXIMUM_GLOBAL_WOOL) {\n totalWoolEarned += \n (block.timestamp -lastClaimTimestamp)\n * totalSheepStaked\n * DAILY_WOOL_RATE / 1 days; \n lastClaimTimestamp = block.timestamp;\n }\n _;\n}\n\n /** ADMIN */\n\n /**\n * allows owner to enable \"rescue mode\"\n * simplifies accounting, prioritizes tokens out in emergency\n*/\n function setRescueEnabled(bool _enabled) external onlyOwner {\n rescueEnabled = _enabled;\n }\n\n /**\n * enables owner to pause /unpause minting\n */\n function setPaused(bool _paused) external onlyOwner {\n if (_paused) _pause();\n else _unpause();\n }\n\n /**READ ONLY */\n\n /**\n * checks if a token is a Sheep\n * @param tokenId the ID of the token to check\n * @return sheep - whether or not atoken is a Sheep\n */\n function isSheep(uint256 tokenId) public view returns (bool sheep) {\n (sheep, , , , , , , , , ) = woolf.tokenTraits(tokenId);\n }\n\n /**\n * gets the alpha score for a Wolf\n * @param tokenId the ID of the Wolf to get the alpha score for\n * @return thealpha score of the Wolf (5-8)\n */\n function _alphaForWolf(uint256 tokenId) internal view returns (uint8) {\n ( , , , , , , , , , uint8alphaIndex) = woolf.tokenTraits(tokenId);\n return MAX_ALPHA - alphaIndex; // alpha index is 0-3\n }\n\n /**\n * chooses a random Wolf thiefwhen a newly minted token is stolen\n * @param seed a random value to choose a Wolf from\n * @return the owner of the randomly selected Wolfthief\n */\n function randomWolfOwner(uint256 seed) external view returns (address) {\n if (totalAlphaStaked == 0) return address(0x0);\nuint256 bucket = (seed \u0026 0xFFFFFFFF) % totalAlphaStaked; // choose a value from 0 to total alpha staked\n uint256 cumulative;\n seed\u003e\u003e= 32;\n // loop through each bucket of Wolves with the same alpha score\n for (uint i = MAX_ALPHA - 3; i \u003c= MAX_ALPHA; i++){\n cumulative += pack[i].length * i;\n // if the value is not inside of that bucket, keep going\n if (bucket \u003e= cumulative)continue;\n // get the address of a random Wolf with that alpha score\n return pack[i][seed % pack[i].length].owner;\n }\n returnaddress(0x0);\n }\n\n /**\n * generates a pseudorandom number\n * @param seed a value ensure different outcomes for different sources in thesame block\n * @return a pseudorandom value\n */\n function random(uint256 seed) internal view returns (uint256) {\n return uint256(keccak256(abi.encodePacked(\n tx.origin,\n blockhash(block.number - 1),\n block.timestamp,\n seed\n )));\n }\n\n functiononERC721Received(\n address,\n address from,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4){\n require(from == address(0x0), \"Cannot send tokens to Barn directly\");\n return IERC721Receiver.onERC721Received.selector;\n}\n\n \n}"},"Context.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about thecurrent execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying forexecution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate,library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"},"ERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the{IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n* for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId)public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public viewvirtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"},"ERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./IERC20Metadata.sol\";\nimport \"./Context.sol\";\n\n/**\n *@dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supplymechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For adetailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supplymechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. Thisbehavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval}event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening tosaid events. Other implementations of the EIP may not emit\n * these events, as it isn\u0027t required by the specification.\n *\n * Finally, thenon-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n *allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address =\u003e uint256) private _balances;\n\n mapping(address =\u003e mapping(address =\u003e uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private_name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of{decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable:they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name =name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtualoverride returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter versionof the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n/**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of`505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating therelationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: Thisinformation is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n/**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return_totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual overridereturns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n*\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n returntrue;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtualoverride returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n *Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) publicvirtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See{IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See thenote at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * -`sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``\u0027s tokens of at least\n *`amount`.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) public virtualoverride returns (bool) {\n _transfer(sender, recipient, amount);\n\n uint256 currentAllowance = _allowances[sender][_msgSender()];\nrequire(currentAllowance \u003e= amount, \"ERC20: transfer amount exceeds allowance\");\n unchecked {\n _approve(sender,_msgSender(), currentAllowance - amount);\n }\n\n return true;\n }\n\n /**\n * @dev Atomically increases the allowancegranted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problemsdescribed in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n* - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns(bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n return true;\n }\n\n /**\n *@dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used asa mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n*\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of atleast\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool){\n uint256 currentAllowance = _allowances[_msgSender()][spender];\n require(currentAllowance \u003e= subtractedValue, \"ERC20:decreased allowance below zero\");\n unchecked {\n _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n}\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\n *\n * This internalfunction is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n *Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be thezero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(\n address sender,\naddress recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zeroaddress\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient,amount);\n\n uint256 senderBalance = _balances[sender];\n require(senderBalance \u003e= amount, \"ERC20: transfer amount exceedsbalance\");\n unchecked {\n _balances[sender] = senderBalance - amount;\n }\n _balances[recipient] += amount;\n\nemit Transfer(sender, recipient, amount);\n\n _afterTokenTransfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount`tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zeroaddress.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account,uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`,reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n*\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(addressaccount, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n_beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance \u003e=amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n_totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n}\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function isequivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval}event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n*/\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Hook that iscalled before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from`and `to` are both non-zero, `amount` of ``from``\u0027s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokenswill be minted for `to`.\n * - when `to` is zero, `amount` of ``from``\u0027s tokens will be burned.\n * - `from` and `to` are never bothzero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function_beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hookthat is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when`from` and `to` are both non-zero, `amount` of ``from``\u0027s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount`tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``\u0027s tokens have been burned.\n * - `from` and `to` arenever both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\nfunction _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"},"ERC721.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./IERC721Metadata.sol\";\nimport \"./Address.sol\";\nimport \"./Context.sol\";\nimport \"./Strings.sol\";\nimport \"./ERC165.sol\";\n\n/**\n * @devImplementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but notincluding the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721,IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Tokensymbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 =\u003e address) private _owners;\n\n// Mapping owner address to token count\n mapping(address =\u003e uint256) private _balances;\n\n // Mapping from token ID to approvedaddress\n mapping(uint256 =\u003e address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address=\u003e mapping(address =\u003e bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a`symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol= symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public viewvirtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\ninterfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0),\"ERC721: balance query for the zero address\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\nfunction ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: owner query for nonexistent token\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @devSee {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n}\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns(string memory) {\n require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n\n string memory baseURI =_baseURI();\n return bytes(baseURI).length \u003e 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the`tokenId`. Empty\n * by default, can be overriden in child contracts.\n */\n function _baseURI() internal view virtual returns (stringmemory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId)public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is notowner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\nfunction getApproved(uint256 tokenId) public view virtual override returns (address) {\n require(_exists(tokenId), \"ERC721: approved queryfor nonexistent token\");\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\nfunction setApprovalForAll(address operator, bool approved) public virtual override {\n require(operator != _msgSender(), \"ERC721: approveto caller\");\n\n _operatorApprovals[_msgSender()][operator] = approved;\n emit ApprovalForAll(_msgSender(), operator, approved);\n}\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public viewvirtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n*/\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n//solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner norapproved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n functionsafeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n addressfrom,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n _safeTransfer(from, to, tokenId, _data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are awareof the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `_data` is additional data, it has no specified format and itis sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implementalternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be thezero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to asmart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer}event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transferto non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed bytheir owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n* and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\nreturn _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n *Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal viewvirtual returns (bool) {\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));\n }\n\n /**\n* @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If`to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emitsa {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n}\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n *forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256tokenId,\n bytes memory _data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, _data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @devMints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n* Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zeroaddress\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n_balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys`tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n*\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n_balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n }\n\n /**\n * @devTransfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n *Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a{Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual{\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer of token that is not own\");\n require(to != address(0), \"ERC721:transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n_approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emitTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits a {Approval} event.\n*/\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner ofthe given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n* @param _data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magicvalue\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory_data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from,tokenId, _data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytesmemory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n} else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n}\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before anytoken transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``\u0027s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * -When `to` is zero, ``from``\u0027s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more abouthooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\naddress to,\n uint256 tokenId\n ) internal virtual {}\n}\n"},"ERC721Enumerable.sol":{"content":"// SPDX-License-Identifier:MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721.sol\";\nimport \"./IERC721Enumerable.sol\";\n\n/**\n * @dev This implements an optionalextension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n* account.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n // Mapping from owner to list of owned token IDs\nmapping(address =\u003e mapping(uint256 =\u003e uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\nmapping(uint256 =\u003e uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private_allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 =\u003e uint256) private _allTokensIndex;\n\n/**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n}\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)public view virtual override returns (uint256) {\n require(index \u003c ERC721.balanceOf(owner), \"ERC721Enumerable: owner index out ofbounds\");\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n functiontotalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See{IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\nrequire(index \u003c ERC721Enumerable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n return _allTokens[index];\n}\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Callingconditions:\n *\n * - When `from` and `to` are both non-zero, ``from``\u0027s `tokenId` will be\n * transferred to `to`.\n * - When`from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``\u0027s `tokenId` will be burned.\n * - `from` cannotbe the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n_addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n}\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n_addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension\u0027sownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID ofthe token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId)private {\n uint256 length = ERC721.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension\u0027s token tracking data structures.\n * @param tokenIduint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n_allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a tokenfrom this extension\u0027s ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the`_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding doublewrites).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing theprevious owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n*/\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n // To prevent a gap in from\u0027s tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256lastTokenIndex = ERC721.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete isthe last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId =_ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token\u0027s index\n }\n\n // This alsodeletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete_ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension\u0027s token trackingdata structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of thetoken to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // Toprevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap andpop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When thetoken to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted tokenis burnt) that we still do the swap here to avoid the gas cost of adding\n // an \u0027if\u0027 statement (like in_removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; //Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token\u0027sindex\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n"},"IBarn.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE \n\npragma solidity ^0.8.0;\n\ninterface IBarn {\n functionaddManyToBarnAndPack(address account, uint16[] calldata tokenIds) external;\n function randomWolfOwner(uint256 seed) external view returns(address);\n}"},"IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, whichcan then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @devReturns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function callmust use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n*/\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns(uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external viewreturns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller\u0027s account to `recipient`.\n *\n * Returns a booleanvalue indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient,uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed tospend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or{transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n *@dev Sets `amount` as the allowance of `spender` over the caller\u0027s tokens.\n *\n * Returns a boolean value indicating whether theoperation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may useboth the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is tofirst reduce the spender\u0027s allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) externalreturns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is thendeducted from the caller\u0027s\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n* Emits a {Transfer} event.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n*\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n* @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\nevent Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"},"IERC20Metadata.sol":{"content":"// SPDX-License-Identifier:MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n*\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\nfunction name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol()external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() externalview returns (uint8);\n}\n"},"IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId`token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n/**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, addressindexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage allof its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returnsthe number of tokens in ``owner``\u0027s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n/**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\nfunction ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to`to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n *Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must existand be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or{setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon asafe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\nuint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of thismethod is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must beapproved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n functiontransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to`to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a singleaccount can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - Thecaller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\nfunction approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n *Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or{safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n*\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n *@dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n functionisApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from`from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n* - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either{approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which iscalled upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\naddress to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"},"IERC721Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optionalenumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n /**\n * @devReturns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n *@dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of``owner``\u0027s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\n\n/**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerateall tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"},"IERC721Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optionalmetadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returnsthe token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the tokencollection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform ResourceIdentifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"},"IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n *@dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`,this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returnedor the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with`IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"},"ITraits.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.0;\n\ninterface ITraits {\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}"},"IWoolf.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.0;\n\ninterface IWoolf {\n\n // struct to store each token\u0027straits\n struct SheepWolf {\n bool isSheep;\n uint8 fur;\n uint8 head;\n uint8 ears;\n uint8 eyes;\n uint8 nose;\n uint8mouth;\n uint8 neck;\n uint8 feet;\n uint8 alphaIndex;\n }\n\n\n function getPaidTokens() external view returns (uint256);\n functiongetTokenTraits(uint256 tokenId) external view returns (SheepWolf memory);\n}"},"Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragmasolidity ^0.8.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there isan account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one thatdeploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will makeavailable the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contractOwnable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n/**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _setOwner(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address){\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner(){\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contractwithout owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n*/\n function renounceOwnership() public virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /**\n * @dev Transfersownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n_setOwner(newOwner);\n }\n\n function _setOwner(address newOwner) private {\n address oldOwner = _owner;\n _owner = newOwner;\nemit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"},"Pausable.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity^0.8.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can betriggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and`whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module,only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggeredby `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\nevent Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\nconstructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\nfunction paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a functioncallable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\nmodifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make afunction callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\nmodifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n*\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n_paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n*\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emitUnpaused(_msgSender());\n }\n}\n"},"Strings.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Stringoperations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256`to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n //Inspired by OraclizeAPI\u0027s implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\nuint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\nbytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 +uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` toits ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\nif (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0){\n length++;\n temp \u003e\u003e= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @devConverts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\nbuffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i \u003e 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value \u0026 0xf];\nvalue \u003e\u003e= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n}\n}\n"},"Traits.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.0;\nimport \"./Ownable.sol\";\nimport \"./Strings.sol\";\nimport \"./ITraits.sol\";\nimport \"./IWoolf.sol\";\n\ncontract Traits is Ownable, ITraits {\n\n using Strings for uint256;\n\n //struct to store each trait\u0027s data for metadata and rendering\n struct Trait {\n string name;\n string png;\n }\n\n // mapping fromtrait type (index) to its name\n string[9] _traitTypes = [\n \"Fur\",\n \"Head\",\n \"Ears\",\n \"Eyes\",\n \"Nose\",\n\"Mouth\",\n \"Neck\",\n \"Feet\",\n \"Alpha\"\n ];\n // storage of each traits name and base64 PNG data\n mapping(uint8 =\u003emapping(uint8 =\u003e Trait)) public traitData;\n // mapping from alphaIndex to its score\n string[4] _alphas = [\n \"8\",\n \"7\",\n\"6\",\n \"5\"\n ];\n\n IWoolf public woolf;\n\n constructor() {}\n\n /** ADMIN */\n\n function setWoolf(address _woolf) external onlyOwner{\n woolf = IWoolf(_woolf);\n }\n\n /**\n * administrative to upload the names and images associated with each trait\n * @param traitTypethe trait type to upload the traits for (see traitTypes for a mapping)\n * @param traits the names and base64 encoded PNGs for each trait\n*/\n function uploadTraits(uint8 traitType, uint8[] calldata traitIds, Trait[] calldata traits) external onlyOwner {\n require(traitIds.length== traits.length, \"Mismatched inputs\");\n for (uint i = 0; i \u003c traits.length; i++) {\n traitData[traitType][traitIds[i]] = Trait(\ntraits[i].name,\n traits[i].png\n );\n }\n }\n\n /** RENDER */\n\n /**\n * generates an \u003cimage\u003e element usingbase64 encoded PNGs\n * @param trait the trait storing the PNG data\n * @return the \u003cimage\u003e element\n */\n function drawTrait(Trait memory trait) internal pure returns (string memory) {\n return string(abi.encodePacked(\n \u0027\u003cimage x=\"4\" y=\"4\" width=\"32\" height=\"32\" image-rendering=\"pixelated\" preserveAspectRatio=\"xMidYMid\" xlink:href=\"data:image/png;base64,\u0027,\n trait.png,\n\u0027\"/\u003e\u0027\n ));\n }\n\n /**\n * generates an entire SVG by composing multiple \u003cimage\u003e elements of PNGs\n *@param tokenId the ID of the token to generate an SVG for\n * @return a valid SVG of the Sheep / Wolf\n */\n function drawSVG(uint256 tokenId)public view returns (string memory) {\n IWoolf.SheepWolf memory s = woolf.getTokenTraits(tokenId);\n uint8 shift = s.isSheep ? 0 : 9;\n\nstring memory svgString = string(abi.encodePacked(\n drawTrait(traitData[0 + shift][s.fur]),\n s.isSheep ? drawTrait(traitData[1 +shift][s.head]) : drawTrait(traitData[1 + shift][s.alphaIndex]),\n s.isSheep ? drawTrait(traitData[2 + shift][s.ears]) : \u0027\u0027,\ndrawTrait(traitData[3 + shift][s.eyes]),\n s.isSheep ? drawTrait(traitData[4 + shift][s.nose]) : \u0027\u0027,\n drawTrait(traitData[5 +shift][s.mouth]),\n s.isSheep ? \u0027\u0027 : drawTrait(traitData[6 + shift][s.neck]),\n s.isSheep ? drawTrait(traitData[7 + shift][s.feet]) : \u0027\u0027\n ));\n\n return string(abi.encodePacked(\n \u0027\u003csvg id=\"woolf\" width=\"100%\" height=\"100%\" version=\"1.1\" viewBox=\"0 0 40 40\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\u003e\u0027,\n svgString,\n\"\u003c/svg\u003e\"\n ));\n }\n\n /**\n * generates an attribute for the attributes array in the ERC721 metadata standard\n * @paramtraitType the trait type to reference as the metadata key\n * @param value the token\u0027s trait associated with the key\n * @return a JSONdictionary for the single attribute\n */\n function attributeForTypeAndValue(string memory traitType, string memory value) internal pure returns(string memory) {\n return string(abi.encodePacked(\n \u0027{\"trait_type\":\"\u0027,\n traitType,\n \u0027\",\"value\":\"\u0027,\n value,\n \u0027\"}\u0027\n ));\n }\n\n /**\n * generates an array composed of all the individual traits and values\n *@param tokenId the ID of the token to compose the metadata for\n * @return a JSON array of all of the attributes for given token ID\n */\nfunction compileAttributes(uint256 tokenId) public view returns (string memory) {\n IWoolf.SheepWolf memory s = woolf.getTokenTraits(tokenId);\nstring memory traits;\n if (s.isSheep) {\n traits = string(abi.encodePacked(\n attributeForTypeAndValue(_traitTypes[0],traitData[0][s.fur].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[1], traitData[1][s.head].name),\u0027,\u0027,\nattributeForTypeAndValue(_traitTypes[2], traitData[2][s.ears].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[3], traitData[3][s.eyes].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[4], traitData[4][s.nose].name),\u0027,\u0027,\nattributeForTypeAndValue(_traitTypes[5], traitData[5][s.mouth].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[7],traitData[7][s.feet].name),\u0027,\u0027\n ));\n } else {\n traits = string(abi.encodePacked(\n attributeForTypeAndValue(_traitTypes[0], traitData[9][s.fur].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[1], traitData[10][s.alphaIndex].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[3], traitData[12][s.eyes].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[5], traitData[14][s.mouth].name),\u0027,\u0027,\n attributeForTypeAndValue(_traitTypes[6], traitData[15][s.neck].name),\u0027,\u0027,\n attributeForTypeAndValue(\"Alpha Score\", _alphas[s.alphaIndex]),\u0027,\u0027\n ));\n }\n return string(abi.encodePacked(\n \u0027[\u0027,\n traits,\n \u0027{\"trait_type\":\"Generation\",\"value\":\u0027,\n tokenId \u003c= woolf.getPaidTokens() ? \u0027\"Gen 0\"\u0027 : \u0027\"Gen 1\"\u0027,\n \u0027},{\"trait_type\":\"Type\",\"value\":\u0027,\n s.isSheep ?\u0027\"Sheep\"\u0027 : \u0027\"Wolf\"\u0027,\n \u0027}]\u0027\n ));\n }\n\n /**\n * generates a base64 encoded metadata responsewithout referencing off-chain content\n * @param tokenId the ID of the token to generate the metadata for\n * @return a base64 encoded JSONdictionary of the token\u0027s metadata and SVG\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\nIWoolf.SheepWolf memory s = woolf.getTokenTraits(tokenId);\n\n string memory metadata = string(abi.encodePacked(\n \u0027{\"name\":\"\u0027,\n s.isSheep ? \u0027Sheep #\u0027 : \u0027Wolf #\u0027,\n tokenId.toString(),\n \u0027\", \"description\": \"Thousands ofSheep and Wolves compete on a farm in the metaverse. A tempting prize of $WOOL awaits, with deadly high stakes. All the metadata and images aregenerated and stored 100% on-chain. No IPFS. NO API. Just the Ethereum blockchain.\", \"image\": \"data:image/svg+xml;base64,\u0027,\n base64(bytes(drawSVG(tokenId))),\n \u0027\", \"attributes\":\u0027,\n compileAttributes(tokenId),\n \"}\"\n ));\n\n return string(abi.encodePacked(\n \"data:application/json;base64,\",\n base64(bytes(metadata))\n ));\n }\n\n /** BASE 64 - Written by Brech Devos*/\n \n string internal constant TABLE = \u0027ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\u0027;\n\n function base64(bytesmemory data) internal pure returns (string memory) {\n if (data.length == 0) return \u0027\u0027;\n \n // load the table into memory\nstring memory table = TABLE;\n\n // multiply by 4/3 rounded up\n uint256 encodedLen = 4 * ((data.length + 2) / 3);\n\n // add some extrabuffer at the end required for the writing\n string memory result = new string(encodedLen + 32);\n\n assembly {\n // set the actualoutput length\n mstore(result, encodedLen)\n \n // prepare the lookup table\n let tablePtr := add(table, 1)\n \n //input ptr\n let dataPtr := data\n let endPtr := add(dataPtr, mload(data))\n \n // result ptr, jump over length\n letresultPtr := add(result, 32)\n \n // run over the input, 3 bytes at a time\n for {} lt(dataPtr, endPtr) {}\n {\ndataPtr := add(dataPtr, 3)\n \n // read 3 bytes\n let input := mload(dataPtr)\n \n // write 4characters\n mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F)))))\n resultPtr := add(resultPtr, 1)\nmstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F)))))\n resultPtr := add(resultPtr, 1)\n mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F)))))\n resultPtr := add(resultPtr, 1)\n mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F)))))\n resultPtr := add(resultPtr, 1)\n }\n \n // padding with \u0027=\u0027\n switch mod(mload(data), 3)\n case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) }\n case 2 { mstore(sub(resultPtr, 1),shl(248, 0x3d)) }\n }\n \n return result;\n }\n}"},"WOOL.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.0;\nimport \"./ERC20.sol\";\nimport \"./Ownable.sol\";\n\ncontract WOOL is ERC20, Ownable {\n\n // a mapping from an address to whether or not itcan mint / burn\n mapping(address =\u003e bool) controllers;\n \n constructor() ERC20(\"WOOL\", \"WOOL\") { }\n\n /**\n * mints $WOOL to arecipient\n * @param to the recipient of the $WOOL\n * @param amount the amount of $WOOL to mint\n */\n function mint(address to, uint256amount) external {\n require(controllers[msg.sender], \"Only controllers can mint\");\n _mint(to, amount);\n }\n\n /**\n * burns $WOOLfrom a holder\n * @param from the holder of the $WOOL\n * @param amount the amount of $WOOL to burn\n */\n function burn(address from,uint256 amount) external {\n require(controllers[msg.sender], \"Only controllers can burn\");\n _burn(from, amount);\n }\n\n /**\n *enables an address to mint / burn\n * @param controller the address to enable\n */\n function addController(address controller) externalonlyOwner {\n controllers[controller] = true;\n }\n\n /**\n * disables an address from minting / burning\n * @param controller the addressto disbale\n */\n function removeController(address controller) external onlyOwner {\n controllers[controller] = false;\n }\n}"},"Woolf.sol":{"content":"// SPDX-License-Identifier: MIT LICENSE\n\npragma solidity ^0.8.0;\nimport \"./Ownable.sol\";\nimport \"./Pausable.sol\";\nimport \"./ERC721Enumerable.sol\";\nimport \"./IWoolf.sol\";\nimport \"./IBarn.sol\";\nimport \"./ITraits.sol\";\nimport \"./WOOL.sol\";\n\n\ncontract Woolfis IWoolf, ERC721Enumerable, Ownable, Pausable {\n\n // mint price\n uint256 public constant MINT_PRICE = .069420 ether;\n // max number oftokens that can be minted - 50000 in production\n uint256 public immutable MAX_TOKENS;\n // number of tokens that can be claimed for free - 20%of MAX_TOKENS\n uint256 public PAID_TOKENS;\n // number of tokens have been minted so far\n uint16 public minted;\n\n // mapping from tokenIdto a struct containing the token\u0027s traits\n mapping(uint256 =\u003e SheepWolf) public tokenTraits;\n // mapping from hashed(tokenTrait) tothe tokenId it\u0027s associated with\n // used to ensure there are no duplicates\n mapping(uint256 =\u003e uint256) public existingCombinations;\n\n // list of probabilities for each trait type\n // 0 - 9 are associated with Sheep, 10 - 18 are associated with Wolves\n uint8[][18] publicrarities;\n // list of aliases for Walker\u0027s Alias algorithm\n // 0 - 9 are associated with Sheep, 10 - 18 are associated with Wolves\nuint8[][18] public aliases;\n\n // reference to the Barn for choosing random Wolf thieves\n IBarn public barn;\n // reference to $WOOL forburning on mint\n WOOL public wool;\n // reference to Traits\n ITraits public traits;\n\n /** \n * instantiates contract and rarity tables\n*/\n constructor(address _wool, address _traits, uint256 _maxTokens) ERC721(\"Wolf Game\", \u0027WGAME\u0027) { \n wool = WOOL(_wool);\ntraits = ITraits(_traits);\n MAX_TOKENS = _maxTokens;\n PAID_TOKENS = _maxTokens / 5;\n\n // I know this looks weird but it saves usersgas by making lookup O(1)\n // A.J. Walker\u0027s Alias Algorithm\n // sheep\n // fur\n rarities[0] = [15, 50, 200, 250, 255];\naliases[0] = [4, 4, 4, 4, 4];\n // head\n rarities[1] = [190, 215, 240, 100, 110, 135, 160, 185, 80, 210, 235, 240, 80, 80, 100, 100, 100,245, 250, 255];\n aliases[1] = [1, 2, 4, 0, 5, 6, 7, 9, 0, 10, 11, 17, 0, 0, 0, 0, 4, 18, 19, 19];\n // ears\n rarities[2] = [255, 30, 60, 60, 150, 156];\n aliases[2] = [0, 0, 0, 0, 0, 0];\n // eyes\n rarities[3] = [221, 100, 181, 140, 224, 147, 84, 228, 140, 224, 250, 160,241, 207, 173, 84, 254, 220, 196, 140, 168, 252, 140, 183, 236, 252, 224, 255];\n aliases[3] = [1, 2, 5, 0, 1, 7, 1, 10, 5, 10, 11, 12, 13, 14,16, 11, 17, 23, 13, 14, 17, 23, 23, 24, 27, 27, 27, 27];\n // nose\n rarities[4] = [175, 100, 40, 250, 115, 100, 185, 175, 180, 255];\naliases[4] = [3, 0, 4, 6, 6, 7, 8, 8, 9, 9];\n // mouth\n rarities[5] = [80, 225, 227, 228, 112, 240, 64, 160, 167, 217, 171, 64, 240, 126,80, 255];\n aliases[5] = [1, 2, 3, 8, 2, 8, 8, 9, 9, 10, 13, 10, 13, 15, 13, 15];\n // neck\n rarities[6] = [255];\n aliases[6] = [0];\n // feet\n rarities[7] = [243, 189, 133, 133, 57, 95, 152, 135, 133, 57, 222, 168, 57, 57, 38, 114, 114, 114, 255];\n aliases[7] = [1,7, 0, 0, 0, 0, 0, 10, 0, 0, 11, 18, 0, 0, 0, 1, 7, 11, 18];\n // alphaIndex\n rarities[8] = [255];\n aliases[8] = [0];\n\n // wolves\n// fur\n rarities[9] = [210, 90, 9, 9, 9, 150, 9, 255, 9];\n aliases[9] = [5, 0, 0, 5, 5, 7, 5, 7, 5];\n // head\n rarities[10] =[255];\n aliases[10] = [0];\n // ears\n rarities[11] = [255];\n aliases[11] = [0];\n // eyes\n rarities[12] = [135, 177, 219, 141, 183, 225, 147, 189, 231, 135, 135, 135, 135, 246, 150, 150, 156, 165, 171, 180, 186, 195, 201, 210, 243, 252, 255];\n aliases[12] = [1, 2, 3,4, 5, 6, 7, 8, 13, 3, 6, 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, 26];\n // nose\n rarities[13] = [255];\n aliases[13]= [0];\n // mouth\n rarities[14] = [239, 244, 249, 234, 234, 234, 234, 234, 234, 234, 130, 255, 247];\n aliases[14] = [1, 2, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11];\n // neck\n rarities[15] = [75, 180, 165, 120, 60, 150, 105, 195, 45, 225, 75, 45, 195, 120, 255];\naliases[15] = [1, 9, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 14, 12, 14];\n // feet \n rarities[16] = [255];\n aliases[16] = [0];\n //alphaIndex\n rarities[17] = [8, 160, 73, 255]; \n aliases[17] = [2, 3, 3, 3];\n }\n\n /** EXTERNAL */\n\n /** \n * mint a token - 90%Sheep, 10% Wolves\n * The first 20% are free to claim, the remaining cost $WOOL\n */\n function mint(uint256 amount, bool stake) externalpayable whenNotPaused {\n require(tx.origin == _msgSender(), \"Only EOA\");\n require(minted + amount \u003c= MAX_TOKENS, \"All tokensminted\");\n require(amount \u003e 0 \u0026\u0026 amount \u003c= 10, \"Invalid mint amount\");\n if (minted \u003c PAID_TOKENS) {\nrequire(minted + amount \u003c= PAID_TOKENS, \"All tokens on-sale already sold\");\n require(amount * MINT_PRICE == msg.value, \"Invalidpayment amount\");\n } else {\n require(msg.value == 0);\n }\n\n uint256 totalWoolCost = 0;\n uint16[] memory tokenIds = stake ?new uint16[](amount) : new uint16[](0);\n uint256 seed;\n for (uint i = 0; i \u003c amount; i++) {\n minted++;\n seed = random(minted);\n generate(minted, seed);\n address recipient = selectRecipient(seed);\n if (!stake || recipient != _msgSender()) {\n_safeMint(recipient, minted);\n } else {\n _safeMint(address(barn), minted);\n tokenIds[i] = minted;\n }\ntotalWoolCost += mintCost(minted);\n }\n \n if (totalWoolCost \u003e 0) wool.burn(_msgSender(), totalWoolCost);\n if (stake) barn.addManyToBarnAndPack(_msgSender(), tokenIds);\n }\n\n /** \n * the first 20% are paid in ETH\n * the next 20% are 20000 $WOOL\n * the next40% are 40000 $WOOL\n * the final 20% are 80000 $WOOL\n * @param tokenId the ID to check the cost of to mint\n * @return the cost of thegiven token ID\n */\n function mintCost(uint256 tokenId) public view returns (uint256) {\n if (tokenId \u003c= PAID_TOKENS) return 0;\n if(tokenId \u003c= MAX_TOKENS * 2 / 5) return 20000 ether;\n if (tokenId \u003c= MAX_TOKENS * 4 / 5) return 40000 ether;\n return 80000 ether;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n // Hardcode theBarn\u0027s approval so that users don\u0027t have to waste gas approving\n if (_msgSender() != address(barn))\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n _transfer(from, to, tokenId);\n }\n\n /** INTERNAL */\n\n/**\n * generates traits for a specific token, checking to make sure it\u0027s unique\n * @param tokenId the id of the token to generate traitsfor\n * @param seed a pseudorandom 256 bit number to derive traits from\n * @return t - a struct of traits for the given token ID\n */\nfunction generate(uint256 tokenId, uint256 seed) internal returns (SheepWolf memory t) {\n t = selectTraits(seed);\n if(existingCombinations[structToHash(t)] == 0) {\n tokenTraits[tokenId] = t;\n existingCombinations[structToHash(t)] = tokenId;\nreturn t;\n }\n return generate(tokenId, random(seed));\n }\n\n /**\n * uses A.J. Walker\u0027s Alias algorithm for O(1) rarity tablelookup\n * ensuring O(1) instead of O(n) reduces mint cost by more than 50%\n * probability \u0026 alias tables are generated off-chainbeforehand\n * @param seed portion of the 256 bit seed to remove trait correlation\n * @param traitType the trait type to select a trait for \n* @return the ID of the randomly selected trait\n */\n function selectTrait(uint16 seed, uint8 traitType) internal view returns (uint8) {\nuint8 trait = uint8(seed) % uint8(rarities[traitType].length);\n if (seed \u003e\u003e 8 \u003c rarities[traitType][trait]) return trait;\nreturn aliases[traitType][trait];\n }\n\n /**\n * the first 20% (ETH purchases) go to the minter\n * the remaining 80% have a 10% chance tobe given to a random staked wolf\n * @param seed a random value to select a recipient from\n * @return the address of the recipient (either theminter or the Wolf thief\u0027s owner)\n */\n function selectRecipient(uint256 seed) internal view returns (address) {\n if (minted \u003c=PAID_TOKENS || ((seed \u003e\u003e 245) % 10) != 0) return _msgSender(); // top 10 bits haven\u0027t been used\n address thief = barn.randomWolfOwner(seed \u003e\u003e 144); // 144 bits reserved for trait selection\n if (thief == address(0x0)) return _msgSender();\n returnthief;\n }\n\n /**\n * selects the species and all of its traits based on the seed value\n * @param seed a pseudorandom 256 bit number toderive traits from\n * @return t - a struct of randomly selected traits\n */\n function selectTraits(uint256 seed) internal view returns(SheepWolf memory t) { \n t.isSheep = (seed \u0026 0xFFFF) % 10 != 0;\n uint8 shift = t.isSheep ? 0 : 9;\n seed \u003e\u003e= 16;\nt.fur = selectTrait(uint16(seed \u0026 0xFFFF), 0 + shift);\n seed \u003e\u003e= 16;\n t.head = selectTrait(uint16(seed \u0026 0xFFFF), 1 +shift);\n seed \u003e\u003e= 16;\n t.ears = selectTrait(uint16(seed \u0026 0xFFFF), 2 + shift);\n seed \u003e\u003e= 16;\n t.eyes =selectTrait(uint16(seed \u0026 0xFFFF), 3 + shift);\n seed \u003e\u003e= 16;\n t.nose = selectTrait(uint16(seed \u0026 0xFFFF), 4 + shift);\nseed \u003e\u003e= 16;\n t.mouth = selectTrait(uint16(seed \u0026 0xFFFF), 5 + shift);\n seed \u003e\u003e= 16;\n t.neck = selectTrait(uint16(seed \u0026 0xFFFF), 6 + shift);\n seed \u003e\u003e= 16;\n t.feet = selectTrait(uint16(seed \u0026 0xFFFF), 7 + shift);\n seed\u003e\u003e= 16;\n t.alphaIndex = selectTrait(uint16(seed \u0026 0xFFFF), 8 + shift);\n }\n\n /**\n * converts a struct to a 256 bit hashto check for uniqueness\n * @param s the struct to pack into a hash\n * @return the 256 bit hash of the struct\n */\n function structToHash(SheepWolf memory s) internal pure returns (uint256) {\n return uint256(bytes32(\n abi.encodePacked(\n s.isSheep,\n s.fur,\ns.head,\n s.eyes,\n s.mouth,\n s.neck,\n s.ears,\n s.feet,\n s.alphaIndex\n )\n ));\n}\n\n /**\n * generates a pseudorandom number\n * @param seed a value ensure different outcomes for different sources in the same block\n *@return a pseudorandom value\n */\n function random(uint256 seed) internal view returns (uint256) {\n return uint256(keccak256(abi.encodePacked(\n tx.origin,\n blockhash(block.number - 1),\n block.timestamp,\n seed\n )));\n }\n\n /** READ */\n\nfunction getTokenTraits(uint256 tokenId) external view override returns (SheepWolf memory) {\n return tokenTraits[tokenId];\n }\n\n functiongetPaidTokens() external view override returns (uint256) {\n return PAID_TOKENS;\n }\n\n /** ADMIN */\n\n /**\n * called after deploymentso that the contract can get random wolf thieves\n * @param _barn the address of the Barn\n */\n function setBarn(address _barn) externalonlyOwner {\n barn = IBarn(_barn);\n }\n\n /**\n * allows owner to withdraw funds from minting\n */\n function withdraw() externalonlyOwner {\n payable(owner()).transfer(address(this).balance);\n }\n\n /**\n * updates the number of tokens for sale\n */\n functionsetPaidTokens(uint256 _paidTokens) external onlyOwner {\n PAID_TOKENS = _paidTokens;\n }\n\n /**\n * enables owner to pause / unpauseminting\n */\n function setPaused(bool _paused) external onlyOwner {\n if (_paused) _pause();\n else _unpause();\n }\n\n /** RENDER*/\n\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n require(_exists(tokenId), \"ERC721Metadata: URIquery for nonexistent token\");\n return traits.tokenURI(tokenId);\n }\n}"}}
File 5 of 5: WETH9
12345678910111213141516// Copyright (C) 2015, 2016, 2017 Dapphub// This program is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// You should have received a copy of the GNU General Public License// along with this program. If not, see <http://www.gnu.org/licenses/>.pragma solidity ^0.4.18;