Contract 0x952bda8a83c3d5f398a686bb4e8c6dd90072d523 3

Txn Hash Method
Block
From
To
Value [Txn Fee]
0xa43a4eb2662e6dbae4a9bd5a0b882cbd44b6a7f60b6a886aa54187e47153b4caSwap203621752021-10-28 15:07:0136 mins ago0x1f783649a4fb84d0ae1f9ab2269105419bf1417b IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.086355474904
0x84965350bc53564cef1282738aa7e1be7a64fe5586a58abfa3192b2d5d5cffe9Swap203433402021-10-28 10:16:015 hrs 27 mins ago0xdd9129dab356ccb6cdea8b2fc2b27a9d14304dd9 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.104673832226
0x7d806e6d4f6e7f2725d82cb9cf0c5082e2fc970c903cebb6df0609f820d9d378Remove Liquidity...203417132021-10-28 9:53:285 hrs 50 mins ago0x9083b9d320019890dd3c52a10ba7d7cad78a107f IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.04598861459
0x8b6a5edd3b188a9849dd39c222ceb9a0d9c190232b8d3eb477dc50cf633cd88fSwap203399092021-10-28 9:27:486 hrs 15 mins ago0x9ce72293722be9d2bd15bd6f6456b3f018f4be14 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.026204141662
0x6dd7dc96a7c87d6132c9f834b424f3d834210c1313d1261d1487d30f9463eff9Swap203393372021-10-28 9:20:006 hrs 23 mins ago0x9ce72293722be9d2bd15bd6f6456b3f018f4be14 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.02880376232
0x9842d41914458107dbc609243d18e04d0ef8528d44eb82f04dcb17d25a982862Add Liquidity203391852021-10-28 9:17:336 hrs 26 mins ago0x0553aeaaa787ca5bbca6e172d3fde33957ff4b91 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.059882274858
0x12f54630fc6b530b461503dc8211712dfe23d7e923ae972eaa2ecb8e3fe85562Swap203386402021-10-28 9:09:356 hrs 34 mins ago0x9ce72293722be9d2bd15bd6f6456b3f018f4be14 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.025976545072
0xe26ab1b0004e65d7f1f510636369c00b044272ad5178c9a972f0156f7f9dcf32Add Liquidity203262872021-10-28 6:05:219 hrs 38 mins ago0xf5a8f71137041bf4851249e721bfa1bcaa7e657b IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.080128350868
0x86b6bb9b844f78537d3e703741822e717277b2e5c2d5223fd988ec1abe670d60Swap203220262021-10-28 4:59:5910 hrs 43 mins ago0x7f5d7e00d82dfeb7e83a0d4285cb21b31feab2b4 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.031709972306
0xde0ec22f4e8f69f80f01ccd7ec161193812fc1228edf9b74f5d639e582839e3bSwap203215392021-10-28 4:52:1910 hrs 51 mins ago0x7f5d7e00d82dfeb7e83a0d4285cb21b31feab2b4 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.029024914009
0xb5bc9d76274418757440a70139167578cf4d3cc99690251934a633bd81a571a6Add Liquidity203214002021-10-28 4:50:2110 hrs 53 mins ago0xd42b63493e0c7ab1879adbc134e8a07eaa999d3e IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.084672670816
0x49d02af868dc5fadfeea37c9f542e36095cdec2cf16a0507c6760a50a81c3fa9Swap202985432021-10-27 23:10:0916 hrs 33 mins ago0x31f28f27d653dd4fcc9ca3b29eb17993328cbc15 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.022146359013
0xf7cc903e6164e378534ec8bd0d88d0cde920a92aafc779900e31a41f34b33ee7Remove Liquidity...202960382021-10-27 22:33:3217 hrs 10 mins ago0x4a289853eaae3f377c0ae3b72a86cc7a50064367 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.053992485981
0x25a3e6c0a43e73eae538d67a388477dad0674cac65c33822b8873de66edf0a37Add Liquidity202851142021-10-27 20:04:3819 hrs 39 mins ago0x383dc52b03c01b294d6f6e1d453b8d6b3f30ae02 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.11304910686
0x85facd58acf8d81ce310672f95f093912d4221b03829a8ac17a8aa2da98cf001Remove Liquidity...202836432021-10-27 19:42:4320 hrs 1 min ago0x383dc52b03c01b294d6f6e1d453b8d6b3f30ae02 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.107864645172
0xd722a09431e7eb9f2ed4c78a626751e35065262bc0f31aaa61d8ae54c89aedb8Swap202836312021-10-27 19:42:2420 hrs 1 min ago0xdd9129dab356ccb6cdea8b2fc2b27a9d14304dd9 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.051996713275
0xd8c08303450acf35fa32b0fe3a939370611e0b1f5f37492c6dd2cb0f9fb4720eRemove Liquidity...202823252021-10-27 19:21:0020 hrs 22 mins ago0x383dc52b03c01b294d6f6e1d453b8d6b3f30ae02 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.071883425022
0x1dae8a91fe6140f977981e059f83f5afb2d11c1fb4309f5a4c64fcaab988392cSwap202821472021-10-27 19:18:3320 hrs 25 mins ago0x57b0266f2836f5244f5906d62486fe93d5fa210b IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.0379247466
0x5b9abc0844ac5397f2018330ab19d6c84c5a27df4166ec80357e0bc5691ae45aRemove Liquidity...202809802021-10-27 19:02:5320 hrs 40 mins ago0x383dc52b03c01b294d6f6e1d453b8d6b3f30ae02 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.079239960785
0x88e2459428e600f5b251722373ec2fcccf0fa3ddc0a59ccc6df564e22bdc2925Remove Liquidity...202808242021-10-27 19:00:5320 hrs 42 mins ago0x383dc52b03c01b294d6f6e1d453b8d6b3f30ae02 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.088234451525
0x07adc49c3d6c86a1dd2368d78e7314c67da4b75d9fbda7468da2f8b2408fb90dSwap202794312021-10-27 18:42:0521 hrs 1 min ago0x31f28f27d653dd4fcc9ca3b29eb17993328cbc15 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.043599967862
0x3f5ccfb7309f57f97176c207301b1e27af4833ab1e9b4b511a2ffff18297f0a6Swap202760102021-10-27 17:54:0021 hrs 49 mins ago0xc896e266368d3eb26219c5cc74a4941339218d86 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.040574181359
0xd7ec4b128f27459bb325360223c0dcf3b5d0f5b719c2cfe059a803abaabbf316Swap202731102021-10-27 17:13:4122 hrs 30 mins ago0xcb386c078d9a5c8252e95b68e8fb5d78538ff905 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.048852476159
0x6f6945ad703e2d71ae4c7d80ad2ef515d906b49b390ad1169b22a572cf23fc57Add Liquidity202590722021-10-27 13:44:361 day 1 hr ago0x6969c8cabed80cb5b16935523dc7674a166a8e46 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.076571048059
0x86be9fde83fd3c74938c59847465411f2210f519d852b79775511f77cc263b4bSwap202470312021-10-27 10:46:561 day 4 hrs ago0x76be2ebd46e06e471d34275e16f35d9750633ea8 IN  0x952bda8a83c3d5f398a686bb4e8c6dd90072d5230 FTM0.036733148791
[ Download CSV Export 
Latest 2 internal transactions
Parent Txn Hash Block From To Value
0x84ad3c90ae87194358f51ae236461ff646fd5c7f2a55f79f96c88a8c9507d2f0162577402021-09-03 16:17:1754 days 23 hrs ago 0x952bda8a83c3d5f398a686bb4e8c6dd90072d523  Contract Creation0 FTM
0x0fd6a4440ee5ea665abf0e022ed6438e5883c42ecab9b4847d64263f275d4f95162577322021-09-03 16:17:0954 days 23 hrs ago 0x5aebde597752d689132dc64d093ff4b09067e9e6  Contract Creation0 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Similar Match)
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0xaE47B5d1A248bfa345B58F7f4Af334a20fF744c0

Contract Name:
IronSwap

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 16 : IronSwap.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.4;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./base/OwnerPausable.sol";
import "./IronSwapLib.sol";
import "./interfaces/IIronSwap.sol";

