@gooddollar/goodcontracts
Version:
GoodDollar Contracts
539 lines (538 loc) • 419 kB
JSON
{
"contractName": "DonationsStaking",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "caller",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "stakedDAI",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "ethDonated",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "daiDonated",
"type": "uint256"
}
],
"name": "DonationStaked",
"type": "event"
},
{
"inputs": [],
"name": "DAI",
"outputs": [
{
"internalType": "contract cERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "active",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "avatar",
"outputs": [
{
"internalType": "address payable",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "stakingContract",
"outputs": [
{
"internalType": "contract Staking",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalDAIDonated",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalETHDonated",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "uniswap",
"outputs": [
{
"internalType": "contract Uniswap",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_avatar",
"type": "address"
},
{
"internalType": "address",
"name": "_stakingContract",
"type": "address"
},
{
"internalType": "address",
"name": "_dai",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_minDAIAmount",
"type": "uint256"
}
],
"name": "stakeDonations",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "totalStaked",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "_active",
"type": "bool"
}
],
"name": "setActive",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "end",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "getVersion",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"stakedDAI\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"ethDonated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"daiDonated\",\"type\":\"uint256\"}],\"name\":\"DonationStaked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DAI\",\"outputs\":[{\"internalType\":\"contract cERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"active\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"avatar\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"end\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVersion\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"_avatar\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stakingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_dai\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_active\",\"type\":\"bool\"}],\"name\":\"setActive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minDAIAmount\",\"type\":\"uint256\"}],\"name\":\"stakeDonations\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakingContract\",\"outputs\":[{\"internalType\":\"contract Staking\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalDAIDonated\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalETHDonated\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalStaked\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"uniswap\",\"outputs\":[{\"internalType\":\"contract Uniswap\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"end()\":{\"details\":\"withdraws all stakes and then transfer all balances to avatar this can also be called by owner(Foundation) but it is safe as funds are transfered to avatarMock and only avatar can upgrade this contract logic\"},\"stakeDonations(uint256)\":{\"details\":\"stake available funds. It take balance in eth and buy DAI from uniswap then stake outstanding DAI balance. anyone can call this.\",\"params\":{\"_minDAIAmount\":\"enforce expected return from uniswap when converting eth balance to DAI\"}},\"totalStaked()\":{\"details\":\"total DAI value staked\",\"returns\":{\"_0\":\"DAI value staked\"}}},\"title\":\"DonationStaking contract that receives funds in ETH/DAI and stake them in the SimpleStaking contract\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/staking/DonationsStaking.sol\":\"DonationsStaking\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/Interfaces.sol\":{\"keccak256\":\"0xe501727b0e5e15fe639129ab4b1abc59a14ebd3ddd05bb7056ac4fc26a8f3ee7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://90d8797740cfd3933ae849f3144e30f9133a55b26634b3efefa8206cd91f62d8\",\"dweb:/ipfs/QmYLeetoyiPej9acnGzjLLwgVnEg4d2Eg1Xb4k3A1mJqj6\"]},\"/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/staking/DonationsStaking.sol\":{\"keccak256\":\"0xe3eb1174f81e15cd7ba62b1171589ea2e000fcfa51a454487be9304db87d7e2f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://24db48162fa786d56e86c63762821cdd8ca667bd4bfc76ca4ee445eaf43adaaa\",\"dweb:/ipfs/QmUqXSRmP2N18FjJVXqFjxjweq6yv1sr4kmsZBbgqcDdBF\"]},\"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\":{\"keccak256\":\"0xae7044b7c89ed74327b0979ae6f317c65d87b8d17a42d0c62d698d77d5de5511\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://d676c978d8ecee5c4510f045b747d94f3a1381e39feb870d2675d5b6d45a371b\",\"dweb:/ipfs/QmUAokuHWPVAf14QkhPtSdYFyNa8HVje9CBEzwCcxH3xkP\"]}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b50610fa5806100206000396000f3fe6080604052600436106100e15760003560e01c8063904206281161007f578063e0bab4c411610059578063e0bab4c414610212578063ea1eba7114610227578063ee99205c1461023c578063efbe1c1c14610251576100e8565b806390420628146101bd578063acec338a146101d2578063c0c53b8b146101f2576100e8565b80632681f7e4116100bb5780632681f7e41461014f5780635aef7de614610171578063817b1cd2146101865780638da5cb5b146101a8576100e8565b806302fb0c5e146100ed5780630d8e6e2c146101185780632124e2df1461013a576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610102610274565b60405161010f9190610d61565b60405180910390f35b34801561012457600080fd5b5061012d610284565b60405161010f9190610d6c565b61014d610148366004610cde565b6102a3565b005b34801561015b57600080fd5b506101646104ae565b60405161010f9190610d0e565b34801561017d57600080fd5b506101646104bd565b34801561019257600080fd5b5061019b6104d2565b60405161010f9190610e82565b3480156101b457600080fd5b50610164610562565b3480156101c957600080fd5b5061019b610571565b3480156101de57600080fd5b5061014d6101ed366004610c73565b610577565b3480156101fe57600080fd5b5061014d61020d366004610b94565b6105da565b34801561021e57600080fd5b50610164610767565b34801561023357600080fd5b5061019b610776565b34801561024857600080fd5b5061016461077c565b34801561025d57600080fd5b5061026661078b565b60405161010f929190610ef4565b600454600160a01b900460ff1681565b6040805180820190915260058152640312e312e360dc1b602082015290565b600454600160a01b900460ff166102b957600080fd5b6002546040516370a0823160e01b81526000916001600160a01b0316906370a08231906102ea903090600401610d0e565b60206040518083038186803b15801561030257600080fd5b505afa158015610316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033a9190610cf6565b90506000610347836109ab565b6002546040516370a0823160e01b81529192506000916001600160a01b03909116906370a082319061037d903090600401610d0e565b60206040518083038186803b15801561039557600080fd5b505afa1580156103a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cd9190610cf6565b9050600081116103f85760405162461bcd60e51b81526004016103ef90610dbf565b60405180910390fd5b6001546040516364aab23960e01b81526001600160a01b03909116906364aab23990610428908490600401610e82565b600060405180830381600087803b15801561044257600080fd5b505af1158015610456573d6000803e3d6000fd5b50506005805485019055505060068054840190556040517fde176e064212e4ce25421127d59b3d0635e3feef28910a845ff34610c6b6b3bf906104a0903390849086908890610d3b565b60405180910390a150505050565b6004546001600160a01b031681565b6000546201000090046001600160a01b031681565b60006104dc610b57565b6001546040516348b4573960e11b81526001600160a01b0390911690639168ae729061050c903090600401610d0e565b604080518083038186803b15801561052357600080fd5b505afa158015610537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055b9190610cab565b5191505090565b6003546001600160a01b031681565b60055481565b6003546001600160a01b03163314806105a057506000546201000090046001600160a01b031633145b6105bc5760405162461bcd60e51b81526004016103ef90610e36565b60048054911515600160a01b0260ff60a01b19909216919091179055565b600054610100900460ff16806105f357506105f3610b51565b80610601575060005460ff16155b61061d5760405162461bcd60e51b81526004016103ef90610de8565b600054610100900460ff16158015610648576000805460ff1961ff0019909116610100171660011790555b60038054336001600160a01b03199182161790915560048054737a250d5630b4cf539739df2c5dacb4c659f2488d9083161781556002805483166001600160a01b0386811691909117918290556000805462010000600160b01b031916620100008a84160217905560018054909416878216179384905560405163095ea7b360e01b81529181169363095ea7b3936106e99391909216916000199101610d22565b602060405180830381600087803b15801561070357600080fd5b505af1158015610717573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073b9190610c8f565b506004805460ff60a01b1916600160a01b1790558015610761576000805461ff00191690555b50505050565b6002546001600160a01b031681565b60065481565b6001546001600160a01b031681565b60035460009081906001600160a01b03163314806107b957506000546201000090046001600160a01b031633145b6107d55760405162461bcd60e51b81526004016103ef90610e36565b600160009054906101000a90046001600160a01b03166001600160a01b031663bed9d8616040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561082557600080fd5b505af1158015610839573d6000803e3d6000fd5b50506002546040516370a0823160e01b8152600093506001600160a01b0390911691506370a0823190610870903090600401610d0e565b60206040518083038186803b15801561088857600080fd5b505afa15801561089c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c09190610cf6565b60025460005460405163a9059cbb60e01b815292935047926001600160a01b039283169263a9059cbb926109039262010000909104909116908690600401610d22565b602060405180830381600087803b15801561091d57600080fd5b505af1158015610931573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109559190610c8f565b5060008054604051620100009091046001600160a01b0316916108fc841502918491818181858888f19350505050158015610994573d6000803e3d6000fd5b506004805460ff60a01b1916905590925090509091565b600047806109bd576000915050610b4c565b6040805160028082526060808301845292602083019080368337505060025482519293506001600160a01b03169183915060019081106109f957fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600460009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6757600080fd5b505afa158015610a7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9f9190610b71565b81600081518110610aac57fe5b6001600160a01b03928316602091820292909201015260048054604051637ff36ab560e01b8152921691637ff36ab5918591610af091899187913091429101610e8b565b6000604051808303818588803b158015610b0957600080fd5b505af1158015610b1d573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610b469190810190610bde565b50909150505b919050565b303b1590565b604051806040016040528060008152602001600081525090565b600060208284031215610b82578081fd5b8151610b8d81610f49565b9392505050565b600080600060608486031215610ba8578182fd5b8335610bb381610f49565b92506020840135610bc381610f49565b91506040840135610bd381610f49565b809150509250925092565b60006020808385031215610bf0578182fd5b825167ffffffffffffffff811115610c06578283fd5b8301601f81018513610c16578283fd5b8051610c29610c2482610f29565b610f02565b8181528381019083850185840285018601891015610c45578687fd5b8694505b83851015610c67578051835260019490940193918501918501610c49565b50979650505050505050565b600060208284031215610c84578081fd5b8135610b8d81610f61565b600060208284031215610ca0578081fd5b8151610b8d81610f61565b600060408284031215610cbc578081fd5b610cc66040610f02565b82518152602083015160208201528091505092915050565b600060208284031215610cef578081fd5b5035919050565b600060208284031215610d07578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b901515815260200190565b6000602080835283518082850152825b81811015610d9857858101830151858201604001528201610d7c565b81811115610da95783604083870101525b50601f01601f1916929092016040019392505050565b6020808252600f908201526e6e6f2044414920746f207374616b6560881b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602c908201527f4f6e6c79206f776e6572206f72206176617461722063616e20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b90815260200190565b600060808201868352602060808185015281875180845260a0860191508289019350845b81811015610ed45784516001600160a01b031683529383019391830191600101610eaf565b50506001600160a01b039690961660408501525050506060015292915050565b918252602082015260400190565b60405181810167ffffffffffffffff81118282101715610f2157600080fd5b604052919050565b600067ffffffffffffffff821115610f3f578081fd5b5060209081020190565b6001600160a01b0381168114610f5e57600080fd5b50565b8015158114610f5e57600080fdfea2646970667358221220211b18970a82784a35af7c8f1be0194a71e74d2be3b3915a493db1656fd4362164736f6c634300060c0033",
"deployedBytecode": "0x6080604052600436106100e15760003560e01c8063904206281161007f578063e0bab4c411610059578063e0bab4c414610212578063ea1eba7114610227578063ee99205c1461023c578063efbe1c1c14610251576100e8565b806390420628146101bd578063acec338a146101d2578063c0c53b8b146101f2576100e8565b80632681f7e4116100bb5780632681f7e41461014f5780635aef7de614610171578063817b1cd2146101865780638da5cb5b146101a8576100e8565b806302fb0c5e146100ed5780630d8e6e2c146101185780632124e2df1461013a576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610102610274565b60405161010f9190610d61565b60405180910390f35b34801561012457600080fd5b5061012d610284565b60405161010f9190610d6c565b61014d610148366004610cde565b6102a3565b005b34801561015b57600080fd5b506101646104ae565b60405161010f9190610d0e565b34801561017d57600080fd5b506101646104bd565b34801561019257600080fd5b5061019b6104d2565b60405161010f9190610e82565b3480156101b457600080fd5b50610164610562565b3480156101c957600080fd5b5061019b610571565b3480156101de57600080fd5b5061014d6101ed366004610c73565b610577565b3480156101fe57600080fd5b5061014d61020d366004610b94565b6105da565b34801561021e57600080fd5b50610164610767565b34801561023357600080fd5b5061019b610776565b34801561024857600080fd5b5061016461077c565b34801561025d57600080fd5b5061026661078b565b60405161010f929190610ef4565b600454600160a01b900460ff1681565b6040805180820190915260058152640312e312e360dc1b602082015290565b600454600160a01b900460ff166102b957600080fd5b6002546040516370a0823160e01b81526000916001600160a01b0316906370a08231906102ea903090600401610d0e565b60206040518083038186803b15801561030257600080fd5b505afa158015610316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033a9190610cf6565b90506000610347836109ab565b6002546040516370a0823160e01b81529192506000916001600160a01b03909116906370a082319061037d903090600401610d0e565b60206040518083038186803b15801561039557600080fd5b505afa1580156103a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cd9190610cf6565b9050600081116103f85760405162461bcd60e51b81526004016103ef90610dbf565b60405180910390fd5b6001546040516364aab23960e01b81526001600160a01b03909116906364aab23990610428908490600401610e82565b600060405180830381600087803b15801561044257600080fd5b505af1158015610456573d6000803e3d6000fd5b50506005805485019055505060068054840190556040517fde176e064212e4ce25421127d59b3d0635e3feef28910a845ff34610c6b6b3bf906104a0903390849086908890610d3b565b60405180910390a150505050565b6004546001600160a01b031681565b6000546201000090046001600160a01b031681565b60006104dc610b57565b6001546040516348b4573960e11b81526001600160a01b0390911690639168ae729061050c903090600401610d0e565b604080518083038186803b15801561052357600080fd5b505afa158015610537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055b9190610cab565b5191505090565b6003546001600160a01b031681565b60055481565b6003546001600160a01b03163314806105a057506000546201000090046001600160a01b031633145b6105bc5760405162461bcd60e51b81526004016103ef90610e36565b60048054911515600160a01b0260ff60a01b19909216919091179055565b600054610100900460ff16806105f357506105f3610b51565b80610601575060005460ff16155b61061d5760405162461bcd60e51b81526004016103ef90610de8565b600054610100900460ff16158015610648576000805460ff1961ff0019909116610100171660011790555b60038054336001600160a01b03199182161790915560048054737a250d5630b4cf539739df2c5dacb4c659f2488d9083161781556002805483166001600160a01b0386811691909117918290556000805462010000600160b01b031916620100008a84160217905560018054909416878216179384905560405163095ea7b360e01b81529181169363095ea7b3936106e99391909216916000199101610d22565b602060405180830381600087803b15801561070357600080fd5b505af1158015610717573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073b9190610c8f565b506004805460ff60a01b1916600160a01b1790558015610761576000805461ff00191690555b50505050565b6002546001600160a01b031681565b60065481565b6001546001600160a01b031681565b60035460009081906001600160a01b03163314806107b957506000546201000090046001600160a01b031633145b6107d55760405162461bcd60e51b81526004016103ef90610e36565b600160009054906101000a90046001600160a01b03166001600160a01b031663bed9d8616040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561082557600080fd5b505af1158015610839573d6000803e3d6000fd5b50506002546040516370a0823160e01b8152600093506001600160a01b0390911691506370a0823190610870903090600401610d0e565b60206040518083038186803b15801561088857600080fd5b505afa15801561089c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c09190610cf6565b60025460005460405163a9059cbb60e01b815292935047926001600160a01b039283169263a9059cbb926109039262010000909104909116908690600401610d22565b602060405180830381600087803b15801561091d57600080fd5b505af1158015610931573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109559190610c8f565b5060008054604051620100009091046001600160a01b0316916108fc841502918491818181858888f19350505050158015610994573d6000803e3d6000fd5b506004805460ff60a01b1916905590925090509091565b600047806109bd576000915050610b4c565b6040805160028082526060808301845292602083019080368337505060025482519293506001600160a01b03169183915060019081106109f957fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600460009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6757600080fd5b505afa158015610a7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9f9190610b71565b81600081518110610aac57fe5b6001600160a01b03928316602091820292909201015260048054604051637ff36ab560e01b8152921691637ff36ab5918591610af091899187913091429101610e8b565b6000604051808303818588803b158015610b0957600080fd5b505af1158015610b1d573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610b469190810190610bde565b50909150505b919050565b303b1590565b604051806040016040528060008152602001600081525090565b600060208284031215610b82578081fd5b8151610b8d81610f49565b9392505050565b600080600060608486031215610ba8578182fd5b8335610bb381610f49565b92506020840135610bc381610f49565b91506040840135610bd381610f49565b809150509250925092565b60006020808385031215610bf0578182fd5b825167ffffffffffffffff811115610c06578283fd5b8301601f81018513610c16578283fd5b8051610c29610c2482610f29565b610f02565b8181528381019083850185840285018601891015610c45578687fd5b8694505b83851015610c67578051835260019490940193918501918501610c49565b50979650505050505050565b600060208284031215610c84578081fd5b8135610b8d81610f61565b600060208284031215610ca0578081fd5b8151610b8d81610f61565b600060408284031215610cbc578081fd5b610cc66040610f02565b82518152602083015160208201528091505092915050565b600060208284031215610cef578081fd5b5035919050565b600060208284031215610d07578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b901515815260200190565b6000602080835283518082850152825b81811015610d9857858101830151858201604001528201610d7c565b81811115610da95783604083870101525b50601f01601f1916929092016040019392505050565b6020808252600f908201526e6e6f2044414920746f207374616b6560881b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602c908201527f4f6e6c79206f776e6572206f72206176617461722063616e20706572666f726d60408201526b103a3434b99030b1ba34b7b760a11b606082015260800190565b90815260200190565b600060808201868352602060808185015281875180845260a0860191508289019350845b81811015610ed45784516001600160a01b031683529383019391830191600101610eaf565b50506001600160a01b039690961660408501525050506060015292915050565b918252602082015260400190565b60405181810167ffffffffffffffff81118282101715610f2157600080fd5b604052919050565b600067ffffffffffffffff821115610f3f578081fd5b5060209081020190565b6001600160a01b0381168114610f5e57600080fd5b50565b8015158114610f5e57600080fdfea2646970667358221220211b18970a82784a35af7c8f1be0194a71e74d2be3b3915a493db1656fd4362164736f6c634300060c0033",
"immutableReferences": {},
"sourceMap": "315:3458:7:-:0;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "315:3458:7:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;494:18;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;3691:80;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;1772:453::-;;;;;;:::i;:::-;;:::i;:::-;;469:22;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;361:29::-;;;;;;;;;;;;;:::i;2299:157::-;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;446:20::-;;;;;;;;;;;;;:::i;515:30::-;;;;;;;;;;;;;:::i;3051:78::-;;;;;;;;;;-1:-1:-1;3051:78:7;;;;;:::i;:::-;;:::i;1046:470::-;;;;;;;;;;-1:-1:-1;1046:470:7;;;;;:::i;:::-;;:::i;426:17::-;;;;;;;;;;;;;:::i;548:30::-;;;;;;;;;;;;;:::i;393:::-;;;;;;;;;;;;;:::i;3367:321::-;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;494:18::-;;;-1:-1:-1;;;494:18:7;;;;;:::o;3691:80::-;3753:14;;;;;;;;;;;;-1:-1:-1;;;3753:14:7;;;;3691:80;:::o;1772:453::-;995:6;;-1:-1:-1;;;995:6:7;;;;987:15;;;;;;1868:3:::1;::::0;:28:::1;::::0;-1:-1:-1;;;1868:28:7;;1847:18:::1;::::0;-1:-1:-1;;;;;1868:3:7::1;::::0;:13:::1;::::0;:28:::1;::::0;1890:4:::1;::::0;1868:28:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1847:49;;1900:18;1921:22;1929:13;1921:7;:22::i;:::-;1969:3;::::0;:28:::1;::::0;-1:-1:-1;;;1969:28:7;;1900:43;;-1:-1:-1;1948:18:7::1;::::0;-1:-1:-1;;;;;1969:3:7;;::::1;::::0;:13:::1;::::0;:28:::1;::::0;1991:4:::1;::::0;1969:28:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1948:49;;2022:1;2009:10;:14;2001:42;;;;-1:-1:-1::0;;;2001:42:7::1;;;;;;;:::i;:::-;;;;;;;;;2048:15;::::0;:36:::1;::::0;-1:-1:-1;;;2048:36:7;;-1:-1:-1;;;;;2048:15:7;;::::1;::::0;:24:::1;::::0;:36:::1;::::0;2073:10;;2048:36:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;2088:15:7::1;:29:::0;;;::::1;::::0;;-1:-1:-1;;2121:15:7::1;:29:::0;;;::::1;::::0;;2159:62:::1;::::0;::::1;::::0;::::1;::::0;2174:10:::1;::::0;2186;;2107;;2140;;2159:62:::1;:::i;:::-;;;;;;;;1006:1;;;1772:453:::0;:::o;469:22::-;;;-1:-1:-1;;;;;469:22:7;;:::o;361:29::-;;;;;;-1:-1:-1;;;;;361:29:7;;:::o;2299:157::-;2343:7;2356:28;;:::i;:::-;2387:15;;:38;;-1:-1:-1;;;2387:38:7;;-1:-1:-1;;;;;2387:15:7;;;;:23;;:38;;2419:4;;2387:38;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2436:16;;-1:-1:-1;;2299:157:7;:::o;446:20::-;;;-1:-1:-1;;;;;446:20:7;;:::o;515:30::-;;;;:::o;3051:78::-;747:5;;-1:-1:-1;;;;;747:5:7;733:10;:19;;:43;;-1:-1:-1;770:6:7;;;;;-1:-1:-1;;;;;770:6:7;756:10;:20;733:43;721:110;;;;-1:-1:-1;;;721:110:7;;;;;;;:::i;:::-;3109:6:::1;:16:::0;;;::::1;;-1:-1:-1::0;;;3109:16:7::1;-1:-1:-1::0;;;;3109:16:7;;::::1;::::0;;;::::1;::::0;;3051:78::o;1046:470::-;1472:13:16;;;;;;;;:33;;;1489:16;:14;:16::i;:::-;1472:50;;;-1:-1:-1;1510:12:16;;;;1509:13;1472:50;1464:109;;;;-1:-1:-1;;;1464:109:16;;;;;;;:::i;:::-;1584:19;1607:13;;;;;;1606:14;1630:98;;;;1664:13;:20;;-1:-1:-1;;;;1664:20:16;;;;;1698:19;1680:4;1698:19;;;1630:98;1163:5:7::1;:18:::0;;1171:10:::1;-1:-1:-1::0;;;;;;1163:18:7;;::::1;;::::0;;;1185:7:::1;:70:::0;;1211:42:::1;1185:70:::0;;::::1;;::::0;;1259:3:::1;:18:::0;;;::::1;-1:-1:-1::0;;;;;1259:18:7;;::::1;::::0;;;::::1;::::0;;;;-1:-1:-1;1281:16:7;;-1:-1:-1;;;;;;1281:16:7::1;::::0;;;::::1;;;::::0;;-1:-1:-1;1301:43:7;;;;::::1;::::0;;::::1;;::::0;;;;1348:115:::1;::::0;-1:-1:-1;;;1348:115:7;;:3;;::::1;::::0;:11:::1;::::0;:115:::1;::::0;1372:15;;;::::1;::::0;-1:-1:-1;;;1348:115:7::1;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1::0;1499:6:7::1;:13:::0;;-1:-1:-1;;;;1499:13:7::1;-1:-1:-1::0;;;1499:13:7::1;::::0;;1750:66:16;;;;1800:5;1784:21;;-1:-1:-1;;1784:21:16;;;1750:66;1046:470:7;;;;:::o;426:17::-;;;-1:-1:-1;;;;;426:17:7;;:::o;548:30::-;;;;:::o;393:::-;;;-1:-1:-1;;;;;393:30:7;;:::o;3367:321::-;747:5;;3412:7;;;;-1:-1:-1;;;;;747:5:7;733:10;:19;;:43;;-1:-1:-1;770:6:7;;;;;-1:-1:-1;;;;;770:6:7;756:10;:20;733:43;721:110;;;;-1:-1:-1;;;721:110:7;;;;;;;:::i;:::-;3434:15:::1;;;;;;;;;-1:-1:-1::0;;;;;3434:15:7::1;-1:-1:-1::0;;;;;3434:29:7::1;;:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;3490:3:7::1;::::0;:28:::1;::::0;-1:-1:-1;;;3490:28:7;;3469:18:::1;::::0;-1:-1:-1;;;;;;3490:3:7;;::::1;::::0;-1:-1:-1;3490:13:7::1;::::0;:28:::1;::::0;3512:4:::1;::::0;3490:28:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3568:3;::::0;3522:18:::1;3581:6:::0;3568:32:::1;::::0;-1:-1:-1;;;3568:32:7;;3469:49;;-1:-1:-1;3543:21:7::1;::::0;-1:-1:-1;;;;;3568:3:7;;::::1;::::0;:12:::1;::::0;:32:::1;::::0;3581:6;;;::::1;::::0;;::::1;::::0;3469:49;;3568:32:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1::0;3604:6:7::1;::::0;;:27:::1;::::0;:6;;;::::1;-1:-1:-1::0;;;;;3604:6:7::1;::::0;:27:::1;::::0;::::1;;::::0;;;;:6;:27;;:6;:27;::::1;;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;3635:6:7::1;:14:::0;;-1:-1:-1;;;;3635:14:7::1;::::0;;3661:10;;-1:-1:-1;3673:10:7;-1:-1:-1;3367:321:7;;:::o;2647:401::-;2705:7;2760:21;2789:15;2785:29;;2813:1;2806:8;;;;;2785:29;2842:16;;;2856:1;2842:16;;;2818:21;2842:16;;;;;2818:21;2842:16;;;;;;;;-1:-1:-1;;2880:3:7;;2862:7;;;;-1:-1:-1;;;;;;2880:3:7;;2862:7;;-1:-1:-1;2880:3:7;;2862:7;;;;;;;;;;;:22;-1:-1:-1;;;;;2862:22:7;;;-1:-1:-1;;;;;2862:22:7;;;;;2898:7;;;;;;;;;-1:-1:-1;;;;;2898:7:7;-1:-1:-1;;;;;2898:12:7;;:14;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2888:4;2893:1;2888:7;;;;;;;;-1:-1:-1;;;;;2888:24:7;;;:7;;;;;;;;;:24;2916:7;;;:107;;-1:-1:-1;;;2916:107:7;;:7;;;:29;;2954:10;;2916:107;;2971:13;;2989:4;;3006;;3016:3;;2916:107;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;2916:107:7;;;;;;;;;;;;:::i;:::-;-1:-1:-1;3034:10:7;;-1:-1:-1;;2647:401:7;;;;:::o;1912:593:16:-;2348:4;2456:17;2491:7;1912:593;:::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;:::o;2271:263::-;;2386:2;2374:9;2365:7;2361:23;2357:32;2354:2;;;-1:-1;;2392:12;2354:2;226:6;220:13;238:33;265:5;238:33;:::i;:::-;2444:74;2348:186;-1:-1;;;2348:186::o;2541:507::-;;;;2687:2;2675:9;2666:7;2662:23;2658:32;2655:2;;;-1:-1;;2693:12;2655:2;371:6;358:20;383:41;418:5;383:41;:::i;:::-;2745:71;-1:-1;2853:2;2892:22;;72:20;97:33;72:20;97:33;:::i;:::-;2861:63;-1:-1;2961:2;3000:22;;72:20;97:33;72:20;97:33;:::i;:::-;2969:63;;;;2649:399;;;;;:::o;3055:392::-;;3195:2;;3183:9;3174:7;3170:23;3166:32;3163:2;;;-1:-1;;3201:12;3163:2;3252:17;3246:24;3290:18;3282:6;3279:30;3276:2;;;-1:-1;;3312:12;3276:2;3399:22;;575:4;563:17;;559:27;-1:-1;549:2;;-1:-1;;590:12;549:2;630:6;624:13;652:80;667:64;724:6;667:64;:::i;:::-;652:80;:::i;:::-;760:21;;;817:14;;;;792:17;;;906;;;897:27;;;;894:36;-1:-1;891:2;;;-1:-1;;933:12;891:2;-1:-1;959:10;;953:217;978:6;975:1;972:13;953:217;;;2208:13;;1046:61;;1000:1;993:9;;;;;1121:14;;;;1149;;953:217;;;-1:-1;3332:99;3157:290;-1:-1;;;;;;;3157:290::o;3454:235::-;;3555:2;3543:9;3534:7;3530:23;3526:32;3523:2;;;-1:-1;;3561:12;3523:2;1261:6;1248:20;1273:30;1297:5;1273:30;:::i;3696:257::-;;3808:2;3796:9;3787:7;3783:23;3779:32;3776:2;;;-1:-1;;3814:12;3776:2;1396:6;1390:13;1408:30;1432:5;1408:30;:::i;3960:309::-;;4098:2;4086:9;4077:7;4073:23;4069:32;4066:2;;;-1:-1;;4104:12;4066:2;1637:20;4098:2;1637:20;:::i;:::-;2214:6;2208:13;1726:16;1719:86;1871:2;1940:9;1936:22;2208:13;1871:2;1890:5;1886:16;1879:86;4156:97;;;;4060:209;;;;:::o;4276:241::-;;4380:2;4368:9;4359:7;4355:23;4351:32;4348:2;;;-1:-1;;4386:12;4348:2;-1:-1;2060:20;;4342:175;-1:-1;4342:175::o;4524:263::-;;4639:2;4627:9;4618:7;4614:23;4610:32;4607:2;;;-1:-1;;4645:12;4607:2;-1:-1;2208:13;;4601:186;-1:-1;4601:186::o;8709:222::-;-1:-1;;;;;16600:54;;;;5212:45;;8836:2;8821:18;;8807:124::o;9444:349::-;-1:-1;;;;;16600:54;;;;5055:58;;9779:2;9764:18;;8660:37;9607:2;9592:18;;9578:215::o;9800:572::-;-1:-1;;;;;16600:54;;;;5055:58;;10192:2;10177:18;;8660:37;;;;10275:2;10260:18;;8660:37;10358:2;10343:18;;8660:37;10019:3;10004:19;;9990:382::o;10889:210::-;16512:13;;16505:21;6293:34;;11010:2;10995:18;;10981:118::o;11881:310::-;;12028:2;;12049:17;12042:47;7274:5;15598:12;16014:6;12028:2;12017:9;12013:18;16002:19;-1:-1;18258:101;18272:6;18269:1;18266:13;18258:101;;;18339:11;;;;;18333:18;18320:11;;;16042:14;18320:11;18313:39;18287:10;;18258:101;;;18374:6;18371:1;18368:13;18365:2;;;-1:-1;16042:14;18430:6;12017:9;18421:16;;18414:27;18365:2;-1:-1;18546:7;18530:14;-1:-1;;18526:28;7432:39;;;;16042:14;7432:39;;11999:192;-1:-1;;;11999:192::o;12198:416::-;12398:2;12412:47;;;7708:2;12383:18;;;16002:19;-1:-1;;;16042:14;;;7724:38;7781:12;;;12369:245::o;12621:416::-;12821:2;12835:47;;;8032:2;12806:18;;;16002:19;8068:34;16042:14;;;8048:55;-1:-1;;;8123:12;;;8116:38;8173:12;;;12792:245::o;13044:416::-;13244:2;13258:47;;;8424:2;13229:18;;;16002:19;8460:34;16042:14;;;8440:55;-1:-1;;;8515:12;;;8508:36;8563:12;;;13215:245::o;13467:222::-;8660:37;;;13594:2;13579:18;;13565:124::o;13696:720::-;;13965:3;13954:9;13950:19;8690:5;8667:3;8660:37;14084:2;13965:3;14084:2;14073:9;14069:18;14062:48;14124:108;5723:5;15598:12;16014:6;16009:3;16002:19;16042:14;13954:9;16042:14;5735:93;;14084:2;5899:5;15452:14;5911:21;;-1:-1;5938:260;5963:6;5960:1;5957:13;5938:260;;;6024:13;;-1:-1;;;;;16600:54;5212:45;;15857:14;;;;4948;;;;3290:18;5978:9;5938:260;;;-1:-1;;;;;;;16600:54;;;;14319:2;14304:18;;5055:58;-1:-1;;;14402:2;14387:18;8660:37;14116:116;13936:480;-1:-1;;13936:480::o;14423:333::-;8660:37;;;14742:2;14727:18;;8660:37;14578:2;14563:18;;14549:207::o;14763:256::-;14825:2;14819:9;14851:17;;;14926:18;14911:34;;14947:22;;;14908:62;14905:2;;;14983:1;;14973:12;14905:2;14825;14992:22;14803:216;;-1:-1;14803:216::o;15026:304::-;;15185:18;15177:6;15174:30;15171:2;;;-1:-1;;15207:12;15171:2;-1:-1;15252:4;15240:17;;;15305:15;;15108:222::o;18567:117::-;-1:-1;;;;;16600:54;;18626:35;;18616:2;;18675:1;;18665:12;18616:2;18610:74;:::o;18831:111::-;18912:5;16512:13;16505:21;18890:5;18887:32;18877:2;;18933:1;;18923:12",
"source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0;\n\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"../Interfaces.sol\";\n\n/**\n * @title DonationStaking contract that receives funds in ETH/DAI\n * and stake them in the SimpleStaking contract\n */\ncontract DonationsStaking is Initializable {\n\taddress payable public avatar;\n\tStaking public stakingContract;\n\tcERC20 public DAI;\n\taddress public owner;\n\tUniswap public uniswap;\n\tbool public active;\n\tuint256 public totalETHDonated;\n\tuint256 public totalDAIDonated;\n\n\tevent DonationStaked(\n\t\taddress caller,\n\t\tuint256 stakedDAI,\n\t\tuint256 ethDonated,\n\t\tuint256 daiDonated\n\t);\n\n\tmodifier ownerOrAvatar() {\n\t\trequire(\n\t\t\tmsg.sender == owner || msg.sender == avatar,\n\t\t\t\"Only owner or avatar can perform this action\"\n\t\t);\n\t\t_;\n\t}\n\n\tmodifier onlyAvatar() {\n\t\trequire(\n\t\t\tmsg.sender == avatar,\n\t\t\t\"Only DAO avatar can perform this action\"\n\t\t);\n\t\t_;\n\t}\n\n\tmodifier isActive() {\n\t\trequire(active);\n\t\t_;\n\t}\n\n\treceive() external payable {}\n\n\tfunction initialize(\n\t\taddress payable _avatar,\n\t\taddress _stakingContract,\n\t\taddress _dai\n\t) public initializer {\n\t\towner = msg.sender;\n\t\tuniswap = Uniswap(address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D));\n\t\tDAI = cERC20(_dai);\n\t\tavatar = _avatar;\n\t\tstakingContract = Staking(_stakingContract);\n\t\tDAI.approve(\n\t\t\taddress(stakingContract),\n\t\t\t0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n\t\t); //we trust the staking contract\n\t\tactive = true;\n\t}\n\n\t/**\n\t * @dev stake available funds. It\n\t * take balance in eth and buy DAI from uniswap then stake outstanding DAI balance.\n\t * anyone can call this.\n\t * @param _minDAIAmount enforce expected return from uniswap when converting eth balance to DAI\n\t */\n\tfunction stakeDonations(uint256 _minDAIAmount) public payable isActive {\n\t\tuint256 daiDonated = DAI.balanceOf(address(this));\n\t\tuint256 ethDonated = _buyDAI(_minDAIAmount);\n\n\t\tuint256 daiBalance = DAI.balanceOf(address(this));\n\t\trequire(daiBalance > 0, \"no DAI to stake\");\n\n\t\tstakingContract.stakeDAI(daiBalance);\n\t\ttotalETHDonated += ethDonated;\n\t\ttotalDAIDonated += daiDonated;\n\t\temit DonationStaked(msg.sender, daiBalance, ethDonated, daiDonated);\n\t}\n\n\t/**\n\t * @dev total DAI value staked\n\t * @return DAI value staked\n\t */\n\tfunction totalStaked() public view returns (uint256) {\n\t\tStaking.Staker memory staker = stakingContract.stakers(address(this));\n\t\treturn staker.stakedDAI;\n\t}\n\n\t/**\n\t * @dev internal method to buy DAI from uniswap\n\t * @param _minDAIAmount enforce expected return from uniswap when converting eth balance to DAI\n\t * @return eth value converted\n\t */\n\tfunction _buyDAI(uint256 _minDAIAmount) internal returns (uint256) {\n\t\t//buy from uniwasp\n\t\tuint256 ethBalance = address(this).balance;\n\t\tif (ethBalance == 0) return 0;\n\t\taddress[] memory path = new address[](2);\n\t\tpath[1] = address(DAI);\n\t\tpath[0] = uniswap.WETH();\n\t\tuniswap.swapExactETHForTokens{ value: ethBalance }(\n\t\t\t_minDAIAmount,\n\t\t\tpath,\n\t\t\taddress(this),\n\t\t\tnow\n\t\t);\n\t\treturn ethBalance;\n\t}\n\n\tfunction setActive(bool _active) public ownerOrAvatar {\n\t\tactive = _active;\n\t}\n\n\t/**\n\t * @dev withdraws all stakes and then transfer all balances to avatar\n\t * this can also be called by owner(Foundation) but it is safe as funds are transfered to avatarMock\n\t * and only avatar can upgrade this contract logic\n\t */\n\tfunction end() public ownerOrAvatar returns (uint256, uint256) {\n\t\tstakingContract.withdrawStake();\n\t\tuint256 daiBalance = DAI.balanceOf(address(this));\n\t\tuint256 ethBalance = address(this).balance;\n\t\tDAI.transfer(avatar, daiBalance);\n\t\tavatar.transfer(ethBalance);\n\t\tactive = false;\n\t\treturn (daiBalance, ethBalance);\n\t}\n\n\tfunction getVersion() public pure returns (string memory) {\n\t\treturn \"1.1.0\";\n\t}\n}\n",
"sourcePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/staking/DonationsStaking.sol",
"ast": {
"absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/staking/DonationsStaking.sol",
"exportedSymbols": {
"DonationsStaking": [
5127
]
},
"id": 5128,
"license": "MIT",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 4769,
"literals": [
"solidity",
">=",
"0.6",
".0"
],
"nodeType": "PragmaDirective",
"src": "33:24:7"
},
{
"id": 4770,
"literals": [
"experimental",
"ABIEncoderV2"
],
"nodeType": "PragmaDirective",
"src": "59:33:7"
},
{
"absolutePath": "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol",
"file": "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol",
"id": 4771,
"nodeType": "ImportDirective",
"scope": 5128,
"sourceUnit": 8212,
"src": "94:69:7",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/Users/hadar/workspace/GoodDollar/GoodBootstrap/packages/contracts/upgradables/contracts/Interfaces.sol",
"file": "../Interfaces.sol",
"id": 4772,
"nodeType": "ImportDirective",
"scope": 5128,
"sourceUnit": 552,
"src": "164:27:7",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [
{
"arguments": null,
"baseName": {
"contractScope": null,
"id": 4774,
"name": "Initializable",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8211,
"src": "344:13:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Initializable_$8211",
"typeString": "contract Initializable"
}
},
"id": 4775,
"nodeType": "InheritanceSpecifier",
"src": "344:13:7"
}
],
"contractDependencies": [
8211
],
"contractKind": "contract",
"documentation": {
"id": 4773,
"nodeType": "StructuredDocumentation",
"src": "193:121:7",
"text": " @title DonationStaking contract that receives funds in ETH/DAI\n and stake them in the SimpleStaking contract"
},
"fullyImplemented": true,
"id": 5127,
"linearizedBaseContracts": [
5127,
8211
],
"name": "DonationsStaking",
"nodeType": "ContractDefinition",
"nodes": [
{
"constant": false,
"functionSelector": "5aef7de6",
"id": 4777,
"mutability": "mutable",
"name": "avatar",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "361:29:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
},
"typeName": {
"id": 4776,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "361:15:7",
"stateMutability": "payable",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"functionSelector": "ee99205c",
"id": 4779,
"mutability": "mutable",
"name": "stakingContract",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "393:30:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Staking_$351",
"typeString": "contract Staking"
},
"typeName": {
"contractScope": null,
"id": 4778,
"name": "Staking",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 351,
"src": "393:7:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Staking_$351",
"typeString": "contract Staking"
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"functionSelector": "e0bab4c4",
"id": 4781,
"mutability": "mutable",
"name": "DAI",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "426:17:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_contract$_cERC20_$309",
"typeString": "contract cERC20"
},
"typeName": {
"contractScope": null,
"id": 4780,
"name": "cERC20",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 309,
"src": "426:6:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_cERC20_$309",
"typeString": "contract cERC20"
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"functionSelector": "8da5cb5b",
"id": 4783,
"mutability": "mutable",
"name": "owner",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "446:20:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 4782,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "446:7:7",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"functionSelector": "2681f7e4",
"id": 4785,
"mutability": "mutable",
"name": "uniswap",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "469:22:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Uniswap_$444",
"typeString": "contract Uniswap"
},
"typeName": {
"contractScope": null,
"id": 4784,
"name": "Uniswap",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 444,
"src": "469:7:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Uniswap_$444",
"typeString": "contract Uniswap"
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"functionSelector": "02fb0c5e",
"id": 4787,
"mutability": "mutable",
"name": "active",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "494:18:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 4786,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "494:4:7",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"functionSelector": "90420628",
"id": 4789,
"mutability": "mutable",
"name": "totalETHDonated",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 5127,
"src": "515:30:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 4788,