Address Details
contract

0x2901da88dd444a3c41AF51696548DEe3524Cf8Dc

Contract Name
ConstantSumPricingModule
Creator
0x56fd3f–9b8d81 at 0x40cbc3–bb4e15
Balance
0 CELO
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
23694245
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
ConstantSumPricingModule




Optimization enabled
true
Compiler version
v0.5.17+commit.d19bba13




Optimization runs
10000
Verified at
2024-02-26T09:24:47.864097Z

lib/mento-core-2.2.0/contracts/swap/ConstantSumPricingModule.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;
pragma experimental ABIEncoderV2;

import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";

import { IPricingModule } from "../interfaces/IPricingModule.sol";
import { FixidityLib } from "../common/FixidityLib.sol";

/**
 * @title ConstantSumPricingModule
 * @notice The ConstantSumPricingModule calculates the amount in and the amount out for a constant sum AMM.
 */

contract ConstantSumPricingModule is IPricingModule {
  using SafeMath for uint256;
  using FixidityLib for FixidityLib.Fraction;

  /* ==================== View Functions ==================== */
  /**
   * @notice Calculates the amount of tokens that should be received based on the given parameters
   * @dev amountOut = (1 - spread) * amountIn * tokenOutBucketSize) / tokenInBucketSize
   * @param tokenInBucketSize The bucket size of the token swapped in.
   * @param tokenOutBucketSize The bucket size of the token swapped out.
   * @param spread The spread that is applied to a swap.
   * @param amountIn The amount of tokens in wei that is swapped in.
   * @return amountOut The amount of tokens in wei that should be received.
   */
  function getAmountOut(
    uint256 tokenInBucketSize,
    uint256 tokenOutBucketSize,
    uint256 spread,
    uint256 amountIn
  ) external view returns (uint256 amountOut) {
    if (amountIn == 0) return 0;

    FixidityLib.Fraction memory spreadFraction = FixidityLib.fixed1().subtract(FixidityLib.wrap(spread));
    FixidityLib.Fraction memory netAmountIn = spreadFraction.multiply(FixidityLib.newFixed(amountIn));
    FixidityLib.Fraction memory numerator = netAmountIn.multiply(FixidityLib.newFixed(tokenOutBucketSize));
    FixidityLib.Fraction memory denominator = FixidityLib.newFixed(tokenInBucketSize);

    // Can't use FixidityLib.divide because numerator can easily be greater
    // than maxFixedDivisor.
    // Fortunately, we expect an integer result, so integer division gives us as
    // much precision as we could hope for.
    amountOut = numerator.unwrap().div(denominator.unwrap());
    return amountOut;
  }

  /**
   * @notice Calculates the amount of tokens that should be provided in order to receive the desired amount out.
   * @dev amountIn = (amountOut  * tokenInBucketSize) / (tokenOutBucketSize * (1 - spread))
   * @param tokenInBucketSize The bucket size of the token swapped in.
   * @param tokenOutBucketSize The bucket size of the token swapped out.
   * @param spread The spread that is applied to a swap.
   * @param amountOut The amount of tokens in wei that should be swapped out.
   * @return amountIn The amount of tokens in wei that should be provided.
   */
  function getAmountIn(
    uint256 tokenInBucketSize,
    uint256 tokenOutBucketSize,
    uint256 spread,
    uint256 amountOut
  ) external view returns (uint256 amountIn) {
    if (amountOut == 0) return 0;

    FixidityLib.Fraction memory spreadFraction = FixidityLib.fixed1().subtract(FixidityLib.wrap(spread));
    FixidityLib.Fraction memory numerator = FixidityLib.newFixed(amountOut).multiply(
      FixidityLib.newFixed(tokenInBucketSize)
    );
    FixidityLib.Fraction memory denominator = FixidityLib.newFixed(tokenOutBucketSize).multiply(spreadFraction);

    // Can't use FixidityLib.divide because numerator can easily be greater
    // than maxFixedDivisor.
    // Fortunately, we expect an integer result, so integer division gives us as
    // much precision as we could hope for.
    return numerator.unwrap().div(denominator.unwrap());
  }

  /**
   * @notice Returns the AMM that the IPricingModule implements
   * @return Constant Sum.
   */
  function name() external view returns (string memory) {
    return "ConstantSum";
  }
}
        

/lib/mento-core-2.2.0/contracts/interfaces/IPricingModule.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