contract IronSwap is OwnerPausable, ReentrancyGuard, Initializable, IIronSwap {
    using IronSwapLib for IronSwapLib.SwapStorage;
    using SafeERC20 for IERC20;

    /// constants
    uint256 public constant MIN_RAMP_TIME = 1 days;
    uint256 public constant MAX_A = 1e6; // max_a with precision
    uint256 public constant MAX_A_CHANGE = 10;
    uint256 public constant MAX_ADMIN_FEE = 1e10; // 100%
    uint256 public constant MAX_SWAP_FEE = 1e8; // 1%
    uint256 public constant MAX_WITHDRAW_FEE = 1e8; // 1%

    /// STATE VARS
    IronSwapLib.SwapStorage public swapStorage;
    address public feeDistributor;
    address public feeController;
    mapping(address => uint8) public tokenIndexes;

    modifier deadlineCheck(uint256 _deadline) {
        require(block.timestamp <= _deadline, "timeout");
        _;
    }

    modifier onlyFeeControllerOrOwner() {
        require(msg.sender == feeController || msg.sender == owner(), "!feeControllerOrOwner");
        _;
    }

    function initialize(
        address[] memory _coins,
        uint8[] memory _decimals,
        string memory lpTokenName,
        string memory lpTokenSymbol,
        uint256 _A,
        uint256 _fee,
        uint256 _adminFee,
        uint256 _withdrawFee,
        address _feeDistributor
    ) external onlyOwner initializer {
        require(_coins.length == _decimals.length, "coinsLength != decimalsLength");
        require(_feeDistributor != address(0), "feeDistributor = empty");
        uint256 numberOfCoins = _coins.length;
        uint256[] memory rates = new uint256[](numberOfCoins);
        IERC20[] memory coins = new IERC20[](numberOfCoins);
        for (uint256 i = 0; i < numberOfCoins; i++) {
            require(_coins[i] != address(0), "invalidTokenAddress");
            require(_decimals[i] <= IronSwapLib.POOL_TOKEN_COMMON_DECIMALS, "invalidDecimals");
            rates[i] = 10**(IronSwapLib.POOL_TOKEN_COMMON_DECIMALS - _decimals[i]);
            coins[i] = IERC20(_coins[i]);
            tokenIndexes[address(coins[i])] = uint8(i);
        }

        require(_A < MAX_A, "> maxA");
        require(_fee <= MAX_SWAP_FEE, "> maxSwapFee");
        require(_adminFee <= MAX_ADMIN_FEE, "> maxAdminFee");
        require(_withdrawFee <= MAX_WITHDRAW_FEE, "> maxWithdrawFee");

        swapStorage.lpToken = new LPToken(lpTokenName, lpTokenSymbol);
        swapStorage.balances = new uint256[](numberOfCoins);
        swapStorage.tokenMultipliers = rates;
        swapStorage.pooledTokens = coins;
        swapStorage.initialA = _A * IronSwapLib.A_PRECISION;
        swapStorage.futureA = _A * IronSwapLib.A_PRECISION;
        swapStorage.fee = _fee;
        swapStorage.adminFee = _adminFee;
        swapStorage.defaultWithdrawFee = _withdrawFee;
        feeDistributor = _feeDistributor;
    }

    /// PUBLIC FUNCTIONS
    function addLiquidity(
        uint256[] memory amounts,
        uint256 minMintAmount,
        uint256 deadline
    ) external override whenNotPaused nonReentrant deadlineCheck(deadline) returns (uint256) {
        return swapStorage.addLiquidity(amounts, minMintAmount);
    }

    function swap(
        uint8 fromIndex,
        uint8 toIndex,
        uint256 inAmount,
        uint256 minOutAmount,
        uint256 deadline
    ) external override whenNotPaused nonReentrant deadlineCheck(deadline) returns (uint256) {
        return swapStorage.swap(fromIndex, toIndex, inAmount, minOutAmount);
    }

    function removeLiquidity(
        uint256 lpAmount,
        uint256[] memory minAmounts,
        uint256 deadline
    ) external override nonReentrant deadlineCheck(deadline) returns (uint256[] memory) {
        return swapStorage.removeLiquidity(lpAmount, minAmounts);
    }

    function removeLiquidityOneToken(
        uint256 lpAmount,
        uint8 index,
        uint256 minAmount,
        uint256 deadline
    ) external override nonReentrant whenNotPaused deadlineCheck(deadline) returns (uint256) {
        return swapStorage.removeLiquidityOneToken(lpAmount, index, minAmount);
    }

    function removeLiquidityImbalance(
        uint256[] memory amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external override nonReentrant whenNotPaused deadlineCheck(deadline) returns (uint256) {
        return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);
    }

    /// VIEW FUNCTIONS

    function getVirtualPrice() external view override returns (uint256) {
        return swapStorage.getVirtualPrice();
    }

    function getA() external view override returns (uint256) {
        return swapStorage.getA();
    }

    function getAPrecise() external view override returns (uint256) {
        return swapStorage.getAPrecise();
    }

    function getTokens() external view override returns (IERC20[] memory) {
        return swapStorage.pooledTokens;
    }

    function getToken(uint8 index) external view override returns (IERC20) {
        return swapStorage.pooledTokens[index];
    }

    function getLpToken() external view override returns (IERC20) {
        return swapStorage.lpToken;
    }

    function getTokenIndex(address token) external view override returns (uint8 index) {
        index = tokenIndexes[token];
        require(address(swapStorage.pooledTokens[index]) == token, "tokenNotFound");
    }

    function getTokenPrecisionMultipliers() external view returns (uint256[] memory) {
        return swapStorage.tokenMultipliers;
    }

    function getTokenBalances() external view override returns (uint256[] memory) {
        return swapStorage.balances;
    }

    function getTokenBalance(uint8 index) external view override returns (uint256) {
        return swapStorage.balances[index];
    }

    function getNumberOfTokens() external view override returns (uint256) {
        return swapStorage.pooledTokens.length;
    }

    function getAdminBalances() external view override returns (uint256[] memory adminBalances) {
        uint256 length = swapStorage.pooledTokens.length;
        adminBalances = new uint256[](length);
        for (uint256 i = 0; i < length; i++) {
            adminBalances[i] = swapStorage.getAdminBalance(i);
        }
    }

    function getAdminBalance(uint8 index) external view override returns (uint256) {
        return swapStorage.getAdminBalance((index));
    }

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit) external view override returns (uint256) {
        return swapStorage.calculateTokenAmount(amounts, deposit);
    }

    function calculateSwap(
        uint8 inIndex,
        uint8 outIndex,
        uint256 inAmount
    ) external view override returns (uint256) {
        return swapStorage.calculateSwap(inIndex, outIndex, inAmount);
    }

    function calculateRemoveLiquidity(address account, uint256 amount)
        external
        view
        override
        returns (uint256[] memory)
    {
        return swapStorage.calculateRemoveLiquidity(account, amount);
    }

    function calculateRemoveLiquidityOneToken(
        address account,
        uint256 amount,
        uint8 index
    ) external view override returns (uint256) {
        return swapStorage.calculateRemoveLiquidityOneToken(account, amount, index);
    }

    function calculateCurrentWithdrawFee(address account) external view override returns (uint256) {
        return swapStorage._calculateCurrentWithdrawFee(account);
    }

    /// RESTRICTED FUNCTION
    /**
     * @notice Updates the user withdraw fee. This function can only be called by
     * the pool token. Should be used to update the withdraw fee on transfer of pool tokens.
     * Transferring your pool token will reset the 4 weeks period. If the recipient is already
     * holding some pool tokens, the withdraw fee will be discounted in respective amounts.
     * @param recipient address of the recipient of pool token
     * @param transferAmount amount of pool token to transfer
     */
    function updateUserWithdrawFee(address recipient, uint256 transferAmount) external override {
        require(msg.sender == address(swapStorage.lpToken), "!lpToken");
        swapStorage.updateUserWithdrawFee(recipient, transferAmount);
    }

    /**
     * @notice Sets the admin fee
     * @dev adminFee cannot be higher than 100% of the swap fee
     * swap fee cannot be higher than 1% of each swap
     * @param newSwapFee new swap fee to be applied on future transactions
     * @param newAdminFee new admin fee to be applied on future transactions
     * @param newWithdrawFee new initial withdraw fee to be applied on future withdrawal transactions
     */
    function setFee(
        uint256 newSwapFee,
        uint256 newAdminFee,
        uint256 newWithdrawFee
    ) external onlyOwner {
        require(newSwapFee <= MAX_SWAP_FEE, "> maxSwapFee");
        require(newAdminFee <= MAX_ADMIN_FEE, "> maxAdminFee");
        require(newWithdrawFee <= MAX_WITHDRAW_FEE, "> maxWithdrawFee");
        swapStorage.adminFee = newAdminFee;
        swapStorage.fee = newSwapFee;
        swapStorage.defaultWithdrawFee = newWithdrawFee;

        emit NewFee(newSwapFee, newAdminFee, newWithdrawFee);
    }

    /**
     * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_
     * Checks if the change is too rapid, and commits the new A value only when it falls under
     * the limit range.
     * @param futureA the new A to ramp towards
     * @param futureATime timestamp when the new A should be reached
     */
    function rampA(uint256 futureA, uint256 futureATime) external onlyOwner {
        require(block.timestamp >= swapStorage.initialATime + (1 days), "< rampDelay"); // please wait 1 days before start a new ramping
        require(futureATime >= block.timestamp + (MIN_RAMP_TIME), "< minRampTime");
        require(0 < futureA && futureA < MAX_A, "outOfRange");

        uint256 initialAPrecise = swapStorage.getAPrecise();
        uint256 futureAPrecise = futureA * IronSwapLib.A_PRECISION;

        if (futureAPrecise < initialAPrecise) {
            require(futureAPrecise * (MAX_A_CHANGE) >= initialAPrecise, "> maxChange");
        } else {
            require(futureAPrecise <= initialAPrecise * (MAX_A_CHANGE), "> maxChange");
        }

        swapStorage.initialA = initialAPrecise;
        swapStorage.futureA = futureAPrecise;
        swapStorage.initialATime = block.timestamp;
        swapStorage.futureATime = futureATime;

        emit RampA(initialAPrecise, futureAPrecise, block.timestamp, futureATime);
    }

    function stopRampA() external onlyOwner {
        require(swapStorage.futureATime > block.timestamp, "alreadyStopped");
        uint256 currentA = swapStorage.getAPrecise();

        swapStorage.initialA = currentA;
        swapStorage.futureA = currentA;
        swapStorage.initialATime = block.timestamp;
        swapStorage.futureATime = block.timestamp;

        emit StopRampA(currentA, block.timestamp);
    }

    function setFeeController(address _feeController) external onlyOwner() {
        require(_feeController != address(0), "zeroAddress");
        feeController = _feeController;
        emit FeeControllerChanged(_feeController);
    }

    function setFeeDistributor(address _feeDistributor) external onlyOwner() {
        require(_feeDistributor != address(0), "zeroAddress");
        feeDistributor = _feeDistributor;
        emit FeeDistributorChanged(_feeDistributor);
    }

    function withdrawAdminFee() external override onlyFeeControllerOrOwner {
        for (uint256 i = 0; i < swapStorage.pooledTokens.length; i++) {
            IERC20 token = swapStorage.pooledTokens[i];
            uint256 balance = token.balanceOf(address(this)) - (swapStorage.balances[i]);
            if (balance != 0) {
                token.safeTransfer(feeDistributor, balance);
                emit CollectProtocolFee(address(token), balance);
            }
        }
    }
}

File 2 of 16 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

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

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

        _;

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

File 3 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 4 of 16 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 5 of 16 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 6 of 16 : OwnerPausable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

abstract contract OwnerPausable is Ownable, Pausable {
    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }
}

File 7 of 16 : IronSwapLib.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "./tokens/LPToken.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * StableSwap main algorithm
 */
