Contract 0xa06735da049041eb523ccf0b8c3fb9d36216c646

 
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x315dbdbdfe437249edebc8c4050d071b4ba01c61e5e590ef7a553fb507b510b8Send386306172023-01-28 15:51:1521 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009096858629102.44902391
0x8edd11c336bd70eac3c73d5067d6a580e6b2c51b85eeac0311924ab083ecc30eSend386306122023-01-28 15:51:0521 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009163729309103.202123003
0xcb799fcf9e1f29cfa90f4167611b70c464fdd1679e9c439467c6608e577ab18fSend386306062023-01-28 15:50:5121 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009386381458105.70963645
0x6e4603548efda0cf13cdb569bb34e7eee9c8ecc3c05ec2094606873ea1ec0643Send386306022023-01-28 15:50:4321 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009403259118105.899713026
0x6f8e16417103c6b63d933c9f586c3520119235a4a820822476581715fd43ddb5Send386305982023-01-28 15:50:3521 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009506562872107.063122198
0x73ab1514a16c0e842235ee9fe1c06fa7c896e28c1e537ba73461f603c06b0c9cSend386305902023-01-28 15:50:1722 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009901423819111.510054957
0xc1bc30b238b21ff431077ff5ac9226e4c3191c5dccd7af085ab3a972584951c9Send386305832023-01-28 15:50:0322 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.010109129081113.84923623
0xa12b974fcaa0e0754b28570cd25139a5f3415b2b0c1af0b244bf1ccb23cd9018Send386305722023-01-28 15:49:3922 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.010319018306116.213013339
0xabc4be9383a8cc45361178e41b7973ffb2047a9c04819fc8c071791bc7d38602Send386305692023-01-28 15:49:3322 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.01018810347114.738647551
0x7b543f80e6006b1779b8bec4d74f88e59ccbf5025b25f70f1f96f6cee782f396Send386305662023-01-28 15:49:2722 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009485362981106.824368558
0x8f2f46098bfe732a28286c7687fb8bad7653a1ddefeaefc86c074ffc21bd5741Send386305612023-01-28 15:49:1723 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00865092689597.426930819
0x3f21e1e72dda1961d0aa8c40c477c2cf708585fb03c05e6ac8f36bc7b1e00013Send386305552023-01-28 15:49:0323 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009046747045101.884666141
0x7bff66c128483a7389ae23de60ba316c84cc9e79f6dab22afed43e2a4d214819Send386305522023-01-28 15:48:5723 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009046747045101.884666141
0x4c511c0d404266a28d8dd0995217d25fa5fc66e2ca9ed3cee991bf8394899a1dSend386305472023-01-28 15:48:4723 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.009667727772108.878164884
0xcae49087c294dd7611cb8f8e67b25369157891ba22371eccc131dd4b1dcdfd13Send386305432023-01-28 15:48:3723 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.029603224001112.980348909
0x07cc9782e761dad64eeb87847d95fec516c0882d6db027cd44499773edc6d205Send386254742023-01-28 12:44:403 hrs 27 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00478990870353.944058195
0x6f3858828484b43f22dce1c0bbd73ab0ce38840a0720ed94b9a80acdeea311c2Send386253452023-01-28 12:39:383 hrs 32 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00485585376354.686732922
0x94fc649411eec14cd040b007a253e9470a275d7b27b5589b08891cb1824bd7cdSend386253412023-01-28 12:39:243 hrs 32 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00490418645255.231056748
0x4656a1fb6246acff5c660214b9654b86efcaa82befdf8f4688001903648b6bd6Send386253352023-01-28 12:39:123 hrs 33 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00496304009755.893867802
0x61fd5f6540cadb865a7a29aa6545d6fa73c4b0be12d74d849a4041dac98dc148Send386253322023-01-28 12:39:063 hrs 33 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.0050240334256.580775955
0xbdcc37d0fc3df8c93bef3910e3da96849a2d239d32144568c405344109189874Send386253272023-01-28 12:38:543 hrs 33 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00509292286257.356610384
0xa9618cc9bb54ee1f35db2a6637fa3101a29f8ef6079054c0cb06d287f83b8aecSend386253232023-01-28 12:38:463 hrs 33 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00502858228256.632005346
0x30420e671afc0ec4db993f6f7c20c921c137abde73022febe7b0a9ca2ec8c1fdSend386253192023-01-28 12:38:383 hrs 33 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00501600330556.490340629
0x29bc0ca01ac5012f24e92ec3a45c4ae5ece3af492f0ea31901875e6926ecd6edSend386253112023-01-28 12:38:203 hrs 33 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00507637590357.170258165
0x86cf535fa468bcaf9f41b25e42ec28346e7f3733d27c57fe74e28b2fafb6362aSend386253072023-01-28 12:38:123 hrs 34 mins ago0xa329a183fc21ee87f1e33d3e1cfba010aee362e8 IN  0xa06735da049041eb523ccf0b8c3fb9d36216c6460.01 MATIC0.00512393779457.705901243
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x315dbdbdfe437249edebc8c4050d071b4ba01c61e5e590ef7a553fb507b510b8386306172023-01-28 15:51:1521 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009100722957922802 MATIC
0x8edd11c336bd70eac3c73d5067d6a580e6b2c51b85eeac0311924ab083ecc30e386306122023-01-28 15:51:0521 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009094112404704267 MATIC
0xcb799fcf9e1f29cfa90f4167611b70c464fdd1679e9c439467c6608e577ab18f386306062023-01-28 15:50:5121 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.00907210195316919 MATIC
0x6e4603548efda0cf13cdb569bb34e7eee9c8ecc3c05ec2094606873ea1ec0643386306022023-01-28 15:50:4321 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009070433499000378 MATIC
0x6f8e16417103c6b63d933c9f586c3520119235a4a820822476581715fd43ddb5386305982023-01-28 15:50:3521 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009060221325970396 MATIC
0x73ab1514a16c0e842235ee9fe1c06fa7c896e28c1e537ba73461f603c06b0c9c386305902023-01-28 15:50:1722 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009021187039598446 MATIC
0xc1bc30b238b21ff431077ff5ac9226e4c3191c5dccd7af085ab3a972584951c9386305832023-01-28 15:50:0322 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009000654174220306 MATIC
0xa12b974fcaa0e0754b28570cd25139a5f3415b2b0c1af0b244bf1ccb23cd9018386305722023-01-28 15:49:3922 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.008979905411512926 MATIC
0xabc4be9383a8cc45361178e41b7973ffb2047a9c04819fc8c071791bc7d38602386305692023-01-28 15:49:3322 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.008992847099526833 MATIC
0x7b543f80e6006b1779b8bec4d74f88e59ccbf5025b25f70f1f96f6cee782f396386305662023-01-28 15:49:2722 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009062317057671588 MATIC
0x8f2f46098bfe732a28286c7687fb8bad7653a1ddefeaefc86c074ffc21bd5741386305612023-01-28 15:49:1723 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009144805886656982 MATIC
0x3f21e1e72dda1961d0aa8c40c477c2cf708585fb03c05e6ac8f36bc7b1e00013386305552023-01-28 15:49:0323 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009105676777547531 MATIC
0x7bff66c128483a7389ae23de60ba316c84cc9e79f6dab22afed43e2a4d214819386305522023-01-28 15:48:5723 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009105676777547531 MATIC
0x4c511c0d404266a28d8dd0995217d25fa5fc66e2ca9ed3cee991bf8394899a1d386305472023-01-28 15:48:4723 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009044289244281225 MATIC
0xcae49087c294dd7611cb8f8e67b25369157891ba22371eccc131dd4b1dcdfd13386305432023-01-28 15:48:3723 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.007190122232458716 MATIC
0x07cc9782e761dad64eeb87847d95fec516c0882d6db027cd44499773edc6d205386254742023-01-28 12:44:403 hrs 27 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009526489845975929 MATIC
0x6f3858828484b43f22dce1c0bbd73ab0ce38840a0720ed94b9a80acdeea311c2386253452023-01-28 12:39:383 hrs 32 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009519970795757269 MATIC
0x94fc649411eec14cd040b007a253e9470a275d7b27b5589b08891cb1824bd7cd386253412023-01-28 12:39:243 hrs 32 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009515192830077406 MATIC
0x4656a1fb6246acff5c660214b9654b86efcaa82befdf8f4688001903648b6bd6386253352023-01-28 12:39:123 hrs 33 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009509374807207605 MATIC
0x61fd5f6540cadb865a7a29aa6545d6fa73c4b0be12d74d849a4041dac98dc148386253322023-01-28 12:39:063 hrs 33 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009503345264822201 MATIC
0xbdcc37d0fc3df8c93bef3910e3da96849a2d239d32144568c405344109189874386253272023-01-28 12:38:543 hrs 33 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009496535145371325 MATIC
0xa9618cc9bb54ee1f35db2a6637fa3101a29f8ef6079054c0cb06d287f83b8aec386253232023-01-28 12:38:463 hrs 33 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009502895583473882 MATIC
0x30420e671afc0ec4db993f6f7c20c921c137abde73022febe7b0a9ca2ec8c1fd386253192023-01-28 12:38:383 hrs 33 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009504139088026764 MATIC
0x29bc0ca01ac5012f24e92ec3a45c4ae5ece3af492f0ea31901875e6926ecd6ed386253112023-01-28 12:38:203 hrs 33 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009498170907879263 MATIC
0x86cf535fa468bcaf9f41b25e42ec28346e7f3733d27c57fe74e28b2fafb6362a386253072023-01-28 12:38:123 hrs 34 mins ago 0xa06735da049041eb523ccf0b8c3fb9d36216c6460xa329a183fc21ee87f1e33d3e1cfba010aee362e80.009493469140069195 MATIC
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Deb0x

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 14 : Deb0x.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./Deb0xERC20.sol";

