Contract 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b 5

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x1abfa430396b7a5af643f59ee9e0eab30dac011d9c9a17776b4f7dd00d87e981Swap286175742022-05-22 5:14:3816 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002584607844 35.85152089
0xc9028c7704fc8bce9165e299a7dce4cbbf4ed12fda00252301bfbce569e5cd20Swap286175652022-05-22 5:14:2016 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002552657738 35.443734219
0x52d2231f643364ccbdb8742d2fe9c16d60364ac33775e9eef9ea93c4e29c5d7dSwap286171682022-05-22 5:00:4230 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003623601353 50.313820515
0x6849fdfeb2e16582540da128febdd7f8ff0e7b42aa29187b4c05baecf3138a0fSwap286169662022-05-22 4:53:4637 mins ago0x3a31b2206cc5039e01ea6d4bdaf1f9fea77c1372 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.010501646794 150.349999924
0xafd9c34edebf7f1787c19fef6fa3d4063248db67cf5bf76fed37bd6e7e89c5eaSwap286154422022-05-22 4:01:181 hr 29 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.004044860944 56.106932045
0xbb31188bd0803498b69937c77bec19792a990bc497d34830745bb57c724d8377Swap286154312022-05-22 4:00:561 hr 30 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002916554168 40.45600301
0x115f82b0e4263332bedcf07977928b87141eacac281a3d32da678b609bb2664eSwap286102372022-05-22 1:02:114 hrs 29 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002997966422 41.585285785
0xca6a5d651437e30e54e5a96b581c9da25f46de3115219d077c0115ad97ee570cSwap286077422022-05-21 23:36:255 hrs 54 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003932648262 54.550411452
0xd40d85b93deb041aca5575712806020c338306b78bf1b8d2096647d5ceae32caSwap286049912022-05-21 22:01:397 hrs 29 mins ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00336981042445.149933332
0xd7835b696c14a5c82411f810ab298f1151a5963c1e9999afb9b2fbc30095bbacSwap286042542022-05-21 21:36:217 hrs 54 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003867170857 53.651094022
0xcba4d0242bed9f2afca9c088cb8f55d9a036cb7c0a9731af9ba2283a6d97a35cSwap286007632022-05-21 19:36:199 hrs 54 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.004565066666 63.333333332
0x99e96779d7fb1b1652a6effaa212b2c2ccf88e7e65cebf18cafdefb8635aa6e7Swap285991382022-05-21 18:36:1310 hrs 55 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003023916459 41.994173702
0x27d19ec327656b901e2b76a13a6d272053c9665436c2687cf32922891ee8868eSwap285974012022-05-21 17:36:3111 hrs 54 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003471365603 48.151883757
0x811e0fa5b0e33684684ff4b2e61fbcdb0b6e38dc1cff6f1d54333cfc2ec2ebbeSwap285956592022-05-21 16:36:3912 hrs 54 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003714123803 51.519222707
0x99acb6eb6fa54fe72036f60f08dd3843732995f859d7caa0a787dcd4c28123e4Swap285956502022-05-21 16:36:2112 hrs 54 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003489826573 48.416017944
0x30230f6eb61fcad4575a26046d5ddf2e416b9bd568be51121d7f490315aa80c1Swap285939102022-05-21 15:36:2513 hrs 54 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003189636411 44.243971746
0xa16af0f62f3d1862e27c36c381063813b38452fedab3cd2e1baaab8de2836993Swap285939072022-05-21 15:36:1913 hrs 54 mins ago0x81beeb941e9412e1e1099ff7867cfdf4c9485bd1 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003359283439 46.604931177
0xf0927de69af6396297170858652fd25823707117f68360ea200bea73da79453eSwap285931962022-05-21 15:11:5314 hrs 19 mins ago0xeb562f4b862e3d7c7dd306d9a26de98660390310 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.001992934918 39.454682429
0xec37a45f4069324cfc5b301ca07526f7868307a23bc90cae19b4cf28fa8499dfSwap285931932022-05-21 15:11:4714 hrs 19 mins ago0xeb562f4b862e3d7c7dd306d9a26de98660390310 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003552777127 39.832912458
0x7f99d1f5a4a7d4e88f818da24b133dec3b431416713861eddd30a3802cb72680Swap285886822022-05-21 12:36:3916 hrs 54 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003416617258 47.400350419
0x83483f5187ab729721859d4408766d15632dfb02442d3a2e4b1523625613fdb5Swap285869022022-05-21 11:33:0117 hrs 58 mins ago0x7612128bde69d375adfecb792a04ad1d717cc446 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003486423123 37.102238242
0x2d35135372e22719d8691e30d859c73b9c498b7a5aa4757ffc0cd81828999342Swap285854482022-05-21 10:42:1418 hrs 48 mins ago0x0468c8d4e517c37267aa1dbf307350ffc996cbcb IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002667768784 30.69081939
0xdf572bb1afddc759fa3a492c787fd3e4120262f287d3704a613b472242271ca8Swap285847862022-05-21 10:18:0819 hrs 13 mins ago0x64ebaf2601be673f93cb48ae2b3942e7b2650161 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003248249464 45.064504226
0x5a42cf46cd51efcda79b5c7280c5cbccc9802374c388b71ef2acf9c77443a640Swap285847812022-05-21 10:17:5819 hrs 13 mins ago0x0468c8d4e517c37267aa1dbf307350ffc996cbcb IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002817681444 32.415459995
0x4464ac34b55755bde1640eca782dfbbdc909dd4fd8ddec9ab7c87dca40481122Swap285828212022-05-21 9:08:1620 hrs 22 mins ago0x7612128bde69d375adfecb792a04ad1d717cc446 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00253510664 32.980000005
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PegSwap