/**
 * @title Interface for a Mento Pricing Module.
 * @notice A Mento pricing module represents an exchange relation between a pair of ERC20 assets.
 */
interface IPricingModule {
  /**
   * @notice Returns the output amount and new bucket sizes for a given input amount.
   * @param tokenInBucketSize Size of the tokenIn bucket.
   * @param tokenOutBucketSize Size of the tokenOut bucket.
   * @param spread Spread charged on exchanges.
   * @param amountIn Amount of tokenIn being paid in.
   * @return amountOut Amount of tokenOut that will be paid out.
   */
  function getAmountOut(
    uint256 tokenInBucketSize,
    uint256 tokenOutBucketSize,
    uint256 spread,
    uint256 amountIn
  ) external view returns (uint256 amountOut);

  /**
   * @notice Returns the input amount necessary for a given output amount.
   * @param tokenInBucketSize Size of the tokenIn bucket.
   * @param tokenOutBucketSize Size of the tokenOut bucket.
   * @param spread Spread charged on exchanges.
   * @param amountOut Amount of tokenIn being paid out.
   * @return amountIn Amount of tokenOut that would have to be paid in.
   */
  function getAmountIn(
    uint256 tokenInBucketSize,
    uint256 tokenOutBucketSize,
    uint256 spread,
    uint256 amountOut
  ) external view returns (uint256 amountIn);

  /**
   * @notice Retrieve the name of this pricing module.
   * @return exchangeName The name of the pricing module.
   */
  function name() external view returns (string memory pricingModuleName);
}
          

/lib/mento-core-2.2.0/contracts/common/FixidityLib.sol

pragma solidity ^0.5.13;

/**
 * @title FixidityLib
 * @author Gadi Guy, Alberto Cuesta Canada
 * @notice This library provides fixed point arithmetic with protection against
 * overflow.
 * All operations are done with uint256 and the operands must have been created
 * with any of the newFrom* functions, which shift the comma digits() to the
 * right and check for limits, or with wrap() which expects a number already
 * in the internal representation of a fraction.
 * When using this library be sure to use maxNewFixed() as the upper limit for
 * creation of fixed point numbers.
 * @dev All contained functions are pure and thus marked internal to be inlined
 * on consuming contracts at compile time for gas efficiency.
 */