/**
 * Main deb0x protocol contract used to send messages,
 * store public keys, allocate token rewards,
 * distribute native token fees, stake and unstake.
 */
contract Deb0x is ERC2771Context, ReentrancyGuard {

    /**
     * Deb0x Reward Token contract.
     * Initialized in constructor.
     */
    Deb0xERC20 public dbx;

    /**
     * Basis points (bps) representation of the protocol fee (i.e. 10 percent).
     * Calls to send function charge 1000 bps of transaction cost.
     */
    uint16 public constant PROTOCOL_FEE = 1000;

    /**
     * Basis points representation of 100 percent.
     */
    uint16 public constant MAX_BPS = 10000;

    /**
     * Used to minimise division remainder when earned fees are calculated.
     */
    uint256 public constant SCALING_FACTOR = 1e40;

    /**
     * Contract creation timestamp.
     * Initialized in constructor.
     */
    uint256 public immutable i_initialTimestamp;

    /**
     * Length of a reward distribution cycle. 
     * Initialized in contstructor to 1 day.
     */
    uint256 public immutable i_periodDuration;

    /**
     * Reward token amount allocated for the current cycle.
     */
    uint256 public currentCycleReward;

    /**
     * Reward token amount allocated for the previous cycle.
     */
    uint256 public lastCycleReward;

    /**
     * Helper variable to store pending stake amount.   
     */
    uint256 public pendingStake;

    /**
     * Index (0-based) of the current cycle.
     * 
     * Updated upon cycle setup that is triggered by contract interraction 
     * (account sends message, claims fees, claims rewards, stakes or unstakes).
     */
    uint256 public currentCycle;

    /**
     * Helper variable to store the index of the last active cycle.
     */
    uint256 public lastStartedCycle;

    /**
     * Stores the index of the penultimate active cycle plus one.
     */
    uint256 public previousStartedCycle;

    /**
     * Helper variable to store the index of the last active cycle.
     */
    uint256 public currentStartedCycle;

    /**
     * Stores the amount of stake that will be subracted from the total
     * stake once a new cycle starts.
     */
    uint256 public pendingStakeWithdrawal;

    /**
     * Accumulates fees while there are no tokens staked after the
     * entire token supply has been distributed. Once tokens are
     * staked again, these fees will be distributed in the next
     * active cycle.
     */
    uint256 public pendingFees;

    /**
     * Message ID that is incremented every time a message is sent.
     */
    uint256 public sentId = 1;

    /**
     * Stores the public keys of accounts.
     */
    mapping(address => bytes32) public publicKeys;

    /**
     * The amount of gas an account owes towards clients.
     */
    mapping(address => uint256) public accCycleGasOwed;

    /**
     * The amount of gas a client has received from owed
     * account gas.
     */
    mapping(address => uint256) public clientCycleGasEarned;

    /**
     * The amount of gas an account has spent sending messages.
     * Resets during a new cycle when an account performs an action
     * that updates its stats.
     */
    mapping(address => uint256) public accCycleGasUsed;

    /**
     * The total amount of gas all accounts have spent sending
     * messages per cycle.
     */
    mapping(uint256 => uint256) public cycleTotalGasUsed;

    /**
     * The last cycle in which an account has sent messages.
     */
    mapping(address => uint256) public lastActiveCycle;

    /**
     * The last cycle in which the client had its reward updated.
     */
    mapping(address => uint256) public clientLastRewardUpdate;

    /**
     * The last cycle in which the client had its earned fees updated.
     */
    mapping(address => uint256) public clientLastFeeUpdate;

    /**
     * The fee amount the client can withdraw.
     */
    mapping(address => uint256) public clientAccruedFees;

    /**
     * Current unclaimed rewards and staked amounts per account.
     */
    mapping(address => uint256) public accRewards;

    /**
     * The fee amount the account can withdraw.
     */
    mapping(address => uint256) public accAccruedFees;

    /**
     * Current unclaimed rewards per client.
     */
    mapping(address => uint256) public clientRewards;

    /**
     * Total token rewards allocated per cycle.
     */
    mapping(uint256 => uint256) public rewardPerCycle;

    /**
     * Total unclaimed token reward and stake. 
     * 
     * Updated when a new cycle starts and when an account claims rewards, stakes or unstakes externally owned tokens.
     */
    mapping(uint256 => uint256) public summedCycleStakes;

    /**
     * The last cycle in which the account had its fees updated.
     */ 
    mapping(address => uint256) public lastFeeUpdateCycle;

    /**
     * The total amount of accrued fees per cycle.
     */
    mapping(uint256 => uint256) public cycleAccruedFees;

    /**
     * Sum of previous total cycle accrued fees divided by cycle stake.
     */
    mapping(uint256 => uint256) public cycleFeesPerStakeSummed;

    /**
     * Amount an account has staked and is locked during given cycle.
     */
    mapping(address => mapping(uint256 => uint256)) public accStakeCycle;

    /**
     * Stake amount an account can currently withdraw.
     */
    mapping(address => uint256) public accWithdrawableStake;

    /**
     * Cycle in which an account's stake is locked and begins generating fees.
     */
    mapping(address => uint256) public accFirstStake;

    /**
     * Same as accFirstStake, but stores the second stake seperately 
     * in case the account stakes in two consecutive active cycles.
     */
    mapping(address => uint256) public accSecondStake;

    /**
     * @dev Emitted when the client operating `account` claims an amount of `fees` 
     * in native token through {claimClientFees} in `cycle`.
     */
    event ClientFeesClaimed(
        uint256 indexed cycle,
        address indexed account,
        uint256 fees
    );

    /**
     * @dev Emitted when `account` claims an amount of `fees` in native token
     * through {claimFees} in `cycle`.
     */
    event FeesClaimed(
        uint256 indexed cycle,
        address indexed account,
        uint256 fees
    );

    /**
     * @dev Emitted when `account` stakes `amount` DBX tokens through
     * {stake} in `cycle`.
     */
    event Staked(
        uint256 indexed cycle,
        address indexed account,
        uint256 amount
    );

    /**
     * @dev Emitted when `account` unstakes `amount` DBX tokens through
     * {unstake} in `cycle`.
     */
    event Unstaked(
        uint256 indexed cycle,
        address indexed account,
        uint256 amount
    );

    /**
     * @dev Emitted when client operating `account` claims `amount` DBX 
     * token rewards through {claimRewards} in `cycle`.
     */
    event ClientRewardsClaimed(
        uint256 indexed cycle,
        address indexed account,
        uint256 amount
    );

    /**
     * @dev Emitted when `account` claims `amount` DBX 
     * token rewards through {claimRewards} in `cycle`.
     */
    event RewardsClaimed(
        uint256 indexed cycle,
        address indexed account,
        uint256 reward
    );

    /**
     * @dev Emitted when calling {send} marking the new current `cycle`,
     * `calculatedCycleReward` and `summedCycleStakes`.
     */
    event NewCycleStarted(
        uint256 indexed cycle,
        uint256 calculatedCycleReward,
        uint256 summedCycleStakes
    );

    /**
     * @dev Emitted when calling {send} in the current `cycle`,
     * containing the message details such as which `sentId` it has,
     * who the `feeReceiver` is and what `msgFee` it set, respectively
     * any additional `nativeTokenFee` that was paid.
     */
    event SendEntryCreated(
        uint256 indexed cycle,
        uint256 indexed sentId,
        address indexed feeReceiver,
        uint256 msgFee,
        uint256 nativeTokenFee
    );

    /**
     * @dev Emitted when calling {send} containing the message 
     * details such as `to` destination address, `from` sender
     * address, `hash` of the content reference, `sentId`,
     * `timestamp` and `content`.
     */
    event Sent(
        address indexed to,
        address indexed from,
        bytes32 indexed hash,
        uint256 sentId,
        uint256 timestamp,
        bytes32[] content
    );
    
    /**
     * @dev Emitted when calling {setKey}, `to` being assigned this key `value`.
     */
    event KeySet(
        address indexed to, 
        bytes32 indexed value
    );

    /**
     * @dev Measures the amount of consummed gas.
     * In case a fee is applied, the corresponding percentage will be recorded 
     * as consumed by the feeReceiver instead of the caller.
     * 
     * @param feeReceiver the address of the fee receiver (client).
     * @param msgFee fee percentage expressed in basis points.
     */
    modifier gasUsed(address feeReceiver, uint256 msgFee) {
        uint256 startGas = gasleft();

        _;

        uint256 gasConsumed = startGas - gasleft();

        cycleTotalGasUsed[currentCycle] += gasConsumed;

        if (feeReceiver != address(0) && msgFee != 0) {
            uint256 gasOwed = (gasConsumed * msgFee) / MAX_BPS;
            gasConsumed -= gasOwed;
            clientCycleGasEarned[feeReceiver] += gasOwed;
        }

        accCycleGasUsed[_msgSender()] += gasConsumed;
    }

    /**
     * @dev Checks that the caller has sent an amount that is equal or greater 
     * than the sum of the protocol fee and the client's native token fee. 
     * The change is sent back to the caller.
     * 
     * @param nativeTokenFee the amount charged by the client.
     */
    modifier gasWrapper(uint256 nativeTokenFee) {
        uint256 startGas = gasleft();

        _;

        uint256 fee = ((startGas - gasleft() + 39700) * tx.gasprice * PROTOCOL_FEE) / MAX_BPS;
        require(
            msg.value - nativeTokenFee >= fee,
            "Deb0x: value less than required protocol fee"
        );
        
        cycleAccruedFees[currentCycle] += fee;
        sendViaCall(payable(msg.sender), msg.value - fee - nativeTokenFee);
    }

    /**
     * @param forwarder forwarder contract address.
     */
    constructor(address forwarder) ERC2771Context(forwarder) {
        dbx = new Deb0xERC20();
        i_initialTimestamp = block.timestamp;
        i_periodDuration = 1 days;
        currentCycleReward = 10000 * 1e18;
        summedCycleStakes[0] = 10000 * 1e18;
        rewardPerCycle[0] = 10000 * 1e18;
    }

    /**
     * @dev Stores the public key of the sender account.
     * 
     * @param publicKey as encoded by the client.
     */
    function setKey(bytes32 publicKey) external {
        publicKeys[_msgSender()] = publicKey;
        emit KeySet(_msgSender(), publicKey);
    }

    /**
     * @dev Sends messages to multiple accounts. Triggers helper functions 
     * used to update cycle, rewards and fees related state.
     * Optionally may include extra reward token fee and native coin fees on-top of the default protocol fee. 
     * These fees are set in the client user intarface the transaction sender interacts with.
     * 
     * @param to account addresses to send messages to.
     * @param crefs content references to the messages.
     * @param feeReceiver client address.
     * @param msgFee on-top reward token fee charged by the client (in basis points). If 0, no reward token fee applies.
     * @param nativeTokenFee on-top native coin fee charged by the client. If 0, no native token fee applies.
     */
    function send(
        address[] memory to,
        bytes32[][] memory crefs,
        address feeReceiver,
        uint256 msgFee,
        uint256 nativeTokenFee
    )
        external
        payable
        nonReentrant()
        gasWrapper(nativeTokenFee)
        gasUsed(feeReceiver, msgFee)

    {
        require(msgFee <= MAX_BPS, "Deb0x: reward fees exceed 10000 bps");

        uint256 _sentId = _send(to, crefs);
        calculateCycle();
        updateCycleFeesPerStakeSummed();
        setUpNewCycle();
        updateStats(_msgSender());
        updateClientStats(feeReceiver);

        lastActiveCycle[_msgSender()] = currentCycle;
        emit SendEntryCreated(
            currentCycle,
            _sentId,
            feeReceiver,
            msgFee,
            nativeTokenFee
        );
    }

    /**
     * @dev Mints newly accrued account rewards and transfers the entire 
     * allocated amount to the transaction sender address.
     */
    function claimRewards()
        external
        nonReentrant()
    {
        calculateCycle();
        updateCycleFeesPerStakeSummed();
        updateStats(_msgSender());
        uint256 reward = accRewards[_msgSender()] - accWithdrawableStake[_msgSender()];

        require(reward > 0, "Deb0x: account has no rewards");

        accRewards[_msgSender()] -= reward;
        if (lastStartedCycle == currentStartedCycle) {
            pendingStakeWithdrawal += reward;
        } else {
            summedCycleStakes[currentCycle] = summedCycleStakes[currentCycle] - reward;
        }

        dbx.mintReward(_msgSender(), reward);
        emit RewardsClaimed(currentCycle, _msgSender(), reward);
    }

    /**
     * @dev Mints newly accrued client rewards share and transfers the entire 
     * allocated amount to the transaction sender address.
     */
    function claimClientRewards()
        external
        nonReentrant()
    {
        calculateCycle();
        updateCycleFeesPerStakeSummed();

        updateClientStats(_msgSender());

        uint256 reward = clientRewards[_msgSender()];
        require(reward > 0, "Deb0x: client has no rewards");
        clientRewards[_msgSender()] = 0;

        if (lastStartedCycle == currentStartedCycle) {
            pendingStakeWithdrawal += reward;
        } else {
            summedCycleStakes[currentCycle] = summedCycleStakes[currentCycle] - reward;
        }

        dbx.mintReward(_msgSender(), reward);
        emit ClientRewardsClaimed(currentCycle, _msgSender(), reward);
    }

    /**
     * @dev Transfers newly accrued fees to sender's address.
     */
    function claimFees()
        external
        nonReentrant()
    {
        calculateCycle();
        updateCycleFeesPerStakeSummed();
        updateStats(_msgSender());

        uint256 fees = accAccruedFees[_msgSender()];
        require(fees > 0, "Deb0x: amount is zero");

        accAccruedFees[_msgSender()] = 0;
        sendViaCall(payable(_msgSender()), fees);
        emit FeesClaimed(getCurrentCycle(), _msgSender(), fees);
    }

    /**
     * @dev Transfers newly accrued client fee share and transfers 
     * the entire amount to caller address.
     */
    function claimClientFees()
        external
        nonReentrant()
    {
        calculateCycle();
        updateCycleFeesPerStakeSummed();

        updateClientStats(_msgSender());
        uint256 fees = clientAccruedFees[_msgSender()];
        require(fees > 0, "Deb0x: client has no accrued fees");

        clientAccruedFees[_msgSender()] = 0;
        sendViaCall(payable(_msgSender()), fees);
        emit ClientFeesClaimed(getCurrentCycle(), _msgSender(), fees);
    }

    /**
     * @dev Stakes the given amount and increases the share of the daily allocated fees.
     * The tokens are transfered from sender account to this contract.
     * To receive the tokens back, the unstake function must be called by the same account address.
     * 
     * @param amount token amount to be staked (in wei).
     */
    function stake(uint256 amount)
        external
        nonReentrant()
    {
        calculateCycle();
        updateCycleFeesPerStakeSummed();
        updateStats(_msgSender());
        require(amount > 0, "Deb0x: amount is zero");
        pendingStake += amount;
        uint256 cycleToSet = currentCycle + 1;

        if (lastStartedCycle == currentStartedCycle) {
            cycleToSet = currentCycle;
        }

        if (
            (cycleToSet != accFirstStake[_msgSender()] &&
                cycleToSet != accSecondStake[_msgSender()])
        ) {
            if (accFirstStake[_msgSender()] == 0) {
                accFirstStake[_msgSender()] = cycleToSet;
            } else if (accSecondStake[_msgSender()] == 0) {
                accSecondStake[_msgSender()] = cycleToSet;
            }
        }

        accStakeCycle[_msgSender()][cycleToSet] += amount;

        dbx.transferFrom(_msgSender(), address(this), amount);
        emit Staked(cycleToSet, _msgSender(), amount);
    }

    /**
     * @dev Unstakes the given amount and decreases the share of the daily allocated fees.
     * If the balance is availabe, the tokens are transfered from this contract to the sender account.
     * 
     * @param amount token amount to be unstaked (in wei).
     */
    function unstake(uint256 amount)
        external
        nonReentrant()
    {
        calculateCycle();
        updateCycleFeesPerStakeSummed();
        updateStats(_msgSender());
        require(amount > 0, "Deb0x: amount is zero");

        require(
            amount <= accWithdrawableStake[_msgSender()],
            "Deb0x: amount greater than withdrawable stake"
        );

        if (lastStartedCycle == currentStartedCycle) {
            pendingStakeWithdrawal += amount;
        } else {
            summedCycleStakes[currentCycle] -= amount;
        }

        accWithdrawableStake[_msgSender()] -= amount;
        accRewards[_msgSender()] -= amount;

        dbx.transfer(_msgSender(), amount);
        emit Unstaked(currentCycle, _msgSender(), amount);
    }

    /**
     * @dev Returns the index of the cycle at the current block time.
     */
    function getCurrentCycle() public view returns (uint256) {
        return (block.timestamp - i_initialTimestamp) / i_periodDuration;
    }

    /**
     * @dev Updates various helper state variables used to compute token rewards 
     * and fees distribution for a given client.
     * 
     * @param client the address of the client to make the updates for.
     */
    function updateClientStats(address client) internal {
        if (currentCycle > clientLastRewardUpdate[client]) {
            uint256 lastUpdatedCycle = clientLastRewardUpdate[client];

            if (
                clientCycleGasEarned[client] != 0 &&
                cycleTotalGasUsed[lastUpdatedCycle] != 0
            ) {
                uint256 clientRewardsEarned = (clientCycleGasEarned[client] * rewardPerCycle[lastUpdatedCycle]) / 
                    cycleTotalGasUsed[lastUpdatedCycle];
                clientRewards[client] += clientRewardsEarned;
                clientCycleGasEarned[client] = 0;
            }

            clientLastRewardUpdate[client] = currentCycle;
        }

        if (
            currentCycle > lastStartedCycle &&
            clientLastFeeUpdate[client] != lastStartedCycle + 1
        ) {
            clientAccruedFees[client] += (
                clientRewards[client] * 
                    (cycleFeesPerStakeSummed[lastStartedCycle + 1] - 
                        cycleFeesPerStakeSummed[clientLastFeeUpdate[client]]
                    )
            ) /
            SCALING_FACTOR;

            clientLastFeeUpdate[client] = lastStartedCycle + 1;
        }
    }

    /**
     * @dev Updates the index of the cycle.
     */
    function calculateCycle() internal {
        uint256 calculatedCycle = getCurrentCycle();
        
        if (calculatedCycle > currentCycle) {
            currentCycle = calculatedCycle;
        }
        
    }

    /**
     * @dev Updates the global helper variables related to fee distribution.
     */
    function updateCycleFeesPerStakeSummed() internal {
        if (currentCycle != currentStartedCycle) {
            previousStartedCycle = lastStartedCycle + 1;
            lastStartedCycle = currentStartedCycle;
        }
       
        if (
            currentCycle > lastStartedCycle &&
            cycleFeesPerStakeSummed[lastStartedCycle + 1] == 0
        ) {
            uint256 feePerStake;
            if(summedCycleStakes[lastStartedCycle] != 0) {
                feePerStake = ((cycleAccruedFees[lastStartedCycle] + pendingFees) * SCALING_FACTOR) / 
            summedCycleStakes[lastStartedCycle];
                pendingFees = 0;
            } else {
                pendingFees += cycleAccruedFees[lastStartedCycle];
                feePerStake = 0;
            }
            
            cycleFeesPerStakeSummed[lastStartedCycle + 1] = cycleFeesPerStakeSummed[previousStartedCycle] + feePerStake;
        }
    }

    /**
     * @dev Updates the global state related to starting a new cycle along 
     * with helper state variables used in computation of staking rewards.
     */
    function setUpNewCycle() internal {
        if (rewardPerCycle[currentCycle] == 0) {
            lastCycleReward = currentCycleReward;
            uint256 calculatedCycleReward = (lastCycleReward * 10000) / 10020;
            currentCycleReward = calculatedCycleReward;
            rewardPerCycle[currentCycle] = calculatedCycleReward;

            currentStartedCycle = currentCycle;
            
            summedCycleStakes[currentStartedCycle] += summedCycleStakes[lastStartedCycle] + currentCycleReward;
            
            if (pendingStake != 0) {
                summedCycleStakes[currentStartedCycle] += pendingStake;
                pendingStake = 0;
            }
            
            if (pendingStakeWithdrawal != 0) {
                summedCycleStakes[currentStartedCycle] -= pendingStakeWithdrawal;
                pendingStakeWithdrawal = 0;
            }
            
            emit NewCycleStarted(
                currentCycle,
                calculatedCycleReward,
                summedCycleStakes[currentStartedCycle]
            );
        }
    }

    /**
     * @dev Updates various helper state variables used to compute token rewards 
     * and fees distribution for a given account.
     * 
     * @param account the address of the account to make the updates for.
     */
    function updateStats(address account) internal {
         if (	
            currentCycle > lastActiveCycle[account] &&	
            accCycleGasUsed[account] != 0	
        ) {	
            uint256 lastCycleAccReward = (accCycleGasUsed[account] * rewardPerCycle[lastActiveCycle[account]]) / 	
                cycleTotalGasUsed[lastActiveCycle[account]];	
            accRewards[account] += lastCycleAccReward;	
         
            accCycleGasUsed[account] = 0;
        }

        if (
            currentCycle > lastStartedCycle &&
            lastFeeUpdateCycle[account] != lastStartedCycle + 1
        ) {
            accAccruedFees[account] =
                accAccruedFees[account] +
                (
                    (accRewards[account] * 
                        (cycleFeesPerStakeSummed[lastStartedCycle + 1] - 
                            cycleFeesPerStakeSummed[lastFeeUpdateCycle[account]]
                        )
                    )
                ) /
                SCALING_FACTOR;
            lastFeeUpdateCycle[account] = lastStartedCycle + 1;
        }

        if (
            accFirstStake[account] != 0 &&
            currentCycle > accFirstStake[account]
        ) {
            uint256 unlockedFirstStake = accStakeCycle[account][accFirstStake[account]];

            accRewards[account] += unlockedFirstStake;
            accWithdrawableStake[account] += unlockedFirstStake;
            if (lastStartedCycle + 1 > accFirstStake[account]) {
                accAccruedFees[account] = accAccruedFees[account] + 
                (
                    (accStakeCycle[account][accFirstStake[account]] * 
                        (cycleFeesPerStakeSummed[lastStartedCycle + 1] - 
                            cycleFeesPerStakeSummed[accFirstStake[account]]
                        )
                    )
                ) / 
                SCALING_FACTOR;
            }

            accStakeCycle[account][accFirstStake[account]] = 0;
            accFirstStake[account] = 0;

            if (accSecondStake[account] != 0) {
                if (currentCycle > accSecondStake[account]) {
                    uint256 unlockedSecondStake = accStakeCycle[account][accSecondStake[account]];

                    accRewards[account] += unlockedSecondStake;
                    accWithdrawableStake[account] += unlockedSecondStake;
                    
                    if (lastStartedCycle + 1 > accSecondStake[account]) {
                        accAccruedFees[account] = accAccruedFees[account] + 
                        (
                            (accStakeCycle[account][accSecondStake[account]] * 
                                (cycleFeesPerStakeSummed[lastStartedCycle + 1] - 
                                    cycleFeesPerStakeSummed[accSecondStake[account]]
                                )
                            )
                        ) / 
                        SCALING_FACTOR;
                    }

                    accStakeCycle[account][accSecondStake[account]] = 0;
                    accSecondStake[account] = 0;
                } else {
                    accFirstStake[account] = accSecondStake[account];
                    accSecondStake[account] = 0;
                }
            }
        }
    }

    /**
     * @dev For each recipient emits events with correspondig cref.
     * Lengths of recipients and crefs arrays must match.
     * All crefs (content references) must be less than 8 bytes32 long and 
     * are purposed to store pointers (e.g. HTTP urls, IPFS CIDs) to messages content.
     * 
     * @param recipients recipient addresses that messages are stored for.
     * @param crefs content references to the messages.
     */
    function _send(address[] memory recipients, bytes32[][] memory crefs)
        internal
        returns (uint256)
    {
        require(recipients.length == crefs.length, "Deb0x: crefs and recipients lengths not equal");
        require(recipients.length > 0, "Deb0x: recipients array empty");
        for (uint256 idx = 0; idx < recipients.length - 1; idx++) {
            require(crefs[recipients.length - 1].length > 0 , "Deb0x: empty cref");
            require(crefs[recipients.length - 1].length <= 8 , "Deb0x: cref too long");
        }

        for (uint256 idx = 0; idx < recipients.length - 1; idx++) {
            bytes32 bodyHash = keccak256(abi.encode(crefs[idx]));
     
            emit Sent(
                recipients[idx],
                _msgSender(),
                bodyHash,
                sentId,
                block.timestamp,
                crefs[idx]
            );
        }

        bytes32 selfBodyHash = keccak256(
            abi.encode(crefs[recipients.length - 1])
        );
        require(crefs[recipients.length - 1].length > 0 , "Deb0x: empty cref");
        require(crefs[recipients.length - 1].length <= 8 , "Deb0x: cref too long");

        uint256 oldSentId = sentId;
        sentId++;

        emit Sent(
            _msgSender(),
            _msgSender(),
            selfBodyHash,
            oldSentId,
            block.timestamp,
            crefs[recipients.length - 1]
        );

        return oldSentId;
    }

    /**
     * Recommended method to use to send native coins.
     * 
     * @param to receiving address.
     * @param amount in wei.
     */
    function sendViaCall(address payable to, uint256 amount) internal {
        (bool sent, ) = to.call{value: amount}("");
        require(sent, "Deb0x: failed to send amount");
    }
}

