Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 107558362 | 927 days ago | 0.000371220274098 ETH | ||||
| 107558354 | 927 days ago | 0.000480690044498 ETH | ||||
| 107558343 | 927 days ago | 0 ETH | ||||
| 107558343 | 927 days ago | 0 ETH | ||||
| 107558325 | 927 days ago | 0 ETH | ||||
| 107558325 | 927 days ago | 0 ETH | ||||
| 107558325 | 927 days ago | 0 ETH | ||||
| 107558323 | 927 days ago | 0 ETH | ||||
| 107558323 | 927 days ago | 0 ETH | ||||
| 107558256 | 927 days ago | 0 ETH | ||||
| 107558256 | 927 days ago | 0 ETH | ||||
| 107558208 | 927 days ago | 0 ETH | ||||
| 107558208 | 927 days ago | 0 ETH | ||||
| 107558168 | 927 days ago | 0 ETH | ||||
| 107558168 | 927 days ago | 0.000470947144498 ETH | ||||
| 107558095 | 927 days ago | 0 ETH | ||||
| 107558095 | 927 days ago | 0.000995991962897 ETH | ||||
| 107558020 | 927 days ago | 0 ETH | ||||
| 107558020 | 927 days ago | 0 ETH | ||||
| 107558020 | 927 days ago | 0 ETH | ||||
| 107558002 | 927 days ago | 0.000550007206706 ETH | ||||
| 107558002 | 927 days ago | 0 ETH | ||||
| 107558002 | 927 days ago | 0 ETH | ||||
| 107557993 | 927 days ago | 0 ETH | ||||
| 107557993 | 927 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
StargateFacet
Compiler Version
v0.8.13+commit.abaa5c0e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;
import "SafeMath.sol";
import "LibAsset.sol";
import "ISo.sol";
import "ICorrectSwap.sol";
import "IStargate.sol";
import "IStargateFactory.sol";
import "IStargatePool.sol";
import "IStargateFeeLibrary.sol";
import "IStargateReceiver.sol";
import "LibDiamond.sol";
import "ReentrancyGuard.sol";
import "GenericErrors.sol";
import "Swapper.sol";
import "IStargateEthVault.sol";
import "ILibSoFee.sol";
import "LibCross.sol";
import "LibBytes.sol";
/// @title Stargate Facet
/// @author OmniBTC
/// @notice Provides functionality for bridging through Stargate
contract StargateFacet is Swapper, ReentrancyGuard, IStargateReceiver {
using SafeMath for uint256;
using LibBytes for bytes;
/// Storage ///
bytes32 internal constant NAMESPACE =
hex"2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d1"; //keccak256("com.so.facets.stargate");
// Data delimiter, represent ";"
uint8 public constant INTERDELIMITER = 59;
struct Storage {
address stargate; // The stargate route address
uint16 srcStargateChainId; // The stargate chain id of the source/current chain
mapping(address => bool) allowedList; // Permission to allow calls to sgReceive
}
/// Types ///
struct StargateData {
uint256 srcStargatePoolId; // The stargate pool id of the source chain
uint16 dstStargateChainId; // The stargate chain id of the destination chain
uint256 dstStargatePoolId; // The stargate pool id of the destination chain
uint256 minAmount; // The stargate min amount
uint256 dstGasForSgReceive; // destination gas for sgReceive
address payable dstSoDiamond; // destination SoDiamond address
}
struct CachePayload {
ISo.NormalizedSoData soData;
LibSwap.NormalizedSwapData[] swapDataDst;
}
/// Events ///
event StargateInitialized(address stargate, uint256 chainId);
event SetAllowedList(address router, bool isAllowed);
/// Init ///
/// @notice Initializes local variables for the Stargate facet
/// @param stargate address of the canonical Stargate router contract
/// @param chainId chainId of this deployed contract
function initStargate(address stargate, uint16 chainId) external {
LibDiamond.enforceIsContractOwner();
if (stargate == address(0)) revert InvalidConfig();
Storage storage s = getStorage();
s.stargate = stargate;
s.srcStargateChainId = chainId;
s.allowedList[stargate] = true;
s.allowedList[msg.sender] = true;
emit StargateInitialized(stargate, chainId);
}
/// @dev Set permissions to control calls to sgReceive
function setAllowedAddress(address router, bool isAllowed) external {
LibDiamond.enforceIsContractOwner();
Storage storage s = getStorage();
s.allowedList[router] = isAllowed;
emit SetAllowedList(router, isAllowed);
}
/// External Methods ///
/// @notice Bridges tokens via Stargate
/// @param soDataNo Data for tracking cross-chain transactions and a
/// portion of the accompanying cross-chain messages
/// @param swapDataSrcNo Contains a set of data required for Swap
/// transactions on the source chain side
/// @param stargateData Data used to call Stargate's router for swap
/// @param swapDataDstNo Contains a set of Swap transaction data executed
/// on the target chain.
function soSwapViaStargate(
ISo.NormalizedSoData calldata soDataNo,
LibSwap.NormalizedSwapData[] calldata swapDataSrcNo,
StargateData calldata stargateData,
LibSwap.NormalizedSwapData[] calldata swapDataDstNo
) external payable nonReentrant {
uint256 bridgeAmount;
ISo.SoData memory soData = LibCross.denormalizeSoData(soDataNo);
LibSwap.SwapData[] memory swapDataSrc = LibCross.denormalizeSwapData(
swapDataSrcNo
);
if (!LibAsset.isNativeAsset(soData.sendingAssetId)) {
LibAsset.depositAsset(soData.sendingAssetId, soData.amount);
}
if (swapDataSrc.length == 0) {
transferWrappedAsset(
soData.sendingAssetId,
_getStargateTokenByPoolId(stargateData.srcStargatePoolId),
soData.amount
);
bridgeAmount = soData.amount;
} else {
require(soData.amount == swapDataSrc[0].fromAmount, "AmountErr");
bridgeAmount = this.executeAndCheckSwaps(soData, swapDataSrc);
transferWrappedAsset(
swapDataSrc[swapDataSrc.length - 1].receivingAssetId,
_getStargateTokenByPoolId(stargateData.srcStargatePoolId),
bridgeAmount
);
}
uint256 stargateValue = _getStargateValue(soData);
bytes memory payload = encodeStargatePayload(soDataNo, swapDataDstNo);
_startBridge(stargateData, stargateValue, bridgeAmount, payload);
emit SoTransferStarted(soData.transactionId);
}
/// @dev Overload sgReceive of IStargateReceiver, called by stargate router
function sgReceive(
uint16,
bytes memory,
uint256,
address token,
uint256 amount,
bytes memory payload
) external {
Storage storage s = getStorage();
require(s.allowedList[msg.sender], "No permission");
if (LibAsset.getOwnBalance(token) < amount) {
// judge eth
require(
!IStargateEthVault(token).noUnwrapTo(address(this)),
"TokenErr"
);
require(
LibAsset.getOwnBalance(LibAsset.NATIVE_ASSETID) >= amount,
"NotEnough"
);
token = LibAsset.NATIVE_ASSETID;
}
(
ISo.NormalizedSoData memory soDataNo,
LibSwap.NormalizedSwapData[] memory swapDataDstNo
) = decodeStargatePayload(payload);
ISo.SoData memory soData = LibCross.denormalizeSoData(soDataNo);
LibSwap.SwapData[] memory swapDataDst = LibCross.denormalizeSwapData(
swapDataDstNo
);
if (gasleft() < getTransferGas()) revert("Not enough gas!");
uint256 swapGas = gasleft().sub(getTransferGas());
try
this.remoteSoSwap{gas: swapGas}(token, amount, soData, swapDataDst)
{} catch Error(string memory revertReason) {
transferUnwrappedAsset(token, token, amount, soData.receiver);
emit SoTransferFailed(
soData.transactionId,
revertReason,
bytes("")
);
} catch (bytes memory returnData) {
transferUnwrappedAsset(token, token, amount, soData.receiver);
emit SoTransferFailed(soData.transactionId, "", returnData);
}
}
/// @dev For internal calls only, do not add it to DiamondCut,
/// convenient for sgReceive to catch exceptions
function remoteSoSwap(
address token,
uint256 amount,
ISo.SoData calldata soData,
LibSwap.SwapData[] memory swapDataDst
) external {
require(msg.sender == address(this), "NotDiamond");
uint256 soFee = getStargateSoFee(amount);
if (soFee < amount) {
amount = amount.sub(soFee);
}
if (swapDataDst.length == 0) {
if (soFee > 0) {
transferUnwrappedAsset(
token,
soData.receivingAssetId,
soFee,
LibDiamond.contractOwner()
);
}
transferUnwrappedAsset(
token,
soData.receivingAssetId,
amount,
soData.receiver
);
emit SoTransferCompleted(soData.transactionId, amount);
} else {
if (soFee > 0) {
transferUnwrappedAsset(
token,
swapDataDst[0].sendingAssetId,
soFee,
LibDiamond.contractOwner()
);
}
transferUnwrappedAsset(
token,
swapDataDst[0].sendingAssetId,
amount,
address(this)
);
swapDataDst[0].fromAmount = amount;
address correctSwap = appStorage.correctSwapRouterSelectors;
if (correctSwap != address(0)) {
swapDataDst[0].callData = ICorrectSwap(correctSwap).correctSwap(
swapDataDst[0].callData,
swapDataDst[0].fromAmount
);
}
uint256 amountFinal = this.executeAndCheckSwaps(
soData,
swapDataDst
);
transferUnwrappedAsset(
swapDataDst[swapDataDst.length - 1].receivingAssetId,
soData.receivingAssetId,
amountFinal,
soData.receiver
);
emit SoTransferCompleted(soData.transactionId, amountFinal);
}
}
/// @dev Simplifies evaluation of the target chain calls sgReceive's
/// gas to facilitate building applications in the upper layers.
function sgReceiveForGas(
ISo.NormalizedSoData calldata soDataNo,
uint256 dstStargatePoolId,
LibSwap.NormalizedSwapData[] calldata swapDataDstNo
) external {
address token = _getStargateTokenByPoolId(dstStargatePoolId);
uint256 amount = LibAsset.getOwnBalance(token);
if (amount == 0) {
// judge eth
require(
!IStargateEthVault(token).noUnwrapTo(address(this)),
"TokenErr"
);
token = LibAsset.NATIVE_ASSETID;
amount = LibAsset.getOwnBalance(token);
}
amount = amount.div(10);
require(amount > 0, "LittleAmount");
bytes memory payload = getSgReceiveForGasPayload(
soDataNo,
swapDataDstNo
);
// monitor sgReceive
if (LibAsset.getOwnBalance(token) < amount) {
require(
!IStargateEthVault(token).noUnwrapTo(address(this)),
"TokenErr"
);
require(
LibAsset.getOwnBalance(LibAsset.NATIVE_ASSETID) >= amount,
"NotEnough"
);
token = LibAsset.NATIVE_ASSETID;
}
(
ISo.NormalizedSoData memory _soDataNo,
LibSwap.NormalizedSwapData[] memory _swapDataDstNo
) = decodeStargatePayload(payload);
ISo.SoData memory soData = LibCross.denormalizeSoData(_soDataNo);
// Not allow transfer to other
soData.receiver = payable(address(this));
LibSwap.SwapData[] memory swapDataDst = LibCross.denormalizeSwapData(
_swapDataDstNo
);
if (gasleft() < getTransferGas()) revert("Not enough gas!");
uint256 swapGas = gasleft().sub(getTransferGas());
this.remoteSoSwap{gas: swapGas}(token, amount, soData, swapDataDst);
}
/// @dev Used to obtain stargate cross-chain fee
function getStargateFee(
ISo.NormalizedSoData calldata soDataNo,
StargateData calldata stargateData,
LibSwap.NormalizedSwapData[] calldata swapDataDstNo
) external view returns (uint256) {
bytes memory payload = encodeStargatePayload(soDataNo, swapDataDstNo);
Storage storage s = getStorage();
IStargate.lzTxObj memory lzTxParams = IStargate.lzTxObj(
stargateData.dstGasForSgReceive,
0,
bytes("")
);
(uint256 stargateFee, ) = IStargate(s.stargate).quoteLayerZeroFee(
stargateData.dstStargateChainId,
1,
abi.encodePacked(stargateData.dstSoDiamond),
payload,
lzTxParams
);
return stargateFee;
}
/// @dev Estimate the number of tokens that stargate can get
function estimateStargateFinalAmount(
StargateData calldata stargateData,
uint256 amount
) external view returns (uint256) {
uint256 amountSD = _convertStargateLDToSDByPoolId(
stargateData.srcStargatePoolId,
amount
);
IStargatePool.SwapObj memory swapObj = IStargateFeeLibrary(
_getStargateFeeLibraryByPoolId(stargateData.srcStargatePoolId)
).getFees(
stargateData.srcStargatePoolId,
stargateData.dstStargatePoolId,
stargateData.dstStargateChainId,
address(0x0),
amountSD
);
uint256 estimateAmountSD = amountSD
.sub(swapObj.eqFee)
.sub(swapObj.protocolFee)
.sub(swapObj.lpFee)
.add(swapObj.eqReward);
return
_convertStargateSDToLDByPoolId(
stargateData.srcStargatePoolId,
estimateAmountSD
);
}
/// Public Methods ///
/// @dev Get so fee
function getStargateSoFee(uint256 amount) public view returns (uint256) {
Storage storage s = getStorage();
address soFee = appStorage.gatewaySoFeeSelectors[s.stargate];
if (soFee == address(0x0)) {
return 0;
} else {
return ILibSoFee(soFee).getFees(amount);
}
}
/// @dev Get amount from stargate before so fee
function getAmountBeforeSoFee(uint256 amount)
public
view
returns (uint256)
{
Storage storage s = getStorage();
address soFee = appStorage.gatewaySoFeeSelectors[s.stargate];
if (soFee == address(0x0)) {
return amount;
} else {
return ILibSoFee(soFee).getRestoredAmount(amount);
}
}
/// @dev Get remain gas for transfer
function getTransferGas() public view returns (uint256) {
Storage storage s = getStorage();
address soFee = appStorage.gatewaySoFeeSelectors[s.stargate];
if (soFee == address(0x0)) {
return 30000;
} else {
return ILibSoFee(soFee).getTransferForGas();
}
}
/// @dev Get SgReceive for gas payload
function getSgReceiveForGasPayload(
ISo.NormalizedSoData calldata soDataNo,
LibSwap.NormalizedSwapData[] calldata swapDataDstNo
) public pure returns (bytes memory) {
return encodeStargatePayload(soDataNo, swapDataDstNo);
}
/// CrossData
// 1. length + transactionId(SoData)
// 2. length + receiver(SoData)
// 3. length + receivingAssetId(SoData)
// 4. length + swapDataLength(u8)
// 5. length + callTo(SwapData)
// 6. length + sendingAssetId(SwapData)
// 7. length + receivingAssetId(SwapData)
// 8. length + callData(SwapData)
function encodeStargatePayload(
ISo.NormalizedSoData memory soData,
LibSwap.NormalizedSwapData[] memory swapDataDst
) public pure returns (bytes memory) {
bytes memory encodeData = abi.encodePacked(
uint8(soData.transactionId.length),
soData.transactionId,
uint8(soData.receiver.length),
soData.receiver,
uint8(soData.receivingAssetId.length),
soData.receivingAssetId
);
if (swapDataDst.length > 0) {
bytes memory swapLenBytes = LibCross.serializeU256WithHexStr(
swapDataDst.length
);
encodeData = encodeData.concat(
abi.encodePacked(uint8(swapLenBytes.length), swapLenBytes)
);
}
for (uint256 i = 0; i < swapDataDst.length; i++) {
encodeData = encodeData.concat(
abi.encodePacked(
uint8(swapDataDst[i].callTo.length),
swapDataDst[i].callTo,
uint8(swapDataDst[i].sendingAssetId.length),
swapDataDst[i].sendingAssetId,
uint8(swapDataDst[i].receivingAssetId.length),
swapDataDst[i].receivingAssetId,
uint16(swapDataDst[i].callData.length),
swapDataDst[i].callData
)
);
}
return encodeData;
}
/// CrossData
// 1. length + transactionId(SoData)
// 2. length + receiver(SoData)
// 3. length + receivingAssetId(SoData)
// 4. length + swapDataLength(u8)
// 5. length + callTo(SwapData)
// 6. length + sendingAssetId(SwapData)
// 7. length + receivingAssetId(SwapData)
// 8. length + callData(SwapData)
function decodeStargatePayload(bytes memory stargatePayload)
public
pure
returns (
ISo.NormalizedSoData memory soData,
LibSwap.NormalizedSwapData[] memory swapDataDst
)
{
CachePayload memory data;
uint256 index;
uint256 nextLen;
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
data.soData.transactionId = stargatePayload.slice(index, nextLen);
index += nextLen;
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
data.soData.receiver = stargatePayload.slice(index, nextLen);
index += nextLen;
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
data.soData.receivingAssetId = stargatePayload.slice(index, nextLen);
index += nextLen;
if (index < stargatePayload.length) {
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
uint256 swap_len = LibCross.deserializeU256WithHexStr(
stargatePayload.slice(index, nextLen)
);
index += nextLen;
data.swapDataDst = new LibSwap.NormalizedSwapData[](swap_len);
for (uint256 i = 0; i < swap_len; i++) {
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
data.swapDataDst[i].callTo = stargatePayload.slice(
index,
nextLen
);
data.swapDataDst[i].approveTo = data.swapDataDst[i].callTo;
index += nextLen;
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
data.swapDataDst[i].sendingAssetId = stargatePayload.slice(
index,
nextLen
);
index += nextLen;
nextLen = uint256(stargatePayload.toUint8(index));
index += 1;
data.swapDataDst[i].receivingAssetId = stargatePayload.slice(
index,
nextLen
);
index += nextLen;
nextLen = uint256(stargatePayload.toUint16(index));
index += 2;
data.swapDataDst[i].callData = stargatePayload.slice(
index,
nextLen
);
index += nextLen;
}
}
require(index == stargatePayload.length, "LenErr");
return (data.soData, data.swapDataDst);
}
/// Private Methods ///
/// @dev Conatains the business logic for the bridge via Stargate
function _startBridge(
StargateData calldata stargateData,
uint256 stargateValue,
uint256 bridgeAmount,
bytes memory payload
) private {
Storage storage s = getStorage();
address bridge = s.stargate;
// Do Stargate stuff
if (s.srcStargateChainId == stargateData.dstStargateChainId)
revert CannotBridgeToSameNetwork();
// Give Stargate approval to bridge tokens
LibAsset.maxApproveERC20(
IERC20(_getStargateTokenByPoolId(stargateData.srcStargatePoolId)),
bridge,
bridgeAmount
);
IStargate.lzTxObj memory lzTxParams = IStargate.lzTxObj(
stargateData.dstGasForSgReceive,
0,
bytes("")
);
bytes memory to = abi.encodePacked(stargateData.dstSoDiamond);
IStargate(bridge).swap{value: stargateValue}(
stargateData.dstStargateChainId,
stargateData.srcStargatePoolId,
stargateData.dstStargatePoolId,
payable(msg.sender),
bridgeAmount,
stargateData.minAmount,
lzTxParams,
to,
payload
);
}
/// @dev Calculate the fee for paying the stargate bridge
function _getStargateValue(SoData memory soData)
private
view
returns (uint256)
{
if (LibAsset.isNativeAsset(soData.sendingAssetId)) {
require(msg.value > soData.amount, "NotEnough");
return msg.value.sub(soData.amount);
} else {
return msg.value;
}
}
/// @dev Get stargate pool address by poolId
function _getStargatePoolByPoolId(uint256 poolId)
private
view
returns (address)
{
Storage storage s = getStorage();
address factory = IStargate(s.stargate).factory();
return IStargateFactory(factory).getPool(poolId);
}
/// @dev Get stargate bridge token address by poolId
function _getStargateTokenByPoolId(uint256 poolId)
private
view
returns (address)
{
return IStargatePool(_getStargatePoolByPoolId(poolId)).token();
}
/// @dev Get stargate bridge fee library address by poolId
function _getStargateFeeLibraryByPoolId(uint256 poolId)
private
view
returns (address)
{
return IStargatePool(_getStargatePoolByPoolId(poolId)).feeLibrary();
}
/// @dev Get stargate convert rate by poolId
function _getStargateConvertRateByPoolId(uint256 poolId)
private
view
returns (uint256)
{
return IStargatePool(_getStargatePoolByPoolId(poolId)).convertRate();
}
/// @dev Get stargate convert LD to SD poolId
function _convertStargateLDToSDByPoolId(uint256 poolId, uint256 amount)
private
view
returns (uint256)
{
return amount.div(_getStargateConvertRateByPoolId(poolId));
}
/// @dev Get stargate convert SD to LD poolId
function _convertStargateSDToLDByPoolId(uint256 poolId, uint256 amount)
private
view
returns (uint256)
{
return amount.mul(_getStargateConvertRateByPoolId(poolId));
}
/// @dev fetch local storage
function getStorage() private pure returns (Storage storage s) {
bytes32 namespace = NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
s.slot := namespace
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;
import {NullAddrIsNotAnERC20Token, NullAddrIsNotAValidSpender, NoTransferToNullAddress, InvalidAmount, NativeValueWithERC, NativeAssetTransferFailed} from "GenericErrors.sol";
import "SafeERC20.sol";
import "IERC20.sol";
/// @title LibAsset
/// @author Connext <[email protected]>
/// @notice This library contains helpers for dealing with onchain transfers
/// of assets, including accounting for the native asset `assetId`
/// conventions and any noncompliant ERC20 transfers
library LibAsset {
uint256 private constant MAX_INT = type(uint256).max;
address internal constant NULL_ADDRESS =
0x0000000000000000000000000000000000000000; //address(0)
/// @dev All native assets use the empty address for their asset id
/// by convention
address internal constant NATIVE_ASSETID = NULL_ADDRESS; //address(0)
/// @notice Gets the balance of the inheriting contract for the given asset
/// @param assetId The asset identifier to get the balance of
/// @return Balance held by contracts using this library
function getOwnBalance(address assetId) internal view returns (uint256) {
return
assetId == NATIVE_ASSETID
? address(this).balance
: IERC20(assetId).balanceOf(address(this));
}
/// @notice Transfers ether from the inheriting contract to a given
/// recipient
/// @param recipient Address to send ether to
/// @param amount Amount to send to given recipient
function transferNativeAsset(address payable recipient, uint256 amount)
private
{
if (recipient == NULL_ADDRESS) revert NoTransferToNullAddress();
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = recipient.call{value: amount}("");
if (!success) revert NativeAssetTransferFailed();
}
/// @notice Gives MAX approval for another address to spend tokens
/// @param assetId Token address to transfer
/// @param spender Address to give spend approval to
/// @param amount Amount to approve for spending
function maxApproveERC20(
IERC20 assetId,
address spender,
uint256 amount
) internal {
if (address(assetId) == NATIVE_ASSETID) return;
if (spender == NULL_ADDRESS) revert NullAddrIsNotAValidSpender();
uint256 allowance = assetId.allowance(address(this), spender);
if (allowance < amount)
SafeERC20.safeApprove(IERC20(assetId), spender, MAX_INT);
}
/// @notice Transfers tokens from the inheriting contract to a given
/// recipient
/// @param assetId Token address to transfer
/// @param recipient Address to send token to
/// @param amount Amount to send to given recipient
function transferERC20(
address assetId,
address recipient,
uint256 amount
) private {
if (isNativeAsset(assetId)) revert NullAddrIsNotAnERC20Token();
SafeERC20.safeTransfer(IERC20(assetId), recipient, amount);
}
/// @notice Transfers tokens from a sender to a given recipient
/// @param assetId Token address to transfer
/// @param from Address of sender/owner
/// @param to Address of recipient/spender
/// @param amount Amount to transfer from owner to spender
function transferFromERC20(
address assetId,
address from,
address to,
uint256 amount
) internal {
if (assetId == NATIVE_ASSETID) revert NullAddrIsNotAnERC20Token();
if (to == NULL_ADDRESS) revert NoTransferToNullAddress();
SafeERC20.safeTransferFrom(IERC20(assetId), from, to, amount);
}
/// @notice Deposits an asset into the contract and performs checks to avoid NativeValueWithERC
/// @param tokenId Token to deposit
/// @param amount Amount to deposit
/// @param isNative Wether the token is native or ERC20
function depositAsset(
address tokenId,
uint256 amount,
bool isNative
) internal {
if (amount == 0) revert InvalidAmount();
if (isNative) {
if (msg.value != amount) revert InvalidAmount();
} else {
// if (msg.value != 0) revert NativeValueWithERC();
uint256 _fromTokenBalance = LibAsset.getOwnBalance(tokenId);
LibAsset.transferFromERC20(
tokenId,
msg.sender,
address(this),
amount
);
if (LibAsset.getOwnBalance(tokenId) - _fromTokenBalance != amount)
revert InvalidAmount();
}
}
/// @notice Overload for depositAsset(address tokenId, uint256 amount, bool isNative)
/// @param tokenId Token to deposit
/// @param amount Amount to deposit
function depositAsset(address tokenId, uint256 amount) internal {
return depositAsset(tokenId, amount, tokenId == NATIVE_ASSETID);
}
/// @notice Determines whether the given assetId is the native asset
/// @param assetId The asset identifier to evaluate
/// @return Boolean indicating if the asset is the native asset
function isNativeAsset(address assetId) internal pure returns (bool) {
return assetId == NATIVE_ASSETID;
}
/// @notice Wrapper function to transfer a given asset (native or erc20) to
/// some recipient. Should handle all non-compliant return value
/// tokens as well by using the SafeERC20 contract by open zeppelin.
/// @param assetId Asset id for transfer (address(0) for native asset,
/// token address for erc20s)
/// @param recipient Address to send asset to
/// @param amount Amount to send to given recipient
function transferAsset(
address assetId,
address payable recipient,
uint256 amount
) internal {
(assetId == NATIVE_ASSETID)
? transferNativeAsset(recipient, amount)
: transferERC20(assetId, recipient, amount);
}
/// @dev Checks whether the given address is a contract and contains code
function isContract(address contractAddr) internal view returns (bool) {
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize(contractAddr)
}
return size > 0;
}
}// SPDX-License-Identifier: MIT pragma solidity 0.8.13; error InvalidAmount(); // 0x2c5211c6 error TokenAddressIsZero(); // 0xdc2e5e8d error CannotBridgeToSameNetwork(); // 0x4ac09ad3 error ZeroPostSwapBalance(); // 0xf74e8909 error InvalidBridgeConfigLength(); // 0x10502ef9 error NoSwapDataProvided(); // 0x0503c3ed error NotSupportedSwapRouter(); // 0xe986f686 error NativeValueWithERC(); // 0x003f45b5 error ContractCallNotAllowed(); // 0x94539804 error NullAddrIsNotAValidSpender(); // 0x63ba9bff error NullAddrIsNotAnERC20Token(); // 0xd1bebf0c error NoTransferToNullAddress(); // 0x21f74345 error NativeAssetTransferFailed(); // 0x5a046737 error InvalidContract(); // 0x6eefed20 error InvalidConfig(); // 0x35be3ac8
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "IERC20.sol";
import "Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface ISo {
/// Structs ///
struct SoData {
bytes32 transactionId; // unique identification id
address payable receiver; // token receiving account
uint16 sourceChainId; // source chain id
address sendingAssetId; // The starting token address of the source chain
uint16 destinationChainId; // destination chain id
address receivingAssetId; // The final token address of the destination chain
uint256 amount; // User enters amount
}
struct NormalizedSoData {
bytes transactionId; // unique identification id
bytes receiver; // token receiving account
uint16 sourceChainId; // source chain id
bytes sendingAssetId; // The starting token address of the source chain
uint16 destinationChainId; // destination chain id
bytes receivingAssetId; // The final token address of the destination chain
uint256 amount; // User enters amount
}
/// Events ///
event SoTransferStarted(bytes32 indexed transactionId);
event SoTransferFailed(
bytes32 indexed transactionId,
string revertReason,
bytes otherReason
);
event SoTransferCompleted(
bytes32 indexed transactionId,
uint256 receiveAmount
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
interface ICorrectSwap {
function correctSwap(bytes calldata, uint256)
external
pure
returns (bytes memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
interface IStargate {
struct lzTxObj {
uint256 dstGasForCall;
uint256 dstNativeAmount;
bytes dstNativeAddr;
}
struct CachedSwap {
address token;
uint256 amountLD;
address to;
bytes payload;
}
event Revert(
uint8 bridgeFunctionType,
uint16 chainId,
bytes srcAddress,
uint256 nonce
);
event CachedSwapSaved(
uint16 chainId,
bytes srcAddress,
uint256 nonce,
address token,
uint256 amountLD,
address to,
bytes payload,
bytes reason
);
event RevertRedeemLocal(
uint16 srcChainId,
uint256 _srcPoolId,
uint256 _dstPoolId,
bytes to,
uint256 redeemAmountSD,
uint256 mintAmountSD,
uint256 indexed nonce,
bytes indexed srcAddress
);
event RedeemLocalCallback(
uint16 srcChainId,
bytes indexed srcAddress,
uint256 indexed nonce,
uint256 srcPoolId,
uint256 dstPoolId,
address to,
uint256 amountSD,
uint256 mintAmountSD
);
function addLiquidity(
uint256 _poolId,
uint256 _amountLD,
address _to
) external;
function swap(
uint16 _dstChainId,
uint256 _srcPoolId,
uint256 _dstPoolId,
address payable _refundAddress,
uint256 _amountLD,
uint256 _minAmountLD,
lzTxObj memory _lzTxParams,
bytes calldata _to,
bytes calldata _payload
) external payable;
function redeemRemote(
uint16 _dstChainId,
uint256 _srcPoolId,
uint256 _dstPoolId,
address payable _refundAddress,
uint256 _amountLP,
uint256 _minAmountLD,
bytes calldata _to,
lzTxObj memory _lzTxParams
) external payable;
function instantRedeemLocal(
uint16 _srcPoolId,
uint256 _amountLP,
address _to
) external returns (uint256);
function redeemLocal(
uint16 _dstChainId,
uint256 _srcPoolId,
uint256 _dstPoolId,
address payable _refundAddress,
uint256 _amountLP,
bytes calldata _to,
lzTxObj memory _lzTxParams
) external payable;
function sendCredits(
uint16 _dstChainId,
uint256 _srcPoolId,
uint256 _dstPoolId,
address payable _refundAddress
) external payable;
function quoteLayerZeroFee(
uint16 _dstChainId,
uint8 _functionType,
bytes calldata _toAddress,
bytes calldata _transferAndCallPayload,
lzTxObj memory _lzTxParams
) external view returns (uint256, uint256);
function factory() external view returns (address);
function bridge() external view returns (address);
function cachedSwapLookup(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint256 _nonce
) external view returns (CachedSwap memory);
function clearCachedSwap(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint256 _nonce
) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
interface IStargateFactory {
function allPoolsLength() external view returns (uint256);
function allPools(uint256 index) external view returns (address);
function getPool(uint256 poolId) external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
interface IStargatePool {
//---------------------------------------------------------------------------
// STRUCTS
struct ChainPath {
bool ready; // indicate if the counter chainPath has been created.
uint16 dstChainId;
uint256 dstPoolId;
uint256 weight;
uint256 balance;
uint256 lkb;
uint256 credits;
uint256 idealBalance;
}
struct SwapObj {
uint256 amount;
uint256 eqFee;
uint256 eqReward;
uint256 lpFee;
uint256 protocolFee;
uint256 lkbRemove;
}
//---------------------------------------------------------------------------
// EVENTS
event Mint(
address to,
uint256 amountLP,
uint256 amountSD,
uint256 mintFeeAmountSD
);
event Burn(address from, uint256 amountLP, uint256 amountSD);
event RedeemLocalCallback(
address _to,
uint256 _amountSD,
uint256 _amountToMintSD
);
event Swap(
uint16 chainId,
uint256 dstPoolId,
address from,
uint256 amountSD,
uint256 eqReward,
uint256 eqFee,
uint256 protocolFee,
uint256 lpFee
);
event SendCredits(
uint16 dstChainId,
uint256 dstPoolId,
uint256 credits,
uint256 idealBalance
);
event RedeemRemote(
uint16 chainId,
uint256 dstPoolId,
address from,
uint256 amountLP,
uint256 amountSD
);
event RedeemLocal(
address from,
uint256 amountLP,
uint256 amountSD,
uint16 chainId,
uint256 dstPoolId,
bytes to
);
event InstantRedeemLocal(
address from,
uint256 amountLP,
uint256 amountSD,
address to
);
event CreditChainPath(
uint16 chainId,
uint256 srcPoolId,
uint256 amountSD,
uint256 idealBalance
);
event SwapRemote(
address to,
uint256 amountSD,
uint256 protocolFee,
uint256 dstFee
);
event WithdrawRemote(
uint16 srcChainId,
uint256 srcPoolId,
uint256 swapAmount,
uint256 mintAmount
);
event ChainPathUpdate(uint16 dstChainId, uint256 dstPoolId, uint256 weight);
event FeesUpdated(uint256 mintFeeBP);
event FeeLibraryUpdated(address feeLibraryAddr);
event StopSwapUpdated(bool swapStop);
event WithdrawProtocolFeeBalance(address to, uint256 amountSD);
event WithdrawMintFeeBalance(address to, uint256 amountSD);
event DeltaParamUpdated(
bool batched,
uint256 swapDeltaBP,
uint256 lpDeltaBP,
bool defaultSwapMode,
bool defaultLPMode
);
function chainPaths(uint256 index) external view returns (ChainPath memory);
function getChainPathsLength() external view returns (uint256);
function getChainPath(uint16 _dstChainId, uint256 _dstPoolId)
external
view
returns (ChainPath memory);
function convertRate() external view returns (uint256);
function token() external view returns (address);
function feeLibrary() external view returns (address);
function poolId() external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
import "IStargatePool.sol";
interface IStargateFeeLibrary {
function getFees(
uint256 _srcPoolId,
uint256 _dstPoolId,
uint16 _dstChainId,
address _from,
uint256 _amountSD
) external view returns (IStargatePool.SwapObj memory s);
function getVersion() external view returns (string memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
interface IStargateReceiver {
function sgReceive(
uint16 _chainId,
bytes memory _srcAddress,
uint256 _nonce,
address _token,
uint256 _amount,
bytes memory _payload
) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {IDiamondCut} from "IDiamondCut.sol";
library LibDiamond {
bytes32 internal constant DIAMOND_STORAGE_POSITION =
keccak256("diamond.standard.diamond.storage");
struct FacetAddressAndPosition {
address facetAddress;
uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array
}
struct FacetFunctionSelectors {
bytes4[] functionSelectors;
uint256 facetAddressPosition; // position of facetAddress in facetAddresses array
}
struct DiamondStorage {
// maps function selector to the facet address and
// the position of the selector in the facetFunctionSelectors.selectors array
mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
// maps facet addresses to function selectors
mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
// facet addresses
address[] facetAddresses;
// Used to query if a contract implements an interface.
// Used to implement ERC-165.
mapping(bytes4 => bool) supportedInterfaces;
// owner of the contract
address contractOwner;
}
function diamondStorage()
internal
pure
returns (DiamondStorage storage ds)
{
bytes32 position = DIAMOND_STORAGE_POSITION;
// solhint-disable-next-line no-inline-assembly
assembly {
ds.slot := position
}
}
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
function setContractOwner(address _newOwner) internal {
DiamondStorage storage ds = diamondStorage();
address previousOwner = ds.contractOwner;
ds.contractOwner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function contractOwner() internal view returns (address contractOwner_) {
contractOwner_ = diamondStorage().contractOwner;
}
function enforceIsContractOwner() internal view {
require(
msg.sender == diamondStorage().contractOwner,
"LibDiamond: Must be contract owner"
);
}
event DiamondCut(
IDiamondCut.FacetCut[] _diamondCut,
address _init,
bytes _calldata
);
// Internal function version of diamondCut
function diamondCut(
IDiamondCut.FacetCut[] memory _diamondCut,
address _init,
bytes memory _calldata
) internal {
for (
uint256 facetIndex;
facetIndex < _diamondCut.length;
facetIndex++
) {
IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;
if (action == IDiamondCut.FacetCutAction.Add) {
addFunctions(
_diamondCut[facetIndex].facetAddress,
_diamondCut[facetIndex].functionSelectors
);
} else if (action == IDiamondCut.FacetCutAction.Replace) {
replaceFunctions(
_diamondCut[facetIndex].facetAddress,
_diamondCut[facetIndex].functionSelectors
);
} else if (action == IDiamondCut.FacetCutAction.Remove) {
removeFunctions(
_diamondCut[facetIndex].facetAddress,
_diamondCut[facetIndex].functionSelectors
);
} else {
revert("LibDiamondCut: Incorrect FacetCutAction");
}
}
emit DiamondCut(_diamondCut, _init, _calldata);
initializeDiamondCut(_init, _calldata);
}
function addFunctions(
address _facetAddress,
bytes4[] memory _functionSelectors
) internal {
require(
_functionSelectors.length > 0,
"LibDiamondCut: No selectors in facet to cut"
);
DiamondStorage storage ds = diamondStorage();
require(
_facetAddress != address(0),
"LibDiamondCut: Add facet can't be address(0)"
);
uint96 selectorPosition = uint96(
ds.facetFunctionSelectors[_facetAddress].functionSelectors.length
);
// add new facet address if it does not exist
if (selectorPosition == 0) {
addFacet(ds, _facetAddress);
}
for (
uint256 selectorIndex;
selectorIndex < _functionSelectors.length;
selectorIndex++
) {
bytes4 selector = _functionSelectors[selectorIndex];
address oldFacetAddress = ds
.selectorToFacetAndPosition[selector]
.facetAddress;
require(
oldFacetAddress == address(0),
"LibDiamondCut: Can't add function that already exists"
);
addFunction(ds, selector, selectorPosition, _facetAddress);
selectorPosition++;
}
}
function replaceFunctions(
address _facetAddress,
bytes4[] memory _functionSelectors
) internal {
require(
_functionSelectors.length > 0,
"LibDiamondCut: No selectors in facet to cut"
);
DiamondStorage storage ds = diamondStorage();
require(
_facetAddress != address(0),
"LibDiamondCut: Add facet can't be address(0)"
);
uint96 selectorPosition = uint96(
ds.facetFunctionSelectors[_facetAddress].functionSelectors.length
);
// add new facet address if it does not exist
if (selectorPosition == 0) {
addFacet(ds, _facetAddress);
}
for (
uint256 selectorIndex;
selectorIndex < _functionSelectors.length;
selectorIndex++
) {
bytes4 selector = _functionSelectors[selectorIndex];
address oldFacetAddress = ds
.selectorToFacetAndPosition[selector]
.facetAddress;
require(
oldFacetAddress != _facetAddress,
"LibDiamondCut: Can't replace function with same function"
);
removeFunction(ds, oldFacetAddress, selector);
addFunction(ds, selector, selectorPosition, _facetAddress);
selectorPosition++;
}
}
function removeFunctions(
address _facetAddress,
bytes4[] memory _functionSelectors
) internal {
require(
_functionSelectors.length > 0,
"LibDiamondCut: No selectors in facet to cut"
);
DiamondStorage storage ds = diamondStorage();
// if function does not exist then do nothing and return
require(
_facetAddress == address(0),
"LibDiamondCut: Remove facet address must be address(0)"
);
for (
uint256 selectorIndex;
selectorIndex < _functionSelectors.length;
selectorIndex++
) {
bytes4 selector = _functionSelectors[selectorIndex];
address oldFacetAddress = ds
.selectorToFacetAndPosition[selector]
.facetAddress;
removeFunction(ds, oldFacetAddress, selector);
}
}
function addFacet(DiamondStorage storage ds, address _facetAddress)
internal
{
enforceHasContractCode(
_facetAddress,
"LibDiamondCut: New facet has no code"
);
ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = ds
.facetAddresses
.length;
ds.facetAddresses.push(_facetAddress);
}
function addFunction(
DiamondStorage storage ds,
bytes4 _selector,
uint96 _selectorPosition,
address _facetAddress
) internal {
ds
.selectorToFacetAndPosition[_selector]
.functionSelectorPosition = _selectorPosition;
ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(
_selector
);
ds.selectorToFacetAndPosition[_selector].facetAddress = _facetAddress;
}
function removeFunction(
DiamondStorage storage ds,
address _facetAddress,
bytes4 _selector
) internal {
require(
_facetAddress != address(0),
"LibDiamondCut: Can't remove function that doesn't exist"
);
// an immutable function is a function defined directly in a diamond
require(
_facetAddress != address(this),
"LibDiamondCut: Can't remove immutable function"
);
// replace selector with last selector, then delete last selector
uint256 selectorPosition = ds
.selectorToFacetAndPosition[_selector]
.functionSelectorPosition;
uint256 lastSelectorPosition = ds
.facetFunctionSelectors[_facetAddress]
.functionSelectors
.length - 1;
// if not the same then replace _selector with lastSelector
if (selectorPosition != lastSelectorPosition) {
bytes4 lastSelector = ds
.facetFunctionSelectors[_facetAddress]
.functionSelectors[lastSelectorPosition];
ds.facetFunctionSelectors[_facetAddress].functionSelectors[
selectorPosition
] = lastSelector;
ds
.selectorToFacetAndPosition[lastSelector]
.functionSelectorPosition = uint96(selectorPosition);
}
// delete the last selector
ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop();
delete ds.selectorToFacetAndPosition[_selector];
// if no more selectors for facet address then delete the facet address
if (lastSelectorPosition == 0) {
// replace facet address with last facet address and delete last facet address
uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1;
uint256 facetAddressPosition = ds
.facetFunctionSelectors[_facetAddress]
.facetAddressPosition;
if (facetAddressPosition != lastFacetAddressPosition) {
address lastFacetAddress = ds.facetAddresses[
lastFacetAddressPosition
];
ds.facetAddresses[facetAddressPosition] = lastFacetAddress;
ds
.facetFunctionSelectors[lastFacetAddress]
.facetAddressPosition = facetAddressPosition;
}
ds.facetAddresses.pop();
delete ds
.facetFunctionSelectors[_facetAddress]
.facetAddressPosition;
}
}
function initializeDiamondCut(address _init, bytes memory _calldata)
internal
{
if (_init == address(0)) {
require(
_calldata.length == 0,
"LibDiamondCut: _init is address(0) but_calldata is not empty"
);
} else {
require(
_calldata.length > 0,
"LibDiamondCut: _calldata is empty but _init is not address(0)"
);
if (_init != address(this)) {
enforceHasContractCode(
_init,
"LibDiamondCut: _init address has no code"
);
}
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory error) = _init.delegatecall(_calldata);
if (!success) {
if (error.length > 0) {
// bubble up the error
revert(string(error));
} else {
revert("LibDiamondCut: _init function reverted");
}
}
}
}
function enforceHasContractCode(
address _contract,
string memory _errorMessage
) internal view {
uint256 contractSize;
// solhint-disable-next-line no-inline-assembly
assembly {
contractSize := extcodesize(_contract)
}
require(contractSize > 0, _errorMessage);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IDiamondCut {
enum FacetCutAction {
Add,
Replace,
Remove
}
// Add=0, Replace=1, Remove=2
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
/// @notice Add/replace/remove any number of functions and optionally execute
/// a function with delegatecall
/// @param _diamondCut Contains the facet addresses and function selectors
/// @param _init The address of the contract or facet to execute _calldata
/// @param _calldata A function call, including function selector and arguments
/// _calldata is executed with delegatecall on _init
function diamondCut(
FacetCut[] calldata _diamondCut,
address _init,
bytes calldata _calldata
) external;
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;
/// @title Reentrancy Guard
/// @author LI.FI (https://li.fi)
/// @notice Abstract contract to provide protection against reentrancy
abstract contract ReentrancyGuard {
/// Storage ///
bytes32 private constant NAMESPACE =
hex"a65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b";
/// Types ///
struct ReentrancyStorage {
uint256 status;
}
/// Errors ///
error ReentrancyError();
/// Constants ///
uint256 private constant _NOT_ENTERED = 0;
uint256 private constant _ENTERED = 1;
/// Modifiers ///
modifier nonReentrant() {
ReentrancyStorage storage s = reentrancyStorage();
if (s.status == _ENTERED) revert ReentrancyError();
s.status = _ENTERED;
_;
s.status = _NOT_ENTERED;
}
/// Private Methods ///
/// @dev fetch local storage
function reentrancyStorage()
private
pure
returns (ReentrancyStorage storage data)
{
bytes32 position = NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
data.slot := position
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {IWETH} from "IWETH.sol";
import {ISo} from "ISo.sol";
import {ICorrectSwap} from "ICorrectSwap.sol";
import {LibSwap} from "LibSwap.sol";
import {LibAsset} from "LibAsset.sol";
import {LibUtil} from "LibUtil.sol";
import {LibStorage} from "LibStorage.sol";
import {LibAsset} from "LibAsset.sol";
import {InvalidAmount, ContractCallNotAllowed, NoSwapDataProvided, NotSupportedSwapRouter} from "GenericErrors.sol";
/// @title Swapper
/// @notice Abstract contract to provide swap functionality
contract Swapper is ISo {
/// Storage ///
LibStorage internal appStorage;
/// Modifiers ///
/// @dev Sends any leftover balances back to the user
modifier noLeftovers(LibSwap.SwapData[] calldata swapData) {
uint256 nSwaps = swapData.length;
if (nSwaps != 1) {
uint256[] memory initialBalances = _fetchBalances(swapData);
address finalAsset = swapData[nSwaps - 1].receivingAssetId;
uint256 curBalance = 0;
_;
for (uint256 i = 0; i < nSwaps - 1; i++) {
address curAsset = swapData[i].receivingAssetId;
if (curAsset == finalAsset) continue; // Handle multi-to-one swaps
curBalance =
LibAsset.getOwnBalance(curAsset) -
initialBalances[i];
if (curBalance > 0)
LibAsset.transferAsset(
curAsset,
payable(msg.sender),
curBalance
);
}
} else _;
}
/// External Methods ///
/// @dev Validates input before executing swaps
/// @param soData So tracking data
/// @param swapData Array of data used to execute swaps
function executeAndCheckSwaps(
SoData memory soData,
LibSwap.SwapData[] calldata swapData
) external returns (uint256) {
require(msg.sender == address(this), "NotDiamond");
uint256 nSwaps = swapData.length;
if (nSwaps == 0) revert NoSwapDataProvided();
address finalTokenId = swapData[swapData.length - 1].receivingAssetId;
uint256 swapBalance = LibAsset.getOwnBalance(finalTokenId);
_executeSwaps(soData, swapData);
swapBalance = LibAsset.getOwnBalance(finalTokenId) - swapBalance;
if (swapBalance == 0) revert InvalidAmount();
return swapBalance;
}
/// Internal Methods ///
/// @dev Convert eth to wrapped eth and Transfer.
function transferWrappedAsset(
address currentAssetId,
address expectAssetId,
uint256 amount
) internal {
if (currentAssetId == expectAssetId) {
require(
LibAsset.getOwnBalance(currentAssetId) >= amount,
"NotEnough"
);
return;
}
if (LibAsset.isNativeAsset(currentAssetId)) {
// eth -> weth
try IWETH(expectAssetId).deposit{value: amount}() {} catch {
revert("DepositErr");
}
} else {
// weth -> eth -> weth
if (currentAssetId != expectAssetId) {
try IWETH(currentAssetId).withdraw(amount) {} catch {
revert("DepositWithdrawErr");
}
try IWETH(expectAssetId).deposit{value: amount}() {} catch {
revert("WithdrawDepositErr");
}
}
}
}
/// @dev Convert wrapped eth to eth and Transfer.
function transferUnwrappedAsset(
address currentAssetId,
address expectAssetId,
uint256 amount,
address receiver
) internal {
if (LibAsset.isNativeAsset(expectAssetId)) {
if (currentAssetId != expectAssetId) {
try IWETH(currentAssetId).withdraw(amount) {} catch {
revert("WithdrawErr");
}
}
} else {
require(currentAssetId == expectAssetId, "AssetIdErr");
}
if (receiver != address(this)) {
require(
LibAsset.getOwnBalance(expectAssetId) >= amount,
"NotEnough"
);
LibAsset.transferAsset(expectAssetId, payable(receiver), amount);
}
}
/// Private Methods ///
/// @dev Executes swaps and checks that DEXs used are in the allowList
/// @param soData So tracking data
/// @param swapData Array of data used to execute swaps
function _executeSwaps(
SoData memory soData,
LibSwap.SwapData[] calldata swapData
) private {
LibSwap.SwapData memory currentSwapData = swapData[0];
for (uint256 i = 0; i < swapData.length; i++) {
address receivedToken = currentSwapData.receivingAssetId;
uint256 swapBalance = LibAsset.getOwnBalance(receivedToken);
if (
!(appStorage.dexAllowlist[currentSwapData.approveTo] &&
appStorage.dexAllowlist[currentSwapData.callTo] &&
appStorage.dexFuncSignatureAllowList[
bytes32(
LibUtil.getSlice(currentSwapData.callData, 0, 4)
)
])
) revert ContractCallNotAllowed();
LibSwap.swap(soData.transactionId, currentSwapData);
swapBalance = LibAsset.getOwnBalance(receivedToken) - swapBalance;
if (i + 1 < swapData.length) {
currentSwapData = swapData[i + 1];
address correctSwap = appStorage.correctSwapRouterSelectors;
if (correctSwap == address(0)) revert NotSupportedSwapRouter();
currentSwapData.fromAmount = swapBalance;
currentSwapData.callData = ICorrectSwap(correctSwap)
.correctSwap(
currentSwapData.callData,
currentSwapData.fromAmount
);
}
}
}
/// @dev Fetches balances of tokens to be swapped before swapping.
/// @param swapData Array of data used to execute swaps
/// @return uint256[] Array of token balances.
function _fetchBalances(LibSwap.SwapData[] calldata swapData)
private
view
returns (uint256[] memory)
{
uint256 length = swapData.length;
uint256[] memory balances = new uint256[](length);
for (uint256 i = 0; i < length; i++)
balances[i] = LibAsset.getOwnBalance(swapData[i].receivingAssetId);
return balances;
}
}pragma solidity 0.8.13;
import "IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {LibAsset, IERC20} from "LibAsset.sol";
import {LibUtil} from "LibUtil.sol";
import {InvalidContract} from "GenericErrors.sol";
library LibSwap {
error NoSwapFromZeroBalance();
struct SwapData {
address callTo; // The swap address
address approveTo; // The swap address
address sendingAssetId; // The swap start token address
address receivingAssetId; // The swap final token address
uint256 fromAmount; // The swap start token amount
bytes callData; // The swap callData
}
struct NormalizedSwapData {
bytes callTo; // The swap address
bytes approveTo; // The swap address
bytes sendingAssetId; // The swap start token address
bytes receivingAssetId; // The swap final token address
uint256 fromAmount; // The swap start token amount
bytes callData; // The swap callData
}
event AssetSwapped(
bytes32 transactionId,
address dex,
address fromAssetId,
address toAssetId,
uint256 fromAmount,
uint256 toAmount,
uint256 timestamp
);
function swap(bytes32 transactionId, SwapData memory _swapData) internal {
if (!LibAsset.isContract(_swapData.callTo)) revert InvalidContract();
uint256 fromAmount = _swapData.fromAmount;
if (fromAmount == 0) revert NoSwapFromZeroBalance();
uint256 nativeValue = 0;
address fromAssetId = _swapData.sendingAssetId;
address toAssetId = _swapData.receivingAssetId;
uint256 initialSendingAssetBalance = LibAsset.getOwnBalance(
fromAssetId
);
uint256 initialReceivingAssetBalance = LibAsset.getOwnBalance(
toAssetId
);
uint256 toDeposit = initialSendingAssetBalance < fromAmount
? fromAmount - initialSendingAssetBalance
: 0;
if (!LibAsset.isNativeAsset(fromAssetId)) {
LibAsset.maxApproveERC20(
IERC20(fromAssetId),
_swapData.approveTo,
fromAmount
);
if (toDeposit != 0) {
LibAsset.transferFromERC20(
fromAssetId,
msg.sender,
address(this),
toDeposit
);
}
} else {
nativeValue = fromAmount;
}
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory res) = _swapData.callTo.call{
value: nativeValue
}(_swapData.callData);
if (!success) {
string memory reason = LibUtil.getRevertMsg(res);
revert(reason);
}
emit AssetSwapped(
transactionId,
_swapData.callTo,
_swapData.sendingAssetId,
toAssetId,
fromAmount,
LibAsset.getOwnBalance(toAssetId) - initialReceivingAssetBalance,
block.timestamp
);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "LibBytes.sol";
library LibUtil {
using LibBytes for bytes;
function getRevertMsg(bytes memory _res)
internal
pure
returns (string memory)
{
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_res.length < 68) return "Transaction reverted silently";
bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes
return abi.decode(revertData, (string)); // All that remains is the revert string
}
function getSlice(
bytes memory _data,
uint256 _start,
uint256 _end
) internal pure returns (bytes memory) {
require(_start < _end && _end <= _data.length, "DataLength error!");
bytes memory _out = bytes("");
for (uint256 i = _start; i < _end; i++) {
_out = bytes.concat(_out, _data[i]);
}
return _out;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
library LibBytes {
// solhint-disable no-inline-assembly
function concat(bytes memory _preBytes, bytes memory _postBytes)
internal
pure
returns (bytes memory)
{
bytes memory tempBytes;
assembly {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// Store the length of the first bytes array at the beginning of
// the memory for tempBytes.
let length := mload(_preBytes)
mstore(tempBytes, length)
// Maintain a memory counter for the current write location in the
// temp bytes array by adding the 32 bytes for the array length to
// the starting location.
let mc := add(tempBytes, 0x20)
// Stop copying when the memory counter reaches the length of the
// first bytes array.
let end := add(mc, length)
for {
// Initialize a copy counter to the start of the _preBytes data,
// 32 bytes into its memory.
let cc := add(_preBytes, 0x20)
} lt(mc, end) {
// Increase both counters by 32 bytes each iteration.
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// Write the _preBytes data into the tempBytes memory 32 bytes
// at a time.
mstore(mc, mload(cc))
}
// Add the length of _postBytes to the current length of tempBytes
// and store it as the new length in the first 32 bytes of the
// tempBytes memory.
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
// Move the memory counter back from a multiple of 0x20 to the
// actual end of the _preBytes data.
mc := end
// Stop copying when the memory counter reaches the new combined
// length of the arrays.
end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
// Update the free-memory pointer by padding our last write location
// to 32 bytes: add 31 bytes to the end of tempBytes to move to the
// next 32 byte block, then round down to the nearest multiple of
// 32. If the sum of the length of the two arrays is zero then add
// one before rounding down to leave a blank 32 bytes (the length block with 0).
mstore(
0x40,
and(
add(add(end, iszero(add(length, mload(_preBytes)))), 31),
not(31) // Round down to the nearest 32 bytes.
)
)
}
return tempBytes;
}
function concatStorage(bytes storage _preBytes, bytes memory _postBytes)
internal
{
assembly {
// Read the first 32 bytes of _preBytes storage, which is the length
// of the array. (We don't need to use the offset into the slot
// because arrays use the entire slot.)
let fslot := sload(_preBytes.slot)
// Arrays of 31 bytes or less have an even value in their slot,
// while longer arrays have an odd value. The actual length is
// the slot divided by two for odd values, and the lowest order
// byte divided by two for even values.
// If the slot is even, bitwise and the slot with 255 and divide by
// two to get the length. If the slot is odd, bitwise and the slot
// with -1 and divide by two.
let slength := div(
and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),
2
)
let mlength := mload(_postBytes)
let newlength := add(slength, mlength)
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
// Since the new array still fits in the slot, we just need to
// update the contents of the slot.
// uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
sstore(
_preBytes.slot,
// all the modifications to the slot are inside this
// next block
add(
// we can just add to the slot contents because the
// bytes we want to change are the LSBs
fslot,
add(
mul(
div(
// load the bytes from memory
mload(add(_postBytes, 0x20)),
// zero all bytes to the right
exp(0x100, sub(32, mlength))
),
// and now shift left the number of bytes to
// leave space for the length in the slot
exp(0x100, sub(32, newlength))
),
// increase length by the double of the memory
// bytes length
mul(mlength, 2)
)
)
)
}
case 1 {
// The stored value fits in the slot, but the combined value
// will exceed it.
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// The contents of the _postBytes array start 32 bytes into
// the structure. Our first read should obtain the `submod`
// bytes that can fit into the unused space in the last word
// of the stored array. To get this, we read 32 bytes starting
// from `submod`, so the data we read overlaps with the array
// contents by `submod` bytes. Masking the lowest-order
// `submod` bytes allows us to add that value directly to the
// stored value.
let submod := sub(32, slength)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(
sc,
add(
and(
fslot,
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
),
and(mload(mc), mask)
)
)
for {
mc := add(mc, 0x20)
sc := add(sc, 1)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
default {
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
// Start copying to the last used word of the stored array.
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// Copy over the first `submod` bytes of the new data as in
// case 1 above.
let slengthmod := mod(slength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
sc := add(sc, 1)
mc := add(mc, 0x20)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
}
}
function indexOf(
bytes memory _bytes,
uint8 _e,
uint256 _start
) internal pure returns (uint256) {
while (_start < _bytes.length) {
if (toUint8(_bytes, _start) == _e) {
return _start;
}
_start += 1;
}
return _bytes.length;
}
function slice(
bytes memory _bytes,
uint256 _start,
uint256 _length
) internal pure returns (bytes memory) {
require(_length + 31 >= _length, "slice_overflow");
require(_bytes.length >= _start + _length, "slice_outOfBounds");
bytes memory tempBytes;
assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(
add(tempBytes, lengthmod),
mul(0x20, iszero(lengthmod))
)
let end := add(mc, _length)
for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(
add(
add(_bytes, lengthmod),
mul(0x20, iszero(lengthmod))
),
_start
)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
mstore(tempBytes, _length)
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)
mstore(0x40, add(tempBytes, 0x20))
}
}
return tempBytes;
}
function toAddress(bytes memory _bytes, uint256 _start)
internal
pure
returns (address)
{
require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
address tempAddress;
assembly {
tempAddress := div(
mload(add(add(_bytes, 0x20), _start)),
0x1000000000000000000000000
)
}
return tempAddress;
}
function toUint8(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint8)
{
require(_bytes.length >= _start + 1, "toUint8_outOfBounds");
uint8 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x1), _start))
}
return tempUint;
}
function toUint16(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint16)
{
require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
uint16 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x2), _start))
}
return tempUint;
}
function toUint32(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint32)
{
require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
uint32 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x4), _start))
}
return tempUint;
}
function toUint64(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint64)
{
require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
uint64 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x8), _start))
}
return tempUint;
}
function toUint96(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint96)
{
require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
uint96 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0xc), _start))
}
return tempUint;
}
function toUint128(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint128)
{
require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
uint128 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x10), _start))
}
return tempUint;
}
function toUint256(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint256)
{
require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
uint256 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x20), _start))
}
return tempUint;
}
function toBytes32(bytes memory _bytes, uint256 _start)
internal
pure
returns (bytes32)
{
require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
function equal(bytes memory _preBytes, bytes memory _postBytes)
internal
pure
returns (bool)
{
bool success = true;
assembly {
let length := mload(_preBytes)
// if lengths don't match the arrays are not equal
switch eq(length, mload(_postBytes))
case 1 {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
let mc := add(_preBytes, 0x20)
let end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
} eq(add(lt(mc, end), cb), 2) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// if any of these checks fails then arrays are not equal
if iszero(eq(mload(mc), mload(cc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
function equalStorage(bytes storage _preBytes, bytes memory _postBytes)
internal
view
returns (bool)
{
bool success = true;
assembly {
// we know _preBytes_offset is 0
let fslot := sload(_preBytes.slot)
// Decode the length of the stored array like in concatStorage().
let slength := div(
and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),
2
)
let mlength := mload(_postBytes)
// if lengths don't match the arrays are not equal
switch eq(slength, mlength)
case 1 {
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
// blank the last byte which is the length
fslot := mul(div(fslot, 0x100), 0x100)
if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
// unsuccess:
success := 0
}
}
default {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := keccak256(0x0, 0x20)
let mc := add(_postBytes, 0x20)
let end := add(mc, mlength)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
// solhint-disable-next-line no-empty-blocks
for {
} eq(add(lt(mc, end), cb), 2) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
if iszero(eq(sload(sc), mload(mc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
struct LibStorage {
mapping(address => bool) dexAllowlist;
mapping(bytes32 => bool) dexFuncSignatureAllowList;
address[] dexs;
// maps gateway facet addresses to sofee address
mapping(address => address) gatewaySoFeeSelectors;
// Storage correct swap address
address correctSwapRouterSelectors;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IStargateEthVault {
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);
event TransferNative(address indexed src, address indexed dst, uint256 wad);
function balanceOf(address account) external view returns (uint256);
function noUnwrapTo(address) external view returns (bool);
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
function approve(address guy, uint256 wad) external returns (bool);
function transferFrom(
address src,
address dst,
uint256 wad
) external returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;
interface ILibSoFee {
function getFees(uint256 _amount) external view returns (uint256 s);
function getRestoredAmount(uint256 _amount)
external
view
returns (uint256 r);
function getTransferForGas() external view returns (uint256);
function getVersion() external view returns (string memory);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;
import {ISo} from "ISo.sol";
import {LibSwap} from "LibSwap.sol";
import {LibBytes} from "LibBytes.sol";
library LibCross {
using LibBytes for bytes;
function normalizeSoData(ISo.SoData memory soData)
internal
pure
returns (ISo.NormalizedSoData memory)
{
ISo.NormalizedSoData memory data;
data.transactionId = abi.encodePacked(soData.transactionId);
data.receiver = abi.encodePacked(soData.receiver);
data.sourceChainId = soData.sourceChainId;
data.sendingAssetId = abi.encodePacked(soData.sendingAssetId);
data.destinationChainId = soData.destinationChainId;
data.receivingAssetId = abi.encodePacked(soData.receivingAssetId);
data.amount = soData.amount;
return data;
}
function tryAddress(bytes memory data) internal pure returns (address) {
if (data.length == 20) {
return data.toAddress(0);
} else {
return address(0);
}
}
function denormalizeSoData(ISo.NormalizedSoData memory data)
internal
pure
returns (ISo.SoData memory)
{
return
ISo.SoData({
transactionId: data.transactionId.toBytes32(0),
receiver: payable(tryAddress(data.receiver)),
sourceChainId: data.sourceChainId,
sendingAssetId: tryAddress(data.sendingAssetId),
destinationChainId: data.destinationChainId,
receivingAssetId: tryAddress(data.receivingAssetId),
amount: data.amount
});
}
function normalizeSwapData(LibSwap.SwapData[] memory swapData)
internal
pure
returns (LibSwap.NormalizedSwapData[] memory)
{
LibSwap.NormalizedSwapData[]
memory data = new LibSwap.NormalizedSwapData[](swapData.length);
for (uint256 i = 0; i < swapData.length; i++) {
data[i].callTo = abi.encodePacked(swapData[i].callTo);
data[i].approveTo = abi.encodePacked(swapData[i].approveTo);
data[i].sendingAssetId = abi.encodePacked(
swapData[i].sendingAssetId
);
data[i].receivingAssetId = abi.encodePacked(
swapData[i].receivingAssetId
);
data[i].fromAmount = swapData[i].fromAmount;
data[i].callData = abi.encodePacked(swapData[i].callData);
}
return data;
}
function denormalizeSwapData(LibSwap.NormalizedSwapData[] memory data)
internal
pure
returns (LibSwap.SwapData[] memory)
{
LibSwap.SwapData[] memory swapData = new LibSwap.SwapData[](
data.length
);
for (uint256 i = 0; i < swapData.length; i++) {
swapData[i].callTo = data[i].callTo.toAddress(0);
swapData[i].approveTo = data[i].approveTo.toAddress(0);
swapData[i].sendingAssetId = data[i].sendingAssetId.toAddress(0);
swapData[i].receivingAssetId = data[i].receivingAssetId.toAddress(
0
);
swapData[i].fromAmount = data[i].fromAmount;
swapData[i].callData = data[i].callData;
}
return swapData;
}
function encodeNormalizedSoData(ISo.NormalizedSoData memory data)
internal
pure
returns (bytes memory)
{
bytes memory encodeData = abi.encodePacked(
uint64(data.transactionId.length),
data.transactionId,
uint64(data.receiver.length),
data.receiver,
data.sourceChainId
);
// Avoid variable value1 is 1 slot(s) too deep;
encodeData = encodeData.concat(
abi.encodePacked(
uint64(data.sendingAssetId.length),
data.sendingAssetId,
data.destinationChainId,
uint64(data.receivingAssetId.length),
data.receivingAssetId,
data.amount
)
);
return encodeData;
}
function decodeNormalizedSoData(bytes memory soData)
internal
pure
returns (ISo.NormalizedSoData memory)
{
ISo.NormalizedSoData memory data;
uint256 index;
uint256 nextLen;
nextLen = uint256(soData.toUint64(index));
index += 8;
data.transactionId = soData.slice(index, nextLen);
index += nextLen;
nextLen = uint256(soData.toUint64(index));
index += 8;
data.receiver = soData.slice(index, nextLen);
index += nextLen;
nextLen = 2;
data.sourceChainId = soData.toUint16(index);
index += nextLen;
nextLen = uint256(soData.toUint64(index));
index += 8;
data.sendingAssetId = soData.slice(index, nextLen);
index += nextLen;
nextLen = 2;
data.destinationChainId = soData.toUint16(index);
index += nextLen;
nextLen = uint256(soData.toUint64(index));
index += 8;
data.receivingAssetId = soData.slice(index, nextLen);
index += nextLen;
nextLen = 32;
data.amount = soData.toUint256(index);
index += nextLen;
require(index == soData.length, "Length error");
return data;
}
function encodeNormalizedSwapData(LibSwap.NormalizedSwapData[] memory data)
internal
pure
returns (bytes memory)
{
bytes memory encodeData = bytes("");
if (data.length > 0) {
encodeData = abi.encodePacked(uint64(data.length));
}
for (uint256 i = 0; i < data.length; i++) {
encodeData = encodeData.concat(
abi.encodePacked(
uint64(data[i].callTo.length),
data[i].callTo,
uint64(data[i].approveTo.length),
data[i].approveTo,
uint64(data[i].sendingAssetId.length),
data[i].sendingAssetId
)
);
// Avoid variable value1 is 1 slot(s) too deep;
encodeData = encodeData.concat(
abi.encodePacked(
uint64(data[i].receivingAssetId.length),
data[i].receivingAssetId,
data[i].fromAmount,
uint64(data[i].callData.length),
data[i].callData
)
);
}
return encodeData;
}
function decodeNormalizedSwapData(bytes memory swapData)
internal
pure
returns (LibSwap.NormalizedSwapData[] memory)
{
uint256 index;
uint256 nextLen;
nextLen = 8;
uint256 swapLen = uint256(swapData.toUint64(index));
index += nextLen;
LibSwap.NormalizedSwapData[]
memory data = new LibSwap.NormalizedSwapData[](swapLen);
for (uint256 i = 0; i < swapLen; i++) {
nextLen = uint256(swapData.toUint64(index));
index += 8;
data[i].callTo = swapData.slice(index, nextLen);
index += nextLen;
nextLen = uint256(swapData.toUint64(index));
index += 8;
data[i].approveTo = swapData.slice(index, nextLen);
index += nextLen;
nextLen = uint256(swapData.toUint64(index));
index += 8;
data[i].sendingAssetId = swapData.slice(index, nextLen);
index += nextLen;
nextLen = uint256(swapData.toUint64(index));
index += 8;
data[i].receivingAssetId = swapData.slice(index, nextLen);
index += nextLen;
nextLen = 32;
data[i].fromAmount = swapData.toUint256(index);
index += nextLen;
nextLen = uint256(swapData.toUint64(index));
index += 8;
data[i].callData = swapData.slice(index, nextLen);
index += nextLen;
}
require(index == swapData.length, "Length error");
return data;
}
function serializeU256WithHexStr(uint256 data)
internal
pure
returns (bytes memory)
{
bytes memory encodeData = abi.encodePacked(uint8(data & 0xFF));
data = data >> 8;
while (data != 0) {
encodeData = abi.encodePacked(uint8(data & 0xFF)).concat(
encodeData
);
data = data >> 8;
}
return encodeData;
}
function deserializeU256WithHexStr(bytes memory data)
internal
pure
returns (uint256)
{
uint256 buf = 0;
for (uint256 i = 0; i < data.length; i++) {
buf = (buf << 8) + data.toUint8(i);
}
return buf;
}
}{
"evmVersion": "istanbul",
"optimizer": {
"enabled": true,
"runs": 200
},
"libraries": {
"StargateFacet.sol": {}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"CannotBridgeToSameNetwork","type":"error"},{"inputs":[],"name":"ContractCallNotAllowed","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidConfig","type":"error"},{"inputs":[],"name":"InvalidContract","type":"error"},{"inputs":[],"name":"NativeAssetTransferFailed","type":"error"},{"inputs":[],"name":"NoSwapDataProvided","type":"error"},{"inputs":[],"name":"NoSwapFromZeroBalance","type":"error"},{"inputs":[],"name":"NoTransferToNullAddress","type":"error"},{"inputs":[],"name":"NotSupportedSwapRouter","type":"error"},{"inputs":[],"name":"NullAddrIsNotAValidSpender","type":"error"},{"inputs":[],"name":"NullAddrIsNotAnERC20Token","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"router","type":"address"},{"indexed":false,"internalType":"bool","name":"isAllowed","type":"bool"}],"name":"SetAllowedList","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"receiveAmount","type":"uint256"}],"name":"SoTransferCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"string","name":"revertReason","type":"string"},{"indexed":false,"internalType":"bytes","name":"otherReason","type":"bytes"}],"name":"SoTransferFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"SoTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stargate","type":"address"},{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"StargateInitialized","type":"event"},{"inputs":[],"name":"INTERDELIMITER","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"stargatePayload","type":"bytes"}],"name":"decodeStargatePayload","outputs":[{"components":[{"internalType":"bytes","name":"transactionId","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.NormalizedSoData","name":"soData","type":"tuple"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataDst","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"transactionId","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.NormalizedSoData","name":"soData","type":"tuple"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataDst","type":"tuple[]"}],"name":"encodeStargatePayload","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcStargatePoolId","type":"uint256"},{"internalType":"uint16","name":"dstStargateChainId","type":"uint16"},{"internalType":"uint256","name":"dstStargatePoolId","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"dstGasForSgReceive","type":"uint256"},{"internalType":"address payable","name":"dstSoDiamond","type":"address"}],"internalType":"struct StargateFacet.StargateData","name":"stargateData","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"estimateStargateFinalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.SoData","name":"soData","type":"tuple"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.SwapData[]","name":"swapData","type":"tuple[]"}],"name":"executeAndCheckSwaps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getAmountBeforeSoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"transactionId","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.NormalizedSoData","name":"soDataNo","type":"tuple"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataDstNo","type":"tuple[]"}],"name":"getSgReceiveForGasPayload","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"transactionId","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.NormalizedSoData","name":"soDataNo","type":"tuple"},{"components":[{"internalType":"uint256","name":"srcStargatePoolId","type":"uint256"},{"internalType":"uint16","name":"dstStargateChainId","type":"uint16"},{"internalType":"uint256","name":"dstStargatePoolId","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"dstGasForSgReceive","type":"uint256"},{"internalType":"address payable","name":"dstSoDiamond","type":"address"}],"internalType":"struct StargateFacet.StargateData","name":"stargateData","type":"tuple"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataDstNo","type":"tuple[]"}],"name":"getStargateFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getStargateSoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTransferGas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stargate","type":"address"},{"internalType":"uint16","name":"chainId","type":"uint16"}],"name":"initStargate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.SoData","name":"soData","type":"tuple"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"address","name":"sendingAssetId","type":"address"},{"internalType":"address","name":"receivingAssetId","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.SwapData[]","name":"swapDataDst","type":"tuple[]"}],"name":"remoteSoSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"router","type":"address"},{"internalType":"bool","name":"isAllowed","type":"bool"}],"name":"setAllowedAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"sgReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"transactionId","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.NormalizedSoData","name":"soDataNo","type":"tuple"},{"internalType":"uint256","name":"dstStargatePoolId","type":"uint256"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataDstNo","type":"tuple[]"}],"name":"sgReceiveForGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"transactionId","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"uint16","name":"sourceChainId","type":"uint16"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"uint16","name":"destinationChainId","type":"uint16"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISo.NormalizedSoData","name":"soDataNo","type":"tuple"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataSrcNo","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"srcStargatePoolId","type":"uint256"},{"internalType":"uint16","name":"dstStargateChainId","type":"uint16"},{"internalType":"uint256","name":"dstStargatePoolId","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"dstGasForSgReceive","type":"uint256"},{"internalType":"address payable","name":"dstSoDiamond","type":"address"}],"internalType":"struct StargateFacet.StargateData","name":"stargateData","type":"tuple"},{"components":[{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"approveTo","type":"bytes"},{"internalType":"bytes","name":"sendingAssetId","type":"bytes"},{"internalType":"bytes","name":"receivingAssetId","type":"bytes"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct LibSwap.NormalizedSwapData[]","name":"swapDataDstNo","type":"tuple[]"}],"name":"soSwapViaStargate","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b50614c97806100206000396000f3fe6080604052600436106100f35760003560e01c806398e038d71161008a578063df3c5ac311610059578063df3c5ac3146102a4578063e31dc6be146102c4578063eedfa7cd146102e4578063fae36986146102f757600080fd5b806398e038d714610224578063ab8236f314610244578063af66a6d814610264578063cd96eb9a1461028457600080fd5b8063762a9962116100c6578063762a99621461018f5780637e3c358b146101bd57806380d0d656146101dd578063958b3ab01461020457600080fd5b80630e7e8ba2146100f85780633136c5601461012057806331b5d4741461014d5780633729e48c1461016f575b600080fd5b34801561010457600080fd5b5061010d610317565b6040519081526020015b60405180910390f35b34801561012c57600080fd5b5061014061013b36600461378d565b6103be565b604051610117919061384d565b34801561015957600080fd5b5061016d610168366004613a7e565b6103e0565b005b34801561017b57600080fd5b5061010d61018a366004613b7b565b610788565b34801561019b57600080fd5b506101af6101aa366004613c3b565b610885565b604051610117929190613d46565b3480156101c957600080fd5b5061010d6101d8366004613e0a565b610c26565b3480156101e957600080fd5b506101f2603b81565b60405160ff9091168152602001610117565b34801561021057600080fd5b5061016d61021f366004613e23565b610cd4565b34801561023057600080fd5b5061010d61023f366004613e0a565b610fa5565b34801561025057600080fd5b5061016d61025f366004613e92565b611010565b34801561027057600080fd5b5061016d61027f366004613f2c565b611336565b34801561029057600080fd5b5061010d61029f366004613f73565b61142d565b3480156102b057600080fd5b506101406102bf3660046141d4565b611538565b3480156102d057600080fd5b5061010d6102df36600461424b565b6116f7565b61016d6102f23660046142aa565b611829565b34801561030357600080fd5b5061016d610312366004614362565b611a72565b600080516020614c4283398151915280546001600160a01b039081166000908152600360205260408120549092911680610355576175309250505090565b806001600160a01b0316634f0ba55f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b7919061439b565b9250505090565b60606103d66103cc856143b4565b6102bf84866143c0565b90505b9392505050565b3330146104215760405162461bcd60e51b815260206004820152600a602482015269139bdd111a585b5bdb9960b21b60448201526064015b60405180910390fd5b600061042c84610fa5565b905083811015610443576104408482611b05565b93505b81516000036104fd57801561049d5761049d8561046660c0860160a087016143cd565b836104987fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b031690565b611b11565b6104c2856104b160c0860160a087016143cd565b8661049860408801602089016143cd565b6040518481528335907f5272b980ac59723d5a8fe5be29daff5302abfaf057695289598e842dcf306e489060200160405180910390a2610781565b801561055857610558858360008151811061051a5761051a6143ea565b602002602001015160400151836104987fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b031690565b610582858360008151811061056f5761056f6143ea565b6020026020010151604001518630611b11565b8382600081518110610596576105966143ea565b6020908102919091010151608001526004546001600160a01b0316801561068957806001600160a01b0316635c702750846000815181106105d9576105d96143ea565b602002602001015160a00151856000815181106105f8576105f86143ea565b6020026020010151608001516040518363ffffffff1660e01b8152600401610621929190614400565b600060405180830381865afa15801561063e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106669190810190614466565b83600081518110610679576106796143ea565b602002602001015160a001819052505b604051630dca792360e21b81526000903090633729e48c906106b19088908890600401614546565b6020604051808303816000875af11580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f4919061439b565b905061074884600186516107089190614600565b81518110610718576107186143ea565b6020026020010151606001518660a001602081019061073791906143cd565b8361049860408a0160208b016143cd565b6040518181528535907f5272b980ac59723d5a8fe5be29daff5302abfaf057695289598e842dcf306e489060200160405180910390a250505b5050505050565b60003330146107c65760405162461bcd60e51b815260206004820152600a602482015269139bdd111a585b5bdb9960b21b6044820152606401610418565b8160008190036107e957604051630503c3ed60e01b815260040160405180910390fd5b600084846107f8600182614600565b818110610807576108076143ea565b90506020028101906108199190614617565b61082a9060808101906060016143cd565b9050600061083782611c61565b9050610844878787611ce7565b8061084e83611c61565b6108589190614600565b90508060000361087b5760405163162908e360e11b815260040160405180910390fd5b9695505050505050565b61088d6136c5565b606061089761370a565b6000806108a48682611f08565b60ff1690506108b4600183614637565b91506108c1868383611f64565b8351526108ce8183614637565b91506108da8683611f08565b60ff1690506108ea600183614637565b91506108f7868383611f64565b8351602001526109078183614637565b91506109138683611f08565b60ff169050610923600183614637565b9150610930868383611f64565b835160a001526109408183614637565b91508551821015610bd9576109558683611f08565b60ff169050610965600183614637565b9150600061097c610977888585611f64565b612071565b90506109888284614637565b9250806001600160401b038111156109a2576109a2613883565b604051908082528060200260200182016040528015610a0c57816020015b6109f96040518060c001604052806060815260200160608152602001606081526020016060815260200160008152602001606081525090565b8152602001906001900390816109c05790505b50602085015260005b81811015610bd657610a278885611f08565b60ff169250610a37600185614637565b9350610a44888585611f64565b85602001518281518110610a5a57610a5a6143ea565b60200260200101516000018190525084602001518181518110610a7f57610a7f6143ea565b60200260200101516000015185602001518281518110610aa157610aa16143ea565b6020908102919091018101510152610ab98385614637565b9350610ac58885611f08565b60ff169250610ad5600185614637565b9350610ae2888585611f64565b85602001518281518110610af857610af86143ea565b602090810291909101015160400152610b118385614637565b9350610b1d8885611f08565b60ff169250610b2d600185614637565b9350610b3a888585611f64565b85602001518281518110610b5057610b506143ea565b602090810291909101015160600152610b698385614637565b9350610b7588856120b5565b61ffff169250610b86600285614637565b9350610b93888585611f64565b85602001518281518110610ba957610ba96143ea565b602090810291909101015160a00152610bc28385614637565b935080610bce8161464f565b915050610a15565b50505b85518214610c125760405162461bcd60e51b81526020600482015260066024820152652632b722b93960d11b6044820152606401610418565b505080516020909101519094909350915050565b600080516020614c4283398151915280546001600160a01b039081166000908152600360205260408120549092911680610c6257509192915050565b6040516307c0c1df60e01b8152600481018590526001600160a01b038216906307c0c1df906024015b602060405180830381865afa158015610ca8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccc919061439b565b949350505050565b6000610cdf84612112565b90506000610cec82611c61565b905080600003610d8b576040516329c80c2f60e01b81523060048201526001600160a01b038316906329c80c2f90602401602060405180830381865afa158015610d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5e9190614668565b15610d7b5760405162461bcd60e51b815260040161041890614685565b60009150610d8882611c61565b90505b610d9681600a61217e565b905060008111610dd75760405162461bcd60e51b815260206004820152600c60248201526b131a5d1d1b19505b5bdd5b9d60a21b6044820152606401610418565b6000610de48786866103be565b905081610df084611c61565b1015610ea9576040516329c80c2f60e01b81523060048201526001600160a01b038416906329c80c2f90602401602060405180830381865afa158015610e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5e9190614668565b15610e7b5760405162461bcd60e51b815260040161041890614685565b81610e866000611c61565b1015610ea45760405162461bcd60e51b8152600401610418906146a7565b600092505b600080610eb583610885565b915091506000610ec48361218a565b30602082015290506000610ed78361225e565b9050610ee1610317565b5a1015610f225760405162461bcd60e51b815260206004820152600f60248201526e4e6f7420656e6f756768206761732160881b6044820152606401610418565b6000610f36610f2f610317565b5a90611b05565b604051630c6d751d60e21b815290915030906331b5d474908390610f64908c908c9089908990600401614729565b600060405180830381600088803b158015610f7e57600080fd5b5087f1158015610f92573d6000803e3d6000fd5b5050505050505050505050505050505050565b600080516020614c4283398151915280546001600160a01b039081166000908152600360205260408120549092911680610fe3575060009392505050565b6040516335681b5360e21b8152600481018590526001600160a01b0382169063d5a06d4c90602401610c8b565b3360009081527f2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d26020526040902054600080516020614c428339815191529060ff1661108e5760405162461bcd60e51b815260206004820152600d60248201526c2737903832b936b4b9b9b4b7b760991b6044820152606401610418565b8261109885611c61565b1015611151576040516329c80c2f60e01b81523060048201526001600160a01b038516906329c80c2f90602401602060405180830381865afa1580156110e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111069190614668565b156111235760405162461bcd60e51b815260040161041890614685565b8261112e6000611c61565b101561114c5760405162461bcd60e51b8152600401610418906146a7565b600093505b60008061115d84610885565b91509150600061116c8361218a565b905060006111798361225e565b9050611183610317565b5a10156111c45760405162461bcd60e51b815260206004820152600f60248201526e4e6f7420656e6f756768206761732160881b6044820152606401610418565b60006111d1610f2f610317565b604051630c6d751d60e21b815290915030906331b5d4749083906111ff908d908d9089908990600401614729565b600060405180830381600088803b15801561121957600080fd5b5087f19350505050801561122b575060015b61132857611237614761565b806308c379a0036112b4575061124b61477c565b8061125657506112b6565b6112668a8b8b8760200151611b11565b8351604080516020810182526000815290517f9f22c9d1796172ce7238087f7ac46b639876da8736bb55f0d957282f6cccd028916112a691859190614805565b60405180910390a250611328565b505b3d8080156112e0576040519150601f19603f3d011682016040523d82523d6000602084013e6112e5565b606091505b506112f68a8b8b8760200151611b11565b83516040517f9f22c9d1796172ce7238087f7ac46b639876da8736bb55f0d957282f6cccd028906112a690849061482a565b505050505050505050505050565b61133e61251a565b6001600160a01b038216611365576040516306b7c75960e31b815260040160405180910390fd5b600080516020614c42833981519152805461ffff8316600160a01b81026001600160b01b03199092166001600160a01b03861690811792909217835560008281527f2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d260209081526040808320805460ff1990811660019081179092553385529382902080549094161790925581519384528301919091527fdd1aad6fd60873172ecfdee635f5174c3a11648dd0769c10569f27cd596e02e891015b60405180910390a1505050565b60008061143b8435846125a3565b9050600061144985356125b8565b6001600160a01b0316631ab6243086356040880180359061146d9060208b0161484b565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915261ffff166044820152600060648201526084810185905260a40160c060405180830381865afa1580156114c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ec9190614866565b9050600061152b8260400151611525846060015161151f866080015161151f88602001518a611b0590919063ffffffff16565b90611b05565b906125ff565b905061087b86358261260b565b81518051602080850151805160a08701518051604051606097600097611566979096919594919392016148df565b60405160208183030381529060405290506000835111156115c157600061158d8451612620565b90506115bd8151826040516020016115a692919061495a565b60408051601f19818403018152919052839061269f565b9150505b60005b83518110156116ef576116db8482815181106115e2576115e26143ea565b60200260200101516000015151858381518110611601576116016143ea565b60200260200101516000015186848151811061161f5761161f6143ea565b6020026020010151604001515187858151811061163e5761163e6143ea565b60200260200101516040015188868151811061165c5761165c6143ea565b6020026020010151606001515189878151811061167b5761167b6143ea565b6020026020010151606001518a8881518110611699576116996143ea565b602002602001015160a00151518b89815181106116b8576116b86143ea565b602002602001015160a001516040516020016115a6989796959493929190614989565b9150806116e78161464f565b9150506115c4565b509392505050565b600080611710611706876143b4565b6102bf85876143c0565b6040805160608101825260808801358152600060208083018290528351808201855282815283850152600080516020614c42833981519152805495965094929391926001600160a01b031691630a51236991611770918c01908c0161484b565b600161178260c08d0160a08e016143cd565b6040516020016117aa919060609190911b6bffffffffffffffffffffffff1916815260140190565b60405160208183030381529060405288876040518663ffffffff1660e01b81526004016117db959493929190614a58565b6040805180830381865afa1580156117f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181b9190614ab0565b509998505050505050505050565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b80546000190161186d576040516329f745a760e01b815260040160405180910390fd5b600181556000806118856118808a6143b4565b61218a565b9050600061189b611896898b6143c0565b61225e565b90506118b282606001516001600160a01b03161590565b6118c8576118c882606001518360c0015161271c565b80516000036118fa5760608201516118ee906118e48935612112565b8460c00151612735565b8160c001519250611a02565b8060008151811061190d5761190d6143ea565b6020026020010151608001518260c00151146119575760405162461bcd60e51b815260206004820152600960248201526820b6b7bab73a22b93960b91b6044820152606401610418565b604051630dca792360e21b81523090633729e48c9061197c9085908590600401614ad4565b6020604051808303816000875af115801561199b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bf919061439b565b9250611a0281600183516119d39190614600565b815181106119e3576119e36143ea565b6020026020010151606001516119fc8960000135612112565b85612735565b6000611a0d8361294a565b90506000611a27611a1d8d6143b4565b6102bf898b6143c0565b9050611a35898387846129a5565b83516040517f0f0fd0ad174232a46f92a8d76b425830f45436483106ee965bbe91d3b7d1cd2690600090a250506000909355505050505050505050565b611a7a61251a565b6001600160a01b03821660008181527f2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d26020908152604091829020805460ff1916851515908117909155825193845290830152600080516020614c42833981519152917fa915695662b2872d8e64773d8301cf0e418b55f86ee42d4c8f5c07d8f0bb19b09101611420565b60006103d98284614600565b6001600160a01b038316611bca57826001600160a01b0316846001600160a01b031614611bc557604051632e1a7d4d60e01b8152600481018390526001600160a01b03851690632e1a7d4d90602401600060405180830381600087803b158015611b7a57600080fd5b505af1925050508015611b8b575060015b611bc55760405162461bcd60e51b815260206004820152600b60248201526a2bb4ba34323930bba2b93960a91b6044820152606401610418565b611c18565b826001600160a01b0316846001600160a01b031614611c185760405162461bcd60e51b815260206004820152600a60248201526920b9b9b2ba24b222b93960b11b6044820152606401610418565b6001600160a01b0381163014611c5b5781611c3284611c61565b1015611c505760405162461bcd60e51b8152600401610418906146a7565b611c5b838284612b21565b50505050565b60006001600160a01b03821615611cdf576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611cb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cda919061439b565b611ce1565b475b92915050565b600082826000818110611cfc57611cfc6143ea565b9050602002810190611d0e9190614617565b611d1790614af5565b905060005b828110156107815760608201516000611d3482611c61565b6020808601516001600160a01b0316600090815290819052604090205490915060ff168015611d7c575083516001600160a01b031660009081526020819052604090205460ff165b8015611db9575060006001016000611d9b8660a0015160006004612b45565b611da490614b01565b815260208101919091526040016000205460ff165b611dd657604051632514e60160e21b815260040160405180910390fd5b8651611de29085612c03565b80611dec83611c61565b611df69190614600565b905084611e04846001614637565b1015611ef3578585611e17856001614637565b818110611e2657611e266143ea565b9050602002810190611e389190614617565b611e4190614af5565b6004549094506001600160a01b031680611e6e576040516374c37b4360e11b815260040160405180910390fd5b6080850182905260a08501516040516305c7027560e41b81526001600160a01b03831691635c70275091611ea791908690600401614400565b600060405180830381865afa158015611ec4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eec9190810190614466565b60a0860152505b50508080611f009061464f565b915050611d1c565b6000611f15826001614637565b83511015611f5b5760405162461bcd60e51b8152602060048201526013602482015272746f55696e74385f6f75744f66426f756e647360681b6044820152606401610418565b50016001015190565b606081611f7281601f614637565b1015611fb15760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401610418565b611fbb8284614637565b84511015611fff5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401610418565b60608215801561201e5760405191506000825260208201604052612068565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561205757805183526020928301920161203f565b5050858452601f01601f1916604052505b50949350505050565b600080805b83518110156120ae576120898482611f08565b61209a9060ff16600884901b614637565b9150806120a68161464f565b915050612076565b5092915050565b60006120c2826002614637565b835110156121095760405162461bcd60e51b8152602060048201526014602482015273746f55696e7431365f6f75744f66426f756e647360601b6044820152606401610418565b50016002015190565b600061211d82612df2565b6001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561215a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce19190614b25565b60006103d98284614b42565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091526040805160e08101909152825181906121dd906000612ee0565b81526020016121ef8460200151612f3e565b6001600160a01b03168152602001836040015161ffff1681526020016122188460600151612f3e565b6001600160a01b03168152602001836080015161ffff1681526020016122418460a00151612f3e565b6001600160a01b031681526020018360c001518152509050919050565b6060600082516001600160401b0381111561227b5761227b613883565b6040519080825280602002602001820160405280156122dd57816020015b6040805160c081018252600080825260208083018290529282018190526060808301829052608083019190915260a082015282526000199092019101816122995790505b50905060005b81518110156120ae5761231d6000858381518110612303576123036143ea565b602002602001015160000151612f5c90919063ffffffff16565b82828151811061232f5761232f6143ea565b6020026020010151600001906001600160a01b031690816001600160a01b031681525050612384600085838151811061236a5761236a6143ea565b602002602001015160200151612f5c90919063ffffffff16565b828281518110612396576123966143ea565b6020026020010151602001906001600160a01b031690816001600160a01b0316815250506123eb60008583815181106123d1576123d16143ea565b602002602001015160400151612f5c90919063ffffffff16565b8282815181106123fd576123fd6143ea565b6020026020010151604001906001600160a01b031690816001600160a01b0316815250506124526000858381518110612438576124386143ea565b602002602001015160600151612f5c90919063ffffffff16565b828281518110612464576124646143ea565b6020026020010151606001906001600160a01b031690816001600160a01b03168152505083818151811061249a5761249a6143ea565b6020026020010151608001518282815181106124b8576124b86143ea565b602002602001015160800181815250508381815181106124da576124da6143ea565b602002602001015160a001518282815181106124f8576124f86143ea565b602002602001015160a0018190525080806125129061464f565b9150506122e3565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b031633146125a15760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b6064820152608401610418565b565b60006103d96125b184612fc1565b839061217e565b60006125c382612df2565b6001600160a01b0316621edfab6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561215a573d6000803e3d6000fd5b60006103d98284614637565b60006103d961261984612fc1565b839061302d565b6040805160f883901b6001600160f81b031916602082015281516001818303018152602190910190915260089190911c906060905b8215611ce1576040516001600160f81b031960f885901b16602082015261269190829060210160408051601f198184030181529190529061269f565b9050600883901c9250612655565b6060806040519050835180825260208201818101602087015b818310156126d05780518352602092830192016126b8565b50855184518101855292509050808201602086015b818310156126fd5780518352602092830192016126e5565b508651929092011591909101601f01601f191660405250905092915050565b61273182826001600160a01b03821615613039565b5050565b816001600160a01b0316836001600160a01b03160361277b578061275884611c61565b10156127765760405162461bcd60e51b8152600401610418906146a7565b505050565b6001600160a01b03831661280f57816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156127c457600080fd5b505af1935050505080156127d6575060015b6127765760405162461bcd60e51b815260206004820152600a6024820152692232b837b9b4ba22b93960b11b6044820152606401610418565b816001600160a01b0316836001600160a01b03161461277657604051632e1a7d4d60e01b8152600481018290526001600160a01b03841690632e1a7d4d90602401600060405180830381600087803b15801561286a57600080fd5b505af192505050801561287b575060015b6128bc5760405162461bcd60e51b81526020600482015260126024820152712232b837b9b4ba2bb4ba34323930bba2b93960711b6044820152606401610418565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156128f757600080fd5b505af193505050508015612909575060015b6127765760405162461bcd60e51b81526020600482015260126024820152712bb4ba34323930bba232b837b9b4ba22b93960711b6044820152606401610418565b600061296182606001516001600160a01b03161590565b15612999578160c0015134116129895760405162461bcd60e51b8152600401610418906146a7565b60c0820151611ce1903490611b05565b5034919050565b919050565b600080516020614c4283398151915280546001600160a01b03166129cf604087016020880161484b565b825461ffff918216600160a01b90910490911603612a0057604051634ac09ad360e01b815260040160405180910390fd5b612a14612a0d8735612112565b82866130cc565b604080516060810182526080880135815260006020808301829052835190810184528181529282019290925290612a5160c0890160a08a016143cd565b604051602001612a79919060609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040529050826001600160a01b0316639fbf10fc888a6020016020810190612aad919061484b565b8b600001358c60400135338c8f606001358a8a8f6040518b63ffffffff1660e01b8152600401612ae599989796959493929190614b64565b6000604051808303818588803b158015612afe57600080fd5b505af1158015612b12573d6000803e3d6000fd5b50505050505050505050505050565b6001600160a01b03831615612b3b57612776838383613191565b61277682826131c3565b60608183108015612b57575083518211155b612b975760405162461bcd60e51b8152602060048201526011602482015270446174614c656e677468206572726f722160781b6044820152606401610418565b604080516020810190915260008152835b838110156120685781868281518110612bc357612bc36143ea565b602001015160f81c60f81b604051602001612bdf929190614be1565b60405160208183030381529060405291508080612bfb9061464f565b915050612ba8565b80513b612c23576040516303777f6960e51b815260040160405180910390fd5b60808101516000819003612c4a5760405163391b81e760e21b815260040160405180910390fd5b604082015160608301516000919082612c6283611c61565b90506000612c6f83611c61565b90506000868310612c81576000612c8b565b612c8b8388614600565b90506001600160a01b03851615612cc257612cab858960200151896130cc565b8015612cbd57612cbd8533308461325e565b612cc6565b8695505b60008089600001516001600160a01b0316888b60a00151604051612cea9190614c10565b60006040518083038185875af1925050503d8060008114612d27576040519150601f19603f3d011682016040523d82523d6000602084013e612d2c565b606091505b509150915081612d5d576000612d41826132b8565b90508060405162461bcd60e51b8152600401610418919061384d565b7f7bfdfdb5e3a3776976e53cb0607060f54c5312701c8cba1155cc4d5394440b388b8b600001518c60400151898d89612d958d611c61565b612d9f9190614600565b604080519687526001600160a01b0395861660208801529385169386019390935292166060840152608083019190915260a08201524260c082015260e00160405180910390a15050505050505050505050565b600080516020614c4283398151915280546040805163c45a015560e01b815290516000939284926001600160a01b039091169163c45a0155916004808201926020929091908290030181865afa158015612e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e749190614b25565b60405163068bcd8d60e01b8152600481018690529091506001600160a01b0382169063068bcd8d90602401602060405180830381865afa158015612ebc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccc9190614b25565b6000612eed826020614637565b83511015612f355760405162461bcd60e51b8152602060048201526015602482015274746f427974657333325f6f75744f66426f756e647360581b6044820152606401610418565b50016020015190565b60008151601403612f5457611ce1826000612f5c565b506000919050565b6000612f69826014614637565b83511015612fb15760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b6044820152606401610418565b500160200151600160601b900490565b6000612fcc82612df2565b6001600160a01b031663feb56b156040518163ffffffff1660e01b8152600401602060405180830381865afa158015613009573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce1919061439b565b60006103d98284614c22565b8160000361305a5760405163162908e360e11b815260040160405180910390fd5b8015613080578134146127765760405163162908e360e11b815260040160405180910390fd5b600061308b84611c61565b90506130998433308661325e565b82816130a486611c61565b6130ae9190614600565b14611c5b5760405163162908e360e11b815260040160405180910390fd5b6001600160a01b0383166130df57505050565b6001600160a01b038216613106576040516363ba9bff60e01b815260040160405180910390fd5b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015613156573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317a919061439b565b905081811015611c5b57611c5b848460001961332f565b6001600160a01b0383166131b85760405163346fafc360e21b815260040160405180910390fd5b612776838383613477565b6001600160a01b0382166131ea576040516321f7434560e01b815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613237576040519150601f19603f3d011682016040523d82523d6000602084013e61323c565b606091505b505090508061277657604051635a04673760e01b815260040160405180910390fd5b6001600160a01b0384166132855760405163346fafc360e21b815260040160405180910390fd5b6001600160a01b0382166132ac576040516321f7434560e01b815260040160405180910390fd5b611c5b848484846134a7565b60606044825110156132fd57505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b600061331960048085516133119190614600565b859190611f64565b9050808060200190518101906103d99190614466565b8015806133a95750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015613383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a7919061439b565b155b6134145760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610418565b6040516001600160a01b03831660248201526044810182905261277690849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526134df565b6040516001600160a01b03831660248201526044810182905261277690849063a9059cbb60e01b90606401613440565b6040516001600160a01b0380851660248301528316604482015260648101829052611c5b9085906323b872dd60e01b90608401613440565b6000613534826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135b19092919063ffffffff16565b80519091501561277657808060200190518101906135529190614668565b6127765760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610418565b60606103d68484600085856001600160a01b0385163b6136135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610418565b600080866001600160a01b0316858760405161362f9190614c10565b60006040518083038185875af1925050503d806000811461366c576040519150601f19603f3d011682016040523d82523d6000602084013e613671565b606091505b509150915061368182828661368c565b979650505050505050565b6060831561369b5750816103d9565b8251156136ab5782518084602001fd5b8160405162461bcd60e51b8152600401610418919061384d565b6040518060e001604052806060815260200160608152602001600061ffff16815260200160608152602001600061ffff16815260200160608152602001600081525090565b604051806040016040528061371d6136c5565b8152602001606081525090565b600060e0828403121561373c57600080fd5b50919050565b60008083601f84011261375457600080fd5b5081356001600160401b0381111561376b57600080fd5b6020830191508360208260051b850101111561378657600080fd5b9250929050565b6000806000604084860312156137a257600080fd5b83356001600160401b03808211156137b957600080fd5b6137c58783880161372a565b945060208601359150808211156137db57600080fd5b506137e886828701613742565b9497909650939450505050565b60005b838110156138105781810151838201526020016137f8565b83811115611c5b5750506000910152565b600081518084526138398160208601602086016137f5565b601f01601f19169290920160200192915050565b6020815260006103d96020830184613821565b6001600160a01b038116811461387557600080fd5b50565b80356129a081613860565b634e487b7160e01b600052604160045260246000fd5b60e081018181106001600160401b03821117156138b8576138b8613883565b60405250565b601f8201601f191681016001600160401b03811182821017156138e3576138e3613883565b6040525050565b6040516138f681613899565b90565b60405160c081016001600160401b038111828210171561391b5761391b613883565b60405290565b60006001600160401b0382111561393a5761393a613883565b5060051b60200190565b60006001600160401b0382111561395d5761395d613883565b50601f01601f191660200190565b600082601f83011261397c57600080fd5b813561398781613944565b60405161399482826138be565b8281528560208487010111156139a957600080fd5b82602086016020830137600092810160200192909252509392505050565b600060c082840312156139d957600080fd5b60405160c081016001600160401b0382821081831117156139fc576139fc613883565b8160405282935084359150613a1082613860565b818352613a1f60208601613878565b6020840152613a3060408601613878565b6040840152613a4160608601613878565b60608401526080850135608084015260a0850135915080821115613a6457600080fd5b50613a718582860161396b565b60a0830152505092915050565b6000806000806101408587031215613a9557600080fd5b8435613aa081613860565b93506020858101359350613ab7876040880161372a565b92506101208601356001600160401b0380821115613ad457600080fd5b818801915088601f830112613ae857600080fd5b8135613af381613921565b604051613b0082826138be565b82815260059290921b840185019185810191508b831115613b2057600080fd5b8585015b83811015613b5857803585811115613b3c5760008081fd5b613b4a8e89838a01016139c7565b845250918601918601613b24565b50989b979a50959850505050505050565b803561ffff811681146129a057600080fd5b6000806000838503610100811215613b9257600080fd5b60e0811215613ba057600080fd5b50604051613bad81613899565b843581526020850135613bbf81613860565b6020820152613bd060408601613b69565b60408201526060850135613be381613860565b6060820152613bf460808601613b69565b6080820152613c0560a08601613878565b60a082015260c08581013590820152925060e08401356001600160401b03811115613c2f57600080fd5b6137e886828701613742565b600060208284031215613c4d57600080fd5b81356001600160401b03811115613c6357600080fd5b610ccc8482850161396b565b600081518084526020808501808196508360051b8101915082860160005b85811015613d39578284038952815160c08151818752613caf82880182613821565b9150508682015186820388880152613cc78282613821565b91505060408083015187830382890152613ce18382613821565b9250505060608083015187830382890152613cfc8382613821565b92505050608080830151818801525060a08083015192508682038188015250613d258183613821565b9a87019a9550505090840190600101613c8d565b5091979650505050505050565b604081526000835160e06040840152613d63610120840182613821565b90506020850151603f1980858403016060860152613d818383613821565b925061ffff604088015116608086015260608701519150808584030160a0860152613dac8383613821565b925060808701519150613dc560c086018361ffff169052565b60a08701519150808584030160e086015250613de18282613821565b91505060c08501516101008401528281036020840152613e018185613c6f565b95945050505050565b600060208284031215613e1c57600080fd5b5035919050565b60008060008060608587031215613e3957600080fd5b84356001600160401b0380821115613e5057600080fd5b613e5c8883890161372a565b9550602087013594506040870135915080821115613e7957600080fd5b50613e8687828801613742565b95989497509550505050565b60008060008060008060c08789031215613eab57600080fd5b613eb487613b69565b955060208701356001600160401b0380821115613ed057600080fd5b613edc8a838b0161396b565b96506040890135955060608901359150613ef582613860565b9093506080880135925060a08801359080821115613f1257600080fd5b50613f1f89828a0161396b565b9150509295509295509295565b60008060408385031215613f3f57600080fd5b8235613f4a81613860565b9150613f5860208401613b69565b90509250929050565b600060c0828403121561373c57600080fd5b60008060e08385031215613f8657600080fd5b613f908484613f61565b9460c0939093013593505050565b600060e08284031215613fb057600080fd5b613fb86138ea565b905081356001600160401b0380821115613fd157600080fd5b613fdd8583860161396b565b83526020840135915080821115613ff357600080fd5b613fff8583860161396b565b602084015261401060408501613b69565b6040840152606084013591508082111561402957600080fd5b6140358583860161396b565b606084015261404660808501613b69565b608084015260a084013591508082111561405f57600080fd5b5061406c8482850161396b565b60a08301525060c082013560c082015292915050565b600061408d83613921565b6040805161409b83826138be565b858152925060208084019250600586901b850190878211156140bc57600080fd5b855b828110156141c85780356001600160401b03808211156140de5760008081fd5b9088019060c0828c0312156140f35760008081fd5b6140fb6138f9565b82358281111561410b5760008081fd5b6141178d82860161396b565b825250848301358281111561412c5760008081fd5b6141388d82860161396b565b8683015250868301358281111561414f5760008081fd5b61415b8d82860161396b565b8883015250606080840135838111156141745760008081fd5b6141808e82870161396b565b828401525050608080840135818301525060a080840135838111156141a55760008081fd5b6141b18e82870161396b565b9183019190915250875250509381019381016140be565b50505050509392505050565b600080604083850312156141e757600080fd5b82356001600160401b03808211156141fe57600080fd5b61420a86838701613f9e565b9350602085013591508082111561422057600080fd5b508301601f8101851361423257600080fd5b61424185823560208401614082565b9150509250929050565b600080600080610100858703121561426257600080fd5b84356001600160401b038082111561427957600080fd5b6142858883890161372a565b95506142948860208901613f61565b945060e0870135915080821115613e7957600080fd5b60008060008060008061012087890312156142c457600080fd5b86356001600160401b03808211156142db57600080fd5b6142e78a838b0161372a565b975060208901359150808211156142fd57600080fd5b6143098a838b01613742565b909750955085915061431e8a60408b01613f61565b945061010089013591508082111561433557600080fd5b5061434289828a01613742565b979a9699509497509295939492505050565b801515811461387557600080fd5b6000806040838503121561437557600080fd5b823561438081613860565b9150602083013561439081614354565b809150509250929050565b6000602082840312156143ad57600080fd5b5051919050565b6000611ce13683613f9e565b60006103d9368484614082565b6000602082840312156143df57600080fd5b81356103d981613860565b634e487b7160e01b600052603260045260246000fd5b6040815260006144136040830185613821565b90508260208301529392505050565b600061442d83613944565b60405161443a82826138be565b80925084815285858501111561444f57600080fd5b61445d8560208301866137f5565b50509392505050565b60006020828403121561447857600080fd5b81516001600160401b0381111561448e57600080fd5b8201601f8101841361449f57600080fd5b610ccc84825160208401614422565b600081518084526020808501808196508360051b8101915082860160005b85811015613d39578284038952815180516001600160a01b03908116865286820151811687870152604080830151821690870152606080830151909116908601526080808201519086015260a09081015160c09186018290529061453281870183613821565b9a87019a95505050908401906001016144cc565b600061010084358352602085013561455d81613860565b6001600160a01b03818116602086015261457960408801613b69565b61ffff90811660408701526060880135925061459483613860565b8183166060870152806145a960808a01613b69565b1660808701525050506145be60a08601613878565b6001600160a01b03811660a08501525060c085013560c08401528060e0840152613e01818401856144ae565b634e487b7160e01b600052601160045260246000fd5b600082821015614612576146126145ea565b500390565b6000823560be1983360301811261462d57600080fd5b9190910192915050565b6000821982111561464a5761464a6145ea565b500190565b600060018201614661576146616145ea565b5060010190565b60006020828403121561467a57600080fd5b81516103d981614354565b6020808252600890820152672a37b5b2b722b93960c11b604082015260600190565b60208082526009908201526809cdee88adcdeeaced60bb1b604082015260600190565b80518252602081015160018060a01b0380821660208501526040830151915061ffff8083166040860152816060850151166060860152806080850151166080860152508060a08401511660a0850152505060c081015160c08301525050565b6001600160a01b038516815260208101849052600061014061474e60408401866146ca565b80610120840152613681818401856144ae565b600060033d11156138f65760046000803e5060005160e01c90565b600060443d101561478a5790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156147b957505050505090565b82850191508151818111156147d15750505050505090565b843d87010160208285010111156147eb5750505050505090565b6147fa602082860101876138be565b509095945050505050565b6040815260006148186040830185613821565b8281036020840152613e018185613821565b60408152600060408201526060602082015260006103d96060830184613821565b60006020828403121561485d57600080fd5b6103d982613b69565b600060c0828403121561487857600080fd5b60405160c081018181106001600160401b038211171561489a5761489a613883565b8060405250825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a08201528091505092915050565b600060ff60f81b808960f81b1683528751614901816001860160208c016137f5565b8084019050818860f81b1660018201528651614924816002840160208b016137f5565b808201915050818660f81b1660028201528451915061494a8260038301602088016137f5565b0160030198975050505050505050565b60ff60f81b8360f81b1681526000825161497b8160018501602087016137f5565b919091016001019392505050565b600060ff60f81b808b60f81b16835289516149ab816001860160208e016137f5565b8084019050818a60f81b16600182015288516149ce816002840160208d016137f5565b808201915050818860f81b166002820152865191506149f4826003830160208a016137f5565b81810191505061ffff60f01b8560f01b1660038201528351614a1d8160058401602088016137f5565b016005019a9950505050505050505050565b80518252602081015160208301526000604082015160606040850152610ccc6060850182613821565b61ffff8616815260ff8516602082015260a060408201526000614a7e60a0830186613821565b8281036060840152614a908186613821565b90508281036080840152614aa48185614a2f565b98975050505050505050565b60008060408385031215614ac357600080fd5b505080516020909101519092909150565b6000610100614ae383866146ca565b8060e0840152613e01818401856144ae565b6000611ce136836139c7565b8051602080830151919081101561373c5760001960209190910360031b1b16919050565b600060208284031215614b3757600080fd5b81516103d981613860565b600082614b5f57634e487b7160e01b600052601260045260246000fd5b500490565b600061012061ffff8c1683528a602084015289604084015260018060a01b03891660608401528760808401528660a08401528060c0840152614ba881840187614a2f565b905082810360e0840152614bbc8186613821565b9050828103610100840152614bd18185613821565b9c9b505050505050505050505050565b60008351614bf38184602088016137f5565b6001600160f81b0319939093169190920190815260010192915050565b6000825161462d8184602087016137f5565b6000816000190483118215151615614c3c57614c3c6145ea565b50029056fe2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d1a2646970667358221220ffb7c160f3bc3f9b49d38c6a25f3158cee47dcb2df0d45e1ade32315c8344ec564736f6c634300080d0033
Deployed Bytecode
0x6080604052600436106100f35760003560e01c806398e038d71161008a578063df3c5ac311610059578063df3c5ac3146102a4578063e31dc6be146102c4578063eedfa7cd146102e4578063fae36986146102f757600080fd5b806398e038d714610224578063ab8236f314610244578063af66a6d814610264578063cd96eb9a1461028457600080fd5b8063762a9962116100c6578063762a99621461018f5780637e3c358b146101bd57806380d0d656146101dd578063958b3ab01461020457600080fd5b80630e7e8ba2146100f85780633136c5601461012057806331b5d4741461014d5780633729e48c1461016f575b600080fd5b34801561010457600080fd5b5061010d610317565b6040519081526020015b60405180910390f35b34801561012c57600080fd5b5061014061013b36600461378d565b6103be565b604051610117919061384d565b34801561015957600080fd5b5061016d610168366004613a7e565b6103e0565b005b34801561017b57600080fd5b5061010d61018a366004613b7b565b610788565b34801561019b57600080fd5b506101af6101aa366004613c3b565b610885565b604051610117929190613d46565b3480156101c957600080fd5b5061010d6101d8366004613e0a565b610c26565b3480156101e957600080fd5b506101f2603b81565b60405160ff9091168152602001610117565b34801561021057600080fd5b5061016d61021f366004613e23565b610cd4565b34801561023057600080fd5b5061010d61023f366004613e0a565b610fa5565b34801561025057600080fd5b5061016d61025f366004613e92565b611010565b34801561027057600080fd5b5061016d61027f366004613f2c565b611336565b34801561029057600080fd5b5061010d61029f366004613f73565b61142d565b3480156102b057600080fd5b506101406102bf3660046141d4565b611538565b3480156102d057600080fd5b5061010d6102df36600461424b565b6116f7565b61016d6102f23660046142aa565b611829565b34801561030357600080fd5b5061016d610312366004614362565b611a72565b600080516020614c4283398151915280546001600160a01b039081166000908152600360205260408120549092911680610355576175309250505090565b806001600160a01b0316634f0ba55f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b7919061439b565b9250505090565b60606103d66103cc856143b4565b6102bf84866143c0565b90505b9392505050565b3330146104215760405162461bcd60e51b815260206004820152600a602482015269139bdd111a585b5bdb9960b21b60448201526064015b60405180910390fd5b600061042c84610fa5565b905083811015610443576104408482611b05565b93505b81516000036104fd57801561049d5761049d8561046660c0860160a087016143cd565b836104987fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b031690565b611b11565b6104c2856104b160c0860160a087016143cd565b8661049860408801602089016143cd565b6040518481528335907f5272b980ac59723d5a8fe5be29daff5302abfaf057695289598e842dcf306e489060200160405180910390a2610781565b801561055857610558858360008151811061051a5761051a6143ea565b602002602001015160400151836104987fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b031690565b610582858360008151811061056f5761056f6143ea565b6020026020010151604001518630611b11565b8382600081518110610596576105966143ea565b6020908102919091010151608001526004546001600160a01b0316801561068957806001600160a01b0316635c702750846000815181106105d9576105d96143ea565b602002602001015160a00151856000815181106105f8576105f86143ea565b6020026020010151608001516040518363ffffffff1660e01b8152600401610621929190614400565b600060405180830381865afa15801561063e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106669190810190614466565b83600081518110610679576106796143ea565b602002602001015160a001819052505b604051630dca792360e21b81526000903090633729e48c906106b19088908890600401614546565b6020604051808303816000875af11580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f4919061439b565b905061074884600186516107089190614600565b81518110610718576107186143ea565b6020026020010151606001518660a001602081019061073791906143cd565b8361049860408a0160208b016143cd565b6040518181528535907f5272b980ac59723d5a8fe5be29daff5302abfaf057695289598e842dcf306e489060200160405180910390a250505b5050505050565b60003330146107c65760405162461bcd60e51b815260206004820152600a602482015269139bdd111a585b5bdb9960b21b6044820152606401610418565b8160008190036107e957604051630503c3ed60e01b815260040160405180910390fd5b600084846107f8600182614600565b818110610807576108076143ea565b90506020028101906108199190614617565b61082a9060808101906060016143cd565b9050600061083782611c61565b9050610844878787611ce7565b8061084e83611c61565b6108589190614600565b90508060000361087b5760405163162908e360e11b815260040160405180910390fd5b9695505050505050565b61088d6136c5565b606061089761370a565b6000806108a48682611f08565b60ff1690506108b4600183614637565b91506108c1868383611f64565b8351526108ce8183614637565b91506108da8683611f08565b60ff1690506108ea600183614637565b91506108f7868383611f64565b8351602001526109078183614637565b91506109138683611f08565b60ff169050610923600183614637565b9150610930868383611f64565b835160a001526109408183614637565b91508551821015610bd9576109558683611f08565b60ff169050610965600183614637565b9150600061097c610977888585611f64565b612071565b90506109888284614637565b9250806001600160401b038111156109a2576109a2613883565b604051908082528060200260200182016040528015610a0c57816020015b6109f96040518060c001604052806060815260200160608152602001606081526020016060815260200160008152602001606081525090565b8152602001906001900390816109c05790505b50602085015260005b81811015610bd657610a278885611f08565b60ff169250610a37600185614637565b9350610a44888585611f64565b85602001518281518110610a5a57610a5a6143ea565b60200260200101516000018190525084602001518181518110610a7f57610a7f6143ea565b60200260200101516000015185602001518281518110610aa157610aa16143ea565b6020908102919091018101510152610ab98385614637565b9350610ac58885611f08565b60ff169250610ad5600185614637565b9350610ae2888585611f64565b85602001518281518110610af857610af86143ea565b602090810291909101015160400152610b118385614637565b9350610b1d8885611f08565b60ff169250610b2d600185614637565b9350610b3a888585611f64565b85602001518281518110610b5057610b506143ea565b602090810291909101015160600152610b698385614637565b9350610b7588856120b5565b61ffff169250610b86600285614637565b9350610b93888585611f64565b85602001518281518110610ba957610ba96143ea565b602090810291909101015160a00152610bc28385614637565b935080610bce8161464f565b915050610a15565b50505b85518214610c125760405162461bcd60e51b81526020600482015260066024820152652632b722b93960d11b6044820152606401610418565b505080516020909101519094909350915050565b600080516020614c4283398151915280546001600160a01b039081166000908152600360205260408120549092911680610c6257509192915050565b6040516307c0c1df60e01b8152600481018590526001600160a01b038216906307c0c1df906024015b602060405180830381865afa158015610ca8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccc919061439b565b949350505050565b6000610cdf84612112565b90506000610cec82611c61565b905080600003610d8b576040516329c80c2f60e01b81523060048201526001600160a01b038316906329c80c2f90602401602060405180830381865afa158015610d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5e9190614668565b15610d7b5760405162461bcd60e51b815260040161041890614685565b60009150610d8882611c61565b90505b610d9681600a61217e565b905060008111610dd75760405162461bcd60e51b815260206004820152600c60248201526b131a5d1d1b19505b5bdd5b9d60a21b6044820152606401610418565b6000610de48786866103be565b905081610df084611c61565b1015610ea9576040516329c80c2f60e01b81523060048201526001600160a01b038416906329c80c2f90602401602060405180830381865afa158015610e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5e9190614668565b15610e7b5760405162461bcd60e51b815260040161041890614685565b81610e866000611c61565b1015610ea45760405162461bcd60e51b8152600401610418906146a7565b600092505b600080610eb583610885565b915091506000610ec48361218a565b30602082015290506000610ed78361225e565b9050610ee1610317565b5a1015610f225760405162461bcd60e51b815260206004820152600f60248201526e4e6f7420656e6f756768206761732160881b6044820152606401610418565b6000610f36610f2f610317565b5a90611b05565b604051630c6d751d60e21b815290915030906331b5d474908390610f64908c908c9089908990600401614729565b600060405180830381600088803b158015610f7e57600080fd5b5087f1158015610f92573d6000803e3d6000fd5b5050505050505050505050505050505050565b600080516020614c4283398151915280546001600160a01b039081166000908152600360205260408120549092911680610fe3575060009392505050565b6040516335681b5360e21b8152600481018590526001600160a01b0382169063d5a06d4c90602401610c8b565b3360009081527f2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d26020526040902054600080516020614c428339815191529060ff1661108e5760405162461bcd60e51b815260206004820152600d60248201526c2737903832b936b4b9b9b4b7b760991b6044820152606401610418565b8261109885611c61565b1015611151576040516329c80c2f60e01b81523060048201526001600160a01b038516906329c80c2f90602401602060405180830381865afa1580156110e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111069190614668565b156111235760405162461bcd60e51b815260040161041890614685565b8261112e6000611c61565b101561114c5760405162461bcd60e51b8152600401610418906146a7565b600093505b60008061115d84610885565b91509150600061116c8361218a565b905060006111798361225e565b9050611183610317565b5a10156111c45760405162461bcd60e51b815260206004820152600f60248201526e4e6f7420656e6f756768206761732160881b6044820152606401610418565b60006111d1610f2f610317565b604051630c6d751d60e21b815290915030906331b5d4749083906111ff908d908d9089908990600401614729565b600060405180830381600088803b15801561121957600080fd5b5087f19350505050801561122b575060015b61132857611237614761565b806308c379a0036112b4575061124b61477c565b8061125657506112b6565b6112668a8b8b8760200151611b11565b8351604080516020810182526000815290517f9f22c9d1796172ce7238087f7ac46b639876da8736bb55f0d957282f6cccd028916112a691859190614805565b60405180910390a250611328565b505b3d8080156112e0576040519150601f19603f3d011682016040523d82523d6000602084013e6112e5565b606091505b506112f68a8b8b8760200151611b11565b83516040517f9f22c9d1796172ce7238087f7ac46b639876da8736bb55f0d957282f6cccd028906112a690849061482a565b505050505050505050505050565b61133e61251a565b6001600160a01b038216611365576040516306b7c75960e31b815260040160405180910390fd5b600080516020614c42833981519152805461ffff8316600160a01b81026001600160b01b03199092166001600160a01b03861690811792909217835560008281527f2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d260209081526040808320805460ff1990811660019081179092553385529382902080549094161790925581519384528301919091527fdd1aad6fd60873172ecfdee635f5174c3a11648dd0769c10569f27cd596e02e891015b60405180910390a1505050565b60008061143b8435846125a3565b9050600061144985356125b8565b6001600160a01b0316631ab6243086356040880180359061146d9060208b0161484b565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915261ffff166044820152600060648201526084810185905260a40160c060405180830381865afa1580156114c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ec9190614866565b9050600061152b8260400151611525846060015161151f866080015161151f88602001518a611b0590919063ffffffff16565b90611b05565b906125ff565b905061087b86358261260b565b81518051602080850151805160a08701518051604051606097600097611566979096919594919392016148df565b60405160208183030381529060405290506000835111156115c157600061158d8451612620565b90506115bd8151826040516020016115a692919061495a565b60408051601f19818403018152919052839061269f565b9150505b60005b83518110156116ef576116db8482815181106115e2576115e26143ea565b60200260200101516000015151858381518110611601576116016143ea565b60200260200101516000015186848151811061161f5761161f6143ea565b6020026020010151604001515187858151811061163e5761163e6143ea565b60200260200101516040015188868151811061165c5761165c6143ea565b6020026020010151606001515189878151811061167b5761167b6143ea565b6020026020010151606001518a8881518110611699576116996143ea565b602002602001015160a00151518b89815181106116b8576116b86143ea565b602002602001015160a001516040516020016115a6989796959493929190614989565b9150806116e78161464f565b9150506115c4565b509392505050565b600080611710611706876143b4565b6102bf85876143c0565b6040805160608101825260808801358152600060208083018290528351808201855282815283850152600080516020614c42833981519152805495965094929391926001600160a01b031691630a51236991611770918c01908c0161484b565b600161178260c08d0160a08e016143cd565b6040516020016117aa919060609190911b6bffffffffffffffffffffffff1916815260140190565b60405160208183030381529060405288876040518663ffffffff1660e01b81526004016117db959493929190614a58565b6040805180830381865afa1580156117f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181b9190614ab0565b509998505050505050505050565b7fa65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b80546000190161186d576040516329f745a760e01b815260040160405180910390fd5b600181556000806118856118808a6143b4565b61218a565b9050600061189b611896898b6143c0565b61225e565b90506118b282606001516001600160a01b03161590565b6118c8576118c882606001518360c0015161271c565b80516000036118fa5760608201516118ee906118e48935612112565b8460c00151612735565b8160c001519250611a02565b8060008151811061190d5761190d6143ea565b6020026020010151608001518260c00151146119575760405162461bcd60e51b815260206004820152600960248201526820b6b7bab73a22b93960b91b6044820152606401610418565b604051630dca792360e21b81523090633729e48c9061197c9085908590600401614ad4565b6020604051808303816000875af115801561199b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bf919061439b565b9250611a0281600183516119d39190614600565b815181106119e3576119e36143ea565b6020026020010151606001516119fc8960000135612112565b85612735565b6000611a0d8361294a565b90506000611a27611a1d8d6143b4565b6102bf898b6143c0565b9050611a35898387846129a5565b83516040517f0f0fd0ad174232a46f92a8d76b425830f45436483106ee965bbe91d3b7d1cd2690600090a250506000909355505050505050505050565b611a7a61251a565b6001600160a01b03821660008181527f2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d26020908152604091829020805460ff1916851515908117909155825193845290830152600080516020614c42833981519152917fa915695662b2872d8e64773d8301cf0e418b55f86ee42d4c8f5c07d8f0bb19b09101611420565b60006103d98284614600565b6001600160a01b038316611bca57826001600160a01b0316846001600160a01b031614611bc557604051632e1a7d4d60e01b8152600481018390526001600160a01b03851690632e1a7d4d90602401600060405180830381600087803b158015611b7a57600080fd5b505af1925050508015611b8b575060015b611bc55760405162461bcd60e51b815260206004820152600b60248201526a2bb4ba34323930bba2b93960a91b6044820152606401610418565b611c18565b826001600160a01b0316846001600160a01b031614611c185760405162461bcd60e51b815260206004820152600a60248201526920b9b9b2ba24b222b93960b11b6044820152606401610418565b6001600160a01b0381163014611c5b5781611c3284611c61565b1015611c505760405162461bcd60e51b8152600401610418906146a7565b611c5b838284612b21565b50505050565b60006001600160a01b03821615611cdf576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611cb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cda919061439b565b611ce1565b475b92915050565b600082826000818110611cfc57611cfc6143ea565b9050602002810190611d0e9190614617565b611d1790614af5565b905060005b828110156107815760608201516000611d3482611c61565b6020808601516001600160a01b0316600090815290819052604090205490915060ff168015611d7c575083516001600160a01b031660009081526020819052604090205460ff165b8015611db9575060006001016000611d9b8660a0015160006004612b45565b611da490614b01565b815260208101919091526040016000205460ff165b611dd657604051632514e60160e21b815260040160405180910390fd5b8651611de29085612c03565b80611dec83611c61565b611df69190614600565b905084611e04846001614637565b1015611ef3578585611e17856001614637565b818110611e2657611e266143ea565b9050602002810190611e389190614617565b611e4190614af5565b6004549094506001600160a01b031680611e6e576040516374c37b4360e11b815260040160405180910390fd5b6080850182905260a08501516040516305c7027560e41b81526001600160a01b03831691635c70275091611ea791908690600401614400565b600060405180830381865afa158015611ec4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eec9190810190614466565b60a0860152505b50508080611f009061464f565b915050611d1c565b6000611f15826001614637565b83511015611f5b5760405162461bcd60e51b8152602060048201526013602482015272746f55696e74385f6f75744f66426f756e647360681b6044820152606401610418565b50016001015190565b606081611f7281601f614637565b1015611fb15760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401610418565b611fbb8284614637565b84511015611fff5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401610418565b60608215801561201e5760405191506000825260208201604052612068565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561205757805183526020928301920161203f565b5050858452601f01601f1916604052505b50949350505050565b600080805b83518110156120ae576120898482611f08565b61209a9060ff16600884901b614637565b9150806120a68161464f565b915050612076565b5092915050565b60006120c2826002614637565b835110156121095760405162461bcd60e51b8152602060048201526014602482015273746f55696e7431365f6f75744f66426f756e647360601b6044820152606401610418565b50016002015190565b600061211d82612df2565b6001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561215a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce19190614b25565b60006103d98284614b42565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091526040805160e08101909152825181906121dd906000612ee0565b81526020016121ef8460200151612f3e565b6001600160a01b03168152602001836040015161ffff1681526020016122188460600151612f3e565b6001600160a01b03168152602001836080015161ffff1681526020016122418460a00151612f3e565b6001600160a01b031681526020018360c001518152509050919050565b6060600082516001600160401b0381111561227b5761227b613883565b6040519080825280602002602001820160405280156122dd57816020015b6040805160c081018252600080825260208083018290529282018190526060808301829052608083019190915260a082015282526000199092019101816122995790505b50905060005b81518110156120ae5761231d6000858381518110612303576123036143ea565b602002602001015160000151612f5c90919063ffffffff16565b82828151811061232f5761232f6143ea565b6020026020010151600001906001600160a01b031690816001600160a01b031681525050612384600085838151811061236a5761236a6143ea565b602002602001015160200151612f5c90919063ffffffff16565b828281518110612396576123966143ea565b6020026020010151602001906001600160a01b031690816001600160a01b0316815250506123eb60008583815181106123d1576123d16143ea565b602002602001015160400151612f5c90919063ffffffff16565b8282815181106123fd576123fd6143ea565b6020026020010151604001906001600160a01b031690816001600160a01b0316815250506124526000858381518110612438576124386143ea565b602002602001015160600151612f5c90919063ffffffff16565b828281518110612464576124646143ea565b6020026020010151606001906001600160a01b031690816001600160a01b03168152505083818151811061249a5761249a6143ea565b6020026020010151608001518282815181106124b8576124b86143ea565b602002602001015160800181815250508381815181106124da576124da6143ea565b602002602001015160a001518282815181106124f8576124f86143ea565b602002602001015160a0018190525080806125129061464f565b9150506122e3565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b031633146125a15760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b6064820152608401610418565b565b60006103d96125b184612fc1565b839061217e565b60006125c382612df2565b6001600160a01b0316621edfab6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561215a573d6000803e3d6000fd5b60006103d98284614637565b60006103d961261984612fc1565b839061302d565b6040805160f883901b6001600160f81b031916602082015281516001818303018152602190910190915260089190911c906060905b8215611ce1576040516001600160f81b031960f885901b16602082015261269190829060210160408051601f198184030181529190529061269f565b9050600883901c9250612655565b6060806040519050835180825260208201818101602087015b818310156126d05780518352602092830192016126b8565b50855184518101855292509050808201602086015b818310156126fd5780518352602092830192016126e5565b508651929092011591909101601f01601f191660405250905092915050565b61273182826001600160a01b03821615613039565b5050565b816001600160a01b0316836001600160a01b03160361277b578061275884611c61565b10156127765760405162461bcd60e51b8152600401610418906146a7565b505050565b6001600160a01b03831661280f57816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156127c457600080fd5b505af1935050505080156127d6575060015b6127765760405162461bcd60e51b815260206004820152600a6024820152692232b837b9b4ba22b93960b11b6044820152606401610418565b816001600160a01b0316836001600160a01b03161461277657604051632e1a7d4d60e01b8152600481018290526001600160a01b03841690632e1a7d4d90602401600060405180830381600087803b15801561286a57600080fd5b505af192505050801561287b575060015b6128bc5760405162461bcd60e51b81526020600482015260126024820152712232b837b9b4ba2bb4ba34323930bba2b93960711b6044820152606401610418565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156128f757600080fd5b505af193505050508015612909575060015b6127765760405162461bcd60e51b81526020600482015260126024820152712bb4ba34323930bba232b837b9b4ba22b93960711b6044820152606401610418565b600061296182606001516001600160a01b03161590565b15612999578160c0015134116129895760405162461bcd60e51b8152600401610418906146a7565b60c0820151611ce1903490611b05565b5034919050565b919050565b600080516020614c4283398151915280546001600160a01b03166129cf604087016020880161484b565b825461ffff918216600160a01b90910490911603612a0057604051634ac09ad360e01b815260040160405180910390fd5b612a14612a0d8735612112565b82866130cc565b604080516060810182526080880135815260006020808301829052835190810184528181529282019290925290612a5160c0890160a08a016143cd565b604051602001612a79919060609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040529050826001600160a01b0316639fbf10fc888a6020016020810190612aad919061484b565b8b600001358c60400135338c8f606001358a8a8f6040518b63ffffffff1660e01b8152600401612ae599989796959493929190614b64565b6000604051808303818588803b158015612afe57600080fd5b505af1158015612b12573d6000803e3d6000fd5b50505050505050505050505050565b6001600160a01b03831615612b3b57612776838383613191565b61277682826131c3565b60608183108015612b57575083518211155b612b975760405162461bcd60e51b8152602060048201526011602482015270446174614c656e677468206572726f722160781b6044820152606401610418565b604080516020810190915260008152835b838110156120685781868281518110612bc357612bc36143ea565b602001015160f81c60f81b604051602001612bdf929190614be1565b60405160208183030381529060405291508080612bfb9061464f565b915050612ba8565b80513b612c23576040516303777f6960e51b815260040160405180910390fd5b60808101516000819003612c4a5760405163391b81e760e21b815260040160405180910390fd5b604082015160608301516000919082612c6283611c61565b90506000612c6f83611c61565b90506000868310612c81576000612c8b565b612c8b8388614600565b90506001600160a01b03851615612cc257612cab858960200151896130cc565b8015612cbd57612cbd8533308461325e565b612cc6565b8695505b60008089600001516001600160a01b0316888b60a00151604051612cea9190614c10565b60006040518083038185875af1925050503d8060008114612d27576040519150601f19603f3d011682016040523d82523d6000602084013e612d2c565b606091505b509150915081612d5d576000612d41826132b8565b90508060405162461bcd60e51b8152600401610418919061384d565b7f7bfdfdb5e3a3776976e53cb0607060f54c5312701c8cba1155cc4d5394440b388b8b600001518c60400151898d89612d958d611c61565b612d9f9190614600565b604080519687526001600160a01b0395861660208801529385169386019390935292166060840152608083019190915260a08201524260c082015260e00160405180910390a15050505050505050505050565b600080516020614c4283398151915280546040805163c45a015560e01b815290516000939284926001600160a01b039091169163c45a0155916004808201926020929091908290030181865afa158015612e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e749190614b25565b60405163068bcd8d60e01b8152600481018690529091506001600160a01b0382169063068bcd8d90602401602060405180830381865afa158015612ebc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccc9190614b25565b6000612eed826020614637565b83511015612f355760405162461bcd60e51b8152602060048201526015602482015274746f427974657333325f6f75744f66426f756e647360581b6044820152606401610418565b50016020015190565b60008151601403612f5457611ce1826000612f5c565b506000919050565b6000612f69826014614637565b83511015612fb15760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b6044820152606401610418565b500160200151600160601b900490565b6000612fcc82612df2565b6001600160a01b031663feb56b156040518163ffffffff1660e01b8152600401602060405180830381865afa158015613009573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce1919061439b565b60006103d98284614c22565b8160000361305a5760405163162908e360e11b815260040160405180910390fd5b8015613080578134146127765760405163162908e360e11b815260040160405180910390fd5b600061308b84611c61565b90506130998433308661325e565b82816130a486611c61565b6130ae9190614600565b14611c5b5760405163162908e360e11b815260040160405180910390fd5b6001600160a01b0383166130df57505050565b6001600160a01b038216613106576040516363ba9bff60e01b815260040160405180910390fd5b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015613156573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317a919061439b565b905081811015611c5b57611c5b848460001961332f565b6001600160a01b0383166131b85760405163346fafc360e21b815260040160405180910390fd5b612776838383613477565b6001600160a01b0382166131ea576040516321f7434560e01b815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613237576040519150601f19603f3d011682016040523d82523d6000602084013e61323c565b606091505b505090508061277657604051635a04673760e01b815260040160405180910390fd5b6001600160a01b0384166132855760405163346fafc360e21b815260040160405180910390fd5b6001600160a01b0382166132ac576040516321f7434560e01b815260040160405180910390fd5b611c5b848484846134a7565b60606044825110156132fd57505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b600061331960048085516133119190614600565b859190611f64565b9050808060200190518101906103d99190614466565b8015806133a95750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015613383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a7919061439b565b155b6134145760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610418565b6040516001600160a01b03831660248201526044810182905261277690849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526134df565b6040516001600160a01b03831660248201526044810182905261277690849063a9059cbb60e01b90606401613440565b6040516001600160a01b0380851660248301528316604482015260648101829052611c5b9085906323b872dd60e01b90608401613440565b6000613534826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135b19092919063ffffffff16565b80519091501561277657808060200190518101906135529190614668565b6127765760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610418565b60606103d68484600085856001600160a01b0385163b6136135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610418565b600080866001600160a01b0316858760405161362f9190614c10565b60006040518083038185875af1925050503d806000811461366c576040519150601f19603f3d011682016040523d82523d6000602084013e613671565b606091505b509150915061368182828661368c565b979650505050505050565b6060831561369b5750816103d9565b8251156136ab5782518084602001fd5b8160405162461bcd60e51b8152600401610418919061384d565b6040518060e001604052806060815260200160608152602001600061ffff16815260200160608152602001600061ffff16815260200160608152602001600081525090565b604051806040016040528061371d6136c5565b8152602001606081525090565b600060e0828403121561373c57600080fd5b50919050565b60008083601f84011261375457600080fd5b5081356001600160401b0381111561376b57600080fd5b6020830191508360208260051b850101111561378657600080fd5b9250929050565b6000806000604084860312156137a257600080fd5b83356001600160401b03808211156137b957600080fd5b6137c58783880161372a565b945060208601359150808211156137db57600080fd5b506137e886828701613742565b9497909650939450505050565b60005b838110156138105781810151838201526020016137f8565b83811115611c5b5750506000910152565b600081518084526138398160208601602086016137f5565b601f01601f19169290920160200192915050565b6020815260006103d96020830184613821565b6001600160a01b038116811461387557600080fd5b50565b80356129a081613860565b634e487b7160e01b600052604160045260246000fd5b60e081018181106001600160401b03821117156138b8576138b8613883565b60405250565b601f8201601f191681016001600160401b03811182821017156138e3576138e3613883565b6040525050565b6040516138f681613899565b90565b60405160c081016001600160401b038111828210171561391b5761391b613883565b60405290565b60006001600160401b0382111561393a5761393a613883565b5060051b60200190565b60006001600160401b0382111561395d5761395d613883565b50601f01601f191660200190565b600082601f83011261397c57600080fd5b813561398781613944565b60405161399482826138be565b8281528560208487010111156139a957600080fd5b82602086016020830137600092810160200192909252509392505050565b600060c082840312156139d957600080fd5b60405160c081016001600160401b0382821081831117156139fc576139fc613883565b8160405282935084359150613a1082613860565b818352613a1f60208601613878565b6020840152613a3060408601613878565b6040840152613a4160608601613878565b60608401526080850135608084015260a0850135915080821115613a6457600080fd5b50613a718582860161396b565b60a0830152505092915050565b6000806000806101408587031215613a9557600080fd5b8435613aa081613860565b93506020858101359350613ab7876040880161372a565b92506101208601356001600160401b0380821115613ad457600080fd5b818801915088601f830112613ae857600080fd5b8135613af381613921565b604051613b0082826138be565b82815260059290921b840185019185810191508b831115613b2057600080fd5b8585015b83811015613b5857803585811115613b3c5760008081fd5b613b4a8e89838a01016139c7565b845250918601918601613b24565b50989b979a50959850505050505050565b803561ffff811681146129a057600080fd5b6000806000838503610100811215613b9257600080fd5b60e0811215613ba057600080fd5b50604051613bad81613899565b843581526020850135613bbf81613860565b6020820152613bd060408601613b69565b60408201526060850135613be381613860565b6060820152613bf460808601613b69565b6080820152613c0560a08601613878565b60a082015260c08581013590820152925060e08401356001600160401b03811115613c2f57600080fd5b6137e886828701613742565b600060208284031215613c4d57600080fd5b81356001600160401b03811115613c6357600080fd5b610ccc8482850161396b565b600081518084526020808501808196508360051b8101915082860160005b85811015613d39578284038952815160c08151818752613caf82880182613821565b9150508682015186820388880152613cc78282613821565b91505060408083015187830382890152613ce18382613821565b9250505060608083015187830382890152613cfc8382613821565b92505050608080830151818801525060a08083015192508682038188015250613d258183613821565b9a87019a9550505090840190600101613c8d565b5091979650505050505050565b604081526000835160e06040840152613d63610120840182613821565b90506020850151603f1980858403016060860152613d818383613821565b925061ffff604088015116608086015260608701519150808584030160a0860152613dac8383613821565b925060808701519150613dc560c086018361ffff169052565b60a08701519150808584030160e086015250613de18282613821565b91505060c08501516101008401528281036020840152613e018185613c6f565b95945050505050565b600060208284031215613e1c57600080fd5b5035919050565b60008060008060608587031215613e3957600080fd5b84356001600160401b0380821115613e5057600080fd5b613e5c8883890161372a565b9550602087013594506040870135915080821115613e7957600080fd5b50613e8687828801613742565b95989497509550505050565b60008060008060008060c08789031215613eab57600080fd5b613eb487613b69565b955060208701356001600160401b0380821115613ed057600080fd5b613edc8a838b0161396b565b96506040890135955060608901359150613ef582613860565b9093506080880135925060a08801359080821115613f1257600080fd5b50613f1f89828a0161396b565b9150509295509295509295565b60008060408385031215613f3f57600080fd5b8235613f4a81613860565b9150613f5860208401613b69565b90509250929050565b600060c0828403121561373c57600080fd5b60008060e08385031215613f8657600080fd5b613f908484613f61565b9460c0939093013593505050565b600060e08284031215613fb057600080fd5b613fb86138ea565b905081356001600160401b0380821115613fd157600080fd5b613fdd8583860161396b565b83526020840135915080821115613ff357600080fd5b613fff8583860161396b565b602084015261401060408501613b69565b6040840152606084013591508082111561402957600080fd5b6140358583860161396b565b606084015261404660808501613b69565b608084015260a084013591508082111561405f57600080fd5b5061406c8482850161396b565b60a08301525060c082013560c082015292915050565b600061408d83613921565b6040805161409b83826138be565b858152925060208084019250600586901b850190878211156140bc57600080fd5b855b828110156141c85780356001600160401b03808211156140de5760008081fd5b9088019060c0828c0312156140f35760008081fd5b6140fb6138f9565b82358281111561410b5760008081fd5b6141178d82860161396b565b825250848301358281111561412c5760008081fd5b6141388d82860161396b565b8683015250868301358281111561414f5760008081fd5b61415b8d82860161396b565b8883015250606080840135838111156141745760008081fd5b6141808e82870161396b565b828401525050608080840135818301525060a080840135838111156141a55760008081fd5b6141b18e82870161396b565b9183019190915250875250509381019381016140be565b50505050509392505050565b600080604083850312156141e757600080fd5b82356001600160401b03808211156141fe57600080fd5b61420a86838701613f9e565b9350602085013591508082111561422057600080fd5b508301601f8101851361423257600080fd5b61424185823560208401614082565b9150509250929050565b600080600080610100858703121561426257600080fd5b84356001600160401b038082111561427957600080fd5b6142858883890161372a565b95506142948860208901613f61565b945060e0870135915080821115613e7957600080fd5b60008060008060008061012087890312156142c457600080fd5b86356001600160401b03808211156142db57600080fd5b6142e78a838b0161372a565b975060208901359150808211156142fd57600080fd5b6143098a838b01613742565b909750955085915061431e8a60408b01613f61565b945061010089013591508082111561433557600080fd5b5061434289828a01613742565b979a9699509497509295939492505050565b801515811461387557600080fd5b6000806040838503121561437557600080fd5b823561438081613860565b9150602083013561439081614354565b809150509250929050565b6000602082840312156143ad57600080fd5b5051919050565b6000611ce13683613f9e565b60006103d9368484614082565b6000602082840312156143df57600080fd5b81356103d981613860565b634e487b7160e01b600052603260045260246000fd5b6040815260006144136040830185613821565b90508260208301529392505050565b600061442d83613944565b60405161443a82826138be565b80925084815285858501111561444f57600080fd5b61445d8560208301866137f5565b50509392505050565b60006020828403121561447857600080fd5b81516001600160401b0381111561448e57600080fd5b8201601f8101841361449f57600080fd5b610ccc84825160208401614422565b600081518084526020808501808196508360051b8101915082860160005b85811015613d39578284038952815180516001600160a01b03908116865286820151811687870152604080830151821690870152606080830151909116908601526080808201519086015260a09081015160c09186018290529061453281870183613821565b9a87019a95505050908401906001016144cc565b600061010084358352602085013561455d81613860565b6001600160a01b03818116602086015261457960408801613b69565b61ffff90811660408701526060880135925061459483613860565b8183166060870152806145a960808a01613b69565b1660808701525050506145be60a08601613878565b6001600160a01b03811660a08501525060c085013560c08401528060e0840152613e01818401856144ae565b634e487b7160e01b600052601160045260246000fd5b600082821015614612576146126145ea565b500390565b6000823560be1983360301811261462d57600080fd5b9190910192915050565b6000821982111561464a5761464a6145ea565b500190565b600060018201614661576146616145ea565b5060010190565b60006020828403121561467a57600080fd5b81516103d981614354565b6020808252600890820152672a37b5b2b722b93960c11b604082015260600190565b60208082526009908201526809cdee88adcdeeaced60bb1b604082015260600190565b80518252602081015160018060a01b0380821660208501526040830151915061ffff8083166040860152816060850151166060860152806080850151166080860152508060a08401511660a0850152505060c081015160c08301525050565b6001600160a01b038516815260208101849052600061014061474e60408401866146ca565b80610120840152613681818401856144ae565b600060033d11156138f65760046000803e5060005160e01c90565b600060443d101561478a5790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156147b957505050505090565b82850191508151818111156147d15750505050505090565b843d87010160208285010111156147eb5750505050505090565b6147fa602082860101876138be565b509095945050505050565b6040815260006148186040830185613821565b8281036020840152613e018185613821565b60408152600060408201526060602082015260006103d96060830184613821565b60006020828403121561485d57600080fd5b6103d982613b69565b600060c0828403121561487857600080fd5b60405160c081018181106001600160401b038211171561489a5761489a613883565b8060405250825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a08201528091505092915050565b600060ff60f81b808960f81b1683528751614901816001860160208c016137f5565b8084019050818860f81b1660018201528651614924816002840160208b016137f5565b808201915050818660f81b1660028201528451915061494a8260038301602088016137f5565b0160030198975050505050505050565b60ff60f81b8360f81b1681526000825161497b8160018501602087016137f5565b919091016001019392505050565b600060ff60f81b808b60f81b16835289516149ab816001860160208e016137f5565b8084019050818a60f81b16600182015288516149ce816002840160208d016137f5565b808201915050818860f81b166002820152865191506149f4826003830160208a016137f5565b81810191505061ffff60f01b8560f01b1660038201528351614a1d8160058401602088016137f5565b016005019a9950505050505050505050565b80518252602081015160208301526000604082015160606040850152610ccc6060850182613821565b61ffff8616815260ff8516602082015260a060408201526000614a7e60a0830186613821565b8281036060840152614a908186613821565b90508281036080840152614aa48185614a2f565b98975050505050505050565b60008060408385031215614ac357600080fd5b505080516020909101519092909150565b6000610100614ae383866146ca565b8060e0840152613e01818401856144ae565b6000611ce136836139c7565b8051602080830151919081101561373c5760001960209190910360031b1b16919050565b600060208284031215614b3757600080fd5b81516103d981613860565b600082614b5f57634e487b7160e01b600052601260045260246000fd5b500490565b600061012061ffff8c1683528a602084015289604084015260018060a01b03891660608401528760808401528660a08401528060c0840152614ba881840187614a2f565b905082810360e0840152614bbc8186613821565b9050828103610100840152614bd18185613821565b9c9b505050505050505050505050565b60008351614bf38184602088016137f5565b6001600160f81b0319939093169190920190815260010192915050565b6000825161462d8184602087016137f5565b6000816000190483118215151615614c3c57614c3c6145ea565b50029056fe2bd10e5dcb5694caec513d6d8fa1fd90f6a026e0e9320d7b6e2f8e49b93270d1a2646970667358221220ffb7c160f3bc3f9b49d38c6a25f3158cee47dcb2df0d45e1ade32315c8344ec564736f6c634300080d0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
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.