library FixidityLib {
  struct Fraction {
    uint256 value;
  }

  /**
   * @notice Number of positions that the comma is shifted to the right.
   */
  function digits() internal pure returns (uint8) {
    return 24;
  }

  uint256 private constant FIXED1_UINT = 1000000000000000000000000;

  /**
   * @notice This is 1 in the fixed point units used in this library.
   * @dev Test fixed1() equals 10^digits()
   * Hardcoded to 24 digits.
   */
  function fixed1() internal pure returns (Fraction memory) {
    return Fraction(FIXED1_UINT);
  }

  /**
   * @notice Wrap a uint256 that represents a 24-decimal fraction in a Fraction
   * struct.
   * @param x Number that already represents a 24-decimal fraction.
   * @return A Fraction struct with contents x.
   */
  function wrap(uint256 x) internal pure returns (Fraction memory) {
    return Fraction(x);
  }

  /**
   * @notice Unwraps the uint256 inside of a Fraction struct.
   */
  function unwrap(Fraction memory x) internal pure returns (uint256) {
    return x.value;
  }

  /**
   * @notice The amount of decimals lost on each multiplication operand.
   * @dev Test mulPrecision() equals sqrt(fixed1)
   */
  function mulPrecision() internal pure returns (uint256) {
    return 1000000000000;
  }

  /**
   * @notice Maximum value that can be converted to fixed point. Optimize for deployment.
   * @dev
   * Test maxNewFixed() equals maxUint256() / fixed1()
   */
  function maxNewFixed() internal pure returns (uint256) {
    return 115792089237316195423570985008687907853269984665640564;
  }

  /**
   * @notice Converts a uint256 to fixed point Fraction
   * @dev Test newFixed(0) returns 0
   * Test newFixed(1) returns fixed1()
   * Test newFixed(maxNewFixed()) returns maxNewFixed() * fixed1()
   * Test newFixed(maxNewFixed()+1) fails
   */
  function newFixed(uint256 x) internal pure returns (Fraction memory) {
    require(x <= maxNewFixed(), "can't create fixidity number larger than maxNewFixed()");
    return Fraction(x * FIXED1_UINT);
  }

  /**
   * @notice Converts a uint256 in the fixed point representation of this
   * library to a non decimal. All decimal digits will be truncated.
   */
  function fromFixed(Fraction memory x) internal pure returns (uint256) {
    return x.value / FIXED1_UINT;
  }

  /**
   * @notice Converts two uint256 representing a fraction to fixed point units,
   * equivalent to multiplying dividend and divisor by 10^digits().
   * @param numerator numerator must be <= maxNewFixed()
   * @param denominator denominator must be <= maxNewFixed() and denominator can't be 0
   * @dev
   * Test newFixedFraction(1,0) fails
   * Test newFixedFraction(0,1) returns 0
   * Test newFixedFraction(1,1) returns fixed1()
   * Test newFixedFraction(1,fixed1()) returns 1
   */
  function newFixedFraction(uint256 numerator, uint256 denominator) internal pure returns (Fraction memory) {
    Fraction memory convertedNumerator = newFixed(numerator);
    Fraction memory convertedDenominator = newFixed(denominator);
    return divide(convertedNumerator, convertedDenominator);
  }

  /**
   * @notice Returns the integer part of a fixed point number.
   * @dev
   * Test integer(0) returns 0
   * Test integer(fixed1()) returns fixed1()
   * Test integer(newFixed(maxNewFixed())) returns maxNewFixed()*fixed1()
   */
  function integer(Fraction memory x) internal pure returns (Fraction memory) {
    return Fraction((x.value / FIXED1_UINT) * FIXED1_UINT); // Can't overflow
  }

  /**
   * @notice Returns the fractional part of a fixed point number.
   * In the case of a negative number the fractional is also negative.
   * @dev
   * Test fractional(0) returns 0
   * Test fractional(fixed1()) returns 0
   * Test fractional(fixed1()-1) returns 10^24-1
   */
  function fractional(Fraction memory x) internal pure returns (Fraction memory) {
    return Fraction(x.value - (x.value / FIXED1_UINT) * FIXED1_UINT); // Can't overflow
  }

  /**
   * @notice x+y.
   * @dev The maximum value that can be safely used as an addition operator is defined as
   * maxFixedAdd = maxUint256()-1 / 2, or
   * 57896044618658097711785492504343953926634992332820282019728792003956564819967.
   * Test add(maxFixedAdd,maxFixedAdd) equals maxFixedAdd + maxFixedAdd
   * Test add(maxFixedAdd+1,maxFixedAdd+1) throws
   */
  function add(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    uint256 z = x.value + y.value;
    require(z >= x.value, "add overflow detected");
    return Fraction(z);
  }

  /**
   * @notice x-y.
   * @dev
   * Test subtract(6, 10) fails
   */
  function subtract(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    require(x.value >= y.value, "substraction underflow detected");
    return Fraction(x.value - y.value);
  }

  /**
   * @notice x*y. If any of the operators is higher than the max multiplier value it
   * might overflow.
   * @dev The maximum value that can be safely used as a multiplication operator
   * (maxFixedMul) is calculated as sqrt(maxUint256()*fixed1()),
   * or 340282366920938463463374607431768211455999999999999
   * Test multiply(0,0) returns 0
   * Test multiply(maxFixedMul,0) returns 0
   * Test multiply(0,maxFixedMul) returns 0
   * Test multiply(fixed1()/mulPrecision(),fixed1()*mulPrecision()) returns fixed1()
   * Test multiply(maxFixedMul,maxFixedMul) is around maxUint256()
   * Test multiply(maxFixedMul+1,maxFixedMul+1) fails
   */
  // solhint-disable-next-line code-complexity
  function multiply(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    if (x.value == 0 || y.value == 0) return Fraction(0);
    if (y.value == FIXED1_UINT) return x;
    if (x.value == FIXED1_UINT) return y;

    // Separate into integer and fractional parts
    // x = x1 + x2, y = y1 + y2
    uint256 x1 = integer(x).value / FIXED1_UINT;
    uint256 x2 = fractional(x).value;
    uint256 y1 = integer(y).value / FIXED1_UINT;
    uint256 y2 = fractional(y).value;

    // (x1 + x2) * (y1 + y2) = (x1 * y1) + (x1 * y2) + (x2 * y1) + (x2 * y2)
    uint256 x1y1 = x1 * y1;
    if (x1 != 0) require(x1y1 / x1 == y1, "overflow x1y1 detected");

    // x1y1 needs to be multiplied back by fixed1
    // solhint-disable-next-line var-name-mixedcase
    uint256 fixed_x1y1 = x1y1 * FIXED1_UINT;
    if (x1y1 != 0) require(fixed_x1y1 / x1y1 == FIXED1_UINT, "overflow x1y1 * fixed1 detected");
    x1y1 = fixed_x1y1;

    uint256 x2y1 = x2 * y1;
    if (x2 != 0) require(x2y1 / x2 == y1, "overflow x2y1 detected");

    uint256 x1y2 = x1 * y2;
    if (x1 != 0) require(x1y2 / x1 == y2, "overflow x1y2 detected");

    x2 = x2 / mulPrecision();
    y2 = y2 / mulPrecision();
    uint256 x2y2 = x2 * y2;
    if (x2 != 0) require(x2y2 / x2 == y2, "overflow x2y2 detected");

    // result = fixed1() * x1 * y1 + x1 * y2 + x2 * y1 + x2 * y2 / fixed1();
    Fraction memory result = Fraction(x1y1);
    result = add(result, Fraction(x2y1)); // Add checks for overflow
    result = add(result, Fraction(x1y2)); // Add checks for overflow
    result = add(result, Fraction(x2y2)); // Add checks for overflow
    return result;
  }

  /**
   * @notice 1/x
   * @dev
   * Test reciprocal(0) fails
   * Test reciprocal(fixed1()) returns fixed1()
   * Test reciprocal(fixed1()*fixed1()) returns 1 // Testing how the fractional is truncated
   * Test reciprocal(1+fixed1()*fixed1()) returns 0 // Testing how the fractional is truncated
   * Test reciprocal(newFixedFraction(1, 1e24)) returns newFixed(1e24)
   */
  function reciprocal(Fraction memory x) internal pure returns (Fraction memory) {
    require(x.value != 0, "can't call reciprocal(0)");
    return Fraction((FIXED1_UINT * FIXED1_UINT) / x.value); // Can't overflow
  }

  /**
   * @notice x/y. If the dividend is higher than the max dividend value, it
   * might overflow. You can use multiply(x,reciprocal(y)) instead.
   * @dev The maximum value that can be safely used as a dividend (maxNewFixed) is defined as
   * divide(maxNewFixed,newFixedFraction(1,fixed1())) is around maxUint256().
   * This yields the value 115792089237316195423570985008687907853269984665640564.
   * Test maxNewFixed equals maxUint256()/fixed1()
   * Test divide(maxNewFixed,1) equals maxNewFixed*(fixed1)
   * Test divide(maxNewFixed+1,multiply(mulPrecision(),mulPrecision())) throws
   * Test divide(fixed1(),0) fails
   * Test divide(maxNewFixed,1) = maxNewFixed*(10^digits())
   * Test divide(maxNewFixed+1,1) throws
   */
  function divide(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    require(y.value != 0, "can't divide by 0");
    // solhint-disable-next-line var-name-mixedcase
    uint256 X = x.value * FIXED1_UINT;
    require(X / FIXED1_UINT == x.value, "overflow at divide");
    return Fraction(X / y.value);
  }

  /**
   * @notice x > y
   */
  function gt(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value > y.value;
  }

  /**
   * @notice x >= y
   */
  function gte(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value >= y.value;
  }

  /**
   * @notice x < y
   */
  function lt(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value < y.value;
  }

  /**
   * @notice x <= y
   */
  function lte(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value <= y.value;
  }

  /**
   * @notice x == y
   */
  function equals(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value == y.value;
  }

  /**
   * @notice x <= 1
   */
  function isProperFraction(Fraction memory x) internal pure returns (bool) {
    return lte(x, fixed1());
  }
}
          

