Feature Tip: Add private address tag to any address under My Name Tag !
Contract Overview
More Info
[ Download CSV Export ]
View more zero value Internal Transactions in Advanced View mode
Contract Name:
ControllerProxy
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 25000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗ //██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║ //██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║ //██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║ //██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║ //╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝ pragma solidity ^0.7.6; //SPDX-License-Identifier: MIT import "./utils/Errors.sol"; import "./ControllerStorage.sol"; /** @title Paladin Controller contract */ /// @author Paladin contract ControllerProxy is ControllerStorage { event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation); event NewImplementation(address oldImplementation, address newImplementation); constructor(){ admin = msg.sender; } /** * @dev Proposes the address of a new Implementation (the new Controller contract) */ function proposeImplementation(address newPendingImplementation) public adminOnly { address oldPendingImplementation = pendingImplementation; pendingImplementation = newPendingImplementation; emit NewPendingImplementation(oldPendingImplementation, newPendingImplementation); } /** * @dev Accepts the Pending Implementation as new Current Implementation * Only callable by the Pending Implementation contract */ function acceptImplementation() public returns(bool) { require(msg.sender == pendingImplementation || pendingImplementation == address(0), Errors.CALLER_NOT_IMPLEMENTATION); address oldImplementation = currentImplementation; address oldPendingImplementation = pendingImplementation; currentImplementation = pendingImplementation; pendingImplementation = address(0); emit NewImplementation(oldImplementation, currentImplementation); emit NewPendingImplementation(oldPendingImplementation, pendingImplementation); return true; } /** * @dev Delegates execution to an implementation contract. * It returns to the external caller whatever the implementation returns * or forwards reverts. */ fallback() external payable { // delegate all other functions to current implementation (bool success, ) = currentImplementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize()) switch success case 0 { revert(free_mem_ptr, returndatasize()) } default { return(free_mem_ptr, returndatasize()) } } } }
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗ //██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║ //██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║ //██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║ //██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║ //╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝ pragma solidity ^0.7.6; //SPDX-License-Identifier: MIT library Errors { // Admin error string public constant CALLER_NOT_ADMIN = '1'; // 'The caller must be the admin' string public constant CALLER_NOT_CONTROLLER = '29'; // 'The caller must be the admin or the controller' string public constant CALLER_NOT_ALLOWED_POOL = '30'; // 'The caller must be a palPool listed in the controller' string public constant CALLER_NOT_MINTER = '31'; string public constant CALLER_NOT_IMPLEMENTATION = '35'; // 'The caller must be the pending Implementation' // ERC20 type errors string public constant FAIL_TRANSFER = '2'; string public constant FAIL_TRANSFER_FROM = '3'; string public constant BALANCE_TOO_LOW = '4'; string public constant ALLOWANCE_TOO_LOW = '5'; string public constant SELF_TRANSFER = '6'; // PalPool errors string public constant INSUFFICIENT_CASH = '9'; string public constant INSUFFICIENT_BALANCE = '10'; string public constant FAIL_DEPOSIT = '11'; string public constant FAIL_LOAN_INITIATE = '12'; string public constant FAIL_BORROW = '13'; string public constant ZERO_BORROW = '27'; string public constant BORROW_INSUFFICIENT_FEES = '23'; string public constant LOAN_CLOSED = '14'; string public constant NOT_LOAN_OWNER = '15'; string public constant LOAN_OWNER = '16'; string public constant FAIL_LOAN_EXPAND = '17'; string public constant NOT_KILLABLE = '18'; string public constant RESERVE_FUNDS_INSUFFICIENT = '19'; string public constant FAIL_MINT = '20'; string public constant FAIL_BURN = '21'; string public constant FAIL_WITHDRAW = '24'; string public constant FAIL_CLOSE_BORROW = '25'; string public constant FAIL_KILL_BORROW = '26'; string public constant ZERO_ADDRESS = '22'; string public constant INVALID_PARAMETERS = '28'; string public constant FAIL_LOAN_DELEGATEE_CHANGE = '32'; string public constant FAIL_LOAN_TOKEN_BURN = '33'; string public constant FEES_ACCRUED_INSUFFICIENT = '34'; //Controller errors string public constant LIST_SIZES_NOT_EQUAL = '36'; string public constant POOL_LIST_ALREADY_SET = '37'; string public constant POOL_ALREADY_LISTED = '38'; string public constant POOL_NOT_LISTED = '39'; string public constant CALLER_NOT_POOL = '40'; string public constant REWARDS_CASH_TOO_LOW = '41'; string public constant FAIL_BECOME_IMPLEMENTATION = '42'; string public constant INSUFFICIENT_DEPOSITED = '43'; string public constant NOT_CLAIMABLE = '44'; string public constant LOCKED = '45'; }
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗ //██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║ //██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║ //██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║ //██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║ //╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝ pragma solidity ^0.7.6; //SPDX-License-Identifier: MIT import "./utils/Admin.sol"; /** @title Paladin Controller contract */ /// @author Paladin contract ControllerStorage is Admin { /** @notice Layout for the Proxy contract */ address public currentImplementation; address public pendingImplementation; /** @notice List of current active palToken Pools */ address[] public palTokens; address[] public palPools; mapping(address => address) public palTokenToPalPool; bool internal initialized; /** @notice Struct with current SupplyIndex for a Pool, and the block of the last update */ struct PoolRewardsState { uint224 index; uint32 blockNumber; } /** @notice Initial index for Rewards */ uint224 public constant initialRewardsIndex = 1e36; address public rewardTokenAddress; // PAL token address to put here /** @notice State of the Rewards for each Pool */ mapping(address => PoolRewardsState) public supplyRewardState; /** @notice Amount of reward tokens to distribute each block */ mapping(address => uint) public supplySpeeds; /** @notice Last reward index for each Pool for each user */ /** PalPool => User => Index */ mapping(address => mapping(address => uint)) public supplierRewardIndex; /** @notice Deposited amounts by user for each palToken (indexed by corresponding PalPool address) */ /** PalPool => User => Amount */ mapping(address => mapping(address => uint)) public supplierDeposits; /** @notice Total amount of each palToken deposited (indexed by corresponding PalPool address) */ /** PalPool => Total Amount */ mapping(address => uint) public totalSupplierDeposits; /** @notice Ratio to distribute Borrow Rewards */ mapping(address => uint) public borrowRatios; // scaled 1e18 /** @notice Ratio for each PalLoan (set at PalLoan creation) */ mapping(address => uint) public loansBorrowRatios; // scaled 1e18 /** @notice Amount of reward Tokens accrued by the user, and claimable */ mapping(address => uint) public accruedRewards; /** @notice Is Auto Borrow Rewards is activated for the PalPool */ mapping(address => bool) public autoBorrowRewards; /** @notice Was PalLoan Borrow Rewards distributed & claimed */ mapping(address => bool) public isLoanRewardClaimed; /** @notice Block at which Borrow Rewards Ratio where set for the PalPool (if Ratio is put back to 0, this block number is set back to 0 too) */ /** So PalLoan started when no Borrow Rewards where set do not receive rewards */ /** PalPool => Block Number */ mapping(address => uint) public borrowRewardsStartBlock; /** @dev Prevent reentry in some functions */ bool internal locked; /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!! ALWAYS PUT NEW STORAGE AT THE BOTTOM !!!!!!!!!!!!!!!!!! !!!!!!!!! WE DON'T WANT COLLISION WHEN SWITCHING IMPLEMENTATIONS !!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ }
pragma solidity ^0.7.6; //SPDX-License-Identifier: MIT /** @title Admin contract */ /// @author Paladin contract Admin { /** @notice (Admin) Event when the contract admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** @dev Admin address for this contract */ address payable internal admin; modifier adminOnly() { //allows only the admin of this contract to call the function require(msg.sender == admin, '1'); _; } /** * @notice Set a new Admin * @dev Changes the address for the admin parameter * @param _newAdmin address of the new Controller Admin */ function setNewAdmin(address payable _newAdmin) external adminOnly { address _oldAdmin = admin; admin = _newAdmin; emit NewAdmin(_oldAdmin, _newAdmin); } }
{ "optimizer": { "enabled": true, "runs": 25000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"NewPendingImplementation","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"acceptImplementation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accruedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"autoBorrowRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowRatios","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowRewardsStartBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialRewardsIndex","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isLoanRewardClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"loansBorrowRatios","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"palPools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"palTokenToPalPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"palTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"proposeImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newAdmin","type":"address"}],"name":"setNewAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"supplierDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"supplierRewardIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supplyRewardState","outputs":[{"internalType":"uint224","name":"index","type":"uint224"},{"internalType":"uint32","name":"blockNumber","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supplySpeeds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalSupplierDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50600080546001600160a01b03191633179055610d62806100326000396000f3fe60806040526004361061016a5760003560e01c80634c263c53116100cb5780639dd18c151161007f578063d8bd5c2911610059578063d8bd5c2914610671578063db5ea61314610686578063eb3f9c91146106c65761016a565b80639dd18c15146105ab578063aa9e415a146105eb578063c24525b51461062b5761016a565b806382fc8810116100b057806382fc8810146104e95780638eec99c8146105295780639c5b00a31461056b5761016a565b80634c263c53146104595780636e8f4205146104a15761016a565b80632770cff511610122578063396f7b2311610107578063396f7b23146103da578063418b8e01146103ef57806345d465a2146104195761016a565b80632770cff5146103705780632d03d3ec146103b05761016a565b806315ba56e51161015357806315ba56e51461028a578063234ab4cb146102b3578063275bd214146102f35761016a565b8063125f9e33146101fa578063128fced114610238575b60015460405160009173ffffffffffffffffffffffffffffffffffffffff1690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146101da576040519150601f19603f3d011682016040523d82523d6000602084013e6101df565b606091505b505090506040513d6000823e8180156101f6573d82f35b3d82fd5b34801561020657600080fd5b5061020f610706565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561024457600080fd5b506102786004803603602081101561025b57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610727565b60408051918252519081900360200190f35b34801561029657600080fd5b5061029f610739565b604080519115158252519081900360200190f35b3480156102bf57600080fd5b50610278600480360360208110156102d657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610940565b3480156102ff57600080fd5b506103336004803603602081101561031657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610952565b604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff909316835263ffffffff90911660208301528051918290030190f35b34801561037c57600080fd5b506102786004803603602081101561039357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109aa565b3480156103bc57600080fd5b5061020f600480360360208110156103d357600080fd5b50356109bc565b3480156103e657600080fd5b5061020f6109f3565b3480156103fb57600080fd5b5061020f6004803603602081101561041257600080fd5b5035610a0f565b34801561042557600080fd5b5061029f6004803603602081101561043c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610a1f565b34801561046557600080fd5b506102786004803603604081101561047c57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610a34565b3480156104ad57600080fd5b50610278600480360360408110156104c457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610a51565b3480156104f557600080fd5b5061020f6004803603602081101561050c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610a6e565b34801561053557600080fd5b506105696004803603602081101561054c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610a96565b005b34801561057757600080fd5b506102786004803603602081101561058e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610ba4565b3480156105b757600080fd5b50610569600480360360208110156105ce57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610bb6565b3480156105f757600080fd5b506102786004803603602081101561060e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610cc4565b34801561063757600080fd5b50610640610cd6565b604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561067d57600080fd5b5061020f610ce9565b34801561069257600080fd5b50610278600480360360208110156106a957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d05565b3480156106d257600080fd5b5061029f600480360360208110156106e957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d17565b600654610100900473ffffffffffffffffffffffffffffffffffffffff1681565b600e6020526000908152604090205481565b60025460009073ffffffffffffffffffffffffffffffffffffffff16331480610778575060025473ffffffffffffffffffffffffffffffffffffffff16155b6040518060400160405280600281526020017f333500000000000000000000000000000000000000000000000000000000000081525090610851576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108165781810151838201526020016107fe565b50505050905090810190601f1680156108435780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600180546002805473ffffffffffffffffffffffffffffffffffffffff8082167fffffffffffffffffffffffff000000000000000000000000000000000000000080861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a16002546040805173ffffffffffffffffffffffffffffffffffffffff8085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160019250505090565b600d6020526000908152604090205481565b6007602052600090815260409020547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8116907c0100000000000000000000000000000000000000000000000000000000900463ffffffff1682565b60086020526000908152604090205481565b600481815481106109cc57600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b600381815481106109cc57600080fd5b60106020526000908152604090205460ff1681565b600960209081526000928352604080842090915290825290205481565b600a60209081526000928352604080842090915290825290205481565b60056020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b1c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040805191909216808252602082019390935281517ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc929181900390910190a15050565b600c6020526000908152604090205481565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c3c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6002805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040805191909216808252602082019390935281517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d815929181900390910190a15050565b600b6020526000908152604090205481565b6ec097ce7bc90715b34b9f100000000081565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60116020526000908152604090205481565b600f6020526000908152604090205460ff168156fea2646970667358221220fbdf3054da5c1b2127f903d60e530f58c33f202d3fcc924af8c2e164afb65aa664736f6c63430007060033
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.