File 2 of 14 : ERC2771Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)

pragma solidity ^0.8.9;

import "../utils/Context.sol";

/**
 * @dev Context variant with ERC2771 support.
 */
abstract contract ERC2771Context is Context {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable _trustedForwarder;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor(address trustedForwarder) {
        _trustedForwarder = trustedForwarder;
    }

    function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
        return forwarder == _trustedForwarder;
    }

    function _msgSender() internal view virtual override returns (address sender) {
        if (isTrustedForwarder(msg.sender)) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            /// @solidity memory-safe-assembly
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return super._msgSender();
        }
    }

    function _msgData() internal view virtual override returns (bytes calldata) {
        if (isTrustedForwarder(msg.sender)) {
            return msg.data[:msg.data.length - 20];
        } else {
            return super._msgData();
        }
    }
}

File 3 of 14 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _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 making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 4 of 14 : Deb0xERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";

/**
 * Reward token contract to be used by the deb0x protocol.
 * The entire amount is minted by the main deb0x contract 
 * (Deb0x.sol - which is the owner of this contract)
 * directly to an account when it claims rewards.
 */
contract Deb0xERC20 is ERC20Permit {

    /**
     * The address of the Deb0x.sol contract instance.
     */
    address public immutable owner;

    /**
     * Sets the owner address. 
     * Called from within the Deb0x.sol constructor.
     */
    constructor() ERC20("Deb0x Reward Token on Polygon", "pDBX")
    ERC20Permit("Deb0x Reward Token on Polygon") {
        owner = msg.sender;
    }

    /**
     * The total supply is naturally capped by the distribution algorithm 
     * implemented by the main deb0x contract, however an additional check 
     * that will never be triggered is added to reassure the reader.
     * 
     * @param account the address of the reward token reciever
     * @param amount wei to be minted
     */
    function mintReward(address account, uint256 amount) external {
        require(msg.sender == owner, "DBX: caller is not Deb0x contract.");
        require(super.totalSupply() < 5010000000000000000000000, "DBX: max supply already minted");
        _mint(account, amount);
    }
}

