// Verified using https://dapp.tools
// hevm: flattened sources of src/lender/operator.sol
pragma solidity >=0.5.15 >=0.5.15 <0.6.0;
////// lib/tinlake-auth/lib/ds-note/src/note.sol
/// note.sol -- the `note' modifier, for logging calls as events
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/* pragma solidity >=0.5.15; */
contract DSNote {
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 indexed bar,
uint256 wad,
bytes fax
) anonymous;
modifier note {
bytes32 foo;
bytes32 bar;
uint256 wad;
assembly {
foo := calldataload(4)
bar := calldataload(36)
wad := callvalue()
}
_;
emit LogNote(msg.sig, msg.sender, foo, bar, wad, msg.data);
}
}
////// lib/tinlake-auth/src/auth.sol
// Copyright (C) Centrifuge 2020, based on MakerDAO dss https://github.com/makerdao/dss
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.5.15 <0.6.0; */
/* import "ds-note/note.sol"; */
contract Auth is DSNote {
mapping (address => uint) public wards;
function rely(address usr) public auth note { wards[usr] = 1; }
function deny(address usr) public auth note { wards[usr] = 0; }
modifier auth { require(wards[msg.sender] == 1); _; }
}
////// src/lender/operator.sol
// Copyright (C) 2020 Centrifuge
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.5.15 <0.6.0; */
/* import "ds-note/note.sol"; */
/* import "tinlake-auth/auth.sol"; */
contract TrancheLike_2 {
function supplyOrder(address usr, uint currencyAmount) public;
function redeemOrder(address usr, uint tokenAmount) public;
function disburse(address usr) public returns (uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken);
function disburse(address usr, uint endEpoch) public returns (uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken);
function currency() public view returns (address);
}
interface RestrictedTokenLike {
function hasMember(address) external view returns (bool);
}
interface EIP2612PermitLike {
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
interface DaiPermitLike {
function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external;
}
contract Operator is DSNote, Auth {
TrancheLike_2 public tranche;
RestrictedTokenLike public token;
constructor(address tranche_) public {
wards[msg.sender] = 1;
tranche = TrancheLike_2(tranche_);
}
/// sets the dependency to another contract
function depend(bytes32 contractName, address addr) public auth {
if (contractName == "tranche") { tranche = TrancheLike_2(addr); }
else if (contractName == "token") { token = RestrictedTokenLike(addr); }
else revert();
}
/// only investors that are on the memberlist can submit supplyOrders
function supplyOrder(uint amount) public note {
require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token");
tranche.supplyOrder(msg.sender, amount);
}
/// only investors that are on the memberlist can submit redeemOrders
function redeemOrder(uint amount) public note {
require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token");
token.hasMember(msg.sender);
tranche.redeemOrder(msg.sender, amount);
}
/// only investors that are on the memberlist can disburse
function disburse() external
returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken)
{
require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token");
return tranche.disburse(msg.sender);
}
function disburse(uint endEpoch) external
returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken)
{
require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token");
return tranche.disburse(msg.sender, endEpoch);
}
// --- Permit Support ---
function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public {
DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s);
supplyOrder(amount);
}
function supplyOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public {
EIP2612PermitLike(tranche.currency()).permit(msg.sender, address(tranche), value, deadline, v, r, s);
supplyOrder(amount);
}
function redeemOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public {
EIP2612PermitLike(address(token)).permit(msg.sender, address(tranche), value, deadline, v, r, s);
redeemOrder(amount);
}
}
{
"compilationTarget": {
"Operator.sol": "Operator"
},
"evmVersion": "istanbul",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"tranche_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":true,"internalType":"address","name":"guy","type":"address"},{"indexed":true,"internalType":"bytes32","name":"foo","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"bar","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"contractName","type":"bytes32"},{"internalType":"address","name":"addr","type":"address"}],"name":"depend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"disburse","outputs":[{"internalType":"uint256","name":"payoutCurrencyAmount","type":"uint256"},{"internalType":"uint256","name":"payoutTokenAmount","type":"uint256"},{"internalType":"uint256","name":"remainingSupplyCurrency","type":"uint256"},{"internalType":"uint256","name":"remainingRedeemToken","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"endEpoch","type":"uint256"}],"name":"disburse","outputs":[{"internalType":"uint256","name":"payoutCurrencyAmount","type":"uint256"},{"internalType":"uint256","name":"payoutTokenAmount","type":"uint256"},{"internalType":"uint256","name":"remainingSupplyCurrency","type":"uint256"},{"internalType":"uint256","name":"remainingRedeemToken","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeemOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"redeemOrderWithPermit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"supplyOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"supplyOrderWithDaiPermit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"supplyOrderWithPermit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"internalType":"contract RestrictedTokenLike","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tranche","outputs":[{"internalType":"contract TrancheLike_2","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]