Contract 0x1D284ff56AFEC90358faB7A96C0414f95e50FDF6

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x2ec4f0378622b45c5a4afb8b48af0cc41a3f3fecb1d764b29f4bfae87a1fb60f0x608060409066012022-04-27 6:38:54285 days 22 hrs agoLido Staked Polkadot: Deployer IN  Create: Controller0 GLMR0.2566465
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Controller

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 10 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 11 : Controller.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "IERC20.sol";
import "Initializable.sol";

import "IRelayEncoder.sol";
import "IxTokens.sol";
import "IXcmTransactor.sol";
import "ILedger.sol";
import "IAuthManager.sol";
import "ILido.sol";
import "Encoding.sol";


contract Controller is Initializable {
    using Encoding for uint256;

    // Event emitted when weight updated
    event WeightUpdated (
        uint8 index,
        uint64 newValue
    );

    // Event emitted when bond called on relay chain
    event Bond (
        address caller,
        bytes32 stash,
        bytes32 controller,
        uint256 amount
    );

    // Event emitted when bond extra called on relay chain
    event BondExtra (
        address caller,
        bytes32 stash,
        uint256 amount
    );

    // Event emitted when unbond on relay chain
    event Unbond (
        address caller,
        bytes32 stash,
        uint256 amount
    );

    // Event emitted when rebond called on relay chain
    event Rebond (
        address caller,
        bytes32 stash,
        uint256 amount
    );

    // Event emitted when withdraw called on relay chain
    event Withdraw (
        address caller,
        bytes32 stash
    );

    // Event emitted when nominate called on relay chain
    event Nominate (
        address caller,
        bytes32 stash,
        bytes32[] validators
    );

    // Event emitted when chill called on relay chain
    event Chill (
        address caller,
        bytes32 stash
    );

    // Event emitted when transfer vKSM from parachain to relay chain called
    event TransferToRelaychain (
        address from,
        bytes32 to,
        uint256 amount
    );

    // Event emitted when transfer KSM from relay chain to parachain called
    event TransferToParachain (
        bytes32 from,
        address to,
        uint256 amount
    );

    // ledger controller account
    uint16 public rootDerivativeIndex;

    // vKSM precompile
    IERC20 internal VKSM;

    // relay call builder precompile
    IRelayEncoder internal RELAY_ENCODER;

    // xcm transactor precompile
    IXcmTransactor internal XCM_TRANSACTOR;

    // xTokens precompile
    IxTokens internal X_TOKENS;

    // LIDO address
    address public LIDO;

    // first hex for encodeTransfer (defines parachain ID, 2023 for Kusama)
    bytes public hex1;

    // second hex for encodeTransfer (defines asset for transfer, fungible)
    bytes public hex2;

    // hex for determination pallet (0x1801 for Kusama)
    bytes public asDerevativeHex;

    // Second layer derivative-proxy account to index
    mapping(address => uint16) public senderToIndex;

    // Index to second layer derivative-proxy account
    mapping(uint16 => bytes32) public indexToAccount;

    // Enumerator for weights
    enum WEIGHT {
        AS_DERIVATIVE,              // 410_000_000
        BOND_BASE,                  // 600_000_000
        BOND_EXTRA_BASE,            // 1_100_000_000
        UNBOND_BASE,                // 1_250_000_000
        WITHDRAW_UNBONDED_BASE,     // 500_000_000
        WITHDRAW_UNBONDED_PER_UNIT, // 60_000
        REBOND_BASE,                // 1_200_000_000
        REBOND_PER_UNIT,            // 40_000
        CHILL_BASE,                 // 900_000_000
        NOMINATE_BASE,              // 1_000_000_000
        NOMINATE_PER_UNIT,          // 31_000_000
        TRANSFER_TO_PARA_BASE,      // 700_000_000
        TRANSFER_TO_RELAY_BASE      // 4_000_000_000
    }

    // Constant for max weight
    uint64 public MAX_WEIGHT;// = 1_835_300_000;

    // Array with current weights
    uint64[] public weights;

    // Parachain side fee on reverse transfer
    uint256 public REVERSE_TRANSFER_FEE;// = 4_000_000

    // Relay side fee on transfer
    uint256 public TRANSFER_FEE;// = 18_900_000_000

    // Controller manager role
    bytes32 internal constant ROLE_CONTROLLER_MANAGER = keccak256("ROLE_CONTROLLER_MANAGER");

    // Beacon manager role
    bytes32 internal constant ROLE_BEACON_MANAGER = keccak256("ROLE_BEACON_MANAGER");

    // Allows function calls only for registered ledgers
    modifier onlyRegistred() {
        require(senderToIndex[msg.sender] != 0, "CONTROLLER: UNREGISTERED_SENDER");
        _;
    }

    // Allows function calls only for members with role
    modifier auth(bytes32 role) {
        require(IAuthManager(ILido(LIDO).AUTH_MANAGER()).has(role, msg.sender), "CONTROLLER: UNAUTHOROZED");
        _;
    }

    // Allows function calls only for LIDO contract
    modifier onlyLido() {
        require(msg.sender == LIDO, "CONTROLLER: CALLER_NOT_LIDO");
        _;
    }

    /**
    * @notice Initialize ledger contract.
    * @param _rootDerivativeIndex - stash account id
    * @param _vKSM - vKSM contract address
    * @param _relayEncoder - relayEncoder(relaychain calls builder) contract address
    * @param _xcmTransactor - xcmTransactor(relaychain calls relayer) contract address
    * @param _xTokens - minimal allowed nominator balance
    * @param _hex1 - first hex for encodeTransfer
    * @param _hex2 - second hex for encodeTransfer
    * @param _asDerevativeHex - hex for as derevative call
    */
    function initialize(
        uint16 _rootDerivativeIndex,
        address _vKSM,
        address _relayEncoder,
        address _xcmTransactor,
        address _xTokens,
        bytes calldata _hex1,
        bytes calldata _hex2,
        bytes calldata _asDerevativeHex
    ) external initializer {
        require(address(VKSM) == address(0), "CONTROLLER: ALREADY_INITIALIZED");

        rootDerivativeIndex = _rootDerivativeIndex;

        VKSM = IERC20(_vKSM);
        RELAY_ENCODER = IRelayEncoder(_relayEncoder);
        XCM_TRANSACTOR = IXcmTransactor(_xcmTransactor);
        X_TOKENS = IxTokens(_xTokens);

        hex1 = _hex1;
        hex2 = _hex2;
        asDerevativeHex = _asDerevativeHex;
    }

    /**
    * @notice Get current weight by enum
    * @param weightType - enum index of weight
    */
    function getWeight(WEIGHT weightType) public view returns(uint64) {
        return weights[uint256(weightType)];
    }

    /**
    * @notice Set new max weight. Can be called only by ROLE_CONTROLLER_MANAGER
    * @param _maxWeight - max weight
    */
    function setMaxWeight(uint64 _maxWeight) external auth(ROLE_CONTROLLER_MANAGER) {
        MAX_WEIGHT = _maxWeight;
    }

    /**
    * @notice Set new REVERSE_TRANSFER_FEE
    * @param _reverseTransferFee - new fee
    */
    function setReverseTransferFee(uint256 _reverseTransferFee) external auth(ROLE_CONTROLLER_MANAGER) {
        REVERSE_TRANSFER_FEE = _reverseTransferFee;
    }

    /**
    * @notice Set new TRANSFER_FEE
    * @param _transferFee - new fee
    */
    function setTransferFee(uint256 _transferFee) external auth(ROLE_CONTROLLER_MANAGER) {
        TRANSFER_FEE = _transferFee;
    }

    /**
    * @notice Set new relay encoder
    * @param _relayEncoder - new relay encoder
    */
    function setRelayEncoder(address _relayEncoder) external auth(ROLE_BEACON_MANAGER) {
        require(_relayEncoder != address(0), "CONTROLLER: ENCODER_ZERO_ADDRESS");
        RELAY_ENCODER = IRelayEncoder(_relayEncoder);
    }

    /**
    * @notice Set new hexes parametes for encodeTransfer
    * @param _hex1 - first hex for encodeTransfer
    * @param _hex2 - second hex for encodeTransfer
    * @param _asDerevativeHex - hex for as derevative call
    */
    function updateHexParameters(bytes calldata _hex1, bytes calldata _hex2, bytes calldata _asDerevativeHex) external auth(ROLE_CONTROLLER_MANAGER) {
        hex1 = _hex1;
        hex2 = _hex2;
        asDerevativeHex = _asDerevativeHex;
    }

    /**
    * @notice Set LIDO address. Function can be called only once
    * @param _lido - LIDO address
    */
    function setLido(address _lido) external {
        require(LIDO == address(0) && _lido != address(0), "CONTROLLER: LIDO_ALREADY_INITIALIZED");
        LIDO = _lido;
    }

    /**
    * @notice Update weights array. Weight updated only if weight = _weight | 1 << 65
    * @param _weights - weights array
    */
    function setWeights(
        uint128[] calldata _weights
    ) external auth(ROLE_CONTROLLER_MANAGER) {
        require(_weights.length == uint256(type(WEIGHT).max) + 1, "CONTROLLER: WRONG_WEIGHTS_SIZE");
        for (uint256 i = 0; i < _weights.length; ++i) {
            if ((_weights[i] >> 64) > 0) { // if _weights[i] = _weights[i] | 1 << 65 we must update i-th weight
                if (weights.length == i) {
                    weights.push(0);
                }

                weights[i] = uint64(_weights[i]);
                emit WeightUpdated(uint8(i), weights[i]);
            }
        }
    }

    /**
    * @notice Register new ledger contract
    * @param index - index of ledger contract
    * @param accountId - relay chain address of ledger
    * @param paraAddress - parachain address of ledger
    */
    function newSubAccount(uint16 index, bytes32 accountId, address paraAddress) external onlyLido {
        require(indexToAccount[index + 1] == bytes32(0), "CONTROLLER: ALREADY_REGISTERED");

        senderToIndex[paraAddress] = index + 1;
        indexToAccount[index + 1] = accountId;
    }

    /**
    * @notice Unregister ledger contract
    * @param paraAddress - parachain address of ledger
    */
    function deleteSubAccount(address paraAddress) external onlyLido {
        require(senderToIndex[paraAddress] > 0, "CONTROLLER: UNREGISTERED_LEDGER");

        delete indexToAccount[senderToIndex[paraAddress]];
        delete senderToIndex[paraAddress];
    }

    /**
    * @notice Nominate validators from ledger on relay chain
    * @param validators - validators addresses to nominate
    */
    function nominate(bytes32[] calldata validators) external onlyRegistred {
        uint256[] memory convertedValidators = new uint256[](validators.length);
        for (uint256 i = 0; i < validators.length; ++i) {
            convertedValidators[i] = uint256(validators[i]);
        }
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.NOMINATE_BASE) + getWeight(WEIGHT.NOMINATE_PER_UNIT) * uint64(validators.length),
            RELAY_ENCODER.encode_nominate(convertedValidators)
        );

        emit Nominate(msg.sender, getSenderAccount(), validators);
    }

    /**
    * @notice Bond KSM of ledger on relay chain
    * @param controller - controller which used to bond
    * @param amount - amount of KSM to bond
    */
    function bond(bytes32 controller, uint256 amount) external onlyRegistred {
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.BOND_BASE),
            RELAY_ENCODER.encode_bond(uint256(controller), amount, bytes(hex"00"))
        );

        emit Bond(msg.sender, getSenderAccount(), controller, amount);
    }

    /**
    * @notice Bond extra KSM of ledger on relay chain
    * @param amount - extra amount of KSM to bond
    */
    function bondExtra(uint256 amount) external onlyRegistred {
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.BOND_EXTRA_BASE),
            RELAY_ENCODER.encode_bond_extra(amount)
        );

        emit BondExtra(msg.sender, getSenderAccount(), amount);
    }

    /**
    * @notice Unbond KSM of ledger on relay chain
    * @param amount - amount of KSM to unbond
    */
    function unbond(uint256 amount) external onlyRegistred {
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.UNBOND_BASE),
            RELAY_ENCODER.encode_unbond(amount)
        );

        emit Unbond(msg.sender, getSenderAccount(), amount);
    }

    /**
    * @notice Withdraw unbonded tokens (move unbonded tokens to free)
    * @param slashingSpans - number of slashes received by ledger in case if we trying set ledger bonded balance < min, 
    in other cases = 0
    */
    function withdrawUnbonded(uint32 slashingSpans) external onlyRegistred {
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.WITHDRAW_UNBONDED_BASE) + getWeight(WEIGHT.WITHDRAW_UNBONDED_PER_UNIT) * slashingSpans,
            RELAY_ENCODER.encode_withdraw_unbonded(slashingSpans)
        );

        emit Withdraw(msg.sender, getSenderAccount());
    }

    /**
    * @notice Rebond KSM of ledger from unbonded chunks on relay chain
    * @param amount - amount of KSM to rebond
    * @param unbondingChunks - amount of unbonding chunks to rebond
    */
    function rebond(uint256 amount, uint256 unbondingChunks) external onlyRegistred {
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.REBOND_BASE) + getWeight(WEIGHT.REBOND_PER_UNIT) * uint64(unbondingChunks),
            RELAY_ENCODER.encode_rebond(amount)
        );

        emit Rebond(msg.sender, getSenderAccount(), amount);
    }

    /**
    * @notice Put ledger to chill mode
    */
    function chill() external onlyRegistred {
        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.CHILL_BASE),
            RELAY_ENCODER.encode_chill()
        );

        emit Chill(msg.sender, getSenderAccount());
    }

    /**
    * @notice Transfer KSM from relay chain to parachain
    * @param amount - amount of KSM to transfer
    */
    function transferToParachain(uint256 amount) external onlyRegistred {
        // to - msg.sender, from - getSenderIndex()
        uint256 parachain_fee = REVERSE_TRANSFER_FEE;

        callThroughDerivative(
            getSenderIndex(),
            getWeight(WEIGHT.TRANSFER_TO_PARA_BASE),
            //encodeReverseTransfer(msg.sender, amount)
            encodeLimitReserveTransfer(msg.sender, amount, getWeight(WEIGHT.TRANSFER_TO_PARA_BASE))
        );

        // compensate parachain side fee on reverse transfer
        if (amount <= parachain_fee) {
            // if amount less than fee just transfer amount
            VKSM.transfer(msg.sender, amount);
        }
        else {
            // else just compensate fee
            VKSM.transfer(msg.sender, parachain_fee);
        }

        emit TransferToParachain(getSenderAccount(), msg.sender, amount);
    }

    /**
    * @notice Transfer vKSM from parachain to relay chain
    * @param amount - amount of vKSM to transfer
    */
    function transferToRelaychain(uint256 amount) external onlyRegistred {
        // to - getSenderIndex(), from - msg.sender
        VKSM.transferFrom(msg.sender, address(this), amount);
        IxTokens.Multilocation memory destination;
        destination.parents = 1;
        destination.interior = new bytes[](1);
        destination.interior[0] = bytes.concat(bytes1(hex"01"), getSenderAccount(), bytes1(hex"00")); // X2, NetworkId: Any
        X_TOKENS.transfer_with_fee(address(VKSM), amount, TRANSFER_FEE, destination, getWeight(WEIGHT.TRANSFER_TO_RELAY_BASE));

        emit TransferToRelaychain(msg.sender, getSenderAccount(), amount);
    }

    /**
    * @notice Get index of registered ledger
    */
    function getSenderIndex() internal returns(uint16) {
        return senderToIndex[msg.sender] - 1;
    }

    /**
    * @notice Get relay chain address of msg.sender
    */
    function getSenderAccount() internal returns(bytes32) {
        return indexToAccount[senderToIndex[msg.sender]];
    }

    /**
    * @notice Send call to relay cahin through xcm transactor
    * @param index - index of ledger on relay chain
    * @param weight - fees on tx execution
    * @param call - bytes for tx execution
    */
    function callThroughDerivative(uint16 index, uint64 weight, bytes memory call) internal {
        bytes memory le_index = new bytes(2);
        le_index[0] = bytes1(uint8(index));
        le_index[1] = bytes1(uint8(index >> 8));

        uint64 total_weight = weight + getWeight(WEIGHT.AS_DERIVATIVE);
        require(total_weight <= MAX_WEIGHT, "CONTROLLER: TOO_MUCH_WEIGHT");

        XCM_TRANSACTOR.transact_through_derivative(
            0, // The transactor to be used
            rootDerivativeIndex, // The index to be used
            address(VKSM), // Address of the currencyId of the asset to be used for fees
            total_weight, // The weight we want to buy in the destination chain
            bytes.concat(asDerevativeHex, le_index, call) // The inner call to be executed in the destination chain
        );
    }

    /**
    * @notice Encoding bytes to call transfer on relay chain
    * @param to - address of KSM receiver
    * @param amount - amount of KSM to send
    */
    function encodeReverseTransfer(address to, uint256 amount) internal returns(bytes memory) {
        return bytes.concat(
            hex1,
            abi.encodePacked(to),
            hex2,
            amount.scaleCompactUint(),
            hex"00000000"
        );
    }

    /**
    * @notice Encoding bytes to call limit reserve transfer on relay chain
    * @param to - address of KSM receiver
    * @param amount - amount of KSM to send
    * @param weight - weight for xcm call
    */
    function encodeLimitReserveTransfer(address to, uint256 amount, uint64 weight) internal returns(bytes memory) {
        return bytes.concat(
            hex1,
            abi.encodePacked(to),
            hex2,
            amount.scaleCompactUint(),
            hex"0000000001",
            uint256(weight).scaleCompactUint()
        );
    }
}