/lib/mento-core-2.0.0/lib/openzeppelin-contracts/contracts/math/SafeMath.sol

pragma solidity ^0.5.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}
          

Compiler Settings

{"remappings":[":celo-foundry/=lib/celo-foundry/src/",":contracts/=contracts/",":ds-test/=lib/celo-foundry/lib/forge-std/lib/ds-test/src/",":forge-std-next/=lib/mento-core-2.2.0/lib/forge-std-next/src/",":forge-std/=lib/celo-foundry/lib/forge-std/src/",":mento-core-2.0.0/=lib/mento-core-2.0.0/contracts/",":mento-core-2.1.0/=lib/mento-core-2.1.0/contracts/",":mento-core-2.2.0/=lib/mento-core-2.2.0/contracts/",":mento-core/=lib/mento-core/contracts/",":openzeppelin-contracts-next/=lib/mento-core-2.2.0/lib/openzeppelin-contracts-next/",":openzeppelin-contracts-upgradeable/=lib/mento-core-2.2.0/lib/openzeppelin-contracts-upgradeable/",":openzeppelin-contracts/=lib/mento-core-2.0.0/lib/openzeppelin-contracts/contracts/",":openzeppelin-solidity/=lib/mento-core-2.0.0/lib/openzeppelin-contracts/",":test/=lib/mento-core-2.0.0/test/"],"optimizer":{"runs":10000,"enabled":true},"libraries":{"AddressSortedLinkedListWithMedian":"0x99edce8143ff8aefa1fbb6c2103b349add2b9519","AddressLinkedList":"0x3e2cc57f83093ce1ee03482c1590e3b5f4225bd7"},"compilationTarget":{"lib/mento-core-2.2.0/contracts/swap/ConstantSumPricingModule.sol":"ConstantSumPricingModule"}}
              

