├── .env.example ├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .gitmodules ├── .nvmrc ├── .pre-commit-config.yaml ├── .prettierrc ├── .solcover.cjs ├── .soliumignore ├── .soliumrc.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── contracts ├── child │ ├── BaseERC20.sol │ ├── BaseERC20NoSig.sol │ ├── ChildChain.sol │ ├── ChildERC20.sol │ ├── ChildERC721.sol │ ├── ChildERC721Mintable.sol │ ├── ChildToken.sol │ ├── ERC20Detailed.sol │ ├── MRC20.sol │ ├── bor │ │ ├── StateReceiver.sol │ │ └── StateSyncerVerifier.sol │ ├── misc │ │ ├── EIP712.sol │ │ ├── IParentToken.sol │ │ └── LibTokenTransferOrder.sol │ └── proxifiedChildToken │ │ ├── ChildERC20Proxified.sol │ │ ├── ChildERC721Proxified.sol │ │ └── ChildTokenProxy.sol ├── common │ ├── Registry.sol │ ├── gnosis │ │ ├── GnosisSafe.sol │ │ └── GnosisSafeProxy.sol │ ├── governance │ │ ├── Governable.sol │ │ ├── Governance.sol │ │ ├── GovernanceProxy.sol │ │ └── IGovernance.sol │ ├── lib │ │ ├── BytesLib.sol │ │ ├── Common.sol │ │ ├── ECVerify.sol │ │ ├── ExitPayloadReader.sol │ │ ├── Merkle.sol │ │ ├── MerklePatriciaProof.sol │ │ ├── PriorityQueue.sol │ │ └── RLPEncode.sol │ ├── misc │ │ ├── ContractReceiver.sol │ │ ├── DelegateProxy.sol │ │ ├── DelegateProxyForwarder.sol │ │ ├── DrainStakeManager.sol │ │ ├── Drainable.sol │ │ ├── ERCProxy.sol │ │ ├── Proxy.sol │ │ ├── ProxyStorage.sol │ │ └── UpgradableProxy.sol │ ├── mixin │ │ ├── ChainIdMixin.sol.template │ │ ├── GovernanceLockable.sol │ │ ├── Initializable.sol │ │ ├── Lockable.sol │ │ ├── OwnableLockable.sol │ │ └── RootChainable.sol │ └── tokens │ │ ├── ERC20NonTradable.sol │ │ ├── ERC721PlasmaMintable.sol │ │ ├── MaticWETH.sol │ │ ├── RootERC721.sol │ │ ├── TestToken.sol │ │ └── WETH.sol ├── root │ ├── IRootChain.sol │ ├── RootChain.sol │ ├── RootChainProxy.sol │ ├── RootChainStorage.sol │ ├── depositManager │ │ ├── DepositManager.sol │ │ ├── DepositManagerProxy.sol │ │ ├── DepositManagerStorage.sol │ │ └── IDepositManager.sol │ ├── predicates │ │ ├── ERC20Predicate.sol │ │ ├── ERC20PredicateBurnOnly.sol │ │ ├── ERC721Predicate.sol │ │ ├── ERC721PredicateBurnOnly.sol │ │ ├── IPredicate.sol │ │ └── MintableERC721Predicate.sol │ ├── stateSyncer │ │ └── StateSender.sol │ └── withdrawManager │ │ ├── ExitNFT.sol │ │ ├── IWithdrawManager.sol │ │ ├── WithdrawManager.sol │ │ ├── WithdrawManagerProxy.sol │ │ └── WithdrawManagerStorage.sol ├── staking │ ├── EventsHub.sol │ ├── EventsHubProxy.sol │ ├── StakingInfo.sol │ ├── slashing │ │ ├── ISlashingManager.sol │ │ └── SlashingManager.sol │ ├── stakeManager │ │ ├── IStakeManager.sol │ │ ├── StakeManager.sol │ │ ├── StakeManagerExtension.sol │ │ ├── StakeManagerProxy.sol │ │ ├── StakeManagerStorage.sol │ │ ├── StakeManagerStorageExtension.sol │ │ └── StakingNFT.sol │ └── validatorShare │ │ ├── IValidatorShare.sol │ │ ├── ValidatorShare.sol │ │ ├── ValidatorShareFactory.sol │ │ └── ValidatorShareProxy.sol └── test │ ├── ContractActor.sol │ ├── GovernanceLockableTest.sol │ ├── PolygonMigrationTest.sol │ ├── Proxy │ ├── ProxyTestImpl.sol │ └── ProxyTestImplStorageLayoutChange.sol │ ├── StakeManagerTest.sol │ ├── StakeManagerTestable.sol │ ├── TestMaticChildERC20.sol │ └── ValidatorShareTest.sol ├── docs └── autogen │ ├── .gitignore │ ├── book.css │ ├── book.toml │ ├── solidity.min.js │ └── src │ ├── README.md │ ├── SUMMARY.md │ └── contracts │ ├── Migrations.sol │ └── contract.Migrations.md │ ├── README.md │ ├── child │ ├── BaseERC20.sol │ │ └── contract.BaseERC20.md │ ├── BaseERC20NoSig.sol │ │ └── contract.BaseERC20NoSig.md │ ├── ChildChain.sol │ │ └── contract.ChildChain.md │ ├── ChildERC20.sol │ │ └── contract.ChildERC20.md │ ├── ChildERC721.sol │ │ └── contract.ChildERC721.md │ ├── ChildERC721Mintable.sol │ │ └── contract.ChildERC721Mintable.md │ ├── ChildToken.sol │ │ └── contract.ChildToken.md │ ├── ERC20Detailed.sol │ │ └── contract.ERC20Detailed.md │ ├── MRC20.sol │ │ └── contract.MRC20.md │ ├── README.md │ ├── bor │ │ ├── README.md │ │ ├── StateReceiver.sol │ │ │ └── interface.StateReceiver.md │ │ └── StateSyncerVerifier.sol │ │ │ └── contract.StateSyncerVerifier.md │ ├── misc │ │ ├── EIP712.sol │ │ │ └── contract.LibEIP712Domain.md │ │ ├── IParentToken.sol │ │ │ └── interface.IParentToken.md │ │ ├── LibTokenTransferOrder.sol │ │ │ └── contract.LibTokenTransferOrder.md │ │ ├── Marketplace.sol │ │ │ ├── contract.Marketplace.md │ │ │ └── interface.MarketplaceToken.md │ │ ├── ParentTokenMock.sol │ │ │ └── contract.ParentTokenMock.md │ │ └── README.md │ └── proxifiedChildToken │ │ ├── ChildERC20Proxified.sol │ │ └── contract.ChildERC20Proxified.md │ │ ├── ChildERC721Proxified.sol │ │ └── contract.ChildERC721Proxified.md │ │ ├── ChildTokenProxy.sol │ │ └── contract.ChildTokenProxy.md │ │ └── README.md │ ├── common │ ├── README.md │ ├── Registry.sol │ │ └── contract.Registry.md │ ├── gnosis │ │ ├── GnosisSafe.sol │ │ │ ├── contract.Enum.md │ │ │ ├── contract.Executor.md │ │ │ ├── contract.FallbackManager.md │ │ │ ├── contract.GnosisSafe.md │ │ │ ├── contract.ISignatureValidator.md │ │ │ ├── contract.ISignatureValidatorConstants.md │ │ │ ├── contract.MasterCopy.md │ │ │ ├── contract.Module.md │ │ │ ├── contract.ModuleManager.md │ │ │ ├── contract.OwnerManager.md │ │ │ ├── contract.SecuredTokenTransfer.md │ │ │ ├── contract.SelfAuthorized.md │ │ │ ├── contract.SignatureDecoder.md │ │ │ └── library.SafeMath.md │ │ ├── GnosisSafeProxy.sol │ │ │ └── contract.GnosisSafeProxy.md │ │ └── README.md │ ├── governance │ │ ├── Governable.sol │ │ │ └── contract.Governable.md │ │ ├── Governance.sol │ │ │ └── contract.Governance.md │ │ ├── GovernanceProxy.sol │ │ │ └── contract.GovernanceProxy.md │ │ ├── IGovernance.sol │ │ │ └── interface.IGovernance.md │ │ └── README.md │ ├── lib │ │ ├── BytesLib.sol │ │ │ └── library.BytesLib.md │ │ ├── Common.sol │ │ │ └── library.Common.md │ │ ├── ECVerify.sol │ │ │ └── library.ECVerify.md │ │ ├── ExitPayloadReader.sol │ │ │ └── library.ExitPayloadReader.md │ │ ├── Merkle.sol │ │ │ └── library.Merkle.md │ │ ├── MerklePatriciaProof.sol │ │ │ └── library.MerklePatriciaProof.md │ │ ├── PriorityQueue.sol │ │ │ └── contract.PriorityQueue.md │ │ ├── README.md │ │ └── RLPEncode.sol │ │ │ └── library.RLPEncode.md │ ├── misc │ │ ├── ContractReceiver.sol │ │ │ └── contract.ContractReceiver.md │ │ ├── DelegateProxy.sol │ │ │ └── contract.DelegateProxy.md │ │ ├── DelegateProxyForwarder.sol │ │ │ └── contract.DelegateProxyForwarder.md │ │ ├── DrainStakeManager.sol │ │ │ └── contract.DrainStakeManager.md │ │ ├── Drainable.sol │ │ │ └── contract.Drainable.md │ │ ├── ERCProxy.sol │ │ │ └── interface.ERCProxy.md │ │ ├── Proxy.sol │ │ │ └── contract.Proxy.md │ │ ├── ProxyStorage.sol │ │ │ └── contract.ProxyStorage.md │ │ ├── README.md │ │ └── UpgradableProxy.sol │ │ │ └── contract.UpgradableProxy.md │ ├── mixin │ │ ├── ChainIdMixin.sol │ │ │ └── contract.ChainIdMixin.md │ │ ├── GovernanceLockable.sol │ │ │ └── contract.GovernanceLockable.md │ │ ├── Initializable.sol │ │ │ └── contract.Initializable.md │ │ ├── Lockable.sol │ │ │ └── contract.Lockable.md │ │ ├── OwnableLockable.sol │ │ │ └── contract.OwnableLockable.md │ │ ├── README.md │ │ └── RootChainable.sol │ │ │ └── contract.RootChainable.md │ └── tokens │ │ ├── ERC20NonTradable.sol │ │ └── contract.ERC20NonTradable.md │ │ ├── ERC20NonTransferable.sol │ │ └── contract.ERC20NonTransferable.md │ │ ├── ERC721PlasmaMintable.sol │ │ └── contract.ERC721PlasmaMintable.md │ │ ├── MaticWETH.sol │ │ └── contract.MaticWETH.md │ │ ├── POLTokenMock.sol │ │ └── contract.POLTokenMock.md │ │ ├── README.md │ │ ├── RootERC721.sol │ │ └── contract.RootERC721.md │ │ ├── TestToken.sol │ │ └── contract.TestToken.md │ │ └── WETH.sol │ │ └── contract.WETH.md │ ├── root │ ├── IRootChain.sol │ │ └── interface.IRootChain.md │ ├── README.md │ ├── RootChain.sol │ │ └── contract.RootChain.md │ ├── RootChainProxy.sol │ │ └── contract.RootChainProxy.md │ ├── RootChainStorage.sol │ │ ├── contract.RootChainHeader.md │ │ └── contract.RootChainStorage.md │ ├── depositManager │ │ ├── DepositManager.sol │ │ │ ├── contract.DepositManager.md │ │ │ └── interface.IPolygonMigration.md │ │ ├── DepositManagerProxy.sol │ │ │ └── contract.DepositManagerProxy.md │ │ ├── DepositManagerStorage.sol │ │ │ ├── contract.DepositManagerHeader.md │ │ │ └── contract.DepositManagerStorage.md │ │ ├── IDepositManager.sol │ │ │ └── interface.IDepositManager.md │ │ └── README.md │ ├── predicates │ │ ├── ERC20Predicate.sol │ │ │ └── contract.ERC20Predicate.md │ │ ├── ERC20PredicateBurnOnly.sol │ │ │ └── contract.ERC20PredicateBurnOnly.md │ │ ├── ERC721Predicate.sol │ │ │ └── contract.ERC721Predicate.md │ │ ├── ERC721PredicateBurnOnly.sol │ │ │ └── contract.ERC721PredicateBurnOnly.md │ │ ├── IPredicate.sol │ │ │ ├── contract.IErcPredicate.md │ │ │ ├── contract.PredicateUtils.md │ │ │ └── interface.IPredicate.md │ │ ├── MarketplacePredicate.sol │ │ │ └── contract.MarketplacePredicate.md │ │ ├── MintableERC721Predicate.sol │ │ │ └── contract.MintableERC721Predicate.md │ │ ├── README.md │ │ ├── TransferWithSigPredicate.sol │ │ │ └── contract.TransferWithSigPredicate.md │ │ └── TransferWithSigUtils.sol │ │ │ └── library.TransferWithSigUtils.md │ ├── stateSyncer │ │ ├── README.md │ │ └── StateSender.sol │ │ │ └── contract.StateSender.md │ └── withdrawManager │ │ ├── ExitNFT.sol │ │ └── contract.ExitNFT.md │ │ ├── IWithdrawManager.sol │ │ └── contract.IWithdrawManager.md │ │ ├── README.md │ │ ├── WithdrawManager.sol │ │ └── contract.WithdrawManager.md │ │ ├── WithdrawManagerProxy.sol │ │ └── contract.WithdrawManagerProxy.md │ │ └── WithdrawManagerStorage.sol │ │ ├── contract.ExitsDataStructure.md │ │ ├── contract.WithdrawManagerHeader.md │ │ └── contract.WithdrawManagerStorage.md │ ├── staking │ ├── EventsHub.sol │ │ ├── contract.EventsHub.md │ │ └── contract.IStakeManagerEventsHub.md │ ├── EventsHubProxy.sol │ │ └── contract.EventsHubProxy.md │ ├── README.md │ ├── StakingInfo.sol │ │ ├── contract.IStakeManagerLocal.md │ │ └── contract.StakingInfo.md │ ├── slashing │ │ ├── ISlashingManager.sol │ │ │ └── contract.ISlashingManager.md │ │ ├── README.md │ │ └── SlashingManager.sol │ │ │ └── contract.SlashingManager.md │ ├── stakeManager │ │ ├── IStakeManager.sol │ │ │ └── contract.IStakeManager.md │ │ ├── README.md │ │ ├── StakeManager.sol │ │ │ └── contract.StakeManager.md │ │ ├── StakeManagerExtension.sol │ │ │ └── contract.StakeManagerExtension.md │ │ ├── StakeManagerProxy.sol │ │ │ └── contract.StakeManagerProxy.md │ │ ├── StakeManagerStorage.sol │ │ │ └── contract.StakeManagerStorage.md │ │ ├── StakeManagerStorageExtension.sol │ │ │ └── contract.StakeManagerStorageExtension.md │ │ └── StakingNFT.sol │ │ │ └── contract.StakingNFT.md │ └── validatorShare │ │ ├── IValidatorShare.sol │ │ └── contract.IValidatorShare.md │ │ ├── README.md │ │ ├── ValidatorShare.sol │ │ └── contract.ValidatorShare.md │ │ ├── ValidatorShareFactory.sol │ │ └── contract.ValidatorShareFactory.md │ │ └── ValidatorShareProxy.sol │ │ └── contract.ValidatorShareProxy.md │ └── test │ ├── ContractActor.sol │ ├── contract.ContractWitRevertingFallback.md │ ├── contract.ContractWithFallback.md │ └── contract.ContractWithoutFallback.md │ ├── GovernanceLockableTest.sol │ └── contract.GovernanceLockableTest.md │ ├── MarketplacePredicateTest.sol │ └── contract.MarketplacePredicateTest.md │ ├── PolygonMigrationTest.sol │ └── contract.PolygonMigrationTest.md │ ├── Proxy │ ├── ProxyTestImpl.sol │ │ └── contract.ProxyTestImpl.md │ ├── ProxyTestImplStorageLayoutChange.sol │ │ └── contract.ProxyTestImplStorageLayoutChange.md │ └── README.md │ ├── README.md │ ├── StakeManagerTest.sol │ └── contract.StakeManagerTest.md │ ├── StakeManagerTestable.sol │ └── contract.StakeManagerTestable.md │ ├── TestMaticChildERC20.sol │ └── contract.TestMRC20.md │ └── ValidatorShareTest.sol │ └── contract.ValidatorShareTest.md ├── foundry.toml ├── hardhat.config.cjs ├── package-lock.json ├── package.json ├── scripts ├── deployers │ └── CounterDeployer.s.sol ├── process-templates.cjs ├── run-test.sh └── util │ └── doc_gen.sh ├── slither.config.json ├── test-bor-docker ├── clean.sh ├── genesis.json ├── genesis.json.template ├── keystore │ ├── 0_9fb29aac15b9a4b7f17c3385939b007540f4d791 │ └── 1_96c42c56fdb78294f96b0cfa33c92bed7d75f96a ├── password.txt ├── run-docker.sh ├── start.sh ├── start.sh.template ├── stop-docker.sh └── stop.sh └── test ├── helpers ├── StatefulUtils.js ├── artifacts.js ├── blocks.js ├── chain.js ├── deployer.js ├── log-decoder.js ├── marketplaceUtils.js.template ├── merkle-tree.js ├── proofs.js ├── utils.js └── wallets.js ├── integration └── root │ ├── DepositManager.test.js │ ├── DepositManagerUpdate.test.js │ └── predicates │ ├── ERC20PredicateBurnOnly.test.js │ ├── ERC721PredicateBurnOnly.test.js │ └── predicateTestUtils.js ├── mockResponses └── utils.js └── units ├── GovernanceLockable.test.js ├── Initializable.test.js ├── UpgradableProxy.test.js ├── behaviors └── SupportsInterface.behavior.js ├── child ├── ChildErc20.test.js └── ChildErc721.test.js ├── root ├── DepositManager.test.js ├── Drainable.test.js └── RootChain.test.js └── staking ├── DrainStakeManager.test.js ├── SlashingManager.test.js ├── StakingNFT.test.js ├── ValidatorShare.test.js ├── ValidatorShareHelper.js ├── deployment.js └── stakeManager ├── StakeManager.Staking.js └── StakeManager.test.js /.env.example: -------------------------------------------------------------------------------- 1 | INFURA_TOKEN="909b972ab2ff3afb8b0f8f6a9667test" 2 | BOR_CHAIN_URL="http://localhost:9545" 3 | ENV="local" 4 | MNEMONIC_DEV="poly radar mass judge dismiss just intact mind resemble fringe diary casino" -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Setup Node.js environment 16 | uses: actions/setup-node@v4 17 | with: 18 | node-version: "20.x" 19 | registry-url: "https://registry.npmjs.org" 20 | 21 | - name: Cache npm dependencies 22 | uses: actions/cache@v4 23 | with: 24 | path: ~/.npm 25 | key: ${{ runner.OS }}-npm-cache-${{ hashFiles('./package-lock.json') }} 26 | restore-keys: | 27 | ${{ runner.OS }}-npm-cache- 28 | 29 | - name: Install npm dependencies 30 | run: npm install 31 | 32 | - name: Process templates 33 | run: npm run template:process 34 | 35 | - name: Run Coverage and Hardhat tests 36 | run: npm run test:ci 37 | 38 | - name: Install Foundry 39 | uses: foundry-rs/foundry-toolchain@v1 40 | with: 41 | version: nightly 42 | 43 | - name: Run Forge build 44 | run: | 45 | forge --version 46 | forge build --sizes 47 | id: build 48 | 49 | - name: Run Forge tests 50 | run: | 51 | forge test -vvv 52 | id: test 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | artifacts 3 | out 4 | contractAddresses.json 5 | .vscode 6 | 7 | 8 | # ignore generated files 9 | contracts/root/predicates/TransferWithSigUtils.sol 10 | contracts/common/mixin/ChainIdMixin.sol 11 | test/helpers/marketplaceUtils.js 12 | cache_hardhat 13 | forge-cache 14 | 15 | 16 | test-bor-docker/history 17 | test-bor-docker/data 18 | 19 | *.pid 20 | *.log 21 | 22 | .DS_Store 23 | .vscode 24 | *.env 25 | 26 | coverage/ 27 | 28 | coverage.json 29 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/solady"] 2 | path = lib/solady 3 | url = https://github.com/vectorized/solady 4 | [submodule "lib/deployment-log-generator"] 5 | path = lib/deployment-log-generator 6 | url = https://github.com/0xPolygon/deployment-log-generator 7 | [submodule "lib/contract-deployer-template"] 8 | path = lib/contract-deployer-template 9 | url = https://github.com/0xPolygon/contract-deployer-template 10 | [submodule "lib/storage-layout-checker"] 11 | path = lib/storage-layout-checker 12 | url = https://github.com/0xPolygon/storage-layout-checker -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20.6.0 2 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.5.0 4 | hooks: 5 | - id: mixed-line-ending 6 | args: ["--fix=lf"] 7 | description: Forces to replace line ending by the UNIX 'lf' character. 8 | exclude: "^docs/autogen" 9 | - repo: local 10 | hooks: 11 | - id: format 12 | name: Format solidity code 13 | description: Format solidity code with `forge fmt` 14 | language: system 15 | entry: forge fmt 16 | exclude: "^lib/" 17 | pass_filenames: true 18 | - id: doc 19 | name: Generate documentation 20 | description: Generate docs with `forge doc` 21 | language: system 22 | # generates docs and unstages files if only the commit hash changed within the file, this way only when the documentation is updated, the documentation needs to be regenerated and only the changed files are pushed 23 | entry: "scripts/util/doc_gen.sh" 24 | pass_filenames: false 25 | - repo: https://github.com/pre-commit/mirrors-prettier 26 | rev: "v3.0.3" 27 | hooks: 28 | - id: prettier 29 | name: Format non solidity files with prettier 30 | exclude: "^docs/autogen" 31 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": "*.sol", 5 | "options": { 6 | "printWidth": 120, 7 | "tabWidth": 4, 8 | "useTabs": false, 9 | "singleQuote": false, 10 | "bracketSpacing": false, 11 | "explicitTypes": "always" 12 | } 13 | }, 14 | { 15 | "files": "*.js", 16 | "options": { 17 | "semi": false, 18 | "singleQuote": true, 19 | "tabWidth": 2, 20 | "printWidth": 120, 21 | "trailingComma": "none" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /.solcover.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | mocha: { 3 | grep: "@skip-on-coverage", // Find everything with this tag 4 | invert: true, // Run the grep's inverse set. 5 | }, 6 | compileCommand: "npx hardhat compile", 7 | }; 8 | -------------------------------------------------------------------------------- /.soliumignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.soliumrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "solium:all", 3 | "plugins": ["security"], 4 | "rules": { 5 | "imports-on-top": 1, 6 | "variable-declarations": 1, 7 | "array-declarations": 1, 8 | "operator-whitespace": 1, 9 | "lbrace": 0, 10 | "mixedcase": 0, 11 | "camelcase": 1, 12 | "uppercase": 1, 13 | "no-empty-blocks": 1, 14 | "no-unused-vars": 1, 15 | "quotes": 1, 16 | "error-reason": 0, 17 | "indentation": ["error", 4], 18 | "arg-overflow": ["error", 8], 19 | "whitespace": 1, 20 | "deprecated-suicide": 1, 21 | "pragma-on-top": 1, 22 | "no-experimental": 0, 23 | "security/enforce-explicit-visibility": ["error"], 24 | "security/no-block-members": ["warning"], 25 | "security/no-low-level-calls": 0, 26 | "security/no-inline-assembly": 0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!WARNING] 2 | > This repository is no longer in use, and has been migrated to https://github.com/0xPolygon/pos-contracts 3 | 4 | # Matic contracts 5 | 6 | ![Build Status](https://github.com/maticnetwork/contracts/workflows/CI/badge.svg) 7 | 8 | Ethereum smart contracts that power the [Matic Network](https://polygon.technology/polygon-pos). 9 | 10 | ### Install dependencies with 11 | 12 | ``` 13 | npm install 14 | ``` 15 | 16 | ### Setup 17 | 18 | ``` 19 | pre-commit install 20 | ``` 21 | 22 | ### Compile 23 | 24 | ``` 25 | npm run template:process -- --bor-chain-id 15001 26 | ``` 27 | 28 | bor-chain-id should be: 29 | **local: 15001** 30 | Mainnet = 137 31 | TestnetV4 (Mumbai) = 80001 32 | 33 | ### Main chain and side chain 34 | 35 | - Main chain 36 | 37 | All tests are run against a fork of mainnet using Hardhat's forking functionality. No need to run any local chain! 38 | 39 | - Start Matic side chain. Requires docker. 40 | 41 | ``` 42 | npm run bor:simulate 43 | ``` 44 | 45 | - Stop with 46 | 47 | ``` 48 | npm run bor:stop 49 | ``` 50 | 51 | - If you want a clean chain, this also deletes your /data folder containing the chain state. 52 | 53 | ``` 54 | npm run bor:clean 55 | ``` 56 | 57 | ### Run tests 58 | 59 | Run Hardhat test 60 | 61 | ``` 62 | npm test:hardhat 63 | ``` 64 | 65 | Run Foundry test 66 | 67 | ``` 68 | npm test:foundry 69 | ``` 70 | 71 | ### Coverage 72 | 73 | Run coverage with 74 | 75 | ``` 76 | npm run coverage 77 | ``` 78 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Polygon Technology Security Information 2 | 3 | ## Link to vulnerability disclosure details (Bug Bounty). 4 | 5 | - Websites and Applications: https://hackerone.com/polygon-technology 6 | - Smart Contracts: https://immunefi.com/bounty/polygon 7 | 8 | ## Languages that our team speaks and understands. 9 | 10 | Preferred-Languages: en 11 | 12 | ## Security-related job openings at Polygon. 13 | 14 | https://polygon.technology/careers 15 | 16 | ## Polygon security contact details. 17 | 18 | security@polygon.technology 19 | 20 | ## The URL for accessing the security.txt file. 21 | 22 | Canonical: https://polygon.technology/security.txt 23 | -------------------------------------------------------------------------------- /contracts/child/BaseERC20NoSig.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import "./ChildToken.sol"; 4 | 5 | contract BaseERC20NoSig is ChildToken { 6 | event Deposit( 7 | address indexed token, 8 | address indexed from, 9 | uint256 amount, 10 | uint256 input1, 11 | uint256 output1 12 | ); 13 | 14 | event Withdraw( 15 | address indexed token, 16 | address indexed from, 17 | uint256 amount, 18 | uint256 input1, 19 | uint256 output1 20 | ); 21 | 22 | event LogTransfer( 23 | address indexed token, 24 | address indexed from, 25 | address indexed to, 26 | uint256 amount, 27 | uint256 input1, 28 | uint256 input2, 29 | uint256 output1, 30 | uint256 output2 31 | ); 32 | 33 | constructor() public {} 34 | 35 | function transferWithSig( 36 | bytes calldata sig, 37 | uint256 amount, 38 | bytes32 data, 39 | uint256 expiration, 40 | address to 41 | ) external returns (address from) { 42 | revert("Disabled feature"); 43 | } 44 | 45 | function balanceOf(address account) external view returns (uint256); 46 | function _transfer(address sender, address recipient, uint256 amount) 47 | internal; 48 | 49 | /// @param from Address from where tokens are withdrawn. 50 | /// @param to Address to where tokens are sent. 51 | /// @param value Number of tokens to transfer. 52 | /// @return Returns success of function call. 53 | function _transferFrom(address from, address to, uint256 value) 54 | internal 55 | returns (bool) 56 | { 57 | uint256 input1 = this.balanceOf(from); 58 | uint256 input2 = this.balanceOf(to); 59 | _transfer(from, to, value); 60 | emit LogTransfer( 61 | token, 62 | from, 63 | to, 64 | value, 65 | input1, 66 | input2, 67 | this.balanceOf(from), 68 | this.balanceOf(to) 69 | ); 70 | return true; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /contracts/child/ChildERC721Mintable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import "openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol"; 4 | import "openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol"; 5 | 6 | import {ChildERC721} from "./ChildERC721.sol"; 7 | 8 | contract ChildERC721Mintable is 9 | ChildERC721, 10 | ERC721Mintable, 11 | ERC721MetadataMintable 12 | { 13 | constructor(address rootToken, string memory name, string memory symbol) 14 | public 15 | ChildERC721( 16 | msg.sender, /* _owner */ 17 | rootToken, 18 | name, 19 | symbol 20 | ) 21 | {} 22 | } 23 | -------------------------------------------------------------------------------- /contracts/child/ERC20Detailed.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | /** 4 | * @title ERC20Detailed token 5 | * @dev The decimals are only for visualization purposes. 6 | * All the operations are done using the smallest and indivisible token unit, 7 | * just as on Ethereum all the operations are done in wei. 8 | */ 9 | contract ERC20Detailed { 10 | string internal _name; 11 | string internal _symbol; 12 | uint8 internal _decimals; 13 | 14 | constructor (string memory name, string memory symbol, uint8 decimals) public { 15 | _name = name; 16 | _symbol = symbol; 17 | _decimals = decimals; 18 | } 19 | 20 | /** 21 | * @return the name of the token. 22 | */ 23 | function name() public view returns (string memory) { 24 | return _name; 25 | } 26 | 27 | /** 28 | * @return the symbol of the token. 29 | */ 30 | function symbol() public view returns (string memory) { 31 | return _symbol; 32 | } 33 | 34 | /** 35 | * @return the number of decimals of the token. 36 | */ 37 | function decimals() public view returns (uint8) { 38 | return _decimals; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /contracts/child/bor/StateReceiver.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | // StateReceiver represents interface to receive state 4 | interface StateReceiver { 5 | function onStateReceive(uint256 id, bytes calldata data) external; 6 | } 7 | -------------------------------------------------------------------------------- /contracts/child/bor/StateSyncerVerifier.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 4 | 5 | contract StateSyncerVerifier is Ownable { 6 | address public stateSyncer; 7 | 8 | event StateSyncerAddressChanged( 9 | address indexed previousAddress, 10 | address indexed newAddress 11 | ); 12 | 13 | /** 14 | * @dev Throws if called by any account other than state syncer 15 | */ 16 | modifier onlyStateSyncer() { 17 | require( 18 | isOnlyStateSyncerContract(), 19 | "State syncer: caller is not the state syncer contract" 20 | ); 21 | _; 22 | } 23 | 24 | // initial setup 25 | constructor() public { 26 | // default state syncer contract 27 | stateSyncer = 0x0000000000000000000000000000000000001001; 28 | 29 | // emit event for first change 30 | emit StateSyncerAddressChanged(address(0), stateSyncer); 31 | } 32 | 33 | /** 34 | * @dev Returns true if the caller is the state syncer contract 35 | * TODO: replace onlyOwner ownership with 0x1000 for validator majority 36 | */ 37 | function isOnlyStateSyncerContract() public view returns (bool) { 38 | return msg.sender == stateSyncer; 39 | } 40 | 41 | // change state syncer address 42 | function changeStateSyncerAddress(address newAddress) public onlyOwner { 43 | require( 44 | newAddress != address(0), 45 | "State syncer: new state syncer address is the zero address" 46 | ); 47 | emit StateSyncerAddressChanged(stateSyncer, newAddress); 48 | stateSyncer = newAddress; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /contracts/child/misc/IParentToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | //interface for parent contract of any child token 3 | 4 | interface IParentToken { 5 | function beforeTransfer(address sender, address to, uint256 value) 6 | external 7 | returns (bool); 8 | } 9 | -------------------------------------------------------------------------------- /contracts/child/proxifiedChildToken/ChildERC20Proxified.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Initializable} from "../../common/mixin/Initializable.sol"; 4 | import "../ChildERC20.sol"; 5 | 6 | contract ChildERC20Proxified is ChildERC20, Initializable { 7 | constructor() public ChildERC20(address(0x1), address(0x1), "", "", 18) {} 8 | 9 | function initialize( 10 | address _token, 11 | string calldata name, 12 | string calldata symbol, 13 | uint8 decimals 14 | ) external initializer { 15 | require(_token != address(0x0)); 16 | token = _token; 17 | _name = name; 18 | _symbol = symbol; 19 | _decimals = decimals; 20 | } 21 | 22 | // Overriding isOwner from Ownable.sol because owner() and transferOwnership() have been overridden by UpgradableProxy 23 | function isOwner() public view returns (bool) { 24 | address _owner; 25 | bytes32 position = keccak256("matic.network.proxy.owner"); 26 | assembly { 27 | _owner := sload(position) 28 | } 29 | return msg.sender == _owner; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/child/proxifiedChildToken/ChildERC721Proxified.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Initializable} from "../../common/mixin/Initializable.sol"; 4 | import "../ChildERC721.sol"; 5 | 6 | contract ChildERC721Proxified is ChildERC721, Initializable { 7 | string public name; 8 | string public symbol; 9 | 10 | constructor() public ChildERC721(address(0x1), address(0x1), "", "") {} 11 | 12 | function initialize( 13 | address _token, 14 | string calldata _name, 15 | string calldata _symbol 16 | ) external initializer { 17 | require(_token != address(0x0)); 18 | token = _token; 19 | name = _name; 20 | symbol = _symbol; 21 | } 22 | 23 | // Overriding isOwner from Ownable.sol because owner() and transferOwnership() have been overridden by UpgradableProxy 24 | function isOwner() public view returns (bool) { 25 | address _owner; 26 | bytes32 position = keccak256("matic.network.proxy.owner"); 27 | assembly { 28 | _owner := sload(position) 29 | } 30 | return msg.sender == _owner; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /contracts/child/proxifiedChildToken/ChildTokenProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {UpgradableProxy} from "../../common/misc/UpgradableProxy.sol"; 4 | 5 | contract ChildTokenProxy is UpgradableProxy { 6 | constructor(address _proxyTo) public UpgradableProxy(_proxyTo) {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/common/gnosis/GnosisSafeProxy.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2020-01-13 3 | */ 4 | 5 | pragma solidity ^0.5.3; 6 | 7 | /// @title Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract. 8 | /// @author Stefan George - 9 | /// @author Richard Meissner - 10 | contract GnosisSafeProxy { 11 | 12 | // masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated. 13 | // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt` 14 | address internal masterCopy; 15 | 16 | /// @dev Constructor function sets address of master copy contract. 17 | /// @param _masterCopy Master copy address. 18 | constructor(address _masterCopy) 19 | public 20 | { 21 | require(_masterCopy != address(0), "Invalid master copy address provided"); 22 | masterCopy = _masterCopy; 23 | } 24 | 25 | /// @dev Fallback function forwards all transactions and returns all received return data. 26 | function () 27 | external 28 | payable 29 | { 30 | // solium-disable-next-line security/no-inline-assembly 31 | assembly { 32 | let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff) 33 | // 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s 34 | if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) { 35 | mstore(0, masterCopy) 36 | return(0, 0x20) 37 | } 38 | calldatacopy(0, 0, calldatasize()) 39 | let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0) 40 | returndatacopy(0, 0, returndatasize()) 41 | if eq(success, 0) { revert(0, returndatasize()) } 42 | return(0, returndatasize()) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /contracts/common/governance/Governable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {IGovernance} from "./IGovernance.sol"; 4 | 5 | contract Governable { 6 | IGovernance public governance; 7 | 8 | constructor(address _governance) public { 9 | governance = IGovernance(_governance); 10 | } 11 | 12 | modifier onlyGovernance() { 13 | _assertGovernance(); 14 | _; 15 | } 16 | 17 | function _assertGovernance() private view { 18 | require( 19 | msg.sender == address(governance), 20 | "Only governance contract is authorized" 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /contracts/common/governance/Governance.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ProxyStorage} from "../misc/ProxyStorage.sol"; 4 | import {IGovernance} from "./IGovernance.sol"; 5 | 6 | 7 | contract Governance is ProxyStorage, IGovernance { 8 | function update(address target, bytes memory data) public onlyOwner { 9 | (bool success, ) = target.call(data); /* bytes memory returnData */ 10 | require(success, "Update failed"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/common/governance/GovernanceProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Proxy} from "../misc/Proxy.sol"; 4 | 5 | contract GovernanceProxy is Proxy { 6 | constructor(address _proxyTo) public Proxy(_proxyTo) {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/common/governance/IGovernance.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | interface IGovernance { 4 | function update(address target, bytes calldata data) external; 5 | } 6 | -------------------------------------------------------------------------------- /contracts/common/lib/Common.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import "./BytesLib.sol"; 4 | 5 | library Common { 6 | function getV(bytes memory v, uint16 chainId) public pure returns (uint8) { 7 | if (chainId > 0) { 8 | return 9 | uint8( 10 | BytesLib.toUint(BytesLib.leftPad(v), 0) - (chainId * 2) - 8 11 | ); 12 | } else { 13 | return uint8(BytesLib.toUint(BytesLib.leftPad(v), 0)); 14 | } 15 | } 16 | 17 | //assemble the given address bytecode. If bytecode exists then the _addr is a contract. 18 | function isContract(address _addr) public view returns (bool) { 19 | uint256 length; 20 | assembly { 21 | //retrieve the size of the code on target address, this needs assembly 22 | length := extcodesize(_addr) 23 | } 24 | return (length > 0); 25 | } 26 | 27 | // convert bytes to uint8 28 | function toUint8(bytes memory _arg) public pure returns (uint8) { 29 | return uint8(_arg[0]); 30 | } 31 | 32 | function toUint16(bytes memory _arg) public pure returns (uint16) { 33 | return (uint16(uint8(_arg[0])) << 8) | uint16(uint8(_arg[1])); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /contracts/common/lib/Merkle.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | library Merkle { 4 | function checkMembership( 5 | bytes32 leaf, 6 | uint256 index, 7 | bytes32 rootHash, 8 | bytes memory proof 9 | ) internal pure returns (bool) { 10 | require(proof.length % 32 == 0, "Invalid proof length"); 11 | uint256 proofHeight = proof.length / 32; 12 | // Proof of size n means, height of the tree is n+1. 13 | // In a tree of height n+1, max #leafs possible is 2 ^ n 14 | require(index < 2 ** proofHeight, "Leaf index is too big"); 15 | 16 | bytes32 proofElement; 17 | bytes32 computedHash = leaf; 18 | for (uint256 i = 32; i <= proof.length; i += 32) { 19 | assembly { 20 | proofElement := mload(add(proof, i)) 21 | } 22 | 23 | if (index % 2 == 0) { 24 | computedHash = keccak256( 25 | abi.encodePacked(computedHash, proofElement) 26 | ); 27 | } else { 28 | computedHash = keccak256( 29 | abi.encodePacked(proofElement, computedHash) 30 | ); 31 | } 32 | 33 | index = index / 2; 34 | } 35 | return computedHash == rootHash; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /contracts/common/misc/ContractReceiver.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | /* 4 | * Contract that is working with ERC223 tokens 5 | */ 6 | 7 | /// @title ContractReceiver - Standard contract implementation for compatibility with ERC 223 tokens. 8 | contract ContractReceiver { 9 | /// @dev Function that is called when a user or another contract wants to transfer funds. 10 | /// @param _from Transaction initiator, analogue of msg.sender 11 | /// @param _value Number of tokens to transfer. 12 | /// @param _data Data containig a function signature and/or parameters 13 | function tokenFallback(address _from, uint256 _value, bytes memory _data) 14 | public; 15 | } 16 | -------------------------------------------------------------------------------- /contracts/common/misc/DelegateProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ERCProxy} from "./ERCProxy.sol"; 4 | import {DelegateProxyForwarder} from "./DelegateProxyForwarder.sol"; 5 | 6 | contract DelegateProxy is ERCProxy, DelegateProxyForwarder { 7 | function proxyType() external pure returns (uint256 proxyTypeId) { 8 | // Upgradeable proxy 9 | proxyTypeId = 2; 10 | } 11 | 12 | function implementation() external view returns (address); 13 | } 14 | -------------------------------------------------------------------------------- /contracts/common/misc/DelegateProxyForwarder.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | contract DelegateProxyForwarder { 4 | function delegatedFwd(address _dst, bytes memory _calldata) internal { 5 | // solium-disable-next-line security/no-inline-assembly 6 | assembly { 7 | let result := delegatecall( 8 | sub(gas, 10000), 9 | _dst, 10 | add(_calldata, 0x20), 11 | mload(_calldata), 12 | 0, 13 | 0 14 | ) 15 | let size := returndatasize 16 | 17 | let ptr := mload(0x40) 18 | returndatacopy(ptr, 0, size) 19 | 20 | // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas. 21 | // if the call returned error data, forward it 22 | switch result 23 | case 0 { 24 | revert(ptr, size) 25 | } 26 | default { 27 | return(ptr, size) 28 | } 29 | } 30 | } 31 | 32 | function isContract(address _target) internal view returns (bool) { 33 | if (_target == address(0)) { 34 | return false; 35 | } 36 | 37 | uint256 size; 38 | assembly { 39 | size := extcodesize(_target) 40 | } 41 | return size > 0; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /contracts/common/misc/DrainStakeManager.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import { StakeManagerStorage } from "../../staking/stakeManager/StakeManagerStorage.sol"; 4 | import { GovernanceLockable } from "../mixin/GovernanceLockable.sol"; 5 | import {IValidatorShare} from "../../staking/validatorShare/IValidatorShare.sol"; 6 | import {Initializable} from "../../common/mixin/Initializable.sol"; 7 | 8 | // Inheriting from Initializable as well to keep the storage layout same 9 | contract DrainStakeManager is StakeManagerStorage, Initializable { 10 | constructor() public GovernanceLockable(address(0x0)) {} 11 | 12 | function drain(address destination, uint amount) external onlyOwner { 13 | require(token.transfer(destination, amount), "Drain failed"); 14 | } 15 | 16 | function drainValidatorShares( 17 | uint256 validatorId, 18 | address _token, 19 | address payable destination, 20 | uint256 amount 21 | ) external onlyOwner { 22 | address contractAddr = validators[validatorId].contractAddress; 23 | require(contractAddr != address(0x0), "unknown validator or no delegation enabled"); 24 | IValidatorShare validatorShare = IValidatorShare(contractAddr); 25 | validatorShare.drain(_token, destination, amount); 26 | } 27 | 28 | // Overriding isOwner from Ownable.sol because owner() and transferOwnership() have been overridden by UpgradableProxy 29 | function isOwner() public view returns (bool) { 30 | address _owner; 31 | bytes32 position = keccak256("matic.network.proxy.owner"); 32 | assembly { 33 | _owner := sload(position) 34 | } 35 | return msg.sender == _owner; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /contracts/common/misc/Drainable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import { DepositManagerStorage } from "../../root/depositManager/DepositManagerStorage.sol"; 4 | import { GovernanceLockable } from "../mixin/GovernanceLockable.sol"; 5 | import { IERC20 } from "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; 6 | import { IERC721 } from "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol"; 7 | import { WETH } from "../tokens/WETH.sol"; 8 | 9 | 10 | contract Drainable is DepositManagerStorage { 11 | 12 | constructor() public GovernanceLockable(address(0x0)) {} 13 | 14 | function drainErc20( 15 | address[] calldata tokens, 16 | uint256[] calldata values, 17 | address destination 18 | ) external onlyGovernance { 19 | require((tokens.length == values.length), "invalid input"); 20 | for (uint256 i = 0; i < tokens.length; i++) { 21 | require ( 22 | IERC20(tokens[i]).transfer(destination, values[i]), "Transfer failed" 23 | ); 24 | } 25 | } 26 | 27 | function drainErc721( 28 | address[] calldata tokens, 29 | uint256[] calldata values, 30 | address destination 31 | ) external onlyGovernance { 32 | require((tokens.length == values.length), "invalid input"); 33 | for (uint256 i = 0; i < tokens.length; i ++) { 34 | IERC721(tokens[i]).transferFrom(address(this), destination, values[i]); 35 | } 36 | } 37 | 38 | function drainEther( 39 | uint256 amount, 40 | address payable destination 41 | ) external onlyGovernance { 42 | address wethToken = registry.getWethTokenAddress(); 43 | WETH t = WETH(wethToken); 44 | t.withdraw(amount, destination); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /contracts/common/misc/ERCProxy.sol: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identitifer: MIT 3 | */ 4 | 5 | pragma solidity ^0.5.2; 6 | 7 | // See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-897.md 8 | 9 | interface ERCProxy { 10 | function proxyType() external pure returns (uint256 proxyTypeId); 11 | function implementation() external view returns (address codeAddr); 12 | } 13 | -------------------------------------------------------------------------------- /contracts/common/misc/Proxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | import {DelegateProxy} from "./DelegateProxy.sol"; 3 | import {ProxyStorage} from "./ProxyStorage.sol"; 4 | 5 | 6 | contract Proxy is ProxyStorage, DelegateProxy { 7 | event ProxyUpdated(address indexed _new, address indexed _old); 8 | event OwnerUpdate(address _prevOwner, address _newOwner); 9 | 10 | constructor(address _proxyTo) public { 11 | updateImplementation(_proxyTo); 12 | } 13 | 14 | function() external payable { 15 | // require(currentContract != 0, "If app code has not been set yet, do not call"); 16 | // Todo: filter out some calls or handle in the end fallback 17 | delegatedFwd(proxyTo, msg.data); 18 | } 19 | 20 | function implementation() external view returns (address) { 21 | return proxyTo; 22 | } 23 | 24 | function updateImplementation(address _newProxyTo) public onlyOwner { 25 | require(_newProxyTo != address(0x0), "INVALID_PROXY_ADDRESS"); 26 | require(isContract(_newProxyTo), "DESTINATION_ADDRESS_IS_NOT_A_CONTRACT"); 27 | emit ProxyUpdated(_newProxyTo, proxyTo); 28 | proxyTo = _newProxyTo; 29 | } 30 | 31 | function isContract(address _target) internal view returns (bool) { 32 | if (_target == address(0)) { 33 | return false; 34 | } 35 | 36 | uint256 size; 37 | assembly { 38 | size := extcodesize(_target) 39 | } 40 | return size > 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /contracts/common/misc/ProxyStorage.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 3 | 4 | contract ProxyStorage is Ownable { 5 | address internal proxyTo; 6 | } 7 | -------------------------------------------------------------------------------- /contracts/common/mixin/ChainIdMixin.sol.template: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | contract ChainIdMixin { 4 | bytes constant public networkId = hex"{{ borChainIdHex }}"; 5 | uint256 constant public CHAINID = {{ borChainId }}; 6 | } 7 | -------------------------------------------------------------------------------- /contracts/common/mixin/GovernanceLockable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Governable} from "../governance/Governable.sol"; 4 | import {Lockable} from "./Lockable.sol"; 5 | 6 | contract GovernanceLockable is Lockable, Governable { 7 | constructor(address governance) public Governable(governance) {} 8 | 9 | function lock() public onlyGovernance { 10 | super.lock(); 11 | } 12 | 13 | function unlock() public onlyGovernance { 14 | super.unlock(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /contracts/common/mixin/Initializable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | contract Initializable { 4 | bool inited = false; 5 | 6 | modifier initializer() { 7 | require(!inited, "already inited"); 8 | inited = true; 9 | 10 | _; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/common/mixin/Lockable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | contract Lockable { 4 | bool public locked; 5 | 6 | modifier onlyWhenUnlocked() { 7 | _assertUnlocked(); 8 | _; 9 | } 10 | 11 | function _assertUnlocked() private view { 12 | require(!locked, "locked"); 13 | } 14 | 15 | function lock() public { 16 | locked = true; 17 | } 18 | 19 | function unlock() public { 20 | locked = false; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /contracts/common/mixin/OwnableLockable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | import { Lockable } from "./Lockable.sol"; 3 | import { Ownable } from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 4 | 5 | contract OwnableLockable is Lockable, Ownable { 6 | function lock() public onlyOwner { 7 | super.lock(); 8 | } 9 | 10 | function unlock() public onlyOwner { 11 | super.unlock(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/common/mixin/RootChainable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 4 | 5 | /** 6 | * @title RootChainable 7 | */ 8 | contract RootChainable is Ownable { 9 | address public rootChain; 10 | 11 | // Rootchain changed 12 | event RootChainChanged( 13 | address indexed previousRootChain, 14 | address indexed newRootChain 15 | ); 16 | 17 | // only root chain 18 | modifier onlyRootChain() { 19 | require(msg.sender == rootChain); 20 | _; 21 | } 22 | 23 | /** 24 | * @dev Allows the current owner to change root chain address. 25 | * @param newRootChain The address to new rootchain. 26 | */ 27 | function changeRootChain(address newRootChain) public onlyOwner { 28 | require(newRootChain != address(0)); 29 | emit RootChainChanged(rootChain, newRootChain); 30 | rootChain = newRootChain; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /contracts/common/tokens/ERC20NonTradable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ERC20} from "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; 4 | 5 | contract ERC20NonTradable is ERC20 { 6 | function _approve( 7 | address owner, 8 | address spender, 9 | uint256 value 10 | ) internal { 11 | revert("disabled"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/common/tokens/ERC721PlasmaMintable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ERC721Mintable} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol"; 4 | import {ERC721MetadataMintable} from "openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol"; 5 | import {ERC721Metadata} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol"; 6 | 7 | contract ERC721PlasmaMintable is ERC721Mintable, ERC721MetadataMintable { 8 | constructor(string memory name, string memory symbol) 9 | public 10 | ERC721Metadata(name, symbol) 11 | {} 12 | 13 | /** 14 | * @dev Returns whether the specified token exists 15 | * @param tokenId uint256 ID of the token to query the existence of 16 | * @return bool whether the token exists 17 | */ 18 | function exists(uint256 tokenId) public view returns (bool) { 19 | return _exists(tokenId); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /contracts/common/tokens/MaticWETH.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {WETH} from "./WETH.sol"; 4 | 5 | 6 | contract MaticWETH is WETH { 7 | string public name = "Wrapped Ether"; 8 | string public symbol = "WETH"; 9 | uint8 public decimals = 18; 10 | 11 | function deposit() public payable { 12 | _mint(msg.sender, msg.value); 13 | emit Deposit(msg.sender, msg.value); 14 | } 15 | 16 | function withdraw(uint256 wad) public { 17 | require(balanceOf(msg.sender) >= wad); 18 | _burn(msg.sender, wad); 19 | msg.sender.transfer(wad); 20 | emit Withdrawal(msg.sender, wad); 21 | } 22 | 23 | function withdraw(uint256 wad, address user) public { 24 | require(balanceOf(msg.sender) >= wad); 25 | _burn(msg.sender, wad); 26 | address(uint160(user)).transfer(wad); 27 | emit Withdrawal(user, wad); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /contracts/common/tokens/RootERC721.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ERC721Full} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol"; 4 | 5 | contract RootERC721 is ERC721Full { 6 | constructor(string memory name, string memory symbol) 7 | public 8 | ERC721Full(name, symbol) 9 | {} 10 | 11 | function mint(uint256 tokenId) public { 12 | _mint(msg.sender, tokenId); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/common/tokens/TestToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import "openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol"; 4 | 5 | contract TestToken is ERC20Mintable { 6 | // detailed ERC20 7 | string public name; 8 | string public symbol; 9 | uint8 public decimals = 18; 10 | 11 | constructor(string memory _name, string memory _symbol) public { 12 | name = _name; 13 | symbol = _symbol; 14 | 15 | uint256 value = 10**10 * (10**18); 16 | mint(msg.sender, value); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /contracts/common/tokens/WETH.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; 4 | 5 | contract WETH is ERC20 { 6 | event Deposit(address indexed dst, uint256 wad); 7 | event Withdrawal(address indexed src, uint256 wad); 8 | 9 | function deposit() public payable; 10 | 11 | function withdraw(uint256 wad) public; 12 | 13 | function withdraw(uint256 wad, address user) public; 14 | } 15 | -------------------------------------------------------------------------------- /contracts/root/IRootChain.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | 4 | interface IRootChain { 5 | function slash() external; 6 | 7 | function submitHeaderBlock(bytes calldata data, bytes calldata sigs) 8 | external; 9 | 10 | function submitCheckpoint(bytes calldata data, uint[3][] calldata sigs) 11 | external; 12 | 13 | function getLastChildBlock() external view returns (uint256); 14 | 15 | function currentHeaderBlock() external view returns (uint256); 16 | } 17 | -------------------------------------------------------------------------------- /contracts/root/RootChainProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {RootChainStorage} from "./RootChainStorage.sol"; 4 | import {Proxy} from "../common/misc/Proxy.sol"; 5 | import {Registry} from "../common/Registry.sol"; 6 | 7 | contract RootChainProxy is Proxy, RootChainStorage { 8 | constructor(address _proxyTo, address _registry, string memory _heimdallId) 9 | public 10 | Proxy(_proxyTo) 11 | { 12 | registry = Registry(_registry); 13 | heimdallId = keccak256(abi.encodePacked(_heimdallId)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /contracts/root/RootChainStorage.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Registry} from "../common/Registry.sol"; 4 | import {ProxyStorage} from "../common/misc/ProxyStorage.sol"; 5 | import {ChainIdMixin} from "../common/mixin/ChainIdMixin.sol"; 6 | 7 | 8 | contract RootChainHeader { 9 | event NewHeaderBlock( 10 | address indexed proposer, 11 | uint256 indexed headerBlockId, 12 | uint256 indexed reward, 13 | uint256 start, 14 | uint256 end, 15 | bytes32 root 16 | ); 17 | // housekeeping event 18 | event ResetHeaderBlock(address indexed proposer, uint256 indexed headerBlockId); 19 | struct HeaderBlock { 20 | bytes32 root; 21 | uint256 start; 22 | uint256 end; 23 | uint256 createdAt; 24 | address proposer; 25 | } 26 | } 27 | 28 | 29 | contract RootChainStorage is ProxyStorage, RootChainHeader, ChainIdMixin { 30 | bytes32 public heimdallId; 31 | uint8 public constant VOTE_TYPE = 2; 32 | 33 | uint16 internal constant MAX_DEPOSITS = 10000; 34 | uint256 public _nextHeaderBlock = MAX_DEPOSITS; 35 | uint256 internal _blockDepositId = 1; 36 | mapping(uint256 => HeaderBlock) public headerBlocks; 37 | Registry internal registry; 38 | } 39 | -------------------------------------------------------------------------------- /contracts/root/depositManager/DepositManagerProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {DepositManagerStorage} from "./DepositManagerStorage.sol"; 4 | import {Proxy} from "../../common/misc/Proxy.sol"; 5 | import {Registry} from "../../common/Registry.sol"; 6 | import {RootChain} from "../RootChain.sol"; 7 | import {GovernanceLockable} from "../../common/mixin/GovernanceLockable.sol"; 8 | 9 | contract DepositManagerProxy is Proxy, DepositManagerStorage { 10 | constructor( 11 | address _proxyTo, 12 | address _registry, 13 | address _rootChain, 14 | address _governance 15 | ) public Proxy(_proxyTo) GovernanceLockable(_governance) { 16 | registry = Registry(_registry); 17 | rootChain = RootChain(_rootChain); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /contracts/root/depositManager/DepositManagerStorage.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Registry} from "../../common/Registry.sol"; 4 | import {RootChain} from "../RootChain.sol"; 5 | import {ProxyStorage} from "../../common/misc/ProxyStorage.sol"; 6 | import {StateSender} from "../stateSyncer/StateSender.sol"; 7 | import {GovernanceLockable} from "../../common/mixin/GovernanceLockable.sol"; 8 | 9 | 10 | contract DepositManagerHeader { 11 | event NewDepositBlock(address indexed owner, address indexed token, uint256 amountOrNFTId, uint256 depositBlockId); 12 | event MaxErc20DepositUpdate(uint256 indexed oldLimit, uint256 indexed newLimit); 13 | 14 | struct DepositBlock { 15 | bytes32 depositHash; 16 | uint256 createdAt; 17 | } 18 | } 19 | 20 | 21 | contract DepositManagerStorage is ProxyStorage, GovernanceLockable, DepositManagerHeader { 22 | Registry public registry; 23 | RootChain public rootChain; 24 | StateSender public stateSender; 25 | 26 | mapping(uint256 => DepositBlock) public deposits; 27 | 28 | address public childChain; 29 | uint256 public maxErc20Deposit = 100 * (10**18); 30 | } 31 | -------------------------------------------------------------------------------- /contracts/root/depositManager/IDepositManager.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | interface IDepositManager { 4 | function depositEther() external payable; 5 | function transferAssets( 6 | address _token, 7 | address _user, 8 | uint256 _amountOrNFTId 9 | ) external; 10 | function depositERC20(address _token, uint256 _amount) external; 11 | function depositERC721(address _token, uint256 _tokenId) external; 12 | } 13 | -------------------------------------------------------------------------------- /contracts/root/stateSyncer/StateSender.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 4 | import {SafeMath} from "openzeppelin-solidity/contracts/math/SafeMath.sol"; 5 | 6 | contract StateSender is Ownable { 7 | using SafeMath for uint256; 8 | 9 | uint256 public counter; 10 | mapping(address => address) public registrations; 11 | 12 | event NewRegistration( 13 | address indexed user, 14 | address indexed sender, 15 | address indexed receiver 16 | ); 17 | event RegistrationUpdated( 18 | address indexed user, 19 | address indexed sender, 20 | address indexed receiver 21 | ); 22 | event StateSynced( 23 | uint256 indexed id, 24 | address indexed contractAddress, 25 | bytes data 26 | ); 27 | 28 | modifier onlyRegistered(address receiver) { 29 | require(registrations[receiver] == msg.sender, "Invalid sender"); 30 | _; 31 | } 32 | 33 | function syncState(address receiver, bytes calldata data) 34 | external 35 | onlyRegistered(receiver) 36 | { 37 | counter = counter.add(1); 38 | emit StateSynced(counter, receiver, data); 39 | } 40 | 41 | // register new contract for state sync 42 | function register(address sender, address receiver) public { 43 | require( 44 | isOwner() || registrations[receiver] == msg.sender, 45 | "StateSender.register: Not authorized to register" 46 | ); 47 | registrations[receiver] = sender; 48 | if (registrations[receiver] == address(0)) { 49 | emit NewRegistration(msg.sender, sender, receiver); 50 | } else { 51 | emit RegistrationUpdated(msg.sender, sender, receiver); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /contracts/root/withdrawManager/ExitNFT.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ERC721} from "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol"; 4 | import {Registry} from "../../common/Registry.sol"; 5 | 6 | contract ExitNFT is ERC721 { 7 | Registry internal registry; 8 | 9 | modifier onlyWithdrawManager() { 10 | require( 11 | msg.sender == registry.getWithdrawManagerAddress(), 12 | "UNAUTHORIZED_WITHDRAW_MANAGER_ONLY" 13 | ); 14 | _; 15 | } 16 | 17 | constructor(address _registry) public { 18 | registry = Registry(_registry); 19 | } 20 | 21 | function mint(address _owner, uint256 _tokenId) 22 | external 23 | onlyWithdrawManager 24 | { 25 | _mint(_owner, _tokenId); 26 | } 27 | 28 | function burn(uint256 _tokenId) external onlyWithdrawManager { 29 | _burn(_tokenId); 30 | } 31 | 32 | function exists(uint256 tokenId) public view returns (bool) { 33 | return _exists(tokenId); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /contracts/root/withdrawManager/IWithdrawManager.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | contract IWithdrawManager { 4 | function createExitQueue(address token) external; 5 | 6 | function verifyInclusion( 7 | bytes calldata data, 8 | uint8 offset, 9 | bool verifyTxInclusion 10 | ) external view returns (uint256 age); 11 | 12 | function addExitToQueue( 13 | address exitor, 14 | address childToken, 15 | address rootToken, 16 | uint256 exitAmountOrTokenId, 17 | bytes32 txHash, 18 | bool isRegularExit, 19 | uint256 priority 20 | ) external; 21 | 22 | function addInput( 23 | uint256 exitId, 24 | uint256 age, 25 | address utxoOwner, 26 | address token 27 | ) external; 28 | 29 | function challengeExit( 30 | uint256 exitId, 31 | uint256 inputId, 32 | bytes calldata challengeData, 33 | address adjudicatorPredicate 34 | ) external; 35 | } 36 | -------------------------------------------------------------------------------- /contracts/root/withdrawManager/WithdrawManagerProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Registry} from "../../common/Registry.sol"; 4 | import {Proxy} from "../../common/misc/Proxy.sol"; 5 | import {WithdrawManagerStorage} from "./WithdrawManagerStorage.sol"; 6 | import {RootChain} from "../RootChain.sol"; 7 | import {ExitNFT} from "./ExitNFT.sol"; 8 | 9 | contract WithdrawManagerProxy is Proxy, WithdrawManagerStorage { 10 | constructor( 11 | address _proxyTo, 12 | address _registry, 13 | address _rootChain, 14 | address _exitNft 15 | ) public Proxy(_proxyTo) { 16 | registry = Registry(_registry); 17 | rootChain = RootChain(_rootChain); 18 | exitNft = ExitNFT(_exitNft); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /contracts/staking/EventsHubProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.5.17; 2 | 3 | import {UpgradableProxy} from "../common/misc/UpgradableProxy.sol"; 4 | 5 | contract EventsHubProxy is UpgradableProxy { 6 | constructor(address _proxyTo) public UpgradableProxy(_proxyTo) {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/staking/slashing/ISlashingManager.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | import {StakingInfo} from "../StakingInfo.sol"; 3 | import {Registry} from "../../common/Registry.sol"; 4 | 5 | 6 | contract ISlashingManager { 7 | bytes32 public heimdallId; 8 | uint8 public constant VOTE_TYPE = 2; 9 | uint256 public reportRate = 5; // dummy default value 10 | uint256 public proposerRate = 50; // dummy default value 11 | uint256 public jailCheckpoints = 5; // checkpoints 12 | uint256 public slashingNonce; 13 | Registry public registry; 14 | StakingInfo public logger; 15 | } 16 | -------------------------------------------------------------------------------- /contracts/staking/stakeManager/StakeManagerProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {UpgradableProxy} from "../../common/misc/UpgradableProxy.sol"; 4 | 5 | contract StakeManagerProxy is UpgradableProxy { 6 | constructor(address _proxyTo) public UpgradableProxy(_proxyTo) {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/staking/stakeManager/StakeManagerStorageExtension.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.5.17; 2 | 3 | contract StakeManagerStorageExtension { 4 | address public eventsHub; 5 | uint256 public rewardPerStake; 6 | address public extensionCode; 7 | address[] public signers; 8 | 9 | uint256 constant CHK_REWARD_PRECISION = 100; 10 | uint256 public prevBlockInterval; 11 | // how much less reward per skipped checkpoint, 0 - 100% 12 | uint256 public rewardDecreasePerCheckpoint; 13 | // how many checkpoints to reward 14 | uint256 public maxRewardedCheckpoints; 15 | // increase / decrease value for faster or slower checkpoints, 0 - 100% 16 | uint256 public checkpointRewardDelta; 17 | } 18 | -------------------------------------------------------------------------------- /contracts/staking/stakeManager/StakingNFT.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol"; 4 | import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; 5 | 6 | 7 | contract StakingNFT is ERC721Full, Ownable { 8 | constructor(string memory name, string memory symbol) 9 | public 10 | ERC721Full(name, symbol) 11 | { 12 | // solhint-disable-previous-line no-empty-blocks 13 | } 14 | 15 | function mint(address to, uint256 tokenId) public onlyOwner { 16 | require( 17 | balanceOf(to) == 0, 18 | "Validators MUST NOT own multiple stake position" 19 | ); 20 | _mint(to, tokenId); 21 | } 22 | 23 | function burn(uint256 tokenId) public onlyOwner { 24 | _burn(tokenId); 25 | } 26 | 27 | function _transferFrom(address from, address to, uint256 tokenId) internal { 28 | require( 29 | balanceOf(to) == 0, 30 | "Validators MUST NOT own multiple stake position" 31 | ); 32 | super._transferFrom(from, to, tokenId); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /contracts/staking/validatorShare/IValidatorShare.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.5.17; 2 | 3 | // note this contract interface is only for stakeManager use 4 | contract IValidatorShare { 5 | function withdrawRewards() public; 6 | 7 | function unstakeClaimTokens() public; 8 | 9 | function getLiquidRewards(address user) public view returns (uint256); 10 | 11 | function owner() public view returns (address); 12 | 13 | function restake() public returns(uint256, uint256); 14 | 15 | function unlock() external; 16 | 17 | function lock() external; 18 | 19 | function drain( 20 | address token, 21 | address payable destination, 22 | uint256 amount 23 | ) external; 24 | 25 | function slash(uint256 valPow, uint256 delegatedAmount, uint256 totalAmountToSlash) external returns (uint256); 26 | 27 | function updateDelegation(bool delegation) external; 28 | 29 | function migrateOut(address user, uint256 amount) external; 30 | 31 | function migrateIn(address user, uint256 amount) external; 32 | } 33 | -------------------------------------------------------------------------------- /contracts/staking/validatorShare/ValidatorShareFactory.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {ValidatorShareProxy} from "./ValidatorShareProxy.sol"; 4 | import {ValidatorShare} from "./ValidatorShare.sol"; 5 | 6 | contract ValidatorShareFactory { 7 | /** 8 | - factory to create new validatorShare contracts 9 | */ 10 | function create(uint256 validatorId, address loggerAddress, address registry) public returns (address) { 11 | ValidatorShareProxy proxy = new ValidatorShareProxy(registry); 12 | 13 | proxy.transferOwnership(msg.sender); 14 | 15 | address proxyAddr = address(proxy); 16 | (bool success, bytes memory data) = proxyAddr.call.gas(gasleft())( 17 | abi.encodeWithSelector( 18 | ValidatorShare(proxyAddr).initialize.selector, 19 | validatorId, 20 | loggerAddress, 21 | msg.sender 22 | ) 23 | ); 24 | require(success, string(data)); 25 | 26 | return proxyAddr; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /contracts/staking/validatorShare/ValidatorShareProxy.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {UpgradableProxy} from "../../common/misc/UpgradableProxy.sol"; 4 | import {Registry} from "../../common/Registry.sol"; 5 | 6 | contract ValidatorShareProxy is UpgradableProxy { 7 | constructor(address _registry) public UpgradableProxy(_registry) {} 8 | 9 | function loadImplementation() internal view returns (address) { 10 | return Registry(super.loadImplementation()).getValidatorShareAddress(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/test/ContractActor.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {IERC20} from "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; 4 | import "../root/depositManager/IDepositManager.sol"; 5 | import "../root/withdrawManager/WithdrawManager.sol"; 6 | 7 | contract ContractWithFallback { 8 | function deposit(address depositManager, address token, uint256 amount) public { 9 | IERC20(token).approve(depositManager, amount); 10 | IDepositManager(depositManager).depositERC20(token, amount); 11 | } 12 | 13 | function startExitWithDepositedTokens( 14 | address payable withdrawManager, 15 | uint256 depositId, 16 | address token, 17 | uint256 amountOrToken) public payable { 18 | WithdrawManager(withdrawManager).startExitWithDepositedTokens.value(10**17)(depositId, token, amountOrToken); 19 | } 20 | 21 | function() external payable {} 22 | } 23 | 24 | contract ContractWithoutFallback { 25 | function deposit(address depositManager, address token, uint256 amount) public { 26 | IERC20(token).approve(depositManager, amount); 27 | IDepositManager(depositManager).depositERC20(token, amount); 28 | } 29 | 30 | function startExitWithDepositedTokens( 31 | address payable withdrawManager, 32 | uint256 depositId, 33 | address token, 34 | uint256 amountOrToken) public payable { 35 | WithdrawManager(withdrawManager).startExitWithDepositedTokens.value(10**17)(depositId, token, amountOrToken); 36 | } 37 | } 38 | 39 | contract ContractWitRevertingFallback { 40 | function deposit(address depositManager, address token, uint256 amount) public { 41 | IERC20(token).approve(depositManager, amount); 42 | IDepositManager(depositManager).depositERC20(token, amount); 43 | } 44 | 45 | function startExitWithDepositedTokens( 46 | address payable withdrawManager, 47 | uint256 depositId, 48 | address token, 49 | uint256 amountOrToken) public payable { 50 | WithdrawManager(withdrawManager).startExitWithDepositedTokens.value(10**17)(depositId, token, amountOrToken); 51 | } 52 | 53 | function() external payable { 54 | revert("not implemented"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /contracts/test/GovernanceLockableTest.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import { GovernanceLockable } from "../common/mixin/GovernanceLockable.sol"; 4 | 5 | contract GovernanceLockableTest is GovernanceLockable { 6 | constructor(address governance) public GovernanceLockable(governance) {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/test/PolygonMigrationTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.5.2; 3 | 4 | import {IERC20} from "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; 5 | import {SafeERC20} from "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; 6 | 7 | // this impl was shortened for testing purposes 8 | // full impl at https://github.com/0xPolygon/indicia/blob/main/src/PolygonMigration.sol 9 | contract PolygonMigrationTest { 10 | using SafeERC20 for IERC20; 11 | 12 | event Migrated(address indexed account, uint256 amount); 13 | 14 | IERC20 public polygon; 15 | IERC20 public matic; 16 | 17 | function setTokenAddresses(address matic_, address polygon_) external { 18 | if (matic_ == address(0)) revert(); 19 | matic = IERC20(matic_); 20 | 21 | if (polygon_ == address(0)) revert(); 22 | polygon = IERC20(polygon_); 23 | } 24 | 25 | /// @notice This function allows for migrating MATIC tokens to POL tokens 26 | /// @dev The function does not do any validation since the migration is a one-way process 27 | /// @param amount Amount of MATIC to migrate 28 | function migrate(uint256 amount) external { 29 | emit Migrated(msg.sender, amount); 30 | 31 | matic.safeTransferFrom(msg.sender, address(this), amount); 32 | polygon.safeTransfer(msg.sender, amount); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /contracts/test/Proxy/ProxyTestImpl.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Initializable} from "../../common/mixin/Initializable.sol"; 4 | 5 | contract ProxyTestImpl is Initializable { 6 | uint256 public a = 1; 7 | uint256 public b = 2; 8 | uint256 public ctorInit; 9 | 10 | constructor() public { 11 | ctorInit = 3; 12 | } 13 | 14 | function init() public initializer { 15 | a = 1; 16 | b = 2; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /contracts/test/Proxy/ProxyTestImplStorageLayoutChange.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {Initializable} from "../../common/mixin/Initializable.sol"; 4 | 5 | contract ProxyTestImplStorageLayoutChange is Initializable { 6 | uint256 public b; 7 | uint256 public a; 8 | } 9 | -------------------------------------------------------------------------------- /contracts/test/StakeManagerTest.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import {StakeManager} from "../staking/stakeManager/StakeManager.sol"; 4 | 5 | 6 | contract StakeManagerTest is StakeManager { 7 | function checkSignatures( 8 | uint256 blockInterval, 9 | bytes32 voteHash, 10 | bytes32 stateRoot, 11 | address proposer, 12 | uint[3][] calldata sigs 13 | ) external onlyRootChain returns (uint256) { 14 | return CHECKPOINT_REWARD; // for dummy tests return full reward 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /contracts/test/StakeManagerTestable.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | 3 | import { StakeManager } from "../staking/stakeManager/StakeManager.sol"; 4 | import { IValidatorShare } from "../staking/validatorShare/IValidatorShare.sol"; 5 | 6 | contract StakeManagerTestable is StakeManager { 7 | function advanceEpoch(uint256 delta) public { 8 | for (uint256 i = 0; i < delta; ++i) { 9 | _finalizeCommit(); 10 | } 11 | } 12 | 13 | function testLockShareContract(uint256 validatorId, bool lock) public { 14 | if (lock) { 15 | IValidatorShare(validators[validatorId].contractAddress).lock(); 16 | } else { 17 | IValidatorShare(validators[validatorId].contractAddress).unlock(); 18 | } 19 | } 20 | 21 | function forceFinalizeCommit() public { 22 | _finalizeCommit(); 23 | } 24 | 25 | function resetSignerUsed(address signer) public { 26 | signerToValidator[signer] = 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /contracts/test/TestMaticChildERC20.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.11; 2 | 3 | import {MRC20} from "../child/MRC20.sol"; 4 | 5 | contract TestMRC20 is MRC20 { 6 | function() external payable {} 7 | } 8 | -------------------------------------------------------------------------------- /contracts/test/ValidatorShareTest.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.5.2; 2 | import {ValidatorShare} from "../staking/validatorShare/ValidatorShare.sol"; 3 | 4 | contract ValidatorShareTest is ValidatorShare { 5 | function amountStaked(address user) public view returns(uint256) { 6 | (uint256 totalStaked, ) = getTotalStake(user); 7 | return totalStaked; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/autogen/.gitignore: -------------------------------------------------------------------------------- 1 | book/ -------------------------------------------------------------------------------- /docs/autogen/book.css: -------------------------------------------------------------------------------- 1 | table { 2 | margin: 0 auto; 3 | border-collapse: collapse; 4 | width: 100%; 5 | } 6 | 7 | table td:first-child { 8 | width: 15%; 9 | } 10 | 11 | table td:nth-child(2) { 12 | width: 25%; 13 | } -------------------------------------------------------------------------------- /docs/autogen/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | src = "src" 3 | title = "" 4 | 5 | [output.html] 6 | no-section-label = true 7 | additional-js = ["solidity.min.js"] 8 | additional-css = ["book.css"] 9 | git-repository-url = "https://github.com/maticnetwork/contracts" 10 | 11 | [output.html.fold] 12 | enable = true 13 | -------------------------------------------------------------------------------- /docs/autogen/src/README.md: -------------------------------------------------------------------------------- 1 | # Matic contracts 2 | 3 | ![Build Status](https://github.com/maticnetwork/contracts/workflows/CI/badge.svg) 4 | 5 | Ethereum smart contracts that power the [Matic Network](https://matic.network). 6 | 7 | ### Install dependencies with 8 | 9 | ``` 10 | npm install 11 | ``` 12 | 13 | ### Setup 14 | 15 | ``` 16 | pre-commit install 17 | ``` 18 | 19 | ### Compile 20 | 21 | ``` 22 | npm run template:process -- --bor-chain-id 15001 23 | ``` 24 | 25 | bor-chain-id should be: 26 | **local: 15001** 27 | Mainnet = 137 28 | TestnetV4 (Mumbai) = 80001 29 | 30 | ### Main chain and side chain 31 | 32 | - Main chain 33 | 34 | All tests are run against a fork of mainnet using Hardhat's forking functionality. No need to run any local chain! 35 | 36 | - Start Matic side chain. Requires docker. 37 | 38 | ``` 39 | npm run bor:simulate 40 | ``` 41 | 42 | - Stop with 43 | 44 | ``` 45 | npm run bor:stop 46 | ``` 47 | 48 | - If you want a clean chain, this also deletes your /data folder containing the chain state. 49 | 50 | ``` 51 | npm run bor:clean 52 | ``` 53 | 54 | ### Run tests 55 | 56 | Run Hardhat test 57 | 58 | ``` 59 | npm test:hardhat 60 | ``` 61 | 62 | Run Foundry test 63 | 64 | ``` 65 | npm test:foundry 66 | ``` 67 | 68 | ### Coverage 69 | 70 | Run coverage with 71 | 72 | ``` 73 | npm run coverage 74 | ``` 75 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/Migrations.sol/contract.Migrations.md: -------------------------------------------------------------------------------- 1 | # Migrations 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/Migrations.sol) 3 | 4 | 5 | ## State Variables 6 | ### owner 7 | 8 | ```solidity 9 | address public owner; 10 | ``` 11 | 12 | 13 | ### last_completed_migration 14 | 15 | ```solidity 16 | uint256 public last_completed_migration; 17 | ``` 18 | 19 | 20 | ## Functions 21 | ### restricted 22 | 23 | 24 | ```solidity 25 | modifier restricted(); 26 | ``` 27 | 28 | ### constructor 29 | 30 | 31 | ```solidity 32 | constructor() public; 33 | ``` 34 | 35 | ### setCompleted 36 | 37 | 38 | ```solidity 39 | function setCompleted(uint256 completed) public restricted; 40 | ``` 41 | 42 | ### upgrade 43 | 44 | 45 | ```solidity 46 | function upgrade(address new_address) public restricted; 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [child](/contracts/child) 5 | - [common](/contracts/common) 6 | - [root](/contracts/root) 7 | - [staking](/contracts/staking) 8 | - [test](/contracts/test) 9 | - [Migrations](Migrations.sol/contract.Migrations.md) 10 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/BaseERC20.sol/contract.BaseERC20.md: -------------------------------------------------------------------------------- 1 | # BaseERC20 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/BaseERC20.sol) 3 | 4 | **Inherits:** 5 | [ChildToken](/contracts/child/ChildToken.sol/contract.ChildToken.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public; 14 | ``` 15 | 16 | ### transferWithSig 17 | 18 | 19 | ```solidity 20 | function transferWithSig(bytes calldata sig, uint256 amount, bytes32 data, uint256 expiration, address to) external returns (address from); 21 | ``` 22 | 23 | ### balanceOf 24 | 25 | 26 | ```solidity 27 | function balanceOf(address account) external view returns (uint256); 28 | ``` 29 | 30 | ### _transfer 31 | 32 | 33 | ```solidity 34 | function _transfer(address sender, address recipient, uint256 amount) internal; 35 | ``` 36 | 37 | ### _transferFrom 38 | 39 | 40 | ```solidity 41 | function _transferFrom(address from, address to, uint256 value) internal returns (bool); 42 | ``` 43 | **Parameters** 44 | 45 | |Name|Type|Description| 46 | |----|----|-----------| 47 | |`from`|`address`|Address from where tokens are withdrawn.| 48 | |`to`|`address`|Address to where tokens are sent.| 49 | |`value`|`uint256`|Number of tokens to transfer.| 50 | 51 | **Returns** 52 | 53 | |Name|Type|Description| 54 | |----|----|-----------| 55 | |``|`bool`|Returns success of function call.| 56 | 57 | 58 | ## Events 59 | ### Deposit 60 | 61 | ```solidity 62 | event Deposit(address indexed token, address indexed from, uint256 amount, uint256 input1, uint256 output1); 63 | ``` 64 | 65 | ### Withdraw 66 | 67 | ```solidity 68 | event Withdraw(address indexed token, address indexed from, uint256 amount, uint256 input1, uint256 output1); 69 | ``` 70 | 71 | ### LogTransfer 72 | 73 | ```solidity 74 | event LogTransfer( 75 | address indexed token, address indexed from, address indexed to, uint256 amount, uint256 input1, uint256 input2, uint256 output1, uint256 output2 76 | ); 77 | ``` 78 | 79 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/BaseERC20NoSig.sol/contract.BaseERC20NoSig.md: -------------------------------------------------------------------------------- 1 | # BaseERC20NoSig 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/BaseERC20NoSig.sol) 3 | 4 | **Inherits:** 5 | [ChildToken](/contracts/child/ChildToken.sol/contract.ChildToken.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public; 14 | ``` 15 | 16 | ### transferWithSig 17 | 18 | 19 | ```solidity 20 | function transferWithSig(bytes calldata sig, uint256 amount, bytes32 data, uint256 expiration, address to) external returns (address from); 21 | ``` 22 | 23 | ### balanceOf 24 | 25 | 26 | ```solidity 27 | function balanceOf(address account) external view returns (uint256); 28 | ``` 29 | 30 | ### _transfer 31 | 32 | 33 | ```solidity 34 | function _transfer(address sender, address recipient, uint256 amount) internal; 35 | ``` 36 | 37 | ### _transferFrom 38 | 39 | 40 | ```solidity 41 | function _transferFrom(address from, address to, uint256 value) internal returns (bool); 42 | ``` 43 | **Parameters** 44 | 45 | |Name|Type|Description| 46 | |----|----|-----------| 47 | |`from`|`address`|Address from where tokens are withdrawn.| 48 | |`to`|`address`|Address to where tokens are sent.| 49 | |`value`|`uint256`|Number of tokens to transfer.| 50 | 51 | **Returns** 52 | 53 | |Name|Type|Description| 54 | |----|----|-----------| 55 | |``|`bool`|Returns success of function call.| 56 | 57 | 58 | ## Events 59 | ### Deposit 60 | 61 | ```solidity 62 | event Deposit(address indexed token, address indexed from, uint256 amount, uint256 input1, uint256 output1); 63 | ``` 64 | 65 | ### Withdraw 66 | 67 | ```solidity 68 | event Withdraw(address indexed token, address indexed from, uint256 amount, uint256 input1, uint256 output1); 69 | ``` 70 | 71 | ### LogTransfer 72 | 73 | ```solidity 74 | event LogTransfer( 75 | address indexed token, address indexed from, address indexed to, uint256 amount, uint256 input1, uint256 input2, uint256 output1, uint256 output2 76 | ); 77 | ``` 78 | 79 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/ChildERC721Mintable.sol/contract.ChildERC721Mintable.md: -------------------------------------------------------------------------------- 1 | # ChildERC721Mintable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/ChildERC721Mintable.sol) 3 | 4 | **Inherits:** 5 | [ChildERC721](/contracts/child/ChildERC721.sol/contract.ChildERC721.md), ERC721Mintable, ERC721MetadataMintable 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address rootToken, string memory name, string memory symbol) public ChildERC721(msg.sender, rootToken, name, symbol); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/ChildToken.sol/contract.ChildToken.md: -------------------------------------------------------------------------------- 1 | # ChildToken 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/ChildToken.sol) 3 | 4 | **Inherits:** 5 | Ownable, [LibTokenTransferOrder](/contracts/child/misc/LibTokenTransferOrder.sol/contract.LibTokenTransferOrder.md) 6 | 7 | 8 | ## State Variables 9 | ### token 10 | 11 | ```solidity 12 | address public token; 13 | ``` 14 | 15 | 16 | ### childChain 17 | 18 | ```solidity 19 | address public childChain; 20 | ``` 21 | 22 | 23 | ### parent 24 | 25 | ```solidity 26 | address public parent; 27 | ``` 28 | 29 | 30 | ### disabledHashes 31 | 32 | ```solidity 33 | mapping(bytes32 => bool) public disabledHashes; 34 | ``` 35 | 36 | 37 | ## Functions 38 | ### onlyChildChain 39 | 40 | 41 | ```solidity 42 | modifier onlyChildChain(); 43 | ``` 44 | 45 | ### deposit 46 | 47 | 48 | ```solidity 49 | function deposit(address user, uint256 amountOrTokenId) public; 50 | ``` 51 | 52 | ### withdraw 53 | 54 | 55 | ```solidity 56 | function withdraw(uint256 amountOrTokenId) public payable; 57 | ``` 58 | 59 | ### ecrecovery 60 | 61 | 62 | ```solidity 63 | function ecrecovery(bytes32 hash, bytes memory sig) public pure returns (address result); 64 | ``` 65 | 66 | ### changeChildChain 67 | 68 | 69 | ```solidity 70 | function changeChildChain(address newAddress) public onlyOwner; 71 | ``` 72 | 73 | ### setParent 74 | 75 | 76 | ```solidity 77 | function setParent(address newAddress) public onlyOwner; 78 | ``` 79 | 80 | ## Events 81 | ### LogFeeTransfer 82 | 83 | ```solidity 84 | event LogFeeTransfer( 85 | address indexed token, address indexed from, address indexed to, uint256 amount, uint256 input1, uint256 input2, uint256 output1, uint256 output2 86 | ); 87 | ``` 88 | 89 | ### ChildChainChanged 90 | 91 | ```solidity 92 | event ChildChainChanged(address indexed previousAddress, address indexed newAddress); 93 | ``` 94 | 95 | ### ParentChanged 96 | 97 | ```solidity 98 | event ParentChanged(address indexed previousAddress, address indexed newAddress); 99 | ``` 100 | 101 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/ERC20Detailed.sol/contract.ERC20Detailed.md: -------------------------------------------------------------------------------- 1 | # ERC20Detailed 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/ERC20Detailed.sol) 3 | 4 | *The decimals are only for visualization purposes. 5 | All the operations are done using the smallest and indivisible token unit, 6 | just as on Ethereum all the operations are done in wei.* 7 | 8 | 9 | ## State Variables 10 | ### _name 11 | 12 | ```solidity 13 | string internal _name; 14 | ``` 15 | 16 | 17 | ### _symbol 18 | 19 | ```solidity 20 | string internal _symbol; 21 | ``` 22 | 23 | 24 | ### _decimals 25 | 26 | ```solidity 27 | uint8 internal _decimals; 28 | ``` 29 | 30 | 31 | ## Functions 32 | ### constructor 33 | 34 | 35 | ```solidity 36 | constructor(string memory name, string memory symbol, uint8 decimals) public; 37 | ``` 38 | 39 | ### name 40 | 41 | 42 | ```solidity 43 | function name() public view returns (string memory); 44 | ``` 45 | **Returns** 46 | 47 | |Name|Type|Description| 48 | |----|----|-----------| 49 | |``|`string`|the name of the token.| 50 | 51 | 52 | ### symbol 53 | 54 | 55 | ```solidity 56 | function symbol() public view returns (string memory); 57 | ``` 58 | **Returns** 59 | 60 | |Name|Type|Description| 61 | |----|----|-----------| 62 | |``|`string`|the symbol of the token.| 63 | 64 | 65 | ### decimals 66 | 67 | 68 | ```solidity 69 | function decimals() public view returns (uint8); 70 | ``` 71 | **Returns** 72 | 73 | |Name|Type|Description| 74 | |----|----|-----------| 75 | |``|`uint8`|the number of decimals of the token.| 76 | 77 | 78 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [bor](/contracts/child/bor) 5 | - [misc](/contracts/child/misc) 6 | - [proxifiedChildToken](/contracts/child/proxifiedChildToken) 7 | - [BaseERC20](BaseERC20.sol/contract.BaseERC20.md) 8 | - [BaseERC20NoSig](BaseERC20NoSig.sol/contract.BaseERC20NoSig.md) 9 | - [ChildChain](ChildChain.sol/contract.ChildChain.md) 10 | - [ChildERC20](ChildERC20.sol/contract.ChildERC20.md) 11 | - [ChildERC721](ChildERC721.sol/contract.ChildERC721.md) 12 | - [ChildERC721Mintable](ChildERC721Mintable.sol/contract.ChildERC721Mintable.md) 13 | - [ChildToken](ChildToken.sol/contract.ChildToken.md) 14 | - [ERC20Detailed](ERC20Detailed.sol/contract.ERC20Detailed.md) 15 | - [MRC20](MRC20.sol/contract.MRC20.md) 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/bor/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [StateReceiver](StateReceiver.sol/interface.StateReceiver.md) 5 | - [StateSyncerVerifier](StateSyncerVerifier.sol/contract.StateSyncerVerifier.md) 6 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/bor/StateReceiver.sol/interface.StateReceiver.md: -------------------------------------------------------------------------------- 1 | # StateReceiver 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/bor/StateReceiver.sol) 3 | 4 | 5 | ## Functions 6 | ### onStateReceive 7 | 8 | 9 | ```solidity 10 | function onStateReceive(uint256 id, bytes calldata data) external; 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/bor/StateSyncerVerifier.sol/contract.StateSyncerVerifier.md: -------------------------------------------------------------------------------- 1 | # StateSyncerVerifier 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/bor/StateSyncerVerifier.sol) 3 | 4 | **Inherits:** 5 | Ownable 6 | 7 | 8 | ## State Variables 9 | ### stateSyncer 10 | 11 | ```solidity 12 | address public stateSyncer; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### onlyStateSyncer 18 | 19 | *Throws if called by any account other than state syncer* 20 | 21 | 22 | ```solidity 23 | modifier onlyStateSyncer(); 24 | ``` 25 | 26 | ### constructor 27 | 28 | 29 | ```solidity 30 | constructor() public; 31 | ``` 32 | 33 | ### isOnlyStateSyncerContract 34 | 35 | *Returns true if the caller is the state syncer contract 36 | TODO: replace onlyOwner ownership with 0x1000 for validator majority* 37 | 38 | 39 | ```solidity 40 | function isOnlyStateSyncerContract() public view returns (bool); 41 | ``` 42 | 43 | ### changeStateSyncerAddress 44 | 45 | 46 | ```solidity 47 | function changeStateSyncerAddress(address newAddress) public onlyOwner; 48 | ``` 49 | 50 | ## Events 51 | ### StateSyncerAddressChanged 52 | 53 | ```solidity 54 | event StateSyncerAddressChanged(address indexed previousAddress, address indexed newAddress); 55 | ``` 56 | 57 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/EIP712.sol/contract.LibEIP712Domain.md: -------------------------------------------------------------------------------- 1 | # LibEIP712Domain 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/misc/EIP712.sol) 3 | 4 | **Inherits:** 5 | [ChainIdMixin](/contracts/common/mixin/ChainIdMixin.sol/contract.ChainIdMixin.md) 6 | 7 | 8 | ## State Variables 9 | ### EIP712_DOMAIN_SCHEMA 10 | 11 | ```solidity 12 | string internal constant EIP712_DOMAIN_SCHEMA = "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"; 13 | ``` 14 | 15 | 16 | ### EIP712_DOMAIN_SCHEMA_HASH 17 | 18 | ```solidity 19 | bytes32 public constant EIP712_DOMAIN_SCHEMA_HASH = keccak256(abi.encodePacked(EIP712_DOMAIN_SCHEMA)); 20 | ``` 21 | 22 | 23 | ### EIP712_DOMAIN_NAME 24 | 25 | ```solidity 26 | string internal constant EIP712_DOMAIN_NAME = "Matic Network"; 27 | ``` 28 | 29 | 30 | ### EIP712_DOMAIN_VERSION 31 | 32 | ```solidity 33 | string internal constant EIP712_DOMAIN_VERSION = "1"; 34 | ``` 35 | 36 | 37 | ### EIP712_DOMAIN_CHAINID 38 | 39 | ```solidity 40 | uint256 internal constant EIP712_DOMAIN_CHAINID = CHAINID; 41 | ``` 42 | 43 | 44 | ### EIP712_DOMAIN_HASH 45 | 46 | ```solidity 47 | bytes32 public EIP712_DOMAIN_HASH; 48 | ``` 49 | 50 | 51 | ## Functions 52 | ### constructor 53 | 54 | 55 | ```solidity 56 | constructor() public; 57 | ``` 58 | 59 | ### hashEIP712Message 60 | 61 | 62 | ```solidity 63 | function hashEIP712Message(bytes32 hashStruct) internal view returns (bytes32 result); 64 | ``` 65 | 66 | ### hashEIP712MessageWithAddress 67 | 68 | 69 | ```solidity 70 | function hashEIP712MessageWithAddress(bytes32 hashStruct, address add) internal view returns (bytes32 result); 71 | ``` 72 | 73 | ### _hashEIP712Message 74 | 75 | 76 | ```solidity 77 | function _hashEIP712Message(bytes32 hashStruct, bytes32 domainHash) internal pure returns (bytes32 result); 78 | ``` 79 | 80 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/IParentToken.sol/interface.IParentToken.md: -------------------------------------------------------------------------------- 1 | # IParentToken 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/misc/IParentToken.sol) 3 | 4 | 5 | ## Functions 6 | ### beforeTransfer 7 | 8 | 9 | ```solidity 10 | function beforeTransfer(address sender, address to, uint256 value) external returns (bool); 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/LibTokenTransferOrder.sol/contract.LibTokenTransferOrder.md: -------------------------------------------------------------------------------- 1 | # LibTokenTransferOrder 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/misc/LibTokenTransferOrder.sol) 3 | 4 | **Inherits:** 5 | [LibEIP712Domain](/contracts/child/misc/EIP712.sol/contract.LibEIP712Domain.md) 6 | 7 | 8 | ## State Variables 9 | ### EIP712_TOKEN_TRANSFER_ORDER_SCHEMA 10 | 11 | ```solidity 12 | string internal constant EIP712_TOKEN_TRANSFER_ORDER_SCHEMA = "TokenTransferOrder(address spender,uint256 tokenIdOrAmount,bytes32 data,uint256 expiration)"; 13 | ``` 14 | 15 | 16 | ### EIP712_TOKEN_TRANSFER_ORDER_SCHEMA_HASH 17 | 18 | ```solidity 19 | bytes32 public constant EIP712_TOKEN_TRANSFER_ORDER_SCHEMA_HASH = keccak256(abi.encodePacked(EIP712_TOKEN_TRANSFER_ORDER_SCHEMA)); 20 | ``` 21 | 22 | 23 | ## Functions 24 | ### getTokenTransferOrderHash 25 | 26 | 27 | ```solidity 28 | function getTokenTransferOrderHash(address spender, uint256 tokenIdOrAmount, bytes32 data, uint256 expiration) public view returns (bytes32 orderHash); 29 | ``` 30 | 31 | ### hashTokenTransferOrder 32 | 33 | 34 | ```solidity 35 | function hashTokenTransferOrder(address spender, uint256 tokenIdOrAmount, bytes32 data, uint256 expiration) internal pure returns (bytes32 result); 36 | ``` 37 | 38 | ## Structs 39 | ### TokenTransferOrder 40 | 41 | ```solidity 42 | struct TokenTransferOrder { 43 | address spender; 44 | uint256 tokenIdOrAmount; 45 | bytes32 data; 46 | uint256 expiration; 47 | } 48 | ``` 49 | 50 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/Marketplace.sol/contract.Marketplace.md: -------------------------------------------------------------------------------- 1 | # Marketplace 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/misc/Marketplace.sol) 3 | 4 | 5 | ## Functions 6 | ### executeOrder 7 | 8 | 9 | ```solidity 10 | function executeOrder(bytes memory data1, bytes memory data2, bytes32 orderId, uint256 expiration, address taker) public; 11 | ``` 12 | 13 | ### decode 14 | 15 | 16 | ```solidity 17 | function decode(bytes memory data) internal pure returns (Order memory order); 18 | ``` 19 | 20 | ## Structs 21 | ### Order 22 | 23 | ```solidity 24 | struct Order { 25 | address token; 26 | bytes sig; 27 | uint256 tokenIdOrAmount; 28 | } 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/Marketplace.sol/interface.MarketplaceToken.md: -------------------------------------------------------------------------------- 1 | # MarketplaceToken 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/misc/Marketplace.sol) 3 | 4 | 5 | ## Functions 6 | ### transferWithSig 7 | 8 | 9 | ```solidity 10 | function transferWithSig(bytes calldata sig, uint256 tokenIdOrAmount, bytes32 data, uint256 expiration, address to) external returns (address); 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/ParentTokenMock.sol/contract.ParentTokenMock.md: -------------------------------------------------------------------------------- 1 | # ParentTokenMock 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/misc/ParentTokenMock.sol) 3 | 4 | **Inherits:** 5 | [IParentToken](/contracts/child/misc/IParentToken.sol/interface.IParentToken.md), Ownable 6 | 7 | 8 | ## State Variables 9 | ### isAllowed 10 | 11 | ```solidity 12 | mapping(address => bool) isAllowed; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### beforeTransfer 18 | 19 | 20 | ```solidity 21 | function beforeTransfer(address sender, address to, uint256 value) external returns (bool); 22 | ``` 23 | 24 | ### updatePermission 25 | 26 | 27 | ```solidity 28 | function updatePermission(address user) public onlyOwner; 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/misc/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [LibEIP712Domain](EIP712.sol/contract.LibEIP712Domain.md) 5 | - [IParentToken](IParentToken.sol/interface.IParentToken.md) 6 | - [LibTokenTransferOrder](LibTokenTransferOrder.sol/contract.LibTokenTransferOrder.md) 7 | - [MarketplaceToken](Marketplace.sol/interface.MarketplaceToken.md) 8 | - [Marketplace](Marketplace.sol/contract.Marketplace.md) 9 | - [ParentTokenMock](ParentTokenMock.sol/contract.ParentTokenMock.md) 10 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/proxifiedChildToken/ChildERC20Proxified.sol/contract.ChildERC20Proxified.md: -------------------------------------------------------------------------------- 1 | # ChildERC20Proxified 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/proxifiedChildToken/ChildERC20Proxified.sol) 3 | 4 | **Inherits:** 5 | [ChildERC20](/contracts/child/ChildERC20.sol/contract.ChildERC20.md), [Initializable](/contracts/common/mixin/Initializable.sol/contract.Initializable.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public ChildERC20(address(0x1), address(0x1), "", "", 18); 14 | ``` 15 | 16 | ### initialize 17 | 18 | 19 | ```solidity 20 | function initialize(address _token, string calldata name, string calldata symbol, uint8 decimals) external initializer; 21 | ``` 22 | 23 | ### isOwner 24 | 25 | 26 | ```solidity 27 | function isOwner() public view returns (bool); 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/proxifiedChildToken/ChildERC721Proxified.sol/contract.ChildERC721Proxified.md: -------------------------------------------------------------------------------- 1 | # ChildERC721Proxified 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/proxifiedChildToken/ChildERC721Proxified.sol) 3 | 4 | **Inherits:** 5 | [ChildERC721](/contracts/child/ChildERC721.sol/contract.ChildERC721.md), [Initializable](/contracts/common/mixin/Initializable.sol/contract.Initializable.md) 6 | 7 | 8 | ## State Variables 9 | ### name 10 | 11 | ```solidity 12 | string public name; 13 | ``` 14 | 15 | 16 | ### symbol 17 | 18 | ```solidity 19 | string public symbol; 20 | ``` 21 | 22 | 23 | ## Functions 24 | ### constructor 25 | 26 | 27 | ```solidity 28 | constructor() public ChildERC721(address(0x1), address(0x1), "", ""); 29 | ``` 30 | 31 | ### initialize 32 | 33 | 34 | ```solidity 35 | function initialize(address _token, string calldata _name, string calldata _symbol) external initializer; 36 | ``` 37 | 38 | ### isOwner 39 | 40 | 41 | ```solidity 42 | function isOwner() public view returns (bool); 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/proxifiedChildToken/ChildTokenProxy.sol/contract.ChildTokenProxy.md: -------------------------------------------------------------------------------- 1 | # ChildTokenProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/child/proxifiedChildToken/ChildTokenProxy.sol) 3 | 4 | **Inherits:** 5 | [UpgradableProxy](/contracts/common/misc/UpgradableProxy.sol/contract.UpgradableProxy.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo) public UpgradableProxy(_proxyTo); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/child/proxifiedChildToken/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ChildERC20Proxified](ChildERC20Proxified.sol/contract.ChildERC20Proxified.md) 5 | - [ChildERC721Proxified](ChildERC721Proxified.sol/contract.ChildERC721Proxified.md) 6 | - [ChildTokenProxy](ChildTokenProxy.sol/contract.ChildTokenProxy.md) 7 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [gnosis](/contracts/common/gnosis) 5 | - [governance](/contracts/common/governance) 6 | - [lib](/contracts/common/lib) 7 | - [misc](/contracts/common/misc) 8 | - [mixin](/contracts/common/mixin) 9 | - [tokens](/contracts/common/tokens) 10 | - [Registry](Registry.sol/contract.Registry.md) 11 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.Enum.md: -------------------------------------------------------------------------------- 1 | # Enum 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Author:** 5 | Richard Meissner - 6 | 7 | 8 | ## Enums 9 | ### Operation 10 | 11 | ```solidity 12 | enum Operation { 13 | Call, 14 | DelegateCall 15 | } 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.Executor.md: -------------------------------------------------------------------------------- 1 | # Executor 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Author:** 5 | Richard Meissner - 6 | 7 | 8 | ## Functions 9 | ### execute 10 | 11 | 12 | ```solidity 13 | function execute(address to, uint256 value, bytes memory data, Enum.Operation operation, uint256 txGas) internal returns (bool success); 14 | ``` 15 | 16 | ### executeCall 17 | 18 | 19 | ```solidity 20 | function executeCall(address to, uint256 value, bytes memory data, uint256 txGas) internal returns (bool success); 21 | ``` 22 | 23 | ### executeDelegateCall 24 | 25 | 26 | ```solidity 27 | function executeDelegateCall(address to, bytes memory data, uint256 txGas) internal returns (bool success); 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.FallbackManager.md: -------------------------------------------------------------------------------- 1 | # FallbackManager 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Inherits:** 5 | [SelfAuthorized](/contracts/common/gnosis/GnosisSafe.sol/contract.SelfAuthorized.md) 6 | 7 | **Author:** 8 | Richard Meissner - 9 | 10 | 11 | ## State Variables 12 | ### FALLBACK_HANDLER_STORAGE_SLOT 13 | 14 | ```solidity 15 | bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5; 16 | ``` 17 | 18 | 19 | ## Functions 20 | ### internalSetFallbackHandler 21 | 22 | 23 | ```solidity 24 | function internalSetFallbackHandler(address handler) internal; 25 | ``` 26 | 27 | ### setFallbackHandler 28 | 29 | *Allows to add a contract to handle fallback calls. 30 | Only fallback calls without value and with data will be forwarded. 31 | This can only be done via a Safe transaction.* 32 | 33 | 34 | ```solidity 35 | function setFallbackHandler(address handler) public authorized; 36 | ``` 37 | **Parameters** 38 | 39 | |Name|Type|Description| 40 | |----|----|-----------| 41 | |`handler`|`address`|contract to handle fallbacks calls.| 42 | 43 | 44 | ### function 45 | 46 | 47 | ```solidity 48 | function() external payable; 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.ISignatureValidator.md: -------------------------------------------------------------------------------- 1 | # ISignatureValidator 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Inherits:** 5 | [ISignatureValidatorConstants](/contracts/common/gnosis/GnosisSafe.sol/contract.ISignatureValidatorConstants.md) 6 | 7 | 8 | ## Functions 9 | ### isValidSignature 10 | 11 | *Should return whether the signature provided is valid for the provided data* 12 | 13 | 14 | ```solidity 15 | function isValidSignature(bytes memory _data, bytes memory _signature) public view returns (bytes4); 16 | ``` 17 | **Parameters** 18 | 19 | |Name|Type|Description| 20 | |----|----|-----------| 21 | |`_data`|`bytes`|Arbitrary length data signed on the behalf of address(this)| 22 | |`_signature`|`bytes`|Signature byte array associated with _data MUST return the bytes4 magic value 0x20c13b0b when function passes. MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) MUST allow external calls| 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.ISignatureValidatorConstants.md: -------------------------------------------------------------------------------- 1 | # ISignatureValidatorConstants 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | 5 | ## State Variables 6 | ### EIP1271_MAGIC_VALUE 7 | 8 | ```solidity 9 | bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b; 10 | ``` 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.MasterCopy.md: -------------------------------------------------------------------------------- 1 | # MasterCopy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Inherits:** 5 | [SelfAuthorized](/contracts/common/gnosis/GnosisSafe.sol/contract.SelfAuthorized.md) 6 | 7 | **Author:** 8 | Richard Meissner - 9 | 10 | 11 | ## State Variables 12 | ### masterCopy 13 | 14 | ```solidity 15 | address private masterCopy; 16 | ``` 17 | 18 | 19 | ## Functions 20 | ### changeMasterCopy 21 | 22 | *Allows to upgrade the contract. This can only be done via a Safe transaction.* 23 | 24 | 25 | ```solidity 26 | function changeMasterCopy(address _masterCopy) public authorized; 27 | ``` 28 | **Parameters** 29 | 30 | |Name|Type|Description| 31 | |----|----|-----------| 32 | |`_masterCopy`|`address`|New contract address.| 33 | 34 | 35 | ## Events 36 | ### ChangedMasterCopy 37 | 38 | ```solidity 39 | event ChangedMasterCopy(address masterCopy); 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.Module.md: -------------------------------------------------------------------------------- 1 | # Module 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Inherits:** 5 | [MasterCopy](/contracts/common/gnosis/GnosisSafe.sol/contract.MasterCopy.md) 6 | 7 | **Authors:** 8 | Stefan George - , Richard Meissner - 9 | 10 | 11 | ## State Variables 12 | ### manager 13 | 14 | ```solidity 15 | ModuleManager public manager; 16 | ``` 17 | 18 | 19 | ## Functions 20 | ### authorized 21 | 22 | 23 | ```solidity 24 | modifier authorized(); 25 | ``` 26 | 27 | ### setManager 28 | 29 | 30 | ```solidity 31 | function setManager() internal; 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.SecuredTokenTransfer.md: -------------------------------------------------------------------------------- 1 | # SecuredTokenTransfer 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Author:** 5 | Richard Meissner - 6 | 7 | 8 | ## Functions 9 | ### transferToken 10 | 11 | *Transfers a token and returns if it was a success* 12 | 13 | 14 | ```solidity 15 | function transferToken(address token, address receiver, uint256 amount) internal returns (bool transferred); 16 | ``` 17 | **Parameters** 18 | 19 | |Name|Type|Description| 20 | |----|----|-----------| 21 | |`token`|`address`|Token that should be transferred| 22 | |`receiver`|`address`|Receiver to whom the token should be transferred| 23 | |`amount`|`uint256`|The amount of tokens that should be transferred| 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.SelfAuthorized.md: -------------------------------------------------------------------------------- 1 | # SelfAuthorized 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Author:** 5 | Richard Meissner - 6 | 7 | Submitted for verification at Etherscan.io on 2019-12-26 8 | 9 | 10 | ## Functions 11 | ### authorized 12 | 13 | 14 | ```solidity 15 | modifier authorized(); 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/contract.SignatureDecoder.md: -------------------------------------------------------------------------------- 1 | # SignatureDecoder 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | **Authors:** 5 | Ricardo Guilherme Schmidt (Status Research & Development GmbH), Richard Meissner - 6 | 7 | 8 | ## Functions 9 | ### recoverKey 10 | 11 | *Recovers address who signed the message* 12 | 13 | 14 | ```solidity 15 | function recoverKey(bytes32 messageHash, bytes memory messageSignature, uint256 pos) internal pure returns (address); 16 | ``` 17 | **Parameters** 18 | 19 | |Name|Type|Description| 20 | |----|----|-----------| 21 | |`messageHash`|`bytes32`|operation ethereum signed message hash| 22 | |`messageSignature`|`bytes`|message `txHash` signature| 23 | |`pos`|`uint256`|which signature to read| 24 | 25 | 26 | ### signatureSplit 27 | 28 | Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures 29 | 30 | *divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.* 31 | 32 | 33 | ```solidity 34 | function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns (uint8 v, bytes32 r, bytes32 s); 35 | ``` 36 | **Parameters** 37 | 38 | |Name|Type|Description| 39 | |----|----|-----------| 40 | |`signatures`|`bytes`|concatenated rsv signatures| 41 | |`pos`|`uint256`|which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access| 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafe.sol/library.SafeMath.md: -------------------------------------------------------------------------------- 1 | # SafeMath 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafe.sol) 3 | 4 | *Math operations with safety checks that revert on error 5 | TODO: remove once open zeppelin update to solc 0.5.0* 6 | 7 | 8 | ## Functions 9 | ### mul 10 | 11 | *Multiplies two numbers, reverts on overflow.* 12 | 13 | 14 | ```solidity 15 | function mul(uint256 a, uint256 b) internal pure returns (uint256); 16 | ``` 17 | 18 | ### div 19 | 20 | *Integer division of two numbers truncating the quotient, reverts on division by zero.* 21 | 22 | 23 | ```solidity 24 | function div(uint256 a, uint256 b) internal pure returns (uint256); 25 | ``` 26 | 27 | ### sub 28 | 29 | *Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).* 30 | 31 | 32 | ```solidity 33 | function sub(uint256 a, uint256 b) internal pure returns (uint256); 34 | ``` 35 | 36 | ### add 37 | 38 | *Adds two numbers, reverts on overflow.* 39 | 40 | 41 | ```solidity 42 | function add(uint256 a, uint256 b) internal pure returns (uint256); 43 | ``` 44 | 45 | ### mod 46 | 47 | *Divides two numbers and returns the remainder (unsigned integer modulo), 48 | reverts when dividing by zero.* 49 | 50 | 51 | ```solidity 52 | function mod(uint256 a, uint256 b) internal pure returns (uint256); 53 | ``` 54 | 55 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/GnosisSafeProxy.sol/contract.GnosisSafeProxy.md: -------------------------------------------------------------------------------- 1 | # GnosisSafeProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/gnosis/GnosisSafeProxy.sol) 3 | 4 | **Authors:** 5 | Stefan George - , Richard Meissner - 6 | 7 | Submitted for verification at Etherscan.io on 2020-01-13 8 | 9 | 10 | ## State Variables 11 | ### masterCopy 12 | 13 | ```solidity 14 | address internal masterCopy; 15 | ``` 16 | 17 | 18 | ## Functions 19 | ### constructor 20 | 21 | *Constructor function sets address of master copy contract.* 22 | 23 | 24 | ```solidity 25 | constructor(address _masterCopy) public; 26 | ``` 27 | **Parameters** 28 | 29 | |Name|Type|Description| 30 | |----|----|-----------| 31 | |`_masterCopy`|`address`|Master copy address.| 32 | 33 | 34 | ### function 35 | 36 | *Fallback function forwards all transactions and returns all received return data.* 37 | 38 | 39 | ```solidity 40 | function() external payable; 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/gnosis/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [SelfAuthorized](GnosisSafe.sol/contract.SelfAuthorized.md) 5 | - [MasterCopy](GnosisSafe.sol/contract.MasterCopy.md) 6 | - [Module](GnosisSafe.sol/contract.Module.md) 7 | - [Enum](GnosisSafe.sol/contract.Enum.md) 8 | - [Executor](GnosisSafe.sol/contract.Executor.md) 9 | - [SecuredTokenTransfer](GnosisSafe.sol/contract.SecuredTokenTransfer.md) 10 | - [ModuleManager](GnosisSafe.sol/contract.ModuleManager.md) 11 | - [OwnerManager](GnosisSafe.sol/contract.OwnerManager.md) 12 | - [FallbackManager](GnosisSafe.sol/contract.FallbackManager.md) 13 | - [SignatureDecoder](GnosisSafe.sol/contract.SignatureDecoder.md) 14 | - [ISignatureValidatorConstants](GnosisSafe.sol/contract.ISignatureValidatorConstants.md) 15 | - [ISignatureValidator](GnosisSafe.sol/contract.ISignatureValidator.md) 16 | - [SafeMath](GnosisSafe.sol/library.SafeMath.md) 17 | - [GnosisSafe](GnosisSafe.sol/contract.GnosisSafe.md) 18 | - [GnosisSafeProxy](GnosisSafeProxy.sol/contract.GnosisSafeProxy.md) 19 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/governance/Governable.sol/contract.Governable.md: -------------------------------------------------------------------------------- 1 | # Governable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/governance/Governable.sol) 3 | 4 | 5 | ## State Variables 6 | ### governance 7 | 8 | ```solidity 9 | IGovernance public governance; 10 | ``` 11 | 12 | 13 | ## Functions 14 | ### constructor 15 | 16 | 17 | ```solidity 18 | constructor(address _governance) public; 19 | ``` 20 | 21 | ### onlyGovernance 22 | 23 | 24 | ```solidity 25 | modifier onlyGovernance(); 26 | ``` 27 | 28 | ### _assertGovernance 29 | 30 | 31 | ```solidity 32 | function _assertGovernance() private view; 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/governance/Governance.sol/contract.Governance.md: -------------------------------------------------------------------------------- 1 | # Governance 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/governance/Governance.sol) 3 | 4 | **Inherits:** 5 | [ProxyStorage](/contracts/common/misc/ProxyStorage.sol/contract.ProxyStorage.md), [IGovernance](/contracts/common/governance/IGovernance.sol/interface.IGovernance.md) 6 | 7 | 8 | ## Functions 9 | ### update 10 | 11 | 12 | ```solidity 13 | function update(address target, bytes memory data) public onlyOwner; 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/governance/GovernanceProxy.sol/contract.GovernanceProxy.md: -------------------------------------------------------------------------------- 1 | # GovernanceProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/governance/GovernanceProxy.sol) 3 | 4 | **Inherits:** 5 | [Proxy](/contracts/common/misc/Proxy.sol/contract.Proxy.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo) public Proxy(_proxyTo); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/governance/IGovernance.sol/interface.IGovernance.md: -------------------------------------------------------------------------------- 1 | # IGovernance 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/governance/IGovernance.sol) 3 | 4 | 5 | ## Functions 6 | ### update 7 | 8 | 9 | ```solidity 10 | function update(address target, bytes calldata data) external; 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/governance/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [Governable](Governable.sol/contract.Governable.md) 5 | - [Governance](Governance.sol/contract.Governance.md) 6 | - [GovernanceProxy](GovernanceProxy.sol/contract.GovernanceProxy.md) 7 | - [IGovernance](IGovernance.sol/interface.IGovernance.md) 8 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/BytesLib.sol/library.BytesLib.md: -------------------------------------------------------------------------------- 1 | # BytesLib 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/lib/BytesLib.sol) 3 | 4 | 5 | ## Functions 6 | ### concat 7 | 8 | 9 | ```solidity 10 | function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory); 11 | ``` 12 | 13 | ### slice 14 | 15 | 16 | ```solidity 17 | function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory); 18 | ``` 19 | 20 | ### leftPad 21 | 22 | 23 | ```solidity 24 | function leftPad(bytes memory _bytes) internal pure returns (bytes memory); 25 | ``` 26 | 27 | ### toBytes32 28 | 29 | 30 | ```solidity 31 | function toBytes32(bytes memory b) internal pure returns (bytes32); 32 | ``` 33 | 34 | ### toBytes4 35 | 36 | 37 | ```solidity 38 | function toBytes4(bytes memory b) internal pure returns (bytes4 result); 39 | ``` 40 | 41 | ### fromBytes32 42 | 43 | 44 | ```solidity 45 | function fromBytes32(bytes32 x) internal pure returns (bytes memory); 46 | ``` 47 | 48 | ### fromUint 49 | 50 | 51 | ```solidity 52 | function fromUint(uint256 _num) internal pure returns (bytes memory _ret); 53 | ``` 54 | 55 | ### toUint 56 | 57 | 58 | ```solidity 59 | function toUint(bytes memory _bytes, uint256 _start) internal pure returns (uint256); 60 | ``` 61 | 62 | ### toAddress 63 | 64 | 65 | ```solidity 66 | function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address); 67 | ``` 68 | 69 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/Common.sol/library.Common.md: -------------------------------------------------------------------------------- 1 | # Common 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/lib/Common.sol) 3 | 4 | 5 | ## Functions 6 | ### getV 7 | 8 | 9 | ```solidity 10 | function getV(bytes memory v, uint16 chainId) public pure returns (uint8); 11 | ``` 12 | 13 | ### isContract 14 | 15 | 16 | ```solidity 17 | function isContract(address _addr) public view returns (bool); 18 | ``` 19 | 20 | ### toUint8 21 | 22 | 23 | ```solidity 24 | function toUint8(bytes memory _arg) public pure returns (uint8); 25 | ``` 26 | 27 | ### toUint16 28 | 29 | 30 | ```solidity 31 | function toUint16(bytes memory _arg) public pure returns (uint16); 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/ECVerify.sol/library.ECVerify.md: -------------------------------------------------------------------------------- 1 | # ECVerify 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/lib/ECVerify.sol) 3 | 4 | 5 | ## Functions 6 | ### ecrecovery 7 | 8 | 9 | ```solidity 10 | function ecrecovery(bytes32 hash, uint256[3] memory sig) internal pure returns (address); 11 | ``` 12 | 13 | ### ecrecovery 14 | 15 | 16 | ```solidity 17 | function ecrecovery(bytes32 hash, bytes memory sig) internal pure returns (address); 18 | ``` 19 | 20 | ### ecrecovery 21 | 22 | 23 | ```solidity 24 | function ecrecovery(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address); 25 | ``` 26 | 27 | ### ecverify 28 | 29 | 30 | ```solidity 31 | function ecverify(bytes32 hash, bytes memory sig, address signer) internal pure returns (bool); 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/Merkle.sol/library.Merkle.md: -------------------------------------------------------------------------------- 1 | # Merkle 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/lib/Merkle.sol) 3 | 4 | 5 | ## Functions 6 | ### checkMembership 7 | 8 | 9 | ```solidity 10 | function checkMembership(bytes32 leaf, uint256 index, bytes32 rootHash, bytes memory proof) internal pure returns (bool); 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/MerklePatriciaProof.sol/library.MerklePatriciaProof.md: -------------------------------------------------------------------------------- 1 | # MerklePatriciaProof 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/lib/MerklePatriciaProof.sol) 3 | 4 | 5 | ## Functions 6 | ### verify 7 | 8 | 9 | ```solidity 10 | function verify(bytes memory value, bytes memory encodedPath, bytes memory rlpParentNodes, bytes32 root) internal pure returns (bool); 11 | ``` 12 | 13 | ### _nibblesToTraverse 14 | 15 | 16 | ```solidity 17 | function _nibblesToTraverse(bytes memory encodedPartialPath, bytes memory path, uint256 pathPtr) private pure returns (uint256); 18 | ``` 19 | 20 | ### _getNibbleArray 21 | 22 | 23 | ```solidity 24 | function _getNibbleArray(bytes memory b) private pure returns (bytes memory); 25 | ``` 26 | 27 | ### _getNthNibbleOfBytes 28 | 29 | 30 | ```solidity 31 | function _getNthNibbleOfBytes(uint256 n, bytes memory str) private pure returns (bytes1); 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [BytesLib](BytesLib.sol/library.BytesLib.md) 5 | - [Common](Common.sol/library.Common.md) 6 | - [ECVerify](ECVerify.sol/library.ECVerify.md) 7 | - [ExitPayloadReader](ExitPayloadReader.sol/library.ExitPayloadReader.md) 8 | - [Merkle](Merkle.sol/library.Merkle.md) 9 | - [MerklePatriciaProof](MerklePatriciaProof.sol/library.MerklePatriciaProof.md) 10 | - [PriorityQueue](PriorityQueue.sol/contract.PriorityQueue.md) 11 | - [RLPEncode](RLPEncode.sol/library.RLPEncode.md) 12 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/lib/RLPEncode.sol/library.RLPEncode.md: -------------------------------------------------------------------------------- 1 | # RLPEncode 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/lib/RLPEncode.sol) 3 | 4 | 5 | ## Functions 6 | ### encodeItem 7 | 8 | 9 | ```solidity 10 | function encodeItem(bytes memory self) internal pure returns (bytes memory); 11 | ``` 12 | 13 | ### encodeList 14 | 15 | 16 | ```solidity 17 | function encodeList(bytes[] memory self) internal pure returns (bytes memory); 18 | ``` 19 | 20 | ### encodeLength 21 | 22 | 23 | ```solidity 24 | function encodeLength(uint256 L, uint256 offset) internal pure returns (bytes memory); 25 | ``` 26 | 27 | ### getLengthBytes 28 | 29 | 30 | ```solidity 31 | function getLengthBytes(uint256 x) internal pure returns (bytes memory b); 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/ContractReceiver.sol/contract.ContractReceiver.md: -------------------------------------------------------------------------------- 1 | # ContractReceiver 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/ContractReceiver.sol) 3 | 4 | 5 | ## Functions 6 | ### tokenFallback 7 | 8 | *Function that is called when a user or another contract wants to transfer funds.* 9 | 10 | 11 | ```solidity 12 | function tokenFallback(address _from, uint256 _value, bytes memory _data) public; 13 | ``` 14 | **Parameters** 15 | 16 | |Name|Type|Description| 17 | |----|----|-----------| 18 | |`_from`|`address`|Transaction initiator, analogue of msg.sender| 19 | |`_value`|`uint256`|Number of tokens to transfer.| 20 | |`_data`|`bytes`|Data containig a function signature and/or parameters| 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/DelegateProxy.sol/contract.DelegateProxy.md: -------------------------------------------------------------------------------- 1 | # DelegateProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/DelegateProxy.sol) 3 | 4 | **Inherits:** 5 | [ERCProxy](/contracts/common/misc/ERCProxy.sol/interface.ERCProxy.md), [DelegateProxyForwarder](/contracts/common/misc/DelegateProxyForwarder.sol/contract.DelegateProxyForwarder.md) 6 | 7 | 8 | ## Functions 9 | ### proxyType 10 | 11 | 12 | ```solidity 13 | function proxyType() external pure returns (uint256 proxyTypeId); 14 | ``` 15 | 16 | ### implementation 17 | 18 | 19 | ```solidity 20 | function implementation() external view returns (address); 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/DelegateProxyForwarder.sol/contract.DelegateProxyForwarder.md: -------------------------------------------------------------------------------- 1 | # DelegateProxyForwarder 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/DelegateProxyForwarder.sol) 3 | 4 | 5 | ## Functions 6 | ### delegatedFwd 7 | 8 | 9 | ```solidity 10 | function delegatedFwd(address _dst, bytes memory _calldata) internal; 11 | ``` 12 | 13 | ### isContract 14 | 15 | 16 | ```solidity 17 | function isContract(address _target) internal view returns (bool); 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/DrainStakeManager.sol/contract.DrainStakeManager.md: -------------------------------------------------------------------------------- 1 | # DrainStakeManager 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/DrainStakeManager.sol) 3 | 4 | **Inherits:** 5 | [StakeManagerStorage](/contracts/staking/stakeManager/StakeManagerStorage.sol/contract.StakeManagerStorage.md), [Initializable](/contracts/common/mixin/Initializable.sol/contract.Initializable.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public GovernanceLockable(address(0x0)); 14 | ``` 15 | 16 | ### drain 17 | 18 | 19 | ```solidity 20 | function drain(address destination, uint256 amount) external onlyOwner; 21 | ``` 22 | 23 | ### drainValidatorShares 24 | 25 | 26 | ```solidity 27 | function drainValidatorShares(uint256 validatorId, address _token, address payable destination, uint256 amount) external onlyOwner; 28 | ``` 29 | 30 | ### isOwner 31 | 32 | 33 | ```solidity 34 | function isOwner() public view returns (bool); 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/Drainable.sol/contract.Drainable.md: -------------------------------------------------------------------------------- 1 | # Drainable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/Drainable.sol) 3 | 4 | **Inherits:** 5 | [DepositManagerStorage](/contracts/root/depositManager/DepositManagerStorage.sol/contract.DepositManagerStorage.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public GovernanceLockable(address(0x0)); 14 | ``` 15 | 16 | ### drainErc20 17 | 18 | 19 | ```solidity 20 | function drainErc20(address[] calldata tokens, uint256[] calldata values, address destination) external onlyGovernance; 21 | ``` 22 | 23 | ### drainErc721 24 | 25 | 26 | ```solidity 27 | function drainErc721(address[] calldata tokens, uint256[] calldata values, address destination) external onlyGovernance; 28 | ``` 29 | 30 | ### drainEther 31 | 32 | 33 | ```solidity 34 | function drainEther(uint256 amount, address payable destination) external onlyGovernance; 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/ERCProxy.sol/interface.ERCProxy.md: -------------------------------------------------------------------------------- 1 | # ERCProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/ERCProxy.sol) 3 | 4 | 5 | ## Functions 6 | ### proxyType 7 | 8 | 9 | ```solidity 10 | function proxyType() external pure returns (uint256 proxyTypeId); 11 | ``` 12 | 13 | ### implementation 14 | 15 | 16 | ```solidity 17 | function implementation() external view returns (address codeAddr); 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/Proxy.sol/contract.Proxy.md: -------------------------------------------------------------------------------- 1 | # Proxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/Proxy.sol) 3 | 4 | **Inherits:** 5 | [ProxyStorage](/contracts/common/misc/ProxyStorage.sol/contract.ProxyStorage.md), [DelegateProxy](/contracts/common/misc/DelegateProxy.sol/contract.DelegateProxy.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo) public; 14 | ``` 15 | 16 | ### function 17 | 18 | 19 | ```solidity 20 | function() external payable; 21 | ``` 22 | 23 | ### implementation 24 | 25 | 26 | ```solidity 27 | function implementation() external view returns (address); 28 | ``` 29 | 30 | ### updateImplementation 31 | 32 | 33 | ```solidity 34 | function updateImplementation(address _newProxyTo) public onlyOwner; 35 | ``` 36 | 37 | ### isContract 38 | 39 | 40 | ```solidity 41 | function isContract(address _target) internal view returns (bool); 42 | ``` 43 | 44 | ## Events 45 | ### ProxyUpdated 46 | 47 | ```solidity 48 | event ProxyUpdated(address indexed _new, address indexed _old); 49 | ``` 50 | 51 | ### OwnerUpdate 52 | 53 | ```solidity 54 | event OwnerUpdate(address _prevOwner, address _newOwner); 55 | ``` 56 | 57 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/ProxyStorage.sol/contract.ProxyStorage.md: -------------------------------------------------------------------------------- 1 | # ProxyStorage 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/misc/ProxyStorage.sol) 3 | 4 | **Inherits:** 5 | Ownable 6 | 7 | 8 | ## State Variables 9 | ### proxyTo 10 | 11 | ```solidity 12 | address internal proxyTo; 13 | ``` 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/misc/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ContractReceiver](ContractReceiver.sol/contract.ContractReceiver.md) 5 | - [DelegateProxy](DelegateProxy.sol/contract.DelegateProxy.md) 6 | - [DelegateProxyForwarder](DelegateProxyForwarder.sol/contract.DelegateProxyForwarder.md) 7 | - [DrainStakeManager](DrainStakeManager.sol/contract.DrainStakeManager.md) 8 | - [Drainable](Drainable.sol/contract.Drainable.md) 9 | - [ERCProxy](ERCProxy.sol/interface.ERCProxy.md) 10 | - [Proxy](Proxy.sol/contract.Proxy.md) 11 | - [ProxyStorage](ProxyStorage.sol/contract.ProxyStorage.md) 12 | - [UpgradableProxy](UpgradableProxy.sol/contract.UpgradableProxy.md) 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/ChainIdMixin.sol/contract.ChainIdMixin.md: -------------------------------------------------------------------------------- 1 | # ChainIdMixin 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/mixin/ChainIdMixin.sol) 3 | 4 | 5 | ## State Variables 6 | ### networkId 7 | 8 | ```solidity 9 | bytes public constant networkId = hex"3A99"; 10 | ``` 11 | 12 | 13 | ### CHAINID 14 | 15 | ```solidity 16 | uint256 public constant CHAINID = 15_001; 17 | ``` 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/GovernanceLockable.sol/contract.GovernanceLockable.md: -------------------------------------------------------------------------------- 1 | # GovernanceLockable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/mixin/GovernanceLockable.sol) 3 | 4 | **Inherits:** 5 | [Lockable](/contracts/common/mixin/Lockable.sol/contract.Lockable.md), [Governable](/contracts/common/governance/Governable.sol/contract.Governable.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address governance) public Governable(governance); 14 | ``` 15 | 16 | ### lock 17 | 18 | 19 | ```solidity 20 | function lock() public onlyGovernance; 21 | ``` 22 | 23 | ### unlock 24 | 25 | 26 | ```solidity 27 | function unlock() public onlyGovernance; 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/Initializable.sol/contract.Initializable.md: -------------------------------------------------------------------------------- 1 | # Initializable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/mixin/Initializable.sol) 3 | 4 | 5 | ## State Variables 6 | ### inited 7 | 8 | ```solidity 9 | bool inited = false; 10 | ``` 11 | 12 | 13 | ## Functions 14 | ### initializer 15 | 16 | 17 | ```solidity 18 | modifier initializer(); 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/Lockable.sol/contract.Lockable.md: -------------------------------------------------------------------------------- 1 | # Lockable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/mixin/Lockable.sol) 3 | 4 | 5 | ## State Variables 6 | ### locked 7 | 8 | ```solidity 9 | bool public locked; 10 | ``` 11 | 12 | 13 | ## Functions 14 | ### onlyWhenUnlocked 15 | 16 | 17 | ```solidity 18 | modifier onlyWhenUnlocked(); 19 | ``` 20 | 21 | ### _assertUnlocked 22 | 23 | 24 | ```solidity 25 | function _assertUnlocked() private view; 26 | ``` 27 | 28 | ### lock 29 | 30 | 31 | ```solidity 32 | function lock() public; 33 | ``` 34 | 35 | ### unlock 36 | 37 | 38 | ```solidity 39 | function unlock() public; 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/OwnableLockable.sol/contract.OwnableLockable.md: -------------------------------------------------------------------------------- 1 | # OwnableLockable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/mixin/OwnableLockable.sol) 3 | 4 | **Inherits:** 5 | [Lockable](/contracts/common/mixin/Lockable.sol/contract.Lockable.md), Ownable 6 | 7 | 8 | ## Functions 9 | ### lock 10 | 11 | 12 | ```solidity 13 | function lock() public onlyOwner; 14 | ``` 15 | 16 | ### unlock 17 | 18 | 19 | ```solidity 20 | function unlock() public onlyOwner; 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ChainIdMixin](ChainIdMixin.sol/contract.ChainIdMixin.md) 5 | - [GovernanceLockable](GovernanceLockable.sol/contract.GovernanceLockable.md) 6 | - [Initializable](Initializable.sol/contract.Initializable.md) 7 | - [Lockable](Lockable.sol/contract.Lockable.md) 8 | - [OwnableLockable](OwnableLockable.sol/contract.OwnableLockable.md) 9 | - [RootChainable](RootChainable.sol/contract.RootChainable.md) 10 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/mixin/RootChainable.sol/contract.RootChainable.md: -------------------------------------------------------------------------------- 1 | # RootChainable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/mixin/RootChainable.sol) 3 | 4 | **Inherits:** 5 | Ownable 6 | 7 | 8 | ## State Variables 9 | ### rootChain 10 | 11 | ```solidity 12 | address public rootChain; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### onlyRootChain 18 | 19 | 20 | ```solidity 21 | modifier onlyRootChain(); 22 | ``` 23 | 24 | ### changeRootChain 25 | 26 | *Allows the current owner to change root chain address.* 27 | 28 | 29 | ```solidity 30 | function changeRootChain(address newRootChain) public onlyOwner; 31 | ``` 32 | **Parameters** 33 | 34 | |Name|Type|Description| 35 | |----|----|-----------| 36 | |`newRootChain`|`address`|The address to new rootchain.| 37 | 38 | 39 | ## Events 40 | ### RootChainChanged 41 | 42 | ```solidity 43 | event RootChainChanged(address indexed previousRootChain, address indexed newRootChain); 44 | ``` 45 | 46 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/ERC20NonTradable.sol/contract.ERC20NonTradable.md: -------------------------------------------------------------------------------- 1 | # ERC20NonTradable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/ERC20NonTradable.sol) 3 | 4 | **Inherits:** 5 | ERC20 6 | 7 | 8 | ## Functions 9 | ### _approve 10 | 11 | 12 | ```solidity 13 | function _approve(address owner, address spender, uint256 value) internal; 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/ERC20NonTransferable.sol/contract.ERC20NonTransferable.md: -------------------------------------------------------------------------------- 1 | # ERC20NonTransferable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/ERC20NonTransferable.sol) 3 | 4 | **Inherits:** 5 | ERC20 6 | 7 | 8 | ## Functions 9 | ### _transfer 10 | 11 | 12 | ```solidity 13 | function _transfer(address from, address to, uint256 value) internal; 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/ERC721PlasmaMintable.sol/contract.ERC721PlasmaMintable.md: -------------------------------------------------------------------------------- 1 | # ERC721PlasmaMintable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/ERC721PlasmaMintable.sol) 3 | 4 | **Inherits:** 5 | ERC721Mintable, ERC721MetadataMintable 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(string memory name, string memory symbol) public ERC721Metadata(name, symbol); 14 | ``` 15 | 16 | ### exists 17 | 18 | *Returns whether the specified token exists* 19 | 20 | 21 | ```solidity 22 | function exists(uint256 tokenId) public view returns (bool); 23 | ``` 24 | **Parameters** 25 | 26 | |Name|Type|Description| 27 | |----|----|-----------| 28 | |`tokenId`|`uint256`|uint256 ID of the token to query the existence of| 29 | 30 | **Returns** 31 | 32 | |Name|Type|Description| 33 | |----|----|-----------| 34 | |``|`bool`|bool whether the token exists| 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/MaticWETH.sol/contract.MaticWETH.md: -------------------------------------------------------------------------------- 1 | # MaticWETH 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/MaticWETH.sol) 3 | 4 | **Inherits:** 5 | [WETH](/contracts/common/tokens/WETH.sol/contract.WETH.md) 6 | 7 | 8 | ## State Variables 9 | ### name 10 | 11 | ```solidity 12 | string public name = "Wrapped Ether"; 13 | ``` 14 | 15 | 16 | ### symbol 17 | 18 | ```solidity 19 | string public symbol = "WETH"; 20 | ``` 21 | 22 | 23 | ### decimals 24 | 25 | ```solidity 26 | uint8 public decimals = 18; 27 | ``` 28 | 29 | 30 | ## Functions 31 | ### deposit 32 | 33 | 34 | ```solidity 35 | function deposit() public payable; 36 | ``` 37 | 38 | ### withdraw 39 | 40 | 41 | ```solidity 42 | function withdraw(uint256 wad) public; 43 | ``` 44 | 45 | ### withdraw 46 | 47 | 48 | ```solidity 49 | function withdraw(uint256 wad, address user) public; 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/POLTokenMock.sol/contract.POLTokenMock.md: -------------------------------------------------------------------------------- 1 | # POLTokenMock 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/POLTokenMock.sol) 3 | 4 | **Inherits:** 5 | ERC20Mintable 6 | 7 | 8 | ## State Variables 9 | ### name 10 | 11 | ```solidity 12 | string public name; 13 | ``` 14 | 15 | 16 | ### symbol 17 | 18 | ```solidity 19 | string public symbol; 20 | ``` 21 | 22 | 23 | ### decimals 24 | 25 | ```solidity 26 | uint8 public decimals = 18; 27 | ``` 28 | 29 | 30 | ## Functions 31 | ### constructor 32 | 33 | 34 | ```solidity 35 | constructor(string memory _name, string memory _symbol) public; 36 | ``` 37 | 38 | ### safeTransfer 39 | 40 | 41 | ```solidity 42 | function safeTransfer(IERC20 token, address to, uint256 value) public; 43 | ``` 44 | 45 | ### safeTransferFrom 46 | 47 | 48 | ```solidity 49 | function safeTransferFrom(IERC20 token, address from, address to, uint256 value) public; 50 | ``` 51 | 52 | ### callOptionalReturn 53 | 54 | *Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement 55 | on the return value: the return value is optional (but if data is returned, it must equal true).* 56 | 57 | 58 | ```solidity 59 | function callOptionalReturn(IERC20 token, bytes memory data) private; 60 | ``` 61 | **Parameters** 62 | 63 | |Name|Type|Description| 64 | |----|----|-----------| 65 | |`token`|`IERC20`|The token targeted by the call.| 66 | |`data`|`bytes`|The call data (encoded using abi.encode or one of its variants).| 67 | 68 | 69 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ERC20NonTradable](ERC20NonTradable.sol/contract.ERC20NonTradable.md) 5 | - [ERC20NonTransferable](ERC20NonTransferable.sol/contract.ERC20NonTransferable.md) 6 | - [ERC721PlasmaMintable](ERC721PlasmaMintable.sol/contract.ERC721PlasmaMintable.md) 7 | - [MaticWETH](MaticWETH.sol/contract.MaticWETH.md) 8 | - [POLTokenMock](POLTokenMock.sol/contract.POLTokenMock.md) 9 | - [RootERC721](RootERC721.sol/contract.RootERC721.md) 10 | - [TestToken](TestToken.sol/contract.TestToken.md) 11 | - [WETH](WETH.sol/contract.WETH.md) 12 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/RootERC721.sol/contract.RootERC721.md: -------------------------------------------------------------------------------- 1 | # RootERC721 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/RootERC721.sol) 3 | 4 | **Inherits:** 5 | ERC721Full 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(string memory name, string memory symbol) public ERC721Full(name, symbol); 14 | ``` 15 | 16 | ### mint 17 | 18 | 19 | ```solidity 20 | function mint(uint256 tokenId) public; 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/TestToken.sol/contract.TestToken.md: -------------------------------------------------------------------------------- 1 | # TestToken 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/TestToken.sol) 3 | 4 | **Inherits:** 5 | ERC20Mintable 6 | 7 | 8 | ## State Variables 9 | ### name 10 | 11 | ```solidity 12 | string public name; 13 | ``` 14 | 15 | 16 | ### symbol 17 | 18 | ```solidity 19 | string public symbol; 20 | ``` 21 | 22 | 23 | ### decimals 24 | 25 | ```solidity 26 | uint8 public decimals = 18; 27 | ``` 28 | 29 | 30 | ## Functions 31 | ### constructor 32 | 33 | 34 | ```solidity 35 | constructor(string memory _name, string memory _symbol) public; 36 | ``` 37 | 38 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/common/tokens/WETH.sol/contract.WETH.md: -------------------------------------------------------------------------------- 1 | # WETH 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/common/tokens/WETH.sol) 3 | 4 | **Inherits:** 5 | ERC20 6 | 7 | 8 | ## Functions 9 | ### deposit 10 | 11 | 12 | ```solidity 13 | function deposit() public payable; 14 | ``` 15 | 16 | ### withdraw 17 | 18 | 19 | ```solidity 20 | function withdraw(uint256 wad) public; 21 | ``` 22 | 23 | ### withdraw 24 | 25 | 26 | ```solidity 27 | function withdraw(uint256 wad, address user) public; 28 | ``` 29 | 30 | ## Events 31 | ### Deposit 32 | 33 | ```solidity 34 | event Deposit(address indexed dst, uint256 wad); 35 | ``` 36 | 37 | ### Withdrawal 38 | 39 | ```solidity 40 | event Withdrawal(address indexed src, uint256 wad); 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/IRootChain.sol/interface.IRootChain.md: -------------------------------------------------------------------------------- 1 | # IRootChain 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/IRootChain.sol) 3 | 4 | 5 | ## Functions 6 | ### slash 7 | 8 | 9 | ```solidity 10 | function slash() external; 11 | ``` 12 | 13 | ### submitHeaderBlock 14 | 15 | 16 | ```solidity 17 | function submitHeaderBlock(bytes calldata data, bytes calldata sigs) external; 18 | ``` 19 | 20 | ### submitCheckpoint 21 | 22 | 23 | ```solidity 24 | function submitCheckpoint(bytes calldata data, uint256[3][] calldata sigs) external; 25 | ``` 26 | 27 | ### getLastChildBlock 28 | 29 | 30 | ```solidity 31 | function getLastChildBlock() external view returns (uint256); 32 | ``` 33 | 34 | ### currentHeaderBlock 35 | 36 | 37 | ```solidity 38 | function currentHeaderBlock() external view returns (uint256); 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [depositManager](/contracts/root/depositManager) 5 | - [predicates](/contracts/root/predicates) 6 | - [stateSyncer](/contracts/root/stateSyncer) 7 | - [withdrawManager](/contracts/root/withdrawManager) 8 | - [IRootChain](IRootChain.sol/interface.IRootChain.md) 9 | - [RootChain](RootChain.sol/contract.RootChain.md) 10 | - [RootChainProxy](RootChainProxy.sol/contract.RootChainProxy.md) 11 | - [RootChainHeader](RootChainStorage.sol/contract.RootChainHeader.md) 12 | - [RootChainStorage](RootChainStorage.sol/contract.RootChainStorage.md) 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/RootChain.sol/contract.RootChain.md: -------------------------------------------------------------------------------- 1 | # RootChain 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/RootChain.sol) 3 | 4 | **Inherits:** 5 | [RootChainStorage](/contracts/root/RootChainStorage.sol/contract.RootChainStorage.md), [IRootChain](/contracts/root/IRootChain.sol/interface.IRootChain.md) 6 | 7 | 8 | ## Functions 9 | ### onlyDepositManager 10 | 11 | 12 | ```solidity 13 | modifier onlyDepositManager(); 14 | ``` 15 | 16 | ### submitHeaderBlock 17 | 18 | 19 | ```solidity 20 | function submitHeaderBlock(bytes calldata data, bytes calldata sigs) external; 21 | ``` 22 | 23 | ### submitCheckpoint 24 | 25 | 26 | ```solidity 27 | function submitCheckpoint(bytes calldata data, uint256[3][] calldata sigs) external; 28 | ``` 29 | 30 | ### updateDepositId 31 | 32 | prefix 01 to data 33 | 01 represents positive vote on data and 00 is negative vote 34 | malicious validator can try to send 2/3 on negative vote so 01 is appended 35 | 36 | 37 | ```solidity 38 | function updateDepositId(uint256 numDeposits) external onlyDepositManager returns (uint256 depositId); 39 | ``` 40 | 41 | ### getLastChildBlock 42 | 43 | 44 | ```solidity 45 | function getLastChildBlock() external view returns (uint256); 46 | ``` 47 | 48 | ### slash 49 | 50 | 51 | ```solidity 52 | function slash() external; 53 | ``` 54 | 55 | ### currentHeaderBlock 56 | 57 | 58 | ```solidity 59 | function currentHeaderBlock() public view returns (uint256); 60 | ``` 61 | 62 | ### _buildHeaderBlock 63 | 64 | 65 | ```solidity 66 | function _buildHeaderBlock(address proposer, uint256 start, uint256 end, bytes32 rootHash) private returns (bool); 67 | ``` 68 | 69 | ### setNextHeaderBlock 70 | 71 | 72 | ```solidity 73 | function setNextHeaderBlock(uint256 _value) public onlyOwner; 74 | ``` 75 | 76 | ### setHeimdallId 77 | 78 | 79 | ```solidity 80 | function setHeimdallId(string memory _heimdallId) public onlyOwner; 81 | ``` 82 | 83 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/RootChainProxy.sol/contract.RootChainProxy.md: -------------------------------------------------------------------------------- 1 | # RootChainProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/RootChainProxy.sol) 3 | 4 | **Inherits:** 5 | [Proxy](/contracts/common/misc/Proxy.sol/contract.Proxy.md), [RootChainStorage](/contracts/root/RootChainStorage.sol/contract.RootChainStorage.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo, address _registry, string memory _heimdallId) public Proxy(_proxyTo); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/RootChainStorage.sol/contract.RootChainHeader.md: -------------------------------------------------------------------------------- 1 | # RootChainHeader 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/RootChainStorage.sol) 3 | 4 | 5 | ## Events 6 | ### NewHeaderBlock 7 | 8 | ```solidity 9 | event NewHeaderBlock(address indexed proposer, uint256 indexed headerBlockId, uint256 indexed reward, uint256 start, uint256 end, bytes32 root); 10 | ``` 11 | 12 | ### ResetHeaderBlock 13 | 14 | ```solidity 15 | event ResetHeaderBlock(address indexed proposer, uint256 indexed headerBlockId); 16 | ``` 17 | 18 | ## Structs 19 | ### HeaderBlock 20 | 21 | ```solidity 22 | struct HeaderBlock { 23 | bytes32 root; 24 | uint256 start; 25 | uint256 end; 26 | uint256 createdAt; 27 | address proposer; 28 | } 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/RootChainStorage.sol/contract.RootChainStorage.md: -------------------------------------------------------------------------------- 1 | # RootChainStorage 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/RootChainStorage.sol) 3 | 4 | **Inherits:** 5 | [ProxyStorage](/contracts/common/misc/ProxyStorage.sol/contract.ProxyStorage.md), [RootChainHeader](/contracts/root/RootChainStorage.sol/contract.RootChainHeader.md), [ChainIdMixin](/contracts/common/mixin/ChainIdMixin.sol/contract.ChainIdMixin.md) 6 | 7 | 8 | ## State Variables 9 | ### heimdallId 10 | 11 | ```solidity 12 | bytes32 public heimdallId; 13 | ``` 14 | 15 | 16 | ### VOTE_TYPE 17 | 18 | ```solidity 19 | uint8 public constant VOTE_TYPE = 2; 20 | ``` 21 | 22 | 23 | ### MAX_DEPOSITS 24 | 25 | ```solidity 26 | uint16 internal constant MAX_DEPOSITS = 10_000; 27 | ``` 28 | 29 | 30 | ### _nextHeaderBlock 31 | 32 | ```solidity 33 | uint256 public _nextHeaderBlock = MAX_DEPOSITS; 34 | ``` 35 | 36 | 37 | ### _blockDepositId 38 | 39 | ```solidity 40 | uint256 internal _blockDepositId = 1; 41 | ``` 42 | 43 | 44 | ### headerBlocks 45 | 46 | ```solidity 47 | mapping(uint256 => HeaderBlock) public headerBlocks; 48 | ``` 49 | 50 | 51 | ### registry 52 | 53 | ```solidity 54 | Registry internal registry; 55 | ``` 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/depositManager/DepositManager.sol/interface.IPolygonMigration.md: -------------------------------------------------------------------------------- 1 | # IPolygonMigration 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/depositManager/DepositManager.sol) 3 | 4 | 5 | ## Functions 6 | ### migrate 7 | 8 | 9 | ```solidity 10 | function migrate(uint256 amount) external; 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/depositManager/DepositManagerProxy.sol/contract.DepositManagerProxy.md: -------------------------------------------------------------------------------- 1 | # DepositManagerProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/depositManager/DepositManagerProxy.sol) 3 | 4 | **Inherits:** 5 | [Proxy](/contracts/common/misc/Proxy.sol/contract.Proxy.md), [DepositManagerStorage](/contracts/root/depositManager/DepositManagerStorage.sol/contract.DepositManagerStorage.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo, address _registry, address _rootChain, address _governance) public Proxy(_proxyTo) GovernanceLockable(_governance); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/depositManager/DepositManagerStorage.sol/contract.DepositManagerHeader.md: -------------------------------------------------------------------------------- 1 | # DepositManagerHeader 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/depositManager/DepositManagerStorage.sol) 3 | 4 | 5 | ## Events 6 | ### NewDepositBlock 7 | 8 | ```solidity 9 | event NewDepositBlock(address indexed owner, address indexed token, uint256 amountOrNFTId, uint256 depositBlockId); 10 | ``` 11 | 12 | ### MaxErc20DepositUpdate 13 | 14 | ```solidity 15 | event MaxErc20DepositUpdate(uint256 indexed oldLimit, uint256 indexed newLimit); 16 | ``` 17 | 18 | ## Structs 19 | ### DepositBlock 20 | 21 | ```solidity 22 | struct DepositBlock { 23 | bytes32 depositHash; 24 | uint256 createdAt; 25 | } 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/depositManager/DepositManagerStorage.sol/contract.DepositManagerStorage.md: -------------------------------------------------------------------------------- 1 | # DepositManagerStorage 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/depositManager/DepositManagerStorage.sol) 3 | 4 | **Inherits:** 5 | [ProxyStorage](/contracts/common/misc/ProxyStorage.sol/contract.ProxyStorage.md), [GovernanceLockable](/contracts/common/mixin/GovernanceLockable.sol/contract.GovernanceLockable.md), [DepositManagerHeader](/contracts/root/depositManager/DepositManagerStorage.sol/contract.DepositManagerHeader.md) 6 | 7 | 8 | ## State Variables 9 | ### registry 10 | 11 | ```solidity 12 | Registry public registry; 13 | ``` 14 | 15 | 16 | ### rootChain 17 | 18 | ```solidity 19 | RootChain public rootChain; 20 | ``` 21 | 22 | 23 | ### stateSender 24 | 25 | ```solidity 26 | StateSender public stateSender; 27 | ``` 28 | 29 | 30 | ### deposits 31 | 32 | ```solidity 33 | mapping(uint256 => DepositBlock) public deposits; 34 | ``` 35 | 36 | 37 | ### childChain 38 | 39 | ```solidity 40 | address public childChain; 41 | ``` 42 | 43 | 44 | ### maxErc20Deposit 45 | 46 | ```solidity 47 | uint256 public maxErc20Deposit = 100 * (10 ** 18); 48 | ``` 49 | 50 | 51 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/depositManager/IDepositManager.sol/interface.IDepositManager.md: -------------------------------------------------------------------------------- 1 | # IDepositManager 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/depositManager/IDepositManager.sol) 3 | 4 | 5 | ## Functions 6 | ### depositEther 7 | 8 | 9 | ```solidity 10 | function depositEther() external payable; 11 | ``` 12 | 13 | ### transferAssets 14 | 15 | 16 | ```solidity 17 | function transferAssets(address _token, address _user, uint256 _amountOrNFTId) external; 18 | ``` 19 | 20 | ### depositERC20 21 | 22 | 23 | ```solidity 24 | function depositERC20(address _token, uint256 _amount) external; 25 | ``` 26 | 27 | ### depositERC721 28 | 29 | 30 | ```solidity 31 | function depositERC721(address _token, uint256 _tokenId) external; 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/depositManager/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [IPolygonMigration](DepositManager.sol/interface.IPolygonMigration.md) 5 | - [DepositManager](DepositManager.sol/contract.DepositManager.md) 6 | - [DepositManagerProxy](DepositManagerProxy.sol/contract.DepositManagerProxy.md) 7 | - [DepositManagerHeader](DepositManagerStorage.sol/contract.DepositManagerHeader.md) 8 | - [DepositManagerStorage](DepositManagerStorage.sol/contract.DepositManagerStorage.md) 9 | - [IDepositManager](IDepositManager.sol/interface.IDepositManager.md) 10 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/ERC20PredicateBurnOnly.sol/contract.ERC20PredicateBurnOnly.md: -------------------------------------------------------------------------------- 1 | # ERC20PredicateBurnOnly 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/predicates/ERC20PredicateBurnOnly.sol) 3 | 4 | **Inherits:** 5 | [IErcPredicate](/contracts/root/predicates/IPredicate.sol/contract.IErcPredicate.md) 6 | 7 | 8 | ## State Variables 9 | ### WITHDRAW_EVENT_SIG 10 | 11 | ```solidity 12 | bytes32 constant WITHDRAW_EVENT_SIG = 0xebff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### constructor 18 | 19 | 20 | ```solidity 21 | constructor(address _withdrawManager, address _depositManager) public IErcPredicate(_withdrawManager, _depositManager); 22 | ``` 23 | 24 | ### startExitWithBurntTokens 25 | 26 | 27 | ```solidity 28 | function startExitWithBurntTokens(bytes calldata data) external; 29 | ``` 30 | 31 | ### verifyDeprecation 32 | 33 | 34 | ```solidity 35 | function verifyDeprecation(bytes calldata exit, bytes calldata inputUtxo, bytes calldata challengeData) external returns (bool); 36 | ``` 37 | 38 | ### interpretStateUpdate 39 | 40 | 41 | ```solidity 42 | function interpretStateUpdate(bytes calldata state) external view returns (bytes memory); 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/ERC721PredicateBurnOnly.sol/contract.ERC721PredicateBurnOnly.md: -------------------------------------------------------------------------------- 1 | # ERC721PredicateBurnOnly 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/predicates/ERC721PredicateBurnOnly.sol) 3 | 4 | **Inherits:** 5 | [IErcPredicate](/contracts/root/predicates/IPredicate.sol/contract.IErcPredicate.md) 6 | 7 | 8 | ## State Variables 9 | ### WITHDRAW_EVENT_SIG 10 | 11 | ```solidity 12 | bytes32 constant WITHDRAW_EVENT_SIG = 0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### constructor 18 | 19 | 20 | ```solidity 21 | constructor(address _withdrawManager, address _depositManager) public IErcPredicate(_withdrawManager, _depositManager); 22 | ``` 23 | 24 | ### verifyDeprecation 25 | 26 | 27 | ```solidity 28 | function verifyDeprecation(bytes calldata exit, bytes calldata inputUtxo, bytes calldata challengeData) external returns (bool); 29 | ``` 30 | 31 | ### interpretStateUpdate 32 | 33 | 34 | ```solidity 35 | function interpretStateUpdate(bytes calldata state) external view returns (bytes memory b); 36 | ``` 37 | 38 | ### startExitWithBurntTokens 39 | 40 | 41 | ```solidity 42 | function startExitWithBurntTokens(bytes memory data) public returns (bytes memory); 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/IPredicate.sol/contract.IErcPredicate.md: -------------------------------------------------------------------------------- 1 | # IErcPredicate 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/predicates/IPredicate.sol) 3 | 4 | **Inherits:** 5 | [IPredicate](/contracts/root/predicates/IPredicate.sol/interface.IPredicate.md), [PredicateUtils](/contracts/root/predicates/IPredicate.sol/contract.PredicateUtils.md) 6 | 7 | 8 | ## State Variables 9 | ### MAX_LOGS 10 | 11 | ```solidity 12 | uint256 internal constant MAX_LOGS = 10; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### constructor 18 | 19 | 20 | ```solidity 21 | constructor(address _withdrawManager, address _depositManager) public; 22 | ``` 23 | 24 | ## Structs 25 | ### ExitTxData 26 | 27 | ```solidity 28 | struct ExitTxData { 29 | uint256 amountOrToken; 30 | bytes32 txHash; 31 | address childToken; 32 | address signer; 33 | ExitType exitType; 34 | } 35 | ``` 36 | 37 | ### ReferenceTxData 38 | 39 | ```solidity 40 | struct ReferenceTxData { 41 | uint256 closingBalance; 42 | uint256 age; 43 | address childToken; 44 | address rootToken; 45 | } 46 | ``` 47 | 48 | ## Enums 49 | ### ExitType 50 | 51 | ```solidity 52 | enum ExitType { 53 | Invalid, 54 | OutgoingTransfer, 55 | IncomingTransfer, 56 | Burnt 57 | } 58 | ``` 59 | 60 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/IPredicate.sol/contract.PredicateUtils.md: -------------------------------------------------------------------------------- 1 | # PredicateUtils 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/predicates/IPredicate.sol) 3 | 4 | **Inherits:** 5 | [ExitsDataStructure](/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.ExitsDataStructure.md), [ChainIdMixin](/contracts/common/mixin/ChainIdMixin.sol/contract.ChainIdMixin.md) 6 | 7 | 8 | ## State Variables 9 | ### BOND_AMOUNT 10 | 11 | ```solidity 12 | uint256 private constant BOND_AMOUNT = 10 ** 17; 13 | ``` 14 | 15 | 16 | ### withdrawManager 17 | 18 | ```solidity 19 | IWithdrawManager internal withdrawManager; 20 | ``` 21 | 22 | 23 | ### depositManager 24 | 25 | ```solidity 26 | IDepositManager internal depositManager; 27 | ``` 28 | 29 | 30 | ## Functions 31 | ### onlyWithdrawManager 32 | 33 | 34 | ```solidity 35 | modifier onlyWithdrawManager(); 36 | ``` 37 | 38 | ### isBondProvided 39 | 40 | 41 | ```solidity 42 | modifier isBondProvided(); 43 | ``` 44 | 45 | ### onFinalizeExit 46 | 47 | 48 | ```solidity 49 | function onFinalizeExit(bytes calldata data) external onlyWithdrawManager; 50 | ``` 51 | 52 | ### sendBond 53 | 54 | 55 | ```solidity 56 | function sendBond() internal; 57 | ``` 58 | 59 | ### getAddressFromTx 60 | 61 | 62 | ```solidity 63 | function getAddressFromTx(RLPReader.RLPItem[] memory txList) internal pure returns (address signer, bytes32 txHash); 64 | ``` 65 | 66 | ### decodeExit 67 | 68 | 69 | ```solidity 70 | function decodeExit(bytes memory data) internal pure returns (PlasmaExit memory); 71 | ``` 72 | 73 | ### decodeExitForProcessExit 74 | 75 | 76 | ```solidity 77 | function decodeExitForProcessExit(bytes memory data) internal pure returns (uint256 exitId, address token, address exitor, uint256 tokenId); 78 | ``` 79 | 80 | ### decodeInputUtxo 81 | 82 | 83 | ```solidity 84 | function decodeInputUtxo(bytes memory data) internal pure returns (uint256 age, address signer, address predicate, address token); 85 | ``` 86 | 87 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/IPredicate.sol/interface.IPredicate.md: -------------------------------------------------------------------------------- 1 | # IPredicate 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/predicates/IPredicate.sol) 3 | 4 | 5 | ## Functions 6 | ### verifyDeprecation 7 | 8 | Verify the deprecation of a state update 9 | 10 | 11 | ```solidity 12 | function verifyDeprecation(bytes calldata exit, bytes calldata inputUtxo, bytes calldata challengeData) external returns (bool); 13 | ``` 14 | **Parameters** 15 | 16 | |Name|Type|Description| 17 | |----|----|-----------| 18 | |`exit`|`bytes`|ABI encoded PlasmaExit data| 19 | |`inputUtxo`|`bytes`|ABI encoded Input UTXO data| 20 | |`challengeData`|`bytes`|RLP encoded data of the challenge reference tx that encodes the following fields headerNumber Header block number of which the reference tx was a part of blockProof Proof that the block header (in the child chain) is a leaf in the submitted merkle root blockNumber Block number of which the reference tx is a part of blockTime Reference tx block time blocktxRoot Transactions root of block blockReceiptsRoot Receipts root of block receipt Receipt of the reference transaction receiptProof Merkle proof of the reference receipt branchMask Merkle proof branchMask for the receipt logIndex Log Index to read from the receipt tx Challenge transaction txProof Merkle proof of the challenge tx| 21 | 22 | **Returns** 23 | 24 | |Name|Type|Description| 25 | |----|----|-----------| 26 | |``|`bool`|Whether or not the state is deprecated| 27 | 28 | 29 | ### interpretStateUpdate 30 | 31 | 32 | ```solidity 33 | function interpretStateUpdate(bytes calldata state) external view returns (bytes memory); 34 | ``` 35 | 36 | ### onFinalizeExit 37 | 38 | 39 | ```solidity 40 | function onFinalizeExit(bytes calldata data) external; 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ERC20Predicate](ERC20Predicate.sol/contract.ERC20Predicate.md) 5 | - [ERC20PredicateBurnOnly](ERC20PredicateBurnOnly.sol/contract.ERC20PredicateBurnOnly.md) 6 | - [ERC721Predicate](ERC721Predicate.sol/contract.ERC721Predicate.md) 7 | - [ERC721PredicateBurnOnly](ERC721PredicateBurnOnly.sol/contract.ERC721PredicateBurnOnly.md) 8 | - [IPredicate](IPredicate.sol/interface.IPredicate.md) 9 | - [PredicateUtils](IPredicate.sol/contract.PredicateUtils.md) 10 | - [IErcPredicate](IPredicate.sol/contract.IErcPredicate.md) 11 | - [MarketplacePredicate](MarketplacePredicate.sol/contract.MarketplacePredicate.md) 12 | - [MintableERC721Predicate](MintableERC721Predicate.sol/contract.MintableERC721Predicate.md) 13 | - [TransferWithSigPredicate](TransferWithSigPredicate.sol/contract.TransferWithSigPredicate.md) 14 | - [TransferWithSigUtils](TransferWithSigUtils.sol/library.TransferWithSigUtils.md) 15 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/predicates/TransferWithSigUtils.sol/library.TransferWithSigUtils.md: -------------------------------------------------------------------------------- 1 | # TransferWithSigUtils 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/predicates/TransferWithSigUtils.sol) 3 | 4 | 5 | ## Functions 6 | ### getTokenTransferOrderHash 7 | 8 | 9 | ```solidity 10 | function getTokenTransferOrderHash(address token, address spender, uint256 amount, bytes32 data, uint256 expiration) public pure returns (bytes32 orderHash); 11 | ``` 12 | 13 | ### hashTokenTransferOrder 14 | 15 | 16 | ```solidity 17 | function hashTokenTransferOrder(address spender, uint256 amount, bytes32 data, uint256 expiration) internal pure returns (bytes32 result); 18 | ``` 19 | 20 | ### hashEIP712Message 21 | 22 | 23 | ```solidity 24 | function hashEIP712Message(address token, bytes32 hashStruct) internal pure returns (bytes32 result); 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/stateSyncer/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [StateSender](StateSender.sol/contract.StateSender.md) 5 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/stateSyncer/StateSender.sol/contract.StateSender.md: -------------------------------------------------------------------------------- 1 | # StateSender 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/stateSyncer/StateSender.sol) 3 | 4 | **Inherits:** 5 | Ownable 6 | 7 | 8 | ## State Variables 9 | ### counter 10 | 11 | ```solidity 12 | uint256 public counter; 13 | ``` 14 | 15 | 16 | ### registrations 17 | 18 | ```solidity 19 | mapping(address => address) public registrations; 20 | ``` 21 | 22 | 23 | ## Functions 24 | ### onlyRegistered 25 | 26 | 27 | ```solidity 28 | modifier onlyRegistered(address receiver); 29 | ``` 30 | 31 | ### syncState 32 | 33 | 34 | ```solidity 35 | function syncState(address receiver, bytes calldata data) external onlyRegistered(receiver); 36 | ``` 37 | 38 | ### register 39 | 40 | 41 | ```solidity 42 | function register(address sender, address receiver) public; 43 | ``` 44 | 45 | ## Events 46 | ### NewRegistration 47 | 48 | ```solidity 49 | event NewRegistration(address indexed user, address indexed sender, address indexed receiver); 50 | ``` 51 | 52 | ### RegistrationUpdated 53 | 54 | ```solidity 55 | event RegistrationUpdated(address indexed user, address indexed sender, address indexed receiver); 56 | ``` 57 | 58 | ### StateSynced 59 | 60 | ```solidity 61 | event StateSynced(uint256 indexed id, address indexed contractAddress, bytes data); 62 | ``` 63 | 64 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/ExitNFT.sol/contract.ExitNFT.md: -------------------------------------------------------------------------------- 1 | # ExitNFT 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/withdrawManager/ExitNFT.sol) 3 | 4 | **Inherits:** 5 | ERC721 6 | 7 | 8 | ## State Variables 9 | ### registry 10 | 11 | ```solidity 12 | Registry internal registry; 13 | ``` 14 | 15 | 16 | ## Functions 17 | ### onlyWithdrawManager 18 | 19 | 20 | ```solidity 21 | modifier onlyWithdrawManager(); 22 | ``` 23 | 24 | ### constructor 25 | 26 | 27 | ```solidity 28 | constructor(address _registry) public; 29 | ``` 30 | 31 | ### mint 32 | 33 | 34 | ```solidity 35 | function mint(address _owner, uint256 _tokenId) external onlyWithdrawManager; 36 | ``` 37 | 38 | ### burn 39 | 40 | 41 | ```solidity 42 | function burn(uint256 _tokenId) external onlyWithdrawManager; 43 | ``` 44 | 45 | ### exists 46 | 47 | 48 | ```solidity 49 | function exists(uint256 tokenId) public view returns (bool); 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/IWithdrawManager.sol/contract.IWithdrawManager.md: -------------------------------------------------------------------------------- 1 | # IWithdrawManager 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/withdrawManager/IWithdrawManager.sol) 3 | 4 | 5 | ## Functions 6 | ### createExitQueue 7 | 8 | 9 | ```solidity 10 | function createExitQueue(address token) external; 11 | ``` 12 | 13 | ### verifyInclusion 14 | 15 | 16 | ```solidity 17 | function verifyInclusion(bytes calldata data, uint8 offset, bool verifyTxInclusion) external view returns (uint256 age); 18 | ``` 19 | 20 | ### addExitToQueue 21 | 22 | 23 | ```solidity 24 | function addExitToQueue( 25 | address exitor, 26 | address childToken, 27 | address rootToken, 28 | uint256 exitAmountOrTokenId, 29 | bytes32 txHash, 30 | bool isRegularExit, 31 | uint256 priority 32 | ) external; 33 | ``` 34 | 35 | ### addInput 36 | 37 | 38 | ```solidity 39 | function addInput(uint256 exitId, uint256 age, address utxoOwner, address token) external; 40 | ``` 41 | 42 | ### challengeExit 43 | 44 | 45 | ```solidity 46 | function challengeExit(uint256 exitId, uint256 inputId, bytes calldata challengeData, address adjudicatorPredicate) external; 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ExitNFT](ExitNFT.sol/contract.ExitNFT.md) 5 | - [IWithdrawManager](IWithdrawManager.sol/contract.IWithdrawManager.md) 6 | - [WithdrawManager](WithdrawManager.sol/contract.WithdrawManager.md) 7 | - [WithdrawManagerProxy](WithdrawManagerProxy.sol/contract.WithdrawManagerProxy.md) 8 | - [ExitsDataStructure](WithdrawManagerStorage.sol/contract.ExitsDataStructure.md) 9 | - [WithdrawManagerHeader](WithdrawManagerStorage.sol/contract.WithdrawManagerHeader.md) 10 | - [WithdrawManagerStorage](WithdrawManagerStorage.sol/contract.WithdrawManagerStorage.md) 11 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/WithdrawManagerProxy.sol/contract.WithdrawManagerProxy.md: -------------------------------------------------------------------------------- 1 | # WithdrawManagerProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/withdrawManager/WithdrawManagerProxy.sol) 3 | 4 | **Inherits:** 5 | [Proxy](/contracts/common/misc/Proxy.sol/contract.Proxy.md), [WithdrawManagerStorage](/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.WithdrawManagerStorage.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo, address _registry, address _rootChain, address _exitNft) public Proxy(_proxyTo); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.ExitsDataStructure.md: -------------------------------------------------------------------------------- 1 | # ExitsDataStructure 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/withdrawManager/WithdrawManagerStorage.sol) 3 | 4 | 5 | ## Structs 6 | ### Input 7 | 8 | ```solidity 9 | struct Input { 10 | address utxoOwner; 11 | address predicate; 12 | address token; 13 | } 14 | ``` 15 | 16 | ### PlasmaExit 17 | 18 | ```solidity 19 | struct PlasmaExit { 20 | uint256 receiptAmountOrNFTId; 21 | bytes32 txHash; 22 | address owner; 23 | address token; 24 | bool isRegularExit; 25 | address predicate; 26 | mapping(uint256 => Input) inputs; 27 | } 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.WithdrawManagerHeader.md: -------------------------------------------------------------------------------- 1 | # WithdrawManagerHeader 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/withdrawManager/WithdrawManagerStorage.sol) 3 | 4 | **Inherits:** 5 | [ExitsDataStructure](/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.ExitsDataStructure.md) 6 | 7 | 8 | ## Events 9 | ### Withdraw 10 | 11 | ```solidity 12 | event Withdraw(uint256 indexed exitId, address indexed user, address indexed token, uint256 amount); 13 | ``` 14 | 15 | ### ExitStarted 16 | 17 | ```solidity 18 | event ExitStarted(address indexed exitor, uint256 indexed exitId, address indexed token, uint256 amount, bool isRegularExit); 19 | ``` 20 | 21 | ### ExitUpdated 22 | 23 | ```solidity 24 | event ExitUpdated(uint256 indexed exitId, uint256 indexed age, address signer); 25 | ``` 26 | 27 | ### ExitPeriodUpdate 28 | 29 | ```solidity 30 | event ExitPeriodUpdate(uint256 indexed oldExitPeriod, uint256 indexed newExitPeriod); 31 | ``` 32 | 33 | ### ExitCancelled 34 | 35 | ```solidity 36 | event ExitCancelled(uint256 indexed exitId); 37 | ``` 38 | 39 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.WithdrawManagerStorage.md: -------------------------------------------------------------------------------- 1 | # WithdrawManagerStorage 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/root/withdrawManager/WithdrawManagerStorage.sol) 3 | 4 | **Inherits:** 5 | [ProxyStorage](/contracts/common/misc/ProxyStorage.sol/contract.ProxyStorage.md), [WithdrawManagerHeader](/contracts/root/withdrawManager/WithdrawManagerStorage.sol/contract.WithdrawManagerHeader.md) 6 | 7 | 8 | ## State Variables 9 | ### HALF_EXIT_PERIOD 10 | 11 | ```solidity 12 | uint256 public HALF_EXIT_PERIOD = 302_400; 13 | ``` 14 | 15 | 16 | ### BOND_AMOUNT 17 | 18 | ```solidity 19 | uint256 internal constant BOND_AMOUNT = 10 ** 17; 20 | ``` 21 | 22 | 23 | ### registry 24 | 25 | ```solidity 26 | Registry internal registry; 27 | ``` 28 | 29 | 30 | ### rootChain 31 | 32 | ```solidity 33 | RootChain internal rootChain; 34 | ``` 35 | 36 | 37 | ### isKnownExit 38 | 39 | ```solidity 40 | mapping(uint128 => bool) isKnownExit; 41 | ``` 42 | 43 | 44 | ### exits 45 | 46 | ```solidity 47 | mapping(uint256 => PlasmaExit) public exits; 48 | ``` 49 | 50 | 51 | ### ownerExits 52 | 53 | ```solidity 54 | mapping(bytes32 => uint256) public ownerExits; 55 | ``` 56 | 57 | 58 | ### exitsQueues 59 | 60 | ```solidity 61 | mapping(address => address) public exitsQueues; 62 | ``` 63 | 64 | 65 | ### exitNft 66 | 67 | ```solidity 68 | ExitNFT public exitNft; 69 | ``` 70 | 71 | 72 | ### ON_FINALIZE_GAS_LIMIT 73 | 74 | ```solidity 75 | uint32 public ON_FINALIZE_GAS_LIMIT = 300_000; 76 | ``` 77 | 78 | 79 | ### exitWindow 80 | 81 | ```solidity 82 | uint256 public exitWindow; 83 | ``` 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/EventsHub.sol/contract.IStakeManagerEventsHub.md: -------------------------------------------------------------------------------- 1 | # IStakeManagerEventsHub 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/EventsHub.sol) 3 | 4 | 5 | ## State Variables 6 | ### validators 7 | 8 | ```solidity 9 | mapping(uint256 => Validator) public validators; 10 | ``` 11 | 12 | 13 | ## Structs 14 | ### Validator 15 | 16 | ```solidity 17 | struct Validator { 18 | uint256 amount; 19 | uint256 reward; 20 | uint256 activationEpoch; 21 | uint256 deactivationEpoch; 22 | uint256 jailTime; 23 | address signer; 24 | address contractAddress; 25 | } 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/EventsHubProxy.sol/contract.EventsHubProxy.md: -------------------------------------------------------------------------------- 1 | # EventsHubProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/EventsHubProxy.sol) 3 | 4 | **Inherits:** 5 | [UpgradableProxy](/contracts/common/misc/UpgradableProxy.sol/contract.UpgradableProxy.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo) public UpgradableProxy(_proxyTo); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [slashing](/contracts/staking/slashing) 5 | - [stakeManager](/contracts/staking/stakeManager) 6 | - [validatorShare](/contracts/staking/validatorShare) 7 | - [IStakeManagerEventsHub](EventsHub.sol/contract.IStakeManagerEventsHub.md) 8 | - [EventsHub](EventsHub.sol/contract.EventsHub.md) 9 | - [EventsHubProxy](EventsHubProxy.sol/contract.EventsHubProxy.md) 10 | - [IStakeManagerLocal](StakingInfo.sol/contract.IStakeManagerLocal.md) 11 | - [StakingInfo](StakingInfo.sol/contract.StakingInfo.md) 12 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/StakingInfo.sol/contract.IStakeManagerLocal.md: -------------------------------------------------------------------------------- 1 | # IStakeManagerLocal 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/StakingInfo.sol) 3 | 4 | 5 | ## State Variables 6 | ### validators 7 | 8 | ```solidity 9 | mapping(uint256 => Validator) public validators; 10 | ``` 11 | 12 | 13 | ### accountStateRoot 14 | 15 | ```solidity 16 | bytes32 public accountStateRoot; 17 | ``` 18 | 19 | 20 | ### activeAmount 21 | 22 | ```solidity 23 | uint256 public activeAmount; 24 | ``` 25 | 26 | 27 | ### validatorRewards 28 | 29 | ```solidity 30 | uint256 public validatorRewards; 31 | ``` 32 | 33 | 34 | ## Functions 35 | ### currentValidatorSetTotalStake 36 | 37 | 38 | ```solidity 39 | function currentValidatorSetTotalStake() public view returns (uint256); 40 | ``` 41 | 42 | ### signerToValidator 43 | 44 | 45 | ```solidity 46 | function signerToValidator(address validatorAddress) public view returns (uint256); 47 | ``` 48 | 49 | ### isValidator 50 | 51 | 52 | ```solidity 53 | function isValidator(uint256 validatorId) public view returns (bool); 54 | ``` 55 | 56 | ## Structs 57 | ### Validator 58 | 59 | ```solidity 60 | struct Validator { 61 | uint256 amount; 62 | uint256 reward; 63 | uint256 activationEpoch; 64 | uint256 deactivationEpoch; 65 | uint256 jailTime; 66 | address signer; 67 | address contractAddress; 68 | Status status; 69 | } 70 | ``` 71 | 72 | ## Enums 73 | ### Status 74 | 75 | ```solidity 76 | enum Status { 77 | Inactive, 78 | Active, 79 | Locked, 80 | Unstaked 81 | } 82 | ``` 83 | 84 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/slashing/ISlashingManager.sol/contract.ISlashingManager.md: -------------------------------------------------------------------------------- 1 | # ISlashingManager 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/slashing/ISlashingManager.sol) 3 | 4 | 5 | ## State Variables 6 | ### heimdallId 7 | 8 | ```solidity 9 | bytes32 public heimdallId; 10 | ``` 11 | 12 | 13 | ### VOTE_TYPE 14 | 15 | ```solidity 16 | uint8 public constant VOTE_TYPE = 2; 17 | ``` 18 | 19 | 20 | ### reportRate 21 | 22 | ```solidity 23 | uint256 public reportRate = 5; 24 | ``` 25 | 26 | 27 | ### proposerRate 28 | 29 | ```solidity 30 | uint256 public proposerRate = 50; 31 | ``` 32 | 33 | 34 | ### jailCheckpoints 35 | 36 | ```solidity 37 | uint256 public jailCheckpoints = 5; 38 | ``` 39 | 40 | 41 | ### slashingNonce 42 | 43 | ```solidity 44 | uint256 public slashingNonce; 45 | ``` 46 | 47 | 48 | ### registry 49 | 50 | ```solidity 51 | Registry public registry; 52 | ``` 53 | 54 | 55 | ### logger 56 | 57 | ```solidity 58 | StakingInfo public logger; 59 | ``` 60 | 61 | 62 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/slashing/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ISlashingManager](ISlashingManager.sol/contract.ISlashingManager.md) 5 | - [SlashingManager](SlashingManager.sol/contract.SlashingManager.md) 6 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/slashing/SlashingManager.sol/contract.SlashingManager.md: -------------------------------------------------------------------------------- 1 | # SlashingManager 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/slashing/SlashingManager.sol) 3 | 4 | **Inherits:** 5 | [ISlashingManager](/contracts/staking/slashing/ISlashingManager.sol/contract.ISlashingManager.md), Ownable 6 | 7 | 8 | ## Functions 9 | ### onlyStakeManager 10 | 11 | 12 | ```solidity 13 | modifier onlyStakeManager(); 14 | ``` 15 | 16 | ### constructor 17 | 18 | 19 | ```solidity 20 | constructor(address _registry, address _logger, string memory _heimdallId) public; 21 | ``` 22 | 23 | ### updateSlashedAmounts 24 | 25 | 26 | ```solidity 27 | function updateSlashedAmounts(bytes memory data, bytes memory sigs) public; 28 | ``` 29 | 30 | ### verifyConsensus 31 | 32 | 33 | ```solidity 34 | function verifyConsensus(bytes32 voteHash, bytes memory sigs) public view returns (bool); 35 | ``` 36 | 37 | ### updateReportRate 38 | 39 | 40 | ```solidity 41 | function updateReportRate(uint256 newReportRate) public onlyOwner; 42 | ``` 43 | 44 | ### updateProposerRate 45 | 46 | 47 | ```solidity 48 | function updateProposerRate(uint256 newProposerRate) public onlyOwner; 49 | ``` 50 | 51 | ### setHeimdallId 52 | 53 | 54 | ```solidity 55 | function setHeimdallId(string memory _heimdallId) public onlyOwner; 56 | ``` 57 | 58 | ### drainTokens 59 | 60 | 61 | ```solidity 62 | function drainTokens(uint256 value, address token, address destination) external onlyOwner; 63 | ``` 64 | 65 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/stakeManager/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [IStakeManager](IStakeManager.sol/contract.IStakeManager.md) 5 | - [StakeManager](StakeManager.sol/contract.StakeManager.md) 6 | - [StakeManagerExtension](StakeManagerExtension.sol/contract.StakeManagerExtension.md) 7 | - [StakeManagerProxy](StakeManagerProxy.sol/contract.StakeManagerProxy.md) 8 | - [StakeManagerStorage](StakeManagerStorage.sol/contract.StakeManagerStorage.md) 9 | - [StakeManagerStorageExtension](StakeManagerStorageExtension.sol/contract.StakeManagerStorageExtension.md) 10 | - [StakingNFT](StakingNFT.sol/contract.StakingNFT.md) 11 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/stakeManager/StakeManagerExtension.sol/contract.StakeManagerExtension.md: -------------------------------------------------------------------------------- 1 | # StakeManagerExtension 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/stakeManager/StakeManagerExtension.sol) 3 | 4 | **Inherits:** 5 | [StakeManagerStorage](/contracts/staking/stakeManager/StakeManagerStorage.sol/contract.StakeManagerStorage.md), [Initializable](/contracts/common/mixin/Initializable.sol/contract.Initializable.md), [StakeManagerStorageExtension](/contracts/staking/stakeManager/StakeManagerStorageExtension.sol/contract.StakeManagerStorageExtension.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public GovernanceLockable(address(0x0)); 14 | ``` 15 | 16 | ### startAuction 17 | 18 | 19 | ```solidity 20 | function startAuction(uint256 validatorId, uint256 amount, bool _acceptDelegation, bytes calldata _signerPubkey) external; 21 | ``` 22 | 23 | ### confirmAuctionBid 24 | 25 | 26 | ```solidity 27 | function confirmAuctionBid(uint256 validatorId, uint256 heimdallFee, IStakeManager stakeManager) external; 28 | ``` 29 | 30 | ### migrateValidatorsData 31 | 32 | 33 | ```solidity 34 | function migrateValidatorsData(uint256 validatorIdFrom, uint256 validatorIdTo) external; 35 | ``` 36 | 37 | ### updateCheckpointRewardParams 38 | 39 | 40 | ```solidity 41 | function updateCheckpointRewardParams(uint256 _rewardDecreasePerCheckpoint, uint256 _maxRewardedCheckpoints, uint256 _checkpointRewardDelta) external; 42 | ``` 43 | 44 | ### updateCommissionRate 45 | 46 | 47 | ```solidity 48 | function updateCommissionRate(uint256 validatorId, uint256 newCommissionRate) external; 49 | ``` 50 | 51 | ### _getOrCacheEventsHub 52 | 53 | 54 | ```solidity 55 | function _getOrCacheEventsHub() private returns (EventsHub); 56 | ``` 57 | 58 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/stakeManager/StakeManagerProxy.sol/contract.StakeManagerProxy.md: -------------------------------------------------------------------------------- 1 | # StakeManagerProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/stakeManager/StakeManagerProxy.sol) 3 | 4 | **Inherits:** 5 | [UpgradableProxy](/contracts/common/misc/UpgradableProxy.sol/contract.UpgradableProxy.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _proxyTo) public UpgradableProxy(_proxyTo); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/stakeManager/StakeManagerStorageExtension.sol/contract.StakeManagerStorageExtension.md: -------------------------------------------------------------------------------- 1 | # StakeManagerStorageExtension 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/stakeManager/StakeManagerStorageExtension.sol) 3 | 4 | 5 | ## State Variables 6 | ### eventsHub 7 | 8 | ```solidity 9 | address public eventsHub; 10 | ``` 11 | 12 | 13 | ### rewardPerStake 14 | 15 | ```solidity 16 | uint256 public rewardPerStake; 17 | ``` 18 | 19 | 20 | ### extensionCode 21 | 22 | ```solidity 23 | address public extensionCode; 24 | ``` 25 | 26 | 27 | ### signers 28 | 29 | ```solidity 30 | address[] public signers; 31 | ``` 32 | 33 | 34 | ### CHK_REWARD_PRECISION 35 | 36 | ```solidity 37 | uint256 constant CHK_REWARD_PRECISION = 100; 38 | ``` 39 | 40 | 41 | ### prevBlockInterval 42 | 43 | ```solidity 44 | uint256 public prevBlockInterval; 45 | ``` 46 | 47 | 48 | ### rewardDecreasePerCheckpoint 49 | 50 | ```solidity 51 | uint256 public rewardDecreasePerCheckpoint; 52 | ``` 53 | 54 | 55 | ### maxRewardedCheckpoints 56 | 57 | ```solidity 58 | uint256 public maxRewardedCheckpoints; 59 | ``` 60 | 61 | 62 | ### checkpointRewardDelta 63 | 64 | ```solidity 65 | uint256 public checkpointRewardDelta; 66 | ``` 67 | 68 | 69 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/stakeManager/StakingNFT.sol/contract.StakingNFT.md: -------------------------------------------------------------------------------- 1 | # StakingNFT 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/stakeManager/StakingNFT.sol) 3 | 4 | **Inherits:** 5 | ERC721Full, Ownable 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(string memory name, string memory symbol) public ERC721Full(name, symbol); 14 | ``` 15 | 16 | ### mint 17 | 18 | 19 | ```solidity 20 | function mint(address to, uint256 tokenId) public onlyOwner; 21 | ``` 22 | 23 | ### burn 24 | 25 | 26 | ```solidity 27 | function burn(uint256 tokenId) public onlyOwner; 28 | ``` 29 | 30 | ### _transferFrom 31 | 32 | 33 | ```solidity 34 | function _transferFrom(address from, address to, uint256 tokenId) internal; 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/validatorShare/IValidatorShare.sol/contract.IValidatorShare.md: -------------------------------------------------------------------------------- 1 | # IValidatorShare 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/validatorShare/IValidatorShare.sol) 3 | 4 | 5 | ## Functions 6 | ### withdrawRewards 7 | 8 | 9 | ```solidity 10 | function withdrawRewards() public; 11 | ``` 12 | 13 | ### unstakeClaimTokens 14 | 15 | 16 | ```solidity 17 | function unstakeClaimTokens() public; 18 | ``` 19 | 20 | ### getLiquidRewards 21 | 22 | 23 | ```solidity 24 | function getLiquidRewards(address user) public view returns (uint256); 25 | ``` 26 | 27 | ### owner 28 | 29 | 30 | ```solidity 31 | function owner() public view returns (address); 32 | ``` 33 | 34 | ### restake 35 | 36 | 37 | ```solidity 38 | function restake() public returns (uint256, uint256); 39 | ``` 40 | 41 | ### unlock 42 | 43 | 44 | ```solidity 45 | function unlock() external; 46 | ``` 47 | 48 | ### lock 49 | 50 | 51 | ```solidity 52 | function lock() external; 53 | ``` 54 | 55 | ### drain 56 | 57 | 58 | ```solidity 59 | function drain(address token, address payable destination, uint256 amount) external; 60 | ``` 61 | 62 | ### slash 63 | 64 | 65 | ```solidity 66 | function slash(uint256 valPow, uint256 delegatedAmount, uint256 totalAmountToSlash) external returns (uint256); 67 | ``` 68 | 69 | ### updateDelegation 70 | 71 | 72 | ```solidity 73 | function updateDelegation(bool delegation) external; 74 | ``` 75 | 76 | ### migrateOut 77 | 78 | 79 | ```solidity 80 | function migrateOut(address user, uint256 amount) external; 81 | ``` 82 | 83 | ### migrateIn 84 | 85 | 86 | ```solidity 87 | function migrateIn(address user, uint256 amount) external; 88 | ``` 89 | 90 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/validatorShare/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [IValidatorShare](IValidatorShare.sol/contract.IValidatorShare.md) 5 | - [ValidatorShare](ValidatorShare.sol/contract.ValidatorShare.md) 6 | - [ValidatorShareFactory](ValidatorShareFactory.sol/contract.ValidatorShareFactory.md) 7 | - [ValidatorShareProxy](ValidatorShareProxy.sol/contract.ValidatorShareProxy.md) 8 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/validatorShare/ValidatorShareFactory.sol/contract.ValidatorShareFactory.md: -------------------------------------------------------------------------------- 1 | # ValidatorShareFactory 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/validatorShare/ValidatorShareFactory.sol) 3 | 4 | 5 | ## Functions 6 | ### create 7 | 8 | - factory to create new validatorShare contracts 9 | 10 | 11 | ```solidity 12 | function create(uint256 validatorId, address loggerAddress, address registry) public returns (address); 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/staking/validatorShare/ValidatorShareProxy.sol/contract.ValidatorShareProxy.md: -------------------------------------------------------------------------------- 1 | # ValidatorShareProxy 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/staking/validatorShare/ValidatorShareProxy.sol) 3 | 4 | **Inherits:** 5 | [UpgradableProxy](/contracts/common/misc/UpgradableProxy.sol/contract.UpgradableProxy.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address _registry) public UpgradableProxy(_registry); 14 | ``` 15 | 16 | ### loadImplementation 17 | 18 | 19 | ```solidity 20 | function loadImplementation() internal view returns (address); 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/ContractActor.sol/contract.ContractWitRevertingFallback.md: -------------------------------------------------------------------------------- 1 | # ContractWitRevertingFallback 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/ContractActor.sol) 3 | 4 | 5 | ## Functions 6 | ### deposit 7 | 8 | 9 | ```solidity 10 | function deposit(address depositManager, address token, uint256 amount) public; 11 | ``` 12 | 13 | ### startExitWithDepositedTokens 14 | 15 | 16 | ```solidity 17 | function startExitWithDepositedTokens(address payable withdrawManager, uint256 depositId, address token, uint256 amountOrToken) public payable; 18 | ``` 19 | 20 | ### function 21 | 22 | 23 | ```solidity 24 | function() external payable; 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/ContractActor.sol/contract.ContractWithFallback.md: -------------------------------------------------------------------------------- 1 | # ContractWithFallback 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/ContractActor.sol) 3 | 4 | 5 | ## Functions 6 | ### deposit 7 | 8 | 9 | ```solidity 10 | function deposit(address depositManager, address token, uint256 amount) public; 11 | ``` 12 | 13 | ### startExitWithDepositedTokens 14 | 15 | 16 | ```solidity 17 | function startExitWithDepositedTokens(address payable withdrawManager, uint256 depositId, address token, uint256 amountOrToken) public payable; 18 | ``` 19 | 20 | ### function 21 | 22 | 23 | ```solidity 24 | function() external payable; 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/ContractActor.sol/contract.ContractWithoutFallback.md: -------------------------------------------------------------------------------- 1 | # ContractWithoutFallback 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/ContractActor.sol) 3 | 4 | 5 | ## Functions 6 | ### deposit 7 | 8 | 9 | ```solidity 10 | function deposit(address depositManager, address token, uint256 amount) public; 11 | ``` 12 | 13 | ### startExitWithDepositedTokens 14 | 15 | 16 | ```solidity 17 | function startExitWithDepositedTokens(address payable withdrawManager, uint256 depositId, address token, uint256 amountOrToken) public payable; 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/GovernanceLockableTest.sol/contract.GovernanceLockableTest.md: -------------------------------------------------------------------------------- 1 | # GovernanceLockableTest 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/GovernanceLockableTest.sol) 3 | 4 | **Inherits:** 5 | [GovernanceLockable](/contracts/common/mixin/GovernanceLockable.sol/contract.GovernanceLockable.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor(address governance) public GovernanceLockable(governance); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/MarketplacePredicateTest.sol/contract.MarketplacePredicateTest.md: -------------------------------------------------------------------------------- 1 | # MarketplacePredicateTest 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/MarketplacePredicateTest.sol) 3 | 4 | **Inherits:** 5 | [MarketplacePredicate](/contracts/root/predicates/MarketplacePredicate.sol/contract.MarketplacePredicate.md) 6 | 7 | 8 | ## Functions 9 | ### constructor 10 | 11 | 12 | ```solidity 13 | constructor() public MarketplacePredicate(address(0x0), address(0x0), address(0x0)); 14 | ``` 15 | 16 | ### processLogTransferReceiptTest 17 | 18 | 19 | ```solidity 20 | function processLogTransferReceiptTest(address predicate, bytes memory data, address participant) public view returns (bytes memory b); 21 | ``` 22 | 23 | ### processExitTx 24 | 25 | 26 | ```solidity 27 | function processExitTx(bytes memory exitTx) public view returns (bytes memory b); 28 | ``` 29 | 30 | ### testGetAddressFromTx 31 | 32 | 33 | ```solidity 34 | function testGetAddressFromTx(bytes memory exitTx) public pure returns (address signer, bytes32 txHash); 35 | ``` 36 | 37 | ### decodeExitTx 38 | 39 | 40 | ```solidity 41 | function decodeExitTx(bytes memory exitTx) internal pure returns (ExitTxData memory txData); 42 | ``` 43 | 44 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/PolygonMigrationTest.sol/contract.PolygonMigrationTest.md: -------------------------------------------------------------------------------- 1 | # PolygonMigrationTest 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/PolygonMigrationTest.sol) 3 | 4 | 5 | ## State Variables 6 | ### polygon 7 | 8 | ```solidity 9 | IERC20 public polygon; 10 | ``` 11 | 12 | 13 | ### matic 14 | 15 | ```solidity 16 | IERC20 public matic; 17 | ``` 18 | 19 | 20 | ## Functions 21 | ### setTokenAddresses 22 | 23 | 24 | ```solidity 25 | function setTokenAddresses(address matic_, address polygon_) external; 26 | ``` 27 | 28 | ### migrate 29 | 30 | This function allows for migrating MATIC tokens to POL tokens 31 | 32 | *The function does not do any validation since the migration is a one-way process* 33 | 34 | 35 | ```solidity 36 | function migrate(uint256 amount) external; 37 | ``` 38 | **Parameters** 39 | 40 | |Name|Type|Description| 41 | |----|----|-----------| 42 | |`amount`|`uint256`|Amount of MATIC to migrate| 43 | 44 | 45 | ## Events 46 | ### Migrated 47 | 48 | ```solidity 49 | event Migrated(address indexed account, uint256 amount); 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/Proxy/ProxyTestImpl.sol/contract.ProxyTestImpl.md: -------------------------------------------------------------------------------- 1 | # ProxyTestImpl 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/Proxy/ProxyTestImpl.sol) 3 | 4 | **Inherits:** 5 | [Initializable](/contracts/common/mixin/Initializable.sol/contract.Initializable.md) 6 | 7 | 8 | ## State Variables 9 | ### a 10 | 11 | ```solidity 12 | uint256 public a = 1; 13 | ``` 14 | 15 | 16 | ### b 17 | 18 | ```solidity 19 | uint256 public b = 2; 20 | ``` 21 | 22 | 23 | ### ctorInit 24 | 25 | ```solidity 26 | uint256 public ctorInit; 27 | ``` 28 | 29 | 30 | ## Functions 31 | ### constructor 32 | 33 | 34 | ```solidity 35 | constructor() public; 36 | ``` 37 | 38 | ### init 39 | 40 | 41 | ```solidity 42 | function init() public initializer; 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/Proxy/ProxyTestImplStorageLayoutChange.sol/contract.ProxyTestImplStorageLayoutChange.md: -------------------------------------------------------------------------------- 1 | # ProxyTestImplStorageLayoutChange 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/Proxy/ProxyTestImplStorageLayoutChange.sol) 3 | 4 | **Inherits:** 5 | [Initializable](/contracts/common/mixin/Initializable.sol/contract.Initializable.md) 6 | 7 | 8 | ## State Variables 9 | ### b 10 | 11 | ```solidity 12 | uint256 public b; 13 | ``` 14 | 15 | 16 | ### a 17 | 18 | ```solidity 19 | uint256 public a; 20 | ``` 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/Proxy/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [ProxyTestImpl](ProxyTestImpl.sol/contract.ProxyTestImpl.md) 5 | - [ProxyTestImplStorageLayoutChange](ProxyTestImplStorageLayoutChange.sol/contract.ProxyTestImplStorageLayoutChange.md) 6 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contents 4 | - [Proxy](/contracts/test/Proxy) 5 | - [ContractWithFallback](ContractActor.sol/contract.ContractWithFallback.md) 6 | - [ContractWithoutFallback](ContractActor.sol/contract.ContractWithoutFallback.md) 7 | - [ContractWitRevertingFallback](ContractActor.sol/contract.ContractWitRevertingFallback.md) 8 | - [GovernanceLockableTest](GovernanceLockableTest.sol/contract.GovernanceLockableTest.md) 9 | - [MarketplacePredicateTest](MarketplacePredicateTest.sol/contract.MarketplacePredicateTest.md) 10 | - [PolygonMigrationTest](PolygonMigrationTest.sol/contract.PolygonMigrationTest.md) 11 | - [StakeManagerTest](StakeManagerTest.sol/contract.StakeManagerTest.md) 12 | - [StakeManagerTestable](StakeManagerTestable.sol/contract.StakeManagerTestable.md) 13 | - [TestMRC20](TestMaticChildERC20.sol/contract.TestMRC20.md) 14 | - [ValidatorShareTest](ValidatorShareTest.sol/contract.ValidatorShareTest.md) 15 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/StakeManagerTest.sol/contract.StakeManagerTest.md: -------------------------------------------------------------------------------- 1 | # StakeManagerTest 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/StakeManagerTest.sol) 3 | 4 | **Inherits:** 5 | [StakeManager](/contracts/staking/stakeManager/StakeManager.sol/contract.StakeManager.md) 6 | 7 | 8 | ## Functions 9 | ### checkSignatures 10 | 11 | 12 | ```solidity 13 | function checkSignatures(uint256 blockInterval, bytes32 voteHash, bytes32 stateRoot, address proposer, uint256[3][] calldata sigs) 14 | external 15 | onlyRootChain 16 | returns (uint256); 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/StakeManagerTestable.sol/contract.StakeManagerTestable.md: -------------------------------------------------------------------------------- 1 | # StakeManagerTestable 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/StakeManagerTestable.sol) 3 | 4 | **Inherits:** 5 | [StakeManager](/contracts/staking/stakeManager/StakeManager.sol/contract.StakeManager.md) 6 | 7 | 8 | ## Functions 9 | ### advanceEpoch 10 | 11 | 12 | ```solidity 13 | function advanceEpoch(uint256 delta) public; 14 | ``` 15 | 16 | ### testLockShareContract 17 | 18 | 19 | ```solidity 20 | function testLockShareContract(uint256 validatorId, bool lock) public; 21 | ``` 22 | 23 | ### forceFinalizeCommit 24 | 25 | 26 | ```solidity 27 | function forceFinalizeCommit() public; 28 | ``` 29 | 30 | ### resetSignerUsed 31 | 32 | 33 | ```solidity 34 | function resetSignerUsed(address signer) public; 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/TestMaticChildERC20.sol/contract.TestMRC20.md: -------------------------------------------------------------------------------- 1 | # TestMRC20 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/TestMaticChildERC20.sol) 3 | 4 | **Inherits:** 5 | [MRC20](/contracts/child/MRC20.sol/contract.MRC20.md) 6 | 7 | 8 | ## Functions 9 | ### function 10 | 11 | 12 | ```solidity 13 | function() external payable; 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /docs/autogen/src/contracts/test/ValidatorShareTest.sol/contract.ValidatorShareTest.md: -------------------------------------------------------------------------------- 1 | # ValidatorShareTest 2 | [Git Source](https://github.com/maticnetwork/contracts/blob/155f729fd8db0676297384375468d4d45b8aa44e/contracts/test/ValidatorShareTest.sol) 3 | 4 | **Inherits:** 5 | [ValidatorShare](/contracts/staking/validatorShare/ValidatorShare.sol/contract.ValidatorShare.md) 6 | 7 | 8 | ## Functions 9 | ### amountStaked 10 | 11 | 12 | ```solidity 13 | function amountStaked(address user) public view returns (uint256); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'contracts' 3 | out = 'out' 4 | libs = ['node_modules'] 5 | match-path = 'test/foundry' 6 | optimizer = true 7 | optimizer_runs = 200 8 | via_ir = true 9 | cache_path = 'forge-cache' 10 | verbosity = 2 11 | solc_version = '0.5.17' 12 | ffi = true 13 | 14 | remappings = [ 15 | "openzeppelin-solidity/=node_modules/openzeppelin-solidity/", 16 | "solidity-rlp/=node_modules/solidity-rlp/" 17 | ] 18 | 19 | [invariant] 20 | fail_on_revert = false 21 | call_override = false 22 | dictionary_weight = 80 23 | include_storage = true 24 | include_push_bytes = true 25 | 26 | [profile.intense.fuzz] 27 | runs = 10000 28 | max_test_rejects = 999999 29 | 30 | [fmt] 31 | line_length = 160 32 | number_underscore = "thousands" 33 | 34 | [rpc_endpoints] 35 | anvil = "http://127.0.0.1:8545" 36 | mainnet = "https://mainnet.infura.io/v3/${INFURA_KEY}" 37 | goerli = "https://goerli.infura.io/v3/${INFURA_KEY}" 38 | sepolia = "https://sepolia.infura.io/v3/${INFURA_KEY}" 39 | polygon_pos = "https://polygon-mainnet.infura.io/v3/${INFURA_KEY}" 40 | mumbai = "https://polygon-mumbai.infura.io/v3/${INFURA_KEY}" 41 | polygon_zkevm = "https://zkevm-rpc.com" 42 | polygon_zkevm_testnet = "https://rpc.public.zkevm-test.net" 43 | 44 | [etherscan] 45 | mainnet = { key = "${ETHERSCAN_API_KEY}" } 46 | goerli = { key = "${ETHERSCAN_API_KEY}" } 47 | sepolia = { key = "${ETHERSCAN_API_KEY}" } 48 | polygon_pos = { key = "${POLYGONSCAN_API_KEY}" } 49 | mumbai = { key = "${POLYGONSCAN_API_KEY}" } 50 | polygon_zkevm = { key = "${POLYGONSCAN_ZKEVM_API_KEY}" } 51 | polygon_zkevm_testnet = { key = "${POLYGONSCAN_ZKEVM_API_KEY}" } 52 | 53 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config -------------------------------------------------------------------------------- /scripts/deployers/CounterDeployer.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | //////////////////////////////////////////////////// 5 | // AUTOGENERATED - DO NOT EDIT THIS FILE DIRECTLY // 6 | //////////////////////////////////////////////////// 7 | 8 | import "forge-std/Script.sol"; 9 | 10 | import "src/Counter.sol"; 11 | import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; 12 | import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; 13 | 14 | abstract contract CounterDeployer is Script { 15 | Counter internal counter; 16 | ProxyAdmin internal counterProxyAdmin; 17 | address internal counterImplementation; 18 | 19 | function deployCounterTransparent(address proxyAdminOwner, uint256 initialNumber) 20 | internal 21 | returns (address implementation, address proxyAdmin, address proxy) 22 | { 23 | bytes memory initData = abi.encodeCall(Counter.initialize, (initialNumber)); 24 | 25 | vm.startBroadcast(vm.envUint("PRIVATE_KEY")); 26 | 27 | counterImplementation = address(new Counter()); 28 | counter = Counter(address(new TransparentUpgradeableProxy(counterImplementation, proxyAdminOwner, initData))); 29 | 30 | vm.stopBroadcast(); 31 | 32 | counterProxyAdmin = 33 | ProxyAdmin(address(uint160(uint256(vm.load(address(counter), hex"b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"))))); 34 | 35 | return (counterImplementation, address(counterProxyAdmin), address(counter)); 36 | } 37 | 38 | function deployCounterImplementation() internal returns (address implementation) { 39 | vm.startBroadcast(vm.envUint("PRIVATE_KEY")); 40 | implementation = address(new Counter()); 41 | vm.stopBroadcast(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /scripts/process-templates.cjs: -------------------------------------------------------------------------------- 1 | const program = require("commander"); 2 | const nunjucks = require("nunjucks"); 3 | const glob = require("glob"); 4 | const fs = require("fs"); 5 | const path = require("path"); 6 | 7 | program.version("0.0.1"); 8 | program.option("-c, --bor-chain-id ", "Bor chain id", "15001"); 9 | program.parse(process.argv); 10 | 11 | //joining path of directory 12 | const directoryPath = path.join(__dirname, "..", "**/*.template"); 13 | //passsing directoryPath and callback function 14 | glob(directoryPath, function (err, files) { 15 | //handling error 16 | if (err) { 17 | return console.log("Unable to scan directory: " + err); 18 | } 19 | 20 | //listing all files using forEach 21 | files.forEach(function (file) { 22 | // Do whatever you want to do with the file 23 | const borChainIdHex = parseInt(program.borChainId, 10) 24 | .toString(16) 25 | .toUpperCase(); 26 | 27 | const data = { 28 | borChainId: program.borChainId, 29 | borChainIdHex: 30 | borChainIdHex.length % 2 !== 0 ? `0${borChainIdHex}` : borChainIdHex, 31 | }; 32 | 33 | const templateString = fs.readFileSync(file).toString(); 34 | const resultString = nunjucks.renderString(templateString, data); 35 | fs.writeFileSync(file.replace(".template", ""), resultString); 36 | }); 37 | 38 | console.log("All template files have been processed."); 39 | }); 40 | -------------------------------------------------------------------------------- /scripts/run-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit script as soon as a command fails. 4 | set -o errexit 5 | 6 | # Executes cleanup function at script exit. 7 | trap cleanup EXIT 8 | 9 | # get current directory 10 | PWD=$(pwd) 11 | 12 | cleanup() { 13 | echo "Cleaning up" 14 | pkill -f ganache 15 | cd $PWD/test-bor-docker 16 | bash stop-docker.sh 17 | cd .. 18 | echo "Done" 19 | } 20 | 21 | start_testrpc() { 22 | npm run testrpc > /dev/null & 23 | } 24 | 25 | start_blockchain() { 26 | cd $PWD/test-bor-docker 27 | bash run-docker.sh 28 | cd .. 29 | } 30 | 31 | 32 | echo "Starting our own testrpc instance" 33 | start_testrpc 34 | 35 | echo "Starting our own geth instance" 36 | start_blockchain 37 | 38 | export LOCAL_NETWORK=true 39 | npm run coverage "$@" 40 | npm run test:hardhat "$@" 41 | -------------------------------------------------------------------------------- /scripts/util/doc_gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | foundryup 4 | # generate docs 5 | forge doc -b -o docs/autogen 6 | 7 | # Unstage all docs where only the commit hash changed 8 | # Get a list of all unstaged files in the directory 9 | files=$(git diff --name-only -- 'docs/autogen/*') 10 | 11 | # Loop over each file 12 | for file in $files; do 13 | # Get the diff for the file, only lines that start with - or + 14 | diff=$(git diff $file | grep '^[+-][^+-]') 15 | # Check if there are any other changes in the diff besides the commit hash (in that case the file has more than 1 line that changed, one minus one plus) 16 | if [[ $(echo "$diff" | wc -l) -eq 2 ]]; then 17 | # If there are no other changes, discard the changes for the file 18 | git reset HEAD $file 19 | git checkout -- $file 20 | fi 21 | done -------------------------------------------------------------------------------- /slither.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "filter_paths": "(lib/|test/|scripts/)" 3 | } 4 | -------------------------------------------------------------------------------- /test-bor-docker/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | CWD=$PWD 4 | 5 | # pkill -f geth 6 | 7 | rm -rf $CWD/data 8 | -------------------------------------------------------------------------------- /test-bor-docker/keystore/0_9fb29aac15b9a4b7f17c3385939b007540f4d791: -------------------------------------------------------------------------------- 1 | {"version":3,"id":"19fd8653-e681-4b48-bcbe-7258fffd576e","address":"9fb29aac15b9a4b7f17c3385939b007540f4d791","crypto":{"ciphertext":"cc5c4e4b039fee14bed896e818786fcc75647c6ed042a698c83134a5d3abd559","cipherparams":{"iv":"3d4ce2b60f2ad6f017ce70c1400220ee"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"7dd0972d90dafbb8a5dc139c4f138d5607026d21c50564496f4e560eb46c84b0","n":262144,"r":8,"p":1},"mac":"2a757ac9e1a594bd8bc6b8632f17af995ab4126e05113e1bb5e6bf9bf92f5de0"}} 2 | -------------------------------------------------------------------------------- /test-bor-docker/keystore/1_96c42c56fdb78294f96b0cfa33c92bed7d75f96a: -------------------------------------------------------------------------------- 1 | {"version":3,"id":"2ef581c0-4a37-4b5b-ab69-7ae547a4f08e","address":"96c42c56fdb78294f96b0cfa33c92bed7d75f96a","crypto":{"ciphertext":"397df1a2d4a5eebf78ac7c3b8d36809be5c270bd4c7f232eefafddf7d3bd4141","cipherparams":{"iv":"4fac67f95a0fecefdaff3c2227dad759"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"bf74edcd3f6d1d3e95ca4fad9b0505c5aab5b6af5b573ee67403ec306d5b6077","n":262144,"r":8,"p":1},"mac":"5546177dd4850b11987636e0507f1585a62569124f9e43606ebbbf347270820c"}} 2 | -------------------------------------------------------------------------------- /test-bor-docker/password.txt: -------------------------------------------------------------------------------- 1 | OqnV*12q$ 2 | OqnV*12q$ 3 | -------------------------------------------------------------------------------- /test-bor-docker/run-docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | docker run --name bor-test -it -d -p 9545:9545 -v $(pwd):/bordata maticnetwork/bor:v0.2.8 /bin/sh -c "cd /bordata; sh start.sh" 4 | -------------------------------------------------------------------------------- /test-bor-docker/start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | BOR=bor 4 | DIR=$PWD 5 | 6 | mkdir $DIR/data 7 | $BOR --datadir $DIR/data init $DIR/genesis.json 8 | cp -rf $DIR/keystore $DIR/data/ 9 | 10 | $BOR --datadir $DIR/data \ 11 | --port 30303 \ 12 | --http --http.addr '0.0.0.0' \ 13 | --http.vhosts '*' \ 14 | --http.corsdomain '*' \ 15 | --http.port 9545 \ 16 | --ipcdisable \ 17 | --http.api 'personal,db,eth,net,web3,txpool,miner,admin,bor' \ 18 | --syncmode 'full' \ 19 | --networkid '15001' \ 20 | --unlock '0x9fb29aac15b9a4b7f17c3385939b007540f4d791, 0x96C42C56fdb78294F96B0cFa33c92bed7D75F96a' \ 21 | --password $DIR/password.txt \ 22 | --allow-insecure-unlock \ 23 | --miner.gastarget '20000000' \ 24 | --miner.gaslimit '20000000' \ 25 | --bor.withoutheimdall \ 26 | --mine 27 | -------------------------------------------------------------------------------- /test-bor-docker/start.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | BOR=bor 4 | DIR=$PWD 5 | 6 | mkdir $DIR/data 7 | $BOR --datadir $DIR/data init $DIR/genesis.json 8 | cp -rf $DIR/keystore $DIR/data/ 9 | 10 | $BOR --datadir $DIR/data \ 11 | --port 30303 \ 12 | --http --http.addr '0.0.0.0' \ 13 | --http.vhosts '*' \ 14 | --http.corsdomain '*' \ 15 | --http.port 9545 \ 16 | --ipcdisable \ 17 | --http.api 'personal,db,eth,net,web3,txpool,miner,admin,bor' \ 18 | --syncmode 'full' \ 19 | --networkid '{{ borChainId }}' \ 20 | --unlock '0x9fb29aac15b9a4b7f17c3385939b007540f4d791, 0x96C42C56fdb78294F96B0cFa33c92bed7D75F96a' \ 21 | --password $DIR/password.txt \ 22 | --allow-insecure-unlock \ 23 | --miner.gastarget '20000000' \ 24 | --miner.gaslimit '20000000' \ 25 | --bor.withoutheimdall \ 26 | --mine 27 | -------------------------------------------------------------------------------- /test-bor-docker/stop-docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | docker stop bor-test 4 | docker rm bor-test 5 | -------------------------------------------------------------------------------- /test-bor-docker/stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | CWD=$PWD 4 | 5 | pkill -f geth 6 | -------------------------------------------------------------------------------- /test/helpers/blocks.js: -------------------------------------------------------------------------------- 1 | import ethUtils from 'ethereumjs-util' 2 | import { Buffer } from 'safe-buffer' 3 | 4 | const sha3 = ethUtils.keccak256 5 | const BN = ethUtils.BN 6 | 7 | export async function getHeaders(start, end, web3) { 8 | if (start >= end) { 9 | return [] 10 | } 11 | 12 | let current = start 13 | let p = [] 14 | let result = [] 15 | while (current <= end) { 16 | p = [] 17 | 18 | for (let i = 0; i < 10 && current <= end; i++) { 19 | p.push(web3.eth.getBlock(current)) 20 | current++ 21 | } 22 | 23 | if (p.length > 0) { 24 | result.push(...(await Promise.all(p))) 25 | } 26 | } 27 | 28 | return result.map(getBlockHeader) 29 | } 30 | 31 | export function getBlockHeader(block) { 32 | const n = new BN(block.number).toArrayLike(Buffer, 'be', 32) 33 | const ts = new BN(block.timestamp).toArrayLike(Buffer, 'be', 32) 34 | const txRoot = ethUtils.toBuffer(block.transactionsRoot) 35 | const receiptsRoot = ethUtils.toBuffer(block.receiptsRoot) 36 | return sha3(Buffer.concat([n, ts, txRoot, receiptsRoot])) 37 | } 38 | -------------------------------------------------------------------------------- /test/helpers/chain.js: -------------------------------------------------------------------------------- 1 | export function increaseBlockTime(seconds) { 2 | return web3.currentProvider.send( 3 | { 4 | jsonrpc: '2.0', 5 | method: 'evm_increaseTime', 6 | params: [seconds], 7 | id: new Date().getTime() 8 | }, 9 | () => {} 10 | ) 11 | } 12 | export function mineOneBlock() { 13 | return web3.currentProvider.send( 14 | { 15 | jsonrpc: '2.0', 16 | method: 'evm_mine', 17 | id: new Date().getTime() 18 | }, 19 | () => {} 20 | ) 21 | } 22 | -------------------------------------------------------------------------------- /test/helpers/log-decoder.js: -------------------------------------------------------------------------------- 1 | export class LogDecoder { 2 | decodeLogs(logs, ...contractInterfaces) { 3 | contractInterfaces.forEach((contractInterface) => { 4 | logs = logs.map((log) => { 5 | try { 6 | const parsedLog = contractInterface.parseLog(log) 7 | return { 8 | address: log.address.toLowerCase(), 9 | event: parsedLog.name, 10 | signature: parsedLog.signature, 11 | args: parsedLog.args 12 | } 13 | } catch (e) { 14 | return log 15 | } 16 | }) 17 | }) 18 | return logs 19 | } 20 | } 21 | 22 | const logDecoder = new LogDecoder() 23 | export default logDecoder 24 | -------------------------------------------------------------------------------- /test/helpers/wallets.js: -------------------------------------------------------------------------------- 1 | import bip39 from 'bip39' 2 | import wallet from 'ethereumjs-wallet' 3 | import fs from 'fs'; 4 | 5 | function readJSON (path) { 6 | return JSON.parse(fs.readFileSync(path)); 7 | } 8 | 9 | const config = readJSON('package.json').config 10 | 11 | export const mnemonics = config.mnemonics 12 | export function generateFirstWallets(mnemonics, n, hdPathIndex = 0) { 13 | const hdwallet = wallet.hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonics)) 14 | const result = [] 15 | for (let i = 0; i < n; i++) { 16 | const node = hdwallet.derivePath(`m/44'/60'/0'/0/${i + hdPathIndex}`) 17 | result.push(node.getWallet()) 18 | } 19 | 20 | return result 21 | } 22 | -------------------------------------------------------------------------------- /test/integration/root/DepositManager.test.js: -------------------------------------------------------------------------------- 1 | import * as chai from 'chai' 2 | import chaiAsPromised from 'chai-as-promised' 3 | import deployer from '../../helpers/deployer.js' 4 | import * as utils from '../../helpers/utils.js' 5 | import crypto from 'crypto' 6 | 7 | chai.use(chaiAsPromised).should() 8 | 9 | describe('DepositManager @skip-on-coverage', async function (accounts) { 10 | let depositManager, childContracts 11 | const amount = web3.utils.toBN('10').pow(web3.utils.toBN('18')) 12 | 13 | describe('deposits on root and child', async function () { 14 | before(async () => { 15 | accounts = await ethers.getSigners() 16 | accounts = accounts.map((account) => { 17 | return account.address 18 | }) 19 | }) 20 | 21 | beforeEach(async function () { 22 | const contracts = await deployer.freshDeploy(accounts[0]) 23 | depositManager = contracts.depositManager 24 | childContracts = await deployer.initializeChildChain() 25 | }) 26 | 27 | it('depositERC20', async function () { 28 | const bob = accounts[1] 29 | const e20 = await deployer.deployChildErc20() 30 | // console.log('child token from mapping: ', await childContracts.childChain.tokens(e20.rootERC20.address)) 31 | await utils.deposit(depositManager, childContracts.childChain, e20.rootERC20, bob, amount, { 32 | rootDeposit: true, 33 | erc20: true 34 | }) 35 | 36 | // assert deposit on child chain 37 | const balance = await e20.childToken.balanceOf(bob) 38 | utils.assertBigNumberEquality(balance, amount) 39 | }) 40 | 41 | it('deposit Matic Tokens', async function () { 42 | const bob = '0x' + crypto.randomBytes(20).toString('hex') 43 | const e20 = await deployer.deployMaticToken() 44 | utils.assertBigNumberEquality(await e20.childToken.balanceOf(bob), 0) 45 | await utils.deposit(depositManager, childContracts.childChain, e20.rootERC20, bob, amount, { 46 | rootDeposit: true, 47 | erc20: true 48 | }) 49 | 50 | // assert deposit on child chain 51 | utils.assertBigNumberEquality(await e20.childToken.balanceOf(bob), amount) 52 | }) 53 | }) 54 | }) 55 | -------------------------------------------------------------------------------- /test/mockResponses/utils.js: -------------------------------------------------------------------------------- 1 | import MerkleTree from '../helpers/merkle-tree.js' 2 | 3 | import * as Proofs from '../helpers/proofs.js' 4 | import { getBlockHeader } from '../helpers/blocks.js' 5 | import * as chai from 'chai' 6 | 7 | const assert = chai.assert 8 | 9 | 10 | let headerNumber = 0 11 | export async function build(event) { 12 | let blockHeader = getBlockHeader(event.block) 13 | let tree = new MerkleTree([blockHeader]) 14 | let receiptProof = await Proofs.getReceiptProof(event.receipt, event.block, null /* web3 */, [event.receipt]) 15 | let txProof = await Proofs.getTxProof(event.tx, event.block) 16 | assert.ok( 17 | Proofs.verifyTxProof(receiptProof), 18 | 'verify receipt proof failed in js' 19 | ) 20 | headerNumber += 1 21 | return { 22 | header: { number: headerNumber, root: tree.getRoot(), start: event.receipt.blockNumber }, 23 | receipt: Proofs.getReceiptBytes(event.receipt), // rlp encoded 24 | receiptParentNodes: receiptProof.parentNodes, 25 | tx: Proofs.getTxBytes(event.tx), // rlp encoded 26 | txParentNodes: txProof.parentNodes, 27 | path: receiptProof.path, 28 | number: event.receipt.blockNumber, 29 | timestamp: event.block.timestamp, 30 | transactionsRoot: Buffer.from(event.block.transactionsRoot.slice(2), 'hex'), 31 | receiptsRoot: Buffer.from(event.block.receiptsRoot.slice(2), 'hex'), 32 | proof: await tree.getProof(blockHeader) 33 | } 34 | } -------------------------------------------------------------------------------- /test/units/GovernanceLockable.test.js: -------------------------------------------------------------------------------- 1 | import { GovernanceLockableTest } from '../helpers/artifacts.js' 2 | import expectRevert from '@openzeppelin/test-helpers/src/expectRevert.js' 3 | import deployer from '../helpers/deployer.js' 4 | import { generateFirstWallets, mnemonics } from '../helpers/wallets.js' 5 | 6 | describe('GovernanceLockable', function() { 7 | const wallets = generateFirstWallets(mnemonics, 10) 8 | 9 | async function freshDeploy() { 10 | this.governance = await deployer.deployGovernance() 11 | this.lockableContract = await GovernanceLockableTest.deploy(this.governance.address) 12 | } 13 | 14 | beforeEach(freshDeploy) 15 | 16 | describe('lock', function() { 17 | describe('when from is not governance', function() { 18 | it('reverts', async function () { 19 | const rootSigner1 = this.lockableContract.provider.getSigner(1) 20 | const lockableContract1 = this.lockableContract.connect(rootSigner1) 21 | 22 | await expectRevert(lockableContract1.lock(), 'Only governance contract is authorized') 23 | }) 24 | }) 25 | 26 | describe('when from is governance', function() { 27 | it('must lock', async function() { 28 | await this.governance.update( 29 | this.lockableContract.address, 30 | this.lockableContract.interface.encodeFunctionData("lock", []) 31 | ) 32 | }) 33 | }) 34 | }) 35 | 36 | describe('unlock', function() { 37 | describe('when from is not governance', function() { 38 | it('reverts', async function () { 39 | const rootSigner2 = this.lockableContract.provider.getSigner(2) 40 | const lockableContract2 = this.lockableContract.connect(rootSigner2) 41 | await expectRevert(lockableContract2.unlock(), 'Only governance contract is authorized') 42 | }) 43 | }) 44 | 45 | describe('when from is governance', function() { 46 | it('must unlock', async function() { 47 | await this.governance.update( 48 | this.lockableContract.address, 49 | this.lockableContract.interface.encodeFunctionData("unlock", []) 50 | ) 51 | }) 52 | }) 53 | }) 54 | }) 55 | -------------------------------------------------------------------------------- /test/units/Initializable.test.js: -------------------------------------------------------------------------------- 1 | import testHelpers from '@openzeppelin/test-helpers' 2 | 3 | 4 | describe('Initializable', function() { 5 | before(async function() { 6 | const ProxyTestImpl = await ethers.getContractFactory('ProxyTestImpl') 7 | this.impl = await ProxyTestImpl.deploy() 8 | }) 9 | 10 | it('must initialize', async function() { 11 | await this.impl.init() 12 | }) 13 | 14 | it('must revert when attempt to initialize again', async function() { 15 | await testHelpers.expectRevert(this.impl.init(), 'already inited') 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /test/units/staking/StakingNFT.test.js: -------------------------------------------------------------------------------- 1 | import { StakingNFT } from '../../helpers/artifacts.js' 2 | import { generateFirstWallets, mnemonics } from '../../helpers/wallets.js' 3 | import { InterfaceIds, shouldSupportInterfaces } from '../behaviors/SupportsInterface.behavior.js' 4 | import testHelpers from '@openzeppelin/test-helpers' 5 | const expectRevert = testHelpers.expectRevert 6 | 7 | describe('StakingNFT', async function () { 8 | let stakingNFT, wallets 9 | 10 | before(async function () { 11 | wallets = generateFirstWallets(mnemonics, 10) 12 | }) 13 | 14 | beforeEach(async function () { 15 | stakingNFT = await StakingNFT.deploy('StakingNFT', 'SNFT') 16 | this.contract = stakingNFT 17 | }) 18 | 19 | shouldSupportInterfaces([InterfaceIds.ERC721, InterfaceIds.ERC721Enumerable]) 20 | 21 | describe('when mint more than once for the same address', function () { 22 | beforeEach(async function () { 23 | this.user = wallets[2].getAddressString() 24 | await stakingNFT.mint(this.user, 1) 25 | }) 26 | 27 | it('reverts', async function () { 28 | await expectRevert(stakingNFT.mint(this.user, 2), 'Validators MUST NOT own multiple stake position') 29 | }) 30 | }) 31 | 32 | describe('when transfer to another address that already have staking NFT', function () { 33 | beforeEach(async function () { 34 | this.user1 = wallets[2].getAddressString() 35 | this.user2 = wallets[3].getAddressString() 36 | await stakingNFT.mint(this.user1, 1) 37 | await stakingNFT.mint(this.user2, 2) 38 | }) 39 | 40 | it('reverts', async function () { 41 | const stakingNFT_2 = stakingNFT.connect(stakingNFT.provider.getSigner(this.user2)) 42 | await expectRevert( 43 | stakingNFT_2.transferFrom(this.user2, this.user1, 2), 44 | 'Validators MUST NOT own multiple stake position' 45 | ) 46 | }) 47 | }) 48 | }) 49 | -------------------------------------------------------------------------------- /test/units/staking/ValidatorShareHelper.js: -------------------------------------------------------------------------------- 1 | export async function buyVoucher(validatorContract, amount, delegator, minSharesToMint) { 2 | const validatorContract_Delegator = validatorContract.connect(validatorContract.provider.getSigner(delegator)) 3 | return validatorContract_Delegator.buyVoucher(amount.toString(), minSharesToMint || 0) 4 | } 5 | 6 | export async function sellVoucher(validatorContract, delegator, minClaimAmount, maxShares) { 7 | if (maxShares === undefined) { 8 | maxShares = await validatorContract.balanceOf(delegator) 9 | } 10 | 11 | if (minClaimAmount === undefined) { 12 | minClaimAmount = await validatorContract.amountStaked(delegator) 13 | } 14 | 15 | const validatorContract_Delegator = validatorContract.connect(validatorContract.provider.getSigner(delegator)) 16 | 17 | return validatorContract_Delegator.sellVoucher(minClaimAmount, maxShares) 18 | } 19 | 20 | export async function sellVoucherNew(validatorContract, delegator, minClaimAmount, maxShares) { 21 | if (maxShares === undefined) { 22 | maxShares = await validatorContract.balanceOf(delegator) 23 | } 24 | 25 | if (minClaimAmount === undefined) { 26 | minClaimAmount = await validatorContract.amountStaked(delegator) 27 | } 28 | const validatorContract_Delegator = validatorContract.connect(validatorContract.provider.getSigner(delegator)) 29 | 30 | return validatorContract_Delegator.sellVoucher_new(minClaimAmount.toString(), maxShares) 31 | } 32 | --------------------------------------------------------------------------------