zellic-audit
Initial commit
f998fcd
raw
history blame
59.5 kB
{
"language": "Solidity",
"sources": {
"src/token.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// token.sol -- I frobbed an inc and all I got was this lousy token\n\n// Copyright (C) 2022 Horsefacts <[email protected]>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\npragma solidity ^0.8.15;\n\nimport {DSSLike} from \"dss/dss.sol\";\nimport {DSNote} from \"ds-note/note.sol\";\nimport {ERC721} from \"solmate/tokens/ERC721.sol\";\nimport {FixedPointMathLib} from \"solmate/utils/FixedPointMathLib.sol\";\n\nimport {Render, DataURI} from \"./render.sol\";\n\ninterface SumLike {\n function incs(address)\n external\n view\n returns (uint256, uint256, uint256, uint256, uint256);\n}\n\ninterface CTRLike {\n function balanceOf(address) external view returns (uint256);\n function push(address, uint256) external;\n}\n\nstruct Inc {\n address guy;\n uint256 net;\n uint256 tab;\n uint256 tax;\n uint256 num;\n uint256 hop;\n}\n\ncontract DSSToken is ERC721, DSNote {\n using FixedPointMathLib for uint256;\n using DataURI for string;\n\n error WrongPayment(uint256 sent, uint256 cost);\n error Forbidden();\n error PullFailed();\n\n uint256 constant WAD = 1 ether;\n uint256 constant BASE_PRICE = 0.01 ether;\n uint256 constant INCREASE = 1.1 ether;\n\n DSSLike public immutable dss; // DSS module\n DSSLike public immutable coins; // Token ID counter\n DSSLike public immutable price; // Token price counter\n CTRLike public immutable ctr; // CTR token\n\n address public owner;\n\n modifier auth() {\n if (msg.sender != owner) revert Forbidden();\n _;\n }\n\n modifier owns(uint256 tokenId) {\n if (msg.sender != ownerOf(tokenId)) revert Forbidden();\n _;\n }\n\n modifier exists(uint256 tokenId) {\n ownerOf(tokenId);\n _;\n }\n\n constructor(address _dss, address _ctr) ERC721(\"CounterDAO\", \"++\") {\n owner = msg.sender;\n\n dss = DSSLike(_dss);\n ctr = CTRLike(_ctr);\n\n // Build a counter to track token IDs.\n coins = DSSLike(dss.build(\"coins\", address(0)));\n\n // Build a counter to track token price.\n price = DSSLike(dss.build(\"price\", address(0)));\n\n // Authorize core dss modules.\n coins.bless();\n price.bless();\n\n // Initialize counters.\n coins.use();\n price.use();\n }\n\n /// @notice Mint a dss-token to caller. Must send ether equal to\n /// current `cost`. Distributes 100 CTR to caller if a sufficient\n /// balance is available in the contract.\n function mint() external payable note {\n uint256 _cost = cost();\n if (msg.value != _cost) {\n revert WrongPayment(msg.value, _cost);\n }\n\n // Increment token ID.\n coins.hit();\n uint256 id = coins.see();\n\n // Build and initialize a counter associated with this token.\n DSSLike _count = DSSLike(dss.build(bytes32(id), address(0)));\n _count.bless();\n _count.use();\n\n // Distribute 100 CTR to caller.\n _give(msg.sender, 100 * WAD);\n _safeMint(msg.sender, id);\n }\n\n /// @notice Increase `cost` by 10%. Distributes 10 CTR to caller\n /// if a sufficient balance is available in the contract.\n function hike() external note {\n if (price.see() < 100) {\n // Increment price counter.\n price.hit();\n _give(msg.sender, 10 * WAD);\n }\n }\n\n /// @notice Decrease `cost` by 10%. Distributes 10 CTR to caller\n /// if a sufficient balance is available in the contract.\n function drop() external note {\n if (price.see() > 0) {\n // Decrement price counter.\n price.dip();\n _give(msg.sender, 10 * WAD);\n }\n }\n\n /// @notice Get cost to `mint` a dss-token.\n /// @return Current `mint` price in wei.\n function cost() public view returns (uint256) {\n return cost(price.see());\n }\n\n /// @notice Get cost to `mint` a dss-token for a given value\n /// of the `price` counter.\n /// @param net Value of the `price` counter.\n /// @return `mint` price in wei.\n function cost(uint256 net) public pure returns (uint256) {\n // Calculate cost to mint based on price counter value.\n // Price increases by 10% for each counter increment, i.e.:\n //\n // cost = 0.01 ether * 1.01 ether ^ (counter value)\n\n return BASE_PRICE.mulWadUp(INCREASE.rpow(net, WAD));\n }\n\n /// @notice Increment a token's counter. Only token owner.\n /// @param tokenId dss-token ID.\n function hit(uint256 tokenId) external owns(tokenId) note {\n count(tokenId).hit();\n }\n\n /// @notice Decrement a token's counter. Only token owner.\n /// @param tokenId dss-token ID\n function dip(uint256 tokenId) external owns(tokenId) note {\n count(tokenId).dip();\n }\n\n /// @notice Withdraw ether balance from contract. Only contract owner.\n /// @param dst Destination address.\n function pull(address dst) external auth note {\n (bool ok,) = payable(dst).call{ value: address(this).balance }(\"\");\n if (!ok) revert PullFailed();\n }\n\n /// @notice Change contract owner. Only contract owner.\n /// @param guy New contract owner.\n function swap(address guy) external auth note {\n owner = guy;\n }\n\n /// @notice Read a token's counter value.\n /// @param tokenId dss-token ID.\n function see(uint256 tokenId) external view returns (uint256) {\n return count(tokenId).see();\n }\n\n /// @notice Get the DSSProxy for a token's counter.\n /// @param tokenId dss-token ID.\n function count(uint256 tokenId) public view returns (DSSLike) {\n // dss.scry returns the deterministic address of a DSSProxy contract for\n // a given deployer, salt, and owner. Since we know these values, we\n // don't need to write the counter address to storage.\n return DSSLike(dss.scry(address(this), bytes32(tokenId), address(0)));\n }\n\n /// @notice Get the Inc for a DSSProxy address.\n /// @param guy DSSProxy address.\n function inc(address guy) public view returns (Inc memory) {\n // Get low level counter information from the Sum.\n SumLike sum = SumLike(dss.sum());\n (uint256 net, uint256 tab, uint256 tax, uint256 num, uint256 hop) =\n sum.incs(guy);\n return Inc(guy, net, tab, tax, num, hop);\n }\n\n /// @notice Get URI for a dss-token.\n /// @param tokenId dss-token ID.\n /// @return base64 encoded Data URI string.\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n exists(tokenId)\n returns (string memory)\n {\n return tokenJSON(tokenId).toDataURI(\"application/json\");\n }\n\n /// @notice Get JSON metadata for a dss-token.\n /// @param tokenId dss-token ID.\n /// @return JSON metadata string.\n function tokenJSON(uint256 tokenId)\n public\n view\n exists(tokenId)\n returns (string memory)\n {\n Inc memory countInc = inc(address(count(tokenId)));\n return Render.json(tokenId, tokenSVG(tokenId).toDataURI(\"image/svg+xml\"), countInc);\n }\n\n /// @notice Get SVG image for a dss-token.\n /// @param tokenId dss-token ID.\n /// @return SVG image string.\n function tokenSVG(uint256 tokenId)\n public\n view\n exists(tokenId)\n returns (string memory)\n {\n Inc memory countInc = inc(address(count(tokenId)));\n Inc memory priceInc = inc(address(price));\n return Render.image(tokenId, coins.see(), countInc, priceInc);\n }\n\n function _give(address dst, uint256 wad) internal {\n if (ctr.balanceOf(address(this)) >= wad) ctr.push(dst, wad);\n }\n}\n"
},
"lib/dss/src/dss.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n/// dss.sol -- Decentralized Summation System\n\n// Copyright (C) 2022 Horsefacts <[email protected]>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\npragma solidity ^0.8.15;\n\nimport {DSSProxy} from \"./proxy/proxy.sol\";\n\ninterface DSSLike {\n function sum() external view returns(address);\n function use() external;\n function see() external view returns (uint256);\n function hit() external;\n function dip() external;\n function nil() external;\n function hope(address) external;\n function nope(address) external;\n function bless() external;\n function build(bytes32 wit, address god) external returns (address);\n function scry(address guy, bytes32 wit, address god) external view returns (address);\n}\n\ninterface SumLike {\n function hope(address) external;\n function nope(address) external;\n}\n\ninterface UseLike {\n function use() external;\n}\n\ninterface SpyLike {\n function see() external view returns (uint256);\n}\n\ninterface HitterLike {\n function hit() external;\n}\n\ninterface DipperLike {\n function dip() external;\n}\n\ninterface NilLike {\n function nil() external;\n}\n\ncontract DSS {\n // --- Data ---\n address immutable public sum;\n address immutable public _use;\n address immutable public _spy;\n address immutable public _hitter;\n address immutable public _dipper;\n address immutable public _nil;\n\n // --- Init ---\n constructor(\n address sum_,\n address use_,\n address spy_,\n address hitter_,\n address dipper_,\n address nil_)\n {\n sum = sum_; // Core ICV engine\n _use = use_; // Creation module\n _spy = spy_; // Read module\n _hitter = hitter_; // Increment module\n _dipper = dipper_; // Decrement module\n _nil = nil_; // Reset module\n }\n\n // --- DSS Operations ---\n function use() external {\n UseLike(_use).use();\n }\n\n function see() external view returns (uint256) {\n return SpyLike(_spy).see();\n }\n\n function hit() external {\n HitterLike(_hitter).hit();\n }\n\n function dip() external {\n DipperLike(_dipper).dip();\n }\n\n function nil() external {\n NilLike(_nil).nil();\n }\n\n function hope(address usr) external {\n SumLike(sum).hope(usr);\n }\n\n function nope(address usr) external {\n SumLike(sum).nope(usr);\n }\n\n function bless() external {\n SumLike(sum).hope(_use);\n SumLike(sum).hope(_hitter);\n SumLike(sum).hope(_dipper);\n SumLike(sum).hope(_nil);\n }\n\n function build(bytes32 wit, address god) external returns (address proxy) {\n proxy = address(new DSSProxy{ salt: wit }(address(this), msg.sender, god));\n }\n\n function scry(address guy, bytes32 wit, address god) external view returns (address) {\n address me = address(this);\n return address(uint160(uint256(keccak256(\n abi.encodePacked(\n bytes1(0xff),\n me,\n wit,\n keccak256(\n abi.encodePacked(\n type(DSSProxy).creationCode,\n abi.encode(me),\n abi.encode(guy),\n abi.encode(god)\n )\n )\n )\n ))));\n }\n}\n"
},
"lib/ds-note/src/note.sol": {
"content": "/// note.sol -- the `note' modifier, for logging calls as events\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >=0.4.23;\n\ncontract DSNote {\n event LogNote(\n bytes4 indexed sig,\n address indexed guy,\n bytes32 indexed foo,\n bytes32 indexed bar,\n uint256 wad,\n bytes fax\n ) anonymous;\n\n modifier note {\n bytes32 foo;\n bytes32 bar;\n uint256 wad;\n\n assembly {\n foo := calldataload(4)\n bar := calldataload(36)\n wad := callvalue()\n }\n\n _;\n\n emit LogNote(msg.sig, msg.sender, foo, bar, wad, msg.data);\n }\n}\n"
},
"lib/solmate/src/tokens/ERC721.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)\nabstract contract ERC721 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 indexed id);\n\n event Approval(address indexed owner, address indexed spender, uint256 indexed id);\n\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE/LOGIC\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n function tokenURI(uint256 id) public view virtual returns (string memory);\n\n /*//////////////////////////////////////////////////////////////\n ERC721 BALANCE/OWNER STORAGE\n //////////////////////////////////////////////////////////////*/\n\n mapping(uint256 => address) internal _ownerOf;\n\n mapping(address => uint256) internal _balanceOf;\n\n function ownerOf(uint256 id) public view virtual returns (address owner) {\n require((owner = _ownerOf[id]) != address(0), \"NOT_MINTED\");\n }\n\n function balanceOf(address owner) public view virtual returns (uint256) {\n require(owner != address(0), \"ZERO_ADDRESS\");\n\n return _balanceOf[owner];\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC721 APPROVAL STORAGE\n //////////////////////////////////////////////////////////////*/\n\n mapping(uint256 => address) public getApproved;\n\n mapping(address => mapping(address => bool)) public isApprovedForAll;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(string memory _name, string memory _symbol) {\n name = _name;\n symbol = _symbol;\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC721 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 id) public virtual {\n address owner = _ownerOf[id];\n\n require(msg.sender == owner || isApprovedForAll[owner][msg.sender], \"NOT_AUTHORIZED\");\n\n getApproved[id] = spender;\n\n emit Approval(owner, spender, id);\n }\n\n function setApprovalForAll(address operator, bool approved) public virtual {\n isApprovedForAll[msg.sender][operator] = approved;\n\n emit ApprovalForAll(msg.sender, operator, approved);\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 id\n ) public virtual {\n require(from == _ownerOf[id], \"WRONG_FROM\");\n\n require(to != address(0), \"INVALID_RECIPIENT\");\n\n require(\n msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],\n \"NOT_AUTHORIZED\"\n );\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n unchecked {\n _balanceOf[from]--;\n\n _balanceOf[to]++;\n }\n\n _ownerOf[id] = to;\n\n delete getApproved[id];\n\n emit Transfer(from, to, id);\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id\n ) public virtual {\n transferFrom(from, to, id);\n\n require(\n to.code.length == 0 ||\n ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, \"\") ==\n ERC721TokenReceiver.onERC721Received.selector,\n \"UNSAFE_RECIPIENT\"\n );\n }\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n bytes calldata data\n ) public virtual {\n transferFrom(from, to, id);\n\n require(\n to.code.length == 0 ||\n ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==\n ERC721TokenReceiver.onERC721Received.selector,\n \"UNSAFE_RECIPIENT\"\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC165 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return\n interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165\n interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721\n interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 id) internal virtual {\n require(to != address(0), \"INVALID_RECIPIENT\");\n\n require(_ownerOf[id] == address(0), \"ALREADY_MINTED\");\n\n // Counter overflow is incredibly unrealistic.\n unchecked {\n _balanceOf[to]++;\n }\n\n _ownerOf[id] = to;\n\n emit Transfer(address(0), to, id);\n }\n\n function _burn(uint256 id) internal virtual {\n address owner = _ownerOf[id];\n\n require(owner != address(0), \"NOT_MINTED\");\n\n // Ownership check above ensures no underflow.\n unchecked {\n _balanceOf[owner]--;\n }\n\n delete _ownerOf[id];\n\n delete getApproved[id];\n\n emit Transfer(owner, address(0), id);\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL SAFE MINT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _safeMint(address to, uint256 id) internal virtual {\n _mint(to, id);\n\n require(\n to.code.length == 0 ||\n ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, \"\") ==\n ERC721TokenReceiver.onERC721Received.selector,\n \"UNSAFE_RECIPIENT\"\n );\n }\n\n function _safeMint(\n address to,\n uint256 id,\n bytes memory data\n ) internal virtual {\n _mint(to, id);\n\n require(\n to.code.length == 0 ||\n ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==\n ERC721TokenReceiver.onERC721Received.selector,\n \"UNSAFE_RECIPIENT\"\n );\n }\n}\n\n/// @notice A generic interface for a contract which properly accepts ERC721 tokens.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)\nabstract contract ERC721TokenReceiver {\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external virtual returns (bytes4) {\n return ERC721TokenReceiver.onERC721Received.selector;\n }\n}\n"
},
"lib/solmate/src/utils/FixedPointMathLib.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\nlibrary FixedPointMathLib {\n /*//////////////////////////////////////////////////////////////\n SIMPLIFIED FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n }\n\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n }\n\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n }\n\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n }\n\n /*//////////////////////////////////////////////////////////////\n LOW LEVEL FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function mulDivDown(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // Divide z by the denominator.\n z := div(z, denominator)\n }\n }\n\n function mulDivUp(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // First, divide z - 1 by the denominator and add 1.\n // We allow z - 1 to underflow if z is 0, because we multiply the\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\n }\n }\n\n function rpow(\n uint256 x,\n uint256 n,\n uint256 scalar\n ) internal pure returns (uint256 z) {\n assembly {\n switch x\n case 0 {\n switch n\n case 0 {\n // 0 ** 0 = 1\n z := scalar\n }\n default {\n // 0 ** n = 0\n z := 0\n }\n }\n default {\n switch mod(n, 2)\n case 0 {\n // If n is even, store scalar in z for now.\n z := scalar\n }\n default {\n // If n is odd, store x in z for now.\n z := x\n }\n\n // Shifting right by 1 is like dividing by 2.\n let half := shr(1, scalar)\n\n for {\n // Shift n right by 1 before looping to halve it.\n n := shr(1, n)\n } n {\n // Shift n right by 1 each iteration to halve it.\n n := shr(1, n)\n } {\n // Revert immediately if x ** 2 would overflow.\n // Equivalent to iszero(eq(div(xx, x), x)) here.\n if shr(128, x) {\n revert(0, 0)\n }\n\n // Store x squared.\n let xx := mul(x, x)\n\n // Round to the nearest number.\n let xxRound := add(xx, half)\n\n // Revert if xx + half overflowed.\n if lt(xxRound, xx) {\n revert(0, 0)\n }\n\n // Set x to scaled xxRound.\n x := div(xxRound, scalar)\n\n // If n is even:\n if mod(n, 2) {\n // Compute z * x.\n let zx := mul(z, x)\n\n // If z * x overflowed:\n if iszero(eq(div(zx, x), z)) {\n // Revert if x is non-zero.\n if iszero(iszero(x)) {\n revert(0, 0)\n }\n }\n\n // Round to the nearest number.\n let zxRound := add(zx, half)\n\n // Revert if zx + half overflowed.\n if lt(zxRound, zx) {\n revert(0, 0)\n }\n\n // Return properly scaled zxRound.\n z := div(zxRound, scalar)\n }\n }\n }\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n GENERAL NUMBER UTILITIES\n //////////////////////////////////////////////////////////////*/\n\n function sqrt(uint256 x) internal pure returns (uint256 z) {\n assembly {\n // Start off with z at 1.\n z := 1\n\n // Used below to help find a nearby power of 2.\n let y := x\n\n // Find the lowest power of 2 that is at least sqrt(x).\n if iszero(lt(y, 0x100000000000000000000000000000000)) {\n y := shr(128, y) // Like dividing by 2 ** 128.\n z := shl(64, z) // Like multiplying by 2 ** 64.\n }\n if iszero(lt(y, 0x10000000000000000)) {\n y := shr(64, y) // Like dividing by 2 ** 64.\n z := shl(32, z) // Like multiplying by 2 ** 32.\n }\n if iszero(lt(y, 0x100000000)) {\n y := shr(32, y) // Like dividing by 2 ** 32.\n z := shl(16, z) // Like multiplying by 2 ** 16.\n }\n if iszero(lt(y, 0x10000)) {\n y := shr(16, y) // Like dividing by 2 ** 16.\n z := shl(8, z) // Like multiplying by 2 ** 8.\n }\n if iszero(lt(y, 0x100)) {\n y := shr(8, y) // Like dividing by 2 ** 8.\n z := shl(4, z) // Like multiplying by 2 ** 4.\n }\n if iszero(lt(y, 0x10)) {\n y := shr(4, y) // Like dividing by 2 ** 4.\n z := shl(2, z) // Like multiplying by 2 ** 2.\n }\n if iszero(lt(y, 0x8)) {\n // Equivalent to 2 ** z.\n z := shl(1, z)\n }\n\n // Shifting right by 1 is like dividing by 2.\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n\n // Compute a rounded down version of z.\n let zRoundDown := div(x, z)\n\n // If zRoundDown is smaller, use it.\n if lt(zRoundDown, z) {\n z := zRoundDown\n }\n }\n }\n}\n"
},
"src/render.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n// render.sol -- DSSToken render module\n\n// Copyright (C) 2022 Horsefacts <[email protected]>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\npragma solidity ^0.8.15;\n\nimport {svg} from \"hot-chain-svg/SVG.sol\";\nimport {utils} from \"hot-chain-svg/Utils.sol\";\nimport {Base64} from \"openzeppelin-contracts/contracts/utils/Base64.sol\";\nimport {Strings} from \"openzeppelin-contracts/contracts/utils/Strings.sol\";\n\nimport {Inc} from \"./token.sol\";\n\nlibrary DataURI {\n function toDataURI(string memory data, string memory mimeType)\n internal\n pure\n returns (string memory)\n {\n return string.concat(\n \"data:\", mimeType, \";base64,\", Base64.encode(abi.encodePacked(data))\n );\n }\n}\n\nlibrary Render {\n function json(uint256 _tokenId, string memory _svg, Inc memory _count)\n internal\n pure\n returns (string memory)\n {\n return string.concat(\n '{\"name\": \"CounterDAO',\n \" #\",\n utils.uint2str(_tokenId),\n '\", \"description\": \"I frobbed an inc and all I got was this lousy dss-token\", \"image\": \"',\n _svg,\n '\", \"attributes\": ',\n attributes(_count),\n '}'\n );\n }\n\n function attributes(Inc memory inc) internal pure returns (string memory) {\n return string.concat(\n \"[\",\n attribute(\"net\", inc.net),\n \",\",\n attribute(\"tab\", inc.tab),\n \",\",\n attribute(\"tax\", inc.tax),\n \",\",\n attribute(\"num\", inc.num),\n \",\",\n attribute(\"hop\", inc.hop),\n \"]\"\n );\n }\n\n function attribute(string memory name, uint256 value)\n internal\n pure\n returns (string memory)\n {\n return string.concat(\n '{\"trait_type\": \"',\n name,\n '\", \"value\": \"',\n utils.uint2str(value),\n '\", \"display_type\": \"number\"}'\n );\n }\n\n function image(\n uint256 _tokenId,\n uint256 _supply,\n Inc memory _count,\n Inc memory _price\n )\n internal\n pure\n returns (string memory)\n {\n return string.concat(\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 300 300\" style=\"background:#7CC3B3;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;\">',\n svg.el(\n \"path\",\n string.concat(\n svg.prop(\"id\", \"top\"),\n svg.prop(\n \"d\",\n \"M 10 10 H 280 a10,10 0 0 1 10,10 V 280 a10,10 0 0 1 -10,10 H 20 a10,10 0 0 1 -10,-10 V 10 z\"\n ),\n svg.prop(\"fill\", \"#7CC3B3\")\n ),\n \"\"\n ),\n svg.el(\n \"path\",\n string.concat(\n svg.prop(\"id\", \"bottom\"),\n svg.prop(\n \"d\",\n \"M 290 290 H 20 a10,10 0 0 1 -10,-10 V 20 a10,10 0 0 1 10,-10 H 280 a10,10 0 0 1 10,10 V 290 z\"\n ),\n svg.prop(\"fill\", \"#7CC3B3\")\n ),\n \"\"\n ),\n svg.text(\n string.concat(\n svg.prop(\"dominant-baseline\", \"middle\"),\n svg.prop(\"font-family\", \"Menlo, monospace\"),\n svg.prop(\"font-size\", \"9\"),\n svg.prop(\"fill\", \"white\")\n ),\n string.concat(\n svg.el(\n \"textPath\",\n string.concat(svg.prop(\"href\", \"#top\")),\n string.concat(\n formatInc(_count),\n svg.el(\n \"animate\",\n string.concat(\n svg.prop(\"attributeName\", \"startOffset\"),\n svg.prop(\"from\", \"0%\"),\n svg.prop(\"to\", \"100%\"),\n svg.prop(\"dur\", \"120s\"),\n svg.prop(\"begin\", \"0s\"),\n svg.prop(\"repeatCount\", \"indefinite\")\n ),\n \"\"\n )\n )\n )\n )\n ),\n svg.text(\n string.concat(\n svg.prop(\"x\", \"50%\"),\n svg.prop(\"y\", \"45%\"),\n svg.prop(\"text-anchor\", \"middle\"),\n svg.prop(\"dominant-baseline\", \"middle\"),\n svg.prop(\"font-size\", \"150\"),\n svg.prop(\"font-weight\", \"bold\"),\n svg.prop(\"fill\", \"white\")\n ),\n string.concat(svg.cdata(\"++\"))\n ),\n svg.text(\n string.concat(\n svg.prop(\"x\", \"50%\"),\n svg.prop(\"y\", \"70%\"),\n svg.prop(\"text-anchor\", \"middle\"),\n svg.prop(\"font-size\", \"20\"),\n svg.prop(\"fill\", \"white\")\n ),\n string.concat(utils.uint2str(_tokenId), \" / \", utils.uint2str(_supply))\n ),\n svg.text(\n string.concat(\n svg.prop(\"x\", \"50%\"),\n svg.prop(\"y\", \"80%\"),\n svg.prop(\"text-anchor\", \"middle\"),\n svg.prop(\"font-size\", \"20\"),\n svg.prop(\"fill\", \"white\")\n ),\n utils.uint2str(_count.net)\n ),\n svg.text(\n string.concat(\n svg.prop(\"dominant-baseline\", \"middle\"),\n svg.prop(\"font-family\", \"Menlo, monospace\"),\n svg.prop(\"font-size\", \"9\"),\n svg.prop(\"fill\", \"white\")\n ),\n string.concat(\n svg.el(\n \"textPath\",\n string.concat(svg.prop(\"href\", \"#bottom\")),\n string.concat(\n formatInc(_price),\n svg.el(\n \"animate\",\n string.concat(\n svg.prop(\"attributeName\", \"startOffset\"),\n svg.prop(\"from\", \"0%\"),\n svg.prop(\"to\", \"100%\"),\n svg.prop(\"dur\", \"120s\"),\n svg.prop(\"begin\", \"0s\"),\n svg.prop(\"repeatCount\", \"indefinite\")\n ),\n \"\"\n )\n )\n )\n )\n ),\n \"</svg>\"\n );\n }\n\n function formatInc(Inc memory inc) internal pure returns (string memory) {\n return svg.cdata(\n string.concat(\n \"Inc \",\n Strings.toHexString(uint160(inc.guy), 20),\n \" | net: \",\n utils.uint2str(inc.net),\n \" | tab: \",\n utils.uint2str(inc.tab),\n \" | tax: \",\n utils.uint2str(inc.tax),\n \" | num: \",\n utils.uint2str(inc.num),\n \" | hop: \",\n utils.uint2str(inc.hop)\n )\n );\n }\n}\n"
},
"lib/dss/src/proxy/proxy.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-or-later\n\n/// proxy.sol -- Execute DSS actions through the proxy's identity\n\n// Copyright (C) 2022 Horsefacts <[email protected]>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\npragma solidity ^0.8.15;\n\nimport {DSAuth} from \"ds-auth/auth.sol\";\nimport {DSNote} from \"ds-note/note.sol\";\n\ncontract DSSProxy is DSAuth, DSNote {\n // --- Data ---\n address public dss;\n\n // --- Auth ---\n mapping (address => uint) public wards;\n function rely(address usr) external auth note { wards[usr] = 1; }\n function deny(address usr) external auth note { wards[usr] = 0; }\n modifier ward {\n require(wards[msg.sender] == 1, \"DSSProxy/not-authorized\");\n require(msg.sender != owner, \"DSSProxy/owner-not-ward\");\n _;\n }\n\n // --- Init ---\n constructor(address dss_, address usr, address god) {\n dss = dss_;\n wards[usr] = 1;\n setOwner(god);\n }\n\n // --- Upgrade ---\n function upgrade(address dss_) external auth note {\n dss = dss_;\n }\n\n // --- Proxy ---\n fallback() external ward note {\n address _dss = dss;\n assembly {\n calldatacopy(0, 0, calldatasize())\n let result := delegatecall(gas(), _dss, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n"
},
"lib/hot-chain-svg/contracts/SVG.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\nimport './Utils.sol';\n\n// Core SVG utilitiy library which helps us construct\n// onchain SVG's with a simple, web-like API.\nlibrary svg {\n /* MAIN ELEMENTS */\n function g(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('g', _props, _children);\n }\n\n function path(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('path', _props, _children);\n }\n\n function text(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('text', _props, _children);\n }\n\n function line(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('line', _props, _children);\n }\n\n function circle(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('circle', _props, _children);\n }\n\n function circle(string memory _props)\n internal\n pure\n returns (string memory)\n {\n return el('circle', _props);\n }\n\n function rect(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('rect', _props, _children);\n }\n\n function rect(string memory _props)\n internal\n pure\n returns (string memory)\n {\n return el('rect', _props);\n }\n\n function filter(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('filter', _props, _children);\n }\n\n function cdata(string memory _content)\n internal\n pure\n returns (string memory)\n {\n return string.concat('<![CDATA[', _content, ']]>');\n }\n\n /* GRADIENTS */\n function radialGradient(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('radialGradient', _props, _children);\n }\n\n function linearGradient(string memory _props, string memory _children)\n internal\n pure\n returns (string memory)\n {\n return el('linearGradient', _props, _children);\n }\n\n function gradientStop(\n uint256 offset,\n string memory stopColor,\n string memory _props\n ) internal pure returns (string memory) {\n return\n el(\n 'stop',\n string.concat(\n prop('stop-color', stopColor),\n ' ',\n prop('offset', string.concat(utils.uint2str(offset), '%')),\n ' ',\n _props\n )\n );\n }\n\n function animateTransform(string memory _props)\n internal\n pure\n returns (string memory)\n {\n return el('animateTransform', _props);\n }\n\n function image(string memory _href, string memory _props)\n internal\n pure\n returns (string memory)\n {\n return\n el(\n 'image',\n string.concat(prop('href', _href), ' ', _props)\n );\n }\n\n /* COMMON */\n // A generic element, can be used to construct any SVG (or HTML) element\n function el(\n string memory _tag,\n string memory _props,\n string memory _children\n ) internal pure returns (string memory) {\n return\n string.concat(\n '<',\n _tag,\n ' ',\n _props,\n '>',\n _children,\n '</',\n _tag,\n '>'\n );\n }\n\n // A generic element, can be used to construct any SVG (or HTML) element without children\n function el(\n string memory _tag,\n string memory _props\n ) internal pure returns (string memory) {\n return\n string.concat(\n '<',\n _tag,\n ' ',\n _props,\n '/>'\n );\n }\n\n // an SVG attribute\n function prop(string memory _key, string memory _val)\n internal\n pure\n returns (string memory)\n {\n return string.concat(_key, '=', '\"', _val, '\" ');\n }\n}\n"
},
"lib/hot-chain-svg/contracts/Utils.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\n// Core utils used extensively to format CSS and numbers.\nlibrary utils {\n // used to simulate empty strings\n string internal constant NULL = '';\n\n // formats a CSS variable line. includes a semicolon for formatting.\n function setCssVar(string memory _key, string memory _val)\n internal\n pure\n returns (string memory)\n {\n return string.concat('--', _key, ':', _val, ';');\n }\n\n // formats getting a css variable\n function getCssVar(string memory _key)\n internal\n pure\n returns (string memory)\n {\n return string.concat('var(--', _key, ')');\n }\n\n // formats getting a def URL\n function getDefURL(string memory _id)\n internal\n pure\n returns (string memory)\n {\n return string.concat('url(#', _id, ')');\n }\n\n // formats rgba white with a specified opacity / alpha\n function white_a(uint256 _a) internal pure returns (string memory) {\n return rgba(255, 255, 255, _a);\n }\n\n // formats rgba black with a specified opacity / alpha\n function black_a(uint256 _a) internal pure returns (string memory) {\n return rgba(0, 0, 0, _a);\n }\n\n // formats generic rgba color in css\n function rgba(\n uint256 _r,\n uint256 _g,\n uint256 _b,\n uint256 _a\n ) internal pure returns (string memory) {\n string memory formattedA = _a < 100\n ? string.concat('0.', utils.uint2str(_a))\n : '1';\n return\n string.concat(\n 'rgba(',\n utils.uint2str(_r),\n ',',\n utils.uint2str(_g),\n ',',\n utils.uint2str(_b),\n ',',\n formattedA,\n ')'\n );\n }\n\n // checks if two strings are equal\n function stringsEqual(string memory _a, string memory _b)\n internal\n pure\n returns (bool)\n {\n return\n keccak256(abi.encodePacked(_a)) == keccak256(abi.encodePacked(_b));\n }\n\n // returns the length of a string in characters\n function utfStringLength(string memory _str)\n internal\n pure\n returns (uint256 length)\n {\n uint256 i = 0;\n bytes memory string_rep = bytes(_str);\n\n while (i < string_rep.length) {\n if (string_rep[i] >> 7 == 0) i += 1;\n else if (string_rep[i] >> 5 == bytes1(uint8(0x6))) i += 2;\n else if (string_rep[i] >> 4 == bytes1(uint8(0xE))) i += 3;\n else if (string_rep[i] >> 3 == bytes1(uint8(0x1E)))\n i += 4;\n //For safety\n else i += 1;\n\n length++;\n }\n }\n\n // converts an unsigned integer to a string\n function uint2str(uint256 _i)\n internal\n pure\n returns (string memory _uintAsString)\n {\n if (_i == 0) {\n return '0';\n }\n uint256 j = _i;\n uint256 len;\n while (j != 0) {\n len++;\n j /= 10;\n }\n bytes memory bstr = new bytes(len);\n uint256 k = len;\n while (_i != 0) {\n k = k - 1;\n uint8 temp = (48 + uint8(_i - (_i / 10) * 10));\n bytes1 b1 = bytes1(temp);\n bstr[k] = b1;\n _i /= 10;\n }\n return string(bstr);\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\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's 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 }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes 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` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"lib/dss/lib/ds-auth/src/auth.sol": {
"content": "// SPDX-License-Identifier: GNU-3\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >=0.4.23;\n\ninterface DSAuthority {\n function canCall(\n address src, address dst, bytes4 sig\n ) external view returns (bool);\n}\n\ncontract DSAuthEvents {\n event LogSetAuthority (address indexed authority);\n event LogSetOwner (address indexed owner);\n}\n\ncontract DSAuth is DSAuthEvents {\n DSAuthority public authority;\n address public owner;\n\n constructor() public {\n owner = msg.sender;\n emit LogSetOwner(msg.sender);\n }\n\n function setOwner(address owner_)\n public\n auth\n {\n owner = owner_;\n emit LogSetOwner(owner);\n }\n\n function setAuthority(DSAuthority authority_)\n public\n auth\n {\n authority = authority_;\n emit LogSetAuthority(address(authority));\n }\n\n modifier auth {\n require(isAuthorized(msg.sender, msg.sig), \"ds-auth-unauthorized\");\n _;\n }\n\n function isAuthorized(address src, bytes4 sig) internal view returns (bool) {\n if (src == address(this)) {\n return true;\n } else if (src == owner) {\n return true;\n } else if (authority == DSAuthority(address(0))) {\n return false;\n } else {\n return authority.canCall(src, address(this), sig);\n }\n }\n}\n"
}
},
"settings": {
"remappings": [
"@openzeppelin/=lib/hot-chain-svg/node_modules/@openzeppelin/contracts/",
"ds-auth/=lib/dss/lib/ds-auth/src/",
"ds-chief/=lib/dss/lib/ds-chief/src/",
"ds-math/=lib/dss/lib/ds-token/lib/ds-math/src/",
"ds-note/=lib/ds-note/src/",
"ds-pause/=lib/dss/lib/ds-pause/src/",
"ds-roles/=lib/dss/lib/ds-chief/lib/ds-roles/src/",
"ds-test/=lib/dss/lib/ds-test/src/",
"ds-thing/=lib/dss/lib/ds-chief/lib/ds-thing/src/",
"ds-token/=lib/dss/lib/ds-token/src/",
"dss/=lib/dss/src/",
"forge-std/=lib/forge-std/src/",
"hot-chain-svg/=lib/hot-chain-svg/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"script/=script/",
"solmate/=lib/solmate/src/",
"src/=src/",
"test/=test/",
"src/=src/",
"test/=test/",
"script/=script/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}