library IronSwapLib {
    using SafeERC20 for IERC20;

    event AddLiquidity(
        address indexed provider,
        uint256[] token_amounts,
        uint256[] fees,
        uint256 invariant,
        uint256 token_supply
    );

    event TokenExchange(
        address indexed buyer,
        uint256 sold_id,
        uint256 tokens_sold,
        uint256 bought_id,
        uint256 tokens_bought
    );

    event RemoveLiquidity(address indexed provider, uint256[] token_amounts, uint256[] fees, uint256 token_supply);

    event RemoveLiquidityOne(address indexed provider, uint256 index, uint256 token_amount, uint256 coin_amount);

    event RemoveLiquidityImbalance(
        address indexed provider,
        uint256[] token_amounts,
        uint256[] fees,
        uint256 invariant,
        uint256 token_supply
    );

    uint256 public constant FEE_DENOMINATOR = 1e10;
    // uint256 public constant PRECISION = 1e18;

    /// @dev protect from division loss when run approximation loop. We cannot divide at the end because of overflow,
    /// so we add some (small) PRECISION when divide in each iteration
    uint256 public constant A_PRECISION = 100;
    /// @dev max iteration of converge calccuate
    uint256 internal constant MAX_ITERATION = 256;
    uint256 public constant POOL_TOKEN_COMMON_DECIMALS = 18;

    struct SwapStorage {
        IERC20[] pooledTokens;
        LPToken lpToken;
        /// @dev token i multiplier to reach POOL_TOKEN_COMMON_DECIMALS
        uint256[] tokenMultipliers;
        /// @dev effective balance which might different from token balance of the contract 'cause it hold admin fee as well
        uint256[] balances;
        /// @dev swap fee ratio. Charge on any action which move balance state far from the ideal state
        uint256 fee;
        /// @dev admin fee in ratio of swap fee.
        uint256 adminFee;
        /// @dev observation of A, multiplied with A_PRECISION
        uint256 initialA;
        uint256 futureA;
        uint256 initialATime;
        uint256 futureATime;
        // withdrawal fee control
        uint256 defaultWithdrawFee;
        mapping(address => uint256) depositTimestamp;
        mapping(address => uint256) withdrawFeeMultiplier;
    }

    /**
     * @notice Deposit coins into the pool
     * @param amounts List of amounts of coins to deposit
     * @param minMintAmount Minimum amount of LP tokens to mint from the deposit
     * @return mintAmount Amount of LP tokens received by depositing
     */
    function addLiquidity(
        SwapStorage storage self,
        uint256[] memory amounts,
        uint256 minMintAmount
    ) external returns (uint256 mintAmount) {
        uint256 nCoins = self.pooledTokens.length;
        require(amounts.length == nCoins, "invalidAmountsLength");
        uint256[] memory fees = new uint256[](nCoins);
        uint256 _fee = _feePerToken(self);

        uint256 tokenSupply = self.lpToken.totalSupply();
        uint256 amp = _getAPrecise(self);

        uint256 D0 = 0;
        if (tokenSupply > 0) {
            D0 = _getD(_xp(self.balances, self.tokenMultipliers), amp);
        }

        uint256[] memory newBalances = self.balances;

        for (uint256 i = 0; i < nCoins; i++) {
            if (tokenSupply == 0) {
                require(amounts[i] > 0, "initialDepositRequireAllTokens");
            }
            // get real transfer in amount
            newBalances[i] += _doTransferIn(self.pooledTokens[i], amounts[i]);
        }

        uint256 D1 = _getD(_xp(newBalances, self.tokenMultipliers), amp);
        assert(D1 > D0); // double check

        if (tokenSupply == 0) {
            self.balances = newBalances;
            mintAmount = D1;
        } else {
            uint256 diff = 0;
            for (uint256 i = 0; i < nCoins; i++) {
                diff = _distance((D1 * self.balances[i]) / D0, newBalances[i]);
                fees[i] = (_fee * diff) / FEE_DENOMINATOR;
                self.balances[i] = newBalances[i] - ((fees[i] * self.adminFee) / FEE_DENOMINATOR);
                newBalances[i] -= fees[i];
            }
            D1 = _getD(_xp(newBalances, self.tokenMultipliers), amp);
            mintAmount = (tokenSupply * (D1 - D0)) / D0;
        }

        require(mintAmount >= minMintAmount, "> slippage");

        self.lpToken.mint(msg.sender, mintAmount);
        emit AddLiquidity(msg.sender, amounts, fees, D1, mintAmount);
    }

    function swap(
        SwapStorage storage self,
        uint256 i,
        uint256 j,
        uint256 inAmount,
        uint256 minOutAmount
    ) external returns (uint256) {
        IERC20 inCoin = self.pooledTokens[i];
        uint256[] memory normalizedBalances = _xp(self);
        inAmount = _doTransferIn(inCoin, inAmount);

        uint256 x = normalizedBalances[i] + (inAmount * self.tokenMultipliers[i]);
        uint256 y = _getY(self, i, j, x, normalizedBalances);

        uint256 dy = normalizedBalances[j] - y - 1; // iliminate rouding errors
        uint256 dy_fee = (dy * self.fee) / FEE_DENOMINATOR;

        dy = (dy - dy_fee) / self.tokenMultipliers[j]; // denormalize

        require(dy >= minOutAmount, "> slippage");

        uint256 _adminFee = (dy_fee * self.adminFee) / FEE_DENOMINATOR / self.tokenMultipliers[j];

        // update balances
        self.balances[i] += inAmount;
        self.balances[j] -= dy + _adminFee;

        self.pooledTokens[j].safeTransfer(msg.sender, dy);
        emit TokenExchange(msg.sender, i, inAmount, j, dy);
        return dy;
    }

    function removeLiquidity(
        SwapStorage storage self,
        uint256 lpAmount,
        uint256[] memory minAmounts
    ) external returns (uint256[] memory amounts) {
        uint256 totalSupply = self.lpToken.totalSupply();
        require(lpAmount <= totalSupply);
        uint256 nCoins = self.pooledTokens.length;

        uint256[] memory fees = new uint256[](nCoins);
        amounts = _calculateRemoveLiquidity(self, msg.sender, lpAmount);

        for (uint256 i = 0; i < amounts.length; i++) {
            require(amounts[i] >= minAmounts[i], "> slippage");
            self.balances[i] = self.balances[i] - amounts[i];
            self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);
        }

        self.lpToken.burnFrom(msg.sender, lpAmount);
        emit RemoveLiquidity(msg.sender, amounts, fees, totalSupply - lpAmount);
    }

    function removeLiquidityOneToken(
        SwapStorage storage self,
        uint256 lpAmount,
        uint256 index,
        uint256 minAmount
    ) external returns (uint256) {
        uint256 totalSupply = self.lpToken.totalSupply();
        require(totalSupply > 0, "totalSupply = 0");
        uint256 numTokens = self.pooledTokens.length;
        require(lpAmount <= self.lpToken.balanceOf(msg.sender), "> balance");
        require(lpAmount <= totalSupply, "> totalSupply");
        require(index < numTokens, "tokenNotFound");

        uint256 dyFee;
        uint256 dy;

        (dy, dyFee) = _calculateRemoveLiquidityOneToken(self, msg.sender, lpAmount, index);

        require(dy >= minAmount, "> slippage");

        self.balances[index] -= (dy + (dyFee * self.adminFee) / FEE_DENOMINATOR);
        self.lpToken.burnFrom(msg.sender, lpAmount);
        self.pooledTokens[index].safeTransfer(msg.sender, dy);

        emit RemoveLiquidityOne(msg.sender, index, lpAmount, dy);

        return dy;
    }

    function removeLiquidityImbalance(
        SwapStorage storage self,
        uint256[] memory amounts,
        uint256 maxBurnAmount
    ) external returns (uint256 burnAmount) {
        uint256 nCoins = self.pooledTokens.length;
        require(amounts.length == nCoins, "invalidAmountsLength");
        uint256 totalSupply = self.lpToken.totalSupply();
        require(totalSupply != 0, "totalSupply = 0");
        uint256 _fee = _feePerToken(self);
        uint256 amp = _getAPrecise(self);

        uint256[] memory newBalances = self.balances;
        uint256 D0 = _getD(_xp(self), amp);

        for (uint256 i = 0; i < nCoins; i++) {
            newBalances[i] -= amounts[i];
        }

        uint256 D1 = _getD(_xp(newBalances, self.tokenMultipliers), amp);
        uint256[] memory fees = new uint256[](nCoins);

        for (uint256 i = 0; i < nCoins; i++) {
            uint256 idealBalance = (D1 * self.balances[i]) / D0;
            uint256 diff = _distance(newBalances[i], idealBalance);
            fees[i] = (_fee * diff) / FEE_DENOMINATOR;
            self.balances[i] = newBalances[i] - ((fees[i] * self.adminFee) / FEE_DENOMINATOR);
            newBalances[i] -= fees[i];
        }

        // recalculate invariant with fee charged balances
        D1 = _getD(_xp(newBalances, self.tokenMultipliers), amp);
        burnAmount = ((D0 - D1) * totalSupply) / D0;
        assert(burnAmount > 0);
        burnAmount = (burnAmount + 1) * (FEE_DENOMINATOR - _calculateCurrentWithdrawFee(self, msg.sender)); //In case of rounding errors - make it unfavorable for the "attacker"
        require(burnAmount <= maxBurnAmount, "> slippage");

        self.lpToken.burnFrom(msg.sender, burnAmount);

        for (uint256 i = 0; i < nCoins; i++) {
            if (amounts[i] != 0) {
                self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);
            }
        }

        emit RemoveLiquidityImbalance(msg.sender, amounts, fees, D1, totalSupply - burnAmount);
    }

    /// VIEW FUNCTIONS
    function getAPrecise(SwapStorage storage self) external view returns (uint256) {
        return _getAPrecise(self);
    }

    /**
     * Returns portfolio virtual price (for calculating profit)
     * scaled up by 1e18
     */
    function getVirtualPrice(SwapStorage storage self) external view returns (uint256) {
        uint256 D = _getD(_xp(self), _getAPrecise(self));
        uint256 tokenSupply = self.lpToken.totalSupply();
        return (D * 10**POOL_TOKEN_COMMON_DECIMALS) / tokenSupply;
    }

    function getAdminBalance(SwapStorage storage self, uint256 index) external view returns (uint256) {
        require(index < self.pooledTokens.length, "indexOutOfRange");
        return self.pooledTokens[index].balanceOf(address(this)) - (self.balances[index]);
    }

    /**
     * Estimate amount of LP token minted or burned at deposit or withdrawal
     * without taking fees into account
     */
    function calculateTokenAmount(
        SwapStorage storage self,
        uint256[] memory amounts,
        bool deposit
    ) external view returns (uint256) {
        uint256 nCoins = self.pooledTokens.length;
        require(amounts.length == nCoins, "invalidAmountsLength");
        uint256 amp = _getAPrecise(self);
        uint256 D0 = _getD(_xp(self), amp);

        uint256[] memory newBalances = self.balances;
        for (uint256 i = 0; i < nCoins; i++) {
            if (deposit) {
                newBalances[i] += amounts[i];
            } else {
                newBalances[i] -= amounts[i];
            }
        }

        uint256 D1 = _getD(_xp(newBalances, self.tokenMultipliers), amp);
        uint256 totalSupply = self.lpToken.totalSupply();

        if (totalSupply == 0) {
            return D1; // first depositor take it all
        }

        uint256 diff = deposit ? D1 - D0 : D0 - D1;
        return (diff * self.lpToken.totalSupply()) / D0;
    }

    function getA(SwapStorage storage self) external view returns (uint256) {
        return _getAPrecise(self) / A_PRECISION;
    }

    function calculateSwap(
        SwapStorage storage self,
        uint256 inIndex,
        uint256 outIndex,
        uint256 inAmount
    ) external view returns (uint256) {
        uint256[] memory normalizedBalances = _xp(self);
        uint256 newInBalance = normalizedBalances[inIndex] + (inAmount * self.tokenMultipliers[inIndex]);
        uint256 outBalance = _getY(self, inIndex, outIndex, newInBalance, normalizedBalances);
        uint256 outAmount = (normalizedBalances[outIndex] - outBalance - 1) / self.tokenMultipliers[outIndex];
        uint256 _fee = (self.fee * outAmount) / FEE_DENOMINATOR;
        return outAmount - _fee;
    }

    function calculateRemoveLiquidity(
        SwapStorage storage self,
        address account,
        uint256 amount
    ) external view returns (uint256[] memory) {
        return _calculateRemoveLiquidity(self, account, amount);
    }

    function calculateRemoveLiquidityOneToken(
        SwapStorage storage self,
        address account,
        uint256 lpAmount,
        uint256 tokenIndex
    ) external view returns (uint256 amount) {
        (amount, ) = _calculateRemoveLiquidityOneToken(self, account, lpAmount, tokenIndex);
    }

    /**
     * @notice Update the withdraw fee for `user`. If the user is currently
     * not providing liquidity in the pool, sets to default value. If not, recalculate
     * the starting withdraw fee based on the last deposit's time & amount relative
     * to the new deposit.
     *
     * @param self Swap struct to read from and write to
     * @param user address of the user depositing tokens
     * @param toMint amount of pool tokens to be minted
     */
    function updateUserWithdrawFee(
        SwapStorage storage self,
        address user,
        uint256 toMint
    ) external {
        _updateUserWithdrawFee(self, user, toMint);
    }

    /// INTERNAL FUNCTIONS

    /**
     * Ramping A up or down, return A with precision of A_PRECISION
     */
    function _getAPrecise(SwapStorage storage self) internal view returns (uint256) {
        if (block.timestamp >= self.futureATime) {
            return self.futureA;
        }

        if (self.futureA > self.initialA) {
            return
                self.initialA +
                ((self.futureA - self.initialA) * (block.timestamp - self.initialATime)) /
                (self.futureATime - self.initialATime);
        }

        return
            self.initialA -
            ((self.initialA - self.futureA) * (block.timestamp - self.initialATime)) /
            (self.futureATime - self.initialATime);
    }

    /**
     * normalized balances of each tokens.
     */
    function _xp(uint256[] memory balances, uint256[] memory rates) internal pure returns (uint256[] memory) {
        for (uint256 i = 0; i < balances.length; i++) {
            rates[i] = (rates[i] * balances[i]);
        }

        return rates;
    }

    function _xp(SwapStorage storage self) internal view returns (uint256[] memory) {
        return _xp(self.balances, self.tokenMultipliers);
    }

    /**
     * Calculate D for *NORMALIZED* balances of each tokens
     * @param xp normalized balances of token
     */
    function _getD(uint256[] memory xp, uint256 amp) internal pure returns (uint256) {
        uint256 nCoins = xp.length;
        uint256 sum = _sumOf(xp);
        if (sum == 0) {
            return 0;
        }

        uint256 Dprev = 0;
        uint256 D = sum;
        uint256 Ann = amp * nCoins;

        for (uint256 i = 0; i < MAX_ITERATION; i++) {
            uint256 D_P = D;
            for (uint256 j = 0; j < xp.length; j++) {
                D_P = (D_P * D) / (xp[j] * nCoins);
            }
            Dprev = D;
            D =
                (((Ann * sum) / A_PRECISION + D_P * nCoins) * D) /
                (((Ann - A_PRECISION) * D) / A_PRECISION + (nCoins + 1) * D_P);
            if (_distance(D, Dprev) <= 1) {
                return D;
            }
        }

        // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong
        // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`
        // function which does not rely on D.
        revert("invariantCalculationFailed");
    }

    /**
     * calculate new balance of when swap
     * Done by solving quadratic equation iteratively.
     *  x_1**2 + x_1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)
     *  x_1**2 + b*x_1 = c
     *  x_1 = (x_1**2 + c) / (2*x_1 + b)
     * @param inIndex index of token to swap in
     * @param outIndex index of token to swap out
     * @param inBalance new balance (normalized) of input token if the swap success
     * @return NORMALIZED balance of output token if the swap success
     */
    function _getY(
        SwapStorage storage self,
        uint256 inIndex,
        uint256 outIndex,
        uint256 inBalance,
        uint256[] memory normalizedBalances
    ) internal view returns (uint256) {
        require(inIndex != outIndex, "sameToken");
        uint256 nCoins = self.pooledTokens.length;
        require(inIndex < nCoins && outIndex < nCoins, "indexOutOfRange");

        uint256 amp = _getAPrecise(self);
        uint256 Ann = amp * nCoins;
        uint256 D = _getD(normalizedBalances, amp);

        uint256 sum = 0; // sum of new balances except output token
        uint256 c = D;
        for (uint256 i = 0; i < nCoins; i++) {
            if (i == outIndex) {
                continue;
            }

            uint256 x = i == inIndex ? inBalance : normalizedBalances[i];
            sum += x;
            c = (c * D) / (x * nCoins);
        }

        c = (c * D * A_PRECISION) / (Ann * nCoins);
        uint256 b = sum + (D * A_PRECISION) / Ann;

        uint256 lastY = 0;
        uint256 y = D;

        for (uint256 index = 0; index < MAX_ITERATION; index++) {
            lastY = y;
            y = (y * y + c) / (2 * y + b - D);
            if (_distance(lastY, y) <= 1) {
                return y;
            }
        }

        revert("yCalculationFailed");
    }

    function _calculateRemoveLiquidity(
        SwapStorage storage self,
        address account,
        uint256 amount
    ) internal view returns (uint256[] memory) {
        uint256 totalSupply = self.lpToken.totalSupply();
        require(amount <= totalSupply, "Cannot exceed total supply");

        uint256 feeAdjustedAmount = (amount * (FEE_DENOMINATOR - _calculateCurrentWithdrawFee(self, account))) /
            FEE_DENOMINATOR;

        uint256[] memory amounts = new uint256[](self.pooledTokens.length);

        for (uint256 i = 0; i < self.pooledTokens.length; i++) {
            amounts[i] = (self.balances[i] * (feeAdjustedAmount)) / (totalSupply);
        }
        return amounts;
    }

    function _calculateRemoveLiquidityOneToken(
        SwapStorage storage self,
        address account,
        uint256 tokenAmount,
        uint256 index
    ) internal view returns (uint256 dy, uint256 fee) {
        require(index < self.pooledTokens.length, "indexOutOfRange");
        uint256 amp = _getAPrecise(self);
        uint256[] memory xp = _xp(self);
        uint256 D0 = _getD(xp, amp);
        uint256 D1 = D0 - (tokenAmount * D0) / self.lpToken.totalSupply();
        uint256 newY = _getYD(self, amp, index, xp, D1);
        uint256[] memory reducedXP = xp;
        uint256 _fee = _feePerToken(self);

        for (uint256 i = 0; i < self.pooledTokens.length; i++) {
            uint256 expectedDx = 0;
            if (i == index) {
                expectedDx = (xp[i] * D1) / D0 - newY;
            } else {
                expectedDx = xp[i] - (xp[i] * D1) / D0;
            }
            reducedXP[i] -= (_fee * expectedDx) / FEE_DENOMINATOR;
        }

        dy = reducedXP[index] - _getYD(self, amp, index, reducedXP, D1);
        dy = (dy - 1) / self.tokenMultipliers[index];
        fee = ((xp[index] - newY) / self.tokenMultipliers[index]) - dy;
        dy = (dy * (FEE_DENOMINATOR - _calculateCurrentWithdrawFee(self, account))) / FEE_DENOMINATOR;
    }

    function _feePerToken(SwapStorage storage self) internal view returns (uint256) {
        uint256 nCoins = self.pooledTokens.length;
        return (self.fee * nCoins) / (4 * (nCoins - 1));
    }

    function _getYD(
        SwapStorage storage self,
        uint256 A,
        uint256 index,
        uint256[] memory xp,
        uint256 D
    ) internal view returns (uint256) {
        uint256 nCoins = self.pooledTokens.length;
        assert(index < nCoins);
        uint256 Ann = A * nCoins;
        uint256 c = D;
        uint256 s = 0;
        uint256 _x = 0;
        uint256 yPrev = 0;

        for (uint256 i = 0; i < nCoins; i++) {
            if (i == index) {
                continue;
            }
            _x = xp[i];
            s += _x;
            c = (c * D) / (_x * nCoins);
        }

        c = (c * D * A_PRECISION) / (Ann * nCoins);
        uint256 b = s + (D * A_PRECISION) / Ann;
        uint256 y = D;

        for (uint256 i = 0; i < MAX_ITERATION; i++) {
            yPrev = y;
            y = (y * y + c) / (2 * y + b - D);
            if (_distance(yPrev, y) <= 1) {
                return y;
            }
        }
        revert("invariantCalculationFailed");
    }

    function _updateUserWithdrawFee(
        SwapStorage storage self,
        address user,
        uint256 toMint
    ) internal {
        // If token is transferred to address 0 (or burned), don't update the fee.
        if (user == address(0)) {
            return;
        }
        if (self.defaultWithdrawFee == 0) {
            // If current fee is set to 0%, set multiplier to FEE_DENOMINATOR
            self.withdrawFeeMultiplier[user] = FEE_DENOMINATOR;
        } else {
            // Otherwise, calculate appropriate discount based on last deposit amount
            uint256 currentFee = _calculateCurrentWithdrawFee(self, user);
            uint256 currentBalance = self.lpToken.balanceOf(user);

            // ((currentBalance * currentFee) + (toMint * defaultWithdrawFee)) * FEE_DENOMINATOR /
            // ((toMint + currentBalance) * defaultWithdrawFee)
            if ((toMint + currentBalance) * self.defaultWithdrawFee != 0) {
                self.withdrawFeeMultiplier[user] =
                    (((currentBalance * currentFee) + (toMint * self.defaultWithdrawFee)) * (FEE_DENOMINATOR)) /
                    ((toMint + currentBalance) * self.defaultWithdrawFee);
            }
        }
        self.depositTimestamp[user] = block.timestamp;
    }

    /**
     * @notice Calculate the fee that is applied when the given user withdraws.
     * Withdraw fee decays linearly over 4 weeks.
     * @param user address you want to calculate withdraw fee of
     * @return current withdraw fee of the user
     */
    function _calculateCurrentWithdrawFee(SwapStorage storage self, address user) internal view returns (uint256) {
        uint256 endTime = self.depositTimestamp[user] + (4 weeks);
        if (endTime > block.timestamp) {
            uint256 timeLeftover = endTime - block.timestamp;
            return
                (self.defaultWithdrawFee * self.withdrawFeeMultiplier[user] * timeLeftover) /
                (4 weeks) /
                FEE_DENOMINATOR;
        }
        return 0;
    }

    function _doTransferIn(IERC20 token, uint256 amount) internal returns (uint256) {
        uint256 priorBalance = token.balanceOf(address(this));
        token.safeTransferFrom(msg.sender, address(this), amount);
        return token.balanceOf(address(this)) - priorBalance;
    }

    function _sumOf(uint256[] memory x) internal pure returns (uint256 sum) {
        sum = 0;
        for (uint256 i = 0; i < x.length; i++) {
            sum += x[i];
        }
    }

    function _distance(uint256 x, uint256 y) internal pure returns (uint256) {
        return x > y ? x - y : y - x;
    }
}