Contract ABI

[{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amountIn","internalType":"uint256"}],"name":"getAmountIn","inputs":[{"type":"uint256","name":"tokenInBucketSize","internalType":"uint256"},{"type":"uint256","name":"tokenOutBucketSize","internalType":"uint256"},{"type":"uint256","name":"spread","internalType":"uint256"},{"type":"uint256","name":"amountOut","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amountOut","internalType":"uint256"}],"name":"getAmountOut","inputs":[{"type":"uint256","name":"tokenInBucketSize","internalType":"uint256"},{"type":"uint256","name":"tokenOutBucketSize","internalType":"uint256"},{"type":"uint256","name":"spread","internalType":"uint256"},{"type":"uint256","name":"amountIn","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50610b9b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806306fdde031461004657806352707d8c14610064578063571fd01214610084575b600080fd5b61004e610097565b60405161005b9190610a3e565b60405180910390f35b6100776100723660046107a8565b6100ce565b60405161005b9190610acf565b6100776100923660046107a8565b610183565b60408051808201909152600b81527f436f6e7374616e7453756d000000000000000000000000000000000000000000602082015290565b6000816100dd5750600061017b565b6100e561078a565b6101056100f185610202565b6100f961021c565b9063ffffffff61024016565b905061010f61078a565b61012861011b856102a7565b839063ffffffff61031016565b905061013261078a565b61013e61011b886102a7565b905061014861078a565b610151896102a7565b905061017461015f826105fb565b610168846105fb565b9063ffffffff6105ff16565b9450505050505b949350505050565b6000816101925750600061017b565b61019a61078a565b6101a66100f185610202565b90506101b061078a565b6101d16101bc886102a7565b6101c5866102a7565b9063ffffffff61031016565b90506101db61078a565b6101e8836101c5896102a7565b90506101f661015f826105fb565b98975050505050505050565b61020a61078a565b50604080516020810190915290815290565b61022461078a565b50604080516020810190915269d3c21bcecceda1000000815290565b61024861078a565b81518351101561028d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a5f565b60405180910390fd5b506040805160208101909152815183510381525b92915050565b6102af61078a565b6102b7610648565b8211156102f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a7f565b50604080516020810190915269d3c21bcecceda100000082028152919050565b61031861078a565b8251158061032557508151155b1561033f57506040805160208101909152600081526102a1565b815169d3c21bcecceda100000014156103595750816102a1565b825169d3c21bcecceda100000014156103735750806102a1565b600069d3c21bcecceda100000061038985610663565b518161039157fe5b049050600061039f85610698565b519050600069d3c21bcecceda10000006103b886610663565b51816103c057fe5b04905060006103ce86610698565b519050838202841561041c57828582816103e457fe5b041461041c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a4f565b69d3c21bcecceda10000008102811561047b5769d3c21bcecceda100000082828161044357fe5b041461047b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610aaf565b90508084840285156104c9578486828161049157fe5b04146104c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610abf565b868402871561051457848882816104dc57fe5b0414610514576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a8f565b61051c6106d2565b878161052457fe5b04965061052f6106d2565b858161053757fe5b0494508685028715610585578588828161054d57fe5b0414610585576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a6f565b61058d61078a565b60405180602001604052808781525090506105b6816040518060200160405280878152506106db565b90506105d0816040518060200160405280868152506106db565b90506105ea816040518060200160405280858152506106db565b9d9c50505050505050505050505050565b5190565b600061064183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610739565b9392505050565b7601357c299a88ea76a58924d52ce4f26a85af186c2b9e7490565b61066b61078a565b604051806020016040528069d3c21bcecceda10000008085600001518161068e57fe5b0402905292915050565b6106a061078a565b604051806020016040528069d3c21bcecceda1000000808560000151816106c357fe5b95519504029093039092525090565b64e8d4a5100090565b6106e361078a565b8151835190810190811015610724576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a9f565b60408051602081019091529081529392505050565b60008183610774576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102849190610a3e565b50600083858161078057fe5b0495945050505050565b6040518060200160405280600081525090565b80356102a181610b41565b600080600080608085870312156107be57600080fd5b60006107ca878761079d565b94505060206107db8782880161079d565b93505060406107ec8782880161079d565b92505060606107fd8782880161079d565b91505092959194509250565b6000610814826105fb565b61081e8185610add565b935061082e818560208601610ae9565b61083781610b19565b9093019392505050565b600061084e601683610add565b7f6f766572666c6f77207831793120646574656374656400000000000000000000815260200192915050565b6000610887601f83610add565b7f737562737472616374696f6e20756e646572666c6f7720646574656374656400815260200192915050565b60006108c0601683610add565b7f6f766572666c6f77207832793220646574656374656400000000000000000000815260200192915050565b60006108f9603683610add565b7f63616e277420637265617465206669786964697479206e756d626572206c617281527f676572207468616e206d61784e65774669786564282900000000000000000000602082015260400192915050565b6000610958601683610add565b7f6f766572666c6f77207831793220646574656374656400000000000000000000815260200192915050565b6000610991601583610add565b7f616464206f766572666c6f772064657465637465640000000000000000000000815260200192915050565b60006109ca601f83610add565b7f6f766572666c6f772078317931202a2066697865643120646574656374656400815260200192915050565b6000610a03601683610add565b7f6f766572666c6f77207832793120646574656374656400000000000000000000815260200192915050565b610a3881610ae6565b82525050565b602080825281016106418184610809565b602080825281016102a181610841565b602080825281016102a18161087a565b602080825281016102a1816108b3565b602080825281016102a1816108ec565b602080825281016102a18161094b565b602080825281016102a181610984565b602080825281016102a1816109bd565b602080825281016102a1816109f6565b602081016102a18284610a2f565b90815260200190565b90565b60005b83811015610b04578181015183820152602001610aec565b83811115610b13576000848401525b50505050565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b610b4a81610ae6565b8114610b5557600080fd5b5056fea365627a7a7231582088e1d43bb0bbae670f2682884354b0cfe585b946cf1f0a78cd0c5c0085e2dd206c6578706572696d656e74616cf564736f6c63430005110040

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100415760003560e01c806306fdde031461004657806352707d8c14610064578063571fd01214610084575b600080fd5b61004e610097565b60405161005b9190610a3e565b60405180910390f35b6100776100723660046107a8565b6100ce565b60405161005b9190610acf565b6100776100923660046107a8565b610183565b60408051808201909152600b81527f436f6e7374616e7453756d000000000000000000000000000000000000000000602082015290565b6000816100dd5750600061017b565b6100e561078a565b6101056100f185610202565b6100f961021c565b9063ffffffff61024016565b905061010f61078a565b61012861011b856102a7565b839063ffffffff61031016565b905061013261078a565b61013e61011b886102a7565b905061014861078a565b610151896102a7565b905061017461015f826105fb565b610168846105fb565b9063ffffffff6105ff16565b9450505050505b949350505050565b6000816101925750600061017b565b61019a61078a565b6101a66100f185610202565b90506101b061078a565b6101d16101bc886102a7565b6101c5866102a7565b9063ffffffff61031016565b90506101db61078a565b6101e8836101c5896102a7565b90506101f661015f826105fb565b98975050505050505050565b61020a61078a565b50604080516020810190915290815290565b61022461078a565b50604080516020810190915269d3c21bcecceda1000000815290565b61024861078a565b81518351101561028d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a5f565b60405180910390fd5b506040805160208101909152815183510381525b92915050565b6102af61078a565b6102b7610648565b8211156102f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a7f565b50604080516020810190915269d3c21bcecceda100000082028152919050565b61031861078a565b8251158061032557508151155b1561033f57506040805160208101909152600081526102a1565b815169d3c21bcecceda100000014156103595750816102a1565b825169d3c21bcecceda100000014156103735750806102a1565b600069d3c21bcecceda100000061038985610663565b518161039157fe5b049050600061039f85610698565b519050600069d3c21bcecceda10000006103b886610663565b51816103c057fe5b04905060006103ce86610698565b519050838202841561041c57828582816103e457fe5b041461041c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a4f565b69d3c21bcecceda10000008102811561047b5769d3c21bcecceda100000082828161044357fe5b041461047b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610aaf565b90508084840285156104c9578486828161049157fe5b04146104c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610abf565b868402871561051457848882816104dc57fe5b0414610514576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a8f565b61051c6106d2565b878161052457fe5b04965061052f6106d2565b858161053757fe5b0494508685028715610585578588828161054d57fe5b0414610585576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a6f565b61058d61078a565b60405180602001604052808781525090506105b6816040518060200160405280878152506106db565b90506105d0816040518060200160405280868152506106db565b90506105ea816040518060200160405280858152506106db565b9d9c50505050505050505050505050565b5190565b600061064183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610739565b9392505050565b7601357c299a88ea76a58924d52ce4f26a85af186c2b9e7490565b61066b61078a565b604051806020016040528069d3c21bcecceda10000008085600001518161068e57fe5b0402905292915050565b6106a061078a565b604051806020016040528069d3c21bcecceda1000000808560000151816106c357fe5b95519504029093039092525090565b64e8d4a5100090565b6106e361078a565b8151835190810190811015610724576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028490610a9f565b60408051602081019091529081529392505050565b60008183610774576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102849190610a3e565b50600083858161078057fe5b0495945050505050565b6040518060200160405280600081525090565b80356102a181610b41565b600080600080608085870312156107be57600080fd5b60006107ca878761079d565b94505060206107db8782880161079d565b93505060406107ec8782880161079d565b92505060606107fd8782880161079d565b91505092959194509250565b6000610814826105fb565b61081e8185610add565b935061082e818560208601610ae9565b61083781610b19565b9093019392505050565b600061084e601683610add565b7f6f766572666c6f77207831793120646574656374656400000000000000000000815260200192915050565b6000610887601f83610add565b7f737562737472616374696f6e20756e646572666c6f7720646574656374656400815260200192915050565b60006108c0601683610add565b7f6f766572666c6f77207832793220646574656374656400000000000000000000815260200192915050565b60006108f9603683610add565b7f63616e277420637265617465206669786964697479206e756d626572206c617281527f676572207468616e206d61784e65774669786564282900000000000000000000602082015260400192915050565b6000610958601683610add565b7f6f766572666c6f77207831793220646574656374656400000000000000000000815260200192915050565b6000610991601583610add565b7f616464206f766572666c6f772064657465637465640000000000000000000000815260200192915050565b60006109ca601f83610add565b7f6f766572666c6f772078317931202a2066697865643120646574656374656400815260200192915050565b6000610a03601683610add565b7f6f766572666c6f77207832793120646574656374656400000000000000000000815260200192915050565b610a3881610ae6565b82525050565b602080825281016106418184610809565b602080825281016102a181610841565b602080825281016102a18161087a565b602080825281016102a1816108b3565b602080825281016102a1816108ec565b602080825281016102a18161094b565b602080825281016102a181610984565b602080825281016102a1816109bd565b602080825281016102a1816109f6565b602081016102a18284610a2f565b90815260200190565b90565b60005b83811015610b04578181015183820152602001610aec565b83811115610b13576000848401525b50505050565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b610b4a81610ae6565b8114610b5557600080fd5b5056fea365627a7a7231582088e1d43bb0bbae670f2682884354b0cfe585b946cf1f0a78cd0c5c0085e2dd206c6578706572696d656e74616cf564736f6c63430005110040

External libraries

AddressLinkedList : 0x3e2cc57f83093ce1ee03482c1590e3b5f4225bd7  
AddressSortedLinkedListWithMedian : 0x99edce8143ff8aefa1fbb6c2103b349add2b9519