Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 16905679 | 17 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x3332b646...9224bce64 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
GlacisFacet
Compiler Version
v0.8.29+commit.ab55807c
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
import { ILiFi } from "../Interfaces/ILiFi.sol";
import { LibAsset, IERC20 } from "../Libraries/LibAsset.sol";
import { LibSwap } from "../Libraries/LibSwap.sol";
import { ReentrancyGuard } from "../Helpers/ReentrancyGuard.sol";
import { SwapperV2 } from "../Helpers/SwapperV2.sol";
import { Validatable } from "../Helpers/Validatable.sol";
import { LiFiData } from "../Helpers/LiFiData.sol";
import { IGlacisAirlift } from "../Interfaces/IGlacisAirlift.sol";
import { InvalidConfig, InvalidCallData, InvalidNonEVMReceiver, InvalidReceiver } from "../Errors/GenericErrors.sol";
/// @title GlacisFacet
/// @author LI.FI (https://li.fi/)
/// @notice Integration of the Glacis airlift (wrapper for native token bridging standards)
/// @custom:version 1.2.0
contract GlacisFacet is
ILiFi,
ReentrancyGuard,
SwapperV2,
Validatable,
LiFiData
{
/// Storage ///
/// @notice The contract address of the glacis airlift on the source chain.
IGlacisAirlift public immutable AIRLIFT;
/// Types ///
/// @param receiverAddress The address that would receive the tokens on the destination chain
/// @param refundAddress The address that would receive potential refunds on source chain
/// @param nativeFee The fee amount in native token required by the Glacis Airlift
/// @param outputToken The address of the token to receive on the destination chain (use bytes32(0) for default routing)
struct GlacisData {
bytes32 receiverAddress;
address refundAddress;
uint256 nativeFee;
bytes32 outputToken;
}
/// Constructor ///
/// @notice Initializes the GlacisFacet contract
/// @param _airlift The address of Glacis Airlift contract.
constructor(IGlacisAirlift _airlift) {
if (address(_airlift) == address(0)) {
revert InvalidConfig();
}
AIRLIFT = _airlift;
}
/// Errors ///
/// External Methods ///
/// @notice Bridges tokens via Glacis
/// @param _bridgeData The core information needed for bridging
/// @param _glacisData Data specific to Glacis
function startBridgeTokensViaGlacis(
ILiFi.BridgeData memory _bridgeData,
GlacisData calldata _glacisData
)
external
payable
nonReentrant
refundExcessNative(payable(msg.sender))
validateBridgeData(_bridgeData)
doesNotContainSourceSwaps(_bridgeData)
doesNotContainDestinationCalls(_bridgeData)
noNativeAsset(_bridgeData)
{
LibAsset.depositAsset(
_bridgeData.sendingAssetId,
_bridgeData.minAmount
);
_startBridge(_bridgeData, _glacisData);
}
/// @notice Performs a swap before bridging via Glacis
/// @param _bridgeData The core information needed for bridging
/// @param _swapData An array of swap related data for performing swaps before bridging
/// @param _glacisData Data specific to Glacis
function swapAndStartBridgeTokensViaGlacis(
ILiFi.BridgeData memory _bridgeData,
LibSwap.SwapData[] calldata _swapData,
GlacisData calldata _glacisData
)
external
payable
nonReentrant
refundExcessNative(payable(msg.sender))
containsSourceSwaps(_bridgeData)
doesNotContainDestinationCalls(_bridgeData)
validateBridgeData(_bridgeData)
noNativeAsset(_bridgeData)
{
_bridgeData.minAmount = _depositAndSwap(
_bridgeData.transactionId,
_bridgeData.minAmount,
_swapData,
payable(msg.sender),
_glacisData.nativeFee
);
_startBridge(_bridgeData, _glacisData);
}
/// Internal Methods ///
/// @dev Contains the business logic for the bridge via Glacis
/// @param _bridgeData The core information needed for bridging
/// @param _glacisData Data specific to Glacis
function _startBridge(
ILiFi.BridgeData memory _bridgeData,
GlacisData calldata _glacisData
) internal {
// Validate receiver address based on destination chain type
if (_bridgeData.receiver == NON_EVM_ADDRESS) {
// destination chain is non-EVM
// make sure it's non-zero (we cannot validate further)
if (_glacisData.receiverAddress == bytes32(0)) {
revert InvalidNonEVMReceiver();
}
// Emit event for non-EVM chains
emit BridgeToNonEVMChainBytes32(
_bridgeData.transactionId,
_bridgeData.destinationChainId,
_glacisData.receiverAddress
);
} else {
// destination chain is EVM
// make sure that bridgeData and glacisData receiver addresses match
if (
_bridgeData.receiver !=
address(uint160(uint256(_glacisData.receiverAddress)))
) {
revert InvalidReceiver();
}
}
if (_glacisData.refundAddress == address(0)) {
revert InvalidCallData();
}
// Approve the Airlift contract to spend the required amount of tokens.
// The `send` function assumes that the caller has already approved the token transfer,
// ensuring that the cross-chain transaction and token transfer happen atomically.
LibAsset.maxApproveERC20(
IERC20(_bridgeData.sendingAssetId),
address(AIRLIFT),
_bridgeData.minAmount
);
// Call the 6-parameter send() with outputToken parameter
// When outputToken is bytes32(0), Glacis uses default routing (backwards compatible)
// When outputToken is specified, enables multibridge routing for tokens like USDT & LBTC
// solhint-disable-next-line check-send-result
AIRLIFT.send{ value: _glacisData.nativeFee }(
_bridgeData.sendingAssetId,
_bridgeData.minAmount,
_glacisData.receiverAddress,
_bridgeData.destinationChainId,
_glacisData.refundAddress,
_glacisData.outputToken
);
emit LiFiTransferStarted(_bridgeData);
}
}// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
/// @title ILiFi
/// @author LI.FI (https://li.fi)
/// @custom:version 1.0.1
interface ILiFi {
/// Structs ///
struct BridgeData {
bytes32 transactionId;
string bridge;
string integrator;
address referrer;
address sendingAssetId;
address receiver;
uint256 minAmount;
uint256 destinationChainId;
bool hasSourceSwaps;
bool hasDestinationCall;
}
/// Events ///
event LiFiTransferStarted(ILiFi.BridgeData bridgeData);
event LiFiTransferCompleted(
bytes32 indexed transactionId,
address receivingAssetId,
address receiver,
uint256 amount,
uint256 timestamp
);
event LiFiTransferRecovered(
bytes32 indexed transactionId,
address receivingAssetId,
address receiver,
uint256 amount,
uint256 timestamp
);
event LiFiGenericSwapCompleted(
bytes32 indexed transactionId,
string integrator,
string referrer,
address receiver,
address fromAssetId,
address toAssetId,
uint256 fromAmount,
uint256 toAmount
);
// this event is emitted when a bridge transction is initiated to a non-EVM chain
event BridgeToNonEVMChain(
bytes32 indexed transactionId,
uint256 indexed destinationChainId,
bytes receiver
);
event BridgeToNonEVMChainBytes32(
bytes32 indexed transactionId,
uint256 indexed destinationChainId,
bytes32 receiver
);
// Deprecated but kept here to include in ABI to parse historic events
event LiFiSwappedGeneric(
bytes32 indexed transactionId,
string integrator,
string referrer,
address fromAssetId,
address toAssetId,
uint256 fromAmount,
uint256 toAmount
);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { LibSwap } from "./LibSwap.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
// solhint-disable-next-line max-line-length
import { InvalidReceiver, NullAddrIsNotAValidSpender, InvalidAmount, NullAddrIsNotAnERC20Token } from "../Errors/GenericErrors.sol";
/// @title LibAsset
/// @author LI.FI (https://li.fi)
/// @custom:version 2.1.3
/// @notice This library contains helpers for dealing with onchain transfers
/// of assets, including accounting for the native asset `assetId`
/// conventions and any noncompliant ERC20 transfers
library LibAsset {
using SafeTransferLib for address;
using SafeTransferLib for address payable;
/// @dev All native assets use the empty address for their asset id
/// by convention
address internal constant NULL_ADDRESS = address(0);
/// @dev EIP-7702 delegation designator prefix for Account Abstraction
bytes3 internal constant DELEGATION_DESIGNATOR = 0xef0100;
/// @notice Gets the balance of the inheriting contract for the given asset
/// @param assetId The asset identifier to get the balance of
/// @return Balance held by contracts using this library (returns 0 if assetId does not exist)
function getOwnBalance(address assetId) internal view returns (uint256) {
return
isNativeAsset(assetId)
? address(this).balance
: assetId.balanceOf(address(this));
}
/// @notice Wrapper function to transfer a given asset (native or erc20) to
/// some recipient. Should handle all non-compliant return value
/// tokens as well by using the SafeERC20 contract by open zeppelin.
/// @param assetId Asset id for transfer (address(0) for native asset,
/// token address for erc20s)
/// @param recipient Address to send asset to
/// @param amount Amount to send to given recipient
function transferAsset(
address assetId,
address payable recipient,
uint256 amount
) internal {
if (isNativeAsset(assetId)) {
transferNativeAsset(recipient, amount);
} else {
transferERC20(assetId, recipient, amount);
}
}
/// @notice Transfers ether from the inheriting contract to a given
/// recipient
/// @param recipient Address to send ether to
/// @param amount Amount to send to given recipient
function transferNativeAsset(
address payable recipient,
uint256 amount
) internal {
// make sure a meaningful receiver address was provided
if (recipient == NULL_ADDRESS) revert InvalidReceiver();
// transfer native asset (will revert if target reverts or contract has insufficient balance)
recipient.safeTransferETH(amount);
}
/// @notice Transfers tokens from the inheriting contract to a given recipient
/// @param assetId Token address to transfer
/// @param recipient Address to send tokens to
/// @param amount Amount to send to given recipient
function transferERC20(
address assetId,
address recipient,
uint256 amount
) internal {
// make sure a meaningful receiver address was provided
if (recipient == NULL_ADDRESS) {
revert InvalidReceiver();
}
// transfer ERC20 assets (will revert if target reverts or contract has insufficient balance)
assetId.safeTransfer(recipient, amount);
}
/// @notice Transfers tokens from a sender to a given recipient
/// @param assetId Token address to transfer
/// @param from Address of sender/owner
/// @param recipient Address of recipient/spender
/// @param amount Amount to transfer from owner to spender
function transferFromERC20(
address assetId,
address from,
address recipient,
uint256 amount
) internal {
// check if native asset
if (isNativeAsset(assetId)) {
revert NullAddrIsNotAnERC20Token();
}
// make sure a meaningful receiver address was provided
if (recipient == NULL_ADDRESS) {
revert InvalidReceiver();
}
// transfer ERC20 assets (will revert if target reverts or contract has insufficient balance)
assetId.safeTransferFrom(from, recipient, amount);
}
/// @notice Pulls tokens from msg.sender
/// @param assetId Token address to transfer
/// @param amount Amount to transfer from owner
function depositAsset(address assetId, uint256 amount) internal {
// make sure a meaningful amount was provided
if (amount == 0) revert InvalidAmount();
// check if native asset
if (isNativeAsset(assetId)) {
// ensure msg.value is equal or greater than amount
if (msg.value < amount) revert InvalidAmount();
} else {
// transfer ERC20 assets (will revert if target reverts or contract has insufficient balance)
assetId.safeTransferFrom(msg.sender, address(this), amount);
}
}
function depositAssets(LibSwap.SwapData[] calldata swaps) internal {
for (uint256 i = 0; i < swaps.length; ) {
LibSwap.SwapData calldata swap = swaps[i];
if (swap.requiresDeposit) {
depositAsset(swap.sendingAssetId, swap.fromAmount);
}
unchecked {
i++;
}
}
}
/// @notice If the current allowance is insufficient, the allowance for a given spender
/// is set to MAX_UINT.
/// @param assetId Token address to transfer
/// @param spender Address to give spend approval to
/// @param amount allowance amount required for current transaction
function maxApproveERC20(
IERC20 assetId,
address spender,
uint256 amount
) internal {
approveERC20(assetId, spender, amount, type(uint256).max);
}
/// @notice If the current allowance is insufficient, the allowance for a given spender
/// is set to the amount provided
/// @param assetId Token address to transfer
/// @param spender Address to give spend approval to
/// @param requiredAllowance Allowance required for current transaction
/// @param setAllowanceTo The amount the allowance should be set to if current allowance is insufficient
function approveERC20(
IERC20 assetId,
address spender,
uint256 requiredAllowance,
uint256 setAllowanceTo
) internal {
if (isNativeAsset(address(assetId))) {
return;
}
// make sure a meaningful spender address was provided
if (spender == NULL_ADDRESS) {
revert NullAddrIsNotAValidSpender();
}
// check if allowance is sufficient, otherwise set allowance to provided amount
// If the initial attempt to approve fails, attempts to reset the approved amount to zero,
// then retries the approval again (some tokens, e.g. USDT, requires this).
// Reverts upon failure
if (assetId.allowance(address(this), spender) < requiredAllowance) {
address(assetId).safeApproveWithRetry(spender, setAllowanceTo);
}
}
/// @notice Determines whether the given assetId is the native asset
/// @param assetId The asset identifier to evaluate
/// @return Boolean indicating if the asset is the native asset
function isNativeAsset(address assetId) internal pure returns (bool) {
return assetId == NULL_ADDRESS;
}
/// @notice Checks if the given address is a contract
/// Returns true for any account with runtime code (excluding EIP-7702 accounts).
/// For EIP-7702 accounts, checks if code size is exactly 23 bytes (delegation format).
/// Limitations:
/// - Cannot distinguish between EOA and self-destructed contract
/// @param account The address to be checked
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
// Return true only for regular contracts (size > 23)
// EIP-7702 delegated accounts (size == 23) are still EOAs, not contracts
return size > 23;
}
}// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
import { LibAsset } from "./LibAsset.sol";
import { LibUtil } from "./LibUtil.sol";
import { InvalidContract, NoSwapFromZeroBalance } from "../Errors/GenericErrors.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// @title LibSwap
/// @custom:version 1.1.0
/// @notice This library contains functionality to execute mostly swaps but also
/// other calls such as fee collection, token wrapping/unwrapping or
/// sending gas to destination chain
library LibSwap {
/// @notice Struct containing all necessary data to execute a swap or generic call
/// @param callTo The address of the contract to call for executing the swap
/// @param approveTo The address that will receive token approval (can be different than callTo for some DEXs)
/// @param sendingAssetId The address of the token being sent
/// @param receivingAssetId The address of the token expected to be received
/// @param fromAmount The exact amount of the sending asset to be used in the call
/// @param callData Encoded function call data to be sent to the `callTo` contract
/// @param requiresDeposit A flag indicating whether the tokens must be deposited (pulled) before the call
struct SwapData {
address callTo;
address approveTo;
address sendingAssetId;
address receivingAssetId;
uint256 fromAmount;
bytes callData;
bool requiresDeposit;
}
/// @notice Emitted after a successful asset swap or related operation
/// @param transactionId The unique identifier associated with the swap operation
/// @param dex The address of the DEX or contract that handled the swap
/// @param fromAssetId The address of the token that was sent
/// @param toAssetId The address of the token that was received
/// @param fromAmount The amount of `fromAssetId` sent
/// @param toAmount The amount of `toAssetId` received
/// @param timestamp The timestamp when the swap was executed
event AssetSwapped(
bytes32 transactionId,
address dex,
address fromAssetId,
address toAssetId,
uint256 fromAmount,
uint256 toAmount,
uint256 timestamp
);
function swap(bytes32 transactionId, SwapData calldata _swap) internal {
// make sure callTo is a contract
if (!LibAsset.isContract(_swap.callTo)) revert InvalidContract();
// make sure that fromAmount is not 0
uint256 fromAmount = _swap.fromAmount;
if (fromAmount == 0) revert NoSwapFromZeroBalance();
// determine how much native value to send with the swap call
uint256 nativeValue = LibAsset.isNativeAsset(_swap.sendingAssetId)
? _swap.fromAmount
: 0;
// store initial balance (required for event emission)
uint256 initialReceivingAssetBalance = LibAsset.getOwnBalance(
_swap.receivingAssetId
);
// max approve (if ERC20)
if (nativeValue == 0) {
LibAsset.maxApproveERC20(
IERC20(_swap.sendingAssetId),
_swap.approveTo,
_swap.fromAmount
);
}
// we used to have a sending asset balance check here (initialSendingAssetBalance >= _swap.fromAmount)
// this check was removed to allow for more flexibility with rebasing/fee-taking tokens
// the general assumption is that if not enough tokens are available to execute the calldata,
// the transaction will fail anyway
// the error message might not be as explicit though
// execute the swap
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory res) = _swap.callTo.call{
value: nativeValue
}(_swap.callData);
if (!success) {
LibUtil.revertWith(res);
}
// get post-swap balance
uint256 newBalance = LibAsset.getOwnBalance(_swap.receivingAssetId);
// emit event
emit AssetSwapped(
transactionId,
_swap.callTo,
_swap.sendingAssetId,
_swap.receivingAssetId,
_swap.fromAmount,
newBalance > initialReceivingAssetBalance
? newBalance - initialReceivingAssetBalance
: newBalance,
block.timestamp
);
}
}// SPDX-License-Identifier: UNLICENSED
/// @custom:version 1.0.0
pragma solidity ^0.8.17;
/// @title Reentrancy Guard
/// @author LI.FI (https://li.fi)
/// @notice Abstract contract to provide protection against reentrancy
abstract contract ReentrancyGuard {
/// Storage ///
bytes32 private constant NAMESPACE = keccak256("com.lifi.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
}
}
}// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
import { ILiFi } from "../Interfaces/ILiFi.sol";
import { LibSwap } from "../Libraries/LibSwap.sol";
import { LibAsset } from "../Libraries/LibAsset.sol";
import { LibAllowList } from "../Libraries/LibAllowList.sol";
import { ContractCallNotAllowed, NoSwapDataProvided, CumulativeSlippageTooHigh } from "../Errors/GenericErrors.sol";
/// @title SwapperV2
/// @author LI.FI (https://li.fi)
/// @notice Abstract contract to provide swap functionality with leftover token handling
/// @custom:version 1.1.0
contract SwapperV2 is ILiFi {
/// Types ///
/// @dev only used to get around "Stack Too Deep" errors
struct ReserveData {
bytes32 transactionId;
address payable leftoverReceiver;
uint256 nativeReserve;
}
/// Modifiers ///
/// @dev Sends any leftover balances back to the user
/// @notice Sends any leftover balances to the user
/// @param _swaps Swap data array
/// @param _leftoverReceiver Address to send leftover tokens to
/// @param _initialBalances Array of initial token balances
modifier noLeftovers(
LibSwap.SwapData[] calldata _swaps,
address payable _leftoverReceiver,
uint256[] memory _initialBalances
) {
_;
_refundLeftovers(_swaps, _leftoverReceiver, _initialBalances, 0);
}
/// @dev Sends any leftover balances back to the user reserving native tokens
/// @notice Sends any leftover balances to the user
/// @param _swaps Swap data array
/// @param _leftoverReceiver Address to send leftover tokens to
/// @param _initialBalances Array of initial token balances
/// @param _nativeReserve Amount of native token to prevent from being swept
modifier noLeftoversReserve(
LibSwap.SwapData[] calldata _swaps,
address payable _leftoverReceiver,
uint256[] memory _initialBalances,
uint256 _nativeReserve
) {
_;
_refundLeftovers(
_swaps,
_leftoverReceiver,
_initialBalances,
_nativeReserve
);
}
/// @dev Refunds any excess native asset sent to the contract after the main function
/// @notice Refunds any excess native asset sent to the contract after the main function
/// @param _refundReceiver Address to send refunds to
modifier refundExcessNative(address payable _refundReceiver) {
uint256 initialBalance = address(this).balance - msg.value;
_;
uint256 finalBalance = address(this).balance;
if (finalBalance > initialBalance) {
LibAsset.transferAsset(
LibAsset.NULL_ADDRESS,
_refundReceiver,
finalBalance - initialBalance
);
}
}
/// Internal Methods ///
/// @dev Deposits value, executes swaps, and performs minimum amount check
/// @param _transactionId the transaction id associated with the operation
/// @param _minAmount the minimum amount of the final asset to receive
/// @param _swaps Array of data used to execute swaps
/// @param _leftoverReceiver The address to send leftover funds to
/// @return uint256 result of the swap
function _depositAndSwap(
bytes32 _transactionId,
uint256 _minAmount,
LibSwap.SwapData[] calldata _swaps,
address payable _leftoverReceiver
) internal returns (uint256) {
uint256 numSwaps = _swaps.length;
if (numSwaps == 0) {
revert NoSwapDataProvided();
}
address finalTokenId = _swaps[numSwaps - 1].receivingAssetId;
uint256 initialBalance = LibAsset.getOwnBalance(finalTokenId);
if (LibAsset.isNativeAsset(finalTokenId)) {
initialBalance -= msg.value;
}
uint256[] memory initialBalances = _fetchBalances(_swaps);
LibAsset.depositAssets(_swaps);
_executeSwaps(
_transactionId,
_swaps,
_leftoverReceiver,
initialBalances
);
uint256 newBalance = LibAsset.getOwnBalance(finalTokenId) -
initialBalance;
if (newBalance < _minAmount) {
revert CumulativeSlippageTooHigh(_minAmount, newBalance);
}
return newBalance;
}
/// @dev Deposits value, executes swaps, and performs minimum amount check and reserves native token for fees
/// @param _transactionId the transaction id associated with the operation
/// @param _minAmount the minimum amount of the final asset to receive
/// @param _swaps Array of data used to execute swaps
/// @param _leftoverReceiver The address to send leftover funds to
/// @param _nativeReserve Amount of native token to prevent from being swept back to the caller
function _depositAndSwap(
bytes32 _transactionId,
uint256 _minAmount,
LibSwap.SwapData[] calldata _swaps,
address payable _leftoverReceiver,
uint256 _nativeReserve
) internal returns (uint256) {
uint256 numSwaps = _swaps.length;
if (numSwaps == 0) {
revert NoSwapDataProvided();
}
address finalTokenId = _swaps[numSwaps - 1].receivingAssetId;
uint256 initialBalance = LibAsset.getOwnBalance(finalTokenId);
if (LibAsset.isNativeAsset(finalTokenId)) {
initialBalance -= msg.value;
}
uint256[] memory initialBalances = _fetchBalances(_swaps);
LibAsset.depositAssets(_swaps);
ReserveData memory reserveData = ReserveData({
transactionId: _transactionId,
leftoverReceiver: _leftoverReceiver,
nativeReserve: _nativeReserve
});
_executeSwaps(reserveData, _swaps, initialBalances);
uint256 newBalance = LibAsset.getOwnBalance(finalTokenId) -
initialBalance;
if (LibAsset.isNativeAsset(finalTokenId)) {
newBalance -= _nativeReserve;
}
if (newBalance < _minAmount) {
revert CumulativeSlippageTooHigh(_minAmount, newBalance);
}
return newBalance;
}
/// Private Methods ///
/// @dev Executes swaps and checks that DEXs used are in the allowList
/// @param _transactionId the transaction id associated with the operation
/// @param _swaps Array of data used to execute swaps
/// @param _leftoverReceiver Address to send leftover tokens to
/// @param _initialBalances Array of initial balances
function _executeSwaps(
bytes32 _transactionId,
LibSwap.SwapData[] calldata _swaps,
address payable _leftoverReceiver,
uint256[] memory _initialBalances
) internal noLeftovers(_swaps, _leftoverReceiver, _initialBalances) {
uint256 numSwaps = _swaps.length;
for (uint256 i; i < numSwaps; ++i) {
LibSwap.SwapData calldata currentSwap = _swaps[i];
if (
!((LibAsset.isNativeAsset(currentSwap.sendingAssetId) ||
LibAllowList.contractIsAllowed(currentSwap.approveTo)) &&
LibAllowList.contractIsAllowed(currentSwap.callTo) &&
LibAllowList.selectorIsAllowed(
bytes4(currentSwap.callData[:4])
))
) revert ContractCallNotAllowed();
LibSwap.swap(_transactionId, currentSwap);
}
}
/// @dev Executes swaps and checks that DEXs used are in the allowList
/// @param _reserveData Data passed used to reserve native tokens
/// @param _swaps Array of data used to execute swaps
/// @param _initialBalances Array of initial balances
function _executeSwaps(
ReserveData memory _reserveData,
LibSwap.SwapData[] calldata _swaps,
uint256[] memory _initialBalances
)
internal
noLeftoversReserve(
_swaps,
_reserveData.leftoverReceiver,
_initialBalances,
_reserveData.nativeReserve
)
{
uint256 numSwaps = _swaps.length;
for (uint256 i; i < numSwaps; ++i) {
LibSwap.SwapData calldata currentSwap = _swaps[i];
if (
!((LibAsset.isNativeAsset(currentSwap.sendingAssetId) ||
LibAllowList.contractIsAllowed(currentSwap.approveTo)) &&
LibAllowList.contractIsAllowed(currentSwap.callTo) &&
LibAllowList.selectorIsAllowed(
bytes4(currentSwap.callData[:4])
))
) revert ContractCallNotAllowed();
LibSwap.swap(_reserveData.transactionId, currentSwap);
}
}
/// @dev Fetches balances of tokens to be swapped before swapping.
/// @param _swaps Array of data used to execute swaps
/// @return uint256[] Array of token balances.
function _fetchBalances(
LibSwap.SwapData[] calldata _swaps
) internal view returns (uint256[] memory) {
uint256 numSwaps = _swaps.length;
uint256[] memory balances = new uint256[](numSwaps);
address asset;
for (uint256 i; i < numSwaps; ++i) {
asset = _swaps[i].receivingAssetId;
balances[i] = LibAsset.getOwnBalance(asset);
if (LibAsset.isNativeAsset(asset)) {
balances[i] -= msg.value;
}
}
return balances;
}
/// @dev Refunds leftover tokens to a specified receiver after swaps complete
/// @param _swaps Swap data array
/// @param _leftoverReceiver Address to send leftover tokens to
/// @param _initialBalances Array of initial token balances
/// @param _nativeReserve Amount of native token to prevent from being swept (0 for no reserve)
function _refundLeftovers(
LibSwap.SwapData[] calldata _swaps,
address payable _leftoverReceiver,
uint256[] memory _initialBalances,
uint256 _nativeReserve
) private {
uint256 numSwaps = _swaps.length;
address finalAsset = _swaps[numSwaps - 1].receivingAssetId;
// Handle both intermediate receiving assets and leftover input tokens in a single loop
uint256 leftoverAmount;
address curAsset;
address inputAsset;
uint256 curAssetReserve;
uint256 currentInputBalance;
uint256 inputAssetReserve;
for (uint256 i; i < numSwaps; ++i) {
// Handle intermediate receiving assets (only for non-final swaps when numSwaps > 1)
if (i < numSwaps - 1 && numSwaps != 1) {
curAsset = _swaps[i].receivingAssetId;
// Handle multiple swap steps
if (curAsset != finalAsset) {
leftoverAmount =
LibAsset.getOwnBalance(curAsset) -
_initialBalances[i];
curAssetReserve = LibAsset.isNativeAsset(curAsset)
? _nativeReserve
: 0;
if (leftoverAmount > curAssetReserve) {
LibAsset.transferAsset(
curAsset,
_leftoverReceiver,
leftoverAmount - curAssetReserve
);
}
}
}
// Handle leftover input tokens (but never sweep the final receiving asset)
inputAsset = _swaps[i].sendingAssetId;
currentInputBalance = LibAsset.getOwnBalance(inputAsset);
inputAssetReserve = LibAsset.isNativeAsset(inputAsset)
? _nativeReserve
: 0;
// Only transfer leftovers if there's actually a balance remaining after reserve
// and if it's not the final receiving asset (which should be kept for bridging)
if (
currentInputBalance > inputAssetReserve &&
inputAsset != finalAsset
) {
LibAsset.transferAsset(
inputAsset,
_leftoverReceiver,
currentInputBalance - inputAssetReserve
);
}
}
}
}// SPDX-License-Identifier: UNLICENSED
/// @custom:version 1.0.0
pragma solidity ^0.8.17;
import { LibAsset } from "../Libraries/LibAsset.sol";
import { LibUtil } from "../Libraries/LibUtil.sol";
// solhint-disable-next-line max-line-length
import { InvalidReceiver, InformationMismatch, InvalidSendingToken, InvalidAmount, NativeAssetNotSupported, InvalidDestinationChain, CannotBridgeToSameNetwork } from "../Errors/GenericErrors.sol";
import { ILiFi } from "../Interfaces/ILiFi.sol";
// solhint-disable-next-line no-unused-import
import { LibSwap } from "../Libraries/LibSwap.sol";
contract Validatable {
modifier validateBridgeData(ILiFi.BridgeData memory _bridgeData) {
if (LibUtil.isZeroAddress(_bridgeData.receiver)) {
revert InvalidReceiver();
}
if (_bridgeData.minAmount == 0) {
revert InvalidAmount();
}
if (_bridgeData.destinationChainId == block.chainid) {
revert CannotBridgeToSameNetwork();
}
_;
}
modifier noNativeAsset(ILiFi.BridgeData memory _bridgeData) {
if (LibAsset.isNativeAsset(_bridgeData.sendingAssetId)) {
revert NativeAssetNotSupported();
}
_;
}
modifier onlyAllowSourceToken(
ILiFi.BridgeData memory _bridgeData,
address _token
) {
if (_bridgeData.sendingAssetId != _token) {
revert InvalidSendingToken();
}
_;
}
modifier onlyAllowDestinationChain(
ILiFi.BridgeData memory _bridgeData,
uint256 _chainId
) {
if (_bridgeData.destinationChainId != _chainId) {
revert InvalidDestinationChain();
}
_;
}
modifier containsSourceSwaps(ILiFi.BridgeData memory _bridgeData) {
if (!_bridgeData.hasSourceSwaps) {
revert InformationMismatch();
}
_;
}
modifier doesNotContainSourceSwaps(ILiFi.BridgeData memory _bridgeData) {
if (_bridgeData.hasSourceSwaps) {
revert InformationMismatch();
}
_;
}
modifier doesNotContainDestinationCalls(
ILiFi.BridgeData memory _bridgeData
) {
if (_bridgeData.hasDestinationCall) {
revert InformationMismatch();
}
_;
}
}// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
/// @title LiFiData
/// @author LI.FI (https://li.fi)
/// @notice A storage for LI.FI-internal config data (addresses, chainIDs, etc.)
/// @custom:version 1.0.1
contract LiFiData {
address internal constant NON_EVM_ADDRESS =
0x11f111f111f111F111f111f111F111f111f111F1;
// LI.FI non-EVM Custom Chain IDs (IDs are made up by the LI.FI team)
uint256 internal constant LIFI_CHAIN_ID_APTOS = 9271000000000010;
uint256 internal constant LIFI_CHAIN_ID_BCH = 20000000000002;
uint256 internal constant LIFI_CHAIN_ID_BTC = 20000000000001;
uint256 internal constant LIFI_CHAIN_ID_DGE = 20000000000004;
uint256 internal constant LIFI_CHAIN_ID_LTC = 20000000000003;
uint256 internal constant LIFI_CHAIN_ID_SOLANA = 1151111081099710;
uint256 internal constant LIFI_CHAIN_ID_SUI = 9270000000000000;
uint256 internal constant LIFI_CHAIN_ID_TRON = 1885080386571452;
uint256 internal constant LIFI_CHAIN_ID_HYPERCORE = 1337;
}// SPDX-License-Identifier: LGPL-3.0-only
/// @custom:version 1.1.0
pragma solidity ^0.8.17;
struct QuoteSendInfo {
Fee gmpFee;
uint256 amountSent;
uint256 valueSent;
AirliftFeeInfo airliftFeeInfo;
}
struct AirliftFeeInfo {
Fee airliftFee;
uint256 correctedAmount;
uint256 correctedValue;
}
struct Fee {
uint256 nativeFee;
uint256 tokenFee;
}
interface IGlacisAirlift {
/// Use to send a token from chain A to chain B after approving this contract with the token.
/// This function should only be used when a smart contract calls it, so that the token's transfer
/// and the cross-chain send are atomic within a single transaction.
/// @param token The address of the token sending across chains.
/// @param amount The amount of the token you want to send across chains.
/// @param receiver The target address that should receive the funds on the destination chain.
/// @param destinationChainId The Ethereum chain ID of the destination chain.
/// @param refundAddress The address that should receive any funds in the case the cross-chain gas value is too high.
/// @return sendResponse The response from the token's handler function: not standardized.
function send(
address token,
uint256 amount,
bytes32 receiver,
uint256 destinationChainId,
address refundAddress
) external payable returns (bytes memory);
/// Use to send a token from chain A to chain B with a specific output token.
/// This allows routing through a specific bridge when multiple bridges are available.
/// @param token The address of the token sending across chains.
/// @param amount The amount of the token you want to send across chains.
/// @param receiver The target address that should receive the funds on the destination chain.
/// @param destinationChainId The Ethereum chain ID of the destination chain.
/// @param refundAddress The address that should receive any funds in the case the cross-chain gas value is too high.
/// @param outputToken The address of the token to receive on the destination chain. Use bytes32(0) for default routing.
/// @return sendResponse The response from the token's handler function: not standardized.
function send(
address token,
uint256 amount,
bytes32 receiver,
uint256 destinationChainId,
address refundAddress,
bytes32 outputToken
) external payable returns (bytes memory);
/// Use to quote the send a token from chain A to chain B.
/// @param token The address of the token sending across chains.
/// @param amount The amount of the token you want to send across chains.
/// @param receiver The target address that should receive the funds on the destination chain.
/// @param destinationChainId The Ethereum chain ID of the destination chain.
/// @param refundAddress The address that should receive any funds in the case the cross-chain gas value is too high.
/// @param msgValue The value that will be sent with the transaction.
/// @return The amount of token and value fees required to send the token across chains.
function quoteSend(
address token,
uint256 amount,
bytes32 receiver,
uint256 destinationChainId,
address refundAddress,
uint256 msgValue
) external returns (QuoteSendInfo memory);
/// Use to quote sending a token from chain A to chain B with a specific output token.
/// @param token The address of the token sending across chains.
/// @param amount The amount of the token you want to send across chains.
/// @param receiver The target address that should receive the funds on the destination chain.
/// @param destinationChainId The Ethereum chain ID of the destination chain.
/// @param refundAddress The address that should receive any funds in the case the cross-chain gas value is too high.
/// @param msgValue The value that will be sent with the transaction.
/// @param outputToken The address of the token to receive on the destination chain. Use bytes32(0) for default routing.
/// @return The amount of token and value fees required to send the token across chains.
function quoteSend(
address token,
uint256 amount,
bytes32 receiver,
uint256 destinationChainId,
address refundAddress,
uint256 msgValue,
bytes32 outputToken
) external returns (QuoteSendInfo memory);
}// SPDX-License-Identifier: LGPL-3.0-only /// @custom:version 1.0.2 pragma solidity ^0.8.17; error AlreadyInitialized(); error CannotAuthoriseSelf(); error CannotBridgeToSameNetwork(); error ContractCallNotAllowed(); error CumulativeSlippageTooHigh(uint256 minAmount, uint256 receivedAmount); error DiamondIsPaused(); error ETHTransferFailed(); error ExternalCallFailed(); error FunctionDoesNotExist(); error InformationMismatch(); error InsufficientBalance(uint256 required, uint256 balance); error InvalidAmount(); error InvalidCallData(); error InvalidConfig(); error InvalidContract(); error InvalidDestinationChain(); error InvalidFallbackAddress(); error InvalidNonEVMReceiver(); error InvalidReceiver(); error InvalidSendingToken(); error NativeAssetNotSupported(); error NativeAssetTransferFailed(); error NoSwapDataProvided(); error NoSwapFromZeroBalance(); error NotAContract(); error NotInitialized(); error NoTransferToNullAddress(); error NullAddrIsNotAnERC20Token(); error NullAddrIsNotAValidSpender(); error OnlyContractOwner(); error RecoveryAddressCannotBeZero(); error ReentrancyError(); error TokenNotSupported(); error TransferFromFailed(); error UnAuthorized(); error UnsupportedChainId(uint256 chainId); error WithdrawFailed(); error ZeroAmount();
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)
///
/// @dev Note:
/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.
/// - For ERC20s, this implementation won't check that a token has code,
/// responsibility is delegated to the caller.
library SafeTransferLib {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The ETH transfer has failed.
error ETHTransferFailed();
/// @dev The ERC20 `transferFrom` has failed.
error TransferFromFailed();
/// @dev The ERC20 `transfer` has failed.
error TransferFailed();
/// @dev The ERC20 `approve` has failed.
error ApproveFailed();
/// @dev The Permit2 operation has failed.
error Permit2Failed();
/// @dev The Permit2 amount must be less than `2**160 - 1`.
error Permit2AmountOverflow();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.
uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;
/// @dev Suggested gas stipend for contract receiving ETH to perform a few
/// storage reads and writes, but low enough to prevent griefing.
uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;
/// @dev The unique EIP-712 domain domain separator for the DAI token contract.
bytes32 internal constant DAI_DOMAIN_SEPARATOR =
0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;
/// @dev The address for the WETH9 contract on Ethereum mainnet.
address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
/// @dev The canonical Permit2 address.
/// [Github](https://github.com/Uniswap/permit2)
/// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ETH OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.
//
// The regular variants:
// - Forwards all remaining gas to the target.
// - Reverts if the target reverts.
// - Reverts if the current contract has insufficient balance.
//
// The force variants:
// - Forwards with an optional gas stipend
// (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).
// - If the target reverts, or if the gas stipend is exhausted,
// creates a temporary contract to force send the ETH via `SELFDESTRUCT`.
// Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.
// - Reverts if the current contract has insufficient balance.
//
// The try variants:
// - Forwards with a mandatory gas stipend.
// - Instead of reverting, returns whether the transfer succeeded.
/// @dev Sends `amount` (in wei) ETH to `to`.
function safeTransferETH(address to, uint256 amount) internal {
/// @solidity memory-safe-assembly
assembly {
if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Sends all the ETH in the current contract to `to`.
function safeTransferAllETH(address to) internal {
/// @solidity memory-safe-assembly
assembly {
// Transfer all the ETH and check if it succeeded or not.
if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {
/// @solidity memory-safe-assembly
assembly {
if lt(selfbalance(), amount) {
mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
revert(0x1c, 0x04)
}
if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
/// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.
function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {
/// @solidity memory-safe-assembly
assembly {
if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
/// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.
function forceSafeTransferETH(address to, uint256 amount) internal {
/// @solidity memory-safe-assembly
assembly {
if lt(selfbalance(), amount) {
mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
revert(0x1c, 0x04)
}
if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
/// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.
function forceSafeTransferAllETH(address to) internal {
/// @solidity memory-safe-assembly
assembly {
// forgefmt: disable-next-item
if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
/// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)
internal
returns (bool success)
{
/// @solidity memory-safe-assembly
assembly {
success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)
}
}
/// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.
function trySafeTransferAllETH(address to, uint256 gasStipend)
internal
returns (bool success)
{
/// @solidity memory-safe-assembly
assembly {
success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC20 OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
/// Reverts upon failure.
///
/// The `from` account must have at least `amount` approved for
/// the current contract to manage.
function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x60, amount) // Store the `amount` argument.
mstore(0x40, to) // Store the `to` argument.
mstore(0x2c, shl(96, from)) // Store the `from` argument.
mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
// Perform the transfer, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
) {
mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
revert(0x1c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot to zero.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
///
/// The `from` account must have at least `amount` approved for the current contract to manage.
function trySafeTransferFrom(address token, address from, address to, uint256 amount)
internal
returns (bool success)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x60, amount) // Store the `amount` argument.
mstore(0x40, to) // Store the `to` argument.
mstore(0x2c, shl(96, from)) // Store the `from` argument.
mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
success :=
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
mstore(0x60, 0) // Restore the zero slot to zero.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Sends all of ERC20 `token` from `from` to `to`.
/// Reverts upon failure.
///
/// The `from` account must have their entire balance approved for the current contract to manage.
function safeTransferAllFrom(address token, address from, address to)
internal
returns (uint256 amount)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x40, to) // Store the `to` argument.
mstore(0x2c, shl(96, from)) // Store the `from` argument.
mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
// Read the balance, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
gt(returndatasize(), 0x1f), // At least 32 bytes returned.
staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)
)
) {
mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
revert(0x1c, 0x04)
}
mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.
amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.
// Perform the transfer, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
) {
mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
revert(0x1c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot to zero.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.
/// Reverts upon failure.
function safeTransfer(address token, address to, uint256 amount) internal {
/// @solidity memory-safe-assembly
assembly {
mstore(0x14, to) // Store the `to` argument.
mstore(0x34, amount) // Store the `amount` argument.
mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.
// Perform the transfer, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
revert(0x1c, 0x04)
}
mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
}
}
/// @dev Sends all of ERC20 `token` from the current contract to `to`.
/// Reverts upon failure.
function safeTransferAll(address token, address to) internal returns (uint256 amount) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.
mstore(0x20, address()) // Store the address of the current contract.
// Read the balance, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
gt(returndatasize(), 0x1f), // At least 32 bytes returned.
staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)
)
) {
mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
revert(0x1c, 0x04)
}
mstore(0x14, to) // Store the `to` argument.
amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.
mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.
// Perform the transfer, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
revert(0x1c, 0x04)
}
mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
}
}
/// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.
/// Reverts upon failure.
function safeApprove(address token, address to, uint256 amount) internal {
/// @solidity memory-safe-assembly
assembly {
mstore(0x14, to) // Store the `to` argument.
mstore(0x34, amount) // Store the `amount` argument.
mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
// Perform the approval, reverting upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.
revert(0x1c, 0x04)
}
mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
}
}
/// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.
/// If the initial attempt to approve fails, attempts to reset the approved amount to zero,
/// then retries the approval again (some tokens, e.g. USDT, requires this).
/// Reverts upon failure.
function safeApproveWithRetry(address token, address to, uint256 amount) internal {
/// @solidity memory-safe-assembly
assembly {
mstore(0x14, to) // Store the `to` argument.
mstore(0x34, amount) // Store the `amount` argument.
mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
// Perform the approval, retrying upon failure.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x34, 0) // Store 0 for the `amount`.
mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.
mstore(0x34, amount) // Store back the original `amount`.
// Retry the approval, reverting upon failure.
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.
revert(0x1c, 0x04)
}
}
mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
}
}
/// @dev Returns the amount of ERC20 `token` owned by `account`.
/// Returns zero if the `token` does not exist.
function balanceOf(address token, address account) internal view returns (uint256 amount) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x14, account) // Store the `account` argument.
mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
amount :=
mul( // The arguments of `mul` are evaluated from right to left.
mload(0x20),
and( // The arguments of `and` are evaluated from right to left.
gt(returndatasize(), 0x1f), // At least 32 bytes returned.
staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)
)
)
}
}
/// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
/// If the initial attempt fails, try to use Permit2 to transfer the token.
/// Reverts upon failure.
///
/// The `from` account must have at least `amount` approved for the current contract to manage.
function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {
if (!trySafeTransferFrom(token, from, to, amount)) {
permit2TransferFrom(token, from, to, amount);
}
}
/// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.
/// Reverts upon failure.
function permit2TransferFrom(address token, address from, address to, uint256 amount)
internal
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
mstore(add(m, 0x74), shr(96, shl(96, token)))
mstore(add(m, 0x54), amount)
mstore(add(m, 0x34), to)
mstore(add(m, 0x20), shl(96, from))
// `transferFrom(address,address,uint160,address)`.
mstore(m, 0x36c78516000000000000000000000000)
let p := PERMIT2
let exists := eq(chainid(), 1)
if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }
if iszero(and(call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), exists)) {
mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.
revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)
}
}
}
/// @dev Permit a user to spend a given amount of
/// another user's tokens via native EIP-2612 permit if possible, falling
/// back to Permit2 if native permit fails or is not implemented on the token.
function permit2(
address token,
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
for {} shl(96, xor(token, WETH9)) {} {
mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.
if iszero(
and( // The arguments of `and` are evaluated from right to left.
lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.
// Gas stipend to limit gas burn for tokens that don't refund gas when
// an non-existing function is called. 5K should be enough for a SLOAD.
staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)
)
) { break }
// After here, we can be sure that token is a contract.
let m := mload(0x40)
mstore(add(m, 0x34), spender)
mstore(add(m, 0x20), shl(96, owner))
mstore(add(m, 0x74), deadline)
if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {
mstore(0x14, owner)
mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.
mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))
mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.
// `nonces` is already at `add(m, 0x54)`.
// `1` is already stored at `add(m, 0x94)`.
mstore(add(m, 0xb4), and(0xff, v))
mstore(add(m, 0xd4), r)
mstore(add(m, 0xf4), s)
success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)
break
}
mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.
mstore(add(m, 0x54), amount)
mstore(add(m, 0x94), and(0xff, v))
mstore(add(m, 0xb4), r)
mstore(add(m, 0xd4), s)
success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)
break
}
}
if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);
}
/// @dev Simple permit on the Permit2 contract.
function simplePermit2(
address token,
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
mstore(m, 0x927da105) // `allowance(address,address,address)`.
{
let addressMask := shr(96, not(0))
mstore(add(m, 0x20), and(addressMask, owner))
mstore(add(m, 0x40), and(addressMask, token))
mstore(add(m, 0x60), and(addressMask, spender))
mstore(add(m, 0xc0), and(addressMask, spender))
}
let p := mul(PERMIT2, iszero(shr(160, amount)))
if iszero(
and( // The arguments of `and` are evaluated from right to left.
gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.
staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)
)
) {
mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.
revert(add(0x18, shl(2, iszero(p))), 0x04)
}
mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).
// `owner` is already `add(m, 0x20)`.
// `token` is already at `add(m, 0x40)`.
mstore(add(m, 0x60), amount)
mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.
// `nonce` is already at `add(m, 0xa0)`.
// `spender` is already at `add(m, 0xc0)`.
mstore(add(m, 0xe0), deadline)
mstore(add(m, 0x100), 0x100) // `signature` offset.
mstore(add(m, 0x120), 0x41) // `signature` length.
mstore(add(m, 0x140), r)
mstore(add(m, 0x160), s)
mstore(add(m, 0x180), shl(248, v))
if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) {
mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.
revert(0x1c, 0x04)
}
}
}
}// SPDX-License-Identifier: LGPL-3.0-only
/// @custom:version 1.0.0
pragma solidity ^0.8.17;
// solhint-disable-next-line no-global-import
import "./LibBytes.sol";
library LibUtil {
using LibBytes for bytes;
function getRevertMsg(
bytes memory _res
) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_res.length < 68) return "Transaction reverted silently";
bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes
return abi.decode(revertData, (string)); // All that remains is the revert string
}
/// @notice Determines whether the given address is the zero address
/// @param addr The address to verify
/// @return Boolean indicating if the address is the zero address
function isZeroAddress(address addr) internal pure returns (bool) {
return addr == address(0);
}
function revertWith(bytes memory data) internal pure {
assembly {
let dataSize := mload(data) // Load the size of the data
let dataPtr := add(data, 0x20) // Advance data pointer to the next word
revert(dataPtr, dataSize) // Revert with the given data
}
}
}// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
import { InvalidContract, InvalidCallData } from "../Errors/GenericErrors.sol";
import { LibAsset } from "./LibAsset.sol";
/// @title LibAllowList
/// @author LI.FI (https://li.fi)
/// @notice Manages a dual-model allow list to support a secure, granular permissions system
/// while maintaining backward compatibility with a non-granular, global system.
/// @dev This library is the single source of truth for all whitelist state changes.
/// It ensures that both the new granular mapping and the global arrays used by older
/// contracts are kept perfectly synchronized. The long-term goal is to migrate all usage
/// to the new granular system. New development should exclusively use the "Primary Interface" functions.
///
/// Special ApproveTo-Only Selector:
/// - Use 0xffffffff to whitelist contracts that are used only as approveTo in
/// LibSwap.SwapData, without allowing function calls to them.
/// - Some DEXs have specific contracts that need to be approved to while another
/// (router) contract must be called to initiate the swap.
/// - This selector makes contractIsAllowed(_contract) return true for backward
/// compatibility, but does not authorize any granular calls. In the granular
/// system, real function selectors must be explicitly whitelisted to be callable.
/// @custom:version 2.0.0
library LibAllowList {
/// Storage ///
bytes32 internal constant NAMESPACE =
keccak256("com.lifi.library.allow.list");
struct AllowListStorage {
// --- STORAGE FOR OLDER VERSIONS ---
/// @dev [BACKWARD COMPATIBILITY] [V1 DATA] Boolean mapping actively maintained
/// by functions to support older, deployed contracts that read from it.
/// Also kept for storage layout compatibility.
mapping(address => bool) contractAllowList;
/// @dev [BACKWARD COMPATIBILITY] [V1 DATA] Boolean mapping actively maintained
/// by functions to support older, deployed contracts that read from it.
/// Also kept for storage layout compatibility.
mapping(bytes4 => bool) selectorAllowList;
/// @dev [BACKWARD COMPATIBILITY] The global list of all unique whitelisted contracts for older facets.
address[] contracts;
// --- NEW GRANULAR STORAGE & SYNCHRONIZATION ---
// These variables form the new, secure, and preferred whitelist system.
/// @dev [BACKWARD COMPATIBILITY] 1-based index for `contracts` array for efficient removal.
mapping(address => uint256) contractToIndex;
/// @dev [BACKWARD COMPATIBILITY] 1-based index for `selectors` array for efficient removal.
mapping(bytes4 => uint256) selectorToIndex;
/// @dev [BACKWARD COMPATIBILITY] The global list of all unique whitelisted selectors for older facets.
bytes4[] selectors;
/// @dev The SOURCE OF TRUTH for the new granular system.
mapping(address => mapping(bytes4 => bool)) contractSelectorAllowList;
/// @dev A global reference count for each selector to manage the `selectors` array for backward compatibility.
mapping(bytes4 => uint256) selectorReferenceCount;
/// @dev Iterable list of selectors for each contract, used by the backend getter.
/// The length of this array also serves as the IMPLICIT contract reference count.
mapping(address => bytes4[]) whitelistedSelectorsByContract;
/// @dev 1-based index for `whitelistedSelectorsByContract` array for efficient removal.
mapping(address => mapping(bytes4 => uint256)) selectorIndices;
/// @dev Flag to indicate completion of a one-time data migration.
bool migrated;
}
/// @notice Adds a specific contract-selector pair to the allow list.
/// @dev This is the primary entry point for whitelisting. It updates the granular
/// mapping and synchronizes the global arrays (for backward compatibility) via reference counting.
/// @param _contract The contract address.
/// @param _selector The function selector.
function addAllowedContractSelector(
address _contract,
bytes4 _selector
) internal {
if (_contract == address(0) || _selector == bytes4(0))
revert InvalidCallData();
AllowListStorage storage als = _getStorage();
// Skip if the pair is already allowed.
if (als.contractSelectorAllowList[_contract][_selector]) return;
// 1. Update the source of truth for the new system.
als.contractSelectorAllowList[_contract][_selector] = true;
// 2. Update the `contracts` variables if this is the first selector for this contract.
// We use the length of the iterable array as an implicit reference count.
if (als.whitelistedSelectorsByContract[_contract].length == 0) {
_addAllowedContract(_contract);
}
// 3. Update the `selectors` variables if this is the first time this selector is used globally.
if (++als.selectorReferenceCount[_selector] == 1) {
_addAllowedSelector(_selector);
}
// 4. Update the iterable list used by the on-chain getter.
als.whitelistedSelectorsByContract[_contract].push(_selector);
// Store 1-based index for efficient removal later.
als.selectorIndices[_contract][_selector] = als
.whitelistedSelectorsByContract[_contract]
.length;
}
/// @notice Removes a specific contract-selector pair from the allow list.
/// @dev This is the primary entry point for removal. It updates the granular
/// mapping and synchronizes the global arrays (for backward compatibility) via reference counting.
/// @param _contract The contract address.
/// @param _selector The function selector.
function removeAllowedContractSelector(
address _contract,
bytes4 _selector
) internal {
AllowListStorage storage als = _getStorage();
// Skip if the pair is not currently allowed.
if (!als.contractSelectorAllowList[_contract][_selector]) return;
// 1. Update the source of truth.
delete als.contractSelectorAllowList[_contract][_selector];
// 2. Update the iterable list FIRST to get the new length.
_removeSelectorFromIterableList(_contract, _selector);
// 3. If the iterable list's new length is 0, it was the last selector,
// so remove the contract from the global list.
if (als.whitelistedSelectorsByContract[_contract].length == 0) {
_removeAllowedContract(_contract);
}
// 4. If the global reference count is now 0, it was the last usage of this
// selector, so remove it from the global list.
if (--als.selectorReferenceCount[_selector] == 0) {
_removeAllowedSelector(_selector);
}
}
/// @notice Checks if a specific contract-selector pair is allowed.
/// @dev Preferred runtime check for all new contracts/facets.
/// @param _contract The contract address.
/// @param _selector The function selector.
/// @return isAllowed True if the contract-selector pair is allowed, false otherwise.
function contractSelectorIsAllowed(
address _contract,
bytes4 _selector
) internal view returns (bool) {
return _getStorage().contractSelectorAllowList[_contract][_selector];
}
/// @notice Gets all approved selectors for a specific contract.
/// @dev Used by the on-chain getter in the facet for backend synchronization.
/// @param _contract The contract address.
/// @return selectors The whitelisted selectors for the contract.
function getWhitelistedSelectorsForContract(
address _contract
) internal view returns (bytes4[] memory) {
return _getStorage().whitelistedSelectorsByContract[_contract];
}
/// Backward Compatibility Interface (V1) ///
// These functions read from the global arrays. They are required for existing,
// deployed facets to continue functioning. They should be considered part of a
// transitional phase and MUST NOT be used in new development.
/// @notice [Backward Compatibility] Checks if a contract is on the global allow list.
/// @dev This function reads from the global list and is NOT granular. It is required for
/// older, deployed facets to function correctly. Avoid use in new code.
/// @param _contract The contract address.
/// @return isAllowed True if the contract is allowed, false otherwise.
function contractIsAllowed(
address _contract
) internal view returns (bool) {
return _getStorage().contractAllowList[_contract];
}
/// @notice [Backward Compatibility] Checks if a selector is on the global allow list.
/// @dev This function reads from the global list and is NOT granular. It is required for
/// older, deployed facets to function correctly. Avoid use in new code.
/// @param _selector The function selector.
/// @return isAllowed True if the selector is allowed, false otherwise.
function selectorIsAllowed(bytes4 _selector) internal view returns (bool) {
return _getStorage().selectorAllowList[_selector];
}
/// @notice [Backward Compatibility] Gets the entire global list of whitelisted contracts.
/// @dev Returns the `contracts` array, which is synchronized with the new granular system.
/// @return contracts The global list of whitelisted contracts.
function getAllowedContracts() internal view returns (address[] memory) {
return _getStorage().contracts;
}
/// @notice [Backward Compatibility] Gets the entire global list of whitelisted selectors.
/// @dev Returns the `selectors` array, which is synchronized with the new granular system.
function getAllowedSelectors() internal view returns (bytes4[] memory) {
return _getStorage().selectors;
}
/// Private Helpers (Internal Use Only) ///
/// @dev Internal helper to add a contract to the `contracts` array.
/// @param _contract The contract address.
function _addAllowedContract(address _contract) private {
// Ensure address is actually a contract.
if (!LibAsset.isContract(_contract)) revert InvalidContract();
AllowListStorage storage als = _getStorage();
// Add contract to the old allow list for backward compatibility
als.contractAllowList[_contract] = true;
// Skip if contract is already in allow list (1-based index).
if (als.contractToIndex[_contract] > 0) return;
// Add contract to allow list array.
als.contracts.push(_contract);
// Store 1-based index for efficient removal later.
als.contractToIndex[_contract] = als.contracts.length;
}
/// @dev Internal helper to remove a contract from the `contracts` array.
/// @param _contract The contract address.
function _removeAllowedContract(address _contract) private {
AllowListStorage storage als = _getStorage();
// The V1 boolean mapping must be cleared before any checks.
// This delete operation is placed at the top to ensure V1/V2 sync
// and primarily solves two issues of stale item where
// V1 data - als.selectorAllowList[_selector]=true,
// V2 data - als.selectorToIndex[_selector]=0.
// This scenario is different from selectors; it's an unlikely
// edge case for contracts because the migration iterates the
// full on-chain `contracts` array for a "perfect" cleanup.
// However, this defensive delete ensures the function is robust
//against any state corruption.
delete als.contractAllowList[_contract];
// Get the 1-based index; return if not found.
uint256 oneBasedIndex = als.contractToIndex[_contract];
if (oneBasedIndex == 0) {
return;
}
// Convert to 0-based index for array operations.
uint256 index = oneBasedIndex - 1;
uint256 lastIndex = als.contracts.length - 1;
// If the contract to remove isn't the last one,
// move the last contract to the removed contract's position.
if (index != lastIndex) {
address lastContract = als.contracts[lastIndex];
als.contracts[index] = lastContract;
als.contractToIndex[lastContract] = oneBasedIndex;
}
// Remove the last element and clean up mappings.
als.contracts.pop();
delete als.contractToIndex[_contract];
}
/// @dev Internal helper to add a selector to the `selectors` array.
/// @param _selector The function selector.
function _addAllowedSelector(bytes4 _selector) private {
AllowListStorage storage als = _getStorage();
// Add selector to the old allow list for backward compatibility
als.selectorAllowList[_selector] = true;
// Skip if selector is already in allow list (1-based index).
if (als.selectorToIndex[_selector] > 0) return;
// Add selector to the array.
als.selectors.push(_selector);
// Store 1-based index for efficient removal later.
als.selectorToIndex[_selector] = als.selectors.length;
}
/// @dev Internal helper to remove a selector from the `selectors` array.
/// @param _selector The function selector.
function _removeAllowedSelector(bytes4 _selector) private {
AllowListStorage storage als = _getStorage();
// The V1 boolean mapping must be cleared before any checks.
// The migration's selector cleanup is "imperfect" as it relies on an
// off-chain list. A "stale selector" ( V1 data - als.selectorAllowList[_selector]=true, V2 data - als.selectorToIndex[_selector]=0) is possible.
// Placing `delete` here allows an admin to fix this by
// add-then-remove, as this line will clean the V1 bool even if
// the V2 `oneBasedIndex` is 0.
delete als.selectorAllowList[_selector];
// Get the 1-based index; return if not found.
uint256 oneBasedIndex = als.selectorToIndex[_selector];
if (oneBasedIndex == 0) {
return;
}
// Convert to 0-based index for array operations.
uint256 index = oneBasedIndex - 1;
uint256 lastIndex = als.selectors.length - 1;
// If the selector to remove isn't the last one,
// move the last selector to the removed selector's position.
if (index != lastIndex) {
bytes4 lastSelector = als.selectors[lastIndex];
als.selectors[index] = lastSelector;
als.selectorToIndex[lastSelector] = oneBasedIndex;
}
// Remove the last element and clean up mappings.
als.selectors.pop();
delete als.selectorToIndex[_selector];
}
/// @dev Internal helper to manage the iterable array for the getter function.
/// @param _contract The contract address.
/// @param _selector The function selector.
function _removeSelectorFromIterableList(
address _contract,
bytes4 _selector
) private {
AllowListStorage storage als = _getStorage();
// Get the 1-based index; return if not found.
uint256 oneBasedIndex = als.selectorIndices[_contract][_selector];
if (oneBasedIndex == 0) return;
// Convert to 0-based index for array operations.
uint256 index = oneBasedIndex - 1;
bytes4[] storage selectorsArray = als.whitelistedSelectorsByContract[
_contract
];
uint256 lastIndex = selectorsArray.length - 1;
// If the selector to remove isn't the last one,
// move the last selector to the removed selector's position.
if (index != lastIndex) {
bytes4 lastSelector = selectorsArray[lastIndex];
selectorsArray[index] = lastSelector;
als.selectorIndices[_contract][lastSelector] = oneBasedIndex;
}
// Remove the last element and clean up mappings.
selectorsArray.pop();
delete als.selectorIndices[_contract][_selector];
}
/// @dev Fetches the storage pointer for this library.
/// @return als The storage pointer.
function _getStorage()
internal
pure
returns (AllowListStorage storage als)
{
bytes32 position = NAMESPACE;
assembly {
als.slot := position
}
}
}// SPDX-License-Identifier: LGPL-3.0-only
/// @custom:version 1.0.0
pragma solidity ^0.8.17;
library LibBytes {
// solhint-disable no-inline-assembly
// LibBytes specific errors
error SliceOverflow();
error SliceOutOfBounds();
error AddressOutOfBounds();
bytes16 private constant _SYMBOLS = "0123456789abcdef";
// -------------------------
function slice(
bytes memory _bytes,
uint256 _start,
uint256 _length
) internal pure returns (bytes memory) {
if (_length + 31 < _length) revert SliceOverflow();
if (_bytes.length < _start + _length) revert SliceOutOfBounds();
bytes memory tempBytes;
assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(
add(tempBytes, lengthmod),
mul(0x20, iszero(lengthmod))
)
let end := add(mc, _length)
for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(
add(
add(_bytes, lengthmod),
mul(0x20, iszero(lengthmod))
),
_start
)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
mstore(tempBytes, _length)
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)
mstore(0x40, add(tempBytes, 0x20))
}
}
return tempBytes;
}
function toAddress(
bytes memory _bytes,
uint256 _start
) internal pure returns (address) {
if (_bytes.length < _start + 20) {
revert AddressOutOfBounds();
}
address tempAddress;
assembly {
tempAddress := div(
mload(add(add(_bytes, 0x20), _start)),
0x1000000000000000000000000
)
}
return tempAddress;
}
/// Copied from OpenZeppelin's `Strings.sol` utility library.
/// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/8335676b0e99944eef6a742e16dcd9ff6e68e609
/// /contracts/utils/Strings.sol
function toHexString(
uint256 value,
uint256 length
) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
// solhint-disable-next-line gas-custom-errors
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}{
"remappings": [
"@eth-optimism/=node_modules/@hop-protocol/sdk/node_modules/@eth-optimism/",
"@uniswap/=node_modules/@uniswap/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"celer-network/=lib/sgn-v2-contracts/",
"create3-factory/=lib/create3-factory/src/",
"solmate/=lib/solmate/src/",
"solady/=lib/solady/src/",
"permit2/=lib/Permit2/src/",
"ds-test/=lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"lifi/=src/",
"test/=test/",
"@cowprotocol/=node_modules/@cowprotocol/",
"Permit2/=lib/Permit2/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/Permit2/lib/forge-gas-snapshot/src/",
"hardhat/=node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"sgn-v2-contracts/=lib/sgn-v2-contracts/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IGlacisAirlift","name":"_airlift","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CannotBridgeToSameNetwork","type":"error"},{"inputs":[],"name":"ContractCallNotAllowed","type":"error"},{"inputs":[{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"receivedAmount","type":"uint256"}],"name":"CumulativeSlippageTooHigh","type":"error"},{"inputs":[],"name":"InformationMismatch","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidCallData","type":"error"},{"inputs":[],"name":"InvalidConfig","type":"error"},{"inputs":[],"name":"InvalidContract","type":"error"},{"inputs":[],"name":"InvalidNonEVMReceiver","type":"error"},{"inputs":[],"name":"InvalidReceiver","type":"error"},{"inputs":[],"name":"NativeAssetNotSupported","type":"error"},{"inputs":[],"name":"NoSwapDataProvided","type":"error"},{"inputs":[],"name":"NoSwapFromZeroBalance","type":"error"},{"inputs":[],"name":"NullAddrIsNotAValidSpender","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"dex","type":"address"},{"indexed":false,"internalType":"address","name":"fromAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"toAssetId","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"AssetSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"receiver","type":"bytes"}],"name":"BridgeToNonEVMChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"receiver","type":"bytes32"}],"name":"BridgeToNonEVMChainBytes32","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"string","name":"integrator","type":"string"},{"indexed":false,"internalType":"string","name":"referrer","type":"string"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"fromAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"toAssetId","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toAmount","type":"uint256"}],"name":"LiFiGenericSwapCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"string","name":"integrator","type":"string"},{"indexed":false,"internalType":"string","name":"referrer","type":"string"},{"indexed":false,"internalType":"address","name":"fromAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"toAssetId","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toAmount","type":"uint256"}],"name":"LiFiSwappedGeneric","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"receivingAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"LiFiTransferCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"receivingAssetId","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"LiFiTransferRecovered","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"bridge","type":"string"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"}],"indexed":false,"internalType":"struct ILiFi.BridgeData","name":"bridgeData","type":"tuple"}],"name":"LiFiTransferStarted","type":"event"},{"inputs":[],"name":"AIRLIFT","outputs":[{"internalType":"contract IGlacisAirlift","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"bridge","type":"string"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"}],"internalType":"struct ILiFi.BridgeData","name":"_bridgeData","type":"tuple"},{"components":[{"internalType":"bytes32","name":"receiverAddress","type":"bytes32"},{"internalType":"address","name":"refundAddress","type":"address"},{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"bytes32","name":"outputToken","type":"bytes32"}],"internalType":"struct GlacisFacet.GlacisData","name":"_glacisData","type":"tuple"}],"name":"startBridgeTokensViaGlacis","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"string","name":"bridge","type":"string"},{"internalType":"string","name":"integrator","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"}],"internalType":"struct ILiFi.BridgeData","name":"_bridgeData","type":"tuple"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bool","name":"requiresDeposit","type":"bool"}],"internalType":"struct LibSwap.SwapData[]","name":"_swapData","type":"tuple[]"},{"components":[{"internalType":"bytes32","name":"receiverAddress","type":"bytes32"},{"internalType":"address","name":"refundAddress","type":"address"},{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"bytes32","name":"outputToken","type":"bytes32"}],"internalType":"struct GlacisFacet.GlacisData","name":"_glacisData","type":"tuple"}],"name":"swapAndStartBridgeTokensViaGlacis","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
0x60a060405234801561000f575f5ffd5b50604051611f61380380611f6183398101604081905261002e91610066565b6001600160a01b038116610055576040516306b7c75960e31b815260040160405180910390fd5b6001600160a01b0316608052610093565b5f60208284031215610076575f5ffd5b81516001600160a01b038116811461008c575f5ffd5b9392505050565b608051611ea96100b85f395f8181607001528181610810015261085f0152611ea95ff3fe608060405260043610610033575f3560e01c80636f9206ba146100375780639c4b6dd91461004c578063bbbf77d51461005f575b5f5ffd5b61004a6100453660046119b1565b6100bb565b005b61004a61005a3660046119fd565b61033b565b34801561006a575f5ffd5b506100927f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610136576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018155335f6101463447611aaa565b90508461016b8160a0015173ffffffffffffffffffffffffffffffffffffffff161590565b156101a2576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060c001515f036101df576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b468160e001510361021c576040517f4ac09ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b858061010001511561025a576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8680610120015115610298576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b876102bb816080015173ffffffffffffffffffffffffffffffffffffffff161590565b156102f2576040517f5ded599700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61030489608001518a60c001516105c3565b61030e8989610677565b50479250505081811115610330576103305f8461032b8585611aaa565b6109ad565b50505f909155505050565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016103b6576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018155335f6103c63447611aaa565b905086806101000151610405576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8780610120015115610443576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b886104668160a0015173ffffffffffffffffffffffffffffffffffffffff161590565b1561049d576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060c001515f036104da576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b468160e0015103610517576040517f4ac09ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8961053a816080015173ffffffffffffffffffffffffffffffffffffffff161590565b15610571576040517f5ded599700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61058a8b5f01518c60c001518c8c338d604001356109e2565b60c08c01526105998b89610677565b504792505050818111156105b6576105b65f8461032b8585611aaa565b50505f9091555050505050565b805f036105fc576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166106555780341015610651576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b61065173ffffffffffffffffffffffffffffffffffffffff8316333084610b7c565b7311f111f111f111f111f111f111f111f111f111f173ffffffffffffffffffffffffffffffffffffffff168260a0015173ffffffffffffffffffffffffffffffffffffffff160361073a5780356106fa576040517f58b0510000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60e08201518251604051833581527f815cd8dc72093a13fe3577112c391b6279303956526382ab98772d0239dbf78c9060200160405180910390a36107a8565b805f01355f1c73ffffffffffffffffffffffffffffffffffffffff168260a0015173ffffffffffffffffffffffffffffffffffffffff16146107a8576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107b96040830160208401611ae2565b73ffffffffffffffffffffffffffffffffffffffff1603610806576040517f1c49f4d100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61083982608001517f00000000000000000000000000000000000000000000000000000000000000008460c00151610bd4565b608082015160c083015160e084015173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001692631f9cd527926040860180359387359161089d9060208a01611ae2565b60405160e088901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff95861660048201526024810194909452604484019290925260648301529091166084820152606085013560a482015260c4015f6040518083038185885af115801561092b573d5f5f3e3d5ffd5b50505050506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526109719190810190611b02565b507fcba69f43792f9f399347222505213b55af8e0b0b54b893085c2e27ecbe1644f1826040516109a19190611bc3565b60405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff83166109d7576109d28282610c00565b505050565b6109d2838383610c6d565b5f83808203610a1d576040517f0503c3ed00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8686610a2b600185611aaa565b818110610a3a57610a3a611cd6565b9050602002810190610a4c9190611d03565b610a5d906080810190606001611ae2565b90505f610a6982610cdb565b905073ffffffffffffffffffffffffffffffffffffffff8216610a9357610a903482611aaa565b90505b5f610a9e8989610d25565b9050610aaa8989610e2f565b604080516060810182528c815273ffffffffffffffffffffffffffffffffffffffff89166020820152908101879052610ae5818b8b85610e9b565b5f83610af086610cdb565b610afa9190611aaa565b905073ffffffffffffffffffffffffffffffffffffffff8516610b2457610b218882611aaa565b90505b8b811015610b6c576040517f275c273c000000000000000000000000000000000000000000000000000000008152600481018d90526024810182905260440160405180910390fd5b9c9b505050505050505050505050565b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c5260205f6064601c5f895af13d1560015f51141716610bc757637939f4245f526004601cfd5b5f60605260405250505050565b6109d28383837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61106b565b73ffffffffffffffffffffffffffffffffffffffff8216610c4d576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61065173ffffffffffffffffffffffffffffffffffffffff831682611198565b73ffffffffffffffffffffffffffffffffffffffff8216610cba576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109d273ffffffffffffffffffffffffffffffffffffffff841683836111b1565b5f73ffffffffffffffffffffffffffffffffffffffff821615610d1d57610d1873ffffffffffffffffffffffffffffffffffffffff8316306111fa565b610d1f565b475b92915050565b6060815f8167ffffffffffffffff811115610d4257610d4261173f565b604051908082528060200260200182016040528015610d6b578160200160208202803683370190505b5090505f5f5b83811015610e2457868682818110610d8b57610d8b611cd6565b9050602002810190610d9d9190611d03565b610dae906080810190606001611ae2565b9150610db982610cdb565b838281518110610dcb57610dcb611cd6565b602090810291909101015273ffffffffffffffffffffffffffffffffffffffff8216610e1c5734838281518110610e0457610e04611cd6565b60200260200101818151610e189190611aaa565b9052505b600101610d71565b509095945050505050565b5f5b818110156109d25736838383818110610e4c57610e4c611cd6565b9050602002810190610e5e9190611d03565b9050610e7060e0820160c08301611d3f565b15610e9257610e92610e886060830160408401611ae2565b82608001356105c3565b50600101610e31565b60208401516040850151849184918490835f5b8181101561105157368a8a83818110610ec957610ec9611cd6565b9050602002810190610edb9190611d03565b9050610f0a610ef06060830160408401611ae2565b73ffffffffffffffffffffffffffffffffffffffff161590565b80610f6c5750610f6c610f236040830160208401611ae2565b73ffffffffffffffffffffffffffffffffffffffff165f9081527f7a8ac5d3b7183f220a0602439da45ea337311d699902d1ed11a3725a714e7f1e602052604090205460ff1690565b8015610f835750610f83610f236020830183611ae2565b80156110065750611006610f9a60a0830183611d58565b610fa8916004915f91611dc0565b610fb191611de7565b7fffffffff00000000000000000000000000000000000000000000000000000000165f9081527f7a8ac5d3b7183f220a0602439da45ea337311d699902d1ed11a3725a714e7f1f602052604090205460ff1690565b61103c576040517f9453980400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8b51611048908261122d565b50600101610eae565b505061106085858585856114a0565b505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416156111925773ffffffffffffffffffffffffffffffffffffffff83166110d4576040517f63ba9bff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff848116602483015283919086169063dd62ed3e90604401602060405180830381865afa158015611147573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061116b9190611e4d565b10156111925761119273ffffffffffffffffffffffffffffffffffffffff851684836116b7565b50505050565b5f385f3884865af16106515763b12d13eb5f526004601cfd5b81601452806034526fa9059cbb0000000000000000000000005f5260205f604460105f875af13d1560015f511417166111f1576390b8ec185f526004601cfd5b5f603452505050565b5f816014526f70a082310000000000000000000000005f5260208060246010865afa601f3d111660205102905092915050565b61124561123d6020830183611ae2565b6017903b1190565b61127b576040517f6eefed2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60808101355f8190036112ba576040517fe46e079c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112ce610ef06060850160408601611ae2565b6112d8575f6112de565b82608001355b90505f6112f96112f46080860160608701611ae2565b610cdb565b9050815f0361132f5761132f6113156060860160408701611ae2565b6113256040870160208801611ae2565b8660800135610bd4565b5f8061133e6020870187611ae2565b73ffffffffffffffffffffffffffffffffffffffff168461136260a0890189611d58565b604051611370929190611e64565b5f6040518083038185875af1925050503d805f81146113aa576040519150601f19603f3d011682016040523d82523d5f602084013e6113af565b606091505b5091509150816113c2576113c281611735565b5f6113d66112f46080890160608a01611ae2565b90507f7bfdfdb5e3a3776976e53cb0607060f54c5312701c8cba1155cc4d5394440b388861140760208a018a611ae2565b61141760608b0160408c01611ae2565b61142760808c0160608d01611ae2565b8b608001358987116114395786611443565b6114438a88611aaa565b6040805196875273ffffffffffffffffffffffffffffffffffffffff95861660208801529385169386019390935292166060840152608083019190915260a08201524260c082015260e00160405180910390a15050505050505050565b835f86826114af600182611aaa565b8181106114be576114be611cd6565b90506020028101906114d09190611d03565b6114e1906080810190606001611ae2565b90505f5f5f5f5f5f5f5b888110156116a7576114fe60018a611aaa565b8110801561150d575088600114155b156115e8578d8d8281811061152457611524611cd6565b90506020028101906115369190611d03565b611547906080810190606001611ae2565b95508773ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16146115e8578a818151811061158e5761158e611cd6565b602002602001015161159f87610cdb565b6115a99190611aaa565b965073ffffffffffffffffffffffffffffffffffffffff8616156115cd575f6115cf565b895b9350838711156115e8576115e8868d61032b878b611aaa565b8d8d828181106115fa576115fa611cd6565b905060200281019061160c9190611d03565b61161d906060810190604001611ae2565b945061162885610cdb565b925073ffffffffffffffffffffffffffffffffffffffff85161561164c575f61164e565b895b9150818311801561168b57508773ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b1561169f5761169f858d61032b8587611aaa565b6001016114eb565b5050505050505050505050505050565b81601452806034526f095ea7b30000000000000000000000005f5260205f604460105f875af13d1560015f511417166111f1575f6034526f095ea7b30000000000000000000000005f525f38604460105f875af1508060345260205f604460105f875af13d1560015f511417166111f157633e3f8f735f526004601cfd5b8051602082018181fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051610140810167ffffffffffffffff811182821017156117905761179061173f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156117dd576117dd61173f565b604052919050565b5f67ffffffffffffffff8211156117fe576117fe61173f565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b5f82601f830112611839575f5ffd5b813561184c611847826117e5565b611796565b818152846020838601011115611860575f5ffd5b816020850160208301375f918101602001919091529392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461189f575f5ffd5b919050565b8035801515811461189f575f5ffd5b5f61014082840312156118c4575f5ffd5b6118cc61176c565b823581529050602082013567ffffffffffffffff8111156118eb575f5ffd5b6118f78482850161182a565b602083015250604082013567ffffffffffffffff811115611916575f5ffd5b6119228482850161182a565b6040830152506119346060830161187c565b60608201526119456080830161187c565b608082015261195660a0830161187c565b60a082015260c0828101359082015260e0808301359082015261197c61010083016118a4565b61010082015261198f61012083016118a4565b61012082015292915050565b5f608082840312156119ab575f5ffd5b50919050565b5f5f60a083850312156119c2575f5ffd5b823567ffffffffffffffff8111156119d8575f5ffd5b6119e4858286016118b3565b9250506119f4846020850161199b565b90509250929050565b5f5f5f5f60c08587031215611a10575f5ffd5b843567ffffffffffffffff811115611a26575f5ffd5b611a32878288016118b3565b945050602085013567ffffffffffffffff811115611a4e575f5ffd5b8501601f81018713611a5e575f5ffd5b803567ffffffffffffffff811115611a74575f5ffd5b8760208260051b8401011115611a88575f5ffd5b60209190910193509150611a9f866040870161199b565b905092959194509250565b81810381811115610d1f577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f60208284031215611af2575f5ffd5b611afb8261187c565b9392505050565b5f60208284031215611b12575f5ffd5b815167ffffffffffffffff811115611b28575f5ffd5b8201601f81018413611b38575f5ffd5b8051611b46611847826117e5565b818152856020838501011115611b5a575f5ffd5b8160208401602083015e5f91810160200191909152949350505050565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b60208152815160208201525f60208301516101406040840152611bea610160840182611b77565b905060408401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848303016060850152611c258282611b77565b9150506060840151611c4f608085018273ffffffffffffffffffffffffffffffffffffffff169052565b50608084015173ffffffffffffffffffffffffffffffffffffffff811660a08501525060a084015173ffffffffffffffffffffffffffffffffffffffff811660c08501525060c084015160e084015260e0840151610100840152610100840151611cbe61012085018215159052565b50610120840151801515610140850152509392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21833603018112611d35575f5ffd5b9190910192915050565b5f60208284031215611d4f575f5ffd5b611afb826118a4565b5f5f83357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112611d8b575f5ffd5b83018035915067ffffffffffffffff821115611da5575f5ffd5b602001915036819003821315611db9575f5ffd5b9250929050565b5f5f85851115611dce575f5ffd5b83861115611dda575f5ffd5b5050820193919092039150565b80357fffffffff000000000000000000000000000000000000000000000000000000008116906004841015611e46577fffffffff00000000000000000000000000000000000000000000000000000000808560040360031b1b82161691505b5092915050565b5f60208284031215611e5d575f5ffd5b5051919050565b818382375f910190815291905056fea2646970667358221220d677b2904c8d00141befcaa89999821ed8cdd263bc0a54027ace8a83ecbd4edf64736f6c634300081d0033000000000000000000000000290d54179960984599f16f77dcda81320301b158
Deployed Bytecode
0x608060405260043610610033575f3560e01c80636f9206ba146100375780639c4b6dd91461004c578063bbbf77d51461005f575b5f5ffd5b61004a6100453660046119b1565b6100bb565b005b61004a61005a3660046119fd565b61033b565b34801561006a575f5ffd5b506100927f000000000000000000000000290d54179960984599f16f77dcda81320301b15881565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610136576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018155335f6101463447611aaa565b90508461016b8160a0015173ffffffffffffffffffffffffffffffffffffffff161590565b156101a2576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060c001515f036101df576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b468160e001510361021c576040517f4ac09ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b858061010001511561025a576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8680610120015115610298576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b876102bb816080015173ffffffffffffffffffffffffffffffffffffffff161590565b156102f2576040517f5ded599700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61030489608001518a60c001516105c3565b61030e8989610677565b50479250505081811115610330576103305f8461032b8585611aaa565b6109ad565b50505f909155505050565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016103b6576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018155335f6103c63447611aaa565b905086806101000151610405576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8780610120015115610443576040517f50dc905c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b886104668160a0015173ffffffffffffffffffffffffffffffffffffffff161590565b1561049d576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060c001515f036104da576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b468160e0015103610517576040517f4ac09ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8961053a816080015173ffffffffffffffffffffffffffffffffffffffff161590565b15610571576040517f5ded599700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61058a8b5f01518c60c001518c8c338d604001356109e2565b60c08c01526105998b89610677565b504792505050818111156105b6576105b65f8461032b8585611aaa565b50505f9091555050505050565b805f036105fc576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166106555780341015610651576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b61065173ffffffffffffffffffffffffffffffffffffffff8316333084610b7c565b7311f111f111f111f111f111f111f111f111f111f173ffffffffffffffffffffffffffffffffffffffff168260a0015173ffffffffffffffffffffffffffffffffffffffff160361073a5780356106fa576040517f58b0510000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60e08201518251604051833581527f815cd8dc72093a13fe3577112c391b6279303956526382ab98772d0239dbf78c9060200160405180910390a36107a8565b805f01355f1c73ffffffffffffffffffffffffffffffffffffffff168260a0015173ffffffffffffffffffffffffffffffffffffffff16146107a8576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107b96040830160208401611ae2565b73ffffffffffffffffffffffffffffffffffffffff1603610806576040517f1c49f4d100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61083982608001517f000000000000000000000000290d54179960984599f16f77dcda81320301b1588460c00151610bd4565b608082015160c083015160e084015173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000290d54179960984599f16f77dcda81320301b1581692631f9cd527926040860180359387359161089d9060208a01611ae2565b60405160e088901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff95861660048201526024810194909452604484019290925260648301529091166084820152606085013560a482015260c4015f6040518083038185885af115801561092b573d5f5f3e3d5ffd5b50505050506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526109719190810190611b02565b507fcba69f43792f9f399347222505213b55af8e0b0b54b893085c2e27ecbe1644f1826040516109a19190611bc3565b60405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff83166109d7576109d28282610c00565b505050565b6109d2838383610c6d565b5f83808203610a1d576040517f0503c3ed00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8686610a2b600185611aaa565b818110610a3a57610a3a611cd6565b9050602002810190610a4c9190611d03565b610a5d906080810190606001611ae2565b90505f610a6982610cdb565b905073ffffffffffffffffffffffffffffffffffffffff8216610a9357610a903482611aaa565b90505b5f610a9e8989610d25565b9050610aaa8989610e2f565b604080516060810182528c815273ffffffffffffffffffffffffffffffffffffffff89166020820152908101879052610ae5818b8b85610e9b565b5f83610af086610cdb565b610afa9190611aaa565b905073ffffffffffffffffffffffffffffffffffffffff8516610b2457610b218882611aaa565b90505b8b811015610b6c576040517f275c273c000000000000000000000000000000000000000000000000000000008152600481018d90526024810182905260440160405180910390fd5b9c9b505050505050505050505050565b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c5260205f6064601c5f895af13d1560015f51141716610bc757637939f4245f526004601cfd5b5f60605260405250505050565b6109d28383837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61106b565b73ffffffffffffffffffffffffffffffffffffffff8216610c4d576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61065173ffffffffffffffffffffffffffffffffffffffff831682611198565b73ffffffffffffffffffffffffffffffffffffffff8216610cba576040517f1e4ec46b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109d273ffffffffffffffffffffffffffffffffffffffff841683836111b1565b5f73ffffffffffffffffffffffffffffffffffffffff821615610d1d57610d1873ffffffffffffffffffffffffffffffffffffffff8316306111fa565b610d1f565b475b92915050565b6060815f8167ffffffffffffffff811115610d4257610d4261173f565b604051908082528060200260200182016040528015610d6b578160200160208202803683370190505b5090505f5f5b83811015610e2457868682818110610d8b57610d8b611cd6565b9050602002810190610d9d9190611d03565b610dae906080810190606001611ae2565b9150610db982610cdb565b838281518110610dcb57610dcb611cd6565b602090810291909101015273ffffffffffffffffffffffffffffffffffffffff8216610e1c5734838281518110610e0457610e04611cd6565b60200260200101818151610e189190611aaa565b9052505b600101610d71565b509095945050505050565b5f5b818110156109d25736838383818110610e4c57610e4c611cd6565b9050602002810190610e5e9190611d03565b9050610e7060e0820160c08301611d3f565b15610e9257610e92610e886060830160408401611ae2565b82608001356105c3565b50600101610e31565b60208401516040850151849184918490835f5b8181101561105157368a8a83818110610ec957610ec9611cd6565b9050602002810190610edb9190611d03565b9050610f0a610ef06060830160408401611ae2565b73ffffffffffffffffffffffffffffffffffffffff161590565b80610f6c5750610f6c610f236040830160208401611ae2565b73ffffffffffffffffffffffffffffffffffffffff165f9081527f7a8ac5d3b7183f220a0602439da45ea337311d699902d1ed11a3725a714e7f1e602052604090205460ff1690565b8015610f835750610f83610f236020830183611ae2565b80156110065750611006610f9a60a0830183611d58565b610fa8916004915f91611dc0565b610fb191611de7565b7fffffffff00000000000000000000000000000000000000000000000000000000165f9081527f7a8ac5d3b7183f220a0602439da45ea337311d699902d1ed11a3725a714e7f1f602052604090205460ff1690565b61103c576040517f9453980400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8b51611048908261122d565b50600101610eae565b505061106085858585856114a0565b505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416156111925773ffffffffffffffffffffffffffffffffffffffff83166110d4576040517f63ba9bff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff848116602483015283919086169063dd62ed3e90604401602060405180830381865afa158015611147573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061116b9190611e4d565b10156111925761119273ffffffffffffffffffffffffffffffffffffffff851684836116b7565b50505050565b5f385f3884865af16106515763b12d13eb5f526004601cfd5b81601452806034526fa9059cbb0000000000000000000000005f5260205f604460105f875af13d1560015f511417166111f1576390b8ec185f526004601cfd5b5f603452505050565b5f816014526f70a082310000000000000000000000005f5260208060246010865afa601f3d111660205102905092915050565b61124561123d6020830183611ae2565b6017903b1190565b61127b576040517f6eefed2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60808101355f8190036112ba576040517fe46e079c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112ce610ef06060850160408601611ae2565b6112d8575f6112de565b82608001355b90505f6112f96112f46080860160608701611ae2565b610cdb565b9050815f0361132f5761132f6113156060860160408701611ae2565b6113256040870160208801611ae2565b8660800135610bd4565b5f8061133e6020870187611ae2565b73ffffffffffffffffffffffffffffffffffffffff168461136260a0890189611d58565b604051611370929190611e64565b5f6040518083038185875af1925050503d805f81146113aa576040519150601f19603f3d011682016040523d82523d5f602084013e6113af565b606091505b5091509150816113c2576113c281611735565b5f6113d66112f46080890160608a01611ae2565b90507f7bfdfdb5e3a3776976e53cb0607060f54c5312701c8cba1155cc4d5394440b388861140760208a018a611ae2565b61141760608b0160408c01611ae2565b61142760808c0160608d01611ae2565b8b608001358987116114395786611443565b6114438a88611aaa565b6040805196875273ffffffffffffffffffffffffffffffffffffffff95861660208801529385169386019390935292166060840152608083019190915260a08201524260c082015260e00160405180910390a15050505050505050565b835f86826114af600182611aaa565b8181106114be576114be611cd6565b90506020028101906114d09190611d03565b6114e1906080810190606001611ae2565b90505f5f5f5f5f5f5f5b888110156116a7576114fe60018a611aaa565b8110801561150d575088600114155b156115e8578d8d8281811061152457611524611cd6565b90506020028101906115369190611d03565b611547906080810190606001611ae2565b95508773ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16146115e8578a818151811061158e5761158e611cd6565b602002602001015161159f87610cdb565b6115a99190611aaa565b965073ffffffffffffffffffffffffffffffffffffffff8616156115cd575f6115cf565b895b9350838711156115e8576115e8868d61032b878b611aaa565b8d8d828181106115fa576115fa611cd6565b905060200281019061160c9190611d03565b61161d906060810190604001611ae2565b945061162885610cdb565b925073ffffffffffffffffffffffffffffffffffffffff85161561164c575f61164e565b895b9150818311801561168b57508773ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b1561169f5761169f858d61032b8587611aaa565b6001016114eb565b5050505050505050505050505050565b81601452806034526f095ea7b30000000000000000000000005f5260205f604460105f875af13d1560015f511417166111f1575f6034526f095ea7b30000000000000000000000005f525f38604460105f875af1508060345260205f604460105f875af13d1560015f511417166111f157633e3f8f735f526004601cfd5b8051602082018181fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051610140810167ffffffffffffffff811182821017156117905761179061173f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156117dd576117dd61173f565b604052919050565b5f67ffffffffffffffff8211156117fe576117fe61173f565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b5f82601f830112611839575f5ffd5b813561184c611847826117e5565b611796565b818152846020838601011115611860575f5ffd5b816020850160208301375f918101602001919091529392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461189f575f5ffd5b919050565b8035801515811461189f575f5ffd5b5f61014082840312156118c4575f5ffd5b6118cc61176c565b823581529050602082013567ffffffffffffffff8111156118eb575f5ffd5b6118f78482850161182a565b602083015250604082013567ffffffffffffffff811115611916575f5ffd5b6119228482850161182a565b6040830152506119346060830161187c565b60608201526119456080830161187c565b608082015261195660a0830161187c565b60a082015260c0828101359082015260e0808301359082015261197c61010083016118a4565b61010082015261198f61012083016118a4565b61012082015292915050565b5f608082840312156119ab575f5ffd5b50919050565b5f5f60a083850312156119c2575f5ffd5b823567ffffffffffffffff8111156119d8575f5ffd5b6119e4858286016118b3565b9250506119f4846020850161199b565b90509250929050565b5f5f5f5f60c08587031215611a10575f5ffd5b843567ffffffffffffffff811115611a26575f5ffd5b611a32878288016118b3565b945050602085013567ffffffffffffffff811115611a4e575f5ffd5b8501601f81018713611a5e575f5ffd5b803567ffffffffffffffff811115611a74575f5ffd5b8760208260051b8401011115611a88575f5ffd5b60209190910193509150611a9f866040870161199b565b905092959194509250565b81810381811115610d1f577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f60208284031215611af2575f5ffd5b611afb8261187c565b9392505050565b5f60208284031215611b12575f5ffd5b815167ffffffffffffffff811115611b28575f5ffd5b8201601f81018413611b38575f5ffd5b8051611b46611847826117e5565b818152856020838501011115611b5a575f5ffd5b8160208401602083015e5f91810160200191909152949350505050565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b60208152815160208201525f60208301516101406040840152611bea610160840182611b77565b905060408401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848303016060850152611c258282611b77565b9150506060840151611c4f608085018273ffffffffffffffffffffffffffffffffffffffff169052565b50608084015173ffffffffffffffffffffffffffffffffffffffff811660a08501525060a084015173ffffffffffffffffffffffffffffffffffffffff811660c08501525060c084015160e084015260e0840151610100840152610100840151611cbe61012085018215159052565b50610120840151801515610140850152509392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21833603018112611d35575f5ffd5b9190910192915050565b5f60208284031215611d4f575f5ffd5b611afb826118a4565b5f5f83357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112611d8b575f5ffd5b83018035915067ffffffffffffffff821115611da5575f5ffd5b602001915036819003821315611db9575f5ffd5b9250929050565b5f5f85851115611dce575f5ffd5b83861115611dda575f5ffd5b5050820193919092039150565b80357fffffffff000000000000000000000000000000000000000000000000000000008116906004841015611e46577fffffffff00000000000000000000000000000000000000000000000000000000808560040360031b1b82161691505b5092915050565b5f60208284031215611e5d575f5ffd5b5051919050565b818382375f910190815291905056fea2646970667358221220d677b2904c8d00141befcaa89999821ed8cdd263bc0a54027ace8a83ecbd4edf64736f6c634300081d0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
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.