File 2 of 11 : 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 3 of 11 : 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 11 : IRelayEncoder.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @author The Moonbeam Team
/// @title The interface through which solidity contracts will interact with Relay Encoder
/// We follow this same interface including four-byte function selectors, in the precompile that
/// wraps the pallet
interface IRelayEncoder {
    // dev Encode 'bond' relay call
    // Selector: 31627376
    // @param controller_address: Address of the controller
    // @param amount: The amount to bond
    // @param reward_destination: the account that should receive the reward
    // @returns The bytes associated with the encoded call
    function encode_bond(uint256 controller_address, uint256 amount, bytes memory reward_destination) external view returns (bytes memory result);

    // dev Encode 'bond_extra' relay call
    // Selector: 49def326
    // @param amount: The extra amount to bond
    // @returns The bytes associated with the encoded call
    function encode_bond_extra(uint256 amount) external view returns (bytes memory result);

    // dev Encode 'unbond' relay call
    // Selector: bc4b2187
    // @param amount: The amount to unbond
    // @returns The bytes associated with the encoded call
    function encode_unbond(uint256 amount) external view returns (bytes memory result);

    // dev Encode 'withdraw_unbonded' relay call
    // Selector: 2d220331
    // @param slashes: Weight hint, number of slashing spans
    // @returns The bytes associated with the encoded call
    function encode_withdraw_unbonded(uint32 slashes) external view returns (bytes memory result);

