UNPKG

@techchainswapfinance/sdk

Version:

đź›  An SDK for building applications on top of STEPCOIN.

850 lines (687 loc) • 88.4 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 invariant = _interopDefault(require('tiny-invariant')); var warning = _interopDefault(require('tiny-warning')); var address = require('@ethersproject/address'); var _Big = _interopDefault(require('big.js')); var toFormat = _interopDefault(require('toformat')); var _Decimal = _interopDefault(require('decimal.js-light')); var solidity = require('@ethersproject/solidity'); var contracts = require('@ethersproject/contracts'); var networks = require('@ethersproject/networks'); var providers = require('@ethersproject/providers'); var IUniswapV2Pair = _interopDefault(require('@uniswap/v2-core/build/IUniswapV2Pair.json')); var _ANT_TOKEN_ADDRESS, _THIRD_PARTY_INFO, _INIT_CODE_HASH, _FACTORY_ADDRESS, _ROUTER_ADDRESS, _SUSHI_ADDRESS, _MASTERCHEF_ADDRESS, _BAR_ADDRESS, _MAKER_ADDRESS, _TIMELOCK_ADDRESS, _SOLIDITY_TYPE_MAXIMA; (function (ChainId) { ChainId[ChainId["MAINNET"] = 1] = "MAINNET"; ChainId[ChainId["ROPSTEN"] = 3] = "ROPSTEN"; ChainId[ChainId["RINKEBY"] = 4] = "RINKEBY"; ChainId[ChainId["G\xD6RLI"] = 5] = "G\xD6RLI"; ChainId[ChainId["KOVAN"] = 42] = "KOVAN"; ChainId[ChainId["MATIC"] = 137] = "MATIC"; ChainId[ChainId["MATIC_TESTNET"] = 80001] = "MATIC_TESTNET"; ChainId[ChainId["FANTOM"] = 250] = "FANTOM"; ChainId[ChainId["FANTOM_TESTNET"] = 4002] = "FANTOM_TESTNET"; ChainId[ChainId["XDAI"] = 100] = "XDAI"; ChainId[ChainId["BSC"] = 56] = "BSC"; ChainId[ChainId["BSC_TESTNET"] = 97] = "BSC_TESTNET"; ChainId[ChainId["ARBITRUM"] = 79377087078960] = "ARBITRUM"; ChainId[ChainId["MOONBASE"] = 1287] = "MOONBASE"; ChainId[ChainId["AVALANCHE"] = 43114] = "AVALANCHE"; ChainId[ChainId["FUJI"] = 43113] = "FUJI"; ChainId[ChainId["HECO"] = 128] = "HECO"; ChainId[ChainId["HECO_TESTNET"] = 256] = "HECO_TESTNET"; ChainId[ChainId["HARMONY"] = 1666600000] = "HARMONY"; ChainId[ChainId["HARMONY_TESTNET"] = 1666700000] = "HARMONY_TESTNET"; ChainId[ChainId["OKEX"] = 66] = "OKEX"; ChainId[ChainId["OKEX_TESTNET"] = 65] = "OKEX_TESTNET"; })(exports.ChainId || (exports.ChainId = {})); (function (TradeType) { TradeType[TradeType["EXACT_INPUT"] = 0] = "EXACT_INPUT"; TradeType[TradeType["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT"; })(exports.TradeType || (exports.TradeType = {})); (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 = {})); var ANT_TOKEN_ADDRESS = (_ANT_TOKEN_ADDRESS = {}, _ANT_TOKEN_ADDRESS[exports.ChainId.MAINNET] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.ROPSTEN] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.RINKEBY] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.GĂ–RLI] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.KOVAN] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.FANTOM] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.MATIC] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.MATIC_TESTNET] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.XDAI] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.BSC] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.BSC_TESTNET] = '0x2aC7A8C7101B83803f6fD8daa020E0288C36FC16', _ANT_TOKEN_ADDRESS[exports.ChainId.ARBITRUM] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.MOONBASE] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.AVALANCHE] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.FUJI] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.HECO] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.HECO_TESTNET] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.HARMONY] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.OKEX] = '', _ANT_TOKEN_ADDRESS[exports.ChainId.OKEX_TESTNET] = '', _ANT_TOKEN_ADDRESS); var THIRD_PARTY_INFO = (_THIRD_PARTY_INFO = {}, _THIRD_PARTY_INFO[exports.ChainId.MAINNET] = '', _THIRD_PARTY_INFO[exports.ChainId.ROPSTEN] = '', _THIRD_PARTY_INFO[exports.ChainId.RINKEBY] = '', _THIRD_PARTY_INFO[exports.ChainId.GĂ–RLI] = '', _THIRD_PARTY_INFO[exports.ChainId.KOVAN] = '', _THIRD_PARTY_INFO[exports.ChainId.FANTOM] = '', _THIRD_PARTY_INFO[exports.ChainId.FANTOM_TESTNET] = '', _THIRD_PARTY_INFO[exports.ChainId.MATIC] = { LP_TOKEN_SYMBOL: 'SUSHI-LP', LP_TOKEN_NAME: 'Sushiswap LPs', INIT_CODE_HASH: '0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303', FACTORY_ADDRESS: '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', ROUTER_ADDRESS: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506' }, _THIRD_PARTY_INFO[exports.ChainId.MATIC_TESTNET] = { LP_TOKEN_SYMBOL: 'SUSHI-LP', LP_TOKEN_NAME: 'Sushiswap LPs', INIT_CODE_HASH: '0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303', FACTORY_ADDRESS: '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', ROUTER_ADDRESS: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506' }, _THIRD_PARTY_INFO[exports.ChainId.XDAI] = '', _THIRD_PARTY_INFO[exports.ChainId.BSC] = { LP_TOKEN_SYMBOL: 'CAKE-LP', LP_TOKEN_NAME: 'Pancakeswap LPs', INIT_CODE_HASH: '0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5', FACTORY_ADDRESS: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73', ROUTER_ADDRESS: '0x10ed43c718714eb63d5aa57b78b54704e256024e' }, _THIRD_PARTY_INFO[exports.ChainId.BSC_TESTNET] = { LP_TOKEN_SYMBOL: 'CAKE-LP', LP_TOKEN_NAME: 'Pancakeswap LPs', INIT_CODE_HASH: '0xae7373e804a043c4c08107a81def627eeb3792e211fb4711fcfe32f0e4c45fd5', // INIT_CODE_HASH: '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', // ape FACTORY_ADDRESS: '0xAaA7E4d03CafDD1EBb774aDa645b5F1f05b11829', // FACTORY_ADDRESS: '0x152349604d49c2af10adee94b918b051104a143e', // ape ROUTER_ADDRESS: '0x28eE8f0f9Fdd620b0e51E51C77Ef7c926b47F713' // pancake // ROUTER_ADDRESS: '0x3380ae82e39e42ca34ebed69af67faa0683bb5c1' // ape }, _THIRD_PARTY_INFO[exports.ChainId.ARBITRUM] = '', _THIRD_PARTY_INFO[exports.ChainId.MOONBASE] = '', _THIRD_PARTY_INFO[exports.ChainId.AVALANCHE] = '', _THIRD_PARTY_INFO[exports.ChainId.FUJI] = '', _THIRD_PARTY_INFO[exports.ChainId.HECO] = '', _THIRD_PARTY_INFO[exports.ChainId.HECO_TESTNET] = '', _THIRD_PARTY_INFO[exports.ChainId.HARMONY] = '', _THIRD_PARTY_INFO[exports.ChainId.HARMONY_TESTNET] = '', _THIRD_PARTY_INFO[exports.ChainId.OKEX] = '', _THIRD_PARTY_INFO[exports.ChainId.OKEX_TESTNET] = '', _THIRD_PARTY_INFO); var INIT_CODE_HASH = (_INIT_CODE_HASH = {}, _INIT_CODE_HASH[exports.ChainId.MAINNET] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.ROPSTEN] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.RINKEBY] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.GĂ–RLI] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.KOVAN] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.FANTOM] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.FANTOM_TESTNET] = '', _INIT_CODE_HASH[exports.ChainId.MATIC] = '0x511f0f358fe530cda0859ec20becf391718fdf5a329be02f4c95361f3d6a42d8', _INIT_CODE_HASH[exports.ChainId.MATIC_TESTNET] = '0x622305c53f48476a1676ab1e8229684b0f4889cce3f42d4a25dfb9d8247a3dfe', _INIT_CODE_HASH[exports.ChainId.XDAI] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.BSC] = '0x34dd5c9ffd19b7da01d56a079d0ceb1522563ae4a67df6dc33dc2abb46d5636e', _INIT_CODE_HASH[exports.ChainId.BSC_TESTNET] = '0xae7373e804a043c4c08107a81def627eeb3792e211fb4711fcfe32f0e4c45fd5', _INIT_CODE_HASH[exports.ChainId.ARBITRUM] = '', _INIT_CODE_HASH[exports.ChainId.MOONBASE] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.AVALANCHE] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.FUJI] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.HECO] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.HECO_TESTNET] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.HARMONY] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.HARMONY_TESTNET] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.OKEX] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH[exports.ChainId.OKEX_TESTNET] = '0xf4ccce374816856d11f00e4069e7cada164065686fbef53c6167a63ec2fd8c5b', _INIT_CODE_HASH); var FACTORY_ADDRESS = (_FACTORY_ADDRESS = {}, _FACTORY_ADDRESS[exports.ChainId.MAINNET] = '0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac', _FACTORY_ADDRESS[exports.ChainId.ROPSTEN] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.RINKEBY] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.GĂ–RLI] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.KOVAN] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.FANTOM] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _FACTORY_ADDRESS[exports.ChainId.MATIC] = '0x81d7178de30ed6069Cbc2D56EE0A3D1A393A9858', _FACTORY_ADDRESS[exports.ChainId.MATIC_TESTNET] = '0x90f786153CAae42A25892687fFc28Aa01cD9e298', _FACTORY_ADDRESS[exports.ChainId.XDAI] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.BSC] = '0xD803336833E2b18568495eddE961cbA5022BF132', _FACTORY_ADDRESS[exports.ChainId.BSC_TESTNET] = '0xAaA7E4d03CafDD1EBb774aDa645b5F1f05b11829', _FACTORY_ADDRESS[exports.ChainId.ARBITRUM] = '', _FACTORY_ADDRESS[exports.ChainId.MOONBASE] = '0x2Ce3F07dD4c62b56a502E223A7cBE38b1d77A1b5', _FACTORY_ADDRESS[exports.ChainId.AVALANCHE] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.FUJI] = '0xd00ae08403B9bbb9124bB305C09058E32C39A48c', _FACTORY_ADDRESS[exports.ChainId.HECO] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.HECO_TESTNET] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.HARMONY] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.OKEX] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS[exports.ChainId.OKEX_TESTNET] = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', _FACTORY_ADDRESS); var ROUTER_ADDRESS = (_ROUTER_ADDRESS = {}, _ROUTER_ADDRESS[exports.ChainId.MAINNET] = '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F', _ROUTER_ADDRESS[exports.ChainId.RINKEBY] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.ROPSTEN] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.GĂ–RLI] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.KOVAN] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.FANTOM] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _ROUTER_ADDRESS[exports.ChainId.MATIC] = '0x5Ee27aa2B25720612c37A42802Aa417c63C520Aa', _ROUTER_ADDRESS[exports.ChainId.MATIC_TESTNET] = '0x02Cfd91bBcf7c964727b73a4e93A3Ff457FfF399', _ROUTER_ADDRESS[exports.ChainId.XDAI] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.BSC] = '0x3a1e652c5213F4f04917a2AA71F57729826A9d43', _ROUTER_ADDRESS[exports.ChainId.BSC_TESTNET] = '0x28eE8f0f9Fdd620b0e51E51C77Ef7c926b47F713', _ROUTER_ADDRESS[exports.ChainId.ARBITRUM] = '', _ROUTER_ADDRESS[exports.ChainId.MOONBASE] = '0xeB5c2BB5E83B51d83F3534Ae21E84336B8B376ef', _ROUTER_ADDRESS[exports.ChainId.AVALANCHE] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.FUJI] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.HECO] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.HECO_TESTNET] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.HARMONY] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.OKEX] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS[exports.ChainId.OKEX_TESTNET] = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506', _ROUTER_ADDRESS); var SUSHI_ADDRESS = (_SUSHI_ADDRESS = {}, _SUSHI_ADDRESS[exports.ChainId.MAINNET] = '0x6B3595068778DD592e39A122f4f5a5cF09C90fE2', _SUSHI_ADDRESS[exports.ChainId.ROPSTEN] = '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F', _SUSHI_ADDRESS[exports.ChainId.RINKEBY] = '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F', _SUSHI_ADDRESS[exports.ChainId.GĂ–RLI] = '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F', _SUSHI_ADDRESS[exports.ChainId.KOVAN] = '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F', _SUSHI_ADDRESS[exports.ChainId.FANTOM] = '', _SUSHI_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _SUSHI_ADDRESS[exports.ChainId.MATIC] = '', _SUSHI_ADDRESS[exports.ChainId.MATIC_TESTNET] = '', _SUSHI_ADDRESS[exports.ChainId.XDAI] = '', _SUSHI_ADDRESS[exports.ChainId.BSC] = '', _SUSHI_ADDRESS[exports.ChainId.BSC_TESTNET] = '', _SUSHI_ADDRESS[exports.ChainId.ARBITRUM] = '', _SUSHI_ADDRESS[exports.ChainId.MOONBASE] = '', _SUSHI_ADDRESS[exports.ChainId.AVALANCHE] = '', _SUSHI_ADDRESS[exports.ChainId.FUJI] = '', _SUSHI_ADDRESS[exports.ChainId.HECO] = '', _SUSHI_ADDRESS[exports.ChainId.HECO_TESTNET] = '', _SUSHI_ADDRESS[exports.ChainId.HARMONY] = '', _SUSHI_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '', _SUSHI_ADDRESS[exports.ChainId.OKEX] = '', _SUSHI_ADDRESS[exports.ChainId.OKEX_TESTNET] = '', _SUSHI_ADDRESS); var MASTERCHEF_ADDRESS = (_MASTERCHEF_ADDRESS = {}, _MASTERCHEF_ADDRESS[exports.ChainId.MAINNET] = '0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd', _MASTERCHEF_ADDRESS[exports.ChainId.ROPSTEN] = '0x80C7DD17B01855a6D2347444a0FCC36136a314de', _MASTERCHEF_ADDRESS[exports.ChainId.RINKEBY] = '0x80C7DD17B01855a6D2347444a0FCC36136a314de', _MASTERCHEF_ADDRESS[exports.ChainId.GĂ–RLI] = '0x80C7DD17B01855a6D2347444a0FCC36136a314de', _MASTERCHEF_ADDRESS[exports.ChainId.KOVAN] = '0x80C7DD17B01855a6D2347444a0FCC36136a314de', _MASTERCHEF_ADDRESS[exports.ChainId.FANTOM] = '', _MASTERCHEF_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _MASTERCHEF_ADDRESS[exports.ChainId.MATIC] = '', _MASTERCHEF_ADDRESS[exports.ChainId.MATIC_TESTNET] = '', _MASTERCHEF_ADDRESS[exports.ChainId.XDAI] = '', _MASTERCHEF_ADDRESS[exports.ChainId.BSC] = '', _MASTERCHEF_ADDRESS[exports.ChainId.BSC_TESTNET] = '', _MASTERCHEF_ADDRESS[exports.ChainId.ARBITRUM] = '', _MASTERCHEF_ADDRESS[exports.ChainId.MOONBASE] = '', _MASTERCHEF_ADDRESS[exports.ChainId.AVALANCHE] = '', _MASTERCHEF_ADDRESS[exports.ChainId.FUJI] = '', _MASTERCHEF_ADDRESS[exports.ChainId.HECO] = '', _MASTERCHEF_ADDRESS[exports.ChainId.HECO_TESTNET] = '', _MASTERCHEF_ADDRESS[exports.ChainId.HARMONY] = '', _MASTERCHEF_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '', _MASTERCHEF_ADDRESS[exports.ChainId.OKEX] = '', _MASTERCHEF_ADDRESS[exports.ChainId.OKEX_TESTNET] = '', _MASTERCHEF_ADDRESS); var BAR_ADDRESS = (_BAR_ADDRESS = {}, _BAR_ADDRESS[exports.ChainId.MAINNET] = '0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272', _BAR_ADDRESS[exports.ChainId.ROPSTEN] = '0x1be211D8DA40BC0ae8719c6663307Bfc987b1d6c', _BAR_ADDRESS[exports.ChainId.RINKEBY] = '0x1be211D8DA40BC0ae8719c6663307Bfc987b1d6c', _BAR_ADDRESS[exports.ChainId.GĂ–RLI] = '0x1be211D8DA40BC0ae8719c6663307Bfc987b1d6c', _BAR_ADDRESS[exports.ChainId.KOVAN] = '0x1be211D8DA40BC0ae8719c6663307Bfc987b1d6c', _BAR_ADDRESS[exports.ChainId.FANTOM] = '', _BAR_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _BAR_ADDRESS[exports.ChainId.MATIC] = '', _BAR_ADDRESS[exports.ChainId.MATIC_TESTNET] = '', _BAR_ADDRESS[exports.ChainId.XDAI] = '', _BAR_ADDRESS[exports.ChainId.BSC] = '', _BAR_ADDRESS[exports.ChainId.BSC_TESTNET] = '', _BAR_ADDRESS[exports.ChainId.ARBITRUM] = '', _BAR_ADDRESS[exports.ChainId.MOONBASE] = '', _BAR_ADDRESS[exports.ChainId.AVALANCHE] = '', _BAR_ADDRESS[exports.ChainId.FUJI] = '', _BAR_ADDRESS[exports.ChainId.HECO] = '', _BAR_ADDRESS[exports.ChainId.HECO_TESTNET] = '', _BAR_ADDRESS[exports.ChainId.HARMONY] = '', _BAR_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '', _BAR_ADDRESS[exports.ChainId.OKEX] = '', _BAR_ADDRESS[exports.ChainId.OKEX_TESTNET] = '', _BAR_ADDRESS); var MAKER_ADDRESS = (_MAKER_ADDRESS = {}, _MAKER_ADDRESS[exports.ChainId.MAINNET] = '0xE11fc0B43ab98Eb91e9836129d1ee7c3Bc95df50', _MAKER_ADDRESS[exports.ChainId.ROPSTEN] = '0x1b9d177CcdeA3c79B6c8F40761fc8Dc9d0500EAa', _MAKER_ADDRESS[exports.ChainId.RINKEBY] = '0x1b9d177CcdeA3c79B6c8F40761fc8Dc9d0500EAa', _MAKER_ADDRESS[exports.ChainId.GĂ–RLI] = '0x1b9d177CcdeA3c79B6c8F40761fc8Dc9d0500EAa', _MAKER_ADDRESS[exports.ChainId.KOVAN] = '0x1b9d177CcdeA3c79B6c8F40761fc8Dc9d0500EAa', _MAKER_ADDRESS[exports.ChainId.FANTOM] = '', _MAKER_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _MAKER_ADDRESS[exports.ChainId.MATIC] = '', _MAKER_ADDRESS[exports.ChainId.MATIC_TESTNET] = '', _MAKER_ADDRESS[exports.ChainId.XDAI] = '', _MAKER_ADDRESS[exports.ChainId.BSC] = '', _MAKER_ADDRESS[exports.ChainId.BSC_TESTNET] = '', _MAKER_ADDRESS[exports.ChainId.ARBITRUM] = '', _MAKER_ADDRESS[exports.ChainId.MOONBASE] = '', _MAKER_ADDRESS[exports.ChainId.AVALANCHE] = '', _MAKER_ADDRESS[exports.ChainId.FUJI] = '', _MAKER_ADDRESS[exports.ChainId.HECO] = '', _MAKER_ADDRESS[exports.ChainId.HECO_TESTNET] = '', _MAKER_ADDRESS[exports.ChainId.HARMONY] = '', _MAKER_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '', _MAKER_ADDRESS[exports.ChainId.OKEX] = '', _MAKER_ADDRESS[exports.ChainId.OKEX_TESTNET] = '', _MAKER_ADDRESS); var TIMELOCK_ADDRESS = (_TIMELOCK_ADDRESS = {}, _TIMELOCK_ADDRESS[exports.ChainId.MAINNET] = '0x9a8541Ddf3a932a9A922B607e9CF7301f1d47bD1', _TIMELOCK_ADDRESS[exports.ChainId.ROPSTEN] = '', _TIMELOCK_ADDRESS[exports.ChainId.RINKEBY] = '', _TIMELOCK_ADDRESS[exports.ChainId.GĂ–RLI] = '', _TIMELOCK_ADDRESS[exports.ChainId.KOVAN] = '', _TIMELOCK_ADDRESS[exports.ChainId.FANTOM] = '', _TIMELOCK_ADDRESS[exports.ChainId.FANTOM_TESTNET] = '', _TIMELOCK_ADDRESS[exports.ChainId.MATIC] = '', _TIMELOCK_ADDRESS[exports.ChainId.MATIC_TESTNET] = '', _TIMELOCK_ADDRESS[exports.ChainId.XDAI] = '', _TIMELOCK_ADDRESS[exports.ChainId.BSC] = '', _TIMELOCK_ADDRESS[exports.ChainId.BSC_TESTNET] = '', _TIMELOCK_ADDRESS[exports.ChainId.ARBITRUM] = '', _TIMELOCK_ADDRESS[exports.ChainId.MOONBASE] = '', _TIMELOCK_ADDRESS[exports.ChainId.AVALANCHE] = '', _TIMELOCK_ADDRESS[exports.ChainId.FUJI] = '', _TIMELOCK_ADDRESS[exports.ChainId.HECO] = '', _TIMELOCK_ADDRESS[exports.ChainId.HECO_TESTNET] = '', _TIMELOCK_ADDRESS[exports.ChainId.HARMONY] = '', _TIMELOCK_ADDRESS[exports.ChainId.HARMONY_TESTNET] = '', _TIMELOCK_ADDRESS[exports.ChainId.OKEX] = '', _TIMELOCK_ADDRESS[exports.ChainId.OKEX_TESTNET] = '', _TIMELOCK_ADDRESS); var MINIMUM_LIQUIDITY = /*#__PURE__*/JSBI.BigInt(1000); // 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 _998 = /*#__PURE__*/JSBI.BigInt(998); var _1000 = /*#__PURE__*/JSBI.BigInt(1000); var SolidityType; (function (SolidityType) { SolidityType["uint8"] = "uint8"; SolidityType["uint256"] = "uint256"; })(SolidityType || (SolidityType = {})); var SOLIDITY_TYPE_MAXIMA = (_SOLIDITY_TYPE_MAXIMA = {}, _SOLIDITY_TYPE_MAXIMA[SolidityType.uint8] = /*#__PURE__*/JSBI.BigInt('0xff'), _SOLIDITY_TYPE_MAXIMA[SolidityType.uint256] = /*#__PURE__*/JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), _SOLIDITY_TYPE_MAXIMA); 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; subClass.__proto__ = 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 { Date.prototype.toString.call(Reflect.construct(Date, [], 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; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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."); } it = o[Symbol.iterator](); return it.next.bind(it); } // 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)); function validateSolidityTypeInstance(value, solidityType) { !JSBI.greaterThanOrEqual(value, ZERO) ? invariant(false, value + " is not a " + solidityType + ".") : void 0; !JSBI.lessThanOrEqual(value, SOLIDITY_TYPE_MAXIMA[solidityType]) ? invariant(false, value + " is not a " + solidityType + ".") : void 0; } // warns if addresses are not checksummed 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.") ; } } function parseBigintIsh(bigintIsh) { return bigintIsh instanceof JSBI ? bigintIsh : typeof bigintIsh === 'bigint' ? JSBI.BigInt(bigintIsh.toString()) : JSBI.BigInt(bigintIsh); } // mock the on-chain sqrt function function sqrt(y) { validateSolidityTypeInstance(y, SolidityType.uint256); var z = ZERO; var x; if (JSBI.greaterThan(y, THREE)) { z = y; x = JSBI.add(JSBI.divide(y, TWO), ONE); while (JSBI.lessThan(x, z)) { z = x; x = JSBI.divide(JSBI.add(JSBI.divide(y, x), x), TWO); } } else if (JSBI.notEqual(y, ZERO)) { z = ONE; } return z; } // given an array of items sorted by `comparator`, insert an item into its sort index and constrain the size to // `maxSize` by removing the last item function sortedInsert(items, add, maxSize, comparator) { !(maxSize > 0) ? invariant(false, 'MAX_SIZE_ZERO') : void 0; // this is an invariant because the interface cannot return multiple removed items if items.length exceeds maxSize !(items.length <= maxSize) ? invariant(false, 'ITEMS_SIZE') : void 0; // short circuit first item add if (items.length === 0) { items.push(add); return null; } else { var isFull = items.length === maxSize; // short circuit if full and the additional item does not come before the last item if (isFull && comparator(items[items.length - 1], add) <= 0) { return add; } var lo = 0, hi = items.length; while (lo < hi) { var mid = lo + hi >>> 1; if (comparator(items[mid], add) <= 0) { lo = mid + 1; } else { hi = mid; } } items.splice(lo, 0, add); return isFull ? items.pop() : null; } } var _Currency$NATIVE; /** * A currency is any fungible financial instrument on Ethereum, including Ether and all ERC20 tokens. * * The only instance of the base class `Currency` is Ether. */ var Currency = /*#__PURE__*/function () { /** * Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`. * @param decimals decimals of the currency * @param symbol symbol of the currency * @param name of the currency */ function Currency(decimals, symbol, name) { validateSolidityTypeInstance(JSBI.BigInt(decimals), SolidityType.uint8); this.decimals = decimals; this.symbol = symbol; this.name = name; } Currency.getNativeCurrency = function getNativeCurrency(chainId) { if (!chainId) { throw Error("No chainId " + chainId); } if (!(chainId in Currency.NATIVE)) { throw Error("No native currency defined for chainId " + chainId); } return Currency.NATIVE[chainId]; }; Currency.getNativeCurrencySymbol = function getNativeCurrencySymbol(chainId) { var nativeCurrency = this.getNativeCurrency(chainId); return nativeCurrency.symbol; }; Currency.getNativeCurrencyName = function getNativeCurrencyName(chainId) { var nativeCurrency = this.getNativeCurrency(chainId); return nativeCurrency.name; }; var _proto = Currency.prototype; _proto.getSymbol = function getSymbol(chainId) { if (!chainId) { return this === null || this === void 0 ? void 0 : this.symbol; } if ((this === null || this === void 0 ? void 0 : this.symbol) === 'ETH') { return Currency.getNativeCurrencySymbol(chainId); } // if (this?.symbol === 'WETH') { // return `W${Currency.getNativeCurrencySymbol(chainId)}` // } return this === null || this === void 0 ? void 0 : this.symbol; }; _proto.getName = function getName(chainId) { if (!chainId) { return this === null || this === void 0 ? void 0 : this.name; } if ((this === null || this === void 0 ? void 0 : this.name) === 'Ether') { return Currency.getNativeCurrencyName(chainId); } return this === null || this === void 0 ? void 0 : this.name; }; return Currency; }(); Currency.ETHER = /*#__PURE__*/new Currency(18, 'ETH', 'Ether'); Currency.BNB = /*#__PURE__*/new Currency(18, 'BNB', 'Binance Coin'); Currency.FTM = /*#__PURE__*/new Currency(18, 'FTM', 'Fantom'); Currency.MATIC = /*#__PURE__*/new Currency(18, 'MATIC', 'Matic'); Currency.XDAI = /*#__PURE__*/new Currency(18, 'XDAI', 'xDai'); Currency.GLMR = /*#__PURE__*/new Currency(18, 'GLMR', 'Glimmer'); Currency.AVAX = /*#__PURE__*/new Currency(18, 'AVAX', 'Avalanche'); Currency.HT = /*#__PURE__*/new Currency(18, 'HT', 'Heco Token'); Currency.ONE = /*#__PURE__*/new Currency(18, 'ONE', 'Harmony'); Currency.OKT = /*#__PURE__*/new Currency(18, 'OKT', 'OKExChain'); Currency.NATIVE = (_Currency$NATIVE = {}, _Currency$NATIVE[exports.ChainId.MAINNET] = Currency.ETHER, _Currency$NATIVE[exports.ChainId.ROPSTEN] = Currency.ETHER, _Currency$NATIVE[exports.ChainId.RINKEBY] = Currency.ETHER, _Currency$NATIVE[exports.ChainId.GĂ–RLI] = Currency.ETHER, _Currency$NATIVE[exports.ChainId.KOVAN] = Currency.ETHER, _Currency$NATIVE[exports.ChainId.FANTOM] = Currency.FTM, _Currency$NATIVE[exports.ChainId.FANTOM_TESTNET] = Currency.FTM, _Currency$NATIVE[exports.ChainId.MATIC] = Currency.MATIC, _Currency$NATIVE[exports.ChainId.MATIC_TESTNET] = Currency.MATIC, _Currency$NATIVE[exports.ChainId.XDAI] = Currency.XDAI, _Currency$NATIVE[exports.ChainId.BSC] = Currency.BNB, _Currency$NATIVE[exports.ChainId.BSC_TESTNET] = Currency.BNB, _Currency$NATIVE[exports.ChainId.ARBITRUM] = Currency.ETHER, _Currency$NATIVE[exports.ChainId.MOONBASE] = Currency.GLMR, _Currency$NATIVE[exports.ChainId.AVALANCHE] = Currency.AVAX, _Currency$NATIVE[exports.ChainId.FUJI] = Currency.AVAX, _Currency$NATIVE[exports.ChainId.HECO] = Currency.HT, _Currency$NATIVE[exports.ChainId.HECO_TESTNET] = Currency.HT, _Currency$NATIVE[exports.ChainId.HARMONY] = Currency.ONE, _Currency$NATIVE[exports.ChainId.HARMONY_TESTNET] = Currency.ONE, _Currency$NATIVE[exports.ChainId.OKEX] = Currency.OKT, _Currency$NATIVE[exports.ChainId.OKEX_TESTNET] = Currency.OKT, _Currency$NATIVE); var ETHER = Currency.ETHER; // const NATIVE_CURRENCY = { var _WETH; /** * Represents an ERC20 token with a unique address and some metadata. */ var Token = /*#__PURE__*/function (_Currency) { _inheritsLoose(Token, _Currency); function Token(chainId, address, decimals, symbol, name) { var _this; _this = _Currency.call(this, decimals, symbol, name) || this; _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) { // short circuit on reference equality if (this === other) { return true; } return 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 Token; }(Currency); /** * 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; } } // In reality this is a map of the wrapped version of the native token for a given network. // TODO: Rename to WNATIVE for sanity var WETH = (_WETH = {}, _WETH[exports.ChainId.MAINNET] = /*#__PURE__*/new Token(exports.ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.ROPSTEN] = /*#__PURE__*/new Token(exports.ChainId.ROPSTEN, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.RINKEBY] = /*#__PURE__*/new Token(exports.ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.GĂ–RLI] = /*#__PURE__*/new Token(exports.ChainId.GĂ–RLI, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.KOVAN] = /*#__PURE__*/new Token(exports.ChainId.KOVAN, '0xd0A1E359811322d97991E03f863a0C30C2cF029C', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.FANTOM] = /*#__PURE__*/new Token(exports.ChainId.FANTOM, '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83', 18, 'WFTM', 'Wrapped FTM'), _WETH[exports.ChainId.FANTOM_TESTNET] = /*#__PURE__*/new Token(exports.ChainId.FANTOM_TESTNET, '0xf1277d1Ed8AD466beddF92ef448A132661956621', 18, 'FTM', 'Wrapped FTM'), _WETH[exports.ChainId.MATIC] = /*#__PURE__*/new Token(exports.ChainId.MATIC, '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 18, 'WMATIC', 'Wrapped Matic'), _WETH[exports.ChainId.MATIC_TESTNET] = /*#__PURE__*/new Token(exports.ChainId.MATIC_TESTNET, '0x5B67676a984807a212b1c59eBFc9B3568a474F0a', 18, 'WMATIC', 'Wrapped Matic'), _WETH[exports.ChainId.XDAI] = /*#__PURE__*/new Token(exports.ChainId.XDAI, '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', 18, 'WXDAI', 'Wrapped xDai'), _WETH[exports.ChainId.BSC] = /*#__PURE__*/new Token(exports.ChainId.BSC, '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 18, 'WBNB', 'Wrapped BNB'), _WETH[exports.ChainId.BSC_TESTNET] = /*#__PURE__*/new Token(exports.ChainId.BSC_TESTNET, '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd', 18, 'WBNB', 'Wrapped BNB'), _WETH[exports.ChainId.ARBITRUM] = /*#__PURE__*/new Token(exports.ChainId.ARBITRUM, '0xf8456e5e6A225C2C1D74D8C9a4cB2B1d5dc1153b', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.MOONBASE] = /*#__PURE__*/new Token(exports.ChainId.MOONBASE, '0xe73763DB808ecCDC0E36bC8E32510ED126910394', 18, 'WETH', 'Wrapped Ether'), _WETH[exports.ChainId.AVALANCHE] = /*#__PURE__*/new Token(exports.ChainId.AVALANCHE, '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', 18, 'WAVAX', 'Wrapped AVAX'), _WETH[exports.ChainId.FUJI] = /*#__PURE__*/new Token(exports.ChainId.FUJI, '0xd00ae08403B9bbb9124bB305C09058E32C39A48c', 18, 'WAVAX', 'Wrapped AVAX'), _WETH[exports.ChainId.HECO] = /*#__PURE__*/new Token(exports.ChainId.HECO, '0x5545153CCFcA01fbd7Dd11C0b23ba694D9509A6F', 18, 'WHT', 'Wrapped HT'), _WETH[exports.ChainId.HECO_TESTNET] = /*#__PURE__*/new Token(exports.ChainId.HECO_TESTNET, '0x5B2DA6F42CA09C77D577a12BeaD0446148830687', 18, 'WHT', 'Wrapped HT'), _WETH[exports.ChainId.HARMONY] = /*#__PURE__*/new Token(exports.ChainId.HARMONY, '0xcF664087a5bB0237a0BAd6742852ec6c8d69A27a', 18, 'WONE', 'Wrapped ONE'), _WETH[exports.ChainId.HARMONY_TESTNET] = /*#__PURE__*/new Token(exports.ChainId.HARMONY_TESTNET, '0x7a2afac38517d512E55C0bCe3b6805c10a04D60F', 18, 'WONE', 'Wrapped ONE'), _WETH[exports.ChainId.OKEX] = /*#__PURE__*/new Token(exports.ChainId.OKEX, '0x8F8526dbfd6E38E3D8307702cA8469Bae6C56C15', 18, 'WOKT', 'Wrapped OKExChain'), _WETH[exports.ChainId.OKEX_TESTNET] = /*#__PURE__*/new Token(exports.ChainId.OKEX_TESTNET, '0x2219845942d28716c0F7C605765fABDcA1a7d9E0', 18, 'WOKT', 'Wrapped OKExChain'), _WETH); var _toSignificantRoundin, _toFixedRounding; var Decimal = /*#__PURE__*/toFormat(_Decimal); var Big = /*#__PURE__*/toFormat(_Big); 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 = ONE; } this.numerator = parseBigintIsh(numerator); this.denominator = parseBigintIsh(denominator); } // 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 = other instanceof Fraction ? other : new Fraction(parseBigintIsh(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 = other instanceof Fraction ? other : new Fraction(parseBigintIsh(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 = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)); return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)); }; _proto.equalTo = function equalTo(other) { var otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)); return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)); }; _proto.greaterThan = function greaterThan(other) { var otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)); return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)); }; _proto.multiply = function multiply(other) { var otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)); return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator)); }; _proto.divide = function divide(other) { var otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(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); }; _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); } }]); return Fraction; }(); var Big$1 = /*#__PURE__*/toFormat(_Big); var CurrencyAmount = /*#__PURE__*/function (_Fraction) { _inheritsLoose(CurrencyAmount, _Fraction); // amount _must_ be raw, i.e. in the native representation function CurrencyAmount(currency, amount) { var _this; var parsedAmount = parseBigintIsh(amount); validateSolidityTypeInstance(parsedAmount, SolidityType.uint256); _this = _Fraction.call(this, parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(currency.decimals))) || this; _this.currency = currency; return _this; } /** * Helper that calls the constructor with the ETHER currency * @param amount ether amount in wei */ CurrencyAmount.ether = function ether(amount) { return new CurrencyAmount(ETHER, amount); }; var _proto = CurrencyAmount.prototype; _proto.add = function add(other) { !currencyEquals(this.currency, other.currency) ? invariant(false, 'TOKEN') : void 0; return new CurrencyAmount(this.currency, JSBI.add(this.raw, other.raw)); }; _proto.subtract = function subtract(other) { !currencyEquals(this.currency, other.currency) ? invariant(false, 'TOKEN') : void 0; return new CurrencyAmount(this.currency, JSBI.subtract(this.raw, other.raw)); }; _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.toSignificant.call(this, 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.toFixed.call(this, 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.numerator.toString()).div(this.denominator.toString()).toFormat(format); }; _createClass(CurrencyAmount, [{ key: "raw", get: function get() { return this.numerator; } }]); return CurrencyAmount; }(Fraction); var TokenAmount = /*#__PURE__*/function (_CurrencyAmount) { _inheritsLoose(TokenAmount, _CurrencyAmount); // amount _must_ be raw, i.e. in the native representation function TokenAmount(token, amount) { var _this; _this = _CurrencyAmount.call(this, token, amount) || this; _this.token = token; return _this; } var _proto = TokenAmount.prototype; _proto.add = function add(other) { !this.token.equals(other.token) ? invariant(false, 'TOKEN') : void 0; return new TokenAmount(this.token, JSBI.add(this.raw, other.raw)); }; _proto.subtract = function subtract(other) { !this.token.equals(other.token) ? invariant(false, 'TOKEN') : void 0; return new TokenAmount(this.token, JSBI.subtract(this.raw, other.raw)); }; return TokenAmount; }(CurrencyAmount); var Price = /*#__PURE__*/function (_Fraction) { _inheritsLoose(Price, _Fraction); // denominator and numerator _must_ be raw, i.e. in the native representation function Price(baseCurrency, quoteCurrency, denominator, numerator) { var _this; _this = _Fraction.call(this, numerator, denominator) || this; _this.baseCurrency = baseCurrency; _this.quoteCurrency = quoteCurrency; _this.scalar = new Fraction(JSBI.exponentiate(TEN, JSBI.BigInt(baseCurrency.decimals)), JSBI.exponentiate(TEN, JSBI.BigInt(quoteCurrency.decimals))); return _this; } Price.fromRoute = function fromRoute(route) { var prices = []; for (var _iterator = _createForOfIteratorHelperLoose(route.pairs.entries()), _step; !(_step = _iterator()).done;) { var _step$value = _step.value, i = _step$value[0], pair = _step$value[1]; prices.push(route.path[i].equals(pair.token0) ? new Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.raw, pair.reserve1.raw) : new Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.raw, pair.reserve0.raw)); } return prices.slice(1).reduce(function (accumulator, currentValue) { return accumulator.multiply(currentValue); }, prices[0]); }; var _proto = Price.prototype; _proto.invert = function invert() { return new Price(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator); }; _proto.multiply = function multiply(other) { !currencyEquals(this.quoteCurrency, 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); } // performs floor division on overflow ; _proto.quote = function quote(currencyAmount) { !currencyEquals(currencyAmount.currency, this.baseCurrency) ? invariant(false, 'TOKEN') : void 0; if (this.quoteCurrency instanceof Token) { return new TokenAmount(this.quoteCurrency, _Fraction.prototype.multiply.call(this, currencyAmount.raw).quotient); } return CurrencyAmount.ether(_Fraction.prototype.multiply.call(this, currencyAmount.raw).quotient); }; _proto.toSignificant = function toSignificant(significantDigits, format, rounding) { if (significantDigits === void 0) { significantDigits = 6; } return this.adjusted.toSignificant(significantDigits, format, rounding);