Overview
GLMR Balance
GLMR Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
10526147 | 3 days ago | 98.50958246 GLMR | ||||
10526147 | 3 days ago | 0.14798635 GLMR | ||||
10515700 | 4 days ago | 9.975 GLMR | ||||
10515700 | 4 days ago | 0.01 GLMR | ||||
10515700 | 4 days ago | 0.015 GLMR | ||||
10204542 | 26 days ago | 19.97 GLMR | ||||
10204542 | 26 days ago | 0.03 GLMR | ||||
9248131 | 93 days ago | 255.57665876 GLMR | ||||
9191848 | 97 days ago | 3.03700414 GLMR | ||||
9191845 | 97 days ago | 3.9641969 GLMR | ||||
9082503 | 105 days ago | 59.05644981 GLMR | ||||
9021163 | 109 days ago | 1.46052165 GLMR | ||||
9018033 | 110 days ago | 140.64263421 GLMR | ||||
9007427 | 110 days ago | 1.49625 GLMR | ||||
9007427 | 110 days ago | 0.0015 GLMR | ||||
9007427 | 110 days ago | 0.00225 GLMR | ||||
8995041 | 111 days ago | 0.99619583 GLMR | ||||
8995034 | 111 days ago | 0.98973694 GLMR | ||||
8995019 | 111 days ago | 0.9975 GLMR | ||||
8995019 | 111 days ago | 0.001 GLMR | ||||
8995019 | 111 days ago | 0.0015 GLMR | ||||
8995001 | 111 days ago | 0.9975 GLMR | ||||
8995001 | 111 days ago | 0.001 GLMR | ||||
8995001 | 111 days ago | 0.0015 GLMR | ||||
8969896 | 113 days ago | 36.53482497 GLMR |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
RangoSwapperFacet
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity 0.8.25; import "../../libraries/LibDiamond.sol"; import "../../libraries/LibSwapper.sol"; import "../../utils/ReentrancyGuard.sol"; import "../../libraries/LibPausable.sol"; contract RangoSwapperFacet is ReentrancyGuard{ /// Events /// /// @notice initializes the base swapper and sets the init params /// @param _weth Address of wrapped token (WETH, WBNB, etc.) on the current chain function initBaseSwapper(address _weth, address payable _feeReceiver) public { LibDiamond.enforceIsContractOwner(); LibSwapper.setWeth(_weth); LibSwapper.updateFeeContractAddress(_feeReceiver); } /// @notice Sets the wallet that receives Rango's fees from now on /// @param _address The receiver wallet address function updateFeeReceiver(address payable _address) external { LibDiamond.enforceIsContractOwner(); LibSwapper.updateFeeContractAddress(_address); } /// @notice Transfers an ERC20 token from this contract to msg.sender /// @dev This endpoint is to return money to a user if we didn't handle failure correctly and the money is still in the contract /// @dev Currently the money goes to admin and they should manually transfer it to a wallet later /// @param _tokenAddress The address of ERC20 token to be transferred /// @param _amount The amount of money that should be transfered function refund(address _tokenAddress, uint256 _amount) external { LibDiamond.enforceIsContractOwner(); LibPausable.enforceNotPaused(); IERC20 ercToken = IERC20(_tokenAddress); uint balance = ercToken.balanceOf(address(this)); require(balance >= _amount, "Insufficient balance"); SafeERC20.safeTransfer(ercToken, msg.sender, _amount); emit LibSwapper.Refunded(_tokenAddress, _amount); } /// @notice Transfers the native token from this contract to msg.sender /// @dev This endpoint is to return money to a user if we didn't handle failure correctly and the money is still in the contract /// @dev Currently the money goes to admin and they should manually transfer it to a wallet later /// @param _amount The amount of native token that should be transfered function refundNative(uint256 _amount) external { LibDiamond.enforceIsContractOwner(); LibPausable.enforceNotPaused(); uint balance = address(this).balance; require(balance >= _amount, "Insufficient balance"); LibSwapper._sendToken(LibSwapper.ETH, _amount, msg.sender, false); emit LibSwapper.Refunded(LibSwapper.ETH, _amount); } /// @notice Does a simple on-chain swap /// @param request The general swap request containing from/to token and fee/affiliate rewards /// @param calls The list of DEX calls /// @param receiver The address that should receive the output of swaps. /// @return The byte array result of all DEX calls function onChainSwaps( LibSwapper.SwapRequest memory request, LibSwapper.Call[] calldata calls, address receiver ) external payable nonReentrant returns (bytes[] memory) { LibPausable.enforceNotPaused(); require(receiver != LibSwapper.ETH, "receiver cannot be address(0)"); (bytes[] memory result, uint outputAmount) = LibSwapper.onChainSwapsInternal(request, calls, 0); LibSwapper.emitSwapEvent(request, outputAmount, receiver); LibSwapper._sendToken(request.toToken, outputAmount, receiver, false); return result; } function isContractWhitelisted(address _contractAddress) external view returns (bool) { LibDiamond.enforceIsContractOwner(); LibSwapper.BaseSwapperStorage storage baseSwapperStorage = LibSwapper.getBaseSwapperStorage(); return baseSwapperStorage.whitelistContracts[_contractAddress]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../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; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { bytes memory returndata = address(token).functionCall(abi.encodeCall(token.transfer, (to, value))); if (address(token)!=0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C && returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } // _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @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); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.25; 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: LGPL-3.0-only pragma solidity 0.8.25; interface IRango { struct RangoBridgeRequest { address requestId; address token; uint amount; uint platformFee; uint affiliateFee; address payable affiliatorAddress; uint destinationExecutorFee; uint16 dAppTag; string dAppName; } enum BridgeType { Across, CBridge, Hop, Hyphen, Multichain, Stargate, Synapse, Thorchain, Symbiosis, Axelar, Voyager, Poly, OptimismBridge, ArbitrumBridge, Wormhole, AllBridge, CCTP, Connext, NitroAssetForwarder, DeBridge, YBridge, Swft, Orbiter, ChainFlip } /// @notice Status of cross-chain swap /// @param Succeeded The whole process is success and end-user received the desired token in the destination /// @param RefundInSource Bridge was out of liquidity and middle asset (ex: USDC) is returned to user on source chain /// @param RefundInDestination Our handler on dest chain this.executeMessageWithTransfer failed and we send middle asset (ex: USDC) to user on destination chain /// @param SwapFailedInDestination Everything was ok, but the final DEX on destination failed (ex: Market price change and slippage) enum CrossChainOperationStatus { Succeeded, RefundInSource, RefundInDestination, SwapFailedInDestination } event RangoBridgeInitiated( address indexed requestId, address bridgeToken, uint256 bridgeAmount, address receiver, uint destinationChainId, bool hasInterchainMessage, bool hasDestinationSwap, uint8 indexed bridgeId, uint16 indexed dAppTag, string dAppName ); event RangoBridgeCompleted( address indexed requestId, address indexed token, address indexed originalSender, address receiver, uint amount, CrossChainOperationStatus status, uint16 dAppTag ); }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.8.25; interface IWETH { function deposit() external payable; function withdraw(uint256) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.25; import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; /// Implementation of EIP-2535 Diamond Standard /// https://eips.ethereum.org/EIPS/eip-2535 library LibDiamond { /// Storage /// bytes32 internal constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); // Diamond specific errors error IncorrectFacetCutAction(); error NoSelectorsInFacet(); error FunctionAlreadyExists(); error FacetAddressIsZero(); error FacetAddressIsNotZero(); error FacetContainsNoCode(); error FunctionDoesNotExist(); error FunctionIsImmutable(); error InitZeroButCalldataNotEmpty(); error CalldataEmptyButInitNotZero(); error InitReverted(); // ---------------- 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; ) { 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 IncorrectFacetCutAction(); } unchecked { ++facetIndex; } } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { if (_facetAddress == address(0)) { revert FacetAddressIsZero(); } if (_functionSelectors.length == 0) { revert NoSelectorsInFacet(); } DiamondStorage storage ds = diamondStorage(); 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; ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; if (oldFacetAddress != address(0)) { revert FunctionAlreadyExists(); } addFunction(ds, selector, selectorPosition, _facetAddress); unchecked { ++selectorPosition; ++selectorIndex; } } } function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { if (_functionSelectors.length == 0) { revert NoSelectorsInFacet(); } if (_facetAddress == address(0)) { revert FacetAddressIsZero(); } DiamondStorage storage ds = diamondStorage(); 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; ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; if (oldFacetAddress == _facetAddress) { revert FunctionAlreadyExists(); } removeFunction(ds, oldFacetAddress, selector); addFunction(ds, selector, selectorPosition, _facetAddress); unchecked { ++selectorPosition; ++selectorIndex; } } } function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { if (_functionSelectors.length == 0) { revert NoSelectorsInFacet(); } DiamondStorage storage ds = diamondStorage(); // if function does not exist then do nothing and return if (_facetAddress != address(0)) { revert FacetAddressIsNotZero(); } for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; removeFunction(ds, oldFacetAddress, selector); unchecked { ++selectorIndex; } } } function addFacet(DiamondStorage storage ds, address _facetAddress) internal { enforceHasContractCode(_facetAddress); 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 { if (_facetAddress == address(0)) { revert FunctionDoesNotExist(); } // an immutable function is a function defined directly in a diamond if (_facetAddress == address(this)) { revert FunctionIsImmutable(); } // 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)) { if (_calldata.length != 0) { revert InitZeroButCalldataNotEmpty(); } } else { if (_calldata.length == 0) { revert CalldataEmptyButInitNotZero(); } if (_init != address(this)) { enforceHasContractCode(_init); } // 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 InitReverted(); } } } } function enforceHasContractCode(address _contract) internal view { uint256 contractSize; // solhint-disable-next-line no-inline-assembly assembly { contractSize := extcodesize(_contract) } if (contractSize == 0) { revert FacetContainsNoCode(); } } }
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity 0.8.25; /// @title Pausable Library /// @author 0xiDen /// @notice This library provides pausable feature across entire diamond protected methods. Be advised only methods that call `enforceNotPaused` will be protected! library LibPausable { /// Storage /// bytes32 private constant NAMESPACE = keccak256("exchange.rango.library.pausable"); /// Types /// struct PausableStorage { bool isPaused; } /// Events /// /// @notice Notifies that Rango's paused state is updated /// @param _oldPausedState The previous paused state /// @param _newPausedState The new fee wallet address event PausedStateUpdated(bool _oldPausedState, bool _newPausedState); /// Errors /// /// Constants /// /// Modifiers /// /// Internal Methods /// /// @notice Sets the isPaused state for Rango /// @param _paused The receiver wallet address function updatePauseState(bool _paused) internal { PausableStorage storage pausableStorage = getPausableStorage(); bool oldState = pausableStorage.isPaused; pausableStorage.isPaused = _paused; emit PausedStateUpdated(oldState, _paused); } function enforceNotPaused() internal view { PausableStorage storage pausableStorage = getPausableStorage(); require(pausableStorage.isPaused == false, "Paused"); } /// Private Methods /// /// @dev fetch local storage function getPausableStorage() private pure returns (PausableStorage storage data) { bytes32 position = NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { data.slot := position } } }
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity 0.8.25; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IWETH.sol"; import "../interfaces/IRango.sol"; /// @title BaseSwapper /// @author 0xiden /// @notice library to provide swap functionality library LibSwapper { bytes32 internal constant BASE_SWAPPER_NAMESPACE = keccak256("exchange.rango.library.swapper"); address payable constant ETH = payable(0x0000000000000000000000000000000000000000); struct BaseSwapperStorage { address payable feeContractAddress; address WETH; mapping(address => bool) whitelistContracts; mapping(address => mapping(bytes4 => bool)) whitelistMethods; } /// @notice Emitted if any fee transfer was required /// @param token The address of received token, address(0) for native /// @param affiliatorAddress The address of affiliate wallet /// @param platformFee The amount received as platform fee /// @param destinationExecutorFee The amount received to execute transaction on destination (only for cross chain txs) /// @param affiliateFee The amount received by affiliate /// @param dAppTag Optional identifier to make tracking easier. event FeeInfo( address token, address indexed affiliatorAddress, uint platformFee, uint destinationExecutorFee, uint affiliateFee, uint16 indexed dAppTag ); /// @notice A call to another dex or contract done and here is the result /// @param target The address of dex or contract that is called /// @param success A boolean indicating that the call was success or not /// @param returnData The response of function call event CallResult(address target, bool success, bytes returnData); /// @notice A swap request is done and we also emit the output /// @param requestId Optional parameter to make tracking of transaction easier /// @param fromToken Input token address to be swapped from /// @param toToken Output token address to be swapped to /// @param amountIn Input amount of fromToken that is being swapped /// @param dAppTag Optional identifier to make tracking easier /// @param outputAmount The output amount of the swap, measured by the balance change before and after the swap /// @param receiver The address to receive the output of swap. Can be address(0) when swap is before a bridge action /// @param dAppName The human readable name of the dApp event RangoSwap( address indexed requestId, address fromToken, address toToken, uint amountIn, uint minimumAmountExpected, uint16 indexed dAppTag, uint outputAmount, address receiver, string dAppName ); /// @notice Output amount of a dex calls is logged /// @param _token The address of output token, ZERO address for native /// @param amount The amount of output event DexOutput(address _token, uint amount); /// @notice The output money (ERC20/Native) is sent to a wallet /// @param _token The token that is sent to a wallet, ZERO address for native /// @param _amount The sent amount /// @param _receiver The receiver wallet address event SendToken(address _token, uint256 _amount, address _receiver); /// @notice Notifies that Rango's fee receiver address updated /// @param _oldAddress The previous fee wallet address /// @param _newAddress The new fee wallet address event FeeContractAddressUpdated(address _oldAddress, address _newAddress); /// @notice Notifies that WETH address is updated /// @param _oldAddress The previous weth address /// @param _newAddress The new weth address event WethContractAddressUpdated(address _oldAddress, address _newAddress); /// @notice Notifies that admin manually refunded some money /// @param _token The address of refunded token, 0x000..00 address for native token /// @param _amount The amount that is refunded event Refunded(address _token, uint _amount); /// @notice The requested call data which is computed off-chain and passed to the contract /// @dev swapFromToken and amount parameters are only helper params and the actual amount and /// token are set in callData /// @param spender The contract which the approval is given to if swapFromToken is not native. /// @param target The dex contract address that should be called /// @param swapFromToken Token address of to be used in the swap. /// @param amount The amount to be approved or native amount sent. /// @param callData The required data field that should be give to the dex contract to perform swap struct Call { address spender; address payable target; address swapFromToken; address swapToToken; bool needsTransferFromUser; uint amount; bytes callData; } /// @notice General swap request which is given to us in all relevant functions /// @param requestId The request id passed to make tracking transactions easier /// @param fromToken The source token that is going to be swapped (in case of simple swap or swap + bridge) or the briding token (in case of solo bridge) /// @param toToken The output token of swapping. This is the output of DEX step and is also input of bridging step /// @param amountIn The amount of input token to be swapped /// @param platformFee The amount of fee charged by platform /// @param destinationExecutorFee The amount of fee required for relayer execution on the destination /// @param affiliateFee The amount of fee charged by affiliator dApp /// @param affiliatorAddress The wallet address that the affiliator fee should be sent to /// @param minimumAmountExpected The minimum amount of toToken expected after executing Calls /// @param feeFromInputToken If set to true, the fees will be taken from input token and otherwise, from output token. (platformFee,destinationExecutorFee,affiliateFee) /// @param dAppTag An optional parameter /// @param dAppName The Name of the dApp struct SwapRequest { address requestId; address fromToken; address toToken; uint amountIn; uint platformFee; uint destinationExecutorFee; uint affiliateFee; address payable affiliatorAddress; uint minimumAmountExpected; bool feeFromInputToken; uint16 dAppTag; string dAppName; } /// @notice initializes the base swapper and sets the init params (such as Wrapped token address) /// @param _weth Address of wrapped token (WETH, WBNB, etc.) on the current chain function setWeth(address _weth) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); address oldAddress = baseStorage.WETH; baseStorage.WETH = _weth; require(_weth != address(0), "Invalid WETH!"); emit WethContractAddressUpdated(oldAddress, _weth); } /// @notice Sets the wallet that receives Rango's fees from now on /// @param _address The receiver wallet address function updateFeeContractAddress(address payable _address) internal { BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage(); address oldAddress = baseSwapperStorage.feeContractAddress; baseSwapperStorage.feeContractAddress = _address; emit FeeContractAddressUpdated(oldAddress, _address); } /// Whitelist /// /// @notice Adds a contract to the whitelisted DEXes that can be called /// @param contractAddress The address of the DEX function addWhitelist(address contractAddress) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); baseStorage.whitelistContracts[contractAddress] = true; } /// @notice Adds a method of contract to the whitelisted DEXes that can be called /// @param contractAddress The address of the DEX /// @param methodIds The method of the DEX function addMethodWhitelists(address contractAddress, bytes4[] calldata methodIds) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); baseStorage.whitelistContracts[contractAddress] = true; for (uint i = 0; i < methodIds.length; i++) baseStorage.whitelistMethods[contractAddress][methodIds[i]] = true; } /// @notice Adds a method of contract to the whitelisted DEXes that can be called /// @param contractAddress The address of the DEX /// @param methodId The method of the DEX function addMethodWhitelist(address contractAddress, bytes4 methodId) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); baseStorage.whitelistContracts[contractAddress] = true; baseStorage.whitelistMethods[contractAddress][methodId] = true; } /// @notice Removes a contract from the whitelisted DEXes /// @param contractAddress The address of the DEX or dApp function removeWhitelist(address contractAddress) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); delete baseStorage.whitelistContracts[contractAddress]; } /// @notice Removes a method of contract from the whitelisted DEXes /// @param contractAddress The address of the DEX or dApp /// @param methodId The method of the DEX function removeMethodWhitelist(address contractAddress, bytes4 methodId) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); delete baseStorage.whitelistMethods[contractAddress][methodId]; } function onChainSwapsPreBridge( SwapRequest memory request, Call[] calldata calls, uint extraFee ) internal returns (uint out) { uint minimumRequiredValue = getPreBridgeMinAmount(request) + extraFee; require(msg.value >= minimumRequiredValue, 'Send more ETH to cover input amount + fee'); (, out) = onChainSwapsInternal(request, calls, extraFee); // when there is a bridge after swap, set the receiver in swap event to address(0) emitSwapEvent(request, out, ETH); return out; } /// @notice Internal function to compute output amount of DEXes /// @param request The general swap request containing from/to token and fee/affiliate rewards /// @param calls The list of DEX calls /// @param extraNativeFee The amount of native tokens to keep and not return to user as excess amount. /// @return The response of all DEX calls and the output amount of the whole process function onChainSwapsInternal( SwapRequest memory request, Call[] calldata calls, uint256 extraNativeFee ) internal returns (bytes[] memory, uint) { uint toBalanceBefore = getBalanceOf(request.toToken); uint fromBalanceBefore = getBalanceOf(request.fromToken); uint256[] memory initialBalancesList = getInitialBalancesList(calls); // transfer tokens from user for SwapRequest and Calls that require transfer from user. transferTokensFromUserForSwapRequest(request); transferTokensFromUserForCalls(calls); bytes[] memory result = callSwapsAndFees(request, calls); // check if any extra tokens were taken from contract and return excess tokens if any. returnExcessAmounts(request, calls, initialBalancesList); // get balance after returning excesses. uint fromBalanceAfter = getBalanceOf(request.fromToken); // check over-expense of fromToken and return excess if any. if (request.fromToken != ETH) { require(fromBalanceAfter >= fromBalanceBefore, "Source token balance on contract must not decrease after swap"); if (fromBalanceAfter > fromBalanceBefore) _sendToken(request.fromToken, fromBalanceAfter - fromBalanceBefore, msg.sender); } else { require(fromBalanceAfter >= fromBalanceBefore - msg.value + extraNativeFee, "Source token balance on contract must not decrease after swap"); // When we are keeping extraNativeFee for bridgingFee, we should consider it in calculations. if (fromBalanceAfter > fromBalanceBefore - msg.value + extraNativeFee) _sendToken(request.fromToken, fromBalanceAfter + msg.value - fromBalanceBefore - extraNativeFee, msg.sender); } uint toBalanceAfter = getBalanceOf(request.toToken); uint secondaryBalance = toBalanceAfter - toBalanceBefore; require(secondaryBalance >= request.minimumAmountExpected, "Output is less than minimum expected"); return (result, secondaryBalance); } /// @notice Private function to handle fetching money from wallet to contract, reduce fee/affiliate, perform DEX calls /// @param request The general swap request containing from/to token and fee/affiliate rewards /// @param calls The list of DEX calls /// @dev It checks the whitelisting of all DEX addresses + having enough msg.value as input /// @return The bytes of all DEX calls response function callSwapsAndFees(SwapRequest memory request, Call[] calldata calls) private returns (bytes[] memory) { BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage(); for (uint256 i = 0; i < calls.length; i++) { require(baseSwapperStorage.whitelistContracts[calls[i].spender], "Contract spender not whitelisted"); require(baseSwapperStorage.whitelistContracts[calls[i].target], "Contract target not whitelisted"); bytes4 sig = bytes4(calls[i].callData[: 4]); require(baseSwapperStorage.whitelistMethods[calls[i].target][sig], "Unauthorized call data!"); } // Get Fees Before swap collectFeesBeforeSwap(request); // Execute swap Calls bytes[] memory returnData = new bytes[](calls.length); address tmpSwapFromToken; for (uint256 i = 0; i < calls.length; i++) { tmpSwapFromToken = calls[i].swapFromToken; bool isTokenNative = tmpSwapFromToken == ETH; if (isTokenNative == false) approveMax(tmpSwapFromToken, calls[i].spender, calls[i].amount); (bool success, bytes memory ret) = isTokenNative ? calls[i].target.call{value : calls[i].amount}(calls[i].callData) : calls[i].target.call(calls[i].callData); emit CallResult(calls[i].target, success, ret); if (!success) revert(_getRevertMsg(ret)); returnData[i] = ret; } // Get Fees After swap collectFeesAfterSwap(request); return returnData; } /// @notice Approves an ERC20 token to a contract to transfer from the current contract /// @param token The address of an ERC20 token /// @param spender The contract address that should be approved /// @param value The amount that should be approved function approve(address token, address spender, uint value) internal { SafeERC20.forceApprove(IERC20(token), spender, value); } /// @notice Approves an ERC20 token to a contract to transfer from the current contract, approves for inf value /// @param token The address of an ERC20 token /// @param spender The contract address that should be approved /// @param value The desired allowance. If current allowance is less than this value, infinite allowance will be given function approveMax(address token, address spender, uint value) internal { uint256 currentAllowance = IERC20(token).allowance(address(this), spender); if (currentAllowance < value) { SafeERC20.forceApprove(IERC20(token), spender, type(uint256).max); } } function _sendToken(address _token, uint256 _amount, address _receiver) internal { (_token == ETH) ? _sendNative(_receiver, _amount) : SafeERC20.safeTransfer(IERC20(_token), _receiver, _amount); } function sumFees(IRango.RangoBridgeRequest memory request) internal pure returns (uint256) { return request.platformFee + request.affiliateFee + request.destinationExecutorFee; } function sumFees(SwapRequest memory request) internal pure returns (uint256) { return request.platformFee + request.affiliateFee + request.destinationExecutorFee; } function getPreBridgeMinAmount(SwapRequest memory request) internal pure returns (uint256) { bool isNative = request.fromToken == ETH; if (request.feeFromInputToken) { return (isNative ? request.platformFee + request.affiliateFee + request.amountIn + request.destinationExecutorFee : 0); } return (isNative ? request.amountIn : 0); } function collectFeesForSwap(SwapRequest memory request) internal { BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage(); // Get Platform fee bool hasPlatformFee = request.platformFee > 0; bool hasDestExecutorFee = request.destinationExecutorFee > 0; bool hasAffiliateFee = request.affiliateFee > 0; address feeToken = request.feeFromInputToken ? request.fromToken : request.toToken; if (hasPlatformFee || hasDestExecutorFee) { require(baseSwapperStorage.feeContractAddress != ETH, "Fee contract address not set"); _sendToken(feeToken, request.platformFee + request.destinationExecutorFee, baseSwapperStorage.feeContractAddress, false); } // Get affiliate fee if (hasAffiliateFee) { require(request.affiliatorAddress != ETH, "Invalid affiliatorAddress"); _sendToken(feeToken, request.affiliateFee, request.affiliatorAddress, false); } // emit Fee event if (hasPlatformFee || hasDestExecutorFee || hasAffiliateFee) { emit FeeInfo( feeToken, request.affiliatorAddress, request.platformFee, request.destinationExecutorFee, request.affiliateFee, request.dAppTag ); } } function collectFees(IRango.RangoBridgeRequest memory request) internal { // Get Platform fee bool hasPlatformFee = request.platformFee > 0; bool hasDestExecutorFee = request.destinationExecutorFee > 0; bool hasAffiliateFee = request.affiliateFee > 0; bool hasAnyFee = hasPlatformFee || hasDestExecutorFee || hasAffiliateFee; if (!hasAnyFee) { return; } BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage(); if (hasPlatformFee || hasDestExecutorFee) { require(baseSwapperStorage.feeContractAddress != ETH, "Fee contract address not set"); _sendToken(request.token, request.platformFee + request.destinationExecutorFee, baseSwapperStorage.feeContractAddress, false); } // Get affiliate fee if (hasAffiliateFee) { require(request.affiliatorAddress != ETH, "Invalid affiliatorAddress"); _sendToken(request.token, request.affiliateFee, request.affiliatorAddress, false); } // emit Fee event emit FeeInfo( request.token, request.affiliatorAddress, request.platformFee, request.destinationExecutorFee, request.affiliateFee, request.dAppTag ); } function collectFeesBeforeSwap(SwapRequest memory request) internal { if (request.feeFromInputToken) { collectFeesForSwap(request); } } function collectFeesAfterSwap(SwapRequest memory request) internal { if (!request.feeFromInputToken) { collectFeesForSwap(request); } } function collectFeesFromSender(IRango.RangoBridgeRequest memory request) internal { // Get Platform fee bool hasPlatformFee = request.platformFee > 0; bool hasDestExecutorFee = request.destinationExecutorFee > 0; bool hasAffiliateFee = request.affiliateFee > 0; bool hasAnyFee = hasPlatformFee || hasDestExecutorFee || hasAffiliateFee; if (!hasAnyFee) { return; } bool isSourceNative = request.token == ETH; BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage(); if (hasPlatformFee || hasDestExecutorFee) { require(baseSwapperStorage.feeContractAddress != ETH, "Fee contract address not set"); if (isSourceNative) _sendToken(request.token, request.platformFee + request.destinationExecutorFee, baseSwapperStorage.feeContractAddress, false); else SafeERC20.safeTransferFrom( IERC20(request.token), msg.sender, baseSwapperStorage.feeContractAddress, request.platformFee + request.destinationExecutorFee ); } // Get affiliate fee if (hasAffiliateFee) { require(request.affiliatorAddress != ETH, "Invalid affiliatorAddress"); if (isSourceNative) _sendToken(request.token, request.affiliateFee, request.affiliatorAddress, false); else SafeERC20.safeTransferFrom( IERC20(request.token), msg.sender, request.affiliatorAddress, request.affiliateFee ); } // emit Fee event emit FeeInfo( request.token, request.affiliatorAddress, request.platformFee, request.destinationExecutorFee, request.affiliateFee, request.dAppTag ); } /// @notice An internal function to send a token from the current contract to another contract or wallet /// @dev This function also can convert WETH to ETH before sending if _withdraw flat is set to true /// @dev To send native token _token param should be set to address zero, otherwise we assume it's an ERC20 transfer /// @param _token The token that is going to be sent to a wallet, ZERO address for native /// @param _amount The sent amount /// @param _receiver The receiver wallet address or contract /// @param _withdraw If true, indicates that we should swap WETH to ETH before sending the money and _nativeOut must also be true function _sendToken( address _token, uint256 _amount, address _receiver, bool _withdraw ) internal { BaseSwapperStorage storage baseStorage = getBaseSwapperStorage(); emit SendToken(_token, _amount, _receiver); bool nativeOut = _token == LibSwapper.ETH; if (_withdraw) { require(_token == baseStorage.WETH, "token mismatch"); IWETH(baseStorage.WETH).withdraw(_amount); nativeOut = true; } if (nativeOut) { _sendNative(_receiver, _amount); } else { SafeERC20.safeTransfer(IERC20(_token), _receiver, _amount); } } /// @notice An internal function to send native token to a contract or wallet /// @param _receiver The address that will receive the native token /// @param _amount The amount of the native token that should be sent function _sendNative(address _receiver, uint _amount) internal { (bool sent,) = _receiver.call{value : _amount}(""); require(sent, "failed to send native"); } /// @notice A utility function to fetch storage from a predefined random slot using assembly /// @return s The storage object function getBaseSwapperStorage() internal pure returns (BaseSwapperStorage storage s) { bytes32 namespace = BASE_SWAPPER_NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { s.slot := namespace } } /// @notice To extract revert message from a DEX/contract call to represent to the end-user in the blockchain /// @param _returnData The resulting bytes of a failed call to a DEX or contract /// @return A string that describes what was the error function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (_returnData.length < 68) return 'Transaction reverted silently'; assembly { // Slice the sighash. _returnData := add(_returnData, 0x04) } return abi.decode(_returnData, (string)); // All that remains is the revert string } function getBalanceOf(address token) internal view returns (uint) { return token == ETH ? address(this).balance : IERC20(token).balanceOf(address(this)); } /// @notice Fetches the balances of swapToTokens. /// @dev this fetches the balances for swapToToken of swap Calls. If native eth is received, the balance has already increased so we subtract msg.value. function getInitialBalancesList(Call[] calldata calls) internal view returns (uint256[] memory) { uint callsLength = calls.length; uint256[] memory balancesList = new uint256[](callsLength); address token; for (uint256 i = 0; i < callsLength; i++) { token = calls[i].swapToToken; balancesList[i] = getBalanceOf(token); if (token == ETH) balancesList[i] -= msg.value; } return balancesList; } /// This function transfers tokens from users based on the SwapRequest, it transfers amountIn + fees. function transferTokensFromUserForSwapRequest(SwapRequest memory request) private { uint transferAmount = request.amountIn + (request.feeFromInputToken ? sumFees(request) : 0); if (request.fromToken != ETH) SafeERC20.safeTransferFrom(IERC20(request.fromToken), msg.sender, address(this), transferAmount); else require(msg.value >= transferAmount); } /// This function iterates on calls and if needsTransferFromUser, transfers tokens from user function transferTokensFromUserForCalls(Call[] calldata calls) private { uint callsLength = calls.length; Call calldata call; address token; for (uint256 i = 0; i < callsLength; i++) { call = calls[i]; token = call.swapFromToken; if (call.needsTransferFromUser && token != ETH) SafeERC20.safeTransferFrom(IERC20(call.swapFromToken), msg.sender, address(this), call.amount); } } /// @dev returns any excess token left by the contract. /// We iterate over `swapToToken`s because each swapToToken is either the request.toToken or is the output of /// another `Call` in the list of swaps which itself either has transferred tokens from user, /// or is a middle token that is the output of another `Call`. function returnExcessAmounts( SwapRequest memory request, Call[] calldata calls, uint256[] memory initialBalancesList) internal { uint excessAmountToToken; address tmpSwapToToken; uint currentBalanceTo; for (uint256 i = 0; i < calls.length; i++) { tmpSwapToToken = calls[i].swapToToken; currentBalanceTo = getBalanceOf(tmpSwapToToken); excessAmountToToken = currentBalanceTo - initialBalancesList[i]; if (excessAmountToToken > 0 && tmpSwapToToken != request.toToken) { _sendToken(tmpSwapToToken, excessAmountToToken, msg.sender); } } } function emitSwapEvent(SwapRequest memory request, uint output, address receiver) internal { emit RangoSwap( request.requestId, request.fromToken, request.toToken, request.amountIn, request.minimumAmountExpected, request.dAppTag, output, receiver, request.dAppName ); } }
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity 0.8.25; /// @title Reentrancy Guard /// @author /// @notice Abstract contract to provide protection against reentrancy abstract contract ReentrancyGuard { /// Storage /// bytes32 private constant NAMESPACE = keccak256("exchange.rango.reentrancyguard"); /// 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 } } }
{ "optimizer": { "enabled": true, "runs": 10000 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"bytes","name":"returnData","type":"bytes"}],"name":"CallResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_newAddress","type":"address"}],"name":"FeeContractAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"affiliatorAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"platformFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destinationExecutorFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"affiliateFee","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"dAppTag","type":"uint16"}],"name":"FeeInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requestId","type":"address"},{"indexed":false,"internalType":"address","name":"fromToken","type":"address"},{"indexed":false,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minimumAmountExpected","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"dAppTag","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"outputAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"string","name":"dAppName","type":"string"}],"name":"RangoSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Refunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_receiver","type":"address"}],"name":"SendToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_newAddress","type":"address"}],"name":"WethContractAddressUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"initBaseSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contractAddress","type":"address"}],"name":"isContractWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"requestId","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"platformFee","type":"uint256"},{"internalType":"uint256","name":"destinationExecutorFee","type":"uint256"},{"internalType":"uint256","name":"affiliateFee","type":"uint256"},{"internalType":"address payable","name":"affiliatorAddress","type":"address"},{"internalType":"uint256","name":"minimumAmountExpected","type":"uint256"},{"internalType":"bool","name":"feeFromInputToken","type":"bool"},{"internalType":"uint16","name":"dAppTag","type":"uint16"},{"internalType":"string","name":"dAppName","type":"string"}],"internalType":"struct LibSwapper.SwapRequest","name":"request","type":"tuple"},{"components":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"address payable","name":"target","type":"address"},{"internalType":"address","name":"swapFromToken","type":"address"},{"internalType":"address","name":"swapToToken","type":"address"},{"internalType":"bool","name":"needsTransferFromUser","type":"bool"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwapper.Call[]","name":"calls","type":"tuple[]"},{"internalType":"address","name":"receiver","type":"address"}],"name":"onChainSwaps","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"refundNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_address","type":"address"}],"name":"updateFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052348015600f57600080fd5b506126c98061001f6000396000f3fe6080604052600436106100655760003560e01c8063c057058a11610043578063c057058a146100d5578063c69bebe414610105578063eb26b3561461012557600080fd5b806314d08fca1461006a578063410085df146100935780639fae52e6146100b5575b600080fd5b61007d6100783660046120b3565b610145565b60405161008a919061226a565b60405180910390f35b34801561009f57600080fd5b506100b36100ae3660046122ec565b61026a565b005b3480156100c157600080fd5b506100b36100d0366004612318565b6103a5565b3480156100e157600080fd5b506100f56100f0366004612331565b610452565b604051901515815260200161008a565b34801561011157600080fd5b506100b3610120366004612331565b61049a565b34801561013157600080fd5b506100b361014036600461234e565b6104ae565b7f4fe94118b1030ac5f570795d403ee5116fd91b8f0b5d11f2487377c2b0ab25598054606091907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016101c4576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181556101d06104cc565b6001600160a01b03831661022b5760405162461bcd60e51b815260206004820152601d60248201527f72656365697665722063616e6e6f74206265206164647265737328302900000060448201526064015b60405180910390fd5b60008061023b888888600061053f565b9150915061024a8882876107dc565b61025b886040015182876000610852565b50915060009055949350505050565b6102726109d5565b61027a6104cc565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156102dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103009190612387565b9050828110156103525760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610222565b61035d823385610a79565b604080516001600160a01b0386168152602081018590527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d0651910160405180910390a150505050565b6103ad6109d5565b6103b56104cc565b47818110156104065760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610222565b610414600083336000610852565b6040805160008152602081018490527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d0651910160405180910390a15050565b600061045c6109d5565b506001600160a01b031660009081527f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64c602052604090205460ff1690565b6104a26109d5565b6104ab81610b93565b50565b6104b66109d5565b6104bf82610c2d565b6104c881610b93565b5050565b7f322c2f1d9209969f334c8955443b224cadc85f453939eb2b4ffb8af019944ece805460ff16156104ab5760405162461bcd60e51b815260206004820152600660248201527f50617573656400000000000000000000000000000000000000000000000000006044820152606401610222565b60606000806105518760400151610d34565b905060006105628860200151610d34565b905060006105708888610dd3565b905061057b89610ed2565b6105858888610f30565b60006105928a8a8a610fc6565b90506105a08a8a8a85611609565b60006105af8b60200151610d34565b60208c01519091506001600160a01b031615610661578381101561063b5760405162461bcd60e51b815260206004820152603d60248201527f536f7572636520746f6b656e2062616c616e6365206f6e20636f6e747261637460448201527f206d757374206e6f7420646563726561736520616674657220737761700000006064820152608401610222565b8381111561065c5760208b015161065c9061065686846123cf565b336116c8565b610730565b8761066c34866123cf565b61067691906123e2565b8110156106eb5760405162461bcd60e51b815260206004820152603d60248201527f536f7572636520746f6b656e2062616c616e6365206f6e20636f6e747261637460448201527f206d757374206e6f7420646563726561736520616674657220737761700000006064820152608401610222565b876106f634866123cf565b61070091906123e2565b8111156107305760208b015161073090898661071c34866123e2565b61072691906123cf565b61065691906123cf565b600061073f8c60400151610d34565b9050600061074d87836123cf565b90508c61010001518110156107c95760405162461bcd60e51b8152602060048201526024808201527f4f7574707574206973206c657373207468616e206d696e696d756d206578706560448201527f63746564000000000000000000000000000000000000000000000000000000006064820152608401610222565b929c929b50919950505050505050505050565b82610140015161ffff1683600001516001600160a01b03167f0e9201911743fd4d03e146f00ad23945dc8f3ffc200906eff25179a52b726f1785602001518660400151876060015188610100015188888b610160015160405161084597969594939291906123f5565b60405180910390a3505050565b604080516001600160a01b0386811682526020820186905284168183015290517f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a917fdf4363408b2d9811d1e5c23efdb5bae0b7a68bd9de2de1cbae18a11be3e67ef5919081900360600190a16001600160a01b0385161582156109ad5760018201546001600160a01b0387811691161461092f5760405162461bcd60e51b815260206004820152600e60248201527f746f6b656e206d69736d617463680000000000000000000000000000000000006044820152606401610222565b60018201546040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b15801561099057600080fd5b505af11580156109a4573d6000803e3d6000fd5b50505050600190505b80156109c2576109bd84866116ed565b6109cd565b6109cd868587610a79565b505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b03163314610a775760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201527f65720000000000000000000000000000000000000000000000000000000000006064820152608401610222565b565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052600091610aff9190861690611790565b905073a614f803b6fd780986a42c78ec9c7f77e6ded13c6001600160a01b03851614801590610b2e5750805115155b8015610b4b575080806020019051810190610b499190612448565b155b15610b8d576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610222565b50505050565b7f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a80546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117845560408051929093168083526020830191909152917f1c7cb0cdc9ba781f9745f3e24b6de0c45db97bf81b2091dfbcc45e9fdd1c1d1391015b60405180910390a1505050565b7f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64b80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093557f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a92911690610cf45760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964205745544821000000000000000000000000000000000000006044820152606401610222565b604080516001600160a01b038084168252851660208201527fcfdb33c0c0613c5035b8848040c10b9625e341ee97988ee2720de0ffbe5392d29101610c20565b60006001600160a01b03821615610dcb576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610da2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc69190612387565b610dcd565b475b92915050565b60608160008167ffffffffffffffff811115610df157610df1611ed3565b604051908082528060200260200182016040528015610e1a578160200160208202803683370190505b5090506000805b83811015610ec757868682818110610e3b57610e3b612465565b9050602002810190610e4d9190612494565b610e5e906080810190606001612331565b9150610e6982610d34565b838281518110610e7b57610e7b612465565b60209081029190910101526001600160a01b038216610ebf5734838281518110610ea757610ea7612465565b60200260200101818151610ebb91906123cf565b9052505b600101610e21565b509095945050505050565b6000816101200151610ee5576000610eee565b610eee8261179e565b8260600151610efd91906123e2565b60208301519091506001600160a01b031615610f23576104c882602001513330846117c3565b803410156104c857600080fd5b80366000805b838110156109cd57858582818110610f5057610f50612465565b9050602002810190610f629190612494565b9250610f746060840160408501612331565b9150610f8660a08401608085016124d2565b8015610f9a57506001600160a01b03821615155b15610fbe57610fbe610fb26060850160408601612331565b33308660a001356117c3565b600101610f36565b60607f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a60005b838110156112635781600201600086868481811061100c5761100c612465565b905060200281019061101e9190612494565b61102c906020810190612331565b6001600160a01b0316815260208101919091526040016000205460ff166110955760405162461bcd60e51b815260206004820181905260248201527f436f6e7472616374207370656e646572206e6f742077686974656c69737465646044820152606401610222565b8160020160008686848181106110ad576110ad612465565b90506020028101906110bf9190612494565b6110d0906040810190602001612331565b6001600160a01b0316815260208101919091526040016000205460ff166111395760405162461bcd60e51b815260206004820152601f60248201527f436f6e747261637420746172676574206e6f742077686974656c6973746564006044820152606401610222565b600085858381811061114d5761114d612465565b905060200281019061115f9190612494565b61116d9060c08101906124ef565b61117c91600491600091612554565b6111859161257e565b905082600301600087878581811061119f5761119f612465565b90506020028101906111b19190612494565b6111c2906040810190602001612331565b6001600160a01b03168152602080820192909252604090810160009081207fffffffff000000000000000000000000000000000000000000000000000000008516825290925290205460ff1661125a5760405162461bcd60e51b815260206004820152601760248201527f556e617574686f72697a65642063616c6c2064617461210000000000000000006044820152606401610222565b50600101610fec565b5061126d8561183f565b60008367ffffffffffffffff81111561128857611288611ed3565b6040519080825280602002602001820160405280156112bb57816020015b60608152602001906001900390816112a65790505b5090506000805b858110156115f3578686828181106112dc576112dc612465565b90506020028101906112ee9190612494565b6112ff906060810190604001612331565b91506001600160a01b038216156000819003611378576113788389898581811061132b5761132b612465565b905060200281019061133d9190612494565b61134b906020810190612331565b8a8a8681811061135d5761135d612465565b905060200281019061136f9190612494565b60a00135611853565b600080826114465789898581811061139257611392612465565b90506020028101906113a49190612494565b6113b5906040810190602001612331565b6001600160a01b03168a8a868181106113d0576113d0612465565b90506020028101906113e29190612494565b6113f09060c08101906124ef565b6040516113fe9291906125c6565b6000604051808303816000865af19150503d806000811461143b576040519150601f19603f3d011682016040523d82523d6000602084013e611440565b606091505b50611530565b89898581811061145857611458612465565b905060200281019061146a9190612494565b61147b906040810190602001612331565b6001600160a01b03168a8a8681811061149657611496612465565b90506020028101906114a89190612494565b60a001358b8b878181106114be576114be612465565b90506020028101906114d09190612494565b6114de9060c08101906124ef565b6040516114ec9291906125c6565b60006040518083038185875af1925050503d8060008114611529576040519150601f19603f3d011682016040523d82523d6000602084013e61152e565b606091505b505b915091507f2fc0d44e6ef6b3e7707cacd3cc326511198c3d1598c65dd54be5a9e37ce02f128a8a8681811061156757611567612465565b90506020028101906115799190612494565b61158a906040810190602001612331565b838360405161159b939291906125d6565b60405180910390a1816115ca576115b181611915565b60405162461bcd60e51b81526004016102229190612600565b808685815181106115dd576115dd612465565b60209081029190910101525050506001016112c2565b506115fd87611974565b509150505b9392505050565b60008080805b858110156116be5786868281811061162957611629612465565b905060200281019061163b9190612494565b61164c906080810190606001612331565b925061165783610d34565b915084818151811061166b5761166b612465565b60200260200101518261167e91906123cf565b93506000841180156116a6575087604001516001600160a01b0316836001600160a01b031614155b156116b6576116b68385336116c8565b60010161160f565b5050505050505050565b6001600160a01b038316156116e7576116e2838284610a79565b505050565b6116e281835b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461173a576040519150601f19603f3d011682016040523d82523d6000602084013e61173f565b606091505b50509050806116e25760405162461bcd60e51b815260206004820152601560248201527f6661696c656420746f2073656e64206e617469766500000000000000000000006044820152606401610222565b606061160283836000611987565b60008160a001518260c0015183608001516117b991906123e2565b610dcd91906123e2565b6040516001600160a01b038481166024830152838116604483015260648201839052610b8d9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611a3d565b806101200151156104ab576104ab81611ab9565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156118bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e09190612387565b905081811015610b8d57610b8d84847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611cb6565b606060448251101561195a57505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b60048201915081806020019051810190610dcd9190612613565b8061012001516104ab576104ab81611ab9565b6060814710156119c5576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610222565b600080856001600160a01b031684866040516119e19190612681565b60006040518083038185875af1925050503d8060008114611a1e576040519150601f19603f3d011682016040523d82523d6000602084013e611a23565b606091505b5091509150611a33868383611d74565b9695505050505050565b6000611a526001600160a01b03841683611790565b90508051600014158015611a77575080806020019051810190611a759190612448565b155b156116e2576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610222565b608081015160a082015160c08301516101208401517f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a93151592151591151590600090611b0a578560400151611b10565b85602001515b90508380611b1b5750825b15611ba15784546001600160a01b0316611b775760405162461bcd60e51b815260206004820152601c60248201527f46656520636f6e74726163742061646472657373206e6f7420736574000000006044820152606401610222565b611ba1818760a001518860800151611b8f91906123e2565b87546001600160a01b03166000610852565b8115611c165760e08601516001600160a01b0316611c015760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420616666696c6961746f7241646472657373000000000000006044820152606401610222565b611c16818760c001518860e001516000610852565b8380611c1f5750825b80611c275750815b156109cd5785610140015161ffff168660e001516001600160a01b03167ff14fbd8b6e3ad3ae34babfa1f3b6a099f57643662f4cfc24eb335ae8718f534b8389608001518a60a001518b60c00151604051611ca694939291906001600160a01b0394909416845260208401929092526040830152606082015260800190565b60405180910390a3505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052611d358482611de9565b610b8d576040516001600160a01b03848116602483015260006044830152611d6a91869182169063095ea7b3906064016117f8565b610b8d8482611a3d565b606082611d8957611d8482611e91565b611602565b8151158015611da057506001600160a01b0384163b155b15611de2576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610222565b5080611602565b6000806000846001600160a01b031684604051611e069190612681565b6000604051808303816000865af19150503d8060008114611e43576040519150601f19603f3d011682016040523d82523d6000602084013e611e48565b606091505b5091509150818015611e72575080511580611e72575080806020019051810190611e729190612448565b8015611e8857506000856001600160a01b03163b115b95945050505050565b805115611ea15780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610180810167ffffffffffffffff81118282101715611f2657611f26611ed3565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611f7357611f73611ed3565b604052919050565b6001600160a01b03811681146104ab57600080fd5b8035611f9b81611f7b565b919050565b80151581146104ab57600080fd5b8035611f9b81611fa0565b803561ffff81168114611f9b57600080fd5b600067ffffffffffffffff821115611fe557611fe5611ed3565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261202257600080fd5b813561203561203082611fcb565b611f2c565b81815284602083860101111561204a57600080fd5b816020850160208301376000918101602001919091529392505050565b60008083601f84011261207957600080fd5b50813567ffffffffffffffff81111561209157600080fd5b6020830191508360208260051b85010111156120ac57600080fd5b9250929050565b600080600080606085870312156120c957600080fd5b843567ffffffffffffffff808211156120e157600080fd5b9086019061018082890312156120f657600080fd5b6120fe611f02565b61210783611f90565b815261211560208401611f90565b602082015261212660408401611f90565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015261215f60e08401611f90565b60e0820152610100838101359082015261012061217d818501611fae565b9082015261014061218f848201611fb9565b9082015261016083810135838111156121a757600080fd5b6121b38b828701612011565b8284015250508096505060208701359150808211156121d157600080fd5b506121de87828801612067565b90945092506121f1905060408601611f90565b905092959194509250565b60005b838110156122175781810151838201526020016121ff565b50506000910152565b600081518084526122388160208601602086016121fc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b828110156122df577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08886030184526122cd858351612220565b94509285019290850190600101612293565b5092979650505050505050565b600080604083850312156122ff57600080fd5b823561230a81611f7b565b946020939093013593505050565b60006020828403121561232a57600080fd5b5035919050565b60006020828403121561234357600080fd5b813561160281611f7b565b6000806040838503121561236157600080fd5b823561236c81611f7b565b9150602083013561237c81611f7b565b809150509250929050565b60006020828403121561239957600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610dcd57610dcd6123a0565b80820180821115610dcd57610dcd6123a0565b60006001600160a01b03808a168352808916602084015287604084015286606084015285608084015280851660a08401525060e060c083015261243b60e0830184612220565b9998505050505050505050565b60006020828403121561245a57600080fd5b815161160281611fa0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff218336030181126124c857600080fd5b9190910192915050565b6000602082840312156124e457600080fd5b813561160281611fa0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261252457600080fd5b83018035915067ffffffffffffffff82111561253f57600080fd5b6020019150368190038213156120ac57600080fd5b6000808585111561256457600080fd5b8386111561257157600080fd5b5050820193919092039150565b7fffffffff0000000000000000000000000000000000000000000000000000000081358181169160048510156125be5780818660040360031b1b83161692505b505092915050565b8183823760009101908152919050565b6001600160a01b03841681528215156020820152606060408201526000611e886060830184612220565b6020815260006116026020830184612220565b60006020828403121561262557600080fd5b815167ffffffffffffffff81111561263c57600080fd5b8201601f8101841361264d57600080fd5b805161265b61203082611fcb565b81815285602083850101111561267057600080fd5b611e888260208301602086016121fc565b600082516124c88184602087016121fc56fea2646970667358221220a3742e0441790d24eba6cca211b2ccdd69af9a94bec6b1897fec3250a416e7b864736f6c63430008190033
Deployed Bytecode
0x6080604052600436106100655760003560e01c8063c057058a11610043578063c057058a146100d5578063c69bebe414610105578063eb26b3561461012557600080fd5b806314d08fca1461006a578063410085df146100935780639fae52e6146100b5575b600080fd5b61007d6100783660046120b3565b610145565b60405161008a919061226a565b60405180910390f35b34801561009f57600080fd5b506100b36100ae3660046122ec565b61026a565b005b3480156100c157600080fd5b506100b36100d0366004612318565b6103a5565b3480156100e157600080fd5b506100f56100f0366004612331565b610452565b604051901515815260200161008a565b34801561011157600080fd5b506100b3610120366004612331565b61049a565b34801561013157600080fd5b506100b361014036600461234e565b6104ae565b7f4fe94118b1030ac5f570795d403ee5116fd91b8f0b5d11f2487377c2b0ab25598054606091907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016101c4576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181556101d06104cc565b6001600160a01b03831661022b5760405162461bcd60e51b815260206004820152601d60248201527f72656365697665722063616e6e6f74206265206164647265737328302900000060448201526064015b60405180910390fd5b60008061023b888888600061053f565b9150915061024a8882876107dc565b61025b886040015182876000610852565b50915060009055949350505050565b6102726109d5565b61027a6104cc565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156102dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103009190612387565b9050828110156103525760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610222565b61035d823385610a79565b604080516001600160a01b0386168152602081018590527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d0651910160405180910390a150505050565b6103ad6109d5565b6103b56104cc565b47818110156104065760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610222565b610414600083336000610852565b6040805160008152602081018490527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d0651910160405180910390a15050565b600061045c6109d5565b506001600160a01b031660009081527f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64c602052604090205460ff1690565b6104a26109d5565b6104ab81610b93565b50565b6104b66109d5565b6104bf82610c2d565b6104c881610b93565b5050565b7f322c2f1d9209969f334c8955443b224cadc85f453939eb2b4ffb8af019944ece805460ff16156104ab5760405162461bcd60e51b815260206004820152600660248201527f50617573656400000000000000000000000000000000000000000000000000006044820152606401610222565b60606000806105518760400151610d34565b905060006105628860200151610d34565b905060006105708888610dd3565b905061057b89610ed2565b6105858888610f30565b60006105928a8a8a610fc6565b90506105a08a8a8a85611609565b60006105af8b60200151610d34565b60208c01519091506001600160a01b031615610661578381101561063b5760405162461bcd60e51b815260206004820152603d60248201527f536f7572636520746f6b656e2062616c616e6365206f6e20636f6e747261637460448201527f206d757374206e6f7420646563726561736520616674657220737761700000006064820152608401610222565b8381111561065c5760208b015161065c9061065686846123cf565b336116c8565b610730565b8761066c34866123cf565b61067691906123e2565b8110156106eb5760405162461bcd60e51b815260206004820152603d60248201527f536f7572636520746f6b656e2062616c616e6365206f6e20636f6e747261637460448201527f206d757374206e6f7420646563726561736520616674657220737761700000006064820152608401610222565b876106f634866123cf565b61070091906123e2565b8111156107305760208b015161073090898661071c34866123e2565b61072691906123cf565b61065691906123cf565b600061073f8c60400151610d34565b9050600061074d87836123cf565b90508c61010001518110156107c95760405162461bcd60e51b8152602060048201526024808201527f4f7574707574206973206c657373207468616e206d696e696d756d206578706560448201527f63746564000000000000000000000000000000000000000000000000000000006064820152608401610222565b929c929b50919950505050505050505050565b82610140015161ffff1683600001516001600160a01b03167f0e9201911743fd4d03e146f00ad23945dc8f3ffc200906eff25179a52b726f1785602001518660400151876060015188610100015188888b610160015160405161084597969594939291906123f5565b60405180910390a3505050565b604080516001600160a01b0386811682526020820186905284168183015290517f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a917fdf4363408b2d9811d1e5c23efdb5bae0b7a68bd9de2de1cbae18a11be3e67ef5919081900360600190a16001600160a01b0385161582156109ad5760018201546001600160a01b0387811691161461092f5760405162461bcd60e51b815260206004820152600e60248201527f746f6b656e206d69736d617463680000000000000000000000000000000000006044820152606401610222565b60018201546040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b15801561099057600080fd5b505af11580156109a4573d6000803e3d6000fd5b50505050600190505b80156109c2576109bd84866116ed565b6109cd565b6109cd868587610a79565b505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b03163314610a775760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201527f65720000000000000000000000000000000000000000000000000000000000006064820152608401610222565b565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052600091610aff9190861690611790565b905073a614f803b6fd780986a42c78ec9c7f77e6ded13c6001600160a01b03851614801590610b2e5750805115155b8015610b4b575080806020019051810190610b499190612448565b155b15610b8d576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610222565b50505050565b7f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a80546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117845560408051929093168083526020830191909152917f1c7cb0cdc9ba781f9745f3e24b6de0c45db97bf81b2091dfbcc45e9fdd1c1d1391015b60405180910390a1505050565b7f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64b80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093557f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a92911690610cf45760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964205745544821000000000000000000000000000000000000006044820152606401610222565b604080516001600160a01b038084168252851660208201527fcfdb33c0c0613c5035b8848040c10b9625e341ee97988ee2720de0ffbe5392d29101610c20565b60006001600160a01b03821615610dcb576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610da2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc69190612387565b610dcd565b475b92915050565b60608160008167ffffffffffffffff811115610df157610df1611ed3565b604051908082528060200260200182016040528015610e1a578160200160208202803683370190505b5090506000805b83811015610ec757868682818110610e3b57610e3b612465565b9050602002810190610e4d9190612494565b610e5e906080810190606001612331565b9150610e6982610d34565b838281518110610e7b57610e7b612465565b60209081029190910101526001600160a01b038216610ebf5734838281518110610ea757610ea7612465565b60200260200101818151610ebb91906123cf565b9052505b600101610e21565b509095945050505050565b6000816101200151610ee5576000610eee565b610eee8261179e565b8260600151610efd91906123e2565b60208301519091506001600160a01b031615610f23576104c882602001513330846117c3565b803410156104c857600080fd5b80366000805b838110156109cd57858582818110610f5057610f50612465565b9050602002810190610f629190612494565b9250610f746060840160408501612331565b9150610f8660a08401608085016124d2565b8015610f9a57506001600160a01b03821615155b15610fbe57610fbe610fb26060850160408601612331565b33308660a001356117c3565b600101610f36565b60607f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a60005b838110156112635781600201600086868481811061100c5761100c612465565b905060200281019061101e9190612494565b61102c906020810190612331565b6001600160a01b0316815260208101919091526040016000205460ff166110955760405162461bcd60e51b815260206004820181905260248201527f436f6e7472616374207370656e646572206e6f742077686974656c69737465646044820152606401610222565b8160020160008686848181106110ad576110ad612465565b90506020028101906110bf9190612494565b6110d0906040810190602001612331565b6001600160a01b0316815260208101919091526040016000205460ff166111395760405162461bcd60e51b815260206004820152601f60248201527f436f6e747261637420746172676574206e6f742077686974656c6973746564006044820152606401610222565b600085858381811061114d5761114d612465565b905060200281019061115f9190612494565b61116d9060c08101906124ef565b61117c91600491600091612554565b6111859161257e565b905082600301600087878581811061119f5761119f612465565b90506020028101906111b19190612494565b6111c2906040810190602001612331565b6001600160a01b03168152602080820192909252604090810160009081207fffffffff000000000000000000000000000000000000000000000000000000008516825290925290205460ff1661125a5760405162461bcd60e51b815260206004820152601760248201527f556e617574686f72697a65642063616c6c2064617461210000000000000000006044820152606401610222565b50600101610fec565b5061126d8561183f565b60008367ffffffffffffffff81111561128857611288611ed3565b6040519080825280602002602001820160405280156112bb57816020015b60608152602001906001900390816112a65790505b5090506000805b858110156115f3578686828181106112dc576112dc612465565b90506020028101906112ee9190612494565b6112ff906060810190604001612331565b91506001600160a01b038216156000819003611378576113788389898581811061132b5761132b612465565b905060200281019061133d9190612494565b61134b906020810190612331565b8a8a8681811061135d5761135d612465565b905060200281019061136f9190612494565b60a00135611853565b600080826114465789898581811061139257611392612465565b90506020028101906113a49190612494565b6113b5906040810190602001612331565b6001600160a01b03168a8a868181106113d0576113d0612465565b90506020028101906113e29190612494565b6113f09060c08101906124ef565b6040516113fe9291906125c6565b6000604051808303816000865af19150503d806000811461143b576040519150601f19603f3d011682016040523d82523d6000602084013e611440565b606091505b50611530565b89898581811061145857611458612465565b905060200281019061146a9190612494565b61147b906040810190602001612331565b6001600160a01b03168a8a8681811061149657611496612465565b90506020028101906114a89190612494565b60a001358b8b878181106114be576114be612465565b90506020028101906114d09190612494565b6114de9060c08101906124ef565b6040516114ec9291906125c6565b60006040518083038185875af1925050503d8060008114611529576040519150601f19603f3d011682016040523d82523d6000602084013e61152e565b606091505b505b915091507f2fc0d44e6ef6b3e7707cacd3cc326511198c3d1598c65dd54be5a9e37ce02f128a8a8681811061156757611567612465565b90506020028101906115799190612494565b61158a906040810190602001612331565b838360405161159b939291906125d6565b60405180910390a1816115ca576115b181611915565b60405162461bcd60e51b81526004016102229190612600565b808685815181106115dd576115dd612465565b60209081029190910101525050506001016112c2565b506115fd87611974565b509150505b9392505050565b60008080805b858110156116be5786868281811061162957611629612465565b905060200281019061163b9190612494565b61164c906080810190606001612331565b925061165783610d34565b915084818151811061166b5761166b612465565b60200260200101518261167e91906123cf565b93506000841180156116a6575087604001516001600160a01b0316836001600160a01b031614155b156116b6576116b68385336116c8565b60010161160f565b5050505050505050565b6001600160a01b038316156116e7576116e2838284610a79565b505050565b6116e281835b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461173a576040519150601f19603f3d011682016040523d82523d6000602084013e61173f565b606091505b50509050806116e25760405162461bcd60e51b815260206004820152601560248201527f6661696c656420746f2073656e64206e617469766500000000000000000000006044820152606401610222565b606061160283836000611987565b60008160a001518260c0015183608001516117b991906123e2565b610dcd91906123e2565b6040516001600160a01b038481166024830152838116604483015260648201839052610b8d9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611a3d565b806101200151156104ab576104ab81611ab9565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156118bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e09190612387565b905081811015610b8d57610b8d84847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611cb6565b606060448251101561195a57505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b60048201915081806020019051810190610dcd9190612613565b8061012001516104ab576104ab81611ab9565b6060814710156119c5576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610222565b600080856001600160a01b031684866040516119e19190612681565b60006040518083038185875af1925050503d8060008114611a1e576040519150601f19603f3d011682016040523d82523d6000602084013e611a23565b606091505b5091509150611a33868383611d74565b9695505050505050565b6000611a526001600160a01b03841683611790565b90508051600014158015611a77575080806020019051810190611a759190612448565b155b156116e2576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610222565b608081015160a082015160c08301516101208401517f43da06808a8e54e76a41d6f7b48ddfb23969b1387a8710ef6241423a5aefe64a93151592151591151590600090611b0a578560400151611b10565b85602001515b90508380611b1b5750825b15611ba15784546001600160a01b0316611b775760405162461bcd60e51b815260206004820152601c60248201527f46656520636f6e74726163742061646472657373206e6f7420736574000000006044820152606401610222565b611ba1818760a001518860800151611b8f91906123e2565b87546001600160a01b03166000610852565b8115611c165760e08601516001600160a01b0316611c015760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420616666696c6961746f7241646472657373000000000000006044820152606401610222565b611c16818760c001518860e001516000610852565b8380611c1f5750825b80611c275750815b156109cd5785610140015161ffff168660e001516001600160a01b03167ff14fbd8b6e3ad3ae34babfa1f3b6a099f57643662f4cfc24eb335ae8718f534b8389608001518a60a001518b60c00151604051611ca694939291906001600160a01b0394909416845260208401929092526040830152606082015260800190565b60405180910390a3505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052611d358482611de9565b610b8d576040516001600160a01b03848116602483015260006044830152611d6a91869182169063095ea7b3906064016117f8565b610b8d8482611a3d565b606082611d8957611d8482611e91565b611602565b8151158015611da057506001600160a01b0384163b155b15611de2576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610222565b5080611602565b6000806000846001600160a01b031684604051611e069190612681565b6000604051808303816000865af19150503d8060008114611e43576040519150601f19603f3d011682016040523d82523d6000602084013e611e48565b606091505b5091509150818015611e72575080511580611e72575080806020019051810190611e729190612448565b8015611e8857506000856001600160a01b03163b115b95945050505050565b805115611ea15780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610180810167ffffffffffffffff81118282101715611f2657611f26611ed3565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611f7357611f73611ed3565b604052919050565b6001600160a01b03811681146104ab57600080fd5b8035611f9b81611f7b565b919050565b80151581146104ab57600080fd5b8035611f9b81611fa0565b803561ffff81168114611f9b57600080fd5b600067ffffffffffffffff821115611fe557611fe5611ed3565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261202257600080fd5b813561203561203082611fcb565b611f2c565b81815284602083860101111561204a57600080fd5b816020850160208301376000918101602001919091529392505050565b60008083601f84011261207957600080fd5b50813567ffffffffffffffff81111561209157600080fd5b6020830191508360208260051b85010111156120ac57600080fd5b9250929050565b600080600080606085870312156120c957600080fd5b843567ffffffffffffffff808211156120e157600080fd5b9086019061018082890312156120f657600080fd5b6120fe611f02565b61210783611f90565b815261211560208401611f90565b602082015261212660408401611f90565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015261215f60e08401611f90565b60e0820152610100838101359082015261012061217d818501611fae565b9082015261014061218f848201611fb9565b9082015261016083810135838111156121a757600080fd5b6121b38b828701612011565b8284015250508096505060208701359150808211156121d157600080fd5b506121de87828801612067565b90945092506121f1905060408601611f90565b905092959194509250565b60005b838110156122175781810151838201526020016121ff565b50506000910152565b600081518084526122388160208601602086016121fc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b828110156122df577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08886030184526122cd858351612220565b94509285019290850190600101612293565b5092979650505050505050565b600080604083850312156122ff57600080fd5b823561230a81611f7b565b946020939093013593505050565b60006020828403121561232a57600080fd5b5035919050565b60006020828403121561234357600080fd5b813561160281611f7b565b6000806040838503121561236157600080fd5b823561236c81611f7b565b9150602083013561237c81611f7b565b809150509250929050565b60006020828403121561239957600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610dcd57610dcd6123a0565b80820180821115610dcd57610dcd6123a0565b60006001600160a01b03808a168352808916602084015287604084015286606084015285608084015280851660a08401525060e060c083015261243b60e0830184612220565b9998505050505050505050565b60006020828403121561245a57600080fd5b815161160281611fa0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff218336030181126124c857600080fd5b9190910192915050565b6000602082840312156124e457600080fd5b813561160281611fa0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261252457600080fd5b83018035915067ffffffffffffffff82111561253f57600080fd5b6020019150368190038213156120ac57600080fd5b6000808585111561256457600080fd5b8386111561257157600080fd5b5050820193919092039150565b7fffffffff0000000000000000000000000000000000000000000000000000000081358181169160048510156125be5780818660040360031b1b83161692505b505092915050565b8183823760009101908152919050565b6001600160a01b03841681528215156020820152606060408201526000611e886060830184612220565b6020815260006116026020830184612220565b60006020828403121561262557600080fd5b815167ffffffffffffffff81111561263c57600080fd5b8201601f8101841361264d57600080fd5b805161265b61203082611fcb565b81815285602083850101111561267057600080fd5b611e888260208301602086016121fc565b600082516124c88184602087016121fc56fea2646970667358221220a3742e0441790d24eba6cca211b2ccdd69af9a94bec6b1897fec3250a416e7b864736f6c63430008190033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.