    // dev Encode 'validate' relay call
    // Selector: 3a0d803a
    // @param comission: Comission of the validator as parts_per_billion
    // @param blocked: Whether or not the validator is accepting more nominations
    // @returns The bytes associated with the encoded call
    // selector: 3a0d803a
    // function encode_validate(uint256 comission, bool blocked) external pure returns (bytes memory result);

    // dev Encode 'nominate' relay call
    // Selector: a7cb124b
    // @param nominees: An array of AccountIds corresponding to the accounts we will nominate
    // @param blocked: Whether or not the validator is accepting more nominations
    // @returns The bytes associated with the encoded call
    function encode_nominate(uint256 [] memory nominees) external view returns (bytes memory result);

    // dev Encode 'chill' relay call
    // Selector: bc4b2187
    // @returns The bytes associated with the encoded call
    function encode_chill() external view returns (bytes memory result);

    // dev Encode 'set_payee' relay call
    // Selector: 9801b147
    // @param reward_destination: the account that should receive the reward
    // @returns The bytes associated with the encoded call
    // function encode_set_payee(bytes memory reward_destination) external pure returns (bytes memory result);

    // dev Encode 'set_controller' relay call
    // Selector: 7a8f48c2
    // @param controller: The controller address
    // @returns The bytes associated with the encoded call
    // function encode_set_controller(uint256 controller) external pure returns (bytes memory result);

    // dev Encode 'rebond' relay call
    // Selector: add6b3bf
    // @param amount: The amount to rebond
    // @returns The bytes associated with the encoded call
    function encode_rebond(uint256 amount) external view returns (bytes memory result);
}