File 8 of 16 : IIronSwap.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IIronSwap {
    /// EVENTS
    event AddLiquidity(
        address indexed provider,
        uint256[] tokenAmounts,
        uint256[] fees,
        uint256 invariant,
        uint256 tokenSupply
    );

    event TokenExchange(
        address indexed buyer,
        uint256 soldId,
        uint256 tokensSold,
        uint256 boughtId,
        uint256 tokensBought
    );

    event RemoveLiquidity(address indexed provider, uint256[] tokenAmounts, uint256[] fees, uint256 tokenSupply);

    event RemoveLiquidityOne(address indexed provider, uint256 tokenIndex, uint256 tokenAmount, uint256 coinAmount);

    event RemoveLiquidityImbalance(
        address indexed provider,
        uint256[] tokenAmounts,
        uint256[] fees,
        uint256 invariant,
        uint256 tokenSupply
    );

    event RampA(uint256 oldA, uint256 newA, uint256 initialTime, uint256 futureTime);

    event StopRampA(uint256 A, uint256 timestamp);

    event NewFee(uint256 fee, uint256 adminFee, uint256 withdrawFee);

    event CollectProtocolFee(address token, uint256 amount);

    event FeeControllerChanged(address newController);

    event FeeDistributorChanged(address newController);

    // pool data view functions
    function getLpToken() external view returns (IERC20 lpToken);

    function getA() external view returns (uint256);

    function getAPrecise() external view returns (uint256);

    function getToken(uint8 index) external view returns (IERC20);

    function getTokens() external view returns (IERC20[] memory);

    function getTokenIndex(address tokenAddress) external view returns (uint8);

    function getTokenBalance(uint8 index) external view returns (uint256);

    function getTokenBalances() external view returns (uint256[] memory);

    function getNumberOfTokens() external view returns (uint256);

    function getVirtualPrice() external view returns (uint256);

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit) external view returns (uint256);

    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateRemoveLiquidity(address account, uint256 amount) external view returns (uint256[] memory);

    function calculateRemoveLiquidityOneToken(
        address account,
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 availableTokenAmount);

    function getAdminBalances() external view returns (uint256[] memory adminBalances);

    function getAdminBalance(uint8 index) external view returns (uint256);

    function calculateCurrentWithdrawFee(address account) external view returns (uint256);

    // state modifying functions
    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory);

    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external returns (uint256);

    function updateUserWithdrawFee(address recipient, uint256 transferAmount) external;

    function withdrawAdminFee() external;
}

