Address Contract Partially Verified
Address
0x2F06F9cC66B0B052795D6DE81A670E9850ef9846
Balance
0 ETH
Nonce
1
Code Size
4668 bytes
Creator
0xd2f6c381...88FF at tx 0x65299f4e...b38cf6
Indexed Transactions
0
Contract Bytecode
4668 bytes
0x608060405234801561001057600080fd5b50600436106100eb5760003560e01c80638da5cb5b116100925780638da5cb5b14610195578063919722bb146101a6578063a22ca2a6146101ce578063d8bd9260146101e1578063e63ea408146101f4578063ee6649a114610207578063f2fde38b1461022a578063f4b9fa751461023d578063f7260d3e1461025057600080fd5b806302fb0c5e146100f05780630aa2f4201461011257806310b11e14146101295780632b3ba6811461013e578063575a86b2146101475780636764120c14610167578063715018a61461017a578063864f4a9a14610182575b600080fd5b6006546100fd9060ff1681565b60405190151581526020015b60405180910390f35b61011b60055481565b604051908152602001610109565b61013c610137366004610dfe565b610268565b005b61011b61271081565b60015461015a906001600160a01b031681565b6040516101099190610e35565b61013c610175366004610e49565b6102fa565b61013c61034a565b60035461015a906001600160a01b031681565b6000546001600160a01b031661015a565b6101b96101b4366004610e6d565b61035e565b60408051928352602083019190915201610109565b60045461015a906001600160a01b031681565b61013c6101ef366004610ead565b610725565b61013c610202366004610ec6565b610790565b6100fd610215366004610f02565b60076020526000908152604090205460ff1681565b61013c610238366004610f02565b6108b0565b60025461015a906001600160a01b031681565b60065461015a9061010090046001600160a01b031681565b610270610a85565b6001600160a01b0382166102975760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038216600081815260076020908152604091829020805460ff19168515159081179091558251938452908301527ff9c4e47c60b7a9d21f5359984eeb75eec20ab7d5f5c633e2eb7780dc61911035910160405180910390a15050565b610302610a85565b6006805460ff19168215159081179091556040519081527f1aeaaae8f3dfe7571a27a3576558260788745acdc3b5bd1c09041614d4fdbef8906020015b60405180910390a150565b610352610a85565b61035c6000610adf565b565b600654600090819060ff16610386576040516384c9906960e01b815260040160405180910390fd5b6001600160a01b03851660009081526007602052604090205460ff16156103c0576040516316e7880d60e11b815260040160405180910390fd5b60015460405163372c12b160e01b81526001600160a01b039091169063372c12b1906103f0908890600401610e35565b602060405180830381865afa15801561040d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104319190610f1d565b61044e57604051630b094f2760e31b815260040160405180910390fd5b6001600160a01b0385166104755760405163fd684c3b60e01b815260040160405180910390fd5b836104935760405163162908e360e11b815260040160405180910390fd5b60055460048054600354604051631f69565f60e01b81526000946127109490936001600160a01b0390811693631f69565f936104d493919092169101610e35565b600060405180830381865afa1580156104f1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105199190810190610fe5565b6040015161052791906110bd565b61053191906110ea565b905083156105785784925061271061054982856110bd565b61055391906110ea565b915081610573576040516342ad51d160e11b815260040160405180910390fd5b6105b2565b84915080610588612710846110bd565b61059291906110ea565b9250826105b25760405163e8fae43960e01b815260040160405180910390fd5b600154604080516379502c5560e01b815290516000926001600160a01b0316916379502c559160048083019260c09291908290030181865afa1580156105fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610620919061110c565b80519091508410156106455760405163e8fae43960e01b815260040160405180910390fd5b600654600254610669916001600160a01b0391821691339161010090041686610b2f565b6001546040516311f9fbc960e21b81526001600160a01b03909116906347e7ef249061069b908a908890600401611185565b600060405180830381600087803b1580156106b557600080fd5b505af11580156106c9573d6000803e3d6000fd5b5050604080518815158152602081018790529081018790526001600160a01b038a1692507fbfd50a04f1e6e4aee344f5d0e7f15d74d0dbb58cd1f711daa6463094ca9508cd915060600160405180910390a25050935093915050565b61072d610a85565b606481108061073d575061271081115b1561075b5760405163e598f05760e01b815260040160405180910390fd5b60058190556040518181527f917e55c2d7008aafff17508706d05cc815c72de9b45d508a5080b24d3c24f7819060200161033f565b610798610a85565b6001600160a01b0382166107bf5760405163e6c4247b60e01b815260040160405180910390fd5b6040516370a0823160e01b815281906001600160a01b038516906370a08231906107ed903090600401610e35565b602060405180830381865afa15801561080a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082e919061119e565b101561084d57604051631e9acf1760e31b815260040160405180910390fd5b6108616001600160a01b0384168383610b6d565b604080516001600160a01b0385811682526020820184905284168183015290517f56c54ba9bd38d8fd62012e42c7ee564519b09763c426d331b3661b537ead19b29181900360600190a1505050565b6108b8610a85565b6001600160a01b0381166109225760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61092b81610adf565b50565b8015806109a85750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a6919061119e565b155b610a135760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610919565b610a698363095ea7b360e01b8484604051602401610a32929190611185565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610b8c565b505050565b6060610a7d8484600085610c5e565b949350505050565b6000546001600160a01b0316331461035c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610919565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b0380851660248301528316604482015260648101829052610b679085906323b872dd60e01b90608401610a32565b50505050565b610a698363a9059cbb60e01b8484604051602401610a32929190611185565b6000610be1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610a6e9092919063ffffffff16565b805190915015610a695780806020019051810190610bff9190610f1d565b610a695760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610919565b606082471015610cbf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610919565b600080866001600160a01b03168587604051610cdb91906111b7565b60006040518083038185875af1925050503d8060008114610d18576040519150601f19603f3d011682016040523d82523d6000602084013e610d1d565b606091505b5091509150610d2e87838387610d39565b979650505050505050565b60608315610da5578251610d9e576001600160a01b0385163b610d9e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610919565b5081610a7d565b610a7d8383815115610dba5781518083602001fd5b8060405162461bcd60e51b815260040161091991906111d3565b80356001600160a01b0381168114610deb57600080fd5b919050565b801515811461092b57600080fd5b60008060408385031215610e1157600080fd5b610e1a83610dd4565b91506020830135610e2a81610df0565b809150509250929050565b6001600160a01b0391909116815260200190565b600060208284031215610e5b57600080fd5b8135610e6681610df0565b9392505050565b600080600060608486031215610e8257600080fd5b610e8b84610dd4565b9250602084013591506040840135610ea281610df0565b809150509250925092565b600060208284031215610ebf57600080fd5b5035919050565b600080600060608486031215610edb57600080fd5b610ee484610dd4565b9250610ef260208501610dd4565b9150604084013590509250925092565b600060208284031215610f1457600080fd5b610e6682610dd4565b600060208284031215610f2f57600080fd5b8151610e6681610df0565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b0381118282101715610f7257610f72610f3a565b60405290565b604051601f8201601f191681016001600160401b0381118282101715610fa057610fa0610f3a565b604052919050565b60005b83811015610fc3578181015183820152602001610fab565b83811115610b675750506000910152565b805160ff81168114610deb57600080fd5b60006020808385031215610ff857600080fd5b82516001600160401b038082111561100f57600080fd5b908401906060828703121561102357600080fd5b61102b610f50565b82518281111561103a57600080fd5b8301601f8101881361104b57600080fd5b80518381111561105d5761105d610f3a565b61106f601f8201601f19168701610f78565b9350808452888682840101111561108557600080fd5b61109481878601888501610fa8565b50508181526110a4848401610fd4565b9381019390935250604090810151908201529392505050565b60008160001904831182151516156110e557634e487b7160e01b600052601160045260246000fd5b500290565b60008261110757634e487b7160e01b600052601260045260246000fd5b500490565b600060c0828403121561111e57600080fd5b60405160c081018181106001600160401b038211171561114057611140610f3a565b8060405250825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a08201528091505092915050565b6001600160a01b03929092168252602082015260400190565b6000602082840312156111b057600080fd5b5051919050565b600082516111c9818460208701610fa8565b9190910192915050565b60208152600082518060208401526111f2816040850160208701610fa8565b601f01601f1916919091016040019291505056fea2646970667358221220ba3d168ff4471dfdaeaa12beb407f481810d80b938422d6b1bae349cf0edb93264736f6c634300080c0033
Verified Source Code Partial Match
Compiler: v0.8.12+commit.f00d7308
EVM: istanbul
Optimization: Yes (50 runs)
ReSwap.sol 139 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../treasury/interface/ILiquidityTreasury.sol";
struct Configuration {
uint256 depositThreshold;
uint256 claimThreshold;
uint256 claimCharge;
uint256 commissionRatio;
uint256 cooldown;
uint256 withdrawalCharge;
}
interface IMasterChef {
function config() external view returns (Configuration memory);
function whiteList(address user) external view returns (bool);
function highestParent() external view returns (address);
function deposit(address from, uint256 amount) external;
}
contract ReSwap is Ownable {
using SafeERC20 for IERC20;
IMasterChef public masterChef;
IERC20 public dai;
IERC20 public bark;
ILiquidityTreasury public lt;
uint256 public priceRatio;
bool public active;
address public receiver;
mapping(address => bool) public disableUser;
uint256 public constant RATE_PRECISION = 10000;
// @dev Errors
error InvalidAddress();
error InvalidAmount();
error InactiveContract();
error DisabledUser();
error InsufficientBalance();
error InvalidPriceRatio();
error NotWhitelisted();
error InvalidDAIAmount();
error InvalidBarkAmount();
error InvalidUser();
event Swap(address indexed from, bool inputBark, uint256 daiAmount, uint256 barkAmount);
event UpdateActive(bool state);
event UpdatePriceRatio(uint256 priceRatio);
event UpdateReceiver(address receiver);
event UpdateDisableUser(address from, bool state);
event Withdraw(address token, uint256 amount, address to);
constructor(
address _masterChef,
address _dai,
address _bark,
address _lt,
uint256 _priceRatio,
address _owner
) {
masterChef = IMasterChef(_masterChef);
dai = IERC20(_dai);
bark = IERC20(_bark);
lt = ILiquidityTreasury(_lt);
priceRatio = _priceRatio;
receiver = masterChef.highestParent();
active = true;
bark.safeApprove(_masterChef, type(uint256).max);
_transferOwnership(_owner);
}
function swap(address from, uint256 amount, bool inputBark) external returns (uint256 barkAmount, uint256 daiAmount) {
if (!active) revert InactiveContract();
if (disableUser[from]) revert DisabledUser();
if (!masterChef.whiteList(from)) revert NotWhitelisted();
if (from == address(0)) revert InvalidUser();
if (amount == 0) revert InvalidAmount();
uint256 price = lt.getTokenInfo(address(bark)).internalPrice * priceRatio / RATE_PRECISION;
if (inputBark) {// Mode 1: Input BARK, calculate DAI
barkAmount = amount;
daiAmount = barkAmount * price / RATE_PRECISION;
if (daiAmount == 0) revert InvalidDAIAmount();
} else {// Mode 2: Input DAI, calculate BARK
daiAmount = amount;
barkAmount = amount * RATE_PRECISION / price;
if (barkAmount == 0) revert InvalidBarkAmount();
}
Configuration memory config = masterChef.config();
if (barkAmount < config.depositThreshold) revert InvalidBarkAmount();
dai.safeTransferFrom(msg.sender, receiver, daiAmount);
masterChef.deposit(from, barkAmount);
emit Swap(from, inputBark, daiAmount, barkAmount);
}
function updateActive(bool _active) external onlyOwner {
active = _active;
emit UpdateActive(_active);
}
function updatePriceRatio(uint256 _priceRatio) external onlyOwner {
if (_priceRatio < 100 || _priceRatio > RATE_PRECISION) revert InvalidPriceRatio();
priceRatio = _priceRatio;
emit UpdatePriceRatio(_priceRatio);
}
function updateDisableUser(address from, bool state) external onlyOwner {
if (from == address(0)) revert InvalidAddress();
disableUser[from] = state;
emit UpdateDisableUser(from, state);
}
function emergencyWithdraw(address token, address to, uint256 amount) external onlyOwner {
if (to == address(0)) revert InvalidAddress();
if (IERC20(token).balanceOf(address(this)) < amount) revert InsufficientBalance();
IERC20(token).safeTransfer(to, amount);
emit Withdraw(token, amount, to);
}
}
ILiquidityTreasury.sol 66 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;
interface ILiquidityTreasury {
struct TokenInfo {
string name;
uint8 decimals;
uint256 internalPrice;
}
enum Operation { ADD, UPDATE }
function emergencyWithdrawal(address token, address to, uint256 amount) external;
function manageTokenPair(
uint256 pairId,
address tokenA,
address tokenB,
uint256 minAmount,
Operation op
) external;
function manageBondLife(uint256 durationInDays) external;
function manageBondType(
uint256 bondTypeId,
uint256 pairId,
uint256 lifeId,
bool offerActive,
bool settlementActive,
Operation op
) external;
function setBasicReturns(
address[] calldata tokens,
uint256[] calldata lifeIds,
uint256[] calldata returnRates
) external;
function setBatchUserRates(
address[] calldata users,
uint256[] calldata lifeIds,
uint256[] calldata points
) external;
function setReceiver(address to) external;
function setUniversalOfferLoanDisable(bool state) external;
function setUniversalSettlementDisable(bool state) external;
function setUniversalDropOut(bool state) external;
function setUserOfferLoanDisable(address from, bool state) external;
function setUserGetIncentiveDisable(address from, bool state) external;
function setUserSettlementDisable(address from, bool state) external;
function setSingleBondSettlementDisable(uint256 tokenId, bool state) external;
function transferOwnership(address newOwner) external;
function setIncentiveRate(uint256 rate) external;
function setInternalPrice(address token, uint256 price) external;
function setPointConfig(
uint256 lifeId,
uint256 activeUpperLevel,
uint256[] calldata weightFactors
) external;
function updatePoint(address from, uint256 lifeId, uint256 amount) external;
function setPointPermission(address from, bool enabled) external;
function setInFlowMode(uint256 mode, bool enabled) external;
function setOutFlowMode(uint256 mode) external;
function setFromPermission(address addr, bool enabled) external;
function setToPermission(address addr, bool enabled) external;
function getTokenInfo(address token) external view returns (TokenInfo memory);
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed 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.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (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.
*/
function allowance(address owner, address spender) external view returns (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.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` 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.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Read Contract
RATE_PRECISION 0x2b3ba681 → uint256
active 0x02fb0c5e → bool
bark 0x864f4a9a → address
dai 0xf4b9fa75 → address
disableUser 0xee6649a1 → bool
lt 0xa22ca2a6 → address
masterChef 0x575a86b2 → address
owner 0x8da5cb5b → address
priceRatio 0x0aa2f420 → uint256
receiver 0xf7260d3e → address
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
emergencyWithdraw 0xe63ea408
address token
address to
uint256 amount
renounceOwnership 0x715018a6
No parameters
swap 0x919722bb
address from
uint256 amount
bool inputBark
returns: uint256, uint256
transferOwnership 0xf2fde38b
address newOwner
updateActive 0x6764120c
bool _active
updateDisableUser 0x10b11e14
address from
bool state
updatePriceRatio 0xd8bd9260
uint256 _priceRatio
Recent Transactions
No transactions found for this address