Compiler Version
v0.6.6+commit.6c089d02

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity)

/**
 *Submitted for verification at polygonscan.com on 2021-06-30
*/

// File: @chainlink/contracts/src/v0.6/Owned.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

/**
 * @title The Owned contract
 * @notice A contract with helpers for basic contract ownership.
 */
contract Owned {

  address public owner;
  address private pendingOwner;

  event OwnershipTransferRequested(
    address indexed from,
    address indexed to
  );
  event OwnershipTransferred(
    address indexed from,
    address indexed to
  );

  constructor() public {
    owner = msg.sender;
  }

  /**
   * @dev Allows an owner to begin transferring ownership to a new address,
   * pending.
   */
  function transferOwnership(address _to)
    external
    onlyOwner()
  {
    pendingOwner = _to;

    emit OwnershipTransferRequested(owner, _to);
  }

  /**
   * @dev Allows an ownership transfer to be completed by the recipient.
   */
  function acceptOwnership()
    external
  {
    require(msg.sender == pendingOwner, "Must be proposed owner");

    address oldOwner = owner;
    owner = msg.sender;
    pendingOwner = address(0);

    emit OwnershipTransferred(oldOwner, msg.sender);
  }

  /**
   * @dev Reverts if called by anyone other than the contract owner.
   */
  modifier onlyOwner() {
    require(msg.sender == owner, "Only callable by owner");
    _;
  }

}

// File: @openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `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.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @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);
}

// File: @openzeppelin/contracts/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @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.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting 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.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;




/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

// File: contracts/v0.6/token/ERC677Receiver.sol

pragma solidity ^0.6.0;

abstract contract ERC677Receiver {
  function onTokenTransfer(address _sender, uint _value, bytes memory _data) public virtual;
}

// File: contracts/v0.6/PegSwap.sol

pragma solidity >=0.6.0 <0.8.0;






/**
 * @notice This contract provides a one-to-one swap between pairs of tokens. It
 * is controlled by an owner who manages liquidity pools for all pairs. Most
 * users should only interact with the swap, onTokenTransfer, and
 * getSwappableAmount functions.
 */
