bxswap-sdk
Version:
An SDK for building applications on top of DXswap.
1,985 lines (1,869 loc) • 126 kB
JavaScript
'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 address = require('@ethersproject/address');
var _contracts_json = require('dxswap-core/.contracts.json');
var _contracts_json$1 = require('dxswap-periphery/.contracts.json');
var _Big = _interopDefault(require('big.js'));
var toFormat = _interopDefault(require('toformat'));
var _Decimal = _interopDefault(require('decimal.js-light'));
var solidity = require('@ethersproject/solidity');
var ethers = require('ethers');
var contracts = require('@ethersproject/contracts');
var networks = require('@ethersproject/networks');
var providers = require('@ethersproject/providers');
var IDXswapPair = _interopDefault(require('dxswap-core/build/IDXswapPair.json'));
var IDXswapFactory = _interopDefault(require('dxswap-core/build/IDXswapFactory.json'));
var abi = require('@ethersproject/abi');
var fetch = _interopDefault(require('node-fetch'));
var PERMISSIVE_MULTICALL_ABI = [
{
inputs: [
{
components: [
{
internalType: "address",
name: "target",
type: "address"
},
{
internalType: "bytes",
name: "callData",
type: "bytes"
}
],
internalType: "struct PermissiveMulticall.Call[]",
name: "calls",
type: "tuple[]"
}
],
name: "aggregate",
outputs: [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256"
},
{
internalType: "bytes[]",
name: "returnData",
type: "bytes[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
components: [
{
internalType: "address",
name: "target",
type: "address"
},
{
internalType: "bytes",
name: "callData",
type: "bytes"
}
],
internalType: "struct PermissiveMulticall.Call[]",
name: "calls",
type: "tuple[]"
}
],
name: "aggregateWithPermissiveness",
outputs: [
{
internalType: "uint256",
name: "blockNumber",
type: "uint256"
},
{
components: [
{
internalType: "bool",
name: "success",
type: "bool"
},
{
internalType: "bytes",
name: "data",
type: "bytes"
}
],
internalType: "struct PermissiveMulticall.CallOutcome[]",
name: "callOutcomes",
type: "tuple[]"
}
],
stateMutability: "view",
type: "function"
}
];
var stakingRewardsDistributionFactory = [
{
inputs: [
{
internalType: "address",
name: "_rewardTokensValidatorAddress",
type: "address"
},
{
internalType: "address",
name: "_stakableTokenValidatorAddress",
type: "address"
}
],
stateMutability: "nonpayable",
type: "constructor"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address",
name: "owner",
type: "address"
},
{
indexed: false,
internalType: "address",
name: "deployedAt",
type: "address"
}
],
name: "DistributionCreated",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
inputs: [
{
internalType: "address[]",
name: "_rewardTokensAddresses",
type: "address[]"
},
{
internalType: "address",
name: "_stakableTokenAddress",
type: "address"
},
{
internalType: "uint256[]",
name: "_rewardAmounts",
type: "uint256[]"
},
{
internalType: "uint64",
name: "_startingTimestamp",
type: "uint64"
},
{
internalType: "uint64",
name: "_endingTimestmp",
type: "uint64"
},
{
internalType: "bool",
name: "_locked",
type: "bool"
},
{
internalType: "uint256",
name: "_stakingCap",
type: "uint256"
}
],
name: "createDistribution",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
name: "distributions",
outputs: [
{
internalType: "contract ERC20StakingRewardsDistribution",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "getDistributionsAmount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "owner",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "renounceOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "rewardTokensValidator",
outputs: [
{
internalType: "contract IRewardTokensValidator",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_rewardTokensValidatorAddress",
type: "address"
}
],
name: "setRewardTokensValidator",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_stakableTokenValidatorAddress",
type: "address"
}
],
name: "setStakableTokenValidator",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "stakableTokenValidator",
outputs: [
{
internalType: "contract IStakableTokenValidator",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "transferOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
}
];
var stakingRewardsDistribution = [
{
anonymous: false,
inputs: [
],
name: "Canceled",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "claimer",
type: "address"
},
{
indexed: false,
internalType: "uint256[]",
name: "amounts",
type: "uint256[]"
}
],
name: "Claimed",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address[]",
name: "rewardsTokenAddresses",
type: "address[]"
},
{
indexed: false,
internalType: "address",
name: "stakableTokenAddress",
type: "address"
},
{
indexed: false,
internalType: "uint256[]",
name: "rewardsAmounts",
type: "uint256[]"
},
{
indexed: false,
internalType: "uint64",
name: "startingTimestamp",
type: "uint64"
},
{
indexed: false,
internalType: "uint64",
name: "endingTimestamp",
type: "uint64"
},
{
indexed: false,
internalType: "bool",
name: "locked",
type: "bool"
},
{
indexed: false,
internalType: "uint256",
name: "stakingCap",
type: "uint256"
}
],
name: "Initialized",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256[]",
name: "amounts",
type: "uint256[]"
}
],
name: "Recovered",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "staker",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256"
}
],
name: "Staked",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "withdrawer",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256"
}
],
name: "Withdrawn",
type: "event"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
},
{
internalType: "address",
name: "",
type: "address"
}
],
name: "claimedReward",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
},
{
internalType: "address",
name: "",
type: "address"
}
],
name: "consolidatedRewardsPerStakedToken",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
},
{
internalType: "address",
name: "",
type: "address"
}
],
name: "earnedRewards",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "endingTimestamp",
outputs: [
{
internalType: "uint64",
name: "",
type: "uint64"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "initialized",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "lastConsolidationTimestamp",
outputs: [
{
internalType: "uint64",
name: "",
type: "uint64"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "locked",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "owner",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "recoverableUnassignedReward",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "renounceOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "rewardAmount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "rewardPerStakedToken",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
name: "rewardTokens",
outputs: [
{
internalType: "contract ERC20",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "secondsDuration",
outputs: [
{
internalType: "uint64",
name: "",
type: "uint64"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "stakableToken",
outputs: [
{
internalType: "contract ERC20",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "stakedTokenAmount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "stakedTokensOf",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "stakingCap",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "startingTimestamp",
outputs: [
{
internalType: "uint64",
name: "",
type: "uint64"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
name: "totalClaimedRewards",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "totalStakedTokensAmount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "transferOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "getRewardTokens",
outputs: [
{
internalType: "contract ERC20[]",
name: "",
type: "address[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_claimer",
type: "address"
}
],
name: "getClaimedRewards",
outputs: [
{
internalType: "uint256[]",
name: "",
type: "uint256[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address[]",
name: "_rewardTokenAddresses",
type: "address[]"
},
{
internalType: "address",
name: "_stakableTokenAddress",
type: "address"
},
{
internalType: "uint256[]",
name: "_rewardAmounts",
type: "uint256[]"
},
{
internalType: "uint64",
name: "_startingTimestamp",
type: "uint64"
},
{
internalType: "uint64",
name: "_endingTimestamp",
type: "uint64"
},
{
internalType: "bool",
name: "_locked",
type: "bool"
},
{
internalType: "uint256",
name: "_stakingCap",
type: "uint256"
}
],
name: "initialize",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "cancel",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "recoverUnassignedRewards",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_amount",
type: "uint256"
}
],
name: "stake",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_amount",
type: "uint256"
}
],
name: "withdraw",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256[]",
name: "_amounts",
type: "uint256[]"
},
{
internalType: "address",
name: "_recipient",
type: "address"
}
],
name: "claim",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_recipient",
type: "address"
}
],
name: "claimAll",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_recipient",
type: "address"
}
],
name: "exit",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "consolidateReward",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_staker",
type: "address"
}
],
name: "claimableRewards",
outputs: [
{
internalType: "uint256[]",
name: "",
type: "uint256[]"
}
],
stateMutability: "view",
type: "function"
}
];
var tokenRegistry = [
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256",
name: "listId",
type: "uint256"
},
{
indexed: false,
internalType: "string",
name: "listName",
type: "string"
}
],
name: "AddList",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256",
name: "listId",
type: "uint256"
},
{
indexed: false,
internalType: "address",
name: "token",
type: "address"
}
],
name: "AddToken",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256",
name: "listId",
type: "uint256"
},
{
indexed: false,
internalType: "address",
name: "token",
type: "address"
}
],
name: "RemoveToken",
type: "event"
},
{
inputs: [
{
internalType: "string",
name: "_listName",
type: "string"
}
],
name: "addList",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_listId",
type: "uint256"
},
{
internalType: "address[]",
name: "_tokens",
type: "address[]"
}
],
name: "addTokens",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_trader",
type: "address"
},
{
internalType: "address[]",
name: "_assetAddresses",
type: "address[]"
}
],
name: "getExternalBalances",
outputs: [
{
internalType: "uint256[]",
name: "",
type: "uint256[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_listId",
type: "uint256"
}
],
name: "getTokens",
outputs: [
{
internalType: "address[]",
name: "",
type: "address[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address[]",
name: "_tokens",
type: "address[]"
}
],
name: "getTokensData",
outputs: [
{
internalType: "string[]",
name: "names",
type: "string[]"
},
{
internalType: "string[]",
name: "symbols",
type: "string[]"
},
{
internalType: "uint256[]",
name: "decimals",
type: "uint256[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_listId",
type: "uint256"
},
{
internalType: "uint256",
name: "_start",
type: "uint256"
},
{
internalType: "uint256",
name: "_end",
type: "uint256"
}
],
name: "getTokensRange",
outputs: [
{
internalType: "address[]",
name: "tokensRange",
type: "address[]"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_listId",
type: "uint256"
},
{
internalType: "address",
name: "_token",
type: "address"
}
],
name: "isTokenActive",
outputs: [
{
internalType: "bool",
name: "",
type: "bool"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "listCount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
],
name: "owner",
outputs: [
{
internalType: "address",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "_listId",
type: "uint256"
},
{
internalType: "address[]",
name: "_tokens",
type: "address[]"
}
],
name: "removeTokens",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
],
name: "renounceOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
name: "tcrs",
outputs: [
{
internalType: "uint256",
name: "listId",
type: "uint256"
},
{
internalType: "string",
name: "listName",
type: "string"
},
{
internalType: "uint256",
name: "activeTokenCount",
type: "uint256"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "transferOwnership",
outputs: [
],
stateMutability: "nonpayable",
type: "function"
}
];
var coreCandle = {
deployer: '0x546D090bbcEC3d96903d41e38C3436c1C601AF9c',
factory: '0x251cd2C527Eca282a8C6A4Ef75EfAb19A9Ac5796',
feeReceiver: '0x546D090bbcEC3d96903d41e38C3436c1C601AF9c',
feeSetter: '0x546D090bbcEC3d96903d41e38C3436c1C601AF9c'
};
var peripheryCandle = {
router: '0x252D8FDAA323094fe43cCa93ad8e650fC72521A7'
};
var _FACTORY_ADDRESS, _ROUTER_ADDRESS, _STAKING_REWARDS_FACT, _TOKEN_REGISTRY_ADDRE, _DXSWAP_TOKEN_LIST_ID, _INIT_CODE_HASH, _SOLIDITY_TYPE_MAXIMA, _PERMISSIVE_MULTICALL;
(function (ChainId) {
ChainId[ChainId["MAINNET"] = 1] = "MAINNET";
ChainId[ChainId["RINKEBY"] = 4] = "RINKEBY";
ChainId[ChainId["ARBITRUM_TESTNET_V3"] = 79377087078960] = "ARBITRUM_TESTNET_V3";
ChainId[ChainId["SOKOL"] = 77] = "SOKOL";
ChainId[ChainId["XDAI"] = 100] = "XDAI";
ChainId[ChainId["MATIC"] = 137] = "MATIC";
ChainId[ChainId["CANDLE"] = 534] = "CANDLE";
})(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 ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
var FACTORY_ADDRESS = (_FACTORY_ADDRESS = {}, _FACTORY_ADDRESS[exports.ChainId.MAINNET] = _contracts_json.mainnet.factory, _FACTORY_ADDRESS[exports.ChainId.RINKEBY] = _contracts_json.rinkeby.factory, _FACTORY_ADDRESS[exports.ChainId.ARBITRUM_TESTNET_V3] = _contracts_json.arbitrumTestnetV3.factory, _FACTORY_ADDRESS[exports.ChainId.SOKOL] = _contracts_json.sokol.factory, _FACTORY_ADDRESS[exports.ChainId.XDAI] = _contracts_json.xdai.factory, _FACTORY_ADDRESS[exports.ChainId.MATIC] = _contracts_json.matic.factory, _FACTORY_ADDRESS[exports.ChainId.CANDLE] = coreCandle.factory, _FACTORY_ADDRESS);
var ROUTER_ADDRESS = (_ROUTER_ADDRESS = {}, _ROUTER_ADDRESS[exports.ChainId.RINKEBY] = _contracts_json$1.rinkeby.router, _ROUTER_ADDRESS[exports.ChainId.MAINNET] = _contracts_json$1.mainnet.router, _ROUTER_ADDRESS[exports.ChainId.ARBITRUM_TESTNET_V3] = _contracts_json$1.arbitrumTestnetV3.router, _ROUTER_ADDRESS[exports.ChainId.SOKOL] = _contracts_json$1.sokol.router, _ROUTER_ADDRESS[exports.ChainId.XDAI] = _contracts_json$1.xdai.router, _ROUTER_ADDRESS[exports.ChainId.MATIC] = _contracts_json$1.matic.router, _ROUTER_ADDRESS[exports.ChainId.CANDLE] = peripheryCandle.router, _ROUTER_ADDRESS);
var STAKING_REWARDS_FACTORY_ADDRESS = (_STAKING_REWARDS_FACT = {}, _STAKING_REWARDS_FACT[exports.ChainId.MAINNET] = '0x0000000000000000000000000000000000001234', _STAKING_REWARDS_FACT[exports.ChainId.RINKEBY] = '0xDcA39454f0B83c6f0807708b0E6a620dd9BA6808', _STAKING_REWARDS_FACT[exports.ChainId.ARBITRUM_TESTNET_V3] = '0xB95Ad562EDE8DD78BBFC287fA18150e802b09D9F', _STAKING_REWARDS_FACT[exports.ChainId.SOKOL] = '0xD436e756Cf41318ADeC62E8dCbEF2608753Ae068', _STAKING_REWARDS_FACT[exports.ChainId.XDAI] = '0xCD2A45F36464FdB1065160e03A2353996Ea8Ff57', _STAKING_REWARDS_FACT[exports.ChainId.MATIC] = '0x0000000000000000000000000000000000001234', _STAKING_REWARDS_FACT);
var TOKEN_REGISTRY_ADDRESS = (_TOKEN_REGISTRY_ADDRE = {}, _TOKEN_REGISTRY_ADDRE[exports.ChainId.MAINNET] = '0x93DB90445B76329e9ed96ECd74e76D8fbf2590d8', _TOKEN_REGISTRY_ADDRE[exports.ChainId.RINKEBY] = '0x815d1b18f6baaeb3853b0f637475a5c2b28e2253', _TOKEN_REGISTRY_ADDRE[exports.ChainId.ARBITRUM_TESTNET_V3] = '0x9d6f6d86b81289e40e07fcda805c06f6e9b8f629', _TOKEN_REGISTRY_ADDRE[exports.ChainId.SOKOL] = '0x681c3836a5589b933062ACA4fd846c1287a2865F', _TOKEN_REGISTRY_ADDRE[exports.ChainId.XDAI] = '0x85E001DfFF16F388Bc32Cd18009ceDF8F9b62C9E', _TOKEN_REGISTRY_ADDRE[exports.ChainId.MATIC] = '0x0000000000000000000000000000000000001234', _TOKEN_REGISTRY_ADDRE);
var DXSWAP_TOKEN_LIST_ID = (_DXSWAP_TOKEN_LIST_ID = {}, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.MAINNET] = 1, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.RINKEBY] = 1, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.ARBITRUM_TESTNET_V3] = 1, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.SOKOL] = 1, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.XDAI] = 5, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.MATIC] = 137, _DXSWAP_TOKEN_LIST_ID[exports.ChainId.CANDLE] = 534, _DXSWAP_TOKEN_LIST_ID);
var INIT_CODE_HASH = (_INIT_CODE_HASH = {}, _INIT_CODE_HASH[exports.ChainId.MAINNET] = '0xd306a548755b9295ee49cc729e13ca4a45e00199bbd890fa146da43a50571776', _INIT_CODE_HASH[exports.ChainId.RINKEBY] = '0xd306a548755b9295ee49cc729e13ca4a45e00199bbd890fa146da43a50571776', _INIT_CODE_HASH[exports.ChainId.ARBITRUM_TESTNET_V3] = '0xd306a548755b9295ee49cc729e13ca4a45e00199bbd890fa146da43a50571776', _INIT_CODE_HASH[exports.ChainId.SOKOL] = '0xd306a548755b9295ee49cc729e13ca4a45e00199bbd890fa146da43a50571776', _INIT_CODE_HASH[exports.ChainId.XDAI] = '0x3f88503e8580ab941773b59034fb4b2a63e86dbc031b3633a925533ad3ed2b93', _INIT_CODE_HASH[exports.ChainId.MATIC] = '0xae81bbc68f315fbbf7617eb881349af83b1e95241f616966e1e0583ecd0793fe', _INIT_CODE_HASH[exports.ChainId.CANDLE] = '0x28c241e10c96199764fdd6fbf9be7c3424e0eae79c17ec3a8ed0adc30b65cf39', _INIT_CODE_HASH);
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 _25 = /*#__PURE__*/JSBI.BigInt(25);
var SECONDS_IN_YEAR = /*#__PURE__*/JSBI.BigInt(31536000);
var _30 = /*#__PURE__*/JSBI.BigInt(30);
var _100 = /*#__PURE__*/JSBI.BigInt(100);
var _1000 = /*#__PURE__*/JSBI.BigInt(1000);
var _10000 = /*#__PURE__*/JSBI.BigInt(10000);
var defaultSwapFee = _25;
var defaultProtocolFeeDenominator = FIVE;
(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 PERMISSIVE_MULTICALL_ADDRESS = (_PERMISSIVE_MULTICALL = {}, _PERMISSIVE_MULTICALL[exports.ChainId.MAINNET] = '0x0946f567d0ed891e6566c1da8e5093517f43571d', _PERMISSIVE_MULTICALL[exports.ChainId.RINKEBY] = '0x798d8ced4dff8f054a5153762187e84751a73344', _PERMISSIVE_MULTICALL[exports.ChainId.ARBITRUM_TESTNET_V3] = '0x73a08DC74eF4ed2c360199244bb69F1464204E7C', _PERMISSIVE_MULTICALL[exports.ChainId.SOKOL] = '0x4D97Bd8eFaCf46b33c4438Ed0B7B6AABfa2359FB', _PERMISSIVE_MULTICALL[exports.ChainId.XDAI] = '0x4E75068ED2338fCa56631E740B0723A6dbc1d5CD', _PERMISSIVE_MULTICALL[exports.ChainId.MATIC] = '0x95028E5B8a734bb7E2071F96De89BABe75be9C8E', _PERMISSIVE_MULTICALL[exports.ChainId.CANDLE] = '0xb5cEE8f223397D01e517070E3CF4DA215baAc673', _PERMISSIVE_MULTICALL);
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); // warning(address === checksummedAddress, `${address} is not checksummed.`)
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, exports.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;
}
}
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);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
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.");
}
// 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 _Currency$NATIVE_CURR;
/**
* A currency is any fungible financial instrument on the target chain.
*
* The only instances of the base class `Currency` are native currencies such as Ether for Ethereum,
* SPOA for the Sokol testnet and xDAI for xDAI.
*/
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), exports.SolidityType.uint8);
this.decimals = decimals;
this.symbol = symbol;
this.name = name;
}
Currency.isNative = function isNative(currency) {
return Object.values(Currency.NATIVE_CURRENCY).indexOf(currency) >= 0;
};
Currency.getNative = function getNative(chainId) {
return Currency.NATIVE_CURRENCY[chainId];
};
return Currency;
}(); // fiat currencies used to represent countervalues
Currency.USD = /*#__PURE__*/new Currency(18, 'USD', 'US dollar'); // Native currencies for deployment chains
Currency.ETHER = /*#__PURE__*/new Currency(18, 'ETH', 'Ether');
Currency.SPOA = /*#__PURE__*/new Currency(18, 'SPOA', 'Sokol POA');
Currency.XDAI = /*#__PURE__*/new Currency(18, 'XDAI', 'xDAI');
Currency.MATIC = /*#__PURE__*/new Currency(18, 'MATIC', 'MATIC');
Currency.CANDLE = /*#__PURE__*/new Currency(18, 'CNDL', 'CANDLE');
Currency.NATIVE_CURRENCY = (_Currency$NATIVE_CURR = {}, _Currency$NATIVE_CURR[exports.ChainId.MAINNET] = Currency.ETHER, _Currency$NATIVE_CURR[exports.ChainId.RINKEBY] = Currency.ETHER, _Currency$NATIVE_CURR[exports.ChainId.ARBITRUM_TESTNET_V3] = Currency.ETHER, _Currency$NATIVE_CURR[exports.ChainId.SOKOL] = Currency.SPOA, _Currency$NATIVE_CURR[exports.ChainId.XDAI] = Currency.XDAI, _Currency$NATIVE_CURR[exports.ChainId.MATIC] = Currency.MATIC, _Currency$NATIVE_CURR[exports.ChainId.CANDLE] = Currency.CANDLE, _Currency$NATIVE_CURR);
var USD = Currency.USD;
var ETHER = Currency.ETHER;
var SPOA = Currency.SPOA;
var XDAI = Currency.XDAI;
var MATIC = Currency.MATIC;
var CANDLE = Currency.CANDLE;
var _Token$WETH, _Token$WSPOA, _Token$WXDAI, _Token$WMATIC, _Token$WCNDL, _Token$DXD, _Token$NATIVE_CURRENC;
/**
* 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();
};
Token.getNativeWrapper = function getNativeWrapper(chainId) {
return Token.NATIVE_CURRENCY_WRAPPER[chainId];
};
Token.isNativeWrapper = function isNativeWrapper(token) {
return Token.NATIVE_CURRENCY_WRAPPER[token.chainId].equals(token);
};
return Token;
}(Currency);
Token.WETH = (_Token$WETH = {}, _Token$WETH[exports.ChainId.MAINNET] = /*#__PURE__*/new Token(exports.ChainId.MAINNET, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _Token$WETH[exports.ChainId.RINKEBY] = /*#__PURE__*/new Token(exports.ChainId.RINKEBY, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _Token$WETH[exports.ChainId.ARBITRUM_TESTNET_V3] = /*#__PURE__*/new Token(exports.ChainId.ARBITRUM_TESTNET_V3, '0xf8456e5e6A225C2C1D74D8C9a4cB2B1d5dc1153b', 18, 'WETH', 'Wrapped Ether'), _Token$WETH[exports.ChainId.SOKOL] = /*#__PURE__*/new Token(exports.ChainId.SOKOL, '0xfDc50eF6b67F65Dddc36e56729a9D07BAe1A1f68', 18, 'WETH', 'Wrapped Ether'), _Token$WETH[exports.ChainId.XDAI] = /*#__PURE__*/new Token(exports.ChainId.XDAI, '0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1', 18, 'WETH', 'Wrapped Ether on xDai'), _Token$WETH[exports.ChainId.MATIC] = /*#__PURE__*/new Token(exports.ChainId.MATIC, '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619', 18, 'WETH', 'Wrapped Ether on Matic'), _Token$WETH);
Token.WSPOA = (_Token$WSPOA = {}, _Token$WSPOA[exports.ChainId.SOKOL] = /*#__PURE__*/new Token(exports.ChainId.SOKOL, '0xc655c6D80ac92d75fBF4F40e95280aEb855B1E87', 18, 'WSPOA', 'Wrapped SPOA'), _Token$WSPOA);
Token.WXDAI = (_Token$WXDAI = {}, _Token$WXDAI[exports.ChainId.XDAI] = /*#__PURE__*/new Token(exports.ChainId.XDAI, '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', 18, 'WXDAI', 'Wrapped xDAI'), _Token$WXDAI);
Token.WMATIC = (_Token$WMATIC = {}, _Token$WMATIC[exports.ChainId.MATIC] = /*#__PURE__*/new Token(exports.ChainId.MATIC, '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 18, 'WMATIC', 'Wrapped Matic'), _Token$WMATIC);
Token.WCNDL = (_Token$WCNDL = {}, _Token$WCNDL[exports.ChainId.CANDLE] = /*#__PURE__*/new Token(exports.ChainId.CANDLE, '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 18, 'WCNDL', 'Wrapped Candle'), _Token$WCNDL);
Token.DXD = (_Token$DXD = {}, _Token$DXD[exports.ChainId.MAINNET] = /*#__PURE__*/new Token(exports.ChainId.MAINNET, '0xa1d65E8fB6e87b60FECCBc582F7f97804B725521', 18, 'DXD', 'DXdao'), _Token$DXD[exports.ChainId.RINKEBY] = /*#__PURE__*/new Token(exports.ChainId.RINKEBY, '0x554898A0BF98aB0C03ff86C7DccBE29269cc4d29', 18, 'DXD', 'DXdao'), _Token$DXD[exports.ChainId.XDAI] = /*#__PURE__*/new Token(exports.ChainId.XDAI, '0xb90d6bec20993be5d72a5ab353343f7a0281f158', 18, 'DXD', 'DXdao from Ethereum'), _Token$DXD);
Token.NATIVE_CURRENCY_WRAPPER = (_Token$NATIVE_CURRENC = {}, _Token$NATIVE_CURRENC[exports.ChainId.MAINNET] = Token.WETH[exports.ChainId.MAINNET], _Token$NATIVE_CURRENC[exports.ChainId.RINKEBY] = Token.WETH[exports.ChainId.RINKEBY], _Token$NATIVE_CURRENC[exports.ChainId.ARBITRUM_TESTNET_V3] = Token.WETH[exports.ChainId.ARBITRUM_TESTNET_V3], _Token$NATIVE_CURRENC[exports.ChainId.SOKOL] = Token.WSPOA[exports.ChainId.SOKOL], _Token$NATIVE_CURRENC[exports.ChainId.XDAI] = Token.WXDAI[exports.ChainId.XDAI], _Token$NATIVE_CURRENC[exports.ChainId.MATIC] = Token.WMATIC[exports.ChainId.MATIC], _Token$NATIVE_CURRENC[exports.ChainId.CANDLE] = Token.WCNDL[exports.ChainId.CANDLE], _Token$NATIVE_CURRENC);
/**
* 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;
}
} // reexport for convenience
var WETH = Token.WETH;
var WSPOA = Token.WSPOA;
var DXD = Token.DXD;
var WXDAI = Token.WXDAI;
var WMATIC = Token.WMATIC;
var WCNDL = Token.WCNDL;
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.toS