Polygon Sponsored slots available. Book your slot here!
Contract Overview
Balance:
0 MATIC
MATIC Value:
$0.00
My Name Tag:
Not Available, login to update
Latest 1 internal transaction
Parent Txn Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
0x160fdb87ef0ba376bec5f8257e4319069b70c466fe92e41c31603527ad48e0a6 | 31918401 | 291 days 10 hrs ago | 0x2fd525b8b2e2a69d054dccb033a0e33e0b4ab370 | Contract Creation | 0 MATIC |
[ Download CSV Export ]
Contract Name:
NXTPFacet
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 10000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import { ITransactionManager } from "../Interfaces/ITransactionManager.sol"; import { ILiFi } from "../Interfaces/ILiFi.sol"; import { LibAsset, IERC20 } from "../Libraries/LibAsset.sol"; import { LibDiamond } from "../Libraries/LibDiamond.sol"; import { ReentrancyGuard } from "../Helpers/ReentrancyGuard.sol"; import { InvalidAmount, NativeValueWithERC, NoSwapDataProvided, InvalidConfig } from "../Errors/GenericErrors.sol"; import { SwapperV2, LibSwap } from "../Helpers/SwapperV2.sol"; /// @title NXTP (Connext) Facet /// @author LI.FI (https://li.fi) /// @notice Provides functionality for bridging through NXTP (Connext) contract NXTPFacet is ILiFi, SwapperV2, ReentrancyGuard { /// Storage /// bytes32 internal constant NAMESPACE = hex"cb4800033539e504944b70f0275e98829f191b99c5226e9a5a072ab49d2a753e"; //keccak256("com.lifi.facets.nxtp"); struct Storage { ITransactionManager nxtpTxManager; } /// Events /// event NXTPInitialized(ITransactionManager txMgrAddr); /// Init /// // @notice Initializes local variables for the NXTP facet /// @param _txMgrAddr address of the NXTP Transaction Manager contract function initNXTP(ITransactionManager _txMgrAddr) external { LibDiamond.enforceIsContractOwner(); if (address(_txMgrAddr) == address(0)) revert InvalidConfig(); Storage storage s = getStorage(); s.nxtpTxManager = _txMgrAddr; emit NXTPInitialized(_txMgrAddr); } /// External Methods /// /// @notice This function starts a cross-chain transaction using the NXTP protocol /// @param _lifiData data used purely for tracking and analytics /// @param _nxtpData data needed to complete an NXTP cross-chain transaction function startBridgeTokensViaNXTP(LiFiData calldata _lifiData, ITransactionManager.PrepareArgs calldata _nxtpData) external payable nonReentrant { LibAsset.depositAsset(_nxtpData.invariantData.sendingAssetId, _nxtpData.amount); _startBridge(_nxtpData); emit LiFiTransferStarted( _lifiData.transactionId, "nxtp", "", _lifiData.integrator, _lifiData.referrer, _nxtpData.invariantData.sendingAssetId, _lifiData.receivingAssetId, _nxtpData.invariantData.receivingAddress, _nxtpData.amount, _nxtpData.invariantData.receivingChainId, false, _nxtpData.invariantData.callTo != address(0) ); } /// @notice This function performs a swap or multiple swaps and then starts a cross-chain transaction /// using the NXTP protocol. /// @param _lifiData data used purely for tracking and analytics /// @param _swapData array of data needed for swaps /// @param _nxtpData data needed to complete an NXTP cross-chain transaction function swapAndStartBridgeTokensViaNXTP( LiFiData calldata _lifiData, LibSwap.SwapData[] calldata _swapData, ITransactionManager.PrepareArgs memory _nxtpData ) external payable nonReentrant { _nxtpData.amount = _executeAndCheckSwaps(_lifiData, _swapData, payable(msg.sender)); _startBridge(_nxtpData); emit LiFiTransferStarted( _lifiData.transactionId, "nxtp", "", _lifiData.integrator, _lifiData.referrer, _swapData[0].sendingAssetId, _lifiData.receivingAssetId, _nxtpData.invariantData.receivingAddress, _swapData[0].fromAmount, _nxtpData.invariantData.receivingChainId, true, _nxtpData.invariantData.callTo != address(0) ); } /// @notice Completes a cross-chain transaction on the receiving chain using the NXTP protocol. /// @param _lifiData data used purely for tracking and analytics /// @param assetId token received on the receiving chain /// @param receiver address that will receive the tokens /// @param amount number of tokens received function completeBridgeTokensViaNXTP( LiFiData calldata _lifiData, address assetId, address receiver, uint256 amount ) external payable nonReentrant { LibAsset.depositAsset(assetId, amount); LibAsset.transferAsset(assetId, payable(receiver), amount); emit LiFiTransferCompleted(_lifiData.transactionId, assetId, receiver, amount, block.timestamp); } /// @notice Performs a swap before completing a cross-chain transaction /// on the receiving chain using the NXTP protocol. /// @param _lifiData data used purely for tracking and analytics /// @param _swapData array of data needed for swaps /// @param finalAssetId token received on the receiving chain /// @param receiver address that will receive the tokens function swapAndCompleteBridgeTokensViaNXTP( LiFiData calldata _lifiData, LibSwap.SwapData[] calldata _swapData, address finalAssetId, address receiver ) external payable nonReentrant { uint256 swapBalance = _executeAndCheckSwaps(_lifiData, _swapData, payable(receiver)); LibAsset.transferAsset(finalAssetId, payable(receiver), swapBalance); emit LiFiTransferCompleted(_lifiData.transactionId, finalAssetId, receiver, swapBalance, block.timestamp); } /// @notice show the NXTP transaction manager contract address function getNXTPTransactionManager() external view returns (address) { Storage storage s = getStorage(); return address(s.nxtpTxManager); } /// Private Methods /// /// @dev Conatains the business logic for the bridge via NXTP /// @param _nxtpData data specific to NXTP function _startBridge(ITransactionManager.PrepareArgs memory _nxtpData) private returns (bytes32) { Storage storage s = getStorage(); IERC20 sendingAssetId = IERC20(_nxtpData.invariantData.sendingAssetId); // Give Connext approval to bridge tokens LibAsset.maxApproveERC20(IERC20(sendingAssetId), address(s.nxtpTxManager), _nxtpData.amount); uint256 value = LibAsset.isNativeAsset(address(sendingAssetId)) ? _nxtpData.amount : 0; // Initiate bridge transaction on sending chain ITransactionManager.TransactionData memory result = s.nxtpTxManager.prepare{ value: value }(_nxtpData); return result.transactionId; } /// @dev fetch local storage function getStorage() private pure returns (Storage storage s) { bytes32 namespace = NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { s.slot := namespace } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; interface ITransactionManager { // Structs // Holds all data that is constant between sending and // receiving chains. The hash of this is what gets signed // to ensure the signature can be used on both chains. struct InvariantTransactionData { address receivingChainTxManagerAddress; address user; address router; address initiator; // msg.sender of sending side address sendingAssetId; address receivingAssetId; address sendingChainFallback; // funds sent here on cancel address receivingAddress; address callTo; uint256 sendingChainId; uint256 receivingChainId; bytes32 callDataHash; // hashed to prevent free option bytes32 transactionId; } // Holds all data that varies between sending and receiving // chains. The hash of this is stored onchain to ensure the // information passed in is valid. struct VariantTransactionData { uint256 amount; uint256 expiry; uint256 preparedBlockNumber; } // All Transaction data, constant and variable struct TransactionData { address receivingChainTxManagerAddress; address user; address router; address initiator; // msg.sender of sending side address sendingAssetId; address receivingAssetId; address sendingChainFallback; address receivingAddress; address callTo; bytes32 callDataHash; bytes32 transactionId; uint256 sendingChainId; uint256 receivingChainId; uint256 amount; uint256 expiry; uint256 preparedBlockNumber; // Needed for removal of active blocks on fulfill/cancel } // The structure of the signed data for fulfill struct SignedFulfillData { bytes32 transactionId; uint256 relayerFee; string functionIdentifier; // "fulfill" or "cancel" uint256 receivingChainId; // For domain separation address receivingChainTxManagerAddress; // For domain separation } // The structure of the signed data for cancellation struct SignedCancelData { bytes32 transactionId; string functionIdentifier; uint256 receivingChainId; address receivingChainTxManagerAddress; // For domain separation } /** * Arguments for calling prepare() * @param invariantData The data for a crosschain transaction that will * not change between sending and receiving chains. * The hash of this data is used as the key to store * the inforamtion that does change between chains * (amount,expiry,preparedBlock) for verification * @param amount The amount of the transaction on this chain * @param expiry The block.timestamp when the transaction will no longer be * fulfillable and is freely cancellable on this chain * @param encryptedCallData The calldata to be executed when the tx is * fulfilled. Used in the function to allow the user * to reconstruct the tx from events. Hash is stored * onchain to prevent shenanigans. * @param encodedBid The encoded bid that was accepted by the user for this * crosschain transfer. It is supplied as a param to the * function but is only used in event emission * @param bidSignature The signature of the bidder on the encoded bid for * this transaction. Only used within the function for * event emission. The validity of the bid and * bidSignature are enforced offchain * @param encodedMeta The meta for the function */ struct PrepareArgs { InvariantTransactionData invariantData; uint256 amount; uint256 expiry; bytes encryptedCallData; bytes encodedBid; bytes bidSignature; bytes encodedMeta; } /** * @param txData All of the data (invariant and variant) for a crosschain * transaction. The variant data provided is checked against * what was stored when the `prepare` function was called. * @param relayerFee The fee that should go to the relayer when they are * calling the function on the receiving chain for the user * @param signature The users signature on the transaction id + fee that * can be used by the router to unlock the transaction on * the sending chain * @param callData The calldata to be sent to and executed by the * `FulfillHelper` * @param encodedMeta The meta for the function */ struct FulfillArgs { TransactionData txData; uint256 relayerFee; bytes signature; bytes callData; bytes encodedMeta; } /** * Arguments for calling cancel() * @param txData All of the data (invariant and variant) for a crosschain * transaction. The variant data provided is checked against * what was stored when the `prepare` function was called. * @param signature The user's signature that allows a transaction to be * cancelled by a relayer * @param encodedMeta The meta for the function */ struct CancelArgs { TransactionData txData; bytes signature; bytes encodedMeta; } // Adding/removing asset events event RouterAdded(address indexed addedRouter, address indexed caller); event RouterRemoved(address indexed removedRouter, address indexed caller); // Adding/removing router events event AssetAdded(address indexed addedAssetId, address indexed caller); event AssetRemoved(address indexed removedAssetId, address indexed caller); // Liquidity events event LiquidityAdded(address indexed router, address indexed assetId, uint256 amount, address caller); event LiquidityRemoved(address indexed router, address indexed assetId, uint256 amount, address recipient); // Transaction events event TransactionPrepared( address indexed user, address indexed router, bytes32 indexed transactionId, TransactionData txData, address caller, PrepareArgs args ); event TransactionFulfilled( address indexed user, address indexed router, bytes32 indexed transactionId, FulfillArgs args, bool success, bool isContract, bytes returnData, address caller ); event TransactionCancelled( address indexed user, address indexed router, bytes32 indexed transactionId, CancelArgs args, address caller ); // Getters function getChainId() external view returns (uint256); function getStoredChainId() external view returns (uint256); // Owner only methods function addRouter(address router) external; function removeRouter(address router) external; function addAssetId(address assetId) external; function removeAssetId(address assetId) external; // Router only methods function addLiquidityFor( uint256 amount, address assetId, address router ) external payable; function addLiquidity(uint256 amount, address assetId) external payable; function removeLiquidity( uint256 amount, address assetId, address payable recipient ) external; // Methods for crosschain transfers // called in the following order (in happy case) // 1. prepare by user on sending chain // 2. prepare by router on receiving chain // 3. fulfill by user on receiving chain // 4. fulfill by router on sending chain function prepare(PrepareArgs calldata args) external payable returns (TransactionData memory); function fulfill(FulfillArgs calldata args) external returns (TransactionData memory); function cancel(CancelArgs calldata args) external returns (TransactionData memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; interface ILiFi { /// Structs /// struct LiFiData { bytes32 transactionId; string integrator; address referrer; address sendingAssetId; address receivingAssetId; address receiver; uint256 destinationChainId; uint256 amount; } /// Events /// event LiFiTransferStarted( bytes32 indexed transactionId, string bridge, string bridgeData, string integrator, address referrer, address sendingAssetId, address receivingAssetId, address receiver, uint256 amount, uint256 destinationChainId, bool hasSourceSwap, bool hasDestinationCall ); event LiFiTransferCompleted( bytes32 indexed transactionId, address receivingAssetId, address receiver, uint256 amount, uint256 timestamp ); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; import { NullAddrIsNotAnERC20Token, NullAddrIsNotAValidSpender, NoTransferToNullAddress, InvalidAmount, NativeValueWithERC, NativeAssetTransferFailed } from "../Errors/GenericErrors.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @title LibAsset /// @author Connext <[email protected]> /// @notice This library contains helpers for dealing with onchain transfers /// of assets, including accounting for the native asset `assetId` /// conventions and any noncompliant ERC20 transfers library LibAsset { uint256 private constant MAX_INT = type(uint256).max; address internal constant NULL_ADDRESS = 0x0000000000000000000000000000000000000000; //address(0) /// @dev All native assets use the empty address for their asset id /// by convention address internal constant NATIVE_ASSETID = NULL_ADDRESS; //address(0) /// @notice Gets the balance of the inheriting contract for the given asset /// @param assetId The asset identifier to get the balance of /// @return Balance held by contracts using this library function getOwnBalance(address assetId) internal view returns (uint256) { return assetId == NATIVE_ASSETID ? address(this).balance : IERC20(assetId).balanceOf(address(this)); } /// @notice Transfers ether from the inheriting contract to a given /// recipient /// @param recipient Address to send ether to /// @param amount Amount to send to given recipient function transferNativeAsset(address payable recipient, uint256 amount) private { if (recipient == NULL_ADDRESS) revert NoTransferToNullAddress(); // solhint-disable-next-line avoid-low-level-calls (bool success, ) = recipient.call{ value: amount }(""); if (!success) revert NativeAssetTransferFailed(); } /// @notice Gives MAX approval for another address to spend tokens /// @param assetId Token address to transfer /// @param spender Address to give spend approval to /// @param amount Amount to approve for spending function maxApproveERC20( IERC20 assetId, address spender, uint256 amount ) internal { if (address(assetId) == NATIVE_ASSETID) return; if (spender == NULL_ADDRESS) revert NullAddrIsNotAValidSpender(); uint256 allowance = assetId.allowance(address(this), spender); if (allowance < amount) SafeERC20.safeApprove(IERC20(assetId), spender, MAX_INT); } /// @notice Transfers tokens from the inheriting contract to a given /// recipient /// @param assetId Token address to transfer /// @param recipient Address to send token to /// @param amount Amount to send to given recipient function transferERC20( address assetId, address recipient, uint256 amount ) private { if (isNativeAsset(assetId)) revert NullAddrIsNotAnERC20Token(); SafeERC20.safeTransfer(IERC20(assetId), recipient, amount); } /// @notice Transfers tokens from a sender to a given recipient /// @param assetId Token address to transfer /// @param from Address of sender/owner /// @param to Address of recipient/spender /// @param amount Amount to transfer from owner to spender function transferFromERC20( address assetId, address from, address to, uint256 amount ) internal { if (assetId == NATIVE_ASSETID) revert NullAddrIsNotAnERC20Token(); if (to == NULL_ADDRESS) revert NoTransferToNullAddress(); SafeERC20.safeTransferFrom(IERC20(assetId), from, to, amount); } /// @notice Deposits an asset into the contract and performs checks to avoid NativeValueWithERC /// @param tokenId Token to deposit /// @param amount Amount to deposit /// @param isNative Wether the token is native or ERC20 function depositAsset( address tokenId, uint256 amount, bool isNative ) internal { if (amount == 0) revert InvalidAmount(); if (isNative) { if (msg.value != amount) revert InvalidAmount(); } else { if (msg.value != 0) revert NativeValueWithERC(); uint256 _fromTokenBalance = LibAsset.getOwnBalance(tokenId); LibAsset.transferFromERC20(tokenId, msg.sender, address(this), amount); if (LibAsset.getOwnBalance(tokenId) - _fromTokenBalance != amount) revert InvalidAmount(); } } /// @notice Overload for depositAsset(address tokenId, uint256 amount, bool isNative) /// @param tokenId Token to deposit /// @param amount Amount to deposit function depositAsset(address tokenId, uint256 amount) internal { return depositAsset(tokenId, amount, tokenId == NATIVE_ASSETID); } /// @notice Determines whether the given assetId is the native asset /// @param assetId The asset identifier to evaluate /// @return Boolean indicating if the asset is the native asset function isNativeAsset(address assetId) internal pure returns (bool) { return assetId == NATIVE_ASSETID; } /// @notice Wrapper function to transfer a given asset (native or erc20) to /// some recipient. Should handle all non-compliant return value /// tokens as well by using the SafeERC20 contract by open zeppelin. /// @param assetId Asset id for transfer (address(0) for native asset, /// token address for erc20s) /// @param recipient Address to send asset to /// @param amount Amount to send to given recipient function transferAsset( address assetId, address payable recipient, uint256 amount ) internal { (assetId == NATIVE_ASSETID) ? transferNativeAsset(recipient, amount) : transferERC20(assetId, recipient, amount); } /// @dev Checks whether the given address is a contract and contains code function isContract(address _contractAddr) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(_contractAddr) } return size > 0; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import { IDiamondCut } from "../Interfaces/IDiamondCut.sol"; library LibDiamond { bytes32 internal constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct FacetAddressAndPosition { address facetAddress; uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array } struct FacetFunctionSelectors { bytes4[] functionSelectors; uint256 facetAddressPosition; // position of facetAddress in facetAddresses array } struct DiamondStorage { // maps function selector to the facet address and // the position of the selector in the facetFunctionSelectors.selectors array mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition; // maps facet addresses to function selectors mapping(address => FacetFunctionSelectors) facetFunctionSelectors; // facet addresses address[] facetAddresses; // Used to query if a contract implements an interface. // Used to implement ERC-165. mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; // solhint-disable-next-line no-inline-assembly assembly { ds.slot := position } } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function enforceIsContractOwner() internal view { require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner"); } event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); // Internal function version of diamondCut function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; if (action == IDiamondCut.FacetCutAction.Add) { addFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors); } else if (action == IDiamondCut.FacetCutAction.Replace) { replaceFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors); } else if (action == IDiamondCut.FacetCutAction.Remove) { removeFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors); } else { revert("LibDiamondCut: Incorrect FacetCutAction"); } } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); DiamondStorage storage ds = diamondStorage(); require(_facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)"); uint96 selectorPosition = uint96(ds.facetFunctionSelectors[_facetAddress].functionSelectors.length); // add new facet address if it does not exist if (selectorPosition == 0) { addFacet(ds, _facetAddress); } for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; require(oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists"); addFunction(ds, selector, selectorPosition, _facetAddress); selectorPosition++; } } function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); DiamondStorage storage ds = diamondStorage(); require(_facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)"); uint96 selectorPosition = uint96(ds.facetFunctionSelectors[_facetAddress].functionSelectors.length); // add new facet address if it does not exist if (selectorPosition == 0) { addFacet(ds, _facetAddress); } for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; require(oldFacetAddress != _facetAddress, "LibDiamondCut: Can't replace function with same function"); removeFunction(ds, oldFacetAddress, selector); addFunction(ds, selector, selectorPosition, _facetAddress); selectorPosition++; } } function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); DiamondStorage storage ds = diamondStorage(); // if function does not exist then do nothing and return require(_facetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)"); for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; removeFunction(ds, oldFacetAddress, selector); } } function addFacet(DiamondStorage storage ds, address _facetAddress) internal { enforceHasContractCode(_facetAddress, "LibDiamondCut: New facet has no code"); ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = ds.facetAddresses.length; ds.facetAddresses.push(_facetAddress); } function addFunction( DiamondStorage storage ds, bytes4 _selector, uint96 _selectorPosition, address _facetAddress ) internal { ds.selectorToFacetAndPosition[_selector].functionSelectorPosition = _selectorPosition; ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(_selector); ds.selectorToFacetAndPosition[_selector].facetAddress = _facetAddress; } function removeFunction( DiamondStorage storage ds, address _facetAddress, bytes4 _selector ) internal { require(_facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist"); // an immutable function is a function defined directly in a diamond require(_facetAddress != address(this), "LibDiamondCut: Can't remove immutable function"); // replace selector with last selector, then delete last selector uint256 selectorPosition = ds.selectorToFacetAndPosition[_selector].functionSelectorPosition; uint256 lastSelectorPosition = ds.facetFunctionSelectors[_facetAddress].functionSelectors.length - 1; // if not the same then replace _selector with lastSelector if (selectorPosition != lastSelectorPosition) { bytes4 lastSelector = ds.facetFunctionSelectors[_facetAddress].functionSelectors[lastSelectorPosition]; ds.facetFunctionSelectors[_facetAddress].functionSelectors[selectorPosition] = lastSelector; ds.selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint96(selectorPosition); } // delete the last selector ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop(); delete ds.selectorToFacetAndPosition[_selector]; // if no more selectors for facet address then delete the facet address if (lastSelectorPosition == 0) { // replace facet address with last facet address and delete last facet address uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1; uint256 facetAddressPosition = ds.facetFunctionSelectors[_facetAddress].facetAddressPosition; if (facetAddressPosition != lastFacetAddressPosition) { address lastFacetAddress = ds.facetAddresses[lastFacetAddressPosition]; ds.facetAddresses[facetAddressPosition] = lastFacetAddress; ds.facetFunctionSelectors[lastFacetAddress].facetAddressPosition = facetAddressPosition; } ds.facetAddresses.pop(); delete ds.facetFunctionSelectors[_facetAddress].facetAddressPosition; } } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { require(_calldata.length == 0, "LibDiamondCut: _init is address(0) but_calldata is not empty"); } else { require(_calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)"); if (_init != address(this)) { enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); } // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up the error revert(string(error)); } else { revert("LibDiamondCut: _init function reverted"); } } } } function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { uint256 contractSize; // solhint-disable-next-line no-inline-assembly assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.13; /// @title Reentrancy Guard /// @author LI.FI (https://li.fi) /// @notice Abstract contract to provide protection against reentrancy abstract contract ReentrancyGuard { /// Storage /// bytes32 private constant NAMESPACE = hex"a65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b"; /// Types /// struct ReentrancyStorage { uint256 status; } /// Errors /// error ReentrancyError(); /// Constants /// uint256 private constant _NOT_ENTERED = 0; uint256 private constant _ENTERED = 1; /// Modifiers /// modifier nonReentrant() { ReentrancyStorage storage s = reentrancyStorage(); if (s.status == _ENTERED) revert ReentrancyError(); s.status = _ENTERED; _; s.status = _NOT_ENTERED; } /// Private Methods /// /// @dev fetch local storage function reentrancyStorage() private pure returns (ReentrancyStorage storage data) { bytes32 position = NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { data.slot := position } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; error InvalidAmount(); error TokenAddressIsZero(); error CannotBridgeToSameNetwork(); error ZeroPostSwapBalance(); error InvalidBridgeConfigLength(); error NoSwapDataProvided(); error NativeValueWithERC(); error ContractCallNotAllowed(); error NullAddrIsNotAValidSpender(); error NullAddrIsNotAnERC20Token(); error NoTransferToNullAddress(); error NativeAssetTransferFailed(); error InvalidContract(); error InvalidConfig();
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import { ILiFi } from "../Interfaces/ILiFi.sol"; import { LibSwap } from "../Libraries/LibSwap.sol"; import { LibAsset } from "../Libraries/LibAsset.sol"; import { LibStorage } from "../Libraries/LibStorage.sol"; import { LibAsset } from "../Libraries/LibAsset.sol"; import { InvalidAmount, ContractCallNotAllowed, NoSwapDataProvided } from "../Errors/GenericErrors.sol"; /// @title Swapper /// @author LI.FI (https://li.fi) /// @notice Abstract contract to provide swap functionality contract SwapperV2 is ILiFi { /// Storage /// LibStorage internal appStorage; /// Modifiers /// /// @dev Sends any leftover balances back to the user modifier noLeftovers(LibSwap.SwapData[] calldata _swapData, address payable _receiver) { uint256 nSwaps = _swapData.length; if (nSwaps != 1) { uint256[] memory initialBalances = _fetchBalances(_swapData); address finalAsset = _swapData[nSwaps - 1].receivingAssetId; uint256 curBalance = 0; uint256 newBalance = 0; _; for (uint256 i = 0; i < nSwaps - 1; i++) { address curAsset = _swapData[i].receivingAssetId; if (curAsset == finalAsset) continue; // Handle multi-to-one swaps newBalance = LibAsset.getOwnBalance(curAsset); curBalance = newBalance > initialBalances[i] ? newBalance - initialBalances[i] : newBalance; if (curBalance > 0) LibAsset.transferAsset(curAsset, _receiver, curBalance); } } else _; } /// Internal Methods /// /// @dev Validates input before executing swaps /// @param _lifiData LiFi tracking data /// @param _swapData Array of data used to execute swaps function _executeAndCheckSwaps( LiFiData memory _lifiData, LibSwap.SwapData[] calldata _swapData, address payable _receiver ) internal returns (uint256) { uint256 nSwaps = _swapData.length; if (nSwaps == 0) revert NoSwapDataProvided(); address finalTokenId = _swapData[_swapData.length - 1].receivingAssetId; uint256 swapBalance = LibAsset.getOwnBalance(finalTokenId); _executeSwaps(_lifiData, _swapData, _receiver); uint256 newBalance = LibAsset.getOwnBalance(finalTokenId); swapBalance = newBalance > swapBalance ? newBalance - swapBalance : newBalance; if (swapBalance == 0) revert InvalidAmount(); return swapBalance; } /// Private Methods /// /// @dev Executes swaps and checks that DEXs used are in the allowList /// @param _lifiData LiFi tracking data /// @param _swapData Array of data used to execute swaps function _executeSwaps( LiFiData memory _lifiData, LibSwap.SwapData[] calldata _swapData, address payable _receiver ) internal noLeftovers(_swapData, _receiver) { for (uint256 i = 0; i < _swapData.length; i++) { LibSwap.SwapData calldata currentSwapData = _swapData[i]; if ( !(appStorage.dexAllowlist[currentSwapData.approveTo] && appStorage.dexAllowlist[currentSwapData.callTo] && appStorage.dexFuncSignatureAllowList[bytes32(currentSwapData.callData[:8])]) ) revert ContractCallNotAllowed(); LibSwap.swap(_lifiData.transactionId, currentSwapData); } } /// @dev Fetches balances of tokens to be swapped before swapping. /// @param _swapData Array of data used to execute swaps /// @return uint256[] Array of token balances. function _fetchBalances(LibSwap.SwapData[] calldata _swapData) private view returns (uint256[] memory) { uint256 length = _swapData.length; uint256[] memory balances = new uint256[](length); for (uint256 i = 0; i < length; i++) { balances[i] = LibAsset.getOwnBalance(_swapData[i].receivingAssetId); } return balances; } }
// 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' 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 require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// 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); }
// 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; 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"); (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"); (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"); (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"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; interface IDiamondCut { enum FacetCutAction { Add, Replace, Remove } // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import { LibAsset, IERC20 } from "./LibAsset.sol"; import { LibUtil } from "./LibUtil.sol"; import { InvalidContract } from "../Errors/GenericErrors.sol"; library LibSwap { error NoSwapFromZeroBalance(); struct SwapData { address callTo; address approveTo; address sendingAssetId; address receivingAssetId; uint256 fromAmount; bytes callData; } event AssetSwapped( bytes32 transactionId, address dex, address fromAssetId, address toAssetId, uint256 fromAmount, uint256 toAmount, uint256 timestamp ); function swap(bytes32 transactionId, SwapData calldata _swapData) internal { if (!LibAsset.isContract(_swapData.callTo)) revert InvalidContract(); uint256 fromAmount = _swapData.fromAmount; if (fromAmount == 0) revert NoSwapFromZeroBalance(); uint256 nativeValue = 0; address fromAssetId = _swapData.sendingAssetId; address toAssetId = _swapData.receivingAssetId; uint256 initialSendingAssetBalance = LibAsset.getOwnBalance(fromAssetId); uint256 initialReceivingAssetBalance = LibAsset.getOwnBalance(toAssetId); uint256 toDeposit = initialSendingAssetBalance < fromAmount ? fromAmount - initialSendingAssetBalance : 0; if (!LibAsset.isNativeAsset(fromAssetId)) { LibAsset.maxApproveERC20(IERC20(fromAssetId), _swapData.approveTo, fromAmount); if (toDeposit != 0) { LibAsset.transferFromERC20(fromAssetId, msg.sender, address(this), toDeposit); } } else { nativeValue = fromAmount; } // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory res) = _swapData.callTo.call{ value: nativeValue }(_swapData.callData); if (!success) { string memory reason = LibUtil.getRevertMsg(res); revert(reason); } uint256 newBalance = LibAsset.getOwnBalance(toAssetId); emit AssetSwapped( transactionId, _swapData.callTo, _swapData.sendingAssetId, toAssetId, fromAmount, newBalance > initialReceivingAssetBalance ? newBalance - initialReceivingAssetBalance : newBalance, block.timestamp ); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; struct LibStorage { mapping(address => bool) dexAllowlist; mapping(bytes32 => bool) dexFuncSignatureAllowList; address[] dexs; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; import "./LibBytes.sol"; library LibUtil { using LibBytes for bytes; function getRevertMsg(bytes memory _res) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (_res.length < 68) return "Transaction reverted silently"; bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes return abi.decode(revertData, (string)); // All that remains is the revert string } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.13; library LibBytes { // solhint-disable no-inline-assembly function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ) ) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1, "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) // solhint-disable-next-line no-empty-blocks for { } eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
{ "optimizer": { "enabled": true, "runs": 10000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"ContractCallNotAllowed","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidConfig","type":"error"},{"inputs":[],"name":"InvalidContract","type":"error"},{"inputs":[],"name":"NativeAssetTransferFailed","type":"error"},{"inputs":[],"name":"NativeValueWithERC","type":"error"},{"inputs":[],"name":"NoSwapDataProvided","type":"error"},{"inputs":[],"name":"NoSwapFromZeroBalance","type":"error"},{"inputs":[],"name":"NoTransferToNullAddress","type":"error"},{"inputs":[],"name":"NullAddrIsNotAValidSpender","type":"error"},{"inputs":[],"name":"NullAddrIsNotAnERC20Token","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"receivingAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"LiFiTransferCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"string","name":"bridge","type":"string"},{"indexed":false,"internalType":"string","name":"bridgeData","type":"string"},{"indexed":false,"internalType":"string","name":"integrator","type":"string"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"address","name":"sendingAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"receivingAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"hasSourceSwap","type":"bool"},{"indexed":false,"internalType":"bool","name":"hasDestinationCall","type":"bool"}],"name":"LiFiTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ITransactionManager","name":"txMgrAddr","type":"address"}],"name":"NXTPInitialized","type":"event"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ILiFi.LiFiData","name":"_lifiData","type":"tuple"},{"internalType":"address","name":"assetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"completeBridgeTokensViaNXTP","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getNXTPTransactionManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITransactionManager","name":"_txMgrAddr","type":"address"}],"name":"initNXTP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ILiFi.LiFiData","name":"_lifiData","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"receivingChainTxManagerAddress","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"address","name":"sendingChainFallback","type":"address"},{"internalType":"address","name":"receivingAddress","type":"address"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"uint256","name":"sendingChainId","type":"uint256"},{"internalType":"uint256","name":"receivingChainId","type":"uint256"},{"internalType":"bytes32","name":"callDataHash","type":"bytes32"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"internalType":"struct ITransactionManager.InvariantTransactionData","name":"invariantData","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bytes","name":"encryptedCallData","type":"bytes"},{"internalType":"bytes","name":"encodedBid","type":"bytes"},{"internalType":"bytes","name":"bidSignature","type":"bytes"},{"internalType":"bytes","name":"encodedMeta","type":"bytes"}],"internalType":"struct ITransactionManager.PrepareArgs","name":"_nxtpData","type":"tuple"}],"name":"startBridgeTokensViaNXTP","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ILiFi.LiFiData","name":"_lifiData","type":"tuple"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.SwapData[]","name":"_swapData","type":"tuple[]"},{"internalType":"address","name":"finalAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"}],"name":"swapAndCompleteBridgeTokensViaNXTP","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ILiFi.LiFiData","name":"_lifiData","type":"tuple"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.SwapData[]","name":"_swapData","type":"tuple[]"},{"components":[{"components":[{"internalType":"address","name":"receivingChainTxManagerAddress","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"address","name":"sendingChainFallback","type":"address"},{"internalType":"address","name":"receivingAddress","type":"address"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"uint256","name":"sendingChainId","type":"uint256"},{"internalType":"uint256","name":"receivingChainId","type":"uint256"},{"internalType":"bytes32","name":"callDataHash","type":"bytes32"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"internalType":"struct ITransactionManager.InvariantTransactionData","name":"invariantData","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bytes","name":"encryptedCallData","type":"bytes"},{"internalType":"bytes","name":"encodedBid","type":"bytes"},{"internalType":"bytes","name":"bidSignature","type":"bytes"},{"internalType":"bytes","name":"encodedMeta","type":"bytes"}],"internalType":"struct ITransactionManager.PrepareArgs","name":"_nxtpData","type":"tuple"}],"name":"swapAndStartBridgeTokensViaNXTP","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061297b806100206000396000f3fe6080604052600436106100655760003560e01c80637d7aecd3116100435780637d7aecd3146100dd578063bfa1fc0a146100f0578063cf76d3131461011057600080fd5b806328225f0c1461006a5780632a7a70421461007f5780634f7c96b514610092575b600080fd5b61007d610078366004611c77565b610123565b005b61007d61008d36600461206b565b6101f8565b34801561009e57600080fd5b507fcb4800033539e504944b70f0275e98829f191b99c5226e9a5a072ab49d2a753e54604080516001600160a01b039092168252519081900360200190f35b61007d6100eb3660046120f9565b610363565b3480156100fc57600080fd5b5061007d61010b366004612165565b6104c8565b61007d61011e366004612182565b61059b565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b805460001901610180576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001815561018e848361067f565b610199848484610698565b604080516001600160a01b038087168252851660208201529081018390524260608201528535907fb8c86983f929c6b770461983d1bbde1870408120f07123e9c12d49f35a0b4c4b906080015b60405180910390a26000905550505050565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b805460001901610255576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001815561026d61026586612213565b8585336106c1565b602083015261027b826107c5565b5084357f438f81f3fe94456cd9d98e9073524f1c2bafb3ce75def8ced69f708061ddd5c46102ac60208801886122bf565b6102bc60608a0160408b01612165565b888860008181106102cf576102cf612324565b90506020028101906102e19190612353565b6102f2906060810190604001612165565b61030260a08c0160808d01612165565b885160e001518b8b60008161031957610319612324565b905060200281019061032b9190612353565b8a51610140810151610100909101516040516101e6999897969594936080013592916001916001600160a01b03909116151590612391565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b8054600019016103c0576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181556103e26103d760a0840160808501612165565b836101a0013561067f565b6103f36103ee83612474565b6107c5565b5082357f438f81f3fe94456cd9d98e9073524f1c2bafb3ce75def8ced69f708061ddd5c461042460208601866122bf565b6104346060880160408901612165565b61044460a0880160808901612165565b61045460a08a0160808b01612165565b6104656101008a0160e08b01612165565b896101a001358a60000161014001356000806001600160a01b03168d6000016101000160208101906104979190612165565b6001600160a01b031614156040516104b89a99989796959493929190612391565b60405180910390a2600090555050565b6104d06108cd565b6001600160a01b038116610510576040517f35be3ac800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcb4800033539e504944b70f0275e98829f191b99c5226e9a5a072ab49d2a753e80546001600160a01b0383167fffffffffffffffffffffffff00000000000000000000000000000000000000009091168117825560408051918252517f2ef7cbc72cbbb19695283339290d52328d612ad910a40b47fe777e67f593320e9181900360200190a15050565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b8054600019016105f8576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018155600061061261060a88612213565b8787866106c1565b905061061f848483610698565b604080516001600160a01b038087168252851660208201529081018290524260608201528735907fb8c86983f929c6b770461983d1bbde1870408120f07123e9c12d49f35a0b4c4b9060800160405180910390a250600090555050505050565b61069482826001600160a01b03821615610990565b5050565b6001600160a01b038316156106b7576106b2838383610aab565b505050565b6106b28282610af6565b6000828082036106fd576040517f0503c3ed00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000858561070c6001826124af565b81811061071b5761071b612324565b905060200281019061072d9190612353565b61073e906080810190606001612165565b9050600061074b82610bc3565b905061075988888888610c62565b600061076483610bc3565b9050818111610773578061077d565b61077d82826124af565b9150816000036107b9576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50979650505050505050565b8051608001517fcb4800033539e504944b70f0275e98829f191b99c5226e9a5a072ab49d2a753e805460208401516000939161080c9183916001600160a01b031690611025565b60006001600160a01b0382161561082457600061082a565b84602001515b83546040517fd94593720000000000000000000000000000000000000000000000000000000081529192506000916001600160a01b039091169063d945937290849061087a908a90600401612629565b6102006040518083038185885af1158015610899573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108be91906126df565b61014001519695505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316331461098e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201527f657200000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b565b816000036109ca576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8015610a09578134146106b2576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3415610a40576040517e3f45b500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a4b84610bc3565b9050610a598433308661111c565b8281610a6486610bc3565b610a6e91906124af565b14610aa5576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b6001600160a01b038316610aeb576040517fd1bebf0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6106b28383836111a8565b6001600160a01b038216610b36576040517f21f7434500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610b83576040519150601f19603f3d011682016040523d82523d6000602084013e610b88565b606091505b50509050806106b2576040517f5a04673700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006001600160a01b03821615610c5a576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5591906127e4565b610c5c565b475b92915050565b8282828160018114610ee8576000610c7a8585611251565b905060008585610c8b6001866124af565b818110610c9a57610c9a612324565b9050602002810190610cac9190612353565b610cbd906080810190606001612165565b905060008060005b8a811015610df357368c8c83818110610ce057610ce0612324565b9050602002810190610cf29190612353565b9050600080610d076040840160208501612165565b6001600160a01b0316815260208101919091526040016000205460ff168015610d595750600080610d3b6020840184612165565b6001600160a01b0316815260208101919091526040016000205460ff165b8015610d9e575060016000610d7160a08401846122bf565b610d80916008916000916127fd565b610d8991612827565b815260208101919091526040016000205460ff165b610dd4576040517f9453980400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8d51610de0908261131b565b5080610deb81612845565b915050610cc5565b5060005b610e026001876124af565b811015610ede576000898983818110610e1d57610e1d612324565b9050602002810190610e2f9190612353565b610e40906080810190606001612165565b9050846001600160a01b0316816001600160a01b031603610e615750610ecc565b610e6a81610bc3565b9250858281518110610e7e57610e7e612324565b60200260200101518311610e925782610eb7565b858281518110610ea457610ea4612324565b602002602001015183610eb791906124af565b93508315610eca57610eca818986610698565b505b80610ed681612845565b915050610df7565b505050505061101b565b60005b868110156110195736888883818110610f0657610f06612324565b9050602002810190610f189190612353565b9050600080610f2d6040840160208501612165565b6001600160a01b0316815260208101919091526040016000205460ff168015610f7f5750600080610f616020840184612165565b6001600160a01b0316815260208101919091526040016000205460ff165b8015610fc4575060016000610f9760a08401846122bf565b610fa6916008916000916127fd565b610faf91612827565b815260208101919091526040016000205460ff165b610ffa576040517f9453980400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8951611006908261131b565b508061101181612845565b915050610eeb565b505b5050505050505050565b6001600160a01b03831661103857505050565b6001600160a01b038216611078576040517f63ba9bff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156110e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110591906127e4565b905081811015610aa557610aa584846000196115c8565b6001600160a01b03841661115c576040517fd1bebf0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03821661119c576040517f21f7434500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610aa584848484611730565b6040516001600160a01b0383166024820152604481018290526106b29084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611781565b60608160008167ffffffffffffffff81111561126f5761126f611d2d565b604051908082528060200260200182016040528015611298578160200160208202803683370190505b50905060005b82811015611312576112e38686838181106112bb576112bb612324565b90506020028101906112cd9190612353565b6112de906080810190606001612165565b610bc3565b8282815181106112f5576112f5612324565b60209081029190910101528061130a81612845565b91505061129e565b50949350505050565b61133161132b6020830183612165565b3b151590565b611367576040517f6eefed2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b608081013560008190036113a7576040517fe46e079c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806113ba6060850160408601612165565b905060006113ce6080860160608701612165565b905060006113db83610bc3565b905060006113e883610bc3565b905060008683106113fa576000611404565b61140483886124af565b90506001600160a01b038516156114465761142f8561142960408b0160208c01612165565b89611025565b8015611441576114418533308461111c565b61144a565b8695505b60008061145a60208b018b612165565b6001600160a01b03168861147160a08d018d6122bf565b60405161147f92919061285f565b60006040518083038185875af1925050503d80600081146114bc576040519150601f19603f3d011682016040523d82523d6000602084013e6114c1565b606091505b50915091508161150c5760006114d682611880565b9050806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610985919061286f565b600061151787610bc3565b90507f7bfdfdb5e3a3776976e53cb0607060f54c5312701c8cba1155cc4d5394440b388c61154860208e018e612165565b8d604001602081019061155b9190612165565b8a8e8a871161156a5786611574565b6115748b886124af565b604080519687526001600160a01b0395861660208801529385169386019390935292166060840152608083019190915260a08201524260c082015260e00160405180910390a1505050505050505050505050565b80158061165b57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611635573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165991906127e4565b155b6116e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610985565b6040516001600160a01b0383166024820152604481018290526106b29084907f095ea7b300000000000000000000000000000000000000000000000000000000906064016111ed565b6040516001600160a01b0380851660248301528316604482015260648101829052610aa59085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016111ed565b60006117d6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118fe9092919063ffffffff16565b8051909150156106b257808060200190518101906117f49190612882565b6106b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610985565b60606044825110156118c557505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b60006118e160048085516118d991906124af565b859190611915565b9050808060200190518101906118f791906128a4565b9392505050565b606061190d8484600085611a70565b949350505050565b60608161192381601f61291b565b101561198b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152606401610985565b611995828461291b565b845110156119ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152606401610985565b606082158015611a1e5760405191506000825260208201604052611312565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015611a57578051835260209283019201611a3f565b5050858452601f01601f19166040525050949350505050565b606082471015611b02576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610985565b843b611b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610985565b600080866001600160a01b03168587604051611b869190612933565b60006040518083038185875af1925050503d8060008114611bc3576040519150601f19603f3d011682016040523d82523d6000602084013e611bc8565b606091505b5091509150611bd8828286611be3565b979650505050505050565b60608315611bf25750816118f7565b825115611c025782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610985919061286f565b60006101008284031215611c4957600080fd5b50919050565b6001600160a01b0381168114611c6457600080fd5b50565b8035611c7281611c4f565b919050565b60008060008060808587031215611c8d57600080fd5b843567ffffffffffffffff811115611ca457600080fd5b611cb087828801611c36565b9450506020850135611cc181611c4f565b92506040850135611cd181611c4f565b9396929550929360600135925050565b60008083601f840112611cf357600080fd5b50813567ffffffffffffffff811115611d0b57600080fd5b6020830191508360208260051b8501011115611d2657600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516101a0810167ffffffffffffffff81118282101715611d8057611d80611d2d565b60405290565b60405160e0810167ffffffffffffffff81118282101715611d8057611d80611d2d565b604051610100810167ffffffffffffffff81118282101715611d8057611d80611d2d565b604051610200810167ffffffffffffffff81118282101715611d8057611d80611d2d565b604051601f8201601f1916810167ffffffffffffffff81118282101715611e1a57611e1a611d2d565b604052919050565b60006101a08284031215611e3557600080fd5b611e3d611d5c565b9050611e4882611c67565b8152611e5660208301611c67565b6020820152611e6760408301611c67565b6040820152611e7860608301611c67565b6060820152611e8960808301611c67565b6080820152611e9a60a08301611c67565b60a0820152611eab60c08301611c67565b60c0820152611ebc60e08301611c67565b60e0820152610100611ecf818401611c67565b908201526101208281013590820152610140808301359082015261016080830135908201526101809182013591810191909152919050565b600067ffffffffffffffff821115611f2157611f21611d2d565b50601f01601f191660200190565b600082601f830112611f4057600080fd5b8135611f53611f4e82611f07565b611df1565b818152846020838601011115611f6857600080fd5b816020850160208301376000918101602001919091529392505050565b60006102608284031215611f9857600080fd5b611fa0611d86565b9050611fac8383611e22565b81526101a082013560208201526101c082013560408201526101e082013567ffffffffffffffff80821115611fe057600080fd5b611fec85838601611f2f565b606084015261020084013591508082111561200657600080fd5b61201285838601611f2f565b608084015261022084013591508082111561202c57600080fd5b61203885838601611f2f565b60a084015261024084013591508082111561205257600080fd5b5061205f84828501611f2f565b60c08301525092915050565b6000806000806060858703121561208157600080fd5b843567ffffffffffffffff8082111561209957600080fd5b6120a588838901611c36565b955060208701359150808211156120bb57600080fd5b6120c788838901611ce1565b909550935060408701359150808211156120e057600080fd5b506120ed87828801611f85565b91505092959194509250565b6000806040838503121561210c57600080fd5b823567ffffffffffffffff8082111561212457600080fd5b61213086838701611c36565b9350602085013591508082111561214657600080fd5b508301610260818603121561215a57600080fd5b809150509250929050565b60006020828403121561217757600080fd5b81356118f781611c4f565b60008060008060006080868803121561219a57600080fd5b853567ffffffffffffffff808211156121b257600080fd5b6121be89838a01611c36565b965060208801359150808211156121d457600080fd5b506121e188828901611ce1565b90955093505060408601356121f581611c4f565b9150606086013561220581611c4f565b809150509295509295909350565b6000610100823603121561222657600080fd5b61222e611da9565b82358152602083013567ffffffffffffffff81111561224c57600080fd5b61225836828601611f2f565b60208301525061226a60408401611c67565b604082015261227b60608401611c67565b606082015261228c60808401611c67565b608082015261229d60a08401611c67565b60a082015260c083013560c082015260e083013560e082015280915050919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126122f457600080fd5b83018035915067ffffffffffffffff82111561230f57600080fd5b602001915036819003821315611d2657600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4183360301811261238757600080fd5b9190910192915050565b6000610160808352600481840152507f6e787470000000000000000000000000000000000000000000000000000000006101808301526101a0806020840152600081840152506101c08060408401528b81840152506101e08b8d8285013760008c84018201526001600160a01b038b166060840152601f19601f8d011683010190506001600160a01b03891660808301526001600160a01b03881660a08301526001600160a01b03871660c08301528560e08301528461010083015261245c61012083018515159052565b8215156101408301529b9a5050505050505050505050565b6000610c5c3683611f85565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000828210156124c1576124c1612480565b500390565b80516001600160a01b0316825260208101516124ed60208401826001600160a01b03169052565b50604081015161250860408401826001600160a01b03169052565b50606081015161252360608401826001600160a01b03169052565b50608081015161253e60808401826001600160a01b03169052565b5060a081015161255960a08401826001600160a01b03169052565b5060c081015161257460c08401826001600160a01b03169052565b5060e081015161258f60e08401826001600160a01b03169052565b50610100818101516001600160a01b03169083015261012080820151908301526101408082015190830152610160808201519083015261018090810151910152565b60005b838110156125ec5781810151838201526020016125d4565b83811115610aa55750506000910152565b600081518084526126158160208601602086016125d1565b601f01601f19169290920160200192915050565b6020815261263b6020820183516124c6565b60208201516101c082015260408201516101e082015260006060830151610260806102008501526126706102808501836125fd565b91506080850151601f19808685030161022087015261268f84836125fd565b935060a0870151915080868503016102408701526126ad84836125fd565b935060c08701519150808685030183870152506126ca83826125fd565b9695505050505050565b8051611c7281611c4f565b600061020082840312156126f257600080fd5b6126fa611dcd565b612703836126d4565b8152612711602084016126d4565b6020820152612722604084016126d4565b6040820152612733606084016126d4565b6060820152612744608084016126d4565b608082015261275560a084016126d4565b60a082015261276660c084016126d4565b60c082015261277760e084016126d4565b60e082015261010061278a8185016126d4565b9082015261012083810151908201526101408084015190820152610160808401519082015261018080840151908201526101a080840151908201526101c080840151908201526101e0928301519281019290925250919050565b6000602082840312156127f657600080fd5b5051919050565b6000808585111561280d57600080fd5b8386111561281a57600080fd5b5050820193919092039150565b80356020831015610c5c57600019602084900360031b1b1692915050565b6000600019820361285857612858612480565b5060010190565b8183823760009101908152919050565b6020815260006118f760208301846125fd565b60006020828403121561289457600080fd5b815180151581146118f757600080fd5b6000602082840312156128b657600080fd5b815167ffffffffffffffff8111156128cd57600080fd5b8201601f810184136128de57600080fd5b80516128ec611f4e82611f07565b81815285602083850101111561290157600080fd5b6129128260208301602086016125d1565b95945050505050565b6000821982111561292e5761292e612480565b500190565b600082516123878184602087016125d156fea264697066735822122024617791bc93714febb5fa5d83e4bbad331f9e842c84873a28f1a23547e3643e64736f6c634300080d0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.