Contract 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b 5

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x086b4cf694c2e642f14d5d285ef1cbac9b711b59ba310423d670ad4c744f4771Swap304195352022-07-06 22:16:469 mins ago0x877998df4eae3e230646a95d9a2bfc15f4ab2419 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00223485231
0xcc251f5eabd292faffc72229f5f3bcdebe9300b8a3efaaf244b242605299a313Swap304192212022-07-06 22:01:4225 mins ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003425792445.900000012
0x383a25e0d76b73decd68c5cfacbd18e054cac5b878dbcd334d778e9c48bcf10eSwap304182042022-07-06 21:24:241 hr 2 mins ago0x943ec19143f06e3420b3f0a6ac98e7f3ee700774 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003491834763 39.14964081
0x3824a68ba1b5b704d146d647f959360e9e40de3a32c35bb9c3b2c2c6be653283Swap304181382022-07-06 21:20:121 hr 6 mins ago0x42056ee6060ab779124be04ae124ee87dd7ea99b IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002932146839 33.732304541
0xdf85145ea344a6fd2245dcbc1289149aa5a6d335b55d3017bd9cc7fcc352972fSwap304174892022-07-06 20:55:461 hr 30 mins ago0x4dc81f63cb356c1420d4620414f366794072a3a8 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.004156182019 47.807375761
0xa163430e483c8a7c5206670915080764d0e7b6350a891113236b05f388143c06Swap304097532022-07-06 15:51:506 hrs 34 mins ago0xd94e880075afa8395fd61bf47595c878a84e8add IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002334503037 30.365544196
0x0a0718bc7bad721a71d2cb47876ea8e238b65d0ee80ff69461f5bcada8d3ca30Swap304094602022-07-06 15:39:366 hrs 47 mins ago0xd94e880075afa8395fd61bf47595c878a84e8add IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002819040001 30.000000015
0xb592c8abe2d7e848ea5186ca2b568d5d7aafc74f1638792519df40b6f03ae975Swap304011452022-07-06 10:42:4111 hrs 44 mins ago0xef0f7ecef8385483ac6a2e92d761f571c4b782bd IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002477742482 34.38061945
0xc603c66d8ed04c032ec8e3d58fc7b3e56bab58f0ebe622f97ee1904380bd0fd5Swap303980102022-07-06 8:48:2513 hrs 38 mins ago0x62395e1758781d1f68d3892af0f7bb4cef3bb827 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00375694605950.328824071
0xa44972086b908545201f88f1265bf00acca345bf6a5d335fc780ef1c9a123061Swap303935472022-07-06 6:02:0816 hrs 24 mins ago0x11cb4b21b11b6c1282291a01cb7725933fd76792 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003521479707 39.49263982
0xd55b77bbbf646c78eed5039b24371d336a90faa945863a1780129c8bb443c2c7Swap303924832022-07-06 5:19:0817 hrs 7 mins ago0x42056ee6060ab779124be04ae124ee87dd7ea99b IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002681284534 30.070031121
0xc7564854ca2b4338279e43b0016fd12bbd49237ce5630982d33f1ea751da0e01Swap303913482022-07-06 4:37:5817 hrs 48 mins ago0x077d79c5f8d7186bc3bb96134a336a6aa928a11b IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002680758858 30.06413577
0xba42e7228a7b53bb01f8b32bfc083bef9e7d2c03bc237948ebfafcf534d7d8f2Swap303884032022-07-06 2:46:0419 hrs 40 mins ago0x75397161c7df290080ec9c12a371750145a00502 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002213326316 31.693200013
0x9223617fa6ed18eade26b44b02416e780389c3e265e293d4349c08ffb494e1dfSwap303852792022-07-06 0:43:3921 hrs 43 mins ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00467489047162.656013398
0x0932ea1bbf4948bb785be35494525fa2dce1092c2bc4124c79a736673cba4ce3Swap303813142022-07-05 22:01:481 day 24 mins ago0xec4d4686670ddaaa6b44847c34122df21fac1948 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00498493971766.790017115
0x715a33e993e1fb1ea977ae0b778c0c56b0330e407a7d8020af5242bfe7c6e61bSwap303767352022-07-05 19:07:171 day 3 hrs ago0x87defe2895d1a4ff9ac5b83eb4133cc197b0fa9c IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.013442698081 164.553421163
0xd1bf88b0f1d867c7d3c9e65aad9c7144b2d23e960148975835ef0eb522cb576dSwap303762272022-07-05 18:47:411 day 3 hrs ago0xb8c6e43f37e04a2411562a13c1c48b3ad5975cf4 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.003353221334 38.565824801
0x726ff8184efa3fa9da430dd09a420e67fbd9954cd4c6a0dece9030d274d95a4eSwap303703182022-07-05 15:13:511 day 7 hrs ago0x9efa0a617c0552f1558c95993aa8b8a68b3e709c IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002168387212 31.049705198
0xa60417c0a2ef73fec888c665532a898e4223e1daccbfbd99612bd7f13a24ecd1Swap303699742022-07-05 15:01:591 day 7 hrs ago0x034e67f401521cb404ccea1b97ae9b28883c0638 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00294155216 32.980000002
0xed3c58e5cda5b636a9797ffff203e27857bc5b844ebbca84e90ec6534c8fe6d4Swap303674072022-07-05 13:27:211 day 8 hrs ago0x682dda43596e5be2979d6d983343b0ba52888481 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002094360001 30.000000018
0xe2ba04cfc31ee7350e15eea6852acbfbb4bb7649614310abd4c15305ad366496Swap303664962022-07-05 12:51:471 day 9 hrs ago0x62395e1758781d1f68d3892af0f7bb4cef3bb827 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00238402399630.999999954
0xfddd804ac56a062bc7bc3a22bd631ad71dffb7778d5141ac7286e85b35d17a65Swap303651262022-07-05 12:02:351 day 10 hrs ago0x0a4ac5853dc9eff78f10c3c88f40dc9b9386f97c IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002967507049 33.2710002
0x7f4b8c07d8b5100a4539bdd60dc5914119331afcf999afea06f0245ea30075f0Swap303646182022-07-05 11:42:591 day 10 hrs ago0x682dda43596e5be2979d6d983343b0ba52888481 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.002142246967 30.67539618
0x4410af98133dee24fc23a184e841f9eb46409928866e50199168e1581d9d50cbSwap303635462022-07-05 11:03:571 day 11 hrs ago0x62395e1758781d1f68d3892af0f7bb4cef3bb827 IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00231250426230.070012773
0x8293e8a203b98b4a9ba0ce16bf157ae471cb2203079fd6e695c0d64e3637081dSwap303633952022-07-05 10:56:391 day 11 hrs ago0xbc9ac18ea3b24fdff0a63bd7cb9dfd5469c199da IN  0xaa1dc356dc4b18f30c347798fd5379f3d77abc5b0 MATIC0.00267579766 30.000422237
[ 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.