pragmasolidity ^0.7.6;//SPDX-License-Identifier: MIT/** @title Admin contract *//// @author PaladincontractAdmin{
/** @notice (Admin) Event when the contract admin is updated */eventNewAdmin(address oldAdmin, address newAdmin);
/** @dev Admin address for this contract */addresspayableinternal admin;
modifieradminOnly() {
//allows only the admin of this contract to call the functionrequire(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
*/functionsetNewAdmin(addresspayable _newAdmin) externaladminOnly{
address _oldAdmin = admin;
admin = _newAdmin;
emit NewAdmin(_oldAdmin, _newAdmin);
}
}
Contract Source Code
File 2 of 5: Errors.sol
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝pragmasolidity ^0.7.6;//SPDX-License-Identifier: MITlibraryErrors{
// Admin errorstringpublicconstant CALLER_NOT_ADMIN ='1'; // 'The caller must be the admin'stringpublicconstant CALLER_NOT_CONTROLLER ='29'; // 'The caller must be the admin or the controller'stringpublicconstant CALLER_NOT_ALLOWED_POOL ='30'; // 'The caller must be a palPool listed in the controller'stringpublicconstant CALLER_NOT_MINTER ='31';
// ERC20 type errorsstringpublicconstant FAIL_TRANSFER ='2';
stringpublicconstant FAIL_TRANSFER_FROM ='3';
stringpublicconstant BALANCE_TOO_LOW ='4';
stringpublicconstant ALLOWANCE_TOO_LOW ='5';
stringpublicconstant SELF_TRANSFER ='6';
// PalPool errorsstringpublicconstant INSUFFICIENT_CASH ='9';
stringpublicconstant INSUFFICIENT_BALANCE ='10';
stringpublicconstant FAIL_DEPOSIT ='11';
stringpublicconstant FAIL_LOAN_INITIATE ='12';
stringpublicconstant FAIL_BORROW ='13';
stringpublicconstant ZERO_BORROW ='27';
stringpublicconstant BORROW_INSUFFICIENT_FEES ='23';
stringpublicconstant LOAN_CLOSED ='14';
stringpublicconstant NOT_LOAN_OWNER ='15';
stringpublicconstant LOAN_OWNER ='16';
stringpublicconstant FAIL_LOAN_EXPAND ='17';
stringpublicconstant NOT_KILLABLE ='18';
stringpublicconstant RESERVE_FUNDS_INSUFFICIENT ='19';
stringpublicconstant FAIL_MINT ='20';
stringpublicconstant FAIL_BURN ='21';
stringpublicconstant FAIL_WITHDRAW ='24';
stringpublicconstant FAIL_CLOSE_BORROW ='25';
stringpublicconstant FAIL_KILL_BORROW ='26';
stringpublicconstant ZERO_ADDRESS ='22';
stringpublicconstant INVALID_PARAMETERS ='28';
stringpublicconstant FAIL_LOAN_DELEGATEE_CHANGE ='32';
stringpublicconstant FAIL_LOAN_TOKEN_BURN ='33';
stringpublicconstant FEES_ACCRUED_INSUFFICIENT ='34';
}
Contract Source Code
File 3 of 5: IERC20.sol
// SPDX-License-Identifier: agpl-3.0pragmasolidity ^0.7.6;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransfer(address recipient, uint256 amount) externalreturns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/functionallowance(address owner, address spender) externalviewreturns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/functionapprove(address spender, uint256 amount) externalreturns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransferFrom(address sender,
address recipient,
uint256 amount
) externalreturns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
}
pragmasolidity ^0.7.6;//SPDX-License-Identifier: MIT// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol// Subject to the MIT license./**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/librarySafeMath{
/**
* @dev Returns the addition of two unsigned integers, reverting on overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/functionadd(uint256 a, uint256 b) internalpurereturns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the addition of two unsigned integers, reverting with custom message on overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/functionadd(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
uint256 c = a + b;
require(c >= a, errorMessage);
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot underflow.
*/functionsub(uint256 a, uint256 b) internalpurereturns (uint256) {
return sub(a, b, "SafeMath: subtraction underflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot underflow.
*/functionsub(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/functionmul(uint256 a, uint256 b) internalpurereturns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the// benefit is lost if 'b' is also tested.// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522if (a ==0) {
return0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/functionmul(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the// benefit is lost if 'b' is also tested.// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522if (a ==0) {
return0;
}
uint256 c = a * b;
require(c / a == b, errorMessage);
return c;
}
/**
* @dev Returns the integer division of two unsigned integers.
* Reverts on division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/functiondiv(uint256 a, uint256 b) internalpurereturns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers.
* Reverts with custom message on division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/functiondiv(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
// Solidity only automatically asserts when dividing by 0require(b >0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't holdreturn c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/functionmod(uint256 a, uint256 b) internalpurereturns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/functionmod(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
require(b !=0, errorMessage);
return a % b;
}
}