File 5 of 14 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 6 of 14 : draft-ERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)

pragma solidity ^0.8.0;

import "./draft-IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/draft-EIP712.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/Counters.sol";

/**
 * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * _Available since v3.4._
 */
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
    using Counters for Counters.Counter;

    mapping(address => Counters.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private constant _PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
    /**
     * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
     * However, to ensure consistency with the upgradeable transpiler, we will continue
     * to reserve a slot.
     * @custom:oz-renamed-from _PERMIT_TYPEHASH
     */
    // solhint-disable-next-line var-name-mixedcase
    bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    constructor(string memory name) EIP712(name, "1") {}

    /**
     * @dev See {IERC20Permit-permit}.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSA.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @dev See {IERC20Permit-nonces}.
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        Counters.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
}

File 7 of 14 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 8 of 14 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.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 Contracts guidelines: functions revert
 * instead 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, IERC20Metadata {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override 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 this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

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

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

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, 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}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, 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}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        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) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + 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) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This 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:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, 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:
     *
     * - `account` 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 += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(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);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

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

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

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 9 of 14 : draft-EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

File 10 of 14 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 11 of 14 : Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 12 of 14 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 13 of 14 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 14 of 14 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"fees","type":"uint256"}],"name":"ClientFeesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClientRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"fees","type":"uint256"}],"name":"FeesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"bytes32","name":"value","type":"bytes32"}],"name":"KeySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"calculatedCycleReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"summedCycleStakes","type":"uint256"}],"name":"NewCycleStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"sentId","type":"uint256"},{"indexed":true,"internalType":"address","name":"feeReceiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"msgFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nativeTokenFee","type":"uint256"}],"name":"SendEntryCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"bytes32","name":"hash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"sentId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"bytes32[]","name":"content","type":"bytes32[]"}],"name":"Sent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"cycle","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unstaked","type":"event"},{"inputs":[],"name":"MAX_BPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_FEE","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SCALING_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accAccruedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accCycleGasOwed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accCycleGasUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accFirstStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accSecondStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"accStakeCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accWithdrawableStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimClientFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimClientRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"clientAccruedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"clientCycleGasEarned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"clientLastFeeUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"clientLastRewardUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"clientRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentCycleReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentStartedCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cycleAccruedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cycleFeesPerStakeSummed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cycleTotalGasUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dbx","outputs":[{"internalType":"contract Deb0xERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"i_initialTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"i_periodDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastActiveCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastCycleReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastFeeUpdateCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastStartedCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingStakeWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousStartedCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"publicKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardPerCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"bytes32[][]","name":"crefs","type":"bytes32[][]"},{"internalType":"address","name":"feeReceiver","type":"address"},{"internalType":"uint256","name":"msgFee","type":"uint256"},{"internalType":"uint256","name":"nativeTokenFee","type":"uint256"}],"name":"send","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"sentId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"publicKey","type":"bytes32"}],"name":"setKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"summedCycleStakes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60e06040526001600b553480156200001657600080fd5b506040516200457d3803806200457d833981016040819052620000399162000116565b6001600160a01b0381166080526001600055604051620000599062000108565b604051809103906000f08015801562000076573d6000803e3d6000fd5b50600180546001600160a01b0319166001600160a01b0392909216919091179055504260a0526201518060c05269021e19e0c9bab24000006002819055600080527fd2ac945fcc0096878c763e37d6929b78378c1a2defabde8ba7ee5ed1d6e7a5b281905560186020527f999d26de3473317ead3eeaf34ca78057f1439db67b6953469c3c96ce9caf6bd75562000148565b6114ee806200308f83390190565b6000602082840312156200012957600080fd5b81516001600160a01b03811681146200014157600080fd5b9392505050565b60805160a05160c051612f026200018d600039600081816103f401526118180152600081816105ab015261183c01526000818161048b0152611b4d0152612f026000f3fe6080604052600436106102885760003560e01c80639986314b1161015a578063c4235ae9116100c1578063e60c90c41161007a578063e60c90c41461089e578063ed725e83146108cb578063ef4cadc5146108f8578063f1b371e21461091b578063fa845ca914610931578063fd967f471461095e57600080fd5b8063c4235ae9146107c0578063ce96c0af146107ed578063d294f0931461081a578063d4432e4e1461082f578063db80a28c14610845578063dd23a9bd1461087157600080fd5b8063adc0f68611610113578063adc0f686146106ee578063bab2f5521461071b578063bc71329014610731578063be26ed7f1461075e578063bebc9dfc14610773578063c3d2c355146107a057600080fd5b80639986314b146105f9578063a3d6f9a914610626578063a694fc3a14610653578063a707140b14610673578063a95f1dac146106a0578063aabbb1bd146106b657600080fd5b8063549af694116101fe57806369ec283e116101b757806369ec283e1461053957806374846d9f1461054e5780637d818c23146105615780638bd955631461059957806391b30020146105cd57806398a5db57146105e357600080fd5b8063549af69414610441578063572b6c051461046e5780635730c8fd146104cb5780635f5080b4146104f8578063654773cd1461050e57806368f057691461052357600080fd5b80631fcd6ca9116102505780631fcd6ca91461037d578063224438d1146103aa5780632e17de78146103c05780632f7cdab0146103e2578063372500ab14610416578063436091c11461042b57600080fd5b80630b4501fd1461028d5780630ece2154146102bb57806313e65890146102f6578063143a1766146103235780631ed6380f14610350575b600080fd5b34801561029957600080fd5b506102a36103e881565b60405161ffff90911681526020015b60405180910390f35b3480156102c757600080fd5b506102e86102d6366004612a76565b601b6020526000908152604090205481565b6040519081526020016102b2565b34801561030257600080fd5b506102e8610311366004612a76565b60106020526000908152604090205481565b34801561032f57600080fd5b506102e861033e366004612aab565b60176020526000908152604090205481565b34801561035c57600080fd5b506102e861036b366004612aab565b601e6020526000908152604090205481565b34801561038957600080fd5b506102e8610398366004612aab565b600e6020526000908152604090205481565b3480156103b657600080fd5b506102e8600a5481565b3480156103cc57600080fd5b506103e06103db366004612a76565b610974565b005b3480156103ee57600080fd5b506102e87f000000000000000000000000000000000000000000000000000000000000000081565b34801561042257600080fd5b506103e0610c28565b34801561043757600080fd5b506102e860065481565b34801561044d57600080fd5b506102e861045c366004612aab565b600f6020526000908152604090205481565b34801561047a57600080fd5b506104bb610489366004612aab565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60405190151581526020016102b2565b3480156104d757600080fd5b506102e86104e6366004612aab565b600d6020526000908152604090205481565b34801561050457600080fd5b506102e860075481565b34801561051a57600080fd5b506103e0610e79565b34801561052f57600080fd5b506102e860095481565b34801561054557600080fd5b506103e0610fcd565b6103e061055c366004612c1e565b6111ce565b34801561056d57600080fd5b50600154610581906001600160a01b031681565b6040516001600160a01b0390911681526020016102b2565b3480156105a557600080fd5b506102e87f000000000000000000000000000000000000000000000000000000000000000081565b3480156105d957600080fd5b506102e860025481565b3480156105ef57600080fd5b506102e8600b5481565b34801561060557600080fd5b506102e8610614366004612aab565b60126020526000908152604090205481565b34801561063257600080fd5b506102e8610641366004612aab565b600c6020526000908152604090205481565b34801561065f57600080fd5b506103e061066e366004612a76565b611518565b34801561067f57600080fd5b506102e861068e366004612aab565b601a6020526000908152604090205481565b3480156106ac57600080fd5b506102e860035481565b3480156106c257600080fd5b506102e86106d1366004612d00565b601d60209081526000928352604080842090915290825290205481565b3480156106fa57600080fd5b506102e8610709366004612a76565b60186020526000908152604090205481565b34801561072757600080fd5b506102e860055481565b34801561073d57600080fd5b506102e861074c366004612aab565b60166020526000908152604090205481565b34801561076a57600080fd5b506102e8611814565b34801561077f57600080fd5b506102e861078e366004612a76565b601c6020526000908152604090205481565b3480156107ac57600080fd5b506103e06107bb366004612a76565b611870565b3480156107cc57600080fd5b506102e86107db366004612a76565b60196020526000908152604090205481565b3480156107f957600080fd5b506102e8610808366004612aab565b60136020526000908152604090205481565b34801561082657600080fd5b506103e06118d8565b34801561083b57600080fd5b506102e860045481565b34801561085157600080fd5b506102e8610860366004612aab565b602080526000908152604090205481565b34801561087d57600080fd5b506102e861088c366004612aab565b60146020526000908152604090205481565b3480156108aa57600080fd5b506102e86108b9366004612aab565b601f6020526000908152604090205481565b3480156108d757600080fd5b506102e86108e6366004612aab565b60156020526000908152604090205481565b34801561090457600080fd5b506102e86b1d6329f1c35ca4bfabb9f56160281b81565b34801561092757600080fd5b506102e860085481565b34801561093d57600080fd5b506102e861094c366004612aab565b60116020526000908152604090205481565b34801561096a57600080fd5b506102a361271081565b60026000540361099f5760405162461bcd60e51b815260040161099690612d2a565b60405180910390fd5b60026000556109ac6119e7565b6109b4611a06565b6109c46109bf611b49565b611b8d565b600081116109e45760405162461bcd60e51b815260040161099690612d61565b601e60006109f0611b49565b6001600160a01b03166001600160a01b0316815260200190815260200160002054811115610a765760405162461bcd60e51b815260206004820152602d60248201527f44656230783a20616d6f756e742067726561746572207468616e20776974686460448201526c72617761626c65207374616b6560981b6064820152608401610996565b60085460065403610a9e578060096000828254610a939190612da6565b90915550610ac59050565b60055460009081526019602052604081208054839290610abf908490612db9565b90915550505b80601e6000610ad2611b49565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610b019190612db9565b9091555081905060156000610b14611b49565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610b439190612db9565b90915550506001546001600160a01b031663a9059cbb610b61611b49565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015610bae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd29190612dcc565b50610bdb611b49565b6001600160a01b03166005547f37375b03d8924bd8f076f11f8411b9962aa5c02fb489021507bc6bb6f850e36583604051610c1891815260200190565b60405180910390a3506001600055565b600260005403610c4a5760405162461bcd60e51b815260040161099690612d2a565b6002600055610c576119e7565b610c5f611a06565b610c6a6109bf611b49565b6000601e6000610c78611b49565b6001600160a01b03166001600160a01b031681526020019081526020016000205460156000610ca5611b49565b6001600160a01b03166001600160a01b0316815260200190815260200160002054610cd09190612db9565b905060008111610d225760405162461bcd60e51b815260206004820152601d60248201527f44656230783a206163636f756e7420686173206e6f20726577617264730000006044820152606401610996565b8060156000610d2f611b49565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610d5e9190612db9565b909155505060085460065403610d8b578060096000828254610d809190612da6565b90915550610dbb9050565b600554600090815260196020526040902054610da8908290612db9565b6005546000908152601960205260409020555b6001546001600160a01b0316639a49090e610dd4611b49565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015610e1c57600080fd5b505af1158015610e30573d6000803e3d6000fd5b50505050610e3c611b49565b6001600160a01b03166005547f3300bdb359cfb956935bca32e9db727413eab1ca84341f2e36caea85bb79696883604051610c1891815260200190565b600260005403610e9b5760405162461bcd60e51b815260040161099690612d2a565b6002600055610ea86119e7565b610eb0611a06565b610ec0610ebb611b49565b6121ae565b600060146000610ece611b49565b6001600160a01b03166001600160a01b0316815260200190815260200160002054905060008111610f4b5760405162461bcd60e51b815260206004820152602160248201527f44656230783a20636c69656e7420686173206e6f2061636372756564206665656044820152607360f81b6064820152608401610996565b600060146000610f59611b49565b6001600160a01b03168152602081019190915260400160002055610f84610f7e611b49565b826123e8565b610f8c611b49565b6001600160a01b0316610f9d611814565b6040518381527f71080b6b70140bab68812ff30dd24dd3f4fafdb253085461fcc624ab5f1bbe9b90602001610c18565b600260005403610fef5760405162461bcd60e51b815260040161099690612d2a565b6002600055610ffc6119e7565b611004611a06565b61100f610ebb611b49565b60006017600061101d611b49565b6001600160a01b03166001600160a01b03168152602001908152602001600020549050600081116110905760405162461bcd60e51b815260206004820152601c60248201527f44656230783a20636c69656e7420686173206e6f2072657761726473000000006044820152606401610996565b60006017600061109e611b49565b6001600160a01b03168152602081019190915260400160002055600854600654036110e05780600960008282546110d59190612da6565b909155506111109050565b6005546000908152601960205260409020546110fd908290612db9565b6005546000908152601960205260409020555b6001546001600160a01b0316639a49090e611129611b49565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b15801561117157600080fd5b505af1158015611185573d6000803e3d6000fd5b50505050611191611b49565b6001600160a01b03166005547f73d4ecbe623e0c89f3cfb75a853104d35d1105e8ec5f0ec6e4bb924da1ffb29283604051610c1891815260200190565b6002600054036111f05760405162461bcd60e51b815260040161099690612d2a565b6002600090815581905a9050848460005a90506127108711156112615760405162461bcd60e51b815260206004820152602360248201527f44656230783a207265776172642066656573206578636565642031303030302060448201526262707360e81b6064820152608401610996565b600061126d8b8b612490565b90506112776119e7565b61127f611a06565b61128761291a565b6112926109bf611b49565b61129b896121ae565b600554601160006112aa611b49565b6001600160a01b03166001600160a01b0316815260200190815260200160002081905550886001600160a01b0316816005547f6288811d8cdbed319ad675bb04053011e25d30480e6eb483c02d54ef3bc863f18b8b604051611316929190918252602082015260400190565b60405180910390a45060005a61132c9083612db9565b90508060106000600554815260200190815260200160002060008282546113539190612da6565b90915550506001600160a01b0384161580159061136f57508215155b156113cd5760006127106113838584612dee565b61138d9190612e05565b90506113998183612db9565b6001600160a01b0386166000908152600e60205260408120805492945083929091906113c6908490612da6565b9091555050505b80600f60006113da611b49565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546114099190612da6565b909155506000945061271093506103e892503a9150505a61142a9086612db9565b61143690619b14612da6565b6114409190612dee565b61144a9190612dee565b6114549190612e05565b9050806114618434612db9565b10156114c45760405162461bcd60e51b815260206004820152602c60248201527f44656230783a2076616c7565206c657373207468616e2072657175697265642060448201526b70726f746f636f6c2066656560a01b6064820152608401610996565b6005546000908152601b6020526040812080548392906114e5908490612da6565b90915550611509905033846114fa8434612db9565b6115049190612db9565b6123e8565b50506001600055505050505050565b60026000540361153a5760405162461bcd60e51b815260040161099690612d2a565b60026000556115476119e7565b61154f611a06565b61155a6109bf611b49565b6000811161157a5760405162461bcd60e51b815260040161099690612d61565b806004600082825461158c9190612da6565b90915550506005546000906115a2906001612da6565b9050600854600654036115b457506005545b601f60006115c0611b49565b6001600160a01b03166001600160a01b0316815260200190815260200160002054811415801561161c5750602060006115f7611b49565b6001600160a01b03166001600160a01b03168152602001908152602001600020548114155b156116dd57601f600061162d611b49565b6001600160a01b03166001600160a01b03168152602001908152602001600020546000036116815780601f6000611662611b49565b6001600160a01b031681526020810191909152604001600020556116dd565b6020600061168d611b49565b6001600160a01b03166001600160a01b03168152602001908152602001600020546000036116dd5780602060006116c2611b49565b6001600160a01b031681526020810191909152604001600020555b81601d60006116ea611b49565b6001600160a01b03166001600160a01b031681526020019081526020016000206000838152602001908152602001600020600082825461172a9190612da6565b90915550506001546001600160a01b03166323b872dd611748611b49565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152306024820152604481018590526064016020604051808303816000875af115801561179b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117bf9190612dcc565b506117c8611b49565b6001600160a01b0316817f18dcd430020e4d4899772fd94a8b40451dc5044dfb70bc46b532eeae431c864f8460405161180391815260200190565b60405180910390a350506001600055565b60007f00000000000000000000000000000000000000000000000000000000000000006118617f000000000000000000000000000000000000000000000000000000000000000042612db9565b61186b9190612e05565b905090565b80600c600061187d611b49565b6001600160a01b03168152602081019190915260400160002055806118a0611b49565b6001600160a01b03167f8e06b8416b712e88dc5bdfc009fcc4de46c26bf894cd73d9a855ceb8170ea78d60405160405180910390a350565b6002600054036118fa5760405162461bcd60e51b815260040161099690612d2a565b60026000556119076119e7565b61190f611a06565b61191a6109bf611b49565b600060166000611928611b49565b6001600160a01b03166001600160a01b031681526020019081526020016000205490506000811161196b5760405162461bcd60e51b815260040161099690612d61565b600060166000611979611b49565b6001600160a01b0316815260208101919091526040016000205561199e610f7e611b49565b6119a6611b49565b6001600160a01b03166119b7611814565b6040518381527f2227733fc4c8a9034cb58087dcf6995128b9c0233b038b03366aaf30c92b92d690602001610c18565b60006119f1611814565b9050600554811115611a035760058190555b50565b60085460055414611a2957600654611a1f906001612da6565b6007556008546006555b600654600554118015611a5d5750601c60006006546001611a4a9190612da6565b8152602001908152602001600020546000145b15611b475760065460009081526019602052604081205415611ad357600654600090815260196020908152604080832054600a54601b9093529220546b1d6329f1c35ca4bfabb9f56160281b91611ab391612da6565b611abd9190612dee565b611ac79190612e05565b6000600a559050611b04565b601b6000600654815260200190815260200160002054600a6000828254611afa9190612da6565b9091555060009150505b6007546000908152601c6020526040902054611b21908290612da6565b601c60006006546001611b349190612da6565b8152602081019190915260400160002055505b565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303611b88575060131936013560601c90565b503390565b6001600160a01b038116600090815260116020526040902054600554118015611bcd57506001600160a01b0381166000908152600f602052604090205415155b15611c70576001600160a01b038116600081815260116020908152604080832054835260108252808320546018835281842054948452600f90925282205491929091611c199190612dee565b611c239190612e05565b6001600160a01b038316600090815260156020526040812080549293508392909190611c50908490612da6565b9091555050506001600160a01b0381166000908152600f60205260408120555b600654600554118015611ca85750600654611c8c906001612da6565b6001600160a01b0382166000908152601a602052604090205414155b15611da1576001600160a01b0381166000908152601a60209081526040808320548352601c918290528220546006546b1d6329f1c35ca4bfabb9f56160281b9391929190611cf7906001612da6565b815260200190815260200160002054611d109190612db9565b6001600160a01b038316600090815260156020526040902054611d339190612dee565b611d3d9190612e05565b6001600160a01b038216600090815260166020526040902054611d609190612da6565b6001600160a01b038216600090815260166020526040902055600654611d87906001612da6565b6001600160a01b0382166000908152601a60205260409020555b6001600160a01b0381166000908152601f602052604090205415801590611de157506001600160a01b0381166000908152601f6020526040902054600554115b15611a03576001600160a01b0381166000818152601d60209081526040808320601f8352818420548452825280832054938352601590915281208054839290611e2b908490612da6565b90915550506001600160a01b0382166000908152601e602052604081208054839290611e58908490612da6565b90915550506001600160a01b0382166000908152601f6020526040902054600654611e84906001612da6565b1115611f69576001600160a01b0382166000908152601f60209081526040808320548352601c918290528220546006546b1d6329f1c35ca4bfabb9f56160281b9391929190611ed4906001612da6565b815260200190815260200160002054611eed9190612db9565b6001600160a01b0384166000908152601d60209081526040808320601f8352818420548452909152902054611f229190612dee565b611f2c9190612e05565b6001600160a01b038316600090815260166020526040902054611f4f9190612da6565b6001600160a01b0383166000908152601660205260409020555b6001600160a01b0382166000818152601d60209081526040808320601f8352818420805485529083528184208490559383529282905580522054156121aa576001600160a01b0382166000908152602080526040902054600554111561217f576001600160a01b0382166000818152601d6020908152604080832082805281842054845282528083205493835260159091528120805483929061200d908490612da6565b90915550506001600160a01b0383166000908152601e60205260408120805483929061203a908490612da6565b90915550506001600160a01b0383166000908152602080526040902054600654612065906001612da6565b1115612147576001600160a01b038316600090815260208080526040808320548352601c918290528220546006546b1d6329f1c35ca4bfabb9f56160281b93919291906120b3906001612da6565b8152602001908152602001600020546120cc9190612db9565b6001600160a01b0385166000908152601d602090815260408083208280528184205484529091529020546121009190612dee565b61210a9190612e05565b6001600160a01b03841660009081526016602052604090205461212d9190612da6565b6001600160a01b0384166000908152601660205260409020555b50506001600160a01b03166000818152601d602090815260408083208280528184208054855290835290832083905592825280529055565b6001600160a01b0382166000908152602080805260408083208054601f845291842091909155908052555b5050565b6001600160a01b03811660009081526012602052604090205460055411156122c4576001600160a01b038116600090815260126020908152604080832054600e9092529091205415801590612210575060008181526010602052604090205415155b156122a65760008181526010602090815260408083205460188352818420546001600160a01b0387168552600e90935290832054909161224f91612dee565b6122599190612e05565b6001600160a01b038416600090815260176020526040812080549293508392909190612286908490612da6565b9091555050506001600160a01b0382166000908152600e60205260408120555b506005546001600160a01b0382166000908152601260205260409020555b6006546005541180156122fc57506006546122e0906001612da6565b6001600160a01b03821660009081526013602052604090205414155b15611a03576001600160a01b0381166000908152601360209081526040808320548352601c918290528220546006546b1d6329f1c35ca4bfabb9f56160281b939192919061234b906001612da6565b8152602001908152602001600020546123649190612db9565b6001600160a01b0383166000908152601760205260409020546123879190612dee565b6123919190612e05565b6001600160a01b038216600090815260146020526040812080549091906123b9908490612da6565b90915550506006546123cc906001612da6565b6001600160a01b03821660009081526013602052604090205550565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612435576040519150601f19603f3d011682016040523d82523d6000602084013e61243a565b606091505b505090508061248b5760405162461bcd60e51b815260206004820152601c60248201527f44656230783a206661696c656420746f2073656e6420616d6f756e74000000006044820152606401610996565b505050565b600081518351146124f95760405162461bcd60e51b815260206004820152602d60248201527f44656230783a20637265667320616e6420726563697069656e7473206c656e6760448201526c1d1a1cc81b9bdd08195c5d585b609a1b6064820152608401610996565b600083511161254a5760405162461bcd60e51b815260206004820152601d60248201527f44656230783a20726563697069656e747320617272617920656d7074790000006044820152606401610996565b60005b6001845161255b9190612db9565b81101561264e57600083600186516125739190612db9565b8151811061258357612583612e27565b602002602001015151116125cd5760405162461bcd60e51b81526020600482015260116024820152702232b1183c1d1032b6b83a3c9031b932b360791b6044820152606401610996565b600883600186516125de9190612db9565b815181106125ee576125ee612e27565b602002602001015151111561263c5760405162461bcd60e51b815260206004820152601460248201527344656230783a206372656620746f6f206c6f6e6760601b6044820152606401610996565b8061264681612e3d565b91505061254d565b5060005b600184516126609190612db9565b81101561274957600083828151811061267b5761267b612e27565b60200260200101516040516020016126939190612e91565b604051602081830303815290604052805190602001209050806126b4611b49565b6001600160a01b03168684815181106126cf576126cf612e27565b60200260200101516001600160a01b03167fa33bc9a10d8f3a335b59663beb6a02681748ac0b3db1251c7bb08f3e99dd0bb4600b544289888151811061271757612717612e27565b602002602001015160405161272e93929190612ea4565b60405180910390a4508061274181612e3d565b915050612652565b506000826001855161275b9190612db9565b8151811061276b5761276b612e27565b60200260200101516040516020016127839190612e91565b604051602081830303815290604052805190602001209050600083600186516127ac9190612db9565b815181106127bc576127bc612e27565b602002602001015151116128065760405162461bcd60e51b81526020600482015260116024820152702232b1183c1d1032b6b83a3c9031b932b360791b6044820152606401610996565b600883600186516128179190612db9565b8151811061282757612827612e27565b60200260200101515111156128755760405162461bcd60e51b815260206004820152601460248201527344656230783a206372656620746f6f206c6f6e6760601b6044820152606401610996565b600b8054908190600061288783612e3d565b919050555081612895611b49565b6001600160a01b03166128a6611b49565b6001600160a01b03167fa33bc9a10d8f3a335b59663beb6a02681748ac0b3db1251c7bb08f3e99dd0bb484428960018c516128e19190612db9565b815181106128f1576128f1612e27565b602002602001015160405161290893929190612ea4565b60405180910390a49150505b92915050565b6005546000908152601860205260408120549003611b475760025460038190556000906127249061294d90612710612dee565b6129579190612e05565b600281905560058054600090815260186020908152604080832085905592546008556006548252601990522054909150612992908290612da6565b600854600090815260196020526040812080549091906129b3908490612da6565b9091555050600454156129ef57600454600854600090815260196020526040812080549091906129e4908490612da6565b909155505060006004555b60095415612a265760095460085460009081526019602052604081208054909190612a1b908490612db9565b909155505060006009555b600554600854600090815260196020908152604091829020548251858152918201527f0666a61c1092f5b86c2cfe6ea1ad0d9a36032c4fb92d285b4e43f662d48f19b4910160405180910390a250565b600060208284031215612a8857600080fd5b5035919050565b80356001600160a01b0381168114612aa657600080fd5b919050565b600060208284031215612abd57600080fd5b612ac682612a8f565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612b0c57612b0c612acd565b604052919050565b600067ffffffffffffffff821115612b2e57612b2e612acd565b5060051b60200190565b600082601f830112612b4957600080fd5b81356020612b5e612b5983612b14565b612ae3565b828152600592831b8501820192828201919087851115612b7d57600080fd5b8387015b85811015612c1157803567ffffffffffffffff811115612ba15760008081fd5b8801603f81018a13612bb35760008081fd5b858101356040612bc5612b5983612b14565b82815291851b8301810191888101908d841115612be25760008081fd5b938201935b83851015612c0057843582529389019390890190612be7565b885250505093850193508401612b81565b5090979650505050505050565b600080600080600060a08688031215612c3657600080fd5b853567ffffffffffffffff80821115612c4e57600080fd5b818801915088601f830112612c6257600080fd5b81356020612c72612b5983612b14565b82815260059290921b8401810191818101908c841115612c9157600080fd5b948201945b83861015612cb657612ca786612a8f565b82529482019490820190612c96565b99505089013592505080821115612ccc57600080fd5b50612cd988828901612b38565b945050612ce860408701612a8f565b94979396509394606081013594506080013592915050565b60008060408385031215612d1357600080fd5b612d1c83612a8f565b946020939093013593505050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526015908201527444656230783a20616d6f756e74206973207a65726f60581b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561291457612914612d90565b8181038181111561291457612914612d90565b600060208284031215612dde57600080fd5b81518015158114612ac657600080fd5b808202811582820484141761291457612914612d90565b600082612e2257634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b600060018201612e4f57612e4f612d90565b5060010190565b600081518084526020808501945080840160005b83811015612e8657815187529582019590820190600101612e6a565b509495945050505050565b602081526000612ac66020830184612e56565b838152826020820152606060408201526000612ec36060830184612e56565b9594505050505056fea2646970667358221220ee06594c5c9c58674e35af899ec0bdfeee7b1cbaaf46277f290475705c292a1664736f6c634300081100336101606040523480156200001257600080fd5b506040518060400160405280601d81526020017f44656230782052657761726420546f6b656e206f6e20506f6c79676f6e00000081525080604051806040016040528060018152602001603160f81b8152506040518060400160405280601d81526020017f44656230782052657761726420546f6b656e206f6e20506f6c79676f6e000000815250604051806040016040528060048152602001630e08884b60e31b8152508160039081620000c891906200021a565b506004620000d782826200021a565b5050825160209384012082519284019290922060e08390526101008190524660a0818152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818901819052818301979097526060810194909452608080850193909352308483018190528151808603909301835260c0948501909152815191909601209052929092526101205250503361014052620002e6565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001a057607f821691505b602082108103620001c157634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200021557600081815260208120601f850160051c81016020861015620001f05750805b601f850160051c820191505b818110156200021157828155600101620001fc565b5050505b505050565b81516001600160401b0381111562000236576200023662000175565b6200024e816200024784546200018b565b84620001c7565b602080601f8311600181146200028657600084156200026d5750858301515b600019600386901b1c1916600185901b17855562000211565b600085815260208120601f198616915b82811015620002b75788860151825594840194600190910190840162000296565b5085821015620002d65787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516101005161012051610140516111a662000348600039600081816101d601526103b201526000610aad01526000610afc01526000610ad701526000610a3001526000610a5a01526000610a8401526111a66000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80637ecebe0011610097578063a457c2d711610066578063a457c2d71461022d578063a9059cbb14610240578063d505accf14610253578063dd62ed3e1461026657600080fd5b80637ecebe00146101be5780638da5cb5b146101d157806395d89b41146102105780639a49090e1461021857600080fd5b8063313ce567116100d3578063313ce5671461016b5780633644e5151461017a578063395093511461018257806370a082311461019557600080fd5b806306fdde0314610105578063095ea7b31461012357806318160ddd1461014657806323b872dd14610158575b600080fd5b61010d610279565b60405161011a9190610f6d565b60405180910390f35b610136610131366004610fd7565b61030b565b604051901515815260200161011a565b6002545b60405190815260200161011a565b610136610166366004611001565b610325565b6040516012815260200161011a565b61014a610349565b610136610190366004610fd7565b610358565b61014a6101a336600461103d565b6001600160a01b031660009081526020819052604090205490565b61014a6101cc36600461103d565b61037a565b6101f87f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161011a565b61010d610398565b61022b610226366004610fd7565b6103a7565b005b61013661023b366004610fd7565b61049f565b61013661024e366004610fd7565b61051a565b61022b61026136600461105f565b610528565b61014a6102743660046110d2565b61068c565b60606003805461028890611105565b80601f01602080910402602001604051908101604052809291908181526020018280546102b490611105565b80156103015780601f106102d657610100808354040283529160200191610301565b820191906000526020600020905b8154815290600101906020018083116102e457829003601f168201915b5050505050905090565b6000336103198185856106b7565b60019150505b92915050565b6000336103338582856107db565b61033e858585610855565b506001949350505050565b6000610353610a23565b905090565b60003361031981858561036b838361068c565b6103759190611139565b6106b7565b6001600160a01b03811660009081526005602052604081205461031f565b60606004805461028890611105565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461042f5760405162461bcd60e51b815260206004820152602260248201527f4442583a2063616c6c6572206973206e6f7420446562307820636f6e747261636044820152613a1760f11b60648201526084015b60405180910390fd5b6a0424e8a4eaca5ed740000061044460025490565b106104915760405162461bcd60e51b815260206004820152601e60248201527f4442583a206d617820737570706c7920616c7265616479206d696e74656400006044820152606401610426565b61049b8282610b4a565b5050565b600033816104ad828661068c565b90508381101561050d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610426565b61033e82868684036106b7565b600033610319818585610855565b834211156105785760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610426565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886105a78c610c29565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061060282610c51565b9050600061061282878787610c9f565b9050896001600160a01b0316816001600160a01b0316146106755760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610426565b6106808a8a8a6106b7565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166107195760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610426565b6001600160a01b03821661077a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610426565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006107e7848461068c565b9050600019811461084f57818110156108425760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610426565b61084f84848484036106b7565b50505050565b6001600160a01b0383166108b95760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610426565b6001600160a01b03821661091b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610426565b6001600160a01b038316600090815260208190526040902054818110156109935760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610426565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906109ca908490611139565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a1691815260200190565b60405180910390a361084f565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610a7c57507f000000000000000000000000000000000000000000000000000000000000000046145b15610aa657507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6001600160a01b038216610ba05760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610426565b8060026000828254610bb29190611139565b90915550506001600160a01b03821660009081526020819052604081208054839290610bdf908490611139565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b600061031f610c5e610a23565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000610cb087878787610cc7565b91509150610cbd81610db4565b5095945050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610cfe5750600090506003610dab565b8460ff16601b14158015610d1657508460ff16601c14155b15610d275750600090506004610dab565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d7b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610da457600060019250925050610dab565b9150600090505b94509492505050565b6000816004811115610dc857610dc861115a565b03610dd05750565b6001816004811115610de457610de461115a565b03610e315760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610426565b6002816004811115610e4557610e4561115a565b03610e925760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610426565b6003816004811115610ea657610ea661115a565b03610efe5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610426565b6004816004811115610f1257610f1261115a565b03610f6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610426565b50565b600060208083528351808285015260005b81811015610f9a57858101830151858201604001528201610f7e565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610fd257600080fd5b919050565b60008060408385031215610fea57600080fd5b610ff383610fbb565b946020939093013593505050565b60008060006060848603121561101657600080fd5b61101f84610fbb565b925061102d60208501610fbb565b9150604084013590509250925092565b60006020828403121561104f57600080fd5b61105882610fbb565b9392505050565b600080600080600080600060e0888a03121561107a57600080fd5b61108388610fbb565b965061109160208901610fbb565b95506040880135945060608801359350608088013560ff811681146110b557600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156110e557600080fd5b6110ee83610fbb565b91506110fc60208401610fbb565b90509250929050565b600181811c9082168061111957607f821691505b602082108103610c4b57634e487b7160e01b600052602260045260246000fd5b8082018082111561031f57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fdfea2646970667358221220d0a4727cb921f52cc313f42f491fa3949c6a96b4ace4d342a8c451a34016e7c564736f6c634300081100330000000000000000000000008f94c0193c3c63eff990ac386b855a396750032f

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000008f94c0193c3c63eff990ac386b855a396750032f

-----Decoded View---------------
Arg [0] : forwarder (address): 0x8f94c0193c3c63eff990ac386b855a396750032f

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000008f94c0193c3c63eff990ac386b855a396750032f


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