Contract 0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b 5

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xcd2a3d6e35afb2431df80747f5d8ded889ab15db1f5a39da573ec344e83c9cf2Swap317818852022-08-11 21:16:4914 mins ago0x1982c37b698ff8070fae3664022c3303392132fa IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003018405111 33.841657457
0xcf6ceb504f67549ef71b9363ed6ce198431b686b7b95765323ee9e6cfdaf565aSwap317799432022-08-11 20:01:311 hr 29 mins ago0x59ecf48345a221e0731e785ed79ed40d0a94e2a5 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002160210468 30.927305985
0xff627e57acac7e37e90f83544e1cfc49e3b923cf73f1f7a9708179b9a335eaa6Swap317777692022-08-11 18:32:562 hrs 58 mins ago0x077d79c5f8d7186bc3bb96134a336a6aa928a11b IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002758888951 38.269002826
0xec6487b9e0a0ef7c1b1ba1678925b36441b1c0ac7568981aeeb7f089b7b15679Swap317773192022-08-11 18:13:563 hrs 17 mins ago0xd6c9f0f1025bdeeab2f8d2b2d4a95c24b3f5eb2f IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00223373631
0xbc5dc62d47ff83da6fb7d4a96ac3caacca885264e462b11315738567aa65d3a7Swap317759352022-08-11 17:19:334 hrs 11 mins ago0xeb766229994df8018df659801cdc6a85073dd112 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002675040006 30.00000007
0xf27fb206d634f3085a9dcd1b1166c35df1d2b3ea87dd589a171ef771ee64140fSwap317701632022-08-11 13:37:167 hrs 53 mins ago0x87defe2895d1a4ff9ac5b83eb4133cc197b0fa9c IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.004002908008 49.000000103
0x2ce0b153623f2125be4ab677daa237a5af5f8cb2a7522b6e2816ef74c69434f4Swap317700422022-08-11 13:33:067 hrs 57 mins ago0x711d0613aa152f5dce8ab32996cde29ed52ce277 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.089204 1,000
0x4f7858327d5e55cc32a8367b0821b6d60df1eb7613cb18df6879145d817add17Swap317692482022-08-11 13:03:398 hrs 27 mins ago0x6182ecd8234397aee84e37f97a0ecef652cc264e IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.010401965105 135.280199568
0x50985de6fd3a9545db8896e0531a6b2ecf788f164b05797203fd2f18f5e2c629Swap317684712022-08-11 12:32:418 hrs 58 mins ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00358137624148.000003236
0x053b5261d539834f7ad67672c383ee3b4b5d7f47896fb3987c3b04258c4e54f1Swap317657482022-08-11 10:54:4710 hrs 36 mins ago0x62395e1758781d1f68d3892af0f7bb4cef3bb827 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.0023071200130.000000142
0xba69618c5fd7b192e204ebd3d34d1a7f137bdbfc27a26dbdf210a3cc465711a4Swap317594442022-08-11 6:56:3714 hrs 34 mins ago0x2430403186b3a9e08ba7264fbb924447cb7a31d6 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002167445599 30.069999988
0x49c0de7669ae017f7350904d39fed5261a8572431a3b8e4c3379fdc8992f20e2Swap317528402022-08-11 2:52:3418 hrs 38 mins ago0x75397161c7df290080ec9c12a371750145a00502 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002573759095 36.847999885
0xfd0c3c22aff4490166629dd4e26611433fc87de4f2c8d019b81d7801713454bfSwap317515432022-08-11 2:05:4719 hrs 25 mins ago0x31fbc238e1d63bdda394379c148e07bd2a77e517 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.004023546685 45.105002974
0x7e897d0035ac16a0192e6c01b6696295d61aa2c1aedad940739e3b9da9b6d302Swap317511672022-08-11 1:52:5119 hrs 38 mins ago0x3cbc647b54625b5a4dcfc34430e1418b5dc7da57 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.004574759915 56.000096889
0x1815ef62edaf4a870ddf0b5d56b33e97c4db9720d11dd411e6f41569d100d806Swap317459122022-08-10 22:32:2022 hrs 58 mins ago0x3fb4600736d306ee2a89edf0356d4272fb095768 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00209544001430.000000203
0x128662bbc37fc9d495db46cd9e9999d6274dba13983b70fc0700d0cf118281e5Swap317451492022-08-10 22:01:5023 hrs 29 mins ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.0034705737146.499996125
0x362628f20c0dbaff166725df77b5ba418515aac36e6bc13be8b398db19f78062Swap317445492022-08-10 21:40:2223 hrs 50 mins ago0x2642127cd8a3a4d6765daa860d0b1a56d03b9547 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.030752400
0x0356ee7357f0da572f176ebdae0c4bd2bdbd6e07e193fabf58a4b17f3c0b874cSwap317443592022-08-10 21:32:3423 hrs 58 mins ago0x2642127cd8a3a4d6765daa860d0b1a56d03b9547 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.030752400
0x89c3eb94ca81e6e21f33481b67cbd34c16692fe4915579576f8bae725f2c450fSwap317441012022-08-10 21:21:341 day 9 mins ago0xa20dec41a1e26b050fdd352eeb387cc6cb28c2be IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002543405761 35.280000014
0x17174f38866a341f7e5ca2cb4a2ebbf1b8f562cd952a990a1a0dec97d73eb308Swap317426742022-08-10 20:23:561 day 1 hr ago0x09978e74f3152fde5012420cc258468be76cafc5 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002971455628 31.621995028
0x1e85e5d9aa06ff5940b917cab24ee0c4421d659d2043a774d968f386a1a466a1Swap317408212022-08-10 19:05:121 day 2 hrs ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00357619101347.915094772
0x137fa13961522cf82b9dd47dd69518bac9b31a43d8953d4f1013f76174a9da0cSwap317358362022-08-10 15:28:391 day 6 hrs ago0xa688a477c3cc4835cb6cba3160391bd5ae1d93aa IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.007551112294 84.684105219
0xe2df5443d873c9e21d39effd63547dd25a4e83a3dc3a061be268f9697d3e9250Swap317342842022-08-10 14:22:301 day 7 hrs ago0x4fd8ddcff8e0757831913535447ea3185159fda4 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.01774229543 217.185225366
0x741c66e667cf0b32619e0f8f049e315fc62c902ff4b6e46a322bc581b3e0cc0cSwap317342402022-08-10 14:20:581 day 7 hrs ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.024829684784332.784066694
0x7da40e5be1d3f7ff0722cb9d6824ca2bfb1ddfdf6e828fd5e416a3b24f4ee8c4Swap317319082022-08-10 12:35:101 day 8 hrs ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.04797968115643.055824136
[ 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.