├── .gitattributes ├── deps ├── @openzeppelin │ ├── upgrades │ │ ├── .npmignore │ │ ├── README.adoc │ │ ├── application │ │ │ └── ImplementationProvider.sol │ │ ├── upgradeability │ │ │ ├── UpgradeabilityProxy.sol │ │ │ ├── AdminUpgradeabilityProxy.sol │ │ │ ├── InitializableUpgradeabilityProxy.sol │ │ │ ├── InitializableAdminUpgradeabilityProxy.sol │ │ │ ├── BaseUpgradeabilityProxy.sol │ │ │ └── Proxy.sol │ │ ├── utils │ │ │ └── Address.sol │ │ └── Initializable.sol │ ├── contracts │ │ ├── math │ │ │ ├── README.adoc │ │ │ └── Math.sol │ │ ├── access │ │ │ ├── README.adoc │ │ │ └── Ownable.sol │ │ ├── cryptography │ │ │ ├── README.adoc │ │ │ └── MerkleProof.sol │ │ ├── token │ │ │ ├── ERC1155 │ │ │ │ ├── ERC1155Receiver.sol │ │ │ │ ├── IERC1155MetadataURI.sol │ │ │ │ ├── ERC1155Holder.sol │ │ │ │ ├── ERC1155Burnable.sol │ │ │ │ ├── ERC1155Pausable.sol │ │ │ │ ├── README.adoc │ │ │ │ └── IERC1155Receiver.sol │ │ │ ├── ERC777 │ │ │ │ ├── README.adoc │ │ │ │ ├── IERC777Recipient.sol │ │ │ │ └── IERC777Sender.sol │ │ │ ├── ERC721 │ │ │ │ ├── IERC721Metadata.sol │ │ │ │ ├── ERC721Holder.sol │ │ │ │ ├── ERC721Burnable.sol │ │ │ │ ├── ERC721Pausable.sol │ │ │ │ ├── IERC721Receiver.sol │ │ │ │ ├── IERC721Enumerable.sol │ │ │ │ └── README.adoc │ │ │ └── ERC20 │ │ │ │ ├── ERC20Pausable.sol │ │ │ │ ├── ERC20Burnable.sol │ │ │ │ ├── ERC20Capped.sol │ │ │ │ ├── README.adoc │ │ │ │ └── TokenTimelock.sol │ │ ├── presets │ │ │ └── README.adoc │ │ ├── introspection │ │ │ ├── IERC1820Implementer.sol │ │ │ ├── IERC165.sol │ │ │ ├── ERC1820Implementer.sol │ │ │ ├── README.adoc │ │ │ └── ERC165.sol │ │ ├── payment │ │ │ ├── README.adoc │ │ │ ├── escrow │ │ │ │ ├── ConditionalEscrow.sol │ │ │ │ └── Escrow.sol │ │ │ └── PullPayment.sol │ │ ├── GSN │ │ │ ├── Context.sol │ │ │ └── README.adoc │ │ ├── utils │ │ │ ├── Strings.sol │ │ │ ├── Counters.sol │ │ │ ├── Arrays.sol │ │ │ ├── README.adoc │ │ │ ├── Pausable.sol │ │ │ ├── ReentrancyGuard.sol │ │ │ └── Create2.sol │ │ ├── proxy │ │ │ ├── README.adoc │ │ │ └── Initializable.sol │ │ └── package.json │ └── contracts-upgradeable │ │ ├── math │ │ ├── README.adoc │ │ └── MathUpgradeable.sol │ │ ├── access │ │ └── README.adoc │ │ ├── cryptography │ │ ├── README.adoc │ │ └── MerkleProofUpgradeable.sol │ │ ├── token │ │ ├── ERC1155 │ │ │ ├── IERC1155MetadataURIUpgradeable.sol │ │ │ ├── ERC1155ReceiverUpgradeable.sol │ │ │ ├── ERC1155HolderUpgradeable.sol │ │ │ ├── ERC1155BurnableUpgradeable.sol │ │ │ ├── README.adoc │ │ │ ├── ERC1155PausableUpgradeable.sol │ │ │ └── IERC1155ReceiverUpgradeable.sol │ │ ├── ERC777 │ │ │ ├── README.adoc │ │ │ ├── IERC777RecipientUpgradeable.sol │ │ │ └── IERC777SenderUpgradeable.sol │ │ ├── ERC721 │ │ │ ├── IERC721MetadataUpgradeable.sol │ │ │ ├── IERC721ReceiverUpgradeable.sol │ │ │ ├── IERC721EnumerableUpgradeable.sol │ │ │ ├── ERC721HolderUpgradeable.sol │ │ │ ├── ERC721BurnableUpgradeable.sol │ │ │ ├── ERC721PausableUpgradeable.sol │ │ │ └── README.adoc │ │ └── ERC20 │ │ │ ├── ERC20PausableUpgradeable.sol │ │ │ ├── ERC20CappedUpgradeable.sol │ │ │ ├── ERC20BurnableUpgradeable.sol │ │ │ ├── README.adoc │ │ │ └── TokenTimelockUpgradeable.sol │ │ ├── presets │ │ └── README.adoc │ │ ├── introspection │ │ ├── IERC1820ImplementerUpgradeable.sol │ │ ├── IERC165Upgradeable.sol │ │ ├── README.adoc │ │ ├── ERC1820ImplementerUpgradeable.sol │ │ └── ERC165Upgradeable.sol │ │ ├── payment │ │ ├── README.adoc │ │ └── escrow │ │ │ └── ConditionalEscrowUpgradeable.sol │ │ ├── utils │ │ ├── StringsUpgradeable.sol │ │ ├── CountersUpgradeable.sol │ │ ├── ArraysUpgradeable.sol │ │ ├── README.adoc │ │ └── PausableUpgradeable.sol │ │ ├── GSN │ │ ├── ContextUpgradeable.sol │ │ └── README.adoc │ │ ├── proxy │ │ ├── README.adoc │ │ └── Initializable.sol │ │ └── package.json ├── SettAccessControlDefended.sol └── SettAccessControl.sol ├── helpers ├── time.py ├── constants.py ├── multicall │ ├── __init__.py │ ├── constants.py │ ├── multicall.py │ ├── call.py │ ├── signature.py │ └── functions.py ├── utils.py └── snapshot │ └── snap.py ├── brownie_hooks.py ├── commitlint.config.js ├── .env.example ├── requirements.txt ├── .gitignore ├── interfaces ├── badger │ ├── IPing.sol │ ├── IDefender.sol │ ├── IOwnable.sol │ ├── IUnifiedLogger.sol │ ├── IMintr.sol │ ├── IPausable.sol │ ├── IConverter.sol │ ├── IAddressWhitelist.sol │ ├── ISettAccessControlDefended.sol │ ├── ISimpleTimelockWithVoting.sol │ ├── IMerkleAddressWhitelist.sol │ ├── IToken.sol │ ├── IController.sol │ ├── IBadgerERC1155.sol │ ├── IBadgerGeyser.sol │ ├── IStakingRewardsSignalOnly.sol │ ├── IMerkleDistributor.sol │ ├── IOneSplitAudit.sol │ ├── ISett.sol │ ├── ISwapStrategyRouter.sol │ ├── IMiniMe.sol │ ├── ICumulativeMultiTokenMerkleDistributor.sol │ ├── IStrategy.sol │ └── IBadgerTreeV2.sol ├── yearn │ ├── GuestlistApi.sol │ ├── BadgerGuestlistApi.sol │ └── BadgerWrapperApi.sol ├── erc20 │ ├── WETH.sol │ ├── IWETH.sol │ └── USDT.sol └── uniswap │ ├── IUniswapPair.sol │ ├── IStakingRewards.sol │ ├── IUniswapV2Factory.sol │ └── IUniswapFactory.sol ├── brownie-config.yml ├── tests ├── test_custom.py ├── examples │ ├── test_basic.py │ └── test_are_you_trying.py └── test_profitable.py ├── package.json ├── config ├── __init__.py └── StrategyResolver.py ├── contracts └── deps │ └── MockToken.sol ├── .github └── workflows │ ├── test.yaml │ └── lint.yaml └── scripts └── 4_production_wireup.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.vy linguist-language=Python 2 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/.npmignore: -------------------------------------------------------------------------------- 1 | mocks 2 | -------------------------------------------------------------------------------- /helpers/time.py: -------------------------------------------------------------------------------- 1 | def days(days): 2 | return int(days * 86400.0) 3 | -------------------------------------------------------------------------------- /brownie_hooks.py: -------------------------------------------------------------------------------- 1 | from dotenv import load_dotenv 2 | 3 | load_dotenv() 4 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: ["@commitlint/config-conventional"] }; 2 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | ETHERSCAN_TOKEN= 2 | WEB3_INFURA_PROJECT_ID= 3 | 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | black==21.8b0 2 | eth-brownie>=1.11.0,<2.0.0 3 | dotmap==1.3.24 4 | python-dotenv==0.16.0 5 | tabulate==0.8.9 6 | rich==10.7.0 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Brownie 2 | __pycache__ 3 | .history 4 | .hypothesis/ 5 | build/ 6 | reports/ 7 | .env 8 | venv/ 9 | cache/ 10 | artifacts/ 11 | 12 | # Node/npm 13 | node_modules/ 14 | -------------------------------------------------------------------------------- /interfaces/badger/IPing.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IPing { 5 | function ping() external pure returns (uint256); 6 | } 7 | -------------------------------------------------------------------------------- /interfaces/badger/IDefender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IDefender { 5 | function isAllowed(address) external returns (bool); 6 | } 7 | -------------------------------------------------------------------------------- /interfaces/badger/IOwnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IOwnable { 5 | function transferOwnership(address newOwner) external; 6 | } 7 | -------------------------------------------------------------------------------- /helpers/constants.py: -------------------------------------------------------------------------------- 1 | AddressZero = "0x0000000000000000000000000000000000000000" 2 | MaxUint256 = str(int(2 ** 256 - 1)) 3 | EmptyBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000" 4 | -------------------------------------------------------------------------------- /interfaces/badger/IUnifiedLogger.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IUnifiedLogger { 5 | function batchLogs(bytes memory logs) external; 6 | } 7 | -------------------------------------------------------------------------------- /interfaces/badger/IMintr.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | interface IMintr { 7 | function mint(address) external; 8 | } 9 | -------------------------------------------------------------------------------- /interfaces/badger/IPausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IPausable { 5 | function pause() external; 6 | 7 | function unpause() external; 8 | } 9 | -------------------------------------------------------------------------------- /interfaces/badger/IConverter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | interface IConverter { 7 | function convert(address) external returns (uint256); 8 | } 9 | -------------------------------------------------------------------------------- /interfaces/yearn/GuestlistApi.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.0 <0.7.0; 3 | 4 | interface GuestListAPI { 5 | function authorized(address guest, uint256 amount) 6 | external 7 | view 8 | returns (bool); 9 | } 10 | -------------------------------------------------------------------------------- /interfaces/badger/IAddressWhitelist.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.0; 3 | 4 | // Generic address whitelist. 5 | interface IAddressWhitelist { 6 | // Checks if address exists in whitelist. 7 | function exists(address addr) external returns (bool); 8 | } 9 | -------------------------------------------------------------------------------- /interfaces/badger/ISettAccessControlDefended.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.11; 3 | 4 | interface ISettAccessControlDefended { 5 | function approveContractAccess(address account) external; 6 | 7 | function revokeContractAccess(address account) external; 8 | } 9 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/math/README.adoc: -------------------------------------------------------------------------------- 1 | = Math 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/math 5 | 6 | These are math-related utilities. 7 | 8 | == Libraries 9 | 10 | {{SafeMath}} 11 | 12 | {{SignedSafeMath}} 13 | 14 | {{Math}} 15 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/math/README.adoc: -------------------------------------------------------------------------------- 1 | = Math 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/math 5 | 6 | These are math-related utilities. 7 | 8 | == Libraries 9 | 10 | {{SafeMath}} 11 | 12 | {{SignedSafeMath}} 13 | 14 | {{Math}} 15 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/access/README.adoc: -------------------------------------------------------------------------------- 1 | = Access 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/access 5 | 6 | Contract modules for authorization and access control mechanisms. 7 | 8 | == Contracts 9 | 10 | {{Ownable}} 11 | 12 | {{AccessControl}} 13 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/access/README.adoc: -------------------------------------------------------------------------------- 1 | = Access 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/access 5 | 6 | Contract modules for authorization and access control mechanisms. 7 | 8 | == Contracts 9 | 10 | {{Ownable}} 11 | 12 | {{AccessControl}} 13 | -------------------------------------------------------------------------------- /interfaces/erc20/WETH.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface WETH { 5 | function deposit() external payable; 6 | 7 | function withdraw(uint256 wad) external; 8 | 9 | event Deposit(address indexed dst, uint256 wad); 10 | event Withdrawal(address indexed src, uint256 wad); 11 | } 12 | -------------------------------------------------------------------------------- /interfaces/erc20/IWETH.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IWETH { 5 | function deposit() external payable; 6 | 7 | function withdraw(uint256 wad) external; 8 | 9 | event Deposit(address indexed dst, uint256 wad); 10 | event Withdrawal(address indexed src, uint256 wad); 11 | } 12 | -------------------------------------------------------------------------------- /interfaces/erc20/USDT.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | // https://forum.openzeppelin.com/t/can-not-call-the-function-approve-of-the-usdt-contract/2130/2 5 | interface USDT { 6 | function approve(address guy, uint256 wad) external; 7 | 8 | function transfer(address _to, uint256 _value) external; 9 | } 10 | -------------------------------------------------------------------------------- /interfaces/badger/ISimpleTimelockWithVoting.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface ISimpleTimelockWithVoting { 5 | function release() external; 6 | 7 | function vote( 8 | uint256 _voteId, 9 | bool _supports, 10 | bool _executesIfDecided 11 | ) external payable; 12 | } 13 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/cryptography/README.adoc: -------------------------------------------------------------------------------- 1 | = Cryptography 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/cryptography 5 | 6 | This collection of libraries provides simple and safe ways to use different cryptographic primitives. 7 | 8 | == Libraries 9 | 10 | {{ECDSA}} 11 | 12 | {{MerkleProof}} 13 | -------------------------------------------------------------------------------- /interfaces/badger/IMerkleAddressWhitelist.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.0; 3 | 4 | // Generic address whitelist impl as a merkle tree. 5 | interface IMerkleAddressWhitelist { 6 | // Checks if address exists in whitelist. 7 | function exists(address addr, bytes32[] calldata merkleProof) 8 | external 9 | returns (bool); 10 | } 11 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/cryptography/README.adoc: -------------------------------------------------------------------------------- 1 | = Cryptography 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/cryptography 5 | 6 | This collection of libraries provides simple and safe ways to use different cryptographic primitives. 7 | 8 | == Libraries 9 | 10 | {{ECDSA}} 11 | 12 | {{MerkleProof}} 13 | -------------------------------------------------------------------------------- /helpers/multicall/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Inlined version of bantegs' multicall.py for brownie compatibility 3 | https://github.com/banteg/multicall.py 4 | """ 5 | __version__ = "0.1.1" 6 | 7 | from helpers.multicall.signature import Signature 8 | from helpers.multicall.call import Call 9 | from helpers.multicall.multicall import Multicall 10 | from helpers.multicall.functions import func, as_wei 11 | -------------------------------------------------------------------------------- /interfaces/badger/IToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | // NOTE: Basically an alias for Vaults 7 | interface IbERC20 { 8 | function deposit(uint256 _amount) external; 9 | 10 | function withdraw(uint256 _amount) external; 11 | 12 | function getPricePerFullShare() external view returns (uint256); 13 | } 14 | -------------------------------------------------------------------------------- /brownie-config.yml: -------------------------------------------------------------------------------- 1 | # use Ganache's forked mainnet mode as the default network 2 | # NOTE: You don't *have* to do this, but it is often helpful for testing 3 | networks: 4 | default: mainnet-fork 5 | 6 | # automatically fetch contract sources from Etherscan 7 | autofetch_sources: True 8 | 9 | # path remapping to support imports from GitHub/NPM 10 | compiler: 11 | solc: 12 | version: 0.6.12 13 | 14 | reports: 15 | -------------------------------------------------------------------------------- /interfaces/yearn/BadgerGuestlistApi.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.0 <0.7.0; 3 | 4 | interface BadgerGuestListAPI { 5 | function authorized( 6 | address guest, 7 | uint256 amount, 8 | bytes32[] calldata merkleProof 9 | ) external view returns (bool); 10 | 11 | function setGuests(address[] calldata _guests, bool[] calldata _invited) 12 | external; 13 | } 14 | -------------------------------------------------------------------------------- /tests/test_custom.py: -------------------------------------------------------------------------------- 1 | import brownie 2 | from brownie import * 3 | from helpers.constants import MaxUint256 4 | from helpers.SnapshotManager import SnapshotManager 5 | from helpers.time import days 6 | 7 | """ 8 | TODO: Put your tests here to prove the strat is good! 9 | See test_harvest_flow, for the basic tests 10 | See test_strategy_permissions, for tests at the permissions level 11 | """ 12 | 13 | 14 | def test_my_custom_test(deployed): 15 | assert False 16 | -------------------------------------------------------------------------------- /interfaces/uniswap/IUniswapPair.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.0; 3 | 4 | interface IUniswapPair { 5 | function token0() external view returns (address); 6 | 7 | function token1() external view returns (address); 8 | 9 | function getReserves() 10 | external 11 | view 12 | returns ( 13 | uint112 reserve0, 14 | uint112 reserve1, 15 | uint32 blockTimestampLast 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/ERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC1155Receiver.sol"; 6 | import "../../introspection/ERC165.sol"; 7 | 8 | /** 9 | * @dev _Available since v3.1._ 10 | */ 11 | abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { 12 | constructor() public { 13 | _registerInterface( 14 | ERC1155Receiver(0).onERC1155Received.selector ^ 15 | ERC1155Receiver(0).onERC1155BatchReceived.selector 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/README.adoc: -------------------------------------------------------------------------------- 1 | = API Reference 2 | 3 | == Proxies 4 | 5 | {{Proxy}} 6 | 7 | {{UpgradeabilityProxy}} 8 | 9 | {{AdminUpgradeabilityProxy}} 10 | 11 | {{BaseAdminUpgradeabilityProxy}} 12 | 13 | {{BaseUpgradeabilityProxy}} 14 | 15 | {{InitializableAdminUpgradeabilityProxy}} 16 | 17 | {{InitializableUpgradeabilityProxy}} 18 | 19 | {{ProxyAdmin}} 20 | 21 | {{ProxyFactory}} 22 | 23 | == Application 24 | 25 | {{App}} 26 | 27 | {{ImplementationDirectory}} 28 | 29 | {{ImplementationProvider}} 30 | 31 | {{Package}} 32 | 33 | == Utility 34 | 35 | {{Initializable}} 36 | -------------------------------------------------------------------------------- /interfaces/badger/IController.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IController { 5 | function withdraw(address, uint256) external; 6 | 7 | function strategies(address) external view returns (address); 8 | 9 | function balanceOf(address) external view returns (uint256); 10 | 11 | function earn(address, uint256) external; 12 | 13 | function want(address) external view returns (address); 14 | 15 | function rewards() external view returns (address); 16 | 17 | function vaults(address) external view returns (address); 18 | } 19 | -------------------------------------------------------------------------------- /interfaces/badger/IBadgerERC1155.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IBadgerERC1155 { 5 | function balanceOf(address account, uint256 id) 6 | external 7 | view 8 | returns (uint256); 9 | 10 | function totalSupply(uint256 id) external view returns (uint256); 11 | 12 | function tokenSupply(uint256 id) external view returns (uint256); 13 | 14 | function safeTransferFrom( 15 | address from, 16 | address to, 17 | uint256 id, 18 | uint256 amount, 19 | bytes memory data 20 | ) external; 21 | } 22 | -------------------------------------------------------------------------------- /interfaces/badger/IBadgerGeyser.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | interface IBadgerGeyser { 7 | function stake(address) external returns (uint256); 8 | 9 | function signalTokenLock( 10 | address token, 11 | uint256 amount, 12 | uint256 durationSec, 13 | uint256 startTime 14 | ) external; 15 | 16 | function modifyTokenLock( 17 | address token, 18 | uint256 index, 19 | uint256 amount, 20 | uint256 durationSec, 21 | uint256 startTime 22 | ) external; 23 | } 24 | -------------------------------------------------------------------------------- /interfaces/badger/IStakingRewardsSignalOnly.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IStakingRewardsSignalOnly { 5 | function stakingToken() external view returns (address); 6 | 7 | function rewardsToken() external view returns (address); 8 | 9 | function withdraw(uint256) external; 10 | 11 | function getReward() external; 12 | 13 | function earned(address account) external view returns (uint256); 14 | 15 | function stake(uint256) external; 16 | 17 | function balanceOf(address) external view returns (uint256); 18 | 19 | function exit() external; 20 | } 21 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/application/ImplementationProvider.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | /** 4 | * @title ImplementationProvider 5 | * @dev Abstract contract for providing implementation addresses for other contracts by name. 6 | */ 7 | contract ImplementationProvider { 8 | /** 9 | * @dev Abstract function to return the implementation address of a contract. 10 | * @param contractName Name of the contract. 11 | * @return Implementation address of the contract. 12 | */ 13 | function getImplementation(string memory contractName) 14 | public 15 | view 16 | returns (address); 17 | } 18 | -------------------------------------------------------------------------------- /helpers/utils.py: -------------------------------------------------------------------------------- 1 | # Assert approximate integer 2 | def approx(actual, expected, percentage_threshold): 3 | print(actual, expected, percentage_threshold) 4 | diff = int(abs(actual - expected)) 5 | # 0 diff should automtically be a match 6 | if diff == 0: 7 | return True 8 | return diff < (actual * percentage_threshold // 100) 9 | 10 | 11 | def val(amount=0, decimals=18, token=None): 12 | # return amount 13 | # return "{:,.0f}".format(amount) 14 | # If no token specified, use decimals 15 | if token: 16 | decimals = interface.IERC20(token).decimals() 17 | 18 | return "{:,.18f}".format(amount / 10 ** decimals) 19 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./IERC1155.sol"; 6 | 7 | /** 8 | * @dev Interface of the optional ERC1155MetadataExtension interface, as defined 9 | * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. 10 | * 11 | * _Available since v3.1._ 12 | */ 13 | interface IERC1155MetadataURI is IERC1155 { 14 | /** 15 | * @dev Returns the URI for token type `id`. 16 | * 17 | * If the `\{id\}` substring is present in the URI, it must be replaced by 18 | * clients with the actual token type ID. 19 | */ 20 | function uri(uint256 id) external view returns (string memory); 21 | } 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yearn-protocol", 3 | "devDependencies": { 4 | "@commitlint/cli": "^11.0.0", 5 | "@commitlint/config-conventional": "^11.0.0", 6 | "ethlint": "^1.2.5", 7 | "husky": "^4.3.0", 8 | "prettier": "^2.1.2", 9 | "prettier-plugin-solidity": "^1.0.0-alpha.57", 10 | "pretty-quick": "^3.0.2" 11 | }, 12 | "scripts": { 13 | "lint": "pretty-quick --pattern '**/*.*(sol|json)' --verbose", 14 | "lint:check": "prettier --check **/*.sol **/*.json", 15 | "lint:fix": "pretty-quick --pattern '**/*.*(sol|json)' --staged --verbose" 16 | }, 17 | "husky": { 18 | "hooks": { 19 | "pre-commit": "yarn lint:fix", 20 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /helpers/snapshot/snap.py: -------------------------------------------------------------------------------- 1 | class Snap: 2 | def __init__(self, data, block, entityKeys): 3 | self.data = data 4 | self.block = block 5 | self.entityKeys = entityKeys 6 | 7 | # ===== Getters ===== 8 | 9 | def balances(self, tokenKey, accountKey): 10 | return self.data["balances." + tokenKey + "." + accountKey] 11 | 12 | def shares(self, tokenKey, accountKey): 13 | return self.data["shares." + tokenKey + "." + accountKey] 14 | 15 | def get(self, key): 16 | if key not in self.data.keys(): 17 | raise Exception("Key {} not found in snap data".format(key)) 18 | return self.data[key] 19 | 20 | # ===== Setters ===== 21 | 22 | def set(self, key, value): 23 | self.data[key] = value 24 | -------------------------------------------------------------------------------- /interfaces/badger/IMerkleDistributor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity >=0.5.0; 3 | 4 | // Allows anyone to claim a token if they exist in a merkle root. 5 | interface IMerkleDistributor { 6 | // Returns true if the index has been marked claimed. 7 | function isClaimed(uint256 index) external view returns (bool); 8 | 9 | // Claim the given amount of the token to the given address. Reverts if the inputs are invalid. 10 | function claim( 11 | uint256 index, 12 | address account, 13 | uint256 amount, 14 | bytes32[] calldata merkleProof 15 | ) external; 16 | 17 | // This event is triggered whenever a call to #claim succeeds. 18 | event Claimed(uint256 index, address account, uint256 amount); 19 | } 20 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155MetadataURIUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./IERC1155Upgradeable.sol"; 6 | 7 | /** 8 | * @dev Interface of the optional ERC1155MetadataExtension interface, as defined 9 | * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. 10 | * 11 | * _Available since v3.1._ 12 | */ 13 | interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { 14 | /** 15 | * @dev Returns the URI for token type `id`. 16 | * 17 | * If the `\{id\}` substring is present in the URI, it must be replaced by 18 | * clients with the actual token type ID. 19 | */ 20 | function uri(uint256 id) external view returns (string memory); 21 | } 22 | -------------------------------------------------------------------------------- /interfaces/badger/IOneSplitAudit.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // SPDX-License-Identifier: MIT 3 | pragma solidity >=0.5.0 <0.8.0; 4 | 5 | interface IOneSplitAudit { 6 | function swap( 7 | address fromToken, 8 | address destToken, 9 | uint256 amount, 10 | uint256 minReturn, 11 | uint256[] calldata distribution, 12 | uint256 flags 13 | ) external payable returns (uint256 returnAmount); 14 | 15 | function getExpectedReturn( 16 | address fromToken, 17 | address destToken, 18 | uint256 amount, 19 | uint256 parts, 20 | uint256 flags // See constants in IOneSplit.sol 21 | ) 22 | external 23 | view 24 | returns (uint256 returnAmount, uint256[] memory distribution); 25 | } 26 | -------------------------------------------------------------------------------- /interfaces/uniswap/IStakingRewards.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IStakingRewards { 5 | function stakingToken() external view returns (address); 6 | 7 | function rewardsToken() external view returns (address); 8 | 9 | function withdraw(uint256) external; 10 | 11 | function getReward() external; 12 | 13 | function earned(address account) external view returns (uint256); 14 | 15 | function stake(uint256) external; 16 | 17 | function balanceOf(address) external view returns (uint256); 18 | 19 | function exit() external; 20 | 21 | function notifyRewardAmount(uint256 startTimestamp, uint256 reward) 22 | external; 23 | 24 | function setRewardsDuration(uint256 _rewardsDuration) external; 25 | } 26 | -------------------------------------------------------------------------------- /interfaces/badger/ISett.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface ISett { 5 | function token() external view returns (address); 6 | 7 | function deposit(uint256) external; 8 | 9 | function depositFor(address, uint256) external; 10 | 11 | function depositAll() external; 12 | 13 | function withdraw(uint256) external; 14 | 15 | function withdrawAll() external; 16 | 17 | function earn() external; 18 | 19 | function balanceOf(address account) external view returns (uint256); 20 | 21 | function totalSupply() external view returns (uint256); 22 | 23 | function claimInsurance() external; // NOTE: Only yDelegatedVault implements this 24 | 25 | function getPricePerFullShare() external view returns (uint256); 26 | } 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/presets/README.adoc: -------------------------------------------------------------------------------- 1 | = Presets 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/presets 5 | 6 | These contracts integrate different Ethereum standards (ERCs) with custom extensions and modules, showcasing common configurations that are ready to deploy **without having to write any Solidity code**. 7 | 8 | They can be used as-is for quick prototyping and testing, but are **also suitable for production environments**. 9 | 10 | TIP: Intermediate and advanced users can use these as starting points when writing their own contracts, extending them with custom functionality as they see fit. 11 | 12 | == Tokens 13 | 14 | {{ERC20PresetMinterPauser}} 15 | 16 | {{ERC721PresetMinterPauserAutoId}} 17 | 18 | {{ERC1155PresetMinterPauser}} 19 | -------------------------------------------------------------------------------- /interfaces/yearn/BadgerWrapperApi.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.6.0 <0.7.0; 3 | pragma experimental ABIEncoderV2; 4 | 5 | import "deps/@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | 7 | interface BadgerWrapperAPI is IERC20 { 8 | function name() external view returns (string calldata); 9 | 10 | function symbol() external view returns (string calldata); 11 | 12 | function decimals() external view returns (uint256); 13 | 14 | function token() external view returns (address); 15 | 16 | function pricePerShare() external view returns (uint256); 17 | 18 | function totalWrapperBalance(address account) 19 | external 20 | view 21 | returns (uint256); 22 | 23 | function totalVaultBalance(address account) external view returns (uint256); 24 | } 25 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/presets/README.adoc: -------------------------------------------------------------------------------- 1 | = Presets 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/presets 5 | 6 | These contracts integrate different Ethereum standards (ERCs) with custom extensions and modules, showcasing common configurations that are ready to deploy **without having to write any Solidity code**. 7 | 8 | They can be used as-is for quick prototyping and testing, but are **also suitable for production environments**. 9 | 10 | TIP: Intermediate and advanced users can use these as starting points when writing their own contracts, extending them with custom functionality as they see fit. 11 | 12 | == Tokens 13 | 14 | {{ERC20PresetMinterPauser}} 15 | 16 | {{ERC721PresetMinterPauserAutoId}} 17 | 18 | {{ERC1155PresetMinterPauser}} 19 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC777/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 777 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc777 5 | 6 | This set of interfaces and contracts are all related to the [ERC777 token standard](https://eips.ethereum.org/EIPS/eip-777). 7 | 8 | TIP: For an overview of ERC777 tokens and a walk through on how to create a token contract read our xref:ROOT:erc777.adoc[ERC777 guide]. 9 | 10 | The token behavior itself is implemented in the core contracts: {IERC777}, {ERC777}. 11 | 12 | Additionally there are interfaces used to develop contracts that react to token movements: {IERC777Sender}, {IERC777Recipient}. 13 | 14 | == Core 15 | 16 | {{IERC777}} 17 | 18 | {{ERC777}} 19 | 20 | == Hooks 21 | 22 | {{IERC777Sender}} 23 | 24 | {{IERC777Recipient}} 25 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/ERC1155Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC1155Receiver.sol"; 6 | 7 | /** 8 | * @dev _Available since v3.1._ 9 | */ 10 | contract ERC1155Holder is ERC1155Receiver { 11 | function onERC1155Received( 12 | address, 13 | address, 14 | uint256, 15 | uint256, 16 | bytes memory 17 | ) public virtual override returns (bytes4) { 18 | return this.onERC1155Received.selector; 19 | } 20 | 21 | function onERC1155BatchReceived( 22 | address, 23 | address, 24 | uint256[] memory, 25 | uint256[] memory, 26 | bytes memory 27 | ) public virtual override returns (bytes4) { 28 | return this.onERC1155BatchReceived.selector; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./IERC721.sol"; 6 | 7 | /** 8 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 9 | * @dev See https://eips.ethereum.org/EIPS/eip-721 10 | */ 11 | interface IERC721Metadata is IERC721 { 12 | /** 13 | * @dev Returns the token collection name. 14 | */ 15 | function name() external view returns (string memory); 16 | 17 | /** 18 | * @dev Returns the token collection symbol. 19 | */ 20 | function symbol() external view returns (string memory); 21 | 22 | /** 23 | * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. 24 | */ 25 | function tokenURI(uint256 tokenId) external view returns (string memory); 26 | } 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC777/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 777 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc777 5 | 6 | This set of interfaces and contracts are all related to the [ERC777 token standard](https://eips.ethereum.org/EIPS/eip-777). 7 | 8 | TIP: For an overview of ERC777 tokens and a walk through on how to create a token contract read our xref:ROOT:erc777.adoc[ERC777 guide]. 9 | 10 | The token behavior itself is implemented in the core contracts: {IERC777}, {ERC777}. 11 | 12 | Additionally there are interfaces used to develop contracts that react to token movements: {IERC777Sender}, {IERC777Recipient}. 13 | 14 | == Core 15 | 16 | {{IERC777}} 17 | 18 | {{ERC777}} 19 | 20 | == Hooks 21 | 22 | {{IERC777Sender}} 23 | 24 | {{IERC777Recipient}} 25 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/introspection/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface for an ERC1820 implementer, as defined in the 7 | * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP]. 8 | * Used by contracts that will be registered as implementers in the 9 | * {IERC1820Registry}. 10 | */ 11 | interface IERC1820Implementer { 12 | /** 13 | * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract 14 | * implements `interfaceHash` for `account`. 15 | * 16 | * See {IERC1820Registry-setInterfaceImplementer}. 17 | */ 18 | function canImplementInterfaceForAddress( 19 | bytes32 interfaceHash, 20 | address account 21 | ) external view returns (bytes32); 22 | } 23 | -------------------------------------------------------------------------------- /interfaces/uniswap/IUniswapV2Factory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IUniswapV2Factory { 5 | event PairCreated( 6 | address indexed token0, 7 | address indexed token1, 8 | address pair, 9 | uint256 10 | ); 11 | 12 | function getPair(address tokenA, address tokenB) 13 | external 14 | view 15 | returns (address pair); 16 | 17 | function allPairs(uint256) external view returns (address pair); 18 | 19 | function allPairsLength() external view returns (uint256); 20 | 21 | function feeTo() external view returns (address); 22 | 23 | function feeToSetter() external view returns (address); 24 | 25 | function createPair(address tokenA, address tokenB) 26 | external 27 | returns (address pair); 28 | } 29 | -------------------------------------------------------------------------------- /config/__init__.py: -------------------------------------------------------------------------------- 1 | ## Ideally, they have one file with the settings for the strat and deployment 2 | ## This file would allow them to configure so they can test, deploy and interact with the strategy 3 | 4 | BADGER_DEV_MULTISIG = "0xb65cef03b9b89f99517643226d76e286ee999e77" 5 | 6 | WANT = "0x6b175474e89094c44da98b954eedeac495271d0f" ## Dai 7 | LP_COMPONENT = "0x028171bca77440897b824ca71d1c56cac55b68a3" ## aDAI 8 | REWARD_TOKEN = "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9" ## AAVE Token 9 | 10 | PROTECTED_TOKENS = [WANT, LP_COMPONENT, REWARD_TOKEN] 11 | ## Fees in Basis Points 12 | DEFAULT_GOV_PERFORMANCE_FEE = 1000 13 | DEFAULT_PERFORMANCE_FEE = 1000 14 | DEFAULT_WITHDRAWAL_FEE = 10 15 | 16 | FEES = [DEFAULT_GOV_PERFORMANCE_FEE, DEFAULT_PERFORMANCE_FEE, DEFAULT_WITHDRAWAL_FEE] 17 | 18 | REGISTRY = "0xFda7eB6f8b7a9e9fCFd348042ae675d1d652454f" # Multichain BadgerRegistry 19 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/introspection/IERC1820ImplementerUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface for an ERC1820 implementer, as defined in the 7 | * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP]. 8 | * Used by contracts that will be registered as implementers in the 9 | * {IERC1820Registry}. 10 | */ 11 | interface IERC1820ImplementerUpgradeable { 12 | /** 13 | * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract 14 | * implements `interfaceHash` for `account`. 15 | * 16 | * See {IERC1820Registry-setInterfaceImplementer}. 17 | */ 18 | function canImplementInterfaceForAddress( 19 | bytes32 interfaceHash, 20 | address account 21 | ) external view returns (bytes32); 22 | } 23 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/ERC721Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC721Receiver.sol"; 6 | 7 | /** 8 | * @dev Implementation of the {IERC721Receiver} interface. 9 | * 10 | * Accepts all token transfers. 11 | * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. 12 | */ 13 | contract ERC721Holder is IERC721Receiver { 14 | /** 15 | * @dev See {IERC721Receiver-onERC721Received}. 16 | * 17 | * Always returns `IERC721Receiver.onERC721Received.selector`. 18 | */ 19 | function onERC721Received( 20 | address, 21 | address, 22 | uint256, 23 | bytes memory 24 | ) public virtual override returns (bytes4) { 25 | return this.onERC721Received.selector; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../GSN/Context.sol"; 6 | import "./ERC721.sol"; 7 | 8 | /** 9 | * @title ERC721 Burnable Token 10 | * @dev ERC721 Token that can be irreversibly burned (destroyed). 11 | */ 12 | abstract contract ERC721Burnable is Context, ERC721 { 13 | /** 14 | * @dev Burns `tokenId`. See {ERC721-_burn}. 15 | * 16 | * Requirements: 17 | * 18 | * - The caller must own `tokenId` or be an approved operator. 19 | */ 20 | function burn(uint256 tokenId) public virtual { 21 | //solhint-disable-next-line max-line-length 22 | require( 23 | _isApprovedOrOwner(_msgSender(), tokenId), 24 | "ERC721Burnable: caller is not owner nor approved" 25 | ); 26 | _burn(tokenId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/IERC721MetadataUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./IERC721Upgradeable.sol"; 6 | 7 | /** 8 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 9 | * @dev See https://eips.ethereum.org/EIPS/eip-721 10 | */ 11 | interface IERC721MetadataUpgradeable is IERC721Upgradeable { 12 | /** 13 | * @dev Returns the token collection name. 14 | */ 15 | function name() external view returns (string memory); 16 | 17 | /** 18 | * @dev Returns the token collection symbol. 19 | */ 20 | function symbol() external view returns (string memory); 21 | 22 | /** 23 | * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. 24 | */ 25 | function tokenURI(uint256 tokenId) external view returns (string memory); 26 | } 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/payment/README.adoc: -------------------------------------------------------------------------------- 1 | = Payment 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/payment 5 | 6 | Utilities related to sending and receiving payments. Examples are {PullPayment}, which implements the best security practices when sending funds to third parties, and {PaymentSplitter} to receive incoming payments among a number of beneficiaries. 7 | 8 | TIP: When transferring funds to and from untrusted third parties, there is always a security risk of reentrancy. If you would like to learn more about this and ways to protect against it, check out our blog post https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. 9 | 10 | == Utilities 11 | 12 | {{PaymentSplitter}} 13 | 14 | {{PullPayment}} 15 | 16 | == Escrow 17 | 18 | {{Escrow}} 19 | 20 | {{ConditionalEscrow}} 21 | 22 | {{RefundEscrow}} 23 | -------------------------------------------------------------------------------- /deps/SettAccessControlDefended.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.11; 3 | 4 | import "./SettAccessControl.sol"; 5 | 6 | /* 7 | Add ability to prevent unwanted contract access to Sett permissions 8 | */ 9 | contract SettAccessControlDefended is SettAccessControl { 10 | mapping(address => bool) public approved; 11 | 12 | function approveContractAccess(address account) external { 13 | _onlyGovernance(); 14 | approved[account] = true; 15 | } 16 | 17 | function revokeContractAccess(address account) external { 18 | _onlyGovernance(); 19 | approved[account] = false; 20 | } 21 | 22 | function _defend() internal view returns (bool) { 23 | require( 24 | approved[msg.sender] || msg.sender == tx.origin, 25 | "Access denied for caller" 26 | ); 27 | } 28 | 29 | uint256[50] private __gap; 30 | } 31 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/payment/README.adoc: -------------------------------------------------------------------------------- 1 | = Payment 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/payment 5 | 6 | Utilities related to sending and receiving payments. Examples are {PullPayment}, which implements the best security practices when sending funds to third parties, and {PaymentSplitter} to receive incoming payments among a number of beneficiaries. 7 | 8 | TIP: When transferring funds to and from untrusted third parties, there is always a security risk of reentrancy. If you would like to learn more about this and ways to protect against it, check out our blog post https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. 9 | 10 | == Utilities 11 | 12 | {{PaymentSplitter}} 13 | 14 | {{PullPayment}} 15 | 16 | == Escrow 17 | 18 | {{Escrow}} 19 | 20 | {{ConditionalEscrow}} 21 | 22 | {{RefundEscrow}} 23 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/introspection/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface of the ERC165 standard, as defined in the 7 | * https://eips.ethereum.org/EIPS/eip-165[EIP]. 8 | * 9 | * Implementers can declare support of contract interfaces, which can then be 10 | * queried by others ({ERC165Checker}). 11 | * 12 | * For an implementation, see {ERC165}. 13 | */ 14 | interface IERC165 { 15 | /** 16 | * @dev Returns true if this contract implements the interface defined by 17 | * `interfaceId`. See the corresponding 18 | * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] 19 | * to learn more about how these ids are created. 20 | * 21 | * This function call must use less than 30 000 gas. 22 | */ 23 | function supportsInterface(bytes4 interfaceId) external view returns (bool); 24 | } 25 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface of the ERC165 standard, as defined in the 7 | * https://eips.ethereum.org/EIPS/eip-165[EIP]. 8 | * 9 | * Implementers can declare support of contract interfaces, which can then be 10 | * queried by others ({ERC165Checker}). 11 | * 12 | * For an implementation, see {ERC165}. 13 | */ 14 | interface IERC165Upgradeable { 15 | /** 16 | * @dev Returns true if this contract implements the interface defined by 17 | * `interfaceId`. See the corresponding 18 | * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] 19 | * to learn more about how these ids are created. 20 | * 21 | * This function call must use less than 30 000 gas. 22 | */ 23 | function supportsInterface(bytes4 interfaceId) external view returns (bool); 24 | } 25 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/math/Math.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Standard math utilities missing in the Solidity language. 7 | */ 8 | library Math { 9 | /** 10 | * @dev Returns the largest of two numbers. 11 | */ 12 | function max(uint256 a, uint256 b) internal pure returns (uint256) { 13 | return a >= b ? a : b; 14 | } 15 | 16 | /** 17 | * @dev Returns the smallest of two numbers. 18 | */ 19 | function min(uint256 a, uint256 b) internal pure returns (uint256) { 20 | return a < b ? a : b; 21 | } 22 | 23 | /** 24 | * @dev Returns the average of two numbers. The result is rounded towards 25 | * zero. 26 | */ 27 | function average(uint256 a, uint256 b) internal pure returns (uint256) { 28 | // (a + b) / 2 can overflow, so we distribute 29 | return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /helpers/multicall/constants.py: -------------------------------------------------------------------------------- 1 | # Credit: https://github.com/banteg/multicall.py/blob/master/multicall/constants.py 2 | from enum import IntEnum 3 | 4 | 5 | class Network(IntEnum): 6 | Mainnet = 1 7 | Kovan = 42 8 | Rinkeby = 4 9 | Görli = 5 10 | xDai = 100 11 | Forknet = 1337 12 | BSC = 56 13 | Hardhat = 31337 14 | Arbitrum = 42161 15 | 16 | 17 | MULTICALL_ADDRESSES = { 18 | Network.Mainnet: "0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441", 19 | Network.Kovan: "0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A", 20 | Network.Rinkeby: "0x42Ad527de7d4e9d9d011aC45B31D8551f8Fe9821", 21 | Network.Görli: "0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e", 22 | Network.xDai: "0xb5b692a88BDFc81ca69dcB1d924f59f0413A602a", 23 | Network.Forknet: "0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441", 24 | Network.BSC: "0xec8c00da6ce45341fb8c31653b598ca0d8251804", 25 | Network.Arbitrum: "0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee", 26 | } 27 | -------------------------------------------------------------------------------- /tests/examples/test_basic.py: -------------------------------------------------------------------------------- 1 | from config import ( 2 | BADGER_DEV_MULTISIG, 3 | WANT, 4 | LP_COMPONENT, 5 | REWARD_TOKEN, 6 | DEFAULT_GOV_PERFORMANCE_FEE, 7 | DEFAULT_PERFORMANCE_FEE, 8 | DEFAULT_WITHDRAWAL_FEE, 9 | ) 10 | 11 | 12 | def test_deploy_settings(deployed): 13 | """ 14 | Verifies that you set up the Strategy properly 15 | """ 16 | strategy = deployed.strategy 17 | 18 | protected_tokens = strategy.getProtectedTokens() 19 | 20 | ## NOTE: Change based on how you set your contract 21 | assert protected_tokens[0] == WANT 22 | assert protected_tokens[1] == LP_COMPONENT 23 | assert protected_tokens[2] == REWARD_TOKEN 24 | 25 | assert strategy.governance() == BADGER_DEV_MULTISIG 26 | 27 | assert strategy.performanceFeeGovernance() == DEFAULT_GOV_PERFORMANCE_FEE 28 | assert strategy.performanceFeeStrategist() == DEFAULT_PERFORMANCE_FEE 29 | assert strategy.withdrawalFee() == DEFAULT_WITHDRAWAL_FEE 30 | -------------------------------------------------------------------------------- /interfaces/badger/ISwapStrategyRouter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.6.0; 4 | 5 | // ISwapStrategyRouter performs optimal routing of swaps. 6 | interface ISwapStrategyRouter { 7 | // Return the optimal rate and the strategy ID. 8 | function optimizeSwap( 9 | address _from, 10 | address _to, 11 | uint256 _amount 12 | ) external returns (address strategy, uint256 amount); 13 | } 14 | 15 | // ISwapStrategy enforces a standard API for swaps. 16 | interface ISwapStrategy { 17 | function swapTokens( 18 | address _from, 19 | address _to, 20 | uint256 _amount, 21 | // Slippage is in bps. 22 | uint256 _slippage 23 | ) external returns (uint256 amount); 24 | 25 | // Estimate swap amount returns the swap rate. 26 | function estimateSwapAmount( 27 | address _from, 28 | address _to, 29 | uint256 _amount 30 | ) external returns (uint256 amount); 31 | } 32 | -------------------------------------------------------------------------------- /interfaces/badger/IMiniMe.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | interface IMiniMe { 7 | event ClaimedTokens( 8 | address indexed _token, 9 | address indexed _controller, 10 | uint256 _amount 11 | ); 12 | event Transfer(address indexed _from, address indexed _to, uint256 _amount); 13 | event NewCloneToken(address indexed _cloneToken, uint256 _snapshotBlock); 14 | event Approval( 15 | address indexed _owner, 16 | address indexed _spender, 17 | uint256 _amount 18 | ); 19 | 20 | function claimTokens(address _token) external; 21 | 22 | function enableTransfers(bool _transfersEnabled) external; 23 | 24 | function generateTokens(address _owner, uint256 _amount) 25 | external 26 | returns (bool); 27 | 28 | function destroyTokens(address _owner, uint256 _amount) 29 | external 30 | returns (bool); 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Standard math utilities missing in the Solidity language. 7 | */ 8 | library MathUpgradeable { 9 | /** 10 | * @dev Returns the largest of two numbers. 11 | */ 12 | function max(uint256 a, uint256 b) internal pure returns (uint256) { 13 | return a >= b ? a : b; 14 | } 15 | 16 | /** 17 | * @dev Returns the smallest of two numbers. 18 | */ 19 | function min(uint256 a, uint256 b) internal pure returns (uint256) { 20 | return a < b ? a : b; 21 | } 22 | 23 | /** 24 | * @dev Returns the average of two numbers. The result is rounded towards 25 | * zero. 26 | */ 27 | function average(uint256 a, uint256 b) internal pure returns (uint256) { 28 | // (a + b) / 2 can overflow, so we distribute 29 | return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155ReceiverUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC1155ReceiverUpgradeable.sol"; 6 | import "../../introspection/ERC165Upgradeable.sol"; 7 | import "../../proxy/Initializable.sol"; 8 | 9 | /** 10 | * @dev _Available since v3.1._ 11 | */ 12 | abstract contract ERC1155ReceiverUpgradeable is 13 | Initializable, 14 | ERC165Upgradeable, 15 | IERC1155ReceiverUpgradeable 16 | { 17 | function __ERC1155Receiver_init() internal initializer { 18 | __ERC165_init_unchained(); 19 | __ERC1155Receiver_init_unchained(); 20 | } 21 | 22 | function __ERC1155Receiver_init_unchained() internal initializer { 23 | _registerInterface( 24 | ERC1155ReceiverUpgradeable(0).onERC1155Received.selector ^ 25 | ERC1155ReceiverUpgradeable(0).onERC1155BatchReceived.selector 26 | ); 27 | } 28 | 29 | uint256[50] private __gap; 30 | } 31 | -------------------------------------------------------------------------------- /contracts/deps/MockToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../deps/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; 6 | 7 | contract MockToken is ERC20Upgradeable { 8 | function initialize(address[] memory holders, uint256[] memory balances) 9 | public 10 | initializer 11 | { 12 | __ERC20_init("Mock", "Mock"); 13 | require( 14 | holders.length == balances.length, 15 | "Constructor array size mismatch" 16 | ); 17 | for (uint256 i = 0; i < holders.length; i++) { 18 | _mint(holders[i], balances[i]); 19 | } 20 | } 21 | 22 | /// @dev Open minting capabilities 23 | function mint(address account, uint256 amount) public { 24 | _mint(account, amount); 25 | } 26 | 27 | /// @dev Open burning capabilities, from any account 28 | function burn(address account, uint256 amount) public { 29 | _burn(account, amount); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC20.sol"; 6 | import "../../utils/Pausable.sol"; 7 | 8 | /** 9 | * @dev ERC20 token with pausable token transfers, minting and burning. 10 | * 11 | * Useful for scenarios such as preventing trades until the end of an evaluation 12 | * period, or having an emergency switch for freezing all token transfers in the 13 | * event of a large bug. 14 | */ 15 | abstract contract ERC20Pausable is ERC20, Pausable { 16 | /** 17 | * @dev See {ERC20-_beforeTokenTransfer}. 18 | * 19 | * Requirements: 20 | * 21 | * - the contract must not be paused. 22 | */ 23 | function _beforeTokenTransfer( 24 | address from, 25 | address to, 26 | uint256 amount 27 | ) internal virtual override { 28 | super._beforeTokenTransfer(from, to, amount); 29 | 30 | require(!paused(), "ERC20Pausable: token transfer while paused"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/ERC721Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC721.sol"; 6 | import "../../utils/Pausable.sol"; 7 | 8 | /** 9 | * @dev ERC721 token with pausable token transfers, minting and burning. 10 | * 11 | * Useful for scenarios such as preventing trades until the end of an evaluation 12 | * period, or having an emergency switch for freezing all token transfers in the 13 | * event of a large bug. 14 | */ 15 | abstract contract ERC721Pausable is ERC721, Pausable { 16 | /** 17 | * @dev See {ERC721-_beforeTokenTransfer}. 18 | * 19 | * Requirements: 20 | * 21 | * - the contract must not be paused. 22 | */ 23 | function _beforeTokenTransfer( 24 | address from, 25 | address to, 26 | uint256 tokenId 27 | ) internal virtual override { 28 | super._beforeTokenTransfer(from, to, tokenId); 29 | 30 | require(!paused(), "ERC721Pausable: token transfer while paused"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @title ERC721 token receiver interface 7 | * @dev Interface for any contract that wants to support safeTransfers 8 | * from ERC721 asset contracts. 9 | */ 10 | interface IERC721Receiver { 11 | /** 12 | * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} 13 | * by `operator` from `from`, this function is called. 14 | * 15 | * It must return its Solidity selector to confirm the token transfer. 16 | * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. 17 | * 18 | * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. 19 | */ 20 | function onERC721Received( 21 | address operator, 22 | address from, 23 | uint256 tokenId, 24 | bytes calldata data 25 | ) external returns (bytes4); 26 | } 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/payment/escrow/ConditionalEscrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./Escrow.sol"; 6 | 7 | /** 8 | * @title ConditionalEscrow 9 | * @dev Base abstract escrow to only allow withdrawal if a condition is met. 10 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. 11 | */ 12 | abstract contract ConditionalEscrow is Escrow { 13 | /** 14 | * @dev Returns whether an address is allowed to withdraw their funds. To be 15 | * implemented by derived contracts. 16 | * @param payee The destination address of the funds. 17 | */ 18 | function withdrawalAllowed(address payee) 19 | public 20 | view 21 | virtual 22 | returns (bool); 23 | 24 | function withdraw(address payable payee) public virtual override { 25 | require( 26 | withdrawalAllowed(payee), 27 | "ConditionalEscrow: payee is not allowed to withdraw" 28 | ); 29 | super.withdraw(payee); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/GSN/Context.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /* 6 | * @dev Provides information about the current execution context, including the 7 | * sender of the transaction and its data. While these are generally available 8 | * via msg.sender and msg.data, they should not be accessed in such a direct 9 | * manner, since when dealing with GSN meta-transactions the account sending and 10 | * paying for execution may not be the actual sender (as far as an application 11 | * is concerned). 12 | * 13 | * This contract is only required for intermediate, library-like contracts. 14 | */ 15 | abstract contract Context { 16 | function _msgSender() internal view virtual returns (address payable) { 17 | return msg.sender; 18 | } 19 | 20 | function _msgData() internal view virtual returns (bytes memory) { 21 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 22 | return msg.data; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @title ERC721 token receiver interface 7 | * @dev Interface for any contract that wants to support safeTransfers 8 | * from ERC721 asset contracts. 9 | */ 10 | interface IERC721ReceiverUpgradeable { 11 | /** 12 | * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} 13 | * by `operator` from `from`, this function is called. 14 | * 15 | * It must return its Solidity selector to confirm the token transfer. 16 | * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. 17 | * 18 | * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. 19 | */ 20 | function onERC721Received( 21 | address operator, 22 | address from, 23 | uint256 tokenId, 24 | bytes calldata data 25 | ) external returns (bytes4); 26 | } 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/Strings.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev String operations. 7 | */ 8 | library Strings { 9 | /** 10 | * @dev Converts a `uint256` to its ASCII `string` representation. 11 | */ 12 | function toString(uint256 value) internal pure returns (string memory) { 13 | // Inspired by OraclizeAPI's implementation - MIT licence 14 | // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol 15 | 16 | if (value == 0) { 17 | return "0"; 18 | } 19 | uint256 temp = value; 20 | uint256 digits; 21 | while (temp != 0) { 22 | digits++; 23 | temp /= 10; 24 | } 25 | bytes memory buffer = new bytes(digits); 26 | uint256 index = digits - 1; 27 | temp = value; 28 | while (temp != 0) { 29 | buffer[index--] = bytes1(uint8(48 + (temp % 10))); 30 | temp /= 10; 31 | } 32 | return string(buffer); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./IERC721.sol"; 6 | 7 | /** 8 | * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension 9 | * @dev See https://eips.ethereum.org/EIPS/eip-721 10 | */ 11 | interface IERC721Enumerable is IERC721 { 12 | /** 13 | * @dev Returns the total amount of tokens stored by the contract. 14 | */ 15 | function totalSupply() external view returns (uint256); 16 | 17 | /** 18 | * @dev Returns a token ID owned by `owner` at a given `index` of its token list. 19 | * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. 20 | */ 21 | function tokenOfOwnerByIndex(address owner, uint256 index) 22 | external 23 | view 24 | returns (uint256 tokenId); 25 | 26 | /** 27 | * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. 28 | * Use along with {totalSupply} to enumerate all tokens. 29 | */ 30 | function tokenByIndex(uint256 index) external view returns (uint256); 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev String operations. 7 | */ 8 | library StringsUpgradeable { 9 | /** 10 | * @dev Converts a `uint256` to its ASCII `string` representation. 11 | */ 12 | function toString(uint256 value) internal pure returns (string memory) { 13 | // Inspired by OraclizeAPI's implementation - MIT licence 14 | // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol 15 | 16 | if (value == 0) { 17 | return "0"; 18 | } 19 | uint256 temp = value; 20 | uint256 digits; 21 | while (temp != 0) { 22 | digits++; 23 | temp /= 10; 24 | } 25 | bytes memory buffer = new bytes(digits); 26 | uint256 index = digits - 1; 27 | temp = value; 28 | while (temp != 0) { 29 | buffer[index--] = bytes1(uint8(48 + (temp % 10))); 30 | temp /= 10; 31 | } 32 | return string(buffer); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /helpers/multicall/multicall.py: -------------------------------------------------------------------------------- 1 | # Credit: https://github.com/banteg/multicall.py/blob/master/multicall/multicall.py 2 | from typing import List 3 | 4 | from brownie import web3 5 | 6 | from helpers.multicall import Call 7 | from helpers.multicall.constants import MULTICALL_ADDRESSES 8 | from rich.console import Console 9 | 10 | console = Console() 11 | 12 | 13 | class Multicall: 14 | def __init__(self, calls: List[Call]): 15 | self.calls = calls 16 | 17 | def printCalls(self): 18 | for call in self.calls: 19 | console.print( 20 | {"target": call.target, "function": call.function, "args": call.args} 21 | ) 22 | 23 | def __call__(self): 24 | aggregate = Call( 25 | MULTICALL_ADDRESSES[web3.eth.chainId], 26 | "aggregate((address,bytes)[])(uint256,bytes[])", 27 | ) 28 | args = [[[call.target, call.data] for call in self.calls]] 29 | block, outputs = aggregate(args) 30 | result = {} 31 | for call, output in zip(self.calls, outputs): 32 | result.update(call.decode_output(output)) 33 | return result 34 | -------------------------------------------------------------------------------- /interfaces/badger/ICumulativeMultiTokenMerkleDistributor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity >=0.5.0; 3 | 4 | /* 5 | Cumulative Merkle distributor 6 | */ 7 | interface ICumulativeMultiTokenMerkleDistributor { 8 | /// @notice Emit when insufficient funds to handle incoming root totals 9 | event InsufficientFundsForRoot(bytes32 indexed root); 10 | event RootProposed( 11 | uint256 indexed cycle, 12 | bytes32 indexed root, 13 | bytes32 indexed contentHash, 14 | uint256 startBlock, 15 | uint256 endBlock, 16 | uint256 timestamp, 17 | uint256 blockNumber 18 | ); 19 | event RootUpdated( 20 | uint256 indexed cycle, 21 | bytes32 indexed root, 22 | bytes32 indexed contentHash, 23 | uint256 startBlock, 24 | uint256 endBlock, 25 | uint256 timestamp, 26 | uint256 blockNumber 27 | ); 28 | event Claimed( 29 | address indexed user, 30 | address indexed token, 31 | uint256 amount, 32 | uint256 indexed cycle, 33 | uint256 timestamp, 34 | uint256 blockNumber 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/ERC1155Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC1155.sol"; 6 | 7 | /** 8 | * @dev Extension of {ERC1155} that allows token holders to destroy both their 9 | * own tokens and those that they have been approved to use. 10 | * 11 | * _Available since v3.1._ 12 | */ 13 | abstract contract ERC1155Burnable is ERC1155 { 14 | function burn( 15 | address account, 16 | uint256 id, 17 | uint256 value 18 | ) public virtual { 19 | require( 20 | account == _msgSender() || isApprovedForAll(account, _msgSender()), 21 | "ERC1155: caller is not owner nor approved" 22 | ); 23 | 24 | _burn(account, id, value); 25 | } 26 | 27 | function burnBatch( 28 | address account, 29 | uint256[] memory ids, 30 | uint256[] memory values 31 | ) public virtual { 32 | require( 33 | account == _msgSender() || isApprovedForAll(account, _msgSender()), 34 | "ERC1155: caller is not owner nor approved" 35 | ); 36 | 37 | _burnBatch(account, ids, values); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/IERC721EnumerableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./IERC721Upgradeable.sol"; 6 | 7 | /** 8 | * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension 9 | * @dev See https://eips.ethereum.org/EIPS/eip-721 10 | */ 11 | interface IERC721EnumerableUpgradeable is IERC721Upgradeable { 12 | /** 13 | * @dev Returns the total amount of tokens stored by the contract. 14 | */ 15 | function totalSupply() external view returns (uint256); 16 | 17 | /** 18 | * @dev Returns a token ID owned by `owner` at a given `index` of its token list. 19 | * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. 20 | */ 21 | function tokenOfOwnerByIndex(address owner, uint256 index) 22 | external 23 | view 24 | returns (uint256 tokenId); 25 | 26 | /** 27 | * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. 28 | * Use along with {totalSupply} to enumerate all tokens. 29 | */ 30 | function tokenByIndex(uint256 index) external view returns (uint256); 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/ERC1155Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC1155.sol"; 6 | import "../../utils/Pausable.sol"; 7 | 8 | /** 9 | * @dev ERC1155 token with pausable token transfers, minting and burning. 10 | * 11 | * Useful for scenarios such as preventing trades until the end of an evaluation 12 | * period, or having an emergency switch for freezing all token transfers in the 13 | * event of a large bug. 14 | * 15 | * _Available since v3.1._ 16 | */ 17 | abstract contract ERC1155Pausable is ERC1155, Pausable { 18 | /** 19 | * @dev See {ERC1155-_beforeTokenTransfer}. 20 | * 21 | * Requirements: 22 | * 23 | * - the contract must not be paused. 24 | */ 25 | function _beforeTokenTransfer( 26 | address operator, 27 | address from, 28 | address to, 29 | uint256[] memory ids, 30 | uint256[] memory amounts, 31 | bytes memory data 32 | ) internal virtual override { 33 | super._beforeTokenTransfer(operator, from, to, ids, amounts, data); 34 | 35 | require(!paused(), "ERC1155Pausable: token transfer while paused"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/ERC721HolderUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC721ReceiverUpgradeable.sol"; 6 | import "../../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC721Receiver} interface. 10 | * 11 | * Accepts all token transfers. 12 | * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. 13 | */ 14 | contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { 15 | function __ERC721Holder_init() internal initializer { 16 | __ERC721Holder_init_unchained(); 17 | } 18 | 19 | function __ERC721Holder_init_unchained() internal initializer {} 20 | 21 | /** 22 | * @dev See {IERC721Receiver-onERC721Received}. 23 | * 24 | * Always returns `IERC721Receiver.onERC721Received.selector`. 25 | */ 26 | function onERC721Received( 27 | address, 28 | address, 29 | uint256, 30 | bytes memory 31 | ) public virtual override returns (bytes4) { 32 | return this.onERC721Received.selector; 33 | } 34 | 35 | uint256[50] private __gap; 36 | } 37 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155HolderUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC1155ReceiverUpgradeable.sol"; 6 | import "../../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev _Available since v3.1._ 10 | */ 11 | contract ERC1155HolderUpgradeable is Initializable, ERC1155ReceiverUpgradeable { 12 | function __ERC1155Holder_init() internal initializer { 13 | __ERC165_init_unchained(); 14 | __ERC1155Receiver_init_unchained(); 15 | __ERC1155Holder_init_unchained(); 16 | } 17 | 18 | function __ERC1155Holder_init_unchained() internal initializer {} 19 | 20 | function onERC1155Received( 21 | address, 22 | address, 23 | uint256, 24 | uint256, 25 | bytes memory 26 | ) public virtual override returns (bytes4) { 27 | return this.onERC1155Received.selector; 28 | } 29 | 30 | function onERC1155BatchReceived( 31 | address, 32 | address, 33 | uint256[] memory, 34 | uint256[] memory, 35 | bytes memory 36 | ) public virtual override returns (bytes4) { 37 | return this.onERC1155BatchReceived.selector; 38 | } 39 | 40 | uint256[50] private __gap; 41 | } 42 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/upgradeability/UpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | import "./BaseUpgradeabilityProxy.sol"; 4 | 5 | /** 6 | * @title UpgradeabilityProxy 7 | * @dev Extends BaseUpgradeabilityProxy with a constructor for initializing 8 | * implementation and init data. 9 | */ 10 | contract UpgradeabilityProxy is BaseUpgradeabilityProxy { 11 | /** 12 | * @dev Contract constructor. 13 | * @param _logic Address of the initial implementation. 14 | * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. 15 | * It should include the signature and the parameters of the function to be called, as described in 16 | * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. 17 | * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. 18 | */ 19 | constructor(address _logic, bytes memory _data) public payable { 20 | assert( 21 | IMPLEMENTATION_SLOT == 22 | bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1) 23 | ); 24 | _setImplementation(_logic); 25 | if (_data.length > 0) { 26 | (bool success, ) = _logic.delegatecall(_data); 27 | require(success); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. 7 | * 8 | * Accounts can be notified of {IERC777} tokens being sent to them by having a 9 | * contract implement this interface (contract holders can be their own 10 | * implementer) and registering it on the 11 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. 12 | * 13 | * See {IERC1820Registry} and {ERC1820Implementer}. 14 | */ 15 | interface IERC777Recipient { 16 | /** 17 | * @dev Called by an {IERC777} token contract whenever tokens are being 18 | * moved or created into a registered account (`to`). The type of operation 19 | * is conveyed by `from` being the zero address or not. 20 | * 21 | * This call occurs _after_ the token contract's state is updated, so 22 | * {IERC777-balanceOf}, etc., can be used to query the post-operation state. 23 | * 24 | * This function may revert to prevent the operation from being executed. 25 | */ 26 | function tokensReceived( 27 | address operator, 28 | address from, 29 | address to, 30 | uint256 amount, 31 | bytes calldata userData, 32 | bytes calldata operatorData 33 | ) external; 34 | } 35 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/GSN/ContextUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | import "../proxy/Initializable.sol"; 5 | 6 | /* 7 | * @dev Provides information about the current execution context, including the 8 | * sender of the transaction and its data. While these are generally available 9 | * via msg.sender and msg.data, they should not be accessed in such a direct 10 | * manner, since when dealing with GSN meta-transactions the account sending and 11 | * paying for execution may not be the actual sender (as far as an application 12 | * is concerned). 13 | * 14 | * This contract is only required for intermediate, library-like contracts. 15 | */ 16 | abstract contract ContextUpgradeable is Initializable { 17 | function __Context_init() internal initializer { 18 | __Context_init_unchained(); 19 | } 20 | 21 | function __Context_init_unchained() internal initializer {} 22 | 23 | function _msgSender() internal view virtual returns (address payable) { 24 | return msg.sender; 25 | } 26 | 27 | function _msgData() internal view virtual returns (bytes memory) { 28 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 29 | return msg.data; 30 | } 31 | 32 | uint256[50] private __gap; 33 | } 34 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface of the ERC777TokensSender standard as defined in the EIP. 7 | * 8 | * {IERC777} Token holders can be notified of operations performed on their 9 | * tokens by having a contract implement this interface (contract holders can be 10 | * their own implementer) and registering it on the 11 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. 12 | * 13 | * See {IERC1820Registry} and {ERC1820Implementer}. 14 | */ 15 | interface IERC777Sender { 16 | /** 17 | * @dev Called by an {IERC777} token contract whenever a registered holder's 18 | * (`from`) tokens are about to be moved or destroyed. The type of operation 19 | * is conveyed by `to` being the zero address or not. 20 | * 21 | * This call occurs _before_ the token contract's state is updated, so 22 | * {IERC777-balanceOf}, etc., can be used to query the pre-operation state. 23 | * 24 | * This function may revert to prevent the operation from being executed. 25 | */ 26 | function tokensToSend( 27 | address operator, 28 | address from, 29 | address to, 30 | uint256 amount, 31 | bytes calldata userData, 32 | bytes calldata operatorData 33 | ) external; 34 | } 35 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/ERC721BurnableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../GSN/ContextUpgradeable.sol"; 6 | import "./ERC721Upgradeable.sol"; 7 | import "../../proxy/Initializable.sol"; 8 | 9 | /** 10 | * @title ERC721 Burnable Token 11 | * @dev ERC721 Token that can be irreversibly burned (destroyed). 12 | */ 13 | abstract contract ERC721BurnableUpgradeable is 14 | Initializable, 15 | ContextUpgradeable, 16 | ERC721Upgradeable 17 | { 18 | function __ERC721Burnable_init() internal initializer { 19 | __Context_init_unchained(); 20 | __ERC165_init_unchained(); 21 | __ERC721Burnable_init_unchained(); 22 | } 23 | 24 | function __ERC721Burnable_init_unchained() internal initializer {} 25 | 26 | /** 27 | * @dev Burns `tokenId`. See {ERC721-_burn}. 28 | * 29 | * Requirements: 30 | * 31 | * - The caller must own `tokenId` or be an approved operator. 32 | */ 33 | function burn(uint256 tokenId) public virtual { 34 | //solhint-disable-next-line max-line-length 35 | require( 36 | _isApprovedOrOwner(_msgSender(), tokenId), 37 | "ERC721Burnable: caller is not owner nor approved" 38 | ); 39 | _burn(tokenId); 40 | } 41 | 42 | uint256[50] private __gap; 43 | } 44 | -------------------------------------------------------------------------------- /helpers/multicall/call.py: -------------------------------------------------------------------------------- 1 | # Credit: https://github.com/banteg/multicall.py/blob/master/multicall/call.py 2 | from eth_utils import to_checksum_address 3 | from brownie import web3 4 | from helpers.multicall import Signature 5 | 6 | 7 | class Call: 8 | def __init__(self, target, function, returns=None): 9 | self.target = to_checksum_address(target) 10 | if isinstance(function, list): 11 | self.function, *self.args = function 12 | else: 13 | self.function = function 14 | self.args = None 15 | self.signature = Signature(self.function) 16 | self.returns = returns 17 | 18 | @property 19 | def data(self): 20 | return self.signature.encode_data(self.args) 21 | 22 | def decode_output(self, output): 23 | decoded = self.signature.decode_data(output) 24 | if self.returns: 25 | return { 26 | name: handler(value) if handler else value 27 | for (name, handler), value in zip(self.returns, decoded) 28 | } 29 | else: 30 | return decoded if len(decoded) > 1 else decoded[0] 31 | 32 | def __call__(self, args=None): 33 | args = args or self.args 34 | calldata = self.signature.encode_data(args) 35 | output = web3.eth.call({"to": self.target, "data": calldata}) 36 | return self.decode_output(output) 37 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC777/IERC777RecipientUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. 7 | * 8 | * Accounts can be notified of {IERC777} tokens being sent to them by having a 9 | * contract implement this interface (contract holders can be their own 10 | * implementer) and registering it on the 11 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. 12 | * 13 | * See {IERC1820Registry} and {ERC1820Implementer}. 14 | */ 15 | interface IERC777RecipientUpgradeable { 16 | /** 17 | * @dev Called by an {IERC777} token contract whenever tokens are being 18 | * moved or created into a registered account (`to`). The type of operation 19 | * is conveyed by `from` being the zero address or not. 20 | * 21 | * This call occurs _after_ the token contract's state is updated, so 22 | * {IERC777-balanceOf}, etc., can be used to query the post-operation state. 23 | * 24 | * This function may revert to prevent the operation from being executed. 25 | */ 26 | function tokensReceived( 27 | address operator, 28 | address from, 29 | address to, 30 | uint256 amount, 31 | bytes calldata userData, 32 | bytes calldata operatorData 33 | ) external; 34 | } 35 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC777/IERC777SenderUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Interface of the ERC777TokensSender standard as defined in the EIP. 7 | * 8 | * {IERC777} Token holders can be notified of operations performed on their 9 | * tokens by having a contract implement this interface (contract holders can be 10 | * their own implementer) and registering it on the 11 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. 12 | * 13 | * See {IERC1820Registry} and {ERC1820Implementer}. 14 | */ 15 | interface IERC777SenderUpgradeable { 16 | /** 17 | * @dev Called by an {IERC777} token contract whenever a registered holder's 18 | * (`from`) tokens are about to be moved or destroyed. The type of operation 19 | * is conveyed by `to` being the zero address or not. 20 | * 21 | * This call occurs _before_ the token contract's state is updated, so 22 | * {IERC777-balanceOf}, etc., can be used to query the pre-operation state. 23 | * 24 | * This function may revert to prevent the operation from being executed. 25 | */ 26 | function tokensToSend( 27 | address operator, 28 | address from, 29 | address to, 30 | uint256 amount, 31 | bytes calldata userData, 32 | bytes calldata operatorData 33 | ) external; 34 | } 35 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/upgradeability/AdminUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | import "./BaseAdminUpgradeabilityProxy.sol"; 4 | 5 | /** 6 | * @title AdminUpgradeabilityProxy 7 | * @dev Extends from BaseAdminUpgradeabilityProxy with a constructor for 8 | * initializing the implementation, admin, and init data. 9 | */ 10 | contract AdminUpgradeabilityProxy is 11 | BaseAdminUpgradeabilityProxy, 12 | UpgradeabilityProxy 13 | { 14 | /** 15 | * Contract constructor. 16 | * @param _logic address of the initial implementation. 17 | * @param _admin Address of the proxy administrator. 18 | * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. 19 | * It should include the signature and the parameters of the function to be called, as described in 20 | * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. 21 | * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. 22 | */ 23 | constructor( 24 | address _logic, 25 | address _admin, 26 | bytes memory _data 27 | ) public payable UpgradeabilityProxy(_logic, _data) { 28 | assert( 29 | ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1) 30 | ); 31 | _setAdmin(_admin); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /interfaces/uniswap/IUniswapFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.0 <0.8.0; 3 | 4 | interface IUniswapFactory { 5 | event PairCreated( 6 | address indexed token0, 7 | address indexed token1, 8 | address pair, 9 | uint256 10 | ); 11 | 12 | function getPair(address tokenA, address tokenB) 13 | external 14 | view 15 | returns (address pair); 16 | 17 | function allPairs(uint256) external view returns (address pair); 18 | 19 | function allPairsLength() external view returns (uint256); 20 | 21 | function feeTo() external view returns (address); 22 | 23 | function feeToSetter() external view returns (address); 24 | 25 | function createPair(address tokenA, address tokenB) 26 | external 27 | returns (address pair); 28 | 29 | // Create Exchange 30 | function createExchange(address token) external returns (address exchange); 31 | 32 | // Get Exchange and Token Info 33 | function getExchange(address token) 34 | external 35 | view 36 | returns (address exchange); 37 | 38 | function getToken(address exchange) external view returns (address token); 39 | 40 | function getTokenWithId(uint256 tokenId) 41 | external 42 | view 43 | returns (address token); 44 | 45 | // Never use 46 | function initializeFactory(address template) external; 47 | } 48 | -------------------------------------------------------------------------------- /interfaces/badger/IStrategy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | interface IStrategy { 7 | function want() external view returns (address); 8 | 9 | function deposit() external; 10 | 11 | // NOTE: must exclude any tokens used in the yield 12 | // Controller role - withdraw should return to Controller 13 | function withdrawOther(address) external returns (uint256 balance); 14 | 15 | // Controller | Vault role - withdraw should always return to Vault 16 | function withdraw(uint256) external; 17 | 18 | // Controller | Vault role - withdraw should always return to Vault 19 | function withdrawAll() external returns (uint256); 20 | 21 | function balanceOf() external view returns (uint256); 22 | 23 | function getName() external pure returns (string memory); 24 | 25 | function setStrategist(address _strategist) external; 26 | 27 | function setWithdrawalFee(uint256 _withdrawalFee) external; 28 | 29 | function setPerformanceFeeStrategist(uint256 _performanceFeeStrategist) 30 | external; 31 | 32 | function setPerformanceFeeGovernance(uint256 _performanceFeeGovernance) 33 | external; 34 | 35 | function setGovernance(address _governance) external; 36 | 37 | function setController(address _controller) external; 38 | 39 | function tend() external; 40 | 41 | function harvest() external; 42 | } 43 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../GSN/Context.sol"; 6 | import "./ERC20.sol"; 7 | 8 | /** 9 | * @dev Extension of {ERC20} that allows token holders to destroy both their own 10 | * tokens and those that they have an allowance for, in a way that can be 11 | * recognized off-chain (via event analysis). 12 | */ 13 | abstract contract ERC20Burnable is Context, ERC20 { 14 | /** 15 | * @dev Destroys `amount` tokens from the caller. 16 | * 17 | * See {ERC20-_burn}. 18 | */ 19 | function burn(uint256 amount) public virtual { 20 | _burn(_msgSender(), amount); 21 | } 22 | 23 | /** 24 | * @dev Destroys `amount` tokens from `account`, deducting from the caller's 25 | * allowance. 26 | * 27 | * See {ERC20-_burn} and {ERC20-allowance}. 28 | * 29 | * Requirements: 30 | * 31 | * - the caller must have allowance for ``accounts``'s tokens of at least 32 | * `amount`. 33 | */ 34 | function burnFrom(address account, uint256 amount) public virtual { 35 | uint256 decreasedAllowance = 36 | allowance(account, _msgSender()).sub( 37 | amount, 38 | "ERC20: burn amount exceeds allowance" 39 | ); 40 | 41 | _approve(account, _msgSender(), decreasedAllowance); 42 | _burn(account, amount); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/upgradeability/InitializableUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | import "./BaseUpgradeabilityProxy.sol"; 4 | 5 | /** 6 | * @title InitializableUpgradeabilityProxy 7 | * @dev Extends BaseUpgradeabilityProxy with an initializer for initializing 8 | * implementation and init data. 9 | */ 10 | contract InitializableUpgradeabilityProxy is BaseUpgradeabilityProxy { 11 | /** 12 | * @dev Contract initializer. 13 | * @param _logic Address of the initial implementation. 14 | * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. 15 | * It should include the signature and the parameters of the function to be called, as described in 16 | * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. 17 | * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. 18 | */ 19 | function initialize(address _logic, bytes memory _data) public payable { 20 | require(_implementation() == address(0)); 21 | assert( 22 | IMPLEMENTATION_SLOT == 23 | bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1) 24 | ); 25 | _setImplementation(_logic); 26 | if (_data.length > 0) { 27 | (bool success, ) = _logic.delegatecall(_data); 28 | require(success); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC20/ERC20Capped.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC20.sol"; 6 | 7 | /** 8 | * @dev Extension of {ERC20} that adds a cap to the supply of tokens. 9 | */ 10 | abstract contract ERC20Capped is ERC20 { 11 | uint256 private _cap; 12 | 13 | /** 14 | * @dev Sets the value of the `cap`. This value is immutable, it can only be 15 | * set once during construction. 16 | */ 17 | constructor(uint256 cap) public { 18 | require(cap > 0, "ERC20Capped: cap is 0"); 19 | _cap = cap; 20 | } 21 | 22 | /** 23 | * @dev Returns the cap on the token's total supply. 24 | */ 25 | function cap() public view returns (uint256) { 26 | return _cap; 27 | } 28 | 29 | /** 30 | * @dev See {ERC20-_beforeTokenTransfer}. 31 | * 32 | * Requirements: 33 | * 34 | * - minted tokens must not cause the total supply to go over the cap. 35 | */ 36 | function _beforeTokenTransfer( 37 | address from, 38 | address to, 39 | uint256 amount 40 | ) internal virtual override { 41 | super._beforeTokenTransfer(from, to, amount); 42 | 43 | if (from == address(0)) { 44 | // When minting tokens 45 | require( 46 | totalSupply().add(amount) <= _cap, 47 | "ERC20Capped: cap exceeded" 48 | ); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20PausableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC20Upgradeable.sol"; 6 | import "../../utils/PausableUpgradeable.sol"; 7 | import "../../proxy/Initializable.sol"; 8 | 9 | /** 10 | * @dev ERC20 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | */ 16 | abstract contract ERC20PausableUpgradeable is 17 | Initializable, 18 | ERC20Upgradeable, 19 | PausableUpgradeable 20 | { 21 | function __ERC20Pausable_init() internal initializer { 22 | __Context_init_unchained(); 23 | __Pausable_init_unchained(); 24 | __ERC20Pausable_init_unchained(); 25 | } 26 | 27 | function __ERC20Pausable_init_unchained() internal initializer {} 28 | 29 | /** 30 | * @dev See {ERC20-_beforeTokenTransfer}. 31 | * 32 | * Requirements: 33 | * 34 | * - the contract must not be paused. 35 | */ 36 | function _beforeTokenTransfer( 37 | address from, 38 | address to, 39 | uint256 amount 40 | ) internal virtual override { 41 | super._beforeTokenTransfer(from, to, amount); 42 | 43 | require(!paused(), "ERC20Pausable: token transfer while paused"); 44 | } 45 | 46 | uint256[50] private __gap; 47 | } 48 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/GSN/README.adoc: -------------------------------------------------------------------------------- 1 | = Gas Station Network (GSN) 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/gsn 5 | 6 | This set of contracts provide all the tools required to make a contract callable via the https://gsn.openzeppelin.com[Gas Station Network]. 7 | 8 | TIP: If you're new to the GSN, head over to our xref:learn::sending-gasless-transactions.adoc[overview of the system] and basic guide to xref:ROOT:gsn.adoc[creating a GSN-capable contract]. 9 | 10 | The core contract a recipient must inherit from is {GSNRecipient}: it includes all necessary interfaces, as well as some helper methods to make interacting with the GSN easier. 11 | 12 | Utilities to make writing xref:ROOT:gsn-strategies.adoc[GSN strategies] easy are available in {GSNRecipient}, or you can simply use one of our pre-made strategies: 13 | 14 | * {GSNRecipientERC20Fee} charges the end user for gas costs in an application-specific xref:ROOT:tokens.adoc#ERC20[ERC20 token] 15 | * {GSNRecipientSignature} accepts all relayed calls that have been signed by a trusted third party (e.g. a private key in a backend) 16 | 17 | You can also take a look at the two contract interfaces that make up the GSN protocol: {IRelayRecipient} and {IRelayHub}, but you won't need to use those directly. 18 | 19 | == Recipient 20 | 21 | {{GSNRecipient}} 22 | 23 | == Strategies 24 | 25 | {{GSNRecipientSignature}} 26 | {{GSNRecipientERC20Fee}} 27 | 28 | == Protocol 29 | 30 | {{IRelayRecipient}} 31 | {{IRelayHub}} 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/GSN/README.adoc: -------------------------------------------------------------------------------- 1 | = Gas Station Network (GSN) 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/gsn 5 | 6 | This set of contracts provide all the tools required to make a contract callable via the https://gsn.openzeppelin.com[Gas Station Network]. 7 | 8 | TIP: If you're new to the GSN, head over to our xref:learn::sending-gasless-transactions.adoc[overview of the system] and basic guide to xref:ROOT:gsn.adoc[creating a GSN-capable contract]. 9 | 10 | The core contract a recipient must inherit from is {GSNRecipient}: it includes all necessary interfaces, as well as some helper methods to make interacting with the GSN easier. 11 | 12 | Utilities to make writing xref:ROOT:gsn-strategies.adoc[GSN strategies] easy are available in {GSNRecipient}, or you can simply use one of our pre-made strategies: 13 | 14 | * {GSNRecipientERC20Fee} charges the end user for gas costs in an application-specific xref:ROOT:tokens.adoc#ERC20[ERC20 token] 15 | * {GSNRecipientSignature} accepts all relayed calls that have been signed by a trusted third party (e.g. a private key in a backend) 16 | 17 | You can also take a look at the two contract interfaces that make up the GSN protocol: {IRelayRecipient} and {IRelayHub}, but you won't need to use those directly. 18 | 19 | == Recipient 20 | 21 | {{GSNRecipient}} 22 | 23 | == Strategies 24 | 25 | {{GSNRecipientSignature}} 26 | {{GSNRecipientERC20Fee}} 27 | 28 | == Protocol 29 | 30 | {{IRelayRecipient}} 31 | {{IRelayHub}} 32 | -------------------------------------------------------------------------------- /tests/examples/test_are_you_trying.py: -------------------------------------------------------------------------------- 1 | from brownie import * 2 | from helpers.constants import MaxUint256 3 | 4 | 5 | def test_are_you_trying(deployer, sett, strategy, want): 6 | """ 7 | Verifies that you set up the Strategy properly 8 | """ 9 | # Setup 10 | startingBalance = want.balanceOf(deployer) 11 | 12 | depositAmount = startingBalance // 2 13 | assert startingBalance >= depositAmount 14 | assert startingBalance >= 0 15 | # End Setup 16 | 17 | # Deposit 18 | assert want.balanceOf(sett) == 0 19 | 20 | want.approve(sett, MaxUint256, {"from": deployer}) 21 | sett.deposit(depositAmount, {"from": deployer}) 22 | 23 | available = sett.available() 24 | assert available > 0 25 | 26 | sett.earn({"from": deployer}) 27 | 28 | chain.sleep(10000 * 13) # Mine so we get some interest 29 | 30 | ## TEST 1: Does the want get used in any way? 31 | assert want.balanceOf(sett) == depositAmount - available 32 | 33 | # Did the strategy do something with the asset? 34 | assert want.balanceOf(strategy) < available 35 | 36 | # Use this if it should invest all 37 | # assert want.balanceOf(strategy) == 0 38 | 39 | # Change to this if the strat is supposed to hodl and do nothing 40 | # assert strategy.balanceOf(want) = depositAmount 41 | 42 | ## TEST 2: Is the Harvest profitable? 43 | harvest = strategy.harvest({"from": deployer}) 44 | event = harvest.events["Harvest"] 45 | # If it doesn't print, we don't want it 46 | assert event["harvested"] > 0 47 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/payment/escrow/ConditionalEscrowUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./EscrowUpgradeable.sol"; 6 | import "../../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @title ConditionalEscrow 10 | * @dev Base abstract escrow to only allow withdrawal if a condition is met. 11 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. 12 | */ 13 | abstract contract ConditionalEscrowUpgradeable is 14 | Initializable, 15 | EscrowUpgradeable 16 | { 17 | function __ConditionalEscrow_init() internal initializer { 18 | __Context_init_unchained(); 19 | __Ownable_init_unchained(); 20 | __Escrow_init_unchained(); 21 | __ConditionalEscrow_init_unchained(); 22 | } 23 | 24 | function __ConditionalEscrow_init_unchained() internal initializer {} 25 | 26 | /** 27 | * @dev Returns whether an address is allowed to withdraw their funds. To be 28 | * implemented by derived contracts. 29 | * @param payee The destination address of the funds. 30 | */ 31 | function withdrawalAllowed(address payee) 32 | public 33 | view 34 | virtual 35 | returns (bool); 36 | 37 | function withdraw(address payable payee) public virtual override { 38 | require( 39 | withdrawalAllowed(payee), 40 | "ConditionalEscrow: payee is not allowed to withdraw" 41 | ); 42 | super.withdraw(payee); 43 | } 44 | 45 | uint256[50] private __gap; 46 | } 47 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/proxy/README.adoc: -------------------------------------------------------------------------------- 1 | = Proxies 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/proxy 5 | 6 | This is a low-level set of contracts implementing the proxy pattern for upgradeability. For an in-depth overview of this pattern check out the xref:upgrades-plugins::proxies.adoc[Proxy Upgrade Pattern] page. 7 | 8 | The abstract {Proxy} contract implements the core delegation functionality. If the concrete proxies that we provide below are not suitable, we encourage building on top of this base contract since it contains an assembly block that may be hard to get right. 9 | 10 | Upgradeability is implemented in the {UpgradeableProxy} contract, although it provides only an internal upgrade interface. For an upgrade interface exposed externally to an admin, we provide {TransparentUpgradeableProxy}. Both of these contracts use the storage slots specified in https://eips.ethereum.org/EIPS/eip-1967[EIP1967] to avoid clashes with the storage of the implementation contract behind the proxy. 11 | 12 | CAUTION: Using upgradeable proxies correctly and securely is a difficult task that requires deep knowledge of the proxy pattern, Solidity, and the EVM. Unless you want a lot of low level control, we recommend using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins] for Truffle and Buidler. 13 | 14 | == Core 15 | 16 | {{Proxy}} 17 | 18 | {{UpgradeableProxy}} 19 | 20 | {{TransparentUpgradeableProxy}} 21 | 22 | == Utilities 23 | 24 | {{Initializable}} 25 | 26 | {{ProxyAdmin}} 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/proxy/README.adoc: -------------------------------------------------------------------------------- 1 | = Proxies 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/proxy 5 | 6 | This is a low-level set of contracts implementing the proxy pattern for upgradeability. For an in-depth overview of this pattern check out the xref:upgrades-plugins::proxies.adoc[Proxy Upgrade Pattern] page. 7 | 8 | The abstract {Proxy} contract implements the core delegation functionality. If the concrete proxies that we provide below are not suitable, we encourage building on top of this base contract since it contains an assembly block that may be hard to get right. 9 | 10 | Upgradeability is implemented in the {UpgradeableProxy} contract, although it provides only an internal upgrade interface. For an upgrade interface exposed externally to an admin, we provide {TransparentUpgradeableProxy}. Both of these contracts use the storage slots specified in https://eips.ethereum.org/EIPS/eip-1967[EIP1967] to avoid clashes with the storage of the implementation contract behind the proxy. 11 | 12 | CAUTION: Using upgradeable proxies correctly and securely is a difficult task that requires deep knowledge of the proxy pattern, Solidity, and the EVM. Unless you want a lot of low level control, we recommend using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins] for Truffle and Buidler. 13 | 14 | == Core 15 | 16 | {{Proxy}} 17 | 18 | {{UpgradeableProxy}} 19 | 20 | {{TransparentUpgradeableProxy}} 21 | 22 | == Utilities 23 | 24 | {{Initializable}} 25 | 26 | {{ProxyAdmin}} 27 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/ERC721PausableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC721Upgradeable.sol"; 6 | import "../../utils/PausableUpgradeable.sol"; 7 | import "../../proxy/Initializable.sol"; 8 | 9 | /** 10 | * @dev ERC721 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | */ 16 | abstract contract ERC721PausableUpgradeable is 17 | Initializable, 18 | ERC721Upgradeable, 19 | PausableUpgradeable 20 | { 21 | function __ERC721Pausable_init() internal initializer { 22 | __Context_init_unchained(); 23 | __ERC165_init_unchained(); 24 | __Pausable_init_unchained(); 25 | __ERC721Pausable_init_unchained(); 26 | } 27 | 28 | function __ERC721Pausable_init_unchained() internal initializer {} 29 | 30 | /** 31 | * @dev See {ERC721-_beforeTokenTransfer}. 32 | * 33 | * Requirements: 34 | * 35 | * - the contract must not be paused. 36 | */ 37 | function _beforeTokenTransfer( 38 | address from, 39 | address to, 40 | uint256 tokenId 41 | ) internal virtual override { 42 | super._beforeTokenTransfer(from, to, tokenId); 43 | 44 | require(!paused(), "ERC721Pausable: token transfer while paused"); 45 | } 46 | 47 | uint256[50] private __gap; 48 | } 49 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/cryptography/MerkleProof.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev These functions deal with verification of Merkle trees (hash trees), 7 | */ 8 | library MerkleProof { 9 | /** 10 | * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree 11 | * defined by `root`. For this, a `proof` must be provided, containing 12 | * sibling hashes on the branch from the leaf to the root of the tree. Each 13 | * pair of leaves and each pair of pre-images are assumed to be sorted. 14 | */ 15 | function verify( 16 | bytes32[] memory proof, 17 | bytes32 root, 18 | bytes32 leaf 19 | ) internal pure returns (bool) { 20 | bytes32 computedHash = leaf; 21 | 22 | for (uint256 i = 0; i < proof.length; i++) { 23 | bytes32 proofElement = proof[i]; 24 | 25 | if (computedHash <= proofElement) { 26 | // Hash(current computed hash + current element of the proof) 27 | computedHash = keccak256( 28 | abi.encodePacked(computedHash, proofElement) 29 | ); 30 | } else { 31 | // Hash(current element of the proof + current computed hash) 32 | computedHash = keccak256( 33 | abi.encodePacked(proofElement, computedHash) 34 | ); 35 | } 36 | } 37 | 38 | // Check if the computed hash (root) is equal to the provided root 39 | return computedHash == root; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/upgradeability/InitializableAdminUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | import "./BaseAdminUpgradeabilityProxy.sol"; 4 | import "./InitializableUpgradeabilityProxy.sol"; 5 | 6 | /** 7 | * @title InitializableAdminUpgradeabilityProxy 8 | * @dev Extends from BaseAdminUpgradeabilityProxy with an initializer for 9 | * initializing the implementation, admin, and init data. 10 | */ 11 | contract InitializableAdminUpgradeabilityProxy is 12 | BaseAdminUpgradeabilityProxy, 13 | InitializableUpgradeabilityProxy 14 | { 15 | /** 16 | * Contract initializer. 17 | * @param _logic address of the initial implementation. 18 | * @param _admin Address of the proxy administrator. 19 | * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. 20 | * It should include the signature and the parameters of the function to be called, as described in 21 | * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. 22 | * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. 23 | */ 24 | function initialize( 25 | address _logic, 26 | address _admin, 27 | bytes memory _data 28 | ) public payable { 29 | require(_implementation() == address(0)); 30 | InitializableUpgradeabilityProxy.initialize(_logic, _data); 31 | assert( 32 | ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1) 33 | ); 34 | _setAdmin(_admin); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /helpers/multicall/signature.py: -------------------------------------------------------------------------------- 1 | # Credit: https://github.com/banteg/multicall.py/blob/master/multicall/signature.py 2 | 3 | from eth_abi import encode_single, decode_single 4 | from eth_utils import function_signature_to_4byte_selector 5 | 6 | 7 | def parse_signature(signature): 8 | """ 9 | Breaks 'func(address)(uint256)' into ['func', '(address)', '(uint256)'] 10 | """ 11 | parts = [] 12 | stack = [] 13 | start = 0 14 | for end, letter in enumerate(signature): 15 | if letter == "(": 16 | stack.append(letter) 17 | if not parts: 18 | parts.append(signature[start:end]) 19 | start = end 20 | if letter == ")": 21 | stack.pop() 22 | if not stack: # we are only interested in outermost groups 23 | parts.append(signature[start : end + 1]) 24 | start = end + 1 25 | return parts 26 | 27 | 28 | class Signature: 29 | def __init__(self, signature): 30 | self.signature = signature 31 | self.parts = parse_signature(signature) 32 | self.input_types = self.parts[1] 33 | self.output_types = self.parts[2] 34 | self.function = "".join(self.parts[:2]) 35 | self.fourbyte = function_signature_to_4byte_selector(self.function) 36 | 37 | def encode_data(self, args=None): 38 | return ( 39 | self.fourbyte + encode_single(self.input_types, args) 40 | if args 41 | else self.fourbyte 42 | ) 43 | 44 | def decode_data(self, output): 45 | return decode_single(self.output_types, output) 46 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/cryptography/MerkleProofUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev These functions deal with verification of Merkle trees (hash trees), 7 | */ 8 | library MerkleProofUpgradeable { 9 | /** 10 | * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree 11 | * defined by `root`. For this, a `proof` must be provided, containing 12 | * sibling hashes on the branch from the leaf to the root of the tree. Each 13 | * pair of leaves and each pair of pre-images are assumed to be sorted. 14 | */ 15 | function verify( 16 | bytes32[] memory proof, 17 | bytes32 root, 18 | bytes32 leaf 19 | ) internal pure returns (bool) { 20 | bytes32 computedHash = leaf; 21 | 22 | for (uint256 i = 0; i < proof.length; i++) { 23 | bytes32 proofElement = proof[i]; 24 | 25 | if (computedHash <= proofElement) { 26 | // Hash(current computed hash + current element of the proof) 27 | computedHash = keccak256( 28 | abi.encodePacked(computedHash, proofElement) 29 | ); 30 | } else { 31 | // Hash(current element of the proof + current computed hash) 32 | computedHash = keccak256( 33 | abi.encodePacked(proofElement, computedHash) 34 | ); 35 | } 36 | } 37 | 38 | // Check if the computed hash (root) is equal to the provided root 39 | return computedHash == root; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155BurnableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC1155Upgradeable.sol"; 6 | import "../../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev Extension of {ERC1155} that allows token holders to destroy both their 10 | * own tokens and those that they have been approved to use. 11 | * 12 | * _Available since v3.1._ 13 | */ 14 | abstract contract ERC1155BurnableUpgradeable is 15 | Initializable, 16 | ERC1155Upgradeable 17 | { 18 | function __ERC1155Burnable_init() internal initializer { 19 | __Context_init_unchained(); 20 | __ERC165_init_unchained(); 21 | __ERC1155Burnable_init_unchained(); 22 | } 23 | 24 | function __ERC1155Burnable_init_unchained() internal initializer {} 25 | 26 | function burn( 27 | address account, 28 | uint256 id, 29 | uint256 value 30 | ) public virtual { 31 | require( 32 | account == _msgSender() || isApprovedForAll(account, _msgSender()), 33 | "ERC1155: caller is not owner nor approved" 34 | ); 35 | 36 | _burn(account, id, value); 37 | } 38 | 39 | function burnBatch( 40 | address account, 41 | uint256[] memory ids, 42 | uint256[] memory values 43 | ) public virtual { 44 | require( 45 | account == _msgSender() || isApprovedForAll(account, _msgSender()), 46 | "ERC1155: caller is not owner nor approved" 47 | ); 48 | 49 | _burnBatch(account, ids, values); 50 | } 51 | 52 | uint256[50] private __gap; 53 | } 54 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 1155 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc1155 5 | 6 | This set of interfaces and contracts are all related to the https://eips.ethereum.org/EIPS/eip-1155[ERC1155 Multi Token Standard]. 7 | 8 | The EIP consists of three interfaces which fulfill different roles, found here as {IERC1155}, {IERC1155MetadataURI} and {IERC1155Receiver}. 9 | 10 | {ERC1155} implements the mandatory {IERC1155} interface, as well as the optional extension {IERC1155MetadataURI}, by relying on the substitution mechanism to use the same URI for all token types, dramatically reducing gas costs. 11 | 12 | Additionally there are multiple custom extensions, including: 13 | 14 | * designation of addresses that can pause token transfers for all users ({ERC1155Pausable}). 15 | * destruction of own tokens ({ERC1155Burnable}). 16 | 17 | NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC1155 (such as <>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc1155.adoc#Presets[ERC1155 Presets] (such as {ERC1155PresetMinterPauser}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts. 18 | 19 | == Core 20 | 21 | {{IERC1155}} 22 | 23 | {{IERC1155MetadataURI}} 24 | 25 | {{ERC1155}} 26 | 27 | {{IERC1155Receiver}} 28 | 29 | == Extensions 30 | 31 | {{ERC1155Pausable}} 32 | 33 | {{ERC1155Burnable}} 34 | 35 | == Convenience 36 | 37 | {{ERC1155Holder}} 38 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 1155 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc1155 5 | 6 | This set of interfaces and contracts are all related to the https://eips.ethereum.org/EIPS/eip-1155[ERC1155 Multi Token Standard]. 7 | 8 | The EIP consists of three interfaces which fulfill different roles, found here as {IERC1155}, {IERC1155MetadataURI} and {IERC1155Receiver}. 9 | 10 | {ERC1155} implements the mandatory {IERC1155} interface, as well as the optional extension {IERC1155MetadataURI}, by relying on the substitution mechanism to use the same URI for all token types, dramatically reducing gas costs. 11 | 12 | Additionally there are multiple custom extensions, including: 13 | 14 | * designation of addresses that can pause token transfers for all users ({ERC1155Pausable}). 15 | * destruction of own tokens ({ERC1155Burnable}). 16 | 17 | NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC1155 (such as <>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc1155.adoc#Presets[ERC1155 Presets] (such as {ERC1155PresetMinterPauser}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts. 18 | 19 | == Core 20 | 21 | {{IERC1155}} 22 | 23 | {{IERC1155MetadataURI}} 24 | 25 | {{ERC1155}} 26 | 27 | {{IERC1155Receiver}} 28 | 29 | == Extensions 30 | 31 | {{ERC1155Pausable}} 32 | 33 | {{ERC1155Burnable}} 34 | 35 | == Convenience 36 | 37 | {{ERC1155Holder}} 38 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/introspection/ERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC1820Implementer.sol"; 6 | 7 | /** 8 | * @dev Implementation of the {IERC1820Implementer} interface. 9 | * 10 | * Contracts may inherit from this and call {_registerInterfaceForAddress} to 11 | * declare their willingness to be implementers. 12 | * {IERC1820Registry-setInterfaceImplementer} should then be called for the 13 | * registration to be complete. 14 | */ 15 | contract ERC1820Implementer is IERC1820Implementer { 16 | bytes32 private constant _ERC1820_ACCEPT_MAGIC = 17 | keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); 18 | 19 | mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; 20 | 21 | /** 22 | * See {IERC1820Implementer-canImplementInterfaceForAddress}. 23 | */ 24 | function canImplementInterfaceForAddress( 25 | bytes32 interfaceHash, 26 | address account 27 | ) public view override returns (bytes32) { 28 | return 29 | _supportedInterfaces[interfaceHash][account] 30 | ? _ERC1820_ACCEPT_MAGIC 31 | : bytes32(0x00); 32 | } 33 | 34 | /** 35 | * @dev Declares the contract as willing to be an implementer of 36 | * `interfaceHash` for `account`. 37 | * 38 | * See {IERC1820Registry-setInterfaceImplementer} and 39 | * {IERC1820Registry-interfaceHash}. 40 | */ 41 | function _registerInterfaceForAddress( 42 | bytes32 interfaceHash, 43 | address account 44 | ) internal virtual { 45 | _supportedInterfaces[interfaceHash][account] = true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/Counters.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../math/SafeMath.sol"; 6 | 7 | /** 8 | * @title Counters 9 | * @author Matt Condon (@shrugs) 10 | * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number 11 | * of elements in a mapping, issuing ERC721 ids, or counting request ids. 12 | * 13 | * Include with `using Counters for Counters.Counter;` 14 | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} 15 | * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never 16 | * directly accessed. 17 | */ 18 | library Counters { 19 | using SafeMath for uint256; 20 | 21 | struct Counter { 22 | // This variable should never be directly accessed by users of the library: interactions must be restricted to 23 | // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add 24 | // this feature: see https://github.com/ethereum/solidity/issues/4637 25 | uint256 _value; // default: 0 26 | } 27 | 28 | function current(Counter storage counter) internal view returns (uint256) { 29 | return counter._value; 30 | } 31 | 32 | function increment(Counter storage counter) internal { 33 | // The {SafeMath} overflow check can be skipped here, see the comment at the top 34 | counter._value += 1; 35 | } 36 | 37 | function decrement(Counter storage counter) internal { 38 | counter._value = counter._value.sub(1); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/utils/Address.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | /** 4 | * Utility library of inline functions on addresses 5 | * 6 | * Source https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-solidity/v2.1.3/contracts/utils/Address.sol 7 | * This contract is copied here and renamed from the original to avoid clashes in the compiled artifacts 8 | * when the user imports a zos-lib contract (that transitively causes this contract to be compiled and added to the 9 | * build/artifacts folder) as well as the vanilla Address implementation from an openzeppelin version. 10 | */ 11 | library OpenZeppelinUpgradesAddress { 12 | /** 13 | * Returns whether the target address is a contract 14 | * @dev This function will return false if invoked during the constructor of a contract, 15 | * as the code is not actually created until after the constructor finishes. 16 | * @param account address of the account to check 17 | * @return whether the target address is a contract 18 | */ 19 | function isContract(address account) internal view returns (bool) { 20 | uint256 size; 21 | // XXX Currently there is no better way to check if there is a contract in an address 22 | // than to check the size of the code at that address. 23 | // See https://ethereum.stackexchange.com/a/14016/36603 24 | // for more details about how this works. 25 | // TODO Check this again before the Serenity release, because all addresses will be 26 | // contracts then. 27 | // solhint-disable-next-line no-inline-assembly 28 | assembly { 29 | size := extcodesize(account) 30 | } 31 | return size > 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155PausableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC1155Upgradeable.sol"; 6 | import "../../utils/PausableUpgradeable.sol"; 7 | import "../../proxy/Initializable.sol"; 8 | 9 | /** 10 | * @dev ERC1155 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | * 16 | * _Available since v3.1._ 17 | */ 18 | abstract contract ERC1155PausableUpgradeable is 19 | Initializable, 20 | ERC1155Upgradeable, 21 | PausableUpgradeable 22 | { 23 | function __ERC1155Pausable_init() internal initializer { 24 | __Context_init_unchained(); 25 | __ERC165_init_unchained(); 26 | __Pausable_init_unchained(); 27 | __ERC1155Pausable_init_unchained(); 28 | } 29 | 30 | function __ERC1155Pausable_init_unchained() internal initializer {} 31 | 32 | /** 33 | * @dev See {ERC1155-_beforeTokenTransfer}. 34 | * 35 | * Requirements: 36 | * 37 | * - the contract must not be paused. 38 | */ 39 | function _beforeTokenTransfer( 40 | address operator, 41 | address from, 42 | address to, 43 | uint256[] memory ids, 44 | uint256[] memory amounts, 45 | bytes memory data 46 | ) internal virtual override { 47 | super._beforeTokenTransfer(operator, from, to, ids, amounts, data); 48 | 49 | require(!paused(), "ERC1155Pausable: token transfer while paused"); 50 | } 51 | 52 | uint256[50] private __gap; 53 | } 54 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/Arrays.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../math/Math.sol"; 6 | 7 | /** 8 | * @dev Collection of functions related to array types. 9 | */ 10 | library Arrays { 11 | /** 12 | * @dev Searches a sorted `array` and returns the first index that contains 13 | * a value greater or equal to `element`. If no such index exists (i.e. all 14 | * values in the array are strictly less than `element`), the array length is 15 | * returned. Time complexity O(log n). 16 | * 17 | * `array` is expected to be sorted in ascending order, and to contain no 18 | * repeated elements. 19 | */ 20 | function findUpperBound(uint256[] storage array, uint256 element) 21 | internal 22 | view 23 | returns (uint256) 24 | { 25 | if (array.length == 0) { 26 | return 0; 27 | } 28 | 29 | uint256 low = 0; 30 | uint256 high = array.length; 31 | 32 | while (low < high) { 33 | uint256 mid = Math.average(low, high); 34 | 35 | // Note that mid will always be strictly less than high (i.e. it will be a valid array index) 36 | // because Math.average rounds down (it does integer division with truncation). 37 | if (array[mid] > element) { 38 | high = mid; 39 | } else { 40 | low = mid + 1; 41 | } 42 | } 43 | 44 | // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. 45 | if (low > 0 && array[low - 1] == element) { 46 | return low - 1; 47 | } else { 48 | return low; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../math/SafeMathUpgradeable.sol"; 6 | 7 | /** 8 | * @title Counters 9 | * @author Matt Condon (@shrugs) 10 | * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number 11 | * of elements in a mapping, issuing ERC721 ids, or counting request ids. 12 | * 13 | * Include with `using Counters for Counters.Counter;` 14 | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} 15 | * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never 16 | * directly accessed. 17 | */ 18 | library CountersUpgradeable { 19 | using SafeMathUpgradeable for uint256; 20 | 21 | struct Counter { 22 | // This variable should never be directly accessed by users of the library: interactions must be restricted to 23 | // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add 24 | // this feature: see https://github.com/ethereum/solidity/issues/4637 25 | uint256 _value; // default: 0 26 | } 27 | 28 | function current(Counter storage counter) internal view returns (uint256) { 29 | return counter._value; 30 | } 31 | 32 | function increment(Counter storage counter) internal { 33 | // The {SafeMath} overflow check can be skipped here, see the comment at the top 34 | counter._value += 1; 35 | } 36 | 37 | function decrement(Counter storage counter) internal { 38 | counter._value = counter._value.sub(1); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/utils/ArraysUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../math/MathUpgradeable.sol"; 6 | 7 | /** 8 | * @dev Collection of functions related to array types. 9 | */ 10 | library ArraysUpgradeable { 11 | /** 12 | * @dev Searches a sorted `array` and returns the first index that contains 13 | * a value greater or equal to `element`. If no such index exists (i.e. all 14 | * values in the array are strictly less than `element`), the array length is 15 | * returned. Time complexity O(log n). 16 | * 17 | * `array` is expected to be sorted in ascending order, and to contain no 18 | * repeated elements. 19 | */ 20 | function findUpperBound(uint256[] storage array, uint256 element) 21 | internal 22 | view 23 | returns (uint256) 24 | { 25 | if (array.length == 0) { 26 | return 0; 27 | } 28 | 29 | uint256 low = 0; 30 | uint256 high = array.length; 31 | 32 | while (low < high) { 33 | uint256 mid = MathUpgradeable.average(low, high); 34 | 35 | // Note that mid will always be strictly less than high (i.e. it will be a valid array index) 36 | // because Math.average rounds down (it does integer division with truncation). 37 | if (array[mid] > element) { 38 | high = mid; 39 | } else { 40 | low = mid + 1; 41 | } 42 | } 43 | 44 | // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. 45 | if (low > 0 && array[low - 1] == element) { 46 | return low - 1; 47 | } else { 48 | return low; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/test_profitable.py: -------------------------------------------------------------------------------- 1 | import brownie 2 | from brownie import * 3 | from helpers.constants import MaxUint256 4 | from helpers.SnapshotManager import SnapshotManager 5 | from config import DEFAULT_WITHDRAWAL_FEE 6 | 7 | MAX_BASIS = 10000 8 | 9 | 10 | def test_is_profitable(deployed): 11 | deployer = deployed.deployer 12 | vault = deployed.vault 13 | controller = deployed.controller 14 | strategy = deployed.strategy 15 | want = deployed.want 16 | randomUser = accounts[6] 17 | 18 | initial_balance = want.balanceOf(deployer) 19 | 20 | settKeeper = accounts.at(vault.keeper(), force=True) 21 | 22 | snap = SnapshotManager(vault, strategy, controller, "StrategySnapshot") 23 | 24 | # Deposit 25 | assert want.balanceOf(deployer) > 0 26 | 27 | depositAmount = int(want.balanceOf(deployer) * 0.8) 28 | assert depositAmount > 0 29 | 30 | want.approve(vault.address, MaxUint256, {"from": deployer}) 31 | 32 | snap.settDeposit(depositAmount, {"from": deployer}) 33 | 34 | # Earn 35 | with brownie.reverts("onlyAuthorizedActors"): 36 | vault.earn({"from": randomUser}) 37 | 38 | min = vault.min() 39 | max = vault.max() 40 | remain = max - min 41 | 42 | snap.settEarn({"from": settKeeper}) 43 | 44 | chain.sleep(15) 45 | chain.mine(1) 46 | 47 | snap.settWithdrawAll({"from": deployer}) 48 | 49 | ending_balance = want.balanceOf(deployer) 50 | 51 | initial_balance_with_fees = initial_balance * ( 52 | 1 - (DEFAULT_WITHDRAWAL_FEE / MAX_BASIS) 53 | ) 54 | 55 | print("Initial Balance") 56 | print(initial_balance) 57 | print("initial_balance_with_fees") 58 | print(initial_balance_with_fees) 59 | print("Ending Balance") 60 | print(ending_balance) 61 | 62 | assert ending_balance > initial_balance_with_fees 63 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20CappedUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./ERC20Upgradeable.sol"; 6 | import "../../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev Extension of {ERC20} that adds a cap to the supply of tokens. 10 | */ 11 | abstract contract ERC20CappedUpgradeable is Initializable, ERC20Upgradeable { 12 | uint256 private _cap; 13 | 14 | /** 15 | * @dev Sets the value of the `cap`. This value is immutable, it can only be 16 | * set once during construction. 17 | */ 18 | function __ERC20Capped_init(uint256 cap) internal initializer { 19 | __Context_init_unchained(); 20 | __ERC20Capped_init_unchained(cap); 21 | } 22 | 23 | function __ERC20Capped_init_unchained(uint256 cap) internal initializer { 24 | require(cap > 0, "ERC20Capped: cap is 0"); 25 | _cap = cap; 26 | } 27 | 28 | /** 29 | * @dev Returns the cap on the token's total supply. 30 | */ 31 | function cap() public view returns (uint256) { 32 | return _cap; 33 | } 34 | 35 | /** 36 | * @dev See {ERC20-_beforeTokenTransfer}. 37 | * 38 | * Requirements: 39 | * 40 | * - minted tokens must not cause the total supply to go over the cap. 41 | */ 42 | function _beforeTokenTransfer( 43 | address from, 44 | address to, 45 | uint256 amount 46 | ) internal virtual override { 47 | super._beforeTokenTransfer(from, to, amount); 48 | 49 | if (from == address(0)) { 50 | // When minting tokens 51 | require( 52 | totalSupply().add(amount) <= _cap, 53 | "ERC20Capped: cap exceeded" 54 | ); 55 | } 56 | } 57 | 58 | uint256[49] private __gap; 59 | } 60 | -------------------------------------------------------------------------------- /deps/SettAccessControl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.11; 3 | 4 | import "./@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; 5 | 6 | /* 7 | Common base for permissioned roles throughout Sett ecosystem 8 | */ 9 | contract SettAccessControl is Initializable { 10 | address public governance; 11 | address public strategist; 12 | address public keeper; 13 | 14 | // ===== MODIFIERS ===== 15 | function _onlyGovernance() internal view { 16 | require(msg.sender == governance, "onlyGovernance"); 17 | } 18 | 19 | function _onlyGovernanceOrStrategist() internal view { 20 | require( 21 | msg.sender == strategist || msg.sender == governance, 22 | "onlyGovernanceOrStrategist" 23 | ); 24 | } 25 | 26 | function _onlyAuthorizedActors() internal view { 27 | require( 28 | msg.sender == keeper || msg.sender == governance, 29 | "onlyAuthorizedActors" 30 | ); 31 | } 32 | 33 | // ===== PERMISSIONED ACTIONS ===== 34 | 35 | /// @notice Change strategist address 36 | /// @notice Can only be changed by governance itself 37 | function setStrategist(address _strategist) external { 38 | _onlyGovernance(); 39 | strategist = _strategist; 40 | } 41 | 42 | /// @notice Change keeper address 43 | /// @notice Can only be changed by governance itself 44 | function setKeeper(address _keeper) external { 45 | _onlyGovernance(); 46 | keeper = _keeper; 47 | } 48 | 49 | /// @notice Change governance address 50 | /// @notice Can only be changed by governance itself 51 | function setGovernance(address _governance) public { 52 | _onlyGovernance(); 53 | governance = _governance; 54 | } 55 | 56 | uint256[50] private __gap; 57 | } 58 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../GSN/ContextUpgradeable.sol"; 6 | import "./ERC20Upgradeable.sol"; 7 | import "../../proxy/Initializable.sol"; 8 | 9 | /** 10 | * @dev Extension of {ERC20} that allows token holders to destroy both their own 11 | * tokens and those that they have an allowance for, in a way that can be 12 | * recognized off-chain (via event analysis). 13 | */ 14 | abstract contract ERC20BurnableUpgradeable is 15 | Initializable, 16 | ContextUpgradeable, 17 | ERC20Upgradeable 18 | { 19 | function __ERC20Burnable_init() internal initializer { 20 | __Context_init_unchained(); 21 | __ERC20Burnable_init_unchained(); 22 | } 23 | 24 | function __ERC20Burnable_init_unchained() internal initializer {} 25 | 26 | /** 27 | * @dev Destroys `amount` tokens from the caller. 28 | * 29 | * See {ERC20-_burn}. 30 | */ 31 | function burn(uint256 amount) public virtual { 32 | _burn(_msgSender(), amount); 33 | } 34 | 35 | /** 36 | * @dev Destroys `amount` tokens from `account`, deducting from the caller's 37 | * allowance. 38 | * 39 | * See {ERC20-_burn} and {ERC20-allowance}. 40 | * 41 | * Requirements: 42 | * 43 | * - the caller must have allowance for ``accounts``'s tokens of at least 44 | * `amount`. 45 | */ 46 | function burnFrom(address account, uint256 amount) public virtual { 47 | uint256 decreasedAllowance = 48 | allowance(account, _msgSender()).sub( 49 | amount, 50 | "ERC20: burn amount exceeds allowance" 51 | ); 52 | 53 | _approve(account, _msgSender(), decreasedAllowance); 54 | _burn(account, amount); 55 | } 56 | 57 | uint256[50] private __gap; 58 | } 59 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - develop 8 | workflow_dispatch: 9 | pull_request: 10 | 11 | jobs: 12 | test: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v1 17 | 18 | - name: Cache compiler installations 19 | uses: actions/cache@v2 20 | with: 21 | path: | 22 | ~/.solcx 23 | ~/.vvm 24 | key: ${{ runner.os }}-compiler-cache 25 | 26 | - name: Setup node.js 27 | uses: actions/setup-node@v1 28 | with: 29 | node-version: '14.x' 30 | 31 | - name: Install ganache 32 | run: npm install -g ganache-cli@6.12.1 33 | 34 | - name: Set up python 3.9 35 | uses: actions/setup-python@v2 36 | with: 37 | python-version: 3.9 38 | 39 | - name: Set pip cache directory path 40 | id: pip-cache-dir-path 41 | run: | 42 | echo "::set-output name=dir::$(pip cache dir)" 43 | 44 | - name: Restore pip cache 45 | uses: actions/cache@v2 46 | id: pip-cache 47 | with: 48 | path: | 49 | ${{ steps.pip-cache-dir-path.outputs.dir }} 50 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 51 | restore-keys: | 52 | ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 53 | ${{ runner.os }}-pip- 54 | 55 | - name: Install python dependencies 56 | run: pip install -r requirements.txt 57 | 58 | - name: Compile Code 59 | run: brownie compile --size 60 | 61 | - name: Run Tests 62 | env: 63 | ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }} 64 | WEB3_INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }} 65 | run: | 66 | [ -f network-config.yaml ] && brownie networks import network-config.yaml true 67 | brownie test 68 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/introspection/README.adoc: -------------------------------------------------------------------------------- 1 | = Introspection 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/introspection 5 | 6 | This set of interfaces and contracts deal with https://en.wikipedia.org/wiki/Type_introspection[type introspection] of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_. 7 | 8 | Ethereum contracts have no native concept of an interface, so applications must usually simply trust they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may even not be any direct calls to them! (e.g. `ERC20` tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors. 9 | 10 | There are two main ways to approach this. 11 | 12 | * Locally, where a contract implements `IERC165` and declares an interface, and a second one queries it directly via `ERC165Checker`. 13 | * Globally, where a global and unique registry (`IERC1820Registry`) is used to register implementers of a certain interface (`IERC1820Implementer`). It is then the registry that is queried, which allows for more complex setups, like contracts implementing interfaces for externally-owned accounts. 14 | 15 | Note that, in all cases, accounts simply _declare_ their interfaces, but they are not required to actually implement them. This mechanism can therefore be used to both prevent errors and allow for complex interactions (see `ERC777`), but it must not be relied on for security. 16 | 17 | == Local 18 | 19 | {{IERC165}} 20 | 21 | {{ERC165}} 22 | 23 | {{ERC165Checker}} 24 | 25 | == Global 26 | 27 | {{IERC1820Registry}} 28 | 29 | {{IERC1820Implementer}} 30 | 31 | {{ERC1820Implementer}} 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/introspection/README.adoc: -------------------------------------------------------------------------------- 1 | = Introspection 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/introspection 5 | 6 | This set of interfaces and contracts deal with https://en.wikipedia.org/wiki/Type_introspection[type introspection] of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_. 7 | 8 | Ethereum contracts have no native concept of an interface, so applications must usually simply trust they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may even not be any direct calls to them! (e.g. `ERC20` tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors. 9 | 10 | There are two main ways to approach this. 11 | 12 | * Locally, where a contract implements `IERC165` and declares an interface, and a second one queries it directly via `ERC165Checker`. 13 | * Globally, where a global and unique registry (`IERC1820Registry`) is used to register implementers of a certain interface (`IERC1820Implementer`). It is then the registry that is queried, which allows for more complex setups, like contracts implementing interfaces for externally-owned accounts. 14 | 15 | Note that, in all cases, accounts simply _declare_ their interfaces, but they are not required to actually implement them. This mechanism can therefore be used to both prevent errors and allow for complex interactions (see `ERC777`), but it must not be relied on for security. 16 | 17 | == Local 18 | 19 | {{IERC165}} 20 | 21 | {{ERC165}} 22 | 23 | {{ERC165Checker}} 24 | 25 | == Global 26 | 27 | {{IERC1820Registry}} 28 | 29 | {{IERC1820Implementer}} 30 | 31 | {{ERC1820Implementer}} 32 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/introspection/ERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC165.sol"; 6 | 7 | /** 8 | * @dev Implementation of the {IERC165} interface. 9 | * 10 | * Contracts may inherit from this and call {_registerInterface} to declare 11 | * their support of an interface. 12 | */ 13 | contract ERC165 is IERC165 { 14 | /* 15 | * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 16 | */ 17 | bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; 18 | 19 | /** 20 | * @dev Mapping of interface ids to whether or not it's supported. 21 | */ 22 | mapping(bytes4 => bool) private _supportedInterfaces; 23 | 24 | constructor() internal { 25 | // Derived contracts need only register support for their own interfaces, 26 | // we register support for ERC165 itself here 27 | _registerInterface(_INTERFACE_ID_ERC165); 28 | } 29 | 30 | /** 31 | * @dev See {IERC165-supportsInterface}. 32 | * 33 | * Time complexity O(1), guaranteed to always use less than 30 000 gas. 34 | */ 35 | function supportsInterface(bytes4 interfaceId) 36 | public 37 | view 38 | override 39 | returns (bool) 40 | { 41 | return _supportedInterfaces[interfaceId]; 42 | } 43 | 44 | /** 45 | * @dev Registers the contract as an implementer of the interface defined by 46 | * `interfaceId`. Support of the actual ERC165 interface is automatic and 47 | * registering its interface id is not required. 48 | * 49 | * See {IERC165-supportsInterface}. 50 | * 51 | * Requirements: 52 | * 53 | * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). 54 | */ 55 | function _registerInterface(bytes4 interfaceId) internal virtual { 56 | require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); 57 | _supportedInterfaces[interfaceId] = true; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "@openzeppelin/contracts", 3 | "_id": "@openzeppelin/contracts@3.2.0", 4 | "_inBundle": false, 5 | "_integrity": "sha512-bUOmkSoPkjnUyMiKo6RYnb0VHBk5D9KKDAgNLzF41aqAM3TeE0yGdFF5dVRcV60pZdJLlyFT/jjXIZCWyyEzAQ==", 6 | "_location": "/@openzeppelin/contracts", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "@openzeppelin/contracts", 12 | "name": "@openzeppelin/contracts", 13 | "escapedName": "@openzeppelin%2fcontracts", 14 | "scope": "@openzeppelin", 15 | "rawSpec": "", 16 | "saveSpec": null, 17 | "fetchSpec": "latest" 18 | }, 19 | "_requiredBy": [ 20 | "#USER", 21 | "/" 22 | ], 23 | "_resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-3.2.0.tgz", 24 | "_shasum": "3e6b3a7662d8ed64271ade96ef42655db983fd9d", 25 | "_spec": "@openzeppelin/contracts", 26 | "_where": "/Users/present/code/brownie-sett", 27 | "author": { 28 | "name": "OpenZeppelin Community", 29 | "email": "maintainers@openzeppelin.org" 30 | }, 31 | "bugs": { 32 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" 33 | }, 34 | "bundleDependencies": false, 35 | "deprecated": false, 36 | "description": "Secure Smart Contract library for Solidity", 37 | "files": [ 38 | "**/*.sol", 39 | "/build/contracts/*.json", 40 | "!/mocks", 41 | "!/examples" 42 | ], 43 | "homepage": "https://openzeppelin.com/contracts/", 44 | "keywords": [ 45 | "solidity", 46 | "ethereum", 47 | "smart", 48 | "contracts", 49 | "security", 50 | "zeppelin" 51 | ], 52 | "license": "MIT", 53 | "name": "@openzeppelin/contracts", 54 | "repository": { 55 | "type": "git", 56 | "url": "git+https://github.com/OpenZeppelin/openzeppelin-contracts.git" 57 | }, 58 | "scripts": { 59 | "prepare": "bash ../scripts/prepare-contracts-package.sh", 60 | "prepare-docs": "cd ..; npm run prepare-docs" 61 | }, 62 | "version": "3.2.0" 63 | } 64 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/introspection/ERC1820ImplementerUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC1820ImplementerUpgradeable.sol"; 6 | import "../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC1820Implementer} interface. 10 | * 11 | * Contracts may inherit from this and call {_registerInterfaceForAddress} to 12 | * declare their willingness to be implementers. 13 | * {IERC1820Registry-setInterfaceImplementer} should then be called for the 14 | * registration to be complete. 15 | */ 16 | contract ERC1820ImplementerUpgradeable is 17 | Initializable, 18 | IERC1820ImplementerUpgradeable 19 | { 20 | function __ERC1820Implementer_init() internal initializer { 21 | __ERC1820Implementer_init_unchained(); 22 | } 23 | 24 | function __ERC1820Implementer_init_unchained() internal initializer {} 25 | 26 | bytes32 private constant _ERC1820_ACCEPT_MAGIC = 27 | keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); 28 | 29 | mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; 30 | 31 | /** 32 | * See {IERC1820Implementer-canImplementInterfaceForAddress}. 33 | */ 34 | function canImplementInterfaceForAddress( 35 | bytes32 interfaceHash, 36 | address account 37 | ) public view override returns (bytes32) { 38 | return 39 | _supportedInterfaces[interfaceHash][account] 40 | ? _ERC1820_ACCEPT_MAGIC 41 | : bytes32(0x00); 42 | } 43 | 44 | /** 45 | * @dev Declares the contract as willing to be an implementer of 46 | * `interfaceHash` for `account`. 47 | * 48 | * See {IERC1820Registry-setInterfaceImplementer} and 49 | * {IERC1820Registry-interfaceHash}. 50 | */ 51 | function _registerInterfaceForAddress( 52 | bytes32 interfaceHash, 53 | address account 54 | ) internal virtual { 55 | _supportedInterfaces[interfaceHash][account] = true; 56 | } 57 | 58 | uint256[49] private __gap; 59 | } 60 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC721/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 721 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc721 5 | 6 | This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-721[ERC721 Non-Fungible Token Standard]. 7 | 8 | TIP: For a walk through on how to create an ERC721 token read our xref:ROOT:erc721.adoc[ERC721 guide]. 9 | 10 | The EIP consists of three interfaces, found here as {IERC721}, {IERC721Metadata}, and {IERC721Enumerable}. Only the first one is required in a contract to be ERC721 compliant. However, all three are implemented in {ERC721}. 11 | 12 | Additionally, {IERC721Receiver} can be used to prevent tokens from becoming forever locked in contracts. Imagine sending an in-game item to an exchange address that can't send it back!. When using <>, the token contract checks to see that the receiver is an {IERC721Receiver}, which implies that it knows how to handle {ERC721} tokens. If you're writing a contract that needs to receive {ERC721} tokens, you'll want to include this interface. 13 | 14 | Additionally there are multiple custom extensions, including: 15 | 16 | * designation of addresses that can pause token transfers for all users ({ERC721Pausable}). 17 | * destruction of own tokens ({ERC721Burnable}). 18 | 19 | NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC721 (such as <>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc721.adoc#Presets[ERC721 Presets] (such as {ERC721PresetMinterPauserAutoId}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts. 20 | 21 | 22 | == Core 23 | 24 | {{IERC721}} 25 | 26 | {{IERC721Metadata}} 27 | 28 | {{IERC721Enumerable}} 29 | 30 | {{ERC721}} 31 | 32 | {{IERC721Receiver}} 33 | 34 | == Extensions 35 | 36 | {{ERC721Pausable}} 37 | 38 | {{ERC721Burnable}} 39 | 40 | == Convenience 41 | 42 | {{ERC721Holder}} 43 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC721/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 721 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc721 5 | 6 | This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-721[ERC721 Non-Fungible Token Standard]. 7 | 8 | TIP: For a walk through on how to create an ERC721 token read our xref:ROOT:erc721.adoc[ERC721 guide]. 9 | 10 | The EIP consists of three interfaces, found here as {IERC721}, {IERC721Metadata}, and {IERC721Enumerable}. Only the first one is required in a contract to be ERC721 compliant. However, all three are implemented in {ERC721}. 11 | 12 | Additionally, {IERC721Receiver} can be used to prevent tokens from becoming forever locked in contracts. Imagine sending an in-game item to an exchange address that can't send it back!. When using <>, the token contract checks to see that the receiver is an {IERC721Receiver}, which implies that it knows how to handle {ERC721} tokens. If you're writing a contract that needs to receive {ERC721} tokens, you'll want to include this interface. 13 | 14 | Additionally there are multiple custom extensions, including: 15 | 16 | * designation of addresses that can pause token transfers for all users ({ERC721Pausable}). 17 | * destruction of own tokens ({ERC721Burnable}). 18 | 19 | NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC721 (such as <>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc721.adoc#Presets[ERC721 Presets] (such as {ERC721PresetMinterPauserAutoId}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts. 20 | 21 | 22 | == Core 23 | 24 | {{IERC721}} 25 | 26 | {{IERC721Metadata}} 27 | 28 | {{IERC721Enumerable}} 29 | 30 | {{ERC721}} 31 | 32 | {{IERC721Receiver}} 33 | 34 | == Extensions 35 | 36 | {{ERC721Pausable}} 37 | 38 | {{ERC721Burnable}} 39 | 40 | == Convenience 41 | 42 | {{ERC721Holder}} 43 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "@openzeppelin/contracts-upgradeable", 3 | "_id": "@openzeppelin/contracts-upgradeable@3.2.0", 4 | "_inBundle": false, 5 | "_integrity": "sha512-f2q4FjT84ixIl8MUo9WbCMSBtV9T52c8QbrCfzoCBbDwEuVjf9jnvm1JETAWSC9Q9oLcUXpRFBMavb1B23tx1g==", 6 | "_location": "/@openzeppelin/contracts-upgradeable", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "tag", 10 | "registry": true, 11 | "raw": "@openzeppelin/contracts-upgradeable", 12 | "name": "@openzeppelin/contracts-upgradeable", 13 | "escapedName": "@openzeppelin%2fcontracts-upgradeable", 14 | "scope": "@openzeppelin", 15 | "rawSpec": "", 16 | "saveSpec": null, 17 | "fetchSpec": "latest" 18 | }, 19 | "_requiredBy": [ 20 | "#USER", 21 | "/" 22 | ], 23 | "_resolved": "https://registry.npmjs.org/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-3.2.0.tgz", 24 | "_shasum": "fb6959659e7585f419060ea1c546c0c11f1d0582", 25 | "_spec": "@openzeppelin/contracts-upgradeable", 26 | "_where": "/Users/present/code/brownie-sett", 27 | "author": { 28 | "name": "OpenZeppelin Community", 29 | "email": "maintainers@openzeppelin.org" 30 | }, 31 | "bugs": { 32 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/issues" 33 | }, 34 | "bundleDependencies": false, 35 | "deprecated": false, 36 | "description": "Secure Smart Contract library for Solidity", 37 | "files": [ 38 | "**/*.sol", 39 | "/build/contracts/*.json", 40 | "!/mocks", 41 | "!/examples" 42 | ], 43 | "homepage": "https://openzeppelin.com/contracts/", 44 | "keywords": [ 45 | "solidity", 46 | "ethereum", 47 | "smart", 48 | "contracts", 49 | "security", 50 | "zeppelin" 51 | ], 52 | "license": "MIT", 53 | "name": "@openzeppelin/contracts-upgradeable", 54 | "repository": { 55 | "type": "git", 56 | "url": "git+https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable.git" 57 | }, 58 | "scripts": { 59 | "prepare": "bash ../scripts/prepare-contracts-package.sh", 60 | "prepare-docs": "cd ..; npm run prepare-docs" 61 | }, 62 | "version": "3.2.0" 63 | } 64 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC20/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 20 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc20 5 | 6 | This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-20[ERC20 Token Standard]. 7 | 8 | TIP: For an overview of ERC20 tokens and a walk through on how to create a token contract read our xref:ROOT:erc20.adoc[ERC20 guide]. 9 | 10 | There a few core contracts that implement the behavior specified in the EIP: 11 | 12 | * {IERC20}: the interface all ERC20 implementations should conform to. 13 | * {ERC20}: the implementation of the ERC20 interface, including the <>, <> and <> optional standard extension to the base interface. 14 | 15 | Additionally there are multiple custom extensions, including: 16 | 17 | * designation of addresses that can pause token transfers for all users ({ERC20Pausable}). 18 | * efficient storage of past token balances to be later queried at any point in time ({ERC20Snapshot}). 19 | * destruction of own tokens ({ERC20Burnable}). 20 | * enforcement of a cap to the total supply when minting tokens ({ERC20Capped}). 21 | 22 | Finally, there are some utilities to interact with ERC20 contracts in various ways. 23 | 24 | * {SafeERC20} is a wrapper around the interface that eliminates the need to handle boolean return values. 25 | * {TokenTimelock} can hold tokens for a beneficiary until a specified time. 26 | 27 | NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC20 (such as <>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc20.adoc#Presets[ERC20 Presets] (such as {ERC20PresetMinterPauser}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts. 28 | 29 | == Core 30 | 31 | {{IERC20}} 32 | 33 | {{ERC20}} 34 | 35 | == Extensions 36 | 37 | {{ERC20Snapshot}} 38 | 39 | {{ERC20Pausable}} 40 | 41 | {{ERC20Burnable}} 42 | 43 | {{ERC20Capped}} 44 | 45 | == Utilities 46 | 47 | {{SafeERC20}} 48 | 49 | {{TokenTimelock}} 50 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC20/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 20 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc20 5 | 6 | This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-20[ERC20 Token Standard]. 7 | 8 | TIP: For an overview of ERC20 tokens and a walk through on how to create a token contract read our xref:ROOT:erc20.adoc[ERC20 guide]. 9 | 10 | There a few core contracts that implement the behavior specified in the EIP: 11 | 12 | * {IERC20}: the interface all ERC20 implementations should conform to. 13 | * {ERC20}: the implementation of the ERC20 interface, including the <>, <> and <> optional standard extension to the base interface. 14 | 15 | Additionally there are multiple custom extensions, including: 16 | 17 | * designation of addresses that can pause token transfers for all users ({ERC20Pausable}). 18 | * efficient storage of past token balances to be later queried at any point in time ({ERC20Snapshot}). 19 | * destruction of own tokens ({ERC20Burnable}). 20 | * enforcement of a cap to the total supply when minting tokens ({ERC20Capped}). 21 | 22 | Finally, there are some utilities to interact with ERC20 contracts in various ways. 23 | 24 | * {SafeERC20} is a wrapper around the interface that eliminates the need to handle boolean return values. 25 | * {TokenTimelock} can hold tokens for a beneficiary until a specified time. 26 | 27 | NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC20 (such as <>) and expose them as external functions in the way they prefer. On the other hand, xref:ROOT:erc20.adoc#Presets[ERC20 Presets] (such as {ERC20PresetMinterPauser}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts. 28 | 29 | == Core 30 | 31 | {{IERC20}} 32 | 33 | {{ERC20}} 34 | 35 | == Extensions 36 | 37 | {{ERC20Snapshot}} 38 | 39 | {{ERC20Pausable}} 40 | 41 | {{ERC20Burnable}} 42 | 43 | {{ERC20Capped}} 44 | 45 | == Utilities 46 | 47 | {{SafeERC20}} 48 | 49 | {{TokenTimelock}} 50 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/introspection/ERC165Upgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./IERC165Upgradeable.sol"; 6 | import "../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC165} interface. 10 | * 11 | * Contracts may inherit from this and call {_registerInterface} to declare 12 | * their support of an interface. 13 | */ 14 | contract ERC165Upgradeable is Initializable, IERC165Upgradeable { 15 | /* 16 | * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 17 | */ 18 | bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; 19 | 20 | /** 21 | * @dev Mapping of interface ids to whether or not it's supported. 22 | */ 23 | mapping(bytes4 => bool) private _supportedInterfaces; 24 | 25 | function __ERC165_init() internal initializer { 26 | __ERC165_init_unchained(); 27 | } 28 | 29 | function __ERC165_init_unchained() internal initializer { 30 | // Derived contracts need only register support for their own interfaces, 31 | // we register support for ERC165 itself here 32 | _registerInterface(_INTERFACE_ID_ERC165); 33 | } 34 | 35 | /** 36 | * @dev See {IERC165-supportsInterface}. 37 | * 38 | * Time complexity O(1), guaranteed to always use less than 30 000 gas. 39 | */ 40 | function supportsInterface(bytes4 interfaceId) 41 | public 42 | view 43 | override 44 | returns (bool) 45 | { 46 | return _supportedInterfaces[interfaceId]; 47 | } 48 | 49 | /** 50 | * @dev Registers the contract as an implementer of the interface defined by 51 | * `interfaceId`. Support of the actual ERC165 interface is automatic and 52 | * registering its interface id is not required. 53 | * 54 | * See {IERC165-supportsInterface}. 55 | * 56 | * Requirements: 57 | * 58 | * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). 59 | */ 60 | function _registerInterface(bytes4 interfaceId) internal virtual { 61 | require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); 62 | _supportedInterfaces[interfaceId] = true; 63 | } 64 | 65 | uint256[49] private __gap; 66 | } 67 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/upgradeability/BaseUpgradeabilityProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | import "./Proxy.sol"; 4 | import "../utils/Address.sol"; 5 | 6 | /** 7 | * @title BaseUpgradeabilityProxy 8 | * @dev This contract implements a proxy that allows to change the 9 | * implementation address to which it will delegate. 10 | * Such a change is called an implementation upgrade. 11 | */ 12 | contract BaseUpgradeabilityProxy is Proxy { 13 | /** 14 | * @dev Emitted when the implementation is upgraded. 15 | * @param implementation Address of the new implementation. 16 | */ 17 | event Upgraded(address indexed implementation); 18 | 19 | /** 20 | * @dev Storage slot with the address of the current implementation. 21 | * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is 22 | * validated in the constructor. 23 | */ 24 | bytes32 internal constant IMPLEMENTATION_SLOT = 25 | 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; 26 | 27 | /** 28 | * @dev Returns the current implementation. 29 | * @return Address of the current implementation 30 | */ 31 | function _implementation() internal view returns (address impl) { 32 | bytes32 slot = IMPLEMENTATION_SLOT; 33 | assembly { 34 | impl := sload(slot) 35 | } 36 | } 37 | 38 | /** 39 | * @dev Upgrades the proxy to a new implementation. 40 | * @param newImplementation Address of the new implementation. 41 | */ 42 | function _upgradeTo(address newImplementation) internal { 43 | _setImplementation(newImplementation); 44 | emit Upgraded(newImplementation); 45 | } 46 | 47 | /** 48 | * @dev Sets the implementation address of the proxy. 49 | * @param newImplementation Address of the new implementation. 50 | */ 51 | function _setImplementation(address newImplementation) internal { 52 | require( 53 | OpenZeppelinUpgradesAddress.isContract(newImplementation), 54 | "Cannot set a proxy implementation to a non-contract address" 55 | ); 56 | 57 | bytes32 slot = IMPLEMENTATION_SLOT; 58 | 59 | assembly { 60 | sstore(slot, newImplementation) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/README.adoc: -------------------------------------------------------------------------------- 1 | = Utilities 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/utils 5 | 6 | Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives. 7 | 8 | Security tools include: 9 | 10 | * {Pausable}: provides a simple way to halt activity in your contracts (often in response to an external threat). 11 | * {ReentrancyGuard}: protects you from https://blog.openzeppelin.com/reentrancy-after-istanbul/[reentrant calls]. 12 | 13 | The {Address}, {Arrays} and {Strings} libraries provide more operations related to these native data types, while {SafeCast} adds ways to safely convert between the different signed and unsigned numeric types. 14 | 15 | For new data types: 16 | 17 | * {Counters}: a simple way to get a counter that can only be incremented or decremented. Very useful for ID generation, counting contract activity, among others. 18 | * {EnumerableMap}: like Solidity's https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] type, but with key-value _enumeration_: this will let you know how many entries a mapping has, and iterate over them (which is not possible with `mapping`). 19 | * {EnumerableSet}: like {EnumerableMap}, but for https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets]. Can be used to store privileged accounts, issued IDs, etc. 20 | 21 | [NOTE] 22 | ==== 23 | Because Solidity does not support generic types, {EnumerableMap} and {EnumerableSet} are specialized to a limited number of key-value types. 24 | 25 | As of v3.0, {EnumerableMap} supports `uint256 -> address` (`UintToAddressMap`), and {EnumerableSet} supports `address` and `uint256` (`AddressSet` and `UintSet`). 26 | ==== 27 | 28 | Finally, {Create2} contains all necessary utilities to safely use the https://blog.openzeppelin.com/getting-the-most-out-of-create2/[`CREATE2` EVM opcode], without having to deal with low-level assembly. 29 | 30 | == Contracts 31 | 32 | {{Pausable}} 33 | 34 | {{ReentrancyGuard}} 35 | 36 | == Libraries 37 | 38 | {{Address}} 39 | 40 | {{Arrays}} 41 | 42 | {{Counters}} 43 | 44 | {{Create2}} 45 | 46 | {{EnumerableMap}} 47 | 48 | {{EnumerableSet}} 49 | 50 | {{SafeCast}} 51 | 52 | {{Strings}} 53 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/utils/README.adoc: -------------------------------------------------------------------------------- 1 | = Utilities 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/utils 5 | 6 | Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives. 7 | 8 | Security tools include: 9 | 10 | * {Pausable}: provides a simple way to halt activity in your contracts (often in response to an external threat). 11 | * {ReentrancyGuard}: protects you from https://blog.openzeppelin.com/reentrancy-after-istanbul/[reentrant calls]. 12 | 13 | The {Address}, {Arrays} and {Strings} libraries provide more operations related to these native data types, while {SafeCast} adds ways to safely convert between the different signed and unsigned numeric types. 14 | 15 | For new data types: 16 | 17 | * {Counters}: a simple way to get a counter that can only be incremented or decremented. Very useful for ID generation, counting contract activity, among others. 18 | * {EnumerableMap}: like Solidity's https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] type, but with key-value _enumeration_: this will let you know how many entries a mapping has, and iterate over them (which is not possible with `mapping`). 19 | * {EnumerableSet}: like {EnumerableMap}, but for https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets]. Can be used to store privileged accounts, issued IDs, etc. 20 | 21 | [NOTE] 22 | ==== 23 | Because Solidity does not support generic types, {EnumerableMap} and {EnumerableSet} are specialized to a limited number of key-value types. 24 | 25 | As of v3.0, {EnumerableMap} supports `uint256 -> address` (`UintToAddressMap`), and {EnumerableSet} supports `address` and `uint256` (`AddressSet` and `UintSet`). 26 | ==== 27 | 28 | Finally, {Create2} contains all necessary utilities to safely use the https://blog.openzeppelin.com/getting-the-most-out-of-create2/[`CREATE2` EVM opcode], without having to deal with low-level assembly. 29 | 30 | == Contracts 31 | 32 | {{Pausable}} 33 | 34 | {{ReentrancyGuard}} 35 | 36 | == Libraries 37 | 38 | {{Address}} 39 | 40 | {{Arrays}} 41 | 42 | {{Counters}} 43 | 44 | {{Create2}} 45 | 46 | {{EnumerableMap}} 47 | 48 | {{EnumerableSet}} 49 | 50 | {{SafeCast}} 51 | 52 | {{Strings}} 53 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./SafeERC20.sol"; 6 | 7 | /** 8 | * @dev A token holder contract that will allow a beneficiary to extract the 9 | * tokens after a given release time. 10 | * 11 | * Useful for simple vesting schedules like "advisors get all of their tokens 12 | * after 1 year". 13 | */ 14 | contract TokenTimelock { 15 | using SafeERC20 for IERC20; 16 | 17 | // ERC20 basic token contract being held 18 | IERC20 private _token; 19 | 20 | // beneficiary of tokens after they are released 21 | address private _beneficiary; 22 | 23 | // timestamp when token release is enabled 24 | uint256 private _releaseTime; 25 | 26 | constructor( 27 | IERC20 token, 28 | address beneficiary, 29 | uint256 releaseTime 30 | ) public { 31 | // solhint-disable-next-line not-rely-on-time 32 | require( 33 | releaseTime > block.timestamp, 34 | "TokenTimelock: release time is before current time" 35 | ); 36 | _token = token; 37 | _beneficiary = beneficiary; 38 | _releaseTime = releaseTime; 39 | } 40 | 41 | /** 42 | * @return the token being held. 43 | */ 44 | function token() public view returns (IERC20) { 45 | return _token; 46 | } 47 | 48 | /** 49 | * @return the beneficiary of the tokens. 50 | */ 51 | function beneficiary() public view returns (address) { 52 | return _beneficiary; 53 | } 54 | 55 | /** 56 | * @return the time when the tokens are released. 57 | */ 58 | function releaseTime() public view returns (uint256) { 59 | return _releaseTime; 60 | } 61 | 62 | /** 63 | * @notice Transfers tokens held by timelock to beneficiary. 64 | */ 65 | function release() public virtual { 66 | // solhint-disable-next-line not-rely-on-time 67 | require( 68 | block.timestamp >= _releaseTime, 69 | "TokenTimelock: current time is before release time" 70 | ); 71 | 72 | uint256 amount = _token.balanceOf(address(this)); 73 | require(amount > 0, "TokenTimelock: no tokens to release"); 74 | 75 | _token.safeTransfer(_beneficiary, amount); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /interfaces/badger/IBadgerTreeV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // SPDX-License-Identifier: MIT 4 | pragma solidity >=0.5.0 <0.8.0; 5 | 6 | interface IBadgerTreeV2 { 7 | /// @dev Return true if account has outstanding claims in any token from the given input data 8 | function isClaimAvailableFor( 9 | address user, 10 | address[] memory tokens, 11 | uint256[] memory cumulativeAmounts 12 | ) external view; 13 | 14 | /// @dev Get the number of tokens claimable for an account, given a list of tokens and latest cumulativeAmounts data 15 | function getClaimableFor( 16 | address user, 17 | address[] memory tokens, 18 | uint256[] memory cumulativeAmounts 19 | ) external view; 20 | 21 | /// @dev Get the cumulative number of tokens claimed for an account, given a list of tokens 22 | function getClaimedFor(address user, address[] memory tokens) external view; 23 | 24 | /// @dev Utility function to encode a merkle tree node 25 | function encodeClaim( 26 | address[] calldata tokens, 27 | uint256[] calldata cumulativeAmounts, 28 | address account, 29 | uint256 index, 30 | uint256 cycle 31 | ) external pure; 32 | 33 | /// @notice Claim specifiedrewards for a set of tokens at a given cycle number 34 | /// @notice Can choose to skip certain tokens by setting amount to claim to zero for that token index 35 | function claim( 36 | address[] calldata tokens, 37 | uint256[] calldata cumulativeAmounts, 38 | uint256 index, 39 | uint256 cycle, 40 | bytes32[] calldata merkleProof, 41 | uint256[] calldata amountsToClaim 42 | ) external; 43 | 44 | // ===== Root Updater Restricted ===== 45 | 46 | /// @notice Propose a new root and content hash, which will be stored as pending until approved 47 | function proposeRoot( 48 | bytes32 root, 49 | bytes32 contentHash, 50 | uint256 cycle, 51 | uint256 startBlock, 52 | uint256 endBlock 53 | ) external; 54 | 55 | /// ===== Guardian Restricted ===== 56 | 57 | /// @notice Approve the current pending root and content hash 58 | function approveRoot( 59 | bytes32 root, 60 | bytes32 contentHash, 61 | uint256 cycle, 62 | uint256 startBlock, 63 | uint256 endBlock 64 | ) external; 65 | } 66 | -------------------------------------------------------------------------------- /helpers/multicall/functions.py: -------------------------------------------------------------------------------- 1 | from dotmap import DotMap 2 | 3 | 4 | def as_wei(value): 5 | return value 6 | 7 | 8 | def as_original(value): 9 | return value 10 | 11 | 12 | erc20 = DotMap( 13 | balanceOf="balanceOf(address)(uint256)", 14 | totalSupply="totalSupply()(uint256)", 15 | transfer="transfer(address,uint256)()", 16 | safeTransfer="safeTransfer(address,uint256)()", 17 | name="name()(string)", 18 | symbol="symbol()(string)", 19 | decimals="decimals()(uint256)", 20 | ) 21 | sett = DotMap( 22 | getPricePerFullShare="getPricePerFullShare()(uint256)", 23 | available="available()(uint256)", 24 | balance="balance()(uint256)", 25 | controller="controller()(address)", 26 | governance="governance()(address)", 27 | strategist="strategist()(address)", 28 | keeper="keeper()(address)", 29 | shares="shares()(uint256)", 30 | ) 31 | strategy = DotMap( 32 | balanceOfPool="balanceOfPool()(uint256)", 33 | balanceOfWant="balanceOfWant()(uint256)", 34 | balanceOf="balanceOf()(uint256)", 35 | isTendable="isTendable()(bool)", 36 | getProtectedTokens="getProtectedTokens()(address[])", 37 | getName="getName()(string)", 38 | withdrawalFee="withdrawalFee()(uint256)", 39 | performanceFeeGovernance="performanceFeeGovernance()(uint256)", 40 | performanceFeeStrategist="performanceFeeStrategist()(uint256)", 41 | farmPerformanceFeeGovernance="farmPerformanceFeeGovernance()(uint256)", 42 | farmPerformanceFeeStrategist="farmPerformanceFeeStrategist()(uint256)", 43 | sharesOfPool="sharesOfPool()(uint256)", 44 | sharesOfWant="sharesOfWant()(uint256)", 45 | sharesOf="sharesOf()(uint256)", 46 | ) 47 | harvestFarm = DotMap(earned="earned()(uint256)") 48 | rewardPool = DotMap( 49 | # claimable rewards 50 | earned="earned(address)(uint256)", 51 | # amount staked 52 | balanceOf="balanceOf(address)(uint256)", 53 | ) 54 | digg = DotMap(sharesOf="sharesOf(address)(uint256)") 55 | diggFaucet = DotMap( 56 | # claimable rewards 57 | earned="earned()(uint256)", 58 | ) 59 | pancakeChef = DotMap( 60 | pendingCake="pendingCake(uint256,uint256)(uint256)", 61 | userInfo="userInfo(uint256,address)(uint256,uint256)", 62 | ) 63 | 64 | func = DotMap( 65 | erc20=erc20, 66 | sett=sett, 67 | strategy=strategy, 68 | rewardPool=rewardPool, 69 | diggFaucet=diggFaucet, 70 | digg=digg, 71 | pancakeChef=pancakeChef, 72 | ) 73 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/Initializable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.24 <0.7.0; 2 | 3 | /** 4 | * @title Initializable 5 | * 6 | * @dev Helper contract to support initializer functions. To use it, replace 7 | * the constructor with a function that has the `initializer` modifier. 8 | * WARNING: Unlike constructors, initializer functions must be manually 9 | * invoked. This applies both to deploying an Initializable contract, as well 10 | * as extending an Initializable contract via inheritance. 11 | * WARNING: When used with inheritance, manual care must be taken to not invoke 12 | * a parent initializer twice, or ensure that all initializers are idempotent, 13 | * because this is not dealt with automatically as with constructors. 14 | */ 15 | contract Initializable { 16 | /** 17 | * @dev Indicates that the contract has been initialized. 18 | */ 19 | bool private initialized; 20 | 21 | /** 22 | * @dev Indicates that the contract is in the process of being initialized. 23 | */ 24 | bool private initializing; 25 | 26 | /** 27 | * @dev Modifier to use in the initializer function of a contract. 28 | */ 29 | modifier initializer() { 30 | require( 31 | initializing || isConstructor() || !initialized, 32 | "Contract instance has already been initialized" 33 | ); 34 | 35 | bool isTopLevelCall = !initializing; 36 | if (isTopLevelCall) { 37 | initializing = true; 38 | initialized = true; 39 | } 40 | 41 | _; 42 | 43 | if (isTopLevelCall) { 44 | initializing = false; 45 | } 46 | } 47 | 48 | /// @dev Returns true if and only if the function is running in the constructor 49 | function isConstructor() private view returns (bool) { 50 | // extcodesize checks the size of the code stored in an address, and 51 | // address returns the current address. Since the code is still not 52 | // deployed when running a constructor, any checks on its code size will 53 | // yield zero, making it an effective way to detect if a contract is 54 | // under construction or not. 55 | address self = address(this); 56 | uint256 cs; 57 | assembly { 58 | cs := extcodesize(self) 59 | } 60 | return cs == 0; 61 | } 62 | 63 | // Reserved storage space to allow for layout changes in the future. 64 | uint256[50] private ______gap; 65 | } 66 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/payment/escrow/Escrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../math/SafeMath.sol"; 6 | import "../../access/Ownable.sol"; 7 | import "../../utils/Address.sol"; 8 | 9 | /** 10 | * @title Escrow 11 | * @dev Base escrow contract, holds funds designated for a payee until they 12 | * withdraw them. 13 | * 14 | * Intended usage: This contract (and derived escrow contracts) should be a 15 | * standalone contract, that only interacts with the contract that instantiated 16 | * it. That way, it is guaranteed that all Ether will be handled according to 17 | * the `Escrow` rules, and there is no need to check for payable functions or 18 | * transfers in the inheritance tree. The contract that uses the escrow as its 19 | * payment method should be its owner, and provide public methods redirecting 20 | * to the escrow's deposit and withdraw. 21 | */ 22 | contract Escrow is Ownable { 23 | using SafeMath for uint256; 24 | using Address for address payable; 25 | 26 | event Deposited(address indexed payee, uint256 weiAmount); 27 | event Withdrawn(address indexed payee, uint256 weiAmount); 28 | 29 | mapping(address => uint256) private _deposits; 30 | 31 | function depositsOf(address payee) public view returns (uint256) { 32 | return _deposits[payee]; 33 | } 34 | 35 | /** 36 | * @dev Stores the sent amount as credit to be withdrawn. 37 | * @param payee The destination address of the funds. 38 | */ 39 | function deposit(address payee) public payable virtual onlyOwner { 40 | uint256 amount = msg.value; 41 | _deposits[payee] = _deposits[payee].add(amount); 42 | 43 | emit Deposited(payee, amount); 44 | } 45 | 46 | /** 47 | * @dev Withdraw accumulated balance for a payee, forwarding all gas to the 48 | * recipient. 49 | * 50 | * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. 51 | * Make sure you trust the recipient, or are either following the 52 | * checks-effects-interactions pattern or using {ReentrancyGuard}. 53 | * 54 | * @param payee The address whose funds will be withdrawn and transferred to. 55 | */ 56 | function withdraw(address payable payee) public virtual onlyOwner { 57 | uint256 payment = _deposits[payee]; 58 | 59 | _deposits[payee] = 0; 60 | 61 | payee.sendValue(payment); 62 | 63 | emit Withdrawn(payee, payment); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../GSN/Context.sol"; 6 | 7 | /** 8 | * @dev Contract module which allows children to implement an emergency stop 9 | * mechanism that can be triggered by an authorized account. 10 | * 11 | * This module is used through inheritance. It will make available the 12 | * modifiers `whenNotPaused` and `whenPaused`, which can be applied to 13 | * the functions of your contract. Note that they will not be pausable by 14 | * simply including this module, only once the modifiers are put in place. 15 | */ 16 | contract Pausable is Context { 17 | /** 18 | * @dev Emitted when the pause is triggered by `account`. 19 | */ 20 | event Paused(address account); 21 | 22 | /** 23 | * @dev Emitted when the pause is lifted by `account`. 24 | */ 25 | event Unpaused(address account); 26 | 27 | bool private _paused; 28 | 29 | /** 30 | * @dev Initializes the contract in unpaused state. 31 | */ 32 | constructor() internal { 33 | _paused = false; 34 | } 35 | 36 | /** 37 | * @dev Returns true if the contract is paused, and false otherwise. 38 | */ 39 | function paused() public view returns (bool) { 40 | return _paused; 41 | } 42 | 43 | /** 44 | * @dev Modifier to make a function callable only when the contract is not paused. 45 | * 46 | * Requirements: 47 | * 48 | * - The contract must not be paused. 49 | */ 50 | modifier whenNotPaused() { 51 | require(!_paused, "Pausable: paused"); 52 | _; 53 | } 54 | 55 | /** 56 | * @dev Modifier to make a function callable only when the contract is paused. 57 | * 58 | * Requirements: 59 | * 60 | * - The contract must be paused. 61 | */ 62 | modifier whenPaused() { 63 | require(_paused, "Pausable: not paused"); 64 | _; 65 | } 66 | 67 | /** 68 | * @dev Triggers stopped state. 69 | * 70 | * Requirements: 71 | * 72 | * - The contract must not be paused. 73 | */ 74 | function _pause() internal virtual whenNotPaused { 75 | _paused = true; 76 | emit Paused(_msgSender()); 77 | } 78 | 79 | /** 80 | * @dev Returns to normal state. 81 | * 82 | * Requirements: 83 | * 84 | * - The contract must be paused. 85 | */ 86 | function _unpause() internal virtual whenPaused { 87 | _paused = false; 88 | emit Unpaused(_msgSender()); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../introspection/IERC165.sol"; 6 | 7 | /** 8 | * _Available since v3.1._ 9 | */ 10 | interface IERC1155Receiver is IERC165 { 11 | /** 12 | @dev Handles the receipt of a single ERC1155 token type. This function is 13 | called at the end of a `safeTransferFrom` after the balance has been updated. 14 | To accept the transfer, this must return 15 | `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` 16 | (i.e. 0xf23a6e61, or its own function selector). 17 | @param operator The address which initiated the transfer (i.e. msg.sender) 18 | @param from The address which previously owned the token 19 | @param id The ID of the token being transferred 20 | @param value The amount of tokens being transferred 21 | @param data Additional data with no specified format 22 | @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed 23 | */ 24 | function onERC1155Received( 25 | address operator, 26 | address from, 27 | uint256 id, 28 | uint256 value, 29 | bytes calldata data 30 | ) external returns (bytes4); 31 | 32 | /** 33 | @dev Handles the receipt of a multiple ERC1155 token types. This function 34 | is called at the end of a `safeBatchTransferFrom` after the balances have 35 | been updated. To accept the transfer(s), this must return 36 | `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` 37 | (i.e. 0xbc197c81, or its own function selector). 38 | @param operator The address which initiated the batch transfer (i.e. msg.sender) 39 | @param from The address which previously owned the token 40 | @param ids An array containing ids of each token being transferred (order and length must match values array) 41 | @param values An array containing amounts of each token being transferred (order and length must match ids array) 42 | @param data Additional data with no specified format 43 | @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed 44 | */ 45 | function onERC1155BatchReceived( 46 | address operator, 47 | address from, 48 | uint256[] calldata ids, 49 | uint256[] calldata values, 50 | bytes calldata data 51 | ) external returns (bytes4); 52 | } 53 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/access/Ownable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../GSN/Context.sol"; 6 | 7 | /** 8 | * @dev Contract module which provides a basic access control mechanism, where 9 | * there is an account (an owner) that can be granted exclusive access to 10 | * specific functions. 11 | * 12 | * By default, the owner account will be the one that deploys the contract. This 13 | * can later be changed with {transferOwnership}. 14 | * 15 | * This module is used through inheritance. It will make available the modifier 16 | * `onlyOwner`, which can be applied to your functions to restrict their use to 17 | * the owner. 18 | */ 19 | contract Ownable is Context { 20 | address private _owner; 21 | 22 | event OwnershipTransferred( 23 | address indexed previousOwner, 24 | address indexed newOwner 25 | ); 26 | 27 | /** 28 | * @dev Initializes the contract setting the deployer as the initial owner. 29 | */ 30 | constructor() internal { 31 | address msgSender = _msgSender(); 32 | _owner = msgSender; 33 | emit OwnershipTransferred(address(0), msgSender); 34 | } 35 | 36 | /** 37 | * @dev Returns the address of the current owner. 38 | */ 39 | function owner() public view returns (address) { 40 | return _owner; 41 | } 42 | 43 | /** 44 | * @dev Throws if called by any account other than the owner. 45 | */ 46 | modifier onlyOwner() { 47 | require(_owner == _msgSender(), "Ownable: caller is not the owner"); 48 | _; 49 | } 50 | 51 | /** 52 | * @dev Leaves the contract without owner. It will not be possible to call 53 | * `onlyOwner` functions anymore. Can only be called by the current owner. 54 | * 55 | * NOTE: Renouncing ownership will leave the contract without an owner, 56 | * thereby removing any functionality that is only available to the owner. 57 | */ 58 | function renounceOwnership() public virtual onlyOwner { 59 | emit OwnershipTransferred(_owner, address(0)); 60 | _owner = address(0); 61 | } 62 | 63 | /** 64 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 65 | * Can only be called by the current owner. 66 | */ 67 | function transferOwnership(address newOwner) public virtual onlyOwner { 68 | require( 69 | newOwner != address(0), 70 | "Ownable: new owner is the zero address" 71 | ); 72 | emit OwnershipTransferred(_owner, newOwner); 73 | _owner = newOwner; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../../introspection/IERC165Upgradeable.sol"; 6 | 7 | /** 8 | * _Available since v3.1._ 9 | */ 10 | interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { 11 | /** 12 | @dev Handles the receipt of a single ERC1155 token type. This function is 13 | called at the end of a `safeTransferFrom` after the balance has been updated. 14 | To accept the transfer, this must return 15 | `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` 16 | (i.e. 0xf23a6e61, or its own function selector). 17 | @param operator The address which initiated the transfer (i.e. msg.sender) 18 | @param from The address which previously owned the token 19 | @param id The ID of the token being transferred 20 | @param value The amount of tokens being transferred 21 | @param data Additional data with no specified format 22 | @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed 23 | */ 24 | function onERC1155Received( 25 | address operator, 26 | address from, 27 | uint256 id, 28 | uint256 value, 29 | bytes calldata data 30 | ) external returns (bytes4); 31 | 32 | /** 33 | @dev Handles the receipt of a multiple ERC1155 token types. This function 34 | is called at the end of a `safeBatchTransferFrom` after the balances have 35 | been updated. To accept the transfer(s), this must return 36 | `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` 37 | (i.e. 0xbc197c81, or its own function selector). 38 | @param operator The address which initiated the batch transfer (i.e. msg.sender) 39 | @param from The address which previously owned the token 40 | @param ids An array containing ids of each token being transferred (order and length must match values array) 41 | @param values An array containing amounts of each token being transferred (order and length must match ids array) 42 | @param data Additional data with no specified format 43 | @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed 44 | */ 45 | function onERC1155BatchReceived( 46 | address operator, 47 | address from, 48 | uint256[] calldata ids, 49 | uint256[] calldata values, 50 | bytes calldata data 51 | ) external returns (bytes4); 52 | } 53 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - develop 8 | pull_request: 9 | 10 | jobs: 11 | solidity: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Check out github repository 16 | uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 1 19 | 20 | - name: Setup node.js 21 | uses: actions/setup-node@v1 22 | with: 23 | node-version: "14.x" 24 | 25 | - name: Set yarn cache directory path 26 | id: yarn-cache-dir-path 27 | run: echo "::set-output name=dir::$(yarn cache dir)" 28 | 29 | - name: Restore yarn cache 30 | uses: actions/cache@v2 31 | id: yarn-cache 32 | with: 33 | path: | 34 | ${{ steps.yarn-cache-dir-path.outputs.dir }} 35 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 36 | restore-keys: | 37 | ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 38 | ${{ runner.os }}-yarn- 39 | 40 | - name: Install node.js dependencies 41 | run: yarn --frozen-lockfile 42 | 43 | - name: Run linter on *.sol and *.json 44 | run: yarn lint:check 45 | 46 | commits: 47 | runs-on: ubuntu-latest 48 | 49 | steps: 50 | - name: Check out github repository 51 | uses: actions/checkout@v2 52 | with: 53 | fetch-depth: 0 54 | 55 | - name: Run commitlint 56 | uses: wagoid/commitlint-github-action@v2 57 | 58 | brownie: 59 | runs-on: ubuntu-latest 60 | 61 | steps: 62 | - name: Check out github repository 63 | uses: actions/checkout@v2 64 | with: 65 | fetch-depth: 1 66 | 67 | - name: Set up python 3.9 68 | uses: actions/setup-python@v2 69 | with: 70 | python-version: 3.9 71 | 72 | - name: Set pip cache directory path 73 | id: pip-cache-dir-path 74 | run: | 75 | echo "::set-output name=dir::$(pip cache dir)" 76 | 77 | - name: Restore pip cache 78 | uses: actions/cache@v2 79 | id: pip-cache 80 | with: 81 | path: | 82 | ${{ steps.pip-cache-dir-path.outputs.dir }} 83 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 84 | restore-keys: | 85 | ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 86 | ${{ runner.os }}-pip- 87 | 88 | - name: Install python dependencies 89 | run: pip install -r requirements.txt 90 | 91 | - name: Run black 92 | run: black --check --include "(tests|scripts)" . 93 | # TODO: Add Slither Static Analyzer 94 | -------------------------------------------------------------------------------- /deps/@openzeppelin/upgrades/upgradeability/Proxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.0; 2 | 3 | /** 4 | * @title Proxy 5 | * @dev Implements delegation of calls to other contracts, with proper 6 | * forwarding of return values and bubbling of failures. 7 | * It defines a fallback function that delegates all calls to the address 8 | * returned by the abstract _implementation() internal function. 9 | */ 10 | contract Proxy { 11 | /** 12 | * @dev Fallback function. 13 | * Implemented entirely in `_fallback`. 14 | */ 15 | function() external payable { 16 | _fallback(); 17 | } 18 | 19 | /** 20 | * @return The Address of the implementation. 21 | */ 22 | function _implementation() internal view returns (address); 23 | 24 | /** 25 | * @dev Delegates execution to an implementation contract. 26 | * This is a low level function that doesn't return to its internal call site. 27 | * It will return to the external caller whatever the implementation returns. 28 | * @param implementation Address to delegate. 29 | */ 30 | function _delegate(address implementation) internal { 31 | assembly { 32 | // Copy msg.data. We take full control of memory in this inline assembly 33 | // block because it will not return to Solidity code. We overwrite the 34 | // Solidity scratch pad at memory position 0. 35 | calldatacopy(0, 0, calldatasize) 36 | 37 | // Call the implementation. 38 | // out and outsize are 0 because we don't know the size yet. 39 | let result := delegatecall( 40 | gas, 41 | implementation, 42 | 0, 43 | calldatasize, 44 | 0, 45 | 0 46 | ) 47 | 48 | // Copy the returned data. 49 | returndatacopy(0, 0, returndatasize) 50 | 51 | switch result 52 | // delegatecall returns 0 on error. 53 | case 0 { 54 | revert(0, returndatasize) 55 | } 56 | default { 57 | return(0, returndatasize) 58 | } 59 | } 60 | } 61 | 62 | /** 63 | * @dev Function that is run as the first thing in the fallback function. 64 | * Can be redefined in derived contracts to add functionality. 65 | * Redefinitions must call super._willFallback(). 66 | */ 67 | function _willFallback() internal {} 68 | 69 | /** 70 | * @dev fallback implementation. 71 | * Extracted to enable manual triggering. 72 | */ 73 | function _fallback() internal { 74 | _willFallback(); 75 | _delegate(_implementation()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /scripts/4_production_wireup.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from brownie import ( 4 | accounts, 5 | network, 6 | Controller, 7 | BadgerRegistry, 8 | ) 9 | 10 | import click 11 | from rich.console import Console 12 | 13 | from config import REGISTRY 14 | 15 | from helpers.constants import AddressZero 16 | 17 | console = Console() 18 | 19 | sleep_between_tx = 1 20 | 21 | 22 | def main(): 23 | """ 24 | GOVERNANCE ONLY 25 | Connects the Strategies to the Vaults via the Production Controller 26 | 27 | This script is enabled to handle multiple sets of strategy + vault + want. It must be 28 | called from the controller's governance account. 29 | """ 30 | 31 | # dev must be the controller's governance (get from keystore) 32 | dev = connect_account() 33 | 34 | # NOTE: Add the strategies, vaults and their corresponding wants 35 | # to the arrays below. It is very important that indexes are the 36 | # same for corresponding contracts. Example: to wire SettA, the 37 | # address of strategyA, vaultA and wantA must all be position at 38 | # the same index within their respective arrays. 39 | 40 | # Strategies to wire up 41 | strategies = [ 42 | "0x1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a", 43 | ] 44 | # Vaults to wire up 45 | vaults = [ 46 | "0x1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a", 47 | ] 48 | # Wants related to strategies and vaults 49 | wants = [ 50 | "0x1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a", 51 | ] 52 | 53 | # Get production controller from registry 54 | registry = BadgerRegistry.at(REGISTRY) 55 | controllerAddr = registry.get("controller") 56 | assert controllerAddr != AddressZero 57 | controller = Controller.at(controllerAddr) 58 | 59 | # Wire up strategies 60 | for strat in strategies: 61 | want = wants[strategies.index(strat)] 62 | 63 | controller.approveStrategy(want, strat, {"from": dev}) 64 | time.sleep(sleep_between_tx) 65 | assert controller.approvedStrategies(want, strat) == True 66 | 67 | controller.setStrategy(want, strat, {"from": dev}) 68 | time.sleep(sleep_between_tx) 69 | assert controller.strategies(want) == strat 70 | 71 | # Wire up vaults 72 | for vault in vaults: 73 | want = wants[vaults.index(vault)] 74 | 75 | controller.setVault(want, vault, {"from": dev}) 76 | time.sleep(sleep_between_tx) 77 | assert controller.vaults(want) == vault 78 | 79 | 80 | def connect_account(): 81 | click.echo(f"You are using the '{network.show_active()}' network") 82 | dev = accounts.load(click.prompt("Account", type=click.Choice(accounts.load()))) 83 | click.echo(f"You are using: 'dev' [{dev.address}]") 84 | return dev 85 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/proxy/Initializable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.4.24 <0.7.0; 4 | 5 | /** 6 | * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed 7 | * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an 8 | * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer 9 | * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. 10 | * 11 | * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as 12 | * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. 13 | * 14 | * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure 15 | * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. 16 | */ 17 | abstract contract Initializable { 18 | /** 19 | * @dev Indicates that the contract has been initialized. 20 | */ 21 | bool private _initialized; 22 | 23 | /** 24 | * @dev Indicates that the contract is in the process of being initialized. 25 | */ 26 | bool private _initializing; 27 | 28 | /** 29 | * @dev Modifier to protect an initializer function from being invoked twice. 30 | */ 31 | modifier initializer() { 32 | require( 33 | _initializing || _isConstructor() || !_initialized, 34 | "Initializable: contract is already initialized" 35 | ); 36 | 37 | bool isTopLevelCall = !_initializing; 38 | if (isTopLevelCall) { 39 | _initializing = true; 40 | _initialized = true; 41 | } 42 | 43 | _; 44 | 45 | if (isTopLevelCall) { 46 | _initializing = false; 47 | } 48 | } 49 | 50 | /// @dev Returns true if and only if the function is running in the constructor 51 | function _isConstructor() private view returns (bool) { 52 | // extcodesize checks the size of the code stored in an address, and 53 | // address returns the current address. Since the code is still not 54 | // deployed when running a constructor, any checks on its code size will 55 | // yield zero, making it an effective way to detect if a contract is 56 | // under construction or not. 57 | address self = address(this); 58 | uint256 cs; 59 | // solhint-disable-next-line no-inline-assembly 60 | assembly { 61 | cs := extcodesize(self) 62 | } 63 | return cs == 0; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/proxy/Initializable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.4.24 <0.7.0; 4 | 5 | /** 6 | * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed 7 | * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an 8 | * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer 9 | * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. 10 | * 11 | * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as 12 | * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. 13 | * 14 | * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure 15 | * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. 16 | */ 17 | abstract contract Initializable { 18 | /** 19 | * @dev Indicates that the contract has been initialized. 20 | */ 21 | bool private _initialized; 22 | 23 | /** 24 | * @dev Indicates that the contract is in the process of being initialized. 25 | */ 26 | bool private _initializing; 27 | 28 | /** 29 | * @dev Modifier to protect an initializer function from being invoked twice. 30 | */ 31 | modifier initializer() { 32 | require( 33 | _initializing || _isConstructor() || !_initialized, 34 | "Initializable: contract is already initialized" 35 | ); 36 | 37 | bool isTopLevelCall = !_initializing; 38 | if (isTopLevelCall) { 39 | _initializing = true; 40 | _initialized = true; 41 | } 42 | 43 | _; 44 | 45 | if (isTopLevelCall) { 46 | _initializing = false; 47 | } 48 | } 49 | 50 | /// @dev Returns true if and only if the function is running in the constructor 51 | function _isConstructor() private view returns (bool) { 52 | // extcodesize checks the size of the code stored in an address, and 53 | // address returns the current address. Since the code is still not 54 | // deployed when running a constructor, any checks on its code size will 55 | // yield zero, making it an effective way to detect if a contract is 56 | // under construction or not. 57 | address self = address(this); 58 | uint256 cs; 59 | // solhint-disable-next-line no-inline-assembly 60 | assembly { 61 | cs := extcodesize(self) 62 | } 63 | return cs == 0; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/token/ERC20/TokenTimelockUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "./SafeERC20Upgradeable.sol"; 6 | import "../../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev A token holder contract that will allow a beneficiary to extract the 10 | * tokens after a given release time. 11 | * 12 | * Useful for simple vesting schedules like "advisors get all of their tokens 13 | * after 1 year". 14 | */ 15 | contract TokenTimelockUpgradeable is Initializable { 16 | using SafeERC20Upgradeable for IERC20Upgradeable; 17 | 18 | // ERC20 basic token contract being held 19 | IERC20Upgradeable private _token; 20 | 21 | // beneficiary of tokens after they are released 22 | address private _beneficiary; 23 | 24 | // timestamp when token release is enabled 25 | uint256 private _releaseTime; 26 | 27 | function __TokenTimelock_init( 28 | IERC20Upgradeable token, 29 | address beneficiary, 30 | uint256 releaseTime 31 | ) internal initializer { 32 | __TokenTimelock_init_unchained(token, beneficiary, releaseTime); 33 | } 34 | 35 | function __TokenTimelock_init_unchained( 36 | IERC20Upgradeable token, 37 | address beneficiary, 38 | uint256 releaseTime 39 | ) internal initializer { 40 | // solhint-disable-next-line not-rely-on-time 41 | require( 42 | releaseTime > block.timestamp, 43 | "TokenTimelock: release time is before current time" 44 | ); 45 | _token = token; 46 | _beneficiary = beneficiary; 47 | _releaseTime = releaseTime; 48 | } 49 | 50 | /** 51 | * @return the token being held. 52 | */ 53 | function token() public view returns (IERC20Upgradeable) { 54 | return _token; 55 | } 56 | 57 | /** 58 | * @return the beneficiary of the tokens. 59 | */ 60 | function beneficiary() public view returns (address) { 61 | return _beneficiary; 62 | } 63 | 64 | /** 65 | * @return the time when the tokens are released. 66 | */ 67 | function releaseTime() public view returns (uint256) { 68 | return _releaseTime; 69 | } 70 | 71 | /** 72 | * @notice Transfers tokens held by timelock to beneficiary. 73 | */ 74 | function release() public virtual { 75 | // solhint-disable-next-line not-rely-on-time 76 | require( 77 | block.timestamp >= _releaseTime, 78 | "TokenTimelock: current time is before release time" 79 | ); 80 | 81 | uint256 amount = _token.balanceOf(address(this)); 82 | require(amount > 0, "TokenTimelock: no tokens to release"); 83 | 84 | _token.safeTransfer(_beneficiary, amount); 85 | } 86 | 87 | uint256[47] private __gap; 88 | } 89 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/ReentrancyGuard.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Contract module that helps prevent reentrant calls to a function. 7 | * 8 | * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier 9 | * available, which can be applied to functions to make sure there are no nested 10 | * (reentrant) calls to them. 11 | * 12 | * Note that because there is a single `nonReentrant` guard, functions marked as 13 | * `nonReentrant` may not call one another. This can be worked around by making 14 | * those functions `private`, and then adding `external` `nonReentrant` entry 15 | * points to them. 16 | * 17 | * TIP: If you would like to learn more about reentrancy and alternative ways 18 | * to protect against it, check out our blog post 19 | * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. 20 | */ 21 | contract ReentrancyGuard { 22 | // Booleans are more expensive than uint256 or any type that takes up a full 23 | // word because each write operation emits an extra SLOAD to first read the 24 | // slot's contents, replace the bits taken up by the boolean, and then write 25 | // back. This is the compiler's defense against contract upgrades and 26 | // pointer aliasing, and it cannot be disabled. 27 | 28 | // The values being non-zero value makes deployment a bit more expensive, 29 | // but in exchange the refund on every call to nonReentrant will be lower in 30 | // amount. Since refunds are capped to a percentage of the total 31 | // transaction's gas, it is best to keep them low in cases like this one, to 32 | // increase the likelihood of the full refund coming into effect. 33 | uint256 private constant _NOT_ENTERED = 1; 34 | uint256 private constant _ENTERED = 2; 35 | 36 | uint256 private _status; 37 | 38 | constructor() internal { 39 | _status = _NOT_ENTERED; 40 | } 41 | 42 | /** 43 | * @dev Prevents a contract from calling itself, directly or indirectly. 44 | * Calling a `nonReentrant` function from another `nonReentrant` 45 | * function is not supported. It is possible to prevent this from happening 46 | * by making the `nonReentrant` function external, and make it call a 47 | * `private` function that does the actual work. 48 | */ 49 | modifier nonReentrant() { 50 | // On the first call to nonReentrant, _notEntered will be true 51 | require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); 52 | 53 | // Any calls to nonReentrant after this point will fail 54 | _status = _ENTERED; 55 | 56 | _; 57 | 58 | // By storing the original value once again, a refund is triggered (see 59 | // https://eips.ethereum.org/EIPS/eip-2200) 60 | _status = _NOT_ENTERED; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/utils/Create2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | /** 6 | * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer. 7 | * `CREATE2` can be used to compute in advance the address where a smart 8 | * contract will be deployed, which allows for interesting new mechanisms known 9 | * as 'counterfactual interactions'. 10 | * 11 | * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more 12 | * information. 13 | */ 14 | library Create2 { 15 | /** 16 | * @dev Deploys a contract using `CREATE2`. The address where the contract 17 | * will be deployed can be known in advance via {computeAddress}. 18 | * 19 | * The bytecode for a contract can be obtained from Solidity with 20 | * `type(contractName).creationCode`. 21 | * 22 | * Requirements: 23 | * 24 | * - `bytecode` must not be empty. 25 | * - `salt` must have not been used for `bytecode` already. 26 | * - the factory must have a balance of at least `amount`. 27 | * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. 28 | */ 29 | function deploy( 30 | uint256 amount, 31 | bytes32 salt, 32 | bytes memory bytecode 33 | ) internal returns (address) { 34 | address addr; 35 | require( 36 | address(this).balance >= amount, 37 | "Create2: insufficient balance" 38 | ); 39 | require(bytecode.length != 0, "Create2: bytecode length is zero"); 40 | // solhint-disable-next-line no-inline-assembly 41 | assembly { 42 | addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt) 43 | } 44 | require(addr != address(0), "Create2: Failed on deploy"); 45 | return addr; 46 | } 47 | 48 | /** 49 | * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the 50 | * `bytecodeHash` or `salt` will result in a new destination address. 51 | */ 52 | function computeAddress(bytes32 salt, bytes32 bytecodeHash) 53 | internal 54 | view 55 | returns (address) 56 | { 57 | return computeAddress(salt, bytecodeHash, address(this)); 58 | } 59 | 60 | /** 61 | * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at 62 | * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. 63 | */ 64 | function computeAddress( 65 | bytes32 salt, 66 | bytes32 bytecodeHash, 67 | address deployer 68 | ) internal pure returns (address) { 69 | bytes32 _data = 70 | keccak256( 71 | abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash) 72 | ); 73 | return address(uint256(_data)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /config/StrategyResolver.py: -------------------------------------------------------------------------------- 1 | from helpers.StrategyCoreResolver import StrategyCoreResolver 2 | from rich.console import Console 3 | 4 | console = Console() 5 | 6 | 7 | class StrategyResolver(StrategyCoreResolver): 8 | def get_strategy_destinations(self): 9 | """ 10 | Track balances for all strategy implementations 11 | (Strategy Must Implement) 12 | """ 13 | # E.G 14 | # strategy = self.manager.strategy 15 | # return { 16 | # "gauge": strategy.gauge(), 17 | # "mintr": strategy.mintr(), 18 | # } 19 | 20 | return {} 21 | 22 | def hook_after_confirm_withdraw(self, before, after, params): 23 | """ 24 | Specifies extra check for ordinary operation on withdrawal 25 | Use this to verify that balances in the get_strategy_destinations are properly set 26 | """ 27 | assert False 28 | 29 | def hook_after_confirm_deposit(self, before, after, params): 30 | """ 31 | Specifies extra check for ordinary operation on deposit 32 | Use this to verify that balances in the get_strategy_destinations are properly set 33 | """ 34 | assert False 35 | 36 | def hook_after_earn(self, before, after, params): 37 | """ 38 | Specifies extra check for ordinary operation on earn 39 | Use this to verify that balances in the get_strategy_destinations are properly set 40 | """ 41 | assert False 42 | 43 | def confirm_harvest(self, before, after, tx): 44 | """ 45 | Verfies that the Harvest produced yield and fees 46 | """ 47 | console.print("=== Compare Harvest ===") 48 | self.manager.printCompare(before, after) 49 | self.confirm_harvest_state(before, after, tx) 50 | 51 | valueGained = after.get("sett.pricePerFullShare") > before.get( 52 | "sett.pricePerFullShare" 53 | ) 54 | 55 | # # Strategist should earn if fee is enabled and value was generated 56 | # if before.get("strategy.performanceFeeStrategist") > 0 and valueGained: 57 | # assert after.balances("want", "strategist") > before.balances( 58 | # "want", "strategist" 59 | # ) 60 | 61 | # # Strategist should earn if fee is enabled and value was generated 62 | # if before.get("strategy.performanceFeeGovernance") > 0 and valueGained: 63 | # assert after.balances("want", "governanceRewards") > before.balances( 64 | # "want", "governanceRewards" 65 | # ) 66 | 67 | def confirm_tend(self, before, after, tx): 68 | """ 69 | Tend Should; 70 | - Increase the number of staked tended tokens in the strategy-specific mechanism 71 | - Reduce the number of tended tokens in the Strategy to zero 72 | 73 | (Strategy Must Implement) 74 | """ 75 | assert True 76 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.0; 4 | 5 | import "../GSN/ContextUpgradeable.sol"; 6 | import "../proxy/Initializable.sol"; 7 | 8 | /** 9 | * @dev Contract module which allows children to implement an emergency stop 10 | * mechanism that can be triggered by an authorized account. 11 | * 12 | * This module is used through inheritance. It will make available the 13 | * modifiers `whenNotPaused` and `whenPaused`, which can be applied to 14 | * the functions of your contract. Note that they will not be pausable by 15 | * simply including this module, only once the modifiers are put in place. 16 | */ 17 | contract PausableUpgradeable is Initializable, ContextUpgradeable { 18 | /** 19 | * @dev Emitted when the pause is triggered by `account`. 20 | */ 21 | event Paused(address account); 22 | 23 | /** 24 | * @dev Emitted when the pause is lifted by `account`. 25 | */ 26 | event Unpaused(address account); 27 | 28 | bool private _paused; 29 | 30 | /** 31 | * @dev Initializes the contract in unpaused state. 32 | */ 33 | function __Pausable_init() internal initializer { 34 | __Context_init_unchained(); 35 | __Pausable_init_unchained(); 36 | } 37 | 38 | function __Pausable_init_unchained() internal initializer { 39 | _paused = false; 40 | } 41 | 42 | /** 43 | * @dev Returns true if the contract is paused, and false otherwise. 44 | */ 45 | function paused() public view returns (bool) { 46 | return _paused; 47 | } 48 | 49 | /** 50 | * @dev Modifier to make a function callable only when the contract is not paused. 51 | * 52 | * Requirements: 53 | * 54 | * - The contract must not be paused. 55 | */ 56 | modifier whenNotPaused() { 57 | require(!_paused, "Pausable: paused"); 58 | _; 59 | } 60 | 61 | /** 62 | * @dev Modifier to make a function callable only when the contract is paused. 63 | * 64 | * Requirements: 65 | * 66 | * - The contract must be paused. 67 | */ 68 | modifier whenPaused() { 69 | require(_paused, "Pausable: not paused"); 70 | _; 71 | } 72 | 73 | /** 74 | * @dev Triggers stopped state. 75 | * 76 | * Requirements: 77 | * 78 | * - The contract must not be paused. 79 | */ 80 | function _pause() internal virtual whenNotPaused { 81 | _paused = true; 82 | emit Paused(_msgSender()); 83 | } 84 | 85 | /** 86 | * @dev Returns to normal state. 87 | * 88 | * Requirements: 89 | * 90 | * - The contract must be paused. 91 | */ 92 | function _unpause() internal virtual whenPaused { 93 | _paused = false; 94 | emit Unpaused(_msgSender()); 95 | } 96 | 97 | uint256[49] private __gap; 98 | } 99 | -------------------------------------------------------------------------------- /deps/@openzeppelin/contracts/payment/PullPayment.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.6.2; 4 | 5 | import "./escrow/Escrow.sol"; 6 | 7 | /** 8 | * @dev Simple implementation of a 9 | * https://consensys.github.io/smart-contract-best-practices/recommendations/#favor-pull-over-push-for-external-calls[pull-payment] 10 | * strategy, where the paying contract doesn't interact directly with the 11 | * receiver account, which must withdraw its payments itself. 12 | * 13 | * Pull-payments are often considered the best practice when it comes to sending 14 | * Ether, security-wise. It prevents recipients from blocking execution, and 15 | * eliminates reentrancy concerns. 16 | * 17 | * TIP: If you would like to learn more about reentrancy and alternative ways 18 | * to protect against it, check out our blog post 19 | * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. 20 | * 21 | * To use, derive from the `PullPayment` contract, and use {_asyncTransfer} 22 | * instead of Solidity's `transfer` function. Payees can query their due 23 | * payments with {payments}, and retrieve them with {withdrawPayments}. 24 | */ 25 | contract PullPayment { 26 | Escrow private _escrow; 27 | 28 | constructor() internal { 29 | _escrow = new Escrow(); 30 | } 31 | 32 | /** 33 | * @dev Withdraw accumulated payments, forwarding all gas to the recipient. 34 | * 35 | * Note that _any_ account can call this function, not just the `payee`. 36 | * This means that contracts unaware of the `PullPayment` protocol can still 37 | * receive funds this way, by having a separate account call 38 | * {withdrawPayments}. 39 | * 40 | * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. 41 | * Make sure you trust the recipient, or are either following the 42 | * checks-effects-interactions pattern or using {ReentrancyGuard}. 43 | * 44 | * @param payee Whose payments will be withdrawn. 45 | */ 46 | function withdrawPayments(address payable payee) public virtual { 47 | _escrow.withdraw(payee); 48 | } 49 | 50 | /** 51 | * @dev Returns the payments owed to an address. 52 | * @param dest The creditor's address. 53 | */ 54 | function payments(address dest) public view returns (uint256) { 55 | return _escrow.depositsOf(dest); 56 | } 57 | 58 | /** 59 | * @dev Called by the payer to store the sent amount as credit to be pulled. 60 | * Funds sent in this way are stored in an intermediate {Escrow} contract, so 61 | * there is no danger of them being spent before withdrawal. 62 | * 63 | * @param dest The destination address of the funds. 64 | * @param amount The amount to transfer. 65 | */ 66 | function _asyncTransfer(address dest, uint256 amount) internal virtual { 67 | _escrow.deposit{value: amount}(dest); 68 | } 69 | } 70 | --------------------------------------------------------------------------------