File 9 of 16 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 10 of 16 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 11 of 16 : Pausable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor () {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 12 of 16 : Context.sol
// SPDX-License-Identifier: MIT

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) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 13 of 16 : LPToken.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "../interfaces/IIronSwap.sol";

contract LPToken is Ownable, ERC20Burnable {
    IIronSwap public swap;

    constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {
        swap = IIronSwap(msg.sender);
    }

    function mint(address _to, uint256 _amount) external onlyOwner {
        require(_amount > 0, "zeroMintAmount");
        _mint(_to, _amount);
    }

    /**
     * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including
     * minting and burning. This ensures that swap.updateUserWithdrawFees are called everytime.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal override(ERC20) {
        super._beforeTokenTransfer(from, to, amount);
        swap.updateUserWithdrawFee(to, amount);
    }
}

File 14 of 16 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        _approve(account, _msgSender(), currentAllowance - amount);
        _burn(account, amount);
    }
}

File 15 of 16 : ERC20.sol
// SPDX-License-Identifier: MIT

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 guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, 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 defaut 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:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

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

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

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

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        _approve(sender, _msgSender(), currentAllowance - 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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][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) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }

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

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

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

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

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

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

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

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

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

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

File 16 of 16 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

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);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {
    "contracts/IronSwapLib.sol": {
      "IronSwapLib": "0x0fc441afd5e58a58997ac779063fd0f3754f55b5"
    }
  }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"invariant","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenSupply","type":"uint256"}],"name":"AddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CollectProtocolFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newController","type":"address"}],"name":"FeeControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newController","type":"address"}],"name":"FeeDistributorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"adminFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawFee","type":"uint256"}],"name":"NewFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"initialTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"futureTime","type":"uint256"}],"name":"RampA","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"tokenSupply","type":"uint256"}],"name":"RemoveLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"invariant","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenSupply","type":"uint256"}],"name":"RemoveLiquidityImbalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"coinAmount","type":"uint256"}],"name":"RemoveLiquidityOne","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"A","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"StopRampA","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"soldId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensSold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boughtId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensBought","type":"uint256"}],"name":"TokenExchange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"MAX_A","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ADMIN_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_A_CHANGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SWAP_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WITHDRAW_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_RAMP_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"minMintAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"calculateCurrentWithdrawFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateRemoveLiquidity","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint8","name":"index","type":"uint8"}],"name":"calculateRemoveLiquidityOneToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"inIndex","type":"uint8"},{"internalType":"uint8","name":"outIndex","type":"uint8"},{"internalType":"uint256","name":"inAmount","type":"uint256"}],"name":"calculateSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bool","name":"deposit","type":"bool"}],"name":"calculateTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeDistributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getA","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAPrecise","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"getAdminBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAdminBalances","outputs":[{"internalType":"uint256[]","name":"adminBalances","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLpToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumberOfTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"getTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenBalances","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenIndex","outputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenPrecisionMultipliers","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokens","outputs":[{"internalType":"contract IERC20[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVirtualPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_coins","type":"address[]"},{"internalType":"uint8[]","name":"_decimals","type":"uint8[]"},{"internalType":"string","name":"lpTokenName","type":"string"},{"internalType":"string","name":"lpTokenSymbol","type":"string"},{"internalType":"uint256","name":"_A","type":"uint256"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"uint256","name":"_adminFee","type":"uint256"},{"internalType":"uint256","name":"_withdrawFee","type":"uint256"},{"internalType":"address","name":"_feeDistributor","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"futureA","type":"uint256"},{"internalType":"uint256","name":"futureATime","type":"uint256"}],"name":"rampA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lpAmount","type":"uint256"},{"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"maxBurnAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityImbalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lpAmount","type":"uint256"},{"internalType":"uint8","name":"index","type":"uint8"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityOneToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newSwapFee","type":"uint256"},{"internalType":"uint256","name":"newAdminFee","type":"uint256"},{"internalType":"uint256","name":"newWithdrawFee","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeController","type":"address"}],"name":"setFeeController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeDistributor","type":"address"}],"name":"setFeeDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopRampA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"fromIndex","type":"uint8"},{"internalType":"uint8","name":"toIndex","type":"uint8"},{"internalType":"uint256","name":"inAmount","type":"uint256"},{"internalType":"uint256","name":"minOutAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapStorage","outputs":[{"internalType":"contract LPToken","name":"lpToken","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"adminFee","type":"uint256"},{"internalType":"uint256","name":"initialA","type":"uint256"},{"internalType":"uint256","name":"futureA","type":"uint256"},{"internalType":"uint256","name":"initialATime","type":"uint256"},{"internalType":"uint256","name":"futureATime","type":"uint256"},{"internalType":"uint256","name":"defaultWithdrawFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenIndexes","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"transferAmount","type":"uint256"}],"name":"updateUserWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAdminFee","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506000805460ff60a01b191690556001805561486f806100726000396000f3fe60806040523480156200001157600080fd5b5060043610620002cd5760003560e01c806384cdd9bc1162000185578063c4db7fa011620000df578063e25aa5fa1162000092578063e25aa5fa146200067b578063e6ab28061462000685578063efeecb51146200069c578063f2fde38b14620006a5578063f3de036214620006bc578063fe49abe314620006c957600080fd5b8063c4db7fa0146200062f578063ccfc2e8d1462000639578063d41f65681462000650578063d46300fd146200065a578063d4b0de2f1462000603578063df3ed68d146200066457600080fd5b8063a1dc90311162000138578063a1dc903114620005c9578063a95b089f14620005d3578063aa6ca80814620005ea578063ab3d85441462000603578063ab5ac061146200060f578063c00c125c146200061857600080fd5b806384cdd9bc14620005445780638554a7d4146200055b5780638da5cb5b146200057257806391695586146200058457806391ceb3eb146200059b57806398899f4014620005b257600080fd5b80634d49e87d11620002375780636999b37711620001ea5780636999b37714620004dc578063715018a614620004f05780637c61e56114620004fa5780638214f5a4146200051157806382b8660014620005235780638456cb59146200053a57600080fd5b80634d49e87d14620003ec578063593d132c14620004035780635b65b9ab146200041a5780635c975abb14620004315780635fd65f0f146200044f57806366c0bd2414620004c557600080fd5b806331cd52b0116200029057806331cd52b014620003795780633969841514620003905780633e3a1560146200039b5780633ed4c67814620003b25780633f4ba83a14620003cb5780634a1b0d5714620003d557600080fd5b806304bc3b1c14620002d257806306e9481c146200030f5780630ba8195914620003295780630d43e8ad146200033357806318f52ce21462000360575b600080fd5b620002f8620002e336600462002c3d565b60126020526000908152604090205460ff1681565b60405160ff90911681526020015b60405180910390f35b6200031a6201518081565b60405190815260200162000306565b6200031a620006d3565b60105462000347906001600160a01b031681565b6040516001600160a01b03909116815260200162000306565b6200036a62000763565b604051620003069190620031c3565b6200036a6200038a36600462002f61565b6200089e565b6200031a620f424081565b6200031a620003ac36600462003001565b6200099b565b620003c9620003c336600462002c3d565b62000ac5565b005b620003c962000b8d565b6200031a620003e636600462002c3d565b62000bc6565b6200031a620003fd36600462002ed9565b62000bdb565b620003c96200041436600462002fb3565b62000cea565b620003c96200042b36600462002fd5565b62000fac565b600054600160a01b900460ff16604051901515815260200162000306565b600454600754600854600954600a54600b54600c54600d546200047f976001600160a01b03169695949392919088565b604080516001600160a01b0390991689526020890197909752958701949094526060860192909252608085015260a084015260c083015260e08201526101000162000306565b620002f8620004d636600462002c3d565b62001103565b60115462000347906001600160a01b031681565b620003c96200119f565b6200036a6200050b36600462002c5a565b62001216565b6004546001600160a01b031662000347565b62000347620005343660046200303e565b620012c1565b620003c962001306565b6200031a6200055536600462002ed9565b6200133d565b6200031a6200056c3660046200303e565b620013f9565b6000546001600160a01b031662000347565b6200031a620005953660046200309b565b6200148c565b6200031a620005ac3660046200303e565b620015be565b6200031a620005c336600462002c86565b620015f9565b6200036a620016ab565b6200031a620005e43660046200305b565b62001707565b620005f46200175b565b60405162000306919062003174565b6200031a6305f5e10081565b6200031a600a81565b620003c96200062936600462002c5a565b620017c1565b620003c962001887565b620003c96200064a36600462002c3d565b620019d2565b6200036a62001a94565b6200031a62001aef565b620003c96200067536600462002cc6565b62001b2b565b6200031a62002217565b6200031a6200069636600462002db5565b62002253565b6003546200031a565b620003c9620006b636600462002c3d565b62002296565b6200031a6402540be40081565b620003c962002385565b60405163da2a54b160e01b815260036004820152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063da2a54b1906024015b60206040518083038186803b1580156200072357600080fd5b505af415801562000738573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200075e919062002f48565b905090565b6003546060908067ffffffffffffffff8111156200079157634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015620007bb578160200160208202803683370190505b50915060005b818110156200089957604051632c08163160e21b81526003600482015260248101829052730fc441afd5e58a58997ac779063fd0f3754f55b59063b02058c49060440160206040518083038186803b1580156200081d57600080fd5b505af415801562000832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000858919062002f48565b8382815181106200087957634e487b7160e01b600052603260045260246000fd5b60209081029190910101528062000890816200359c565b915050620007c1565b505090565b606060026001541415620008cf5760405162461bcd60e51b8152600401620008c690620032c4565b60405180910390fd5b60026001558142811015620008f85760405162461bcd60e51b8152600401620008c690620032a3565b6040516332751fb560e21b8152730fc441afd5e58a58997ac779063fd0f3754f55b59063c9d47ed49062000936906003908990899060040162003370565b60006040518083038186803b1580156200094f57600080fd5b505af415801562000964573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200098e919081019062002e3d565b6001805595945050505050565b600060026001541415620009c35760405162461bcd60e51b8152600401620008c690620032c4565b6002600155600054600160a01b900460ff1615620009f55760405162461bcd60e51b8152600401620008c69062003244565b818042111562000a195760405162461bcd60e51b8152600401620008c690620032a3565b60405163db41b10b60e01b8152600360048201526024810187905260ff8616604482015260648101859052730fc441afd5e58a58997ac779063fd0f3754f55b59063db41b10b9060840160206040518083038186803b15801562000a7c57600080fd5b505af415801562000a91573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ab7919062002f48565b600180559695505050505050565b6000546001600160a01b0316331462000af25760405162461bcd60e51b8152600401620008c6906200326e565b6001600160a01b03811662000b385760405162461bcd60e51b815260206004820152600b60248201526a7a65726f4164647265737360a81b6044820152606401620008c6565b601180546001600160a01b0319166001600160a01b0383169081179091556040519081527f4c3f3b9852ccceadd50f16518f348e2624c8f0240acdd5bc81911c0fba83ec67906020015b60405180910390a150565b6000546001600160a01b0316331462000bba5760405162461bcd60e51b8152600401620008c6906200326e565b62000bc462002576565b565b600062000bd560038362002615565b92915050565b60008054600160a01b900460ff161562000c095760405162461bcd60e51b8152600401620008c69062003244565b6002600154141562000c2f5760405162461bcd60e51b8152600401620008c690620032c4565b6002600155814281101562000c585760405162461bcd60e51b8152600401620008c690620032a3565b604051636601432f60e01b8152730fc441afd5e58a58997ac779063fd0f3754f55b590636601432f9062000c96906003908990899060040162003345565b60206040518083038186803b15801562000caf57600080fd5b505af415801562000cc4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200098e919062002f48565b6000546001600160a01b0316331462000d175760405162461bcd60e51b8152600401620008c6906200326e565b600b5462000d299062015180620033ec565b42101562000d685760405162461bcd60e51b815260206004820152600b60248201526a3c2072616d7044656c617960a81b6044820152606401620008c6565b62000d776201518042620033ec565b81101562000db85760405162461bcd60e51b815260206004820152600d60248201526c3c206d696e52616d7054696d6560981b6044820152606401620008c6565b81600010801562000dcb5750620f424082105b62000e065760405162461bcd60e51b815260206004820152600a6024820152696f75744f6652616e676560b01b6044820152606401620008c6565b60405163da2a54b160e01b815260036004820152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063da2a54b19060240160206040518083038186803b15801562000e5557600080fd5b505af415801562000e6a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e90919062002f48565b9050600062000ea16064856200352d565b90508181101562000efe578162000eba600a836200352d565b101562000ef85760405162461bcd60e51b815260206004820152600b60248201526a3e206d61784368616e676560a81b6044820152606401620008c6565b62000f4a565b62000f0b600a836200352d565b81111562000f4a5760405162461bcd60e51b815260206004820152600b60248201526a3e206d61784368616e676560a81b6044820152606401620008c6565b6009829055600a81905542600b819055600c84905560408051848152602081018490528082019290925260608201859052517fa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c2549181900360800190a150505050565b6000546001600160a01b0316331462000fd95760405162461bcd60e51b8152600401620008c6906200326e565b6305f5e1008311156200101e5760405162461bcd60e51b815260206004820152600c60248201526b3e206d61785377617046656560a01b6044820152606401620008c6565b6402540be400821115620010655760405162461bcd60e51b815260206004820152600d60248201526c3e206d617841646d696e46656560981b6044820152606401620008c6565b6305f5e100811115620010ae5760405162461bcd60e51b815260206004820152601060248201526f3e206d6178576974686472617746656560801b6044820152606401620008c6565b60088290556007839055600d81905560408051848152602081018490529081018290527fcfca96e0fef3432146913b2a5a2268a55d3f475fe057e7ffde1082b77693f4f39060600160405180910390a1505050565b6001600160a01b0381166000818152601260205260409020546003805460ff9092169291839081106200114657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316146200119a5760405162461bcd60e51b815260206004820152600d60248201526c1d1bdad95b939bdd119bdd5b99609a1b6044820152606401620008c6565b919050565b6000546001600160a01b03163314620011cc5760405162461bcd60e51b8152600401620008c6906200326e565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60405163a93f034160e01b8152600360048201526001600160a01b038316602482015260448101829052606090730fc441afd5e58a58997ac779063fd0f3754f55b59063a93f03419060640160006040518083038186803b1580156200127b57600080fd5b505af415801562001290573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620012ba919081019062002e3d565b9392505050565b600060036000018260ff1681548110620012eb57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b6000546001600160a01b03163314620013335760405162461bcd60e51b8152600401620008c6906200326e565b62000bc4620026cf565b600060026001541415620013655760405162461bcd60e51b8152600401620008c690620032c4565b6002600155600054600160a01b900460ff1615620013975760405162461bcd60e51b8152600401620008c69062003244565b8180421115620013bb5760405162461bcd60e51b8152600401620008c690620032a3565b60405163e92ad71560e01b8152730fc441afd5e58a58997ac779063fd0f3754f55b59063e92ad7159062000c96906003908990899060040162003345565b604051632c08163160e21b81526003600482015260ff82166024820152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063b02058c49060440160206040518083038186803b1580156200145157600080fd5b505af415801562001466573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000bd5919062002f48565b60008054600160a01b900460ff1615620014ba5760405162461bcd60e51b8152600401620008c69062003244565b60026001541415620014e05760405162461bcd60e51b8152600401620008c690620032c4565b60026001558142811015620015095760405162461bcd60e51b8152600401620008c690620032a3565b60405163080e7d2960e41b81526003600482015260ff8089166024830152871660448201526064810186905260848101859052730fc441afd5e58a58997ac779063fd0f3754f55b5906380e7d2909060a40160206040518083038186803b1580156200157457600080fd5b505af415801562001589573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620015af919062002f48565b60018055979650505050505050565b6000600380018260ff1681548110620015e757634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b604051632a4f48ef60e01b8152600360048201526001600160a01b03841660248201526044810183905260ff82166064820152600090730fc441afd5e58a58997ac779063fd0f3754f55b590632a4f48ef906084015b60206040518083038186803b1580156200166857600080fd5b505af41580156200167d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620016a3919062002f48565b949350505050565b606060038001805480602002602001604051908101604052809291908181526020018280548015620016fd57602002820191906000526020600020905b815481526020019060010190808311620016e8575b5050505050905090565b6040516373ee2be560e11b81526003600482015260ff80851660248301528316604482015260648101829052600090730fc441afd5e58a58997ac779063fd0f3754f55b59063e7dc57ca906084016200164f565b60606003600001805480602002602001604051908101604052809291908181526020018280548015620016fd57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162001799575050505050905090565b6004546001600160a01b03163314620018085760405162461bcd60e51b815260206004820152600860248201526710b6382a37b5b2b760c11b6044820152606401620008c6565b60405163699638a560e01b8152600360048201526001600160a01b038316602482015260448101829052730fc441afd5e58a58997ac779063fd0f3754f55b59063699638a59060640160006040518083038186803b1580156200186a57600080fd5b505af41580156200187f573d6000803e3d6000fd5b505050505050565b6000546001600160a01b03163314620018b45760405162461bcd60e51b8152600401620008c6906200326e565b600c544210620018f85760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e54dd1bdc1c195960921b6044820152606401620008c6565b60405163da2a54b160e01b815260036004820152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063da2a54b19060240160206040518083038186803b1580156200194757600080fd5b505af41580156200195c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001982919062002f48565b6009819055600a81905542600b819055600c8190556040519192507f46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc2019389162000b8291848252602082015260400190565b6000546001600160a01b03163314620019ff5760405162461bcd60e51b8152600401620008c6906200326e565b6001600160a01b03811662001a455760405162461bcd60e51b815260206004820152600b60248201526a7a65726f4164647265737360a81b6044820152606401620008c6565b601080546001600160a01b0319166001600160a01b0383169081179091556040519081527fae5a12c29e496b092467a620746b9eaf4e0e231a631a4370c233b1fac38e8e269060200162000b82565b60606003600201805480602002602001604051908101604052809291908181526020018280548015620016fd5760200282019190600052602060002090815481526020019060010190808311620016e8575050505050905090565b60405163329b20ed60e01b815260036004820152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063329b20ed906024016200070a565b6000546001600160a01b0316331462001b585760405162461bcd60e51b8152600401620008c6906200326e565b600254610100900460ff168062001b72575060025460ff16155b62001bd75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401620008c6565b600254610100900460ff1615801562001bfa576002805461ffff19166101011790555b88518a511462001c4d5760405162461bcd60e51b815260206004820152601d60248201527f636f696e734c656e67746820213d20646563696d616c734c656e6774680000006044820152606401620008c6565b6001600160a01b03821662001c9e5760405162461bcd60e51b81526020600482015260166024820152756665654469737472696275746f72203d20656d70747960501b6044820152606401620008c6565b895160008167ffffffffffffffff81111562001cca57634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801562001cf4578160200160208202803683370190505b50905060008267ffffffffffffffff81111562001d2157634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801562001d4b578160200160208202803683370190505b50905060005b8381101562001fa75760006001600160a01b03168e828151811062001d8657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316141562001ddd5760405162461bcd60e51b8152602060048201526013602482015272696e76616c6964546f6b656e4164647265737360681b6044820152606401620008c6565b60128d828151811062001e0057634e487b7160e01b600052603260045260246000fd5b602002602001015160ff16111562001e4d5760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964446563696d616c7360881b6044820152606401620008c6565b8c818151811062001e6e57634e487b7160e01b600052603260045260246000fd5b602002602001015160ff16601262001e8791906200354f565b62001e9490600a62003471565b83828151811062001eb557634e487b7160e01b600052603260045260246000fd5b6020026020010181815250508d818151811062001ee257634e487b7160e01b600052603260045260246000fd5b602002602001015182828151811062001f0b57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050806012600084848151811062001f5157634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908360ff160217905550808062001f9e906200359c565b91505062001d51565b50620f4240891062001fe55760405162461bcd60e51b81526020600482015260066024820152653e206d61784160d01b6044820152606401620008c6565b6305f5e1008811156200202a5760405162461bcd60e51b815260206004820152600c60248201526b3e206d61785377617046656560a01b6044820152606401620008c6565b6402540be400871115620020715760405162461bcd60e51b815260206004820152600d60248201526c3e206d617841646d696e46656560981b6044820152606401620008c6565b6305f5e100861115620020ba5760405162461bcd60e51b815260206004820152601060248201526f3e206d6178576974686472617746656560801b6044820152606401620008c6565b8a8a604051620020ca9062002983565b620020d792919062003212565b604051809103906000f080158015620020f4573d6000803e3d6000fd5b50600480546001600160a01b0319166001600160a01b03929092169190911790558267ffffffffffffffff8111156200213d57634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801562002167578160200160208202803683370190505b5080516200217e9160069160209091019062002991565b5081516200219490600590602085019062002991565b508051620021aa906003906020840190620029e1565b50620021b860648a6200352d565b600955620021c860648a6200352d565b600a5550505060078590556008849055600d839055601080546001600160a01b0319166001600160a01b03841617905580156200220b576002805461ff00191690555b50505050505050505050565b604051632946144b60e21b815260036004820152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063a518512c906024016200070a565b604051631ce8027360e31b8152600090730fc441afd5e58a58997ac779063fd0f3754f55b59063e7401398906200164f90600390889088908890600401620032fb565b6000546001600160a01b03163314620022c35760405162461bcd60e51b8152600401620008c6906200326e565b6001600160a01b0381166200232a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401620008c6565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6011546001600160a01b0316331480620023a957506000546001600160a01b031633145b620023ef5760405162461bcd60e51b815260206004820152601560248201527410b332b2a1b7b73a3937b63632b927b927bbb732b960591b6044820152606401620008c6565b60005b60035481101562002573576000600360000182815481106200242457634e487b7160e01b600052603260045260246000fd5b6000918252602082200154600680546001600160a01b03909216935090849081106200246057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b038416906370a082319060240160206040518083038186803b158015620024ac57600080fd5b505afa158015620024c1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620024e7919062002f48565b620024f391906200354f565b905080156200255b5760105462002518906001600160a01b0384811691168362002738565b604080516001600160a01b0384168152602081018390527fee3859efa95e525bc2bcb149b51b60a8bb4e89c647392d9d4112e03c3e73bdd6910160405180910390a15b505080806200256a906200359c565b915050620023f2565b50565b600054600160a01b900460ff16620025c85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401620008c6565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0381166000908152600b83016020526040812054819062002641906224ea00620033ec565b905042811115620026c55760006200265a42836200354f565b6001600160a01b0385166000908152600c87016020526040902054600a8701549192506402540be400916224ea009184916200269791906200352d565b620026a391906200352d565b620026af919062003407565b620026bb919062003407565b9250505062000bd5565b5060009392505050565b600054600160a01b900460ff1615620026fc5760405162461bcd60e51b8152600401620008c69062003244565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620025f83390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526200278c90849062002791565b505050565b6000620027e8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200286a9092919063ffffffff16565b8051909150156200278c578080602001905181019062002809919062002f29565b6200278c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620008c6565b6060620016a3848460008585843b620028c65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620008c6565b600080866001600160a01b03168587604051620028e4919062003156565b60006040518083038185875af1925050503d806000811462002923576040519150601f19603f3d011682016040523d82523d6000602084013e62002928565b606091505b50915091506200293a82828662002945565b979650505050505050565b6060831562002956575081620012ba565b825115620029675782518084602001fd5b8160405162461bcd60e51b8152600401620008c69190620031fd565b61124480620035f683390190565b828054828255906000526020600020908101928215620029cf579160200282015b82811115620029cf578251825591602001919060010190620029b2565b50620029dd92915062002a39565b5090565b828054828255906000526020600020908101928215620029cf579160200282015b82811115620029cf57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062002a02565b5b80821115620029dd576000815560010162002a3a565b80356001600160a01b03811681146200119a57600080fd5b600082601f83011262002a79578081fd5b8135602062002a9262002a8c83620033c5565b62003391565b80838252828201915082860187848660051b890101111562002ab2578586fd5b855b8581101562002adb5762002ac88262002a50565b8452928401929084019060010162002ab4565b5090979650505050505050565b600082601f83011262002af9578081fd5b8135602062002b0c62002a8c83620033c5565b80838252828201915082860187848660051b890101111562002b2c578586fd5b855b8581101562002adb5781358452928401929084019060010162002b2e565b600082601f83011262002b5d578081fd5b8135602062002b7062002a8c83620033c5565b80838252828201915082860187848660051b890101111562002b90578586fd5b855b8581101562002adb5762002ba68262002c2b565b8452928401929084019060010162002b92565b600082601f83011262002bca578081fd5b813567ffffffffffffffff81111562002be75762002be7620035d0565b62002bfc601f8201601f191660200162003391565b81815284602083860101111562002c11578283fd5b816020850160208301379081016020019190915292915050565b803560ff811681146200119a57600080fd5b60006020828403121562002c4f578081fd5b620012ba8262002a50565b6000806040838503121562002c6d578081fd5b62002c788362002a50565b946020939093013593505050565b60008060006060848603121562002c9b578081fd5b62002ca68462002a50565b92506020840135915062002cbd6040850162002c2b565b90509250925092565b60008060008060008060008060006101208a8c03121562002ce5578485fd5b893567ffffffffffffffff8082111562002cfd578687fd5b62002d0b8d838e0162002a68565b9a5060208c013591508082111562002d21578687fd5b62002d2f8d838e0162002b4c565b995060408c013591508082111562002d45578687fd5b62002d538d838e0162002bb9565b985060608c013591508082111562002d69578687fd5b5062002d788c828d0162002bb9565b96505060808a0135945060a08a0135935060c08a0135925060e08a0135915062002da66101008b0162002a50565b90509295985092959850929598565b60008060006040848603121562002dca578081fd5b833567ffffffffffffffff8082111562002de2578283fd5b818601915086601f83011262002df6578283fd5b81358181111562002e05578384fd5b8760208260051b850101111562002e1a578384fd5b6020928301955093505084013562002e3281620035e6565b809150509250925092565b6000602080838503121562002e50578182fd5b825167ffffffffffffffff81111562002e67578283fd5b8301601f8101851362002e78578283fd5b805162002e8962002a8c82620033c5565b80828252848201915084840188868560051b870101111562002ea9578687fd5b8694505b8385101562002ecd57805183526001949094019391850191850162002ead565b50979650505050505050565b60008060006060848603121562002eee578081fd5b833567ffffffffffffffff81111562002f05578182fd5b62002f138682870162002ae8565b9660208601359650604090950135949350505050565b60006020828403121562002f3b578081fd5b8151620012ba81620035e6565b60006020828403121562002f5a578081fd5b5051919050565b60008060006060848603121562002f76578081fd5b83359250602084013567ffffffffffffffff81111562002f94578182fd5b62002fa28682870162002ae8565b925050604084013590509250925092565b6000806040838503121562002fc6578182fd5b50508035926020909101359150565b60008060006060848603121562002fea578081fd5b505081359360208301359350604090920135919050565b6000806000806080858703121562003017578182fd5b84359350620030296020860162002c2b565b93969395505050506040820135916060013590565b60006020828403121562003050578081fd5b620012ba8262002c2b565b60008060006060848603121562003070578081fd5b6200307b8462002c2b565b92506200308b6020850162002c2b565b9150604084013590509250925092565b600080600080600060a08688031215620030b3578283fd5b620030be8662002c2b565b9450620030ce6020870162002c2b565b94979496505050506040830135926060810135926080909101359150565b6000815180845260208085019450808401835b838110156200311d57815187529582019590820190600101620030ff565b509495945050505050565b600081518084526200314281602086016020860162003569565b601f01601f19169290920160200192915050565b600082516200316a81846020870162003569565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015620031b75783516001600160a01b03168352928401929184019160010162003190565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015620031b757835183529284019291840191600101620031df565b602081526000620012ba602083018462003128565b60408152600062003227604083018562003128565b82810360208401526200323b818562003128565b95945050505050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600790820152661d1a5b595bdd5d60ca1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b848152606060208201819052810183905260006001600160fb1b0384111562003322578081fd5b8360051b8086608085013782016080019081529115156040909101529392505050565b838152606060208201526000620033606060830185620030ec565b9050826040830152949350505050565b8381528260208201526060604082015260006200323b6060830184620030ec565b604051601f8201601f1916810167ffffffffffffffff81118282101715620033bd57620033bd620035d0565b604052919050565b600067ffffffffffffffff821115620033e257620033e2620035d0565b5060051b60200190565b60008219821115620034025762003402620035ba565b500190565b6000826200342357634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115620034695781600019048211156200344d576200344d620035ba565b808516156200345b57918102915b93841c93908002906200342d565b509250929050565b6000620012ba83836000826200348a5750600162000bd5565b81620034995750600062000bd5565b8160018114620034b25760028114620034bd57620034dd565b600191505062000bd5565b60ff841115620034d157620034d1620035ba565b50506001821b62000bd5565b5060208310610133831016604e8410600b841016171562003502575081810a62000bd5565b6200350e838362003428565b8060001904821115620035255762003525620035ba565b029392505050565b60008160001904831182151516156200354a576200354a620035ba565b500290565b600082821015620035645762003564620035ba565b500390565b60005b83811015620035865781810151838201526020016200356c565b8381111562003596576000848401525b50505050565b6000600019821415620035b357620035b3620035ba565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146200257357600080fdfe60806040523480156200001157600080fd5b50604051620012443803806200124483398101604081905262000034916200021b565b600080546001600160a01b03191633908117825560405184928492918291907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35081516200008e906004906020850190620000c2565b508051620000a4906005906020840190620000c2565b5050600680546001600160a01b0319163317905550620002d5915050565b828054620000d09062000282565b90600052602060002090601f016020900481019282620000f457600085556200013f565b82601f106200010f57805160ff19168380011785556200013f565b828001600101855582156200013f579182015b828111156200013f57825182559160200191906001019062000122565b506200014d92915062000151565b5090565b5b808211156200014d576000815560010162000152565b600082601f83011262000179578081fd5b81516001600160401b0380821115620001965762000196620002bf565b604051601f8301601f19908116603f01168101908282118183101715620001c157620001c1620002bf565b81604052838152602092508683858801011115620001dd578485fd5b8491505b83821015620002005785820183015181830184015290820190620001e1565b838211156200021157848385830101525b9695505050505050565b600080604083850312156200022e578182fd5b82516001600160401b038082111562000245578384fd5b620002538683870162000168565b9350602085015191508082111562000269578283fd5b50620002788582860162000168565b9150509250929050565b600181811c908216806200029757607f821691505b60208210811415620002b957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b610f5f80620002e56000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063715018a6116100a257806395d89b411161007157806395d89b411461024b578063a457c2d714610253578063a9059cbb14610266578063dd62ed3e14610279578063f2fde38b146102b257600080fd5b8063715018a6146101f457806379cc6790146101fc5780638119c0651461020f5780638da5cb5b1461023a57600080fd5b8063313ce567116100e9578063313ce56714610181578063395093511461019057806340c10f19146101a357806342966c68146101b857806370a08231146101cb57600080fd5b806306fdde031461011b578063095ea7b31461013957806318160ddd1461015c57806323b872dd1461016e575b600080fd5b6101236102c5565b6040516101309190610e21565b60405180910390f35b61014c610147366004610de0565b610357565b6040519015158152602001610130565b6003545b604051908152602001610130565b61014c61017c366004610da5565b61036d565b60405160128152602001610130565b61014c61019e366004610de0565b610423565b6101b66101b1366004610de0565b61045a565b005b6101b66101c6366004610e09565b6104d3565b6101606101d9366004610d52565b6001600160a01b031660009081526001602052604090205490565b6101b66104e0565b6101b661020a366004610de0565b610554565b600654610222906001600160a01b031681565b6040516001600160a01b039091168152602001610130565b6000546001600160a01b0316610222565b6101236105dc565b61014c610261366004610de0565b6105eb565b61014c610274366004610de0565b610686565b610160610287366004610d73565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101b66102c0366004610d52565b610693565b6060600480546102d490610ed8565b80601f016020809104026020016040519081016040528092919081815260200182805461030090610ed8565b801561034d5780601f106103225761010080835404028352916020019161034d565b820191906000526020600020905b81548152906001019060200180831161033057829003601f168201915b5050505050905090565b600061036433848461077d565b50600192915050565b600061037a8484846108a2565b6001600160a01b0384166000908152600260209081526040808320338452909152902054828110156104045760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61041885336104138685610ec1565b61077d565b506001949350505050565b3360008181526002602090815260408083206001600160a01b03871684529091528120549091610364918590610413908690610ea9565b6000546001600160a01b031633146104845760405162461bcd60e51b81526004016103fb90610e74565b600081116104c55760405162461bcd60e51b815260206004820152600e60248201526d1e995c9bd35a5b9d105b5bdd5b9d60921b60448201526064016103fb565b6104cf8282610a85565b5050565b6104dd3382610b70565b50565b6000546001600160a01b0316331461050a5760405162461bcd60e51b81526004016103fb90610e74565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60006105608333610287565b9050818110156105be5760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b60648201526084016103fb565b6105cd83336104138585610ec1565b6105d78383610b70565b505050565b6060600580546102d490610ed8565b3360009081526002602090815260408083206001600160a01b03861684529091528120548281101561066d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016103fb565b61067c33856104138685610ec1565b5060019392505050565b60006103643384846108a2565b6000546001600160a01b031633146106bd5760405162461bcd60e51b81526004016103fb90610e74565b6001600160a01b0381166107225760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103fb565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166107df5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103fb565b6001600160a01b0382166108405760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103fb565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166109065760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103fb565b6001600160a01b0382166109685760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103fb565b610973838383610ccb565b6001600160a01b038316600090815260016020526040902054818110156109eb5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016103fb565b6109f58282610ec1565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610a2b908490610ea9565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a7791815260200190565b60405180910390a350505050565b6001600160a01b038216610adb5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016103fb565b610ae760008383610ccb565b8060036000828254610af99190610ea9565b90915550506001600160a01b03821660009081526001602052604081208054839290610b26908490610ea9565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038216610bd05760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016103fb565b610bdc82600083610ccb565b6001600160a01b03821660009081526001602052604090205481811015610c505760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016103fb565b610c5a8282610ec1565b6001600160a01b03841660009081526001602052604081209190915560038054849290610c88908490610ec1565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610895565b600654604051633003049760e21b81526001600160a01b038481166004830152602482018490529091169063c00c125c90604401600060405180830381600087803b158015610d1957600080fd5b505af1158015610d2d573d6000803e3d6000fd5b50505050505050565b80356001600160a01b0381168114610d4d57600080fd5b919050565b600060208284031215610d63578081fd5b610d6c82610d36565b9392505050565b60008060408385031215610d85578081fd5b610d8e83610d36565b9150610d9c60208401610d36565b90509250929050565b600080600060608486031215610db9578081fd5b610dc284610d36565b9250610dd060208501610d36565b9150604084013590509250925092565b60008060408385031215610df2578182fd5b610dfb83610d36565b946020939093013593505050565b600060208284031215610e1a578081fd5b5035919050565b6000602080835283518082850152825b81811015610e4d57858101830151858201604001528201610e31565b81811115610e5e5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610ebc57610ebc610f13565b500190565b600082821015610ed357610ed3610f13565b500390565b600181811c90821680610eec57607f821691505b60208210811415610f0d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220719ebbb233caffd6cce9b8805af6dcc591cb98a94a738af9495cb18166f3c55d64736f6c63430008040033a2646970667358221220037e5b93a9628f7e5c109e1a2173e4e0a563d7d452da42f9f3f2f37ca5fde5ff64736f6c63430008040033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
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.