Spend less on fees, more on crypto. Buy crypto easily with MoonPay Balance. 20M+ users trust MoonPay worldwide.
Ready to onboard to Ethereum? With MetaMask Portfolio, you're in control.
Don’t invest unless you’re prepared to lose all the money you invest.
Everyday giveaways up to 100 ETH, Lucky Spins. Deposit BONUS 300% and Cashbacks!
5000+ Slots & Live Casino Games, 50+cryptos. Register with Etherscan and get 760% deposit bonus. Win Big$, withdraw it fast.
Slots, Roulette, Poker & more - Proud sponsors of UFC, Everton & StakeF1 team!
5000+ Slots & Live Casino Games, 50+cryptos. Register with Etherscan and get 760% deposit bonus. Win Big$, withdraw it fast.
Anonymous play on awesome games - sign up now for 25 free jackpot spins - worth $100s!
100s of games, generous bonuses, 20+ years of trusted gaming. Join CryptoWins & start winning today!
Overview
ETH Balance
Eth Value
$64,081.66 (@ $3,394.56/ETH)Token Holdings
Could not find any matches!
- ERC-20 Tokens (>200)57,847.68363946 1INCH1INCH Token (1INCH)$22,449.88@0.388137.80783481 ANYAnyswap (ANY)$262.57@6.94480.6757429 arNXMArmor NXM (arNXM)$15.62@23.12256.99961321 CTSICartesi Toke... (CTSI)$47.21@0.183717 CHIChi Gastoken... (CHI)$0.24@0.01423,345.10578066 DOVDOVU (DOV)$2.63@0.00083,640.61072056 NCTNameChangeTo... (NCT)$3.38@0.00097.40830164 OPIUMOpium Govern... (OPIUM)$0.45@0.060534.20734897 POOLPoolTogether (POOL)$42.42@1.24383.46461896 PRTPortion Toke... (PRT)$0.06@0.00020.01609707 stETHstETH (stETH)$54.67@3,396.352.2296341 TORNTORN Token (TORN)$40.45@18.1465.45841891 VSPVesperToken (VSP)$15.70@0.23992,557.62311921 WXTWirex Token (WXT)$8.22@0.00326,000.23864948 DAIDai Stableco... (DAI)$5,993.70@0.998952.23464618 FTMFantom Token (FTM)$57.98@1.116,790.592762 USDTTether USD (USDT)$6,785.33@0.9992913.595765 USDCUSDC (USDC)$913.04@0.99940.01305113 WBTCWrapped BTC (WBTC)$1,204.18@92,266.0048,000 Earn $TUSD airdrops at https://www.tenorusd.org$ tenorusd.o... (Earn $...)0.00000219 1LP-1INCH-0xae7ab96520de3a18e5e111b5eaab095312d7fe1inch Liquid... (1LP-1I...)0.96080716 1LP-1INCH-ALPHA1inch Liquid... (1LP-1I...)0 1LP-1INCH-AMPL1inch Liquid... (1LP-1I...)0.05825121 1LP-1INCH-ANKR1inch Liquid... (1LP-1I...)64.6009277 1LP-1INCH-ARCX1inch Liquid... (1LP-1I...)1.38941717 1LP-1INCH-ARCX1inch Liquid... (1LP-1I...)0.66341502 1LP-1INCH-AUDIO1inch Liquid... (1LP-1I...)714.81129588 1LP-1INCH-AURORA1inch Liquid... (1LP-1I...)61.49387461 1LP-1INCH-AVINOC1inch Liquid... (1LP-1I...)1,132.25269318 1LP-1INCH-BAO1inch Liquid... (1LP-1I...)136.03024898ERC20 ***1.95942169 1LP-1INCH-EFI1inch Liquid... (1LP-1I...)233.42696887 1LP-1INCH-ELON1inch Liquid... (1LP-1I...)0.17737819 1LP-1INCH-FET1inch Liquid... (1LP-1I...)0.03280558 1LP-1INCH-FORTH1inch Liquid... (1LP-1I...)119.09156315 1LP-1INCH-ICHI1inch Liquid... (1LP-1I...)0 1LP-1INCH-INXT1inch Liquid... (1LP-1I...)1.25667633 1LP-1INCH-JRT1inch Liquid... (1LP-1I...)0.09215106 1LP-1INCH-LDO1inch Liquid... (1LP-1I...)1.77721972 1LP-1INCH-MARK1inch Liquid... (1LP-1I...)5.43576364 1LP-1INCH-MILK21inch Liquid... (1LP-1I...)3.91171883 1LP-1INCH-OCTO1inch Liquid... (1LP-1I...)754.71089271 1LP-1INCH-OPIUM1inch Liquid... (1LP-1I...)0.63929284 1LP-1INCH-PHA1inch Liquid... (1LP-1I...)20.13010098 1LP-1INCH-renDGB1inch Liquid... (1LP-1I...)1.99087381 1LP-1INCH-RGT1inch Liquid... (1LP-1I...)1.19615716 1LP-1INCH-SHAKE1inch Liquid... (1LP-1I...)4,173.69771559 1LP-1INCH-SHIB1inch Liquid... (1LP-1I...)1,797.84677361 1LP-1INCH-SPH1inch Liquid... (1LP-1I...)5.37671795 1LP-1INCH-STORJ1inch Liquid... (1LP-1I...)744.91474798 1LP-1INCH-SWISE1inch Liquid... (1LP-1I...)106.75865708 1LP-1INCH-TMM1inch Liquid... (1LP-1I...)1.65934871 1LP-1INCH-UNI1inch Liquid... (1LP-1I...)56.54335542 1LP-1INCH-USDK1inch Liquid... (1LP-1I...)30.17603099ERC20 ***0.05683692 1LP-1INCH-VERI1inch Liquid... (1LP-1I...)0.28593559 1LP-1INCH-VOW1inch Liquid... (1LP-1I...)0.25331075 1LP-1INCH-VSP1inch Liquid... (1LP-1I...)0.00003336 1LP-1INCH-WETH1inch Liquid... (1LP-1I...)16.69414789 1LP-1INCH-XYO1inch Liquid... (1LP-1I...)1,213.90513196ERC20 ***65,424.89774807ERC20 ***38.85761972 1LP-AMPL-WAMPL1inch Liquid... (1LP-AM...)4,802.88741036ERC20 ***2,165.010609ERC20 ***12.1730138 1LP-BNT-ETHMNY1inch Liquid... (1LP-BN...)8,557.20169826ERC20 ***178.71188886 1LP-BXX-WETH1inch Liquid... (1LP-BX...)0ERC20 ***116.85560143 1LP-CHIP-1INCH1inch Liquid... (1LP-CH...)2.86021549ERC20 ***10.04946706 1LP-DAI-0xae7ab96520de3a18e5e111b5eaab095312d7fe841inch Liquidity Pool (DAI-0xae7ab96520de3a18e5e111b5eaab095312d7fe84)617.32701704ERC20 ***2.62741738ERC20 ***62.80602994ERC20 ***0.65870547ERC20 ***94.19879423ERC20 ***0.00005698ERC20 ***0.88444006ERC20 ***537.19653908ERC20 ***541.18057528ERC20 ***0.0000004 1LP-ETH-0xae7ab96520de3a18e5e111b5eaab095312d7fe841inch Liquid... (1LP-ET...)3.06370238 1LP-ETH-1INCH1inch Liquid... (1LP-ET...)5,908.09647706 1LP-ETH-ABYSS1inch Liquid... (1LP-ET...)696.24576591 1LP-ETH-AGOR1inch Liquid... (1LP-ET...)0.00130807 1LP-ETH-ALCX1inch Liquid... (1LP-ET...)0.00207016 1LP-ETH-AMPL1inch Liquid... (1LP-ET...)1.15169221 1LP-ETH-ANY1inch Liquid... (1LP-ET...)7.61010656 1LP-ETH-APE1inch Liquid... (1LP-ET...)0.00127366 1LP-ETH-APECOIN1inch Liquid... (1LP-ET...)139.99487004 1LP-ETH-ARCONA1inch Liquid... (1LP-ET...)4,513.12401549 1LP-ETH-ARMOR1inch Liquid... (1LP-ET...)0.05048346 1LP-ETH-arNXM1inch Liquid... (1LP-ET...)4.3574327 1LP-ETH-AUDIO1inch Liquid... (1LP-ET...)2.15522855 1LP-ETH-AURORA1inch Liquid... (1LP-ET...)101.52672516 1LP-ETH-AVINOC1inch Liquid... (1LP-ET...)34.63339966 1LP-ETH-BAT1inch Liquid... (1LP-ET...)1,019.75537401 1LP-ETH-BFC1inch Liquid... (1LP-ET...)379.6742155 1LP-ETH-BLES1inch Liquid... (1LP-ET...)0.02870146 1LP-ETH-BUILD1inch Liquid... (1LP-ET...)0.00000145 1LP-ETH-BUSD1inch Liquid... (1LP-ET...)194.51986197 1LP-ETH-BXX1inch Liquid... (1LP-ET...)0.0014964 1LP-ETH-CHI1inch Liquid... (1LP-ET...)0.15851416 1LP-ETH-CHIP1inch Liquid... (1LP-ET...)37,225.91119195 1LP-ETH-CMCX1inch Liquid... (1LP-ET...)5.89605929 1LP-ETH-CRV1inch Liquid... (1LP-ET...)0.26831105 1LP-ETH-CVP1inch Liquid... (1LP-ET...)0.86806829ERC20 ***2,229.34911792 1LP-ETH-DEP1inch Liquid... (1LP-ET...)0.00370787 1LP-ETH-DJ151inch Liquid... (1LP-ET...)0.00060116 1LP-ETH-DPI1inch Liquid... (1LP-ET...)0.9308416 1LP-ETH-DRC1inch Liquid... (1LP-ET...)845.91167636 1LP-ETH-DRGN1inch Liquid... (1LP-ET...)14,924.3999527 1LP-ETH-DSLA1inch Liquid... (1LP-ET...)16,957,424,615,798,600 1LP-ETH-DUNG1inch Liquid... (1LP-ET...)0.12323536 1LP-ETH-EFI1inch Liquid... (1LP-ET...)0.01272272 1LP-ETH-ETHMNY1inch Liquid... (1LP-ET...)0.65281103 1LP-ETH-FAR1inch Liquid... (1LP-ET...)5.14082796 1LP-ETH-FEI1inch Liquid... (1LP-ET...)12.81444896 1LP-ETH-FET1inch Liquid... (1LP-ET...)277.26441776 1LP-ETH-FMY1inch Liquid... (1LP-ET...)0.20571016 1LP-ETH-FNT1inch Liquid... (1LP-ET...)0.0093574 1LP-ETH-FRX1inch Liquid... (1LP-ET...)0.00011765 1LP-ETH-GALA1inch Liquid... (1LP-ET...)32,012,574.8678554 1LP-ETH-GDOG1inch Liquid... (1LP-ET...)0.00011193 1LP-ETH-HEX1inch Liquid... (1LP-ET...)0.01401112 1LP-ETH-HOGE1inch Liquid... (1LP-ET...)0.06974074 1LP-ETH-ICHI1inch Liquid... (1LP-ET...)0.00078402 1LP-ETH-ILV1inch Liquid... (1LP-ET...)0.09444232 1LP-ETH-INXT1inch Liquid... (1LP-ET...)0.16578515 1LP-ETH-IQV1inch Liquid... (1LP-ET...)0.71615692 1LP-ETH-IRS1inch Liquid... (1LP-ET...)149.18353883 1LP-ETH-JPEGS1inch Liquid... (1LP-ET...)0.24988767 1LP-ETH-KISHU1inch Liquid... (1LP-ET...)17.92389678 1LP-ETH-LDO1inch Liquid... (1LP-ET...)0.18977125 1LP-ETH-LINK1inch Liquid... (1LP-ET...)0.00601684 1LP-ETH-LOX1inch Liquid... (1LP-ET...)4,142,208,592,836.8 1LP-ETH-MAK1inch Liquid... (1LP-ET...)0.63924271 1LP-ETH-MATIC1inch Liquid... (1LP-ET...)19,816.57731132 1LP-ETH-MHTN1inch Liquid... (1LP-ET...)0.00331294 1LP-ETH-MKR1inch Liquid... (1LP-ET...)0.01611572 1LP-ETH-MRXe1inch Liquid... (1LP-ET...)2,065,561.14430478 1LP-ETH-MTDR1inch Liquid... (1LP-ET...)1.21020396 1LP-ETH-MUSH1inch Liquid... (1LP-ET...)0.6876751 1LP-ETH-NEXO1inch Liquid... (1LP-ET...)1.82023071 1LP-ETH-OCTO1inch Liquid... (1LP-ET...)0.63127239 1LP-ETH-OPIUM1inch Liquid... (1LP-ET...)1,708.50771085 1LP-ETH-ORBS1inch Liquid... (1LP-ET...)0.67243717 1LP-ETH-POLY1inch Liquid... (1LP-ET...)3,686.58173446 1LP-ETH-PRICE1inch Liquid... (1LP-ET...)17.12877154 1LP-ETH-PRT1inch Liquid... (1LP-ET...)0.00410905 1LP-ETH-PRV1inch Liquid... (1LP-ET...)1.03796175 1LP-ETH-PUP1inch Liquid... (1LP-ET...)776.15245582 1LP-ETH-QKC1inch Liquid... (1LP-ET...)0.02094313 1LP-ETH-QTM1inch Liquid... (1LP-ET...)0.19292453 1LP-ETH-RARI1inch Liquid... (1LP-ET...)718.50738435 1LP-ETH-rDAO1inch Liquid... (1LP-ET...)355.77119648 1LP-ETH-REN1inch Liquid... (1LP-ET...)45.44527607 1LP-ETH-RNDR1inch Liquid... (1LP-ET...)0.36467531 1LP-ETH-RUNE1inch Liquid... (1LP-ET...)1,975,569.42897574 1LP-ETH-SHIB1inch Liquid... (1LP-ET...)0 1LP-ETH-SLP1inch Liquid... (1LP-ET...)33.67722895 1LP-ETH-SLR1inch Liquid... (1LP-ET...)0.0297685 1LP-ETH-SNX1inch Liquid... (1LP-ET...)0.04481875 1LP-ETH-SOAR1inch Liquid... (1LP-ET...)30.3295481 1LP-ETH-SPACE1inch Liquid... (1LP-ET...)2,604.53327935 1LP-ETH-SPELL1inch Liquid... (1LP-ET...)3,992,062,542.22704 1LP-ETH-SSINU1inch Liquid... (1LP-ET...)0.01434264 1LP-ETH-STARK1inch Liquid... (1LP-ET...)322,591,707.546401 1LP-ETH-STATE1inch Liquid... (1LP-ET...)0 1LP-ETH-STRK1inch Liquid... (1LP-ET...)0.0536633 1LP-ETH-sUSD1inch Liquid... (1LP-ET...)15.56951053 1LP-ETH-SWISE1inch Liquid... (1LP-ET...)83.62657754 1LP-ETH-SYLO1inch Liquid... (1LP-ET...)0.17563743 1LP-ETH-TMM1inch Liquid... (1LP-ET...)0.11438255 1LP-ETH-TORN1inch Liquid... (1LP-ET...)282.14154332 1LP-ETH-TRAC1inch Liquid... (1LP-ET...)25,977,314.4499058 1LP-ETH-TSMX1inch Liquid... (1LP-ET...)0.20546228 1LP-ETH-UNI1inch Liquid... (1LP-ET...)0.00270277ERC20 ***0.00770353ERC20 ***0.0008592 1LP-ETH-USL1inch Liquid... (1LP-ET...)1.22945929 1LP-ETH-VERI1inch Liquid... (1LP-ET...)1,651.65442178 1LP-ETH-VOW1inch Liquid... (1LP-ET...)30.44990415 1LP-ETH-VSP1inch Liquid... (1LP-ET...)532.8498662 1LP-ETH-VTX1inch Liquid... (1LP-ET...)0.4722801ERC20 ***0.84416123 1LP-ETH-WETH1inch Liquid... (1LP-ET...)0.41278858 1LP-ETH-wNXM1inch Liquid... (1LP-ET...)60.97837724 1LP-ETH-WRN1inch Liquid... (1LP-ET...)9,367.56416844 1LP-ETH-WXT1inch Liquid... (1LP-ET...)0.12748555 1LP-ETH-xBTC1inch Liquid... (1LP-ET...)0.51201024 1LP-ETH-xINCHa1inch Liquid... (1LP-ET...)327.39776065 1LP-ETH-xINCHb1inch Liquid... (1LP-ET...)1,918.9711524 1LP-ETH-XYO1inch Liquid... (1LP-ET...)1.13209063 1LP-ETH-YAXIS1inch Liquid... (1LP-ET...)0.01236036 1LP-ETH-YFI1inch Liquid... (1LP-ET...)15,416.85736672 1LP-ETH-YUAN1inch Liquid... (1LP-ET...)36.95224719 1LP-ETH-ZRX1inch Liquid... (1LP-ET...)0.41157316 1LP-ETH-٨1inch Liquid... (1LP-ET...)NFT Tokens (23)claim rewards on apyusd.netapyusd.netERC-1155nft-lido.comLDO Mysterybox NFTERC-1155claim rewards on pooleth.uspooleth.usERC-1155claim rewards on stakedeth.iostakedeth.ioERC-1155ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Suspicious]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]ERC-1155 TOKEN*[Spam]
- Transactions
- Internal Transactions
- Token Transfers (ERC-20)
- NFT Transfers
- Contract
- Events
- Analytics
- Multichain Portfolio
- Cards New
Advanced Filter- Filter by Tx Type:
- Tx
- Internal Tx
- ERC-20
- NFTs
Latest 25 from a total of 159 transactions
Transaction Hash MethodBlockFromToClaim 18510911 2023-11-06 5:37:59 386 days ago 1699249079 IN 0 ETH$0.00 0.00111508 26 Claim 17456384 2023-06-11 10:48:59 534 days ago 1686480539 IN 0 ETH$0.00 0.00039623 16.40184692 Claim 17180204 2023-05-03 12:30:23 573 days ago 1683117023 IN 0 ETH$0.00 0.00173277 71.72681786 Claim 15514973 2022-09-11 13:06:13 807 days ago 1662901573 IN 0 ETH$0.00 0.0008013 13.35782124 Claim 15339783 2022-08-14 12:36:35 835 days ago 1660480595 IN 0 ETH$0.00 0.00017965 4.1889256 Claim 14357739 2022-03-10 7:24:01 992 days ago 1646897041 IN 0 ETH$0.00 0.00117402 19.57106476 Claim 13394524 2021-10-11 1:58:23 1143 days ago 1633917503 IN 0 ETH$0.00 0.00153874 63.69511964 Claim 13318245 2021-09-29 3:18:24 1155 days ago 1632885504 IN 0 ETH$0.00 0.00364898 60.82857276 Claim 13126640 2021-08-30 11:38:09 1184 days ago 1630323489 IN 0 ETH$0.00 0.0024595 41 Claim 12831099 2021-07-15 10:49:58 1230 days ago 1626346198 IN 0 ETH$0.00 0.00110544 35 Claim 12780577 2021-07-07 13:33:05 1238 days ago 1625664785 IN 0 ETH$0.00 0.00124375 29 Claim 12747307 2021-07-02 9:16:40 1243 days ago 1625217400 IN 0 ETH$0.00 0.00077984 13 Claim 12735572 2021-06-30 13:18:52 1245 days ago 1625059132 IN 0 ETH$0.00 0.00060043 14 Claim 12699450 2021-06-24 22:08:54 1251 days ago 1624572534 IN 0 ETH$0.00 0.0024595 41 Claim 12670469 2021-06-20 9:33:51 1255 days ago 1624181631 IN 0 ETH$0.00 0.00025732 6.00000001 Claim 12653584 2021-06-17 18:37:30 1258 days ago 1623955050 IN 0 ETH$0.00 0.00161967 27 Claim 12640042 2021-06-15 16:15:10 1260 days ago 1623773710 IN 0 ETH$0.00 0.0014997 25 Claim 12619039 2021-06-12 10:11:09 1263 days ago 1623492669 IN 0 ETH$0.00 0.0009598 16 Claim 12575963 2021-06-05 18:12:53 1270 days ago 1622916773 IN 0 ETH$0.00 0.00083983 14 Claim 12570058 2021-06-04 19:55:22 1271 days ago 1622836522 IN 0 ETH$0.00 0.00106178 17.7 Claim 12518146 2021-05-27 19:11:31 1279 days ago 1622142691 IN 0 ETH$0.00 0.0014997 25 Claim 12517802 2021-05-27 17:53:35 1279 days ago 1622138015 IN 0 ETH$0.00 0.00099047 41 Claim 12517723 2021-05-27 17:34:20 1279 days ago 1622136860 IN 0 ETH$0.00 0.00132952 31 Claim 12512710 2021-05-26 22:48:58 1280 days ago 1622069338 IN 0 ETH$0.00 0.00179964 30 Claim 12371829 2021-05-05 3:34:36 1302 days ago 1620185676 IN 0 ETH$0.00 0.00201573 47 Latest 25 internal transactions (View All)
Advanced mode:Parent Transaction Hash Block From To 20044342 2024-06-08 3:11:35 172 days ago 1717816295 0.19208114 ETH$652.03 20043629 2024-06-08 0:48:11 172 days ago 1717807691 0.67492574 ETH$2,291.08 20043311 2024-06-07 23:44:35 172 days ago 1717803875 0.12862614 ETH$436.63 19957204 2024-05-26 23:02:35 184 days ago 1716764555 0.00048796 ETH$1.66 19957204 2024-05-26 23:02:35 184 days ago 1716764555 0.00048796 ETH$1.66 19957170 2024-05-26 22:55:47 184 days ago 1716764147 0.00035691 ETH$1.21 19957170 2024-05-26 22:55:47 184 days ago 1716764147 0.00035691 ETH$1.21 19957150 2024-05-26 22:51:47 184 days ago 1716763907 0.00033723 ETH$1.14 19957150 2024-05-26 22:51:47 184 days ago 1716763907 0.00033723 ETH$1.14 19957130 2024-05-26 22:47:47 184 days ago 1716763667 0.00031867 ETH$1.08 19957130 2024-05-26 22:47:47 184 days ago 1716763667 0.00031867 ETH$1.08 19957107 2024-05-26 22:43:11 184 days ago 1716763391 0.00030124 ETH$1.02 19957107 2024-05-26 22:43:11 184 days ago 1716763391 0.00030124 ETH$1.02 19957083 2024-05-26 22:38:23 184 days ago 1716763103 0.00028508 ETH$0.97 19957083 2024-05-26 22:38:23 184 days ago 1716763103 0.00028508 ETH$0.97 19957036 2024-05-26 22:28:59 184 days ago 1716762539 0.00027019 ETH$0.92 19957036 2024-05-26 22:28:59 184 days ago 1716762539 0.00027019 ETH$0.92 19957004 2024-05-26 22:22:23 184 days ago 1716762143 0.00017039 ETH$0.58 19957004 2024-05-26 22:22:23 184 days ago 1716762143 0.00017039 ETH$0.58 19956983 2024-05-26 22:18:11 184 days ago 1716761891 0.00018702 ETH$0.63 19956983 2024-05-26 22:18:11 184 days ago 1716761891 0.00018702 ETH$0.63 19956822 2024-05-26 21:45:35 184 days ago 1716759935 0.00003389 ETH$0.12 19956822 2024-05-26 21:45:35 184 days ago 1716759935 0.00003389 ETH$0.12 19956817 2024-05-26 21:44:35 184 days ago 1716759875 0.0002531 ETH$0.86 19956817 2024-05-26 21:44:35 184 days ago 1716759875 0.0002531 ETH$0.86 Loading...LoadingContract Name:ReferralFeeReceiver
Compiler Versionv0.6.12+commit.27d51765
Optimization Enabled:Yes with 1000 runs
Other Settings:default evmVersionContract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "./interfaces/IFeeCollector.sol"; import "./libraries/UniERC20.sol"; import "./utils/Converter.sol"; contract ReferralFeeReceiver is IFeeCollector, Converter, ReentrancyGuard { using UniERC20 for IERC20; struct UserInfo { uint256 balance; mapping(IERC20 => mapping(uint256 => uint256)) share; mapping(IERC20 => uint256) firstUnprocessedEpoch; } struct EpochBalance { uint256 totalSupply; uint256 token0Balance; uint256 token1Balance; uint256 inchBalance; } struct TokenInfo { mapping(uint256 => EpochBalance) epochBalance; uint256 firstUnprocessedEpoch; uint256 currentEpoch; } mapping(address => UserInfo) public userInfo; mapping(IERC20 => TokenInfo) public tokenInfo; // solhint-disable-next-line no-empty-blocks constructor(IERC20 _inchToken, IMooniswapFactory _mooniswapFactory) public Converter(_inchToken, _mooniswapFactory) {} function updateRewards(address[] calldata receivers, uint256[] calldata amounts) external override { for (uint i = 0; i < receivers.length; i++) { updateReward(receivers[i], amounts[i]); } } function updateReward(address referral, uint256 amount) public override { Mooniswap mooniswap = Mooniswap(msg.sender); TokenInfo storage token = tokenInfo[mooniswap]; UserInfo storage user = userInfo[referral]; uint256 currentEpoch = token.currentEpoch; // Add new reward to current epoch user.share[mooniswap][currentEpoch] = user.share[mooniswap][currentEpoch].add(amount); token.epochBalance[currentEpoch].totalSupply = token.epochBalance[currentEpoch].totalSupply.add(amount); // Collect all processed epochs and advance user token epoch _collectProcessedEpochs(user, token, mooniswap, currentEpoch); } function freezeEpoch(Mooniswap mooniswap) external nonReentrant validPool(mooniswap) validSpread(mooniswap) { TokenInfo storage token = tokenInfo[mooniswap]; uint256 currentEpoch = token.currentEpoch; require(token.firstUnprocessedEpoch == currentEpoch, "Previous epoch is not finalized"); IERC20[] memory tokens = mooniswap.getTokens(); uint256 token0Balance = tokens[0].uniBalanceOf(address(this)); uint256 token1Balance = tokens[1].uniBalanceOf(address(this)); mooniswap.withdraw(mooniswap.balanceOf(address(this)), new uint256[](0)); token.epochBalance[currentEpoch].token0Balance = tokens[0].uniBalanceOf(address(this)).sub(token0Balance); token.epochBalance[currentEpoch].token1Balance = tokens[1].uniBalanceOf(address(this)).sub(token1Balance); token.currentEpoch = currentEpoch.add(1); } function trade(Mooniswap mooniswap, IERC20[] memory path) external nonReentrant validPool(mooniswap) validPath(path) { TokenInfo storage token = tokenInfo[mooniswap]; uint256 firstUnprocessedEpoch = token.firstUnprocessedEpoch; EpochBalance storage epochBalance = token.epochBalance[firstUnprocessedEpoch]; require(firstUnprocessedEpoch.add(1) == token.currentEpoch, "Prev epoch already finalized"); IERC20[] memory tokens = mooniswap.getTokens(); uint256 availableBalance; if (path[0] == tokens[0]) { availableBalance = epochBalance.token0Balance; } else if (path[0] == tokens[1]) { availableBalance = epochBalance.token1Balance; } else { revert("Invalid first token"); } (uint256 amount, uint256 returnAmount) = _maxAmountForSwap(path, availableBalance); if (returnAmount == 0) { // get rid of dust if (availableBalance > 0) { require(availableBalance == amount, "availableBalance is not dust"); for (uint256 i = 0; i + 1 < path.length; i += 1) { Mooniswap _mooniswap = mooniswapFactory.pools(path[i], path[i+1]); require(_validateSpread(_mooniswap), "Spread is too high"); } if (path[0].isETH()) { tx.origin.transfer(availableBalance); // solhint-disable-line avoid-tx-origin } else { path[0].safeTransfer(address(mooniswap), availableBalance); } } } else { uint256 receivedAmount = _swap(path, amount, payable(address(this))); epochBalance.inchBalance = epochBalance.inchBalance.add(receivedAmount); } if (path[0] == tokens[0]) { epochBalance.token0Balance = epochBalance.token0Balance.sub(amount); } else { epochBalance.token1Balance = epochBalance.token1Balance.sub(amount); } if (epochBalance.token0Balance == 0 && epochBalance.token1Balance == 0) { token.firstUnprocessedEpoch = firstUnprocessedEpoch.add(1); } } function claim(Mooniswap[] memory pools) external { UserInfo storage user = userInfo[msg.sender]; for (uint256 i = 0; i < pools.length; ++i) { Mooniswap mooniswap = pools[i]; TokenInfo storage token = tokenInfo[mooniswap]; _collectProcessedEpochs(user, token, mooniswap, token.currentEpoch); } uint256 balance = user.balance; if (balance > 1) { // Avoid erasing storage to decrease gas footprint for referral payments user.balance = 1; inchToken.transfer(msg.sender, balance - 1); } } function claimCurrentEpoch(Mooniswap mooniswap) external nonReentrant validPool(mooniswap) { TokenInfo storage token = tokenInfo[mooniswap]; UserInfo storage user = userInfo[msg.sender]; uint256 currentEpoch = token.currentEpoch; uint256 balance = user.share[mooniswap][currentEpoch]; if (balance > 0) { user.share[mooniswap][currentEpoch] = 0; token.epochBalance[currentEpoch].totalSupply = token.epochBalance[currentEpoch].totalSupply.sub(balance); mooniswap.transfer(msg.sender, balance); } } function claimFrozenEpoch(Mooniswap mooniswap) external nonReentrant validPool(mooniswap) { TokenInfo storage token = tokenInfo[mooniswap]; UserInfo storage user = userInfo[msg.sender]; uint256 firstUnprocessedEpoch = token.firstUnprocessedEpoch; uint256 currentEpoch = token.currentEpoch; require(firstUnprocessedEpoch.add(1) == currentEpoch, "Epoch already finalized"); require(user.firstUnprocessedEpoch[mooniswap] == firstUnprocessedEpoch, "Epoch funds already claimed"); user.firstUnprocessedEpoch[mooniswap] = currentEpoch; uint256 share = user.share[mooniswap][firstUnprocessedEpoch]; if (share > 0) { EpochBalance storage epochBalance = token.epochBalance[firstUnprocessedEpoch]; uint256 totalSupply = epochBalance.totalSupply; user.share[mooniswap][firstUnprocessedEpoch] = 0; epochBalance.totalSupply = totalSupply.sub(share); IERC20[] memory tokens = mooniswap.getTokens(); epochBalance.token0Balance = _transferTokenShare(tokens[0], epochBalance.token0Balance, share, totalSupply); epochBalance.token1Balance = _transferTokenShare(tokens[1], epochBalance.token1Balance, share, totalSupply); epochBalance.inchBalance = _transferTokenShare(inchToken, epochBalance.inchBalance, share, totalSupply); } } function _transferTokenShare(IERC20 token, uint256 balance, uint256 share, uint256 totalSupply) private returns(uint256 newBalance) { uint256 amount = balance.mul(share).div(totalSupply); if (amount > 0) { token.uniTransfer(msg.sender, amount); } return balance.sub(amount); } function _collectProcessedEpochs(UserInfo storage user, TokenInfo storage token, Mooniswap mooniswap, uint256 currentEpoch) private { // Early return for the new users if (user.share[mooniswap][user.firstUnprocessedEpoch[mooniswap]] == 0) { user.firstUnprocessedEpoch[mooniswap] = currentEpoch; return; } uint256 userEpoch = user.firstUnprocessedEpoch[mooniswap]; uint256 tokenEpoch = token.firstUnprocessedEpoch; uint256 epochCount = Math.min(2, tokenEpoch.sub(userEpoch)); // 0, 1 or 2 epochs if (epochCount == 0) { return; } // Claim 1 or 2 processed epochs for the user uint256 collected = _collectEpoch(user, token, mooniswap, userEpoch); if (epochCount > 1) { collected = collected.add(_collectEpoch(user, token, mooniswap, userEpoch + 1)); } user.balance = user.balance.add(collected); // Update user token epoch counter bool emptySecondEpoch = user.share[mooniswap][userEpoch + 1] == 0; user.firstUnprocessedEpoch[mooniswap] = (epochCount == 2 || emptySecondEpoch) ? currentEpoch : userEpoch + 1; } function _collectEpoch(UserInfo storage user, TokenInfo storage token, Mooniswap mooniswap, uint256 epoch) private returns(uint256 collected) { uint256 share = user.share[mooniswap][epoch]; if (share > 0) { uint256 inchBalance = token.epochBalance[epoch].inchBalance; uint256 totalSupply = token.epochBalance[epoch].totalSupply; collected = inchBalance.mul(share).div(totalSupply); user.share[mooniswap][epoch] = 0; token.epochBalance[epoch].totalSupply = totalSupply.sub(share); token.epochBalance[epoch].inchBalance = inchBalance.sub(collected); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./interfaces/IFeeCollector.sol"; import "./libraries/UniERC20.sol"; import "./libraries/Sqrt.sol"; import "./libraries/VirtualBalance.sol"; import "./governance/MooniswapGovernance.sol"; contract Mooniswap is MooniswapGovernance { using Sqrt for uint256; using SafeMath for uint256; using UniERC20 for IERC20; using VirtualBalance for VirtualBalance.Data; struct Balances { uint256 src; uint256 dst; } struct SwapVolumes { uint128 confirmed; uint128 result; } struct Fees { uint256 fee; uint256 slippageFee; } event Error(string reason); event Deposited( address indexed sender, address indexed receiver, uint256 share, uint256 token0Amount, uint256 token1Amount ); event Withdrawn( address indexed sender, address indexed receiver, uint256 share, uint256 token0Amount, uint256 token1Amount ); event Swapped( address indexed sender, address indexed receiver, address indexed srcToken, address dstToken, uint256 amount, uint256 result, uint256 srcAdditionBalance, uint256 dstRemovalBalance, address referral ); event Sync( uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee, uint256 referralShare, uint256 governanceShare ); uint256 private constant _BASE_SUPPLY = 1000; // Total supply on first deposit IERC20 public immutable token0; IERC20 public immutable token1; mapping(IERC20 => SwapVolumes) public volumes; mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForAddition; mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForRemoval; modifier whenNotShutdown { require(mooniswapFactoryGovernance.isActive(), "Mooniswap: factory shutdown"); _; } constructor( IERC20 _token0, IERC20 _token1, string memory name, string memory symbol, IMooniswapFactoryGovernance _mooniswapFactoryGovernance ) public ERC20(name, symbol) MooniswapGovernance(_mooniswapFactoryGovernance) { require(bytes(name).length > 0, "Mooniswap: name is empty"); require(bytes(symbol).length > 0, "Mooniswap: symbol is empty"); require(_token0 != _token1, "Mooniswap: duplicate tokens"); token0 = _token0; token1 = _token1; } function getTokens() external view returns(IERC20[] memory tokens) { tokens = new IERC20[](2); tokens[0] = token0; tokens[1] = token1; } function tokens(uint256 i) external view returns(IERC20) { if (i == 0) { return token0; } else if (i == 1) { return token1; } else { revert("Pool has two tokens"); } } function getBalanceForAddition(IERC20 token) public view returns(uint256) { uint256 balance = token.uniBalanceOf(address(this)); return Math.max(virtualBalancesForAddition[token].current(decayPeriod(), balance), balance); } function getBalanceForRemoval(IERC20 token) public view returns(uint256) { uint256 balance = token.uniBalanceOf(address(this)); return Math.min(virtualBalancesForRemoval[token].current(decayPeriod(), balance), balance); } function getReturn(IERC20 src, IERC20 dst, uint256 amount) external view returns(uint256) { return _getReturn(src, dst, amount, getBalanceForAddition(src), getBalanceForRemoval(dst), fee(), slippageFee()); } function deposit(uint256[2] memory maxAmounts, uint256[2] memory minAmounts) external payable returns(uint256 fairSupply, uint256[2] memory receivedAmounts) { return depositFor(maxAmounts, minAmounts, msg.sender); } function depositFor(uint256[2] memory maxAmounts, uint256[2] memory minAmounts, address target) public payable nonReentrant returns(uint256 fairSupply, uint256[2] memory receivedAmounts) { IERC20[2] memory _tokens = [token0, token1]; require(msg.value == (_tokens[0].isETH() ? maxAmounts[0] : (_tokens[1].isETH() ? maxAmounts[1] : 0)), "Mooniswap: wrong value usage"); uint256 totalSupply = totalSupply(); if (totalSupply == 0) { fairSupply = _BASE_SUPPLY.mul(99); _mint(address(this), _BASE_SUPPLY); // Donate up to 1% for (uint i = 0; i < maxAmounts.length; i++) { fairSupply = Math.max(fairSupply, maxAmounts[i]); require(maxAmounts[i] > 0, "Mooniswap: amount is zero"); require(maxAmounts[i] >= minAmounts[i], "Mooniswap: minAmount not reached"); _tokens[i].uniTransferFrom(msg.sender, address(this), maxAmounts[i]); receivedAmounts[i] = maxAmounts[i]; } } else { uint256[2] memory realBalances; for (uint i = 0; i < realBalances.length; i++) { realBalances[i] = _tokens[i].uniBalanceOf(address(this)).sub(_tokens[i].isETH() ? msg.value : 0); } // Pre-compute fair supply fairSupply = type(uint256).max; for (uint i = 0; i < maxAmounts.length; i++) { fairSupply = Math.min(fairSupply, totalSupply.mul(maxAmounts[i]).div(realBalances[i])); } uint256 fairSupplyCached = fairSupply; for (uint i = 0; i < maxAmounts.length; i++) { require(maxAmounts[i] > 0, "Mooniswap: amount is zero"); uint256 amount = realBalances[i].mul(fairSupplyCached).add(totalSupply - 1).div(totalSupply); require(amount >= minAmounts[i], "Mooniswap: minAmount not reached"); _tokens[i].uniTransferFrom(msg.sender, address(this), amount); receivedAmounts[i] = _tokens[i].uniBalanceOf(address(this)).sub(realBalances[i]); fairSupply = Math.min(fairSupply, totalSupply.mul(receivedAmounts[i]).div(realBalances[i])); } uint256 _decayPeriod = decayPeriod(); // gas savings for (uint i = 0; i < maxAmounts.length; i++) { virtualBalancesForRemoval[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply); virtualBalancesForAddition[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply); } } require(fairSupply > 0, "Mooniswap: result is not enough"); _mint(target, fairSupply); emit Deposited(msg.sender, target, fairSupply, receivedAmounts[0], receivedAmounts[1]); } function withdraw(uint256 amount, uint256[] memory minReturns) external returns(uint256[2] memory withdrawnAmounts) { return withdrawFor(amount, minReturns, msg.sender); } function withdrawFor(uint256 amount, uint256[] memory minReturns, address payable target) public nonReentrant returns(uint256[2] memory withdrawnAmounts) { IERC20[2] memory _tokens = [token0, token1]; uint256 totalSupply = totalSupply(); uint256 _decayPeriod = decayPeriod(); // gas savings _burn(msg.sender, amount); for (uint i = 0; i < _tokens.length; i++) { IERC20 token = _tokens[i]; uint256 preBalance = token.uniBalanceOf(address(this)); uint256 value = preBalance.mul(amount).div(totalSupply); token.uniTransfer(target, value); withdrawnAmounts[i] = value; require(i >= minReturns.length || value >= minReturns[i], "Mooniswap: result is not enough"); virtualBalancesForAddition[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply); virtualBalancesForRemoval[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply); } emit Withdrawn(msg.sender, target, amount, withdrawnAmounts[0], withdrawnAmounts[1]); } function swap(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral) external payable returns(uint256 result) { return swapFor(src, dst, amount, minReturn, referral, msg.sender); } function swapFor(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral, address payable receiver) public payable nonReentrant whenNotShutdown returns(uint256 result) { require(msg.value == (src.isETH() ? amount : 0), "Mooniswap: wrong value usage"); Balances memory balances = Balances({ src: src.uniBalanceOf(address(this)).sub(src.isETH() ? msg.value : 0), dst: dst.uniBalanceOf(address(this)) }); uint256 confirmed; Balances memory virtualBalances; Fees memory fees = Fees({ fee: fee(), slippageFee: slippageFee() }); (confirmed, result, virtualBalances) = _doTransfers(src, dst, amount, minReturn, receiver, balances, fees); emit Swapped(msg.sender, receiver, address(src), address(dst), confirmed, result, virtualBalances.src, virtualBalances.dst, referral); _mintRewards(confirmed, result, referral, balances, fees); // Overflow of uint128 is desired volumes[src].confirmed += uint128(confirmed); volumes[src].result += uint128(result); } function _doTransfers(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address payable receiver, Balances memory balances, Fees memory fees) private returns(uint256 confirmed, uint256 result, Balances memory virtualBalances) { uint256 _decayPeriod = decayPeriod(); virtualBalances.src = virtualBalancesForAddition[src].current(_decayPeriod, balances.src); virtualBalances.src = Math.max(virtualBalances.src, balances.src); virtualBalances.dst = virtualBalancesForRemoval[dst].current(_decayPeriod, balances.dst); virtualBalances.dst = Math.min(virtualBalances.dst, balances.dst); src.uniTransferFrom(msg.sender, address(this), amount); confirmed = src.uniBalanceOf(address(this)).sub(balances.src); result = _getReturn(src, dst, confirmed, virtualBalances.src, virtualBalances.dst, fees.fee, fees.slippageFee); require(result > 0 && result >= minReturn, "Mooniswap: return is not enough"); dst.uniTransfer(receiver, result); // Update virtual balances to the same direction only at imbalanced state if (virtualBalances.src != balances.src) { virtualBalancesForAddition[src].set(virtualBalances.src.add(confirmed)); } if (virtualBalances.dst != balances.dst) { virtualBalancesForRemoval[dst].set(virtualBalances.dst.sub(result)); } // Update virtual balances to the opposite direction virtualBalancesForRemoval[src].update(_decayPeriod, balances.src); virtualBalancesForAddition[dst].update(_decayPeriod, balances.dst); } function _mintRewards(uint256 confirmed, uint256 result, address referral, Balances memory balances, Fees memory fees) private { (uint256 referralShare, uint256 governanceShare, address govWallet, address feeCollector) = mooniswapFactoryGovernance.shareParameters(); uint256 refReward; uint256 govReward; uint256 invariantRatio = uint256(1e36); invariantRatio = invariantRatio.mul(balances.src.add(confirmed)).div(balances.src); invariantRatio = invariantRatio.mul(balances.dst.sub(result)).div(balances.dst); if (invariantRatio > 1e36) { // calculate share only if invariant increased invariantRatio = invariantRatio.sqrt(); uint256 invIncrease = totalSupply().mul(invariantRatio.sub(1e18)).div(invariantRatio); refReward = (referral != address(0)) ? invIncrease.mul(referralShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0; govReward = (govWallet != address(0)) ? invIncrease.mul(governanceShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0; if (feeCollector == address(0)) { if (refReward > 0) { _mint(referral, refReward); } if (govReward > 0) { _mint(govWallet, govReward); } } else if (refReward > 0 || govReward > 0) { uint256 len = (refReward > 0 ? 1 : 0) + (govReward > 0 ? 1 : 0); address[] memory wallets = new address[](len); uint256[] memory rewards = new uint256[](len); wallets[0] = referral; rewards[0] = refReward; if (govReward > 0) { wallets[len - 1] = govWallet; rewards[len - 1] = govReward; } try IFeeCollector(feeCollector).updateRewards(wallets, rewards) { _mint(feeCollector, refReward.add(govReward)); } catch { emit Error("updateRewards() failed"); } } } emit Sync(balances.src, balances.dst, fees.fee, fees.slippageFee, refReward, govReward); } /* spot_ret = dx * y / x uni_ret = dx * y / (x + dx) slippage = (spot_ret - uni_ret) / spot_ret slippage = dx * dx * y / (x * (x + dx)) / (dx * y / x) slippage = dx / (x + dx) ret = uni_ret * (1 - slip_fee * slippage) ret = dx * y / (x + dx) * (1 - slip_fee * dx / (x + dx)) ret = dx * y / (x + dx) * (x + dx - slip_fee * dx) / (x + dx) x = amount * denominator dx = amount * (denominator - fee) */ function _getReturn(IERC20 src, IERC20 dst, uint256 amount, uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee) internal view returns(uint256) { if (src > dst) { (src, dst) = (dst, src); } if (amount > 0 && src == token0 && dst == token1) { uint256 taxedAmount = amount.sub(amount.mul(fee).div(MooniswapConstants._FEE_DENOMINATOR)); uint256 srcBalancePlusTaxedAmount = srcBalance.add(taxedAmount); uint256 ret = taxedAmount.mul(dstBalance).div(srcBalancePlusTaxedAmount); uint256 feeNumerator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount).sub(slippageFee.mul(taxedAmount)); uint256 feeDenominator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount); return ret.mul(feeNumerator).div(feeDenominator); } } function rescueFunds(IERC20 token, uint256 amount) external nonReentrant onlyOwner { uint256 balance0 = token0.uniBalanceOf(address(this)); uint256 balance1 = token1.uniBalanceOf(address(this)); token.uniTransfer(msg.sender, amount); require(token0.uniBalanceOf(address(this)) >= balance0, "Mooniswap: access denied"); require(token1.uniBalanceOf(address(this)) >= balance1, "Mooniswap: access denied"); require(balanceOf(address(this)) >= _BASE_SUPPLY, "Mooniswap: access denied"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "../interfaces/IMooniswapFactoryGovernance.sol"; import "../libraries/LiquidVoting.sol"; import "../libraries/MooniswapConstants.sol"; import "../libraries/SafeCast.sol"; abstract contract MooniswapGovernance is ERC20, Ownable, ReentrancyGuard { using Vote for Vote.Data; using LiquidVoting for LiquidVoting.Data; using VirtualVote for VirtualVote.Data; using SafeCast for uint256; event FeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount); event SlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount); event DecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount); IMooniswapFactoryGovernance public mooniswapFactoryGovernance; LiquidVoting.Data private _fee; LiquidVoting.Data private _slippageFee; LiquidVoting.Data private _decayPeriod; constructor(IMooniswapFactoryGovernance _mooniswapFactoryGovernance) internal { mooniswapFactoryGovernance = _mooniswapFactoryGovernance; _fee.data.result = _mooniswapFactoryGovernance.defaultFee().toUint104(); _slippageFee.data.result = _mooniswapFactoryGovernance.defaultSlippageFee().toUint104(); _decayPeriod.data.result = _mooniswapFactoryGovernance.defaultDecayPeriod().toUint104(); } function setMooniswapFactoryGovernance(IMooniswapFactoryGovernance newMooniswapFactoryGovernance) external onlyOwner { mooniswapFactoryGovernance = newMooniswapFactoryGovernance; this.discardFeeVote(); this.discardSlippageFeeVote(); this.discardDecayPeriodVote(); } function fee() public view returns(uint256) { return _fee.data.current(); } function slippageFee() public view returns(uint256) { return _slippageFee.data.current(); } function decayPeriod() public view returns(uint256) { return _decayPeriod.data.current(); } function virtualFee() external view returns(uint104, uint104, uint48) { return (_fee.data.oldResult, _fee.data.result, _fee.data.time); } function virtualSlippageFee() external view returns(uint104, uint104, uint48) { return (_slippageFee.data.oldResult, _slippageFee.data.result, _slippageFee.data.time); } function virtualDecayPeriod() external view returns(uint104, uint104, uint48) { return (_decayPeriod.data.oldResult, _decayPeriod.data.result, _decayPeriod.data.time); } function feeVotes(address user) external view returns(uint256) { return _fee.votes[user].get(mooniswapFactoryGovernance.defaultFee); } function slippageFeeVotes(address user) external view returns(uint256) { return _slippageFee.votes[user].get(mooniswapFactoryGovernance.defaultSlippageFee); } function decayPeriodVotes(address user) external view returns(uint256) { return _decayPeriod.votes[user].get(mooniswapFactoryGovernance.defaultDecayPeriod); } function feeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high"); _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate); } function slippageFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high"); _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate); } function decayPeriodVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high"); require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low"); _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate); } function discardFeeVote() external { _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate); } function discardSlippageFeeVote() external { _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate); } function discardDecayPeriodVote() external { _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate); } function _emitFeeVoteUpdate(address account, uint256 newFee, bool isDefault, uint256 newBalance) private { emit FeeVoteUpdate(account, newFee, isDefault, newBalance); } function _emitSlippageFeeVoteUpdate(address account, uint256 newSlippageFee, bool isDefault, uint256 newBalance) private { emit SlippageFeeVoteUpdate(account, newSlippageFee, isDefault, newBalance); } function _emitDecayPeriodVoteUpdate(address account, uint256 newDecayPeriod, bool isDefault, uint256 newBalance) private { emit DecayPeriodVoteUpdate(account, newDecayPeriod, isDefault, newBalance); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal override { if (from == to) { // ignore transfers to self return; } IMooniswapFactoryGovernance _mooniswapFactoryGovernance = mooniswapFactoryGovernance; bool updateFrom = !(from == address(0) || _mooniswapFactoryGovernance.isFeeCollector(from)); bool updateTo = !(to == address(0) || _mooniswapFactoryGovernance.isFeeCollector(to)); if (!updateFrom && !updateTo) { // mint to feeReceiver or burn from feeReceiver return; } uint256 balanceFrom = (from != address(0)) ? balanceOf(from) : 0; uint256 balanceTo = (to != address(0)) ? balanceOf(to) : 0; uint256 newTotalSupply = totalSupply() .add(from == address(0) ? amount : 0) .sub(to == address(0) ? amount : 0); ParamsHelper memory params = ParamsHelper({ from: from, to: to, updateFrom: updateFrom, updateTo: updateTo, amount: amount, balanceFrom: balanceFrom, balanceTo: balanceTo, newTotalSupply: newTotalSupply }); (uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod) = _mooniswapFactoryGovernance.defaults(); _updateOnTransfer(params, defaultFee, _emitFeeVoteUpdate, _fee); _updateOnTransfer(params, defaultSlippageFee, _emitSlippageFeeVoteUpdate, _slippageFee); _updateOnTransfer(params, defaultDecayPeriod, _emitDecayPeriodVoteUpdate, _decayPeriod); } struct ParamsHelper { address from; address to; bool updateFrom; bool updateTo; uint256 amount; uint256 balanceFrom; uint256 balanceTo; uint256 newTotalSupply; } function _updateOnTransfer( ParamsHelper memory params, uint256 defaultValue, function(address, uint256, bool, uint256) internal emitEvent, LiquidVoting.Data storage votingData ) private { Vote.Data memory voteFrom = votingData.votes[params.from]; Vote.Data memory voteTo = votingData.votes[params.to]; if (voteFrom.isDefault() && voteTo.isDefault() && params.updateFrom && params.updateTo) { emitEvent(params.from, voteFrom.get(defaultValue), true, params.balanceFrom.sub(params.amount)); emitEvent(params.to, voteTo.get(defaultValue), true, params.balanceTo.add(params.amount)); return; } if (params.updateFrom) { votingData.updateBalance(params.from, voteFrom, params.balanceFrom, params.balanceFrom.sub(params.amount), params.newTotalSupply, defaultValue, emitEvent); } if (params.updateTo) { votingData.updateBalance(params.to, voteTo, params.balanceTo, params.balanceTo.add(params.amount), params.newTotalSupply, defaultValue, emitEvent); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IFeeCollector { function updateReward(address receiver, uint256 amount) external; function updateRewards(address[] calldata receivers, uint256[] calldata amounts) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../Mooniswap.sol"; interface IMooniswapFactory is IMooniswapFactoryGovernance { function pools(IERC20 token0, IERC20 token1) external view returns (Mooniswap); function isPool(Mooniswap mooniswap) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IMooniswapFactoryGovernance { function shareParameters() external view returns(uint256 referralShare, uint256 governanceShare, address governanceWallet, address referralFeeReceiver); function defaults() external view returns(uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod); function defaultFee() external view returns(uint256); function defaultSlippageFee() external view returns(uint256); function defaultDecayPeriod() external view returns(uint256); function referralShare() external view returns(uint256); function governanceShare() external view returns(uint256); function governanceWallet() external view returns(address); function feeCollector() external view returns(address); function isFeeCollector(address) external view returns(bool); function isActive() external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./SafeCast.sol"; import "./VirtualVote.sol"; import "./Vote.sol"; library LiquidVoting { using SafeMath for uint256; using SafeCast for uint256; using Vote for Vote.Data; using VirtualVote for VirtualVote.Data; struct Data { VirtualVote.Data data; uint256 _weightedSum; uint256 _defaultVotes; mapping(address => Vote.Data) votes; } function updateVote( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 balance, uint256 totalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newVote, balance, balance, totalSupply, defaultVote, emitEvent); } function updateBalance( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, uint256 oldBalance, uint256 newBalance, uint256 newTotalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, newTotalSupply, defaultVote, emitEvent); } function _update( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 oldBalance, uint256 newBalance, uint256 newTotalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) private { uint256 oldWeightedSum = self._weightedSum; uint256 newWeightedSum = oldWeightedSum; uint256 oldDefaultVotes = self._defaultVotes; uint256 newDefaultVotes = oldDefaultVotes; if (oldVote.isDefault()) { newDefaultVotes = newDefaultVotes.sub(oldBalance); } else { newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote))); } if (newVote.isDefault()) { newDefaultVotes = newDefaultVotes.add(newBalance); } else { newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote))); } if (newWeightedSum != oldWeightedSum) { self._weightedSum = newWeightedSum; } if (newDefaultVotes != oldDefaultVotes) { self._defaultVotes = newDefaultVotes; } { uint256 newResult = newTotalSupply == 0 ? defaultVote : newWeightedSum.add(newDefaultVotes.mul(defaultVote)).div(newTotalSupply); VirtualVote.Data memory data = self.data; if (newResult != data.result) { VirtualVote.Data storage sdata = self.data; (sdata.oldResult, sdata.result, sdata.time) = ( data.current().toUint104(), newResult.toUint104(), block.timestamp.toUint48() ); } } if (!newVote.eq(oldVote)) { self.votes[user] = newVote; } emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library MooniswapConstants { uint256 internal constant _FEE_DENOMINATOR = 1e18; uint256 internal constant _MIN_REFERRAL_SHARE = 0.05e18; // 5% uint256 internal constant _MIN_DECAY_PERIOD = 1 minutes; uint256 internal constant _MAX_FEE = 0.01e18; // 1% uint256 internal constant _MAX_SLIPPAGE_FEE = 1e18; // 100% uint256 internal constant _MAX_SHARE = 0.1e18; // 10% uint256 internal constant _MAX_DECAY_PERIOD = 5 minutes; uint256 internal constant _DEFAULT_FEE = 0; uint256 internal constant _DEFAULT_SLIPPAGE_FEE = 1e18; // 100% uint256 internal constant _DEFAULT_REFERRAL_SHARE = 0.1e18; // 10% uint256 internal constant _DEFAULT_GOVERNANCE_SHARE = 0; uint256 internal constant _DEFAULT_DECAY_PERIOD = 1 minutes; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library SafeCast { function toUint216(uint256 value) internal pure returns (uint216) { require(value < 2**216, "value does not fit in 216 bits"); return uint216(value); } function toUint104(uint256 value) internal pure returns (uint104) { require(value < 2**104, "value does not fit in 104 bits"); return uint104(value); } function toUint48(uint256 value) internal pure returns (uint48) { require(value < 2**48, "value does not fit in 48 bits"); return uint48(value); } function toUint40(uint256 value) internal pure returns (uint40) { require(value < 2**40, "value does not fit in 40 bits"); return uint40(value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library Sqrt { // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint256 y) internal pure returns (uint256) { if (y > 3) { uint256 z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } return z; } else if (y != 0) { return 1; } else { return 0; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; library UniERC20 { using SafeMath for uint256; using SafeERC20 for IERC20; function isETH(IERC20 token) internal pure returns(bool) { return (address(token) == address(0)); } function uniBalanceOf(IERC20 token, address account) internal view returns (uint256) { if (isETH(token)) { return account.balance; } else { return token.balanceOf(account); } } function uniTransfer(IERC20 token, address payable to, uint256 amount) internal { if (amount > 0) { if (isETH(token)) { to.transfer(amount); } else { token.safeTransfer(to, amount); } } } function uniTransferFrom(IERC20 token, address payable from, address to, uint256 amount) internal { if (amount > 0) { if (isETH(token)) { require(msg.value >= amount, "UniERC20: not enough value"); require(from == msg.sender, "from is not msg.sender"); require(to == address(this), "to is not this"); if (msg.value > amount) { // Return remainder if exist from.transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(from, to, amount); } } } function uniSymbol(IERC20 token) internal view returns(string memory) { if (isETH(token)) { return "ETH"; } (bool success, bytes memory data) = address(token).staticcall{ gas: 20000 }( abi.encodeWithSignature("symbol()") ); if (!success) { (success, data) = address(token).staticcall{ gas: 20000 }( abi.encodeWithSignature("SYMBOL()") ); } if (success && data.length >= 96) { (uint256 offset, uint256 len) = abi.decode(data, (uint256, uint256)); if (offset == 0x20 && len > 0 && len <= 256) { return string(abi.decode(data, (bytes))); } } if (success && data.length == 32) { uint len = 0; while (len < data.length && data[len] >= 0x20 && data[len] <= 0x7E) { len++; } if (len > 0) { bytes memory result = new bytes(len); for (uint i = 0; i < len; i++) { result[i] = data[i]; } return string(result); } } return _toHex(address(token)); } function _toHex(address account) private pure returns(string memory) { return _toHex(abi.encodePacked(account)); } function _toHex(bytes memory data) private pure returns(string memory) { bytes memory str = new bytes(2 + data.length * 2); str[0] = "0"; str[1] = "x"; uint j = 2; for (uint i = 0; i < data.length; i++) { uint a = uint8(data[i]) >> 4; uint b = uint8(data[i]) & 0x0f; str[j++] = byte(uint8(a + 48 + (a/10)*39)); str[j++] = byte(uint8(b + 48 + (b/10)*39)); } return string(str); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "./SafeCast.sol"; library VirtualBalance { using SafeMath for uint256; using SafeCast for uint256; struct Data { uint216 balance; uint40 time; } function set(VirtualBalance.Data storage self, uint256 balance) internal { (self.balance, self.time) = ( balance.toUint216(), block.timestamp.toUint40() ); } function update(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance) internal { set(self, current(self, decayPeriod, realBalance)); } function scale(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance, uint256 num, uint256 denom) internal { set(self, current(self, decayPeriod, realBalance).mul(num).add(denom.sub(1)).div(denom)); } function current(VirtualBalance.Data memory self, uint256 decayPeriod, uint256 realBalance) internal view returns(uint256) { uint256 timePassed = Math.min(decayPeriod, block.timestamp.sub(self.time)); uint256 timeRemain = decayPeriod.sub(timePassed); return uint256(self.balance).mul(timeRemain).add( realBalance.mul(timePassed) ).div(decayPeriod); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; library VirtualVote { using SafeMath for uint256; uint256 private constant _VOTE_DECAY_PERIOD = 1 days; struct Data { uint104 oldResult; uint104 result; uint48 time; } function current(VirtualVote.Data memory self) internal view returns(uint256) { uint256 timePassed = Math.min(_VOTE_DECAY_PERIOD, block.timestamp.sub(self.time)); uint256 timeRemain = _VOTE_DECAY_PERIOD.sub(timePassed); return uint256(self.oldResult).mul(timeRemain).add( uint256(self.result).mul(timePassed) ).div(_VOTE_DECAY_PERIOD); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; library Vote { struct Data { uint256 value; } function eq(Vote.Data memory self, Vote.Data memory vote) internal pure returns(bool) { return self.value == vote.value; } function init() internal pure returns(Vote.Data memory data) { return Vote.Data({ value: 0 }); } function init(uint256 vote) internal pure returns(Vote.Data memory data) { return Vote.Data({ value: vote + 1 }); } function isDefault(Data memory self) internal pure returns(bool) { return self.value == 0; } function get(Data memory self, uint256 defaultVote) internal pure returns(uint256) { if (self.value > 0) { return self.value - 1; } return defaultVote; } function get(Data memory self, function() external view returns(uint256) defaultVoteFn) internal view returns(uint256) { if (self.value > 0) { return self.value - 1; } return defaultVoteFn(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../interfaces/IMooniswapFactory.sol"; import "../libraries/UniERC20.sol"; import "../libraries/VirtualBalance.sol"; import "../Mooniswap.sol"; contract Converter is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; using UniERC20 for IERC20; using VirtualBalance for VirtualBalance.Data; uint256 private constant _ONE = 1e18; uint256 private constant _MAX_SPREAD = 0.01e18; uint256 private constant _MAX_LIQUIDITY_SHARE = 100; IERC20 public immutable inchToken; IMooniswapFactory public immutable mooniswapFactory; mapping(IERC20 => bool) public pathWhitelist; constructor (IERC20 _inchToken, IMooniswapFactory _mooniswapFactory) public { inchToken = _inchToken; mooniswapFactory = _mooniswapFactory; } receive() external payable { // solhint-disable-next-line avoid-tx-origin require(msg.sender != tx.origin, "ETH transfer forbidden"); } modifier validSpread(Mooniswap mooniswap) { require(_validateSpread(mooniswap), "Spread is too high"); _; } modifier validPool(Mooniswap mooniswap) { require(mooniswapFactory.isPool(mooniswap), "Invalid mooniswap"); _; } modifier validPath(IERC20[] memory path) { require(path.length > 0, "Min path length is 1"); require(path.length < 5, "Max path length is 4"); require(path[path.length - 1] == inchToken, "Should swap to target token"); for (uint256 i = 1; i + 1 < path.length; i += 1) { require(pathWhitelist[path[i]], "Token is not whitelisted"); } _; } function updatePathWhitelist(IERC20 token, bool whitelisted) external onlyOwner { pathWhitelist[token] = whitelisted; } function _validateSpread(Mooniswap mooniswap) internal view returns(bool) { IERC20[] memory tokens = mooniswap.getTokens(); uint256 buyPrice; uint256 sellPrice; uint256 spotPrice; { uint256 token0Balance = tokens[0].uniBalanceOf(address(mooniswap)); uint256 token1Balance = tokens[1].uniBalanceOf(address(mooniswap)); uint256 decayPeriod = mooniswap.decayPeriod(); VirtualBalance.Data memory vb; (vb.balance, vb.time) = mooniswap.virtualBalancesForAddition(tokens[0]); uint256 token0BalanceForAddition = Math.max(vb.current(decayPeriod, token0Balance), token0Balance); (vb.balance, vb.time) = mooniswap.virtualBalancesForAddition(tokens[1]); uint256 token1BalanceForAddition = Math.max(vb.current(decayPeriod, token1Balance), token1Balance); (vb.balance, vb.time) = mooniswap.virtualBalancesForRemoval(tokens[0]); uint256 token0BalanceForRemoval = Math.min(vb.current(decayPeriod, token0Balance), token0Balance); (vb.balance, vb.time) = mooniswap.virtualBalancesForRemoval(tokens[1]); uint256 token1BalanceForRemoval = Math.min(vb.current(decayPeriod, token1Balance), token1Balance); buyPrice = _ONE.mul(token1BalanceForAddition).div(token0BalanceForRemoval); sellPrice = _ONE.mul(token1BalanceForRemoval).div(token0BalanceForAddition); spotPrice = _ONE.mul(token1Balance).div(token0Balance); } return buyPrice.sub(sellPrice).mul(_ONE) < _MAX_SPREAD.mul(spotPrice); } function _maxAmountForSwap(IERC20[] memory path, uint256 amount) internal view returns(uint256 srcAmount, uint256 dstAmount) { srcAmount = amount; dstAmount = amount; uint256 pathLength = path.length; for (uint256 i = 0; i + 1 < pathLength; i += 1) { Mooniswap mooniswap = mooniswapFactory.pools(path[i], path[i+1]); uint256 maxCurStepAmount = path[i].uniBalanceOf(address(mooniswap)).div(_MAX_LIQUIDITY_SHARE); if (maxCurStepAmount < dstAmount) { srcAmount = srcAmount.mul(maxCurStepAmount).div(dstAmount); dstAmount = maxCurStepAmount; } dstAmount = mooniswap.getReturn(path[i], path[i+1], dstAmount); } } function _swap(IERC20[] memory path, uint256 initialAmount, address payable destination) internal returns(uint256 amount) { amount = initialAmount; for (uint256 i = 0; i + 1 < path.length; i += 1) { Mooniswap mooniswap = mooniswapFactory.pools(path[i], path[i+1]); require(_validateSpread(mooniswap), "Spread is too high"); uint256 value = amount; if (!path[i].isETH()) { path[i].safeApprove(address(mooniswap), amount); value = 0; } if (i + 2 < path.length) { amount = mooniswap.swap{value: value}(path[i], path[i+1], amount, 0, address(0)); } else { amount = mooniswap.swapFor{value: value}(path[i], path[i+1], amount, 0, address(0), destination); } } if (path.length == 1) { path[0].transfer(destination, amount); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @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; using Address for address; 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 returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view 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 returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 is 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 { _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 { } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.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]. */ 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; } }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 1000 }, "evmVersion": "istanbul", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
[{"inputs":[{"internalType":"contract IERC20","name":"_inchToken","type":"address"},{"internalType":"contract IMooniswapFactory","name":"_mooniswapFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"contract Mooniswap[]","name":"pools","type":"address[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Mooniswap","name":"mooniswap","type":"address"}],"name":"claimCurrentEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Mooniswap","name":"mooniswap","type":"address"}],"name":"claimFrozenEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Mooniswap","name":"mooniswap","type":"address"}],"name":"freezeEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"inchToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mooniswapFactory","outputs":[{"internalType":"contract IMooniswapFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"name":"pathWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"name":"tokenInfo","outputs":[{"internalType":"uint256","name":"firstUnprocessedEpoch","type":"uint256"},{"internalType":"uint256","name":"currentEpoch","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract Mooniswap","name":"mooniswap","type":"address"},{"internalType":"contract IERC20[]","name":"path","type":"address[]"}],"name":"trade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"bool","name":"whitelisted","type":"bool"}],"name":"updatePathWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"referral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"receivers","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"updateRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60c06040523480156200001157600080fd5b506040516200376938038062003769833981810160405260408110156200003757600080fd5b508051602090910151818160006200004e620000be565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600160601b0319606092831b8116608052911b1660a05250506001600255620000c2565b3390565b60805160601c60a05160601c61364b6200011e600039806109a65280610d835280610e33528061134d52806116d75280611c7e52806127f45280612a5c5250806107da5280610d40528061151f528061183d525061364b6000f3fe6080604052600436106100f75760003560e01c80638da5cb5b1161008a578063f2fde38b11610059578063f2fde38b146104a5578063f3aafa80146104d8578063f583adbc14610598578063f5dab711146105d357610153565b80638da5cb5b14610415578063946e1a621461042a5780639e96b2ce1461045d578063ec9545941461049057610153565b80635e8c8bb7116100c65780635e8c8bb714610355578063715018a61461039c57806371646f98146103b157806385731140146103e457610153565b80630931753c146101585780631959a002146102275780631a3991251461026c578063318d9e5d146102a557610153565b366101535733321415610151576040805162461bcd60e51b815260206004820152601660248201527f455448207472616e7366657220666f7262696464656e00000000000000000000604482015290519081900360640190fd5b005b600080fd5b34801561016457600080fd5b506101516004803603604081101561017b57600080fd5b81019060208101813564010000000081111561019657600080fd5b8201836020820111156101a857600080fd5b803590602001918460208302840111640100000000831117156101ca57600080fd5b9193909290916020810190356401000000008111156101e857600080fd5b8201836020820111156101fa57600080fd5b8035906020019184602083028401116401000000008311171561021c57600080fd5b50909250905061061f565b34801561023357600080fd5b5061025a6004803603602081101561024a57600080fd5b50356001600160a01b0316610670565b60408051918252519081900360200190f35b34801561027857600080fd5b506101516004803603604081101561028f57600080fd5b506001600160a01b038135169060200135610682565b3480156102b157600080fd5b50610151600480360360208110156102c857600080fd5b8101906020810181356401000000008111156102e357600080fd5b8201836020820111156102f557600080fd5b8035906020019184602083028401116401000000008311171561031757600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061072b945050505050565b34801561036157600080fd5b506103886004803603602081101561037857600080fd5b50356001600160a01b0316610851565b604080519115158252519081900360200190f35b3480156103a857600080fd5b50610151610866565b3480156103bd57600080fd5b50610151600480360360208110156103d457600080fd5b50356001600160a01b0316610927565b3480156103f057600080fd5b506103f9610d81565b604080516001600160a01b039092168252519081900360200190f35b34801561042157600080fd5b506103f9610da5565b34801561043657600080fd5b506101516004803603602081101561044d57600080fd5b50356001600160a01b0316610db4565b34801561046957600080fd5b506101516004803603602081101561048057600080fd5b50356001600160a01b03166112ce565b34801561049c57600080fd5b506103f961151d565b3480156104b157600080fd5b50610151600480360360208110156104c857600080fd5b50356001600160a01b0316611541565b3480156104e457600080fd5b50610151600480360360408110156104fb57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561052657600080fd5b82018360208201111561053857600080fd5b8035906020019184602083028401116401000000008311171561055a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611658945050505050565b3480156105a457600080fd5b50610151600480360360408110156105bb57600080fd5b506001600160a01b0381351690602001351515611f11565b3480156105df57600080fd5b50610606600480360360208110156105f657600080fd5b50356001600160a01b0316611fa6565b6040805192835260208301919091528051918290030190f35b60005b838110156106695761066185858381811061063957fe5b905060200201356001600160a01b031684848481811061065557fe5b90506020020135610682565b600101610622565b5050505050565b60036020526000908152604090205481565b3360008181526004602090815260408083206001600160a01b038716845260038352818420600282015486865260018201855283862081875290945291909320549091906106d09086611fc2565b6001600160a01b0385166000908152600184016020908152604080832085845282528083209390935585905220546107089086611fc2565b60008281526020859052604090205561072382848684612025565b505050505050565b336000908152600360205260408120905b82518110156107a057600083828151811061075357fe5b60200260200101519050600060046000836001600160a01b03166001600160a01b0316815260200190815260200160002090506107968482848460020154612025565b505060010161073c565b508054600181111561084c57600182556040805163a9059cbb60e01b81523360048201526000198301602482015290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163a9059cbb9160448083019260209291908290030181600087803b15801561082257600080fd5b505af1158015610836573d6000803e3d6000fd5b505050506040513d602081101561066957600080fd5b505050565b60016020526000908152604090205460ff1681565b61086e612170565b6000546001600160a01b039081169116146108d0576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b60028054141561097e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038084166004830152915183927f00000000000000000000000000000000000000000000000000000000000000001691635b16ebb7916024808301926020929190829003018186803b1580156109ec57600080fd5b505afa158015610a00573d6000803e3d6000fd5b505050506040513d6020811015610a1657600080fd5b5051610a5d576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b6001600160a01b03821660009081526004602090815260408083203384526003909252909120600180830154600284015490918190610a9d908490611fc2565b14610aef576040805162461bcd60e51b815260206004820152601760248201527f45706f636820616c72656164792066696e616c697a6564000000000000000000604482015290519081900360640190fd5b6001600160a01b03861660009081526002840160205260409020548214610b5d576040805162461bcd60e51b815260206004820152601b60248201527f45706f63682066756e647320616c726561647920636c61696d65640000000000604482015290519081900360640190fd5b6001600160a01b038616600090815260028401602090815260408083208490556001860182528083208584529091529020548015610d735760008381526020868152604080832080546001600160a01b038c16855260018901845282852088865290935290832092909255610bd28184612174565b82600001819055506060896001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b158015610c1557600080fd5b505afa158015610c29573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610c5257600080fd5b8101908080516040519392919084640100000000821115610c7257600080fd5b908301906020820185811115610c8757600080fd5b8251866020820283011164010000000082111715610ca457600080fd5b82525081516020918201928201910280838360005b83811015610cd1578181015183820152602001610cb9565b505050509050016040525050509050610d0481600081518110610cf057fe5b6020026020010151846001015486856121b6565b8360010181905550610d3081600181518110610d1c57fe5b6020026020010151846002015486856121b6565b60028401556003830154610d67907f00000000000000000000000000000000000000000000000000000000000000009086856121b6565b83600301819055505050505b505060016002555050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000546001600160a01b031690565b600280541415610e0b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038084166004830152915183927f00000000000000000000000000000000000000000000000000000000000000001691635b16ebb7916024808301926020929190829003018186803b158015610e7957600080fd5b505afa158015610e8d573d6000803e3d6000fd5b505050506040513d6020811015610ea357600080fd5b5051610eea576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b81610ef4816121ff565b610f3a576040805162461bcd60e51b81526020600482015260126024820152710a6e0e4cac2c840d2e640e8dede40d0d2ced60731b604482015290519081900360640190fd5b6001600160a01b0383166000908152600460205260409020600281015460018201548114610faf576040805162461bcd60e51b815260206004820152601f60248201527f50726576696f75732065706f6368206973206e6f742066696e616c697a656400604482015290519081900360640190fd5b6060856001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b158015610fea57600080fd5b505afa158015610ffe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561102757600080fd5b810190808051604051939291908464010000000082111561104757600080fd5b90830190602082018581111561105c57600080fd5b825186602082028301116401000000008211171561107957600080fd5b82525081516020918201928201910280838360005b838110156110a657818101518382015260200161108e565b50505050905001604052505050905060006110e730836000815181106110c857fe5b60200260200101516001600160a01b031661273b90919063ffffffff16565b905060006110fc30846001815181106110c857fe5b9050876001600160a01b0316635915d806896001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561115a57600080fd5b505afa15801561116e573d6000803e3d6000fd5b505050506040513d602081101561118457600080fd5b50516040805160008082526020820190925290506040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156111ed5781810151838201526020016111d5565b5050505090500193505050506040805180830381600087803b15801561121257600080fd5b505af1158015611226573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250604081101561124b57600080fd5b5050825161126c90839061126690309087906000906110c857fe5b90612174565b8560000160008681526020019081526020016000206001018190555061129d8161126630866001815181106110c857fe5b6000858152602087905260409020600201556112ba846001611fc2565b600295860155505060019092555050505050565b600280541415611325576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038084166004830152915183927f00000000000000000000000000000000000000000000000000000000000000001691635b16ebb7916024808301926020929190829003018186803b15801561139357600080fd5b505afa1580156113a7573d6000803e3d6000fd5b505050506040513d60208110156113bd57600080fd5b5051611404576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b6001600160a01b0382166000818152600460209081526040808320338452600383528184206002820154958552600181018452828520868652909352922054919290918015611510576001600160a01b038616600090815260018401602090815260408083208584528252808320839055908690529020546114869082612174565b60008381526020868152604080832093909355825163a9059cbb60e01b81523360048201526024810185905292516001600160a01b038a169363a9059cbb9360448083019493928390030190829087803b1580156114e357600080fd5b505af11580156114f7573d6000803e3d6000fd5b505050506040513d602081101561150d57600080fd5b50505b5050600160025550505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b611549612170565b6000546001600160a01b039081169116146115ab576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166115f05760405162461bcd60e51b815260040180806020018281038252602681526020018061356f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6002805414156116af576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038085166004830152915184927f00000000000000000000000000000000000000000000000000000000000000001691635b16ebb7916024808301926020929190829003018186803b15801561171d57600080fd5b505afa158015611731573d6000803e3d6000fd5b505050506040513d602081101561174757600080fd5b505161178e576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b8160008151116117e5576040805162461bcd60e51b815260206004820152601460248201527f4d696e2070617468206c656e6774682069732031000000000000000000000000604482015290519081900360640190fd5b600581511061183b576040805162461bcd60e51b815260206004820152601460248201527f4d61782070617468206c656e6774682069732034000000000000000000000000604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168160018351038151811061187557fe5b60200260200101516001600160a01b0316146118d8576040805162461bcd60e51b815260206004820152601b60248201527f53686f756c64207377617020746f2074617267657420746f6b656e0000000000604482015290519081900360640190fd5b60015b815181600101101561197757600160008383815181106118f757fe5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1661196f576040805162461bcd60e51b815260206004820152601860248201527f546f6b656e206973206e6f742077686974656c69737465640000000000000000604482015290519081900360640190fd5b6001016118db565b506001600160a01b03841660009081526004602090815260408083206001808201548086529382905291909320600284015490916119b6908490611fc2565b14611a08576040805162461bcd60e51b815260206004820152601c60248201527f507265762065706f636820616c72656164792066696e616c697a656400000000604482015290519081900360640190fd5b6060876001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b158015611a4357600080fd5b505afa158015611a57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015611a8057600080fd5b8101908080516040519392919084640100000000821115611aa057600080fd5b908301906020820185811115611ab557600080fd5b8251866020820283011164010000000082111715611ad257600080fd5b82525081516020918201928201910280838360005b83811015611aff578181015183820152602001611ae7565b505050509050016040525050509050600081600081518110611b1d57fe5b60200260200101516001600160a01b031688600081518110611b3b57fe5b60200260200101516001600160a01b03161415611b5d57506001820154611bf7565b81600181518110611b6a57fe5b60200260200101516001600160a01b031688600081518110611b8857fe5b60200260200101516001600160a01b03161415611baa57506002820154611bf7565b6040805162461bcd60e51b815260206004820152601360248201527f496e76616c696420666972737420746f6b656e00000000000000000000000000604482015290519081900360640190fd5b600080611c048a846127dc565b915091508060001415611e3f578215611e3a57818314611c6b576040805162461bcd60e51b815260206004820152601c60248201527f617661696c61626c6542616c616e6365206973206e6f74206475737400000000604482015290519081900360640190fd5b60005b8a51816001011015611da95760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663901754d78d8481518110611cb757fe5b60200260200101518e8560010181518110611cce57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015611d2357600080fd5b505afa158015611d37573d6000803e3d6000fd5b505050506040513d6020811015611d4d57600080fd5b50519050611d5a816121ff565b611da0576040805162461bcd60e51b81526020600482015260126024820152710a6e0e4cac2c840d2e640e8dede40d0d2ced60731b604482015290519081900360640190fd5b50600101611c6e565b50611dd08a600081518110611dba57fe5b60200260200101516001600160a01b03166129d4565b15611e0857604051329084156108fc029085906000818181858888f19350505050158015611e02573d6000803e3d6000fd5b50611e3a565b611e3a8b848c600081518110611e1a57fe5b60200260200101516001600160a01b03166129e19092919063ffffffff16565b611e65565b6000611e4c8b8430612a48565b6003870154909150611e5e9082611fc2565b6003870155505b83600081518110611e7257fe5b60200260200101516001600160a01b03168a600081518110611e9057fe5b60200260200101516001600160a01b03161415611ec0576001850154611eb69083612174565b6001860155611ed5565b6002850154611ecf9083612174565b60028601555b6001850154158015611ee957506002850154155b15611eff57611ef9866001611fc2565b60018801555b50506001600255505050505050505050565b611f19612170565b6000546001600160a01b03908116911614611f7b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b6004602052600090815260409020600181015460029091015482565b60008282018381101561201c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b6001600160a01b0382166000908152600185016020908152604080832060028801835281842054845290915290205461207a576001600160a01b0382166000908152600285016020526040902081905561216a565b6001600160a01b0382166000908152600280860160205260408220546001860154909290916120b2906120ad8486612174565b612e58565b9050806120c15750505061216a565b60006120cf88888887612e6e565b905060018211156120f6576120f36120ec89898988600101612e6e565b8290611fc2565b90505b87546121029082611fc2565b88556001600160a01b03861660009081526001808a0160209081526040808420928801845291905290205415600283148061213a5750805b6121475784600101612149565b855b6001600160a01b038816600090815260028b01602052604090205550505050505b50505050565b3390565b600061201c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612f26565b6000806121cd836121c78787612fbd565b90613016565b905080156121e9576121e96001600160a01b0387163383613058565b6121f38582612174565b9150505b949350505050565b60006060826001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b15801561223c57600080fd5b505afa158015612250573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561227957600080fd5b810190808051604051939291908464010000000082111561229957600080fd5b9083019060208201858111156122ae57600080fd5b82518660208202830111640100000000821117156122cb57600080fd5b82525081516020918201928201910280838360005b838110156122f85781810151838201526020016122e0565b50505050905001604052505050905060008060008061231e87866000815181106110c857fe5b9050600061233388876001815181106110c857fe5b90506000886001600160a01b03166348d67e1b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237057600080fd5b505afa158015612384573d6000803e3d6000fd5b505050506040513d602081101561239a57600080fd5b505190506123a6613557565b896001600160a01b0316636edc2c09896000815181106123c257fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561240657600080fd5b505afa15801561241a573d6000803e3d6000fd5b505050506040513d604081101561243057600080fd5b50805160209182015164ffffffffff16918301919091526001600160d81b0316815260006124686124628385886130bc565b86613127565b90508a6001600160a01b0316636edc2c098a60018151811061248657fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b1580156124ca57600080fd5b505afa1580156124de573d6000803e3d6000fd5b505050506040513d60408110156124f457600080fd5b50805160209182015164ffffffffff16918401919091526001600160d81b0316825260006125266124628486886130bc565b90508b6001600160a01b0316635ed9156d8b60008151811061254457fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561258857600080fd5b505afa15801561259c573d6000803e3d6000fd5b505050506040513d60408110156125b257600080fd5b50805160209182015164ffffffffff16918501919091526001600160d81b0316835260006125ea6125e485878a6130bc565b88612e58565b90508c6001600160a01b0316635ed9156d8c60018151811061260857fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561264c57600080fd5b505afa158015612660573d6000803e3d6000fd5b505050506040513d604081101561267657600080fd5b50805160209182015164ffffffffff16918601919091526001600160d81b0316845260006126a86125e486888a6130bc565b90506126c0826121c7670de0b6b3a764000086612fbd565b9a506126d8846121c7670de0b6b3a764000084612fbd565b99506126f0886121c7670de0b6b3a76400008a612fbd565b9850505050505050505061271481662386f26fc10000612fbd90919063ffffffff16565b612730670de0b6b3a764000061272a8686612174565b90612fbd565b109695505050505050565b6000612746836129d4565b1561275c57506001600160a01b0381163161201f565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156127a957600080fd5b505afa1580156127bd573d6000803e3d6000fd5b505050506040513d60208110156127d357600080fd5b5051905061201f565b81518190819060005b818160010110156129cb5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663901754d788848151811061282d57fe5b602002602001015189856001018151811061284457fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b15801561289957600080fd5b505afa1580156128ad573d6000803e3d6000fd5b505050506040513d60208110156128c357600080fd5b505187519091506000906128e6906064906121c79085908c90889081106110c857fe5b905084811015612904576128fe856121c78884612fbd565b95508094505b816001600160a01b0316631e1401f889858151811061291f57fe5b60200260200101518a866001018151811061293657fe5b6020026020010151886040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b03168152602001828152602001935050505060206040518083038186803b15801561299357600080fd5b505afa1580156129a7573d6000803e3d6000fd5b505050506040513d60208110156129bd57600080fd5b5051945050506001016127e5565b50509250929050565b6001600160a01b03161590565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b17905261084c908490613137565b8160005b8451816001011015612dae5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663901754d7878481518110612a9557fe5b6020026020010151888560010181518110612aac57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015612b0157600080fd5b505afa158015612b15573d6000803e3d6000fd5b505050506040513d6020811015612b2b57600080fd5b50519050612b38816121ff565b612b7e576040805162461bcd60e51b81526020600482015260126024820152710a6e0e4cac2c840d2e640e8dede40d0d2ced60731b604482015290519081900360640190fd5b6000839050612b92878481518110611dba57fe5b612bcb57612bc78285898681518110612ba757fe5b60200260200101516001600160a01b03166131e89092919063ffffffff16565b5060005b8651836002011015612cb657816001600160a01b031663d5bcb9b582898681518110612bf357fe5b60200260200101518a8760010181518110612c0a57fe5b6020026020010151886000806040518763ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b03168152602001848152602001838152602001826001600160a01b03168152602001955050505050506020604051808303818588803b158015612c8257600080fd5b505af1158015612c96573d6000803e3d6000fd5b50505050506040513d6020811015612cad57600080fd5b50519350612da4565b816001600160a01b031663e331d03982898681518110612cd257fe5b60200260200101518a8760010181518110612ce957fe5b602090810291909101810151604080517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526001600160a01b0394851660048201529184166024830152604482018b90526000606483018190526084830152928b1660a4820152915160c48084019382900301818588803b158015612d7457600080fd5b505af1158015612d88573d6000803e3d6000fd5b50505050506040513d6020811015612d9f57600080fd5b505193505b5050600101612a4c565b50835160011415612e515783600081518110612dc657fe5b60200260200101516001600160a01b031663a9059cbb83836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612e2457600080fd5b505af1158015612e38573d6000803e3d6000fd5b505050506040513d6020811015612e4e57600080fd5b50505b9392505050565b6000818310612e67578161201c565b5090919050565b6001600160a01b038216600090815260018501602090815260408083208484529091528120548015612f1d57600083815260208690526040902060038101549054612ebd816121c78486612fbd565b6001600160a01b038716600090815260018a01602090815260408083208984529091528120559350612eef8184612174565b600086815260208990526040902055612f088285612174565b60008681526020899052604090206003015550505b50949350505050565b60008184841115612fb55760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f7a578181015183820152602001612f62565b50505050905090810190601f168015612fa75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082612fcc5750600061201f565b82820282848281612fd957fe5b041461201c5760405162461bcd60e51b81526004018080602001828103825260218152602001806135956021913960400191505060405180910390fd5b600061201c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613342565b801561084c57613067836129d4565b156130a8576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156130a2573d6000803e3d6000fd5b5061084c565b61084c6001600160a01b03841683836129e1565b6000806130e1846120ad876020015164ffffffffff164261217490919063ffffffff16565b905060006130ef8583612174565b905061311d856121c76131028786612fbd565b8951613117906001600160d81b031686612fbd565b90611fc2565b9695505050505050565b600081831015612e67578161201c565b606061318c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133a79092919063ffffffff16565b80519091501561084c578080602001905160208110156131ab57600080fd5b505161084c5760405162461bcd60e51b815260040180806020018281038252602a8152602001806135b6602a913960400191505060405180910390fd5b8015806132875750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561325957600080fd5b505afa15801561326d573d6000803e3d6000fd5b505050506040513d602081101561328357600080fd5b5051155b6132c25760405162461bcd60e51b81526004018080602001828103825260368152602001806135e06036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261084c908490613137565b600081836133915760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612f7a578181015183820152602001612f62565b50600083858161339d57fe5b0495945050505050565b60606121f7848460008560606133bc8561351e565b61340d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061344c5780518252601f19909201916020918201910161342d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146134ae576040519150601f19603f3d011682016040523d82523d6000602084013e6134b3565b606091505b509150915081156134c75791506121f79050565b8051156134d75780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315612f7a578181015183820152602001612f62565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906121f7575050151592915050565b60408051808201909152600080825260208201529056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212208bcd324180ccac527f5ef98c8f32ab81e2c80d4fb2bb23713aa6afdde13cf68a64736f6c634300060c0033000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a9643Deployed Bytecode
0x6080604052600436106100f75760003560e01c80638da5cb5b1161008a578063f2fde38b11610059578063f2fde38b146104a5578063f3aafa80146104d8578063f583adbc14610598578063f5dab711146105d357610153565b80638da5cb5b14610415578063946e1a621461042a5780639e96b2ce1461045d578063ec9545941461049057610153565b80635e8c8bb7116100c65780635e8c8bb714610355578063715018a61461039c57806371646f98146103b157806385731140146103e457610153565b80630931753c146101585780631959a002146102275780631a3991251461026c578063318d9e5d146102a557610153565b366101535733321415610151576040805162461bcd60e51b815260206004820152601660248201527f455448207472616e7366657220666f7262696464656e00000000000000000000604482015290519081900360640190fd5b005b600080fd5b34801561016457600080fd5b506101516004803603604081101561017b57600080fd5b81019060208101813564010000000081111561019657600080fd5b8201836020820111156101a857600080fd5b803590602001918460208302840111640100000000831117156101ca57600080fd5b9193909290916020810190356401000000008111156101e857600080fd5b8201836020820111156101fa57600080fd5b8035906020019184602083028401116401000000008311171561021c57600080fd5b50909250905061061f565b34801561023357600080fd5b5061025a6004803603602081101561024a57600080fd5b50356001600160a01b0316610670565b60408051918252519081900360200190f35b34801561027857600080fd5b506101516004803603604081101561028f57600080fd5b506001600160a01b038135169060200135610682565b3480156102b157600080fd5b50610151600480360360208110156102c857600080fd5b8101906020810181356401000000008111156102e357600080fd5b8201836020820111156102f557600080fd5b8035906020019184602083028401116401000000008311171561031757600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061072b945050505050565b34801561036157600080fd5b506103886004803603602081101561037857600080fd5b50356001600160a01b0316610851565b604080519115158252519081900360200190f35b3480156103a857600080fd5b50610151610866565b3480156103bd57600080fd5b50610151600480360360208110156103d457600080fd5b50356001600160a01b0316610927565b3480156103f057600080fd5b506103f9610d81565b604080516001600160a01b039092168252519081900360200190f35b34801561042157600080fd5b506103f9610da5565b34801561043657600080fd5b506101516004803603602081101561044d57600080fd5b50356001600160a01b0316610db4565b34801561046957600080fd5b506101516004803603602081101561048057600080fd5b50356001600160a01b03166112ce565b34801561049c57600080fd5b506103f961151d565b3480156104b157600080fd5b50610151600480360360208110156104c857600080fd5b50356001600160a01b0316611541565b3480156104e457600080fd5b50610151600480360360408110156104fb57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561052657600080fd5b82018360208201111561053857600080fd5b8035906020019184602083028401116401000000008311171561055a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611658945050505050565b3480156105a457600080fd5b50610151600480360360408110156105bb57600080fd5b506001600160a01b0381351690602001351515611f11565b3480156105df57600080fd5b50610606600480360360208110156105f657600080fd5b50356001600160a01b0316611fa6565b6040805192835260208301919091528051918290030190f35b60005b838110156106695761066185858381811061063957fe5b905060200201356001600160a01b031684848481811061065557fe5b90506020020135610682565b600101610622565b5050505050565b60036020526000908152604090205481565b3360008181526004602090815260408083206001600160a01b038716845260038352818420600282015486865260018201855283862081875290945291909320549091906106d09086611fc2565b6001600160a01b0385166000908152600184016020908152604080832085845282528083209390935585905220546107089086611fc2565b60008281526020859052604090205561072382848684612025565b505050505050565b336000908152600360205260408120905b82518110156107a057600083828151811061075357fe5b60200260200101519050600060046000836001600160a01b03166001600160a01b0316815260200190815260200160002090506107968482848460020154612025565b505060010161073c565b508054600181111561084c57600182556040805163a9059cbb60e01b81523360048201526000198301602482015290516001600160a01b037f000000000000000000000000111111111117dc0aa78b770fa6a738034120c302169163a9059cbb9160448083019260209291908290030181600087803b15801561082257600080fd5b505af1158015610836573d6000803e3d6000fd5b505050506040513d602081101561066957600080fd5b505050565b60016020526000908152604090205460ff1681565b61086e612170565b6000546001600160a01b039081169116146108d0576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b60028054141561097e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038084166004830152915183927f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96431691635b16ebb7916024808301926020929190829003018186803b1580156109ec57600080fd5b505afa158015610a00573d6000803e3d6000fd5b505050506040513d6020811015610a1657600080fd5b5051610a5d576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b6001600160a01b03821660009081526004602090815260408083203384526003909252909120600180830154600284015490918190610a9d908490611fc2565b14610aef576040805162461bcd60e51b815260206004820152601760248201527f45706f636820616c72656164792066696e616c697a6564000000000000000000604482015290519081900360640190fd5b6001600160a01b03861660009081526002840160205260409020548214610b5d576040805162461bcd60e51b815260206004820152601b60248201527f45706f63682066756e647320616c726561647920636c61696d65640000000000604482015290519081900360640190fd5b6001600160a01b038616600090815260028401602090815260408083208490556001860182528083208584529091529020548015610d735760008381526020868152604080832080546001600160a01b038c16855260018901845282852088865290935290832092909255610bd28184612174565b82600001819055506060896001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b158015610c1557600080fd5b505afa158015610c29573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610c5257600080fd5b8101908080516040519392919084640100000000821115610c7257600080fd5b908301906020820185811115610c8757600080fd5b8251866020820283011164010000000082111715610ca457600080fd5b82525081516020918201928201910280838360005b83811015610cd1578181015183820152602001610cb9565b505050509050016040525050509050610d0481600081518110610cf057fe5b6020026020010151846001015486856121b6565b8360010181905550610d3081600181518110610d1c57fe5b6020026020010151846002015486856121b6565b60028401556003830154610d67907f000000000000000000000000111111111117dc0aa78b770fa6a738034120c3029086856121b6565b83600301819055505050505b505060016002555050505050565b7f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a964381565b6000546001600160a01b031690565b600280541415610e0b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038084166004830152915183927f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96431691635b16ebb7916024808301926020929190829003018186803b158015610e7957600080fd5b505afa158015610e8d573d6000803e3d6000fd5b505050506040513d6020811015610ea357600080fd5b5051610eea576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b81610ef4816121ff565b610f3a576040805162461bcd60e51b81526020600482015260126024820152710a6e0e4cac2c840d2e640e8dede40d0d2ced60731b604482015290519081900360640190fd5b6001600160a01b0383166000908152600460205260409020600281015460018201548114610faf576040805162461bcd60e51b815260206004820152601f60248201527f50726576696f75732065706f6368206973206e6f742066696e616c697a656400604482015290519081900360640190fd5b6060856001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b158015610fea57600080fd5b505afa158015610ffe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561102757600080fd5b810190808051604051939291908464010000000082111561104757600080fd5b90830190602082018581111561105c57600080fd5b825186602082028301116401000000008211171561107957600080fd5b82525081516020918201928201910280838360005b838110156110a657818101518382015260200161108e565b50505050905001604052505050905060006110e730836000815181106110c857fe5b60200260200101516001600160a01b031661273b90919063ffffffff16565b905060006110fc30846001815181106110c857fe5b9050876001600160a01b0316635915d806896001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561115a57600080fd5b505afa15801561116e573d6000803e3d6000fd5b505050506040513d602081101561118457600080fd5b50516040805160008082526020820190925290506040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156111ed5781810151838201526020016111d5565b5050505090500193505050506040805180830381600087803b15801561121257600080fd5b505af1158015611226573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250604081101561124b57600080fd5b5050825161126c90839061126690309087906000906110c857fe5b90612174565b8560000160008681526020019081526020016000206001018190555061129d8161126630866001815181106110c857fe5b6000858152602087905260409020600201556112ba846001611fc2565b600295860155505060019092555050505050565b600280541415611325576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038084166004830152915183927f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96431691635b16ebb7916024808301926020929190829003018186803b15801561139357600080fd5b505afa1580156113a7573d6000803e3d6000fd5b505050506040513d60208110156113bd57600080fd5b5051611404576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b6001600160a01b0382166000818152600460209081526040808320338452600383528184206002820154958552600181018452828520868652909352922054919290918015611510576001600160a01b038616600090815260018401602090815260408083208584528252808320839055908690529020546114869082612174565b60008381526020868152604080832093909355825163a9059cbb60e01b81523360048201526024810185905292516001600160a01b038a169363a9059cbb9360448083019493928390030190829087803b1580156114e357600080fd5b505af11580156114f7573d6000803e3d6000fd5b505050506040513d602081101561150d57600080fd5b50505b5050600160025550505050565b7f000000000000000000000000111111111117dc0aa78b770fa6a738034120c30281565b611549612170565b6000546001600160a01b039081169116146115ab576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166115f05760405162461bcd60e51b815260040180806020018281038252602681526020018061356f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6002805414156116af576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002805560408051635b16ebb760e01b81526001600160a01b038085166004830152915184927f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96431691635b16ebb7916024808301926020929190829003018186803b15801561171d57600080fd5b505afa158015611731573d6000803e3d6000fd5b505050506040513d602081101561174757600080fd5b505161178e576040805162461bcd60e51b81526020600482015260116024820152700496e76616c6964206d6f6f6e697377617607c1b604482015290519081900360640190fd5b8160008151116117e5576040805162461bcd60e51b815260206004820152601460248201527f4d696e2070617468206c656e6774682069732031000000000000000000000000604482015290519081900360640190fd5b600581511061183b576040805162461bcd60e51b815260206004820152601460248201527f4d61782070617468206c656e6774682069732034000000000000000000000000604482015290519081900360640190fd5b7f000000000000000000000000111111111117dc0aa78b770fa6a738034120c3026001600160a01b03168160018351038151811061187557fe5b60200260200101516001600160a01b0316146118d8576040805162461bcd60e51b815260206004820152601b60248201527f53686f756c64207377617020746f2074617267657420746f6b656e0000000000604482015290519081900360640190fd5b60015b815181600101101561197757600160008383815181106118f757fe5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1661196f576040805162461bcd60e51b815260206004820152601860248201527f546f6b656e206973206e6f742077686974656c69737465640000000000000000604482015290519081900360640190fd5b6001016118db565b506001600160a01b03841660009081526004602090815260408083206001808201548086529382905291909320600284015490916119b6908490611fc2565b14611a08576040805162461bcd60e51b815260206004820152601c60248201527f507265762065706f636820616c72656164792066696e616c697a656400000000604482015290519081900360640190fd5b6060876001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b158015611a4357600080fd5b505afa158015611a57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015611a8057600080fd5b8101908080516040519392919084640100000000821115611aa057600080fd5b908301906020820185811115611ab557600080fd5b8251866020820283011164010000000082111715611ad257600080fd5b82525081516020918201928201910280838360005b83811015611aff578181015183820152602001611ae7565b505050509050016040525050509050600081600081518110611b1d57fe5b60200260200101516001600160a01b031688600081518110611b3b57fe5b60200260200101516001600160a01b03161415611b5d57506001820154611bf7565b81600181518110611b6a57fe5b60200260200101516001600160a01b031688600081518110611b8857fe5b60200260200101516001600160a01b03161415611baa57506002820154611bf7565b6040805162461bcd60e51b815260206004820152601360248201527f496e76616c696420666972737420746f6b656e00000000000000000000000000604482015290519081900360640190fd5b600080611c048a846127dc565b915091508060001415611e3f578215611e3a57818314611c6b576040805162461bcd60e51b815260206004820152601c60248201527f617661696c61626c6542616c616e6365206973206e6f74206475737400000000604482015290519081900360640190fd5b60005b8a51816001011015611da95760007f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b031663901754d78d8481518110611cb757fe5b60200260200101518e8560010181518110611cce57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015611d2357600080fd5b505afa158015611d37573d6000803e3d6000fd5b505050506040513d6020811015611d4d57600080fd5b50519050611d5a816121ff565b611da0576040805162461bcd60e51b81526020600482015260126024820152710a6e0e4cac2c840d2e640e8dede40d0d2ced60731b604482015290519081900360640190fd5b50600101611c6e565b50611dd08a600081518110611dba57fe5b60200260200101516001600160a01b03166129d4565b15611e0857604051329084156108fc029085906000818181858888f19350505050158015611e02573d6000803e3d6000fd5b50611e3a565b611e3a8b848c600081518110611e1a57fe5b60200260200101516001600160a01b03166129e19092919063ffffffff16565b611e65565b6000611e4c8b8430612a48565b6003870154909150611e5e9082611fc2565b6003870155505b83600081518110611e7257fe5b60200260200101516001600160a01b03168a600081518110611e9057fe5b60200260200101516001600160a01b03161415611ec0576001850154611eb69083612174565b6001860155611ed5565b6002850154611ecf9083612174565b60028601555b6001850154158015611ee957506002850154155b15611eff57611ef9866001611fc2565b60018801555b50506001600255505050505050505050565b611f19612170565b6000546001600160a01b03908116911614611f7b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b6004602052600090815260409020600181015460029091015482565b60008282018381101561201c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b6001600160a01b0382166000908152600185016020908152604080832060028801835281842054845290915290205461207a576001600160a01b0382166000908152600285016020526040902081905561216a565b6001600160a01b0382166000908152600280860160205260408220546001860154909290916120b2906120ad8486612174565b612e58565b9050806120c15750505061216a565b60006120cf88888887612e6e565b905060018211156120f6576120f36120ec89898988600101612e6e565b8290611fc2565b90505b87546121029082611fc2565b88556001600160a01b03861660009081526001808a0160209081526040808420928801845291905290205415600283148061213a5750805b6121475784600101612149565b855b6001600160a01b038816600090815260028b01602052604090205550505050505b50505050565b3390565b600061201c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612f26565b6000806121cd836121c78787612fbd565b90613016565b905080156121e9576121e96001600160a01b0387163383613058565b6121f38582612174565b9150505b949350505050565b60006060826001600160a01b031663aa6ca8086040518163ffffffff1660e01b815260040160006040518083038186803b15801561223c57600080fd5b505afa158015612250573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561227957600080fd5b810190808051604051939291908464010000000082111561229957600080fd5b9083019060208201858111156122ae57600080fd5b82518660208202830111640100000000821117156122cb57600080fd5b82525081516020918201928201910280838360005b838110156122f85781810151838201526020016122e0565b50505050905001604052505050905060008060008061231e87866000815181106110c857fe5b9050600061233388876001815181106110c857fe5b90506000886001600160a01b03166348d67e1b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237057600080fd5b505afa158015612384573d6000803e3d6000fd5b505050506040513d602081101561239a57600080fd5b505190506123a6613557565b896001600160a01b0316636edc2c09896000815181106123c257fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561240657600080fd5b505afa15801561241a573d6000803e3d6000fd5b505050506040513d604081101561243057600080fd5b50805160209182015164ffffffffff16918301919091526001600160d81b0316815260006124686124628385886130bc565b86613127565b90508a6001600160a01b0316636edc2c098a60018151811061248657fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b1580156124ca57600080fd5b505afa1580156124de573d6000803e3d6000fd5b505050506040513d60408110156124f457600080fd5b50805160209182015164ffffffffff16918401919091526001600160d81b0316825260006125266124628486886130bc565b90508b6001600160a01b0316635ed9156d8b60008151811061254457fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561258857600080fd5b505afa15801561259c573d6000803e3d6000fd5b505050506040513d60408110156125b257600080fd5b50805160209182015164ffffffffff16918501919091526001600160d81b0316835260006125ea6125e485878a6130bc565b88612e58565b90508c6001600160a01b0316635ed9156d8c60018151811061260857fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561264c57600080fd5b505afa158015612660573d6000803e3d6000fd5b505050506040513d604081101561267657600080fd5b50805160209182015164ffffffffff16918601919091526001600160d81b0316845260006126a86125e486888a6130bc565b90506126c0826121c7670de0b6b3a764000086612fbd565b9a506126d8846121c7670de0b6b3a764000084612fbd565b99506126f0886121c7670de0b6b3a76400008a612fbd565b9850505050505050505061271481662386f26fc10000612fbd90919063ffffffff16565b612730670de0b6b3a764000061272a8686612174565b90612fbd565b109695505050505050565b6000612746836129d4565b1561275c57506001600160a01b0381163161201f565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156127a957600080fd5b505afa1580156127bd573d6000803e3d6000fd5b505050506040513d60208110156127d357600080fd5b5051905061201f565b81518190819060005b818160010110156129cb5760007f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b031663901754d788848151811061282d57fe5b602002602001015189856001018151811061284457fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b15801561289957600080fd5b505afa1580156128ad573d6000803e3d6000fd5b505050506040513d60208110156128c357600080fd5b505187519091506000906128e6906064906121c79085908c90889081106110c857fe5b905084811015612904576128fe856121c78884612fbd565b95508094505b816001600160a01b0316631e1401f889858151811061291f57fe5b60200260200101518a866001018151811061293657fe5b6020026020010151886040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b03168152602001828152602001935050505060206040518083038186803b15801561299357600080fd5b505afa1580156129a7573d6000803e3d6000fd5b505050506040513d60208110156129bd57600080fd5b5051945050506001016127e5565b50509250929050565b6001600160a01b03161590565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b17905261084c908490613137565b8160005b8451816001011015612dae5760007f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b031663901754d7878481518110612a9557fe5b6020026020010151888560010181518110612aac57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b158015612b0157600080fd5b505afa158015612b15573d6000803e3d6000fd5b505050506040513d6020811015612b2b57600080fd5b50519050612b38816121ff565b612b7e576040805162461bcd60e51b81526020600482015260126024820152710a6e0e4cac2c840d2e640e8dede40d0d2ced60731b604482015290519081900360640190fd5b6000839050612b92878481518110611dba57fe5b612bcb57612bc78285898681518110612ba757fe5b60200260200101516001600160a01b03166131e89092919063ffffffff16565b5060005b8651836002011015612cb657816001600160a01b031663d5bcb9b582898681518110612bf357fe5b60200260200101518a8760010181518110612c0a57fe5b6020026020010151886000806040518763ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b03168152602001848152602001838152602001826001600160a01b03168152602001955050505050506020604051808303818588803b158015612c8257600080fd5b505af1158015612c96573d6000803e3d6000fd5b50505050506040513d6020811015612cad57600080fd5b50519350612da4565b816001600160a01b031663e331d03982898681518110612cd257fe5b60200260200101518a8760010181518110612ce957fe5b602090810291909101810151604080517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526001600160a01b0394851660048201529184166024830152604482018b90526000606483018190526084830152928b1660a4820152915160c48084019382900301818588803b158015612d7457600080fd5b505af1158015612d88573d6000803e3d6000fd5b50505050506040513d6020811015612d9f57600080fd5b505193505b5050600101612a4c565b50835160011415612e515783600081518110612dc657fe5b60200260200101516001600160a01b031663a9059cbb83836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612e2457600080fd5b505af1158015612e38573d6000803e3d6000fd5b505050506040513d6020811015612e4e57600080fd5b50505b9392505050565b6000818310612e67578161201c565b5090919050565b6001600160a01b038216600090815260018501602090815260408083208484529091528120548015612f1d57600083815260208690526040902060038101549054612ebd816121c78486612fbd565b6001600160a01b038716600090815260018a01602090815260408083208984529091528120559350612eef8184612174565b600086815260208990526040902055612f088285612174565b60008681526020899052604090206003015550505b50949350505050565b60008184841115612fb55760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f7a578181015183820152602001612f62565b50505050905090810190601f168015612fa75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082612fcc5750600061201f565b82820282848281612fd957fe5b041461201c5760405162461bcd60e51b81526004018080602001828103825260218152602001806135956021913960400191505060405180910390fd5b600061201c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613342565b801561084c57613067836129d4565b156130a8576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156130a2573d6000803e3d6000fd5b5061084c565b61084c6001600160a01b03841683836129e1565b6000806130e1846120ad876020015164ffffffffff164261217490919063ffffffff16565b905060006130ef8583612174565b905061311d856121c76131028786612fbd565b8951613117906001600160d81b031686612fbd565b90611fc2565b9695505050505050565b600081831015612e67578161201c565b606061318c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133a79092919063ffffffff16565b80519091501561084c578080602001905160208110156131ab57600080fd5b505161084c5760405162461bcd60e51b815260040180806020018281038252602a8152602001806135b6602a913960400191505060405180910390fd5b8015806132875750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561325957600080fd5b505afa15801561326d573d6000803e3d6000fd5b505050506040513d602081101561328357600080fd5b5051155b6132c25760405162461bcd60e51b81526004018080602001828103825260368152602001806135e06036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261084c908490613137565b600081836133915760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612f7a578181015183820152602001612f62565b50600083858161339d57fe5b0495945050505050565b60606121f7848460008560606133bc8561351e565b61340d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061344c5780518252601f19909201916020918201910161342d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146134ae576040519150601f19603f3d011682016040523d82523d6000602084013e6134b3565b606091505b509150915081156134c75791506121f79050565b8051156134d75780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315612f7a578181015183820152602001612f62565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906121f7575050151592915050565b60408051808201909152600080825260208201529056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212208bcd324180ccac527f5ef98c8f32ab81e2c80d4fb2bb23713aa6afdde13cf68a64736f6c634300060c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a9643
-----Decoded View---------------
Arg [0] : _inchToken (address): 0x111111111117dC0aa78b770fA6A738034120C302
Arg [1] : _mooniswapFactory (address): 0xbAF9A5d4b0052359326A6CDAb54BABAa3a3A9643
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000111111111117dc0aa78b770fa6a738034120c302
Arg [1] : 000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a9643Loading...LoadingLoading...Loading
Loading...Loading
Loading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingMultichain Portfolio | 30 Chains
Chain Token Portfolio % Price Amount Value ETH Ether (ETH)62.81% $3,390.71 18.8778 $64,008.99 ETH 22.03% $0.388086 57,847.6836 $22,449.88 ETH 6.66% $0.999225 6,790.5928 $6,785.33 ETH 5.88% $0.998911 6,000.2386 $5,993.7 ETH 1.18% $92,266 0.0131 $1,204.18 ETH 0.90% $0.999394 913.5958 $913.04 ETH 0.26% $6.94 37.8078 $262.57 ETH 0.06% $1.11 52.2346 $57.98 ETH 0.05% $3,396.35 0.0161 $54.67 ETH 0.05% $0.183713 256.9996 $47.21 ETH 0.04% $1.24 34.2073 $42.42 ETH 0.04% $18.14 2.2296 $40.45 ETH 0.02% $0.239886 65.4584 $15.7 ETH 0.02% $23.12 0.6757 $15.62 ETH <0.01% $0.003215 2,557.6231 $8.22 ETH <0.01% $0.000929 3,640.6107 $3.38 ETH <0.01% $0.000785 3,345.1058 $2.63 ETH <0.01% $0.060471 7.4083 $0.4479 ETH <0.01% $0.014242 17 $0.2421 Loading...Loading[ Download: CSV Export ][ Download: CSV Export ]A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.
Address QR Code
My Address - Private Name Tag or Note
My Name Tag:
Private Name Tags (up to 35 characters) can be used for easy identification of addressesPrivate Note:
A private note (up to 500 characters) can be attached to this address.
Please DO NOT store any passwords or private keys here.Compiler specific version warnings:
The compiled contract might be susceptible to FullInlinerNonExpressionSplitArgumentEvaluationOrder (low-severity), MissingSideEffectsOnSelectorAccess (low-severity), AbiReencodingHeadOverflowWithStaticArrayCleanup (medium-severity), DirtyBytesArrayToStorage (low-severity), DataLocationChangeInInternalOverride (very low-severity), NestedCalldataArrayAbiReencodingSizeValidation (very low-severity), SignedImmutables (very low-severity), ABIDecodeTwoDimensionalArrayMemory (very low-severity), KeccakCaching (medium-severity), EmptyByteArrayCopy (medium-severity), DynamicArrayCleanup (medium-severity) Solidity Compiler Bugs.
Connect a Wallet
Connecting wallet for read function is optional, useful if you want to call certain functions or simply use your wallet's node.Connect a Wallet
Connecting wallet for read function is optional, useful if you want to call certain functions or simply use your wallet's node.Connect a Wallet
Connecting wallet for read function is optional, useful if you want to call certain functions or simply use your wallet's node.SignIn
Address Cards
To use this feature, please login to your Etherscan account and return to this page.Before You Copy
Transaction Private Note
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.