File 5 of 11 : IxTokens.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title Xtokens Interface
 *
 * The interface through which solidity contracts will interact with xtokens pallet
 *
 */
interface IxTokens {
    // A multilocation is defined by its number of parents and the encoded junctions (interior)
    struct Multilocation {
        uint8 parents;
        bytes [] interior;
    }

    /** Transfer a token through XCM based on its currencyId
     *
     * @dev The token transfer burns/transfers the corresponding amount before sending
     * @param currency_address The ERC20 address of the currency we want to transfer
     * @param amount The amount of tokens we want to transfer
     * @param destination The Multilocation to which we want to send the tokens
     * @param weight The weight we want to buy in the destination chain
     */
    function transfer(address currency_address, uint256 amount, Multilocation memory destination, uint64 weight) external;

    /** Transfer a token through XCM based on its currencyId
     *
     * @dev The token transfer burns/transfers the corresponding amount before sending
     * @param currency_address The ERC20 address of the currency we want to transfer
     * @param amount The amount of tokens we want to transfer
     * @param fee The amount of fees
     * @param destination The Multilocation to which we want to send the tokens
     * @param weight The weight we want to buy in the destination chain
     */
    function transfer_with_fee(address currency_address, uint256 amount, uint256 fee, Multilocation memory destination, uint64 weight) external;

    /** Transfer a token through XCM based on its currencyId
     *
     * @dev The token transfer burns/transfers the corresponding amount before sending
     * @param asset The asset we want to transfer, defined by its multilocation. Currently only Concrete Fungible assets
     * @param amount The amount of tokens we want to transfer
     * @param destination The Multilocation to which we want to send the tokens
     * @param weight The weight we want to buy in the destination chain
     */
    function transfer_multiasset(Multilocation memory asset, uint256 amount, Multilocation memory destination, uint64 weight) external;
}

// Function selector reference
// {
// "b9f813ff": "transfer(address,uint256,(uint8,bytes[]),uint64)",
// "b38c60fa": "transfer_multiasset((uint8,bytes[]),uint256,(uint8,bytes[]),uint64)"
//}

File 6 of 11 : IXcmTransactor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title Xcm Transactor Interface
 *
 * The interface through which solidity contracts will interact with xcm transactor pallet
 *
 */
interface IXcmTransactor {
    // A multilocation is defined by its number of parents and the encoded junctions (interior)
    struct Multilocation {
        uint8 parents;
        bytes [] interior;
    }

    /** Get index of an account in xcm transactor
     *
     * @param index The index of which we want to retrieve the account
     */
    function index_to_account(uint16 index) external view returns(address);

    /** Get transact info of a multilocation
     * Selector 71b0edfa
     * @param multilocation The location for which we want to retrieve transact info
     */
    function transact_info(Multilocation memory multilocation)
        external view  returns(uint64, uint256, uint64, uint64, uint256);

    /** Transact through XCM using fee based on its multilocation
     *
     * @dev The token transfer burns/transfers the corresponding amount before sending
     * @param transactor The transactor to be used
     * @param index The index to be used
     * @param fee_asset The asset in which we want to pay fees.
     * It has to be a reserve of the destination chain
     * @param weight The weight we want to buy in the destination chain
     * @param inner_call The inner call to be executed in the destination chain
     */
    function transact_through_derivative_multilocation(
        uint8 transactor,
        uint16 index,
        Multilocation memory fee_asset,
        uint64 weight,
        bytes memory inner_call
    ) external;

    /** Transact through XCM using fee based on its currency_id
     *
     * @dev The token transfer burns/transfers the corresponding amount before sending
     * @param transactor The transactor to be used
     * @param index The index to be used
     * @param currency_id Address of the currencyId of the asset to be used for fees
     * It has to be a reserve of the destination chain
     * @param weight The weight we want to buy in the destination chain
     * @param inner_call The inner call to be executed in the destination chain
     */
    function transact_through_derivative(
        uint8 transactor,
        uint16 index,
        address currency_id,
        uint64 weight,
        bytes memory inner_call
    ) external;
}

File 7 of 11 : ILedger.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "Types.sol";

interface ILedger {
    function initialize(
        bytes32 _stashAccount,
        bytes32 controllerAccount,
        address vKSM,
        address controller,
        uint128 minNominatorBalance,
        address lido,
        uint128 _minimumBalance,
        uint256 _maxUnlockingChunks
    ) external;

    function pushData(uint64 eraId, Types.OracleData calldata staking) external;

    function nominate(bytes32[] calldata validators) external;

    function status() external view returns (Types.LedgerStatus);

    function isEmpty() external view returns (bool);

    function stashAccount() external view returns (bytes32);

    function totalBalance() external view returns (uint128);

    function setRelaySpecs(uint128 minNominatorBalance, uint128 minimumBalance, uint256 _maxUnlockingChunks) external;

    function cachedTotalBalance() external view returns (uint128);

    function transferDownwardBalance() external view returns (uint128);
}

File 8 of 11 : Types.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface Types {
    struct Fee{
        uint16 total;
        uint16 operators;
        uint16 developers;
        uint16 treasury;
    }

    struct Stash {
        bytes32 stashAccount;
        uint64  eraId;
    }

    enum LedgerStatus {
        // bonded but not participate in staking
        Idle,
        // participate as nominator
        Nominator,
        // participate as validator
        Validator,
        // not bonded not participate in staking
        None
    }

    struct UnlockingChunk {
        uint128 balance;
        uint64 era;
    }

    struct OracleData {
        bytes32 stashAccount;
        bytes32 controllerAccount;
        LedgerStatus stakeStatus;
        // active part of stash balance
        uint128 activeBalance;
        // locked for stake stash balance.
        uint128 totalBalance;
        // totalBalance = activeBalance + sum(unlocked.balance)
        UnlockingChunk[] unlocking;
        uint32[] claimedRewards;
        // stash account balance. It includes locked (totalBalance) balance assigned
        // to a controller.
        uint128 stashBalance;
        // slashing spans for ledger
        uint32 slashingSpans;
    }

    struct RelaySpec {
        uint16 maxValidatorsPerLedger;
        uint128 minNominatorBalance;
        uint128 ledgerMinimumActiveBalance;
        uint256 maxUnlockingChunks;
    }
}

File 9 of 11 : IAuthManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAuthManager {
    function has(bytes32 role, address member) external view returns (bool);

    function add(bytes32 role, address member) external;

    function remove(bytes32 role, address member) external;
}

File 10 of 11 : ILido.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "Types.sol";

interface ILido {
    function MAX_ALLOWABLE_DIFFERENCE() external view returns(uint128);

    function deposit(uint256 amount) external returns (uint256);

    function distributeRewards(uint256 totalRewards, uint256 ledgerBalance) external;

    function distributeLosses(uint256 totalLosses, uint256 ledgerBalance) external;

    function getStashAccounts() external view returns (bytes32[] memory);

    function getLedgerAddresses() external view returns (address[] memory);

