test-contracts-sovryn
Version:
Smart contracts for the Sovryn protocol and external integrations.
64 lines • 46 MB
JSON
{
"id": "2b18e7333e3e4e2cf3704f201bb8b6bb",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.5.17",
"solcLongVersion": "0.5.17+commit.d19bba13",
"input": {
"language": "Solidity",
"sources": {
"contracts/connectors/loantoken/AdvancedToken.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\nimport \"./AdvancedTokenStorage.sol\";\n\n/**\n * @title Advanced Token contract.\n * @notice This contract code comes from bZx. bZx is a protocol for tokenized margin\n * trading and lending https://bzx.network similar to the dYdX protocol.\n *\n * AdvancedToken implements standard ERC-20 approval, mint and burn token functionality.\n * Logic (AdvancedToken) is kept aside from storage (AdvancedTokenStorage).\n *\n * For example, LoanTokenLogicDai contract uses AdvancedToken::_mint() to mint\n * its Loan Dai iTokens.\n * */\ncontract AdvancedToken is AdvancedTokenStorage {\n\tusing SafeMath for uint256;\n\n\t/**\n\t * @notice Set an amount as the allowance of `spender` over the caller's tokens.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * IMPORTANT: Beware that changing an allowance with this method brings the risk\n\t * that someone may use both the old and the new allowance by unfortunate\n\t * transaction ordering. One possible solution to mitigate this race\n\t * condition is to first reduce the spender's allowance to 0 and set the\n\t * desired value afterwards:\n\t * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n\t *\n\t * Emits an {Approval} event.\n\t *\n\t * @param _spender The account address that will be able to spend the tokens.\n\t * @param _value The amount of tokens allowed to spend.\n\t * */\n\tfunction approve(address _spender, uint256 _value) public returns (bool) {\n\t\tallowed[msg.sender][_spender] = _value;\n\t\temit Approval(msg.sender, _spender, _value);\n\t\treturn true;\n\t}\n\n\t/**\n\t * @notice The iToken minting process. Meant to issue Loan iTokens.\n\t * Lenders are able to open an iToken position, by minting them.\n\t * This function is called by LoanTokenLogicStandard::_mintToken\n\t * @param _to The recipient of the minted tTokens.\n\t * @param _tokenAmount The amount of iTokens to be minted.\n\t * @param _assetAmount The amount of lended tokens (asset to lend).\n\t * @param _price The price of the lended tokens.\n\t * @return The updated balance of the recipient.\n\t * */\n\tfunction _mint(\n\t\taddress _to,\n\t\tuint256 _tokenAmount,\n\t\tuint256 _assetAmount,\n\t\tuint256 _price\n\t) internal returns (uint256) {\n\t\trequire(_to != address(0), \"15\");\n\n\t\tuint256 _balance = balances[_to].add(_tokenAmount);\n\t\tbalances[_to] = _balance;\n\n\t\ttotalSupply_ = totalSupply_.add(_tokenAmount);\n\n\t\temit Mint(_to, _tokenAmount, _assetAmount, _price);\n\t\temit Transfer(address(0), _to, _tokenAmount);\n\n\t\treturn _balance;\n\t}\n\n\t/**\n\t * @notice The iToken burning process. Meant to destroy Loan iTokens.\n\t * Lenders are able to close an iToken position, by burning them.\n\t * This function is called by LoanTokenLogicStandard::_burnToken\n\t * @param _who The owner of the iTokens to burn.\n\t * @param _tokenAmount The amount of iTokens to burn.\n\t * @param _assetAmount The amount of lended tokens.\n\t * @param _price The price of the lended tokens.\n\t * @return The updated balance of the iTokens owner.\n\t * */\n\tfunction _burn(\n\t\taddress _who,\n\t\tuint256 _tokenAmount,\n\t\tuint256 _assetAmount,\n\t\tuint256 _price\n\t) internal returns (uint256) {\n\t\t//bzx compare\n\t\t//TODO: Unit test\n\t\tuint256 _balance = balances[_who].sub(_tokenAmount, \"16\");\n\n\t\t// a rounding error may leave dust behind, so we clear this out\n\t\tif (_balance <= 10) {\n\t\t\t// We can't leave such small balance quantities.\n\t\t\t_tokenAmount = _tokenAmount.add(_balance);\n\t\t\t_balance = 0;\n\t\t}\n\t\tbalances[_who] = _balance;\n\n\t\ttotalSupply_ = totalSupply_.sub(_tokenAmount);\n\n\t\temit Burn(_who, _tokenAmount, _assetAmount, _price);\n\t\temit Transfer(_who, address(0), _tokenAmount);\n\t\treturn _balance;\n\t}\n}\n"
},
"contracts/connectors/loantoken/AdvancedTokenStorage.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\nimport \"./LoanTokenBase.sol\";\n\n/**\n * @title Advanced Token Storage contract.\n * @notice This contract code comes from bZx. bZx is a protocol for tokenized\n * margin trading and lending https://bzx.network similar to the dYdX protocol.\n *\n * AdvancedTokenStorage implements standard ERC-20 getters functionality:\n * totalSupply, balanceOf, allowance and some events.\n * iToken logic is divided into several contracts AdvancedToken,\n * AdvancedTokenStorage and LoanTokenBase.\n * */\ncontract AdvancedTokenStorage is LoanTokenBase {\n\tusing SafeMath for uint256;\n\n\t/* Events */\n\n\t/// topic: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\n\tevent Transfer(address indexed from, address indexed to, uint256 value);\n\n\t/// topic: 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925\n\tevent Approval(address indexed owner, address indexed spender, uint256 value);\n\n\t/// topic: 0xb4c03061fb5b7fed76389d5af8f2e0ddb09f8c70d1333abbb62582835e10accb\n\tevent Mint(address indexed minter, uint256 tokenAmount, uint256 assetAmount, uint256 price);\n\n\t/// topic: 0x743033787f4738ff4d6a7225ce2bd0977ee5f86b91a902a58f5e4d0b297b4644\n\tevent Burn(address indexed burner, uint256 tokenAmount, uint256 assetAmount, uint256 price);\n\n\tevent FlashBorrow(address borrower, address target, address loanToken, uint256 loanAmount);\n\n\t/* Storage */\n\n\tmapping(address => uint256) internal balances;\n\tmapping(address => mapping(address => uint256)) internal allowed;\n\tuint256 internal totalSupply_;\n\n\t/* Functions */\n\n\t/**\n\t * @notice Get the total supply of iTokens.\n\t * @return The total number of iTokens in existence as of now.\n\t * */\n\tfunction totalSupply() public view returns (uint256) {\n\t\treturn totalSupply_;\n\t}\n\n\t/**\n\t * @notice Get the amount of iTokens owned by an account.\n\t * @param _owner The account owner of the iTokens.\n\t * @return The number of iTokens an account owns.\n\t * */\n\tfunction balanceOf(address _owner) public view returns (uint256) {\n\t\treturn balances[_owner];\n\t}\n\n\t/**\n\t * @notice Get the amount of iTokens allowed to be spent by a\n\t * given account on behalf of the owner.\n\t * @param _owner The account owner of the iTokens.\n\t * @param _spender The account allowed to send the iTokens.\n\t * @return The number of iTokens an account is allowing the spender\n\t * to send on its behalf.\n\t * */\n\tfunction allowance(address _owner, address _spender) public view returns (uint256) {\n\t\treturn allowed[_owner][_spender];\n\t}\n}\n"
},
"contracts/connectors/loantoken/LoanTokenBase.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\nimport \"../../openzeppelin/SafeMath.sol\";\nimport \"../../openzeppelin/SignedSafeMath.sol\";\nimport \"../../openzeppelin/ReentrancyGuard.sol\";\nimport \"../../openzeppelin/Ownable.sol\";\nimport \"../../openzeppelin/Address.sol\";\nimport \"../../interfaces/IWrbtcERC20.sol\";\nimport \"./Pausable.sol\";\n\n/**\n * @title Loan Token Base contract.\n * @notice This contract code comes from bZx. bZx is a protocol for tokenized margin\n * trading and lending https://bzx.network similar to the dYdX protocol.\n *\n * Specific loan related storage for iTokens.\n *\n * An loan token or iToken is a representation of a user funds in the pool and the\n * interest they've earned. The redemption value of iTokens continually increase\n * from the accretion of interest paid into the lending pool by borrowers. The user\n * can sell iTokens to exit its position. The user might potentially use them as\n * collateral wherever applicable.\n *\n * There are three main tokens in the bZx system, iTokens, pTokens, and BZRX tokens.\n * The bZx system of lending and borrowing depends on iTokens and pTokens, and when\n * users lend or borrow money on bZx, their crypto assets go into or come out of\n * global liquidity pools, which are pools of funds shared between many different\n * exchanges. When lenders supply funds into the global liquidity pools, they\n * automatically receive iTokens; When users borrow money to open margin trading\n * positions, they automatically receive pTokens. The system is also designed to\n * use the BZRX tokens, which are only used to pay fees on the network currently.\n * */\ncontract LoanTokenBase is ReentrancyGuard, Ownable, Pausable {\n\tuint256 internal constant WEI_PRECISION = 10**18;\n\tuint256 internal constant WEI_PERCENT_PRECISION = 10**20;\n\n\tint256 internal constant sWEI_PRECISION = 10**18;\n\n\t/// @notice Standard ERC-20 properties\n\tstring public name;\n\tstring public symbol;\n\tuint8 public decimals;\n\n\t/// @notice The address of the loan token (asset to lend) instance.\n\taddress public loanTokenAddress;\n\n\tuint256 public baseRate;\n\tuint256 public rateMultiplier;\n\tuint256 public lowUtilBaseRate;\n\tuint256 public lowUtilRateMultiplier;\n\n\tuint256 public targetLevel;\n\tuint256 public kinkLevel;\n\tuint256 public maxScaleRate;\n\n\tuint256 internal _flTotalAssetSupply;\n\tuint256 public checkpointSupply;\n\tuint256 public initialPrice;\n\n\t/// uint88 for tight packing -> 8 + 88 + 160 = 256\n\tuint88 internal lastSettleTime_;\n\n\t/// Mapping of keccak256(collateralToken, isTorqueLoan) to loanParamsId.\n\tmapping(uint256 => bytes32) public loanParamsIds;\n\n\t/// Price of token at last user checkpoint.\n\tmapping(address => uint256) internal checkpointPrices_;\n\n\t// the maximum trading/borrowing/lending limit per token address\n\tmapping(address => uint256) public transactionLimit;\n\t// 0 -> no limit\n}\n"
},
"contracts/openzeppelin/SafeMath.sol": {
"content": "pragma solidity >=0.5.0 <0.6.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n\t/**\n\t * @dev Returns the addition of two unsigned integers, reverting on\n\t * overflow.\n\t *\n\t * Counterpart to Solidity's `+` operator.\n\t *\n\t * Requirements:\n\t * - Addition cannot overflow.\n\t */\n\tfunction add(uint256 a, uint256 b) internal pure returns (uint256) {\n\t\tuint256 c = a + b;\n\t\trequire(c >= a, \"SafeMath: addition overflow\");\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the subtraction of two unsigned integers, reverting on\n\t * overflow (when the result is negative).\n\t *\n\t * Counterpart to Solidity's `-` operator.\n\t *\n\t * Requirements:\n\t * - Subtraction cannot overflow.\n\t */\n\tfunction sub(uint256 a, uint256 b) internal pure returns (uint256) {\n\t\treturn sub(a, b, \"SafeMath: subtraction overflow\");\n\t}\n\n\t/**\n\t * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n\t * overflow (when the result is negative).\n\t *\n\t * Counterpart to Solidity's `-` operator.\n\t *\n\t * Requirements:\n\t * - Subtraction cannot overflow.\n\t *\n\t * _Available since v2.4.0._\n\t */\n\tfunction sub(\n\t\tuint256 a,\n\t\tuint256 b,\n\t\tstring memory errorMessage\n\t) internal pure returns (uint256) {\n\t\trequire(b <= a, errorMessage);\n\t\tuint256 c = a - b;\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the multiplication of two unsigned integers, reverting on\n\t * overflow.\n\t *\n\t * Counterpart to Solidity's `*` operator.\n\t *\n\t * Requirements:\n\t * - Multiplication cannot overflow.\n\t */\n\tfunction mul(uint256 a, uint256 b) internal pure returns (uint256) {\n\t\t// Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n\t\t// benefit is lost if 'b' is also tested.\n\t\t// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n\t\tif (a == 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tuint256 c = a * b;\n\t\trequire(c / a == b, \"SafeMath: multiplication overflow\");\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the integer division of two unsigned integers. Reverts on\n\t * division by zero. The result is rounded towards zero.\n\t *\n\t * Counterpart to Solidity's `/` operator. Note: this function uses a\n\t * `revert` opcode (which leaves remaining gas untouched) while Solidity\n\t * uses an invalid opcode to revert (consuming all remaining gas).\n\t *\n\t * Requirements:\n\t * - The divisor cannot be zero.\n\t */\n\tfunction div(uint256 a, uint256 b) internal pure returns (uint256) {\n\t\treturn div(a, b, \"SafeMath: division by zero\");\n\t}\n\n\t/**\n\t * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n\t * division by zero. The result is rounded towards zero.\n\t *\n\t * Counterpart to Solidity's `/` operator. Note: this function uses a\n\t * `revert` opcode (which leaves remaining gas untouched) while Solidity\n\t * uses an invalid opcode to revert (consuming all remaining gas).\n\t *\n\t * Requirements:\n\t * - The divisor cannot be zero.\n\t *\n\t * _Available since v2.4.0._\n\t */\n\tfunction div(\n\t\tuint256 a,\n\t\tuint256 b,\n\t\tstring memory errorMessage\n\t) internal pure returns (uint256) {\n\t\t// Solidity only automatically asserts when dividing by 0\n\t\trequire(b != 0, errorMessage);\n\t\tuint256 c = a / b;\n\t\t// assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Integer division of two numbers, rounding up and truncating the quotient\n\t */\n\tfunction divCeil(uint256 a, uint256 b) internal pure returns (uint256) {\n\t\treturn divCeil(a, b, \"SafeMath: division by zero\");\n\t}\n\n\t/**\n\t * @dev Integer division of two numbers, rounding up and truncating the quotient\n\t */\n\tfunction divCeil(\n\t\tuint256 a,\n\t\tuint256 b,\n\t\tstring memory errorMessage\n\t) internal pure returns (uint256) {\n\t\t// Solidity only automatically asserts when dividing by 0\n\t\trequire(b != 0, errorMessage);\n\n\t\tif (a == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 c = ((a - 1) / b) + 1;\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n\t * Reverts when dividing by zero.\n\t *\n\t * Counterpart to Solidity's `%` operator. This function uses a `revert`\n\t * opcode (which leaves remaining gas untouched) while Solidity uses an\n\t * invalid opcode to revert (consuming all remaining gas).\n\t *\n\t * Requirements:\n\t * - The divisor cannot be zero.\n\t */\n\tfunction mod(uint256 a, uint256 b) internal pure returns (uint256) {\n\t\treturn mod(a, b, \"SafeMath: modulo by zero\");\n\t}\n\n\t/**\n\t * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n\t * Reverts with custom message when dividing by zero.\n\t *\n\t * Counterpart to Solidity's `%` operator. This function uses a `revert`\n\t * opcode (which leaves remaining gas untouched) while Solidity uses an\n\t * invalid opcode to revert (consuming all remaining gas).\n\t *\n\t * Requirements:\n\t * - The divisor cannot be zero.\n\t *\n\t * _Available since v2.4.0._\n\t */\n\tfunction mod(\n\t\tuint256 a,\n\t\tuint256 b,\n\t\tstring memory errorMessage\n\t) internal pure returns (uint256) {\n\t\trequire(b != 0, errorMessage);\n\t\treturn a % b;\n\t}\n\n\tfunction min256(uint256 _a, uint256 _b) internal pure returns (uint256) {\n\t\treturn _a < _b ? _a : _b;\n\t}\n}\n"
},
"contracts/openzeppelin/SignedSafeMath.sol": {
"content": "pragma solidity >=0.5.0 <0.6.0;\n\n/**\n * @title SignedSafeMath\n * @dev Signed math operations with safety checks that revert on error.\n */\nlibrary SignedSafeMath {\n\tint256 private constant _INT256_MIN = -2**255;\n\n\t/**\n\t * @dev Returns the multiplication of two signed integers, reverting on\n\t * overflow.\n\t *\n\t * Counterpart to Solidity's `*` operator.\n\t *\n\t * Requirements:\n\t *\n\t * - Multiplication cannot overflow.\n\t */\n\tfunction mul(int256 a, int256 b) internal pure returns (int256) {\n\t\t// Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n\t\t// benefit is lost if 'b' is also tested.\n\t\t// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n\t\tif (a == 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\trequire(!(a == -1 && b == _INT256_MIN), \"SignedSafeMath: multiplication overflow\");\n\n\t\tint256 c = a * b;\n\t\trequire(c / a == b, \"SignedSafeMath: multiplication overflow\");\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the integer division of two signed integers. Reverts on\n\t * division by zero. The result is rounded towards zero.\n\t *\n\t * Counterpart to Solidity's `/` operator. Note: this function uses a\n\t * `revert` opcode (which leaves remaining gas untouched) while Solidity\n\t * uses an invalid opcode to revert (consuming all remaining gas).\n\t *\n\t * Requirements:\n\t *\n\t * - The divisor cannot be zero.\n\t */\n\tfunction div(int256 a, int256 b) internal pure returns (int256) {\n\t\trequire(b != 0, \"SignedSafeMath: division by zero\");\n\t\trequire(!(b == -1 && a == _INT256_MIN), \"SignedSafeMath: division overflow\");\n\n\t\tint256 c = a / b;\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the subtraction of two signed integers, reverting on\n\t * overflow.\n\t *\n\t * Counterpart to Solidity's `-` operator.\n\t *\n\t * Requirements:\n\t *\n\t * - Subtraction cannot overflow.\n\t */\n\tfunction sub(int256 a, int256 b) internal pure returns (int256) {\n\t\tint256 c = a - b;\n\t\trequire((b >= 0 && c <= a) || (b < 0 && c > a), \"SignedSafeMath: subtraction overflow\");\n\n\t\treturn c;\n\t}\n\n\t/**\n\t * @dev Returns the addition of two signed integers, reverting on\n\t * overflow.\n\t *\n\t * Counterpart to Solidity's `+` operator.\n\t *\n\t * Requirements:\n\t *\n\t * - Addition cannot overflow.\n\t */\n\tfunction add(int256 a, int256 b) internal pure returns (int256) {\n\t\tint256 c = a + b;\n\t\trequire((b >= 0 && c >= a) || (b < 0 && c < a), \"SignedSafeMath: addition overflow\");\n\n\t\treturn c;\n\t}\n}\n"
},
"contracts/openzeppelin/ReentrancyGuard.sol": {
"content": "pragma solidity >=0.5.0 <0.6.0;\n\n/**\n * @title Helps contracts guard against reentrancy attacks.\n * @author Remco Bloemen <remco@2π.com>, Eenae <alexey@mixbytes.io>\n * @dev If you mark a function `nonReentrant`, you should also\n * mark it `external`.\n */\ncontract ReentrancyGuard {\n\t/// @dev Constant for unlocked guard state - non-zero to prevent extra gas costs.\n\t/// See: https://github.com/OpenZeppelin/openzeppelin-solidity/issues/1056\n\tuint256 internal constant REENTRANCY_GUARD_FREE = 1;\n\n\t/// @dev Constant for locked guard state\n\tuint256 internal constant REENTRANCY_GUARD_LOCKED = 2;\n\n\t/**\n\t * @dev We use a single lock for the whole contract.\n\t */\n\tuint256 internal reentrancyLock = REENTRANCY_GUARD_FREE;\n\n\t/**\n\t * @dev Prevents a contract from calling itself, directly or indirectly.\n\t * If you mark a function `nonReentrant`, you should also\n\t * mark it `external`. Calling one `nonReentrant` function from\n\t * another is not supported. Instead, you can implement a\n\t * `private` function doing the actual work, and an `external`\n\t * wrapper marked as `nonReentrant`.\n\t */\n\tmodifier nonReentrant() {\n\t\trequire(reentrancyLock == REENTRANCY_GUARD_FREE, \"nonReentrant\");\n\t\treentrancyLock = REENTRANCY_GUARD_LOCKED;\n\t\t_;\n\t\treentrancyLock = REENTRANCY_GUARD_FREE;\n\t}\n}\n"
},
"contracts/openzeppelin/Ownable.sol": {
"content": "pragma solidity >=0.5.0 <0.6.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract Ownable is Context {\n\taddress private _owner;\n\n\tevent OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n\t/**\n\t * @dev Initializes the contract setting the deployer as the initial owner.\n\t */\n\tconstructor() internal {\n\t\taddress msgSender = _msgSender();\n\t\t_owner = msgSender;\n\t\temit OwnershipTransferred(address(0), msgSender);\n\t}\n\n\t/**\n\t * @dev Returns the address of the current owner.\n\t */\n\tfunction owner() public view returns (address) {\n\t\treturn _owner;\n\t}\n\n\t/**\n\t * @dev Throws if called by any account other than the owner.\n\t */\n\tmodifier onlyOwner() {\n\t\trequire(isOwner(), \"unauthorized\");\n\t\t_;\n\t}\n\n\t/**\n\t * @dev Returns true if the caller is the current owner.\n\t */\n\tfunction isOwner() public view returns (bool) {\n\t\treturn _msgSender() == _owner;\n\t}\n\n\t/**\n\t * @dev Transfers ownership of the contract to a new account (`newOwner`).\n\t * Can only be called by the current owner.\n\t */\n\tfunction transferOwnership(address newOwner) public onlyOwner {\n\t\t_transferOwnership(newOwner);\n\t}\n\n\t/**\n\t * @dev Transfers ownership of the contract to a new account (`newOwner`).\n\t */\n\tfunction _transferOwnership(address newOwner) internal {\n\t\trequire(newOwner != address(0), \"Ownable: new owner is the zero address\");\n\t\temit OwnershipTransferred(_owner, newOwner);\n\t\t_owner = newOwner;\n\t}\n}\n"
},
"contracts/openzeppelin/Address.sol": {
"content": "pragma solidity >=0.5.0 <0.6.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n\t/**\n\t * @dev Returns true if `account` is a contract.\n\t *\n\t * [IMPORTANT]\n\t * ====\n\t * It is unsafe to assume that an address for which this function returns\n\t * false is an externally-owned account (EOA) and not a contract.\n\t *\n\t * Among others, `isContract` will return false for the following\n\t * types of addresses:\n\t *\n\t * - an externally-owned account\n\t * - a contract in construction\n\t * - an address where a contract will be created\n\t * - an address where a contract lived, but was destroyed\n\t * ====\n\t */\n\tfunction isContract(address account) internal view returns (bool) {\n\t\t// According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n\t\t// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n\t\t// for accounts without code, i.e. `keccak256('')`\n\t\tbytes32 codehash;\n\t\tbytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\t\t// solhint-disable-next-line no-inline-assembly\n\t\tassembly {\n\t\t\tcodehash := extcodehash(account)\n\t\t}\n\t\treturn (codehash != accountHash && codehash != 0x0);\n\t}\n\n\t/**\n\t * @dev Converts an `address` into `address payable`. Note that this is\n\t * simply a type cast: the actual underlying value is not changed.\n\t *\n\t * _Available since v2.4.0._\n\t */\n\tfunction toPayable(address account) internal pure returns (address payable) {\n\t\treturn address(uint160(account));\n\t}\n\n\t/**\n\t * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n\t * `recipient`, forwarding all available gas and reverting on errors.\n\t *\n\t * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n\t * of certain opcodes, possibly making contracts go over the 2300 gas limit\n\t * imposed by `transfer`, making them unable to receive funds via\n\t * `transfer`. {sendValue} removes this limitation.\n\t *\n\t * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n\t *\n\t * IMPORTANT: because control is transferred to `recipient`, care must be\n\t * taken to not create reentrancy vulnerabilities. Consider using\n\t * {ReentrancyGuard} or the\n\t * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html\n\t * #use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n\t *\n\t * _Available since v2.4.0._\n\t */\n\tfunction sendValue(address recipient, uint256 amount) internal {\n\t\trequire(address(this).balance >= amount, \"Address: insufficient balance\");\n\n\t\t// solhint-disable-next-line avoid-call-value\n\t\t(bool success, ) = recipient.call.value(amount)(\"\");\n\t\trequire(success, \"Address: unable to send value, recipient may have reverted\");\n\t}\n}\n"
},
"contracts/interfaces/IWrbtcERC20.sol": {
"content": "/**\n * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity >=0.5.0 <0.6.0;\n\nimport \"./IWrbtc.sol\";\nimport \"./IERC20.sol\";\n\ncontract IWrbtcERC20 is IWrbtc, IERC20 {}\n"
},
"contracts/connectors/loantoken/Pausable.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\n/**\n * @title Pausable contract.\n * @notice This contract code comes from bZx. bZx is a protocol for tokenized margin\n * trading and lending https://bzx.network similar to the dYdX protocol.\n *\n * The contract implements pausable functionality by reading on slots the\n * pause state of contract functions.\n * */\ncontract Pausable {\n\t/// keccak256(\"Pausable_FunctionPause\")\n\tbytes32 internal constant Pausable_FunctionPause = 0xa7143c84d793a15503da6f19bf9119a2dac94448ca45d77c8bf08f57b2e91047;\n\n\tmodifier pausable(bytes4 sig) {\n\t\trequire(!_isPaused(sig), \"unauthorized\");\n\t\t_;\n\t}\n\n\t/**\n\t * @notice Check whether a function is paused.\n\t *\n\t * @dev Used to read externally from the smart contract to see if a\n\t * function is paused.\n\t *\n\t * @param sig The function ID, the selector on bytes4.\n\t *\n\t * @return isPaused Whether the function is paused: true or false.\n\t * */\n\tfunction _isPaused(bytes4 sig) internal view returns (bool isPaused) {\n\t\tbytes32 slot = keccak256(abi.encodePacked(sig, Pausable_FunctionPause));\n\t\tassembly {\n\t\t\tisPaused := sload(slot)\n\t\t}\n\t}\n}\n"
},
"contracts/openzeppelin/Context.sol": {
"content": "pragma solidity >=0.5.0 <0.6.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\ncontract Context {\n\t// Empty internal constructor, to prevent people from mistakenly deploying\n\t// an instance of this contract, which should be used via inheritance.\n\tconstructor() internal {}\n\n\t// solhint-disable-previous-line no-empty-blocks\n\n\tfunction _msgSender() internal view returns (address payable) {\n\t\treturn msg.sender;\n\t}\n\n\tfunction _msgData() internal view returns (bytes memory) {\n\t\tthis; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n\t\treturn msg.data;\n\t}\n}\n"
},
"contracts/interfaces/IWrbtc.sol": {
"content": "/**\n * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity >=0.5.0 <0.6.0;\n\ninterface IWrbtc {\n\tfunction deposit() external payable;\n\n\tfunction withdraw(uint256 wad) external;\n}\n"
},
"contracts/interfaces/IERC20.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity >=0.5.0 <0.6.0;\n\ncontract IERC20 {\n\tstring public name;\n\tuint8 public decimals;\n\tstring public symbol;\n\n\tfunction totalSupply() public view returns (uint256);\n\n\tfunction balanceOf(address _who) public view returns (uint256);\n\n\tfunction allowance(address _owner, address _spender) public view returns (uint256);\n\n\tfunction approve(address _spender, uint256 _value) public returns (bool);\n\n\tfunction transfer(address _to, uint256 _value) public returns (bool);\n\n\tfunction transferFrom(\n\t\taddress _from,\n\t\taddress _to,\n\t\tuint256 _value\n\t) public returns (bool);\n\n\tevent Transfer(address indexed from, address indexed to, uint256 value);\n\tevent Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
},
"contracts/connectors/loantoken/LoanTokenSettingsLowerAdmin.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport \"./AdvancedToken.sol\";\nimport \"./interfaces/ProtocolSettingsLike.sol\";\n\ncontract LoanTokenSettingsLowerAdmin is AdvancedToken {\n\tusing SafeMath for uint256;\n\n\t/* Storage */\n\n\t/// @dev It is important to maintain the variables order so the delegate\n\t/// calls can access sovrynContractAddress\n\n\t/// ------------- MUST BE THE SAME AS IN LoanToken CONTRACT -------------------\n\taddress public sovrynContractAddress;\n\taddress public wrbtcTokenAddress;\n\taddress public target_;\n\taddress public admin;\n\t/// ------------- END MUST BE THE SAME AS IN LoanToken CONTRACT -------------------\n\n\t/// @dev Add new variables here on the bottom.\n\taddress public earlyAccessToken; //not used anymore, but staying for upgradability\n\taddress public pauser;\n\t/** The address of the liquidity mining contract */\n\taddress public liquidityMiningAddress;\n\n\t/// @dev TODO: Check for restrictions in this contract.\n\tmodifier onlyAdmin() {\n\t\trequire(isOwner() || msg.sender == admin, \"unauthorized\");\n\t\t_;\n\t}\n\n\t/* Events */\n\n\tevent SetTransactionLimits(address[] addresses, uint256[] limits);\n\n\t/* Functions */\n\n\t/**\n\t * @notice Set admin account.\n\t * @param _admin The address of the account to grant admin permissions.\n\t * */\n\tfunction setAdmin(address _admin) public onlyOwner {\n\t\tadmin = _admin;\n\t}\n\n\t/**\n\t * @notice Set pauser account.\n\t * @param _pauser The address of the account to grant pause permissions.\n\t * */\n\tfunction setPauser(address _pauser) public onlyOwner {\n\t\tpauser = _pauser;\n\t}\n\n\t/**\n\t * @notice Fallback function not allowed\n\t * */\n\tfunction() external {\n\t\trevert(\"LoanTokenSettingsLowerAdmin - fallback not allowed\");\n\t}\n\n\t/**\n\t * @notice Set loan token parameters.\n\t *\n\t * @param loanParamsList The array of loan parameters.\n\t * @param areTorqueLoans Whether the loan is a torque loan.\n\t * */\n\tfunction setupLoanParams(LoanParamsStruct.LoanParams[] memory loanParamsList, bool areTorqueLoans) public onlyAdmin {\n\t\tbytes32[] memory loanParamsIdList;\n\t\taddress _loanTokenAddress = loanTokenAddress;\n\n\t\tfor (uint256 i = 0; i < loanParamsList.length; i++) {\n\t\t\tloanParamsList[i].loanToken = _loanTokenAddress;\n\t\t\tloanParamsList[i].maxLoanTerm = areTorqueLoans ? 0 : 28 days;\n\t\t}\n\n\t\tloanParamsIdList = ProtocolSettingsLike(sovrynContractAddress).setupLoanParams(loanParamsList);\n\t\tfor (uint256 i = 0; i < loanParamsIdList.length; i++) {\n\t\t\tloanParamsIds[\n\t\t\t\tuint256(\n\t\t\t\t\tkeccak256(\n\t\t\t\t\t\tabi.encodePacked(\n\t\t\t\t\t\t\tloanParamsList[i].collateralToken,\n\t\t\t\t\t\t\tareTorqueLoans /// isTorqueLoan\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t] = loanParamsIdList[i];\n\t\t}\n\t}\n\n\t/**\n\t * @notice Disable loan token parameters.\n\t *\n\t * @param collateralTokens The array of collateral tokens.\n\t * @param isTorqueLoans Whether the loan is a torque loan.\n\t * */\n\tfunction disableLoanParams(address[] calldata collateralTokens, bool[] calldata isTorqueLoans) external onlyAdmin {\n\t\trequire(collateralTokens.length == isTorqueLoans.length, \"count mismatch\");\n\n\t\tbytes32[] memory loanParamsIdList = new bytes32[](collateralTokens.length);\n\t\tfor (uint256 i = 0; i < collateralTokens.length; i++) {\n\t\t\tuint256 id = uint256(keccak256(abi.encodePacked(collateralTokens[i], isTorqueLoans[i])));\n\t\t\tloanParamsIdList[i] = loanParamsIds[id];\n\t\t\tdelete loanParamsIds[id];\n\t\t}\n\n\t\tProtocolSettingsLike(sovrynContractAddress).disableLoanParams(loanParamsIdList);\n\t}\n\n\t/**\n\t * @notice Set loan token parameters about the demand curve.\n\t *\n\t * @dev These params should be percentages represented\n\t * like so: 5% = 5000000000000000000 /// 18 digits precision.\n\t * rateMultiplier + baseRate can't exceed 100%\n\t *\n\t * To maintain a healthy credit score, it's important to keep your\n\t * credit utilization rate (CUR) low (_lowUtilBaseRate). In general\n\t * you don't want your CUR to exceed 30%, but increasingly financial\n\t * experts are recommending that you don't want to go above 10% if you\n\t * really want an excellent credit score.\n\t *\n\t * Interest rates tend to cluster around the kink level of a kinked\n\t * interest rate model. More info at https://arxiv.org/pdf/2006.13922.pdf\n\t * and https://compound.finance/governance/proposals/12\n\t *\n\t * @param _baseRate The interest rate.\n\t * @param _rateMultiplier The precision multiplier for base rate.\n\t * @param _lowUtilBaseRate The credit utilization rate (CUR) low value.\n\t * @param _lowUtilRateMultiplier The precision multiplier for low util base rate.\n\t * @param _targetLevel The target level.\n\t * @param _kinkLevel The level that interest rates cluster on kinked model.\n\t * @param _maxScaleRate The maximum rate of the scale.\n\t * */\n\tfunction setDemandCurve(\n\t\tuint256 _baseRate,\n\t\tuint256 _rateMultiplier,\n\t\tuint256 _lowUtilBaseRate,\n\t\tuint256 _lowUtilRateMultiplier,\n\t\tuint256 _targetLevel,\n\t\tuint256 _kinkLevel,\n\t\tuint256 _maxScaleRate\n\t) public onlyAdmin {\n\t\trequire(_rateMultiplier.add(_baseRate) <= WEI_PERCENT_PRECISION, \"curve params too high\");\n\t\trequire(_lowUtilRateMultiplier.add(_lowUtilBaseRate) <= WEI_PERCENT_PRECISION, \"curve params too high\");\n\n\t\trequire(_targetLevel <= WEI_PERCENT_PRECISION && _kinkLevel <= WEI_PERCENT_PRECISION, \"levels too high\");\n\n\t\tbaseRate = _baseRate;\n\t\trateMultiplier = _rateMultiplier;\n\t\tlowUtilBaseRate = _lowUtilBaseRate;\n\t\tlowUtilRateMultiplier = _lowUtilRateMultiplier;\n\n\t\ttargetLevel = _targetLevel; /// 80 ether\n\t\tkinkLevel = _kinkLevel; /// 90 ether\n\t\tmaxScaleRate = _maxScaleRate; /// 100 ether\n\t}\n\n\t/**\n\t * @notice Set the pause flag for a function to true or false.\n\t *\n\t * @dev Combining the hash of \"iToken_FunctionPause\" string and a function\n\t * selector gets a slot to write a flag for pause state.\n\t *\n\t * @param funcId The ID of a function, the selector.\n\t * @param isPaused true/false value of the flag.\n\t * */\n\tfunction toggleFunctionPause(\n\t\tstring memory funcId, /// example: \"mint(uint256,uint256)\"\n\t\tbool isPaused\n\t) public {\n\t\trequire(msg.sender == pauser, \"onlyPauser\");\n\t\t/// keccak256(\"iToken_FunctionPause\")\n\t\tbytes32 slot =\n\t\t\tkeccak256(\n\t\t\t\tabi.encodePacked(\n\t\t\t\t\tbytes4(keccak256(abi.encodePacked(funcId))),\n\t\t\t\t\tuint256(0xd46a704bc285dbd6ff5ad3863506260b1df02812f4f857c8cc852317a6ac64f2)\n\t\t\t\t)\n\t\t\t);\n\t\tassembly {\n\t\t\tsstore(slot, isPaused)\n\t\t}\n\t}\n}\n"
},
"contracts/connectors/loantoken/interfaces/ProtocolSettingsLike.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport \"../../../core/objects/LoanParamsStruct.sol\";\n\ninterface ProtocolSettingsLike {\n\tfunction setupLoanParams(LoanParamsStruct.LoanParams[] calldata loanParamsList) external returns (bytes32[] memory loanParamsIdList);\n\n\tfunction disableLoanParams(bytes32[] calldata loanParamsIdList) external;\n\n\tfunction minInitialMargin(bytes32 loanParamsId) external view returns (uint256);\n}\n"
},
"contracts/core/objects/LoanParamsStruct.sol": {
"content": "/**\n * Copyright 2017-2021, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\n/**\n * @title The Loan Parameters.\n * @notice This contract code comes from bZx. bZx is a protocol for tokenized\n * margin trading and lending https://bzx.network similar to the dYdX protocol.\n *\n * This contract contains the storage structure of the Loan Parameters.\n * */\ncontract LoanParamsStruct {\n\tstruct LoanParams {\n\t\t/// @dev ID of loan params object.\n\t\tbytes32 id;\n\t\t/// @dev If false, this object has been disabled by the owner and can't\n\t\t/// be used for future loans.\n\t\tbool active;\n\t\t/// @dev Owner of this object.\n\t\taddress owner;\n\t\t/// @dev The token being loaned.\n\t\taddress loanToken;\n\t\t/// @dev The required collateral token.\n\t\taddress collateralToken;\n\t\t/// @dev The minimum allowed initial margin.\n\t\tuint256 minInitialMargin;\n\t\t/// @dev An unhealthy loan when current margin is at or below this value.\n\t\tuint256 maintenanceMargin;\n\t\t/// @dev The maximum term for new loans (0 means there's no max term).\n\t\tuint256 maxLoanTerm;\n\t}\n}\n"
},
"contracts/mockup/previousLoanToken/PreviousLoanTokenSettingsLowerAdmin.sol": {
"content": "/**\n * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\npragma experimental ABIEncoderV2;\n\nimport \"../../connectors/loantoken/interfaces/ProtocolSettingsLike.sol\";\nimport \"../../connectors/loantoken/AdvancedTokenStorage.sol\";\n\n// It is a LoanToken implementation!\ncontract PreviousLoanTokenSettingsLowerAdmin is AdvancedTokenStorage {\n\tusing SafeMath for uint256;\n\n\t// It is important to maintain the variables order so the delegate calls can access sovrynContractAddress\n\n\t// ------------- MUST BE THE SAME AS IN LoanToken CONTRACT -------------------\n\taddress public sovrynContractAddress;\n\taddress public wrbtcTokenAddress;\n\taddress internal target_;\n\t// ------------- END MUST BE THE SAME AS IN LoanToken CONTRACT -------------------\n\n\tevent SetTransactionLimits(address[] addresses, uint256[] limits);\n\n\t//@todo check for restrictions in this contract\n\tmodifier onlyAdmin() {\n\t\trequire(msg.sender == address(this) || msg.sender == owner(), \"unauthorized\");\n\t\t_;\n\t}\n\n\t//@todo add check for double init, idk but init usually can be called only once.\n\tfunction init(\n\t\taddress _loanTokenAddress,\n\t\tstring memory _name,\n\t\tstring memory _symbol\n\t) public onlyOwner {\n\t\tloanTokenAddress = _loanTokenAddress;\n\n\t\tname = _name;\n\t\tsymbol = _symbol;\n\t\tdecimals = IERC20(loanTokenAddress).decimals();\n\n\t\tinitialPrice = 10**18; // starting price of 1\n\t}\n\n\tfunction() external {\n\t\trevert(\"LoanTokenSettingsLowerAdmin - fallback not allowed\");\n\t}\n\n\tfunction setupLoanParams(LoanParamsStruct.LoanParams[] memory loanParamsList, bool areTorqueLoans) public onlyAdmin {\n\t\tbytes32[] memory loanParamsIdList;\n\t\taddress _loanTokenAddress = loanTokenAddress;\n\n\t\tfor (uint256 i = 0; i < loanParamsList.length; i++) {\n\t\t\tloanParamsList[i].loanToken = _loanTokenAddress;\n\t\t\tloanParamsList[i].maxLoanTerm = areTorqueLoans ? 0 : 28 days;\n\t\t}\n\n\t\tloanParamsIdList = ProtocolSettingsLike(sovrynContractAddress).setupLoanParams(loanParamsList);\n\t\tfor (uint256 i = 0; i < loanParamsIdList.length; i++) {\n\t\t\tloanParamsIds[\n\t\t\t\tuint256(\n\t\t\t\t\tkeccak256(\n\t\t\t\t\t\tabi.encodePacked(\n\t\t\t\t\t\t\tloanParamsList[i].collateralToken,\n\t\t\t\t\t\t\tareTorqueLoans // isTorqueLoan\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t] = loanParamsIdList[i];\n\t\t}\n\t}\n\n\tfunction disableLoanParams(address[] calldata collateralTokens, bool[] calldata isTorqueLoans) external onlyAdmin {\n\t\trequire(collateralTokens.length == isTorqueLoans.length, \"count mismatch\");\n\n\t\tbytes32[] memory loanParamsIdList = new bytes32[](collateralTokens.length);\n\t\tfor (uint256 i = 0; i < collateralTokens.length; i++) {\n\t\t\tuint256 id = uint256(keccak256(abi.encodePacked(collateralTokens[i], isTorqueLoans[i])));\n\t\t\tloanParamsIdList[i] = loanParamsIds[id];\n\t\t\tdelete loanParamsIds[id];\n\t\t}\n\n\t\tProtocolSettingsLike(sovrynContractAddress).disableLoanParams(loanParamsIdList);\n\t}\n\n\t// These params should be percentages represented like so: 5% = 5000000000000000000\n\t// rateMultiplier + baseRate can't exceed 100%\n\tfunction setDemandCurve(\n\t\tuint256 _baseRate,\n\t\tuint256 _rateMultiplier,\n\t\tuint256 _lowUtilBaseRate,\n\t\tuint256 _lowUtilRateMultiplier,\n\t\tuint256 _targetLevel,\n\t\tuint256 _kinkLevel,\n\t\tuint256 _maxScaleRate\n\t) public onlyAdmin {\n\t\trequire(_rateMultiplier.add(_baseRate) <= WEI_PERCENT_PRECISION, \"curve params too high\");\n\t\trequire(_lowUtilRateMultiplier.add(_lowUtilBaseRate) <= WEI_PERCENT_PRECISION, \"curve params too high\");\n\n\t\trequire(_targetLevel <= WEI_PERCENT_PRECISION && _kinkLevel <= WEI_PERCENT_PRECISION, \"levels too high\");\n\n\t\tbaseRate = _baseRate;\n\t\trateMultiplier = _rateMultiplier;\n\t\tlowUtilBaseRate = _lowUtilBaseRate;\n\t\tlowUtilRateMultiplier = _lowUtilRateMultiplier;\n\n\t\ttargetLevel = _targetLevel; // 80 ether\n\t\tkinkLevel = _kinkLevel; // 90 ether\n\t\tmaxScaleRate = _maxScaleRate; // 100 ether\n\t}\n\n\tfunction toggleFunctionPause(\n\t\tstring memory funcId, // example: \"mint(uint256,uint256)\"\n\t\tbool isPaused\n\t) public onlyAdmin {\n\t\t// keccak256(\"iToken_FunctionPause\")\n\t\tbytes32 slot =\n\t\t\tkeccak256(\n\t\t\t\tabi.encodePacked(\n\t\t\t\t\tbytes4(keccak256(abi.encodePacked(funcId))),\n\t\t\t\t\tuint256(0xd46a704bc285dbd6ff5ad3863506260b1df02812f4f857c8cc852317a6ac64f2)\n\t\t\t\t)\n\t\t\t);\n\t\tassembly {\n\t\t\tsstore(slot, isPaused)\n\t\t}\n\t}\n\n\t/**\n\t * sets the transaction limit per token address\n\t * @param addresses the token addresses\n\t * @param limits the limit denominated in the currency of the token address\n\t * */\n\tfunction setTransactionLimits(address[] memory addresses, uint256[] memory limits) public onlyOwner {\n\t\trequire(addresses.length == limits.length, \"mismatched array lengths\");\n\t\tfor (uint256 i = 0; i < addresses.length; i++) {\n\t\t\ttransactionLimit[addresses[i]] = limits[i];\n\t\t}\n\t\temit SetTransactionLimits(addresses, limits);\n\t}\n}\n"
},
"contracts/mockup/previousLoanToken/PreviousLoanToken.sol": {
"content": "/**\n * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\nimport \"../../connectors/loantoken/AdvancedTokenStorage.sol\";\n\n//@todo can I change this proxy to EIP-1822 proxy standard, please. https://eips.ethereum.org/EIPS/eip-1822. It's really hard to work with this.\ncontract PreviousLoanToken is AdvancedTokenStorage {\n\t// It is important to maintain the variables order so the delegate calls can access sovrynContractAddress and wrbtcTokenAddress\n\taddress public sovrynContractAddress;\n\taddress public wrbtcTokenAddress;\n\taddress internal target_;\n\n\tconstructor(\n\t\taddress _newOwner,\n\t\taddress _newTarget,\n\t\taddress _sovrynContractAddress,\n\t\taddress _wrbtcTokenAddress\n\t) public {\n\t\ttransferOwnership(_newOwner);\n\t\t_setTarget(_newTarget);\n\t\t_setSovrynContractAddress(_sovrynContractAddress);\n\t\t_setWrbtcTokenAddress(_wrbtcTokenAddress);\n\t}\n\n\tfunction() external payable {\n\t\tif (gasleft() <= 2300) {\n\t\t\treturn;\n\t\t}\n\n\t\taddress target = target_;\n\t\tbytes memory data = msg.data;\n\t\tassembly {\n\t\t\tlet result := delegatecall(gas, target, add(data, 0x20), mload(data), 0, 0)\n\t\t\tlet size := returndatasize\n\t\t\tlet ptr := mload(0x40)\n\t\t\treturndatacopy(ptr, 0, size)\n\t\t\tswitch result\n\t\t\t\tcase 0 {\n\t\t\t\t\trevert(ptr, size)\n\t\t\t\t}\n\t\t\t\tdefault {\n\t\t\t\t\treturn(ptr, size)\n\t\t\t\t}\n\t\t}\n\t}\n\n\tfunction setTarget(address _newTarget) public onlyOwner {\n\t\t_setTarget(_newTarget);\n\t}\n\n\tfunction _setTarget(address _newTarget) internal {\n\t\trequire(Address.isContract(_newTarget), \"target not a contract\");\n\t\ttarget_ = _newTarget;\n\t}\n\n\tfunction _setSovrynContractAddress(address _sovrynContractAddress) internal {\n\t\trequire(Address.isContract(_sovrynContractAddress), \"sovryn not a contract\");\n\t\tsovrynContractAddress = _sovrynContractAddress;\n\t}\n\n\tfunction _setWrbtcTokenAddress(address _wrbtcTokenAddress) internal {\n\t\trequire(Address.isContract(_wrbtcTokenAddress), \"wrbtc not a contract\");\n\t\twrbtcTokenAddress = _wrbtcTokenAddress;\n\t}\n\n\t//@todo add check for double init, idk but init usually can be called only once.\n\tfunction initialize(\n\t\taddress _loanTokenAddress,\n\t\tstring memory _name,\n\t\tstring memory _symbol\n\t) public onlyOwner {\n\t\tloanTokenAddress = _loanTokenAddress;\n\n\t\tname = _name;\n\t\tsymbol = _symbol;\n\t\tdecimals = IERC20(loanTokenAddress).decimals();\n\n\t\tinitialPrice = 10**18; // starting price of 1\n\t}\n}\n"
},
"contracts/connectors/loantoken/LoanToken.sol": {
"content": "/**\n * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0.\n */\n\npragma solidity 0.5.17;\n\nimport \"./AdvancedTokenStorage.sol\";\n\n/**\n * @title Loan Token contract.\n * @notice This contract code comes from bZx. bZx is a protocol for tokenized\n * margin trading and lending https://bzx.network similar to the dYdX protocol.\n *\n * A loan token (iToken) is created as a proxy to an upgradable token contract.\n *\n * Examples of loan tokens on Sovryn are iRBTC, iDOC, iUSDT, iBPro,\n * iSOV (near future).\n *\n * Lenders receive iTokens that collect interest from the lending pool\n * which they can redeem by withdrawing them. The i in iToken stands for interest.\n *\n * Do not confuse iTokens with underlying tokens. iDOC is an iToken (loan token)\n * whilest DOC is the underlying token (currency).\n *\n * @dev TODO: can I change this proxy to EIP-1822 proxy standard, please.\n * https://eips.ethereum.org/EIPS/eip-1822. It's really hard to work with this.\n * */\ncontract LoanToken is AdvancedTokenStorage {\n\t/// @dev It is important to maintain the variables order so the delegate\n\t/// calls can access sovrynContractAddress and wrbtcTokenAddress\n\taddress public sovrynContractAddress;\n\taddress public wrbtcTokenAddress;\n\taddress internal target_;\n\taddress public admin;\n\n\t/**\n\t * @notice Deploy loan token proxy.\n\t * Sets ERC20 parameters of the token.\n\t *\n\t * @param _newOwner The address of the new owner.\n\t * @param _newTarget The address of the new target contract instance.\n\t * @param _sovrynContractAddress The address of the new sovrynContract instance.\n\t * @param _wrbtcTokenAddress The address of the new wrBTC instance.\n\t * */\n\tconstructor(\n\t\taddress _newOwner,\n\t\taddress _newTarget,\n\t\taddress _sovrynContractAddress,\n\t\taddress _wrbtcTokenAddress\n\t) public {\n\t\ttransferOwnership(_newOwner);\n\t\t_setTarget(_newTarget);\n\t\t_setSovrynContractAddress(_sovrynContractAddress);\n\t\t_setWrbtcTokenAddress(_wrbtcTokenAddress);\n\t}\n\n\t/**\n\t * @notice Fallback function performs a delegate call\n\t * to the actual implementation address is pointing this proxy.\n\t * Returns whatever the implementation call returns.\n\t * */\n\tfunction() external payable {\n\t\tif (gasleft() <= 2300) {\n\t\t\treturn;\n\t\t}\n\n\t\taddress target = target_;\n\t\tbytes memory data = msg.data;\n\t\tassembly {\n\t\t\tlet result := delegatecall(gas, target, add(data, 0x20), mload(data), 0, 0)\n\t\t\tlet size := returndatasize\n\t\t\tlet ptr := mload(0x40)\n\t\t\treturndatacopy(ptr, 0, size)\n\t\t\tswitch result\n\t\t\t\tcase 0 {\n\t\t\t\t\trevert(ptr, size)\n\t\t\t\t}\n\t\t\t\tdefault {\n\t\t\t\t\treturn(ptr, size)\n\t\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @notice Public owner setter for target address.\n\t * @dev Calls internal setter.\n\t * @param _newTarget The address of the new target contract instance.\n\t * */\n\tfunction setTarget(address _newTarget) public onlyOwner {\n\t\t_setTarget(_newTarget);\n\t}\n\n\t/**\n\t * @notice Internal setter for target address.\n\t * @param _newTarget The address of the new target contract instance.\n\t * */\n\tfunction _setTarget(address _newTarget) internal {\n\t\trequire(Address.isContract(_newTarget), \"target not a contract\");\n\t\ttarget_ = _newTarget;\n\t}\n\n\t/**\n\t * @notice Internal setter for sovrynContract address.\n\t * @param _sovrynContractAddress The address of the new sovrynContract instance.\n\t * */\n\tfunction _setSovrynContractAddress(address _sovrynContractAddress) internal {\n\t\trequire(Address.isContract(_sovrynContractAddress), \"sovryn not a c