contract PegSwap is Owned, ReentrancyGuard {
  using SafeMath for uint256;

  event LiquidityUpdated(
    uint256 amount,
    address indexed source,
    address indexed target
  );
  event TokensSwapped(
    uint256 amount,
    address indexed source,
    address indexed target,
    address indexed caller
  );
  event StuckTokensRecovered(
    uint256 amount,
    address indexed target
  );

  mapping(address => mapping(address => uint256)) private s_swappableAmount;

  /**
   * @dev Disallows direct send by setting a default function without the `payable` flag.
   */
  fallback()
    external
  {}

  /**
   * @notice deposits tokens from the target of a swap pair but does not return
   * any. WARNING: Liquidity added through this method is only retrievable by
   * the owner of the contract.
   * @param amount count of liquidity being added
   * @param source the token that can be swapped for what is being deposited
   * @param target the token that can is being deposited for swapping
   */
  function addLiquidity(
    uint256 amount,
    address source,
    address target
  )
    external
  {
    bool allowed = owner == msg.sender || _hasLiquidity(source, target);
    // By only allowing the owner to add a new pair, we reduce the potential of
    // possible attacks mounted by malicious token contracts.
    require(allowed, "only owner can add pairs");

    _addLiquidity(amount, source, target);

    require(ERC20(target).transferFrom(msg.sender, address(this), amount), "transferFrom failed");
  }

  /**
   * @notice withdraws tokens from the target of a swap pair.
   * @dev Only callable by owner
   * @param amount count of liquidity being removed
   * @param source the token that can be swapped for what is being removed
   * @param target the token that can is being withdrawn from swapping
   */
  function removeLiquidity(
    uint256 amount,
    address source,
    address target
  )
    external
    onlyOwner()
  {
    _removeLiquidity(amount, source, target);

    require(ERC20(target).transfer(msg.sender, amount), "transfer failed");
  }

  /**
   * @notice exchanges the source token for target token
   * @param amount count of tokens being swapped
   * @param source the token that is being given
   * @param target the token that is being taken
   */
  function swap(
    uint256 amount,
    address source,
    address target
  )
    external
    nonReentrant()
  {
    _removeLiquidity(amount, source, target);
    _addLiquidity(amount, target, source);

    emit TokensSwapped(amount, source, target, msg.sender);

    require(ERC20(source).transferFrom(msg.sender, address(this), amount), "transferFrom failed");
    require(ERC20(target).transfer(msg.sender, amount), "transfer failed");
  }

  /**
   * @notice send funds that were accidentally transferred back to the owner. This
   * allows rescuing of funds, and poses no additional risk as the owner could
   * already withdraw any funds intended to be swapped. WARNING: If not called
   * correctly this method can throw off the swappable token balances, but that
   * can be recovered from by transferring the discrepancy back to the swap.
   * @dev Only callable by owner
   * @param amount count of tokens being moved
   * @param target the token that is being moved
   */
  function recoverStuckTokens(
    uint256 amount,
    address target
  )
    external
    onlyOwner()
  {
    emit StuckTokensRecovered(amount, target);

    require(ERC20(target).transfer(msg.sender, amount), "transfer failed");
  }

  /**
   * @notice swap tokens in one transaction if the sending token supports ERC677
   * @param sender address that initially initiated the call to the source token
   * @param amount count of tokens sent for the swap
   * @param targetData address of target token encoded as a bytes array
   */
  function onTokenTransfer(
    address sender,
    uint256 amount,
    bytes calldata targetData
  )
    external
  {
    address source = msg.sender;
    address target = abi.decode(targetData, (address));

    _removeLiquidity(amount, source, target);
    _addLiquidity(amount, target, source);

    emit TokensSwapped(amount, source, target, sender);

    require(ERC20(target).transfer(sender, amount), "transfer failed");
  }

  /**
   * @notice returns the amount of tokens for a pair that are available to swap
   * @param source the token that is being given
   * @param target the token that is being taken
   * @return amount count of tokens available to swap
   */
  function getSwappableAmount(
    address source,
    address target
  )
    public
    view
    returns(
      uint256 amount
    )
  {
    return s_swappableAmount[source][target];
  }


  // PRIVATE

  function _addLiquidity(
    uint256 amount,
    address source,
    address target
  )
    private
  {
    uint256 newAmount = getSwappableAmount(source, target).add(amount);
    s_swappableAmount[source][target] = newAmount;

    emit LiquidityUpdated(newAmount, source, target);
  }

  function _removeLiquidity(
    uint256 amount,
    address source,
    address target
  )
    private
  {
    uint256 newAmount = getSwappableAmount(source, target).sub(amount);
    s_swappableAmount[source][target] = newAmount;

    emit LiquidityUpdated(newAmount, source, target);
  }

  function _hasLiquidity(
    address source,
    address target
  )
    private
    returns (
      bool hasLiquidity
    )
  {
    if (getSwappableAmount(source, target) > 0) return true;
    if (getSwappableAmount(target, source) > 0) return true;
    return false;
  }

}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"source","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"}],"name":"LiquidityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"target","type":"address"}],"name":"StuckTokensRecovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"source","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"TokensSwapped","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"source","type":"address"},{"internalType":"address","name":"target","type":"address"}],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"source","type":"address"},{"internalType":"address","name":"target","type":"address"}],"name":"getSwappableAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"targetData","type":"bytes"}],"name":"onTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"target","type":"address"}],"name":"recoverStuckTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"source","type":"address"},{"internalType":"address","name":"target","type":"address"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"source","type":"address"},{"internalType":"address","name":"target","type":"address"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6080604052600080546001600160a01b031916331790556001600255610d5e8061002a6000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c806379ba50971161006657806379ba5097146101695780638da5cb5b14610171578063a4c0ed3614610195578063f2fde38b1461021a578063f31abcc41461024057610093565b806316094ece146100955780632b7f0923146100d5578063442d77b0146101095780634910630a14610135575b005b6100c3600480360360408110156100ab57600080fd5b506001600160a01b0381358116916020013516610274565b60408051918252519081900360200190f35b610093600480360360608110156100eb57600080fd5b508035906001600160a01b03602082013581169160400135166102a1565b6100936004803603604081101561011f57600080fd5b50803590602001356001600160a01b03166104f7565b6100936004803603606081101561014b57600080fd5b508035906001600160a01b0360208201358116916040013516610650565b61009361079c565b61017961084b565b604080516001600160a01b039092168252519081900360200190f35b610093600480360360608110156101ab57600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156101db57600080fd5b8201836020820111156101ed57600080fd5b8035906020019184600183028401116401000000008311171561020f57600080fd5b50909250905061085a565b6100936004803603602081101561023057600080fd5b50356001600160a01b03166109bc565b6100936004803603606081101561025657600080fd5b508035906001600160a01b0360208201358116916040013516610a65565b6001600160a01b038083166000908152600360209081526040808320938516835292905220545b92915050565b6002805414156102f8576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60028055610307838383610b8b565b610312838284610c10565b336001600160a01b0316816001600160a01b0316836001600160a01b03167fee68281800fd374dbd49d54fe359343466bfeac7fcd7971e268acf415097345b866040518082815260200191505060405180910390a4604080516323b872dd60e01b81523360048201523060248201526044810185905290516001600160a01b038416916323b872dd9160648083019260209291908290030181600087803b1580156103bc57600080fd5b505af11580156103d0573d6000803e3d6000fd5b505050506040513d60208110156103e657600080fd5b505161042f576040805162461bcd60e51b81526020600482015260136024820152721d1c985b9cd9995c919c9bdb4819985a5b1959606a1b604482015290519081900360640190fd5b6040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b0383169163a9059cbb9160448083019260209291908290030181600087803b15801561047e57600080fd5b505af1158015610492573d6000803e3d6000fd5b505050506040513d60208110156104a857600080fd5b50516104ed576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b5050600160025550565b6000546001600160a01b0316331461054f576040805162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b604482015290519081900360640190fd5b6040805183815290516001600160a01b038316917f9e491d87752491d550c542a9393e549a5fe64736584d59fdf01e9711e5e27f5a919081900360200190a26040805163a9059cbb60e01b81523360048201526024810184905290516001600160a01b0383169163a9059cbb9160448083019260209291908290030181600087803b1580156105dd57600080fd5b505af11580156105f1573d6000803e3d6000fd5b505050506040513d602081101561060757600080fd5b505161064c576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b5050565b600080546001600160a01b031633148061066f575061066f8383610c2c565b9050806106c3576040805162461bcd60e51b815260206004820152601860248201527f6f6e6c79206f776e65722063616e206164642070616972730000000000000000604482015290519081900360640190fd5b6106ce848484610c10565b604080516323b872dd60e01b81523360048201523060248201526044810186905290516001600160a01b038416916323b872dd9160648083019260209291908290030181600087803b15801561072357600080fd5b505af1158015610737573d6000803e3d6000fd5b505050506040513d602081101561074d57600080fd5b5051610796576040805162461bcd60e51b81526020600482015260136024820152721d1c985b9cd9995c919c9bdb4819985a5b1959606a1b604482015290519081900360640190fd5b50505050565b6001546001600160a01b031633146107f4576040805162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b604482015290519081900360640190fd5b60008054336001600160a01b0319808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b031681565b3360008383602081101561086d57600080fd5b50356001600160a01b03169050610885858383610b8b565b610890858284610c10565b856001600160a01b0316816001600160a01b0316836001600160a01b03167fee68281800fd374dbd49d54fe359343466bfeac7fcd7971e268acf415097345b886040518082815260200191505060405180910390a4806001600160a01b031663a9059cbb87876040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561094557600080fd5b505af1158015610959573d6000803e3d6000fd5b505050506040513d602081101561096f57600080fd5b50516109b4576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b505050505050565b6000546001600160a01b03163314610a14576040805162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000546001600160a01b03163314610abd576040805162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b604482015290519081900360640190fd5b610ac8838383610b8b565b6040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b0383169163a9059cbb9160448083019260209291908290030181600087803b158015610b1757600080fd5b505af1158015610b2b573d6000803e3d6000fd5b505050506040513d6020811015610b4157600080fd5b5051610b86576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b505050565b6000610ba784610b9b8585610274565b9063ffffffff610c6a16565b6001600160a01b0380851660008181526003602090815260408083209488168084529482529182902085905581518581529151949550929391927f9832bb3eced80e5d53e74bd87d617aff406ef3afd433670cd9b3dcbf3ba99d8c92918290030190a350505050565b6000610ba784610c208585610274565b9063ffffffff610cc716565b600080610c398484610274565b1115610c475750600161029b565b6000610c538385610274565b1115610c615750600161029b565b50600092915050565b600082821115610cc1576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015610d21576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b939250505056fea2646970667358221220ffe553a4e0b4056093e60de734f736e4382e68f02936d0e121b913b4bae54d5464736f6c63430006060033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.