Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
ProportionalLiquidity
Compiler Version
v0.5.15+commit.6a57276f
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2020-10-22 */ // hevm: flattened sources of src/ProportionalLiquidity.sol pragma solidity >0.4.13 >=0.4.23 >=0.5.0 <0.6.0 >=0.5.7 <0.6.0; ////// lib/abdk-libraries-solidity/src/ABDKMath64x64.sol /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ /* pragma solidity ^0.5.7; */ /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /** * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /** * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { return int64 (x >> 64); } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { require (x >= 0); return uint64 (x >> 64); } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { return int256 (x) << 64; } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (x) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { require (x != MIN_64x64); return -x; } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { require (x != MIN_64x64); return x < 0 ? -x : x; } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { return int128 ((int256 (x) + int256 (y)) >> 1); } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m), uint256 (x) + uint256 (y) >> 1)); } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { uint256 absoluteResult; bool negativeResult = false; if (x >= 0) { absoluteResult = powu (uint256 (x) << 63, y); } else { // We rely on overflow behavior here absoluteResult = powu (uint256 (uint128 (-x)) << 63, y); negativeResult = y & 1 > 0; } absoluteResult >>= 63; if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { require (x >= 0); return int128 (sqrtu (uint256 (x) << 64, 0x10000000000000000)); } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (x) << 127 - msb; for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { require (x > 0); return int128 ( uint256 (log_2 (x)) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128); } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= 63 - (x >> 64); require (result <= uint256 (MAX_64x64)); return int128 (result); } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } /** * Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed point * number and y is unsigned 256-bit integer number. Revert on overflow. * * @param x unsigned 129.127-bit fixed point number * @param y uint256 value * @return unsigned 129.127-bit fixed point number */ function powu (uint256 x, uint256 y) private pure returns (uint256) { if (y == 0) return 0x80000000000000000000000000000000; else if (x == 0) return 0; else { int256 msb = 0; uint256 xc = x; if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; } if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 xe = msb - 127; if (xe > 0) x >>= xe; else x <<= -xe; uint256 result = 0x80000000000000000000000000000000; int256 re = 0; while (y > 0) { if (y & 1 > 0) { result = result * x; y -= 1; re += xe; if (result >= 0x8000000000000000000000000000000000000000000000000000000000000000) { result >>= 128; re += 1; } else result >>= 127; if (re < -127) return 0; // Underflow require (re < 128); // Overflow } else { x = x * x; y >>= 1; xe <<= 1; if (x >= 0x8000000000000000000000000000000000000000000000000000000000000000) { x >>= 128; xe += 1; } else x >>= 127; if (xe < -127) return 0; // Underflow require (xe < 128); // Overflow } } if (re > 0) result <<= re; else if (re < 0) result >>= -re; return result; } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x, uint256 r) private pure returns (uint128) { if (x == 0) return 0; else { require (r > 0); while (true) { uint256 rr = x / r; if (r == rr || r + 1 == rr) return uint128 (r); else if (r == rr + 1) return uint128 (rr); r = r + rr + 1 >> 1; } } } } ////// src/interfaces/IAssimilator.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ interface IAssimilator { function intakeRaw (uint256 amount) external returns (int128); function intakeRawAndGetBalance (uint256 amount) external returns (int128, int128); function intakeNumeraire (int128 amount) external returns (uint256); function outputRaw (address dst, uint256 amount) external returns (int128); function outputRawAndGetBalance (address dst, uint256 amount) external returns (int128, int128); function outputNumeraire (address dst, int128 amount) external returns (uint256); function viewRawAmount (int128) external view returns (uint256); function viewNumeraireAmount (uint256) external view returns (int128); function viewNumeraireBalance (address) external view returns (int128); function viewNumeraireAmountAndBalance (address, uint256) external view returns (int128, int128); } ////// src/Assimilators.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./interfaces/IAssimilator.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Assimilators { using ABDKMath64x64 for int128; IAssimilator constant iAsmltr = IAssimilator(address(0)); function delegate(address _callee, bytes memory _data) internal returns (bytes memory) { (bool _success, bytes memory returnData_) = _callee.delegatecall(_data); assembly { if eq(_success, 0) { revert(add(returnData_, 0x20), returndatasize()) } } return returnData_; } function viewRawAmount (address _assim, int128 _amt) internal view returns (uint256 amount_) { amount_ = IAssimilator(_assim).viewRawAmount(_amt); } function viewNumeraireAmount (address _assim, uint256 _amt) internal view returns (int128 amt_) { amt_ = IAssimilator(_assim).viewNumeraireAmount(_amt); } function viewNumeraireAmountAndBalance (address _assim, uint256 _amt) internal view returns (int128 amt_, int128 bal_) { ( amt_, bal_ ) = IAssimilator(_assim).viewNumeraireAmountAndBalance(address(this), _amt); } function viewNumeraireBalance (address _assim) internal view returns (int128 bal_) { bal_ = IAssimilator(_assim).viewNumeraireBalance(address(this)); } function intakeRaw (address _assim, uint256 _amt) internal returns (int128 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRaw.selector, _amt); amt_ = abi.decode(delegate(_assim, data), (int128)); } function intakeRawAndGetBalance (address _assim, uint256 _amt) internal returns (int128 amt_, int128 bal_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRawAndGetBalance.selector, _amt); ( amt_, bal_ ) = abi.decode(delegate(_assim, data), (int128,int128)); } function intakeNumeraire (address _assim, int128 _amt) internal returns (uint256 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeNumeraire.selector, _amt); amt_ = abi.decode(delegate(_assim, data), (uint256)); } function outputRaw (address _assim, address _dst, uint256 _amt) internal returns (int128 amt_ ) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputRaw.selector, _dst, _amt); amt_ = abi.decode(delegate(_assim, data), (int128)); amt_ = amt_.neg(); } function outputRawAndGetBalance (address _assim, address _dst, uint256 _amt) internal returns (int128 amt_, int128 bal_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputRawAndGetBalance.selector, _dst, _amt); ( amt_, bal_ ) = abi.decode(delegate(_assim, data), (int128,int128)); amt_ = amt_.neg(); } function outputNumeraire (address _assim, address _dst, int128 _amt) internal returns (uint256 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputNumeraire.selector, _dst, _amt.abs()); amt_ = abi.decode(delegate(_assim, data), (uint256)); } } ////// src/UnsafeMath64x64.sol /* pragma solidity ^0.5.0; */ library UnsafeMath64x64 { /** * Calculate x * y rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function us_mul (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) * y >> 64; return int128 (result); } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function us_div (int128 x, int128 y) internal pure returns (int128) { int256 result = (int256 (x) << 64) / y; return int128 (result); } } ////// src/PartitionedLiquidity.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./ShellStorage.sol"; */ /* import "./UnsafeMath64x64.sol"; */ library PartitionedLiquidity { using ABDKMath64x64 for uint; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event PoolPartitioned(bool); event PartitionRedeemed(address indexed token, address indexed redeemer, uint value); int128 constant ONE = 0x10000000000000000; function partition ( ShellStorage.Shell storage shell, mapping (address => ShellStorage.PartitionTicket) storage partitionTickets ) external { uint _length = shell.assets.length; ShellStorage.PartitionTicket storage totalSupplyTicket = partitionTickets[address(this)]; totalSupplyTicket.initialized = true; for (uint i = 0; i < _length; i++) totalSupplyTicket.claims.push(shell.totalSupply); emit PoolPartitioned(true); } function viewPartitionClaims ( ShellStorage.Shell storage shell, mapping (address => ShellStorage.PartitionTicket) storage partitionTickets, address _addr ) external view returns ( uint[] memory claims_ ) { ShellStorage.PartitionTicket storage ticket = partitionTickets[_addr]; if (ticket.initialized) return ticket.claims; uint _length = shell.assets.length; uint[] memory claims_ = new uint[](_length); uint _balance = shell.balances[msg.sender]; for (uint i = 0; i < _length; i++) claims_[i] = _balance; return claims_; } function partitionedWithdraw ( ShellStorage.Shell storage shell, mapping (address => ShellStorage.PartitionTicket) storage partitionTickets, address[] calldata _derivatives, uint[] calldata _withdrawals ) external returns ( uint[] memory ) { uint _length = shell.assets.length; uint _balance = shell.balances[msg.sender]; ShellStorage.PartitionTicket storage totalSuppliesTicket = partitionTickets[address(this)]; ShellStorage.PartitionTicket storage ticket = partitionTickets[msg.sender]; if (!ticket.initialized) { for (uint i = 0; i < _length; i++) ticket.claims.push(_balance); ticket.initialized = true; } _length = _derivatives.length; uint[] memory withdrawals_ = new uint[](_length); for (uint i = 0; i < _length; i++) { ShellStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(totalSuppliesTicket.claims[_assim.ix] >= _withdrawals[i], "Shell/burn-exceeds-total-supply"); require(ticket.claims[_assim.ix] >= _withdrawals[i], "Shell/insufficient-balance"); require(_assim.addr != address(0), "Shell/unsupported-asset"); int128 _reserveBalance = Assimilators.viewNumeraireBalance(_assim.addr); int128 _multiplier = _withdrawals[i].divu(1e18) .div(totalSuppliesTicket.claims[_assim.ix].divu(1e18)); totalSuppliesTicket.claims[_assim.ix] = totalSuppliesTicket.claims[_assim.ix] - _withdrawals[i]; ticket.claims[_assim.ix] = ticket.claims[_assim.ix] - _withdrawals[i]; uint _withdrawal = Assimilators.outputNumeraire( _assim.addr, msg.sender, _reserveBalance.mul(_multiplier) ); withdrawals_[i] = _withdrawal; emit PartitionRedeemed(_derivatives[i], msg.sender, withdrawals_[i]); } return withdrawals_; } } ////// src/ProportionalLiquidity.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./ShellStorage.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "./ShellMath.sol"; */ library ProportionalLiquidity { using ABDKMath64x64 for uint; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event Transfer(address indexed from, address indexed to, uint256 value); int128 constant ONE = 0x10000000000000000; int128 constant ONE_WEI = 0x12; function proportionalDeposit ( ShellStorage.Shell storage shell, uint256 _deposit ) external returns ( uint256 shells_, uint[] memory ) { int128 __deposit = _deposit.divu(1e18); uint _length = shell.assets.length; uint[] memory deposits_ = new uint[](_length); ( int128 _oGLiq, int128[] memory _oBals ) = getGrossLiquidityAndBalances(shell); if (_oGLiq == 0) { for (uint i = 0; i < _length; i++) { deposits_[i] = Assimilators.intakeNumeraire(shell.assets[i].addr, __deposit.mul(shell.weights[i])); } } else { int128 _multiplier = __deposit.div(_oGLiq); for (uint i = 0; i < _length; i++) { deposits_[i] = Assimilators.intakeNumeraire(shell.assets[i].addr, _oBals[i].mul(_multiplier)); } } int128 _totalShells = shell.totalSupply.divu(1e18); int128 _newShells = _totalShells > 0 ? __deposit.div(_oGLiq).mul(_totalShells) : __deposit; requireLiquidityInvariant( shell, _totalShells, _newShells, _oGLiq, _oBals ); mint(shell, msg.sender, shells_ = _newShells.mulu(1e18)); return (shells_, deposits_); } function viewProportionalDeposit ( ShellStorage.Shell storage shell, uint256 _deposit ) external view returns ( uint shells_, uint[] memory ) { int128 __deposit = _deposit.divu(1e18); uint _length = shell.assets.length; ( int128 _oGLiq, int128[] memory _oBals ) = getGrossLiquidityAndBalances(shell); uint[] memory deposits_ = new uint[](_length); if (_oGLiq == 0) { for (uint i = 0; i < _length; i++) { deposits_[i] = Assimilators.viewRawAmount( shell.assets[i].addr, __deposit.mul(shell.weights[i]) ); } } else { int128 _multiplier = __deposit.div(_oGLiq); for (uint i = 0; i < _length; i++) { deposits_[i] = Assimilators.viewRawAmount( shell.assets[i].addr, _oBals[i].mul(_multiplier) ); } } int128 _totalShells = shell.totalSupply.divu(1e18); int128 _newShells = _totalShells > 0 ? __deposit.div(_oGLiq).mul(_totalShells) : __deposit; shells_ = _newShells.mulu(1e18); return ( shells_, deposits_ ); } function proportionalWithdraw ( ShellStorage.Shell storage shell, uint256 _withdrawal ) external returns ( uint[] memory ) { uint _length = shell.assets.length; ( int128 _oGLiq, int128[] memory _oBals ) = getGrossLiquidityAndBalances(shell); uint[] memory withdrawals_ = new uint[](_length); int128 _totalShells = shell.totalSupply.divu(1e18); int128 __withdrawal = _withdrawal.divu(1e18); int128 _multiplier = __withdrawal .mul(ONE - shell.epsilon) .div(_totalShells); for (uint i = 0; i < _length; i++) { withdrawals_[i] = Assimilators.outputNumeraire( shell.assets[i].addr, msg.sender, _oBals[i].mul(_multiplier) ); } requireLiquidityInvariant( shell, _totalShells, __withdrawal.neg(), _oGLiq, _oBals ); burn(shell, msg.sender, _withdrawal); return withdrawals_; } function viewProportionalWithdraw ( ShellStorage.Shell storage shell, uint256 _withdrawal ) external view returns ( uint[] memory ) { uint _length = shell.assets.length; ( int128 _oGLiq, int128[] memory _oBals ) = getGrossLiquidityAndBalances(shell); uint[] memory withdrawals_ = new uint[](_length); int128 _multiplier = _withdrawal.divu(1e18) .mul(ONE - shell.epsilon) .div(shell.totalSupply.divu(1e18)); for (uint i = 0; i < _length; i++) { withdrawals_[i] = Assimilators.viewRawAmount(shell.assets[i].addr, _oBals[i].mul(_multiplier)); } return withdrawals_; } function getGrossLiquidityAndBalances ( ShellStorage.Shell storage shell ) internal view returns ( int128 grossLiquidity_, int128[] memory ) { uint _length = shell.assets.length; int128[] memory balances_ = new int128[](_length); for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); balances_[i] = _bal; grossLiquidity_ += _bal; } return (grossLiquidity_, balances_); } function requireLiquidityInvariant ( ShellStorage.Shell storage shell, int128 _shells, int128 _newShells, int128 _oGLiq, int128[] memory _oBals ) private { ( int128 _nGLiq, int128[] memory _nBals ) = getGrossLiquidityAndBalances(shell); int128 _beta = shell.beta; int128 _delta = shell.delta; int128[] memory _weights = shell.weights; int128 _omega = ShellMath.calculateFee(_oGLiq, _oBals, _beta, _delta, _weights); int128 _psi = ShellMath.calculateFee(_nGLiq, _nBals, _beta, _delta, _weights); ShellMath.enforceLiquidityInvariant(_shells, _newShells, _oGLiq, _nGLiq, _omega, _psi); } function burn (ShellStorage.Shell storage shell, address account, uint256 amount) private { shell.balances[account] = burn_sub(shell.balances[account], amount); shell.totalSupply = burn_sub(shell.totalSupply, amount); emit Transfer(msg.sender, address(0), amount); } function mint (ShellStorage.Shell storage shell, address account, uint256 amount) private { shell.totalSupply = mint_add(shell.totalSupply, amount); shell.balances[account] = mint_add(shell.balances[account], amount); emit Transfer(address(0), msg.sender, amount); } function mint_add(uint x, uint y) private pure returns (uint z) { require((z = x + y) >= x, "Shell/mint-overflow"); } function burn_sub(uint x, uint y) private pure returns (uint z) { require((z = x - y) <= x, "Shell/burn-underflow"); } } ////// src/SelectiveLiquidity.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./ShellStorage.sol"; */ /* import "./ShellMath.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library SelectiveLiquidity { using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event Transfer(address indexed from, address indexed to, uint256 value); int128 constant ONE = 0x10000000000000000; function selectiveDeposit ( ShellStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts, uint _minShells ) external returns ( uint shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = getLiquidityDepositData(shell, _derivatives, _amounts); int128 _shells = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); shells_ = _shells.mulu(1e18); require(_minShells < shells_, "Shell/under-minimum-shells"); mint(shell, msg.sender, shells_); } function viewSelectiveDeposit ( ShellStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts ) external view returns ( uint shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = viewLiquidityDepositData(shell, _derivatives, _amounts); int128 _shells = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); shells_ = _shells.mulu(1e18); } function selectiveWithdraw ( ShellStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts, uint _maxShells ) external returns ( uint256 shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = getLiquidityWithdrawData(shell, _derivatives, msg.sender, _amounts); int128 _shells = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); _shells = _shells.neg().us_mul(ONE + shell.epsilon); shells_ = _shells.mulu(1e18); require(shells_ < _maxShells, "Shell/above-maximum-shells"); burn(shell, msg.sender, shells_); } function viewSelectiveWithdraw ( ShellStorage.Shell storage shell, address[] calldata _derivatives, uint[] calldata _amounts ) external view returns ( uint shells_ ) { ( int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = viewLiquidityWithdrawData(shell, _derivatives, _amounts); int128 _shells = ShellMath.calculateLiquidityMembrane(shell, _oGLiq, _nGLiq, _oBals, _nBals); _shells = _shells.neg().us_mul(ONE + shell.epsilon); shells_ = _shells.mulu(1e18); } function getLiquidityDepositData ( ShellStorage.Shell storage shell, address[] memory _derivatives, uint[] memory _amounts ) private returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.weights.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { ShellStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && 0 == oBals_[_assim.ix]) { ( int128 _amount, int128 _balance ) = Assimilators.intakeRawAndGetBalance(_assim.addr, _amounts[i]); nBals_[_assim.ix] = _balance; oBals_[_assim.ix] = _balance.sub(_amount); } else { int128 _amount = Assimilators.intakeRaw(_assim.addr, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].add(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function getLiquidityWithdrawData ( ShellStorage.Shell storage shell, address[] memory _derivatives, address _rcpnt, uint[] memory _amounts ) private returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.weights.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { ShellStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && 0 == oBals_[_assim.ix]) { ( int128 _amount, int128 _balance ) = Assimilators.outputRawAndGetBalance(_assim.addr, _rcpnt, _amounts[i]); nBals_[_assim.ix] = _balance; oBals_[_assim.ix] = _balance.sub(_amount); } else { int128 _amount = Assimilators.outputRaw(_assim.addr, _rcpnt, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].add(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function viewLiquidityDepositData ( ShellStorage.Shell storage shell, address[] memory _derivatives, uint[] memory _amounts ) private view returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { ShellStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && 0 == oBals_[_assim.ix]) { ( int128 _amount, int128 _balance ) = Assimilators.viewNumeraireAmountAndBalance(_assim.addr, _amounts[i]); nBals_[_assim.ix] = _balance.add(_amount); oBals_[_assim.ix] = _balance; } else { int128 _amount = Assimilators.viewNumeraireAmount(_assim.addr, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].add(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function viewLiquidityWithdrawData ( ShellStorage.Shell storage shell, address[] memory _derivatives, uint[] memory _amounts ) private view returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); for (uint i = 0; i < _derivatives.length; i++) { ShellStorage.Assimilator memory _assim = shell.assimilators[_derivatives[i]]; require(_assim.addr != address(0), "Shell/unsupported-derivative"); if ( nBals_[_assim.ix] == 0 && 0 == oBals_[_assim.ix]) { ( int128 _amount, int128 _balance ) = Assimilators.viewNumeraireAmountAndBalance(_assim.addr, _amounts[i]); nBals_[_assim.ix] = _balance.sub(_amount); oBals_[_assim.ix] = _balance; } else { int128 _amount = Assimilators.viewNumeraireAmount(_assim.addr, _amounts[i]); nBals_[_assim.ix] = nBals_[_assim.ix].sub(_amount); } } return completeLiquidityData(shell, oBals_, nBals_); } function completeLiquidityData ( ShellStorage.Shell storage shell, int128[] memory oBals_, int128[] memory nBals_ ) private view returns ( int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = oBals_.length; for (uint i = 0; i < _length; i++) { if (oBals_[i] == 0 && 0 == nBals_[i]) { nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(shell.assets[i].addr); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } return ( oGLiq_, nGLiq_, oBals_, nBals_ ); } function burn (ShellStorage.Shell storage shell, address account, uint256 amount) private { shell.balances[account] = burn_sub(shell.balances[account], amount); shell.totalSupply = burn_sub(shell.totalSupply, amount); emit Transfer(msg.sender, address(0), amount); } function mint (ShellStorage.Shell storage shell, address account, uint256 amount) private { shell.totalSupply = mint_add(shell.totalSupply, amount); shell.balances[account] = mint_add(shell.balances[account], amount); emit Transfer(address(0), msg.sender, amount); } function mint_add(uint x, uint y) private pure returns (uint z) { require((z = x + y) >= x, "Shell/mint-overflow"); } function burn_sub(uint x, uint y) private pure returns (uint z) { require((z = x - y) <= x, "Shell/burn-underflow"); } } ////// src/Shells.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./ShellStorage.sol"; */ /* import "./Assimilators.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Shells { using ABDKMath64x64 for int128; event Approval(address indexed _owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function add(uint x, uint y, string memory errorMessage) private pure returns (uint z) { require((z = x + y) >= x, errorMessage); } function sub(uint x, uint y, string memory errorMessage) private pure returns (uint z) { require((z = x - y) <= x, errorMessage); } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(ShellStorage.Shell storage shell, address recipient, uint256 amount) external returns (bool) { _transfer(shell, msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(ShellStorage.Shell storage shell, address spender, uint256 amount) external returns (bool) { _approve(shell, msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount` */ function transferFrom(ShellStorage.Shell storage shell, address sender, address recipient, uint256 amount) external returns (bool) { _transfer(shell, msg.sender, recipient, amount); _approve(shell, sender, msg.sender, sub(shell.allowances[sender][msg.sender], amount, "Shell/insufficient-allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(ShellStorage.Shell storage shell, address spender, uint256 addedValue) external returns (bool) { _approve(shell, msg.sender, spender, add(shell.allowances[msg.sender][spender], addedValue, "Shell/approval-overflow")); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(ShellStorage.Shell storage shell, address spender, uint256 subtractedValue) external returns (bool) { _approve(shell, msg.sender, spender, sub(shell.allowances[msg.sender][spender], subtractedValue, "Shell/allowance-decrease-underflow")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is public function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(ShellStorage.Shell storage shell, address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); shell.balances[sender] = sub(shell.balances[sender], amount, "Shell/insufficient-balance"); shell.balances[recipient] = add(shell.balances[recipient], amount, "Shell/transfer-overflow"); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `_owner`s tokens. * * This is public function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `_owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(ShellStorage.Shell storage shell, address _owner, address spender, uint256 amount) private { require(_owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); shell.allowances[_owner][spender] = amount; emit Approval(_owner, spender, amount); } } ////// src/Swaps.sol /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./ShellStorage.sol"; */ /* import "./ShellMath.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Swaps { using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; event Trade(address indexed trader, address indexed origin, address indexed target, uint256 originAmount, uint256 targetAmount); int128 constant ONE = 0x10000000000000000; function getOriginAndTarget ( ShellStorage.Shell storage shell, address _o, address _t ) private view returns ( ShellStorage.Assimilator memory, ShellStorage.Assimilator memory ) { ShellStorage.Assimilator memory o_ = shell.assimilators[_o]; ShellStorage.Assimilator memory t_ = shell.assimilators[_t]; require(o_.addr != address(0), "Shell/origin-not-supported"); require(t_.addr != address(0), "Shell/target-not-supported"); return ( o_, t_ ); } function originSwap ( ShellStorage.Shell storage shell, address _origin, address _target, uint256 _originAmount, address _recipient ) external returns ( uint256 tAmt_ ) { ( ShellStorage.Assimilator memory _o, ShellStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.outputNumeraire(_t.addr, _recipient, Assimilators.intakeRaw(_o.addr, _originAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) = getOriginSwapData(shell, _o.ix, _t.ix, _o.addr, _originAmount); _amt = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix); _amt = _amt.us_mul(ONE - shell.epsilon); tAmt_ = Assimilators.outputNumeraire(_t.addr, _recipient, _amt); emit Trade(msg.sender, _origin, _target, _originAmount, tAmt_); } function viewOriginSwap ( ShellStorage.Shell storage shell, address _origin, address _target, uint256 _originAmount ) external view returns ( uint256 tAmt_ ) { ( ShellStorage.Assimilator memory _o, ShellStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.viewRawAmount(_t.addr, Assimilators.viewNumeraireAmount(_o.addr, _originAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals ) = viewOriginSwapData(shell, _o.ix, _t.ix, _originAmount, _o.addr); _amt = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix); _amt = _amt.us_mul(ONE - shell.epsilon); tAmt_ = Assimilators.viewRawAmount(_t.addr, _amt.abs()); } function targetSwap ( ShellStorage.Shell storage shell, address _origin, address _target, uint256 _targetAmount, address _recipient ) external returns ( uint256 oAmt_ ) { ( ShellStorage.Assimilator memory _o, ShellStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.intakeNumeraire(_o.addr, Assimilators.outputRaw(_t.addr, _recipient, _targetAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals) = getTargetSwapData(shell, _t.ix, _o.ix, _t.addr, _recipient, _targetAmount); _amt = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix); _amt = _amt.us_mul(ONE + shell.epsilon); oAmt_ = Assimilators.intakeNumeraire(_o.addr, _amt); emit Trade(msg.sender, _origin, _target, oAmt_, _targetAmount); } function viewTargetSwap ( ShellStorage.Shell storage shell, address _origin, address _target, uint256 _targetAmount ) external view returns ( uint256 oAmt_ ) { ( ShellStorage.Assimilator memory _o, ShellStorage.Assimilator memory _t ) = getOriginAndTarget(shell, _origin, _target); if (_o.ix == _t.ix) return Assimilators.viewRawAmount(_o.addr, Assimilators.viewNumeraireAmount(_t.addr, _targetAmount)); ( int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals ) = viewTargetSwapData(shell, _t.ix, _o.ix, _targetAmount, _t.addr); _amt = ShellMath.calculateTrade(shell, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix); _amt = _amt.us_mul(ONE + shell.epsilon); oAmt_ = Assimilators.viewRawAmount(_o.addr, _amt); } function getOriginSwapData ( ShellStorage.Shell storage shell, uint _inputIx, uint _outputIx, address _assim, uint _amt ) private returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); ShellStorage.Assimilator[] memory _reserves = shell.assets; for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.intakeRawAndGetBalance(_assim, _amt); oBals_[i] = _bal.sub(amt_); nBals_[i] = _bal; } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return ( amt_, oGLiq_, nGLiq_, oBals_, nBals_ ); } function getTargetSwapData ( ShellStorage.Shell storage shell, uint _inputIx, uint _outputIx, address _assim, address _recipient, uint _amt ) private returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); ShellStorage.Assimilator[] memory _reserves = shell.assets; for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.outputRawAndGetBalance(_assim, _recipient, _amt); oBals_[i] = _bal.sub(amt_); nBals_[i] = _bal; } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return ( amt_, oGLiq_, nGLiq_, oBals_, nBals_ ); } function viewOriginSwapData ( ShellStorage.Shell storage shell, uint _inputIx, uint _outputIx, uint _amt, address _assim ) private view returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory nBals_ = new int128[](_length); int128[] memory oBals_ = new int128[](_length); for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(shell.assets[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt); oBals_[i] = _bal; nBals_[i] = _bal.add(amt_); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return ( amt_, oGLiq_, nGLiq_, nBals_, oBals_ ); } function viewTargetSwapData ( ShellStorage.Shell storage shell, uint _inputIx, uint _outputIx, uint _amt, address _assim ) private view returns ( int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory ) { uint _length = shell.assets.length; int128[] memory nBals_ = new int128[](_length); int128[] memory oBals_ = new int128[](_length); for (uint i = 0; i < _length; i++) { if (i != _inputIx) nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(shell.assets[i].addr); else { int128 _bal; ( amt_, _bal ) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt); amt_ = amt_.neg(); oBals_[i] = _bal; nBals_[i] = _bal.add(amt_); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return ( amt_, oGLiq_, nGLiq_, nBals_, oBals_ ); } } ////// src/ViewLiquidity.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./ShellStorage.sol"; */ /* import "./Assimilators.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library ViewLiquidity { using ABDKMath64x64 for int128; function viewLiquidity ( ShellStorage.Shell storage shell ) external view returns ( uint total_, uint[] memory individual_ ) { uint _length = shell.assets.length; uint[] memory individual_ = new uint[](_length); uint total_; for (uint i = 0; i < _length; i++) { uint _liquidity = Assimilators.viewNumeraireBalance(shell.assets[i].addr).mulu(1e18); total_ += _liquidity; individual_[i] = _liquidity; } return (total_, individual_); } } ////// src/ShellStorage.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ /* import "./Orchestrator.sol"; */ /* import "./PartitionedLiquidity.sol"; */ /* import "./ProportionalLiquidity.sol"; */ /* import "./SelectiveLiquidity.sol"; */ /* import "./Shells.sol"; */ /* import "./Swaps.sol"; */ /* import "./ViewLiquidity.sol"; */ contract ShellStorage { address public owner; string public constant name = "Shells"; string public constant symbol = "SHL"; uint8 public constant decimals = 18; Shell public shell; struct Shell { int128 alpha; int128 beta; int128 delta; int128 epsilon; int128 lambda; int128[] weights; uint totalSupply; Assimilator[] assets; mapping (address => Assimilator) assimilators; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowances; } struct Assimilator { address addr; uint8 ix; } mapping (address => PartitionTicket) public partitionTickets; struct PartitionTicket { uint[] claims; bool initialized; } address[] public derivatives; address[] public numeraires; address[] public reserves; bool public partitioned = false; bool public frozen = false; bool internal notEntered = true; } ////// src/ShellMath.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./UnsafeMath64x64.sol"; */ /* import "./ShellStorage.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library ShellMath { int128 constant ONE = 0x10000000000000000; int128 constant MAX = 0x4000000000000000; // .25 in layman's terms int128 constant MAX_DIFF = -0x10C6F7A0B5EE; int128 constant ONE_WEI = 0x12; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; using ABDKMath64x64 for uint256; function calculateFee ( int128 _gLiq, int128[] memory _bals, int128 _beta, int128 _delta, int128[] memory _weights ) internal pure returns (int128 psi_) { uint _length = _bals.length; for (uint i = 0; i < _length; i++) { int128 _ideal = _gLiq.us_mul(_weights[i]); psi_ += calculateMicroFee(_bals[i], _ideal, _beta, _delta); } } function calculateMicroFee ( int128 _bal, int128 _ideal, int128 _beta, int128 _delta ) private pure returns (int128 fee_) { if (_bal < _ideal) { int128 _threshold = _ideal.us_mul(ONE - _beta); if (_bal < _threshold) { int128 _feeMargin = _threshold - _bal; fee_ = _feeMargin.us_div(_ideal); fee_ = fee_.us_mul(_delta); if (fee_ > MAX) fee_ = MAX; fee_ = fee_.us_mul(_feeMargin); } else fee_ = 0; } else { int128 _threshold = _ideal.us_mul(ONE + _beta); if (_bal > _threshold) { int128 _feeMargin = _bal - _threshold; fee_ = _feeMargin.us_div(_ideal); fee_ = fee_.us_mul(_delta); if (fee_ > MAX) fee_ = MAX; fee_ = fee_.us_mul(_feeMargin); } else fee_ = 0; } } function calculateTrade ( ShellStorage.Shell storage shell, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals, int128 _inputAmt, uint _outputIndex ) internal view returns (int128 outputAmt_) { outputAmt_ = - _inputAmt; int128 _lambda = shell.lambda; int128 _beta = shell.beta; int128 _delta = shell.delta; int128[] memory _weights = shell.weights; int128 _omega = calculateFee(_oGLiq, _oBals, _beta, _delta, _weights); int128 _psi; for (uint i = 0; i < 32; i++) { _psi = calculateFee(_nGLiq, _nBals, _beta, _delta, _weights); if (( outputAmt_ = _omega < _psi ? - ( _inputAmt + _omega - _psi ) : - ( _inputAmt + _lambda.us_mul(_omega - _psi) ) ) / 1e13 == outputAmt_ / 1e13 ) { _nGLiq = _oGLiq + _inputAmt + outputAmt_; _nBals[_outputIndex] = _oBals[_outputIndex] + outputAmt_; enforceHalts(shell, _oGLiq, _nGLiq, _oBals, _nBals, _weights); enforceSwapInvariant(_oGLiq, _omega, _nGLiq, _psi); return outputAmt_; } else { _nGLiq = _oGLiq + _inputAmt + outputAmt_; _nBals[_outputIndex] = _oBals[_outputIndex].add(outputAmt_); } } revert("Shell/swap-convergence-failed"); } function enforceSwapInvariant ( int128 _oGLiq, int128 _omega, int128 _nGLiq, int128 _psi ) private pure { int128 _nextUtil = _nGLiq - _psi; int128 _prevUtil = _oGLiq - _omega; int128 _diff = _nextUtil - _prevUtil; require(0 < _diff || _diff >= MAX_DIFF, "Shell/swap-invariant-violation"); } function calculateLiquidityMembrane ( ShellStorage.Shell storage shell, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) internal view returns (int128 shells_) { enforceHalts(shell, _oGLiq, _nGLiq, _oBals, _nBals, shell.weights); int128 _omega; int128 _psi; { int128 _beta = shell.beta; int128 _delta = shell.delta; int128[] memory _weights = shell.weights; _omega = calculateFee(_oGLiq, _oBals, _beta, _delta, _weights); _psi = calculateFee(_nGLiq, _nBals, _beta, _delta, _weights); } int128 _feeDiff = _psi.sub(_omega); int128 _liqDiff = _nGLiq.sub(_oGLiq); int128 _oUtil = _oGLiq.sub(_omega); int128 _totalShells = shell.totalSupply.divu(1e18); int128 _shellMultiplier; if (_totalShells == 0) { shells_ = _nGLiq.sub(_psi); } else if (_feeDiff >= 0) { _shellMultiplier = _liqDiff.sub(_feeDiff).div(_oUtil); } else { _shellMultiplier = _liqDiff.sub(shell.lambda.mul(_feeDiff)); _shellMultiplier = _shellMultiplier.div(_oUtil); } if (_totalShells != 0) { shells_ = _totalShells.us_mul(_shellMultiplier); enforceLiquidityInvariant(_totalShells, shells_, _oGLiq, _nGLiq, _omega, _psi); } } function enforceLiquidityInvariant ( int128 _totalShells, int128 _newShells, int128 _oGLiq, int128 _nGLiq, int128 _omega, int128 _psi ) internal view { if (_totalShells == 0 || 0 == _totalShells + _newShells) return; int128 _prevUtilPerShell = _oGLiq .sub(_omega) .div(_totalShells); int128 _nextUtilPerShell = _nGLiq .sub(_psi) .div(_totalShells.add(_newShells)); int128 _diff = _nextUtilPerShell - _prevUtilPerShell; require(0 < _diff || _diff >= MAX_DIFF, "Shell/liquidity-invariant-violation"); } function enforceHalts ( ShellStorage.Shell storage shell, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals, int128[] memory _weights ) private view { uint256 _length = _nBals.length; int128 _alpha = shell.alpha; for (uint i = 0; i < _length; i++) { int128 _nIdeal = _nGLiq.us_mul(_weights[i]); if (_nBals[i] > _nIdeal) { int128 _upperAlpha = ONE + _alpha; int128 _nHalt = _nIdeal.us_mul(_upperAlpha); if (_nBals[i] > _nHalt){ int128 _oHalt = _oGLiq.us_mul(_weights[i]).us_mul(_upperAlpha); if (_oBals[i] < _oHalt) revert("Shell/upper-halt"); if (_nBals[i] - _nHalt > _oBals[i] - _oHalt) revert("Shell/upper-halt"); } } else { int128 _lowerAlpha = ONE - _alpha; int128 _nHalt = _nIdeal.us_mul(_lowerAlpha); if (_nBals[i] < _nHalt){ int128 _oHalt = _oGLiq.us_mul(_weights[i]).us_mul(_lowerAlpha); if (_oBals[i] > _oHalt) revert("Shell/lower-halt"); if (_nHalt - _nBals[i] > _oHalt - _oBals[i]) revert("Shell/lower-halt"); } } } } } ////// src/Orchestrator.sol // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. /* pragma solidity ^0.5.0; */ /* import "./Assimilators.sol"; */ /* import "./ShellMath.sol"; */ /* import "./ShellStorage.sol"; */ /* import "abdk-libraries-solidity/ABDKMath64x64.sol"; */ library Orchestrator { using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; int128 constant ONE_WEI = 0x12; event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda); event AssetIncluded(address indexed numeraire, address indexed reserve, uint weight); event AssimilatorIncluded(address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator); function setParams ( ShellStorage.Shell storage shell, uint256 _alpha, uint256 _beta, uint256 _feeAtHalt, uint256 _epsilon, uint256 _lambda ) external { require(0 < _alpha && _alpha < 1e18, "Shell/parameter-invalid-alpha"); require(0 <= _beta && _beta < _alpha, "Shell/parameter-invalid-beta"); require(_feeAtHalt <= .5e18, "Shell/parameter-invalid-max"); require(0 <= _epsilon && _epsilon <= .01e18, "Shell/parameter-invalid-epsilon"); require(0 <= _lambda && _lambda <= 1e18, "Shell/parameter-invalid-lambda"); int128 _omega = getFee(shell); shell.alpha = (_alpha + 1).divu(1e18); shell.beta = (_beta + 1).divu(1e18); shell.delta = ( _feeAtHalt ).divu(1e18).div(uint(2).fromUInt().mul(shell.alpha.sub(shell.beta))) + ONE_WEI; shell.epsilon = (_epsilon + 1).divu(1e18); shell.lambda = (_lambda + 1).divu(1e18); int128 _psi = getFee(shell); require(_omega >= _psi, "Shell/parameters-increase-fee"); emit ParametersSet(_alpha, _beta, shell.delta.mulu(1e18), _epsilon, _lambda); } function getFee ( ShellStorage.Shell storage shell ) private view returns ( int128 fee_ ) { int128 _gLiq; int128[] memory _bals = new int128[](shell.assets.length); for (uint i = 0; i < _bals.length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _bals[i] = _bal; _gLiq += _bal; } fee_ = ShellMath.calculateFee(_gLiq, _bals, shell.beta, shell.delta, shell.weights); } function initialize ( ShellStorage.Shell storage shell, address[] storage numeraires, address[] storage reserves, address[] storage derivatives, address[] calldata _assets, uint[] calldata _assetWeights, address[] calldata _derivativeAssimilators ) external { for (uint i = 0; i < _assetWeights.length; i++) { uint ix = i*5; numeraires.push(_assets[ix]); derivatives.push(_assets[ix]); reserves.push(_assets[2+ix]); if (_assets[ix] != _assets[2+ix]) derivatives.push(_assets[2+ix]); includeAsset( shell, _assets[ix], // numeraire _assets[1+ix], // numeraire assimilator _assets[2+ix], // reserve _assets[3+ix], // reserve assimilator _assets[4+ix], // reserve approve to _assetWeights[i] ); } for (uint i = 0; i < _derivativeAssimilators.length / 5; i++) { uint ix = i * 5; derivatives.push(_derivativeAssimilators[ix]); includeAssimilator( shell, _derivativeAssimilators[ix], // derivative _derivativeAssimilators[1+ix], // numeraire _derivativeAssimilators[2+ix], // reserve _derivativeAssimilators[3+ix], // assimilator _derivativeAssimilators[4+ix] // derivative approve to ); } } function includeAsset ( ShellStorage.Shell storage shell, address _numeraire, address _numeraireAssim, address _reserve, address _reserveAssim, address _reserveApproveTo, uint256 _weight ) private { require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-adress"); require(_numeraireAssim != address(0), "Shell/numeraire-assimilator-cannot-be-zeroth-adress"); require(_reserve != address(0), "Shell/reserve-cannot-be-zeroth-adress"); require(_reserveAssim != address(0), "Shell/reserve-assimilator-cannot-be-zeroth-adress"); require(_weight < 1e18, "Shell/weight-must-be-less-than-one"); if (_numeraire != _reserve) safeApprove(_numeraire, _reserveApproveTo, uint(-1)); ShellStorage.Assimilator storage _numeraireAssimilator = shell.assimilators[_numeraire]; _numeraireAssimilator.addr = _numeraireAssim; _numeraireAssimilator.ix = uint8(shell.assets.length); ShellStorage.Assimilator storage _reserveAssimilator = shell.assimilators[_reserve]; _reserveAssimilator.addr = _reserveAssim; _reserveAssimilator.ix = uint8(shell.assets.length); int128 __weight = _weight.divu(1e18).add(uint256(1).divu(1e18)); shell.weights.push(__weight); shell.assets.push(_numeraireAssimilator); emit AssetIncluded(_numeraire, _reserve, _weight); emit AssimilatorIncluded(_numeraire, _numeraire, _reserve, _numeraireAssim); if (_numeraireAssim != _reserveAssim) { emit AssimilatorIncluded(_reserve, _numeraire, _reserve, _reserveAssim); } } function includeAssimilator ( ShellStorage.Shell storage shell, address _derivative, address _numeraire, address _reserve, address _assimilator, address _derivativeApproveTo ) private { require(_derivative != address(0), "Shell/derivative-cannot-be-zeroth-address"); require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_reserve != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_assimilator != address(0), "Shell/assimilator-cannot-be-zeroth-address"); safeApprove(_numeraire, _derivativeApproveTo, uint(-1)); ShellStorage.Assimilator storage _numeraireAssim = shell.assimilators[_numeraire]; shell.assimilators[_derivative] = ShellStorage.Assimilator(_assimilator, _numeraireAssim.ix); emit AssimilatorIncluded(_derivative, _numeraire, _reserve, _assimilator); } function safeApprove ( address _token, address _spender, uint256 _value ) private { ( bool success, bytes memory returndata ) = _token.call(abi.encodeWithSignature("approve(address,uint256)", _spender, _value)); require(success, "SafeERC20: low-level call failed"); } function viewShell ( ShellStorage.Shell storage shell ) external view returns ( uint alpha_, uint beta_, uint delta_, uint epsilon_, uint lambda_ ) { alpha_ = shell.alpha.mulu(1e18); beta_ = shell.beta.mulu(1e18); delta_ = shell.delta.mulu(1e18); epsilon_ = shell.epsilon.mulu(1e18); lambda_ = shell.lambda.mulu(1e18); } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]
Contract Creation Code
611d50610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c806318e581fa1461005b5780633da94035146100e8578063a48b9c6314610189578063b47b942b14610223575b600080fd5b6100916004803603604081101561007157600080fd5b8101908080359060200190929190803590602001909291905050506102b7565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100d45780820151818401526020810190506100b9565b505050509050019250505060405180910390f35b8180156100f457600080fd5b5061012b6004803603604081101561010b57600080fd5b81019080803590602001909291908035906020019092919050505061043d565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015610174578082015181840152602081019050610159565b50505050905001935050505060405180910390f35b81801561019557600080fd5b506101cc600480360360408110156101ac57600080fd5b8101908080359060200190929190803590602001909291905050506106ef565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561020f5780820151818401526020810190506101f4565b505050509050019250505060405180910390f35b6102596004803603604081101561023957600080fd5b8101908080359060200190929190803590602001909291905050506108a5565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156102a2578082015181840152602081019050610287565b50505050905001935050505060405180910390f35b6060600083600501805490509050600060606102d286610b3f565b915091506060836040519080825280602002602001820160405280156103075781602001602082028038833980820191505090505b509050600061038b61032e670de0b6b3a76400008a60040154610c1c90919063ffffffff16565b61037a8a60010160109054906101000a9004600f0b6801000000000000000003610369670de0b6b3a76400008c610c1c90919063ffffffff16565b600f0b610c8490919063ffffffff16565b600f0b610cef90919063ffffffff16565b905060008090505b8581101561042e576104098960050182815481106103ad57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610404848785815181106103eb57fe5b6020026020010151600f0b610c8490919063ffffffff16565b610d72565b83828151811061041557fe5b6020026020010181815250508080600101915050610393565b50819550505050505092915050565b60006060600061045e670de0b6b3a764000085610c1c90919063ffffffff16565b905060008560050180549050905060608160405190808252806020026020018201604052801561049d5781602001602082028038833980820191505090505b509050600060606104ad89610b3f565b91509150600082600f0b14156105825760008090505b8481101561057c576105578a60050182815481106104dd57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166105528c600301848154811061051d57fe5b90600052602060002090600291828204019190066010029054906101000a9004600f0b89600f0b610c8490919063ffffffff16565b610e0e565b84828151811061056357fe5b60200260200101818152505080806001019150506104c3565b50610640565b600061059a8387600f0b610cef90919063ffffffff16565b905060008090505b8581101561063d576106188b60050182815481106105bc57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610613848685815181106105fa57fe5b6020026020010151600f0b610c8490919063ffffffff16565b610e0e565b85828151811061062457fe5b60200260200101818152505080806001019150506105a2565b50505b6000610661670de0b6b3a76400008b60040154610c1c90919063ffffffff16565b905060008082600f0b1361067557866106a1565b6106a08261068f868a600f0b610cef90919063ffffffff16565b600f0b610c8490919063ffffffff16565b5b90506106b08b83838787610ee2565b6106db8b336106d3670de0b6b3a764000085600f0b610fda90919063ffffffff16565b9b508b611095565b888598509850505050505050509250929050565b60606000836005018054905090506000606061070a86610b3f565b9150915060608360405190808252806020026020018201604052801561073f5781602001602082028038833980820191505090505b5090506000610763670de0b6b3a76400008960040154610c1c90919063ffffffff16565b90506000610782670de0b6b3a764000089610c1c90919063ffffffff16565b905060006107cd836107bc8c60010160109054906101000a9004600f0b680100000000000000000385600f0b610c8490919063ffffffff16565b600f0b610cef90919063ffffffff16565b905060008090505b878110156108715761084c8b60050182815481106107ef57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633610847858a868151811061082e57fe5b6020026020010151600f0b610c8490919063ffffffff16565b6111a6565b85828151811061085857fe5b60200260200101818152505080806001019150506107d5565b5061088a8a8461088385600f0b6112ba565b8989610ee2565b6108958a338b6112fa565b8397505050505050505092915050565b6000606060006108c6670de0b6b3a764000085610c1c90919063ffffffff16565b9050600085600501805490509050600060606108e188610b3f565b915091506060836040519080825280602002602001820160405280156109165781602001602082028038833980820191505090505b509050600083600f0b14156109ea5760008090505b848110156109e4576109bf8a600501828154811061094557fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166109ba8c600301848154811061098557fe5b90600052602060002090600291828204019190066010029054906101000a9004600f0b89600f0b610c8490919063ffffffff16565b610d72565b8282815181106109cb57fe5b602002602001018181525050808060010191505061092b565b50610aa8565b6000610a028487600f0b610cef90919063ffffffff16565b905060008090505b85811015610aa557610a808b6005018281548110610a2457fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610a7b84878581518110610a6257fe5b6020026020010151600f0b610c8490919063ffffffff16565b610d72565b838281518110610a8c57fe5b6020026020010181815250508080600101915050610a0a565b50505b6000610ac9670de0b6b3a76400008b60040154610c1c90919063ffffffff16565b905060008082600f0b13610add5786610b09565b610b0882610af7878a600f0b610cef90919063ffffffff16565b600f0b610c8490919063ffffffff16565b5b9050610b29670de0b6b3a764000082600f0b610fda90919063ffffffff16565b9850888398509850505050505050509250929050565b60006060600083600501805490509050606081604051908082528060200260200182016040528015610b805781602001602082028038833980820191505090505b50905060008090505b82811015610c0e576000610bd8876005018381548110610ba557fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661140b565b905080838381518110610be757fe5b6020026020010190600f0b9081600f0b815250508086019550508080600101915050610b89565b508381935093505050915091565b600080821415610c2b57600080fd5b6000610c3784846114cc565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff16816fffffffffffffffffffffffffffffffff161115610c7a57600080fd5b8091505092915050565b600080604083600f0b85600f0b02901d90507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015610cdc57506f7fffffffffffffffffffffffffffffff600f0b8113155b610ce557600080fd5b8091505092915050565b60008082600f0b1415610d0157600080fd5b600082600f0b604085600f0b901b81610d1657fe5b0590507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015610d5f57506f7fffffffffffffffffffffffffffffff600f0b8113155b610d6857600080fd5b8091505092915050565b60008273ffffffffffffffffffffffffffffffffffffffff16636b677a8f836040518263ffffffff1660e01b81526004018082600f0b600f0b815260200191505060206040518083038186803b158015610dcb57600080fd5b505afa158015610ddf573d6000803e3d6000fd5b505050506040513d6020811015610df557600080fd5b8101908080519060200190929190505050905092915050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16630271c3c8905060e01b836040516024018082600f0b600f0b8152602001915050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050610eb4848261168d565b8060200190516020811015610ec857600080fd5b810190808051906020019092919050505091505092915050565b60006060610eef87610b3f565b9150915060008760000160109054906101000a9004600f0b905060008860010160009054906101000a9004600f0b9050606089600301805480602002602001604051908101604052809291908181526020018280548015610f9557602002820191906000526020600020906000905b82829054906101000a9004600f0b600f0b81526020019060100190602082600f01049283019260010382029150808411610f5e5790505b505050505090506000610fab8888868686611763565b90506000610fbc8787878787611763565b9050610fcc8b8b8b8a86866117e1565b505050505050505050505050565b600080821415610fed576000905061108f565b600083600f0b1215610ffe57600080fd5b600060406fffffffffffffffffffffffffffffffff841685600f0b02901c90506000608084901c85600f0b02905077ffffffffffffffffffffffffffffffffffffffffffffffff81111561105157600080fd5b604081901b9050817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0381111561108757600080fd5b818101925050505b92915050565b6110a3836004015482611915565b83600401819055506110f68360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611915565b8360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16636fc39052905060e01b846111d985600f0b611998565b604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182600f0b600f0b815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905061128b858261168d565b806020019051602081101561129f57600080fd5b81019080805190602001909291905050509150509392505050565b60007fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b82600f0b14156112ef57600080fd5b816000039050919050565b6113458360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826119ea565b8360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113988360040154826119ea565b8360040181905550600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008173ffffffffffffffffffffffffffffffffffffffff1663ac969a73306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561148a57600080fd5b505afa15801561149e573d6000803e3d6000fd5b505050506040513d60208110156114b457600080fd5b81019080805190602001909291905050509050919050565b6000808214156114db57600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff84116115115782604085901b8161150957fe5b049050611666565b600060c09050600060c086901c9050640100000000811061153a57602081901c90506020820191505b62010000811061155257601081901c90506010820191505b610100811061156957600881901c90506008820191505b6010811061157f57600481901c90506004820191505b6004811061159557600281901c90506002820191505b600281106115a4576001820191505b600160bf830360018703901c018260ff0387901b816115bf57fe5b0492506fffffffffffffffffffffffffffffffff8311156115df57600080fd5b6000608086901c8402905060006fffffffffffffffffffffffffffffffff871685029050600060c089901c9050600060408a901b905082811015611624576001820391505b8281039050608084901b92508281101561163f576001820391505b8281039050608084901c821461165157fe5b88818161165a57fe5b04870196505050505050505b6fffffffffffffffffffffffffffffffff81111561168357600080fd5b8091505092915050565b6060600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b602083106116de57805182526020820191506020810190506020830392506116bb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461173e576040519150601f19603f3d011682016040523d82523d6000602084013e611743565b606091505b50915091506000821415611758573d60208201fd5b809250505092915050565b6000808551905060008090505b818110156117d65760006117a385838151811061178957fe5b60200260200101518a600f0b611a6d90919063ffffffff16565b90506117c48883815181106117b457fe5b6020026020010151828989611a89565b84019350508080600101915050611770565b505095945050505050565b600086600f0b14806117f85750848601600f0b6000145b156118025761190d565b600061182f8761181e8588600f0b611c0790919063ffffffff16565b600f0b610cef90919063ffffffff16565b9050600061187361184c888a600f0b611c6e90919063ffffffff16565b6118628588600f0b611c0790919063ffffffff16565b600f0b610cef90919063ffffffff16565b90506000828203905080600f0b600012806118b457507fffffffffffffffffffffffffffffffffffffffffffffffffffffef39085f4a12600f0b81600f0b12155b611909576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611cf96023913960400191505060405180910390fd5b5050505b505050505050565b6000828284019150811015611992576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5368656c6c2f6d696e742d6f766572666c6f770000000000000000000000000081525060200191505060405180910390fd5b92915050565b60007fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b82600f0b14156119cd57600080fd5b600082600f0b126119de57816119e3565b816000035b9050919050565b6000828284039150811115611a67576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5368656c6c2f6275726e2d756e646572666c6f7700000000000000000000000081525060200191505060405180910390fd5b92915050565b600080604083600f0b85600f0b02901d90508091505092915050565b600083600f0b85600f0b1215611b4e576000611abc84680100000000000000000386600f0b611a6d90919063ffffffff16565b905080600f0b86600f0b1215611b435760008682039050611ae98682600f0b611cd590919063ffffffff16565b9250611b018484600f0b611a6d90919063ffffffff16565b9250674000000000000000600f0b83600f0b1315611b255767400000000000000092505b611b3b8184600f0b611a6d90919063ffffffff16565b925050611b48565b600091505b50611bff565b6000611b7184680100000000000000000186600f0b611a6d90919063ffffffff16565b905080600f0b86600f0b1315611bf85760008187039050611b9e8682600f0b611cd590919063ffffffff16565b9250611bb68484600f0b611a6d90919063ffffffff16565b9250674000000000000000600f0b83600f0b1315611bda5767400000000000000092505b611bf08184600f0b611a6d90919063ffffffff16565b925050611bfd565b600091505b505b949350505050565b60008082600f0b84600f0b0390507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015611c5b57506f7fffffffffffffffffffffffffffffff600f0b8113155b611c6457600080fd5b8091505092915050565b60008082600f0b84600f0b0190507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015611cc257506f7fffffffffffffffffffffffffffffff600f0b8113155b611ccb57600080fd5b8091505092915050565b60008082600f0b604085600f0b901b81611ceb57fe5b059050809150509291505056fe5368656c6c2f6c69717569646974792d696e76617269616e742d76696f6c6174696f6ea265627a7a72315820fd846c1e7d7bd336e530cc09baba53680bf9fdb506ac6f46c7d0493119a2ac5964736f6c634300050f0032
Deployed Bytecode
0x738dec04e31c6ef645cbb43586f7f0895537d2dfb330146080604052600436106100565760003560e01c806318e581fa1461005b5780633da94035146100e8578063a48b9c6314610189578063b47b942b14610223575b600080fd5b6100916004803603604081101561007157600080fd5b8101908080359060200190929190803590602001909291905050506102b7565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100d45780820151818401526020810190506100b9565b505050509050019250505060405180910390f35b8180156100f457600080fd5b5061012b6004803603604081101561010b57600080fd5b81019080803590602001909291908035906020019092919050505061043d565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015610174578082015181840152602081019050610159565b50505050905001935050505060405180910390f35b81801561019557600080fd5b506101cc600480360360408110156101ac57600080fd5b8101908080359060200190929190803590602001909291905050506106ef565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561020f5780820151818401526020810190506101f4565b505050509050019250505060405180910390f35b6102596004803603604081101561023957600080fd5b8101908080359060200190929190803590602001909291905050506108a5565b6040518083815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156102a2578082015181840152602081019050610287565b50505050905001935050505060405180910390f35b6060600083600501805490509050600060606102d286610b3f565b915091506060836040519080825280602002602001820160405280156103075781602001602082028038833980820191505090505b509050600061038b61032e670de0b6b3a76400008a60040154610c1c90919063ffffffff16565b61037a8a60010160109054906101000a9004600f0b6801000000000000000003610369670de0b6b3a76400008c610c1c90919063ffffffff16565b600f0b610c8490919063ffffffff16565b600f0b610cef90919063ffffffff16565b905060008090505b8581101561042e576104098960050182815481106103ad57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610404848785815181106103eb57fe5b6020026020010151600f0b610c8490919063ffffffff16565b610d72565b83828151811061041557fe5b6020026020010181815250508080600101915050610393565b50819550505050505092915050565b60006060600061045e670de0b6b3a764000085610c1c90919063ffffffff16565b905060008560050180549050905060608160405190808252806020026020018201604052801561049d5781602001602082028038833980820191505090505b509050600060606104ad89610b3f565b91509150600082600f0b14156105825760008090505b8481101561057c576105578a60050182815481106104dd57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166105528c600301848154811061051d57fe5b90600052602060002090600291828204019190066010029054906101000a9004600f0b89600f0b610c8490919063ffffffff16565b610e0e565b84828151811061056357fe5b60200260200101818152505080806001019150506104c3565b50610640565b600061059a8387600f0b610cef90919063ffffffff16565b905060008090505b8581101561063d576106188b60050182815481106105bc57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610613848685815181106105fa57fe5b6020026020010151600f0b610c8490919063ffffffff16565b610e0e565b85828151811061062457fe5b60200260200101818152505080806001019150506105a2565b50505b6000610661670de0b6b3a76400008b60040154610c1c90919063ffffffff16565b905060008082600f0b1361067557866106a1565b6106a08261068f868a600f0b610cef90919063ffffffff16565b600f0b610c8490919063ffffffff16565b5b90506106b08b83838787610ee2565b6106db8b336106d3670de0b6b3a764000085600f0b610fda90919063ffffffff16565b9b508b611095565b888598509850505050505050509250929050565b60606000836005018054905090506000606061070a86610b3f565b9150915060608360405190808252806020026020018201604052801561073f5781602001602082028038833980820191505090505b5090506000610763670de0b6b3a76400008960040154610c1c90919063ffffffff16565b90506000610782670de0b6b3a764000089610c1c90919063ffffffff16565b905060006107cd836107bc8c60010160109054906101000a9004600f0b680100000000000000000385600f0b610c8490919063ffffffff16565b600f0b610cef90919063ffffffff16565b905060008090505b878110156108715761084c8b60050182815481106107ef57fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633610847858a868151811061082e57fe5b6020026020010151600f0b610c8490919063ffffffff16565b6111a6565b85828151811061085857fe5b60200260200101818152505080806001019150506107d5565b5061088a8a8461088385600f0b6112ba565b8989610ee2565b6108958a338b6112fa565b8397505050505050505092915050565b6000606060006108c6670de0b6b3a764000085610c1c90919063ffffffff16565b9050600085600501805490509050600060606108e188610b3f565b915091506060836040519080825280602002602001820160405280156109165781602001602082028038833980820191505090505b509050600083600f0b14156109ea5760008090505b848110156109e4576109bf8a600501828154811061094557fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166109ba8c600301848154811061098557fe5b90600052602060002090600291828204019190066010029054906101000a9004600f0b89600f0b610c8490919063ffffffff16565b610d72565b8282815181106109cb57fe5b602002602001018181525050808060010191505061092b565b50610aa8565b6000610a028487600f0b610cef90919063ffffffff16565b905060008090505b85811015610aa557610a808b6005018281548110610a2457fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610a7b84878581518110610a6257fe5b6020026020010151600f0b610c8490919063ffffffff16565b610d72565b838281518110610a8c57fe5b6020026020010181815250508080600101915050610a0a565b50505b6000610ac9670de0b6b3a76400008b60040154610c1c90919063ffffffff16565b905060008082600f0b13610add5786610b09565b610b0882610af7878a600f0b610cef90919063ffffffff16565b600f0b610c8490919063ffffffff16565b5b9050610b29670de0b6b3a764000082600f0b610fda90919063ffffffff16565b9850888398509850505050505050509250929050565b60006060600083600501805490509050606081604051908082528060200260200182016040528015610b805781602001602082028038833980820191505090505b50905060008090505b82811015610c0e576000610bd8876005018381548110610ba557fe5b9060005260206000200160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661140b565b905080838381518110610be757fe5b6020026020010190600f0b9081600f0b815250508086019550508080600101915050610b89565b508381935093505050915091565b600080821415610c2b57600080fd5b6000610c3784846114cc565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff16816fffffffffffffffffffffffffffffffff161115610c7a57600080fd5b8091505092915050565b600080604083600f0b85600f0b02901d90507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015610cdc57506f7fffffffffffffffffffffffffffffff600f0b8113155b610ce557600080fd5b8091505092915050565b60008082600f0b1415610d0157600080fd5b600082600f0b604085600f0b901b81610d1657fe5b0590507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015610d5f57506f7fffffffffffffffffffffffffffffff600f0b8113155b610d6857600080fd5b8091505092915050565b60008273ffffffffffffffffffffffffffffffffffffffff16636b677a8f836040518263ffffffff1660e01b81526004018082600f0b600f0b815260200191505060206040518083038186803b158015610dcb57600080fd5b505afa158015610ddf573d6000803e3d6000fd5b505050506040513d6020811015610df557600080fd5b8101908080519060200190929190505050905092915050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16630271c3c8905060e01b836040516024018082600f0b600f0b8152602001915050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050610eb4848261168d565b8060200190516020811015610ec857600080fd5b810190808051906020019092919050505091505092915050565b60006060610eef87610b3f565b9150915060008760000160109054906101000a9004600f0b905060008860010160009054906101000a9004600f0b9050606089600301805480602002602001604051908101604052809291908181526020018280548015610f9557602002820191906000526020600020906000905b82829054906101000a9004600f0b600f0b81526020019060100190602082600f01049283019260010382029150808411610f5e5790505b505050505090506000610fab8888868686611763565b90506000610fbc8787878787611763565b9050610fcc8b8b8b8a86866117e1565b505050505050505050505050565b600080821415610fed576000905061108f565b600083600f0b1215610ffe57600080fd5b600060406fffffffffffffffffffffffffffffffff841685600f0b02901c90506000608084901c85600f0b02905077ffffffffffffffffffffffffffffffffffffffffffffffff81111561105157600080fd5b604081901b9050817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0381111561108757600080fd5b818101925050505b92915050565b6110a3836004015482611915565b83600401819055506110f68360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611915565b8360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16636fc39052905060e01b846111d985600f0b611998565b604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182600f0b600f0b815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905061128b858261168d565b806020019051602081101561129f57600080fd5b81019080805190602001909291905050509150509392505050565b60007fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b82600f0b14156112ef57600080fd5b816000039050919050565b6113458360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826119ea565b8360070160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113988360040154826119ea565b8360040181905550600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008173ffffffffffffffffffffffffffffffffffffffff1663ac969a73306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561148a57600080fd5b505afa15801561149e573d6000803e3d6000fd5b505050506040513d60208110156114b457600080fd5b81019080805190602001909291905050509050919050565b6000808214156114db57600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff84116115115782604085901b8161150957fe5b049050611666565b600060c09050600060c086901c9050640100000000811061153a57602081901c90506020820191505b62010000811061155257601081901c90506010820191505b610100811061156957600881901c90506008820191505b6010811061157f57600481901c90506004820191505b6004811061159557600281901c90506002820191505b600281106115a4576001820191505b600160bf830360018703901c018260ff0387901b816115bf57fe5b0492506fffffffffffffffffffffffffffffffff8311156115df57600080fd5b6000608086901c8402905060006fffffffffffffffffffffffffffffffff871685029050600060c089901c9050600060408a901b905082811015611624576001820391505b8281039050608084901b92508281101561163f576001820391505b8281039050608084901c821461165157fe5b88818161165a57fe5b04870196505050505050505b6fffffffffffffffffffffffffffffffff81111561168357600080fd5b8091505092915050565b6060600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b602083106116de57805182526020820191506020810190506020830392506116bb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461173e576040519150601f19603f3d011682016040523d82523d6000602084013e611743565b606091505b50915091506000821415611758573d60208201fd5b809250505092915050565b6000808551905060008090505b818110156117d65760006117a385838151811061178957fe5b60200260200101518a600f0b611a6d90919063ffffffff16565b90506117c48883815181106117b457fe5b6020026020010151828989611a89565b84019350508080600101915050611770565b505095945050505050565b600086600f0b14806117f85750848601600f0b6000145b156118025761190d565b600061182f8761181e8588600f0b611c0790919063ffffffff16565b600f0b610cef90919063ffffffff16565b9050600061187361184c888a600f0b611c6e90919063ffffffff16565b6118628588600f0b611c0790919063ffffffff16565b600f0b610cef90919063ffffffff16565b90506000828203905080600f0b600012806118b457507fffffffffffffffffffffffffffffffffffffffffffffffffffffef39085f4a12600f0b81600f0b12155b611909576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611cf96023913960400191505060405180910390fd5b5050505b505050505050565b6000828284019150811015611992576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5368656c6c2f6d696e742d6f766572666c6f770000000000000000000000000081525060200191505060405180910390fd5b92915050565b60007fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b82600f0b14156119cd57600080fd5b600082600f0b126119de57816119e3565b816000035b9050919050565b6000828284039150811115611a67576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5368656c6c2f6275726e2d756e646572666c6f7700000000000000000000000081525060200191505060405180910390fd5b92915050565b600080604083600f0b85600f0b02901d90508091505092915050565b600083600f0b85600f0b1215611b4e576000611abc84680100000000000000000386600f0b611a6d90919063ffffffff16565b905080600f0b86600f0b1215611b435760008682039050611ae98682600f0b611cd590919063ffffffff16565b9250611b018484600f0b611a6d90919063ffffffff16565b9250674000000000000000600f0b83600f0b1315611b255767400000000000000092505b611b3b8184600f0b611a6d90919063ffffffff16565b925050611b48565b600091505b50611bff565b6000611b7184680100000000000000000186600f0b611a6d90919063ffffffff16565b905080600f0b86600f0b1315611bf85760008187039050611b9e8682600f0b611cd590919063ffffffff16565b9250611bb68484600f0b611a6d90919063ffffffff16565b9250674000000000000000600f0b83600f0b1315611bda5767400000000000000092505b611bf08184600f0b611a6d90919063ffffffff16565b925050611bfd565b600091505b505b949350505050565b60008082600f0b84600f0b0390507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015611c5b57506f7fffffffffffffffffffffffffffffff600f0b8113155b611c6457600080fd5b8091505092915050565b60008082600f0b84600f0b0190507fffffffffffffffffffffffffffffffff80000000000000000000000000000000600f0b8112158015611cc257506f7fffffffffffffffffffffffffffffff600f0b8113155b611ccb57600080fd5b8091505092915050565b60008082600f0b604085600f0b901b81611ceb57fe5b059050809150509291505056fe5368656c6c2f6c69717569646974792d696e76617269616e742d76696f6c6174696f6ea265627a7a72315820fd846c1e7d7bd336e530cc09baba53680bf9fdb506ac6f46c7d0493119a2ac5964736f6c634300050f0032
Deployed Bytecode Sourcemap
35365:7301:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;39642:726;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;39642:726:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;39642:726:0;;;;;;;;;;;;;;;;;35684:1432;;8:9:-1;5:2;;;30:1;27;20:12;5:2;35684:1432:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;35684:1432:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;35684:1432:0;;;;;;;;;;;;;;;;;;38501:1129;;8:9:-1;5:2;;;30:1;27;20:12;5:2;38501:1129:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;38501:1129:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;38501:1129:0;;;;;;;;;;;;;;;;;37134:1359;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;37134:1359:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;37134:1359:0;;;;;;;;;;;;;;;;;;39642:726;39790:13;39824:12;39839:5;:12;;:19;;;;39824:34;;39873:13;39888:22;39915:35;39944:5;39915:28;:35::i;:::-;39871:79;;;;39963:26;40003:7;39992:19;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;39992:19:0;;;;39963:48;;40024:18;40045:109;40125:28;40148:4;40125:5;:17;;;:22;;:28;;;;:::i;:::-;40045:61;40092:5;:13;;;;;;;;;;;;35619:19;40086;40045:22;40062:4;40045:11;:16;;:22;;;;:::i;:::-;:40;;;;:61;;;;:::i;:::-;:79;;;;:109;;;;:::i;:::-;40024:130;;40172:6;40181:1;40172:10;;40167:160;40188:7;40184:1;:11;40167:160;;;40237:76;40264:5;:12;;40277:1;40264:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;40286:26;40300:11;40286:6;40293:1;40286:9;;;;;;;;;;;;;;:13;;;;:26;;;;:::i;:::-;40237;:76::i;:::-;40219:12;40232:1;40219:15;;;;;;;;;;;;;:94;;;;;40197:3;;;;;;;40167:160;;;;40346:12;40339:19;;;;;;;39642:726;;;;:::o;35684:1432::-;35819:15;35845:13;35879:16;35898:19;35912:4;35898:8;:13;;:19;;;;:::i;:::-;35879:38;;35930:12;35945:5;:12;;:19;;;;35930:34;;35977:23;36014:7;36003:19;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;36003:19:0;;;;35977:45;;36045:13;36060:22;36087:35;36116:5;36087:28;:35::i;:::-;36043:79;;;;36149:1;36139:6;:11;;;36135:481;;;36174:6;36183:1;36174:10;;36169:172;36190:7;36186:1;:11;36169:172;;;36240:83;36269:5;:12;;36282:1;36269:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;36291:31;36305:5;:13;;36319:1;36305:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;36291:9;:13;;;;:31;;;;:::i;:::-;36240:28;:83::i;:::-;36225:9;36235:1;36225:12;;;;;;;;;;;;;:98;;;;;36199:3;;;;;;;36169:172;;;;36135:481;;;36377:18;36398:21;36412:6;36398:9;:13;;;;:21;;;;:::i;:::-;36377:42;;36441:6;36450:1;36441:10;;36436:167;36457:7;36453:1;:11;36436:167;;;36507:78;36536:5;:12;;36549:1;36536:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;36558:26;36572:11;36558:6;36565:1;36558:9;;;;;;;;;;;;;;:13;;;;:26;;;;:::i;:::-;36507:28;:78::i;:::-;36492:9;36502:1;36492:12;;;;;;;;;;;;;:93;;;;;36466:3;;;;;;;36436:167;;;;36135:481;;36636:19;36658:28;36681:4;36658:5;:17;;;:22;;:28;;;;:::i;:::-;36636:50;;36707:17;36742:1;36727:12;:16;;;:96;;36814:9;36727:96;;;36759:39;36785:12;36759:21;36773:6;36759:9;:13;;;;:21;;;;:::i;:::-;:25;;;;:39;;;;:::i;:::-;36727:96;36707:116;;36836:153;36876:5;36897:12;36924:10;36950:6;36972;36836:25;:153::i;:::-;37010:56;37015:5;37022:10;37044:21;37060:4;37044:10;:15;;;;:21;;;;:::i;:::-;37034:31;;;37010:4;:56::i;:::-;37087:7;37096:9;37079:27;;;;;;;;;;;35684:1432;;;;;:::o;38501:1129::-;38640:13;38674:12;38689:5;:12;;:19;;;;38674:34;;38723:13;38738:22;38765:35;38794:5;38765:28;:35::i;:::-;38721:79;;;;38813:26;38853:7;38842:19;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;38842:19:0;;;;38813:48;;38882:19;38904:28;38927:4;38904:5;:17;;;:22;;:28;;;;:::i;:::-;38882:50;;38943:19;38965:22;38982:4;38965:11;:16;;:22;;;;:::i;:::-;38943:44;;39000:18;39021:83;39091:12;39021:51;39058:5;:13;;;;;;;;;;;;35619:19;39052;39021:12;:30;;;;:51;;;;:::i;:::-;:69;;;;:83;;;;:::i;:::-;39000:104;;39122:6;39131:1;39122:10;;39117:240;39138:7;39134:1;:11;39117:240;;;39187:156;39234:5;:12;;39247:1;39234:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;39273:10;39302:26;39316:11;39302:6;39309:1;39302:9;;;;;;;;;;;;;;:13;;;;:26;;;;:::i;:::-;39187:28;:156::i;:::-;39169:12;39182:1;39169:15;;;;;;;;;;;;;:174;;;;;39147:3;;;;;;;39117:240;;;;39369:162;39409:5;39430:12;39458:18;:12;:16;;;:18::i;:::-;39492:6;39514;39369:25;:162::i;:::-;39552:36;39557:5;39564:10;39576:11;39552:4;:36::i;:::-;39608:12;39601:19;;;;;;;;;38501:1129;;;;:::o;37134:1359::-;37278:12;37301:13;37335:16;37354:19;37368:4;37354:8;:13;;:19;;;;:::i;:::-;37335:38;;37386:12;37401:5;:12;;:19;;;;37386:34;;37435:13;37450:22;37477:35;37506:5;37477:28;:35::i;:::-;37433:79;;;;37525:23;37562:7;37551:19;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;37551:19:0;;;;37525:45;;37597:1;37587:6;:11;;;37583:599;;;37622:6;37631:1;37622:10;;37617:231;37638:7;37634:1;:11;37617:231;;;37688:142;37737:5;:12;;37750:1;37737:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;37780:31;37794:5;:13;;37808:1;37794:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;37780:9;:13;;;;:31;;;;:::i;:::-;37688:26;:142::i;:::-;37673:9;37683:1;37673:12;;;;;;;;;;;;;:157;;;;;37647:3;;;;;;;37617:231;;;;37583:599;;;37884:18;37905:21;37919:6;37905:9;:13;;;;:21;;;;:::i;:::-;37884:42;;37948:6;37957:1;37948:10;;37943:226;37964:7;37960:1;:11;37943:226;;;38014:137;38063:5;:12;;38076:1;38063:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;38106:26;38120:11;38106:6;38113:1;38106:9;;;;;;;;;;;;;;:13;;;;:26;;;;:::i;:::-;38014;:137::i;:::-;37999:9;38009:1;37999:12;;;;;;;;;;;;;:152;;;;;37973:3;;;;;;;37943:226;;;;37583:599;;38202:19;38224:28;38247:4;38224:5;:17;;;:22;;:28;;;;:::i;:::-;38202:50;;38273:17;38308:1;38293:12;:16;;;:96;;38380:9;38293:96;;;38325:39;38351:12;38325:21;38339:6;38325:9;:13;;;;:21;;;;:::i;:::-;:25;;;;:39;;;;:::i;:::-;38293:96;38273:116;;38420:21;38436:4;38420:10;:15;;;;:21;;;;:::i;:::-;38410:31;;38463:7;38472:9;38454:29;;;;;;;;;;;37134:1359;;;;;:::o;40376:614::-;40498:22;40531:15;40575:12;40590:5;:12;;:19;;;;40575:34;;40622:25;40663:7;40650:21;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;148:4;140:6;136:17;126:27;;0:157;40650:21:0;;;;40622:49;;40697:6;40706:1;40697:10;;40692:233;40713:7;40709:1;:11;40692:233;;;40744:11;40758:55;40792:5;:12;;40805:1;40792:15;;;;;;;;;;;;;;;:20;;;;;;;;;;;;40758:33;:55::i;:::-;40744:69;;40857:4;40842:9;40852:1;40842:12;;;;;;;;;;;;;:19;;;;;;;;;;;40895:4;40876:23;;;;40692:233;40722:3;;;;;;;40692:233;;;;40953:15;40970:9;40945:35;;;;;;40376:614;;;:::o;8615:208::-;8675:6;8704:1;8699;:6;;8690:16;;;;;;8713:14;8730:12;8737:1;8740;8730:5;:12::i;:::-;8713:29;;1134:34;8758:29;;:6;:29;;;;8749:39;;;;;;8810:6;8795:22;;;8615:208;;;;:::o;4448:201::-;4505:6;4520:13;4553:2;4548:1;4536:13;;4543:1;4536:9;;:13;:19;;4520:35;;975;4571:19;;:6;:19;;:42;;;;;1134:34;4594:19;;:6;:19;;4571:42;4562:52;;;;;;4636:6;4621:22;;;4448:201;;;;:::o;7007:227::-;7064:6;7093:1;7088;:6;;;;7079:16;;;;;;7102:13;7139:1;7118:22;;7133:2;7127:1;7119:10;;:16;;7118:22;;;;;;7102:38;;975:35;7156:19;;:6;:19;;:42;;;;;1134:34;7179:19;;:6;:19;;7156:42;7147:52;;;;;;7221:6;7206:22;;;7007:227;;;;:::o;27919:166::-;27995:15;28048:6;28035:34;;;28070:4;28035:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;28035:40:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;28035:40:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;28035:40:0;;;;;;;;;;;;;;;;28025:50;;27919:166;;;;:::o;29248:257::-;29321:12;29348:17;27591:1;29391:23;;;:32;;;;29425:4;29368:62;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;29368:62:0;;;;;;;38:4:-1;29:7;25:18;67:10;61:17;96:58;199:8;192:4;186;182:15;179:29;167:10;160:49;0:215;;;29368:62:0;29348:82;;29461:22;29470:6;29478:4;29461:8;:22::i;:::-;29450:45;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;29450:45:0;;;;;;;;;;;;;;;;29443:52;;29248:257;;;;;:::o;41002:742::-;41225:13;41240:22;41267:35;41296:5;41267:28;:35::i;:::-;41223:79;;;;41323:12;41338:5;:10;;;;;;;;;;;;41323:25;;41359:13;41375:5;:11;;;;;;;;;;;;41359:27;;41397:24;41424:5;:13;;41397:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;41458:13;41474:63;41497:6;41505;41513:5;41520:6;41528:8;41474:22;:63::i;:::-;41458:79;;41550:11;41564:63;41587:6;41595;41603:5;41610:6;41618:8;41564:22;:63::i;:::-;41550:77;;41640:86;41676:7;41685:10;41697:6;41705;41713;41721:4;41640:35;:86::i;:::-;41002:742;;;;;;;;;;;;:::o;6270:469::-;6329:7;6354:1;6349;:6;6345:20;;;6364:1;6357:8;;;;6345:20;6388:1;6383;:6;;;;6374:16;;;;;;6399:10;6472:2;6432:34;6428:1;:38;6422:1;6413:11;;:54;6412:62;;6399:75;;6481:10;6514:3;6509:1;:8;;6503:1;6494:11;;:24;6481:37;;6542:50;6536:2;:56;;6527:66;;;;;;6607:2;6600:9;;;;;6709:2;6640:66;:71;6627:2;:84;;6618:94;;;;;;6731:2;6726;:7;6719:14;;;;6270:469;;;;;:::o;42066:306::-;42189:35;42198:5;:17;;;42217:6;42189:8;:35::i;:::-;42169:5;:17;;:55;;;;42263:41;42272:5;:14;;:23;42287:7;42272:23;;;;;;;;;;;;;;;;42297:6;42263:8;:41::i;:::-;42237:5;:14;;:23;42252:7;42237:23;;;;;;;;;;;;;;;:67;;;;42343:10;42322:40;;42339:1;42322:40;;;42355:6;42322:40;;;;;;;;;;;;;;;;;;42066:306;;;:::o;30174:283::-;30261:12;30288:17;27591:1;30331:23;;;:32;;;;30365:4;30371:10;:4;:8;;;:10::i;:::-;30308:74;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;30308:74:0;;;;;;;38:4:-1;29:7;25:18;67:10;61:17;96:58;199:8;192:4;186;182:15;179:29;167:10;160:49;0:215;;;30308:74:0;30288:94;;30413:22;30422:6;30430:4;30413:8;:22::i;:::-;30402:45;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;30402:45:0;;;;;;;;;;;;;;;;30395:52;;30174:283;;;;;;:::o;8991:108::-;9038:6;975:35;9062:14;;:1;:14;;;;9053:24;;;;;;9092:1;9091:2;;9084:9;;8991:108;;;:::o;41752:306::-;41881:41;41890:5;:14;;:23;41905:7;41890:23;;;;;;;;;;;;;;;;41915:6;41881:8;:41::i;:::-;41855:5;:14;;:23;41870:7;41855:23;;;;;;;;;;;;;;;:67;;;;41955:35;41964:5;:17;;;41983:6;41955:8;:35::i;:::-;41935:5;:17;;:55;;;;42037:1;42008:40;;42017:10;42008:40;;;42041:6;42008:40;;;;;;;;;;;;;;;;;;41752:306;;;:::o;28511:169::-;28581:11;28627:6;28614:41;;;28664:4;28614:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;28614:56:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;28614:56:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;28614:56:0;;;;;;;;;;;;;;;;28607:63;;28511:169;;;:::o;21187:1257::-;21247:7;21277:1;21272;:6;;21263:16;;;;;;21288:14;21320:50;21315:1;:55;21311:1035;;21400:1;21394:2;21389:1;:7;;21388:13;;;;;;21379:22;;21311:1035;;;21422:11;21436:3;21422:17;;21448:10;21466:3;21461:1;:8;;21448:21;;21488:11;21482:2;:17;21478:48;;21510:2;21503:9;;;;;21521:2;21514:9;;;;21478:48;21544:7;21538:2;:13;21534:44;;21562:2;21555:9;;;;;21573:2;21566:9;;;;21534:44;21596:5;21590:2;:11;21586:40;;21612:1;21605:8;;;;;21622:1;21615:8;;;;21586:40;21644:4;21638:2;:10;21634:39;;21659:1;21652:8;;;;;21669:1;21662:8;;;;21634:39;21691:3;21685:2;:9;21681:38;;21705:1;21698:8;;;;;21715:1;21708:8;;;;21681:38;21737:3;21731:2;:9;21727:23;;21749:1;21742:8;;;;21727:23;21845:1;21838:3;21832;:9;21827:1;21823;:5;:18;;21822:24;21814:3;21808;:9;21803:1;:14;;21802:45;;;;;;21793:54;;21875:34;21865:6;:44;;21856:54;;;;;;21921:10;21949:3;21944:1;:8;;21934:6;:19;21921:32;;21962:10;21989:34;21985:1;:38;21975:6;:49;21962:62;;22035:10;22053:3;22048:1;:8;;22035:21;;22065:10;22083:2;22078:1;:7;;22065:20;;22105:2;22100;:7;22096:20;;;22115:1;22109:7;;;;22096:20;22131:2;22125:8;;;;22190:3;22184:2;:9;;22179:14;;22211:2;22206;:7;22202:20;;;22221:1;22215:7;;;;22202:20;22237:2;22231:8;;;;22307:3;22301:2;:9;;22295:2;:15;22287:24;;;;22337:1;22332:2;:6;;;;;;22322:16;;;;21311:1035;;;;;;;22373:34;22363:6;:44;;22354:54;;;;;;22431:6;22415:23;;;21187:1257;;;;:::o;27603:308::-;27676:12;27704:13;27719:24;27747:7;:20;;27768:5;27747:27;;;;;;;;;;;;;36:153:-1;66:2;61:3;58:11;36:153;;182:3;176:10;171:3;164:23;98:2;93:3;89:12;82:19;;123:2;118:3;114:12;107:19;;148:2;143:3;139:12;132:19;;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;;;27747:27: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;;27703:71:0;;;;27814:1;27804:8;27801:15;27798:2;;;27850:16;27843:4;27830:11;27826:22;27819:48;27798:2;27890:11;27883:18;;;;27603:308;;;;:::o;73862:447::-;74052:11;74078:12;74093:5;:12;74078:27;;74123:6;74132:1;74123:10;;74118:182;74139:7;74135:1;:11;74118:182;;;74170:13;74186:25;74199:8;74208:1;74199:11;;;;;;;;;;;;;;74186:5;:12;;;;:25;;;;:::i;:::-;74170:41;;74236:50;74254:5;74260:1;74254:8;;;;;;;;;;;;;;74264:6;74272:5;74279:6;74236:17;:50::i;:::-;74228:58;;;;74118:182;74148:3;;;;;;;74118:182;;;;73862:447;;;;;;;;:::o;78867:709::-;79117:1;79101:12;:17;;;:51;;;;79142:10;79127:12;:25;79122:30;;:1;:30;79101:51;79097:64;;;79154:7;;79097:64;79181:24;79208:64;79259:12;79208:32;79233:6;79208;:24;;;;:32;;;;:::i;:::-;:50;;;;:64;;;;:::i;:::-;79181:91;;79297:24;79324:78;79373:28;79390:10;79373:12;:16;;;;:28;;;;:::i;:::-;79324:30;79349:4;79324:6;:24;;;;:30;;;;:::i;:::-;:48;;;;:78;;;;:::i;:::-;79297:105;;79415:12;79450:17;79430;:37;79415:52;;79492:5;79488:9;;:1;:9;:30;;;;73685:15;79501:17;;:5;:17;;;;79488:30;79480:78;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;78867:709;;;;;;;;;;:::o;42380:135::-;42436:6;42480:1;42474;42470;:5;42466:9;;;42465:16;;42457:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;42380:135;;;;:::o;9268:120::-;9315:6;975:35;9339:14;;:1;:14;;;;9330:24;;;;;;9372:1;9368;:5;;;:14;;9381:1;9368:14;;;9377:1;9376:2;;9368:14;9361:21;;9268:120;;;:::o;42523:136::-;42579:6;42623:1;42617;42613;:5;42609:9;;;42608:16;;42600:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;42523:136;;;;:::o;30771:145::-;30831:6;30846:13;30879:2;30874:1;30862:13;;30869:1;30862:9;;:13;:19;;30846:35;;30903:6;30888:22;;;30771:145;;;;:::o;74317:1016::-;74467:11;74504:6;74497:13;;:4;:13;;;74493:831;;;74529:17;74549:26;74569:5;73560:19;74563:11;74549:6;:13;;;;:26;;;;:::i;:::-;74529:46;;74603:10;74596:17;;:4;:17;;;74592:309;;;74636:17;74669:4;74656:10;:17;74636:37;;74701:25;74719:6;74701:10;:17;;;;:25;;;;:::i;:::-;74694:32;;74752:19;74764:6;74752:4;:11;;;;:19;;;;:::i;:::-;74745:26;;73608:18;74796:10;;:4;:10;;;74792:26;;;73608:18;74808:10;;74792:26;74846:23;74858:10;74846:4;:11;;;;:23;;;;:::i;:::-;74839:30;;74592:309;;;;74900:1;74893:8;;74592:309;74493:831;;;;74938:17;74958:26;74978:5;73560:19;74972:11;74958:6;:13;;;;:26;;;;:::i;:::-;74938:46;;75012:10;75005:17;;:4;:17;;;75001:309;;;75045:17;75072:10;75065:4;:17;75045:37;;75110:25;75128:6;75110:10;:17;;;;:25;;;;:::i;:::-;75103:32;;75161:19;75173:6;75161:4;:11;;;;:19;;;;:::i;:::-;75154:26;;73608:18;75205:10;;:4;:10;;;75201:26;;;73608:18;75217:10;;75201:26;75255:23;75267:10;75255:4;:11;;;;:23;;;;:::i;:::-;75248:30;;75001:309;;;;75309:1;75302:8;;75001:309;74493:831;;74317:1016;;;;;;:::o;4017:195::-;4074:6;4089:13;4117:1;4105:13;;4112:1;4105:9;;:13;4089:29;;975:35;4134:19;;:6;:19;;:42;;;;;1134:34;4157:19;;:6;:19;;4134:42;4125:52;;;;;;4199:6;4184:22;;;4017:195;;;;:::o;3600:::-;3657:6;3672:13;3700:1;3688:13;;3695:1;3688:9;;:13;3672:29;;975:35;3717:19;;:6;:19;;:42;;;;;1134:34;3740:19;;:6;:19;;3717:42;3708:52;;;;;;3782:6;3767:22;;;3600:195;;;;:::o;31186:148::-;31246:6;31261:13;31298:1;31277:22;;31292:2;31286:1;31278:10;;:16;;31277:22;;;;;;31261:38;;31321:6;31306:22;;;31186:148;;;;:::o
Swarm Source
bzzr://fd846c1e7d7bd336e530cc09baba53680bf9fdb506ac6f46c7d0493119a2ac59
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.