    function ledgerStake(address ledger) external view returns (uint256);

    function transferFromLedger(uint256 amount, uint256 excess) external;

    function transferFromLedger(uint256 amount) external;

    function transferToLedger(uint256 amount) external;

    function flushStakes() external;

    function findLedger(bytes32 stash) external view returns (address);

    function AUTH_MANAGER() external returns(address);

    function ORACLE_MASTER() external view returns (address);

    function decimals() external view returns (uint8);

    function getPooledKSMByShares(uint256 sharesAmount) external view returns (uint256);

    function getSharesByPooledKSM(uint256 amount) external view returns (uint256);

    function transfer(address recipient, uint256 amount) external returns (bool);

    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}

File 11 of 11 : Encoding.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library Encoding {
    /**
    * @notice Converting uint256 value to le bytes
    * @param value - uint256 value
    * @param len - length of output bytes array
    */
    function toLeBytes(uint256 value, uint256 len) internal pure returns(bytes memory) {
        bytes memory out = new bytes(len);
        for (uint256 idx = 0; idx < len; ++idx) {
            out[idx] = bytes1(uint8(value));
            value = value >> 8;
        }
        return out;
    }

    /**
    * @notice Converting uint256 value to bytes
    * @param value - uint256 value
    */
    function scaleCompactUint(uint256 value) internal pure returns(bytes memory) {
        if (value < 1<<6) {
            return toLeBytes(value << 2, 1);
        }
        else if(value < 1 << 14) {
            return toLeBytes((value << 2) + 1, 2);
        }
        else if(value < 1 << 30) {
            return toLeBytes((value << 2) + 2, 4);
        }
        else {
            uint256 numBytes = 0;
            {
                uint256 m = value;
                for (; numBytes < 256 && m != 0; ++numBytes) {
                    m = m >> 8;
                }
            }

            bytes memory out = new bytes(numBytes + 1);
            out[0] = bytes1(uint8(((numBytes - 4) << 2) + 3));
            for (uint256 i = 0; i < numBytes; ++i) {
                out[i + 1] = bytes1(uint8(value & 0xFF));
                value = value >> 8;
            }
            return out;
        }
    }
}

