UNPKG

@leetswap/sdk-canto

Version:

🛠 An SDK for building applications on top of LeetSwap on Canto.

938 lines (756 loc) • 218 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var JSBI = _interopDefault(require('jsbi')); var bignumber = require('@ethersproject/bignumber'); var invariant = _interopDefault(require('tiny-invariant')); var address = require('@ethersproject/address'); var warning = _interopDefault(require('tiny-warning')); var _Big = _interopDefault(require('big.js')); var _Decimal = _interopDefault(require('decimal.js-light')); var toFormat = _interopDefault(require('toformat')); var solidity = require('@ethersproject/solidity'); var abi$1 = require('@ethersproject/abi'); var signingKey = require('@ethersproject/signing-key'); var eip712 = require('eip-712'); var bytes = require('@ethersproject/bytes'); var contracts = require('@ethersproject/contracts'); var fetch = _interopDefault(require('isomorphic-unfetch')); (function (ChainId) { ChainId[ChainId["CANTO"] = 7700] = "CANTO"; ChainId[ChainId["CANTO_AMBER"] = 10001] = "CANTO_AMBER"; })(exports.ChainId || (exports.ChainId = {})); (function (Rounding) { Rounding[Rounding["ROUND_DOWN"] = 0] = "ROUND_DOWN"; Rounding[Rounding["ROUND_HALF_UP"] = 1] = "ROUND_HALF_UP"; Rounding[Rounding["ROUND_UP"] = 2] = "ROUND_UP"; })(exports.Rounding || (exports.Rounding = {})); (function (TradeType) { TradeType[TradeType["EXACT_INPUT"] = 0] = "EXACT_INPUT"; TradeType[TradeType["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT"; })(exports.TradeType || (exports.TradeType = {})); (function (KashiAction) { KashiAction[KashiAction["ADD_ASSET"] = 1] = "ADD_ASSET"; KashiAction[KashiAction["REPAY"] = 2] = "REPAY"; KashiAction[KashiAction["REMOVE_ASSET"] = 3] = "REMOVE_ASSET"; KashiAction[KashiAction["REMOVE_COLLATERAL"] = 4] = "REMOVE_COLLATERAL"; KashiAction[KashiAction["BORROW"] = 5] = "BORROW"; KashiAction[KashiAction["GET_REPAY_SHARE"] = 6] = "GET_REPAY_SHARE"; KashiAction[KashiAction["GET_REPAY_PART"] = 7] = "GET_REPAY_PART"; KashiAction[KashiAction["ACCRUE"] = 8] = "ACCRUE"; // Functions that don't need accrue to be called KashiAction[KashiAction["ADD_COLLATERAL"] = 10] = "ADD_COLLATERAL"; KashiAction[KashiAction["UPDATE_EXCHANGE_RATE"] = 11] = "UPDATE_EXCHANGE_RATE"; // Function on BentoBox KashiAction[KashiAction["BENTO_DEPOSIT"] = 20] = "BENTO_DEPOSIT"; KashiAction[KashiAction["BENTO_WITHDRAW"] = 21] = "BENTO_WITHDRAW"; KashiAction[KashiAction["BENTO_TRANSFER"] = 22] = "BENTO_TRANSFER"; KashiAction[KashiAction["BENTO_TRANSFER_MULTIPLE"] = 23] = "BENTO_TRANSFER_MULTIPLE"; KashiAction[KashiAction["BENTO_SETAPPROVAL"] = 24] = "BENTO_SETAPPROVAL"; // Any external call (except to BentoBox) KashiAction[KashiAction["CALL"] = 30] = "CALL"; })(exports.KashiAction || (exports.KashiAction = {})); // Fee - Tiers TBD (function (Fee) { Fee[Fee["DEFAULT"] = 30] = "DEFAULT"; })(exports.Fee || (exports.Fee = {})); (function (OrderStatus) { OrderStatus["FILLED"] = "FILLED"; OrderStatus["CANCELLED"] = "CANCELLED"; OrderStatus["EXPIRED"] = "EXPIRED"; OrderStatus["PENDING"] = "PENDING"; })(exports.OrderStatus || (exports.OrderStatus = {})); var _FLEXUSD_ADDRESS, _BCUSDT_ADDRESS, _FACTORY_ADDRESS, _ROUTER_ADDRESS, _MISTROLL_ADDRESS, _MIST_ADDRESS, _MASTERCHEF_ADDRESS, _BAR_ADDRESS, _MAKER_ADDRESS, _BENTOBOX_ADDRESS, _KASHI_ADDRESS, _WCANTO_ADDRESS, _WNATIVE_ADDRESS, _MASTERCHEF_V2_ADDRES, _ENS_REGISTRAR_ADDRES, _MULTICALL2_ADDRESS, _BORING_HELPER_ADDRES, _SABLIER_ADDRESS, _TWAP_0_ORACLE_ADDRES, _TWAP_1_ORACLE_ADDRES, _SUSHISWAP_MULTISWAPP, _SUSHISWAP_MULTI_EXAC; var FLEXUSD_ADDRESS = (_FLEXUSD_ADDRESS = {}, _FLEXUSD_ADDRESS[exports.ChainId.CANTO] = '0x7b2B3C5308ab5b2a1d9a94d20D35CCDf61e05b72', _FLEXUSD_ADDRESS[exports.ChainId.CANTO_AMBER] = '0xD0E6466293c6CdA8CaA96A57683909383c01411D', _FLEXUSD_ADDRESS); var BCUSDT_ADDRESS = (_BCUSDT_ADDRESS = {}, _BCUSDT_ADDRESS[exports.ChainId.CANTO] = '0xBc2F884680c95A02cea099dA2F524b366d9028Ba', _BCUSDT_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x36D564473bDb10E92e97D5908260C81Ba83C0f54', _BCUSDT_ADDRESS); var FACTORY_ADDRESS = (_FACTORY_ADDRESS = {}, _FACTORY_ADDRESS[exports.ChainId.CANTO] = '0x1BB9cf4e63CD2DAb8741c334f525350AB2Ee2c96', _FACTORY_ADDRESS[exports.ChainId.CANTO_AMBER] = '0xaa094cA3FBd19dCCcE91C79d1FffA28293B05f28', _FACTORY_ADDRESS); var ROUTER_ADDRESS = (_ROUTER_ADDRESS = {}, _ROUTER_ADDRESS[exports.ChainId.CANTO] = '0xD463786E7d54Fc570A92982157E15130e469dcD8', _ROUTER_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x72a1A3F85e775dbd82D737830190aCB338fd6D71', _ROUTER_ADDRESS); var MISTROLL_ADDRESS = (_MISTROLL_ADDRESS = {}, _MISTROLL_ADDRESS[exports.ChainId.CANTO] = '0x719288288C7a5390206FA7F4fD51baDFd5CbF28A', _MISTROLL_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x89eb9eC41015074Ffa9353b99EDd6626c2810078', _MISTROLL_ADDRESS); var MIST_ADDRESS = (_MIST_ADDRESS = {}, _MIST_ADDRESS[exports.ChainId.CANTO] = '0x5fA664f69c2A4A3ec94FaC3cBf7049BD9CA73129', _MIST_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x3d2cd929D1fC1dA68D2557AB85336C2740b1Ae81', _MIST_ADDRESS); var MASTERCHEF_ADDRESS = (_MASTERCHEF_ADDRESS = {}, _MASTERCHEF_ADDRESS[exports.ChainId.CANTO] = '0x3A7B9D0ed49a90712da4E087b17eE4Ac1375a5D4', _MASTERCHEF_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x5ee747274cDAc7F6CF5cD3aE2c53123BCEED59c4', _MASTERCHEF_ADDRESS); var BAR_ADDRESS = (_BAR_ADDRESS = {}, _BAR_ADDRESS[exports.ChainId.CANTO] = '0xC41C680c60309d4646379eD62020c534eB67b6f4', _BAR_ADDRESS[exports.ChainId.CANTO_AMBER] = '0xceb95423B86c1823deC2Cc6F877997DC9349C2F1', _BAR_ADDRESS); var MAKER_ADDRESS = (_MAKER_ADDRESS = {}, _MAKER_ADDRESS[exports.ChainId.CANTO] = '0x7D1d91E59D1DA60E3ECC5701a4bc669Ab182DaE8', _MAKER_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x6b8A569B1bA6a172d2e8Dd244282a4b16b14CaEA', _MAKER_ADDRESS); var BENTOBOX_ADDRESS = (_BENTOBOX_ADDRESS = {}, _BENTOBOX_ADDRESS[exports.ChainId.CANTO_AMBER] = '0xEfbb25ec12EB1aAe98600c5614F9C4BCAff41F5d', _BENTOBOX_ADDRESS); var KASHI_ADDRESS = (_KASHI_ADDRESS = {}, _KASHI_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x045e3894e475e14Be14d1c23C1AaF1cB7E275c7d', _KASHI_ADDRESS); var STOP_LIMIT_ORDER_ADDRESS = {}; var WCANTO_ADDRESS = (_WCANTO_ADDRESS = {}, _WCANTO_ADDRESS[exports.ChainId.CANTO] = '0x826551890Dc65655a0Aceca109aB11AbDbD7a07B', _WCANTO_ADDRESS[exports.ChainId.CANTO_AMBER] = '0x17F4FCF5b6E0A95D4eE331c8529041896A073F9b', _WCANTO_ADDRESS); var WNATIVE_ADDRESS = (_WNATIVE_ADDRESS = {}, _WNATIVE_ADDRESS[exports.ChainId.CANTO] = WCANTO_ADDRESS[exports.ChainId.CANTO], _WNATIVE_ADDRESS[exports.ChainId.CANTO_AMBER] = WCANTO_ADDRESS[exports.ChainId.CANTO_AMBER], _WNATIVE_ADDRESS); var MASTERCHEF_V2_ADDRESS = (_MASTERCHEF_V2_ADDRES = {}, _MASTERCHEF_V2_ADDRES[exports.ChainId.CANTO] = '', _MASTERCHEF_V2_ADDRES[exports.ChainId.CANTO_AMBER] = '', _MASTERCHEF_V2_ADDRES); var ENS_REGISTRAR_ADDRESS = (_ENS_REGISTRAR_ADDRES = {}, _ENS_REGISTRAR_ADDRES[exports.ChainId.CANTO] = '0xCfb86556760d03942EBf1ba88a9870e67D77b627', _ENS_REGISTRAR_ADDRES[exports.ChainId.CANTO_AMBER] = '0x32f1FBE59D771bdB7FB247FE97A635f50659202b', _ENS_REGISTRAR_ADDRES); var MULTICALL2_ADDRESS = (_MULTICALL2_ADDRESS = {}, _MULTICALL2_ADDRESS[exports.ChainId.CANTO] = '0x637490E68AA50Ea810688a52D7464E10c25A77c1', _MULTICALL2_ADDRESS[exports.ChainId.CANTO_AMBER] = '0xAF15A45d934a83b95daCFEbaACCaED8cF97e8200', _MULTICALL2_ADDRESS); var BORING_HELPER_ADDRESS = (_BORING_HELPER_ADDRES = {}, _BORING_HELPER_ADDRES[exports.ChainId.CANTO_AMBER] = '0xEd019DA0a65feccB33e4842Cc01B9FD77320e114', _BORING_HELPER_ADDRES); var SABLIER_ADDRESS = (_SABLIER_ADDRESS = {}, _SABLIER_ADDRESS[exports.ChainId.CANTO] = '0x5eB85d9D7dc2F2C70F4C13b4Ba9Ed21d65141037', _SABLIER_ADDRESS[exports.ChainId.CANTO_AMBER] = '0xeE85373F26E5380Fbd71FB7295BD68fdd0818887', _SABLIER_ADDRESS); var CHAINLINK_ORACLE_ADDRESS = {}; var TWAP_0_ORACLE_ADDRESS = (_TWAP_0_ORACLE_ADDRES = {}, _TWAP_0_ORACLE_ADDRES[exports.ChainId.CANTO_AMBER] = "0x2bccA90B7271820dE65267A1806C94548289878b", _TWAP_0_ORACLE_ADDRES); var TWAP_1_ORACLE_ADDRESS = (_TWAP_1_ORACLE_ADDRES = {}, _TWAP_1_ORACLE_ADDRES[exports.ChainId.CANTO_AMBER] = "0xcd4a723bc92E500081f6fA04D87722a62558a77A", _TWAP_1_ORACLE_ADDRES); var SUSHISWAP_MULTISWAPPER_ADDRESS = (_SUSHISWAP_MULTISWAPP = {}, _SUSHISWAP_MULTISWAPP[exports.ChainId.CANTO_AMBER] = "0x9eFdA721Cfa24DA62c5011394F1dBC05C0FDBe83", _SUSHISWAP_MULTISWAPP); var SUSHISWAP_MULTI_EXACT_SWAPPER_ADDRESS = (_SUSHISWAP_MULTI_EXAC = {}, _SUSHISWAP_MULTI_EXAC[exports.ChainId.CANTO_AMBER] = "0x6D701f555d0C6C4df19c6FD4Cb846181871A958C", _SUSHISWAP_MULTI_EXAC); var ACTION_ADD_ASSET = 1; var ACTION_REPAY = 2; var ACTION_REMOVE_ASSET = 3; var ACTION_REMOVE_COLLATERAL = 4; var ACTION_BORROW = 5; var ACTION_GET_REPAY_SHARE = 6; var ACTION_GET_REPAY_PART = 7; var ACTION_ACCRUE = 8; // Functions that don't need accrue to be called var ACTION_ADD_COLLATERAL = 10; var ACTION_UPDATE_EXCHANGE_RATE = 11; // Function on BentoBox var ACTION_BENTO_DEPOSIT = 20; var ACTION_BENTO_WITHDRAW = 21; var ACTION_BENTO_TRANSFER = 22; var ACTION_BENTO_TRANSFER_MULTIPLE = 23; var ACTION_BENTO_SETAPPROVAL = 24; // Any external call (except to BentoBox) var ACTION_CALL = 30; var MINIMUM_TARGET_UTILIZATION = /*#__PURE__*/bignumber.BigNumber.from('700000000000000000'); // 70% var MAXIMUM_TARGET_UTILIZATION = /*#__PURE__*/bignumber.BigNumber.from('800000000000000000'); // 80% var UTILIZATION_PRECISION = /*#__PURE__*/bignumber.BigNumber.from('1000000000000000000'); var FULL_UTILIZATION = /*#__PURE__*/bignumber.BigNumber.from('1000000000000000000'); var FULL_UTILIZATION_MINUS_MAX = /*#__PURE__*/FULL_UTILIZATION.sub(MAXIMUM_TARGET_UTILIZATION); var STARTING_INTEREST_PER_YEAR = /*#__PURE__*/bignumber.BigNumber.from(317097920).mul(bignumber.BigNumber.from(60)).mul(bignumber.BigNumber.from(60)).mul(bignumber.BigNumber.from(24)).mul( /*#__PURE__*/bignumber.BigNumber.from(365)); // approx 1% APR var MINIMUM_INTEREST_PER_YEAR = /*#__PURE__*/bignumber.BigNumber.from(79274480).mul(bignumber.BigNumber.from(60)).mul(bignumber.BigNumber.from(60)).mul(bignumber.BigNumber.from(24)).mul( /*#__PURE__*/bignumber.BigNumber.from(365)); // approx 0.25% APR var MAXIMUM_INTEREST_PER_YEAR = /*#__PURE__*/bignumber.BigNumber.from(317097920000).mul(bignumber.BigNumber.from(60)).mul(bignumber.BigNumber.from(60)).mul(bignumber.BigNumber.from(24)).mul( /*#__PURE__*/bignumber.BigNumber.from(365)); // approx 1000% APR var INTEREST_ELASTICITY = /*#__PURE__*/bignumber.BigNumber.from('28800000000000000000000000000000000000000'); // Half or double in 28800 seconds (8 hours) if linear var FACTOR_PRECISION = /*#__PURE__*/bignumber.BigNumber.from('1000000000000000000'); var PROTOCOL_FEE = /*#__PURE__*/bignumber.BigNumber.from('10000'); // 10% var PROTOCOL_FEE_DIVISOR = /*#__PURE__*/bignumber.BigNumber.from('100000'); function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } /** * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies */ var AbstractCurrency = /** * Constructs an instance of the base class `BaseCurrency`. * @param chainId the chain ID on which this currency resides * @param decimals decimals of the currency * @param symbol symbol of the currency * @param name of the currency */ function AbstractCurrency(chainId, decimals, symbol, name) { !Number.isSafeInteger(chainId) ? invariant(false, 'CHAIN_ID') : void 0; !(decimals >= 0 && decimals < 255 && Number.isInteger(decimals)) ? invariant(false, 'DECIMALS') : void 0; this.chainId = chainId; this.decimals = decimals; this.symbol = symbol; this.name = name; }; /** * Represents the native currency of the chain on which it resides, e.g. */ var NativeCurrency = /*#__PURE__*/function (_AbstractCurrency) { _inheritsLoose(NativeCurrency, _AbstractCurrency); function NativeCurrency() { var _this; _this = _AbstractCurrency.apply(this, arguments) || this; _this.isNative = true; _this.isToken = false; return _this; } return NativeCurrency; }(AbstractCurrency); function validateAndParseAddress(address$1) { try { var checksummedAddress = address.getAddress(address$1); "development" !== "production" ? warning(address$1 === checksummedAddress, address$1 + " is not checksummed.") : void 0; return checksummedAddress; } catch (error) { invariant(false, address$1 + " is not a valid address.") ; } } /** * Represents an ERC20 token with a unique address and some metadata. */ var Token = /*#__PURE__*/function (_AbstractCurrency) { _inheritsLoose(Token, _AbstractCurrency); function Token(chainId, address, decimals, symbol, name) { var _this; _this = _AbstractCurrency.call(this, chainId, decimals, symbol, name) || this; _this.isNative = false; _this.isToken = true; _this.chainId = chainId; _this.address = validateAndParseAddress(address); return _this; } /** * Returns true if the two tokens are equivalent, i.e. have the same chainId and address. * @param other other token to compare */ var _proto = Token.prototype; _proto.equals = function equals(other) { return other.isToken && this.chainId === other.chainId && this.address === other.address; } /** * Returns true if the address of this token sorts before the address of the other token * @param other other token to compare * @throws if the tokens have the same address * @throws if the tokens are on different chains */ ; _proto.sortsBefore = function sortsBefore(other) { !(this.chainId === other.chainId) ? invariant(false, 'CHAIN_IDS') : void 0; !(this.address !== other.address) ? invariant(false, 'ADDRESSES') : void 0; return this.address.toLowerCase() < other.address.toLowerCase(); } /** * Return this token, which does not need to be wrapped */ ; _createClass(Token, [{ key: "wrapped", get: function get() { return this; } }]); return Token; }(AbstractCurrency); /** * Compares two currencies for equality */ function currencyEquals(currencyA, currencyB) { if (currencyA instanceof Token && currencyB instanceof Token) { return currencyA.equals(currencyB); } else if (currencyA instanceof Token) { return false; } else if (currencyB instanceof Token) { return false; } else { return currencyA === currencyB; } } var _FLEXUSD, _WCANTO, _WNATIVE; var FLEXUSD = (_FLEXUSD = {}, _FLEXUSD[exports.ChainId.CANTO] = /*#__PURE__*/new Token(exports.ChainId.CANTO, FLEXUSD_ADDRESS[exports.ChainId.CANTO], 18, 'flexUSD', 'flexUSD'), _FLEXUSD[exports.ChainId.CANTO_AMBER] = /*#__PURE__*/new Token(exports.ChainId.CANTO_AMBER, FLEXUSD_ADDRESS[exports.ChainId.CANTO_AMBER], 18, 'flexUSD', 'flexUSD'), _FLEXUSD); var WCANTO = (_WCANTO = {}, _WCANTO[exports.ChainId.CANTO] = /*#__PURE__*/new Token(exports.ChainId.CANTO, WCANTO_ADDRESS[exports.ChainId.CANTO], 18, 'WCANTO', 'Wrapped BCH'), _WCANTO[exports.ChainId.CANTO_AMBER] = /*#__PURE__*/new Token(exports.ChainId.CANTO_AMBER, WCANTO_ADDRESS[exports.ChainId.CANTO_AMBER], 18, 'WCANTO', 'Wrapped BCH'), _WCANTO); var WNATIVE = (_WNATIVE = {}, _WNATIVE[exports.ChainId.CANTO] = WCANTO[exports.ChainId.CANTO], _WNATIVE[exports.ChainId.CANTO_AMBER] = WCANTO[exports.ChainId.CANTO_AMBER], _WNATIVE); var Canto = /*#__PURE__*/function (_NativeCurrency) { _inheritsLoose(Canto, _NativeCurrency); function Canto(chainId) { return _NativeCurrency.call(this, chainId, 18, 'CANTO', 'Canto') || this; } Canto.onChain = function onChain(chainId) { var _this$_cache$chainId; return (_this$_cache$chainId = this._cache[chainId]) != null ? _this$_cache$chainId : this._cache[chainId] = new Canto(chainId); }; var _proto = Canto.prototype; _proto.equals = function equals(other) { return other.isNative && other.chainId === this.chainId; }; _createClass(Canto, [{ key: "wrapped", get: function get() { var weth9 = WCANTO[this.chainId]; !!!weth9 ? invariant(false, 'WRAPPED') : void 0; return weth9; } }]); return Canto; }(NativeCurrency); Canto._cache = {}; var _NATIVE; var NATIVE = (_NATIVE = {}, _NATIVE[exports.ChainId.CANTO] = /*#__PURE__*/Canto.onChain(exports.ChainId.CANTO), _NATIVE[exports.ChainId.CANTO_AMBER] = /*#__PURE__*/Canto.onChain(exports.ChainId.CANTO_AMBER), _NATIVE); var MaxUint256 = /*#__PURE__*/JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // exports for internal consumption var ZERO = /*#__PURE__*/JSBI.BigInt(0); var ONE = /*#__PURE__*/JSBI.BigInt(1); var TWO = /*#__PURE__*/JSBI.BigInt(2); var THREE = /*#__PURE__*/JSBI.BigInt(3); var FIVE = /*#__PURE__*/JSBI.BigInt(5); var TEN = /*#__PURE__*/JSBI.BigInt(10); var _100 = /*#__PURE__*/JSBI.BigInt(100); var _997 = /*#__PURE__*/JSBI.BigInt(997); var _1000 = /*#__PURE__*/JSBI.BigInt(1000); var _INIT_CODE_HASH, _SOLIDITY_TYPE_MAXIMA; var INIT_CODE_HASH = (_INIT_CODE_HASH = {}, _INIT_CODE_HASH[exports.ChainId.CANTO] = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f', _INIT_CODE_HASH[exports.ChainId.CANTO_AMBER] = '0xacca68b46e4aa677641d8d20d81c9f4b252af83de62ff9e2fb58a9b648ee3537', _INIT_CODE_HASH); var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); (function (SolidityType) { SolidityType["uint8"] = "uint8"; SolidityType["uint256"] = "uint256"; })(exports.SolidityType || (exports.SolidityType = {})); var SOLIDITY_TYPE_MAXIMA = (_SOLIDITY_TYPE_MAXIMA = {}, _SOLIDITY_TYPE_MAXIMA[exports.SolidityType.uint8] = /*#__PURE__*/JSBI.BigInt('0xff'), _SOLIDITY_TYPE_MAXIMA[exports.SolidityType.uint256] = /*#__PURE__*/JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), _SOLIDITY_TYPE_MAXIMA); var LAMBDA_URL = 'https://9epjsvomc4.execute-api.us-east-1.amazonaws.com/dev'; var SOCKET_URL = 'wss://hfimt374ge.execute-api.us-east-1.amazonaws.com/dev'; // see https://stackoverflow.com/a/41102306 var CAN_SET_PROTOTYPE = ('setPrototypeOf' in Object); /** * Indicates that the pair has insufficient reserves for a desired output amount. I.e. the amount of output cannot be * obtained by sending any amount of input. */ var InsufficientReservesError = /*#__PURE__*/function (_Error) { _inheritsLoose(InsufficientReservesError, _Error); function InsufficientReservesError() { var _this; _this = _Error.call(this) || this; _this.isInsufficientReservesError = true; _this.name = _this.constructor.name; if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof InsufficientReservesError ? this.constructor : void 0).prototype); return _this; } return InsufficientReservesError; }( /*#__PURE__*/_wrapNativeSuper(Error)); /** * Indicates that the input amount is too small to produce any amount of output. I.e. the amount of input sent is less * than the price of a single unit of output after fees. */ var InsufficientInputAmountError = /*#__PURE__*/function (_Error2) { _inheritsLoose(InsufficientInputAmountError, _Error2); function InsufficientInputAmountError() { var _this2; _this2 = _Error2.call(this) || this; _this2.isInsufficientInputAmountError = true; _this2.name = _this2.constructor.name; if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(_assertThisInitialized(_this2), (this instanceof InsufficientInputAmountError ? this.constructor : void 0).prototype); return _this2; } return InsufficientInputAmountError; }( /*#__PURE__*/_wrapNativeSuper(Error)); var _toSignificantRoundin, _toFixedRounding; var Decimal = /*#__PURE__*/toFormat(_Decimal); var Big = /*#__PURE__*/toFormat(_Big); Big.strict = true; var toSignificantRounding = (_toSignificantRoundin = {}, _toSignificantRoundin[exports.Rounding.ROUND_DOWN] = Decimal.ROUND_DOWN, _toSignificantRoundin[exports.Rounding.ROUND_HALF_UP] = Decimal.ROUND_HALF_UP, _toSignificantRoundin[exports.Rounding.ROUND_UP] = Decimal.ROUND_UP, _toSignificantRoundin); var toFixedRounding = (_toFixedRounding = {}, _toFixedRounding[exports.Rounding.ROUND_DOWN] = 0, _toFixedRounding[exports.Rounding.ROUND_HALF_UP] = 1, _toFixedRounding[exports.Rounding.ROUND_UP] = 3, _toFixedRounding); var Fraction = /*#__PURE__*/function () { function Fraction(numerator, denominator) { if (denominator === void 0) { denominator = JSBI.BigInt(1); } this.numerator = JSBI.BigInt(numerator); this.denominator = JSBI.BigInt(denominator); } Fraction.tryParseFraction = function tryParseFraction(fractionish) { if (fractionish instanceof JSBI || typeof fractionish === 'number' || typeof fractionish === 'string') return new Fraction(fractionish); if ('numerator' in fractionish && 'denominator' in fractionish) return fractionish; throw new Error('Could not parse fraction'); } // performs floor division ; var _proto = Fraction.prototype; _proto.invert = function invert() { return new Fraction(this.denominator, this.numerator); }; _proto.add = function add(other) { var otherParsed = Fraction.tryParseFraction(other); if (JSBI.equal(this.denominator, otherParsed.denominator)) { return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator); } return new Fraction(JSBI.add(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator)); }; _proto.subtract = function subtract(other) { var otherParsed = Fraction.tryParseFraction(other); if (JSBI.equal(this.denominator, otherParsed.denominator)) { return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator); } return new Fraction(JSBI.subtract(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator)); }; _proto.lessThan = function lessThan(other) { var otherParsed = Fraction.tryParseFraction(other); return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)); }; _proto.equalTo = function equalTo(other) { var otherParsed = Fraction.tryParseFraction(other); return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)); }; _proto.greaterThan = function greaterThan(other) { var otherParsed = Fraction.tryParseFraction(other); return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)); }; _proto.multiply = function multiply(other) { var otherParsed = Fraction.tryParseFraction(other); return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator)); }; _proto.divide = function divide(other) { var otherParsed = Fraction.tryParseFraction(other); return new Fraction(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(this.denominator, otherParsed.numerator)); }; _proto.toSignificant = function toSignificant(significantDigits, format, rounding) { if (format === void 0) { format = { groupSeparator: '' }; } if (rounding === void 0) { rounding = exports.Rounding.ROUND_HALF_UP; } !Number.isInteger(significantDigits) ? invariant(false, significantDigits + " is not an integer.") : void 0; !(significantDigits > 0) ? invariant(false, significantDigits + " is not positive.") : void 0; Decimal.set({ precision: significantDigits + 1, rounding: toSignificantRounding[rounding] }); var quotient = new Decimal(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(significantDigits); return quotient.toFormat(quotient.decimalPlaces(), format); }; _proto.toFixed = function toFixed(decimalPlaces, format, rounding) { if (format === void 0) { format = { groupSeparator: '' }; } if (rounding === void 0) { rounding = exports.Rounding.ROUND_HALF_UP; } !Number.isInteger(decimalPlaces) ? invariant(false, decimalPlaces + " is not an integer.") : void 0; !(decimalPlaces >= 0) ? invariant(false, decimalPlaces + " is negative.") : void 0; Big.DP = decimalPlaces; Big.RM = toFixedRounding[rounding]; return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format); } /** * Helper method for converting any super class back to a fraction */ ; _createClass(Fraction, [{ key: "quotient", get: function get() { return JSBI.divide(this.numerator, this.denominator); } // remainder after floor division }, { key: "remainder", get: function get() { return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator); } }, { key: "asFraction", get: function get() { return new Fraction(this.numerator, this.denominator); } }]); return Fraction; }(); var Big$1 = /*#__PURE__*/toFormat(_Big); Big$1.strict = true; var CurrencyAmount = /*#__PURE__*/function (_Fraction) { _inheritsLoose(CurrencyAmount, _Fraction); function CurrencyAmount(currency, numerator, denominator) { var _this; _this = _Fraction.call(this, numerator, denominator) || this; !JSBI.lessThanOrEqual(_this.quotient, MaxUint256) ? invariant(false, 'AMOUNT') : void 0; _this.currency = currency; _this.decimalScale = JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(currency.decimals)); return _this; } /** * Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount * @param currency the currency in the amount * @param rawAmount the raw token or ether amount */ CurrencyAmount.fromRawAmount = function fromRawAmount(currency, rawAmount) { return new CurrencyAmount(currency, rawAmount); } /** * Construct a currency amount with a denominator that is not equal to 1 * @param currency the currency * @param numerator the numerator of the fractional token amount * @param denominator the denominator of the fractional token amount */ ; CurrencyAmount.fromFractionalAmount = function fromFractionalAmount(currency, numerator, denominator) { return new CurrencyAmount(currency, numerator, denominator); }; var _proto = CurrencyAmount.prototype; _proto.add = function add(other) { !this.currency.equals(other.currency) ? invariant(false, 'CURRENCY') : void 0; var added = _Fraction.prototype.add.call(this, other); return CurrencyAmount.fromFractionalAmount(this.currency, added.numerator, added.denominator); }; _proto.subtract = function subtract(other) { !this.currency.equals(other.currency) ? invariant(false, 'CURRENCY') : void 0; var subtracted = _Fraction.prototype.subtract.call(this, other); return CurrencyAmount.fromFractionalAmount(this.currency, subtracted.numerator, subtracted.denominator); }; _proto.multiply = function multiply(other) { var multiplied = _Fraction.prototype.multiply.call(this, other); return CurrencyAmount.fromFractionalAmount(this.currency, multiplied.numerator, multiplied.denominator); }; _proto.divide = function divide(other) { var divided = _Fraction.prototype.divide.call(this, other); return CurrencyAmount.fromFractionalAmount(this.currency, divided.numerator, divided.denominator); }; _proto.toSignificant = function toSignificant(significantDigits, format, rounding) { if (significantDigits === void 0) { significantDigits = 6; } if (rounding === void 0) { rounding = exports.Rounding.ROUND_DOWN; } return _Fraction.prototype.divide.call(this, this.decimalScale).toSignificant(significantDigits, format, rounding); }; _proto.toFixed = function toFixed(decimalPlaces, format, rounding) { if (decimalPlaces === void 0) { decimalPlaces = this.currency.decimals; } if (rounding === void 0) { rounding = exports.Rounding.ROUND_DOWN; } !(decimalPlaces <= this.currency.decimals) ? invariant(false, 'DECIMALS') : void 0; return _Fraction.prototype.divide.call(this, this.decimalScale).toFixed(decimalPlaces, format, rounding); }; _proto.toExact = function toExact(format) { if (format === void 0) { format = { groupSeparator: '' }; } Big$1.DP = this.currency.decimals; return new Big$1(this.quotient.toString()).div(this.decimalScale.toString()).toFormat(format); }; _createClass(CurrencyAmount, [{ key: "wrapped", get: function get() { if (this.currency.isToken) return this; return CurrencyAmount.fromFractionalAmount(this.currency.wrapped, this.numerator, this.denominator); } }]); return CurrencyAmount; }(Fraction); var Price = /*#__PURE__*/function (_Fraction) { _inheritsLoose(Price, _Fraction); /** * Construct a price, either with the base and quote currency amount, or the * @param args */ function Price() { var _this; var baseCurrency, quoteCurrency, denominator, numerator; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (args.length === 4) { baseCurrency = args[0]; quoteCurrency = args[1]; denominator = args[2]; numerator = args[3]; } else { var result = args[0].quoteAmount.divide(args[0].baseAmount); var _ref = [args[0].baseAmount.currency, args[0].quoteAmount.currency, result.denominator, result.numerator]; baseCurrency = _ref[0]; quoteCurrency = _ref[1]; denominator = _ref[2]; numerator = _ref[3]; } _this = _Fraction.call(this, numerator, denominator) || this; _this.baseCurrency = baseCurrency; _this.quoteCurrency = quoteCurrency; _this.scalar = new Fraction(JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(baseCurrency.decimals)), JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(quoteCurrency.decimals))); return _this; } /** * Flip the price, switching the base and quote currency */ var _proto = Price.prototype; _proto.invert = function invert() { return new Price(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator); } /** * Multiply the price by another price, returning a new price. The other price must have the same base currency as this price's quote currency * @param other the other price */ ; _proto.multiply = function multiply(other) { !this.quoteCurrency.equals(other.baseCurrency) ? invariant(false, 'TOKEN') : void 0; var fraction = _Fraction.prototype.multiply.call(this, other); return new Price(this.baseCurrency, other.quoteCurrency, fraction.denominator, fraction.numerator); } /** * Return the amount of quote currency corresponding to a given amount of the base currency * @param currencyAmount the amount of base currency to quote against the price */ ; _proto.quote = function quote(currencyAmount) { !currencyAmount.currency.equals(this.baseCurrency) ? invariant(false, 'TOKEN') : void 0; var result = _Fraction.prototype.multiply.call(this, currencyAmount); return CurrencyAmount.fromFractionalAmount(this.quoteCurrency, result.numerator, result.denominator); } /** * Get the value scaled by decimals for formatting * @private */ ; _proto.toSignificant = function toSignificant(significantDigits, format, rounding) { if (significantDigits === void 0) { significantDigits = 6; } return this.adjustedForDecimals.toSignificant(significantDigits, format, rounding); }; _proto.toFixed = function toFixed(decimalPlaces, format, rounding) { if (decimalPlaces === void 0) { decimalPlaces = 4; } return this.adjustedForDecimals.toFixed(decimalPlaces, format, rounding); }; _createClass(Price, [{ key: "adjustedForDecimals", get: function get() { return _Fraction.prototype.multiply.call(this, this.scalar); } }]); return Price; }(Fraction); var computePoolInitCodeHash = function computePoolInitCodeHash(_ref) { var creationCode = _ref.creationCode, deployData = _ref.deployData, masterDeployerAddress = _ref.masterDeployerAddress; return solidity.keccak256(['bytes'], [solidity.pack(['bytes', 'bytes'], [creationCode, abi$1.defaultAbiCoder.encode(['bytes', 'address'], [deployData, masterDeployerAddress])])]); }; var MASTER_DEPLOYER_ADDRESS = '0xa2A7Aa74cb94f37221FD49F5BA6F3fF876092700'; var CONSTANT_PRODUCT_POOL_CREATION_CODE = '0x6101806040523480156200001257600080fd5b5060405162004195380380620041958339810160408190526200003591620005d2565b604080518082018252600e81526d29bab9b434902628102a37b5b2b760911b6020918201528151808301835260018152603160f81b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f918101919091527fc2bf45081e840722410522aa366600d7fe4da5bfb5a5b417f4d5125b4ed180a4918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015246608082018190523060a08301529060c0016040516020818303038152906040528051906020012060808181525050506000806000808580602001905181019062000132919062000572565b929650909450925090506001600160a01b038416620001875760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b60448201526064015b60405180910390fd5b826001600160a01b0316846001600160a01b03161415620001eb5760405162461bcd60e51b815260206004820152601360248201527f4944454e544943414c5f4144445245535345530000000000000000000000000060448201526064016200017e565b6001600160a01b038416301415620002365760405162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a22faa27a5a2a760991b60448201526064016200017e565b6001600160a01b038316301415620002815760405162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a22faa27a5a2a760991b60448201526064016200017e565b612710821115620002c85760405162461bcd60e51b815260206004820152601060248201526f494e56414c49445f535741505f46454560801b60448201526064016200017e565b60408051600481526024810182526020810180516001600160e01b03166360a56c0160e11b17905290516000916001600160a01b038816916200030c9190620006b9565b600060405180830381855afa9150503d806000811462000349576040519150601f19603f3d011682016040523d82523d6000602084013e6200034e565b606091505b5060408051600481526024810182526020810180516001600160e01b0316630605066960e11b1790529051919350600092506001600160a01b03891691620003979190620006b9565b600060405180830381855afa9150503d8060008114620003d4576040519150601f19603f3d011682016040523d82523d6000602084013e620003d9565b606091505b5060408051600481526024810182526020810180516001600160e01b0316634da3182760e01b1790529051919350600092506001600160a01b038a1691620004229190620006b9565b600060405180830381855afa9150503d80600081146200045f576040519150601f19603f3d011682016040523d82523d6000602084013e62000464565b606091505b506001600160601b031960608a811b82166101405289901b166101605260a087905261271087900360c0528451909250620004aa9150840160209081019085016200069f565b6004558151620004c490830160209081019084016200054b565b60601b6001600160601b03191660e0528051620004eb90602090830181019083016200054b565b6001600160601b0319606091821b8116610100529089901b1661012052600160095583156200052a57600880546001600160e01b0316600160e01b1790555b50505050505050505062000739565b8051620005468162000720565b919050565b6000602082840312156200055e57600080fd5b81516200056b8162000720565b9392505050565b600080600080608085870312156200058957600080fd5b8451620005968162000720565b6020860151909450620005a98162000720565b6040860151606087015191945092508015158114620005c757600080fd5b939692955090935050565b60008060408385031215620005e657600080fd5b82516001600160401b0380821115620005fe57600080fd5b818501915085601f8301126200061357600080fd5b8151818111156200062857620006286200070a565b604051601f8201601f19908116603f011681019083821181831017156200065357620006536200070a565b816040528281528860208487010111156200066d57600080fd5b62000680836020830160208801620006d7565b8096505050505050620006966020840162000539565b90509250929050565b600060208284031215620006b257600080fd5b5051919050565b60008251620006cd818460208701620006d7565b9190910192915050565b60005b83811015620006f4578181015183820152602001620006da565b8381111562000704576000848401525b50505050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146200073657600080fd5b50565b60805160a05160c05160e05160601c6101005160601c6101205160601c6101405160601c6101605160601c61390062000895600039600081816105b301528181610791015281816108c00152818161096e01528181610ff6015281816110fe01528181611336015281816113a5015281816115e701528181611fc30152818161204a01526129e701526000818161032e0152818161070d01528181610a5301528181610b8201528181610fca01528181611095015281816112e2015281816114860152818161157901528181611d24015281816120830152818161216e01526128e801526000818161058c015281816118070152611c240152600081816103f901528181612650015281816127c6015281816128ac0152612a900152600081816102e20152612eb3015260006125520152600081816104200152818161315501526131c00152600081816103d2015261233901526139006000f3fe608060405234801561001057600080fd5b506004361061020b5760003560e01c8063627dd56a1161012a578063a69840a8116100bd578063c14ad8021161008c578063d21220a711610071578063d21220a7146105ae578063d505accf146105d5578063dd62ed3e146105e857600080fd5b8063c14ad8021461057e578063cf58879a1461058757600080fd5b8063a69840a81461051e578063a8f1f52e14610545578063a9059cbb14610558578063af8c09bf1461056b57600080fd5b80637ba0e2e7116100f95780637ba0e2e7146104a55780637ecebe00146104b857806392bc3219146104d857806395d89b41146104e257600080fd5b8063627dd56a1461045457806367e4ac2c1461046757806370a082311461047c5780637464fc3d1461049c57600080fd5b80632a07b6c7116101a25780634da31827116101715780634da31827146103f457806354cf2aeb1461041b5780635909c0d5146104425780635a3d54931461044b57600080fd5b80632a07b6c71461036c57806330adf81f1461038c578063313ce567146103b35780633644e515146103cd57600080fd5b80630c0a0cd2116101de5780630c0a0cd2146102dd5780630dfe16811461032957806318160ddd1461035057806323b872dd1461035957600080fd5b8063053da1c81461021057806306fdde03146102365780630902f1ac1461027f578063095ea7b3146102ba575b600080fd5b61022361021e366004613566565b610613565b6040519081526020015b60405180910390f35b6102726040518060400160405280600e81526020017f5375736869204c5020546f6b656e00000000000000000000000000000000000081525081565b60405161022d9190613716565b610287610c3e565b604080516dffffffffffffffffffffffffffff948516815293909216602084015263ffffffff169082015260600161022d565b6102cd6102c8366004613449565b610ca7565b604051901515815260200161022d565b6103047f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161022d565b6103047f000000000000000000000000000000000000000000000000000000000000000081565b61022360005481565b6102cd6103673660046134ae565b610d20565b61037f61037a366004613566565b610e6c565b60405161022d91906136b1565b6102237f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b6103bb601281565b60405160ff909116815260200161022d565b6102237f000000000000000000000000000000000000000000000000000000000000000081565b6103047f000000000000000000000000000000000000000000000000000000000000000081565b6102237f000000000000000000000000000000000000000000000000000000000000000081565b61022360055481565b61022360065481565b610223610462366004613566565b6111e1565b61046f611557565b60405161022d9190613657565b61022361048a36600461327d565b60016020526000908152604090205481565b61022360075481565b6102236104b3366004613566565b611656565b6102236104c636600461327d565b60036020526000908152604090205481565b6104e0611bb2565b005b6102726040518060400160405280600381526020017f534c50000000000000000000000000000000000000000000000000000000000081525081565b6102237f54726964656e743a436f6e7374616e7450726f6475637400000000000000000081565b610223610553366004613566565b611cad565b6102cd610566366004613449565b611de0565b610223610579366004613566565b611e65565b61022360045481565b6103047f000000000000000000000000000000000000000000000000000000000000000081565b6103047f000000000000000000000000000000000000000000000000000000000000000081565b6104e06105e33660046134ef565b61220e565b6102236105f6366004613475565b600260209081526000928352604080842090915290825290205481565b6000600954600114610686576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600660248201527f4c4f434b4544000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600260095560008080808061069d87890189613305565b9450945094509450945060008060006107056008546dffffffffffffffffffffffffffff808216926e01000000000000000000000000000083049091169163ffffffff7c01000000000000000000000000000000000000000000000000000000009091041690565b9250925092507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16141561096c5761078a85846dffffffffffffffffffffffffffff16846dffffffffffffffffffffffffffff1661254a565b98506107b87f00000000000000000000000000000000000000000000000000000000000000008a89896125ad565b6040517fbd50c7b1000000000000000000000000000000000000000000000000000000008152339063bd50c7b1906107f4908790600401613716565b600060405180830381600087803b15801561080e57600080fd5b505af1158015610822573d6000803e3d6000fd5b505050506000806108316128a5565b9150915086856dffffffffffffffffffffffffffff16830310156108b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414d4f554e545f494e00000000000000000000604482015260640161067d565b6108be8282878787612b1d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e460628a8f60405161095d929190918252602082015260400190565b60405180910390a45050610c2a565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1614610a21576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f494e56414c49445f494e5055545f544f4b454e00000000000000000000000000604482015260640161067d565b610a4c85836dffffffffffffffffffffffffffff16856dffffffffffffffffffffffffffff1661254a565b9850610a7a7f00000000000000000000000000000000000000000000000000000000000000008a89896125ad565b6040517fbd50c7b1000000000000000000000000000000000000000000000000000000008152339063bd50c7b190610ab6908790600401613716565b600060405180830381600087803b158015610ad057600080fd5b505af1158015610ae4573d6000803e3d6000fd5b50505050600080610af36128a5565b9150915086846dffffffffffffffffffffffffffff1682031015610b73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e53554646494349454e545f414d4f554e545f494e00000000000000000000604482015260640161067d565b610b808282878787612b1d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e460628a8f604051610c1f929190918252602082015260400190565b60405180910390a450505b505060016009555094979650505050505050565b6000806000610c9c6008546dffffffffffffffffffffffffffff808216926e01000000000000000000000000000083049091169163ffffffff7c01000000000000000000000000000000000000000000000000000000009091041690565b925092509250909192565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610d0f9086815260200190565b60405180910390a350600192915050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610dbd5773ffffffffffffffffffffffffffffffffffffffff8416600090815260026020908152604080832033845290915281208054849290610db7908490613792565b90915550505b73ffffffffffffffffffffffffffffffffffffffff841660009081526001602052604081208054849290610df2908490613792565b909155505073ffffffffffffffffffffffffffffffffffffffff8084166000818152