UNPKG

@gooddollar/goodcontracts

Version:
816 lines (815 loc) 498 kB
{ "contractName": "StakingContract", "abi": [ { "constant": false, "inputs": [ { "internalType": "address", "name": "recipient", "type": "address" } ], "name": "collectUBIInterest", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint32", "name": "", "type": "uint32" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"}],\"name\":\"collectUBIInterest\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodFundManager.sol\":\"StakingContract\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/DSMath.sol\":{\"keccak256\":\"0x59fb5b1c4c3f68c1694f6ff5698016ac8ee9401b61e87473113dc103b7a6b0ff\",\"urls\":[\"bzz-raw://7410f43989dea44e64bed870958ce9199606dd8a9783e79fe8deca7b544164af\",\"dweb:/ipfs/QmPrrdvp2ErwL6SJSveB3JANo7ivadSMnk9gpWZD8nR7hy\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/ActivePeriod.sol\":{\"keccak256\":\"0xd6b17fe8c789a03e87c80046319caee9fc9c9b5ded9008b09a550027c205c5ab\",\"urls\":[\"bzz-raw://0f77e8dc5f6abeefc9a2e185c257516f7f0266ae2781dd67c18daf1aac667daf\",\"dweb:/ipfs/QmbeRqLP2MvTZifqPBSK3PUDh8TjC1RaTA8b1dRRAXahmJ\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/FeeFormula.sol\":{\"keccak256\":\"0x2ac93f891a65aa60b93e2b27552850dfa459b88f5a19edc29bb5bab0cc4f3eaa\",\"urls\":[\"bzz-raw://bddb94bc0230d959d2362887a253a47b91f0de6804cba8e4569a7cac47c39b5a\",\"dweb:/ipfs/QmTdkPQHRdzxJ7D7pi9cowLgYY9wVja416dhBwCsdtPEv5\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/FeelessScheme.sol\":{\"keccak256\":\"0x7c542d44cbd864ee0ddecbc5016d9d7eb9ce65ab463fdd9f21eb8ce3c6ffc8ea\",\"urls\":[\"bzz-raw://4753dd823c0b0cbe7d7d02e1df64ace07d7a163af3aaff12697aee70a1b45f2f\",\"dweb:/ipfs/QmPkKeH88M3f6UbHphayUbjEBNV4rmoogtDmVundzBKbFK\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/FormulaHolder.sol\":{\"keccak256\":\"0xb3c0d3bc21e71497784e1be11698ff501ee11545c3106bec2cae2e8af1bacd9b\",\"urls\":[\"bzz-raw://783b4e28b67231de0fbbe48e58f43f69db3f98fd7f75668edce145a55a9b5b17\",\"dweb:/ipfs/QmdeyRfeix3PGfaXqtRQpH1sjmjFpdtuGaPwnvRn7nHAWd\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/SchemeGuard.sol\":{\"keccak256\":\"0x32e1b2a172e2c22a6aa757bfcb0722cc67f64c5c2e48df3dec2737903516d565\",\"urls\":[\"bzz-raw://bee57a8eba08348e93a0c18f3ab534e67865c0fa27afe27f5cf234bd5f248915\",\"dweb:/ipfs/Qmd8aveHWcUkYWMyJrJRZPyVXj8MAMBfpBFo6g4Z2VJeo3\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/identity/Identity.sol\":{\"keccak256\":\"0x282184478f1d618d3523b28a84a7f7003dfdc99cad120e5e358d2cce1f5fb491\",\"urls\":[\"bzz-raw://67e17ecb57b24c4fb801abc2c52c3148af3b967e28da4fb7e074d18efb7a57c1\",\"dweb:/ipfs/QmfZ8jXhdTHtxr3gfByRj4HnXnGynX7SLZWWGR8k768aGB\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/identity/IdentityAdminRole.sol\":{\"keccak256\":\"0x8e82c45eefe0da77d017144dfad12602c68124297035937901cdd08ce48c57ff\",\"urls\":[\"bzz-raw://e20e606342b3b35f41a081294cf3f716fe7e27e81d3090daa37c5208f4ef4bc3\",\"dweb:/ipfs/QmVEhHpiwVsksnPyHkfNa5LpTBLxoP9kj5NRZUBv456ewK\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/identity/IdentityGuard.sol\":{\"keccak256\":\"0xcc395c0e8f812201b5ed1f45e7272120ee5ffe73bfe13e325dfd872aef235b22\",\"urls\":[\"bzz-raw://58f93e4b9f48ec31ac151208e4f9e6b356cc23dfc9585d846bc09bf35d6ff7be\",\"dweb:/ipfs/QmdxJHUCaFx8N66kkDhYdA4k6d2V91yBRG6sombuPxBq7X\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/token/ERC677/ERC677.sol\":{\"keccak256\":\"0x8360b9e356df8584d95990bb7e772342b30d9e22b160f7c875fbca5c0b87453c\",\"urls\":[\"bzz-raw://97cc6e5586cedcd49462cc465a2a8fc5063d7ec6cb9533f4e0099969a75bd4b2\",\"dweb:/ipfs/QmXw6y4iXfqyJHDRrHdd5ofQ6E4cuHDw4LiYupReJ1rCBc\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/token/ERC677/ERC677Receiver.sol\":{\"keccak256\":\"0xc5683b28527097379ed090b28bb46e17a50a2c57ddcb3c7e028fcd04ddc64aef\",\"urls\":[\"bzz-raw://639f6b6cf65382faea738e6326d6aeb289b8b030cf02f40c54bc45ec098eda6d\",\"dweb:/ipfs/QmQi7dFcKiwUxSbzhus4CxFTdNJvUsfiqY6i3bD4RdMQrn\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/token/ERC677BridgeToken.sol\":{\"keccak256\":\"0x014fa09dca773b1406855e628687be50c1eb129894f45a8b5c9fc709d826968d\",\"urls\":[\"bzz-raw://23c6491c0c26471315010687d785a3724ae33198be6ed39828d1a4f7e6873cb4\",\"dweb:/ipfs/QmW62FXHtLdNGzB8Nq9XwmwHp6Jn8jgbAVyrU2j7c7w6By\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/token/ERC677Token.sol\":{\"keccak256\":\"0x553a103b911d77cecb2ce3f355b2370c4a23eb070593d7c8eb46f33e3a5ff141\",\"urls\":[\"bzz-raw://e37438ce280964498b77f63bbe4d1f25c55ff4c178925447a70decceda06e46c\",\"dweb:/ipfs/QmbqCLhWjZqpFBnUVb3H7LkEbAaVmhf76Ln14oWnGimYGM\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/token/GoodDollar.sol\":{\"keccak256\":\"0x7b91359f6912641c7dbfeced9a5c47454acce7c2cab9205d00b8049d228d7b78\",\"urls\":[\"bzz-raw://3a09bc6936d0179e2e5be2687446532d63135bc537f7ab246c6a1101d4849c1f\",\"dweb:/ipfs/QmNshqF7Xu7UX8BryKYRbnRQdTfytPappxkHq5xMxF5vpE\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/BancorFormula.sol\":{\"keccak256\":\"0xa8b83d6e46b4c2b5cf29c3572df676605ec37b8ef9b51ca6627ee225d9c51a77\",\"urls\":[\"bzz-raw://021c034dffe504492175527a436c00e898dfbf508ffb4e68f3e2a059f8934b61\",\"dweb:/ipfs/QmayhA4XBR7SYRQRRgngDcjRWUfJPmgMTbwskjZaEkznJ1\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodFundManager.sol\":{\"keccak256\":\"0xe6d78ea2ce8cdd16eb1e860e4130da01a4c4c3f0f06c9cdef3f80865f64e5064\",\"urls\":[\"bzz-raw://cf0644a9e54c920f28f39c5437937cab60ce462e685c2b0b456164c2047c38c0\",\"dweb:/ipfs/Qmbydu1amsRWsNLyndqjQ3QmYTt6nP5Gri55fhp8Xa1JRN\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodMarketMaker.sol\":{\"keccak256\":\"0x951b08d2bf3aa8d2da3322220bdff8473457ea52845a6c76ab7732bcbccaaf9a\",\"urls\":[\"bzz-raw://7728a9ba486bddaa950c37c033522af874d518e9b53e4f844320bed6e14d41eb\",\"dweb:/ipfs/QmdEFS6efb3QFWoWhvfy9xHBvykQVbfnF6raqUsn9mhAnu\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodReserveCDai.sol\":{\"keccak256\":\"0x0fa6c1c0d54d076325a80278bf47e214dbb176b63c92bd0725983a530462794e\",\"urls\":[\"bzz-raw://87efa2ad8c36bf560ab4a3e982c518dcfa1c757595b0f2aeede8f70b8fd7a398\",\"dweb:/ipfs/QmNSdgBMBDMrv7WNXYQWhRFgRpDCW7gRW8VqPArcgE9yQH\"]},\"@daostack/arc/contracts/controller/Avatar.sol\":{\"keccak256\":\"0x4e4fb9d3bc21f42fbfc6a01e9f8aa483a59e9f447b0d604f55b587a81ec09ef4\",\"urls\":[\"bzz-raw://9d3c1c7575cf6075ea1d89921f09b9b8e322b208dacaf0446cd4f64506c999f0\",\"dweb:/ipfs/QmVGDDHAR2ByuQpbgV7BBKXGEAcbaWvejpEZYzHgaagBFK\"]},\"@daostack/arc/contracts/controller/ControllerInterface.sol\":{\"keccak256\":\"0x933e92612c90f292c7b59908958b003f1a13d90b97bed0572b566353c20974dc\",\"urls\":[\"bzz-raw://ce1fcf85b744fcce2dbd4205e3943e9b4ec36a5f0330d4bbf61e65f1a3e0e470\",\"dweb:/ipfs/QmUWiLkBDdekhpy93nTzBtxDHL6yNh6sTUM9G8VbsHcBzy\"]},\"@daostack/arc/contracts/controller/DAOToken.sol\":{\"keccak256\":\"0x9b213e4e3ceeffcfc1c962a43b70b8d763d8091a2dd713fc1989b97bb68786e6\",\"urls\":[\"bzz-raw://51d1d6e85fd90f45395a16b7a3c703c4636e836041f2a13f806e4222ef2e59c1\",\"dweb:/ipfs/QmQjeCeFf7TJzsYjT5scyZUDDixBA8Yy8YppgBuxcKPDnP\"]},\"@daostack/arc/contracts/globalConstraints/GlobalConstraintInterface.sol\":{\"keccak256\":\"0xc006c4591ec10b845a56e13f6791db2c428610953034686d52b2a934b6c8f36f\",\"urls\":[\"bzz-raw://19495cd88280e54d7ddcd043ffeff75e6d3777a0c42debcd61cae448e9497ea0\",\"dweb:/ipfs/QmYxWz7CgFmmddrcVXJKfob5Ktwykc2imNVUwLSR5WR8bJ\"]},\"@daostack/arc/contracts/libs/SafeERC20.sol\":{\"keccak256\":\"0xf6727d432f67046145b078f40c1cc4f6be7b0d12a6678ecaf457edf7550d244c\",\"urls\":[\"bzz-raw://5dba7734c4fed446c084a707761cbc66ba22b8b93ef53c8d4a22a76b6e271690\",\"dweb:/ipfs/QmP2VpPKUqLh4ZZs6LaxHVpCN1zCmiorygL9bMub4mbYCw\"]},\"@daostack/infra/contracts/Reputation.sol\":{\"keccak256\":\"0x3d226dac0fe7d758f0287fb28bc25fcec1f69d19888ae3a550fa49856d61c482\",\"urls\":[\"bzz-raw://8856852c8fe0ba1c9aab326f0a9a6e7f31a238de2778fa5188e6fc399f7eb352\",\"dweb:/ipfs/QmVH4ppR9Dk7v8yxaSgeArdMv9gBBVoQxEf4E3UsqQ4rY2\"]},\"openzeppelin-solidity/contracts/access/Roles.sol\":{\"keccak256\":\"0x659ba0f9a3392cd50a8a5fafaf5dfd8c6a0878f6a4613bceff4e90dceddcd865\",\"urls\":[\"bzz-raw://4ca6617349a9b36fd82e9442a8e445ce9021a174e4399d1457ddc894ee3f5df3\",\"dweb:/ipfs/QmcmyB4cNazZ1sw963Afaijt67M9bDgwmGXCgQajGTD4tm\"]},\"openzeppelin-solidity/contracts/access/roles/MinterRole.sol\":{\"keccak256\":\"0x3199053db04cdae6c9b4380921a4a4ee720b568d6a9660883b29d25fbec31bc0\",\"urls\":[\"bzz-raw://1b0ff368e21d6007c06e4cfb286fe59d7d7d3ec06283300c9be2153ba11fa93a\",\"dweb:/ipfs/QmRPq2wZM4RAcbj31dP34GCr1CSy2qy3JqfXEkdVie4HLT\"]},\"openzeppelin-solidity/contracts/access/roles/PauserRole.sol\":{\"keccak256\":\"0x6506133e295a7199df2ac5dfc52853d9d767f68450b6d0193e9d8056b164ce86\",\"urls\":[\"bzz-raw://9c03592a9e6b1377e401b74eccf175a250232b5a341347d3fc5cb50e9bc86ba2\",\"dweb:/ipfs/QmYAr1yXT89hNUMJ37aiBpD9HtYfBDqmueVCzphRuuU7oZ\"]},\"openzeppelin-solidity/contracts/lifecycle/Pausable.sol\":{\"keccak256\":\"0x3b0ed31deeba7e3c6cfbbe8092a6b427084ee390800a06acdea5c17c8185d606\",\"urls\":[\"bzz-raw://bbdbf9d3754fcdcc85aec0432fabcec914317b1c2081b43753442ed53853a34a\",\"dweb:/ipfs/QmVHWQBn5xQkQEHhyGNEeS5gjjALZEk5ZfcjFt7kL6MoLy\"]},\"openzeppelin-solidity/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x965012d27b4262d7a41f5028cbb30c51ebd9ecd4be8fb30380aaa7a3c64fbc8b\",\"urls\":[\"bzz-raw://1eb493553b27efd46c231a836a83ce50d215639feb97b4aac9f301d0fd034ff5\",\"dweb:/ipfs/QmbMdvSXcqGKxeeYvzF3VrWpoHQyVzMXBhzhAokF2Gdymv\"]},\"openzeppelin-solidity/contracts/ownership/Ownable.sol\":{\"keccak256\":\"0x980de387a1a020a498f53d00f89fecebb12c949a17e8f160093c0303ede2b786\",\"urls\":[\"bzz-raw://f07a2c393caa85f62f0aaa461e3edd50aa59371d4209778ba0558d7f8b4b856c\",\"dweb:/ipfs/QmeN3ZiYGSjCnQFeYaJNgoXjF9eDue1g3e9pqManRkeBtV\"]},\"openzeppelin-solidity/contracts/token/ERC20/ERC20.sol\":{\"keccak256\":\"0xba431353cb4fe70777ac026231eb5468e41aa1e81240a2b8136917acc5fff4dc\",\"urls\":[\"bzz-raw://f40c91ca270bdc9b156f339081a0fc2bbcf73cf5f62b8c73ba555df753ff6619\",\"dweb:/ipfs/QmT8y2VVjGaFdGphpcXrgvdPi2EgF9LuCDgJiJ89LvpFRV\"]},\"openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol\":{\"keccak256\":\"0xa3e68fd7f987c8fbdaf4867d428a69a15f3cf2f69709a5b0a0fbef750b0e6fbc\",\"urls\":[\"bzz-raw://50b1ff986d3b2793850a66c8429d9886fdfb134b1509b3e98714e3e2a71e24f5\",\"dweb:/ipfs/QmSQBYPeY9tbR3ciGRNQqvcWKnNiuxtVMq2MsPWpLwuGGm\"]},\"openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol\":{\"keccak256\":\"0xe195405e9993d575173cdb5dd408db7459a026b9a98085c1a3b676f020f46584\",\"urls\":[\"bzz-raw://f6beab874b52e710d2c42334e34bb5592146f7dd148d96ff32c0c474412bf2f4\",\"dweb:/ipfs/QmUKmVUX4Fif7dguPgC459cpGegiJd1s24YhgZUrBUkkDN\"]},\"openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol\":{\"keccak256\":\"0xc4ca2883e0b0743604143952024c250bb13737ad54bb666b117efdcb766fe3a8\",\"urls\":[\"bzz-raw://bdaf72028f2dc29aa5191b2bfca315a9e3b1d58f900166bdb5ae5f500d569384\",\"dweb:/ipfs/QmZngPiWLXA9i2vp6XNPcGA23GHxT99V1Qma6iRivtbREy\"]},\"openzeppelin-solidity/contracts/token/ERC20/ERC20Pausable.sol\":{\"keccak256\":\"0x37b840977505e5f6d74bc8fa3d0217facc7913d0ecf064da3e3b26494acd37de\",\"urls\":[\"bzz-raw://7456513521bae915089dfd5879b685e47f3f180ad9ffe24cc3b19275b1da28ed\",\"dweb:/ipfs/QmbM1avKkyyTHEeTs3CqheyZwgAMNzVi3iDudqBdUJ2WPM\"]},\"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x079c4e23ee448f529e43bfa3c4e8fb4be52cd0318ee923a276835bedf45b93d8\",\"urls\":[\"bzz-raw://ee762ff5b7746e41d27dcbcea00c7a3034b58adb1b45ddadddb5b721aff450df\",\"dweb:/ipfs/QmdxqtgEFZjHCoiYyz6pUAQ5iBm7As25jcyEbZoTaAgyDa\"]},\"openzeppelin-solidity/contracts/utils/Address.sol\":{\"keccak256\":\"0x5c731061b804fa256fc8c05150eafe5d20b6bb94541a8f187912bf84f7033f34\",\"urls\":[\"bzz-raw://a3c2d9f046beebab7fb41b1b124a6a124a36f510f7c67365861402ac831bdc71\",\"dweb:/ipfs/QmUtASRgitregbKH83anopLtF9vFQe3BKeAjhUa6F7t9YV\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "sourceMap": "", "deployedSourceMap": "", "source": "pragma solidity >0.5.4;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/token/ERC20/ERC20.sol\";\nimport \"@daostack/arc/contracts/controller/Avatar.sol\";\nimport \"../../contracts/dao/schemes/FeelessScheme.sol\";\nimport \"../../contracts/dao/schemes/ActivePeriod.sol\";\nimport \"./GoodReserveCDai.sol\";\n\n\ninterface StakingContract {\n function collectUBIInterest(address recipient)\n external\n returns (uint256, uint256, uint256, uint32);\n}\n\n\n/**\n * @title GoodFundManager contract that transfer interest from the staking contract\n * to the reserve contract and transfer the return mintable tokens to the staking\n * contract\n * cDAI support only\n */\ncontract GoodFundManager is FeelessScheme, ActivePeriod {\n using SafeMath for uint256;\n\n // The address of cDai\n ERC20 public cDai;\n\n // The address of the reserve contract\n // which recieves the funds from the\n // staking contract\n GoodReserveCDai public reserve;\n\n // The address of the bridge contract\n // which transfers in his turn the\n // UBI funds to the given recipient\n // address on the sidechain\n address public bridgeContract;\n\n // The recipient address on the\n // sidechain. The bridge transfers\n // the funds to the following address\n address public ubiRecipient;\n\n // Determines how many blocks should\n // be passed before the next\n // execution of `transferInterest`\n uint256 public blockInterval;\n\n // Last block number which `transferInterest`\n // has been executed in\n uint256 public lastTransferred;\n\n // Emits when `transferInterest` transfers\n // funds to the staking contract and to\n // the bridge\n event FundsTransferred(\n // The caller address\n address indexed caller,\n // The staking contract address\n address indexed staking,\n // The reserve contract address\n address indexed reserve,\n // Amount of cDai that was transferred\n // from the staking contract to the\n // reserve contract\n uint256 cDAIinterestEarned,\n // How much interest has been donated\n // according to the given donation\n // ratio which determined in the\n // staking contract\n uint256 cDAIinterestDonated,\n // The number of tokens that have been minted\n // by the reserve to the staking contract\n uint256 gdInterest,\n // The number of tokens that have been minted\n // by the reserve to the bridge which in his\n // turn should transfer those funds to the\n // sidechain\n uint256 gdUBI\n );\n\n modifier reserveHasInitialized {\n require(address(reserve) != address(0), \"reserve has not initialized\");\n _;\n }\n\n /**\n * @dev Constructor\n * @param _avatar The avatar of the DAO\n * @param _identity The identity contract\n * @param _cDai The address of cDai\n * @param _bridgeContract The address of the bridge contract\n * @param _ubiRecipient The recipient address on the sidechain\n * @param _blockInterval How many blocks should be passed before the next execution of `transferInterest\n */\n constructor(\n Avatar _avatar,\n Identity _identity,\n address _cDai,\n address _bridgeContract,\n address _ubiRecipient,\n uint256 _blockInterval\n )\n public\n FeelessScheme(_identity, _avatar)\n ActivePeriod(now, now * 2, _avatar)\n {\n cDai = ERC20(_cDai);\n bridgeContract = _bridgeContract;\n ubiRecipient = _ubiRecipient;\n blockInterval = _blockInterval;\n lastTransferred = block.number.div(blockInterval);\n }\n\n /**\n * @dev Start function. Adds this contract to identity as a feeless scheme.\n * Can only be called if scheme is registered\n */\n function start() public onlyRegistered {\n addRights();\n super.start();\n }\n\n /**\n * @dev Sets the whitelisted reserve. Only Avatar\n * can call this method.\n * @param _reserve The new reserve to be whitelisted\n */\n function setReserve(GoodReserveCDai _reserve) public onlyAvatar {\n reserve = _reserve;\n }\n\n /**\n * @dev sets the token bridge address on mainnet and the recipient of minted UBI (avatar on sidechain)\n * @param _bridgeContract address\n * @param _recipient address\n */\n\n /**\n * @dev Sets the bridge address on the current network and the recipient\n * address on the sidechain. Only Avatar can call this method.\n * @param _bridgeContract The new bridge address\n * @param _recipient The new recipient address (NOTICE: this address may be a\n * sidechain address)\n */\n function setBridgeAndUBIRecipient(\n address _bridgeContract,\n address _recipient\n )\n public\n onlyAvatar\n {\n bridgeContract = _bridgeContract;\n ubiRecipient = _recipient;\n }\n\n /**\n * @dev Allows the DAO to change the block interval\n * @param _blockInterval the new interval value\n */\n function setBlockInterval(\n uint256 _blockInterval\n )\n public\n onlyAvatar\n {\n blockInterval = _blockInterval;\n }\n\n /**\n * @dev Checks if enough time has passed away since the\n * last funds transfer time\n * @return (bool) True if enough time has passed\n */\n function canRun() public view returns(bool)\n {\n return block.number.div(blockInterval) > lastTransferred;\n }\n\n /**\n * @dev Collects UBI interest in cDai from a given staking contract and transfers\n * that interest to the reserve contract. Then transfers the given gd which\n * received from the reserve contract back to the staking contract and to the\n * bridge, which locks the funds and then the GD tokens are been minted to the\n * given address on the sidechain\n * @param _staking Contract that implements `collectUBIInterest` and transfer cDai to\n * a given address. The given address should be the same whitelisted `reserve`\n * address in the current contract, in case that the given staking contract transfers\n * the funds to another contract, zero GD tokens will be minted by the reserve contract.\n * Emits `FundsTransferred` event in case which interest has been passed to the `reserve`\n */\n function transferInterest(StakingContract _staking)\n public\n requireActive\n reserveHasInitialized\n requireDAOContract(address(_staking))\n {\n require(\n canRun(),\n \"Need to wait for the next interval\"\n );\n\n lastTransferred = block.number.div(blockInterval);\n\n // cDai balance of the reserve contract\n uint256 currentBalance = cDai.balanceOf(address(reserve));\n\n // Collects the interest from the staking contract and transfers\n // it directly to the reserve contract. `collectUBIInterest` returns\n // (cdaigains, daigains, precission loss, donation ratio)\n (, , , uint32 donationRatio) = _staking.collectUBIInterest(\n address(reserve)\n );\n\n // Finds the actual transferred cDai\n uint256 interest = cDai.balanceOf(address(reserve)).sub(\n currentBalance\n );\n\n uint256 interestDonated = interest.mul(donationRatio).div(1e6);\n uint256 afterDonation = interest.sub(interestDonated);\n // Mints gd while the interest amount is equal to the transferred amount\n (uint256 gdInterest, uint256 gdUBI) = reserve.mintInterestAndUBI(\n cDai,\n interest,\n afterDonation\n );\n // Transfers the minted tokens to the given staking contract\n GoodDollar token = GoodDollar(address(avatar.nativeToken()));\n if(gdInterest > 0)\n require(token.transfer(address(_staking), gdInterest),\"interest transfer failed\");\n if(gdUBI > 0)\n //transfer ubi to avatar on sidechain via bridge\n require(token.transferAndCall(\n bridgeContract,\n gdUBI,\n abi.encodePacked(ubiRecipient)\n ),\"ubi bridge transfer failed\");\n emit FundsTransferred(\n msg.sender,\n address(_staking),\n address(reserve),\n interest,\n interestDonated,\n gdInterest,\n gdUBI\n );\n }\n\n /**\n * @dev Making the contract inactive after it has transferred funds to `_avatar`.\n * Only the avatar can destroy the contract.\n */\n function end() public onlyAvatar {\n // Transfers the remaining amount of cDai and GD to the avatar\n uint256 remainingCDaiReserve = cDai.balanceOf(address(this));\n if (remainingCDaiReserve > 0) {\n require(cDai.transfer(address(avatar), remainingCDaiReserve),\"cdai transfer failed\");\n }\n GoodDollar token = GoodDollar(address(avatar.nativeToken()));\n uint256 remainingGDReserve = token.balanceOf(address(this));\n if (remainingGDReserve > 0) {\n require(token.transfer(address(avatar), remainingGDReserve),\"gd transfer failed\");\n }\n super.internalEnd(avatar);\n }\n}\n", "sourcePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodFundManager.sol", "ast": { "absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodFundManager.sol", "exportedSymbols": { "GoodFundManager": [ 7371 ], "StakingContract": [ 6981 ] }, "id": 7372, "nodeType": "SourceUnit", "nodes": [ { "id": 6961, "literals": [ "solidity", ">", "0.5", ".4" ], "nodeType": "PragmaDirective", "src": "0:23:24" }, { "absolutePath": "openzeppelin-solidity/contracts/math/SafeMath.sol", "file": "openzeppelin-solidity/contracts/math/SafeMath.sol", "id": 6962, "nodeType": "ImportDirective", "scope": 7372, "sourceUnit": 21309, "src": "25:59:24", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol", "file": "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol", "id": 6963, "nodeType": "ImportDirective", "scope": 7372, "sourceUnit": 21850, "src": "85:63:24", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@daostack/arc/contracts/controller/Avatar.sol", "file": "@daostack/arc/contracts/controller/Avatar.sol", "id": 6964, "nodeType": "ImportDirective", "scope": 7372, "sourceUnit": 12706, "src": "149:55:24", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/FeelessScheme.sol", "file": "../../contracts/dao/schemes/FeelessScheme.sol", "id": 6965, "nodeType": "ImportDirective", "scope": 7372, "sourceUnit": 1228, "src": "205:55:24", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/contracts/dao/schemes/ActivePeriod.sol", "file": "../../contracts/dao/schemes/ActivePeriod.sol", "id": 6966, "nodeType": "ImportDirective", "scope": 7372, "sourceUnit": 1005, "src": "261:54:24", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/stakingModel/contracts/GoodReserveCDai.sol", "file": "./GoodReserveCDai.sol", "id": 6967, "nodeType": "ImportDirective", "scope": 7372, "sourceUnit": 9044, "src": "316:31:24", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "interface", "documentation": null, "fullyImplemented": false, "id": 6981, "linearizedBaseContracts": [ 6981 ], "name": "StakingContract", "nodeType": "ContractDefinition", "nodes": [ { "body": null, "documentation": null, "id": 6980, "implemented": false, "kind": "function", "modifiers": [], "name": "collectUBIInterest", "nodeType": "FunctionDefinition", "parameters": { "id": 6970, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 6969, "name": "recipient", "nodeType": "VariableDeclaration", "scope": 6980, "src": "410:17:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 6968, "name": "address", "nodeType": "ElementaryTypeName", "src": "410:7:24", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "409:19:24" }, "returnParameters": { "id": 6979, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 6972, "name": "", "nodeType": "VariableDeclaration", "scope": 6980, "src": "463:7:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6971, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "463:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 6974, "name": "", "nodeType": "VariableDeclaration", "scope": 6980, "src": "472:7:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6973, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "472:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 6976, "name": "", "nodeType": "VariableDeclaration", "scope": 6980, "src": "481:7:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6975, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "481:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 6978, "name": "", "nodeType": "VariableDeclaration", "scope": 6980, "src": "490:6:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 6977, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "490:6:24", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "value": null, "visibility": "internal" } ], "src": "462:35:24" }, "scope": 6981, "src": "382:116:24", "stateMutability": "nonpayable", "superFunction": null, "visibility": "external" } ], "scope": 7372, "src": "350:150:24" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 6982, "name": "FeelessScheme", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1227, "src": "738:13:24", "typeDescriptions": { "typeIdentifier": "t_contract$_FeelessScheme_$1227", "typeString": "contract FeelessScheme" } }, "id": 6983, "nodeType": "InheritanceSpecifier", "src": "738:13:24" }, { "arguments": null, "baseName": { "contractScope": null, "id": 6984, "name": "ActivePeriod", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 1004, "src": "753:12:24", "typeDescriptions": { "typeIdentifier": "t_contract$_ActivePeriod_$1004", "typeString": "contract ActivePeriod" } }, "id": 6985, "nodeType": "InheritanceSpecifier", "src": "753:12:24" } ], "contractDependencies": [ 1004, 1227, 1423, 2667, 21417 ], "contractKind": "contract", "documentation": "@title GoodFundManager contract that transfer interest from the staking contract\nto the reserve contract and transfer the return mintable tokens to the staking\ncontract\ncDAI support only", "fullyImplemented": true, "id": 7371, "linearizedBaseContracts": [ 7371, 1004, 1227, 2667, 1423, 21417 ], "name": "GoodFundManager", "nodeType": "ContractDefinition", "nodes": [ { "id": 6988, "libraryName": { "contractScope": null, "id": 6986, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 21308, "src": "778:8:24", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$21308", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "772:27:24", "typeName": { "id": 6987, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "791:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "constant": false, "id": 6990, "name": "cDai", "nodeType": "VariableDeclaration", "scope": 7371, "src": "832:17:24", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20_$21849", "typeString": "contract ERC20" }, "typeName": { "contractScope": null, "id": 6989, "name": "ERC20", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 21849, "src": "832:5:24", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC20_$21849", "typeString": "contract ERC20" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 6992, "name": "reserve", "nodeType": "VariableDeclaration", "scope": 7371, "src": "964:30:24", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_GoodReserveCDai_$9043", "typeString": "contract GoodReserveCDai" }, "typeName": { "contractScope": null, "id": 6991, "name": "GoodReserveCDai", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 9043, "src": "964:15:24", "typeDescriptions": { "typeIdentifier": "t_contract$_GoodReserveCDai_$9043", "typeString": "contract GoodReserveCDai" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 6994, "name": "bridgeContract", "nodeType": "VariableDeclaration", "scope": 7371, "src": "1154:29:24", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 6993, "name": "address", "nodeType": "ElementaryTypeName", "src": "1154:7:24", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 6996, "name": "ubiRecipient", "nodeType": "VariableDeclaration", "scope": 7371, "src": "1307:27:24", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 6995, "name": "address", "nodeType": "ElementaryTypeName", "src": "1307:7:24", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 6998, "name": "blockInterval", "nodeType": "VariableDeclaration", "scope": 7371, "src": "1454:28:24", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6997, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1454:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 7000, "name": "lastTransferred", "nodeType": "VariableDeclaration", "scope": 7371, "src": "1567:30:24", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 6999, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1567:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "anonymous": false, "documentation": null, "id": 7016, "name": "FundsTransferred", "nodeType": "EventDefinition", "parameters": { "id": 7015, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 7002, "indexed": true, "name": "caller", "nodeType": "VariableDeclaration", "scope": 7016, "src": "1775:22:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 7001, "name": "address", "nodeType": "ElementaryTypeName", "src": "1775:7:24", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 7004, "indexed": true, "name": "staking", "nodeType": "VariableDeclaration", "scope": 7016, "src": "1847:23:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 7003, "name": "address", "nodeType": "ElementaryTypeName", "src": "1847:7:24", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 7006, "indexed": true, "name": "reserve", "nodeType": "VariableDeclaration", "scope": 7016, "src": "1920:23:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 7005, "name": "address", "nodeType": "ElementaryTypeName", "src": "1920:7:24", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 7008, "indexed": false, "name": "cDAIinterestEarned", "nodeType": "VariableDeclaration", "scope": 7016, "src": "2072:26:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 7007, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2072:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 7010, "indexed": false, "name": "cDAIinterestDonated", "nodeType": "VariableDeclaration", "scope": 7016, "src": "2266:27:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 7009, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2266:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 7012, "indexed": false, "name": "gdInterest", "nodeType": "VariableDeclaration", "scope": 7016, "src": "2407:18:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 7011, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2407:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 7014, "indexed": false, "name": "gdUBI", "nodeType": "VariableDeclaration", "scope": 7016, "src": "2614:13:24", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 7013, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2614:7:24", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "1735:898:24" }, "src": "1713:921:24" }, { "body": { "id": 7030, "nodeType": "Block", "src": "2671:98:24", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 7025, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 7020, "name": "reserve", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 6992, "src": "2697:7:24", "typeDescriptions": { "typeIdentifier": "t_contract$_GoodReserveCDai_$9043", "typeString": "contract GoodReserveCDai" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_GoodReserveCDai_$9043", "typeString": "contract GoodReserveCDai" }