Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 25 from a total of 662 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Swap | 11943839 | 1820 days ago | IN | 0.02 ETH | 0.01674308 | ||||
| Swap | 11873340 | 1831 days ago | IN | 0 ETH | 0.04646523 | ||||
| Swap | 11840998 | 1835 days ago | IN | 0.5 ETH | 0.01806738 | ||||
| Swap | 11837315 | 1836 days ago | IN | 0.08772077 ETH | 0.06250105 | ||||
| Swap | 11820836 | 1839 days ago | IN | 0 ETH | 0.02281978 | ||||
| Swap | 11724327 | 1853 days ago | IN | 0.1 ETH | 0.02491751 | ||||
| Swap | 11723188 | 1854 days ago | IN | 1 ETH | 0.02312093 | ||||
| Swap | 11684460 | 1860 days ago | IN | 0 ETH | 0.0176499 | ||||
| Swap | 11677390 | 1861 days ago | IN | 1 ETH | 0.0081182 | ||||
| Swap | 11654929 | 1864 days ago | IN | 0.5 ETH | 0.01350426 | ||||
| Swap | 11639320 | 1866 days ago | IN | 0 ETH | 0.01299455 | ||||
| Swap | 11617099 | 1870 days ago | IN | 10 ETH | 0.02187235 | ||||
| Swap | 11589760 | 1874 days ago | IN | 10 ETH | 0.02516945 | ||||
| Swap | 11581272 | 1875 days ago | IN | 0 ETH | 0.01432053 | ||||
| Swap | 11581240 | 1875 days ago | IN | 10 ETH | 0.02412939 | ||||
| Swap | 11580655 | 1875 days ago | IN | 0 ETH | 0.01511611 | ||||
| Swap | 11574250 | 1876 days ago | IN | 0 ETH | 0.00884578 | ||||
| Swap | 11571418 | 1877 days ago | IN | 2.22 ETH | 0.01252584 | ||||
| Swap | 11564155 | 1878 days ago | IN | 0 ETH | 0.015589 | ||||
| Swap | 11563107 | 1878 days ago | IN | 0 ETH | 0.02660521 | ||||
| Swap | 11563100 | 1878 days ago | IN | 0 ETH | 0.02449239 | ||||
| Swap | 11563096 | 1878 days ago | IN | 0 ETH | 0.02455554 | ||||
| Swap | 11563025 | 1878 days ago | IN | 10 ETH | 0.02442059 | ||||
| Swap | 11560421 | 1879 days ago | IN | 0 ETH | 0.0252126 | ||||
| Swap | 11551286 | 1880 days ago | IN | 0 ETH | 0.02028768 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| Deposit | 16825742 | 1075 days ago | 0.00000006 ETH | ||||
| Transfer | 16825742 | 1075 days ago | 0.00000006 ETH | ||||
| Deposit | 16825742 | 1075 days ago | 0.00049935 ETH | ||||
| Transfer | 16825742 | 1075 days ago | 0.00049935 ETH | ||||
| Swap | 16376674 | 1138 days ago | 0.08 ETH | ||||
| Swap Multi | 16376674 | 1138 days ago | 0.08 ETH | ||||
| Transfer | 16370777 | 1139 days ago | 0.19739691 ETH | ||||
| Transfer | 16370777 | 1139 days ago | 0.19739691 ETH | ||||
| Swap | 16370694 | 1139 days ago | 0.2 ETH | ||||
| Swap Multi | 16370694 | 1139 days ago | 0.2 ETH | ||||
| Swap | 16175572 | 1166 days ago | 0.22 ETH | ||||
| Swap Multi | 16175572 | 1166 days ago | 0.22 ETH | ||||
| Swap | 15741512 | 1227 days ago | 0.14 ETH | ||||
| Swap | 15741512 | 1227 days ago | 0.14 ETH | ||||
| Transfer | 15674411 | 1236 days ago | 0.01368458 ETH | ||||
| Transfer | 15674411 | 1236 days ago | 0.01368458 ETH | ||||
| Transfer | 15376970 | 1281 days ago | 0.00405469 ETH | ||||
| Transfer | 15376970 | 1281 days ago | 0.00405469 ETH | ||||
| - | 14995689 | 1342 days ago | 0.074 ETH | ||||
| - | 14995689 | 1342 days ago | 0.074 ETH | ||||
| - | 14928263 | 1354 days ago | 0.02819775 ETH | ||||
| - | 14928263 | 1354 days ago | 0.02819775 ETH | ||||
| - | 13274891 | 1613 days ago | 0.00343336 ETH | ||||
| - | 13274891 | 1613 days ago | 0.00343336 ETH | ||||
| - | 13274882 | 1613 days ago | 0.004 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
OneSplitWrap
Compiler Version
v0.5.17+commit.d19bba13
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2020-08-10
*/
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: contracts/IOneSplit.sol
pragma solidity ^0.5.0;
//
// [ msg.sender ]
// | |
// | |
// \_/
// +---------------+ ________________________________
// | OneSplitAudit | _______________________________ \
// +---------------+ \ \
// | | ______________ | | (staticcall)
// | | / ____________ \ | |
// | | (call) / / \ \ | |
// | | / / | | | |
// \_/ | | \_/ \_/
// +--------------+ | | +----------------------+
// | OneSplitWrap | | | | OneSplitViewWrap |
// +--------------+ | | +----------------------+
// | | | | | |
// | | (delegatecall) | | (staticcall) | | (staticcall)
// \_/ | | \_/
// +--------------+ | | +------------------+
// | OneSplit | | | | OneSplitView |
// +--------------+ | | +------------------+
// | | / /
// \ \________________/ /
// \__________________/
//
contract IOneSplitConsts {
// flags = FLAG_DISABLE_UNISWAP + FLAG_DISABLE_BANCOR + ...
uint256 internal constant FLAG_DISABLE_UNISWAP = 0x01;
uint256 internal constant DEPRECATED_FLAG_DISABLE_KYBER = 0x02; // Deprecated
uint256 internal constant FLAG_DISABLE_BANCOR = 0x04;
uint256 internal constant FLAG_DISABLE_OASIS = 0x08;
uint256 internal constant FLAG_DISABLE_COMPOUND = 0x10;
uint256 internal constant FLAG_DISABLE_FULCRUM = 0x20;
uint256 internal constant FLAG_DISABLE_CHAI = 0x40;
uint256 internal constant FLAG_DISABLE_AAVE = 0x80;
uint256 internal constant FLAG_DISABLE_SMART_TOKEN = 0x100;
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_ETH = 0x200; // Deprecated, Turned off by default
uint256 internal constant FLAG_DISABLE_BDAI = 0x400;
uint256 internal constant FLAG_DISABLE_IEARN = 0x800;
uint256 internal constant FLAG_DISABLE_CURVE_COMPOUND = 0x1000;
uint256 internal constant FLAG_DISABLE_CURVE_USDT = 0x2000;
uint256 internal constant FLAG_DISABLE_CURVE_Y = 0x4000;
uint256 internal constant FLAG_DISABLE_CURVE_BINANCE = 0x8000;
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_DAI = 0x10000; // Deprecated, Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_USDC = 0x20000; // Deprecated, Turned off by default
uint256 internal constant FLAG_DISABLE_CURVE_SYNTHETIX = 0x40000;
uint256 internal constant FLAG_DISABLE_WETH = 0x80000;
uint256 internal constant FLAG_DISABLE_UNISWAP_COMPOUND = 0x100000; // Works only when one of assets is ETH or FLAG_ENABLE_MULTI_PATH_ETH
uint256 internal constant FLAG_DISABLE_UNISWAP_CHAI = 0x200000; // Works only when ETH<>DAI or FLAG_ENABLE_MULTI_PATH_ETH
uint256 internal constant FLAG_DISABLE_UNISWAP_AAVE = 0x400000; // Works only when one of assets is ETH or FLAG_ENABLE_MULTI_PATH_ETH
uint256 internal constant FLAG_DISABLE_IDLE = 0x800000;
uint256 internal constant FLAG_DISABLE_MOONISWAP = 0x1000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2 = 0x2000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_ETH = 0x4000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_DAI = 0x8000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_USDC = 0x10000000;
uint256 internal constant FLAG_DISABLE_ALL_SPLIT_SOURCES = 0x20000000;
uint256 internal constant FLAG_DISABLE_ALL_WRAP_SOURCES = 0x40000000;
uint256 internal constant FLAG_DISABLE_CURVE_PAX = 0x80000000;
uint256 internal constant FLAG_DISABLE_CURVE_RENBTC = 0x100000000;
uint256 internal constant FLAG_DISABLE_CURVE_TBTC = 0x200000000;
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_USDT = 0x400000000; // Deprecated, Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_WBTC = 0x800000000; // Deprecated, Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_TBTC = 0x1000000000; // Deprecated, Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_RENBTC = 0x2000000000; // Deprecated, Turned off by default
uint256 internal constant FLAG_DISABLE_DFORCE_SWAP = 0x4000000000;
uint256 internal constant FLAG_DISABLE_SHELL = 0x8000000000;
uint256 internal constant FLAG_ENABLE_CHI_BURN = 0x10000000000;
uint256 internal constant FLAG_DISABLE_MSTABLE_MUSD = 0x20000000000;
uint256 internal constant FLAG_DISABLE_CURVE_SBTC = 0x40000000000;
uint256 internal constant FLAG_DISABLE_DMM = 0x80000000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_ALL = 0x100000000000;
uint256 internal constant FLAG_DISABLE_CURVE_ALL = 0x200000000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_ALL = 0x400000000000;
uint256 internal constant FLAG_DISABLE_SPLIT_RECALCULATION = 0x800000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_ALL = 0x1000000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_1 = 0x2000000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_2 = 0x4000000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_3 = 0x8000000000000;
uint256 internal constant DEPRECATED_FLAG_ENABLE_KYBER_UNISWAP_RESERVE = 0x10000000000000; // Deprecated, Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_KYBER_OASIS_RESERVE = 0x20000000000000; // Deprecated, Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_KYBER_BANCOR_RESERVE = 0x40000000000000; // Deprecated, Turned off by default
uint256 internal constant FLAG_ENABLE_REFERRAL_GAS_SPONSORSHIP = 0x80000000000000; // Turned off by default
uint256 internal constant DEPRECATED_FLAG_ENABLE_MULTI_PATH_COMP = 0x100000000000000; // Deprecated, Turned off by default
uint256 internal constant FLAG_DISABLE_KYBER_ALL = 0x200000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_1 = 0x400000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_2 = 0x800000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_3 = 0x1000000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_4 = 0x2000000000000000;
uint256 internal constant FLAG_ENABLE_CHI_BURN_BY_ORIGIN = 0x4000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_ALL = 0x8000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_ETH = 0x10000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_DAI = 0x20000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_USDC = 0x40000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_POOL_TOKEN = 0x80000000000000000;
}
contract IOneSplit is IOneSplitConsts {
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags // See constants in IOneSplit.sol
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
);
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags, // See constants in IOneSplit.sol
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
);
function swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256 flags
)
public
payable
returns(uint256 returnAmount);
}
contract IOneSplitMulti is IOneSplit {
function getExpectedReturnWithGasMulti(
IERC20[] memory tokens,
uint256 amount,
uint256[] memory parts,
uint256[] memory flags,
uint256[] memory destTokenEthPriceTimesGasPrices
)
public
view
returns(
uint256[] memory returnAmounts,
uint256 estimateGasAmount,
uint256[] memory distribution
);
function swapMulti(
IERC20[] memory tokens,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256[] memory flags
)
public
payable
returns(uint256 returnAmount);
}
// File: @openzeppelin/contracts/math/SafeMath.sol
pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @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) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @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 sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @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) {
// 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 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts 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) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts 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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts 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 mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message 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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: contracts/interface/IUniswapExchange.sol
pragma solidity ^0.5.0;
interface IUniswapExchange {
function getEthToTokenInputPrice(uint256 ethSold) external view returns (uint256 tokensBought);
function getTokenToEthInputPrice(uint256 tokensSold) external view returns (uint256 ethBought);
function ethToTokenSwapInput(uint256 minTokens, uint256 deadline)
external
payable
returns (uint256 tokensBought);
function tokenToEthSwapInput(uint256 tokensSold, uint256 minEth, uint256 deadline)
external
returns (uint256 ethBought);
function tokenToTokenSwapInput(
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address tokenAddr
) external returns (uint256 tokensBought);
}
// File: contracts/interface/IUniswapFactory.sol
pragma solidity ^0.5.0;
interface IUniswapFactory {
function getExchange(IERC20 token) external view returns (IUniswapExchange exchange);
}
// File: contracts/interface/IKyberNetworkContract.sol
pragma solidity ^0.5.0;
interface IKyberNetworkContract {
function searchBestRate(IERC20 src, IERC20 dest, uint256 srcAmount, bool usePermissionless)
external
view
returns (address reserve, uint256 rate);
}
// File: contracts/interface/IKyberNetworkProxy.sol
pragma solidity ^0.5.0;
interface IKyberNetworkProxy {
function getExpectedRateAfterFee(
IERC20 src,
IERC20 dest,
uint256 srcQty,
uint256 platformFeeBps,
bytes calldata hint
) external view returns (uint256 expectedRate);
function tradeWithHintAndFee(
IERC20 src,
uint256 srcAmount,
IERC20 dest,
address payable destAddress,
uint256 maxDestAmount,
uint256 minConversionRate,
address payable platformWallet,
uint256 platformFeeBps,
bytes calldata hint
) external payable returns (uint256 destAmount);
function kyberNetworkContract() external view returns (IKyberNetworkContract);
// TODO: Limit usage by tx.gasPrice
// function maxGasPrice() external view returns (uint256);
// TODO: Limit usage by user cap
// function getUserCapInWei(address user) external view returns (uint256);
// function getUserCapInTokenWei(address user, IERC20 token) external view returns (uint256);
}
// File: contracts/interface/IKyberStorage.sol
pragma solidity ^0.5.0;
interface IKyberStorage {
function getReserveIdsPerTokenSrc(
IERC20 token
) external view returns (bytes32[] memory);
}
// File: contracts/interface/IKyberHintHandler.sol
pragma solidity ^0.5.0;
interface IKyberHintHandler {
enum TradeType {
BestOfAll,
MaskIn,
MaskOut,
Split
}
function buildTokenToEthHint(
IERC20 tokenSrc,
TradeType tokenToEthType,
bytes32[] calldata tokenToEthReserveIds,
uint256[] calldata tokenToEthSplits
) external view returns (bytes memory hint);
function buildEthToTokenHint(
IERC20 tokenDest,
TradeType ethToTokenType,
bytes32[] calldata ethToTokenReserveIds,
uint256[] calldata ethToTokenSplits
) external view returns (bytes memory hint);
}
// File: contracts/interface/IBancorNetwork.sol
pragma solidity ^0.5.0;
interface IBancorNetwork {
function getReturnByPath(address[] calldata path, uint256 amount)
external
view
returns (uint256 returnAmount, uint256 conversionFee);
function claimAndConvert(address[] calldata path, uint256 amount, uint256 minReturn)
external
returns (uint256);
function convert(address[] calldata path, uint256 amount, uint256 minReturn)
external
payable
returns (uint256);
}
// File: contracts/interface/IBancorContractRegistry.sol
pragma solidity ^0.5.0;
contract IBancorContractRegistry {
function addressOf(bytes32 contractName) external view returns (address);
}
// File: contracts/interface/IBancorNetworkPathFinder.sol
pragma solidity ^0.5.0;
interface IBancorNetworkPathFinder {
function generatePath(IERC20 sourceToken, IERC20 targetToken)
external
view
returns (address[] memory);
}
// File: contracts/interface/IBancorConverterRegistry.sol
pragma solidity ^0.5.0;
interface IBancorConverterRegistry {
function getConvertibleTokenSmartTokenCount(IERC20 convertibleToken)
external view returns(uint256);
function getConvertibleTokenSmartTokens(IERC20 convertibleToken)
external view returns(address[] memory);
function getConvertibleTokenSmartToken(IERC20 convertibleToken, uint256 index)
external view returns(address);
function isConvertibleTokenSmartToken(IERC20 convertibleToken, address value)
external view returns(bool);
}
// File: contracts/interface/IBancorEtherToken.sol
pragma solidity ^0.5.0;
contract IBancorEtherToken is IERC20 {
function deposit() external payable;
function withdraw(uint256 amount) external;
}
// File: contracts/interface/IBancorFinder.sol
pragma solidity ^0.5.0;
interface IBancorFinder {
function buildBancorPath(
IERC20 fromToken,
IERC20 destToken
)
external
view
returns(address[] memory path);
}
// File: contracts/interface/IOasisExchange.sol
pragma solidity ^0.5.0;
interface IOasisExchange {
function getBuyAmount(IERC20 buyGem, IERC20 payGem, uint256 payAmt)
external
view
returns (uint256 fillAmt);
function sellAllAmount(IERC20 payGem, uint256 payAmt, IERC20 buyGem, uint256 minFillAmount)
external
returns (uint256 fillAmt);
}
// File: contracts/interface/IWETH.sol
pragma solidity ^0.5.0;
contract IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256 amount) external;
}
// File: contracts/interface/ICurve.sol
pragma solidity ^0.5.0;
interface ICurve {
// solium-disable-next-line mixedcase
function get_dy_underlying(int128 i, int128 j, uint256 dx) external view returns(uint256 dy);
// solium-disable-next-line mixedcase
function get_dy(int128 i, int128 j, uint256 dx) external view returns(uint256 dy);
// solium-disable-next-line mixedcase
function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 minDy) external;
// solium-disable-next-line mixedcase
function exchange(int128 i, int128 j, uint256 dx, uint256 minDy) external;
}
contract ICurveRegistry {
function get_pool_info(address pool)
external
view
returns(
uint256[8] memory balances,
uint256[8] memory underlying_balances,
uint256[8] memory decimals,
uint256[8] memory underlying_decimals,
address lp_token,
uint256 A,
uint256 fee
);
}
contract ICurveCalculator {
function get_dy(
int128 nCoins,
uint256[8] calldata balances,
uint256 amp,
uint256 fee,
uint256[8] calldata rates,
uint256[8] calldata precisions,
bool underlying,
int128 i,
int128 j,
uint256[100] calldata dx
) external view returns(uint256[100] memory dy);
}
// File: contracts/interface/IChai.sol
pragma solidity ^0.5.0;
interface IPot {
function dsr() external view returns (uint256);
function chi() external view returns (uint256);
function rho() external view returns (uint256);
function drip() external returns (uint256);
function join(uint256) external;
function exit(uint256) external;
}
contract IChai is IERC20 {
function POT() public view returns (IPot);
function join(address dst, uint256 wad) external;
function exit(address src, uint256 wad) external;
}
library ChaiHelper {
IPot private constant POT = IPot(0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7);
uint256 private constant RAY = 10**27;
function _mul(uint256 x, uint256 y) private pure returns (uint256 z) {
require(y == 0 || (z = x * y) / y == x);
}
function _rmul(uint256 x, uint256 y) private pure returns (uint256 z) {
// always rounds down
z = _mul(x, y) / RAY;
}
function _rdiv(uint256 x, uint256 y) private pure returns (uint256 z) {
// always rounds down
z = _mul(x, RAY) / y;
}
function rpow(uint256 x, uint256 n, uint256 base) private pure returns (uint256 z) {
// solium-disable-next-line security/no-inline-assembly
assembly {
switch x
case 0 {
switch n
case 0 {
z := base
}
default {
z := 0
}
}
default {
switch mod(n, 2)
case 0 {
z := base
}
default {
z := x
}
let half := div(base, 2) // for rounding.
for {
n := div(n, 2)
} n {
n := div(n, 2)
} {
let xx := mul(x, x)
if iszero(eq(div(xx, x), x)) {
revert(0, 0)
}
let xxRound := add(xx, half)
if lt(xxRound, xx) {
revert(0, 0)
}
x := div(xxRound, base)
if mod(n, 2) {
let zx := mul(z, x)
if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) {
revert(0, 0)
}
let zxRound := add(zx, half)
if lt(zxRound, zx) {
revert(0, 0)
}
z := div(zxRound, base)
}
}
}
}
}
function potDrip() private view returns (uint256) {
return _rmul(rpow(POT.dsr(), now - POT.rho(), RAY), POT.chi());
}
function chaiPrice(IChai chai) internal view returns(uint256) {
return chaiToDai(chai, 1e18);
}
function daiToChai(
IChai /*chai*/,
uint256 amount
) internal view returns (uint256) {
uint256 chi = (now > POT.rho()) ? potDrip() : POT.chi();
return _rdiv(amount, chi);
}
function chaiToDai(
IChai /*chai*/,
uint256 amount
) internal view returns (uint256) {
uint256 chi = (now > POT.rho()) ? potDrip() : POT.chi();
return _rmul(chi, amount);
}
}
// File: contracts/interface/ICompound.sol
pragma solidity ^0.5.0;
contract ICompound {
function markets(address cToken)
external
view
returns (bool isListed, uint256 collateralFactorMantissa);
}
contract ICompoundToken is IERC20 {
function underlying() external view returns (address);
function exchangeRateStored() external view returns (uint256);
function mint(uint256 mintAmount) external returns (uint256);
function redeem(uint256 redeemTokens) external returns (uint256);
}
contract ICompoundEther is IERC20 {
function mint() external payable;
function redeem(uint256 redeemTokens) external returns (uint256);
}
// File: contracts/interface/ICompoundRegistry.sol
pragma solidity ^0.5.0;
contract ICompoundRegistry {
function tokenByCToken(ICompoundToken cToken) external view returns(IERC20);
function cTokenByToken(IERC20 token) external view returns(ICompoundToken);
}
// File: contracts/interface/IAaveToken.sol
pragma solidity ^0.5.0;
contract IAaveToken is IERC20 {
function underlyingAssetAddress() external view returns (IERC20);
function redeem(uint256 amount) external;
}
interface IAaveLendingPool {
function core() external view returns (address);
function deposit(IERC20 token, uint256 amount, uint16 refCode) external payable;
}
// File: contracts/interface/IAaveRegistry.sol
pragma solidity ^0.5.0;
contract IAaveRegistry {
function tokenByAToken(IAaveToken aToken) external view returns(IERC20);
function aTokenByToken(IERC20 token) external view returns(IAaveToken);
}
// File: contracts/interface/IMooniswap.sol
pragma solidity ^0.5.0;
interface IMooniswapRegistry {
function pools(IERC20 token1, IERC20 token2) external view returns(IMooniswap);
function isPool(address addr) external view returns(bool);
}
interface IMooniswap {
function fee() external view returns (uint256);
function tokens(uint256 i) external view returns (IERC20);
function deposit(uint256[] calldata amounts, uint256[] calldata minAmounts) external payable returns(uint256 fairSupply);
function withdraw(uint256 amount, uint256[] calldata minReturns) external;
function getBalanceForAddition(IERC20 token) external view returns(uint256);
function getBalanceForRemoval(IERC20 token) external view returns(uint256);
function getReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount
)
external
view
returns(uint256 returnAmount);
function swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 minReturn,
address referral
)
external
payable
returns(uint256 returnAmount);
}
// File: @openzeppelin/contracts/math/Math.sol
pragma solidity ^0.5.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.5.5;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Converts an `address` into `address payable`. Note that this is
* simply a type cast: the actual underlying value is not changed.
*
* _Available since v2.4.0._
*/
function toPayable(address account) internal pure returns (address payable) {
return address(uint160(account));
}
/**
* @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].
*
* _Available since v2.4.0._
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call.value(amount)("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
pragma solidity ^0.5.0;
/**
* @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 ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
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));
}
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'
// solhint-disable-next-line max-line-length
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).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
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.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// File: contracts/UniversalERC20.sol
pragma solidity ^0.5.0;
library UniversalERC20 {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 private constant ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000);
IERC20 private constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
function universalTransfer(IERC20 token, address to, uint256 amount) internal returns(bool) {
if (amount == 0) {
return true;
}
if (isETH(token)) {
address(uint160(to)).transfer(amount);
} else {
token.safeTransfer(to, amount);
return true;
}
}
function universalTransferFrom(IERC20 token, address from, address to, uint256 amount) internal {
if (amount == 0) {
return;
}
if (isETH(token)) {
require(from == msg.sender && msg.value >= amount, "Wrong useage of ETH.universalTransferFrom()");
if (to != address(this)) {
address(uint160(to)).transfer(amount);
}
if (msg.value > amount) {
msg.sender.transfer(msg.value.sub(amount));
}
} else {
token.safeTransferFrom(from, to, amount);
}
}
function universalTransferFromSenderToThis(IERC20 token, uint256 amount) internal {
if (amount == 0) {
return;
}
if (isETH(token)) {
if (msg.value > amount) {
// Return remainder if exist
msg.sender.transfer(msg.value.sub(amount));
}
} else {
token.safeTransferFrom(msg.sender, address(this), amount);
}
}
function universalApprove(IERC20 token, address to, uint256 amount) internal {
if (!isETH(token)) {
if (amount == 0) {
token.safeApprove(to, 0);
return;
}
uint256 allowance = token.allowance(address(this), to);
if (allowance < amount) {
if (allowance > 0) {
token.safeApprove(to, 0);
}
token.safeApprove(to, amount);
}
}
}
function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) {
if (isETH(token)) {
return who.balance;
} else {
return token.balanceOf(who);
}
}
function universalDecimals(IERC20 token) internal view returns (uint256) {
if (isETH(token)) {
return 18;
}
(bool success, bytes memory data) = address(token).staticcall.gas(10000)(
abi.encodeWithSignature("decimals()")
);
if (!success || data.length == 0) {
(success, data) = address(token).staticcall.gas(10000)(
abi.encodeWithSignature("DECIMALS()")
);
}
return (success && data.length > 0) ? abi.decode(data, (uint256)) : 18;
}
function isETH(IERC20 token) internal pure returns(bool) {
return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS));
}
function eq(IERC20 a, IERC20 b) internal pure returns(bool) {
return a == b || (isETH(a) && isETH(b));
}
function notExist(IERC20 token) internal pure returns(bool) {
return (address(token) == address(-1));
}
}
// File: contracts/interface/IUniswapV2Exchange.sol
pragma solidity ^0.5.0;
interface IUniswapV2Exchange {
function getReserves() external view returns(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
}
library UniswapV2ExchangeLib {
using Math for uint256;
using SafeMath for uint256;
using UniversalERC20 for IERC20;
function getReturn(
IUniswapV2Exchange exchange,
IERC20 fromToken,
IERC20 destToken,
uint amountIn
) internal view returns (uint256 result, bool needSync, bool needSkim) {
uint256 reserveIn = fromToken.universalBalanceOf(address(exchange));
uint256 reserveOut = destToken.universalBalanceOf(address(exchange));
(uint112 reserve0, uint112 reserve1,) = exchange.getReserves();
if (fromToken > destToken) {
(reserve0, reserve1) = (reserve1, reserve0);
}
needSync = (reserveIn < reserve0 || reserveOut < reserve1);
needSkim = !needSync && (reserveIn > reserve0 || reserveOut > reserve1);
uint256 amountInWithFee = amountIn.mul(997);
uint256 numerator = amountInWithFee.mul(Math.min(reserveOut, reserve1));
uint256 denominator = Math.min(reserveIn, reserve0).mul(1000).add(amountInWithFee);
result = (denominator == 0) ? 0 : numerator.div(denominator);
}
}
// File: contracts/interface/IUniswapV2Factory.sol
pragma solidity ^0.5.0;
interface IUniswapV2Factory {
function getPair(IERC20 tokenA, IERC20 tokenB) external view returns (IUniswapV2Exchange pair);
}
// File: contracts/interface/IDForceSwap.sol
pragma solidity ^0.5.0;
interface IDForceSwap {
function getAmountByInput(IERC20 input, IERC20 output, uint256 amount) external view returns(uint256);
function swap(IERC20 input, IERC20 output, uint256 amount) external;
}
// File: contracts/interface/IShell.sol
pragma solidity ^0.5.0;
interface IShell {
function viewOriginTrade(
address origin,
address target,
uint256 originAmount
) external view returns (uint256);
function swapByOrigin(
address origin,
address target,
uint256 originAmount,
uint256 minTargetAmount,
uint256 deadline
) external returns (uint256);
}
// File: contracts/interface/IMStable.sol
pragma solidity ^0.5.0;
contract IMStable is IERC20 {
function getSwapOutput(
IERC20 _input,
IERC20 _output,
uint256 _quantity
)
external
view
returns (bool, string memory, uint256 output);
function swap(
IERC20 _input,
IERC20 _output,
uint256 _quantity,
address _recipient
)
external
returns (uint256 output);
function redeem(
IERC20 _basset,
uint256 _bassetQuantity
)
external
returns (uint256 massetRedeemed);
}
interface IMassetValidationHelper {
/**
* @dev Returns a valid bAsset to redeem
* @param _mAsset Masset addr
* @return valid bool
* @return string message
* @return address of bAsset to redeem
*/
function suggestRedeemAsset(
IERC20 _mAsset
)
external
view
returns (
bool valid,
string memory err,
address token
);
/**
* @dev Returns a valid bAsset with which to mint
* @param _mAsset Masset addr
* @return valid bool
* @return string message
* @return address of bAsset to mint
*/
function suggestMintAsset(
IERC20 _mAsset
)
external
view
returns (
bool valid,
string memory err,
address token
);
/**
* @dev Determines if a given Redemption is valid
* @param _mAsset Address of the given mAsset (e.g. mUSD)
* @param _mAssetQuantity Amount of mAsset to redeem (in mUSD units)
* @param _outputBasset Desired output bAsset
* @return valid
* @return validity reason
* @return output in bAsset units
* @return bAssetQuantityArg - required input argument to the 'redeem' call
*/
function getRedeemValidity(
IERC20 _mAsset,
uint256 _mAssetQuantity,
IERC20 _outputBasset
)
external
view
returns (
bool valid,
string memory,
uint256 output,
uint256 bassetQuantityArg
);
}
// File: contracts/interface/IBalancerPool.sol
pragma solidity ^0.5.0;
interface IBalancerPool {
function getSwapFee()
external view returns (uint256 balance);
function getDenormalizedWeight(IERC20 token)
external view returns (uint256 balance);
function getBalance(IERC20 token)
external view returns (uint256 balance);
function swapExactAmountIn(
IERC20 tokenIn,
uint256 tokenAmountIn,
IERC20 tokenOut,
uint256 minAmountOut,
uint256 maxPrice
)
external
returns (uint256 tokenAmountOut, uint256 spotPriceAfter);
}
// 0xA961672E8Db773be387e775bc4937C678F3ddF9a
interface IBalancerHelper {
function getReturns(
IBalancerPool pool,
IERC20 fromToken,
IERC20 destToken,
uint256[] calldata amounts
)
external
view
returns(uint256[] memory rets);
}
// File: contracts/interface/IBalancerRegistry.sol
pragma solidity ^0.5.0;
interface IBalancerRegistry {
event PoolAdded(
address indexed pool
);
event PoolTokenPairAdded(
address indexed pool,
address indexed fromToken,
address indexed destToken
);
event IndicesUpdated(
address indexed fromToken,
address indexed destToken,
bytes32 oldIndices,
bytes32 newIndices
);
// Get info about pool pair for 1 SLOAD
function getPairInfo(address pool, address fromToken, address destToken)
external view returns(uint256 weight1, uint256 weight2, uint256 swapFee);
// Pools
function checkAddedPools(address pool)
external view returns(bool);
function getAddedPoolsLength()
external view returns(uint256);
function getAddedPools()
external view returns(address[] memory);
function getAddedPoolsWithLimit(uint256 offset, uint256 limit)
external view returns(address[] memory result);
// Tokens
function getAllTokensLength()
external view returns(uint256);
function getAllTokens()
external view returns(address[] memory);
function getAllTokensWithLimit(uint256 offset, uint256 limit)
external view returns(address[] memory result);
// Pairs
function getPoolsLength(address fromToken, address destToken)
external view returns(uint256);
function getPools(address fromToken, address destToken)
external view returns(address[] memory);
function getPoolsWithLimit(address fromToken, address destToken, uint256 offset, uint256 limit)
external view returns(address[] memory result);
function getBestPools(address fromToken, address destToken)
external view returns(address[] memory pools);
function getBestPoolsWithLimit(address fromToken, address destToken, uint256 limit)
external view returns(address[] memory pools);
// Get swap rates
function getPoolReturn(address pool, address fromToken, address destToken, uint256 amount)
external view returns(uint256);
function getPoolReturns(address pool, address fromToken, address destToken, uint256[] calldata amounts)
external view returns(uint256[] memory result);
// Add and update registry
function addPool(address pool) external returns(uint256 listed);
function addPools(address[] calldata pools) external returns(uint256[] memory listed);
function updatedIndices(address[] calldata tokens, uint256 lengthLimit) external;
}
// File: contracts/BalancerLib.sol
pragma solidity ^0.5.0;
library BalancerLib {
uint public constant BONE = 10**18;
uint public constant MIN_BOUND_TOKENS = 2;
uint public constant MAX_BOUND_TOKENS = 8;
uint public constant MIN_FEE = BONE / 10**6;
uint public constant MAX_FEE = BONE / 10;
uint public constant EXIT_FEE = 0;
uint public constant MIN_WEIGHT = BONE;
uint public constant MAX_WEIGHT = BONE * 50;
uint public constant MAX_TOTAL_WEIGHT = BONE * 50;
uint public constant MIN_BALANCE = BONE / 10**12;
uint public constant INIT_POOL_SUPPLY = BONE * 100;
uint public constant MIN_BPOW_BASE = 1 wei;
uint public constant MAX_BPOW_BASE = (2 * BONE) - 1 wei;
uint public constant BPOW_PRECISION = BONE / 10**10;
uint public constant MAX_IN_RATIO = BONE / 2;
uint public constant MAX_OUT_RATIO = (BONE / 3) + 1 wei;
function btoi(uint a)
internal pure
returns (uint)
{
return a / BONE;
}
function bfloor(uint a)
internal pure
returns (uint)
{
return btoi(a) * BONE;
}
function badd(uint a, uint b)
internal pure
returns (uint)
{
uint c = a + b;
require(c >= a, "ERR_ADD_OVERFLOW");
return c;
}
function bsub(uint a, uint b)
internal pure
returns (uint)
{
(uint c, bool flag) = bsubSign(a, b);
require(!flag, "ERR_SUB_UNDERFLOW");
return c;
}
function bsubSign(uint a, uint b)
internal pure
returns (uint, bool)
{
if (a >= b) {
return (a - b, false);
} else {
return (b - a, true);
}
}
function bmul(uint a, uint b)
internal pure
returns (uint)
{
uint c0 = a * b;
require(a == 0 || c0 / a == b, "ERR_MUL_OVERFLOW");
uint c1 = c0 + (BONE / 2);
require(c1 >= c0, "ERR_MUL_OVERFLOW");
uint c2 = c1 / BONE;
return c2;
}
function bdiv(uint a, uint b)
internal pure
returns (uint)
{
require(b != 0, "ERR_DIV_ZERO");
uint c0 = a * BONE;
require(a == 0 || c0 / a == BONE, "ERR_DIV_INTERNAL"); // bmul overflow
uint c1 = c0 + (b / 2);
require(c1 >= c0, "ERR_DIV_INTERNAL"); // badd require
uint c2 = c1 / b;
return c2;
}
// DSMath.wpow
function bpowi(uint a, uint n)
internal pure
returns (uint)
{
uint z = n % 2 != 0 ? a : BONE;
for (n /= 2; n != 0; n /= 2) {
a = bmul(a, a);
if (n % 2 != 0) {
z = bmul(z, a);
}
}
return z;
}
// Compute b^(e.w) by splitting it into (b^e)*(b^0.w).
// Use `bpowi` for `b^e` and `bpowK` for k iterations
// of approximation of b^0.w
function bpow(uint base, uint exp)
internal pure
returns (uint)
{
require(base >= MIN_BPOW_BASE, "ERR_BPOW_BASE_TOO_LOW");
require(base <= MAX_BPOW_BASE, "ERR_BPOW_BASE_TOO_HIGH");
uint whole = bfloor(exp);
uint remain = bsub(exp, whole);
uint wholePow = bpowi(base, btoi(whole));
if (remain == 0) {
return wholePow;
}
uint partialResult = bpowApprox(base, remain, BPOW_PRECISION);
return bmul(wholePow, partialResult);
}
function bpowApprox(uint base, uint exp, uint precision)
internal pure
returns (uint)
{
// term 0:
uint a = exp;
(uint x, bool xneg) = bsubSign(base, BONE);
uint term = BONE;
uint sum = term;
bool negative = false;
// term(k) = numer / denom
// = (product(a - i - 1, i=1-->k) * x^k) / (k!)
// each iteration, multiply previous term by (a-(k-1)) * x / k
// continue until term is less than precision
for (uint i = 1; term >= precision; i++) {
uint bigK = i * BONE;
(uint c, bool cneg) = bsubSign(a, bsub(bigK, BONE));
term = bmul(term, bmul(c, x));
term = bdiv(term, bigK);
if (term == 0) break;
if (xneg) negative = !negative;
if (cneg) negative = !negative;
if (negative) {
sum = bsub(sum, term);
} else {
sum = badd(sum, term);
}
}
return sum;
}
/**********************************************************************************************
// calcSpotPrice //
// sP = spotPrice //
// bI = tokenBalanceIn ( bI / wI ) 1 //
// bO = tokenBalanceOut sP = ----------- * ---------- //
// wI = tokenWeightIn ( bO / wO ) ( 1 - sF ) //
// wO = tokenWeightOut //
// sF = swapFee //
**********************************************************************************************/
function calcSpotPrice(
uint tokenBalanceIn,
uint tokenWeightIn,
uint tokenBalanceOut,
uint tokenWeightOut,
uint swapFee
)
internal pure
returns (uint spotPrice)
{
uint numer = bdiv(tokenBalanceIn, tokenWeightIn);
uint denom = bdiv(tokenBalanceOut, tokenWeightOut);
uint ratio = bdiv(numer, denom);
uint scale = bdiv(BONE, bsub(BONE, swapFee));
return (spotPrice = bmul(ratio, scale));
}
/**********************************************************************************************
// calcOutGivenIn //
// aO = tokenAmountOut //
// bO = tokenBalanceOut //
// bI = tokenBalanceIn / / bI \ (wI / wO) \ //
// aI = tokenAmountIn aO = bO * | 1 - | -------------------------- | ^ | //
// wI = tokenWeightIn \ \ ( bI + ( aI * ( 1 - sF )) / / //
// wO = tokenWeightOut //
// sF = swapFee //
**********************************************************************************************/
function calcOutGivenIn(
uint tokenBalanceIn,
uint tokenWeightIn,
uint tokenBalanceOut,
uint tokenWeightOut,
uint tokenAmountIn,
uint swapFee
)
internal pure
returns (uint tokenAmountOut)
{
uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut);
uint adjustedIn = bsub(BONE, swapFee);
adjustedIn = bmul(tokenAmountIn, adjustedIn);
uint y = bdiv(tokenBalanceIn, badd(tokenBalanceIn, adjustedIn));
if (y == 0) {
return 0;
}
uint foo = bpow(y, weightRatio);
uint bar = bsub(BONE, foo);
tokenAmountOut = bmul(tokenBalanceOut, bar);
return tokenAmountOut;
}
/**********************************************************************************************
// calcInGivenOut //
// aI = tokenAmountIn //
// bO = tokenBalanceOut / / bO \ (wO / wI) \ //
// bI = tokenBalanceIn bI * | | ------------ | ^ - 1 | //
// aO = tokenAmountOut aI = \ \ ( bO - aO ) / / //
// wI = tokenWeightIn -------------------------------------------- //
// wO = tokenWeightOut ( 1 - sF ) //
// sF = swapFee //
**********************************************************************************************/
function calcInGivenOut(
uint tokenBalanceIn,
uint tokenWeightIn,
uint tokenBalanceOut,
uint tokenWeightOut,
uint tokenAmountOut,
uint swapFee
)
internal pure
returns (uint tokenAmountIn)
{
uint weightRatio = bdiv(tokenWeightOut, tokenWeightIn);
uint diff = bsub(tokenBalanceOut, tokenAmountOut);
uint y = bdiv(tokenBalanceOut, diff);
if (y == 0) {
return 0;
}
uint foo = bpow(y, weightRatio);
foo = bsub(foo, BONE);
tokenAmountIn = bsub(BONE, swapFee);
tokenAmountIn = bdiv(bmul(tokenBalanceIn, foo), tokenAmountIn);
return tokenAmountIn;
}
/**********************************************************************************************
// calcPoolOutGivenSingleIn //
// pAo = poolAmountOut / \ //
// tAi = tokenAmountIn /// / // wI \ \\ \ wI \ //
// wI = tokenWeightIn //| tAi *| 1 - || 1 - -- | * sF || + tBi \ -- \ //
// tW = totalWeight pAo=|| \ \ \\ tW / // | ^ tW | * pS - pS //
// tBi = tokenBalanceIn \\ ------------------------------------- / / //
// pS = poolSupply \\ tBi / / //
// sF = swapFee \ / //
**********************************************************************************************/
function calcPoolOutGivenSingleIn(
uint tokenBalanceIn,
uint tokenWeightIn,
uint poolSupply,
uint totalWeight,
uint tokenAmountIn,
uint swapFee
)
internal pure
returns (uint poolAmountOut)
{
// Charge the trading fee for the proportion of tokenAi
/// which is implicitly traded to the other pool tokens.
// That proportion is (1- weightTokenIn)
// tokenAiAfterFee = tAi * (1 - (1-weightTi) * poolFee);
uint normalizedWeight = bdiv(tokenWeightIn, totalWeight);
uint zaz = bmul(bsub(BONE, normalizedWeight), swapFee);
uint tokenAmountInAfterFee = bmul(tokenAmountIn, bsub(BONE, zaz));
uint newTokenBalanceIn = badd(tokenBalanceIn, tokenAmountInAfterFee);
uint tokenInRatio = bdiv(newTokenBalanceIn, tokenBalanceIn);
// uint newPoolSupply = (ratioTi ^ weightTi) * poolSupply;
uint poolRatio = bpow(tokenInRatio, normalizedWeight);
uint newPoolSupply = bmul(poolRatio, poolSupply);
poolAmountOut = bsub(newPoolSupply, poolSupply);
return poolAmountOut;
}
/**********************************************************************************************
// calcSingleInGivenPoolOut //
// tAi = tokenAmountIn //(pS + pAo)\ / 1 \\ //
// pS = poolSupply || --------- | ^ | --------- || * bI - bI //
// pAo = poolAmountOut \\ pS / \(wI / tW)// //
// bI = balanceIn tAi = -------------------------------------------- //
// wI = weightIn / wI \ //
// tW = totalWeight | 1 - ---- | * sF //
// sF = swapFee \ tW / //
**********************************************************************************************/
function calcSingleInGivenPoolOut(
uint tokenBalanceIn,
uint tokenWeightIn,
uint poolSupply,
uint totalWeight,
uint poolAmountOut,
uint swapFee
)
internal pure
returns (uint tokenAmountIn)
{
uint normalizedWeight = bdiv(tokenWeightIn, totalWeight);
uint newPoolSupply = badd(poolSupply, poolAmountOut);
uint poolRatio = bdiv(newPoolSupply, poolSupply);
//uint newBalTi = poolRatio^(1/weightTi) * balTi;
uint boo = bdiv(BONE, normalizedWeight);
uint tokenInRatio = bpow(poolRatio, boo);
uint newTokenBalanceIn = bmul(tokenInRatio, tokenBalanceIn);
uint tokenAmountInAfterFee = bsub(newTokenBalanceIn, tokenBalanceIn);
// Do reverse order of fees charged in joinswap_ExternAmountIn, this way
// ``` pAo == joinswap_ExternAmountIn(Ti, joinswap_PoolAmountOut(pAo, Ti)) ```
//uint tAi = tAiAfterFee / (1 - (1-weightTi) * swapFee) ;
uint zar = bmul(bsub(BONE, normalizedWeight), swapFee);
tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar));
return tokenAmountIn;
}
/**********************************************************************************************
// calcSingleOutGivenPoolIn //
// tAo = tokenAmountOut / / \\ //
// bO = tokenBalanceOut / // pS - (pAi * (1 - eF)) \ / 1 \ \\ //
// pAi = poolAmountIn | bO - || ----------------------- | ^ | --------- | * b0 || //
// ps = poolSupply \ \\ pS / \(wO / tW)/ // //
// wI = tokenWeightIn tAo = \ \ // //
// tW = totalWeight / / wO \ \ //
// sF = swapFee * | 1 - | 1 - ---- | * sF | //
// eF = exitFee \ \ tW / / //
**********************************************************************************************/
function calcSingleOutGivenPoolIn(
uint tokenBalanceOut,
uint tokenWeightOut,
uint poolSupply,
uint totalWeight,
uint poolAmountIn,
uint swapFee
)
internal pure
returns (uint tokenAmountOut)
{
uint normalizedWeight = bdiv(tokenWeightOut, totalWeight);
// charge exit fee on the pool token side
// pAiAfterExitFee = pAi*(1-exitFee)
uint poolAmountInAfterExitFee = bmul(poolAmountIn, bsub(BONE, EXIT_FEE));
uint newPoolSupply = bsub(poolSupply, poolAmountInAfterExitFee);
uint poolRatio = bdiv(newPoolSupply, poolSupply);
// newBalTo = poolRatio^(1/weightTo) * balTo;
uint tokenOutRatio = bpow(poolRatio, bdiv(BONE, normalizedWeight));
uint newTokenBalanceOut = bmul(tokenOutRatio, tokenBalanceOut);
uint tokenAmountOutBeforeSwapFee = bsub(tokenBalanceOut, newTokenBalanceOut);
// charge swap fee on the output token side
//uint tAo = tAoBeforeSwapFee * (1 - (1-weightTo) * swapFee)
uint zaz = bmul(bsub(BONE, normalizedWeight), swapFee);
tokenAmountOut = bmul(tokenAmountOutBeforeSwapFee, bsub(BONE, zaz));
return tokenAmountOut;
}
/**********************************************************************************************
// calcPoolInGivenSingleOut //
// pAi = poolAmountIn // / tAo \\ / wO \ \ //
// bO = tokenBalanceOut // | bO - -------------------------- |\ | ---- | \ //
// tAo = tokenAmountOut pS - || \ 1 - ((1 - (tO / tW)) * sF)/ | ^ \ tW / * pS | //
// ps = poolSupply \\ -----------------------------------/ / //
// wO = tokenWeightOut pAi = \\ bO / / //
// tW = totalWeight ------------------------------------------------------------- //
// sF = swapFee ( 1 - eF ) //
// eF = exitFee //
**********************************************************************************************/
function calcPoolInGivenSingleOut(
uint tokenBalanceOut,
uint tokenWeightOut,
uint poolSupply,
uint totalWeight,
uint tokenAmountOut,
uint swapFee
)
internal pure
returns (uint poolAmountIn)
{
// charge swap fee on the output token side
uint normalizedWeight = bdiv(tokenWeightOut, totalWeight);
//uint tAoBeforeSwapFee = tAo / (1 - (1-weightTo) * swapFee) ;
uint zoo = bsub(BONE, normalizedWeight);
uint zar = bmul(zoo, swapFee);
uint tokenAmountOutBeforeSwapFee = bdiv(tokenAmountOut, bsub(BONE, zar));
uint newTokenBalanceOut = bsub(tokenBalanceOut, tokenAmountOutBeforeSwapFee);
uint tokenOutRatio = bdiv(newTokenBalanceOut, tokenBalanceOut);
//uint newPoolSupply = (ratioTo ^ weightTo) * poolSupply;
uint poolRatio = bpow(tokenOutRatio, normalizedWeight);
uint newPoolSupply = bmul(poolRatio, poolSupply);
uint poolAmountInAfterExitFee = bsub(poolSupply, newPoolSupply);
// charge exit fee on the pool token side
// pAi = pAiAfterExitFee/(1-exitFee)
poolAmountIn = bdiv(poolAmountInAfterExitFee, bsub(BONE, EXIT_FEE));
return poolAmountIn;
}
}
// File: contracts/OneSplitBase.sol
pragma solidity ^0.5.0;
contract IOneSplitView is IOneSplitConsts {
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
);
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
);
}
library DisableFlags {
function check(uint256 flags, uint256 flag) internal pure returns(bool) {
return (flags & flag) != 0;
}
}
contract OneSplitRoot is IOneSplitView {
using SafeMath for uint256;
using DisableFlags for uint256;
using UniversalERC20 for IERC20;
using UniversalERC20 for IWETH;
using UniswapV2ExchangeLib for IUniswapV2Exchange;
using ChaiHelper for IChai;
uint256 constant internal DEXES_COUNT = 34;
IERC20 constant internal ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
IERC20 constant internal ZERO_ADDRESS = IERC20(0);
IBancorEtherToken constant internal bancorEtherToken = IBancorEtherToken(0xc0829421C1d260BD3cB3E0F06cfE2D52db2cE315);
IWETH constant internal weth = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IChai constant internal chai = IChai(0x06AF07097C9Eeb7fD685c692751D5C66dB49c215);
IERC20 constant internal dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
IERC20 constant internal usdc = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
IERC20 constant internal usdt = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7);
IERC20 constant internal tusd = IERC20(0x0000000000085d4780B73119b644AE5ecd22b376);
IERC20 constant internal busd = IERC20(0x4Fabb145d64652a948d72533023f6E7A623C7C53);
IERC20 constant internal susd = IERC20(0x57Ab1ec28D129707052df4dF418D58a2D46d5f51);
IERC20 constant internal pax = IERC20(0x8E870D67F660D95d5be530380D0eC0bd388289E1);
IERC20 constant internal renbtc = IERC20(0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D);
IERC20 constant internal wbtc = IERC20(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
IERC20 constant internal tbtc = IERC20(0x1bBE271d15Bb64dF0bc6CD28Df9Ff322F2eBD847);
IERC20 constant internal hbtc = IERC20(0x0316EB71485b0Ab14103307bf65a021042c6d380);
IERC20 constant internal sbtc = IERC20(0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6);
IKyberNetworkProxy constant internal kyberNetworkProxy = IKyberNetworkProxy(0x9AAb3f75489902f3a48495025729a0AF77d4b11e);
IKyberStorage constant internal kyberStorage = IKyberStorage(0xC8fb12402cB16970F3C5F4b48Ff68Eb9D1289301);
IKyberHintHandler constant internal kyberHintHandler = IKyberHintHandler(0xa1C0Fa73c39CFBcC11ec9Eb1Afc665aba9996E2C);
IUniswapFactory constant internal uniswapFactory = IUniswapFactory(0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95);
IBancorContractRegistry constant internal bancorContractRegistry = IBancorContractRegistry(0x52Ae12ABe5D8BD778BD5397F99cA900624CfADD4);
IBancorNetworkPathFinder constant internal bancorNetworkPathFinder = IBancorNetworkPathFinder(0x6F0cD8C4f6F06eAB664C7E3031909452b4B72861);
//IBancorConverterRegistry constant internal bancorConverterRegistry = IBancorConverterRegistry(0xf6E2D7F616B67E46D708e4410746E9AAb3a4C518);
IBancorFinder constant internal bancorFinder = IBancorFinder(0x2B344e14dc2641D11D338C053C908c7A7D4c30B9);
IOasisExchange constant internal oasisExchange = IOasisExchange(0x794e6e91555438aFc3ccF1c5076A74F42133d08D);
ICurve constant internal curveCompound = ICurve(0xA2B47E3D5c44877cca798226B7B8118F9BFb7A56);
ICurve constant internal curveUSDT = ICurve(0x52EA46506B9CC5Ef470C5bf89f17Dc28bB35D85C);
ICurve constant internal curveY = ICurve(0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51);
ICurve constant internal curveBinance = ICurve(0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27);
ICurve constant internal curveSynthetix = ICurve(0xA5407eAE9Ba41422680e2e00537571bcC53efBfD);
ICurve constant internal curvePAX = ICurve(0x06364f10B501e868329afBc005b3492902d6C763);
ICurve constant internal curveRenBTC = ICurve(0x93054188d876f558f4a66B2EF1d97d16eDf0895B);
ICurve constant internal curveTBTC = ICurve(0x9726e9314eF1b96E45f40056bEd61A088897313E);
ICurve constant internal curveSBTC = ICurve(0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714);
IShell constant internal shell = IShell(0xA8253a440Be331dC4a7395B73948cCa6F19Dc97D);
IAaveLendingPool constant internal aave = IAaveLendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119);
ICompound constant internal compound = ICompound(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
ICompoundEther constant internal cETH = ICompoundEther(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5);
IMooniswapRegistry constant internal mooniswapRegistry = IMooniswapRegistry(0x71CD6666064C3A1354a3B4dca5fA1E2D3ee7D303);
IUniswapV2Factory constant internal uniswapV2 = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);
IDForceSwap constant internal dforceSwap = IDForceSwap(0x03eF3f37856bD08eb47E2dE7ABc4Ddd2c19B60F2);
IMStable constant internal musd = IMStable(0xe2f2a5C287993345a840Db3B0845fbC70f5935a5);
IMassetValidationHelper constant internal musd_helper = IMassetValidationHelper(0xaBcC93c3be238884cc3309C19Afd128fAfC16911);
IBalancerRegistry constant internal balancerRegistry = IBalancerRegistry(0x65e67cbc342712DF67494ACEfc06fe951EE93982);
ICurveCalculator constant internal curveCalculator = ICurveCalculator(0xc1DB00a8E5Ef7bfa476395cdbcc98235477cDE4E);
ICurveRegistry constant internal curveRegistry = ICurveRegistry(0x7002B727Ef8F5571Cb5F9D70D13DBEEb4dFAe9d1);
ICompoundRegistry constant internal compoundRegistry = ICompoundRegistry(0xF451Dbd7Ba14BFa7B1B78A766D3Ed438F79EE1D1);
IAaveRegistry constant internal aaveRegistry = IAaveRegistry(0xEd8b133B7B88366E01Bb9E38305Ab11c26521494);
IBalancerHelper constant internal balancerHelper = IBalancerHelper(0xA961672E8Db773be387e775bc4937C678F3ddF9a);
int256 internal constant VERY_NEGATIVE_VALUE = -1e72;
function _findBestDistribution(
uint256 s, // parts
int256[][] memory amounts // exchangesReturns
)
internal
pure
returns(
int256 returnAmount,
uint256[] memory distribution
)
{
uint256 n = amounts.length;
int256[][] memory answer = new int256[][](n); // int[n][s+1]
uint256[][] memory parent = new uint256[][](n); // int[n][s+1]
for (uint i = 0; i < n; i++) {
answer[i] = new int256[](s + 1);
parent[i] = new uint256[](s + 1);
}
for (uint j = 0; j <= s; j++) {
answer[0][j] = amounts[0][j];
for (uint i = 1; i < n; i++) {
answer[i][j] = -1e72;
}
parent[0][j] = 0;
}
for (uint i = 1; i < n; i++) {
for (uint j = 0; j <= s; j++) {
answer[i][j] = answer[i - 1][j];
parent[i][j] = j;
for (uint k = 1; k <= j; k++) {
if (answer[i - 1][j - k] + amounts[i][k] > answer[i][j]) {
answer[i][j] = answer[i - 1][j - k] + amounts[i][k];
parent[i][j] = j - k;
}
}
}
}
distribution = new uint256[](DEXES_COUNT);
uint256 partsLeft = s;
for (uint curExchange = n - 1; partsLeft > 0; curExchange--) {
distribution[curExchange] = partsLeft - parent[curExchange][partsLeft];
partsLeft = parent[curExchange][partsLeft];
}
returnAmount = (answer[n - 1][s] == VERY_NEGATIVE_VALUE) ? 0 : answer[n - 1][s];
}
function _kyberReserveIdByTokens(
IERC20 fromToken,
IERC20 destToken
) internal view returns(bytes32) {
if (!fromToken.isETH() && !destToken.isETH()) {
return 0;
}
bytes32[] memory reserveIds = kyberStorage.getReserveIdsPerTokenSrc(
fromToken.isETH() ? destToken : fromToken
);
for (uint i = 0; i < reserveIds.length; i++) {
if ((uint256(reserveIds[i]) >> 248) != 0xBB && // Bridge
reserveIds[i] != 0xff4b796265722046707200000000000000000000000000000000000000000000 && // Reserve 1
reserveIds[i] != 0xffabcd0000000000000000000000000000000000000000000000000000000000 && // Reserve 2
reserveIds[i] != 0xff4f6e65426974205175616e7400000000000000000000000000000000000000) // Reserve 3
{
return reserveIds[i];
}
}
return 0;
}
function _scaleDestTokenEthPriceTimesGasPrice(
IERC20 fromToken,
IERC20 destToken,
uint256 destTokenEthPriceTimesGasPrice
) internal view returns(uint256) {
if (fromToken == destToken) {
return destTokenEthPriceTimesGasPrice;
}
uint256 mul = _cheapGetPrice(ETH_ADDRESS, destToken, 0.01 ether);
uint256 div = _cheapGetPrice(ETH_ADDRESS, fromToken, 0.01 ether);
if (div > 0) {
return destTokenEthPriceTimesGasPrice.mul(mul).div(div);
}
return 0;
}
function _cheapGetPrice(
IERC20 fromToken,
IERC20 destToken,
uint256 amount
) internal view returns(uint256 returnAmount) {
(returnAmount,,) = this.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
1,
FLAG_DISABLE_SPLIT_RECALCULATION |
FLAG_DISABLE_ALL_SPLIT_SOURCES |
FLAG_DISABLE_UNISWAP_V2_ALL |
FLAG_DISABLE_UNISWAP,
0
);
}
function _linearInterpolation(
uint256 value,
uint256 parts
) internal pure returns(uint256[] memory rets) {
rets = new uint256[](parts);
for (uint i = 0; i < parts; i++) {
rets[i] = value.mul(i + 1).div(parts);
}
}
function _tokensEqual(IERC20 tokenA, IERC20 tokenB) internal pure returns(bool) {
return ((tokenA.isETH() && tokenB.isETH()) || tokenA == tokenB);
}
}
contract OneSplitViewWrapBase is IOneSplitView, OneSplitRoot {
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags // See constants in IOneSplit.sol
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
(returnAmount, , distribution) = this.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
0
);
}
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _getExpectedReturnRespectingGasFloor(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _getExpectedReturnRespectingGasFloor(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags, // See constants in IOneSplit.sol
uint256 destTokenEthPriceTimesGasPrice
)
internal
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
);
}
contract OneSplitView is IOneSplitView, OneSplitRoot {
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags // See constants in IOneSplit.sol
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
(returnAmount, , distribution) = getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
0
);
}
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags, // See constants in IOneSplit.sol
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
distribution = new uint256[](DEXES_COUNT);
if (fromToken == destToken) {
return (amount, 0, distribution);
}
function(IERC20,IERC20,uint256,uint256,uint256) view returns(uint256[] memory, uint256)[DEXES_COUNT] memory reserves = _getAllReserves(flags);
int256[][] memory matrix = new int256[][](DEXES_COUNT);
uint256[DEXES_COUNT] memory gases;
bool atLeastOnePositive = false;
for (uint i = 0; i < DEXES_COUNT; i++) {
uint256[] memory rets;
(rets, gases[i]) = reserves[i](fromToken, destToken, amount, parts, flags);
// Prepend zero and sub gas
int256 gas = int256(gases[i].mul(destTokenEthPriceTimesGasPrice).div(1e18));
matrix[i] = new int256[](parts + 1);
for (uint j = 0; j < rets.length; j++) {
matrix[i][j + 1] = int256(rets[j]) - gas;
atLeastOnePositive = atLeastOnePositive || (matrix[i][j + 1] > 0);
}
}
if (!atLeastOnePositive) {
for (uint i = 0; i < DEXES_COUNT; i++) {
for (uint j = 1; j < parts + 1; j++) {
if (matrix[i][j] == 0) {
matrix[i][j] = VERY_NEGATIVE_VALUE;
}
}
}
}
(, distribution) = _findBestDistribution(parts, matrix);
(returnAmount, estimateGasAmount) = _getReturnAndGasByDistribution(
Args({
fromToken: fromToken,
destToken: destToken,
amount: amount,
parts: parts,
flags: flags,
destTokenEthPriceTimesGasPrice: destTokenEthPriceTimesGasPrice,
distribution: distribution,
matrix: matrix,
gases: gases,
reserves: reserves
})
);
return (returnAmount, estimateGasAmount, distribution);
}
struct Args {
IERC20 fromToken;
IERC20 destToken;
uint256 amount;
uint256 parts;
uint256 flags;
uint256 destTokenEthPriceTimesGasPrice;
uint256[] distribution;
int256[][] matrix;
uint256[DEXES_COUNT] gases;
function(IERC20,IERC20,uint256,uint256,uint256) view returns(uint256[] memory, uint256)[DEXES_COUNT] reserves;
}
function _getReturnAndGasByDistribution(
Args memory args
) internal view returns(uint256 returnAmount, uint256 estimateGasAmount) {
bool[DEXES_COUNT] memory exact = [
true, // "Uniswap",
false, // "Kyber",
false, // "Bancor",
false, // "Oasis",
true, // "Curve Compound",
true, // "Curve USDT",
true, // "Curve Y",
true, // "Curve Binance",
true, // "Curve Synthetix",
true, // "Uniswap Compound",
true, // "Uniswap CHAI",
true, // "Uniswap Aave",
true, // "Mooniswap 1",
true, // "Uniswap V2",
true, // "Uniswap V2 (ETH)",
true, // "Uniswap V2 (DAI)",
true, // "Uniswap V2 (USDC)",
true, // "Curve Pax",
true, // "Curve RenBTC",
true, // "Curve tBTC",
true, // "Dforce XSwap",
false, // "Shell",
true, // "mStable",
true, // "Curve sBTC"
true, // "Balancer 1"
true, // "Balancer 2"
true, // "Balancer 3"
true, // "Kyber 1"
true, // "Kyber 2"
true, // "Kyber 3"
true, // "Kyber 4"
true, // "Mooniswap 2"
true, // "Mooniswap 3"
true // "Mooniswap 4"
];
for (uint i = 0; i < DEXES_COUNT; i++) {
if (args.distribution[i] > 0) {
if (args.distribution[i] == args.parts || exact[i] || args.flags.check(FLAG_DISABLE_SPLIT_RECALCULATION)) {
estimateGasAmount = estimateGasAmount.add(args.gases[i]);
int256 value = args.matrix[i][args.distribution[i]];
returnAmount = returnAmount.add(uint256(
(value == VERY_NEGATIVE_VALUE ? 0 : value) +
int256(args.gases[i].mul(args.destTokenEthPriceTimesGasPrice).div(1e18))
));
}
else {
(uint256[] memory rets, uint256 gas) = args.reserves[i](args.fromToken, args.destToken, args.amount.mul(args.distribution[i]).div(args.parts), 1, args.flags);
estimateGasAmount = estimateGasAmount.add(gas);
returnAmount = returnAmount.add(rets[0]);
}
}
}
}
function _getAllReserves(uint256 flags)
internal
pure
returns(function(IERC20,IERC20,uint256,uint256,uint256) view returns(uint256[] memory, uint256)[DEXES_COUNT] memory)
{
bool invert = flags.check(FLAG_DISABLE_ALL_SPLIT_SOURCES);
return [
invert != flags.check(FLAG_DISABLE_UNISWAP_ALL | FLAG_DISABLE_UNISWAP) ? _calculateNoReturn : calculateUniswap,
_calculateNoReturn, // invert != flags.check(FLAG_DISABLE_KYBER) ? _calculateNoReturn : calculateKyber,
invert != flags.check(FLAG_DISABLE_BANCOR) ? _calculateNoReturn : calculateBancor,
invert != flags.check(FLAG_DISABLE_OASIS) ? _calculateNoReturn : calculateOasis,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_COMPOUND) ? _calculateNoReturn : calculateCurveCompound,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_USDT) ? _calculateNoReturn : calculateCurveUSDT,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_Y) ? _calculateNoReturn : calculateCurveY,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_BINANCE) ? _calculateNoReturn : calculateCurveBinance,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_SYNTHETIX) ? _calculateNoReturn : calculateCurveSynthetix,
invert != flags.check(FLAG_DISABLE_UNISWAP_ALL | FLAG_DISABLE_UNISWAP_COMPOUND) ? _calculateNoReturn : calculateUniswapCompound,
invert != flags.check(FLAG_DISABLE_UNISWAP_ALL | FLAG_DISABLE_UNISWAP_CHAI) ? _calculateNoReturn : calculateUniswapChai,
invert != flags.check(FLAG_DISABLE_UNISWAP_ALL | FLAG_DISABLE_UNISWAP_AAVE) ? _calculateNoReturn : calculateUniswapAave,
invert != flags.check(FLAG_DISABLE_MOONISWAP_ALL | FLAG_DISABLE_MOONISWAP) ? _calculateNoReturn : calculateMooniswap,
invert != flags.check(FLAG_DISABLE_UNISWAP_V2_ALL | FLAG_DISABLE_UNISWAP_V2) ? _calculateNoReturn : calculateUniswapV2,
invert != flags.check(FLAG_DISABLE_UNISWAP_V2_ALL | FLAG_DISABLE_UNISWAP_V2_ETH) ? _calculateNoReturn : calculateUniswapV2ETH,
invert != flags.check(FLAG_DISABLE_UNISWAP_V2_ALL | FLAG_DISABLE_UNISWAP_V2_DAI) ? _calculateNoReturn : calculateUniswapV2DAI,
invert != flags.check(FLAG_DISABLE_UNISWAP_V2_ALL | FLAG_DISABLE_UNISWAP_V2_USDC) ? _calculateNoReturn : calculateUniswapV2USDC,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_PAX) ? _calculateNoReturn : calculateCurvePAX,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_RENBTC) ? _calculateNoReturn : calculateCurveRenBTC,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_TBTC) ? _calculateNoReturn : calculateCurveTBTC,
invert != flags.check(FLAG_DISABLE_DFORCE_SWAP) ? _calculateNoReturn : calculateDforceSwap,
invert != flags.check(FLAG_DISABLE_SHELL) ? _calculateNoReturn : calculateShell,
invert != flags.check(FLAG_DISABLE_MSTABLE_MUSD) ? _calculateNoReturn : calculateMStableMUSD,
invert != flags.check(FLAG_DISABLE_CURVE_ALL | FLAG_DISABLE_CURVE_SBTC) ? _calculateNoReturn : calculateCurveSBTC,
invert != flags.check(FLAG_DISABLE_BALANCER_ALL | FLAG_DISABLE_BALANCER_1) ? _calculateNoReturn : calculateBalancer1,
invert != flags.check(FLAG_DISABLE_BALANCER_ALL | FLAG_DISABLE_BALANCER_2) ? _calculateNoReturn : calculateBalancer2,
invert != flags.check(FLAG_DISABLE_BALANCER_ALL | FLAG_DISABLE_BALANCER_3) ? _calculateNoReturn : calculateBalancer3,
invert != flags.check(FLAG_DISABLE_KYBER_ALL | FLAG_DISABLE_KYBER_1) ? _calculateNoReturn : calculateKyber1,
invert != flags.check(FLAG_DISABLE_KYBER_ALL | FLAG_DISABLE_KYBER_2) ? _calculateNoReturn : calculateKyber2,
invert != flags.check(FLAG_DISABLE_KYBER_ALL | FLAG_DISABLE_KYBER_3) ? _calculateNoReturn : calculateKyber3,
invert != flags.check(FLAG_DISABLE_KYBER_ALL | FLAG_DISABLE_KYBER_4) ? _calculateNoReturn : calculateKyber4,
invert != flags.check(FLAG_DISABLE_MOONISWAP_ALL | FLAG_DISABLE_MOONISWAP_ETH) ? _calculateNoReturn : calculateMooniswapOverETH,
invert != flags.check(FLAG_DISABLE_MOONISWAP_ALL | FLAG_DISABLE_MOONISWAP_DAI) ? _calculateNoReturn : calculateMooniswapOverDAI,
invert != flags.check(FLAG_DISABLE_MOONISWAP_ALL | FLAG_DISABLE_MOONISWAP_USDC) ? _calculateNoReturn : calculateMooniswapOverUSDC
];
}
function _calculateNoGas(
IERC20 /*fromToken*/,
IERC20 /*destToken*/,
uint256 /*amount*/,
uint256 /*parts*/,
uint256 /*destTokenEthPriceTimesGasPrice*/,
uint256 /*flags*/,
uint256 /*destTokenEthPrice*/
) internal view returns(uint256[] memory /*rets*/, uint256 /*gas*/) {
this;
}
// View Helpers
struct Balances {
uint256 src;
uint256 dst;
}
function _calculateBalancer(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 poolIndex
) internal view returns(uint256[] memory rets, uint256 gas) {
address[] memory pools = balancerRegistry.getBestPoolsWithLimit(
address(fromToken.isETH() ? weth : fromToken),
address(destToken.isETH() ? weth : destToken),
poolIndex + 1
);
if (poolIndex >= pools.length) {
return (new uint256[](parts), 0);
}
rets = balancerHelper.getReturns(
IBalancerPool(pools[poolIndex]),
fromToken.isETH() ? weth : fromToken,
destToken.isETH() ? weth : destToken,
_linearInterpolation(amount, parts)
);
gas = 75_000 + (fromToken.isETH() || destToken.isETH() ? 0 : 65_000);
}
function calculateBalancer1(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateBalancer(
fromToken,
destToken,
amount,
parts,
0
);
}
function calculateBalancer2(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateBalancer(
fromToken,
destToken,
amount,
parts,
1
);
}
function calculateBalancer3(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateBalancer(
fromToken,
destToken,
amount,
parts,
2
);
}
function calculateMStableMUSD(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
rets = new uint256[](parts);
if ((fromToken != usdc && fromToken != dai && fromToken != usdt && fromToken != tusd) ||
(destToken != usdc && destToken != dai && destToken != usdt && destToken != tusd))
{
return (rets, 0);
}
for (uint i = 1; i <= parts; i *= 2) {
(bool success, bytes memory data) = address(musd).staticcall(abi.encodeWithSelector(
musd.getSwapOutput.selector,
fromToken,
destToken,
amount.mul(parts.div(i)).div(parts)
));
if (success && data.length > 0) {
(,, uint256 maxRet) = abi.decode(data, (bool,string,uint256));
if (maxRet > 0) {
for (uint j = 0; j < parts.div(i); j++) {
rets[j] = maxRet.mul(j + 1).div(parts.div(i));
}
break;
}
}
}
return (
rets,
700_000
);
}
function _getCurvePoolInfo(
ICurve curve,
bool haveUnderlying
) internal view returns(
uint256[8] memory balances,
uint256[8] memory precisions,
uint256[8] memory rates,
uint256 amp,
uint256 fee
) {
uint256[8] memory underlying_balances;
uint256[8] memory decimals;
uint256[8] memory underlying_decimals;
(
balances,
underlying_balances,
decimals,
underlying_decimals,
/*address lp_token*/,
amp,
fee
) = curveRegistry.get_pool_info(address(curve));
for (uint k = 0; k < 8 && balances[k] > 0; k++) {
precisions[k] = 10 ** (18 - (haveUnderlying ? underlying_decimals : decimals)[k]);
if (haveUnderlying) {
rates[k] = underlying_balances[k].mul(1e18).div(balances[k]);
} else {
rates[k] = 1e18;
}
}
}
function _calculateCurveSelector(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
ICurve curve,
bool haveUnderlying,
IERC20[] memory tokens
) internal view returns(uint256[] memory rets) {
rets = new uint256[](parts);
int128 i = 0;
int128 j = 0;
for (uint t = 0; t < tokens.length; t++) {
if (fromToken == tokens[t]) {
i = int128(t + 1);
}
if (destToken == tokens[t]) {
j = int128(t + 1);
}
}
if (i == 0 || j == 0) {
return rets;
}
bytes memory data = abi.encodePacked(
uint256(haveUnderlying ? 1 : 0),
uint256(i - 1),
uint256(j - 1),
_linearInterpolation100(amount, parts)
);
(
uint256[8] memory balances,
uint256[8] memory precisions,
uint256[8] memory rates,
uint256 amp,
uint256 fee
) = _getCurvePoolInfo(curve, haveUnderlying);
bool success;
(success, data) = address(curveCalculator).staticcall(
abi.encodePacked(
abi.encodeWithSelector(
curveCalculator.get_dy.selector,
tokens.length,
balances,
amp,
fee,
rates,
precisions
),
data
)
);
if (!success || data.length == 0) {
return rets;
}
uint256[100] memory dy = abi.decode(data, (uint256[100]));
for (uint t = 0; t < parts; t++) {
rets[t] = dy[t];
}
}
function _linearInterpolation100(
uint256 value,
uint256 parts
) internal pure returns(uint256[100] memory rets) {
for (uint i = 0; i < parts; i++) {
rets[i] = value.mul(i + 1).div(parts);
}
}
function calculateCurveCompound(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](2);
tokens[0] = dai;
tokens[1] = usdc;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveCompound,
true,
tokens
), 720_000);
}
function calculateCurveUSDT(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](3);
tokens[0] = dai;
tokens[1] = usdc;
tokens[2] = usdt;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveUSDT,
true,
tokens
), 720_000);
}
function calculateCurveY(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](4);
tokens[0] = dai;
tokens[1] = usdc;
tokens[2] = usdt;
tokens[3] = tusd;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveY,
true,
tokens
), 1_400_000);
}
function calculateCurveBinance(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](4);
tokens[0] = dai;
tokens[1] = usdc;
tokens[2] = usdt;
tokens[3] = busd;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveBinance,
true,
tokens
), 1_400_000);
}
function calculateCurveSynthetix(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](4);
tokens[0] = dai;
tokens[1] = usdc;
tokens[2] = usdt;
tokens[3] = susd;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveSynthetix,
true,
tokens
), 200_000);
}
function calculateCurvePAX(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](4);
tokens[0] = dai;
tokens[1] = usdc;
tokens[2] = usdt;
tokens[3] = pax;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curvePAX,
true,
tokens
), 1_000_000);
}
function calculateCurveRenBTC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](2);
tokens[0] = renbtc;
tokens[1] = wbtc;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveRenBTC,
false,
tokens
), 130_000);
}
function calculateCurveTBTC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](3);
tokens[0] = tbtc;
tokens[1] = wbtc;
tokens[2] = hbtc;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveTBTC,
false,
tokens
), 145_000);
}
function calculateCurveSBTC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20[] memory tokens = new IERC20[](3);
tokens[0] = renbtc;
tokens[1] = wbtc;
tokens[2] = sbtc;
return (_calculateCurveSelector(
fromToken,
destToken,
amount,
parts,
curveSBTC,
false,
tokens
), 150_000);
}
function calculateShell(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
(bool success, bytes memory data) = address(shell).staticcall(abi.encodeWithSelector(
shell.viewOriginTrade.selector,
fromToken,
destToken,
amount
));
if (!success || data.length == 0) {
return (new uint256[](parts), 0);
}
uint256 maxRet = abi.decode(data, (uint256));
return (_linearInterpolation(maxRet, parts), 300_000);
}
function calculateDforceSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
(bool success, bytes memory data) = address(dforceSwap).staticcall(
abi.encodeWithSelector(
dforceSwap.getAmountByInput.selector,
fromToken,
destToken,
amount
)
);
if (!success || data.length == 0) {
return (new uint256[](parts), 0);
}
uint256 maxRet = abi.decode(data, (uint256));
uint256 available = destToken.universalBalanceOf(address(dforceSwap));
if (maxRet > available) {
return (new uint256[](parts), 0);
}
return (_linearInterpolation(maxRet, parts), 160_000);
}
function _calculateUniswapFormula(uint256 fromBalance, uint256 toBalance, uint256 amount) internal pure returns(uint256) {
if (amount == 0) {
return 0;
}
return amount.mul(toBalance).mul(997).div(
fromBalance.mul(1000).add(amount.mul(997))
);
}
function _calculateUniswap(
IERC20 fromToken,
IERC20 destToken,
uint256[] memory amounts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
rets = amounts;
if (!fromToken.isETH()) {
IUniswapExchange fromExchange = uniswapFactory.getExchange(fromToken);
if (fromExchange == IUniswapExchange(0)) {
return (new uint256[](rets.length), 0);
}
uint256 fromTokenBalance = fromToken.universalBalanceOf(address(fromExchange));
uint256 fromEtherBalance = address(fromExchange).balance;
for (uint i = 0; i < rets.length; i++) {
rets[i] = _calculateUniswapFormula(fromTokenBalance, fromEtherBalance, rets[i]);
}
}
if (!destToken.isETH()) {
IUniswapExchange toExchange = uniswapFactory.getExchange(destToken);
if (toExchange == IUniswapExchange(0)) {
return (new uint256[](rets.length), 0);
}
uint256 toEtherBalance = address(toExchange).balance;
uint256 toTokenBalance = destToken.universalBalanceOf(address(toExchange));
for (uint i = 0; i < rets.length; i++) {
rets[i] = _calculateUniswapFormula(toEtherBalance, toTokenBalance, rets[i]);
}
}
return (rets, fromToken.isETH() || destToken.isETH() ? 60_000 : 100_000);
}
function calculateUniswap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateUniswap(
fromToken,
destToken,
_linearInterpolation(amount, parts),
flags
);
}
function _calculateUniswapWrapped(
IERC20 fromToken,
IERC20 midToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 midTokenPrice,
uint256 flags,
uint256 gas1,
uint256 gas2
) internal view returns(uint256[] memory rets, uint256 gas) {
if (!fromToken.isETH() && destToken.isETH()) {
(rets, gas) = _calculateUniswap(
midToken,
destToken,
_linearInterpolation(amount.mul(1e18).div(midTokenPrice), parts),
flags
);
return (rets, gas + gas1);
}
else if (fromToken.isETH() && !destToken.isETH()) {
(rets, gas) = _calculateUniswap(
fromToken,
midToken,
_linearInterpolation(amount, parts),
flags
);
for (uint i = 0; i < parts; i++) {
rets[i] = rets[i].mul(midTokenPrice).div(1e18);
}
return (rets, gas + gas2);
}
return (new uint256[](parts), 0);
}
function calculateUniswapCompound(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20 midPreToken;
if (!fromToken.isETH() && destToken.isETH()) {
midPreToken = fromToken;
}
else if (!destToken.isETH() && fromToken.isETH()) {
midPreToken = destToken;
}
if (!midPreToken.isETH()) {
ICompoundToken midToken = compoundRegistry.cTokenByToken(midPreToken);
if (midToken != ICompoundToken(0)) {
return _calculateUniswapWrapped(
fromToken,
midToken,
destToken,
amount,
parts,
midToken.exchangeRateStored(),
flags,
200_000,
200_000
);
}
}
return (new uint256[](parts), 0);
}
function calculateUniswapChai(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken == dai && destToken.isETH() ||
fromToken.isETH() && destToken == dai)
{
return _calculateUniswapWrapped(
fromToken,
chai,
destToken,
amount,
parts,
chai.chaiPrice(),
flags,
180_000,
160_000
);
}
return (new uint256[](parts), 0);
}
function calculateUniswapAave(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
IERC20 midPreToken;
if (!fromToken.isETH() && destToken.isETH()) {
midPreToken = fromToken;
}
else if (!destToken.isETH() && fromToken.isETH()) {
midPreToken = destToken;
}
if (!midPreToken.isETH()) {
IAaveToken midToken = aaveRegistry.aTokenByToken(midPreToken);
if (midToken != IAaveToken(0)) {
return _calculateUniswapWrapped(
fromToken,
midToken,
destToken,
amount,
parts,
1e18,
flags,
310_000,
670_000
);
}
}
return (new uint256[](parts), 0);
}
function calculateKyber1(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateKyber(
fromToken,
destToken,
amount,
parts,
flags,
0xff4b796265722046707200000000000000000000000000000000000000000000 // 0x63825c174ab367968EC60f061753D3bbD36A0D8F
);
}
function calculateKyber2(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateKyber(
fromToken,
destToken,
amount,
parts,
flags,
0xffabcd0000000000000000000000000000000000000000000000000000000000 // 0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D
);
}
function calculateKyber3(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateKyber(
fromToken,
destToken,
amount,
parts,
flags,
0xff4f6e65426974205175616e7400000000000000000000000000000000000000 // 0x4f32BbE8dFc9efD54345Fc936f9fEF1048746fCF
);
}
function calculateKyber4(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
bytes32 reserveId = _kyberReserveIdByTokens(fromToken, destToken);
if (reserveId == 0) {
return (new uint256[](parts), 0);
}
return _calculateKyber(
fromToken,
destToken,
amount,
parts,
flags,
reserveId
);
}
function _kyberGetRate(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags,
bytes memory hint
) private view returns(uint256) {
(, bytes memory data) = address(kyberNetworkProxy).staticcall(
abi.encodeWithSelector(
kyberNetworkProxy.getExpectedRateAfterFee.selector,
fromToken,
destToken,
amount,
(flags >> 255) * 10,
hint
)
);
return (data.length == 32) ? abi.decode(data, (uint256)) : 0;
}
function _calculateKyber(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
bytes32 reserveId
) internal view returns(uint256[] memory rets, uint256 gas) {
bytes memory fromHint;
bytes memory destHint;
{
bytes32[] memory reserveIds = new bytes32[](1);
reserveIds[0] = reserveId;
(bool success, bytes memory data) = address(kyberHintHandler).staticcall(
abi.encodeWithSelector(
kyberHintHandler.buildTokenToEthHint.selector,
fromToken,
IKyberHintHandler.TradeType.MaskIn,
reserveIds,
new uint256[](0)
)
);
fromHint = success ? abi.decode(data, (bytes)) : bytes("");
(success, data) = address(kyberHintHandler).staticcall(
abi.encodeWithSelector(
kyberHintHandler.buildEthToTokenHint.selector,
destToken,
IKyberHintHandler.TradeType.MaskIn,
reserveIds,
new uint256[](0)
)
);
destHint = success ? abi.decode(data, (bytes)) : bytes("");
}
uint256 fromTokenDecimals = 10 ** IERC20(fromToken).universalDecimals();
uint256 destTokenDecimals = 10 ** IERC20(destToken).universalDecimals();
rets = new uint256[](parts);
for (uint i = 0; i < parts; i++) {
if (i > 0 && rets[i - 1] == 0) {
break;
}
rets[i] = amount.mul(i + 1).div(parts);
if (!fromToken.isETH()) {
if (fromHint.length == 0) {
rets[i] = 0;
break;
}
uint256 rate = _kyberGetRate(
fromToken,
ETH_ADDRESS,
rets[i],
flags,
fromHint
);
rets[i] = rate.mul(rets[i]).div(fromTokenDecimals);
}
if (!destToken.isETH() && rets[i] > 0) {
if (destHint.length == 0) {
rets[i] = 0;
break;
}
uint256 rate = _kyberGetRate(
ETH_ADDRESS,
destToken,
rets[i],
10,
destHint
);
rets[i] = rate.mul(rets[i]).mul(destTokenDecimals).div(1e36);
}
}
return (rets, 100_000);
}
function calculateBancor(
IERC20 /*fromToken*/,
IERC20 /*destToken*/,
uint256 /*amount*/,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
return (new uint256[](parts), 0);
// IBancorNetwork bancorNetwork = IBancorNetwork(bancorContractRegistry.addressOf("BancorNetwork"));
// address[] memory path = bancorFinder.buildBancorPath(
// fromToken.isETH() ? bancorEtherToken : fromToken,
// destToken.isETH() ? bancorEtherToken : destToken
// );
// rets = _linearInterpolation(amount, parts);
// for (uint i = 0; i < parts; i++) {
// (bool success, bytes memory data) = address(bancorNetwork).staticcall.gas(500000)(
// abi.encodeWithSelector(
// bancorNetwork.getReturnByPath.selector,
// path,
// rets[i]
// )
// );
// if (!success || data.length == 0) {
// for (; i < parts; i++) {
// rets[i] = 0;
// }
// break;
// } else {
// (uint256 ret,) = abi.decode(data, (uint256,uint256));
// rets[i] = ret;
// }
// }
// return (rets, path.length.mul(150_000));
}
function calculateOasis(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
rets = _linearInterpolation(amount, parts);
for (uint i = 0; i < parts; i++) {
(bool success, bytes memory data) = address(oasisExchange).staticcall.gas(500000)(
abi.encodeWithSelector(
oasisExchange.getBuyAmount.selector,
destToken.isETH() ? weth : destToken,
fromToken.isETH() ? weth : fromToken,
rets[i]
)
);
if (!success || data.length == 0) {
for (; i < parts; i++) {
rets[i] = 0;
}
break;
} else {
rets[i] = abi.decode(data, (uint256));
}
}
return (rets, 500_000);
}
function calculateMooniswapMany(
IERC20 fromToken,
IERC20 destToken,
uint256[] memory amounts
) internal view returns(uint256[] memory rets, uint256 gas) {
rets = new uint256[](amounts.length);
IMooniswap mooniswap = mooniswapRegistry.pools(
fromToken.isETH() ? ZERO_ADDRESS : fromToken,
destToken.isETH() ? ZERO_ADDRESS : destToken
);
if (mooniswap == IMooniswap(0)) {
return (rets, 0);
}
uint256 fee = mooniswap.fee();
uint256 fromBalance = mooniswap.getBalanceForAddition(fromToken.isETH() ? ZERO_ADDRESS : fromToken);
uint256 destBalance = mooniswap.getBalanceForRemoval(destToken.isETH() ? ZERO_ADDRESS : destToken);
if (fromBalance == 0 || destBalance == 0) {
return (rets, 0);
}
for (uint i = 0; i < amounts.length; i++) {
uint256 amount = amounts[i].sub(amounts[i].mul(fee).div(1e18));
rets[i] = amount.mul(destBalance).div(
fromBalance.add(amount)
);
}
return (rets, (fromToken.isETH() || destToken.isETH()) ? 80_000 : 110_000);
}
function calculateMooniswap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
return calculateMooniswapMany(
fromToken,
destToken,
_linearInterpolation(amount, parts)
);
}
function calculateMooniswapOverETH(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken.isETH() || destToken.isETH()) {
return (new uint256[](parts), 0);
}
(uint256[] memory results, uint256 gas1) = calculateMooniswap(fromToken, ZERO_ADDRESS, amount, parts, flags);
(rets, gas) = calculateMooniswapMany(ZERO_ADDRESS, destToken, results);
gas = gas.add(gas1);
}
function calculateMooniswapOverDAI(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken == dai || destToken == dai) {
return (new uint256[](parts), 0);
}
(uint256[] memory results, uint256 gas1) = calculateMooniswap(fromToken, dai, amount, parts, flags);
(rets, gas) = calculateMooniswapMany(dai, destToken, results);
gas = gas.add(gas1);
}
function calculateMooniswapOverUSDC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken == usdc || destToken == usdc) {
return (new uint256[](parts), 0);
}
(uint256[] memory results, uint256 gas1) = calculateMooniswap(fromToken, usdc, amount, parts, flags);
(rets, gas) = calculateMooniswapMany(usdc, destToken, results);
gas = gas.add(gas1);
}
function calculateUniswapV2(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
return _calculateUniswapV2(
fromToken,
destToken,
_linearInterpolation(amount, parts),
flags
);
}
function calculateUniswapV2ETH(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken.isETH() || fromToken == weth || destToken.isETH() || destToken == weth) {
return (new uint256[](parts), 0);
}
return _calculateUniswapV2OverMidToken(
fromToken,
weth,
destToken,
amount,
parts,
flags
);
}
function calculateUniswapV2DAI(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken == dai || destToken == dai) {
return (new uint256[](parts), 0);
}
return _calculateUniswapV2OverMidToken(
fromToken,
dai,
destToken,
amount,
parts,
flags
);
}
function calculateUniswapV2USDC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
if (fromToken == usdc || destToken == usdc) {
return (new uint256[](parts), 0);
}
return _calculateUniswapV2OverMidToken(
fromToken,
usdc,
destToken,
amount,
parts,
flags
);
}
function _calculateUniswapV2(
IERC20 fromToken,
IERC20 destToken,
uint256[] memory amounts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
rets = new uint256[](amounts.length);
IERC20 fromTokenReal = fromToken.isETH() ? weth : fromToken;
IERC20 destTokenReal = destToken.isETH() ? weth : destToken;
IUniswapV2Exchange exchange = uniswapV2.getPair(fromTokenReal, destTokenReal);
if (exchange != IUniswapV2Exchange(0)) {
uint256 fromTokenBalance = fromTokenReal.universalBalanceOf(address(exchange));
uint256 destTokenBalance = destTokenReal.universalBalanceOf(address(exchange));
for (uint i = 0; i < amounts.length; i++) {
rets[i] = _calculateUniswapFormula(fromTokenBalance, destTokenBalance, amounts[i]);
}
return (rets, 50_000);
}
}
function _calculateUniswapV2OverMidToken(
IERC20 fromToken,
IERC20 midToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) internal view returns(uint256[] memory rets, uint256 gas) {
rets = _linearInterpolation(amount, parts);
uint256 gas1;
uint256 gas2;
(rets, gas1) = _calculateUniswapV2(fromToken, midToken, rets, flags);
(rets, gas2) = _calculateUniswapV2(midToken, destToken, rets, flags);
return (rets, gas1 + gas2);
}
function _calculateNoReturn(
IERC20 /*fromToken*/,
IERC20 /*destToken*/,
uint256 /*amount*/,
uint256 parts,
uint256 /*flags*/
) internal view returns(uint256[] memory rets, uint256 gas) {
this;
return (new uint256[](parts), 0);
}
}
contract OneSplitBaseWrap is IOneSplit, OneSplitRoot {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags // See constants in IOneSplit.sol
) internal {
if (fromToken == destToken) {
return;
}
_swapFloor(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _swapFloor(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 /*flags*/ // See constants in IOneSplit.sol
) internal;
}
contract OneSplit is IOneSplit, OneSplitRoot {
IOneSplitView public oneSplitView;
constructor(IOneSplitView _oneSplitView) public {
oneSplitView = _oneSplitView;
}
function() external payable {
// solium-disable-next-line security/no-tx-origin
require(msg.sender != tx.origin);
}
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
(returnAmount, , distribution) = getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
0
);
}
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return oneSplitView.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256 flags // See constants in IOneSplit.sol
) public payable returns(uint256 returnAmount) {
if (fromToken == destToken) {
return amount;
}
function(IERC20,IERC20,uint256,uint256)[DEXES_COUNT] memory reserves = [
_swapOnUniswap,
_swapOnNowhere,
_swapOnBancor,
_swapOnOasis,
_swapOnCurveCompound,
_swapOnCurveUSDT,
_swapOnCurveY,
_swapOnCurveBinance,
_swapOnCurveSynthetix,
_swapOnUniswapCompound,
_swapOnUniswapChai,
_swapOnUniswapAave,
_swapOnMooniswap,
_swapOnUniswapV2,
_swapOnUniswapV2ETH,
_swapOnUniswapV2DAI,
_swapOnUniswapV2USDC,
_swapOnCurvePAX,
_swapOnCurveRenBTC,
_swapOnCurveTBTC,
_swapOnDforceSwap,
_swapOnShell,
_swapOnMStableMUSD,
_swapOnCurveSBTC,
_swapOnBalancer1,
_swapOnBalancer2,
_swapOnBalancer3,
_swapOnKyber1,
_swapOnKyber2,
_swapOnKyber3,
_swapOnKyber4,
_swapOnMooniswapETH,
_swapOnMooniswapDAI,
_swapOnMooniswapUSDC
];
require(distribution.length <= reserves.length, "OneSplit: Distribution array should not exceed reserves array size");
uint256 parts = 0;
uint256 lastNonZeroIndex = 0;
for (uint i = 0; i < distribution.length; i++) {
if (distribution[i] > 0) {
parts = parts.add(distribution[i]);
lastNonZeroIndex = i;
}
}
if (parts == 0) {
if (fromToken.isETH()) {
msg.sender.transfer(msg.value);
return msg.value;
}
return amount;
}
fromToken.universalTransferFrom(msg.sender, address(this), amount);
uint256 remainingAmount = fromToken.universalBalanceOf(address(this));
for (uint i = 0; i < distribution.length; i++) {
if (distribution[i] == 0) {
continue;
}
uint256 swapAmount = amount.mul(distribution[i]).div(parts);
if (i == lastNonZeroIndex) {
swapAmount = remainingAmount;
}
remainingAmount -= swapAmount;
reserves[i](fromToken, destToken, swapAmount, flags);
}
returnAmount = destToken.universalBalanceOf(address(this));
require(returnAmount >= minReturn, "OneSplit: Return amount was not enough");
destToken.universalTransfer(msg.sender, returnAmount);
fromToken.universalTransfer(msg.sender, fromToken.universalBalanceOf(address(this)));
}
// Swap helpers
function _swapOnCurveCompound(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == dai ? 1 : 0) + (fromToken == usdc ? 2 : 0);
int128 j = (destToken == dai ? 1 : 0) + (destToken == usdc ? 2 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveCompound), amount);
curveCompound.exchange_underlying(i - 1, j - 1, amount, 0);
}
function _swapOnCurveUSDT(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == dai ? 1 : 0) +
(fromToken == usdc ? 2 : 0) +
(fromToken == usdt ? 3 : 0);
int128 j = (destToken == dai ? 1 : 0) +
(destToken == usdc ? 2 : 0) +
(destToken == usdt ? 3 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveUSDT), amount);
curveUSDT.exchange_underlying(i - 1, j - 1, amount, 0);
}
function _swapOnCurveY(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == dai ? 1 : 0) +
(fromToken == usdc ? 2 : 0) +
(fromToken == usdt ? 3 : 0) +
(fromToken == tusd ? 4 : 0);
int128 j = (destToken == dai ? 1 : 0) +
(destToken == usdc ? 2 : 0) +
(destToken == usdt ? 3 : 0) +
(destToken == tusd ? 4 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveY), amount);
curveY.exchange_underlying(i - 1, j - 1, amount, 0);
}
function _swapOnCurveBinance(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == dai ? 1 : 0) +
(fromToken == usdc ? 2 : 0) +
(fromToken == usdt ? 3 : 0) +
(fromToken == busd ? 4 : 0);
int128 j = (destToken == dai ? 1 : 0) +
(destToken == usdc ? 2 : 0) +
(destToken == usdt ? 3 : 0) +
(destToken == busd ? 4 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveBinance), amount);
curveBinance.exchange_underlying(i - 1, j - 1, amount, 0);
}
function _swapOnCurveSynthetix(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == dai ? 1 : 0) +
(fromToken == usdc ? 2 : 0) +
(fromToken == usdt ? 3 : 0) +
(fromToken == susd ? 4 : 0);
int128 j = (destToken == dai ? 1 : 0) +
(destToken == usdc ? 2 : 0) +
(destToken == usdt ? 3 : 0) +
(destToken == susd ? 4 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveSynthetix), amount);
curveSynthetix.exchange_underlying(i - 1, j - 1, amount, 0);
}
function _swapOnCurvePAX(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == dai ? 1 : 0) +
(fromToken == usdc ? 2 : 0) +
(fromToken == usdt ? 3 : 0) +
(fromToken == pax ? 4 : 0);
int128 j = (destToken == dai ? 1 : 0) +
(destToken == usdc ? 2 : 0) +
(destToken == usdt ? 3 : 0) +
(destToken == pax ? 4 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curvePAX), amount);
curvePAX.exchange_underlying(i - 1, j - 1, amount, 0);
}
function _swapOnShell(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
fromToken.universalApprove(address(shell), amount);
shell.swapByOrigin(
address(fromToken),
address(destToken),
amount,
0,
now + 50
);
}
function _swapOnMStableMUSD(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
fromToken.universalApprove(address(musd), amount);
musd.swap(
fromToken,
destToken,
amount,
address(this)
);
}
function _swapOnCurveRenBTC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == renbtc ? 1 : 0) +
(fromToken == wbtc ? 2 : 0);
int128 j = (destToken == renbtc ? 1 : 0) +
(destToken == wbtc ? 2 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveRenBTC), amount);
curveRenBTC.exchange(i - 1, j - 1, amount, 0);
}
function _swapOnCurveTBTC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == tbtc ? 1 : 0) +
(fromToken == wbtc ? 2 : 0) +
(fromToken == hbtc ? 3 : 0);
int128 j = (destToken == tbtc ? 1 : 0) +
(destToken == wbtc ? 2 : 0) +
(destToken == hbtc ? 3 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveTBTC), amount);
curveTBTC.exchange(i - 1, j - 1, amount, 0);
}
function _swapOnCurveSBTC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
int128 i = (fromToken == renbtc ? 1 : 0) +
(fromToken == wbtc ? 2 : 0) +
(fromToken == sbtc ? 3 : 0);
int128 j = (destToken == renbtc ? 1 : 0) +
(destToken == wbtc ? 2 : 0) +
(destToken == sbtc ? 3 : 0);
if (i == 0 || j == 0) {
return;
}
fromToken.universalApprove(address(curveSBTC), amount);
curveSBTC.exchange(i - 1, j - 1, amount, 0);
}
function _swapOnDforceSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
fromToken.universalApprove(address(dforceSwap), amount);
dforceSwap.swap(fromToken, destToken, amount);
}
function _swapOnUniswap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
uint256 returnAmount = amount;
if (!fromToken.isETH()) {
IUniswapExchange fromExchange = uniswapFactory.getExchange(fromToken);
if (fromExchange != IUniswapExchange(0)) {
fromToken.universalApprove(address(fromExchange), returnAmount);
returnAmount = fromExchange.tokenToEthSwapInput(returnAmount, 1, now);
}
}
if (!destToken.isETH()) {
IUniswapExchange toExchange = uniswapFactory.getExchange(destToken);
if (toExchange != IUniswapExchange(0)) {
returnAmount = toExchange.ethToTokenSwapInput.value(returnAmount)(1, now);
}
}
}
function _swapOnUniswapCompound(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
if (!fromToken.isETH()) {
ICompoundToken fromCompound = compoundRegistry.cTokenByToken(fromToken);
fromToken.universalApprove(address(fromCompound), amount);
fromCompound.mint(amount);
_swapOnUniswap(IERC20(fromCompound), destToken, IERC20(fromCompound).universalBalanceOf(address(this)), flags);
return;
}
if (!destToken.isETH()) {
ICompoundToken toCompound = compoundRegistry.cTokenByToken(destToken);
_swapOnUniswap(fromToken, IERC20(toCompound), amount, flags);
toCompound.redeem(IERC20(toCompound).universalBalanceOf(address(this)));
destToken.universalBalanceOf(address(this));
return;
}
}
function _swapOnUniswapChai(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
if (fromToken == dai) {
fromToken.universalApprove(address(chai), amount);
chai.join(address(this), amount);
_swapOnUniswap(IERC20(chai), destToken, IERC20(chai).universalBalanceOf(address(this)), flags);
return;
}
if (destToken == dai) {
_swapOnUniswap(fromToken, IERC20(chai), amount, flags);
chai.exit(address(this), chai.balanceOf(address(this)));
return;
}
}
function _swapOnUniswapAave(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
if (!fromToken.isETH()) {
IAaveToken fromAave = aaveRegistry.aTokenByToken(fromToken);
fromToken.universalApprove(aave.core(), amount);
aave.deposit(fromToken, amount, 1101);
_swapOnUniswap(IERC20(fromAave), destToken, IERC20(fromAave).universalBalanceOf(address(this)), flags);
return;
}
if (!destToken.isETH()) {
IAaveToken toAave = aaveRegistry.aTokenByToken(destToken);
_swapOnUniswap(fromToken, IERC20(toAave), amount, flags);
toAave.redeem(toAave.balanceOf(address(this)));
return;
}
}
function _swapOnMooniswap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
IMooniswap mooniswap = mooniswapRegistry.pools(
fromToken.isETH() ? ZERO_ADDRESS : fromToken,
destToken.isETH() ? ZERO_ADDRESS : destToken
);
fromToken.universalApprove(address(mooniswap), amount);
mooniswap.swap.value(fromToken.isETH() ? amount : 0)(
fromToken.isETH() ? ZERO_ADDRESS : fromToken,
destToken.isETH() ? ZERO_ADDRESS : destToken,
amount,
0,
0x68a17B587CAF4f9329f0e372e3A78D23A46De6b5
);
}
function _swapOnMooniswapETH(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnMooniswap(fromToken, ZERO_ADDRESS, amount, flags);
_swapOnMooniswap(ZERO_ADDRESS, destToken, address(this).balance, flags);
}
function _swapOnMooniswapDAI(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnMooniswap(fromToken, dai, amount, flags);
_swapOnMooniswap(dai, destToken, dai.balanceOf(address(this)), flags);
}
function _swapOnMooniswapUSDC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnMooniswap(fromToken, usdc, amount, flags);
_swapOnMooniswap(usdc, destToken, usdc.balanceOf(address(this)), flags);
}
function _swapOnNowhere(
IERC20 /*fromToken*/,
IERC20 /*destToken*/,
uint256 /*amount*/,
uint256 /*flags*/
) internal {
revert("This source was deprecated");
}
function _swapOnKyber1(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnKyber(
fromToken,
destToken,
amount,
flags,
0xff4b796265722046707200000000000000000000000000000000000000000000
);
}
function _swapOnKyber2(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnKyber(
fromToken,
destToken,
amount,
flags,
0xffabcd0000000000000000000000000000000000000000000000000000000000
);
}
function _swapOnKyber3(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnKyber(
fromToken,
destToken,
amount,
flags,
0xff4f6e65426974205175616e7400000000000000000000000000000000000000
);
}
function _swapOnKyber4(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnKyber(
fromToken,
destToken,
amount,
flags,
_kyberReserveIdByTokens(fromToken, destToken)
);
}
function _swapOnKyber(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags,
bytes32 reserveId
) internal {
uint256 returnAmount = amount;
bytes32[] memory reserveIds = new bytes32[](1);
reserveIds[0] = reserveId;
if (!fromToken.isETH()) {
bytes memory fromHint = kyberHintHandler.buildTokenToEthHint(
fromToken,
IKyberHintHandler.TradeType.MaskIn,
reserveIds,
new uint256[](0)
);
fromToken.universalApprove(address(kyberNetworkProxy), amount);
returnAmount = kyberNetworkProxy.tradeWithHintAndFee(
fromToken,
returnAmount,
ETH_ADDRESS,
address(this),
uint256(-1),
0,
0x68a17B587CAF4f9329f0e372e3A78D23A46De6b5,
(flags >> 255) * 10,
fromHint
);
}
if (!destToken.isETH()) {
bytes memory destHint = kyberHintHandler.buildEthToTokenHint(
destToken,
IKyberHintHandler.TradeType.MaskIn,
reserveIds,
new uint256[](0)
);
returnAmount = kyberNetworkProxy.tradeWithHintAndFee.value(returnAmount)(
ETH_ADDRESS,
returnAmount,
destToken,
address(this),
uint256(-1),
0,
0x68a17B587CAF4f9329f0e372e3A78D23A46De6b5,
(flags >> 255) * 10,
destHint
);
}
}
function _swapOnBancor(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
IBancorNetwork bancorNetwork = IBancorNetwork(bancorContractRegistry.addressOf("BancorNetwork"));
address[] memory path = bancorNetworkPathFinder.generatePath(
fromToken.isETH() ? bancorEtherToken : fromToken,
destToken.isETH() ? bancorEtherToken : destToken
);
fromToken.universalApprove(address(bancorNetwork), amount);
bancorNetwork.convert.value(fromToken.isETH() ? amount : 0)(path, amount, 1);
}
function _swapOnOasis(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal {
if (fromToken.isETH()) {
weth.deposit.value(amount)();
}
IERC20 approveToken = fromToken.isETH() ? weth : fromToken;
approveToken.universalApprove(address(oasisExchange), amount);
oasisExchange.sellAllAmount(
fromToken.isETH() ? weth : fromToken,
amount,
destToken.isETH() ? weth : destToken,
1
);
if (destToken.isETH()) {
weth.withdraw(weth.balanceOf(address(this)));
}
}
function _swapOnUniswapV2Internal(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/
) internal returns(uint256 returnAmount) {
if (fromToken.isETH()) {
weth.deposit.value(amount)();
}
IERC20 fromTokenReal = fromToken.isETH() ? weth : fromToken;
IERC20 toTokenReal = destToken.isETH() ? weth : destToken;
IUniswapV2Exchange exchange = uniswapV2.getPair(fromTokenReal, toTokenReal);
bool needSync;
bool needSkim;
(returnAmount, needSync, needSkim) = exchange.getReturn(fromTokenReal, toTokenReal, amount);
if (needSync) {
exchange.sync();
}
else if (needSkim) {
exchange.skim(0x68a17B587CAF4f9329f0e372e3A78D23A46De6b5);
}
fromTokenReal.universalTransfer(address(exchange), amount);
if (uint256(address(fromTokenReal)) < uint256(address(toTokenReal))) {
exchange.swap(0, returnAmount, address(this), "");
} else {
exchange.swap(returnAmount, 0, address(this), "");
}
if (destToken.isETH()) {
weth.withdraw(weth.balanceOf(address(this)));
}
}
function _swapOnUniswapV2OverMid(
IERC20 fromToken,
IERC20 midToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnUniswapV2Internal(
midToken,
destToken,
_swapOnUniswapV2Internal(
fromToken,
midToken,
amount,
flags
),
flags
);
}
function _swapOnUniswapV2(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnUniswapV2Internal(
fromToken,
destToken,
amount,
flags
);
}
function _swapOnUniswapV2ETH(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnUniswapV2OverMid(
fromToken,
weth,
destToken,
amount,
flags
);
}
function _swapOnUniswapV2DAI(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnUniswapV2OverMid(
fromToken,
dai,
destToken,
amount,
flags
);
}
function _swapOnUniswapV2USDC(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnUniswapV2OverMid(
fromToken,
usdc,
destToken,
amount,
flags
);
}
function _swapOnBalancerX(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 /*flags*/,
uint256 poolIndex
) internal {
address[] memory pools = balancerRegistry.getBestPoolsWithLimit(
address(fromToken.isETH() ? weth : fromToken),
address(destToken.isETH() ? weth : destToken),
poolIndex + 1
);
if (fromToken.isETH()) {
weth.deposit.value(amount)();
}
(fromToken.isETH() ? weth : fromToken).universalApprove(pools[poolIndex], amount);
IBalancerPool(pools[poolIndex]).swapExactAmountIn(
fromToken.isETH() ? weth : fromToken,
amount,
destToken.isETH() ? weth : destToken,
0,
uint256(-1)
);
if (destToken.isETH()) {
weth.withdraw(weth.balanceOf(address(this)));
}
}
function _swapOnBalancer1(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnBalancerX(fromToken, destToken, amount, flags, 0);
}
function _swapOnBalancer2(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnBalancerX(fromToken, destToken, amount, flags, 1);
}
function _swapOnBalancer3(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 flags
) internal {
_swapOnBalancerX(fromToken, destToken, amount, flags, 2);
}
}
// File: contracts/OneSplitCompound.sol
pragma solidity ^0.5.0;
contract OneSplitCompoundView is OneSplitViewWrapBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _compoundGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _compoundGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
private
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_COMPOUND)) {
IERC20 underlying = compoundRegistry.tokenByCToken(ICompoundToken(address(fromToken)));
if (underlying != IERC20(0)) {
uint256 compoundRate = ICompoundToken(address(fromToken)).exchangeRateStored();
(returnAmount, estimateGasAmount, distribution) = _compoundGetExpectedReturn(
underlying,
destToken,
amount.mul(compoundRate).div(1e18),
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 295_000, distribution);
}
underlying = compoundRegistry.tokenByCToken(ICompoundToken(address(destToken)));
if (underlying != IERC20(0)) {
uint256 _destTokenEthPriceTimesGasPrice = destTokenEthPriceTimesGasPrice;
uint256 compoundRate = ICompoundToken(address(destToken)).exchangeRateStored();
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
underlying,
amount,
parts,
flags,
_destTokenEthPriceTimesGasPrice.mul(compoundRate).div(1e18)
);
return (returnAmount.mul(1e18).div(compoundRate), estimateGasAmount + 430_000, distribution);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitCompound is OneSplitBaseWrap {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_compoundSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _compoundSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_COMPOUND)) {
IERC20 underlying = compoundRegistry.tokenByCToken(ICompoundToken(address(fromToken)));
if (underlying != IERC20(0)) {
ICompoundToken(address(fromToken)).redeem(amount);
uint256 underlyingAmount = underlying.universalBalanceOf(address(this));
return _compoundSwap(
underlying,
destToken,
underlyingAmount,
distribution,
flags
);
}
underlying = compoundRegistry.tokenByCToken(ICompoundToken(address(destToken)));
if (underlying != IERC20(0)) {
super._swap(
fromToken,
underlying,
amount,
distribution,
flags
);
uint256 underlyingAmount = underlying.universalBalanceOf(address(this));
if (underlying.isETH()) {
cETH.mint.value(underlyingAmount)();
} else {
underlying.universalApprove(address(destToken), underlyingAmount);
ICompoundToken(address(destToken)).mint(underlyingAmount);
}
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/interface/IFulcrum.sol
pragma solidity ^0.5.0;
contract IFulcrumToken is IERC20 {
function tokenPrice() external view returns (uint256);
function loanTokenAddress() external view returns (address);
function mintWithEther(address receiver) external payable returns (uint256 mintAmount);
function mint(address receiver, uint256 depositAmount) external returns (uint256 mintAmount);
function burnToEther(address receiver, uint256 burnAmount)
external
returns (uint256 loanAmountPaid);
function burn(address receiver, uint256 burnAmount) external returns (uint256 loanAmountPaid);
}
// File: contracts/OneSplitFulcrum.sol
pragma solidity ^0.5.0;
contract OneSplitFulcrumBase {
using UniversalERC20 for IERC20;
function _isFulcrumToken(IERC20 token) internal view returns(IERC20) {
if (token.isETH()) {
return IERC20(-1);
}
(bool success, bytes memory data) = address(token).staticcall.gas(5000)(abi.encodeWithSignature(
"name()"
));
if (!success) {
return IERC20(-1);
}
bool foundBZX = false;
for (uint i = 0; i + 6 < data.length; i++) {
if (data[i + 0] == "F" &&
data[i + 1] == "u" &&
data[i + 2] == "l" &&
data[i + 3] == "c" &&
data[i + 4] == "r" &&
data[i + 5] == "u" &&
data[i + 6] == "m")
{
foundBZX = true;
break;
}
}
if (!foundBZX) {
return IERC20(-1);
}
(success, data) = address(token).staticcall.gas(5000)(abi.encodeWithSelector(
IFulcrumToken(address(token)).loanTokenAddress.selector
));
if (!success) {
return IERC20(-1);
}
return abi.decode(data, (IERC20));
}
}
contract OneSplitFulcrumView is OneSplitViewWrapBase, OneSplitFulcrumBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _fulcrumGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _fulcrumGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
private
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_FULCRUM)) {
IERC20 underlying = _isFulcrumToken(fromToken);
if (underlying != IERC20(-1)) {
uint256 fulcrumRate = IFulcrumToken(address(fromToken)).tokenPrice();
(returnAmount, estimateGasAmount, distribution) = _fulcrumGetExpectedReturn(
underlying,
destToken,
amount.mul(fulcrumRate).div(1e18),
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 381_000, distribution);
}
underlying = _isFulcrumToken(destToken);
if (underlying != IERC20(-1)) {
uint256 _destTokenEthPriceTimesGasPrice = destTokenEthPriceTimesGasPrice;
uint256 fulcrumRate = IFulcrumToken(address(destToken)).tokenPrice();
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
underlying,
amount,
parts,
flags,
_destTokenEthPriceTimesGasPrice.mul(fulcrumRate).div(1e18)
);
return (returnAmount.mul(1e18).div(fulcrumRate), estimateGasAmount + 354_000, distribution);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitFulcrum is OneSplitBaseWrap, OneSplitFulcrumBase {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_fulcrumSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _fulcrumSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_FULCRUM)) {
IERC20 underlying = _isFulcrumToken(fromToken);
if (underlying != IERC20(-1)) {
if (underlying.isETH()) {
IFulcrumToken(address(fromToken)).burnToEther(address(this), amount);
} else {
IFulcrumToken(address(fromToken)).burn(address(this), amount);
}
uint256 underlyingAmount = underlying.universalBalanceOf(address(this));
return super._swap(
underlying,
destToken,
underlyingAmount,
distribution,
flags
);
}
underlying = _isFulcrumToken(destToken);
if (underlying != IERC20(-1)) {
super._swap(
fromToken,
underlying,
amount,
distribution,
flags
);
uint256 underlyingAmount = underlying.universalBalanceOf(address(this));
if (underlying.isETH()) {
IFulcrumToken(address(destToken)).mintWithEther.value(underlyingAmount)(address(this));
} else {
underlying.universalApprove(address(destToken), underlyingAmount);
IFulcrumToken(address(destToken)).mint(address(this), underlyingAmount);
}
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/OneSplitChai.sol
pragma solidity ^0.5.0;
contract OneSplitChaiView is OneSplitViewWrapBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_CHAI)) {
if (fromToken == IERC20(chai)) {
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
dai,
destToken,
chai.chaiToDai(amount),
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 197_000, distribution);
}
if (destToken == IERC20(chai)) {
uint256 price = chai.chaiPrice();
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
dai,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice.mul(1e18).div(price)
);
return (returnAmount.mul(price).div(1e18), estimateGasAmount + 168_000, distribution);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitChai is OneSplitBaseWrap {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_CHAI)) {
if (fromToken == IERC20(chai)) {
chai.exit(address(this), amount);
return super._swap(
dai,
destToken,
dai.balanceOf(address(this)),
distribution,
flags
);
}
if (destToken == IERC20(chai)) {
super._swap(
fromToken,
dai,
amount,
distribution,
flags
);
uint256 daiBalance = dai.balanceOf(address(this));
dai.universalApprove(address(chai), daiBalance);
chai.join(address(this), daiBalance);
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/interface/IBdai.sol
pragma solidity ^0.5.0;
contract IBdai is IERC20 {
function join(uint256) external;
function exit(uint256) external;
}
// File: contracts/OneSplitBdai.sol
pragma solidity ^0.5.0;
contract OneSplitBdaiBase {
IBdai internal constant bdai = IBdai(0x6a4FFAafa8DD400676Df8076AD6c724867b0e2e8);
IERC20 internal constant btu = IERC20(0xb683D83a532e2Cb7DFa5275eED3698436371cc9f);
}
contract OneSplitBdaiView is OneSplitViewWrapBase, OneSplitBdaiBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_BDAI)) {
if (fromToken == IERC20(bdai)) {
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
dai,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 227_000, distribution);
}
if (destToken == IERC20(bdai)) {
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
dai,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 295_000, distribution);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitBdai is OneSplitBaseWrap, OneSplitBdaiBase {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_BDAI)) {
if (fromToken == IERC20(bdai)) {
bdai.exit(amount);
uint256 btuBalance = btu.balanceOf(address(this));
if (btuBalance > 0) {
(,uint256[] memory btuDistribution) = getExpectedReturn(
btu,
destToken,
btuBalance,
1,
flags
);
_swap(
btu,
destToken,
btuBalance,
btuDistribution,
flags
);
}
return super._swap(
dai,
destToken,
amount,
distribution,
flags
);
}
if (destToken == IERC20(bdai)) {
super._swap(fromToken, dai, amount, distribution, flags);
uint256 daiBalance = dai.balanceOf(address(this));
dai.universalApprove(address(bdai), daiBalance);
bdai.join(daiBalance);
return;
}
}
return super._swap(fromToken, destToken, amount, distribution, flags);
}
}
// File: contracts/interface/IIearn.sol
pragma solidity ^0.5.0;
contract IIearn is IERC20 {
function token() external view returns(IERC20);
function calcPoolValueInToken() external view returns(uint256);
function deposit(uint256 _amount) external;
function withdraw(uint256 _shares) external;
}
// File: contracts/OneSplitIearn.sol
pragma solidity ^0.5.0;
contract OneSplitIearnBase {
function _yTokens() internal pure returns(IIearn[13] memory) {
return [
IIearn(0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01),
IIearn(0x04Aa51bbcB46541455cCF1B8bef2ebc5d3787EC9),
IIearn(0x73a052500105205d34Daf004eAb301916DA8190f),
IIearn(0x83f798e925BcD4017Eb265844FDDAbb448f1707D),
IIearn(0xd6aD7a6750A7593E092a9B218d66C0A814a3436e),
IIearn(0xF61718057901F84C4eEC4339EF8f0D86D2B45600),
IIearn(0x04bC0Ab673d88aE9dbC9DA2380cB6B79C4BCa9aE),
IIearn(0xC2cB1040220768554cf699b0d863A3cd4324ce32),
IIearn(0xE6354ed5bC4b393a5Aad09f21c46E101e692d447),
IIearn(0x26EA744E5B887E5205727f55dFBE8685e3b21951),
IIearn(0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc),
IIearn(0x9777d7E2b60bB01759D0E2f8be2095df444cb07E),
IIearn(0x1bE5d71F2dA660BFdee8012dDc58D024448A0A59)
];
}
}
contract OneSplitIearnView is OneSplitViewWrapBase, OneSplitIearnBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _iearnGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _iearnGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
private
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (!flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == !flags.check(FLAG_DISABLE_IEARN)) {
IIearn[13] memory yTokens = _yTokens();
for (uint i = 0; i < yTokens.length; i++) {
if (fromToken == IERC20(yTokens[i])) {
(returnAmount, estimateGasAmount, distribution) = _iearnGetExpectedReturn(
yTokens[i].token(),
destToken,
amount
.mul(yTokens[i].calcPoolValueInToken())
.div(yTokens[i].totalSupply()),
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 260_000, distribution);
}
}
for (uint i = 0; i < yTokens.length; i++) {
if (destToken == IERC20(yTokens[i])) {
uint256 _destTokenEthPriceTimesGasPrice = destTokenEthPriceTimesGasPrice;
IERC20 token = yTokens[i].token();
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
token,
amount,
parts,
flags,
_destTokenEthPriceTimesGasPrice
.mul(yTokens[i].calcPoolValueInToken())
.div(yTokens[i].totalSupply())
);
return(
returnAmount
.mul(yTokens[i].totalSupply())
.div(yTokens[i].calcPoolValueInToken()),
estimateGasAmount + 743_000,
distribution
);
}
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitIearn is OneSplitBaseWrap, OneSplitIearnBase {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_iearnSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _iearnSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_IEARN)) {
IIearn[13] memory yTokens = _yTokens();
for (uint i = 0; i < yTokens.length; i++) {
if (fromToken == IERC20(yTokens[i])) {
IERC20 underlying = yTokens[i].token();
yTokens[i].withdraw(amount);
_iearnSwap(underlying, destToken, underlying.balanceOf(address(this)), distribution, flags);
return;
}
}
for (uint i = 0; i < yTokens.length; i++) {
if (destToken == IERC20(yTokens[i])) {
IERC20 underlying = yTokens[i].token();
super._swap(fromToken, underlying, amount, distribution, flags);
uint256 underlyingBalance = underlying.balanceOf(address(this));
underlying.universalApprove(address(yTokens[i]), underlyingBalance);
yTokens[i].deposit(underlyingBalance);
return;
}
}
}
return super._swap(fromToken, destToken, amount, distribution, flags);
}
}
// File: contracts/interface/IIdle.sol
pragma solidity ^0.5.0;
contract IIdle is IERC20 {
function token()
external view returns (IERC20);
function tokenPrice()
external view returns (uint256);
function mintIdleToken(uint256 _amount, uint256[] calldata _clientProtocolAmounts)
external returns (uint256 mintedTokens);
function redeemIdleToken(uint256 _amount, bool _skipRebalance, uint256[] calldata _clientProtocolAmounts)
external returns (uint256 redeemedTokens);
}
// File: contracts/OneSplitIdle.sol
pragma solidity ^0.5.0;
contract OneSplitIdleBase {
function _idleTokens() internal pure returns(IIdle[8] memory) {
// https://developers.idle.finance/contracts-and-codebase
return [
// V3
IIdle(0x78751B12Da02728F467A44eAc40F5cbc16Bd7934),
IIdle(0x12B98C621E8754Ae70d0fDbBC73D6208bC3e3cA6),
IIdle(0x63D27B3DA94A9E871222CB0A32232674B02D2f2D),
IIdle(0x1846bdfDB6A0f5c473dEc610144513bd071999fB),
IIdle(0xcDdB1Bceb7a1979C6caa0229820707429dd3Ec6C),
IIdle(0x42740698959761BAF1B06baa51EfBD88CB1D862B),
// V2
IIdle(0x10eC0D497824e342bCB0EDcE00959142aAa766dD),
IIdle(0xeB66ACc3d011056B00ea521F8203580C2E5d3991)
];
}
}
contract OneSplitIdleView is OneSplitViewWrapBase, OneSplitIdleBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _idleGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _idleGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
internal
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (!flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == !flags.check(FLAG_DISABLE_IDLE)) {
IIdle[8] memory tokens = _idleTokens();
for (uint i = 0; i < tokens.length; i++) {
if (fromToken == IERC20(tokens[i])) {
(returnAmount, estimateGasAmount, distribution) = _idleGetExpectedReturn(
tokens[i].token(),
destToken,
amount.mul(tokens[i].tokenPrice()).div(1e18),
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 2_400_000, distribution);
}
}
for (uint i = 0; i < tokens.length; i++) {
if (destToken == IERC20(tokens[i])) {
uint256 _destTokenEthPriceTimesGasPrice = destTokenEthPriceTimesGasPrice;
uint256 _price = tokens[i].tokenPrice();
IERC20 token = tokens[i].token();
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
token,
amount,
parts,
flags,
_destTokenEthPriceTimesGasPrice.mul(_price).div(1e18)
);
return (returnAmount.mul(1e18).div(_price), estimateGasAmount + 1_300_000, distribution);
}
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitIdle is OneSplitBaseWrap, OneSplitIdleBase {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_idleSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _idleSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
if (!flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == !flags.check(FLAG_DISABLE_IDLE)) {
IIdle[8] memory tokens = _idleTokens();
for (uint i = 0; i < tokens.length; i++) {
if (fromToken == IERC20(tokens[i])) {
IERC20 underlying = tokens[i].token();
uint256 minted = tokens[i].redeemIdleToken(amount, true, new uint256[](0));
_idleSwap(underlying, destToken, minted, distribution, flags);
return;
}
}
for (uint i = 0; i < tokens.length; i++) {
if (destToken == IERC20(tokens[i])) {
IERC20 underlying = tokens[i].token();
super._swap(fromToken, underlying, amount, distribution, flags);
uint256 underlyingBalance = underlying.balanceOf(address(this));
underlying.universalApprove(address(tokens[i]), underlyingBalance);
tokens[i].mintIdleToken(underlyingBalance, new uint256[](0));
return;
}
}
}
return super._swap(fromToken, destToken, amount, distribution, flags);
}
}
// File: contracts/OneSplitAave.sol
pragma solidity ^0.5.0;
contract OneSplitAaveView is OneSplitViewWrapBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags, // See constants in IOneSplit.sol
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _aaveGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _aaveGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
private
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_AAVE)) {
IERC20 underlying = aaveRegistry.tokenByAToken(IAaveToken(address(fromToken)));
if (underlying != IERC20(0)) {
(returnAmount, estimateGasAmount, distribution) = _aaveGetExpectedReturn(
underlying,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 670_000, distribution);
}
underlying = aaveRegistry.tokenByAToken(IAaveToken(address(destToken)));
if (underlying != IERC20(0)) {
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
underlying,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 310_000, distribution);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitAave is OneSplitBaseWrap {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_aaveSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _aaveSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_AAVE)) {
IERC20 underlying = aaveRegistry.tokenByAToken(IAaveToken(address(fromToken)));
if (underlying != IERC20(0)) {
IAaveToken(address(fromToken)).redeem(amount);
return _aaveSwap(
underlying,
destToken,
amount,
distribution,
flags
);
}
underlying = aaveRegistry.tokenByAToken(IAaveToken(address(destToken)));
if (underlying != IERC20(0)) {
super._swap(
fromToken,
underlying,
amount,
distribution,
flags
);
uint256 underlyingAmount = underlying.universalBalanceOf(address(this));
underlying.universalApprove(aave.core(), underlyingAmount);
aave.deposit.value(underlying.isETH() ? underlyingAmount : 0)(
underlying.isETH() ? ETH_ADDRESS : underlying,
underlyingAmount,
1101
);
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/OneSplitWeth.sol
pragma solidity ^0.5.0;
contract OneSplitWethView is OneSplitViewWrapBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _wethGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _wethGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
private
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_WETH)) {
if (fromToken == weth || fromToken == bancorEtherToken) {
return super.getExpectedReturnWithGas(ETH_ADDRESS, destToken, amount, parts, flags, destTokenEthPriceTimesGasPrice);
}
if (destToken == weth || destToken == bancorEtherToken) {
return super.getExpectedReturnWithGas(fromToken, ETH_ADDRESS, amount, parts, flags, destTokenEthPriceTimesGasPrice);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitWeth is OneSplitBaseWrap {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_wethSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _wethSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_WETH)) {
if (fromToken == weth) {
weth.withdraw(weth.balanceOf(address(this)));
super._swap(
ETH_ADDRESS,
destToken,
amount,
distribution,
flags
);
return;
}
if (fromToken == bancorEtherToken) {
bancorEtherToken.withdraw(bancorEtherToken.balanceOf(address(this)));
super._swap(
ETH_ADDRESS,
destToken,
amount,
distribution,
flags
);
return;
}
if (destToken == weth) {
_wethSwap(
fromToken,
ETH_ADDRESS,
amount,
distribution,
flags
);
weth.deposit.value(address(this).balance)();
return;
}
if (destToken == bancorEtherToken) {
_wethSwap(
fromToken,
ETH_ADDRESS,
amount,
distribution,
flags
);
bancorEtherToken.deposit.value(address(this).balance)();
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/OneSplitMStable.sol
pragma solidity ^0.5.0;
contract OneSplitMStableView is OneSplitViewWrapBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_MSTABLE_MUSD)) {
if (fromToken == IERC20(musd)) {
{
(bool valid1,, uint256 res1,) = musd_helper.getRedeemValidity(musd, amount, destToken);
if (valid1) {
return (res1, 300_000, new uint256[](DEXES_COUNT));
}
}
(bool valid,, address token) = musd_helper.suggestRedeemAsset(musd);
if (valid) {
(,, returnAmount,) = musd_helper.getRedeemValidity(musd, amount, IERC20(token));
if (IERC20(token) != destToken) {
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
IERC20(token),
destToken,
returnAmount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
} else {
distribution = new uint256[](DEXES_COUNT);
}
return (returnAmount, estimateGasAmount + 300_000, distribution);
}
}
if (destToken == IERC20(musd)) {
if (fromToken == usdc || fromToken == dai || fromToken == usdt || fromToken == tusd) {
(,, returnAmount) = musd.getSwapOutput(fromToken, destToken, amount);
return (returnAmount, 300_000, new uint256[](DEXES_COUNT));
}
else {
IERC20 _destToken = destToken;
(bool valid,, address token) = musd_helper.suggestMintAsset(_destToken);
if (valid) {
if (IERC20(token) != fromToken) {
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
IERC20(token),
amount,
parts,
flags,
_scaleDestTokenEthPriceTimesGasPrice(
_destToken,
IERC20(token),
destTokenEthPriceTimesGasPrice
)
);
} else {
returnAmount = amount;
}
(,, returnAmount) = musd.getSwapOutput(IERC20(token), _destToken, returnAmount);
return (returnAmount, estimateGasAmount + 300_000, distribution);
}
}
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitMStable is OneSplitBaseWrap {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_MSTABLE_MUSD)) {
if (fromToken == IERC20(musd)) {
if (destToken == usdc || destToken == dai || destToken == usdt || destToken == tusd) {
(,,, uint256 result) = musd_helper.getRedeemValidity(fromToken, amount, destToken);
musd.redeem(
destToken,
result
);
}
else {
(,,, uint256 result) = musd_helper.getRedeemValidity(fromToken, amount, dai);
musd.redeem(
dai,
result
);
super._swap(
dai,
destToken,
dai.balanceOf(address(this)),
distribution,
flags
);
}
return;
}
if (destToken == IERC20(musd)) {
if (fromToken == usdc || fromToken == dai || fromToken == usdt || fromToken == tusd) {
fromToken.universalApprove(address(musd), amount);
musd.swap(
fromToken,
destToken,
amount,
address(this)
);
}
else {
super._swap(
fromToken,
dai,
amount,
distribution,
flags
);
musd.swap(
dai,
destToken,
dai.balanceOf(address(this)),
address(this)
);
}
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/interface/IDMM.sol
pragma solidity ^0.5.0;
interface IDMMController {
function getUnderlyingTokenForDmm(IERC20 token) external view returns(IERC20);
}
contract IDMM is IERC20 {
function getCurrentExchangeRate() public view returns(uint256);
function mint(uint256 underlyingAmount) public returns(uint256);
function redeem(uint256 amount) public returns(uint256);
}
// File: contracts/OneSplitDMM.sol
pragma solidity ^0.5.0;
contract OneSplitDMMBase {
IDMMController internal constant _dmmController = IDMMController(0x4CB120Dd1D33C9A3De8Bc15620C7Cd43418d77E2);
function _getDMMUnderlyingToken(IERC20 token) internal view returns(IERC20) {
(bool success, bytes memory data) = address(_dmmController).staticcall(
abi.encodeWithSelector(
_dmmController.getUnderlyingTokenForDmm.selector,
token
)
);
if (!success || data.length == 0) {
return IERC20(-1);
}
return abi.decode(data, (IERC20));
}
function _getDMMExchangeRate(IDMM dmm) internal view returns(uint256) {
(bool success, bytes memory data) = address(dmm).staticcall(
abi.encodeWithSelector(
dmm.getCurrentExchangeRate.selector
)
);
if (!success || data.length == 0) {
return 0;
}
return abi.decode(data, (uint256));
}
}
contract OneSplitDMMView is OneSplitViewWrapBase, OneSplitDMMBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return _dmmGetExpectedReturn(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _dmmGetExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
private
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_DMM)) {
IERC20 underlying = _getDMMUnderlyingToken(fromToken);
if (underlying != IERC20(-1)) {
if (underlying == weth) {
underlying = ETH_ADDRESS;
}
IERC20 _fromToken = fromToken;
(returnAmount, estimateGasAmount, distribution) = _dmmGetExpectedReturn(
underlying,
destToken,
amount.mul(_getDMMExchangeRate(IDMM(address(_fromToken)))).div(1e18),
parts,
flags,
destTokenEthPriceTimesGasPrice
);
return (returnAmount, estimateGasAmount + 295_000, distribution);
}
underlying = _getDMMUnderlyingToken(destToken);
if (underlying != IERC20(-1)) {
if (underlying == weth) {
underlying = ETH_ADDRESS;
}
uint256 price = _getDMMExchangeRate(IDMM(address(destToken)));
(returnAmount, estimateGasAmount, distribution) = super.getExpectedReturnWithGas(
fromToken,
underlying,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice.mul(price).div(1e18)
);
return (
returnAmount.mul(1e18).div(price),
estimateGasAmount + 430_000,
distribution
);
}
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitDMM is OneSplitBaseWrap, OneSplitDMMBase {
function _swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
_dmmSwap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
function _dmmSwap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
if (fromToken == destToken) {
return;
}
if (flags.check(FLAG_DISABLE_ALL_WRAP_SOURCES) == flags.check(FLAG_DISABLE_DMM)) {
IERC20 underlying = _getDMMUnderlyingToken(fromToken);
if (underlying != IERC20(-1)) {
IDMM(address(fromToken)).redeem(amount);
uint256 balance = underlying.universalBalanceOf(address(this));
if (underlying == weth) {
weth.withdraw(balance);
}
_dmmSwap(
(underlying == weth) ? ETH_ADDRESS : underlying,
destToken,
balance,
distribution,
flags
);
}
underlying = _getDMMUnderlyingToken(destToken);
if (underlying != IERC20(-1)) {
super._swap(
fromToken,
(underlying == weth) ? ETH_ADDRESS : underlying,
amount,
distribution,
flags
);
uint256 underlyingAmount = ((underlying == weth) ? ETH_ADDRESS : underlying).universalBalanceOf(address(this));
if (underlying == weth) {
weth.deposit.value(underlyingAmount);
}
underlying.universalApprove(address(destToken), underlyingAmount);
IDMM(address(destToken)).mint(underlyingAmount);
return;
}
}
return super._swap(
fromToken,
destToken,
amount,
distribution,
flags
);
}
}
// File: contracts/OneSplitMooniswapPoolToken.sol
pragma solidity ^0.5.0;
contract OneSplitMooniswapTokenBase {
using SafeMath for uint256;
using Math for uint256;
using UniversalERC20 for IERC20;
struct TokenInfo {
IERC20 token;
uint256 reserve;
}
struct PoolDetails {
TokenInfo[2] tokens;
uint256 totalSupply;
}
function _getPoolDetails(IMooniswap pool) internal view returns (PoolDetails memory details) {
for (uint i = 0; i < 2; i++) {
IERC20 token = pool.tokens(i);
details.tokens[i] = TokenInfo({
token: token,
reserve: token.universalBalanceOf(address(pool))
});
}
details.totalSupply = IERC20(address(pool)).totalSupply();
}
}
contract OneSplitMooniswapTokenView is OneSplitViewWrapBase, OneSplitMooniswapTokenBase {
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 toToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns (
uint256 returnAmount,
uint256,
uint256[] memory distribution
)
{
if (fromToken.eq(toToken)) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
if (!flags.check(FLAG_DISABLE_MOONISWAP_POOL_TOKEN)) {
bool isPoolTokenFrom = mooniswapRegistry.isPool(address(fromToken));
bool isPoolTokenTo = mooniswapRegistry.isPool(address(toToken));
if (isPoolTokenFrom && isPoolTokenTo) {
(
uint256 returnETHAmount,
uint256[] memory poolTokenFromDistribution
) = _getExpectedReturnFromMooniswapPoolToken(
fromToken,
ETH_ADDRESS,
amount,
parts,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
(
uint256 returnPoolTokenToAmount,
uint256[] memory poolTokenToDistribution
) = _getExpectedReturnToMooniswapPoolToken(
ETH_ADDRESS,
toToken,
returnETHAmount,
parts,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
for (uint i = 0; i < poolTokenToDistribution.length; i++) {
poolTokenFromDistribution[i] |= poolTokenToDistribution[i] << 128;
}
return (returnPoolTokenToAmount, 0, poolTokenFromDistribution);
}
if (isPoolTokenFrom) {
(returnAmount, distribution) = _getExpectedReturnFromMooniswapPoolToken(
fromToken,
toToken,
amount,
parts,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
return (returnAmount, 0, distribution);
}
if (isPoolTokenTo) {
(returnAmount, distribution) = _getExpectedReturnToMooniswapPoolToken(
fromToken,
toToken,
amount,
parts,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
return (returnAmount, 0, distribution);
}
}
return super.getExpectedReturnWithGas(
fromToken,
toToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _getExpectedReturnFromMooniswapPoolToken(
IERC20 poolToken,
IERC20 toToken,
uint256 amount,
uint256 parts,
uint256 flags
)
private
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
distribution = new uint256[](DEXES_COUNT);
PoolDetails memory details = _getPoolDetails(IMooniswap(address(poolToken)));
for (uint i = 0; i < 2; i++) {
uint256 exchangeAmount = amount
.mul(details.tokens[i].reserve)
.div(details.totalSupply);
if (toToken.eq(details.tokens[i].token)) {
returnAmount = returnAmount.add(exchangeAmount);
continue;
}
(uint256 ret, ,uint256[] memory dist) = super.getExpectedReturnWithGas(
details.tokens[i].token,
toToken,
exchangeAmount,
parts,
flags,
0
);
returnAmount = returnAmount.add(ret);
for (uint j = 0; j < distribution.length; j++) {
distribution[j] |= dist[j] << (i * 8);
}
}
return (returnAmount, distribution);
}
function _getExpectedReturnToMooniswapPoolToken(
IERC20 fromToken,
IERC20 poolToken,
uint256 amount,
uint256 parts,
uint256 flags
)
private
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
distribution = new uint256[](DEXES_COUNT);
PoolDetails memory details = _getPoolDetails(IMooniswap(address(poolToken)));
// will overwritten to liquidity amounts
uint256[2] memory amounts;
amounts[0] = amount.div(2);
amounts[1] = amount.sub(amounts[0]);
uint256[] memory dist = new uint256[](distribution.length);
for (uint i = 0; i < 2; i++) {
if (fromToken.eq(details.tokens[i].token)) {
continue;
}
(amounts[i], ,dist) = super.getExpectedReturnWithGas(
fromToken,
details.tokens[i].token,
amounts[i],
parts,
flags,
0
);
for (uint j = 0; j < distribution.length; j++) {
distribution[j] |= dist[j] << (i * 8);
}
}
returnAmount = uint256(-1);
for (uint i = 0; i < 2; i++) {
returnAmount = Math.min(
returnAmount,
details.totalSupply.mul(amounts[i]).div(details.tokens[i].reserve)
);
}
return (
returnAmount,
distribution
);
}
}
contract OneSplitMooniswapToken is OneSplitBaseWrap, OneSplitMooniswapTokenBase {
function _swap(
IERC20 fromToken,
IERC20 toToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
if (fromToken.eq(toToken)) {
return;
}
if (!flags.check(FLAG_DISABLE_MOONISWAP_POOL_TOKEN)) {
bool isPoolTokenFrom = mooniswapRegistry.isPool(address(fromToken));
bool isPoolTokenTo = mooniswapRegistry.isPool(address(toToken));
if (isPoolTokenFrom && isPoolTokenTo) {
uint256[] memory dist = new uint256[](distribution.length);
for (uint i = 0; i < distribution.length; i++) {
dist[i] = distribution[i] & ((1 << 128) - 1);
}
uint256 ethBalanceBefore = ETH_ADDRESS.universalBalanceOf(address(this));
_swapFromMooniswapToken(
fromToken,
ETH_ADDRESS,
amount,
dist,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
for (uint i = 0; i < distribution.length; i++) {
dist[i] = distribution[i] >> 128;
}
uint256 ethBalanceAfter = ETH_ADDRESS.universalBalanceOf(address(this));
return _swapToMooniswapToken(
ETH_ADDRESS,
toToken,
ethBalanceAfter.sub(ethBalanceBefore),
dist,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
}
if (isPoolTokenFrom) {
return _swapFromMooniswapToken(
fromToken,
toToken,
amount,
distribution,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
}
if (isPoolTokenTo) {
return _swapToMooniswapToken(
fromToken,
toToken,
amount,
distribution,
FLAG_DISABLE_MOONISWAP_POOL_TOKEN
);
}
}
return super._swap(
fromToken,
toToken,
amount,
distribution,
flags
);
}
function _swapFromMooniswapToken(
IERC20 poolToken,
IERC20 toToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
IERC20[2] memory tokens = [
IMooniswap(address(poolToken)).tokens(0),
IMooniswap(address(poolToken)).tokens(1)
];
IMooniswap(address(poolToken)).withdraw(
amount,
new uint256[](0)
);
uint256[] memory dist = new uint256[](distribution.length);
for (uint i = 0; i < 2; i++) {
if (toToken.eq(tokens[i])) {
continue;
}
for (uint j = 0; j < distribution.length; j++) {
dist[j] = (distribution[j] >> (i * 8)) & 0xFF;
}
super._swap(
tokens[i],
toToken,
tokens[i].universalBalanceOf(address(this)),
dist,
flags
);
}
}
function _swapToMooniswapToken(
IERC20 fromToken,
IERC20 poolToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) private {
IERC20[2] memory tokens = [
IMooniswap(address(poolToken)).tokens(0),
IMooniswap(address(poolToken)).tokens(1)
];
// will overwritten to liquidity amounts
uint256[] memory amounts = new uint256[](2);
amounts[0] = amount.div(2);
amounts[1] = amount.sub(amounts[0]);
uint256[] memory dist = new uint256[](distribution.length);
for (uint i = 0; i < 2; i++) {
if (fromToken.eq(tokens[i])) {
continue;
}
for (uint j = 0; j < distribution.length; j++) {
dist[j] = (distribution[j] >> (i * 8)) & 0xFF;
}
super._swap(
fromToken,
tokens[i],
amounts[i],
dist,
flags
);
amounts[i] = tokens[i].universalBalanceOf(address(this));
tokens[i].universalApprove(address(poolToken), amounts[i]);
}
uint256 ethValue = (tokens[0].isETH() ? amounts[0] : 0) + (tokens[1].isETH() ? amounts[1] : 0);
IMooniswap(address(poolToken)).deposit.value(ethValue)(
amounts,
new uint256[](2)
);
for (uint i = 0; i < 2; i++) {
tokens[i].universalTransfer(
msg.sender,
tokens[i].universalBalanceOf(address(this))
);
}
}
}
// File: contracts/OneSplit.sol
pragma solidity ^0.5.0;
contract OneSplitViewWrap is
OneSplitViewWrapBase,
OneSplitMStableView,
OneSplitChaiView,
OneSplitBdaiView,
OneSplitAaveView,
OneSplitFulcrumView,
OneSplitCompoundView,
OneSplitIearnView,
OneSplitIdleView,
OneSplitWethView,
OneSplitDMMView,
OneSplitMooniswapTokenView
{
IOneSplitView public oneSplitView;
constructor(IOneSplitView _oneSplit) public {
oneSplitView = _oneSplit;
}
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
(returnAmount, , distribution) = getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
0
);
}
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags, // See constants in IOneSplit.sol
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
if (fromToken == destToken) {
return (amount, 0, new uint256[](DEXES_COUNT));
}
return super.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function _getExpectedReturnRespectingGasFloor(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
internal
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return oneSplitView.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
}
contract OneSplitWrap is
OneSplitBaseWrap,
OneSplitMStable,
OneSplitChai,
OneSplitBdai,
OneSplitAave,
OneSplitFulcrum,
OneSplitCompound,
OneSplitIearn,
OneSplitIdle,
OneSplitWeth,
OneSplitDMM,
OneSplitMooniswapToken
{
IOneSplitView public oneSplitView;
IOneSplit public oneSplit;
constructor(IOneSplitView _oneSplitView, IOneSplit _oneSplit) public {
oneSplitView = _oneSplitView;
oneSplit = _oneSplit;
}
function() external payable {
// solium-disable-next-line security/no-tx-origin
require(msg.sender != tx.origin);
}
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
)
{
(returnAmount, , distribution) = getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
0
);
}
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags,
uint256 destTokenEthPriceTimesGasPrice
)
public
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
return oneSplitView.getExpectedReturnWithGas(
fromToken,
destToken,
amount,
parts,
flags,
destTokenEthPriceTimesGasPrice
);
}
function getExpectedReturnWithGasMulti(
IERC20[] memory tokens,
uint256 amount,
uint256[] memory parts,
uint256[] memory flags,
uint256[] memory destTokenEthPriceTimesGasPrices
)
public
view
returns(
uint256[] memory returnAmounts,
uint256 estimateGasAmount,
uint256[] memory distribution
)
{
uint256[] memory dist;
returnAmounts = new uint256[](tokens.length - 1);
for (uint i = 1; i < tokens.length; i++) {
if (tokens[i - 1] == tokens[i]) {
returnAmounts[i - 1] = (i == 1) ? amount : returnAmounts[i - 2];
continue;
}
IERC20[] memory _tokens = tokens;
(
returnAmounts[i - 1],
amount,
dist
) = getExpectedReturnWithGas(
_tokens[i - 1],
_tokens[i],
(i == 1) ? amount : returnAmounts[i - 2],
parts[i - 1],
flags[i - 1],
destTokenEthPriceTimesGasPrices[i - 1]
);
estimateGasAmount = estimateGasAmount.add(amount);
if (distribution.length == 0) {
distribution = new uint256[](dist.length);
}
for (uint j = 0; j < distribution.length; j++) {
distribution[j] = distribution[j].add(dist[j] << (8 * (i - 1)));
}
}
}
function swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256 flags
) public payable returns(uint256 returnAmount) {
fromToken.universalTransferFrom(msg.sender, address(this), amount);
uint256 confirmed = fromToken.universalBalanceOf(address(this));
_swap(fromToken, destToken, confirmed, distribution, flags);
returnAmount = destToken.universalBalanceOf(address(this));
require(returnAmount >= minReturn, "OneSplit: actual return amount is less than minReturn");
destToken.universalTransfer(msg.sender, returnAmount);
fromToken.universalTransfer(msg.sender, fromToken.universalBalanceOf(address(this)));
}
function swapMulti(
IERC20[] memory tokens,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256[] memory flags
) public payable returns(uint256 returnAmount) {
tokens[0].universalTransferFrom(msg.sender, address(this), amount);
returnAmount = tokens[0].universalBalanceOf(address(this));
for (uint i = 1; i < tokens.length; i++) {
if (tokens[i - 1] == tokens[i]) {
continue;
}
uint256[] memory dist = new uint256[](distribution.length);
for (uint j = 0; j < distribution.length; j++) {
dist[j] = (distribution[j] >> (8 * (i - 1))) & 0xFF;
}
_swap(
tokens[i - 1],
tokens[i],
returnAmount,
dist,
flags[i - 1]
);
returnAmount = tokens[i].universalBalanceOf(address(this));
tokens[i - 1].universalTransfer(msg.sender, tokens[i - 1].universalBalanceOf(address(this)));
}
require(returnAmount >= minReturn, "OneSplit: actual return amount is less than minReturn");
tokens[tokens.length - 1].universalTransfer(msg.sender, returnAmount);
}
function _swapFloor(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256[] memory distribution,
uint256 flags
) internal {
fromToken.universalApprove(address(oneSplit), amount);
oneSplit.swap.value(fromToken.isETH() ? amount : 0)(
fromToken,
destToken,
amount,
0,
distribution,
flags
);
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IOneSplitView","name":"_oneSplitView","type":"address"},{"internalType":"contract IOneSplit","name":"_oneSplit","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"parts","type":"uint256"},{"internalType":"uint256","name":"flags","type":"uint256"}],"name":"getExpectedReturn","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"parts","type":"uint256"},{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"destTokenEthPriceTimesGasPrice","type":"uint256"}],"name":"getExpectedReturnWithGas","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256","name":"estimateGasAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256[]","name":"parts","type":"uint256[]"},{"internalType":"uint256[]","name":"flags","type":"uint256[]"},{"internalType":"uint256[]","name":"destTokenEthPriceTimesGasPrices","type":"uint256[]"}],"name":"getExpectedReturnWithGasMulti","outputs":[{"internalType":"uint256[]","name":"returnAmounts","type":"uint256[]"},{"internalType":"uint256","name":"estimateGasAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"oneSplit","outputs":[{"internalType":"contract IOneSplit","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"oneSplitView","outputs":[{"internalType":"contract IOneSplitView","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minReturn","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"},{"internalType":"uint256","name":"flags","type":"uint256"}],"name":"swap","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minReturn","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"},{"internalType":"uint256[]","name":"flags","type":"uint256[]"}],"name":"swapMulti","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b506040516200540d3803806200540d8339818101604052604081101561003557600080fd5b508051602090910151600080546001600160a01b039384166001600160a01b03199182161790915560018054939092169216919091179055615390806200007d6000396000f3fe6080604052600436106100705760003560e01c80638373f2651161004e5780638373f26514610436578063c7851396146104ed578063e2a7515e146106b0578063fbe4ed951461077857610070565b8063085e2c5b1461007f57806343ee21f0146101295780637b33701a1461015a575b3332141561007d57600080fd5b005b34801561008b57600080fd5b506100ce600480360360a08110156100a257600080fd5b506001600160a01b0381358116916020810135909116906040810135906060810135906080013561078d565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156101145781810151838201526020016100fc565b50505050905001935050505060405180910390f35b34801561013557600080fd5b5061013e6107b0565b604080516001600160a01b039092168252519081900360200190f35b34801561016657600080fd5b50610396600480360360a081101561017d57600080fd5b810190602081018135600160201b81111561019757600080fd5b8201836020820111156101a957600080fd5b803590602001918460208302840111600160201b831117156101ca57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435959094909350604081019250602001359050600160201b81111561022157600080fd5b82018360208201111561023357600080fd5b803590602001918460208302840111600160201b8311171561025457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156102a357600080fd5b8201836020820111156102b557600080fd5b803590602001918460208302840111600160201b831117156102d657600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561032557600080fd5b82018360208201111561033757600080fd5b803590602001918460208302840111600160201b8311171561035857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506107bf945050505050565b604051808060200184815260200180602001838103835286818151815260200191508051906020019060200280838360005b838110156103e05781810151838201526020016103c8565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561041f578181015183820152602001610407565b505050509050019550505050505060405180910390f35b34801561044257600080fd5b5061048b600480360360c081101561045957600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060808101359060a00135610a20565b6040518084815260200183815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156104d75781810151838201526020016104bf565b5050505090500194505050505060405180910390f35b61069e600480360360a081101561050357600080fd5b810190602081018135600160201b81111561051d57600080fd5b82018360208201111561052f57600080fd5b803590602001918460208302840111600160201b8311171561055057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295843595602086013595919450925060608101915060400135600160201b8111156105ab57600080fd5b8201836020820111156105bd57600080fd5b803590602001918460208302840111600160201b831117156105de57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561062d57600080fd5b82018360208201111561063f57600080fd5b803590602001918460208302840111600160201b8311171561066057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b77945050505050565b60408051918252519081900360200190f35b61069e600480360360c08110156106c657600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b81111561070557600080fd5b82018360208201111561071757600080fd5b803590602001918460208302840111600160201b8311171561073857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250610dbd915050565b34801561078457600080fd5b5061013e610eb9565b600060606107a087878787876000610a20565b9199919850909650505050505050565b6001546001600160a01b031681565b6060600060608060018951036040519080825280602002602001820160405280156107f4578160200160208202803883390190505b50935060015b8951811015610a135789818151811061080f57fe5b60200260200101516001600160a01b03168a600183038151811061082f57fe5b60200260200101516001600160a01b0316141561088c578060011461086a5784600282038151811061085d57fe5b602002602001015161086c565b885b85600183038151811061087b57fe5b602002602001018181525050610a0b565b60608a905061092f8160018403815181106108a357fe5b60200260200101518284815181106108b757fe5b6020026020010151846001146108e3578860028603815181106108d657fe5b60200260200101516108e5565b8c5b8c60018703815181106108f457fe5b60200260200101518c600188038151811061090b57fe5b60200260200101518c600189038151811061092257fe5b6020026020010151610a20565b88600186038151811061093e57fe5b60209081029190910101929092529a509250610960858b63ffffffff610ec816565b945083516000141561099b578251604051908082528060200260200182016040528015610997578160200160208202803883390190505b5093505b60005b8451811015610a08576109e9600184036008028583815181106109bd57fe5b6020026020010151901b8683815181106109d357fe5b6020026020010151610ec890919063ffffffff16565b8582815181106109f557fe5b602090810291909101015260010161099e565b50505b6001016107fa565b5050955095509592505050565b6000805460408051638373f26560e01b81526001600160a01b038a81166004830152898116602483015260448201899052606482018890526084820187905260a48201869052915184936060931691638373f2659160c48083019287929190829003018186803b158015610a9357600080fd5b505afa158015610aa7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526060811015610ad057600080fd5b81516020830151604080850180519151939592948301929184600160201b821115610afa57600080fd5b908301906020820185811115610b0f57600080fd5b82518660208202830111600160201b82111715610b2b57600080fd5b82525081516020918201928201910280838360005b83811015610b58578181015183820152602001610b40565b5050505090500160405250505092509250925096509650969350505050565b6000610bad33308789600081518110610b8c57fe5b60200260200101516001600160a01b0316610f2b909392919063ffffffff16565b610bdd3087600081518110610bbe57fe5b60200260200101516001600160a01b031661104a90919063ffffffff16565b905060015b8651811015610d5e57868181518110610bf757fe5b60200260200101516001600160a01b0316876001830381518110610c1757fe5b60200260200101516001600160a01b03161415610c3357610d56565b60608451604051908082528060200260200182016040528015610c60578160200160208202803883390190505b50905060005b8551811015610cae5760018303600802868281518110610c8257fe5b6020026020010151901c60ff16828281518110610c9b57fe5b6020908102919091010152600101610c66565b50610cfb886001840381518110610cc157fe5b6020026020010151898481518110610cd557fe5b60200260200101518584886001880381518110610cee57fe5b60200260200101516110f4565b610d0b30898481518110610bbe57fe5b9250610d5333610d24308b6001870381518110610bbe57fe5b8a6001860381518110610d3357fe5b60200260200101516001600160a01b031661141b9092919063ffffffff16565b50505b600101610be2565b5083811015610d9e5760405162461bcd60e51b815260040180806020018281038252603581526020018061527c6035913960400191505060405180910390fd5b610db333828860018a510381518110610d3357fe5b5095945050505050565b6000610dda6001600160a01b03881633308863ffffffff610f2b16565b6000610df56001600160a01b0389163063ffffffff61104a16565b9050610e0488888387876110f4565b610e1d6001600160a01b0388163063ffffffff61104a16565b915084821015610e5e5760405162461bcd60e51b815260040180806020018281038252603581526020018061527c6035913960400191505060405180910390fd5b610e786001600160a01b038816338463ffffffff61141b16565b50610ead33610e966001600160a01b038b163063ffffffff61104a16565b6001600160a01b038b16919063ffffffff61141b16565b50509695505050505050565b6000546001600160a01b031681565b600082820183811015610f22576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b80610f3557611044565b610f3e84611499565b15611029576001600160a01b03831633148015610f5b5750803410155b610f965760405162461bcd60e51b815260040180806020018281038252602b8152602001806152d1602b913960400191505060405180910390fd5b6001600160a01b0382163014610fde576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610fdc573d6000803e3d6000fd5b505b8034111561102457336108fc610ffa348463ffffffff6114d516565b6040518115909202916000818181858888f19350505050158015611022573d6000803e3d6000fd5b505b611044565b6110446001600160a01b03851684848463ffffffff61151716565b50505050565b600061105583611499565b1561106b57506001600160a01b03811631610f25565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156110c157600080fd5b505afa1580156110d5573d6000803e3d6000fd5b505050506040513d60208110156110eb57600080fd5b50519050610f25565b61110d6001600160a01b0386168563ffffffff61157116565b1561111757611414565b61112b81600160431b63ffffffff6115a716565b6114075760408051635b16ebb760e01b81526001600160a01b038716600482015290516000917371cd6666064c3a1354a3b4dca5fa1e2d3ee7d30391635b16ebb791602480820192602092909190829003018186803b15801561118d57600080fd5b505afa1580156111a1573d6000803e3d6000fd5b505050506040513d60208110156111b757600080fd5b505160408051635b16ebb760e01b81526001600160a01b038816600482015290519192506000917371cd6666064c3a1354a3b4dca5fa1e2d3ee7d30391635b16ebb7916024808301926020929190829003018186803b15801561121957600080fd5b505afa15801561122d573d6000803e3d6000fd5b505050506040513d602081101561124357600080fd5b505190508180156112515750805b156113cf5760608451604051908082528060200260200182016040528015611283578160200160208202803883390190505b50905060005b85518110156112d75785818151811061129e57fe5b60200260200101516fffffffffffffffffffffffffffffffff168282815181106112c457fe5b6020908102919091010152600101611289565b5060006112fe73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee3063ffffffff61104a16565b90506113258973eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8985600160431b6115ad565b60005b865181101561136857608087828151811061133f57fe5b6020026020010151901c83828151811061135557fe5b6020908102919091010152600101611328565b50600061138f73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee3063ffffffff61104a16565b90506113c573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8a6113ba848663ffffffff6114d516565b86600160431b611872565b5050505050611414565b81156113ed576113e687878787600160431b6115ad565b5050611414565b8015611404576113e687878787600160431b611872565b50505b6114148585858585611d4b565b5050505050565b60008161142a57506001611492565b61143384611499565b15611474576040516001600160a01b0384169083156108fc029084906000818181858888f1935050505015801561146e573d6000803e3d6000fd5b50611492565b61148e6001600160a01b038516848463ffffffff611d5816565b5060015b9392505050565b60006001600160a01b03821615806114cd57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b90505b919050565b6000610f2283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611daf565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611044908590611e46565b6000816001600160a01b0316836001600160a01b03161480610f22575061159783611499565b8015610f225750610f2282611499565b16151590565b6115b561521f565b604080518082018083526327b2595f60e11b905260006044820152905181906001600160a01b03891690634f64b2be90606480850191602091818703018186803b15801561160257600080fd5b505afa158015611616573d6000803e3d6000fd5b505050506040513d602081101561162c57600080fd5b50516001600160a01b039081168252604080516327b2595f60e11b8152600160048201529051602093840193928b1692634f64b2be9260248082019391829003018186803b15801561167d57600080fd5b505afa158015611691573d6000803e3d6000fd5b505050506040513d60208110156116a757600080fd5b50516001600160a01b039081169091526040805160008082526020808301808552632c8aec0360e11b8152602484018b815260448501958652845160648601819052979850958d1696635915d806968c969094909360848701939202908190849084905b8381101561172357818101518382015260200161170b565b505050509050019350505050600060405180830381600087803b15801561174957600080fd5b505af115801561175d573d6000803e3d6000fd5b505050506060835160405190808252806020026020018201604052801561178e578160200160208202803883390190505b50905060005b6002811015611868576117c78382600281106117ac57fe5b60200201516001600160a01b0389169063ffffffff61157116565b156117d157611860565b60005b855181101561181957816008028682815181106117ed57fe5b6020026020010151901c60ff1683828151811061180657fe5b60209081029190910101526001016117d4565b5061186083826002811061182957fe5b6020020151886118593087866002811061183f57fe5b60200201516001600160a01b03169063ffffffff61104a16565b8588611d4b565b600101611794565b5050505050505050565b61187a61521f565b604080518082018083526327b2595f60e11b905260006044820152905181906001600160a01b03881690634f64b2be90606480850191602091818703018186803b1580156118c757600080fd5b505afa1580156118db573d6000803e3d6000fd5b505050506040513d60208110156118f157600080fd5b50516001600160a01b039081168252604080516327b2595f60e11b8152600160048201529051602093840193928a1692634f64b2be9260248082019391829003018186803b15801561194257600080fd5b505afa158015611956573d6000803e3d6000fd5b505050506040513d602081101561196c57600080fd5b50516001600160a01b031690526040805160028082526060808301845293945090916020830190803883390190505090506119ae85600263ffffffff611ffe16565b816000815181106119bb57fe5b6020026020010181815250506119ee816000815181106119d757fe5b6020026020010151866114d590919063ffffffff16565b816001815181106119fb57fe5b60200260200101818152505060608451604051908082528060200260200182016040528015611a34578160200160208202803883390190505b50905060005b6002811015611b5f57611a6d848260028110611a5257fe5b60200201516001600160a01b038b169063ffffffff61157116565b15611a7757611b57565b60005b8651811015611abf5781600802878281518110611a9357fe5b6020026020010151901c60ff16838281518110611aac57fe5b6020908102919091010152600101611a7a565b50611af089858360028110611ad057fe5b6020020151858481518110611ae157fe5b60200260200101518589611d4b565b611b003085836002811061183f57fe5b838281518110611b0c57fe5b602002602001018181525050611b5788848381518110611b2857fe5b6020026020010151868460028110611b3c57fe5b60200201516001600160a01b0316919063ffffffff61204016565b600101611a3a565b506000611b7c8460015b60200201516001600160a01b0316611499565b611b87576000611b9d565b82600181518110611b9457fe5b60200260200101515b611ba8856000611b69565b611bb3576000611bc9565b83600081518110611bc057fe5b60200260200101515b019050876001600160a01b031663f223885a82856002604051908082528060200260200182016040528015611c08578160200160208202803883390190505b506040518463ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015611c5c578181015183820152602001611c44565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015611c9b578181015183820152602001611c83565b505050509050019450505050506020604051808303818588803b158015611cc157600080fd5b505af1158015611cd5573d6000803e3d6000fd5b50505050506040513d6020811015611cec57600080fd5b50600090505b6002811015611d3f57611d3633611d0f3088856002811061183f57fe5b878460028110611d1b57fe5b60200201516001600160a01b0316919063ffffffff61141b16565b50600101611cf2565b50505050505050505050565b6114148585858585612134565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611daa908490611e46565b505050565b60008184841115611e3e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611e03578181015183820152602001611deb565b50505050905090810190601f168015611e305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b611e58826001600160a01b0316612482565b611ea9576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310611ee75780518252601f199092019160209182019101611ec8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611f49576040519150601f19603f3d011682016040523d82523d6000602084013e611f4e565b606091505b509150915081611fa5576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561104457808060200190516020811015611fc157600080fd5b50516110445760405162461bcd60e51b815260040180806020018281038252602a8152602001806152fc602a913960400191505060405180910390fd5b6000610f2283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506124be565b61204983611499565b611daa57806120725761206d6001600160a01b03841683600063ffffffff61252316565b611daa565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009286169163dd62ed3e916044808301926020929190829003018186803b1580156120c357600080fd5b505afa1580156120d7573d6000803e3d6000fd5b505050506040513d60208110156120ed57600080fd5b505190508181101561104457801561211a5761211a6001600160a01b03851684600063ffffffff61252316565b6110446001600160a01b038516848463ffffffff61252316565b836001600160a01b0316856001600160a01b0316141561215357611414565b612169816508000000000063ffffffff6115a716565b151561217f82634000000063ffffffff6115a716565b1515141561247557600061219286612636565b90506001600160a01b038082161461231a57856001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156121ea57600080fd5b505af11580156121fe573d6000803e3d6000fd5b505050506040513d602081101561221457600080fd5b50600090506122326001600160a01b0383163063ffffffff61104a16565b90506001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156122cc5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156122b357600080fd5b505af11580156122c7573d6000803e3d6000fd5b505050505b6123186001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146122f9578261230f565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b87838787612134565b505b61232385612636565b90506001600160a01b038082161461247357612381866001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146123635782612379565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b86868661276a565b60006123dc306001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146123b157836123c7565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6001600160a01b03169063ffffffff61104a16565b90505b6123f96001600160a01b038316878363ffffffff61204016565b856001600160a01b031663a0712d68826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561243f57600080fd5b505af1158015612453573d6000803e3d6000fd5b505050506040513d602081101561246957600080fd5b5061141492505050565b505b611414858585858561276a565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906124b657508115155b949350505050565b6000818361250d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611e03578181015183820152602001611deb565b50600083858161251957fe5b0495945050505050565b8015806125a9575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561257b57600080fd5b505afa15801561258f573d6000803e3d6000fd5b505050506040513d60208110156125a557600080fd5b5051155b6125e45760405162461bcd60e51b81526004018080602001828103825260368152602001806153266036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611daa908490611e46565b604080516001600160a01b03831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166330df135f60e21b178152915181516000938493606093734cb120dd1d33c9a3de8bc15620c7cd43418d77e293919290918291908083835b602083106126c45780518252601f1990920191602091820191016126a5565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612724576040519150601f19603f3d011682016040523d82523d6000602084013e612729565b606091505b509150915081158061273a57508051155b1561274b57600019925050506114d0565b80806020019051602081101561276057600080fd5b5051949350505050565b61141485858585855b836001600160a01b0316856001600160a01b0316141561279257611414565b6127a5816208000063ffffffff6115a716565b15156127bb82634000000063ffffffff6115a716565b15151415612aa5576001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156128e957604080516370a0823160e01b8152306004820152905173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc291632e1a7d4d9183916370a08231916024808301926020929190829003018186803b15801561284157600080fd5b505afa158015612855573d6000803e3d6000fd5b505050506040513d602081101561286b57600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b1580156128ab57600080fd5b505af11580156128bf573d6000803e3d6000fd5b505050506128e473eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee85858585612aae565b611414565b6001600160a01b03851673c0829421c1d260bd3cb3e0f06cfe2d52db2ce315141561296757604080516370a0823160e01b8152306004820152905173c0829421c1d260bd3cb3e0f06cfe2d52db2ce31591632e1a7d4d9183916370a08231916024808301926020929190829003018186803b15801561284157600080fd5b6001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415612a10576129ad8573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee858585612773565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156129fc57600080fd5b505af11580156113c5573d6000803e3d6000fd5b6001600160a01b03841673c0829421c1d260bd3cb3e0f06cfe2d52db2ce3151415612aa557612a568573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee858585612773565b73c0829421c1d260bd3cb3e0f06cfe2d52db2ce3156001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156129fc57600080fd5b61141485858585855b61141485858585855b612aca816280000063ffffffff6115a716565b15612adf82634000000063ffffffff6115a716565b151415612f3157612aee61523d565b612af6612f3e565b905060005b6008811015612cc957818160088110612b1057fe5b60200201516001600160a01b0316876001600160a01b03161415612cc1576000828260088110612b3c57fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612b7957600080fd5b505afa158015612b8d573d6000803e3d6000fd5b505050506040513d6020811015612ba357600080fd5b505190506000838360088110612bb557fe5b60200201516001600160a01b031663c85c93aa8860016000604051908082528060200260200182016040528015612bf6578160200160208202803883390190505b506040518463ffffffff1660e01b8152600401808481526020018315151515815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015612c56578181015183820152602001612c3e565b50505050905001945050505050602060405180830381600087803b158015612c7d57600080fd5b505af1158015612c91573d6000803e3d6000fd5b505050506040513d6020811015612ca757600080fd5b50519050612cb88289838989612ab7565b50505050611414565b600101612afb565b5060005b6008811015612f2e57818160088110612ce257fe5b60200201516001600160a01b0316866001600160a01b03161415612f26576000828260088110612d0e57fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d4b57600080fd5b505afa158015612d5f573d6000803e3d6000fd5b505050506040513d6020811015612d7557600080fd5b50519050612d868882888888613024565b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b158015612dd057600080fd5b505afa158015612de4573d6000803e3d6000fd5b505050506040513d6020811015612dfa57600080fd5b50519050612e29848460088110612e0d57fe5b60200201516001600160a01b038416908363ffffffff61204016565b838360088110612e3557fe5b60200201516001600160a01b0316633cfcef64826000604051908082528060200260200182016040528015612e74578160200160208202803883390190505b506040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015612eca578181015183820152602001612eb2565b505050509050019350505050602060405180830381600087803b158015612ef057600080fd5b505af1158015612f04573d6000803e3d6000fd5b505050506040513d6020811015612f1a57600080fd5b50611414945050505050565b600101612ccd565b50505b6114148585858585613024565b612f4661523d565b5060408051610100810182527378751b12da02728f467a44eac40f5cbc16bd793481527312b98c621e8754ae70d0fdbbc73d6208bc3e3ca660208201527363d27b3da94a9e871222cb0a32232674b02d2f2d91810191909152731846bdfdb6a0f5c473dec610144513bd071999fb606082015273cddb1bceb7a1979c6caa0229820707429dd3ec6c60808201527342740698959761baf1b06baa51efbd88cb1d862b60a08201527310ec0d497824e342bcb0edce00959142aaa766dd60c082015273eb66acc3d011056b00ea521f8203580c2e5d399160e082015290565b61141485858585855b836001600160a01b0316856001600160a01b0316141561304c57611414565b61305e8161080063ffffffff6115a716565b151561307482634000000063ffffffff6115a716565b1515141561340f5761308461525c565b61308c61341c565b905060005b600d811015613249578181600d81106130a657fe5b60200201516001600160a01b0316876001600160a01b031614156132415760008282600d81106130d257fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561310f57600080fd5b505afa158015613123573d6000803e3d6000fd5b505050506040513d602081101561313957600080fd5b505190508282600d811061314957fe5b60200201516001600160a01b0316632e1a7d4d876040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561319357600080fd5b505af11580156131a7573d6000803e3d6000fd5b505050506132398188836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561320657600080fd5b505afa15801561321a573d6000803e3d6000fd5b505050506040513d602081101561323057600080fd5b5051888861302d565b505050611414565b600101613091565b5060005b600d81101561340c578181600d811061326257fe5b60200201516001600160a01b0316866001600160a01b031614156134045760008282600d811061328e57fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156132cb57600080fd5b505afa1580156132df573d6000803e3d6000fd5b505050506040513d60208110156132f557600080fd5b505190506133068882888888613589565b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561335057600080fd5b505afa158015613364573d6000803e3d6000fd5b505050506040513d602081101561337a57600080fd5b5051905061338d8484600d8110612e0d57fe5b8383600d811061339957fe5b60200201516001600160a01b031663b6b55f25826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156133e357600080fd5b505af11580156133f7573d6000803e3d6000fd5b5050505050505050611414565b60010161324d565b50505b6114148585858585613589565b61342461525c565b50604080516101a0810182527316de59092dae5ccf4a1e6439d611fd0653f0bd0181527304aa51bbcb46541455ccf1b8bef2ebc5d3787ec960208201527373a052500105205d34daf004eab301916da8190f918101919091527383f798e925bcd4017eb265844fddabb448f1707d606082015273d6ad7a6750a7593e092a9b218d66c0a814a3436e608082015273f61718057901f84c4eec4339ef8f0d86d2b4560060a08201527304bc0ab673d88ae9dbc9da2380cb6b79c4bca9ae60c082015273c2cb1040220768554cf699b0d863a3cd4324ce3260e082015273e6354ed5bc4b393a5aad09f21c46e101e692d4476101008201527326ea744e5b887e5205727f55dfbe8685e3b219516101208201527399d1fa417f94dcd62bfe781a1213c092a47041bc610140820152739777d7e2b60bb01759d0e2f8be2095df444cb07e610160820152731be5d71f2da660bfdee8012ddc58d024448a0a5961018082015290565b61141485858585855b836001600160a01b0316856001600160a01b031614156135b157611414565b6135c281601063ffffffff6115a716565b15156135d882634000000063ffffffff6115a716565b1515141561385f5760408051639bbde94760e01b81526001600160a01b0387166004820152905160009173f451dbd7ba14bfa7b1b78a766d3ed438f79ee1d191639bbde94791602480820192602092909190829003018186803b15801561363e57600080fd5b505afa158015613652573d6000803e3d6000fd5b505050506040513d602081101561366857600080fd5b505190506001600160a01b0381161561371857856001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156136c157600080fd5b505af11580156136d5573d6000803e3d6000fd5b505050506040513d60208110156136eb57600080fd5b50600090506137096001600160a01b0383163063ffffffff61104a16565b90506113e68287838787613592565b60408051639bbde94760e01b81526001600160a01b0387166004820152905173f451dbd7ba14bfa7b1b78a766d3ed438f79ee1d191639bbde947916024808301926020929190829003018186803b15801561377257600080fd5b505afa158015613786573d6000803e3d6000fd5b505050506040513d602081101561379c57600080fd5b505190506001600160a01b0381161561385d576137bc8682868686613868565b60006137d76001600160a01b0383163063ffffffff61104a16565b90506137eb826001600160a01b0316611499565b156123df57734ddc2d193948926d02f9b1fe9e1daa0718270ed56001600160a01b0316631249c58b826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561383f57600080fd5b505af1158015613853573d6000803e3d6000fd5b50505050506113e6565b505b61141485858585855b6114148585858585836001600160a01b0316856001600160a01b0316141561388f57611414565b6138a081602063ffffffff6115a716565b15156138b682634000000063ffffffff6115a716565b15151415613b5d5760006138c986613b6a565b90506001600160a01b0380821614613a19576138ed816001600160a01b0316611499565b15613973576040805163081a6b2560e41b81523060048201526024810186905290516001600160a01b038816916381a6b2509160448083019260209291908290030181600087803b15801561394157600080fd5b505af1158015613955573d6000803e3d6000fd5b505050506040513d602081101561396b57600080fd5b506139ef9050565b60408051632770a7eb60e21b81523060048201526024810186905290516001600160a01b03881691639dc29fac9160448083019260209291908290030181600087803b1580156139c257600080fd5b505af11580156139d6573d6000803e3d6000fd5b505050506040513d60208110156139ec57600080fd5b50505b6000613a0a6001600160a01b0383163063ffffffff61104a16565b90506113e68287838787613ee0565b613a2285613b6a565b90506001600160a01b0380821614613b5b57613a418682868686613ee0565b6000613a5c6001600160a01b0383163063ffffffff61104a16565b9050613a70826001600160a01b0316611499565b15613af25760408051638f6ede1f60e01b815230600482015290516001600160a01b03881691638f6ede1f91849160248082019260209290919082900301818588803b158015613abf57600080fd5b505af1158015613ad3573d6000803e3d6000fd5b50505050506040513d6020811015613aea57600080fd5b506113e69050565b613b0c6001600160a01b038316878363ffffffff61204016565b604080516340c10f1960e01b81523060048201526024810183905290516001600160a01b038816916340c10f199160448083019260209291908290030181600087803b15801561243f57600080fd5b505b6114148585858585613ee0565b6000613b7e826001600160a01b0316611499565b15613b8c57506000196114d0565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b178152915181516000936060936001600160a01b0388169361138893919290918291908083835b60208310613bf75780518252601f199092019160209182019101613bd8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114613c58576040519150601f19603f3d011682016040523d82523d6000602084013e613c5d565b606091505b509150915081613c7357600019925050506114d0565b6000805b8251816006011015613dcc57828160000181518110613c9257fe5b6020910101516001600160f81b031916602360f91b148015613cd55750828160010181518110613cbe57fe5b6020910101516001600160f81b031916607560f81b145b8015613d025750828160020181518110613ceb57fe5b6020910101516001600160f81b031916601b60fa1b145b8015613d2f5750828160030181518110613d1857fe5b6020910101516001600160f81b031916606360f81b145b8015613d5c5750828160040181518110613d4557fe5b6020910101516001600160f81b031916603960f91b145b8015613d895750828160050181518110613d7257fe5b6020910101516001600160f81b031916607560f81b145b8015613db65750828160060181518110613d9f57fe5b6020910101516001600160f81b031916606d60f81b145b15613dc45760019150613dcc565b600101613c77565b5080613ddf5760001993505050506114d0565b60408051600481526024810182526020810180516001600160e01b031663797bf38560e01b178152915181516001600160a01b038916936113889392918291908083835b60208310613e425780518252601f199092019160209182019101613e23565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114613ea3576040519150601f19603f3d011682016040523d82523d6000602084013e613ea8565b606091505b50909350915082613ec05760001993505050506114d0565b818060200190516020811015613ed557600080fd5b505195945050505050565b61141485858585855b836001600160a01b0316856001600160a01b03161415613f0857611414565b613f1981608063ffffffff6115a716565b1515613f2f82634000000063ffffffff6115a716565b1515141561427957604080516354732ba160e11b81526001600160a01b0387166004820152905160009173ed8b133b7b88366e01bb9e38305ab11c265214949163a8e6574291602480820192602092909190829003018186803b158015613f9557600080fd5b505afa158015613fa9573d6000803e3d6000fd5b505050506040513d6020811015613fbf57600080fd5b505190506001600160a01b0381161561404357856001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561401857600080fd5b505af115801561402c573d6000803e3d6000fd5b5050505061403d8186868686613ee9565b50611414565b604080516354732ba160e11b81526001600160a01b0387166004820152905173ed8b133b7b88366e01bb9e38305ab11c265214949163a8e65742916024808301926020929190829003018186803b15801561409d57600080fd5b505afa1580156140b1573d6000803e3d6000fd5b505050506040513d60208110156140c757600080fd5b505190506001600160a01b03811615614277576140e78682868686614282565b60006141026001600160a01b0383163063ffffffff61104a16565b905061419773398ec7346dcd622edc5ae82352f02be94c62d1196001600160a01b031663f2f4eb266040518163ffffffff1660e01b815260040160206040518083038186803b15801561415457600080fd5b505afa158015614168573d6000803e3d6000fd5b505050506040513d602081101561417e57600080fd5b50516001600160a01b038416908363ffffffff61204016565b73398ec7346dcd622edc5ae82352f02be94c62d11963d2d0e0666141c36001600160a01b038516611499565b6141ce5760006141d0565b825b6141e2856001600160a01b0316611499565b6141ec5784614202565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b604080516001600160e01b031960e086901b1681526001600160a01b0390921660048301526024820186905261044d604483015251606480830192600092919082900301818588803b15801561425757600080fd5b505af115801561426b573d6000803e3d6000fd5b50505050505050611414565b505b61141485858585855b836001600160a01b0316856001600160a01b031614156142a157611414565b6142b38161040063ffffffff6115a716565b15156142c982634000000063ffffffff6115a716565b151514156145a0576001600160a01b038516736a4ffaafa8dd400676df8076ad6c724867b0e2e8141561445657736a4ffaafa8dd400676df8076ad6c724867b0e2e86001600160a01b0316637f8661a1846040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561435057600080fd5b505af1158015614364573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516000935073b683d83a532e2cb7dfa5275eed3698436371cc9f92506370a0823191602480820192602092909190829003018186803b1580156143bd57600080fd5b505afa1580156143d1573d6000803e3d6000fd5b505050506040513d60208110156143e757600080fd5b50519050801561443b57606061441573b683d83a532e2cb7dfa5275eed3698436371cc9f878460018761078d565b91505061443973b683d83a532e2cb7dfa5275eed3698436371cc9f878484876110f4565b505b61403d6000805160206152b1833981519152868686866145a9565b6001600160a01b038416736a4ffaafa8dd400676df8076ad6c724867b0e2e814156145a057614496856000805160206152b18339815191528585856145a9565b604080516370a0823160e01b815230600482015290516000916000805160206152b1833981519152916370a0823191602480820192602092909190829003018186803b1580156144e557600080fd5b505afa1580156144f9573d6000803e3d6000fd5b505050506040513d602081101561450f57600080fd5b505190506145466000805160206152b1833981519152736a4ffaafa8dd400676df8076ad6c724867b0e2e88363ffffffff61204016565b736a4ffaafa8dd400676df8076ad6c724867b0e2e86001600160a01b031663049878f3826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156129fc57600080fd5b61141485858585855b836001600160a01b0316856001600160a01b031614156145c857611414565b6145d981604063ffffffff6115a716565b15156145ef82634000000063ffffffff6115a716565b1515141561485d576001600160a01b0385167306af07097c9eeb7fd685c692751d5c66db49c2151415614714576040805163ef693bed60e01b81523060048201526024810185905290517306af07097c9eeb7fd685c692751d5c66db49c2159163ef693bed91604480830192600092919082900301818387803b15801561467557600080fd5b505af1158015614689573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516128e493506000805160206152b18339815191529250879183916370a0823191602480820192602092909190829003018186803b1580156146e157600080fd5b505afa1580156146f5573d6000803e3d6000fd5b505050506040513d602081101561470b57600080fd5b50518585614866565b6001600160a01b0384167306af07097c9eeb7fd685c692751d5c66db49c215141561485d57614754856000805160206152b1833981519152858585614866565b604080516370a0823160e01b815230600482015290516000916000805160206152b1833981519152916370a0823191602480820192602092909190829003018186803b1580156147a357600080fd5b505afa1580156147b7573d6000803e3d6000fd5b505050506040513d60208110156147cd57600080fd5b505190506148046000805160206152b18339815191527306af07097c9eeb7fd685c692751d5c66db49c2158363ffffffff61204016565b60408051633b4da69f60e01b81523060048201526024810183905290517306af07097c9eeb7fd685c692751d5c66db49c21591633b4da69f91604480830192600092919082900301818387803b1580156129fc57600080fd5b61141485858585855b836001600160a01b0316856001600160a01b0316141561488557611414565b61489b816502000000000063ffffffff6115a716565b15156148b182634000000063ffffffff6115a716565b151514156150ad576001600160a01b03851673e2f2a5c287993345a840db3b0845fbc70f5935a51415614df0576001600160a01b03841673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48148061491f57506001600160a01b0384166000805160206152b1833981519152145b8061494657506001600160a01b03841673dac17f958d2ee523a2206206994597c13d831ec7145b8061496857506001600160a01b0384166e085d4780b73119b644ae5ecd22b376145b15614b665760408051633b3fb85360e21b81526001600160a01b0387811660048301526024820186905286166044820152905160009173abcc93c3be238884cc3309c19afd128fafc169119163ecfee14c916064808201928692909190829003018186803b1580156149d957600080fd5b505afa1580156149ed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526080811015614a1657600080fd5b815160208301805160405192949293830192919084600160201b821115614a3c57600080fd5b908301906020820185811115614a5157600080fd5b8251600160201b811182820188101715614a6a57600080fd5b82525081516020918201929091019080838360005b83811015614a97578181015183820152602001614a7f565b50505050905090810190601f168015614ac45780820380516001836020036101000a031916815260200191505b506040818152918201516301e9a69560e41b82526001600160a01b038c16600483015260248201819052915191965073e2f2a5c287993345a840db3b0845fbc70f5935a59550631e9a695094506044808201945060209350908290030181600087803b158015614b3357600080fd5b505af1158015614b47573d6000803e3d6000fd5b505050506040513d6020811015614b5d57600080fd5b506128e4915050565b60408051633b3fb85360e21b81526001600160a01b0387166004820152602481018590526000805160206152b18339815191526044820152905160009173abcc93c3be238884cc3309c19afd128fafc169119163ecfee14c916064808201928692909190829003018186803b158015614bde57600080fd5b505afa158015614bf2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526080811015614c1b57600080fd5b815160208301805160405192949293830192919084600160201b821115614c4157600080fd5b908301906020820185811115614c5657600080fd5b8251600160201b811182820188101715614c6f57600080fd5b82525081516020918201929091019080838360005b83811015614c9c578181015183820152602001614c84565b50505050905090810190601f168015614cc95780820380516001836020036101000a031916815260200191505b506040818152918201516301e9a69560e41b82526000805160206152b1833981519152600483015260248201819052915191965073e2f2a5c287993345a840db3b0845fbc70f5935a59550631e9a695094506044808201945060209350908290030181600087803b158015614d3d57600080fd5b505af1158015614d51573d6000803e3d6000fd5b505050506040513d6020811015614d6757600080fd5b5050604080516370a0823160e01b8152306004820152905161403d916000805160206152b183398151915291889183916370a0823191602480820192602092909190829003018186803b158015614dbd57600080fd5b505afa158015614dd1573d6000803e3d6000fd5b505050506040513d6020811015614de757600080fd5b505186866150b6565b6001600160a01b03841673e2f2a5c287993345a840db3b0845fbc70f5935a514156150ad576001600160a01b03851673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481480614e5657506001600160a01b0385166000805160206152b1833981519152145b80614e7d57506001600160a01b03851673dac17f958d2ee523a2206206994597c13d831ec7145b80614e9f57506001600160a01b0385166e085d4780b73119b644ae5ecd22b376145b15614f7557614ed26001600160a01b03861673e2f2a5c287993345a840db3b0845fbc70f5935a58563ffffffff61204016565b60408051631ba0488760e21b81526001600160a01b0387811660048301528616602482015260448101859052306064820152905173e2f2a5c287993345a840db3b0845fbc70f5935a591636e81221c9160848083019260209291908290030181600087803b158015614f4357600080fd5b505af1158015614f57573d6000803e3d6000fd5b505050506040513d6020811015614f6d57600080fd5b506128e49050565b614f90856000805160206152b18339815191528585856150b6565b604080516370a0823160e01b8152306004820152905173e2f2a5c287993345a840db3b0845fbc70f5935a591636e81221c916000805160206152b183398151915291889183916370a08231916024808301926020929190829003018186803b158015614ffb57600080fd5b505afa15801561500f573d6000803e3d6000fd5b505050506040513d602081101561502557600080fd5b5051604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526044820152306064820152905160848083019260209291908290030181600087803b15801561508357600080fd5b505af1158015615097573d6000803e3d6000fd5b505050506040513d60208110156113e657600080fd5b61141485858585855b836001600160a01b0316856001600160a01b031614156150d557611414565b61141485858585856001546150fd906001600160a01b0387811691168563ffffffff61204016565b6001546001600160a01b039081169063e2a7515e9061511d908816611499565b61512857600061512a565b845b878787600088886040518863ffffffff1660e01b815260040180876001600160a01b03166001600160a01b03168152602001866001600160a01b03166001600160a01b0316815260200185815260200184815260200180602001838152602001828103825284818151815260200191508051906020019060200280838360005b838110156151c25781810151838201526020016151aa565b505050509050019750505050505050506020604051808303818588803b1580156151eb57600080fd5b505af11580156151ff573d6000803e3d6000fd5b50505050506040513d602081101561521657600080fd5b50505050505050565b60405180604001604052806002906020820280388339509192915050565b6040518061010001604052806008906020820280388339509192915050565b604051806101a00160405280600d90602082028038833950919291505056fe4f6e6553706c69743a2061637475616c2072657475726e20616d6f756e74206973206c657373207468616e206d696e52657475726e0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f57726f6e6720757365616765206f66204554482e756e6976657273616c5472616e7366657246726f6d28295361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a723158204716beb8f91925f6e8d1b253b687e8017d19a2b26963dc12104702d3c91b794064736f6c634300051100320000000000000000000000001a3f7583c0af24ef78cdb1a1eb48d957df793824000000000000000000000000480ea104ff7063ed0af41c98d8ef2457afe2a41c
Deployed Bytecode
0x6080604052600436106100705760003560e01c80638373f2651161004e5780638373f26514610436578063c7851396146104ed578063e2a7515e146106b0578063fbe4ed951461077857610070565b8063085e2c5b1461007f57806343ee21f0146101295780637b33701a1461015a575b3332141561007d57600080fd5b005b34801561008b57600080fd5b506100ce600480360360a08110156100a257600080fd5b506001600160a01b0381358116916020810135909116906040810135906060810135906080013561078d565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156101145781810151838201526020016100fc565b50505050905001935050505060405180910390f35b34801561013557600080fd5b5061013e6107b0565b604080516001600160a01b039092168252519081900360200190f35b34801561016657600080fd5b50610396600480360360a081101561017d57600080fd5b810190602081018135600160201b81111561019757600080fd5b8201836020820111156101a957600080fd5b803590602001918460208302840111600160201b831117156101ca57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435959094909350604081019250602001359050600160201b81111561022157600080fd5b82018360208201111561023357600080fd5b803590602001918460208302840111600160201b8311171561025457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156102a357600080fd5b8201836020820111156102b557600080fd5b803590602001918460208302840111600160201b831117156102d657600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561032557600080fd5b82018360208201111561033757600080fd5b803590602001918460208302840111600160201b8311171561035857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506107bf945050505050565b604051808060200184815260200180602001838103835286818151815260200191508051906020019060200280838360005b838110156103e05781810151838201526020016103c8565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561041f578181015183820152602001610407565b505050509050019550505050505060405180910390f35b34801561044257600080fd5b5061048b600480360360c081101561045957600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060808101359060a00135610a20565b6040518084815260200183815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156104d75781810151838201526020016104bf565b5050505090500194505050505060405180910390f35b61069e600480360360a081101561050357600080fd5b810190602081018135600160201b81111561051d57600080fd5b82018360208201111561052f57600080fd5b803590602001918460208302840111600160201b8311171561055057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295843595602086013595919450925060608101915060400135600160201b8111156105ab57600080fd5b8201836020820111156105bd57600080fd5b803590602001918460208302840111600160201b831117156105de57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561062d57600080fd5b82018360208201111561063f57600080fd5b803590602001918460208302840111600160201b8311171561066057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b77945050505050565b60408051918252519081900360200190f35b61069e600480360360c08110156106c657600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b81111561070557600080fd5b82018360208201111561071757600080fd5b803590602001918460208302840111600160201b8311171561073857600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250610dbd915050565b34801561078457600080fd5b5061013e610eb9565b600060606107a087878787876000610a20565b9199919850909650505050505050565b6001546001600160a01b031681565b6060600060608060018951036040519080825280602002602001820160405280156107f4578160200160208202803883390190505b50935060015b8951811015610a135789818151811061080f57fe5b60200260200101516001600160a01b03168a600183038151811061082f57fe5b60200260200101516001600160a01b0316141561088c578060011461086a5784600282038151811061085d57fe5b602002602001015161086c565b885b85600183038151811061087b57fe5b602002602001018181525050610a0b565b60608a905061092f8160018403815181106108a357fe5b60200260200101518284815181106108b757fe5b6020026020010151846001146108e3578860028603815181106108d657fe5b60200260200101516108e5565b8c5b8c60018703815181106108f457fe5b60200260200101518c600188038151811061090b57fe5b60200260200101518c600189038151811061092257fe5b6020026020010151610a20565b88600186038151811061093e57fe5b60209081029190910101929092529a509250610960858b63ffffffff610ec816565b945083516000141561099b578251604051908082528060200260200182016040528015610997578160200160208202803883390190505b5093505b60005b8451811015610a08576109e9600184036008028583815181106109bd57fe5b6020026020010151901b8683815181106109d357fe5b6020026020010151610ec890919063ffffffff16565b8582815181106109f557fe5b602090810291909101015260010161099e565b50505b6001016107fa565b5050955095509592505050565b6000805460408051638373f26560e01b81526001600160a01b038a81166004830152898116602483015260448201899052606482018890526084820187905260a48201869052915184936060931691638373f2659160c48083019287929190829003018186803b158015610a9357600080fd5b505afa158015610aa7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526060811015610ad057600080fd5b81516020830151604080850180519151939592948301929184600160201b821115610afa57600080fd5b908301906020820185811115610b0f57600080fd5b82518660208202830111600160201b82111715610b2b57600080fd5b82525081516020918201928201910280838360005b83811015610b58578181015183820152602001610b40565b5050505090500160405250505092509250925096509650969350505050565b6000610bad33308789600081518110610b8c57fe5b60200260200101516001600160a01b0316610f2b909392919063ffffffff16565b610bdd3087600081518110610bbe57fe5b60200260200101516001600160a01b031661104a90919063ffffffff16565b905060015b8651811015610d5e57868181518110610bf757fe5b60200260200101516001600160a01b0316876001830381518110610c1757fe5b60200260200101516001600160a01b03161415610c3357610d56565b60608451604051908082528060200260200182016040528015610c60578160200160208202803883390190505b50905060005b8551811015610cae5760018303600802868281518110610c8257fe5b6020026020010151901c60ff16828281518110610c9b57fe5b6020908102919091010152600101610c66565b50610cfb886001840381518110610cc157fe5b6020026020010151898481518110610cd557fe5b60200260200101518584886001880381518110610cee57fe5b60200260200101516110f4565b610d0b30898481518110610bbe57fe5b9250610d5333610d24308b6001870381518110610bbe57fe5b8a6001860381518110610d3357fe5b60200260200101516001600160a01b031661141b9092919063ffffffff16565b50505b600101610be2565b5083811015610d9e5760405162461bcd60e51b815260040180806020018281038252603581526020018061527c6035913960400191505060405180910390fd5b610db333828860018a510381518110610d3357fe5b5095945050505050565b6000610dda6001600160a01b03881633308863ffffffff610f2b16565b6000610df56001600160a01b0389163063ffffffff61104a16565b9050610e0488888387876110f4565b610e1d6001600160a01b0388163063ffffffff61104a16565b915084821015610e5e5760405162461bcd60e51b815260040180806020018281038252603581526020018061527c6035913960400191505060405180910390fd5b610e786001600160a01b038816338463ffffffff61141b16565b50610ead33610e966001600160a01b038b163063ffffffff61104a16565b6001600160a01b038b16919063ffffffff61141b16565b50509695505050505050565b6000546001600160a01b031681565b600082820183811015610f22576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b80610f3557611044565b610f3e84611499565b15611029576001600160a01b03831633148015610f5b5750803410155b610f965760405162461bcd60e51b815260040180806020018281038252602b8152602001806152d1602b913960400191505060405180910390fd5b6001600160a01b0382163014610fde576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610fdc573d6000803e3d6000fd5b505b8034111561102457336108fc610ffa348463ffffffff6114d516565b6040518115909202916000818181858888f19350505050158015611022573d6000803e3d6000fd5b505b611044565b6110446001600160a01b03851684848463ffffffff61151716565b50505050565b600061105583611499565b1561106b57506001600160a01b03811631610f25565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156110c157600080fd5b505afa1580156110d5573d6000803e3d6000fd5b505050506040513d60208110156110eb57600080fd5b50519050610f25565b61110d6001600160a01b0386168563ffffffff61157116565b1561111757611414565b61112b81600160431b63ffffffff6115a716565b6114075760408051635b16ebb760e01b81526001600160a01b038716600482015290516000917371cd6666064c3a1354a3b4dca5fa1e2d3ee7d30391635b16ebb791602480820192602092909190829003018186803b15801561118d57600080fd5b505afa1580156111a1573d6000803e3d6000fd5b505050506040513d60208110156111b757600080fd5b505160408051635b16ebb760e01b81526001600160a01b038816600482015290519192506000917371cd6666064c3a1354a3b4dca5fa1e2d3ee7d30391635b16ebb7916024808301926020929190829003018186803b15801561121957600080fd5b505afa15801561122d573d6000803e3d6000fd5b505050506040513d602081101561124357600080fd5b505190508180156112515750805b156113cf5760608451604051908082528060200260200182016040528015611283578160200160208202803883390190505b50905060005b85518110156112d75785818151811061129e57fe5b60200260200101516fffffffffffffffffffffffffffffffff168282815181106112c457fe5b6020908102919091010152600101611289565b5060006112fe73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee3063ffffffff61104a16565b90506113258973eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8985600160431b6115ad565b60005b865181101561136857608087828151811061133f57fe5b6020026020010151901c83828151811061135557fe5b6020908102919091010152600101611328565b50600061138f73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee3063ffffffff61104a16565b90506113c573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8a6113ba848663ffffffff6114d516565b86600160431b611872565b5050505050611414565b81156113ed576113e687878787600160431b6115ad565b5050611414565b8015611404576113e687878787600160431b611872565b50505b6114148585858585611d4b565b5050505050565b60008161142a57506001611492565b61143384611499565b15611474576040516001600160a01b0384169083156108fc029084906000818181858888f1935050505015801561146e573d6000803e3d6000fd5b50611492565b61148e6001600160a01b038516848463ffffffff611d5816565b5060015b9392505050565b60006001600160a01b03821615806114cd57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b90505b919050565b6000610f2283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611daf565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611044908590611e46565b6000816001600160a01b0316836001600160a01b03161480610f22575061159783611499565b8015610f225750610f2282611499565b16151590565b6115b561521f565b604080518082018083526327b2595f60e11b905260006044820152905181906001600160a01b03891690634f64b2be90606480850191602091818703018186803b15801561160257600080fd5b505afa158015611616573d6000803e3d6000fd5b505050506040513d602081101561162c57600080fd5b50516001600160a01b039081168252604080516327b2595f60e11b8152600160048201529051602093840193928b1692634f64b2be9260248082019391829003018186803b15801561167d57600080fd5b505afa158015611691573d6000803e3d6000fd5b505050506040513d60208110156116a757600080fd5b50516001600160a01b039081169091526040805160008082526020808301808552632c8aec0360e11b8152602484018b815260448501958652845160648601819052979850958d1696635915d806968c969094909360848701939202908190849084905b8381101561172357818101518382015260200161170b565b505050509050019350505050600060405180830381600087803b15801561174957600080fd5b505af115801561175d573d6000803e3d6000fd5b505050506060835160405190808252806020026020018201604052801561178e578160200160208202803883390190505b50905060005b6002811015611868576117c78382600281106117ac57fe5b60200201516001600160a01b0389169063ffffffff61157116565b156117d157611860565b60005b855181101561181957816008028682815181106117ed57fe5b6020026020010151901c60ff1683828151811061180657fe5b60209081029190910101526001016117d4565b5061186083826002811061182957fe5b6020020151886118593087866002811061183f57fe5b60200201516001600160a01b03169063ffffffff61104a16565b8588611d4b565b600101611794565b5050505050505050565b61187a61521f565b604080518082018083526327b2595f60e11b905260006044820152905181906001600160a01b03881690634f64b2be90606480850191602091818703018186803b1580156118c757600080fd5b505afa1580156118db573d6000803e3d6000fd5b505050506040513d60208110156118f157600080fd5b50516001600160a01b039081168252604080516327b2595f60e11b8152600160048201529051602093840193928a1692634f64b2be9260248082019391829003018186803b15801561194257600080fd5b505afa158015611956573d6000803e3d6000fd5b505050506040513d602081101561196c57600080fd5b50516001600160a01b031690526040805160028082526060808301845293945090916020830190803883390190505090506119ae85600263ffffffff611ffe16565b816000815181106119bb57fe5b6020026020010181815250506119ee816000815181106119d757fe5b6020026020010151866114d590919063ffffffff16565b816001815181106119fb57fe5b60200260200101818152505060608451604051908082528060200260200182016040528015611a34578160200160208202803883390190505b50905060005b6002811015611b5f57611a6d848260028110611a5257fe5b60200201516001600160a01b038b169063ffffffff61157116565b15611a7757611b57565b60005b8651811015611abf5781600802878281518110611a9357fe5b6020026020010151901c60ff16838281518110611aac57fe5b6020908102919091010152600101611a7a565b50611af089858360028110611ad057fe5b6020020151858481518110611ae157fe5b60200260200101518589611d4b565b611b003085836002811061183f57fe5b838281518110611b0c57fe5b602002602001018181525050611b5788848381518110611b2857fe5b6020026020010151868460028110611b3c57fe5b60200201516001600160a01b0316919063ffffffff61204016565b600101611a3a565b506000611b7c8460015b60200201516001600160a01b0316611499565b611b87576000611b9d565b82600181518110611b9457fe5b60200260200101515b611ba8856000611b69565b611bb3576000611bc9565b83600081518110611bc057fe5b60200260200101515b019050876001600160a01b031663f223885a82856002604051908082528060200260200182016040528015611c08578160200160208202803883390190505b506040518463ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015611c5c578181015183820152602001611c44565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015611c9b578181015183820152602001611c83565b505050509050019450505050506020604051808303818588803b158015611cc157600080fd5b505af1158015611cd5573d6000803e3d6000fd5b50505050506040513d6020811015611cec57600080fd5b50600090505b6002811015611d3f57611d3633611d0f3088856002811061183f57fe5b878460028110611d1b57fe5b60200201516001600160a01b0316919063ffffffff61141b16565b50600101611cf2565b50505050505050505050565b6114148585858585612134565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611daa908490611e46565b505050565b60008184841115611e3e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611e03578181015183820152602001611deb565b50505050905090810190601f168015611e305780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b611e58826001600160a01b0316612482565b611ea9576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310611ee75780518252601f199092019160209182019101611ec8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611f49576040519150601f19603f3d011682016040523d82523d6000602084013e611f4e565b606091505b509150915081611fa5576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561104457808060200190516020811015611fc157600080fd5b50516110445760405162461bcd60e51b815260040180806020018281038252602a8152602001806152fc602a913960400191505060405180910390fd5b6000610f2283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506124be565b61204983611499565b611daa57806120725761206d6001600160a01b03841683600063ffffffff61252316565b611daa565b60408051636eb1769f60e11b81523060048201526001600160a01b038481166024830152915160009286169163dd62ed3e916044808301926020929190829003018186803b1580156120c357600080fd5b505afa1580156120d7573d6000803e3d6000fd5b505050506040513d60208110156120ed57600080fd5b505190508181101561104457801561211a5761211a6001600160a01b03851684600063ffffffff61252316565b6110446001600160a01b038516848463ffffffff61252316565b836001600160a01b0316856001600160a01b0316141561215357611414565b612169816508000000000063ffffffff6115a716565b151561217f82634000000063ffffffff6115a716565b1515141561247557600061219286612636565b90506001600160a01b038082161461231a57856001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156121ea57600080fd5b505af11580156121fe573d6000803e3d6000fd5b505050506040513d602081101561221457600080fd5b50600090506122326001600160a01b0383163063ffffffff61104a16565b90506001600160a01b03821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156122cc5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156122b357600080fd5b505af11580156122c7573d6000803e3d6000fd5b505050505b6123186001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146122f9578261230f565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b87838787612134565b505b61232385612636565b90506001600160a01b038082161461247357612381866001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146123635782612379565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b86868661276a565b60006123dc306001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146123b157836123c7565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b6001600160a01b03169063ffffffff61104a16565b90505b6123f96001600160a01b038316878363ffffffff61204016565b856001600160a01b031663a0712d68826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561243f57600080fd5b505af1158015612453573d6000803e3d6000fd5b505050506040513d602081101561246957600080fd5b5061141492505050565b505b611414858585858561276a565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906124b657508115155b949350505050565b6000818361250d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611e03578181015183820152602001611deb565b50600083858161251957fe5b0495945050505050565b8015806125a9575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561257b57600080fd5b505afa15801561258f573d6000803e3d6000fd5b505050506040513d60208110156125a557600080fd5b5051155b6125e45760405162461bcd60e51b81526004018080602001828103825260368152602001806153266036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611daa908490611e46565b604080516001600160a01b03831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166330df135f60e21b178152915181516000938493606093734cb120dd1d33c9a3de8bc15620c7cd43418d77e293919290918291908083835b602083106126c45780518252601f1990920191602091820191016126a5565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612724576040519150601f19603f3d011682016040523d82523d6000602084013e612729565b606091505b509150915081158061273a57508051155b1561274b57600019925050506114d0565b80806020019051602081101561276057600080fd5b5051949350505050565b61141485858585855b836001600160a01b0316856001600160a01b0316141561279257611414565b6127a5816208000063ffffffff6115a716565b15156127bb82634000000063ffffffff6115a716565b15151415612aa5576001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214156128e957604080516370a0823160e01b8152306004820152905173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc291632e1a7d4d9183916370a08231916024808301926020929190829003018186803b15801561284157600080fd5b505afa158015612855573d6000803e3d6000fd5b505050506040513d602081101561286b57600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b1580156128ab57600080fd5b505af11580156128bf573d6000803e3d6000fd5b505050506128e473eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee85858585612aae565b611414565b6001600160a01b03851673c0829421c1d260bd3cb3e0f06cfe2d52db2ce315141561296757604080516370a0823160e01b8152306004820152905173c0829421c1d260bd3cb3e0f06cfe2d52db2ce31591632e1a7d4d9183916370a08231916024808301926020929190829003018186803b15801561284157600080fd5b6001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21415612a10576129ad8573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee858585612773565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156129fc57600080fd5b505af11580156113c5573d6000803e3d6000fd5b6001600160a01b03841673c0829421c1d260bd3cb3e0f06cfe2d52db2ce3151415612aa557612a568573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee858585612773565b73c0829421c1d260bd3cb3e0f06cfe2d52db2ce3156001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156129fc57600080fd5b61141485858585855b61141485858585855b612aca816280000063ffffffff6115a716565b15612adf82634000000063ffffffff6115a716565b151415612f3157612aee61523d565b612af6612f3e565b905060005b6008811015612cc957818160088110612b1057fe5b60200201516001600160a01b0316876001600160a01b03161415612cc1576000828260088110612b3c57fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612b7957600080fd5b505afa158015612b8d573d6000803e3d6000fd5b505050506040513d6020811015612ba357600080fd5b505190506000838360088110612bb557fe5b60200201516001600160a01b031663c85c93aa8860016000604051908082528060200260200182016040528015612bf6578160200160208202803883390190505b506040518463ffffffff1660e01b8152600401808481526020018315151515815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015612c56578181015183820152602001612c3e565b50505050905001945050505050602060405180830381600087803b158015612c7d57600080fd5b505af1158015612c91573d6000803e3d6000fd5b505050506040513d6020811015612ca757600080fd5b50519050612cb88289838989612ab7565b50505050611414565b600101612afb565b5060005b6008811015612f2e57818160088110612ce257fe5b60200201516001600160a01b0316866001600160a01b03161415612f26576000828260088110612d0e57fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d4b57600080fd5b505afa158015612d5f573d6000803e3d6000fd5b505050506040513d6020811015612d7557600080fd5b50519050612d868882888888613024565b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b158015612dd057600080fd5b505afa158015612de4573d6000803e3d6000fd5b505050506040513d6020811015612dfa57600080fd5b50519050612e29848460088110612e0d57fe5b60200201516001600160a01b038416908363ffffffff61204016565b838360088110612e3557fe5b60200201516001600160a01b0316633cfcef64826000604051908082528060200260200182016040528015612e74578160200160208202803883390190505b506040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015612eca578181015183820152602001612eb2565b505050509050019350505050602060405180830381600087803b158015612ef057600080fd5b505af1158015612f04573d6000803e3d6000fd5b505050506040513d6020811015612f1a57600080fd5b50611414945050505050565b600101612ccd565b50505b6114148585858585613024565b612f4661523d565b5060408051610100810182527378751b12da02728f467a44eac40f5cbc16bd793481527312b98c621e8754ae70d0fdbbc73d6208bc3e3ca660208201527363d27b3da94a9e871222cb0a32232674b02d2f2d91810191909152731846bdfdb6a0f5c473dec610144513bd071999fb606082015273cddb1bceb7a1979c6caa0229820707429dd3ec6c60808201527342740698959761baf1b06baa51efbd88cb1d862b60a08201527310ec0d497824e342bcb0edce00959142aaa766dd60c082015273eb66acc3d011056b00ea521f8203580c2e5d399160e082015290565b61141485858585855b836001600160a01b0316856001600160a01b0316141561304c57611414565b61305e8161080063ffffffff6115a716565b151561307482634000000063ffffffff6115a716565b1515141561340f5761308461525c565b61308c61341c565b905060005b600d811015613249578181600d81106130a657fe5b60200201516001600160a01b0316876001600160a01b031614156132415760008282600d81106130d257fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561310f57600080fd5b505afa158015613123573d6000803e3d6000fd5b505050506040513d602081101561313957600080fd5b505190508282600d811061314957fe5b60200201516001600160a01b0316632e1a7d4d876040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561319357600080fd5b505af11580156131a7573d6000803e3d6000fd5b505050506132398188836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561320657600080fd5b505afa15801561321a573d6000803e3d6000fd5b505050506040513d602081101561323057600080fd5b5051888861302d565b505050611414565b600101613091565b5060005b600d81101561340c578181600d811061326257fe5b60200201516001600160a01b0316866001600160a01b031614156134045760008282600d811061328e57fe5b60200201516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156132cb57600080fd5b505afa1580156132df573d6000803e3d6000fd5b505050506040513d60208110156132f557600080fd5b505190506133068882888888613589565b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561335057600080fd5b505afa158015613364573d6000803e3d6000fd5b505050506040513d602081101561337a57600080fd5b5051905061338d8484600d8110612e0d57fe5b8383600d811061339957fe5b60200201516001600160a01b031663b6b55f25826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156133e357600080fd5b505af11580156133f7573d6000803e3d6000fd5b5050505050505050611414565b60010161324d565b50505b6114148585858585613589565b61342461525c565b50604080516101a0810182527316de59092dae5ccf4a1e6439d611fd0653f0bd0181527304aa51bbcb46541455ccf1b8bef2ebc5d3787ec960208201527373a052500105205d34daf004eab301916da8190f918101919091527383f798e925bcd4017eb265844fddabb448f1707d606082015273d6ad7a6750a7593e092a9b218d66c0a814a3436e608082015273f61718057901f84c4eec4339ef8f0d86d2b4560060a08201527304bc0ab673d88ae9dbc9da2380cb6b79c4bca9ae60c082015273c2cb1040220768554cf699b0d863a3cd4324ce3260e082015273e6354ed5bc4b393a5aad09f21c46e101e692d4476101008201527326ea744e5b887e5205727f55dfbe8685e3b219516101208201527399d1fa417f94dcd62bfe781a1213c092a47041bc610140820152739777d7e2b60bb01759d0e2f8be2095df444cb07e610160820152731be5d71f2da660bfdee8012ddc58d024448a0a5961018082015290565b61141485858585855b836001600160a01b0316856001600160a01b031614156135b157611414565b6135c281601063ffffffff6115a716565b15156135d882634000000063ffffffff6115a716565b1515141561385f5760408051639bbde94760e01b81526001600160a01b0387166004820152905160009173f451dbd7ba14bfa7b1b78a766d3ed438f79ee1d191639bbde94791602480820192602092909190829003018186803b15801561363e57600080fd5b505afa158015613652573d6000803e3d6000fd5b505050506040513d602081101561366857600080fd5b505190506001600160a01b0381161561371857856001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156136c157600080fd5b505af11580156136d5573d6000803e3d6000fd5b505050506040513d60208110156136eb57600080fd5b50600090506137096001600160a01b0383163063ffffffff61104a16565b90506113e68287838787613592565b60408051639bbde94760e01b81526001600160a01b0387166004820152905173f451dbd7ba14bfa7b1b78a766d3ed438f79ee1d191639bbde947916024808301926020929190829003018186803b15801561377257600080fd5b505afa158015613786573d6000803e3d6000fd5b505050506040513d602081101561379c57600080fd5b505190506001600160a01b0381161561385d576137bc8682868686613868565b60006137d76001600160a01b0383163063ffffffff61104a16565b90506137eb826001600160a01b0316611499565b156123df57734ddc2d193948926d02f9b1fe9e1daa0718270ed56001600160a01b0316631249c58b826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561383f57600080fd5b505af1158015613853573d6000803e3d6000fd5b50505050506113e6565b505b61141485858585855b6114148585858585836001600160a01b0316856001600160a01b0316141561388f57611414565b6138a081602063ffffffff6115a716565b15156138b682634000000063ffffffff6115a716565b15151415613b5d5760006138c986613b6a565b90506001600160a01b0380821614613a19576138ed816001600160a01b0316611499565b15613973576040805163081a6b2560e41b81523060048201526024810186905290516001600160a01b038816916381a6b2509160448083019260209291908290030181600087803b15801561394157600080fd5b505af1158015613955573d6000803e3d6000fd5b505050506040513d602081101561396b57600080fd5b506139ef9050565b60408051632770a7eb60e21b81523060048201526024810186905290516001600160a01b03881691639dc29fac9160448083019260209291908290030181600087803b1580156139c257600080fd5b505af11580156139d6573d6000803e3d6000fd5b505050506040513d60208110156139ec57600080fd5b50505b6000613a0a6001600160a01b0383163063ffffffff61104a16565b90506113e68287838787613ee0565b613a2285613b6a565b90506001600160a01b0380821614613b5b57613a418682868686613ee0565b6000613a5c6001600160a01b0383163063ffffffff61104a16565b9050613a70826001600160a01b0316611499565b15613af25760408051638f6ede1f60e01b815230600482015290516001600160a01b03881691638f6ede1f91849160248082019260209290919082900301818588803b158015613abf57600080fd5b505af1158015613ad3573d6000803e3d6000fd5b50505050506040513d6020811015613aea57600080fd5b506113e69050565b613b0c6001600160a01b038316878363ffffffff61204016565b604080516340c10f1960e01b81523060048201526024810183905290516001600160a01b038816916340c10f199160448083019260209291908290030181600087803b15801561243f57600080fd5b505b6114148585858585613ee0565b6000613b7e826001600160a01b0316611499565b15613b8c57506000196114d0565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b178152915181516000936060936001600160a01b0388169361138893919290918291908083835b60208310613bf75780518252601f199092019160209182019101613bd8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114613c58576040519150601f19603f3d011682016040523d82523d6000602084013e613c5d565b606091505b509150915081613c7357600019925050506114d0565b6000805b8251816006011015613dcc57828160000181518110613c9257fe5b6020910101516001600160f81b031916602360f91b148015613cd55750828160010181518110613cbe57fe5b6020910101516001600160f81b031916607560f81b145b8015613d025750828160020181518110613ceb57fe5b6020910101516001600160f81b031916601b60fa1b145b8015613d2f5750828160030181518110613d1857fe5b6020910101516001600160f81b031916606360f81b145b8015613d5c5750828160040181518110613d4557fe5b6020910101516001600160f81b031916603960f91b145b8015613d895750828160050181518110613d7257fe5b6020910101516001600160f81b031916607560f81b145b8015613db65750828160060181518110613d9f57fe5b6020910101516001600160f81b031916606d60f81b145b15613dc45760019150613dcc565b600101613c77565b5080613ddf5760001993505050506114d0565b60408051600481526024810182526020810180516001600160e01b031663797bf38560e01b178152915181516001600160a01b038916936113889392918291908083835b60208310613e425780518252601f199092019160209182019101613e23565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114613ea3576040519150601f19603f3d011682016040523d82523d6000602084013e613ea8565b606091505b50909350915082613ec05760001993505050506114d0565b818060200190516020811015613ed557600080fd5b505195945050505050565b61141485858585855b836001600160a01b0316856001600160a01b03161415613f0857611414565b613f1981608063ffffffff6115a716565b1515613f2f82634000000063ffffffff6115a716565b1515141561427957604080516354732ba160e11b81526001600160a01b0387166004820152905160009173ed8b133b7b88366e01bb9e38305ab11c265214949163a8e6574291602480820192602092909190829003018186803b158015613f9557600080fd5b505afa158015613fa9573d6000803e3d6000fd5b505050506040513d6020811015613fbf57600080fd5b505190506001600160a01b0381161561404357856001600160a01b031663db006a75856040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561401857600080fd5b505af115801561402c573d6000803e3d6000fd5b5050505061403d8186868686613ee9565b50611414565b604080516354732ba160e11b81526001600160a01b0387166004820152905173ed8b133b7b88366e01bb9e38305ab11c265214949163a8e65742916024808301926020929190829003018186803b15801561409d57600080fd5b505afa1580156140b1573d6000803e3d6000fd5b505050506040513d60208110156140c757600080fd5b505190506001600160a01b03811615614277576140e78682868686614282565b60006141026001600160a01b0383163063ffffffff61104a16565b905061419773398ec7346dcd622edc5ae82352f02be94c62d1196001600160a01b031663f2f4eb266040518163ffffffff1660e01b815260040160206040518083038186803b15801561415457600080fd5b505afa158015614168573d6000803e3d6000fd5b505050506040513d602081101561417e57600080fd5b50516001600160a01b038416908363ffffffff61204016565b73398ec7346dcd622edc5ae82352f02be94c62d11963d2d0e0666141c36001600160a01b038516611499565b6141ce5760006141d0565b825b6141e2856001600160a01b0316611499565b6141ec5784614202565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b604080516001600160e01b031960e086901b1681526001600160a01b0390921660048301526024820186905261044d604483015251606480830192600092919082900301818588803b15801561425757600080fd5b505af115801561426b573d6000803e3d6000fd5b50505050505050611414565b505b61141485858585855b836001600160a01b0316856001600160a01b031614156142a157611414565b6142b38161040063ffffffff6115a716565b15156142c982634000000063ffffffff6115a716565b151514156145a0576001600160a01b038516736a4ffaafa8dd400676df8076ad6c724867b0e2e8141561445657736a4ffaafa8dd400676df8076ad6c724867b0e2e86001600160a01b0316637f8661a1846040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561435057600080fd5b505af1158015614364573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516000935073b683d83a532e2cb7dfa5275eed3698436371cc9f92506370a0823191602480820192602092909190829003018186803b1580156143bd57600080fd5b505afa1580156143d1573d6000803e3d6000fd5b505050506040513d60208110156143e757600080fd5b50519050801561443b57606061441573b683d83a532e2cb7dfa5275eed3698436371cc9f878460018761078d565b91505061443973b683d83a532e2cb7dfa5275eed3698436371cc9f878484876110f4565b505b61403d6000805160206152b1833981519152868686866145a9565b6001600160a01b038416736a4ffaafa8dd400676df8076ad6c724867b0e2e814156145a057614496856000805160206152b18339815191528585856145a9565b604080516370a0823160e01b815230600482015290516000916000805160206152b1833981519152916370a0823191602480820192602092909190829003018186803b1580156144e557600080fd5b505afa1580156144f9573d6000803e3d6000fd5b505050506040513d602081101561450f57600080fd5b505190506145466000805160206152b1833981519152736a4ffaafa8dd400676df8076ad6c724867b0e2e88363ffffffff61204016565b736a4ffaafa8dd400676df8076ad6c724867b0e2e86001600160a01b031663049878f3826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156129fc57600080fd5b61141485858585855b836001600160a01b0316856001600160a01b031614156145c857611414565b6145d981604063ffffffff6115a716565b15156145ef82634000000063ffffffff6115a716565b1515141561485d576001600160a01b0385167306af07097c9eeb7fd685c692751d5c66db49c2151415614714576040805163ef693bed60e01b81523060048201526024810185905290517306af07097c9eeb7fd685c692751d5c66db49c2159163ef693bed91604480830192600092919082900301818387803b15801561467557600080fd5b505af1158015614689573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516128e493506000805160206152b18339815191529250879183916370a0823191602480820192602092909190829003018186803b1580156146e157600080fd5b505afa1580156146f5573d6000803e3d6000fd5b505050506040513d602081101561470b57600080fd5b50518585614866565b6001600160a01b0384167306af07097c9eeb7fd685c692751d5c66db49c215141561485d57614754856000805160206152b1833981519152858585614866565b604080516370a0823160e01b815230600482015290516000916000805160206152b1833981519152916370a0823191602480820192602092909190829003018186803b1580156147a357600080fd5b505afa1580156147b7573d6000803e3d6000fd5b505050506040513d60208110156147cd57600080fd5b505190506148046000805160206152b18339815191527306af07097c9eeb7fd685c692751d5c66db49c2158363ffffffff61204016565b60408051633b4da69f60e01b81523060048201526024810183905290517306af07097c9eeb7fd685c692751d5c66db49c21591633b4da69f91604480830192600092919082900301818387803b1580156129fc57600080fd5b61141485858585855b836001600160a01b0316856001600160a01b0316141561488557611414565b61489b816502000000000063ffffffff6115a716565b15156148b182634000000063ffffffff6115a716565b151514156150ad576001600160a01b03851673e2f2a5c287993345a840db3b0845fbc70f5935a51415614df0576001600160a01b03841673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48148061491f57506001600160a01b0384166000805160206152b1833981519152145b8061494657506001600160a01b03841673dac17f958d2ee523a2206206994597c13d831ec7145b8061496857506001600160a01b0384166e085d4780b73119b644ae5ecd22b376145b15614b665760408051633b3fb85360e21b81526001600160a01b0387811660048301526024820186905286166044820152905160009173abcc93c3be238884cc3309c19afd128fafc169119163ecfee14c916064808201928692909190829003018186803b1580156149d957600080fd5b505afa1580156149ed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526080811015614a1657600080fd5b815160208301805160405192949293830192919084600160201b821115614a3c57600080fd5b908301906020820185811115614a5157600080fd5b8251600160201b811182820188101715614a6a57600080fd5b82525081516020918201929091019080838360005b83811015614a97578181015183820152602001614a7f565b50505050905090810190601f168015614ac45780820380516001836020036101000a031916815260200191505b506040818152918201516301e9a69560e41b82526001600160a01b038c16600483015260248201819052915191965073e2f2a5c287993345a840db3b0845fbc70f5935a59550631e9a695094506044808201945060209350908290030181600087803b158015614b3357600080fd5b505af1158015614b47573d6000803e3d6000fd5b505050506040513d6020811015614b5d57600080fd5b506128e4915050565b60408051633b3fb85360e21b81526001600160a01b0387166004820152602481018590526000805160206152b18339815191526044820152905160009173abcc93c3be238884cc3309c19afd128fafc169119163ecfee14c916064808201928692909190829003018186803b158015614bde57600080fd5b505afa158015614bf2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526080811015614c1b57600080fd5b815160208301805160405192949293830192919084600160201b821115614c4157600080fd5b908301906020820185811115614c5657600080fd5b8251600160201b811182820188101715614c6f57600080fd5b82525081516020918201929091019080838360005b83811015614c9c578181015183820152602001614c84565b50505050905090810190601f168015614cc95780820380516001836020036101000a031916815260200191505b506040818152918201516301e9a69560e41b82526000805160206152b1833981519152600483015260248201819052915191965073e2f2a5c287993345a840db3b0845fbc70f5935a59550631e9a695094506044808201945060209350908290030181600087803b158015614d3d57600080fd5b505af1158015614d51573d6000803e3d6000fd5b505050506040513d6020811015614d6757600080fd5b5050604080516370a0823160e01b8152306004820152905161403d916000805160206152b183398151915291889183916370a0823191602480820192602092909190829003018186803b158015614dbd57600080fd5b505afa158015614dd1573d6000803e3d6000fd5b505050506040513d6020811015614de757600080fd5b505186866150b6565b6001600160a01b03841673e2f2a5c287993345a840db3b0845fbc70f5935a514156150ad576001600160a01b03851673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481480614e5657506001600160a01b0385166000805160206152b1833981519152145b80614e7d57506001600160a01b03851673dac17f958d2ee523a2206206994597c13d831ec7145b80614e9f57506001600160a01b0385166e085d4780b73119b644ae5ecd22b376145b15614f7557614ed26001600160a01b03861673e2f2a5c287993345a840db3b0845fbc70f5935a58563ffffffff61204016565b60408051631ba0488760e21b81526001600160a01b0387811660048301528616602482015260448101859052306064820152905173e2f2a5c287993345a840db3b0845fbc70f5935a591636e81221c9160848083019260209291908290030181600087803b158015614f4357600080fd5b505af1158015614f57573d6000803e3d6000fd5b505050506040513d6020811015614f6d57600080fd5b506128e49050565b614f90856000805160206152b18339815191528585856150b6565b604080516370a0823160e01b8152306004820152905173e2f2a5c287993345a840db3b0845fbc70f5935a591636e81221c916000805160206152b183398151915291889183916370a08231916024808301926020929190829003018186803b158015614ffb57600080fd5b505afa15801561500f573d6000803e3d6000fd5b505050506040513d602081101561502557600080fd5b5051604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526044820152306064820152905160848083019260209291908290030181600087803b15801561508357600080fd5b505af1158015615097573d6000803e3d6000fd5b505050506040513d60208110156113e657600080fd5b61141485858585855b836001600160a01b0316856001600160a01b031614156150d557611414565b61141485858585856001546150fd906001600160a01b0387811691168563ffffffff61204016565b6001546001600160a01b039081169063e2a7515e9061511d908816611499565b61512857600061512a565b845b878787600088886040518863ffffffff1660e01b815260040180876001600160a01b03166001600160a01b03168152602001866001600160a01b03166001600160a01b0316815260200185815260200184815260200180602001838152602001828103825284818151815260200191508051906020019060200280838360005b838110156151c25781810151838201526020016151aa565b505050509050019750505050505050506020604051808303818588803b1580156151eb57600080fd5b505af11580156151ff573d6000803e3d6000fd5b50505050506040513d602081101561521657600080fd5b50505050505050565b60405180604001604052806002906020820280388339509192915050565b6040518061010001604052806008906020820280388339509192915050565b604051806101a00160405280600d90602082028038833950919291505056fe4f6e6553706c69743a2061637475616c2072657475726e20616d6f756e74206973206c657373207468616e206d696e52657475726e0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f57726f6e6720757365616765206f66204554482e756e6976657273616c5472616e7366657246726f6d28295361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a723158204716beb8f91925f6e8d1b253b687e8017d19a2b26963dc12104702d3c91b794064736f6c63430005110032
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001a3f7583c0af24ef78cdb1a1eb48d957df793824000000000000000000000000480ea104ff7063ed0af41c98d8ef2457afe2a41c
-----Decoded View---------------
Arg [0] : _oneSplitView (address): 0x1A3f7583C0Af24ef78CdB1a1eB48D957df793824
Arg [1] : _oneSplit (address): 0x480ea104fF7063Ed0Af41c98d8EF2457afE2a41c
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000001a3f7583c0af24ef78cdb1a1eb48d957df793824
Arg [1] : 000000000000000000000000480ea104ff7063ed0af41c98d8ef2457afe2a41c
Deployed Bytecode Sourcemap
225853:5955:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;226472:10;226486:9;226472:23;;226464:32;;;;;;225853:5955;226512:515;;8:9:-1;5:2;;;30:1;27;20:12;5:2;226512:515:0;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;-1:-1;;;;;;226512:515:0;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;226512:515:0;;;;;;;;;;;;;;;;;;226177:25;;8:9:-1;5:2;;;30:1;27;20:12;5:2;226177:25:0;;;:::i;:::-;;;;-1:-1:-1;;;;;226177:25:0;;;;;;;;;;;;;;227670:1551;;8:9:-1;5:2;;;30:1;27;20:12;5:2;227670:1551:0;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;227670:1551:0;;;;;;;;-1:-1:-1;;;5:28;;2:2;;;46:1;43;36:12;2:2;227670:1551:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;227670:1551:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;227670:1551:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;227670:1551:0;;;;;;;;;-1:-1:-1;227670:1551:0;;;;-1:-1:-1;227670:1551:0;;;;-1:-1:-1;;;;5:28;;2:2;;;46:1;43;36:12;2:2;227670:1551:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;227670:1551:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;227670:1551:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;227670:1551:0;;;;;;;;-1:-1:-1;227670:1551:0;;-1:-1:-1;;;;;5:28;;2:2;;;46:1;43;36:12;2:2;227670:1551:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;227670:1551:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;227670:1551:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;227670:1551:0;;;;;;;;-1:-1:-1;227670:1551:0;;-1:-1:-1;;;;;5:28;;2:2;;;46:1;43;36:12;2:2;227670:1551:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;227670:1551:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;227670:1551:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;227670:1551:0;;-1:-1:-1;227670:1551:0;;-1:-1:-1;;;;;227670:1551:0:i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;227670:1551:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;227670:1551:0;;;;;;;;;;;;;;;;;;;;227035:627;;8:9:-1;5:2;;;30:1;27;20:12;5:2;227035:627:0;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;-1:-1;;;;;;227035:627:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;227035:627:0;;;;;;;;;;;;;;;;;;;230035:1306;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;230035:1306:0;;;;;;;;-1:-1:-1;;;5:28;;2:2;;;46:1;43;36:12;2:2;230035:1306:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;230035:1306:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;230035:1306:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;230035:1306:0;;;;;;;;;;;;-1:-1:-1;230035:1306:0;-1:-1:-1;230035:1306:0;;;;-1:-1:-1;230035:1306:0;;;-1:-1:-1;;;5:28;;2:2;;;46:1;43;36:12;2:2;230035:1306:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;230035:1306:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;230035:1306:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;230035:1306:0;;;;;;;;-1:-1:-1;230035:1306:0;;-1:-1:-1;;;;;5:28;;2:2;;;46:1;43;36:12;2:2;230035:1306:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;230035:1306:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;230035:1306:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;230035:1306:0;;-1:-1:-1;230035:1306:0;;-1:-1:-1;;;;;230035:1306:0:i;:::-;;;;;;;;;;;;;;;;229229:798;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;-1:-1;;;;;229229:798:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;5:28;;2:2;;;46:1;43;36:12;2:2;229229:798:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;229229:798:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;-1:-1;;;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;229229:798:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;229229:798:0;;-1:-1:-1;;229229:798:0;;;-1:-1:-1;229229:798:0;;-1:-1:-1;;229229:798:0:i;226137:33::-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;226137:33:0;;;:::i;226512:515::-;226734:20;226769:29;226859:160;226898:9;226922;226946:6;226967:5;226987;227007:1;226859:24;:160::i;:::-;226826:193;;;;-1:-1:-1;226512:515:0;;-1:-1:-1;;;;;;;226512:515:0:o;226177:25::-;;;-1:-1:-1;;;;;226177:25:0;;:::o;227670:1551::-;227960:30;228005:25;228045:29;228102:21;228182:1;228166:6;:13;:17;228152:32;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;228152:32:0;-1:-1:-1;228136:48:0;-1:-1:-1;228209:1:0;228195:1019;228216:6;:13;228212:1;:17;228195:1019;;;228272:6;228279:1;228272:9;;;;;;;;;;;;;;-1:-1:-1;;;;;228255:26:0;:6;228266:1;228262;:5;228255:13;;;;;;;;;;;;;;-1:-1:-1;;;;;228255:26:0;;228251:157;;;228326:1;228331;228326:6;228325:40;;228345:13;228363:1;228359;:5;228345:20;;;;;;;;;;;;;;228325:40;;;228336:6;228325:40;228302:13;228320:1;228316;:5;228302:20;;;;;;;;;;;;;:63;;;;;228384:8;;228251:157;228424:23;228450:6;228424:32;;228578:279;228621:7;228633:1;228629;:5;228621:14;;;;;;;;;;;;;;228654:7;228662:1;228654:10;;;;;;;;;;;;;;228684:1;228689;228684:6;228683:40;;228703:13;228721:1;228717;:5;228703:20;;;;;;;;;;;;;;228683:40;;;228694:6;228683:40;228742:5;228752:1;228748;:5;228742:12;;;;;;;;;;;;;;228773:5;228783:1;228779;:5;228773:12;;;;;;;;;;;;;;228804:31;228840:1;228836;:5;228804:38;;;;;;;;;;;;;;228578:24;:279::i;:::-;228492:13;228510:1;228506;:5;228492:20;;;;;;;;;;;;;;;;;228473:384;;;;;-1:-1:-1;228473:384:0;-1:-1:-1;228892:29:0;:17;228473:384;228892:29;:21;:29;:::i;:::-;228872:49;;228942:12;:19;228965:1;228942:24;228938:106;;;229016:4;:11;229002:26;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;229002:26:0;;228987:41;;228938:106;229063:6;229058:145;229079:12;:19;229075:1;:23;229058:145;;;229142:45;229183:1;229179;:5;229174:1;:11;229162:4;229167:1;229162:7;;;;;;;;;;;;;;:24;;229142:12;229155:1;229142:15;;;;;;;;;;;;;;:19;;:45;;;;:::i;:::-;229124:12;229137:1;229124:15;;;;;;;;;;;;;;;;;:63;229100:3;;229058:145;;;;228195:1019;;228231:3;;228195:1019;;;;227670:1551;;;;;;;;;;:::o;227035:627::-;227313:20;227452:12;;:202;;;-1:-1:-1;;;227452:202:0;;-1:-1:-1;;;;;227452:202:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;227313:20;;227388:29;;227452:12;;:37;;:202;;;;;227313:20;;227452:202;;;;;;;:12;:202;;;5:2:-1;;;;30:1;27;20:12;5:2;227452:202:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;227452:202:0;;;;;;39:16:-1;36:1;17:17;2:54;101:4;227452:202:0;80:15:-1;;;-1:-1;;76:31;65:43;;120:4;113:20;13:2;5:11;;2:2;;;29:1;26;19:12;2:2;227452:202:0;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;11:20;;8:2;;;44:1;41;34:12;8:2;62:21;;;;123:4;114:14;;138:31;;;135:2;;;182:1;179;172:12;135:2;219:3;213:10;331:9;325:2;311:12;307:21;289:16;285:44;282:59;-1:-1;;;247:12;244:29;233:116;230:2;;;362:1;359;352:12;230:2;373:25;;-1:-1;227452:202:0;;421:4:-1;412:14;;;;227452:202:0;;;;;412:14:-1;227452:202:0;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;227452:202:0;;;;;;;;;;;227445:209;;;;;;227035:627;;;;;;;;;;:::o;230035:1306::-;230243:20;230276:66;230308:10;230328:4;230335:6;230276;230283:1;230276:9;;;;;;;;;;;;;;-1:-1:-1;;;;;230276:31:0;;;:66;;;;;;:::i;:::-;230370:43;230407:4;230370:6;230377:1;230370:9;;;;;;;;;;;;;;-1:-1:-1;;;;;230370:28:0;;;:43;;;;:::i;:::-;230355:58;-1:-1:-1;230438:1:0;230424:726;230445:6;:13;230441:1;:17;230424:726;;;230501:6;230508:1;230501:9;;;;;;;;;;;;;;-1:-1:-1;;;;;230484:26:0;:6;230495:1;230491;:5;230484:13;;;;;;;;;;;;;;-1:-1:-1;;;;;230484:26:0;;230480:75;;;230531:8;;230480:75;230571:21;230609:12;:19;230595:34;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;230595:34:0;-1:-1:-1;230571:58:0;-1:-1:-1;230649:6:0;230644:133;230665:12;:19;230661:1;:23;230644:133;;;230750:1;230746;:5;230741:1;:11;230721:12;230734:1;230721:15;;;;;;;;;;;;;;:32;;230757:4;230720:41;230710:4;230715:1;230710:7;;;;;;;;;;;;;;;;;:51;230686:3;;230644:133;;;;230793:165;230817:6;230828:1;230824;:5;230817:13;;;;;;;;;;;;;;230849:6;230856:1;230849:9;;;;;;;;;;;;;;230877:12;230908:4;230931:5;230941:1;230937;:5;230931:12;;;;;;;;;;;;;;230793:5;:165::i;:::-;230988:43;231025:4;230988:6;230995:1;230988:9;;;;;;;:43;230973:58;;231046:92;231078:10;231090:47;231131:4;231090:6;231101:1;231097;:5;231090:13;;;;;;;:47;231046:6;231057:1;231053;:5;231046:13;;;;;;;;;;;;;;-1:-1:-1;;;;;231046:31:0;;;:92;;;;;:::i;:::-;;230424:726;;230460:3;;230424:726;;;;231186:9;231170:12;:25;;231162:91;;;;-1:-1:-1;;;231162:91:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;231264:69;231308:10;231320:12;231264:6;231287:1;231271:6;:13;:17;231264:25;;;;;;;:69;;230035:1306;;;;;;;:::o;229229:798::-;229444:20;229477:66;-1:-1:-1;;;;;229477:31:0;;229509:10;229529:4;229536:6;229477:66;:31;:66;:::i;:::-;229554:17;229574:43;-1:-1:-1;;;;;229574:28:0;;229611:4;229574:43;:28;:43;:::i;:::-;229554:63;;229628:59;229634:9;229645;229656;229667:12;229681:5;229628;:59::i;:::-;229715:43;-1:-1:-1;;;;;229715:28:0;;229752:4;229715:43;:28;:43;:::i;:::-;229700:58;;229793:9;229777:12;:25;;229769:91;;;;-1:-1:-1;;;229769:91:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;229871:53;-1:-1:-1;;;;;229871:27:0;;229899:10;229911:12;229871:53;:27;:53;:::i;:::-;-1:-1:-1;229935:84:0;229963:10;229975:43;-1:-1:-1;;;;;229975:28:0;;230012:4;229975:43;:28;:43;:::i;:::-;-1:-1:-1;;;;;229935:27:0;;;:84;;:27;:84;:::i;:::-;;229229:798;;;;;;;;;:::o;226137:33::-;;;-1:-1:-1;;;;;226137:33:0;;:::o;12663:181::-;12721:7;12753:5;;;12777:6;;;;12769:46;;;;;-1:-1:-1;;;12769:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;12835:1;-1:-1:-1;12663:181:0;;;;;:::o;40062:617::-;40173:11;40169:50;;40201:7;;40169:50;40235:12;40241:5;40235;:12::i;:::-;40231:441;;;-1:-1:-1;;;;;40272:18:0;;40280:10;40272:18;:41;;;;;40307:6;40294:9;:19;;40272:41;40264:97;;;;-1:-1:-1;;;40264:97:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;40380:19:0;;40394:4;40380:19;40376:97;;40420:37;;-1:-1:-1;;;;;40420:29:0;;;:37;;;;;40450:6;;40420:37;;;;40450:6;40420:29;:37;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;40420:37:0;40376:97;40503:6;40491:9;:18;40487:101;;;40530:10;:42;40550:21;:9;40564:6;40550:21;:13;:21;:::i;:::-;40530:42;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;40530:42:0;40487:101;40231:441;;;40620:40;-1:-1:-1;;;;;40620:22:0;;40643:4;40649:2;40653:6;40620:40;:22;:40;:::i;:::-;40062:617;;;;:::o;41664:228::-;41742:7;41766:12;41772:5;41766;:12::i;:::-;41762:123;;;-1:-1:-1;;;;;;41802:11:0;;;41795:18;;41762:123;41853:5;-1:-1:-1;;;;;41853:15:0;;41869:3;41853:20;;;;;;;;;;;;;-1:-1:-1;;;;;41853:20:0;-1:-1:-1;;;;;41853:20:0;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;41853:20:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;41853:20:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;41853:20:0;;-1:-1:-1;41846:27:0;;218252:2387;218439:21;-1:-1:-1;;;;;218439:12:0;;218452:7;218439:21;:12;:21;:::i;:::-;218435:60;;;218477:7;;218435:60;218512:46;:5;-1:-1:-1;;;218512:46:0;:11;:46;:::i;:::-;218507:1969;;218598:44;;;-1:-1:-1;;;218598:44:0;;-1:-1:-1;;;;;218598:44:0;;;;;;;;218575:20;;75523:42;;218598:24;;:44;;;;;;;;;;;;;;;75523:42;218598:44;;;5:2:-1;;;;30:1;27;20:12;5:2;218598:44:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;218598:44:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;218598:44:0;218678:42;;;-1:-1:-1;;;218678:42:0;;-1:-1:-1;;;;;218678:42:0;;;;;;;;218598:44;;-1:-1:-1;218657:18:0;;75523:42;;218678:24;;:42;;;;;218598:44;;218678:42;;;;;;;75523;218678;;;5:2:-1;;;;30:1;27;20:12;5:2;218678:42:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;218678:42:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;218678:42:0;;-1:-1:-1;218741:15:0;:32;;;;;218760:13;218741:32;218737:1126;;;218794:21;218832:12;:19;218818:34;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;218818:34:0;-1:-1:-1;218794:58:0;-1:-1:-1;218876:6:0;218871:134;218892:12;:19;218888:1;:23;218871:134;;;218951:12;218964:1;218951:15;;;;;;;;;;;;;;218970:14;218951:34;218941:4;218946:1;218941:7;;;;;;;;;;;;;;;;;:44;218913:3;;218871:134;;;-1:-1:-1;219025:24:0;219052:45;71580:42;219091:4;219052:45;:30;:45;:::i;:::-;219025:72;;219118:220;219164:9;71580:42;219230:6;219259:4;-1:-1:-1;;;219118:23:0;:220::i;:::-;219364:6;219359:122;219380:12;:19;219376:1;:23;219359:122;;;219458:3;219439:12;219452:1;219439:15;;;;;;;;;;;;;;:22;;219429:4;219434:1;219429:7;;;;;;;;;;;;;;;;;:32;219401:3;;219359:122;;;-1:-1:-1;219501:23:0;219527:45;71580:42;219566:4;219527:45;:30;:45;:::i;:::-;219501:71;-1:-1:-1;219600:247:0;71580:42;219678:7;219708:37;219501:71;219728:16;219708:37;:19;:37;:::i;:::-;219768:4;-1:-1:-1;;;219600:21:0;:247::i;:::-;219593:254;;;;;;;218737:1126;219883:15;219879:287;;;219926:224;219972:9;220004:7;220034:6;220063:12;-1:-1:-1;;;219926:23:0;:224::i;:::-;219919:231;;;;219879:287;220186:13;220182:283;;;220227:222;220271:9;220303:7;220333:6;220362:12;-1:-1:-1;;;220227:21:0;:222::i;220182:283::-;218507:1969;;;220495:136;220521:9;220545:7;220567:6;220588:12;220615:5;220495:11;:136::i;:::-;218252:2387;;;;;:::o;39706:348::-;39792:4;39813:11;39809:55;;-1:-1:-1;39848:4:0;39841:11;;39809:55;39880:12;39886:5;39880;:12::i;:::-;39876:171;;;39909:37;;-1:-1:-1;;;;;39909:29:0;;;:37;;;;;39939:6;;39909:37;;;;39939:6;39909:29;:37;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;39909:37:0;39876:171;;;39979:30;-1:-1:-1;;;;;39979:18:0;;39998:2;40002:6;39979:30;:18;:30;:::i;:::-;-1:-1:-1;40031:4:0;39876:171;39706:348;;;;;:::o;42482:166::-;42533:4;-1:-1:-1;;;;;42558:39:0;;;;:81;;-1:-1:-1;;;;;;42601:38:0;;39654:42;42601:38;42558:81;42550:90;;42482:166;;;;:::o;13119:136::-;13177:7;13204:43;13208:1;13211;13204:43;;;;;;;;;;;;;;;;;:3;:43::i;36361:204::-;36488:68;;;-1:-1:-1;;;;;36488:68:0;;;;;;;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;36488:68:0;;;;;;;;25:18:-1;;61:17;;-1:-1;;;;;182:15;-1:-1;;;179:29;160:49;;36462:95:0;;36481:5;;36462:18;:95::i;42656:118::-;42710:4;42739:1;-1:-1:-1;;;;;42734:6:0;:1;-1:-1:-1;;;;;42734:6:0;;:32;;;;42745:8;42751:1;42745:5;:8::i;:::-;:20;;;;;42757:8;42763:1;42757:5;:8::i;71075:117::-;71166:12;71165:19;;;71075:117::o;220647:1027::-;220847:23;;:::i;:::-;:147;;;;;;;;;-1:-1:-1;;;220888:40:0;;-1:-1:-1;220888:40:0;;;;;;220847:147;;-1:-1:-1;;;;;220888:37:0;;;;;:40;;;;;;;;;;;;:37;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;220888:40:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;220888:40:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;220888:40:0;-1:-1:-1;;;;;220847:147:0;;;;;220943:40;;;-1:-1:-1;;;220943:40:0;;220981:1;220943:40;;;;;;220888;220847:147;;;;220943:37;;;;;;:40;;;;;;;;;;;:37;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;220943:40:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;220943:40:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;220943:40:0;-1:-1:-1;;;;;220847:147:0;;;;;;221082:16;;;221096:1;221082:16;;;220943:40;221082:16;;;;;;-1:-1:-1;;;221007:102:0;;;;;;;;;;;;;;;;;;;;;;220847:147;;-1:-1:-1;221007:39:0;;;;;;221061:6;;221007:102;;;;;;;;221082:16;221007:102;;;;;;221082:16;;8:100:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;221007:102:0;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;221007:102:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;221007:102:0;;;;221122:21;221160:12;:19;221146:34;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;221146:34:0;-1:-1:-1;221122:58:0;-1:-1:-1;221196:6:0;221191:476;221212:1;221208;:5;221191:476;;;221241:21;221252:6;221259:1;221252:9;;;;;;;;;;;-1:-1:-1;;;;;221241:10:0;;;:21;:10;:21;:::i;:::-;221237:70;;;221283:8;;221237:70;221328:6;221323:127;221344:12;:19;221340:1;:23;221323:127;;;221420:1;221424;221420:5;221400:12;221413:1;221400:15;;;;;;;;;;;;;;:26;;221430:4;221399:35;221389:4;221394:1;221389:7;;;;;;;;;;;;;;;;;:45;221365:3;;221323:127;;;;221466:189;221496:6;221503:1;221496:9;;;;;;;;;;;221524:7;221550:43;221587:4;221550:6;221557:1;221550:9;;;;;;;;;;;-1:-1:-1;;;;;221550:28:0;;:43;:28;:43;:::i;:::-;221612:4;221635:5;221466:11;:189::i;:::-;221215:3;;221191:476;;;;220647:1027;;;;;;;:::o;221682:1653::-;221882:23;;:::i;:::-;:147;;;;;;;;;-1:-1:-1;;;221923:40:0;;-1:-1:-1;221923:40:0;;;;;;221882:147;;-1:-1:-1;;;;;221923:37:0;;;;;:40;;;;;;;;;;;;:37;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;221923:40:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;221923:40:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;221923:40:0;-1:-1:-1;;;;;221882:147:0;;;;;221978:40;;;-1:-1:-1;;;221978:40:0;;222016:1;221978:40;;;;;;221923;221882:147;;;;221978:37;;;;;;:40;;;;;;;;;;;:37;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;221978:40:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;221978:40:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;221978:40:0;-1:-1:-1;;;;;221882:147:0;;;222119:16;;;222133:1;222119:16;;;222092:24;222119:16;;;;;221882:147;;-1:-1:-1;222119:16:0;;;;;;;105:10:-1;222119:16:0;88:34:-1;136:17;;-1:-1;;222092:43:0;-1:-1:-1;222159:13:0;:6;222170:1;222159:13;:10;:13;:::i;:::-;222146:7;222154:1;222146:10;;;;;;;;;;;;;:26;;;;;222196:22;222207:7;222215:1;222207:10;;;;;;;;;;;;;;222196:6;:10;;:22;;;;:::i;:::-;222183:7;222191:1;222183:10;;;;;;;;;;;;;:35;;;;;222229:21;222267:12;:19;222253:34;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;222253:34:0;-1:-1:-1;222229:58:0;-1:-1:-1;222303:6:0;222298:593;222319:1;222315;:5;222298:593;;;222348:23;222361:6;222368:1;222361:9;;;;;;;;;;;-1:-1:-1;;;;;222348:12:0;;;:23;:12;:23;:::i;:::-;222344:72;;;222392:8;;222344:72;222437:6;222432:127;222453:12;:19;222449:1;:23;222432:127;;;222529:1;222533;222529:5;222509:12;222522:1;222509:15;;;;;;;;;;;;;;:26;;222539:4;222508:35;222498:4;222503:1;222498:7;;;;;;;;;;;;;;;;;:45;222474:3;;222432:127;;;;222575:158;222605:9;222633:6;222640:1;222633:9;;;;;;;;;;;222661:7;222669:1;222661:10;;;;;;;;;;;;;;222690:4;222713:5;222575:11;:158::i;:::-;222763:43;222800:4;222763:6;222770:1;222763:9;;;;;;:43;222750:7;222758:1;222750:10;;;;;;;;;;;;;:56;;;;;222821:58;222856:9;222868:7;222876:1;222868:10;;;;;;;;;;;;;;222821:6;222828:1;222821:9;;;;;;;;;;;-1:-1:-1;;;;;222821:26:0;;:58;;:26;:58;:::i;:::-;222322:3;;222298:593;;;-1:-1:-1;222903:16:0;222962:17;:6;222969:1;222962:9;;;;;-1:-1:-1;;;;;222962:15:0;;:17::i;:::-;:34;;222995:1;222962:34;;;222982:7;222990:1;222982:10;;;;;;;;;;;;;;222962:34;222923:17;:6;222930:1;222923:9;;:17;:34;;222956:1;222923:34;;;222943:7;222951:1;222943:10;;;;;;;;;;;;;;222923:34;222922:75;222903:94;;223027:9;-1:-1:-1;;;;;223008:38:0;;223053:8;223077:7;223113:1;223099:16;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;223099:16:0;;223008:118;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;223008:118:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;223008:118:0;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;223008:118:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;223008:118:0;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;223144:6:0;;-1:-1:-1;223139:189:0;223160:1;223156;:5;223139:189;;;223183:133;223229:10;223258:43;223295:4;223258:6;223265:1;223258:9;;;;;;:43;223183:6;223190:1;223183:9;;;;;;;;;;;-1:-1:-1;;;;;223183:27:0;;:133;;:27;:133;:::i;:::-;-1:-1:-1;223163:3:0;;223139:189;;;;221682:1653;;;;;;;;;:::o;209125:328::-;209310:135;209333:9;209357;209381:6;209402:12;209429:5;209310:8;:135::i;36177:176::-;36286:58;;;-1:-1:-1;;;;;36286:58:0;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;36286:58:0;;;;;;;;25:18:-1;;61:17;;-1:-1;;;;;182:15;-1:-1;;;179:29;160:49;;36260:85:0;;36279:5;;36260:18;:85::i;:::-;36177:176;;;:::o;13592:192::-;13678:7;13714:12;13706:6;;;;13698:29;;;;-1:-1:-1;;;13698:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;13698:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;13750:5:0;;;13592:192::o;38216:1114::-;38820:27;38828:5;-1:-1:-1;;;;;38820:25:0;;:27::i;:::-;38812:71;;;;;-1:-1:-1;;;38812:71:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;38957:12;38971:23;39006:5;-1:-1:-1;;;;;38998:19:0;39018:4;38998:25;;;;;;;;;;;;;36:153:-1;66:2;61:3;58:11;36:153;;176:10;;164:23;;-1:-1;;139:12;;;;98:2;89:12;;;;114;36:153;;;274:1;267:3;263:2;259:12;254:3;250:22;246:30;315:4;311:9;305:3;299:10;295:26;356:4;350:3;344:10;340:21;389:7;380;377:20;372:3;365:33;3:399;;;38998:25:0;;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;38956:67:0;;;;39042:7;39034:52;;;;;-1:-1:-1;;;39034:52:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;39103:17;;:21;39099:224;;39245:10;39234:30;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;39234:30:0;39226:85;;;;-1:-1:-1;;;39226:85:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;14974:132;15032:7;15059:39;15063:1;15066;15059:39;;;;;;;;;;;;;;;;;:3;:39::i;41138:518::-;41231:12;41237:5;41231;:12::i;:::-;41226:423;;41264:11;41260:101;;41296:24;-1:-1:-1;;;;;41296:17:0;;41314:2;41318:1;41296:24;:17;:24;:::i;:::-;41339:7;;41260:101;41397:34;;;-1:-1:-1;;;41397:34:0;;41421:4;41397:34;;;;-1:-1:-1;;;;;41397:34:0;;;;;;;;;41377:17;;41397:15;;;;;:34;;;;;;;;;;;;;;:15;:34;;;5:2:-1;;;;30:1;27;20:12;5:2;41397:34:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;41397:34:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;41397:34:0;;-1:-1:-1;41450:18:0;;;41446:192;;;41493:13;;41489:86;;41531:24;-1:-1:-1;;;;;41531:17:0;;41549:2;41553:1;41531:24;:17;:24;:::i;:::-;41593:29;-1:-1:-1;;;;;41593:17:0;;41611:2;41615:6;41593:29;:17;:29;:::i;209461:1928::-;209665:9;-1:-1:-1;;;;;209652:22:0;:9;-1:-1:-1;;;;;209652:22:0;;209648:61;;;209691:7;;209648:61;209771:29;:5;7796:13;209771:29;:11;:29;:::i;:::-;209725:75;;:42;:5;6679:10;209725:42;:11;:42;:::i;:::-;:75;;;209721:1503;;;209817:17;209837:33;209860:9;209837:22;:33::i;:::-;209817:53;-1:-1:-1;;;;;;209889:24:0;;;;209885:533;;209947:9;-1:-1:-1;;;;;209934:31:0;;209966:6;209934:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;209934:39:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;209934:39:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;209992:15:0;;-1:-1:-1;210010:44:0;-1:-1:-1;;;;;210010:29:0;;210048:4;210010:44;:29;:44;:::i;:::-;209992:62;-1:-1:-1;;;;;;210077:18:0;;71848:42;210077:18;210073:89;;;71848:42;-1:-1:-1;;;;;210120:13:0;;210134:7;210120:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;210120:22:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;210120:22:0;;;;210073:89;210180:222;-1:-1:-1;;;;;210212:18:0;;71848:42;210212:18;210211:47;;210248:10;210211:47;;;71580:42;210211:47;210281:9;210313:7;210343:12;210378:5;210180:8;:222::i;:::-;209885:533;;210447:33;210470:9;210447:22;:33::i;:::-;210434:46;-1:-1:-1;;;;;;210499:24:0;;;;210495:718;;210544:224;210578:9;-1:-1:-1;;;;;210611:18:0;;71848:42;210611:18;210610:47;;210647:10;210610:47;;;71580:42;210610:47;210680:6;210709:12;210744:5;210544:11;:224::i;:::-;210789:24;210816:83;210893:4;-1:-1:-1;;;;;210818:18:0;;71848:42;210818:18;210817:47;;210854:10;210817:47;;;71580:42;210817:47;-1:-1:-1;;;;;210816:68:0;;:83;:68;:83;:::i;:::-;210789:110;;210918:103;211041:65;-1:-1:-1;;;;;211041:27:0;;211077:9;211089:16;211041:65;:27;:65;:::i;:::-;211138:9;-1:-1:-1;;;;;211125:29:0;;211155:16;211125:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;211125:47:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;211125:47:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;211191:7:0;;-1:-1:-1;;;211191:7:0;210495:718;209721:1503;;211243:138;211269:9;211293;211317:6;211338:12;211365:5;211243:11;:138::i;33206:619::-;33266:4;33734:20;;33577:66;33774:23;;;;;;:42;;-1:-1:-1;33801:15:0;;;33774:42;33766:51;33206:619;-1:-1:-1;;;;33206:619:0:o;15636:345::-;15722:7;15824:12;15817:5;15809:28;;;;-1:-1:-1;;;15809:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;27:10:-1;;8:100;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;15809:28:0;;15848:9;15864:1;15860;:5;;;;;;;15636:345;-1:-1:-1;;;;;15636:345:0:o;36573:621::-;36943:10;;;36942:62;;-1:-1:-1;36959:39:0;;;-1:-1:-1;;;36959:39:0;;36983:4;36959:39;;;;-1:-1:-1;;;;;36959:39:0;;;;;;;;;:15;;;;;;:39;;;;;;;;;;;;;;;:15;:39;;;5:2:-1;;;;30:1;27;20:12;5:2;36959:39:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;36959:39:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;36959:39:0;:44;36942:62;36934:152;;;;-1:-1:-1;;;36934:152:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;37123:62;;;-1:-1:-1;;;;;37123:62:0;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;37123:62:0;;;;;;;;25:18:-1;;61:17;;-1:-1;;;;;182:15;-1:-1;;;179:29;160:49;;37097:89:0;;37116:5;;37097:18;:89::i;205076:455::-;205248:128;;;-1:-1:-1;;;;;205248:128:0;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;205248:128:0;;;;;;;25:18:-1;;61:17;;-1:-1;;;;;182:15;-1:-1;;;179:29;160:49;;205199:188:0;;;;205144:6;;;;205178:17;;205024:42;;205248:128;;205199:188;;;;25:18:-1;205199:188:0;;25:18:-1;36:153;66:2;61:3;58:11;36:153;;176:10;;164:23;;-1:-1;;139:12;;;;98:2;89:12;;;;114;36:153;;;274:1;267:3;263:2;259:12;254:3;250:22;246:30;315:4;311:9;305:3;299:10;295:26;356:4;350:3;344:10;340:21;389:7;380;377:20;372:3;365:33;3:399;;;205199:188:0;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;205163:224:0;;;;205405:7;205404:8;:28;;;-1:-1:-1;205416:11:0;;:16;205404:28;205400:78;;;-1:-1:-1;;205449:17:0;;;;;;205400:78;205508:4;205497:26;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;205497:26:0;;205076:455;-1:-1:-1;;;;205076:455:0:o;195776:329::-;195961:136;195985:9;196009;196033:6;196054:12;196081:5;196113:1972;196318:9;-1:-1:-1;;;;;196305:22:0;:9;-1:-1:-1;;;;;196305:22:0;;196301:61;;;196344:7;;196301:61;196424:30;:5;5708:7;196424:30;:11;:30;:::i;:::-;196378:76;;:42;:5;6679:10;196378:42;:11;:42;:::i;:::-;:76;;;196374:1546;;;-1:-1:-1;;;;;196475:17:0;;71848:42;196475:17;196471:334;;;196527:29;;;-1:-1:-1;;;196527:29:0;;196550:4;196527:29;;;;;;71848:42;;196513:13;;71848:42;;196527:14;;:29;;;;;;;;;;;;;;71848:42;196527:29;;;5:2:-1;;;;30:1;27;20:12;5:2;196527:29:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;196527:29:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;196527:29:0;196513:44;;;-1:-1:-1;;;;;;196513:44:0;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;196513:44:0;;;;;;;-1:-1:-1;196513:44:0;;;;5:2:-1;;;;30:1;27;20:12;5:2;196513:44:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;196513:44:0;;;;196576:188;71580:42;196644:9;196676:6;196705:12;196740:5;196576:11;:188::i;:::-;196783:7;;196471:334;-1:-1:-1;;;;;196825:29:0;;71761:42;196825:29;196821:370;;;196901:41;;;-1:-1:-1;;;196901:41:0;;196936:4;196901:41;;;;;;71761:42;;196875:25;;71761:42;;196901:26;;:41;;;;;;;;;;;;;;71761:42;196901:41;;;5:2:-1;;;;30:1;27;20:12;196821:370:0;-1:-1:-1;;;;;197211:17:0;;71848:42;197211:17;197207:331;;;197249:186;197281:9;71580:42;197347:6;197376:12;197411:5;197249:9;:186::i;:::-;71848:42;-1:-1:-1;;;;;197454:12:0;;197473:21;197454:43;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;197454:43:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;197207:331:0;-1:-1:-1;;;;;197558:29:0;;71761:42;197558:29;197554:355;;;197608:186;197640:9;71580:42;197706:6;197735:12;197770:5;197608:9;:186::i;:::-;71761:42;-1:-1:-1;;;;;197813:24:0;;197844:21;197813:55;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;197554:355:0;197939:138;197965:9;197989;198013:6;198034:12;198061:5;187066:329;187251:136;187275:9;187299;187323:6;187344:12;187371:5;187403:1426;187644:30;:5;6177:8;187644:30;:11;:30;:::i;:::-;187643:31;187597:42;:5;6679:10;187597:42;:11;:42;:::i;:::-;187596:43;:78;187592:1148;;;187691:22;;:::i;:::-;187716:13;:11;:13::i;:::-;187691:38;-1:-1:-1;187751:6:0;187746:401;187767:13;187763:1;:17;187746:401;;;187830:6;187837:1;187830:9;;;;;;;;;;;-1:-1:-1;;;;;187810:30:0;:9;-1:-1:-1;;;;;187810:30:0;;187806:326;;;187865:17;187885:6;187892:1;187885:9;;;;;;;;;;;-1:-1:-1;;;;;187885:15:0;;:17;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;187885:17:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;187885:17:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;187885:17:0;;-1:-1:-1;187925:14:0;187942:6;187949:1;187942:9;;;;;;;;;;;-1:-1:-1;;;;;187942:25:0;;187968:6;187976:4;187996:1;187982:16;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;187982:16:0;;187942:57;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;187942:57:0;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;187942:57:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;187942:57:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;187942:57:0;;-1:-1:-1;188022:61:0;188032:10;188044:9;187942:57;188063:12;188077:5;188022:9;:61::i;:::-;188106:7;;;;;;187806:326;187782:3;;187746:401;;;-1:-1:-1;188168:6:0;188163:566;188184:13;188180:1;:17;188163:566;;;188247:6;188254:1;188247:9;;;;;;;;;;;-1:-1:-1;;;;;188227:30:0;:9;-1:-1:-1;;;;;188227:30:0;;188223:491;;;188282:17;188302:6;188309:1;188302:9;;;;;;;;;;;-1:-1:-1;;;;;188302:15:0;;:17;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188302:17:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;188302:17:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;188302:17:0;;-1:-1:-1;188342:63:0;188354:9;188302:17;188377:6;188385:12;188399:5;188342:11;:63::i;:::-;188458:35;;;-1:-1:-1;;;188458:35:0;;188487:4;188458:35;;;;;;188430:25;;-1:-1:-1;;;;;188458:20:0;;;;;:35;;;;;;;;;;;;;;;:20;:35;;;5:2:-1;;;;30:1;27;20:12;5:2;188458:35:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;188458:35:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;188458:35:0;;-1:-1:-1;188516:66:0;188552:6;188559:1;188552:9;;;;;;;;;;;-1:-1:-1;;;;;188516:27:0;;;188564:17;188516:66;:27;:66;:::i;:::-;188605:6;188612:1;188605:9;;;;;;;;;;;-1:-1:-1;;;;;188605:23:0;;188629:17;188662:1;188648:16;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;188648:16:0;;188605:60;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;188605:60:0;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;188605:60:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;188605:60:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;188688:7:0;;-1:-1:-1;;;;;188688:7:0;188223:491;188199:3;;188163:566;;;;187592:1148;;188759:62;188771:9;188782;188793:6;188801:12;188815:5;188759:11;:62::i;183209:716::-;183254:15;;:::i;:::-;-1:-1:-1;183349:568:0;;;;;;;;183396:42;183349:568;;183460:42;183349:568;;;;183524:42;183349:568;;;;;;;183588:42;183349:568;;;;183652:42;183349:568;;;;183716:42;183349:568;;;;183799:42;183349:568;;;;183863:42;183349:568;;;;183209:716;:::o;180749:330::-;180934:137;180959:9;180983;181007:6;181028:12;181055:5;181087:1465;181293:9;-1:-1:-1;;;;;181280:22:0;:9;-1:-1:-1;;;;;181280:22:0;;181276:61;;;181319:7;;181276:61;181399:31;:5;5080;181399:31;:11;:31;:::i;:::-;181353:77;;:42;:5;6679:10;181353:42;:11;:42;:::i;:::-;:77;;;181349:1114;;;181447:25;;:::i;:::-;181475:10;:8;:10::i;:::-;181447:38;-1:-1:-1;181507:6:0;181502:387;181523:14;181519:1;:18;181502:387;;;181587:7;181595:1;181587:10;;;;;;;;;;;-1:-1:-1;;;;;181567:31:0;:9;-1:-1:-1;;;;;181567:31:0;;181563:311;;;181623:17;181643:7;181651:1;181643:10;;;;;;;;;;;-1:-1:-1;;;;;181643:16:0;;:18;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;181643:18:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;181643:18:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;181643:18:0;;-1:-1:-1;181684:7:0;181692:1;181684:10;;;;;;;;;;;-1:-1:-1;;;;;181684:19:0;;181704:6;181684:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;181684:27:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;181684:27:0;;;;181734:91;181745:10;181757:9;181768:10;-1:-1:-1;;;;;181768:20:0;;181797:4;181768:35;;;;;;;;;;;;;-1:-1:-1;;;;;181768:35:0;-1:-1:-1;;;;;181768:35:0;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;181768:35:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;181768:35:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;181768:35:0;181805:12;181819:5;181734:10;:91::i;:::-;181848:7;;;;;181563:311;181539:3;;181502:387;;;-1:-1:-1;181910:6:0;181905:547;181926:14;181922:1;:18;181905:547;;;181990:7;181998:1;181990:10;;;;;;;;;;;-1:-1:-1;;;;;181970:31:0;:9;-1:-1:-1;;;;;181970:31:0;;181966:471;;;182026:17;182046:7;182054:1;182046:10;;;;;;;;;;;-1:-1:-1;;;;;182046:16:0;;:18;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;182046:18:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;182046:18:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;182046:18:0;;-1:-1:-1;182087:63:0;182099:9;182046:18;182122:6;182130:12;182144:5;182087:11;:63::i;:::-;182203:35;;;-1:-1:-1;;;182203:35:0;;182232:4;182203:35;;;;;;182175:25;;-1:-1:-1;;;;;182203:20:0;;;;;:35;;;;;;;;;;;;;;;:20;:35;;;5:2:-1;;;;30:1;27;20:12;5:2;182203:35:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;182203:35:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;182203:35:0;;-1:-1:-1;182261:67:0;182297:7;182305:1;182297:10;;;;;;182261:67;182351:7;182359:1;182351:10;;;;;;;;;;;-1:-1:-1;;;;;182351:18:0;;182370:17;182351:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;182351:37:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;182351:37:0;;;;182411:7;;;;;;181966:471;181942:3;;181905:547;;;;181349:1114;;182482:62;182494:9;182505;182516:6;182524:12;182538:5;182482:11;:62::i;176314:943::-;176356:17;;:::i;:::-;-1:-1:-1;176386:863:0;;;;;;;;176415:42;176386:863;;176480:42;176386:863;;;;176545:42;176386:863;;;;;;;176610:42;176386:863;;;;176675:42;176386:863;;;;176740:42;176386:863;;;;176805:42;176386:863;;;;176870:42;176386:863;;;;176935:42;176386:863;;;;177000:42;176386:863;;;;177065:42;176386:863;;;;177130:42;176386:863;;;;177195:42;176386:863;;;;176314:943;:::o;158757:333::-;158942:140;158970:9;158994;159018:6;159039:12;159066:5;159098:1867;159307:9;-1:-1:-1;;;;;159294:22:0;:9;-1:-1:-1;;;;;159294:22:0;;159290:61;;;159333:7;;159290:61;159413:34;:5;4610:4;159413:34;:11;:34;:::i;:::-;159367:80;;:42;:5;6679:10;159367:42;:11;:42;:::i;:::-;:80;;;159363:1437;;;159484:66;;;-1:-1:-1;;;159484:66:0;;-1:-1:-1;;;;;159484:66:0;;;;;;;;159464:17;;76447:42;;159484:30;;:66;;;;;;;;;;;;;;;76447:42;159484:66;;;5:2:-1;;;;30:1;27;20:12;5:2;159484:66:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;159484:66:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;159484:66:0;;-1:-1:-1;;;;;;159569:23:0;;;159565:430;;159636:9;-1:-1:-1;;;;;159613:41:0;;159655:6;159613:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;159613:49:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;159613:49:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;159681:24:0;;-1:-1:-1;159708:44:0;-1:-1:-1;;;;;159708:29:0;;159746:4;159708:44;:29;:44;:::i;:::-;159681:71;;159780:199;159816:10;159849:9;159881:16;159920:12;159955:5;159780:13;:199::i;159565:430::-;160024:66;;;-1:-1:-1;;;160024:66:0;;-1:-1:-1;;;;;160024:66:0;;;;;;;;76447:42;;160024:30;;:66;;;;;;;;;;;;;;76447:42;160024:66;;;5:2:-1;;;;30:1;27;20:12;5:2;160024:66:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;160024:66:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;160024:66:0;;-1:-1:-1;;;;;;160109:23:0;;;160105:684;;160153:187;160187:9;160219:10;160252:6;160281:12;160316:5;160153:11;:187::i;:::-;160361:24;160388:44;-1:-1:-1;;;;;160388:29:0;;160426:4;160388:44;:29;:44;:::i;:::-;160361:71;;160457:18;:10;-1:-1:-1;;;;;160457:16:0;;:18::i;:::-;160453:296;;;75397:42;-1:-1:-1;;;;;160500:9:0;;160516:16;160500:35;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;160500:35:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;160500:35:0;;;;;160453:296;;160105:684;159363:1437;;160819:138;160845:9;160869;160893:6;160914:12;160941:5;165992:332;166177:139;166204:9;166228;166252:6;166273:12;166300:5;166540:9;-1:-1:-1;;;;;166527:22:0;:9;-1:-1:-1;;;;;166527:22:0;;166523:61;;;166566:7;;166523:61;166646:33;:5;4670:4;166646:33;:11;:33;:::i;:::-;166600:79;;:42;:5;6679:10;166600:42;:11;:42;:::i;:::-;:79;;;166596:1618;;;166696:17;166716:26;166732:9;166716:15;:26::i;:::-;166696:46;-1:-1:-1;;;;;;166761:24:0;;;;166757:626;;166810:18;:10;-1:-1:-1;;;;;166810:16:0;;:18::i;:::-;166806:245;;;166853:68;;;-1:-1:-1;;;166853:68:0;;166907:4;166853:68;;;;;;;;;;;;-1:-1:-1;;;;;166853:45:0;;;;;:68;;;;;;;;;;;;;;-1:-1:-1;166853:45:0;:68;;;5:2:-1;;;;30:1;27;20:12;5:2;166853:68:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;166853:68:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;166806:245:0;;-1:-1:-1;166806:245:0;;166970:61;;;-1:-1:-1;;;166970:61:0;;167017:4;166970:61;;;;;;;;;;;;-1:-1:-1;;;;;166970:38:0;;;;;:61;;;;;;;;;;;;;;-1:-1:-1;166970:38:0;:61;;;5:2:-1;;;;30:1;27;20:12;5:2;166970:61:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;166970:61:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;166806:245:0;167071:24;167098:44;-1:-1:-1;;;;;167098:29:0;;167136:4;167098:44;:29;:44;:::i;:::-;167071:71;;167170:197;167204:10;167237:9;167269:16;167308:12;167343:5;167170:11;:197::i;166757:626::-;167412:26;167428:9;167412:15;:26::i;:::-;167399:39;-1:-1:-1;;;;;;167457:24:0;;;;167453:750;;167502:187;167536:9;167568:10;167601:6;167630:12;167665:5;167502:11;:187::i;:::-;167710:24;167737:44;-1:-1:-1;;;;;167737:29:0;;167775:4;167737:44;:29;:44;:::i;:::-;167710:71;;167806:18;:10;-1:-1:-1;;;;;167806:16:0;;:18::i;:::-;167802:361;;;167849:86;;;-1:-1:-1;;;167849:86:0;;167929:4;167849:86;;;;;;-1:-1:-1;;;;;167849:47:0;;;;;167903:16;;167849:86;;;;;;;;;;;;;;;167903:16;167849:47;:86;;;5:2:-1;;;;30:1;27;20:12;5:2;167849:86:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;167849:86:0;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;167802:361:0;;-1:-1:-1;167802:361:0;;167984:65;-1:-1:-1;;;;;167984:27:0;;168020:9;168032:16;167984:65;:27;:65;:::i;:::-;168072:71;;;-1:-1:-1;;;168072:71:0;;168119:4;168072:71;;;;;;;;;;;;-1:-1:-1;;;;;168072:38:0;;;;;:71;;;;;;;;;;;;;;-1:-1:-1;168072:38:0;:71;;;5:2:-1;;;;30:1;27;20:12;167453:750:0;166596:1618;;168233:138;168259:9;168283;168307:6;168328:12;168355:5;168233:11;:138::i;161793:1173::-;161854:6;161877:13;:5;-1:-1:-1;;;;;161877:11:0;;:13::i;:::-;161873:63;;;-1:-1:-1;;;161907:17:0;;161873:63;162020:57;;;22:32:-1;6:49;;162020:57:0;;;;;49:4:-1;25:18;;61:17;;-1:-1;;;;;182:15;-1:-1;;;179:29;160:49;;161984:94:0;;;;161949:12;;161963:17;;-1:-1:-1;;;;;161984:25:0;;;162014:4;;162020:57;;161984:94;;;;25:18:-1;161984:94:0;;25:18:-1;36:153;66:2;61:3;58:11;36:153;;176:10;;164:23;;-1:-1;;139:12;;;;98:2;89:12;;;;114;36:153;;;274:1;267:3;263:2;259:12;254:3;250:22;246:30;315:4;311:9;305:3;299:10;295:26;356:4;350:3;344:10;340:21;389:7;380;377:20;372:3;365:33;3:399;;;161984:94:0;;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;161948:130:0;;;;162094:7;162089:58;;-1:-1:-1;;162118:17:0;;;;;;162089:58;162159:13;;162191:414;162216:4;:11;162208:1;162212;162208:5;:19;162191:414;;;162253:4;162258:1;162262;162258:5;162253:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162253:11:0;-1:-1:-1;;;162253:18:0;:57;;;;;162292:4;162297:1;162301;162297:5;162292:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162292:11:0;-1:-1:-1;;;162292:18:0;162253:57;:96;;;;;162331:4;162336:1;162340;162336:5;162331:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162331:11:0;-1:-1:-1;;;162331:18:0;162253:96;:135;;;;;162370:4;162375:1;162379;162375:5;162370:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162370:11:0;-1:-1:-1;;;162370:18:0;162253:135;:174;;;;;162409:4;162414:1;162418;162414:5;162409:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162409:11:0;-1:-1:-1;;;162409:18:0;162253:174;:213;;;;;162448:4;162453:1;162457;162453:5;162448:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162448:11:0;-1:-1:-1;;;162448:18:0;162253:213;:252;;;;;162487:4;162492:1;162496;162492:5;162487:11;;;;;;;;;;;;;-1:-1:-1;;;;;;162487:11:0;-1:-1:-1;;;162487:18:0;162253:252;162249:345;;;162550:4;162539:15;;162573:5;;162249:345;162229:3;;162191:414;;;;162620:8;162615:59;;-1:-1:-1;;162645:17:0;;;;;;;162615:59;162740:103;;;22:32:-1;6:49;;162740:103:0;;;;;49:4:-1;25:18;;61:17;;-1:-1;;;;;182:15;-1:-1;;;179:29;160:49;;162704:140:0;;;;-1:-1:-1;;;;;162704:25:0;;;162734:4;;162740:103;162704:140;;;25:18:-1;162704:140:0;;25:18:-1;36:153;66:2;61:3;58:11;36:153;;176:10;;164:23;;-1:-1;;139:12;;;;98:2;89:12;;;;114;36:153;;;274:1;267:3;263:2;259:12;254:3;250:22;246:30;315:4;311:9;305:3;299:10;295:26;356:4;350:3;344:10;340:21;389:7;380;377:20;372:3;365:33;3:399;;;162704:140:0;;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;-1:-1;162686:158:0;;-1:-1:-1;162686:158:0;-1:-1:-1;162686:158:0;162855:58;;-1:-1:-1;;162884:17:0;;;;;;;162855:58;162943:4;162932:26;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;162932:26:0;;161793:1173;-1:-1:-1;;;;;161793:1173:0:o;191614:329::-;191799:136;191823:9;191847;191871:6;191892:12;191919:5;191951:1731;192156:9;-1:-1:-1;;;;;192143:22:0;:9;-1:-1:-1;;;;;192143:22:0;;192139:61;;;192182:7;;192139:61;192262:30;:5;4784:4;192262:30;:11;:30;:::i;:::-;192216:76;;:42;:5;6679:10;192216:42;:11;:42;:::i;:::-;:76;;;192212:1305;;;192329:58;;;-1:-1:-1;;;192329:58:0;;-1:-1:-1;;;;;192329:58:0;;;;;;;;192309:17;;76558:42;;192329:26;;:58;;;;;;;;;;;;;;;76558:42;192329:58;;;5:2:-1;;;;30:1;27;20:12;5:2;192329:58:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;192329:58:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;192329:58:0;;-1:-1:-1;;;;;;192406:23:0;;;192402:322;;192469:9;-1:-1:-1;;;;;192450:37:0;;192488:6;192450:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;192450:45:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;192450:45:0;;;;192523:185;192555:10;192588:9;192620:6;192649:12;192684:5;192523:9;:185::i;:::-;192516:192;;;192402:322;192753:58;;;-1:-1:-1;;;192753:58:0;;-1:-1:-1;;;;;192753:58:0;;;;;;;;76558:42;;192753:26;;:58;;;;;;;;;;;;;;76558:42;192753:58;;;5:2:-1;;;;30:1;27;20:12;5:2;192753:58:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;192753:58:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;192753:58:0;;-1:-1:-1;;;;;;192830:23:0;;;192826:680;;192874:187;192908:9;192940:10;192973:6;193002:12;193037:5;192874:11;:187::i;:::-;193082:24;193109:44;-1:-1:-1;;;;;193109:29:0;;193147:4;193109:44;:29;:44;:::i;:::-;193082:71;;193174:58;75193:42;-1:-1:-1;;;;;193202:9:0;;:11;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;193202:11:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;193202:11:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;193202:11:0;-1:-1:-1;;;;;193174:27:0;;;193215:16;193174:58;:27;:58;:::i;:::-;75193:42;193251:12;193270:18;-1:-1:-1;;;;;193270:16:0;;;:18::i;:::-;:41;;193310:1;193270:41;;;193291:16;193270:41;193335:18;:10;-1:-1:-1;;;;;193335:16:0;;:18::i;:::-;:45;;193370:10;193335:45;;;71580:42;193335:45;193251:214;;;-1:-1:-1;;;;;;193251:214:0;;;;;;;-1:-1:-1;;;;;193251:214:0;;;;;;;;;;;;;193442:4;193251:214;;;;;;;;;;-1:-1:-1;;193251:214:0;;;;;;;;;;;;5:2:-1;;;;30:1;27;20:12;5:2;193251:214:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;193251:214:0;;;;;193484:7;;;;192826:680;192212:1305;;193536:138;193562:9;193586;193610:6;193631:12;193658:5;174158:1707;174360:9;-1:-1:-1;;;;;174347:22:0;:9;-1:-1:-1;;;;;174347:22:0;;174343:61;;;174386:7;;174343:61;174466:30;:5;5021;174466:30;:11;:30;:::i;:::-;174420:76;;:42;:5;6679:10;174420:42;:11;:42;:::i;:::-;:76;;;174416:1360;;;-1:-1:-1;;;;;174517:25:0;;172109:42;174517:25;174513:913;;;172109:42;-1:-1:-1;;;;;174563:9:0;;174573:6;174563:17;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;174563:17:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;174622:28:0;;;-1:-1:-1;;;174622:28:0;;174644:4;174622:28;;;;;;174601:18;;-1:-1:-1;172197:42:0;;-1:-1:-1;174622:13:0;;:28;;;;;;;;;;;;;;;172197:42;174622:28;;;5:2:-1;;;;30:1;27;20:12;5:2;174622:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;174622:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;174622:28:0;;-1:-1:-1;174673:14:0;;174669:534;;174714:32;174750:203;172197:42;174824:9;174860:10;174897:1;174925:5;174750:17;:203::i;:::-;174712:241;;;174978:205;172197:42;175040:9;175076:10;175113:15;175155:5;174978;:205::i;:::-;174669:534;;175230:180;-1:-1:-1;;;;;;;;;;;175290:9:0;175322:6;175351:12;175386:5;175230:11;:180::i;174513:913::-;-1:-1:-1;;;;;175446:25:0;;172109:42;175446:25;175442:323;;;175492:56;175504:9;-1:-1:-1;;;;;;;;;;;175520:6:0;175528:12;175542:5;175492:11;:56::i;:::-;175590:28;;;-1:-1:-1;;;175590:28:0;;175612:4;175590:28;;;;;;175569:18;;-1:-1:-1;;;;;;;;;;;72023:42:0;175590:13;;:28;;;;;;;;;;;;;;;72023:42;175590:28;;;5:2:-1;;;;30:1;27;20:12;5:2;175590:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;175590:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;175590:28:0;;-1:-1:-1;175637:47:0;-1:-1:-1;;;;;;;;;;;172109:42:0;175590:28;175637:47;:20;:47;:::i;:::-;172109:42;-1:-1:-1;;;;;175703:9:0;;175713:10;175703:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;175442:323:0;175795:62;175807:9;175818;175829:6;175837:12;175851:5;170439:1337;170641:9;-1:-1:-1;;;;;170628:22:0;:9;-1:-1:-1;;;;;170628:22:0;;170624:61;;;170667:7;;170624:61;170747:30;:5;4727:4;170747:30;:11;:30;:::i;:::-;170701:76;;:42;:5;6679:10;170701:42;:11;:42;:::i;:::-;:76;;;170697:914;;;-1:-1:-1;;;;;170798:25:0;;71935:42;170798:25;170794:328;;;170844:32;;;-1:-1:-1;;;170844:32:0;;170862:4;170844:32;;;;;;;;;;;;71935:42;;170844:9;;:32;;;;;-1:-1:-1;;170844:32:0;;;;;;;-1:-1:-1;71935:42:0;170844:32;;;5:2:-1;;;;30:1;27;20:12;5:2;170844:32:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;170996:28:0;;;-1:-1:-1;;;170996:28:0;;171018:4;170996:28;;;;;;170904:202;;-1:-1:-1;;;;;;;;;;;;72023:42:0;-1:-1:-1;170964:9:0;;72023:42;;170996:13;;:28;;;;;;;;;;;;;;;72023:42;170996:28;;;5:2:-1;;;;30:1;27;20:12;5:2;170996:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;170996:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;170996:28:0;171047:12;171082:5;170904:11;:202::i;170794:328::-;-1:-1:-1;;;;;171142:25:0;;71935:42;171142:25;171138:462;;;171188:180;171222:9;-1:-1:-1;;;;;;;;;;;171280:6:0;171309:12;171344:5;171188:11;:180::i;:::-;171410:28;;;-1:-1:-1;;;171410:28:0;;171432:4;171410:28;;;;;;171389:18;;-1:-1:-1;;;;;;;;;;;72023:42:0;171410:13;;:28;;;;;;;;;;;;;;;72023:42;171410:28;;;5:2:-1;;;;30:1;27;20:12;5:2;171410:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;171410:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;171410:28:0;;-1:-1:-1;171457:47:0;-1:-1:-1;;;;;;;;;;;71935:42:0;171410:28;171457:47;:20;:47;:::i;:::-;171523:36;;;-1:-1:-1;;;171523:36:0;;171541:4;171523:36;;;;;;;;;;;;71935:42;;171523:9;;:36;;;;;-1:-1:-1;;171523:36:0;;;;;;;-1:-1:-1;71935:42:0;171523:36;;;5:2:-1;;;;30:1;27;20:12;171138:462:0;171630:138;171656:9;171680;171704:6;171725:12;171752:5;201980:2445;202182:9;-1:-1:-1;;;;;202169:22:0;:9;-1:-1:-1;;;;;202169:22:0;;202165:61;;;202208:7;;202165:61;202288:38;:5;7659:13;202288:38;:11;:38;:::i;:::-;202242:84;;:42;:5;6679:10;202242:42;:11;:42;:::i;:::-;:84;;;202238:2022;;;-1:-1:-1;;;;;202347:25:0;;75837:42;202347:25;202343:937;;;-1:-1:-1;;;;;202397:17:0;;72112:42;202397:17;;:37;;-1:-1:-1;;;;;;202418:16:0;;-1:-1:-1;;;;;;;;;;;202418:16:0;202397:37;:58;;;-1:-1:-1;;;;;;202438:17:0;;72201:42;202438:17;202397:58;:79;;;-1:-1:-1;;;;;;202459:17:0;;72290:42;202459:17;202397:79;202393:847;;;202524:59;;;-1:-1:-1;;;202524:59:0;;-1:-1:-1;;;;;202524:59:0;;;;;;;;;;;;;;;;;;;;;202506:14;;75967:42;;202524:29;;:59;;;;;202506:14;;202524:59;;;;;;;;75967:42;202524:59;;;5:2:-1;;;;30:1;27;20:12;5:2;202524:59:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;202524:59:0;;;;;;39:16:-1;36:1;17:17;2:54;101:4;202524:59:0;80:15:-1;;;-1:-1;;76:31;65:43;;120:4;113:20;13:3;5:12;;2:2;;;30:1;27;20:12;2:2;202524:59:0;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;11:20;;8:2;;;44:1;41;34:12;8:2;62:21;;;;123:4;114:14;;138:31;;;135:2;;;182:1;179;172:12;135:2;213:10;;-1:-1;;;244:29;;285:43;;;282:58;-1:-1;233:115;230:2;;;361:1;358;351:12;230:2;372:25;;-1:-1;202524:59:0;;420:4:-1;411:14;;;;202524:59:0;;;;;411:14:-1;202524:59:0;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;202524:59:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;202524:59:0;;;;;;;;-1:-1:-1;;;202606:103:0;;-1:-1:-1;;;;;202606:103:0;;;;;;;;;;;;;;202524:59;;-1:-1:-1;75837:42:0;;-1:-1:-1;202606:11:0;;-1:-1:-1;202606:103:0;;;;;-1:-1:-1;202524:59:0;;-1:-1:-1;202606:103:0;;;;;;-1:-1:-1;75837:42:0;202606:103;;;5:2:-1;;;;30:1;27;20:12;5:2;202606:103:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;202606:103:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;202393:847:0;;-1:-1:-1;;202393:847:0;;202798:53;;;-1:-1:-1;;;202798:53:0;;-1:-1:-1;;;;;202798:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;202798:53:0;;;;;;202780:14;;75967:42;;202798:29;;:53;;;;;202780:14;;202798:53;;;;;;;;75967:42;202798:53;;;5:2:-1;;;;30:1;27;20:12;5:2;202798:53:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;202798:53:0;;;;;;39:16:-1;36:1;17:17;2:54;101:4;202798:53:0;80:15:-1;;;-1:-1;;76:31;65:43;;120:4;113:20;13:3;5:12;;2:2;;;30:1;27;20:12;2:2;202798:53:0;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;11:20;;8:2;;;44:1;41;34:12;8:2;62:21;;;;123:4;114:14;;138:31;;;135:2;;;182:1;179;172:12;135:2;213:10;;-1:-1;;;244:29;;285:43;;;282:58;-1:-1;233:115;230:2;;;361:1;358;351:12;230:2;372:25;;-1:-1;202798:53:0;;420:4:-1;411:14;;;;202798:53:0;;;;;411:14:-1;202798:53:0;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;202798:53:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;202798:53:0;;;;;;;;-1:-1:-1;;;202874:97:0;;-1:-1:-1;;;;;;;;;;;202874:97:0;;;;;;;;;;;;202798:53;;-1:-1:-1;75837:42:0;;-1:-1:-1;202874:11:0;;-1:-1:-1;202874:97:0;;;;;-1:-1:-1;202798:53:0;;-1:-1:-1;202874:97:0;;;;;;-1:-1:-1;75837:42:0;202874:97;;;5:2:-1;;;;30:1;27;20:12;5:2;202874:97:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;202874:97:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;203098:28:0;;;-1:-1:-1;;;203098:28:0;;203120:4;203098:28;;;;;;202994:226;;-1:-1:-1;;;;;;;;;;;72023:42:0;203062:9;;72023:42;;203098:13;;:28;;;;;202874:97;;203098:28;;;;;;;;72023:42;203098:28;;;5:2:-1;;;;30:1;27;20:12;5:2;203098:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;203098:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;203098:28:0;203153:12;203192:5;202994:11;:226::i;202343:937::-;-1:-1:-1;;;;;203300:25:0;;75837:42;203300:25;203296:953;;;-1:-1:-1;;;;;203350:17:0;;72112:42;203350:17;;:37;;-1:-1:-1;;;;;;203371:16:0;;-1:-1:-1;;;;;;;;;;;203371:16:0;203350:37;:58;;;-1:-1:-1;;;;;;203391:17:0;;72201:42;203391:17;203350:58;:79;;;-1:-1:-1;;;;;;203412:17:0;;72290:42;203412:17;203350:79;203346:863;;;203454:49;-1:-1:-1;;;;;203454:26:0;;75837:42;203496:6;203454:49;:26;:49;:::i;:::-;203526:177;;;-1:-1:-1;;;203526:177:0;;-1:-1:-1;;;;;203526:177:0;;;;;;;;;;;;;;;;;;;203675:4;203526:177;;;;;;75837:42;;203526:9;;:177;;;;;;;;;;;;;;-1:-1:-1;75837:42:0;203526:177;;;5:2:-1;;;;30:1;27;20:12;5:2;203526:177:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;203526:177:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;203346:863:0;;-1:-1:-1;203346:863:0;;203769:204;203807:9;-1:-1:-1;;;;;;;;;;;203873:6:0;203906:12;203945:5;203769:11;:204::i;:::-;204098:28;;;-1:-1:-1;;;204098:28:0;;204120:4;204098:28;;;;;;75837:42;;203996:9;;-1:-1:-1;;;;;;;;;;;72023:42:0;204062:9;;72023:42;;204098:13;;:28;;;;;;;;;;;;;;72023:42;204098:28;;;5:2:-1;;;;30:1;27;20:12;5:2;204098:28:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;204098:28:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;204098:28:0;203996:193;;;-1:-1:-1;;;;;;203996:193:0;;;;;;;-1:-1:-1;;;;;203996:193:0;;;;;;;;;;;;;;;;;;;204161:4;203996:193;;;;;;;;;;;204098:28;;203996:193;;;;;;;-1:-1:-1;203996:193:0;;;;5:2:-1;;;;30:1;27;20:12;5:2;203996:193:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;203996:193:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;203296:953:0;204279:138;204305:9;204329;204353:6;204374:12;204401:5;129275:437;129511:9;-1:-1:-1;;;;;129498:22:0;:9;-1:-1:-1;;;;;129498:22:0;;129494:61;;;129537:7;;129494:61;129567:137;129592:9;129616;129640:6;129661:12;129688:5;231574:8;;231539:53;;-1:-1:-1;;;;;231539:26:0;;;;231574:8;231585:6;231539:53;:26;:53;:::i;:::-;231603:8;;-1:-1:-1;;;;;231603:8:0;;;;:13;;231623:17;;:15;;;:17::i;:::-;:30;;231652:1;231623:30;;;231643:6;231623:30;231669:9;231693;231717:6;231738:1;231754:12;231781:5;231603:194;;;;;;;;;;;;;-1:-1:-1;;;;;231603:194:0;-1:-1:-1;;;;;231603:194:0;;;;;;-1:-1:-1;;;;;231603:194:0;-1:-1:-1;;;;;231603:194:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;231603:194:0;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;231603:194:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;231603:194:0;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;;;;;;231349:456:0:o;225853:5955::-;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;-1:-1;225853:5955:0;;;-1:-1:-1;;225853:5955:0:o;:::-;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;-1:-1;225853:5955:0;;;-1:-1:-1;;225853:5955:0:o;:::-;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;-1:-1;225853:5955:0;;;-1:-1:-1;;225853:5955:0:o
Swarm Source
bzzr://4716beb8f91925f6e8d1b253b687e8017d19a2b26963dc12104702d3c91b7940
Loading...
Loading
Loading...
Loading
Net Worth in USD
$1.76
Net Worth in ETH
0.000892
Token Allocations
ANY
100.00%
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| BSC | 100.00% | $1.76 | 1 | $1.76 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.