Settings
{
  "evmVersion": "istanbul",
  "optimizer": {
    "enabled": true,
    "runs": 10
  },
  "libraries": {
    "Controller.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"controller","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Bond","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BondExtra","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"}],"name":"Chill","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"},{"indexed":false,"internalType":"bytes32[]","name":"validators","type":"bytes32[]"}],"name":"Nominate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Rebond","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"from","type":"bytes32"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferToParachain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"bytes32","name":"to","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferToRelaychain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unbond","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"index","type":"uint8"},{"indexed":false,"internalType":"uint64","name":"newValue","type":"uint64"}],"name":"WeightUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes32","name":"stash","type":"bytes32"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"LIDO","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WEIGHT","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REVERSE_TRANSFER_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TRANSFER_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"asDerevativeHex","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"controller","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"bond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"bondExtra","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"chill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"paraAddress","type":"address"}],"name":"deleteSubAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Controller.WEIGHT","name":"weightType","type":"uint8"}],"name":"getWeight","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hex1","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hex2","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"indexToAccount","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_rootDerivativeIndex","type":"uint16"},{"internalType":"address","name":"_vKSM","type":"address"},{"internalType":"address","name":"_relayEncoder","type":"address"},{"internalType":"address","name":"_xcmTransactor","type":"address"},{"internalType":"address","name":"_xTokens","type":"address"},{"internalType":"bytes","name":"_hex1","type":"bytes"},{"internalType":"bytes","name":"_hex2","type":"bytes"},{"internalType":"bytes","name":"_asDerevativeHex","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"index","type":"uint16"},{"internalType":"bytes32","name":"accountId","type":"bytes32"},{"internalType":"address","name":"paraAddress","type":"address"}],"name":"newSubAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"validators","type":"bytes32[]"}],"name":"nominate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"unbondingChunks","type":"uint256"}],"name":"rebond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rootDerivativeIndex","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"senderToIndex","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lido","type":"address"}],"name":"setLido","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_maxWeight","type":"uint64"}],"name":"setMaxWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_relayEncoder","type":"address"}],"name":"setRelayEncoder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reverseTransferFee","type":"uint256"}],"name":"setReverseTransferFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_transferFee","type":"uint256"}],"name":"setTransferFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128[]","name":"_weights","type":"uint128[]"}],"name":"setWeights","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferToParachain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferToRelaychain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unbond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_hex1","type":"bytes"},{"internalType":"bytes","name":"_hex2","type":"bytes"},{"internalType":"bytes","name":"_asDerevativeHex","type":"bytes"}],"name":"updateHexParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"weights","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"slashingSpans","type":"uint32"}],"name":"withdrawUnbonded","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50612d77806100206000396000f3fe608060405234801561001057600080fd5b50600436106101745760003560e01c8062244eb8146101795780630b2f9ad51461019757806327de9e321461019f5780632b8a3ae6146101b457806336265192146101bc5780633fdc4f36146101d357806349e5c7ae146101f35780634a055eb7146101fb57806351f932151461020e578063548a6706146102215780635aa41175146102345780635d4ebc4014610247578063657a8bba1461025a5780637d774e311461026d5780637f3e3f3b146102805780638977e3c6146102935780638b21f170146102a65780638f02bb5b146102d157806391b00a30146102e457806392ceb703146102f75780639632acf7146103225780639dad7d1314610335578063a68a740c1461033e578063a83427fd14610365578063aac271ed14610389578063ac91326d1461039c578063b5f163ff146103af578063c210aefd146103c2578063e4a28a52146103d5578063eaca88de146103e8578063f5330e96146103fb575b600080fd5b61018161040e565b60405161018e91906122eb565b60405180910390f35b61018161049c565b6101b26101ad366004612305565b6104a9565b005b6101b26105b3565b6101c5600d5481565b60405190815260200161018e565b6101c56101e1366004612330565b60096020526000908152604090205481565b61018161068d565b6101b261020936600461234b565b61069a565b6101b261021c366004612374565b6107cf565b6101b261022f366004612396565b6108b8565b6101b2610242366004612404565b610990565b6101b2610255366004612305565b610ad2565b6101b2610268366004612374565b610c76565b6101b261027b3660046124c0565b610d45565b6101b261028e366004612521565b610de0565b6101b26102a13660046124c0565b61110f565b6004546102b9906001600160a01b031681565b6040516001600160a01b03909116815260200161018e565b6101b26102df366004612305565b6112ac565b6101b26102f2366004612305565b6113c4565b61030a610305366004612562565b6114dc565b6040516001600160401b03909116815260200161018e565b6101b2610330366004612583565b611532565b6101c5600c5481565b6000546103529062010000900461ffff1681565b60405161ffff909116815260200161018e565b6103526103733660046124c0565b60086020526000908152604090205461ffff1681565b6101b26103973660046124c0565b611632565b6101b26103aa3660046125c3565b611702565b61030a6103bd366004612305565b611905565b6101b26103d0366004612305565b611942565b600a5461030a906001600160401b031681565b6101b26103f6366004612305565b611b43565b6101b2610409366004612521565b611be3565b6007805461041b906126b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610447906126b6565b80156104945780601f1061046957610100808354040283529160200191610494565b820191906000526020600020905b81548152906001019060200180831161047757829003601f168201915b505050505081565b6006805461041b906126b6565b3360009081526008602052604090205461ffff166104e25760405162461bcd60e51b81526004016104d9906126f1565b60405180910390fd5b61056e6104ed611d5b565b6104f760036114dc565b600154604051632cd6121760e01b8152600481018690526001600160a01b0390911690632cd61217906024015b600060405180830381865afa158015610541573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610569919081019061273e565b611d80565b7fde937a10138f92e89b0d77ec07df274c490249fe93b77ed997a71754168ffd9d33610598611f2c565b836040516105a8939291906127ea565b60405180910390a150565b3360009081526008602052604090205461ffff166105e35760405162461bcd60e51b81526004016104d9906126f1565b61064b6105ee611d5b565b6105f860086114dc565b600160009054906101000a90046001600160a01b03166001600160a01b031663bc4b21876040518163ffffffff1660e01b8152600401600060405180830381865afa158015610541573d6000803e3d6000fd5b7fba6e8b6a3abbc5a52acdb23c508cb348f0698caf25b067a2bb3b013967b7e27b33610675611f2c565b60405161068392919061280b565b60405180910390a1565b6005805461041b906126b6565b600080516020612d22833981519152600460009054906101000a90046001600160a01b03166001600160a01b031663a1e206c76040518163ffffffff1660e01b81526004016020604051808303816000875af11580156106fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107229190612824565b6001600160a01b031663eff11b2c82336040518363ffffffff1660e01b815260040161074f929190612841565b602060405180830381865afa15801561076c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107909190612858565b6107ac5760405162461bcd60e51b81526004016104d99061287a565b50600a80546001600160401b0319166001600160401b0392909216919091179055565b3360009081526008602052604090205461ffff166107ff5760405162461bcd60e51b81526004016104d9906126f1565b61085961080a611d5b565b61081460016114dc565b6001805460408051808201825292835260006020840152516318b139bb60e11b81526001600160a01b03909116916331627376916105249189918991906004016128ac565b7fd5dbc8fa383c86d1f241084297dadc2b7c6c247092d1714f8de1c4a9cf866a9d33610883611f2c565b604080516001600160a01b03909316835260208301919091528101849052606081018390526080015b60405180910390a15050565b3360009081526008602052604090205461ffff166108e85760405162461bcd60e51b81526004016104d9906126f1565b6109586108f3611d5b565b8263ffffffff1661090460056114dc565b61090e91906128ea565b61091860046114dc565b6109229190612919565b600154604051632d22033160e01b815263ffffffff861660048201526001600160a01b0390911690632d22033190602401610524565b7fb18c630f7b4f080f2ce1a87d68860e67aef56b0978e448ed92312da4eebeb16033610982611f2c565b6040516105a892919061280b565b600080516020612d22833981519152600460009054906101000a90046001600160a01b03166001600160a01b031663a1e206c76040518163ffffffff1660e01b81526004016020604051808303816000875af11580156109f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a189190612824565b6001600160a01b031663eff11b2c82336040518363ffffffff1660e01b8152600401610a45929190612841565b602060405180830381865afa158015610a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a869190612858565b610aa25760405162461bcd60e51b81526004016104d99061287a565b610aae600588886121fa565b50610abb600686866121fa565b50610ac8600784846121fa565b5050505050505050565b3360009081526008602052604090205461ffff16610b025760405162461bcd60e51b81526004016104d9906126f1565b600c54610b2e610b10611d5b565b610b1a600b6114dc565b6105693386610b29600b6114dc565b611f50565b808211610bb65760005460405163a9059cbb60e01b8152600160201b9091046001600160a01b03169063a9059cbb90610b6d903390869060040161280b565b6020604051808303816000875af1158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb09190612858565b50610c33565b60005460405163a9059cbb60e01b8152600160201b9091046001600160a01b03169063a9059cbb90610bee903390859060040161280b565b6020604051808303816000875af1158015610c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c319190612858565b505b7f1f6ca76d5d6a8880c6019f026dbdc28fb59227f3effef64eecc4216b30f5b10a610c5c611f2c565b6040805191825233602083015281018490526060016108ac565b3360009081526008602052604090205461ffff16610ca65760405162461bcd60e51b81526004016104d9906126f1565b610d0b610cb1611d5b565b82610cbc60076114dc565b610cc691906128ea565b610cd060066114dc565b610cda9190612919565b60015460405163add6b3bf60e01b8152600481018790526001600160a01b039091169063add6b3bf90602401610524565b7f83a9fc7121ede847212810044c9749bb4dd5b6febfa9ad3742eb3d40075962d633610d35611f2c565b846040516108ac939291906127ea565b6004546001600160a01b0316158015610d6657506001600160a01b03811615155b610dbe5760405162461bcd60e51b8152602060048201526024808201527f434f4e54524f4c4c45523a204c49444f5f414c52454144595f494e495449414c6044820152631256915160e21b60648201526084016104d9565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020612d22833981519152600460009054906101000a90046001600160a01b03166001600160a01b031663a1e206c76040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610e44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e689190612824565b6001600160a01b031663eff11b2c82336040518363ffffffff1660e01b8152600401610e95929190612841565b602060405180830381865afa158015610eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed69190612858565b610ef25760405162461bcd60e51b81526004016104d99061287a565b610efe600c600161295a565b8214610f4c5760405162461bcd60e51b815260206004820152601e60248201527f434f4e54524f4c4c45523a2057524f4e475f574549474854535f53495a45000060448201526064016104d9565b60005b828110156111095760006040858584818110610f6d57610f6d612972565b9050602002016020810190610f829190612988565b6001600160801b0316901c6001600160801b031611156110f957600b54811415610ffa57600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db96004820401805460039092166008026101000a6001600160401b03021990911690555b83838281811061100c5761100c612972565b90506020020160208101906110219190612988565b600b828154811061103457611034612972565b90600052602060002090600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b031602179055507feaeb3c7640733be05f48249c359ca80c384f5e76d5f39b80ea1c8d1fd86e146881600b83815481106110a2576110a2612972565b90600052602060002090600491828204019190066008029054906101000a90046001600160401b03166040516110f092919060ff9290921682526001600160401b0316602082015260400190565b60405180910390a15b611102816129b1565b9050610f4f565b50505050565b7f9336eb28e461adb6ba7e620f5006a6952a65a21a4db92c2edb104bf7f1c38c63600460009054906101000a90046001600160a01b03166001600160a01b031663a1e206c76040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a99190612824565b6001600160a01b031663eff11b2c82336040518363ffffffff1660e01b81526004016111d6929190612841565b602060405180830381865afa1580156111f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112179190612858565b6112335760405162461bcd60e51b81526004016104d99061287a565b6001600160a01b0382166112895760405162461bcd60e51b815260206004820181905260248201527f434f4e54524f4c4c45523a20454e434f4445525f5a45524f5f4144445245535360448201526064016104d9565b50600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020612d22833981519152600460009054906101000a90046001600160a01b03166001600160a01b031663a1e206c76040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113349190612824565b6001600160a01b031663eff11b2c82336040518363ffffffff1660e01b8152600401611361929190612841565b602060405180830381865afa15801561137e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a29190612858565b6113be5760405162461bcd60e51b81526004016104d99061287a565b50600d55565b600080516020612d22833981519152600460009054906101000a90046001600160a01b03166001600160a01b031663a1e206c76040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611428573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144c9190612824565b6001600160a01b031663eff11b2c82336040518363ffffffff1660e01b8152600401611479929190612841565b602060405180830381865afa158015611496573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ba9190612858565b6114d65760405162461bcd60e51b81526004016104d99061287a565b50600c55565b6000600b82600c8111156114f2576114f2612944565b8154811061150257611502612972565b90600052602060002090600491828204019190066008029054906101000a90046001600160401b03169050919050565b6004546001600160a01b0316331461155c5760405162461bcd60e51b81526004016104d9906129cc565b600060098161156c866001612a01565b61ffff1661ffff16815260200190815260200160002054146115d05760405162461bcd60e51b815260206004820152601e60248201527f434f4e54524f4c4c45523a20414c52454144595f52454749535445524544000060448201526064016104d9565b6115db836001612a01565b6001600160a01b0382166000908152600860205260408120805461ffff191661ffff93909316929092179091558290600990611618866001612a01565b61ffff168152602081019190915260400160002055505050565b6004546001600160a01b0316331461165c5760405162461bcd60e51b81526004016104d9906129cc565b6001600160a01b03811660009081526008602052604090205461ffff166116c55760405162461bcd60e51b815260206004820152601f60248201527f434f4e54524f4c4c45523a20554e524547495354455245445f4c45444745520060448201526064016104d9565b6001600160a01b03166000818152600860208181526040808420805461ffff16855260098352908420849055939092529052805461ffff19169055565b600054610100900460ff168061171b575060005460ff16155b61177e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104d9565b600054610100900460ff161580156117a0576000805461ffff19166101011790555b600054600160201b90046001600160a01b0316156118005760405162461bcd60e51b815260206004820152601f60248201527f434f4e54524f4c4c45523a20414c52454144595f494e495449414c495a45440060448201526064016104d9565b8b600060026101000a81548161ffff021916908361ffff1602179055508a600060046101000a8154816001600160a01b0302191690836001600160a01b0316021790555089600160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555088600260006101000a8154816001600160a01b0302191690836001600160a01b0316021790555087600360006101000a8154816001600160a01b0302191690836001600160a01b031602179055508686600591906118ca9291906121fa565b506118d7600686866121fa565b506118e4600784846121fa565b5080156118f7576000805461ff00191690555b505050505050505050505050565b600b818154811061191557600080fd5b9060005260206000209060049182820401919006600802915054906101000a90046001600160401b031681565b3360009081526008602052604090205461ffff166119725760405162461bcd60e51b81526004016104d9906126f1565b6000546040516323b872dd60e01b815233600482015230602482015260448101839052600160201b9091046001600160a01b0316906323b872dd906064016020604051808303816000875af11580156119cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f39190612858565b506040805180820182526060602082015260018082528251818152808401909352909190816020015b6060815260200190600190039081611a1c5750506020820152600160f81b611a42611f2c565b6040516001600160f81b031990921660208301526021820152600060418201526042016040516020818303038152906040528160200151600081518110611a8b57611a8b612972565b6020908102919091010152600354600054600d546001600160a01b03928316926394f6911592600160201b90041690859085611ac7600c6114dc565b6040518663ffffffff1660e01b8152600401611ae7959493929190612a1e565b600060405180830381600087803b158015611b0157600080fd5b505af1158015611b15573d6000803e3d6000fd5b505050507fa3b72c7718d9c57429d6b0e8ddc6d5e70a150a59d8794a9d90e1b2e4c79ae5b333610d35611f2c565b3360009081526008602052604090205461ffff16611b735760405162461bcd60e51b81526004016104d9906126f1565b611bb9611b7e611d5b565b611b8860026114dc565b6001546040516324ef799360e11b8152600481018690526001600160a01b03909116906349def32690602401610524565b7f3ce484d3b4411b803fda21e2ce839ca75fc0ecf3039ab59bc40c71c64703253633610598611f2c565b3360009081526008602052604090205461ffff16611c135760405162461bcd60e51b81526004016104d9906126f1565b6000816001600160401b03811115611c2d57611c2d612728565b604051908082528060200260200182016040528015611c56578160200160208202803683370190505b50905060005b82811015611cad57838382818110611c7657611c76612972565b9050602002013560001c828281518110611c9257611c92612972565b6020908102919091010152611ca6816129b1565b9050611c5c565b50611d12611cb9611d5b565b83611cc4600a6114dc565b611cce91906128ea565b611cd860096114dc565b611ce29190612919565b60015460405163a7cb124b60e01b81526001600160a01b039091169063a7cb124b90610524908790600401612ace565b7f06591922aa31e57deb079e867d22c7a53032ead799b82fcf4ce6470fba36d49033611d3c611f2c565b8585604051611d4e9493929190612b12565b60405180910390a1505050565b33600090815260086020526040812054611d7b9060019061ffff16612b67565b905090565b6040805160028082528183019092526000916020820181803683370190505090508360f81b81600081518110611db857611db8612972565b60200101906001600160f81b031916908160001a90535060088461ffff16901c60f81b81600181518110611dee57611dee612972565b60200101906001600160f81b031916908160001a9053506000611e1160006114dc565b611e1b9085612919565b600a549091506001600160401b039081169082161115611e7b5760405162461bcd60e51b815260206004820152601b60248201527a10d3d3951493d31311548e881513d3d7d35550d217d5d15251d215602a1b60448201526064016104d9565b600254600080546040516001600160a01b039384169363267d4062939261ffff6201000082041692600160201b909104909116908690611ec4906007908a908c90602001612c24565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401611ef3959493929190612c5d565b600060405180830381600087803b158015611f0d57600080fd5b505af1158015611f21573d6000803e3d6000fd5b505050505050505050565b3360009081526008602090815260408083205461ffff168352600990915290205490565b604051606084811b6001600160601b0319166020830152906005906034016040516020818303038152906040526006611f8886611fc6565b611f9a866001600160401b0316611fc6565b604051602001611fae959493929190612ca3565b60405160208183030381529060405290509392505050565b60606040821015611fe657611fe0600283901b6001612162565b92915050565b61400082101561200957611fe0612002600284901b600161295a565b6002612162565b634000000082101561202d57611fe0612026600284811b9061295a565b6004612162565b6000825b6101008210801561204157508015155b156120595760081c612052826129b1565b9150612031565b50600061206782600161295a565b6001600160401b0381111561207e5761207e612728565b6040519080825280601f01601f1916602001820160405280156120a8576020820181803683370190505b50905060026120b8600484612d0a565b6120c4911b600361295a565b60f81b816000815181106120da576120da612972565b60200101906001600160f81b031916908160001a90535060005b82811015612155576001600160f81b031960f886901b168261211783600161295a565b8151811061212757612127612972565b60200101906001600160f81b031916908160001a90535060089490941c9361214e816129b1565b90506120f4565b509392505050565b919050565b60606000826001600160401b0381111561217e5761217e612728565b6040519080825280601f01601f1916602001820160405280156121a8576020820181803683370190505b50905060005b83811015612155578460f81b8282815181106121cc576121cc612972565b60200101906001600160f81b031916908160001a90535060089490941c936121f3816129b1565b90506121ae565b828054612206906126b6565b90600052602060002090601f016020900481019282612228576000855561226e565b82601f106122415782800160ff1982351617855561226e565b8280016001018555821561226e579182015b8281111561226e578235825591602001919060010190612253565b5061227a92915061227e565b5090565b5b8082111561227a576000815560010161227f565b60005b838110156122ae578181015183820152602001612296565b838111156111095750506000910152565b600081518084526122d7816020860160208601612293565b601f01601f19169290920160200192915050565b6020815260006122fe60208301846122bf565b9392505050565b60006020828403121561231757600080fd5b5035919050565b803561ffff8116811461215d57600080fd5b60006020828403121561234257600080fd5b6122fe8261231e565b60006020828403121561235d57600080fd5b81356001600160401b03811681146122fe57600080fd5b6000806040838503121561238757600080fd5b50508035926020909101359150565b6000602082840312156123a857600080fd5b813563ffffffff811681146122fe57600080fd5b60008083601f8401126123ce57600080fd5b5081356001600160401b038111156123e557600080fd5b6020830191508360208285010111156123fd57600080fd5b9250929050565b6000806000806000806060878903121561241d57600080fd5b86356001600160401b038082111561243457600080fd5b6124408a838b016123bc565b9098509650602089013591508082111561245957600080fd5b6124658a838b016123bc565b9096509450604089013591508082111561247e57600080fd5b5061248b89828a016123bc565b979a9699509497509295939492505050565b6001600160a01b03811681146124b257600080fd5b50565b803561215d8161249d565b6000602082840312156124d257600080fd5b81356122fe8161249d565b60008083601f8401126124ef57600080fd5b5081356001600160401b0381111561250657600080fd5b6020830191508360208260051b85010111156123fd57600080fd5b6000806020838503121561253457600080fd5b82356001600160401b0381111561254a57600080fd5b612556858286016124dd565b90969095509350505050565b60006020828403121561257457600080fd5b8135600d81106122fe57600080fd5b60008060006060848603121561259857600080fd5b6125a18461231e565b92506020840135915060408401356125b88161249d565b809150509250925092565b60008060008060008060008060008060006101008c8e0312156125e557600080fd5b6125ee8c61231e565b9a506125fc60208d016124b5565b995061260a60408d016124b5565b985061261860608d016124b5565b975061262660808d016124b5565b96506001600160401b0360a08d013581101561264157600080fd5b6126518e60a08f01358f016123bc565b909750955060c08d013581101561266757600080fd5b6126778e60c08f01358f016123bc565b909550935060e08d013581101561268d57600080fd5b5061269e8d60e08e01358e016123bc565b81935080925050509295989b509295989b9093969950565b600181811c908216806126ca57607f821691505b602082108114156126eb57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601f908201527f434f4e54524f4c4c45523a20554e524547495354455245445f53454e44455200604082015260600190565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561275057600080fd5b81516001600160401b038082111561276757600080fd5b818401915084601f83011261277b57600080fd5b81518181111561278d5761278d612728565b604051601f8201601f19908116603f011681019083821181831017156127b5576127b5612728565b816040528281528760208487010111156127ce57600080fd5b6127df836020830160208801612293565b979650505050505050565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b03929092168252602082015260400190565b60006020828403121561283657600080fd5b81516122fe8161249d565b9182526001600160a01b0316602082015260400190565b60006020828403121561286a57600080fd5b815180151581146122fe57600080fd5b60208082526018908201527710d3d3951493d31311548e8815539055551213d493d6915160421b604082015260600190565b8381528260208201526060604082015260006128cb60608301846122bf565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b60006001600160401b0382811684821681151582840482111615612910576129106128d4565b02949350505050565b60006001600160401b0382811684821680830382111561293b5761293b6128d4565b01949350505050565b634e487b7160e01b600052602160045260246000fd5b6000821982111561296d5761296d6128d4565b500190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561299a57600080fd5b81356001600160801b03811681146122fe57600080fd5b60006000198214156129c5576129c56128d4565b5060010190565b6020808252601b908201527a434f4e54524f4c4c45523a2043414c4c45525f4e4f545f4c49444f60281b604082015260600190565b600061ffff80831681851680830382111561293b5761293b6128d4565b60018060a01b038616815260006020868184015285604084015260a0606084015260e0830160ff86511660a085015281860151604060c086015281815180845261010093508387019150838160051b8801019350848301925060005b81811015612aa85760ff19888603018352612a968585516122bf565b94509285019291850191600101612a7a565b5050506001600160401b0386166080860152509150612ac49050565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612b0657835183529284019291840191600101612aea565b50909695505050505050565b6001600160a01b038516815260208101849052606060408201819052810182905260006001600160fb1b03831115612b4957600080fd5b8260051b808560808501376000920160800191825250949350505050565b600061ffff83811690831681811015612b8257612b826128d4565b039392505050565b8054600090600181811c9080831680612ba457607f831692505b6020808410821415612bc657634e487b7160e01b600052602260045260246000fd5b818015612bda5760018114612beb57612c18565b60ff19861689528489019650612c18565b60008881526020902060005b86811015612c105781548b820152908501908301612bf7565b505084890196505b50505050505092915050565b6000612c308286612b8a565b8451612c40818360208901612293565b8451910190612c53818360208801612293565b0195945050505050565b60ff8616815261ffff851660208201526001600160a01b03841660408201526001600160401b038316606082015260a0608082018190526000906127df908301846122bf565b6000612caf8288612b8a565b8651612cbf818360208b01612293565b612ccb81830188612b8a565b9150508451612cde818360208901612293565b600160d81b91019081528351612cfb816005840160208801612293565b01600501979650505050505050565b600082821015612d1c57612d1c6128d4565b50039056fec782482f4fcb342b5dc312c5a088cff7e4984bcf7803f44f6541f05e6fd4ce48a26469706673582212205dafad5c8242ced27aebdf960abab23304229c175229c71b985ab8d5e0f10b6764736f6c634300080a0033

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